Repository navigation
feat(stream): §4.1 scoping — scope-aware open + canonical-path registry (Phase 2 PR5) - #520
Merged
Merged
Conversation
…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.
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.
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(root,id) = normalize_path("<root>.streams.<id>"). This single identity is what both a same-scope lookup and alink:-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.sharedChild(&pins)(H1 ancestor pins cover the whole chain).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:
StreamTextureBindingresolves bystream.token()(its PR5 TODO resolved); pycvcstream_opengainsroot_path.pycvc keepalive fix (latent crash shipped by PR4):
stream_open's proxy isdef stream_open(*args)(default args), soval._pycvc_app = apppinned the module-global app class, not the instance →~streamtouched a freed app (boost::lock_errorabort at teardown). Corrected toif 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 tostream.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).