Skip to content

fix(runtime): route interface calls to selected providers - #101

Merged
Upd4ting merged 4 commits into
mainfrom
fix/provider-aware-runtime
Aug 20, 2026
Merged

fix(runtime): route interface calls to selected providers#101
Upd4ting merged 4 commits into
mainfrom
fix/provider-aware-runtime

Conversation

@Upd4ting

@Upd4ting Upd4ting commented Aug 19, 2026

Copy link
Copy Markdown
Member

Summary

  • retain every provider association and route calls per consumer instead of treating importOverrides as metadata only
  • select explicit overrides in configured order and defaults by lexicographically sorted provider module ID
  • build providerRoutes from fix(core): make interface package resolution deterministic #97's canonical interface package entries and stable proxy identities
  • run module evaluation, lifecycle hooks, and provider callbacks in generation-owned module contexts
  • publish provider / selected connection metadata that matches actual dispatch
  • protect replacement providers with owner- and lease-generation-aware cleanup across destroy retry and HMR

Published dependency contract

This branch now uses the released npm package @antelopejs/interface-core@^0.0.11 (runtime protocol 3), backed by interface-core #10 / commit 12cc970170e6188d70158b7e53de9815f15679e9.

The temporary Git SHA, pnpm patchedDependencies, workspace patch configuration, and patch file have been removed. The implementation uses only the public 0.0.11 contract: ModuleExecutionContext.owner, provider route context, provider callback context restoration, attachment leases, generation cleanup, and provider selection metadata.

Integration with current main

The branch includes origin/main through #100 (c5675ea8998ec71a8a60b8ec2b00d2efaa57a45f) without rewritten history:

Routing invariants

  • all compatible providers remain represented in registry connections
  • each consumer gets its own proxy-identity-to-provider route
  • explicit override order wins; the no-override default is deterministic
  • selected provider metadata and connection IDs describe the same provider used for dispatch
  • provider callbacks restore their provider module, owner, and provider context across async boundaries
  • one owner is stable for a module generation and distinct from its replacement
  • ModuleDestroyed runs in the destroyed generation's context; stale cleanup cannot detach a replacement with the same module/provider ID
  • unresolved packages, invalid provider overrides, duplicate IDs, and conflicting proxy routes fail with actionable diagnostics

Package-consumer proof

pnpm test:package-consumer builds and packs @antelopejs/core, installs that tarball into a fresh project, and verifies:

  • the packed manifest depends on npm @antelopejs/interface-core@^0.0.11
  • no Git dependency or workspace patch leaks into the package contract
  • anonymous interface proxies converge through fix(core): make interface package resolution deterministic #97 canonicalisation without an identity-binding API
  • physically distinct compatible interface packages and interface-core copies share the protocol-3 runtime and route to the selected provider
  • a preloaded incompatible interface copy is rejected with the canonicalisation diagnostic

This test is part of pnpm test, so CI exercises the packed-consumer contract.

Fresh verification

Node 22.19.0, pnpm 10.6.5:

  • pnpm install --frozen-lockfile — pass
  • pnpm lint — pass (three pre-existing warnings/info only)
  • pnpm build — pass
  • pnpm test:unit — pass, including full integration and HMR suites
  • pnpm test:coverage — pass; 94.52% lines/statements, 92.03% branches, 91.93% functions
  • pnpm test:playground — all three phases pass
  • pnpm test:package-consumer — pass from a fresh tarball install
  • focused provider-routing suite — 7 passing, including 40 randomized attachment-delay iterations
  • focused lifecycle/HMR suite — pass, including destroy failure/retry and old/replacement generation ownership
  • git diff --check — pass

No merge or package publication is performed by this PR.

Greptile Summary

The PR adds deterministic, consumer-specific provider routing and generation-owned module execution contexts.

  • Retains all compatible provider connections while recording the selected provider.
  • Builds proxy-identity routes from canonical interface package entries.
  • Runs module lifecycle and core provider callbacks within module contexts.
  • Adds routing, replacement-generation, and packed-package consumer coverage.
  • Updates @antelopejs/interface-core to the released protocol-3 implementation.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains.

No blocking failure remains.

Important Files Changed

Filename Overview
src/core/module-manager.ts Retains provider associations, validates ordered overrides, selects deterministic providers, and configures per-module routing contexts.
src/core/module-context.ts Resolves interface declarations and maps discovered proxy identities to selected providers with conflict diagnostics.
src/core/module.ts Gives each module generation a stable owner and runs loading and lifecycle callbacks in its execution context.
src/core/interface-registry.ts Extends connection metadata with provider identity and selected-provider state.
src/core/runtime/module-loading.ts Registers the core module interface from an explicit provider context.
src/core/runtime/dev-server-registry.ts Registers the runtime interface from an explicit core provider context.
test/integration/provider-routing.test.ts Covers explicit and default routing, HMR replacement, compatible runtime copies, generation cleanup, concurrency, and invalid overrides.
test/package-consumer/run.ts Packs and installs the library in an isolated consumer to verify its published dependency contract.
test/package-consumer/verify.cjs Exercises provider routing and runtime compatibility through the packed package.

Sequence Diagram

sequenceDiagram
    participant MM as ModuleManager
    participant IR as InterfaceRegistry
    participant M as Consumer Module
    participant P as Interface Proxy
    participant Provider as Selected Provider
    MM->>MM: Collect all compatible providers
    MM->>MM: Select override or sorted default
    MM->>IR: Publish connections and selected metadata
    MM->>M: Set proxy identity to provider routes
    M->>M: Enter generation-owned context
    M->>P: Invoke interface function
    P->>Provider: Dispatch using consumer route
    Provider-->>M: Return result in provider context
Loading

Reviews (2): Last reviewed commit: "fix(runtime): adopt published provider c..." | Re-trigger Greptile

Copy link
Copy Markdown
Member Author

@greptile review

ampagent and others added 2 commits August 19, 2026 20:42
…ntime

# Conflicts:
#	src/core/module-manager.ts
#	src/core/module.ts
Co-authored-by: Upd4ting <upd4ting@gmail.com>
Co-authored-by: Upd4ting <upd4ting@gmail.com>

Copy link
Copy Markdown
Member Author

@greptile review

@Upd4ting
Upd4ting merged commit b507915 into main Aug 20, 2026
3 checks passed
@Upd4ting
Upd4ting deleted the fix/provider-aware-runtime branch August 20, 2026 08:53
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