Repository navigation
Add service isolation (ctx.isolate) and intercept (ctx.intercept) - #3
Merged
Merged
Conversation
Aligns with upstream packages/core isolate/intercept semantics:
- ctx.isolate(name, label = nil) returns a ctx view whose service name
lives in its own realm; the service store is now keyed by isolate key
(the name itself in the default realm, a unique token or user label in
isolated ones). Two isolates sharing a label share a realm.
- notify takes { name => key } pairs and only touches fibers whose ctx
resolves the name to the same key, so provider swaps and boundary
crossings stay realm-local.
- ctx.intercept(name, config) carries per-caller config on the ctx view
(copy-on-write, chain pre-merged instead of upstream's prototype-chain
walk); Hash inject configs become intercepts on the plugin ctx
(upstream fiber.ts:139). Read via ctx.resolve_config(name, base).
- Stricter than upstream in one spot: the service access walk checks the
realm key of provided services at the terminal fiber, so an isolated
plugin cannot leak the default-realm service through root's store.
Specs mirror upstream tests/isolate.spec.ts (isolated context, shared
label) plus intercept resolution and inject-config conversion.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Two tenants isolate :db, run the same database/web plugin code in separate realms, answer the same event with their own db, and tear down independently. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
ryudoawaru
force-pushed
the
feat/isolate-intercept
branch
from
August 16, 2026 09:05
2b18633 to
d776edf
Compare
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.
Summary
Round 3 of aligning with upstream
packages/core(4.0.0-rc.8): service isolation and per-caller config interception.ctx.isolate(name, label = nil)— returns a ctx view whose servicenamelives in its own realm. The service store is now keyed by isolate key: the name itself in the default realm, a unique token (or a user-supplied label) in isolated ones. Passing the same label to twoisolatecalls shares one realm between them.Context#notifytakes{ name => key }pairs and only touches fibers whose ctx resolves the name to the same key, so provides, provider swaps, and teardowns stay realm-local.Fiber#providedtracks{ name => key }for ACTIVE-boundary notifications.ctx.intercept(name, config)— carries per-caller config on the ctx view. Implemented as copy-on-write with the chain pre-merged at intercept time (upstream walks the prototype chain inService[resolveConfig]instead). Hash-form inject configs (inject: { foo: {...} }) become intercepts on the plugin ctx, mirroring upstreamfiber.ts:139. Consumers read the effective config withctx.resolve_config(name, base).Test plan
bundle exec rspec— 53 examples, 0 failures (newspec/cordis/isolate_spec.rbmirrors upstreamtests/isolate.spec.ts: isolated context, shared label; plus duplicate-per-realm, boundary walk, intercept resolution, and inject-config conversion)bundle exec ruby examples/demo.rbstill runs clean🤖 Generated with Claude Code