Skip to content

feat(sdk-codegen): Rust-rooted command-surface generator (foundation + 1 real command) - #1674

Merged
joelteply merged 13 commits into
canaryfrom
feat/sdk-codegen-rust-source
Jun 18, 2026
Merged

joelteply merged 13 commits into
canaryfrom
feat/sdk-codegen-rust-source

Conversation

@joelteply

@joelteply joelteply commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

What

The command surface is now single-sourced from Rust. One CommandSpec per command (name + WireShape + ts-rs Params/Result) drives BOTH sides — so a command is easy to write and easy to call, and a type change propagates everywhere automatically instead of becoming tech debt.

Easy to call — typed, string-free accessors:

api.chatSend(params)            // typed in, typed out — not execute('chat/send', {...})
api.aiInferenceOpen(params)     // the command string lives once, inside the generated body

Change a Params type in Rust → regenerate → every now-wrong call site fails to compile.

Easy to write — one typed execute, no boilerplate:

async fn execute(&self, ctx: &Ctx, p: GenerateParams) -> Result<Outcome<GenerateResult>, CommandError> {
    let handle = ctx.handle()?;                             // typed envelope accessor
    Ok(self.0.generate(handle, p.request).await?.into())   // `?`, no from_value/match/envelope/try-catch
}

The framework dispatch owns parse → envelope → error→reject. Proven by porting the real ai/inference/* family from ~40 lines of hand dispatch to 4 one-liners (23 e2e tests unchanged-green).

How

  • Envelope single-sourced from Rust: CommandRequest<P>/CommandResponse<T> get #[derive(TS)] + #[ts(flatten)] → ts-rs emits the exact generic wrapper.
  • Faithful WireShape { Bare | Enveloped | Provided } — each command models the REAL wire its handler exchanges. (An earlier pass modeled a bare handler as enveloped; adversarial review caught it; a test now pins "bare != wrapped".) Command failure is a rejected promise, never success:false.
  • Self-assembling registry via inventory (no central list).
  • Vendoring emitter — copies the transitive closure of ts-rs types into sdk/typescript/generated/wire/** (closed tree, mechanical copy from the canonical protocol/typescript output) so the SDK is standalone yet single-sourced.
  • Live: sdk/typescript/generated/{CommandMap,CommandApi}.ts + wire/** now generated (a cargo test regenerates, like ts-rs export_bindings).

Sampling (outlier validation across every shape)

ping (Bare) · interface/screenshot (Provided adapter) · chat/send chat/poll (Enveloped) · ai/inference/open|generate|close|inspect (Enveloped, handle mint/consume) · inference/llm/request (Bare) · data/list (Bare, Rust-rooted contract types).

Validation

  • Rust: green — 14 sdk_codegen + 670 export_bindings + inference/health/envelope.
  • TypeScript: NOT yet typechecked in-env (no node where authored). Consumers reconciled by static analysis. Gate before merge: cd sdk/typescript && npm install && npm run typecheck && npm test.
  • apps/web / apps/desktop may need a pass if they referenced commands outside the sampling.

Follow-ups (not in this PR)

Event registry (Rust-sourced events) · Swift/Kotlin emitters atop uniffi (descriptor API stable; separate files) · reconcile AccessLevel with runtime ACL · align data/list handler to its contract type · the remaining ~250 commands.

🤖 Generated with Claude Code

joelteply and others added 2 commits June 17, 2026 18:21
…port layer

Coherence tighten. The CALL verb was named inconsistently: the Rust
continuum-client `Transport` seam called it `request`, while the FFI facade, the
TS transport, AND the canonical primitive (`Commands.execute()`) all use
`execute`. So the same architectural layer (the transport seam) had different
verb names in Rust vs TS — exactly the subtle drift that makes an SDK feel
incoherent.

Renamed `Transport::request` → `Transport::execute` and all three impls
(AircIpcTransport, MockTransport, InProcessTransport) + the CommandClient caller
+ the mock/in-process test names. The CALL verb is now `execute` everywhere:
Rust transport, TS transport, FFI, and the conformance contract. Mirrors the TS
shape exactly (Transport.execute raw + CommandClient/Commands.execute typed).

NOT touched: airc_lib's own `Airc::request(target, headers, body, deadline)`
calls inside AircIpcTransport — that's a different method on the airc handle, and
unrelated `fn request(prompt)` test helpers in core/tests.

Tests: continuum-client 23, continuum-client-ffi 8, continuum-core
in_process_transport 3 — all green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The command surface's single source of truth becomes RUST, the deepest layer —
not the 98 hand-authored TS spec JSONs + the old tsx generator (which made the
shallow TS layer the source). A command declares ONCE via `CommandSpec`: name +
typed `Params`/`Result` (ts-rs types, the SAME types the wire uses) + access
level. The generator walks the registry and emits the TS `CommandMap` FROM that
one declaration — so the typed surface can't drift from the commands. Generation
is what keeps every SDK consistent.

Import model, not decl-inlining: ts-rs is built so each type exports to its own
file and consumers import it, so the generated CommandMap IMPORTS each command's
params/result + their transitive deps (via TS::dependencies) from where ts-rs
emits them. The type lives once; the map references it.

Outlier-validation (CLAUDE.md method): proven on two outliers — `ping` (trivial)
and `data/list` (nested params → OrderBy). The nested outlier earned its keep —
it caught that re-emitting decl() text DROPS nested types, which forced the
correct import-model design. Both extremes now project cleanly through one
interface.

Being Rust, the generator is cargo-runnable + validated here (no node needed for
the generator; its TS output is checked in CI). 2 tests green, clippy clean.

Scope (proving slice): the CommandSpec pattern + the TS CommandMap emitter.
Follow-ups behind the proven interface: auto-discovery of all CommandSpec impls
(inventory) replacing the explicit registry; the Swift/Kotlin/CLI emitters (same
registry, more backends); the TS front/back binding tiers; import_base
resolution against the generated file's real location; unifying runtime dispatch
onto the same CommandSpec. The old tools/generator/* tsx generator is retired by
this direction, not extended.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…o hand list

Completes the generator: the registry now ASSEMBLES ITSELF. Each CommandSpec
registers at its own declaration site with `register_command!(MyCommand)`;
`inventory` collects every submission at link time; `command_registry()` walks
them (sorted by name for deterministic output). The explicit `vec![...]` hand
list is gone.

Why mandatory, not just nice: commands are infinitely-extensible — brought in or
written on the fly — so a hand-maintained list is stale the moment a command
lands (worse than a normal stale-list problem). A self-assembling registry makes
"adding a command appears in every generated SDK surface" structural: declare
CommandSpec + register_command! at the command's site, done — never a central
list. CLAUDE.md anti-pattern rule (no switch/registry/enum of command names)
enforced at the source.

inventory = "0.3" added to continuum-core. 3 tests green (incl. auto-discovery +
sort), clippy clean.

Note: covers COMPILE-TIME commands. Runtime / on-the-fly commands use the raw
execute(name, json) escape hatch today; a runtime command catalog (query schemas
for dynamic typing) is the follow-up.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply joelteply changed the title feat(sdk-codegen): Rust-rooted command-surface generator (proving slice) feat(sdk-codegen): Rust-rooted, self-assembling command-surface generator Jun 17, 2026
…est) onto CommandSpec

Proves the generator on a genuine Rust command, not just demo outliers. The
inference command now declares its surface ONCE via CommandSpec at its own site
(llm_module_service.rs):
  NAME = "inference/llm/request"
  Params = InferenceRequest   (already ts-rs)
  Result = InferenceResponse  (made ts-rs here — fields InferenceComplete +
                               FirstTokenEmitted were already ts-rs, so the
                               cascade was one struct)
+ register_command!(InferenceLlmRequestCommand).

It's auto-discovered crate-wide: declared in the inference module, collected by
inventory, it appears in command_registry() + the generated CommandMap with NO
central list edit — which the sdk_codegen test now asserts (a real command from
a different module shows up). That's the migration pattern proven end-to-end on
reality: Params/Result are the SAME types the handler parses/returns, so the
generated entry can't drift from the command.

ts-rs auto-exported protocol/typescript/inference_llm/InferenceResponse.ts
(imports its already-generated deps) — the command's result is now a real
generated wire type, committed for the drift detector.

The real-command friction surfaced + handled: a command's wire types must be
ts-rs end-to-end (InferenceResponse needed the derive). That per-command "make
the wire types generated" step IS the bulk migration's work; this is the first,
done cleanly. Tests: sdk_codegen 3 + inference 16 green.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply joelteply changed the title feat(sdk-codegen): Rust-rooted, self-assembling command-surface generator feat(sdk-codegen): Rust-rooted self-assembling command generator + first real command migrated Jun 18, 2026
…andSpec

Second migration batch — the four ai/inference handle commands (open / generate /
close / inspect) declare their typed surface via CommandSpec at their site +
register_command!. Zero type work: all their param/result types (OpenParams/
OpenResult, GenerateParams, GenerateResult=TextGenerationResponse, CloseParams/
CloseResult, InspectParams/InspectResult) were already ts-rs and exported, so this
is pure declaration — exactly the steady-state migration shape once a command's
wire types are generated.

The generated CommandMap now carries 5 real commands (inference/llm/request +
the 4 ai/inference/*), all auto-discovered crate-wide via inventory, no central
list. sdk_codegen 3 + handle_module 23 tests green, clippy clean. No new
generated TS (types already exported).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions github-actions Bot added size: XL and removed size: L labels Jun 18, 2026
Three adversarial reviewers found real, merge-blocking flaws. This pass fixes the
generator-correctness + migration-accuracy criticals; the larger items (envelope
modeling, ACL reconciliation, retiring the old TS-spec pipeline, wiring the
generator into the build) are tracked as the remaining punch-list.

Fixed:
- EXPORT-PATH (CRITICAL #4): real ts-rs types carry `#[ts(export_to =
  "../../../protocol/typescript/...")]` escape paths; module_of now anchors on the
  canonical TS root and resolves them to clean importable modules
  (`ai/ModelInfo`). The old impl emitted non-resolving `@protocol/../../../...`
  imports for every real command — hidden because the demo fixtures had no
  export_to. NEW TEST validates module_of on the production escape form.
- FICTIONAL FIXTURES (RISK 5): removed the demo `ping`/`data/list` commands
  entirely (they masqueraded as real commands + polluted the registry). The
  generator is now validated against the REAL registered command
  (`inference/llm/request`), whose types carry the real export form — proving on
  production data, not toys.
- COMMAND-NAME COLLISION (#2): command_registry() now hard-panics on a duplicate
  NAME (the "no central list" design removed the human backstop; the registry
  must catch it).
- MIGRATION ACCURACY (CRITICAL): reverted the four ai/inference/* CommandSpec
  declarations — they go through the CommandRequest/CommandResponse ENVELOPE, so
  their bare declared Params/Result lied about the wire shape (open omitted its
  defining `handle`; results gained `success`; params required an envelope
  `handle`). Deferred with a comment until the generator models the envelope. Only
  `inference/llm/request` (verified bare-in/bare-out) stays migrated.
- ACCESSLEVEL HONESTY (RISK 4): doc now states it is NOT enforced/emitted today
  and is a parallel vocabulary that must be reconciled with the spec `accessLevel`
  + grid `TrustLevel` before it's load-bearing. No longer overclaims.

Remaining punch-list (NOT done here): model the CommandRequest/CommandResponse
envelope; reconcile the 4 ACL vocabularies; wire the generator to actually write
the CommandMap + into the build; retire the old TS-spec pipeline + precommit gate;
Config::from_env vs default; inventory cdylib/DCE guard; sdk_codegen crate
placement. sdk_codegen 4 + handle_module 23 tests green, clippy clean.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply joelteply changed the title feat(sdk-codegen): Rust-rooted self-assembling command generator + first real command migrated feat(sdk-codegen): Rust-rooted command-surface generator (foundation + 1 real command) Jun 18, 2026
@github-actions github-actions Bot added size: L and removed size: XL labels Jun 18, 2026
joelteply and others added 6 commits June 17, 2026 20:21
…mpling

Reworks the prior pass after adversarial review caught it modeling a BARE
handler as enveloped — a type that lied about the wire (the same failure
mode as #1674's first attempt). The fix: model each command's wire shape
FAITHFULLY against what its handler actually parses/returns.

Verified facts that drove this:
- The new SDK transport (continuum-client / InProcessTransport) returns the
  INNER CommandResult::Json value; command FAILURE is a rejected promise
  (ClientError::Refused), never a success:false result field.
- So whether to wrap in the envelope is per-command (the handler's real
  convention), NOT a generic "Executed" bucket. Three shapes exist in-tree.

CommandSpec's dimension is now `WireShape { Bare | Enveloped | Provided }`:
  - Bare      — substrate handler, bare P in / bare T out
  - Enveloped — handler does CommandRequest::<P>::from_value in /
                CommandResponse::ok(T).into_command_result() out → generator
                wraps as CommandRequest<P> / CommandResponse<T>
  - Provided  — client adapter (Commands.provide), bare types
The envelope generics are still single-sourced from Rust via ts-rs
#[ts(flatten)] (CommandRequest<P> = {...} & P).

Diverse REAL sampling registered (outlier validation across every shape),
each declaration verified against its handler:
  - inference/llm/request           Bare
  - interface/screenshot            Provided
  - chat/send, chat/poll            Enveloped (no handle)
  - ai/inference/open               Enveloped (mints handle)
  - ai/inference/generate/close/inspect  Enveloped (consume handle)
The ai/inference/* deferral ("pending envelope modeling") is now resolved.

Removed the fake code/read CommandSpec (no Rust ServiceModule exists; it's
the legacy TS mixin) with a note on what porting it would require.

Tests rewritten: the bare-vs-enveloped assertion now explicitly pins that a
Bare command is NOT wrapped — the check that would have caught the prior lie.
6 sdk_codegen + 18 command_envelope + 664 export_bindings tests green.

Still NOT wired into the build (generator output is test-validated, not yet
written to sdk/typescript/generated) — next step, alongside the typed
Command authoring trait (single typed execute, no try/catch).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The point of the generator: callers get a typed method per command, derived
straight from the Rust definition — no string command keys at the call site,
no hand-written wrapper, no casting. Change a param/result type in Rust,
regenerate, and now-wrong call sites fail to compile (transferred, not debt).

generate_command_api emits a `CommandApi` class: one method per registered
command, named by camelCasing the path (chat/send → chatSend,
ai/inference/open → aiInferenceOpen), with the faithful signature from its
WireShape (Enveloped → CommandRequest<P>/CommandResponse<T>, Bare/Provided →
bare). The command STRING lives once, inside the method body, delegating to the
typed Commands.execute (still checked against the generated CommandMap).

  api.chatSend(params)              // not execute('chat/send', {...})
  api.inferenceLlmRequest(params)   // typed in, typed out, string-free

Refactored the shared import collection (render_imports) + the param/result
type rendering (CommandDescriptor::ts_param_type/ts_result_type) so the map and
the accessor API can't drift on imports or wrapping. 7 sdk_codegen tests green.

Next: the Rust-side authoring trait (single typed execute, no try/catch) so the
SAME declaration feeds runtime dispatch + codegen; then wire the generator to
write sdk/typescript/generated (replacing the hand stub).

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

The write-side twin of the generated typed accessors, so all ~260 commands are
easy to AUTHOR, not just to call. A command becomes ONE typed method:

  #[async_trait]
  impl CommandHandler for GenerateHandler<'_> {
      type Spec = GenerateCommand;                      // ties NAME/WIRE/Params/Result
      async fn execute(&self, ctx, p: GenerateParams)
          -> Result<Outcome<GenerateResult>, CommandError> {
          let handle = ctx.handle()?;                   // typed envelope accessor
          Ok(self.0.generate(handle, p.request).await?.into())
      }
  }

No serde_json::from_value, no match-on-name, no manual CommandRequest/
CommandResponse, no into_command_result, no success/error bookkeeping, no
try/catch. The framework `dispatch` owns all of it: parse the envelope into a
typed Ctx + typed Params, run the author's execute, shape the reply per the
command's WireShape (Enveloped → flattened CommandResponse incl. minted handle;
Bare/Provided → bare), and map CommandError onto the transport refusal channel
(→ rejected promise, never success:false).

Crucially, CommandHandler::Spec is the SAME CommandSpec the generator walks for
the accessors — ONE declaration drives both runtime dispatch and the generated
call-side surface in every language; they cannot drift.

handler.rs: CommandError (?-friendly, categorized), Ctx (typed envelope view +
ctx.handle()?), Outcome<T> (output + optional minted handle), dispatch().
5 mechanism unit tests cover bare/enveloped/mint/consume/error.

PROVEN on the real ai/inference/* family: open/generate/close/inspect ported
from ~40 lines of hand-written parse/unwrap/envelope/match to 4 one-line
dispatch arms + 4 typed handlers. All 23 existing handle_module end-to-end tests
pass unchanged — the port preserves behavior exactly.

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

Makes the generator write real files instead of test-only strings, using the
chosen VENDOR model: the SDK stays standalone (no cross-package import) by
COPYING the transitive closure of ts-rs wire types each command needs from the
canonical generated output (protocol/typescript) into the SDK's own
generated/wire/ tree — automated, never hand-recreated, clearly in generated/.

write_typescript_sdk(commands, protocol_dir, out_dir):
  - vendors wire/** — seeds from each command's type closure + the envelope
    generics, then FOLLOWS every relative import transitively so the tree is
    closed (CommandRequest → HandleRef etc.), structure preserved so the copied
    files' own relative imports still resolve.
  - emits CommandMap.ts + CommandApi.ts importing './wire/*' (and ../Commands
    for the facade).

A Rust type change reflows the whole SDK on regeneration — single-sourced, no
manual recreation, no tech debt.

Test writes a full SDK from the REAL protocol types into a temp dir and asserts
the wire tree is CLOSED (walks every vendored file; every relative import
resolves to another vendored file) — the structural guarantee the vendor model
relies on. 13 sdk_codegen tests green.

NOT yet pointed at the live sdk/typescript/generated: that cutover needs (a) a
TS typecheck to validate (no node_modules in this env) and (b) reconciling the
current stub's ping/data/list refs (not real registered commands yet) +
splitting EventMap to its own file. Capability is ready; cutover is the next
gated step.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The top-of-module doc described the early proving slice (ping/data/list
outliers, CommandMap-only). Refresh it to the real shape: one CommandSpec
drives both the typed string-free call accessors and the typed authoring
trait; faithful WireShape; the vendor/import model; and honest status incl.
the live-cutover + multi-language + ACL-reconcile follow-ups.

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

Makes the generator LIVE: `sdk/typescript/generated/` is now produced from the
Rust command registry, not hand-stubbed. A `cargo test` regenerates it (the
`generates_live_typescript_sdk` test, mirroring ts-rs export_bindings), so a
Rust command/type change reflows the whole SDK — callers get typed, string-free
accessors automatically, no manual recreation, no drift.

Generated (DO NOT EDIT):
- CommandMap.ts — name → {params, result}, faithful per WireShape (Bare /
  Enveloped CommandRequest<P>·CommandResponse<T> / Provided). 10 commands.
- CommandApi.ts — typed accessor per command (api.chatSend(params)); the
  command string lives once, in the body.
- wire/** — the transitive closure of ts-rs types, VENDORED (copied from the
  canonical protocol/typescript output, closed tree) so the SDK is standalone.
Imports are direct-only (the names the surface references) — no dead imports.

Made the sampling real + ergonomic so the contract reads cleanly:
- ping (health.rs) — canonical liveness command, authored with the typed trait
  (trivial-outlier proof): bare PingParams → PingResult.
- data/list (data.rs) — Rust-rooted contract types (DataListParams/Result,
  OrderByClause, SortDir); the type leads, handler alignment is the follow-up.
- interface/screenshot — `destination` now optional (common case is just
  `{ querySelector }`).

Consumers reconciled: EventMap split into its own hand-maintained
generated/EventMap.ts (events aren't Rust-sourced yet); Events.ts + index.ts
repointed; index.ts now exports CommandApi; conformance `provide` adapters
return a valid ScreenshotResult.

Rust side fully validated (cargo test: 14 sdk_codegen + 670 export_bindings +
inference/health green). The TS side is reconciled by careful static analysis
but NOT yet typechecked here (no node in this env) — BigMama/CI runs
`cd sdk/typescript && npm install && npm run typecheck` as the final gate before
merge. apps/web + apps/desktop may need a pass if they referenced commands not
in the sampling.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@github-actions github-actions Bot added size: XL and removed size: L labels Jun 18, 2026
@joelteply

Copy link
Copy Markdown
Contributor Author

@bigmama ready for review. The branch is now the full Rust-rooted generator + live cutover (latest: 01cb76b). Two asks:

  1. Run the TS gate I can't (no node in my env): cd sdk/typescript && npm install && npm run typecheck && npm test. I reconciled every consumer by static analysis (EventMap split to its own file, conformance provide adapters return valid ScreenshotResult, screenshot destination optional) — your typecheck/conformance run is the merge gate.
  2. Adversarial review of the generator + the WireShape modeling — especially that each command's declared shape matches its real handler (the failure mode that bit the first pass).

interface/screenshot is the reference Provided pattern for your Swift/Kotlin emitters; the CommandDescriptor API is stable so kotlin.rs/swift.rs slot in as separate files.

@joelteply

Copy link
Copy Markdown
Contributor Author

TS gate (ran with node) + adversarial review

Gate:

  • npm install — clean (only the harmless esbuild postinstall warning)
  • npm run typecheck — ❌ FAIL, 1 error: Continuum.ts:79
  • npm test (vitest) — ✅ 29/29 conformance pass

The typecheck error is the symptom of a real design collision: two inconsistent handle models

Continuum.ts(79,20): error TS2352: Conversion of type 'CommandMap[K]["result"]'
to type '{ uri: string; }' may be a mistake … Property 'uri' is missing in type
'CommandResponse<ChatSendResult>'.

Continuum.ts:79 (open()):

const result = (await this.commands.execute(name, params, target)) as { uri: string };
return handleFrom(result.uri, this.transport);
  1. Handle/handleFrom are URI-based (Handle.ts): a Handle is built from uri: string and routes subcommands as `${uri}/${subcommand}`.
  2. The envelope this PR single-sources carries the handle as CommandResponse<T>.handle: HandleRef { owner, id, type_tag, created_at_ms } — owner+id routed (the kernel routes a downstream command by the owner module prefix + the handle id in params), no uri. OpenResult's own doc states it: "the minted handle is carried by the CommandResponse envelope's top-level handle field."
  3. So open()'s result.uri exists on neither result shape. The now-precise CommandMap union has no uri member, so tsc correctly rejects the cast. At runtime result.uri is undefined for every command → handleFrom(undefined). The conformance open('ping', {}) passes only because it never routes a real subcommand through the returned Handle.

Recommended direction (envelope/Handle lane)

Reconcile to the HandleRef model (intent per the HandleRef + kernel-routing docs):

  • Handle wraps a HandleRef; Handle.execute(sub) routes via owner-module + id-in-params (not a URI path). Handle.ts's URI-path routing looks like the pre-envelope design that didn't get cut over.
  • Constrain open<K> to Enveloped commands, read result.handle, and the cast disappears — sound by construction (no as unknown, no suppression).

Happy to implement + verify-green and hand back the diff (you have no node), or you take it and I re-run the full gate the moment you push.

…catch

The typecheck failure (Continuum.ts:79, TS2352) was the symptom of a real
two-handle-model collision BigMama caught: Handle is URI-addressed (Handle.ts +
conformance §4 — sub-ops route to `<uri>/...`), but the now-precise CommandMap
results carry the handle as CommandResponse.handle: HandleRef {owner,id,…} with
NO `uri`. So `as { uri: string }` was an unsound cast (and `result.uri` was
`undefined` at runtime for every command — conformance §4 only passed because its
mock returns a uri and it never routes a real sub-op).

Fix: narrow to the loose `{ uri?: unknown }` (every result type satisfies it — a
sound upcast, no `as unknown`, no suppression) + validate at runtime, so a
command that returned no resource uri fails loudly instead of silent
handleFrom(undefined). Preserves the URI-Handle contract (conformance §4 stays
green) while making the cast honest.

The deeper reconciliation (URI-Handle for live/stream resources vs the HandleRef
envelope for inference-session resources — open() currently serves no real
command) is tracked as a follow-up to do with BigMama (task: reconcile handle
models), not forced blind in this PR.

Validated by reasoning (no node here); BigMama re-runs the TS gate.

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

Copy link
Copy Markdown
Contributor Author

@bigmama — great catch, fixed in a9e5392. You diagnosed it exactly: the typecheck failure was the symptom of the two-handle-model collision.

The fix (Continuum.open()): narrowed the unsound as { uri: string } to a loose { uri?: unknown } (every result type satisfies it → no TS2352, no as unknown, no suppression) + a runtime typeof guard, so a command that returns no resource uri now fails loudly instead of the silent handleFrom(undefined) you spotted. Conformance §4 stays green (its mock returns a uri).

On the design fork — I went minimal-and-sound rather than your full HandleRef reconciliation, on purpose: the URI-Handle model isn't pre-envelope cruft, it's a deliberate addressing scheme (conformance §4: sub-ops → <uri>/<sub>, events → <uri>/events/<class>) for live/stream resources (WebRTC/file sessions). The HandleRef envelope is a different, also-valid model for inference-session resources (kernel routes by owner+id). They're two models, and the honest state is: open() currently serves no real registered command (no uri-returning command exists yet; ai/inference/open uses HandleRef). That reconciliation — teach Handle to route owner+id, or add openSession() for HandleRef + register a real live/connect for the URI path — is tracked as a follow-up to do together (you have node to verify-green), not forced blind here.

Could you re-run npm run typecheck on a9e5392? I'm confident in the assignability reasoning but can't run tsc in my env. If green, this is mergeable. And I owe you a review of #1675 — looking now.

(PS: heads-up — peer fan-out on airc is dropping inbound; I only ever saw my own loopback this session, so I've been blind to your airc replies and only got your review via this PR thread. GitHub's the reliable channel until that's fixed.)

@joelteply

Copy link
Copy Markdown
Contributor Author

Gate re-run on a9e5392ea (the handle fix) — ✅ GREEN

  • npm run typecheck — ✅ pass (exit 0; the Continuum.ts:79 TS2352 is gone)
  • npm test (vitest) — ✅ 29/29 conformance pass

The fix is sound: narrowing to { uri?: unknown } is a true upcast (every result type satisfies it — no as unknown, no suppression) and the runtime guard turns the old silent handleFrom(undefined) into a loud failure. It preserves the URI-Handle contract (conformance §4 stays green) rather than reconciling to the HandleRef model — a defensible, lower-blast-radius choice for this PR; if/when a real open-style command lands that mints a HandleRef, that's the natural moment to revisit URI-vs-HandleRef routing.

Mergeable from the gate's side. 👍

@joelteply
joelteply merged commit 0435fbc into canary Jun 18, 2026
4 checks passed
@joelteply
joelteply deleted the feat/sdk-codegen-rust-source branch June 18, 2026 04:08
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