Skip to content

fix(android): follow an OpenClaw ID re-bind; J5 binding_seq cap - #196442

Draft
jalehman wants to merge 4 commits into
openclaw-517/node-androidfrom
fix/ocid-android-rebind-trust
Draft

jalehman wants to merge 4 commits into
openclaw-517/node-androidfrom
fix/ocid-android-rebind-trust

Conversation

@jalehman

@jalehman jalehman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: an Android OpenClaw ID node stops connecting for good after its claw is moved to new keys, or after a stolen or retired Gateway key signs a snapshot with an inflated binding number.

User Impact

This prepares Android node trust handling for an owner's "Move to new keys" and prevents a retired Gateway key from poisoning binding freshness. Device enrollment, reconnect and upgrade qualification remain incomplete; this draft does not establish a release-ready native-app experience.

Summary

The Android OpenClaw ID node now handles a claw's re-bind ("Move to new keys"), plus the J5 binding_seq cap. It is stacked on the #194194 draft branch.

Why This Change Was Made

  • Ordering: a re-bind changes K_gw. Android ordered every snapshot against one global marker, so the new key's snapshots (seq restarted) were refused as snapshot_replayed forever.
  • J5: a snapshot's K_gw-signed binding_seq could raise the durable high-water past any binding R had signed. That let a stolen or retired K_gw lock the node out permanently with stale_binding.
  • 403: Discovery's unsigned 403 on refresh was treated as verified removal.

Changes

  • Per-key order: the snapshot marker records its K_gw. A new key restarts the order only under a newer R-verified binding.
  • J5 refusal: a snapshot naming binding_seq beyond its verified binding is refused as snapshot_ahead, and none of it is stored.
  • J5 stored value: the stored snapshotBinding is always a verified binding's seq.
  • Legacy markers: a marker with no key, saved by the previous build, is capped at the pin and loses its order on load (clampLegacy), matching the TS clampFreshnessState (fix(openclaw-id): clients follow a re-bind, and a stolen Gateway key can't retire bindings #196402).
  • 403: a refresh 403 is now a retryable OpenClawIdDiscoveryFailure. Only a verified snapshot that no longer lists the node means removal.

Evidence

November 10 restack: current head caa4386438847d15c2c818d2f45f41999d1e3057 is based on repaired parent 9894edf0d4a3dfabe52923f2e4123dd9bd64ce26, after both parent native packaging runs passed. Rebased only the four follow-up commits from their verified old parent 2d4ba2aaaef4cfd659b561940dc25ac7cdeadec7; no conflicts, range-diff 4/4 =, and git diff --check passed. Published with an exact expected-head lease. No substantive follow-up patch changed; this is not a new whole-PR review. Exact-head native packaging passed at caa4386438847d15c2c818d2f45f41999d1e3057. Terminal logs confirm testPlayDebugUnitTest and testThirdPartyDebugUnitTest executed and both default and opt-in Gradle builds succeeded. Workflow checks verified the default APK excludes iroh and both opt-in debug variants contain all four native ABIs. Workflow Sanity and PR evidence checks also passed; broad CI remains skipped for this draft. This is build/unit-test/packaging proof, not device runtime, release/R8, enrollment-to-Gateway or stable-upgrade qualification. Earlier-head results below remain evidence only for their named revisions.

OpenClawIdTrustRebindTest covers:

  • an inflated old-K_gw snapshot is refused and its state is not stored, and an honest re-bind is then dialed;
  • a new key at a lower seq is accepted under binding 2, its own replays are still refused, and the retired binding gets binding_rollback without moving the marker;
  • a legacy stored marker (binding 9, seq 50) loads clamped, and a re-bind is then dialed. Before the fix this was refused forever.

Validation runs in this PR's Android OpenClaw ID native packaging workflow (testPlayDebugUnitTest and testThirdPartyDebugUnitTest). This host has no Android SDK.

OpenClawIdRefreshOutcomeTest now exercises the production controller refresh → real Discovery request signing/HTTP decoding → signature verifier → persistent store. Only HTTP I/O is fixed with an OkHttp interceptor; no callback supplies an assessment. The forwarding-only refreshTarget helper and tests are removed. It covers unsigned 403/404/500/503/network failure without retained-state changes; signed removal persisted before the removal exception; reopen/replay rejection; honest newer admission; and snapshot-ahead refusal without poisoning trust. Serialized store reopening is covered, not Android Keystore runtime behavior. Request-signing execution is covered; the fixture checks header presence, not an independent cryptographic signature oracle.

Prior repair evidence at b51054d. The Android OpenClaw ID native packaging workflow completed successfully on exact head b51054ddb0c474c7935d8ce230613885be3860fd. Its logs show both testPlayDebugUnitTest and testThirdPartyDebugUnitTest executed, plus default/native APK packaging checks. Fresh independent source review of the repair reported no P0–P2 issues; Kotlin formatting passed. This host has no Android SDK. Hosted unit tests do not prove device Keystore, enrollment-to-Gateway runtime, or stable upgrades. The parent must still be qualified and merged before this follow-up can land. Native parent CI is now green and the authorized pre-merge restack is recorded below; another post-merge restack, fresh review and exact-head CI remain required before landing.

Native-app runtime and stable-upgrade proof remain incomplete. Legacy tradeoff: a keyless marker loses unattributable snapshot order on load, allowing otherwise-valid older snapshots within the existing ≤3-hour freshness window until keyed order is stored again.

Review fixes, ddee805:

  • Removed a duplicate JsonObject import that broke compilePlayDebugKotlin.
  • Aligned two trust tests with J5. A snapshot claiming an unverified binding is now snapshot_ahead and not kept; the old test expected it to become retirement evidence. A retired binding below the pin is binding_rollback.

@clawsweeper

clawsweeper Bot commented Nov 10, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head fa9e2f441fa02946c4efd222ae7ac5b2a5b99440, but the PR head is now caa4386438847d15c2c818d2f45f41999d1e3057. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-10T05:04:42.775Z sha fa9e2f4 :: needs real behavior proof before merge. :: [P1] Remove the duplicate JsonObject import | [P2] Update the existing regression for the J5 refusal contract | [P2] Expect binding_rollback for the retired binding | [P2] Exercise refresh without introducing a test-only callback seam

…aise binding_seq (J5)

Snapshot order is kept per K_gw, so a re-bind's new key is not refused as a
replay. A snapshot naming a binding_seq beyond its verified binding is refused
as snapshot_ahead and none of it is stored; a marker saved by the previous
build is capped at the pin and loses its order on load. Discovery's unsigned
403 on refresh is a retryable failure, not removal.
…ified snapshot is removal

The refresh outcome is a pure companion function, tested without Discovery.
A snapshot claiming an unverified binding is snapshot_ahead and not kept, and
a retired binding below the pin is binding_rollback.
@jalehman
jalehman force-pushed the fix/ocid-android-rebind-trust branch from b51054d to caa4386 Compare November 10, 2026 09:12
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android P2 Normal backlog priority with limited blast radius. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant