Skip to content

feat(iroh-ffi): add uniffi bindings for the OpenClaw ID tunnel - #194174

Merged
jalehman merged 12 commits into
mainfrom
openclaw-517/node-ffi
Nov 9, 2026
Merged

jalehman merged 12 commits into
mainfrom
openclaw-517/node-ffi

Conversation

@jalehman

@jalehman jalehman commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Native OpenClaw ID nodes need a Swift/Kotlin transport with QUIC keep-alive and exact numeric application close codes for openclaw/tunnel/1.

User Impact

No user-visible change yet. No app consumes this crate until Android #194194 and Apple #194201 land; default app builds are unchanged. This PR adds the standalone transport foundation, not an app cutover or a release.

Remaining platform and release gates: iOS builds successfully but has not been runtime-proven on a device or simulator. Device transport, mobile lifecycle, and final APK/AAB packaging remain consumer-lane work. License notices for UniFFI, attohttpc, and MPL-covered dependencies must be completed before shipping the apps; they are a release gate, not a gate for merging this source-only crate.

Why This Change Was Made

The OpenClaw-owned adapter pins iroh 1.4.1 (matching the Node addon) and UniFFI 0.31.2. It exposes endpoint bind/connect, bidirectional streams, typed close information preserving every legal 62-bit QUIC application code, home-relay status, and explicit cancellation/shutdown. The existing Node addon is unchanged. Apps retain enrollment, destination verification, framing, protected key storage, and lifecycle ownership.

The native input seed is zeroized on success and failure; this does not promise erasure of Swift/Kotlin or UniFFI marshalling copies. The Minimal preset uses only the supplied relay, with no default discovery service. Android must install its Application context before binding. Swift cancellation must use native CancelToken/stream stop-reset/shutdown; Kotlin callers shield native result delivery with NonCancellable and use the same explicit cancellation signals to avoid abandoning lowered results.

libc stays pinned to 0.2.189 until follow-up openclaw-85d removes the incompatible iOS dependency path. The pin is guarded in CI and documented in PACKAGING.md; the locked dependencies are audited on changes and weekly. No dependency upgrade or pin removal is part of this merge.

Evidence

Final candidate: d5003c1e09b565fd3b23f4e8dcfd991ac8ea3254. Its only change after f1adbdd corrects the README's obsolete no-upload claim to describe the short-lived Apple CI artifact; all code, bindings, lockfiles, tests, and workflows are byte-identical. Final-head CI, native Linux/Android/Apple builds, and dependency audit passed. Required CI/security gates were verified green before native merge submission.

Completed proof at code-identical head f1adbdd671ceb0219961d52d568d00ba7c688274:

  • Native CI passed Linux, Android, and Apple. Linux runs Rust tests/lint, checks generated bindings, and builds the release library. Android builds all four ABIs with ELF LOAD alignment >=16 KiB. Apple builds all five Rust targets into the macOS/iOS-device/iOS-simulator XCFramework and typechecks the generated Swift.
  • Dependency audit passed, including the libc pin check and RustSec audit.
  • Local Rust 1.99 validation passed: cargo test --locked (1 unit + 5 real loopback integration tests), cargo clippy --locked --all-targets --all-features -- -D warnings, formatting, the pin check, deterministic Swift/Kotlin regeneration, and all 21 generated Kotlin ABI checksums against the rebuilt host library. The tests cover exact 2^62−1 application close codes, streams/FIN, input bounds, seed erasure, watcher shutdown, blocked read/accept/connect shutdown, and per-operation dial/stream cancellation while retaining endpoint/connection usability.
  • Linux release library: 13,189,976 bytes; SHA-256 cbda14805e7c8f583c7760a84228b84f590c2c48780654934c60846c11d03bb3.
  • Apple CI artifact is a short-lived workflow artifact, not a published package or app release.

Consumer-lane evidence is distinct from crate CI:

Independent read-only Astra landing review covered the complete 25-file diff from merge-base d88a384060d6d0f55920fc0092877c58d128cc3e to f1adbdd671ceb0219961d52d568d00ba7c688274, including dependency ownership/cancellation and platform packaging contracts. It found no verified P0–P2 findings. This was static review, not an independent runtime rerun. The subsequent README-only correction was inspected separately and passes git diff --check; it changes no code or runtime inputs. The completed final-head ClawSweeper re-review reports no actionable findings and confirms both prior findings resolved. Mobile runtime and distribution limitations above remain unchanged.

Related: #193993 (landed node-join foundation), #194194 (Android consumer), #194201 (Apple consumer).

@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@jalehman
jalehman force-pushed the openclaw-517/node-ffi branch from 47d9310 to 3113717 Compare November 6, 2026 14:55
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Nov 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 6, 2026
@clawsweeper

clawsweeper Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds a standalone Rust transport crate with generated Swift/Kotlin bindings and Apple/Android build workflows.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused transport foundation with substantial native integration and cross-platform build coverage, but harness-level rather than shipped-app proof.
Proof confidence 🦐 gold shrimp (3/6) The host identifies this as maintainer-authored, outside the ordinary contributor proof gate; supplied Rust and Swift/Kotlin loopbacks support transport behavior, while mobile device runtime remains explicitly scoped to the consumer PRs.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Native OpenClaw ID nodes need a Swift/Kotlin transport supporting keep-alives, explicit cancellation, and exact QUIC close codes.
Reason: The maintainer-directed source-only stage has concrete dependent consumers, preserves default builds, and keeps transport separate from app trust policy.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a useful, maintainer-directed native transport foundation with dependent consumer PRs; both prior findings are resolved, and no new actionable correctness defect was verified.

Priority: P2
Reviewed head: d5003c1e09b565fd3b23f4e8dcfd991ac8ea3254

Before merge

None.

Findings

None.

Agent review details

How this fits together

Native apps supply an endpoint seed and verified destination through UniFFI; the crate uses iroh to return bidirectional streams, relay status, cancellation results, and numeric close information while enrollment and authorization remain app-owned.

flowchart LR
  A[Native app trust and lifecycle] --> B[Swift or Kotlin bindings]
  B --> C[OpenClaw UniFFI transport]
  C --> D[iroh endpoint and QUIC streams]
  D --> E[Direct path or selected relay]
  E --> F[Gateway tunnel peer]
Loading

Technical review

Best possible solution:

Land the standalone transport foundation after its existing exact-head gates pass, retaining app authorization, lifecycle, and distribution qualification in the consumer lanes.

Do we have a high-confidence way to reproduce the issue?

This is a new capability rather than an existing bug report; source inspection and supplied integration results establish the intended transport boundary without executing target code.

Is this the best way to solve the issue?

A standalone UniFFI adapter is a coherent first stage because the existing N-API binding cannot serve Swift/Kotlin, while enrollment and authorization stay with existing app owners.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f615e96b55be.

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +309, Docs +252, Config +195, Other +11895. Total +12651 across 25 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 309 0 +309
Docs 2 252 0 +252
Config 2 195 0 +195
Generated 0 0 0 0
Other 20 11895 0 +11895
Total 25 12651 0 +12651

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Build configuration 1 new environment selector OPENCLAW_IROH_APPLE_PLATFORMS selects all Apple slices or macOS only; the default remains all slices.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a useful native transport foundation for approved consumer work, with no immediate change to default app behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-06T16:27:25.621Z sha 8be796d :: blocked before merge. :: [P2] Repair the locked iOS dependency path before packaging all Apple targets | [P3] Correct the README's binary artifact upload claim

Reviewed November 9, 2026, 9:56 AM ET / 14:56 UTC (Revision 2).

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​uniffi@​0.31.21001009310070

View full report

@jalehman
jalehman force-pushed the openclaw-517/node-join branch from b7abc8d to 1b404a8 Compare November 7, 2026 19:51
@jalehman
jalehman force-pushed the openclaw-517/node-ffi branch from 031aad5 to 69e19a5 Compare November 7, 2026 19:52
@jalehman
jalehman force-pushed the openclaw-517/node-join branch from 1b404a8 to a032fd8 Compare November 7, 2026 20:24
@jalehman
jalehman force-pushed the openclaw-517/node-ffi branch from 69e19a5 to 7f9243b Compare November 7, 2026 20:24
@jalehman
jalehman force-pushed the openclaw-517/node-join branch from a032fd8 to 52fc558 Compare November 7, 2026 20:46
@jalehman
jalehman force-pushed the openclaw-517/node-ffi branch from 7f9243b to b6765ac Compare November 7, 2026 20:46
@jalehman
jalehman force-pushed the openclaw-517/node-join branch from 52fc558 to 4c1be1f Compare November 8, 2026 17:23
@jalehman
jalehman force-pushed the openclaw-517/node-ffi branch from b6765ac to 76878bb Compare November 8, 2026 17:23
@jalehman
jalehman force-pushed the openclaw-517/node-join branch from 4c1be1f to 87b4ea8 Compare November 8, 2026 23:03
@jalehman
jalehman force-pushed the openclaw-517/node-join branch from 70d8109 to 7cf477a Compare November 9, 2026 02:08
Base automatically changed from openclaw-517/node-join to main November 9, 2026 13:08
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes labels Nov 9, 2026
A standalone crate on iroh 1.4.1 and UniFFI 0.31.2 that exposes exactly the
openclaw/tunnel/1 transport surface to Swift and Kotlin: Minimal-preset bind
with only the selected relay and a required keep-alive, connect to a verified
endpoint key, bidirectional streams, full-range numeric close codes, a home
relay watcher that ends on shutdown, and shutdown that interrupts pending I/O.
The seed copy is zeroized on every bind path.

Refs openclaw-9d4
…tion

GitHub's Ubuntu image has no sdkmanager on PATH; the Android job failed
before building. Use the repository's setup-android-toolchain action, as the
other Android workflows do.

Refs openclaw-9d4
UniFFI 0.31.2 Swift async calls ignore Task cancellation, so a cancelled
Swift task left its dial running until the endpoint shut down. connect now
takes an optional CancelToken; cancelling it fails that dial with Cancelled
and keeps the endpoint usable. Kotlin coroutine cancellation already frees
the Rust future, so the token defaults to none.

Refs openclaw-9d4
jni 0.22 takes class descriptors as JNIStr; a plain &str no longer
satisfies Desc<JClass>, so the Android library failed to compile.

Refs openclaw-9d4
…Kotlin

UniFFI 0.31.2 lowers a future's result when it becomes ready; freeing the
future before the foreign side lifts it leaks that handle or buffer. Kotlin
callers therefore cancel with explicit native signals, like Swift.

Refs openclaw-9d4
A blocked open_bi (no stream credit) or accept_bi could only be interrupted
by closing the connection. Both now take an optional CancelToken, so a
caller can abandon one wait while the shared connection keeps serving.

Refs openclaw-9d4
…tifact

App integration tests need the full XCFramework, including the iOS simulator
slice, on hosts without the extra Rust targets. Retained for three days; not
a release.

Refs openclaw-9d4
The iOS slices fail to compile: netdev 0.46 (via iroh's netwatch) uses
libc::in6_ifreq, which libc defines only for macOS. OPENCLAW_IROH_APPLE_PLATFORMS=macos
builds the universal macOS slice alone so app work can proceed; the default
still builds every slice.

Refs openclaw-517.12
netdev 0.46 (iroh 1.4.1 -> netwatch 0.19.3) uses libc::in6_ifreq on every
Apple target, and libc 0.2.190 limited that type to macOS. Lock libc at
0.2.189, the version n0's iroh-ffi v1.2.0 ships its iOS builds with.

scripts/check-pins.sh fails if the pin drifts while netdev 0.46.0-0.46.3 is
locked. A new audit workflow runs it and cargo-audit on lockfile changes
and weekly, since nothing else watches this crate's dependencies.

Refs openclaw-85d
@jalehman
jalehman force-pushed the openclaw-517/node-ffi branch from 76878bb to f1adbdd Compare November 9, 2026 13:12
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation cli CLI command changes labels Nov 9, 2026
@jalehman
jalehman marked this pull request as ready for review November 9, 2026 14:50
@jalehman

jalehman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 9, 2026
@jalehman
jalehman merged commit 1c996b1 into main Nov 9, 2026
182 of 190 checks passed
@jalehman

jalehman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@jalehman
jalehman deleted the openclaw-517/node-ffi branch November 9, 2026 15:07
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
…law#194174)

* feat(iroh-ffi): add uniffi bindings for the OpenClaw ID tunnel

A standalone crate on iroh 1.4.1 and UniFFI 0.31.2 that exposes exactly the
openclaw/tunnel/1 transport surface to Swift and Kotlin: Minimal-preset bind
with only the selected relay and a required keep-alive, connect to a verified
endpoint key, bidirectional streams, full-range numeric close codes, a home
relay watcher that ends on shutdown, and shutdown that interrupts pending I/O.
The seed copy is zeroized on every bind path.

Refs openclaw-9d4

* ci(iroh-ffi): install the NDK through the pinned Android toolchain action

GitHub's Ubuntu image has no sdkmanager on PATH; the Android job failed
before building. Use the repository's setup-android-toolchain action, as the
other Android workflows do.

Refs openclaw-9d4

* feat(iroh-ffi): cancel a single dial from Swift with a CancelToken

UniFFI 0.31.2 Swift async calls ignore Task cancellation, so a cancelled
Swift task left its dial running until the endpoint shut down. connect now
takes an optional CancelToken; cancelling it fails that dial with Cancelled
and keeps the endpoint usable. Kotlin coroutine cancellation already frees
the Rust future, so the token defaults to none.

Refs openclaw-9d4

* docs(iroh-ffi): state the Android bootstrap call in the README

Refs openclaw-9d4

* fix(iroh-ffi): pass the Application class descriptor as a JNI string

jni 0.22 takes class descriptors as JNIStr; a plain &str no longer
satisfies Desc<JClass>, so the Android library failed to compile.

Refs openclaw-9d4

* docs(iroh-ffi): forbid coroutine cancellation around native calls in Kotlin

UniFFI 0.31.2 lowers a future's result when it becomes ready; freeing the
future before the foreign side lifts it leaks that handle or buffer. Kotlin
callers therefore cancel with explicit native signals, like Swift.

Refs openclaw-9d4

* feat(iroh-ffi): cancel a single stream open or accept with a CancelToken

A blocked open_bi (no stream credit) or accept_bi could only be interrupted
by closing the connection. Both now take an optional CancelToken, so a
caller can abandon one wait while the shared connection keeps serving.

Refs openclaw-9d4

* ci(iroh-ffi): keep the Apple XCFramework as a short-lived workflow artifact

App integration tests need the full XCFramework, including the iOS simulator
slice, on hosts without the extra Rust targets. Retained for three days; not
a release.

Refs openclaw-9d4

* build(iroh-ffi): allow a macOS-only Apple build

The iOS slices fail to compile: netdev 0.46 (via iroh's netwatch) uses
libc::in6_ifreq, which libc defines only for macOS. OPENCLAW_IROH_APPLE_PLATFORMS=macos
builds the universal macOS slice alone so app work can proceed; the default
still builds every slice.

Refs openclaw-517.12

* docs(iroh-ffi): describe the opt-in Apple consumer contract

Refs openclaw-517.12

* build(iroh-ffi): pin libc 0.2.189 so the iOS slices build

netdev 0.46 (iroh 1.4.1 -> netwatch 0.19.3) uses libc::in6_ifreq on every
Apple target, and libc 0.2.190 limited that type to macOS. Lock libc at
0.2.189, the version n0's iroh-ffi v1.2.0 ships its iOS builds with.

scripts/check-pins.sh fails if the pin drifts while netdev 0.46.0-0.46.3 is
locked. A new audit workflow runs it and cargo-audit on lockfile changes
and weekly, since nothing else watches this crate's dependencies.

Refs openclaw-85d

* docs(iroh-ffi): clarify short-lived Apple CI artifact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant