feat(context-api): supply a per-call final continuation - #241
Closed
taras wants to merge 1 commit into
Closed
Conversation
createApi() composes stable-name middleware around the handler it was built with, and that handler is the only base a call can end in. A caller that owns the authority for one invocation has nowhere to put it: the base is shared, so anything reaching it is reachable by every other call. `Api.terminating` collects the same middleware, in the same max/min order, and composes it around a continuation supplied for that one call. The continuation stays in the caller's lexical state — it is not stored, not placed in a context, not part of the operation's public arguments, and not reachable by the middleware composed around it. A handler that returns without delegating never reaches it, and nested or concurrent calls each reach their own. `operations` and the module-level default are unchanged.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
createApi()composes stable-name middleware around the handler it was built with, and that handler is the only base a call can end in.Apiexposesoperationsandaroundand nothing else, so a caller that owns the authority for one invocation has nowhere to put it — the base is shared, and anything that reaches it is reachable by every other call through the same name.This is a prerequisite for taras/executable.md#432, where the public
Executionname has to keep composing replaceable policy while the final continuation carries authority for exactly one invocation. Without this the only routes are installing the terminal asat:"min"middleware — which is still replaceable — or reproducingcollectMiddleware,$api:$name,contextWindow()andreducePrototypeChain()in the consumer, which couples it to internals of this package and of Effection.What
terminatingmirrorsoperationsfor function members. It collects the same middleware, preservesmax/minordering exactly, and composes it around the continuation supplied for that call instead of thecreateApi()handler.The continuation stays in the caller's lexical state: it is not stored, not placed in a context, not part of the operation's public arguments, not behind a stable name, and not reachable by the middleware composed around it. Middleware cannot tell which base is underneath it.
Value members have no arguments to intercept and no continuation to supply, so they are typed
never.Compatibility
operationsand the module-level default are untouched — additive only. Loaded-copy composition is unchanged, because collection still goes through the same stable-name middleware context.Tests
context-api/terminating.test.ts, 10 cases:createApidefaultmax/minorder with either terminalat:"min"andat:"max"registrations remain public layers outside the supplied continuationcd context-api && npx vitest run→ 49 passed (3 files), which includes the package's existing suites unchanged.