Skip to content

feat(inference): wire InferenceHandleModule through the broker-managed coordinator (slice 5) - #1620

Merged
joelteply merged 1 commit into
canaryfrom
feat/wire-handle-module-coordinator
Jun 14, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/wire-handle-module-coordinator

Conversation

@joelteply

@joelteply joelteply commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Slice 5 — wires the ai/inference/{open,generate,close,inspect} command surface (InferenceHandleModule) through the same InferenceCoordinator Arc that InferenceCoordinatorModule owns and registered with the PressureBroker (slice 4).

Proven single-instance (the load-bearing invariant)

Both register_with_broker (the pool the broker evicts) and the handle module's with_coordinator receive self.coordinator.clone() — one allocation. So a lane opened via the handle surface is the same lane the broker's pool accounts and evicts. No two-instance split. (Adversarial review verified the Arc identity, registration order, and manifest match.)

Purely additive

InferenceModule ("inference", inference/capacity) and InferenceHandleModule ("ai-inference-handle", ai/inference/) are disjoint surfaces. Manifest gains ("ai-inference-handle", Core) so the A.2.2 boot cross-check stays honest.

⚠️ NOT yet end-to-end live (honest scope)

open() resolves its adapter from the handle module's local providers map, which is empty under with_coordinator — so ai/inference/open currently returns "provider not registered" before reaching coordinator.open_lane. Making opens actually create lanes needs a production adapter wired in (registered on the module at boot, or resolved from the shared AdapterRegistry — the get_arc migration the module's own doc flags), which is gated on the LlamaCppAdapter init lifecycle integrating with runtime startup (a known TODO in ipc/mod.rs). This slice lands the correct, identity-proven plumbing that the adapter slice builds on.

Validation (rust:1.95, continuum-core --lib)

25 passed; 0 failed (handle_module + inference_coordinator_module) · whole lib compiles · CARGO_EXIT=0.

🤖 Generated with Claude Code

…d coordinator (slice 5)

Registers the `ai/inference/{open,generate,close,inspect}` command surface
(`InferenceHandleModule`) through the SAME `InferenceCoordinator` Arc that
`InferenceCoordinatorModule` owns and registered with the PressureBroker
(slice 4). Proven single-instance: both `register_with_broker` (the pool the
broker evicts) and the handle module's `with_coordinator` receive
`self.coordinator.clone()` — one allocation, so a lane opened via the handle
surface is the same lane the broker's pool accounts + evicts.

Purely additive, NOT a replacement: `InferenceModule` ("inference",
`inference/capacity`) and `InferenceHandleModule` ("ai-inference-handle",
`ai/inference/`) are disjoint command surfaces. Coordinator Arc fetched from
the already-registered InferenceCoordinatorModule (module_of_type → downcast
→ coordinator()); defensive else-log for the unreachable missing-module
case. Manifest gains ("ai-inference-handle", Core) so the A.2.2 boot
cross-check stays honest.

NOT yet end-to-end live (honest scope): `open()` resolves its adapter from
the handle module's local `providers` map, which is empty under
`with_coordinator`, so `ai/inference/open` currently returns "provider not
registered" before reaching `coordinator.open_lane`. Making opens actually
create lanes needs a production adapter wired in — either registered on the
module at boot or resolved from the shared AdapterRegistry (the `get_arc`
migration the module's own doc flags). That's a follow-up slice, gated on the
LlamaCppAdapter init lifecycle integrating with runtime startup (already a
known TODO in this file). This slice lands the correct, identity-proven
plumbing that adapter slice builds on.

Validated rust:1.95 (continuum-core --lib): 25 tests pass (handle_module +
inference_coordinator_module), whole lib compiles, CARGO_EXIT=0.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply
joelteply force-pushed the feat/wire-handle-module-coordinator branch from 5d6fd14 to c4c1ca5 Compare June 14, 2026 23:00
@joelteply joelteply changed the title feat(inference): wire InferenceHandleModule through the broker-managed coordinator — lane path goes live (slice 5) feat(inference): wire InferenceHandleModule through the broker-managed coordinator (slice 5) Jun 14, 2026
@joelteply
joelteply merged commit 8862f65 into canary Jun 14, 2026
2 checks passed
@joelteply
joelteply deleted the feat/wire-handle-module-coordinator branch June 14, 2026 23:01
joelteply added a commit that referenced this pull request Jun 14, 2026
…ce 6) (#1622)

* feat(inference): open() falls back to the shared AdapterRegistry (slice 6)

InferenceHandleModule::open() resolved the requested adapter ONLY from the
module's local `providers` map, which is empty under `with_coordinator` —
so ai/inference/open 404'd in production even when the adapter was
registered elsewhere in the system. (Reviewer MAJOR on #1620.)

Resolution is now local-map-first, then a fallback to the shared
`ai_provider::global_registry()` via `get_arc` — the #162-era source of
truth the module's own header doc already CLAIMED it used. The local map
stays for adapters explicitly registered on this instance (tests +
pre-#162 wiring sites).

Two substrate subtleties handled:
- `global_registry()` is an `Arc<tokio::sync::RwLock<AdapterRegistry>>`, so
  the read is async (`.read().await`). The registry guard is scoped to a
  single statement (get_arc returns an owned Arc), dropped well before the
  downstream `coordinator.open_lane` await.
- The local DashMap lookup is resolved into an owned `Option` in its OWN
  statement BEFORE the match, so the DashMap `Ref` is never held across the
  registry await — no lock-across-await / shard deadlock
  (CONCURRENCY-STYLE-GUIDE forbidden move #7).

Error message keeps "not registered" (existing typed-error test stays
green) and now reports both the local set and that the registry was
consulted. Fixed two stale doc comments that described registry resolution
the code didn't yet do. Extracted `bare_coordinator_module()` test fixture
(empty local map) so `module_with_coordinator` layers the local heuristic
on top; added a fallback test proving open resolves a registry-only adapter.

Honest scope: this fixes adapter RESOLUTION (single source of truth). Opens
succeeding end-to-end still need an adapter registered into global_registry
at boot — separate from this resolution fix.

Validated rust:1.95 (continuum-core --lib): 24 tests pass (handle_module +
ai_provider, incl. the new fallback test + the unchanged unregistered-error
test), CARGO_EXIT=0.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(inference): correct open() guard comment — open_lane is synchronous (reviewer nit, #1622)

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant