Skip to content

fix(openclaw-id): clients follow a re-bind, and a stolen Gateway key can't retire bindings - #196402

Merged
jalehman merged 7 commits into
mainfrom
fix/ocid-freshness-per-kgw
Nov 10, 2026
Merged

jalehman merged 7 commits into
mainfrom
fix/ocid-freshness-per-kgw

Conversation

@jalehman

@jalehman jalehman commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Related: #196138 (re-bind design, statements.md "Freshness"), #196388 (re-bind ceremony)

What Problem This Solves

Fixes: after an OpenClaw ID claw moves to new keys, clients could refuse its honest snapshots as replays (snapshot_replayed) whenever the retired Gateway key had signed a snapshot with an inflated seq or a later issued_at. A stolen key can do exactly that before the owner re-binds.

User Impact

User impact: browsers (through the vendored protocol), node hosts and native apps follow a re-bind to a new Gateway key without being stuck refusing its snapshots. Rollback protection stays the same: the binding_seq high-water carries across the key change, so the old binding and its key's snapshots are still refused.

Why This Change Was Made

J5 (decided): only R-signed bindings the client verified raise its binding_seq high-water. A snapshot naming a binding_seq above the binding it verified under is refused with snapshot_ahead, and nothing of it is stored. Before this change, mergeFreshnessState stored the snapshot's claimed binding_seq, so a stolen K_gw could make every binding stale_binding forever. J1 always replaces K_gw, so an honest K_gw never names a binding beyond its own. With the cap, the per-key order switch uses the verified binding_seq alone, and the separate k_gw_binding_seq field from the earlier review fix is gone. On load, clampFreshnessState migrates only legacy markers, the ones without k_gw: their binding_seq is capped at the pin, and their (seq, issued_at) is dropped because it can't be attributed to a key. Node hosts do this on parse, and the loader in claw-loader#12. Markers with k_gw are kept as stored, because their binding_seq is always a binding this client verified, even when the pin didn't advance (review P1s). Accepted edge case: right after the upgrade, older snapshots of the current key aren't refused as replays until a new marker is stored. This lasts at most the 3 h freshness window.

Compatibility: a Gateway on current main or the previous build always signs snapshots at its own binding_seq (1). Discovery refuses a snapshot for a binding it doesn't publish, so snapshot_ahead cannot occur for them. After a re-bind, a snapshot read between descriptor writes is signed by the new K_gw and fails verification under the old binding (snapshot_invalid, transient), not snapshot_ahead.

The freshness marker records the K_gw that signed the accepted snapshot. Snapshots are ordered only among those signed by the same K_gw; a higher verified R-signed binding permits switching keys. Only verified bindings raise the retained binding high-water. The separate k_gw_binding_seq field is not part of the final implementation. Node hosts persist the keyed marker. Legacy keyless markers are capped at the pin and have their unattributable order dropped on load, as described above.

Accepted upgrade tradeoff: until a keyed marker is stored again, otherwise-valid older snapshots can pass within the existing ≤3-hour freshness window. Live real-tunnel and stable-upgrade proof remain outstanding; helper and compatibility checks do not close those gates.

Evidence

  • J5: an inflated snapshot is refused and the stored state is unchanged; the honest binding then dials (protocol, node host transport). A legacy inflated high-water is capped on load and its order is dropped. A retired key's inflated legacy seq no longer blocks the replacement key after a J1 re-bind; this test fails on the previous clamp. A keyed marker is never clamped. The honest J1 re-bind path still passes.

  • freshness.test.ts: a retired key's inflated snapshot followed by a re-bind → the new key's snapshot is fresh. Order then continues within the new key (an older one is snapshot_replayed), and the old binding is still stale_binding. The new test and the two marker-shape tests fail on main.

  • Independent review: a retired key's snapshot claiming the next binding could keep the marker on the old key and let Discovery replay the new key's older snapshots. Fixed, and the regression fails before the fix.

  • openclaw-id-target.test.ts: the saved marker keeps a valid k_gw and refuses a malformed one.

  • Node host transport, target and join suites are green, including "retains rollback evidence across restart". tsgo:core, oxlint and format are clean.

  • Discovery restarts order the same way (openclaw/discovery#11). The loader and native apps pick this up when they re-vendor the protocol.

J5 compatibility with existing Gateways (executed)

Honest histories were signed by the publisher and protocol code of current main (a2fdc8d4cf08) and of the previous main build (245cbaf915c2). Each was taken from that ref with git archive and drives publishClaw with a capturing Discovery client. The history covers a link at binding 1, an hourly republish, a membership change (snapshot seq 2→3), an honest K_srv rotation to binding 2 signed by R, and a republish. Each old build's own assessFreshness also recorded the state it stores after every step, which is the legacy unkeyed marker.

The new client code (openclaw 95bc5e5 freshness, and claw-loader 55e799a vendored protocol, which is identical) then:

  • A. checks every binding with verifyBindingForPin and runs assessFreshness from an empty store;
  • B. for each step, loads the old client's saved marker through clampFreshnessState(state, pin.binding_seq), checks it was clamped only as designed (binding_seq unchanged, order dropped, no k_gw), and continues through the remaining steps.

Result (both producers emitted byte-identical evidence):

out-245cbaf-loader.txt: 15 verdicts ok fresh, 0 failures, 4 legacy loads clamped as designed
out-245cbaf-openclaw.txt: 15 verdicts ok fresh, 0 failures, 4 legacy loads clamped as designed
out-origin-main-loader.txt: 15 verdicts ok fresh, 0 failures, 4 legacy loads clamped as designed
out-origin-main-openclaw.txt: 15 verdicts ok fresh, 0 failures, 4 legacy loads clamped as designed

There were no snapshot_ahead verdicts and no refusals. Every loaded legacy marker kept its binding_seq: honest markers never exceed the pin, so the cap is a no-op. Only the unattributable (seq, issued_at) order was dropped, and the next honest snapshot restored a keyed marker.

produce.mts (run inside each archived ref)
// Honest Gateway history signed by THIS tree's own code (publisher.ts publishClaw + protocol),
// and the freshness state THIS tree's client code stores after each step.
import { publishClaw } from "./src/gateway/openclaw-id/publisher.ts";
import { assessFreshness } from "./packages/openclaw-id-protocol/src/freshness/freshness.ts";
import { signStatement } from "./packages/openclaw-id-protocol/src/index.ts";
import { buildWorld, certBody, signChange, mustApply, WORLD_NOW, worldKey } from "./packages/openclaw-id-protocol/src/testing/world.ts";

const w = await buildWorld();
const steps: { label: string; binding: unknown; snapshot: unknown; at: number; oldState: unknown; oldVerdict: unknown }[] = [];
let state = w.state;
let binding = w.binding;
let t = WORLD_NOW;
let stored: unknown = null;
const realNow = Date.now;
async function publish(label: string) {
  Date.now = () => t * 1000;
  let snap: unknown;
  const client = {
    registerClaw: async () => ({ owner_account_id: "acct-owner" }),
    publishDescriptor: async () => {},
    publishSnapshot: async (_id: string, s: unknown) => { snap = s; },
  };
  const out = await publishClaw({
    record: { claw_id: w.state.claw_id, authority: state, binding,
      discovery: { owner_account_id: "acct-owner", published_binding_seq: binding.body.binding_seq } } as never,
    relayUrl: "https://relay.example/", client: client as never, signer: w.gateway.signer,
  });
  Date.now = realNow;
  if (out.state !== "published") throw new Error(`${label}: ${JSON.stringify(out)}`);
  const a = await assessFreshness({ snapshot: snap }, { binding: binding.body, stored: stored as never, now: t + 5, policy: "enforce" });
  stored = a.state;
  steps.push({ label, binding, snapshot: snap, at: t + 5, oldState: a.state, oldVerdict: a.verdict });
}
await publish("link: binding 1, membership seq 2");
t += 1800; await publish("hourly republish (same seq, newer issued_at)");
const d3 = await worldKey("device-3");
const cert3 = await signStatement("OwnerDeviceCert", certBody(d3), w.device1.signer);
state = await mustApply(state, await signChange(state, w.device1.signer, { op: "add_owner_device", cert: cert3 }), "tunnel");
t += 600; await publish("membership change");
// Honest K_srv rotation: owner R signs binding 2 with the same K_gw (what old Gateways can do).
const srv2 = await worldKey("server-2");
binding = await signStatement("ServerBinding", { ...w.binding.body, k_srv: srv2.peer, binding_seq: 2, issued_at: t }, w.root);
t += 60; await publish("K_srv rotation: binding 2");
t += 3000; await publish("republish at binding 2");
console.log(JSON.stringify({ rootPub: w.rootPub, steps }));
consume.mts (new code)
// J5 compatibility: honest history signed by old Gateway builds, read by the new client code.
// usage: tsx consume.mts <producer.json> <path to new protocol src/index.ts>
import { readFileSync } from "node:fs";
const [file, impl] = process.argv.slice(2);
const p = await import(impl!);
const { steps, rootPub } = JSON.parse(readFileSync(file!, "utf8"));
const host = steps[0].binding.body.hostname;
let failures = 0;
const show = (o: unknown) => JSON.stringify(o);
async function verified(i: number, pin: any) {
  const check = await p.verifyBindingForPin(
    { root_pub: rootPub, binding: steps[i].binding }, pin, { host, now: steps[i].at });
  if (!check.ok) throw new Error(`binding ${i}: ${show(check)}`);
  return check;
}
async function run(from: number, stored: any, pin: any, label: string) {
  for (let i = from; i < steps.length; i++) {
    const check = await verified(i, pin);
    pin = check.pin;
    const a = await p.assessFreshness({ snapshot: steps[i].snapshot },
      { binding: check.binding, stored, now: steps[i].at, policy: "enforce" });
    const ok = a.verdict.ok && a.verdict.fresh;
    if (!ok) failures++;
    console.log(`  ${label} step ${i} (${steps[i].label}): ${ok ? "ok fresh" : "FAIL " + show(a.verdict)} -> ${show(a.state.snapshot)}`);
    stored = a.state;
  }
}
const rootFp = await p.fingerprint(rootPub);
const firstPin = { claw_id: steps[0].binding.body.claw_id, root_fp: rootFp, binding_seq: 0 };
console.log("A. new client from scratch");
await run(0, null, firstPin, "new");
console.log("B. state saved by the old client, loaded by the new one (clamp on load), then continued");
for (let i = 0; i < steps.length - 1; i++) {
  const legacy = steps[i].oldState;
  const pinSeq = steps[i].binding.body.binding_seq;
  const loaded = p.clampFreshnessState(legacy, pinSeq);
  const asDesigned = loaded.snapshot.binding_seq === legacy.snapshot.binding_seq &&
    loaded.snapshot.seq === 0 && loaded.snapshot.issued_at === 0 && loaded.snapshot.k_gw === undefined;
  if (!asDesigned) failures++;
  console.log(` old state after step ${i}: ${show(legacy.snapshot)} -> loaded ${show(loaded.snapshot)} (pin ${pinSeq}) ${asDesigned ? "binding_seq kept, order dropped" : "UNEXPECTED"}`);
  const pin = { ...firstPin, binding_seq: pinSeq, k_gw: steps[i].binding.body.k_gw };
  await run(i + 1, loaded, pin, "upgraded");
}
console.log(failures ? `FAILURES: ${failures}` : "all verdicts ok fresh; no snapshot_ahead; stored state clamped only as designed");
process.exit(failures ? 1 : 0);
Output: producer main, consumer openclaw 95bc5e5 (the other three runs are identical)
A. new client from scratch
  new step 0 (link: binding 1, membership seq 2): ok fresh -> {"seq":2,"issued_at":1793318400,"binding_seq":1,"k_gw":"ed25519:d050…"}
  new step 1 (hourly republish (same seq, newer issued_at)): ok fresh -> {"seq":2,"issued_at":1793320200,"binding_seq":1,"k_gw":"ed25519:d050…"}
  new step 2 (membership change): ok fresh -> {"seq":3,"issued_at":1793320800,"binding_seq":1,"k_gw":"ed25519:d050…"}
  new step 3 (K_srv rotation: binding 2): ok fresh -> {"seq":3,"issued_at":1793320860,"binding_seq":2,"k_gw":"ed25519:d050…"}
  new step 4 (republish at binding 2): ok fresh -> {"seq":3,"issued_at":1793323860,"binding_seq":2,"k_gw":"ed25519:d050…"}
B. state saved by the old client, loaded by the new one (clamp on load), then continued
 old state after step 0: {"seq":2,"issued_at":1793318400,"binding_seq":1} -> loaded {"seq":0,"issued_at":0,"binding_seq":1} (pin 1) binding_seq kept, order dropped
  upgraded step 1 (hourly republish (same seq, newer issued_at)): ok fresh -> {"seq":2,"issued_at":1793320200,"binding_seq":1,"k_gw":"ed25519:d050…"}
  upgraded step 2 (membership change): ok fresh -> {"seq":3,"issued_at":1793320800,"binding_seq":1,"k_gw":"ed25519:d050…"}
  upgraded step 3 (K_srv rotation: binding 2): ok fresh -> {"seq":3,"issued_at":1793320860,"binding_seq":2,"k_gw":"ed25519:d050…"}
  upgraded step 4 (republish at binding 2): ok fresh -> {"seq":3,"issued_at":1793323860,"binding_seq":2,"k_gw":"ed25519:d050…"}
 old state after step 1: {"seq":2,"issued_at":1793320200,"binding_seq":1} -> loaded {"seq":0,"issued_at":0,"binding_seq":1} (pin 1) binding_seq kept, order dropped
  upgraded step 2 (membership change): ok fresh -> {"seq":3,"issued_at":1793320800,"binding_seq":1,"k_gw":"ed25519:d050…"}
  upgraded step 3 (K_srv rotation: binding 2): ok fresh -> {"seq":3,"issued_at":1793320860,"binding_seq":2,"k_gw":"ed25519:d050…"}
  upgraded step 4 (republish at binding 2): ok fresh -> {"seq":3,"issued_at":1793323860,"binding_seq":2,"k_gw":"ed25519:d050…"}
 old state after step 2: {"seq":3,"issued_at":1793320800,"binding_seq":1} -> loaded {"seq":0,"issued_at":0,"binding_seq":1} (pin 1) binding_seq kept, order dropped
  upgraded step 3 (K_srv rotation: binding 2): ok fresh -> {"seq":3,"issued_at":1793320860,"binding_seq":2,"k_gw":"ed25519:d050…"}
  upgraded step 4 (republish at binding 2): ok fresh -> {"seq":3,"issued_at":1793323860,"binding_seq":2,"k_gw":"ed25519:d050…"}
 old state after step 3: {"seq":3,"issued_at":1793320860,"binding_seq":2} -> loaded {"seq":0,"issued_at":0,"binding_seq":2} (pin 2) binding_seq kept, order dropped
  upgraded step 4 (republish at binding 2): ok fresh -> {"seq":3,"issued_at":1793323860,"binding_seq":2,"k_gw":"ed25519:d050…"}
all verdicts ok fresh; no snapshot_ahead; stored state clamped only as designed

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 used f08fea43c6979223ebf44f8b05020dd3033414ea. These are integrated proof refs, not the individual PR heads.

  • Actual Control UI rotation 1→2 committed and published, preserving the root and admitted native node (studio-ui-rebind-v4-call-result.json).
  • The earlier CLI 2→3 committed but reported failure; that defect remains recorded above/in feat(openclaw-id): move a claw to new keys with its recovery kit (openclaw id rebind) #196388. A deliberately new repaired CLI 3→4 exited 0, reported 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).
  • The same persistent remote owner browser and saved native node followed 3→4 and reconnected after a separate actual Gateway restart. Production SQLite trust load showed pin/freshness 4 before native dialing; system.which(uname) passed (studio-cli4-restart-call-result.json). This does not retroactively prove owner-browser following of each earlier rotation.
  • Actual native transport with copied real node trust refused a signed snapshot claiming binding 4 under verified binding 3 as 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).
  • Production readStoredClaw/publishClaw used real old binding-3 SQLite and keys against staging: HTTP 409 stale_binding carried binding 4, verified under the root, producing non-retryable binding_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).
  • Final exact-claw retirement completed once; database checks showed no claw/member/relay-key rows and a reserved retired hostname. Independent existing-owner authentication obtained descriptor 404. Owned processes/listeners/transports were absent; private Studio/fsn1 profiles, snapshots, keys and kit copies were removed, with tracked checkouts clean. The original lock holder exited 0, the same canonical lock was verified available, and four reservation-owner release notices were queued. No merge or production deployment occurred.

Shipped older-writer limitation: the remotely verified latest stable v2026.11.2 and beta v2026.11.5-beta.1 examined here contain neither src/gateway/openclaw-id nor packages/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. See shipped-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.

Inspectable native replay and SQLite upgrade evidence — November 10

This update supplies public redacted excerpts for the earlier operator-local proof references and the previously pending native replay/SQLite cases. It supersedes the earlier pending-proof statements only within the boundaries below. IPs, keys, tokens, emails, private identities and non-public endpoints are omitted. No staging claw was recreated.

Existing integrated native re-bind/restart and snapshot_ahead traces

Historical combined Gateway source f864514d93a08efda68c14eabc42768f081af854, repaired CLI f08fea43c6979223ebf44f8b05020dd3033414ea; these are not a fresh deployment of the PR head.

Selected actual Gateway-restart receipt fields:

{
  "passed": true,
  "bindingSeq": 4,
  "publishedBindingSeq": 4,
  "nativePersisted4": true,
  "sameNativeNodeReconnected": true,
  "harmlessCommand": true,
  "sameOwnerReconnected": true,
  "bindingUnchanged": true,
  "cleanupConfirmed": true
}

The production SQLite loader read saved binding-4 pin and keyed freshness before the same native node reconnected and completed system.which. Stored root-signed binding endpoint/Gateway keys were checked against the current binding. The owner profile independently reconnected after that distinct Gateway process restart.

Selected existing native snapshot-ahead receipt fields:

{
  "passed": true,
  "stagingDiscoveryChanged": false,
  "requestSignatureVerified": true,
  "fixtureSignatureVerified": true,
  "descriptorBindingSeq": 3,
  "snapshotClaimedBindingSeq": 4,
  "refusal": "snapshot_ahead",
  "bridgeHttpStatus": 502,
  "descriptorRequests": 1,
  "persistedRefreshes": 1,
  "pinUnchanged": true,
  "freshnessUnchanged": true,
  "targetUnchanged": true,
  "noServerConnection": true,
  "cleanupConfirmed": true
}

This was actual native transport with copied real SQLite node trust and a signed local response fixture—not a malicious staging write. Refusal retained the saved trust and made no server connection. It is distinct from the new fully synthetic exact-head replay cases below.

New exact-head native replay and pre-PR SQLite writer qualification

Additional isolated native/SQLite runtime proof

Candidate 77f6c1e13c49b9897b08b303911986684480a6d7: 11 separate OS processes exited 0 using production node transport and production SQLite workers. Real native addon SHA-256: 570ef4e7323a24b5afa373ec24abda7e89c7cee89367aef1333d7fa8e1d7d7e2; runtime loader reported native, with the artifact observed in require.cache. Native source checkout 8d20985e878b4eef195e040ea0fef6425536566d matches the candidate's tracked addon source.

  • Real QUIC positive controls accepted old-key snapshot sequence 500, then a root-signed replacement key at binding sequence 2 with snapshot sequence 3. Trust was durably saved and reloaded after process exit.
  • After restart, replaying the retired binding/snapshot returned HTTP 502 (rollback); replaying the retired-key snapshot under the current binding returned 502 (snapshot_invalid). Same-key lower sequence and older timestamp each returned 502 (snapshot_replayed). Every refusal had 0 native connect calls, 0 openBi calls, 0 peer accepts/streams/HEADs and 0 peer-addressed send syscall entries. Transparent counters delegated to real addon methods; strace and the real receiver corroborated them. Four accepted controls each completed one real QUIC request. Discovery signatures: 8 valid requests, 0 errors.
  • Logical config and persisted nodeHost.config value JSON bytes stayed identical across the replays, including keyed trust and unrelated node settings.
  • Pre-PR production preview writer eaa8aebfb69368a748f4aaf39166a8bf339f70ec actually wrote a keyless legacy marker (seq=900, binding_seq=50) after a signed synthetic snapshot exceeded verified binding 1. Candidate production SQLite loading normalized it to (seq=0, issued_at=0, binding_seq=1), preserving pin, signed evidence and unrelated settings. A subsequent real-native refresh saved the new keyed marker; another OS process loaded the full config unchanged. This is an unreleased preview-writer upgrade, not an older-shipped/stable upgrade.

Scope: isolated synthetic identities, loopback Discovery and framed-HTTP native peer, source-runtime modules rather than packaged-release qualification. No native/persistence mocks, live/personal profiles or staging identity. Endpoint binding/background relay attempts precede freshness validation; zero-effect claims concern target QUIC connect/stream/request I/O, not all native socket activity. The existing native binary was identified by hash, not rebuilt or reproducible-build qualified here. The synthetic endpoint seed was re-established with identical bytes before each child; this qualifies freshness/config restart behavior, not endpoint-key lifecycle. Legacy unowned snapshot order is intentionally dropped until a keyed marker is learned. Normal runner startup configuration was retained and asserted logically unchanged. Nonqualifying harness/setup attempts were preserved separately; the complete final run passed. All owned processes/endpoints were closed; raw evidence remains private and redacted artifacts contain no keys or routing addresses.

Selected terminal JSON lines from separate real client processes (no keys or addresses):

// 03-retired-binding-replay
{"mode":"request","ok":true,"counts":{"nativeBind":1,"nativeConnect":0,"nativeOpenBi":0,"readTarget":1,"persisted":0},"status":502}
// 04-retired-snapshot-current-binding
{"mode":"request","ok":true,"counts":{"nativeBind":1,"nativeConnect":0,"nativeOpenBi":0,"readTarget":1,"persisted":1},"status":502}
// 05-same-key-sequence-replay
{"mode":"request","ok":true,"counts":{"nativeBind":1,"nativeConnect":0,"nativeOpenBi":0,"readTarget":1,"persisted":1},"status":502}
// 06-same-key-time-replay
{"mode":"request","ok":true,"counts":{"nativeBind":1,"nativeConnect":0,"nativeOpenBi":0,"readTarget":1,"persisted":1},"status":502}
// 08-preview-writer
{"mode":"preview-write","ok":true,"counts":{"nativeBind":0,"nativeConnect":0,"nativeOpenBi":0,"readTarget":0,"persisted":1}}
// 09-candidate-legacy-load
{"mode":"load","ok":true,"counts":{"nativeBind":0,"nativeConnect":0,"nativeOpenBi":0,"readTarget":0,"persisted":0}}
// 11-keyed-restart-load
{"mode":"load","ok":true,"counts":{"nativeBind":0,"nativeConnect":0,"nativeOpenBi":0,"readTarget":0,"persisted":0}}

Production refusal messages were rollback, freshness_unavailable (snapshot_invalid), and freshness_unavailable (snapshot_replayed) for both same-key cases. Endpoint bind occurred once per transport process; target connect/openBi remained zero for refusals.

Preview-written row: (seq=900, binding_seq=50, k_gw absent). Candidate effective load: (seq=0, issued_at=0, binding_seq=1, k_gw absent). After successful native refresh: (seq=3, binding_seq=2, k_gw=[REDACTED_NEW_KEY]). The loader normalizes legacy state; the later ordinary refresh makes keyed storage durable. The preview profile was generated by unmodified production configure/assess/refresh calls, never SQL INSERT or database editing. Pin (including keyed trust), signed binding/root evidence and unrelated settings were compared exactly.

Parent verification independently matched 18 candidate/preview source files to Git, verified the artifact-manifest hashes, inspected both harnesses and the raw assertions, and recounted all 11 address-specific syscall traces. The zero-send result matches both peer address and port, not merely port number.

Older shipped-writer upgrade: not applicable to these unshipped paths. The stable/beta absence evidence above is bounded; no shipped-upgrade execution is claimed. The newly demonstrated compatibility case is an actual pre-PR preview writer → production SQLite loader in a throwaway profile.

Exact-head hosted CI observed terminal with no failures and openclaw/ci-gate success. Hosted proof reassessment is still required; no merge or production deployment is authorized by this evidence.

… not blocked

A retired Gateway key could have signed an inflated seq or a future
issued_at; clients now restart snapshot order with the first snapshot of a
newer binding's K_gw and keep the binding_seq high-water. Node hosts persist
the K_gw of their freshness marker.
@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.

…r R-signed binding

A retired key's snapshot could claim the next binding_seq and keep the marker
on that key, leaving the new key's snapshots unordered. The marker now records
the R-signed binding its key verified under and moves to another key only for
a higher one.
@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: needs maintainer review before merge.

What this changes

This PR orders snapshots by Gateway signing key, rejects inflated binding claims, and migrates saved node freshness markers.

Example: A retired Gateway key signed snapshot sequence 500 before a root-authorized replacement at binding 2 signs sequence 3.

  • Before: The replacement snapshot is refused as snapshot_replayed.
  • After: The replacement snapshot is accepted, while retired-key and subsequent same-key replays remain refused.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused shared-owner repair with meaningful regressions, real native transport evidence and preview SQLite upgrade qualification; integrated staging evidence is historical, while the additional exact-head runs use production source-runtime modules.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Public redacted output now covers integrated native reconnection after rebind and Gateway restart, snapshot_ahead refusal without target connection, and exact-head production transport/SQLite processes accepting replacement-key requests while rejecting retired-key and same-key replays before connect/openBi; this addresses both prior rank-up requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Clients can remain unable to reconnect after an honest key replacement because the retired Gateway key poisoned retained freshness.
Reason: Restores recovery under the existing root-authorized binding contract, with direction and the bounded legacy migration tradeoff recorded by the feature owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main freshness defect. No actionable patch defects remain, and the updated native replay and SQLite upgrade evidence closes the prior proof requests.

Priority: P2
Reviewed head: 77f6c1e13c49b9897b08b303911986684480a6d7

Before merge

None.

Findings

None.

Agent review details

How this fits together

Discovery supplies untrusted signed binding and membership evidence; the shared protocol verifies freshness, the node SQLite owner retains trust, and the transport connects only after verification and persistence.

flowchart LR
  Discovery --> BindingVerification
  SavedTrust --> BindingVerification
  BindingVerification --> FreshnessAssessment
  FreshnessAssessment --> SQLiteTrustOwner
  SQLiteTrustOwner --> NativeTunnel
Loading

Technical review

Best possible solution:

Land the shared freshness repair and node persistence changes, with companion clients adopting the same per-key contract.

Do we have a high-confidence way to reproduce the issue?

Current main compares replacement-key snapshots against the retired key's global order and retains unverified binding claims; the committed regressions identify both failures, without running target code during this review.

Is this the best way to solve the issue?

The patch repairs the existing shared freshness owner, retains binding rollback protection, and updates the existing parser and SQLite merge boundary without adding a competing owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 83d832338dd8.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned change and current-main defect: The introduced diff adds per-key snapshot ordering and snapshot_ahead refusal; fetched main retains global ordering and stores the snapshot's claimed binding sequence. (packages/openclaw-id-protocol/src/freshness/freshness.ts:104, 77f6c1e13c49)
  • Authority checked before target I/O: Bindings require the pinned root's signature, snapshots require the binding's Gateway key, and descriptor refusal propagates before native connect and stream creation. (src/node-host/openclaw-id-transport.ts:105, 77f6c1e13c49)
  • Inspectable native runtime proof: The full updated PR body supplies exact-head real-native positive controls and post-restart retired-binding, retired-key, lower-sequence and older-timestamp refusals, with zero target connect/openBi calls corroborated by receiver and syscall observations. (77f6c1e13c49)
  • Persisted-state compatibility: A production pre-PR preview writer saved a keyless marker with sequence 900 and binding 50; the candidate SQLite loader normalized it against pin 1, preserved signed trust and unrelated settings, then durably saved and reloaded keyed freshness after a real native refresh. (src/node-host/openclaw-id-target.ts:126, 77f6c1e13c49)
  • Accepted migration tradeoff: The maintainer-authored direction explicitly accepts dropping legacy unattributable snapshot order until keyed state is learned, within the existing three-hour freshness window; keyed markers retain their verified high-water. (packages/openclaw-id-protocol/src/freshness/freshness.ts:256, 77f6c1e13c49)
  • Latest stable has no affected writer: The latest stable tree contains neither the protocol package nor the OpenClaw ID Gateway directory, supporting preview-writer upgrade qualification for these unshipped paths. (b556fdf457b0)

Likely related people:

  • Josh Lehman: Raw commit ed57ed7 adds packages/openclaw-id-protocol/src/freshness/freshness.ts:79 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ed57ed752e35; files: packages/openclaw-id-protocol/src/freshness/freshness.ts)
  • Josh Avant: Raw commit 3e4e201 adds src/node-host/openclaw-id-target.ts:9 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3e4e201e11ae; files: src/node-host/openclaw-id-target.ts)

PR surface

Source +65, Tests +200, Docs +11, Other +2. Total +278 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 79 14 +65
Tests 4 219 19 +200
Docs 1 25 14 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 9 325 47 +278

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Repairs persistent reconnect failures and freshness poisoning on the opt-in OpenClaw ID preview surface.
  • merge-risk: 🚨 security-boundary: Changes durable replay protection and deliberately resets unattributable legacy order; the recorded owner decision accepts that bounded tradeoff, and native final-effect evidence covers keyed replay rejection.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-10T03:05:08.375Z sha 985f871 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T05:54:59.729Z sha 77f6c1e :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-10T16:11:02.519Z sha 77f6c1e :: needs real behavior proof before merge. :: none

Reviewed November 10, 2026, 12:13 PM ET / 17:13 UTC (Revision 4).

… high-water (J5)

A snapshot naming a binding_seq above the binding it verified under is refused
as snapshot_ahead and nothing of it is stored, so a stolen K_gw can no longer
retire every binding a client could verify. The per-key order now switches on
the verified binding_seq alone; stored markers from before are capped at the
pin's binding_seq on load (clampFreshnessState), as node hosts do.
@jalehman jalehman changed the title fix(openclaw-id): clients follow a re-bind instead of refusing the new key's snapshots fix(openclaw-id): clients follow a re-bind, and a stolen Gateway key can't retire bindings Nov 10, 2026
A marker with k_gw always carries a verified binding_seq, even when the pin did
not advance, so it is kept as stored. A marker without k_gw (before per-key
order) is capped at the pin and loses its (seq, issued_at): attributed to the
next K_gw, a retired key's inflated seq would block the replacement for good.
… markers do

Unkeyed fixtures are legacy markers, which load capped and without order.
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Nov 10, 2026
@jalehman
jalehman merged commit 7b93144 into main Nov 10, 2026
160 checks passed
@jalehman
jalehman deleted the fix/ocid-freshness-per-kgw branch November 10, 2026 17:31
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 11, 2026
…can't retire bindings (openclaw#196402)

* fix(openclaw-id): order membership snapshots per K_gw so a re-bind is not blocked

A retired Gateway key could have signed an inflated seq or a future
issued_at; clients now restart snapshot order with the first snapshot of a
newer binding's K_gw and keep the binding_seq high-water. Node hosts persist
the K_gw of their freshness marker.

* test(openclaw-id): allocate test lines for per-K_gw snapshot order

* fix(openclaw-id): switch snapshot order to a new K_gw only for a newer R-signed binding

A retired key's snapshot could claim the next binding_seq and keep the marker
on that key, leaving the new key's snapshots unordered. The marker now records
the R-signed binding its key verified under and moves to another key only for
a higher one.

* fix(openclaw-id): only verified bindings raise a client's binding_seq high-water (J5)

A snapshot naming a binding_seq above the binding it verified under is refused
as snapshot_ahead and nothing of it is stored, so a stolen K_gw can no longer
retire every binding a client could verify. The per-key order now switches on
the verified binding_seq alone; stored markers from before are capped at the
pin's binding_seq on load (clampFreshnessState), as node hosts do.

* fix(openclaw-id): migrate only legacy freshness markers on load

A marker with k_gw always carries a verified binding_seq, even when the pin did
not advance, so it is kept as stored. A marker without k_gw (before per-key
order) is capped at the pin and loses its (seq, issued_at): attributed to the
next K_gw, a retired key's inflated seq would block the replacement for good.

* test(openclaw-id): node-host freshness fixtures carry k_gw, as stored markers do

Unkeyed fixtures are legacy markers, which load capped and without order.

* test(openclaw-id): size the per-K_gw freshness test-line allocation to the change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant