Skip to content

fix(apple): follow an OpenClaw ID re-bind; J5 binding_seq cap; re-verify on redial - #196445

Merged
jalehman merged 9 commits into
mainfrom
fix/ocid-apple-rebind-trust
Nov 12, 2026
Merged

jalehman merged 9 commits into
mainfrom
fix/ocid-apple-rebind-trust

Conversation

@jalehman

@jalehman jalehman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #194201 (Apple OpenClaw ID node foundation, landed as 5fdbae53e443), #196402 (protocol: clients follow a re-bind), #196759 (Mac enrollment app wiring, stacked on this)

What Problem This Solves

Apple nodes on the OpenClaw ID foundation stop connecting after an owner uses "Move to new keys": the replacement key's snapshots are refused as replays, and the tunnel keeps dialing the original server key. A retired Gateway signing key can also inflate a snapshot's binding number and lock the node out.

User Impact

No user-visible change on its own; this is the shared foundation that app wiring (#196759) uses. Once wired, an Apple node follows a Gateway re-bind and reconnects to the new server key without a new invite, and a retired or compromised Gateway signing key can no longer lock it out or keep receiving its traffic.

Migration note: this amends the unshipped apple-node-enrollments-v1 schema in place (nullable snapshot_gateway_key on openclaw_id_node_targets). Pre-release development stores must be recreated and the node re-enrolled; nothing is reset automatically.

Why This Change Was Made

Ports the re-bind rules from #196402 into the Swift node:

  • Snapshot order is recorded per Gateway signing key. A new key replaces the marker only under a newer root-signed binding.
  • Binding cap (J5): a snapshot whose binding_seq exceeds the verified root-signed binding is refused without retaining any of its facts. The root-verified binding pin is still saved, but no dial route is stored. (feat(apple): add opt-in OpenClaw ID node foundation #194201 now carries the same cap for its own code.)
  • Legacy keyless markers are clamped to their verified binding; snapshot order that cannot be tied to a signing key is discarded.
  • The tunnel re-verifies the server key before every dial. Reconnects and liveness probes refresh one at a time, and every pending caller waits for a checked installation. A newer key retires the old connection, and a stream that opens late on a retired connection is reset.
  • If a refresh is refused, the published key is cleared and any active connection retired, because a newer binding may already be pinned. A pending dial to the old key cannot install.
  • Only the current server key can report the node removed; a superseded server cannot disable the replacement binding.
  • Unsigned Discovery 403 responses stay retryable; they do not prove the node was removed.

Accepted tradeoff: after keyless order is discarded, an otherwise valid older snapshot can pass within the existing ≤3-hour freshness window until a keyed marker is stored.

Evidence

Head 66b36c047d4f, rebased onto main after #194201 landed as 5fdbae53e443, plus one comment-only commit dropping a Periphery ignore that became superfluous (the trust state initializer is now used in-module). The 8 restacked commits are patch-identical to the previously tested head (diff of diffs empty), whose Swift sources and tests matched the Mac-proven head e33a97b4ffc0; between those heads the only changes are comment lines (Periphery ignore commands) and a CI workflow line inherited from #194201. The first 7 commits match the earlier head d44a16557b1f; the 8th fixes two findings from this pass's review (below).

  • Mac Studio, isolated (Swift 6.4.2, macOS 27.2): the exact-head source was built, then tests ran under sandbox-exec with network, the real home directory, Keychain/preferences IPC, launchctl and open denied. Shared OpenClawIDNode suites 39/39 passed, five consecutive runs; macOS bridge suites 20/20 passed. Tested source and test file hashes match this head's tree. No installed app, Keychain or profile was touched.
  • New regressions, red then green: on the previous tunnel source (927e83b) with the new tests, both fail in three consecutive runs. A refused refresh revokes a pending dial to the previous key: the old dial installed and returned a stream. A superseded key cannot report the node removed: the tunnel shut down with .removed. Both pass with the fix. The removal test holds the old dial's admission timer, so it cannot pass via the timer path.
  • Review: a fresh independent full-diff Astra review of 927e83b reported one P1 (a refused refresh left the old key installable) and one P2 (a superseded key could mark the node removed). Both were verified in source and fixed. A delta re-review found no production defects in the fix. It flagged one test-strength issue (the removal test could pass on a timer race), which is now fixed and re-proven red/green. The review also confirmed the feat(apple): add opt-in OpenClaw ID node foundation #194201 binding-cap gap is closed, including persistence and reopen.
  • CI: the exact-head apple-node-native workflow and broad CI are linked in this head's checks.

Live evidence

Signed Personal Team build 2611000399 ran on a Mac Studio on 2026-11-11 against a real Gateway over OpenClaw ID. It included this PR's earlier head as part of #196759, plus fixes from #197421 (now in #197585) and the macOS packaging fix #197383 (f817a8b). It showed enrollment via invite and owner approval, keys in the Keychain, relaunch with the same node identity, a tunnel connection (relay, then direct) and the dashboard proxy.

Limits: no re-bind was performed on a real device, so this PR's main behavior has no live evidence. The build predates the last commit here and includes changes outside this PR. Also not covered: sleep/wake, network change, in-place app update, TCC prompts, Intel Macs, iOS.

Known gaps

  • Re-bind following is proven only by package tests (signed fixtures, SQLite reopen, controlled dial overlap), not on a device against a Gateway that actually re-binds.
  • The refused-refresh regression mocks the refresh boundary. Durable pin persistence on refusal is covered separately by the enrollment tests.
  • Intel runtime is cross-built only; iOS runtime is unproven.
  • The two SwiftLint size advisories carried from feat(apple): add opt-in OpenClaw ID node foundation #194201 remain; OpenClawIDNodeEnrollmentTests is larger here.

@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 105a012bb0ae084eda3e7c8df6333c54a7817b1d, but the PR head is now d44a16557b1fd2663f3c5d7ab1b2e2de12201829. 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:03:46.711Z sha 105a012bb0ae084eda3e7c8df6333c54a7817b1d :: needs real behavior proof before merge. :: [P2] Preserve the verified binding when no previous row exists | [P3] Correct the claim that app refresh wiring is implemented

@jalehman
jalehman force-pushed the fix/ocid-apple-rebind-trust branch from 0fa1bb0 to e32d769 Compare November 10, 2026 08:30
@jalehman
jalehman force-pushed the fix/ocid-apple-rebind-trust branch from e32d769 to 7b4134a Compare November 10, 2026 15:06
@jalehman
jalehman force-pushed the fix/ocid-apple-rebind-trust branch from 7b4134a to fa8e9be Compare November 10, 2026 17:35
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 10, 2026
@jalehman
jalehman force-pushed the fix/ocid-apple-rebind-trust branch 2 times, most recently from 7cec6bd to d44a165 Compare November 10, 2026 20:44
@jalehman
jalehman force-pushed the openclaw-517/node-apple branch from 7c97d92 to f7d7aec Compare November 10, 2026 20:44
@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. labels Nov 11, 2026
@jalehman
jalehman force-pushed the fix/ocid-apple-rebind-trust branch 4 times, most recently from fdc88a4 to 5960801 Compare November 12, 2026 10:03
Base automatically changed from openclaw-517/node-apple to main November 12, 2026 10:37
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: XL and removed size: L labels Nov 12, 2026
…se binding_seq (J5)

Snapshot order is kept per K_gw, so a re-bind's new key is not refused as a
replay, and a commit under a new key needs a newer verified binding. A snapshot
naming a binding_seq beyond its verified binding is refused and only the
binding's pin advance is kept; a keyless stored row is capped at the pin and
loses its order on load. The tunnel re-verifies K_srv before every dial.
… key

K_srv refreshes from reconnects and liveness probes run one at a time, in
commit order. A dial whose key a newer refresh replaced is closed instead of
installed, and a probe that verifies a newer key retires the active connection.
…erseded

A refused server-key refresh may already have pinned a newer binding, so it now
clears the published key and retires any active connection; a pending dial to the
previous key can no longer install. A close from a superseded key no longer marks
the node removed and disables the replacement binding.
@jalehman
jalehman force-pushed the fix/ocid-apple-rebind-trust branch from 5960801 to 6058cf0 Compare November 12, 2026 10:38
@openclaw-barnacle openclaw-barnacle Bot added size: L and removed scripts Repository scripts size: XL labels Nov 12, 2026
@jalehman
jalehman marked this pull request as ready for review November 12, 2026 10:39
…y ignore

Re-bind verification now constructs trust state in-module, so the initializer is used.
@jalehman
jalehman merged commit 5dd83ba into main Nov 12, 2026
81 of 83 checks passed
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@jalehman
jalehman deleted the fix/ocid-apple-rebind-trust branch November 12, 2026 11:39
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 13, 2026
…ify on redial (openclaw#196445)

* fix(apple): follow an OpenClaw ID re-bind; only verified bindings raise binding_seq (J5)

Snapshot order is kept per K_gw, so a re-bind's new key is not refused as a
replay, and a commit under a new key needs a newer verified binding. A snapshot
naming a binding_seq beyond its verified binding is refused and only the
binding's pin advance is kept; a keyless stored row is capped at the pin and
loses its order on load. The tunnel re-verifies K_srv before every dial.

* test(apple): expect the retired binding's refusal from assess itself

* fix(apple): never keep or install a connection to a superseded server key

K_srv refreshes from reconnects and liveness probes run one at a time, in
commit order. A dial whose key a newer refresh replaced is closed instead of
installed, and a probe that verifies a newer key retires the active connection.

* fix(openclaw-id): retain the first verified Apple binding pin on snapshot refusal

* fix(openclaw-id): let every Apple stream caller join verified connection installation

* test: isolate Apple rebind state and document keyed trust

* style(apple): normalize rebind Swift formatting

* fix(apple): revoke stale tunnel keys when a refresh is refused or superseded

A refused server-key refresh may already have pinned a newer binding, so it now
clears the published key and retires any active connection; a pending dial to the
previous key can no longer install. A close from a superseded key no longer marks
the node removed and disables the replacement binding.

* chore(apple): drop the trust state initializer's superfluous Periphery ignore

Re-bind verification now constructs trust state in-module, so the initializer is used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: macos App: macos docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant