Skip to content

feat(stream): §4.1 scoping — scope-aware open + canonical-path registry (Phase 2 PR5) - #520

Merged
transfix merged 2 commits into
masterfrom
feat/stream-scoping
Oct 1, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/stream-scoping

Conversation

@transfix

@transfix transfix commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Streams become chroot-scoped (isolated per document by default), and cross-scope sharing rides the existing link:/channels: grant model — resolving the HIGH planning-critique finding that a (scope,token) re-key would make grants unsubscribable.

Core:

  • stream_params.root_path (empty = app root/standalone); open() scopes everything under it.
  • Registry key and descriptor path = the canonical registry_key(root,id) = normalize_path("<root>.streams.<id>"). This single identity is what both a same-scope lookup and a link:-grant-followed resolution produce, so a granted sub-app resolves the identical key (grants not dead-ended); isolation falls out (different roots → different keys). token() returns it.
  • Descriptor at that path via full dotted-path sharedChild(&pins) (H1 ancestor pins cover the whole chain).
  • seq/evt channels via resolve_channel_key(root, "streams.<id>.seq"/".evt") (computed once, owner thread; empty root = identity), replacing the Phase-1 global # keys — the producer posts the same scoped key a same-scope (msg-recv …) resolves.

Callers: StreamTextureBinding resolves by stream.token() (its PR5 TODO resolved); pycvc stream_open gains root_path.

pycvc keepalive fix (latent crash shipped by PR4): stream_open's proxy is def stream_open(*args) (default args), so val._pycvc_app = app pinned the module-global app class, not the instance → ~stream touched a freed app (boost::lock_error abort at teardown). Corrected to if args: val._pycvc_app = args[0] (the documented *args-proxy idiom).

Tests: StreamScoping (canonical key, same-id-different-scope isolation, empty-root back-compat) + lookup assertions updated to stream.token(). stream_test 23/23, cvcgl_stream_texture OK, pycvc stream 5/5, exec 8/8. Full cross-document grant integration is deferred to PR6/demo (the keying supports it). Depends on PR1–PR4 (merged).

…ry (Phase 2 PR5)

Streams become chroot-scoped so a document's streams are isolated by default, and
cross-scope sharing rides the EXISTING link:/channels: grant model (resolving the
HIGH planning-critique finding that a (scope,token) re-key would make grants
unsubscribable).

Core (stream.h/stream.cpp):
- stream_params gains root_path (empty = app root / standalone). open(app, p) now
  scopes everything under it.
- The registry key + descriptor node path is the CANONICAL path
  registry_key(root, id) = normalize_path("<root>.streams.<id>"). This single
  identity is what BOTH a same-scope lookup and a link:-grant-followed resolution
  produce, so a granted sub-app resolves the identical key (grants are not
  dead-ended). Isolation falls out: different roots -> different keys -> no
  collision. token() returns it.
- Descriptor created at that canonical path via a full dotted-path sharedChild(&pins)
  so H1 ancestor pins cover the whole chain (a chroot's ancestors, not just the leaf).
- seq/evt event channels use state_exec::resolve_channel_key(root, "streams.<id>.seq"
  /".evt") (pure-string, computed once on the owner thread; empty root = identity,
  else <root>.channels.<name>), so the producer posts the same scoped key a
  same-scope (msg-recv ...) resolves — replacing the Phase-1 global '#' keys.

Callers:
- StreamTextureBinding resolves by the canonical key (caller passes stream.token());
  its PR5 TODO is resolved.
- pycvc stream_open gains root_path (default "" = standalone).
- pycvc KEEPALIVE FIX: stream_open's proxy is `def stream_open(*args)` (default args),
  so `val._pycvc_app = app` pinned the module-global app CLASS, not the instance — a
  latent teardown crash (boost::lock_error in ~stream touching a freed app) that
  PR4 shipped. Corrected to `if args: val._pycvc_app = args[0]`.

Tests: StreamScoping (canonical key, same-id-different-scope isolation, empty-root
back-compat) + updated the registry-lookup assertions to stream.token(). stream_test
23/23, cvcgl_stream_texture OK, pycvc stream 5/5 + exec 8/8.
…unambiguous

PR5 review (SHIP): close the one recommended hardening. The canonical key
<root_path>.streams.<id> made the root/id boundary ambiguous for a dotted id —
registry_key("a.streams","b") == registry_key("a","streams.b") — which could
collide two logically-distinct streams and defeat the cross-scope collision-free
guarantee. open() now rejects an id containing '.' (it must be a single path
segment, the leaf of the canonical key), alongside the empty-id check. Test added.
@transfix
transfix merged commit 616ceba into master Oct 1, 2026
13 checks passed
@transfix
transfix deleted the feat/stream-scoping branch October 29, 2026 20:53
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