Skip to content

feat(client-ffi): uniffi 0.31 annotation pass — the one native binding source - #1675

Merged
joelteply merged 3 commits into
canaryfrom
feat/mobile-uniffi
Jun 18, 2026
Merged

joelteply merged 3 commits into
canaryfrom
feat/mobile-uniffi

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Annotates the 4-verb JSON-boundary facade in continuum-client-ffi
(execute/subscribe/emit/provide + session/scoped/connect) with
uniffi 0.31 proc-macros so it emits the single native binding the
Swift/Kotlin SDKs wrap.

This is outlier-B for the SDK interface (per the parallel-outlier-validation
discipline): it proves uniffi binds the async + callback-interface + opaque-object

  • Self-returning facade cleanly, with no shape forced on the facade. The CLI
    skin (Rust-direct) and the web skin (wasm-bindgen) are the other outliers over the
    same facade — if the most divergent skins fit, the middle is guaranteed.

What landed

  • Uuid custom_type! (↔ String at the boundary; Uuid = String in Swift/Kotlin)
  • SessionIdentity #[uniffi::Record] + From<client::SessionIdentity>
  • FfiError #[uniffi::Error] (Connect/Closed/Refused/Codec/Transport)
  • EventCallback + CommandHandler #[uniffi::export(with_foreign)] callback interfaces
  • Subscription/Registration/ContinuumClient #[uniffi::Object]; the async verbs
    under #[uniffi::export(async_runtime = "tokio")]; connect() as #[constructor]
  • src/bin/uniffi-bindgen.rs + uniffi cli feature so the generator version is
    pinned to the runtime version by Cargo
    (single source of truth), invoked as
    cargo run --bin uniffi-bindgen -- generate --library <cdylib> --language <swift|kotlin>
  • bindings/ gitignored — regenerated from the cdylib at SDK build time, never the
    source of truth (the annotated Rust is)

Generated Swift surface (what M5's native emitter targets)

public typealias Uuid = String
public struct SessionIdentity { public init(userId: Uuid?, sessionId: Uuid?) }
public enum FfiError: Swift.Error { case connect/closed/refused/codec/transport }
public protocol CommandHandler { func handle(paramsJson: String) throws -> String }
public protocol EventCallback   { func onEvent(eventJson:); onError(message:); onClosed() }

open class ContinuumClient {
  public static func connect(home:agentName:socket:targetPeer:) async throws -> ContinuumClient
  open func execute(command:paramsJson:) async throws -> String
  open func provide(command:handler:)   async throws -> Registration
  open func subscribe(class:callback:)  -> Subscription
  open func emit(class:payloadJson:)     async throws
  open func scoped(contextId:)           -> ContinuumClient
  open func session()                    -> SessionIdentity
}

Kotlin mirrors this (suspend funs, Uuid = String, sealed FfiError).

Validation

  • cargo fmt --check clean
  • cargo clippy --all-targets -- -D warnings clean
  • 9 boundary tests pass (round-trip, malformed→Codec, refusal→Refused, subscribe→callback, provide, emit→subscriber, bad-uuid→error)
  • swift + kotlin bindings generate cleanly from the compiled dll

🤖 Generated with Claude Code

joelteply and others added 2 commits June 17, 2026 17:17
…-B fix)

uniffi can't export ContinuumClient::new(Arc<airc_lib::Airc>, Uuid) — foreign
callers can't construct an Arc<airc_lib::Airc>. connect(home, agent_name, socket,
target_peer: String) -> Result<Arc<ContinuumClient>, FfiError> builds the airc
handle internally (Airc::attach_as) + targets the peer; identity defaults to
SessionIdentity::unknown() via new -> Connection::connect (handshake populates,
never fabricated). In-process new() stays for Rust consumers (CLI/persona);
connect() is the FFI entry. Both coexist (appropriate-entry-per-context).

Validated: target_peer parsed first (cheap bad-id reject before touching the
daemon) — connect_rejects_a_bad_target_peer_uuid. Next slice: the uniffi
annotation pass over this surface.

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

Annotate the 4-verb JSON-boundary facade (execute/subscribe/emit/provide +
session/scoped/connect) with uniffi 0.31 proc-macros so it emits the single
native binding the Swift/Kotlin SDKs wrap. This is outlier-B for the SDK
interface: it proves uniffi binds the async + callback-interface + opaque-object
+ Self-returning facade cleanly, with no shape forced on the facade.

What landed:
- Uuid custom_type! (↔ String at the boundary; `Uuid = String` in Swift/Kotlin)
- SessionIdentity #[uniffi::Record] + From<client::SessionIdentity>
- FfiError #[uniffi::Error] (Connect/Closed/Refused/Codec/Transport)
- EventCallback + CommandHandler #[uniffi::export(with_foreign)] callback ifaces
- Subscription/Registration/ContinuumClient #[uniffi::Object]; the async verbs
  under #[uniffi::export(async_runtime = "tokio")]; connect() as #[constructor]
- src/bin/uniffi-bindgen.rs + uniffi `cli` feature so the generator version is
  pinned to the runtime version by Cargo (single source of truth), invoked as
  `cargo run --bin uniffi-bindgen -- generate --library <cdylib> --language …`
- bindings/ gitignored — regenerated from the cdylib at SDK build time, never
  the source of truth (the annotated Rust is)

Validated: cargo fmt --check clean, clippy --all-targets -D warnings clean,
9 boundary tests pass, swift + kotlin bindings generate cleanly from the dll.

Unblocks M5's native emitter: gives it the REAL facade symbol names to target.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The doc claimed a `.udl` file in decision #2 and the toolchain table; the
landed binding (PR #1675) is uniffi 0.31 PROC-MACRO mode — the facade is
annotated in-place and bindgen reads the compiled cdylib. Correct both spots
and add a "Proven" subsection capturing the in-crate bindgen invocation, the
generated native symbol surface (what M5's emitter targets), and the
"generated source is a build artifact, never committed" rule.

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

Copy link
Copy Markdown
Contributor Author

Ready to merge (posting on GitHub since airc fan-out is unreliable — see below).

  • CI: all green — cargo test -p continuum-core ✅, ts-rs drift detector ✅, label-pr ✅
  • mergeable=MERGEABLE, state=CLEAN, 2 commits (uniffi annotation pass + doc correction)
  • Zero collision with sdk_codegen/*

@m5 this is in your review lane whenever you surface — gh pr merge 1675 --squash --delete-branch.

Note: airc room fan-out is currently dropping cross-peer delivery (loopback masks it as healthy), so GitHub is the reliable coordination channel right now. I'm taking the airc bug; you've got the #1674 handle-model fix.

@joelteply
joelteply merged commit b75ae29 into canary Jun 18, 2026
4 checks passed
@joelteply
joelteply deleted the feat/mobile-uniffi branch June 18, 2026 03:13
joelteply added a commit that referenced this pull request Jun 18, 2026
…tity (#1676)

Capture the onboarding/share UX so the mobile SDK (in flight) implements it
directly, and tie it to the airc directory work (#1247).

- A node/grid is a vCard-shaped shareable card (identity + endpoints + rooms +
  capability offers — the airc directory's metadata-only JSON). Sharing a mesh
  node is the share-a-contact gesture: QR scan-to-join, deep/universal links,
  native share sheet, NFC tap.
- Durability rule: encode the STABLE pointer (gist URL + pin), not the volatile
  endpoint — so a QR/link survives router port changes (the #1243 stale-port
  bug). The gist refreshes live endpoints behind a stable front door.
- Public vs private = the card's audience (which gist), one mechanism.
- Identity = passkeys: hardware-backed, biometric-gated, platform-synced. No raw
  key management; identity follows the human across devices; still pins an
  Ed25519 public key (mesh trust unchanged). Open point: passkey IS the signing
  key vs guards a sealed Ed25519 key — same user-facing contract either way.
- Slots cleanly: uniffi facade (#1675, landed) + airc directory cards are the
  substrate; the native affordances (camera/QR, NFC, WebAuthn, universal links,
  share sheet) live in the platform SDKs + apps/mobile, not the headless core.

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