fix(runtime): preserve provider generation context - #10
Merged
Conversation
Capture provider execution contexts on proxy attachment and key automatic cleanup by explicit owner generations. Expose provider selection metadata and reject incompatible shared runtimes. Amp-Thread-ID: https://ampcode.com/threads/T-01a01742-a6f0-7092-a10b-01e8e6633a0d Co-authored-by: Upd4ting <upd4ting@gmail.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a01742-a6f0-7092-a10b-01e8e6633a0d Co-authored-by: Upd4ting <upd4ting@gmail.com>
Member
Author
|
@greptile review |
Co-authored-by: Upd4ting <upd4ting@gmail.com>
Member
Author
|
@greptile review |
Co-authored-by: Upd4ting <upd4ting@gmail.com>
Member
Author
|
@greptile review |
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
ModuleExecutionContextfor async and registering callbacks, including replay and unregister pathsInterfaceConnectionand enforce runtime protocol v3 across physical package copiesThis supplies the minimal public interface-core contract needed by AntelopeJS/antelopejs#101 without including any core changes.
Public contract
ModuleExecutionContextadds optionalowner, a unique lifecycle generation ID:A loader that can overlap an old module instance with its replacement should assign a distinct
ownerto each generation and emit the existingEvents.ModuleDestroyed(moduleId)event inside that generation'sRunWithModuleContext. Withoutowner, behavior remains module-scoped for compatibility.InterfaceConnectionis now exported from the package root and includes:Proxy attachments continue to return generation-guarded leases. Provider callbacks now execute under the context captured at attachment, across nested calls and awaits. Invocation after owner invalidation fails with
ModuleContextInvalidatedErrorrather than running stale code.Compatibility and migration
owneris optional and defaults tomodule.ModuleDestroyedevent payload remains the module ID.onRegister/onUnregisterattachment remains supported, including manual routes.Recommended release: 0.0.11, subject to maintainers confirming the current release sequence.
Verification
corepack pnpm install --frozen-lockfilecorepack pnpm run lintcorepack pnpm run buildcorepack pnpm dlx @antelopejs/core module test .— 71 passingcorepack pnpm run test:packagegit diff --checkThe package-consumer test builds and packs the real tarball, installs it in an isolated project, executes the provider-context/generation/metadata contract, and compiles the public types. The standalone explanatory HTML is a review artifact and is not included in the package: https://t-03gpgyh60w6e7a0062f1i9lal-p28351.onamp.dev/interface-core-provider-context.html
Greptile Summary
The PR preserves complete provider execution context across asynchronous and registering callbacks while introducing generation-specific ownership and cleanup.
InterfaceConnectionand advances the shared runtime protocol to version 3.Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Provider attaches callback] --> B[Capture module context and owner] B --> C[Create generation-guarded attachment lease] C --> D[Consumer invokes proxy] D --> E[Restore captured provider context] E --> F[Execute callback across nested calls and awaits] G[ModuleDestroyed within owner context] --> H[Invalidate owner token] H --> I[Detach only matching owner-generation leases]Reviews (3): Last reviewed commit: "address greptile review feedback (greplo..." | Re-trigger Greptile