Skip to content

fix(runtime): make proxy routing cross-copy safe - #9

Merged
Upd4ting merged 4 commits into
mainfrom
fix/proxy-runtime-correctness
Aug 19, 2026
Merged

fix(runtime): make proxy routing cross-copy safe#9
Upd4ting merged 4 commits into
mainfrom
fix/proxy-runtime-correctness

Conversation

@Upd4ting

@Upd4ting Upd4ting commented Aug 18, 2026

Copy link
Copy Markdown
Member

Summary

  • converge compatible physical copies on a protocol-versioned globalThis runtime and fail clearly on incompatible runtime protocols
  • replace internal cross-copy instanceof dispatch with a stable proxy brand and explicit proxy identities
  • route async and registering proxies by provider using AsyncLocalStorage module contexts, per-proxy route bindings, and owner+generation leases
  • validate ImplementInterface inputs strictly and atomically, including missing/malformed handlers, cycles, thenables, and cross-realm promises
  • bound permanent missing-provider queues while preserving bootstrap/reload replay
  • make registration replay, event delivery, and module cleanup resilient and observable through runtime error reporting
  • harden shared registries with maps, sets, and a null-prototype compatibility object

Compatibility and migration

Existing single-provider direct calls, InterfaceFunction(), proxy constructors, onCall, onRegister, onUnregister, and parameterless detach() remain supported. instanceof still works within one package copy, while IsInterfaceProxy is the cross-copy check.

Interfaces that can be loaded from duplicate package copies should pass a stable identity to InterfaceFunction(identity) or proxy constructors. Provider/core integrations can use RunWithModuleContext from @antelopejs/interface-core/modules; set provider for one route or providerRoutes keyed by GetInterfaceProxyIdentity(proxy) when one module context uses multiple providers.

ImplementInterface now rejects missing or malformed proxy handlers before attaching anything. Implementors that previously supplied partial implementation objects must provide every declared async/registering handler. Event proxies and non-proxy constants do not require handlers.

Calls without an explicit route continue to use the sole provider. With multiple providers they now reject with AmbiguousProviderError; an explicit unavailable route rejects with MissingProviderError rather than selecting by attachment timing. Unattached queues are capped at 1,000 operations and reject overflow with ProviderQueueFullError.

Event handler exceptions no longer abort later handlers. They are reported through internal.runtimeErrorReporter, as are replay and cleanup failures.

Verification

  • corepack pnpm run build
  • corepack pnpm run lint
  • corepack pnpm dlx @antelopejs/core --version1.4.7
  • corepack pnpm dlx @antelopejs/core module test .45 passing

Greptile Summary

The PR introduces a protocol-versioned global runtime and cross-copy-safe proxy identities while adding provider-aware routing, bounded queues, stricter interface validation, and resilient cleanup.

  • Shares proxy state across compatible package copies.
  • Routes async and registering proxies through module execution contexts and provider leases.
  • Validates implementations atomically before attaching handlers.
  • Adds bounded pending-operation queues and structured runtime error reporting.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/proxies.ts Implements branded cross-copy proxies, provider routing, attachment leases, replay, and module-aware cleanup; the previously reported legacy split-handler sequence now remains on one route.
src/internal.ts Introduces the shared protocol-versioned runtime and AsyncLocalStorage-backed module execution contexts.
src/index.ts Replaces copy-local proxy dispatch with branded protocol checks and adds strict atomic implementation validation.
src/modules.ts Exposes module-context APIs and makes module destruction cleanup resilient and observable.
src/tests/registering-proxy-replay.test.ts Adds regression coverage confirming legacy split registration handlers share the same manual route.

Reviews (4): Last reviewed commit: "fix(runtime): preserve module generation..." | Re-trigger Greptile

Share a protocol-versioned runtime across compatible package copies, brand
proxies with stable identities, and route provider attachments through module
execution context.

Validate interface implementations atomically, bound missing-provider queues,
and make replay and module cleanup failures observable without aborting
remaining work.

Copy link
Copy Markdown
Member Author

@greptile review

Comment thread src/proxies.ts Outdated

Copy link
Copy Markdown
Member Author

@greptile review

Copy link
Copy Markdown
Member Author

@greptile review

Integrate explicit ownership invalidation from main with the shared provider-aware execution context. This keeps cross-copy contexts coherent and prevents stale asynchronous work from registering after module destruction.

Co-authored-by: Upd4ting <upd4ting@gmail.com>

Copy link
Copy Markdown
Member Author

@greptile review

@Upd4ting
Upd4ting merged commit a4c38d4 into main Aug 19, 2026
3 checks passed
@Upd4ting
Upd4ting deleted the fix/proxy-runtime-correctness branch August 19, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants