Repository navigation
feat(openclaw-id): add protocol contracts package - #191469
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 changes before merge. What this changesThis PR adds a private, browser-compatible package defining OpenClaw ID statements, membership authority, enrollment, discovery, and tunnel contracts. Example: An owner removes browser A, which approved browser B.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open as a useful foundation for OpenClaw ID; the previously reported ServerBinding documentation mismatch remains. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe package accepts signed statements, discovery payloads, and tunnel bytes, then returns verified contracts, membership transitions, and codecs for later Gateway and browser integrations. flowchart LR
A[Owner and browser keys] --> B[Protocol contracts]
C[Discovery payloads] --> B
B --> D[Gateway membership authority]
D --> E[Tunnel admission and removal]
B --> F[Browser pin verification]
Technical reviewBest possible solution: Retain the shared private package and make Discovery’s ServerBinding signer contract consistently R-only. Do we have a high-confidence way to reproduce the issue? This is a new capability rather than a released bug report; source inspection confirms the retained documentation mismatch without executing target code. Is this the best way to solve the issue? A dependency-free shared contract package is a coherent first stage, with Gateway persistence and effects left to their existing owners. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 29e1324fa337. TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
PR surfaceSource +5530, Tests +2094, Docs +844, Config +13, Other +4. Total +8485 across 69 files. Added test files: 19. View PR surface stats
LabelsLabel changes: No label 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 (3 earlier review cycles)
Reviewed November 3, 2026, 12:40 AM ET / 05:40 UTC (Revision 4). |
e79cc7d to
0068d2a
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
9133171 to
79a0cbc
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
A claw's root never changes in this version; owner reset is redesigned in a later PR (OCF-319). Removes the RootRotation statement, repinRoot, regenerateOwnerKey, root epochs in anchors and pins, and the frozen state. root_epoch stays on the wire as the constant 1 so existing signed statements still verify. Descriptors carry no rotations.
…verBinding signer
Raises the baseline by 2,485: the package's 2,092 new test lines plus main's existing 393-line overage at the time of this rebase.
60283ab to
28fefdc
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* feat(openclaw-id): add protocol contracts package
* refactor(openclaw-id): document or remove protocol type assertions
* feat(openclaw-id): per-claw allowlist protocol; address review findings
Replaces certificate chains and revocation lists with a per-claw allowlist:
statements signed by an owner device are checked against the claw's current
owner devices, revoking a device deletes it and every device it approved,
unused keys are dropped after 90/30 days, and snapshots carry current state
only. Also refuses root-signed invites while frozen, keeps untrusted
signatures and strings from throwing, and tears down an owner's tunnel key on
removal.
* feat(openclaw-id): carry granted owner-device caps in the signed snapshot
An owner device may grant only caps it holds (caps_escalation otherwise) and a
re-add through an owner device cannot raise a listed device's caps; R may grant
any. The Gateway records the granted caps, and MembershipSnapshot lists
owner_devices as { device_pub, caps }, so readers outside the claw take caps
from the K_gw-signed snapshot instead of a presented certificate.
* fix(openclaw-id): address second protocol review
Schema lookups use own properties only, so prototype-named variants and
undeclared constructor fields are malformed instead of throwing. Re-adding an
owner device with replacement peer keys tears down the dropped keys, and
repinRoot ends the earlier owner devices' sessions and tokens. Package tests
now typecheck.
* feat(openclaw-id): remove root rotation and owner-key regeneration
A claw's root never changes in this version; owner reset is redesigned
in a later PR (OCF-319). Removes the RootRotation statement, repinRoot,
regenerateOwnerKey, root epochs in anchors and pins, and the frozen
state. root_epoch stays on the wire as the constant 1 so existing signed
statements still verify. Descriptors carry no rotations.
* fix(openclaw-id): drop chained body assertion; document R as sole ServerBinding signer
* fix(openclaw-id): widen statement body without a type parameter
* chore(test-lines): raise baseline for the openclaw-id protocol package
Raises the baseline by 2,485: the package's 2,092 new test lines plus main's
existing 393-line overage at the time of this rebase.
What Problem This Solves
OpenClaw ID (remote access to a Gateway through an OpenClaw ID account) needs one shared definition of its wire protocol that the Gateway, the Control UI and the People plugin can all use. This draft adds that definition as its own package, so it can be reviewed apart from the code that uses it.
User Impact
No user-visible change. Nothing imports the package yet. Later PRs in this stack wire it into the Gateway, the Control UI and the People plugin, behind an OpenClaw ID Labs switch that is off by default.
Why This Change Was Made
packages/openclaw-id-protocolholds the v1-draft protocol contracts as pure TypeScript with no Node built-ins (a test enforces this), so browser and Gateway code can share it:caps_escalationotherwise), re-adding a listed device through an owner device cannot raise its capabilities, and only R may grant anything; the K_gw-signedMembershipSnapshotlistsowner_devicesas{ device_pub, caps }, so readers outside the claw (Discovery) take an owner device's capabilities from the snapshot, not from a certificate a browser presents;root_epochstays on the wire as the constant 1 so statements signed earlier still verify (any other value ismalformed), descriptors carry no rotations, and a client pin accepts a binding only from the pinned root with abinding_seqthat does not go back. Owner reset was removed from this PR (see below);The specs are in
packages/openclaw-id-protocol/docs/.The only other changes are wiring: tsconfig paths, Vitest source aliases, the pnpm lockfile importer entry, and a raise of the test-line baseline (see Test-line baseline below).
This is the first PR of a stack. The next PRs add the iroh Node binding, Gateway authority and publication, the tunnel child and admission, the Gateway security-boundary changes, the Control UI, the People plugin, and docs.
Owner reset: removed here, redesigned later
Removed: the
RootRotationstatement, owner-key regeneration, root epochs and the frozen state.Why: a new owner-reset design replaces them, and the old mechanism never worked end to end: after a reset, the republish under the new root was rejected.
What the new design adds back to this package later:
RootResetstatement signed by the Gateway key (K_gw);Why later: its security rests on facts only the Gateway can establish: only that machine holds K_gw, and the request arrived over local loopback. So it lands with the Gateway PR, where it can be proven live: a reset succeeds locally and is refused over the tunnel.
Until then: there is no owner reset. A lost recovery kit means unlinking and relinking the claw.
Evidence
pnpm test packages/openclaw-id-protocol: 19 files, 129 tests passed. Fixed root: aRootRotationstatement or aroot_epochother than 1 ismalformed, another root's signature isnot_an_owner, and a binding from another root fails the pin withroot_mismatch(acceptance test 9 and a new pin vector). Second-review regressions (each fails on the head before them): a MembershipChangeopof__proto__,constructor,toStringorhasOwnPropertyismalformedinstead of throwing; an undeclaredconstructorfield (including one holding a lone surrogate) ismalformed; re-adding an owner device whose certificate replaces[W1]with[W2]disconnects and invalidates W1. Granted caps: an owner device cannot grant caps it lacks, a re-add cannot escalate, R may grant any caps, and the snapshot round-trips owner devices with their caps (unknown caps aremalformed). Earlier: one regression test per remaining first-review finding: a noncanonical request signature returnsunauthorizedinstead of throwing; lone surrogates aremalformed; removing an owner device tears down its tunnel key W when W differs from D (test fixtures now use distinct D and W); a deeply nestedchainmember is refused at the top level. (The first-review freeze fix for invite registration and the second-reviewrepinRootteardown went away with owner reset.)pnpm check:changed --base origin/main: every check passed except lint. Lint fails only onmax-linesin six files this PR does not touch; those files already exceed the limit onmain. No findings inpackages/openclaw-id-protocol.pnpm tsgo:corepassed andoxlint --type-awarereports no findings in the package.pnpm check:assertion-safety --base origin/mainpassed: the remaining type assertions in the package have// SAFETY:comments, and the ones that were not needed were removed. The type error invalidity.test.tswas also fixed.pnpm check:test-lines-ratchet: passes with the baseline raise below (slack 0 at the time of the rebase).pnpm tsgo:test:packages: no errors inpackages/openclaw-id-protocol(the package's own test files now typecheck, includingauthority/validity.test.ts).pnpm install --frozen-lockfile: lockfile accepted.Behavior proof
From the staging testnet on 2026-11-02 and 2026-11-03 (UTC). The lab Gateways now run this protocol package (openclaw
1bc84010c2e; the first two items were recorded on80343b56535, the capabilities item onab79a959ae4), and the evidence comes from real browsers going through the relay. Keys are shown asfp:prefixes only; the browsers are disposable test browsers.tunnel: admission rejected: peer=fp:45adc476andpeer=fp:a68c5810, 23:26:00). It logged no later HTTP or WebSocket line for either peer, and both loaders showednot_admitted. Discovery's relay admission (POST /iroh/admit) returnedfalsefor both keys andtruefor the remaining owner device and the claw's server key.tunnel: peer removed: peer=fp:45adc476 closed_conns=1andpeer=fp:a68c5810 closed_conns=1, and closed both Control UI sessions withcode=1008 reason=removed from this claw.devices liston the Gateway host shows the operator tokens of both browsers revoked (6df7ee74…,ba06d8d9…). The claw's next published snapshot lists neither device and has norevokedfield.limit_reachedon both.ab79a959ae4both lab claws migrated in place on restart (each owner device took its caps from its stored certificate) and republished. The allowlist gate passed on both: Discovery's snapshot verifies under K_gw and lists the saved owner browser inowner_deviceswithapprove_device, bind, invite, manage_members, matching the Gateway. SAS approval (E approves N with E's granted caps) passed on both. Discovery's mailbox reader now refuses a certificate self-signed by D that claimsapprove_devicewhen the snapshot grants D less (Discovery test suite).1bc84010c2eboth lab claws migrated in place on restart (the stored root epoch, root history, rotations and freeze were dropped; nothing was relinked and the recovery kits are unchanged) and republished a descriptor withoutrotations. Discovery's migration removed its stored root epoch and strippedrotationsfrom stored descriptors. Loaders on the new protocol (which refuse a descriptor carryingrotations) pinned the existing root, enrolled with the existing kits and connected on both claws; the allowlist and owner gates passed on both. Your devices offers no owner reset.Test-line baseline
This PR raises
config/test-lines-baseline.txtby 2,485 lines instead of adding an allocation file:main's existing overage at the time of the rebase: onmainalone the check reports "over by 393". An allocation can't cover it, because allocation credit is capped at the lines a PR adds.If
mainadds test lines before this lands, the check may need the raise adjusted again.