Own actor loopbacks at the runtime boundary - #27
Merged
Conversation
Hosts cannot distinguish an exact self-call from a cross-actor continuation by reading hasCurrent(): it describes a held lock, not caller identity. Put the three-way decision in ActorContainer.resolveLoopback() so raw invocation is limited to the exact current actor, while every other hop enters the callee and resumes through the caller's awaitIo. Make the surrounding handoffs explicit: name IoContext.run() inputs, thread AbortSignal to queued admission, reject broken critical sections with one typed error, verify await coverage against Rollup's final graph, align package declarations with their runtime entrypoint, and drop the inert SAH WAL pragma.
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.
Why
The pre-production review found that Rook's loopback shortcut treated
hasCurrent()as caller identity. It is only lock state: during a facet → parent call, both actors can report a current lock, so the parent can run ungated inside the wrong transaction.The runtime already knew the required three-way distinction—exact self-call, lock-holding continuation, or external entry—but only documented it. That left each host to reproduce gate policy using internals it could not fully access.
What changed
ActorContainer.resolveLoopback()as the single owner of in-realm routing. Exact self-calls use the raw instance; cross-actor calls enter the target and resume through the exact current, transformed, or structurally supplied caller.{ input, signal }options insideIoContext.run(); expose cancellation onentry()andrun(), and remove abort listeners when waits settle.blockConcurrencyWhile()calls with the sameBrokenActorErrorthat breaks and aborts the placement; export it andCanceledErrorfrom the package root.cloudflare-workersdeclaration path with its JavaScript entrypoint, verify the packed surface, and remove the ineffective WAL pragma from the single-connection SAH scheduler database.The public
entry(target)andrun(event)calls remain source-compatible; their signals are optional. The intentional behavior change is that a failedblockConcurrencyWhile()now rejects a reachable same-realm caller instead of leaving it pending forever.Validation
Sources and follow-up
IoContextandio-context.hblockConcurrencyWhile()documentationbuildEndRook can replace its private loopback predicate once this patch is released.