Repository navigation
state_exec: chroot-scope message channels (§12 core) - #463
Merged
Merged
Conversation
Message channels were GLOBAL (raw string keys) while state is chrooted per document — an isolation gap vs. §4.7/§11.4's per-document model (two docs on one app collided on a channel name). This scopes channels to mirror state, entirely at the msg-* intrinsic boundary (no async_scheduler change, no parallel registry). - resolve_channel_key(root_path, channel) [public, pure-string, thread-safe for host posters] + resolve_channel(ctx, channel) [file-local, adds grant following]. Rules: a '#'-bearing channel (the runtime's own tick/key/ pointer channels) and an empty root_path return verbatim (backward-compat identity — every existing raw-key msg-* caller uses prefix "" and stays green); a leading '/' is the app-root-global escape (stripped); otherwise the channel is private at "<root_path>.channels.<name>". A §12 mount grant is a transparent-link node planted at channels.<name> (wire_holes); we read its linkTarget() string directly (a channel key is a redirect, not a state value — the target node need not exist), so a sender and a granted receiver agree on one key via the SAME link mechanism state uses. - msg-send scopes only its scheduler deliver key; the state-side sendMessage stays on the raw chroot-relative path (already scoped, independent bus). msg-recv/msg-pending scope their scheduler calls. - nav_compute demo: the intrinsic captures ictx.root_path and posts via resolve_channel_key (resolved on the scheduler thread, string captured — the worker never walks the tree). - Tests: 5 ChannelScopeKey unit tests (the pure rules) + 3 ChannelScopeIntegrationTest scheduler tests (two docs don't cross-talk; a link-granted channel crosses; root scope keeps raw keys). Full state_exec suites green (151+85+71+108), no regressions. Follow-up (PR-B): the .ari `channels:` declaration + globals allowlist + error/opt-out/suppress enforcement on top of this mechanical core.
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR-A of the channel-scoping work (core resolution). Message channels were global (raw string keys) while state is chrooted per document — an isolation gap vs. §4.7/§11.4's per-document model (two docs on one app collide on a channel name, e.g.
"nav.done"). This makes channels mirror state, entirely at themsg-*intrinsic boundary — noasync_schedulerchange, no parallel registry.Resolution (reuses the §12 transparent-link mechanism)
resolve_channel_key(root_path, channel)(public, pure-string, thread-safe — for host posters) +resolve_channel(ctx, channel)(file-local, adds grant following). Rules:#-bearing channel (the runtime's own tick/key/pointer channels) and an emptyroot_pathreturn verbatim — the backward-compat identity path; every existingmsg-*caller uses prefix""and stays green/is the app-root-global escape (stripped)<root_path>.channels.<name>channels.<name>(by the existingwire_holes); we read itslinkTarget()string directly — a channel key is a redirect, not a state value, so the target node need not exist — so a sender and a granted receiver resolve to one key via the same link mechanism state uses.msg-sendscopes only its scheduler deliver key (the state-sidesendMessagestays on the raw chroot-relative path — independent bus);msg-recv/msg-pendingscope their scheduler calls.Demo + tests
nav_compute: the intrinsic capturesictx.root_pathand posts viaresolve_channel_key(resolved on the scheduler thread, string captured — the worker never walks the tree).ChannelScopeKeyunit tests (the pure rules: identity, private-by-prefix, distinct-prefixes-don't-collide,/-global,#-exempt) + 3ChannelScopeIntegrationTestscheduler tests (two docs don't cross-talk on the same name; a link-granted channel crosses scope; root scope keeps raw keys).state_execsuites green locally (151 + 85 + 71 + 108), the item-2msg-recvtests still pass — no regressions (the empty-prefix identity rule guarantees it).Follow-up (PR-B, already scoped + agreed)
The
.ari channels:declaration (list/map form) + the globals allowlist (default-deny;/-refs checked against declaredglobal: truechannels; error if undeclared) + error/opt-out/suppress enforcement (strict by default when achannels:block is present) + mountchannels:grant lowering toLinkHole. This PR is the mechanical core it builds on.