Skip to content

feat(client): provide() — the serve side of the Command primitive (bidirectional commands) - #1664

Merged
joelteply merged 1 commit into
canaryfrom
feat/client-ffi-provide
Jun 17, 2026
Merged

joelteply merged 1 commit into
canaryfrom
feat/client-ffi-provide

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

The serve side of the Command primitive — the third of the four SDK facade verbs (execute+subscribe shipped in #1663; this is provide; emit follows once the substrate's EventPublishAdapter lands). A client can now provide (serve) a command, not just call one — for client-provided commands the core can't run: interface/screenshot, capture, sensors (the SDK's display / renderer / hardware). OpenCV-style adapter polymorphism: one command identity, N platform handlers (web = DOM/canvas, AR/VR = renderer capture).

Commands = execute (call) + provide (serve) — one primitive, both directions. Per M5's sequencing: provide first (fully grounded), emit second.

How (the serve side on the Transport trait — M5's design call)

  • continuum-client Transport trait gains provide(command, Arc<dyn ServeHandler>) + revoke(command) (+ the ServeHandler trait). Symmetric with request — one trait owns the Command primitive both ways.
  • AircIpcTransport real serve loop: the client-side twin of persona/command_inbound_pump.rs — a second broadcast subscribe, decode inbound AircCommandRequest (reply-to/correlation from the airc.* headers), dispatch to the registered handler, reply AircCommandResponse via airc.reply. Same protocol types as request → zero wire drift. Dispatch is spawned per request so a slow handler (a screenshot) doesn't stall the loop; the loop starts once on first provide.
  • MockTransport serve registry + dispatch_provided(command, params) to exercise the serve path without a live daemon.
  • Connection gains provide/revoke + a manual Clone (shares the one Arc<T>; derived Clone would wrongly demand T: Clone).
  • Facade (continuum-client-ffi): provide(command, Arc<dyn CommandHandler>) -> Registration (drop = revoke, the serve twin of Subscription). CommandHandler { handle(params_json) -> Result<String, FfiError> } is the foreign callback (mirror of EventCallback); the adapter runs it on spawn_blocking so a heavy handler stays off the async worker (off-main-thread).

Validation

cargo fmt + cargo clippy -D warnings + cargo test — continuum-client 18 tests, facade 7 tests (4 prior + 3 new: provided-handler-answers, handler-error→Refused, revoke-stops-serving). Serve path validated end-to-end via MockTransport (register → dispatch → handler → result), no live daemon.

Also: a one-line dep (airc-protocol workspace dep — the crate the substrate's command_handler reads the correlation/reply-to header keys from, zero drift) and two trivial pre-existing clippy nits in continuum-client's existing tests, fixed in passing.

Next

emit (the publish verb) once the substrate-side EventPublishAdapter (the receive-door twin of EventSubscribeAdapter) lands — then the uniffi .udl binds all four verbs in one pass → native swift/kotlin SDKs (Android here, xcframework on macOS CI). Env-targeting (airc://peer:env/path) composes as an internal filter once #1662's CommandUri lands — provide's signature is env-agnostic.

🤖 Generated with Claude Code

@joelteply
joelteply merged commit 16a68f3 into canary Jun 17, 2026
4 of 5 checks passed
@joelteply
joelteply deleted the feat/client-ffi-provide branch June 17, 2026 20:42
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