Repository navigation
refactor(gateway): retire the standalone node pairing store - #103120
Conversation
…legacy tokens in CLI JSON
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9df2a995b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (device.nodeSurface) { | ||
| continue; | ||
| } | ||
| device.nodeSurface = { |
There was a problem hiding this comment.
Preserve legacy node last-seen during migration
For upgraded gateways where an offline node only has lastSeenAtMs/lastSeenReason in the retired nodes/paired.json row, this migration archives that legacy file without copying those fields onto the device record. Current listNodePairing/node.list project last-seen from devices/paired.json, and new node.presence.alive writes go there, so existing offline nodes lose their persisted last-seen status until they reconnect or emit another presence event. Copy the legacy last-seen fields to the device record before archiving the old store.
Useful? React with 👍 / 👎.
|
Land-ready verification:
|
|
Landed as f5806d0 (squash). The standalone |
…#103120) * refactor(gateway): fold node pairing store into device records * docs+cli: retire standalone node pairing store references * test(infra): respec node pairing as device-backed surface approvals * test(infra): assemble migration token fixtures dynamically * fix(pairing): preserve node surface across device re-approval, strip legacy tokens in CLI JSON * test(gateway): drop retired node token from pairing fixtures * chore(protocol): regenerate Swift models, drop dead pairing-pending module
What Problem This Solves
Resolves the last piece of node-pairing duplication: OpenClaw kept two pairing stores for the same machines. Device pairing (
devices/paired.json) has gated the WS connect handshake since the TCP bridge was removed in January 2026, but the standalone gateway-owned node pairing store (nodes/{paired,pending}.json, "Option B") lived on — holding the approved capability surface plus a per-node token that nothing has consumed since the bridge died. Two stores meant duplicated rows for every node, duplicatedlastSeenwrites on every presence event, an entire cleanup-claim system reconciling the two, and two dead RPCs (node.pair.request,node.pair.verify) with no callers anywhere in core, apps, or the SDK.Why This Change Was Made
Six months after deprecation, the store is dropped and its one remaining job — the approved node capability surface with its pending re-approval queue — moves onto the paired device record (
PairedDevice.nodeSurface/pendingNodeSurface), behind the same store lock as device pairing.node-pairing.tskeeps its exported functions and semantics (pending reuse/supersede rules, cleanup-claim race guards, approval scope checks, rate-limit integration) but reads/writes device records; the standalone per-node token is deleted outright (node auth is the device pairing token). The shippednode.pair.list/approve/reject/remove+node.renameRPCs and theopenclaw nodesCLI keep their response shapes minus the token field, which the CLI only carried in order to delete it before output.node.pair.requestandnode.pair.verifyare removed from the protocol (no production caller existed; pending requests are created by the gateway during connects). A one-time startup migration — following therunStartupSessionMigrationprecedent — folds legacy rows into device records, drops orphans that no longer map to a node-role device (they cannot pass the WS handshake), and archives the files asnodes/*.json.migrated; a failed fold logs and retries next boot without blocking startup.Non-goals: no change to device pairing auth, silent/trusted-CIDR approval policy, node command gating semantics, or the Control UI.
User Impact
node.pair.list,node.list, the Control UI, and the CLI all read the device record, so approving/removing/renaming a node can no longer leave a stale twin in a second store.node.pair.request/node.pair.verifyRPCs had no clients.Evidence
src/infra/node-pairing.test.tsrespec'd against the device-backed store (13 tests: pending reuse/supersede, cleanup-claim races, approval scopes, rename, runtime metadata); newsrc/infra/node-pairing-migration.test.ts(fold, orphan drop,.migratedarchive, idempotence, token never crossing over, existing-surface precedence).tsgocore clean.node.pair.list/approve/rejectonly); iOS/Android have nonode.pair.*usage; gateway-client SDK exposes none.docs/gateway/pairing.mdrewritten for the folded store (removal notice for the two RPCs, new storage layout, migration note),docs/gateway/protocol.md,docs/refactor/database-first.md.pnpm check:changeddelegated to Blacksmith Testbox + Codex autoreview on the final branch state (results in PR discussion).