Repository navigation
feat(iroh-ffi): add uniffi bindings for the OpenClaw ID tunnel - #194174
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
47d9310 to
3113717
Compare
|
Codex review: needs maintainer review before merge. What this changesThis PR adds a standalone Rust transport crate with generated Swift/Kotlin bindings and Apple/Android build workflows. Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherNative 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]
Technical reviewBest 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. TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceTests +309, Docs +252, Config +195, Other +11895. Total +12651 across 25 files. Added test files: 1. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 9:56 AM ET / 14:56 UTC (Revision 2). |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
b7abc8d to
1b404a8
Compare
031aad5 to
69e19a5
Compare
1b404a8 to
a032fd8
Compare
69e19a5 to
7f9243b
Compare
a032fd8 to
52fc558
Compare
7f9243b to
b6765ac
Compare
52fc558 to
4c1be1f
Compare
b6765ac to
76878bb
Compare
4c1be1f to
87b4ea8
Compare
70d8109 to
7cf477a
Compare
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
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
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
76878bb to
f1adbdd
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…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
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 withNonCancellableand use the same explicit cancellation signals to avoid abandoning lowered results.libcstays pinned to 0.2.189 until follow-up openclaw-85d removes the incompatible iOS dependency path. The pin is guarded in CI and documented inPACKAGING.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 afterf1adbddcorrects 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: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.cbda14805e7c8f583c7760a84228b84f590c2c48780654934c60846c11d03bb3.Consumer-lane evidence is distinct from crate CI:
ee25eeaea9129b4999b59c4dc7e535be760858a1, based on this crate headf1adbdd. It builds matching bindings/macOS XCFramework and passes the native Swift → Rust loopback (1/1) and shared tests (25/25). This is macOS proof, not iOS runtime proof.d5f9459788221dc623e9b9f9e0ee778236f2ca61, based on this crate headf1adbdd..sobuilt at crate92c2506, whose ABI sources and generated bindings are unchanged atf1adbdd. This is prior-build evidence, not a freshly rebuilt exact-head JVM run or Android device proof.Independent read-only Astra landing review covered the complete 25-file diff from merge-base
d88a384060d6d0f55920fc0092877c58d128cc3etof1adbdd671ceb0219961d52d568d00ba7c688274, 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 passesgit 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).