Skip to content

state_exec: chroot-scope message channels (§12 core) - #463

Merged
transfix merged 1 commit into
masterfrom
design/ariadne-channel-scoping
Sep 29, 2026
Merged

transfix merged 1 commit into
masterfrom
design/ariadne-channel-scoping

Conversation

@transfix

Copy link
Copy Markdown
Owner

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 the msg-* intrinsic boundary — no async_scheduler change, 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:

  • a #-bearing channel (the runtime's own tick/key/pointer channels) and an empty root_path return verbatim — the backward-compat identity path; every existing 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> (by the existing wire_holes); we read its linkTarget() 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-send scopes only its scheduler deliver key (the state-side sendMessage stays on the raw chroot-relative path — independent bus); msg-recv/msg-pending scope their scheduler calls.

Demo + tests

  • nav_compute: 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).
  • 5 ChannelScopeKey unit tests (the pure rules: identity, private-by-prefix, distinct-prefixes-don't-collide, /-global, #-exempt) + 3 ChannelScopeIntegrationTest scheduler tests (two docs don't cross-talk on the same name; a link-granted channel crosses scope; root scope keeps raw keys).
  • Full state_exec suites green locally (151 + 85 + 71 + 108), the item-2 msg-recv tests 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 declared global: true channels; error if undeclared) + error/opt-out/suppress enforcement (strict by default when a channels: block is present) + mount channels: grant lowering to LinkHole. This PR is the mechanical core it builds on.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant