Skip to content

fix(node): reconnect after OpenClaw ID server rotation - #194459

Merged
jalehman merged 10 commits into
mainfrom
fix/node-id-freshness
Nov 9, 2026
Merged

jalehman merged 10 commits into
mainfrom
fix/node-id-freshness

Conversation

@joshavant

@joshavant joshavant commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #193993, #193982

What Problem This Solves

Fixes: a saved OpenClaw ID node keeps dialing the Gateway server key it learned at enrollment, so it cannot reconnect after the Gateway honestly rotates that key.

User Impact

User impact: nodes refresh and verify the claw's current signed server authority and membership before every connection, follow an honest server-key rotation without rejoining, close a connection whose server key was replaced, and keep learned trust across restarts and refused rejoins. A node whose access was removed stops with a rejoin instruction, and the reason for any other refusal is printed once instead of a bare connection failure.

  • A preview target saved without a Discovery origin no longer breaks openclaw node config loading. It still never connects: the owner removes the node on the Access page, then it rejoins with a new link and --discovery-url, keeping its verified trust.
  • Reconnects now fail closed when Discovery is unreachable or serves stale evidence. A Discovery outage therefore interrupts node connections until it recovers. This is an intended tradeoff.
  • Pairing assumes the invitation stays secret. The six-digit comparison does not protect against a stolen invitation combined with control of pairing delivery.

Why This Change Was Made

Enrollment and reconnect share one node-signed Discovery client and descriptor verifier. Before each dial and periodic probe, the node verifies the binding, snapshot freshness and its own membership. The canonical SQLite writer saves the strongest binding, the membership order and the binding-retirement facts before any dial, without touching unrelated node settings. If that save fails, the node stops.

Rebased onto main after #193993. Its pre-mail re-enroll refusal, recovery-hint messages, loadNodeTunnelKey export and supervised foreground join are kept. Maintainer follow-up commits on top of Josh Avant's commit:

  • Signed trust from a Discovery response is saved even when the response's unsigned relay URL is invalid; that response is still never dialed. Before this fix, a later attempt could accept older evidence that was still fresh.
  • Preview targets without discoveryUrl load for an explicit-origin rejoin, but the runner refuses to dial them.
  • Refusal reasons reach the node operator: once per distinct reason, built locally, with no Discovery response text.
  • When Discovery refuses to serve a node's descriptor (403), for example after a removed node restarts, the host prints re-join guidance and keeps retrying without dialing. The refusal is unsigned, so it does not stop the host the way verified removal does.

Evidence

  • Regression tests, each red on the pre-fix code and green with the fix:
    • invalid relay URLs (ftp:, embedded credentials) keep binding 2 and snapshot 3, then refuse the older binding-1 evidence;
    • a preview SQLite row without discoveryUrl loads, refuses to dial, keeps stronger trust on a refused rejoin, and adopts the explicit origin on an admitted rejoin;
    • a refusal is reported once across repeated bridged requests;
    • an unsigned Discovery 403 prints re-join guidance and neither stops the host nor dials.
  • Focused suites pass on the final head: enrollment, join, connection, transport, target, SQLite config, runner and protocol freshness (107 tests).
  • The native node-host Gateway suite passes 6 of 7 with the real Linux iroh addon. The remaining case, both streaming transfer routes use the same private bridge (ECONNRESET), fails the same way on unmodified origin/main on the same host.
  • Other checks: pnpm tsgo:core, changed-file oxlint and format, git diff --check, the mock-export ratchet and knip pass. The test-line ratchet against origin/main passes with an exact allocation (+776, slack 0). deadcode:exports reports only untouched exports in src/daemon/launchd.ts and ui/.../dashboard-tools.tsx, so that failure comes from main.
  • An independent review found no P0 or P1 issues. Two findings were verified and fixed: refusal diagnostics (P2) and the preview-target recovery path, which conflicted with the re-enroll refusal (P3).
  • At 92bbf99, CI failed only checks-node-changed-12. Two update-command-resume-completion.test.ts cases failed because their Doctor fixture timed out (exit 124) under Bun. This PR does not touch that file, and it passes locally (11 of 11). At head 7863d1d, all CI checks pass, including checks-node-changed-12, Scan changed paths (precise), check-lint-core-2 and openclaw/ci-gate.
  • ClawSweeper's input scanner (TruffleHog URI detector) refused two synthetic https://user:…@ test fixtures: one added here and one already on main in openclaw-id-target.test.ts. Both fixtures now build their userinfo at runtime. A local TruffleHog scan of all changed files at 58ac569 reports 0 findings. That head changes only those two tests and the line allocation.

Live proof

The proof ran 7 of 7 steps green on build 92bbf99, against staging OpenClaw ID and Discovery with a throwaway claw.

  • Gateway: an isolated Gateway on the Mac Studio, with its own profile, state directory and port.
  • Owner: real Chromium.
  • Node: this PR's CLI on Linux, with env -i and isolated profiles.
  • Discovery: the node reached staging Discovery through a local untrusted proxy. In pass mode the proxy forwards node-signed requests unchanged. It can also corrupt the unsigned relay_url or replay an earlier captured response.
Step Result
Join Owner and node codes matched; the node connected over the tunnel with binding 1.
Honest rotation 1→2 while the node runs The Gateway restarted on a new key (iroh:3abd… → iroh:c952…). The same node ID reconnected in about 7 s without rejoining. system.which ran over the new connection. The saved target is binding 2 with the new key, snapshot seq 3.
Restarted node, replayed binding 1 (still fresh) Refused once: Possible claw substitution: rollback. No connection while the replay was served. The node connected once current evidence returned, without a restart.
(a) Rotation 2→3 served with relay ftp://… Refused: Discovery returned an invalid relay URL…, and nothing was dialed. The saved target advanced to binding 3 with the new key and kept the previous relay. A replay of binding 2 was then refused (rollback), and the node connected on current evidence.
(b) Preview target without discoveryUrl node run exits with the owner-removal and re-join guidance and makes no Discovery request. node join --discovery-url loads the profile, the owner approves, and the node connects. The saved target has the explicit origin and binding 3.
Verified removal The owner removed the running node on Access. The host stopped with OpenClaw ID node access was removed or is not admitted; re-join this node. A restarted node never connected.

Gaps:

  • No production rotation path. main has no Gateway command that rotates the server key. Proof-only plumbing stopped the isolated Gateway, generated a new endpoint key, and signed ServerBinding(seq+1) for it with the claw root from the throwaway recovery kit. The unmodified Gateway then republished on start.
  • Retiring a still-live old connection was not shown live. The old key went away with the restart, so this proof cannot separate retiring a still-live old connection from losing it. The transport tests cover that retirement.
  • The removed-restart guidance was fixed after this run. On 92bbf99 the restarted node retried silently on Discovery's 403. On 7863d1d, a rerun against the same removed node prints Discovery does not list this node for the claw; retrying. If the owner removed this node, re-join it with a new link. and does not dial.

Cleanup: the throwaway claw was retired from staging Discovery. The isolated Gateway was stopped, and its profile was backed up and removed. The local node profiles, proxy and secrets were removed, and the staging lock was released.

@clawsweeper

clawsweeper Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL labels Nov 7, 2026
@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. labels Nov 7, 2026
@joshavant
joshavant marked this pull request as ready for review November 7, 2026 04:49
@joshavant
joshavant requested a review from jalehman November 7, 2026 04:49
@joshavant
joshavant marked this pull request as draft November 7, 2026 05:11
@jalehman
jalehman force-pushed the openclaw-517/node-join branch 6 times, most recently 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 app: web-ui App: web-ui cli CLI command changes scripts Repository scripts agents Agent runtime and tooling plugin: openclaw-id-access labels Nov 9, 2026
@jalehman
jalehman force-pushed the fix/node-id-freshness branch from b697e1b to 92bbf99 Compare November 9, 2026 14:30
@openclaw-barnacle openclaw-barnacle Bot removed app: web-ui App: web-ui cli CLI command changes scripts Repository scripts agents Agent runtime and tooling plugin: openclaw-id-access labels Nov 9, 2026
@jalehman
jalehman marked this pull request as ready for review November 9, 2026 14:30
joshavant and others added 4 commits November 9, 2026 06:49
Refresh signed Discovery authority before every tunnel dial and periodic probe. Persist stronger binding and membership facts before acting, retain them on refused re-enrollment, and merge trust through the canonical SQLite owner.

Document invitation secrecy as the pairing threat-model limit. Verified with baseline regressions, isolated native transport and Gateway flows, SQLite durability, focused tests, targeted static checks, and independent review.
@jalehman
jalehman force-pushed the fix/node-id-freshness branch from 92bbf99 to 7863d1d Compare November 9, 2026 14:54
@jalehman

jalehman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman
jalehman force-pushed the fix/node-id-freshness branch from 7863d1d to 58ac569 Compare November 9, 2026 15:32
@jalehman

jalehman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman

jalehman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Landing note (maintainer): ClawSweeper could not review this PR, and that was not caused by anything in this PR's final code.

  • Why it could not run: both re-reviews were refused by its input scanner before review started (run at 7863d1d, run at 58ac569). The scanner reads the full history of every touched file (src/pr-review-history.ts, prefetchReviewHistory), not just the PR's commits.
  • What it flags: TruffleHog's URI detector matches the synthetic https://user:[email protected] fixture in src/node-host/openclaw-id-target.test.ts. That fixture has been on main since 21c02885 (feat(node-host): connect nodes over the OpenClaw ID tunnel #193982). It is not a credential.
  • Local evidence:
    • TruffleHog 3.97.1 over every historical blob of the changed files reports only URI matches. They are in openclaw-id-target.test.ts (on main since 21c02885) and in this PR's intermediate commits of openclaw-id-transport.test.ts.
    • TruffleHog over all changed files at head 58ac569 reports 0 findings: both fixtures now build their userinfo at runtime.
  • Review and proof without ClawSweeper:
    • An independent Astra review (read-only, high effort) found no P0 or P1 issues. Its P2 (refusal diagnostics) and P3 (preview-target recovery path) were verified and fixed.
    • The live staging proof passed 7 of 7 steps, as described in the PR body.
    • Exact-head CI at 58ac569 is green, including openclaw/ci-gate.
  • Decision: Josh Lehman authorized landing once the rebase, both P2 fixes, CI and the live proof were done; a ClawSweeper verdict was not one of his conditions. The scanner issue is tracked separately, because changing ClawSweeper's policy is up to its maintainer, not this PR.

@jalehman
jalehman merged commit 3e4e201 into main Nov 9, 2026
133 of 134 checks passed
@jalehman
jalehman deleted the fix/node-id-freshness branch November 9, 2026 15:55
@jalehman

jalehman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 10, 2026
* fix(node): refresh OpenClaw ID authority before reconnecting

Refresh signed Discovery authority before every tunnel dial and periodic probe. Persist stronger binding and membership facts before acting, retain them on refused re-enrollment, and merge trust through the canonical SQLite owner.

Document invitation secrecy as the pairing threat-model limit. Verified with baseline regressions, isolated native transport and Gateway flows, SQLite durability, focused tests, targeted static checks, and independent review.

* test(node): reset pre-mail admission fixture for rejoin refusal

* fix(node): keep verified OpenClaw ID trust when Discovery routing is invalid

* fix(node): let preview OpenClaw ID targets rejoin with an explicit Discovery origin

* test: size the node ID reconnect test allocation exactly

* test(node): document runner config mock isolation

* docs(node): route preview-target recovery through owner removal

* fix(node): report OpenClaw ID connection refusals to the node operator

* fix(node): explain an unsigned Discovery refusal of a removed node

* test(node): build synthetic userinfo URLs at runtime for the review scanner

---------

Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. docs Improvements or additions to documentation gateway Gateway runtime size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants