Repository navigation
fix(openclaw-id): linked claw no longer mints new keys when its key files are lost - #196380
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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR prevents linked OpenClaw ID Gateways from replacing missing or mismatched machine keys and permits promotion only of staged keys named by their binding. Example: A linked Gateway restarts after openclaw-id/endpoint.key is deleted.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main identity bug, and the updated runtime evidence resolves the previous proof blocker; no new correctness findings remain, but the required CI gate is still red. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe OpenClaw ID service reads the persisted owner-signed binding, supplies its endpoint constraint to the supervised tunnel child, and uses its Gateway-key constraint for Discovery signing. flowchart TD
A[Stored signed binding] --> B[OpenClaw ID service]
B --> C[Gateway key loader]
B --> D[Tunnel supervisor]
D --> E[Native tunnel child]
C --> F[Bound key selection]
E --> F
F --> G[Use matching key or refuse]
Technical reviewBest possible solution: Land the bound-key selection and restart constraint after the inherited CI gate is handled through the repository’s landing policy. Do we have a high-confidence way to reproduce the issue? Current-main source creates missing keys without checking the stored binding, and the supplied regression evidence reports both lost-key Gateway cases failing on main; this review executed no target code. Is this the best way to solve the issue? The patch restores the binding invariant in the existing shared key loader and service, with justified extractions and a single retained endpoint constraint rather than a competing authority owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ecbad2efa1d7. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +278, Tests +458, Docs +8, Other +2. Total +746 across 24 files. Added test files: 3. 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. 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 (4 earlier review cycles)
Reviewed November 10, 2026, 12:00 PM ET / 17:00 UTC (Revision 5). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
e2e8df5 to
3c40bfb
Compare
|
@clawsweeper re-review |
…iles are lost (openclaw#196380) * fix(openclaw-id): keep a linked claw off its lost keys instead of minting new ones A linked claw's stored binding now names the only K_srv and K_gw it may use. When a key file is missing or holds another key, remote access stays off with keys_missing or key_mismatch, nothing is created, published or dialed with another key, and the Gateway keeps running for local use. A staged .next key is promoted only when its seed derives the bound key. * fix(openclaw-id): restart the tunnel child on the bound key while authority is withdrawn * test(openclaw-id): allocate test lines for the lost-key regressions * test(openclaw-id): size the lost-key test-line allocation to the change's growth * fix(openclaw-id): remember the K_srv a link commits for child restarts A Gateway that starts unlinked never read a binding, so if the authority was withdrawn after linking, before any restart read it, the next child start was the unlinked one. Recovery copy now says to restart after restoring the key files, and linkedClaw's key directories are removed after each test file. * fix(openclaw-id): constrain endpoint identity before initial link settlement
Related: #196138 (re-bind design, "Key files at every start")
What Problem This Solves
Fixes: a linked claw silently creates a new endpoint key or Gateway key when its key file is lost (disk loss, a restore that skipped
openclaw-id/, an accidental delete), then publishes and signs under keys its owner-signed server binding does not name, which strands every device.User Impact
User impact: when a linked claw's key file is missing or holds a different key, OpenClaw ID remote access stays off with status
keys_refused(key: endpoint | gateway,reason: keys_missing | key_mismatch). Nothing is created, published, signed or dialed with another key. The Gateway itself keeps running, so everything on the machine works as before. Restoring the original key file brings remote access back. The way to move a claw to new keys (openclaw id rebind) follows in a stacked PR. Unlinked Gateways create keys exactly as before.Why This Change Was Made
Once a claw is linked, its stored binding is the only record of which K_srv and K_gw are current. At every start the Gateway (for K_gw) and the tunnel child (for K_srv, via
expectedEndpointKeyin its start message) use the key file only when its seed derives the bound public key. Otherwise they promote a staged<file>.nextonly if its seed derives the bound key, so a planted file is never used, and if neither matches they refuse. The re-bind uses that.nextpromotion to finish an interrupted commit. The child exits with new codes 76/75, which the supervisor does not retry. The Gateway never reads the K_srv file.Owner decision for this fix: the Gateway is not blocked from starting, and nothing in startup or Doctor treats this state as fatal.
Notes for reviewers
claw-name-check.tsandservice-gateway-key.tsare extracted fromservice.ts(max-lines). Name-check behavior is unchanged, and the lifetime signal is still captured on admission.linkedClaw()now writes its K_gw seed into a per-claw state dir. Several existing tests relied on the bug, because the Gateway minted a key for a linked claw.Evidence
src/gateway/server.openclaw-id-keys.test.ts). A linked claw withgateway.keygone returnskeys_refused/gateway/keys_missing, with no key files created andhealthstill answering. Withendpoint.keygone, the real tunnel child returnskeys_refused/endpoint/keys_missingand creates no key. Both fail onmain(statuson, keys minted).fetch, no file, andpublish()→failed keys_missing. A local membership change is still accepted and stays pending for publication. Red onmain.keyfile.test.ts): match, staged match, missing, mismatch, and a planted staged key that is not promoted. Supervisor: 76/75 are not retried.linkedClawkey directories are tracked and removed after each test file (ClawSweeper P3).src/gateway/openclaw-idsuite green, plustsgo:core,tsgo:ui, oxlint and format. Inherited failure:server.auth.openclaw-id-node-host.test.ts"both streaming transfer routes use the same private bridge" fails identically onmainin this environment.Initial-link uncertain settlement correction
a71dce7addresses the new current-head P2: the initial link may be durable even when its acknowledgement and reconciliation read both fail. The service now retains the supervisor-reported running K_srv before awaiting link settlement, rather than only after a successful return. It does not trust caller-supplied binding data or restore withdrawn authority. A readable binding still wins; a refused link attempt conservatively retains the already-running endpoint constraint for that process. Fresh unlinked startups remain unchanged.The existing withdrawn-authority regression now covers both the initial-link and later-write cases. The initial case verifies the persisted binding, withdrawn authority and endpoint constraint delivered to the next child start. It fails on
3c40bfb(getter returns undefined) and passes with this change. Focused service/keyfile/name/real-Gateway lost-key suites: 5 files, 20/20 tests. Core typecheck, targeted type-aware lint, format, diff check and the test-lines ratchet pass. Fresh independent source review found no P0–P2 findings. The test matrix reuses the existing fixture; production repair moves one assignment before settlement without introducing another owner or state field.This regression reads the real service's restart-key getter with the native child mocked. The sibling real-Gateway tests exercise both lost key files, but the exact uncertain-initial-link path through an isolated real tunnel and stable upgrade is still an explicit proof gap, not claimed complete here. No deployment or merge.
Integrated staging acceptance and final cleanup — November 10
This closes the earlier pending same-claw staging run, not exact-head hosted CI or every PR-specific test gap. The isolated Gateway used combined source
f864514d93a08efda68c14eabc42768f081af854; the repaired registered CLI usedf08fea43c6979223ebf44f8b05020dd3033414ea. These are integrated proof refs, not the individual PR heads.studio-ui-rebind-v4-call-result.json).moved:true/published:true, and authenticated readback confirmed binding/published 4. Root, two owner certificates and membership remained intact (studio-cli4-owner-follow-call-result.json).system.which(uname)passed (studio-cli4-restart-call-result.json). This does not retroactively prove owner-browser following of each earlier rotation.snapshot_ahead, without advancing pin/freshness or connecting. This used an isolated signed HTTP fixture, not a malicious write to staging (studio-snapshot-ahead-native-result.json).readStoredClaw/publishClawused real old binding-3 SQLite and keys against staging: HTTP 409stale_bindingcarried binding 4, verified under the root, producing non-retryablebinding_superseded. Current-key authentication succeeded before/after; current Gateway/native/owner recovery then passed. This is persisted-state/publisher integration, not a full old-Gateway boot (studio-rollback3-publisher-result.json,studio-post-rollback4-recovery-call-result.json).Shipped older-writer limitation: the remotely verified latest stable
v2026.11.2and betav2026.11.5-beta.1examined here contain neithersrc/gateway/openclaw-idnorpackages/openclaw-id-protocol. A compatible shipped writer was not available in that bounded set, so a shipped-writer upgrade was not executed and cannot be claimed. This is not an exhaustive statement about every historical release. Seeshipped-old-writer-feasibility.json.Evidence files above are operator-local under
/tmp/ocid-rollout-evidence/, not downloadable GitHub attachments. Final receipts:studio-final-retirement-descriptor-result.json,studio-final-cleanup-result.json,studio-final-private-state-cleanup-result.json,studio-final-lock-release-result.json; full run chronology:studio-harness-integration-audit.md.For #196380 specifically, this combined run does not newly prove the exact uncertain-initial-link failure through a real tunnel; its existing focused regression and stated scope remain unchanged.
Current-main CI comparison and clean rebase — November 10
The prior UI failure is not classified as inherited. The latest scheduled main run 42844215728, at
da0190f377a8384223fca256990dae0a2bff2678, passed the exactchat-transcript-end-follow.browser.test.tscasepreserves clamp intent (settled, at end: true, movement: 8, before clamp: true)in 409 ms (job). Newer main push runs skipped this UI lane; their success is not test-execution evidence. The PR was therefore rebased without conflicts onto pinned current mainb21829a4c85fb685888538b3bc1369bfb5b36bd4, producing8d20985e878b4eef195e040ea0fef6425536566d. The complete PR patch has unchanged stable patch ID5081067f0443cbe4937af751d3392ecd95d1bf1a;git diff --checkpasses. The accepted independent full-PR review remains source-applicable; prior-head CI and integrated runtime proof retain their actual tested identities. New-head hosted CI is pending, not claimed green.The test-line failure is inherited budget debt, not an unallocated PR increase. Counts use the repository ratchet's literal LF-byte patterns and existing allocation; no ceiling or allocation was changed:
baccc7e1b21829a48d20985eIn both comparisons, PR test growth +458 = existing allocation +458, so the PR adds no debt. Running
node --import ./scripts/tsx.mjs scripts/check-test-lines-ratchet.mts --base b21829a4c85fb685888538b3bc1369bfb5b36bd4 --no-merge-baseon the rebased PR exits 1 with total 6,630,011, ceiling 6,629,991, overage 20 and net delta +458. This is an evidenced failure, not a waiver or passing gate. Local receipts:pr196380-budget-current-main.jsonandpr196380-rebased-test-lines.log. No merge or production deployment is authorized by this evidence update.Inspectable runtime evidence — November 10
The excerpts below supersede the earlier pending real-child proof note. Values are selected from retained terminal/JSON receipts; keys, IPs, tokens, emails, node/claw identifiers, private paths and non-public endpoints are omitted. Historical integrated runs retain their original revisions. No retired staging claw was recreated, and no personal profile was used.
Existing live run: bound signing and endpoint success
Combined Gateway source:
f864514d93a08efda68c14eabc42768f081af854. These are historical integrated-run observations, not a fresh exact-head deployment.Selected
studio-rollback3-publisher-result.json→remote.publisherfields:{ "passed": true, "currentKeyAuthenticatedBefore": true, "currentKeyAuthenticatedAfter": true, "publishedBindingUnchanged": true, "databaseWorkersClosed": true }The retained request sequence has HTTP statuses 200 → 409 → 200: current-key authentication, stale binding-3 publication refusal, current-key authentication again. Production
readStoredClaw/publishClawwere used; the refusal wasbinding_superseded,retryable:false, and the returned current binding was root-verified. This shows current-key signing/authentication succeeds while the retired publisher fails; it is not a full old-Gateway boot.Selected
studio-cli4-restart-call-result.jsonfields:{ "passed": true, "bindingSeq": 4, "publishedBindingSeq": 4, "nativePersisted4": true, "sameNativeNodeReconnected": true, "harmlessCommand": true, "sameOwnerReconnected": true, "bindingUnchanged": true, "cleanupConfirmed": true }Before reconnect, the verifier loaded the real node's production SQLite config and asserted persisted binding-4 evidence's
k_srvandk_gwequal the live Gateway's binding. Readback additionally confirms the persisted pin and keyed snapshot marker name that samek_gw. The saved native node then completed its real transport connection andsystem.whichrequest after a distinct Gateway process restart; the persistent owner browser also reconnected. This is end-to-end bound-key success, not a standalone claim that a protocol-only signature check opened a native endpoint.New exact-head local run: real child refuses mismatched current/staged keys before IP I/O
Source:
8d20985e878b4eef195e040ea0fef6425536566d. ProductionresolveRuntimeProcessEntrypointUrl("openclawIdTunnel"),resolveRuntimeWorkerArgv,tunnel-child/entry.tsand the realloadIrohBinding()addon were used. No mock child or mocked native binding. Loaded addon SHA-256:570ef4e7323a24b5afa373ec24abda7e89c7cee89367aef1333d7fa8e1d7d7e2(the observed binary, not an assertion about a reproducible rebuild).Redacted terminal output:
{"mode":"current","result":"passed","exitCode":75,"readyMessages":0} {"mode":"staged","result":"passed","exitCode":76,"readyMessages":0}key_mismatch), original file unchanged, no ready message..nextseed is present. Exit 76 (keys_missing), staged file unchanged, no promotion/current-key creation, no ready message.strace -f -e trace=networkcaptured parent and native child threads. Zero AF_INET/AF_INET6 syscall lines in each complete trace; the captured network calls are local IPC, not IP tunnel I/O.New exact-head local run: uncertain initial-link persistence followed by a real native child restart
Same exact source and native binary as above. The production service, authority, tunnel runtime, supervisor and native child ran unchanged. Only persistence was fault-injected through the authority's store interface: write the JSON record to the throwaway profile, then throw the acknowledgement error; the reconciliation read also throws. This is a real on-disk write with injected acknowledgement/read failure, not a SQLite crash/durability qualification or full Gateway-process restart. Unrelated membership side effects were inert fixture callbacks.
Procedure: start genuinely unlinked; let the native child bind and report its running endpoint; create valid owner-signed initial-link statements for that endpoint; call production
service.commitLink; observe the persisted binding and withdrawn authority; place nonmatching current and staged seeds in the isolated profile; kill only the owned native child; let the unchanged production supervisor restart it.Redacted terminal output:
{ "mode": "uncertain", "result": "passed", "persistedBindingMatchesRunningKey": true, "authorityWithdrawn": true, "failedAcks": 1, "failedReads": 1, "restartStatus": {"state":"keys_refused","key":"endpoint","reason":"key_mismatch"}, "readyCount": 1, "wrongKeyNotAdopted": true }strace -f -e trace=network,processsaw two real child execs. Descendant threads were attributed through traced clone/fork edges:The initial child's successful ready event is the only ready event. The restarted child exits at key refusal, does not bind another endpoint, and leaves the planted key unchanged. The authority remains withdrawn; the service's retained running-key constraint is what prevents an unlinked start. Owned service/children were stopped at run end; product source and historical proof refs were not changed.
Older shipped-writer upgrade: not applicable to these unshipped paths. No compatible shipped writer is available for this feature; the bounded stable/beta inspection above is the verified release evidence, not a fabricated shipped-upgrade run. Preview-writer SQLite migration is being qualified separately under #196402.
Exact-head CI is terminal, with inherited debt
CI run 42854952850 completed for head
8d20985e878b4eef195e040ea0fef6425536566d. The only root failure is test-line budget;openclaw/ci-gatereports that failure. The other CI jobs, including UI, are terminal without a failure.CI used base
53aed90ae4c7522f5dae79c6b6d6cb4f0fccf551, merged8b78d23d0604a63aad29642abd6346131571ef2. Its log reports:Independent LF-byte recount of that exact base: 6,631,022 lines / 6,631,002 ceiling = 20 debt. The PR contributes +458 lines / +458 existing allocation, preserving the same debt. No budget adjustment, waiver or green-CI claim. Hosted reassessment and explicit merge authorization remain required.