Repository navigation
feat(gateway): route pairing and default approvals through the live owner; routing docs (routing 4/4) - #164075
Conversation
…wner Route local pairing list/code approval and default approval snapshots and edits through the selected root's serving Gateway, with operation capabilities, current-owner guards, and retained offline custody. Preserve approval policy and CAS semantics, legacy RPC results, and acknowledged pairing bootstrap. Document the complete routed CLI/API contracts and retained raw and legacy writer boundaries. Cover the real two-process routes and native transaction rollback, including refusal and unknown-outcome behavior.
|
🦞👀 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. |
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 3, 2026, 5:19 AM ET / 09:19 UTC (Revision 7). ClawSweeper reviewWhat this changesRoutes pairing commands and default execution-approval reads and edits through the serving Gateway or exclusive offline ownership, and documents the routing and compatibility contracts. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful: current main still accesses pairing and default approval state directly. The newly recorded published-driver update and recovery results resolve the previous blocker; no actionable correctness or security findings remain. Priority: P2 Review scores
Verification
How this fits togetherPairing controls who can contact an agent, while execution approvals hold host command policy. Administrative CLI commands now select the process owning the installation’s state before reading or changing its SQLite records. flowchart TD
A[Administrative CLI commands] --> B[Selected state directory]
B --> C{Discover current owner}
C --> D[Serving Gateway]
C --> E[Exclusive offline custody]
D --> F[Check capability and live authority]
E --> F
F --> G[Existing SQLite records]
F --> H[Result or explicit refusal]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +212, Tests +640, Docs +207, Other +3. Total +1062 across 30 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing physical-root owner for these administrative operations, preserving explicit refusal, offline recovery, legacy RPC compatibility, and unchanged execution policy. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main directly invokes mutation-capable pairing and approval stores from the CLI while a Gateway can own that root; the recorded baseline process checks expose caller-process SQL. This review did not execute the code. Is this the best way to solve the issue? Yes. Reusing the established owner-routing helper and existing stores avoids a competing state owner while retaining legacy wire contracts and tested mixed-version recovery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 99babf272543. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…wner (openclaw#164075) Route local pairing list/code approval and default approval snapshots and edits through the selected root's serving Gateway, with operation capabilities, current-owner guards, and retained offline custody. Preserve approval policy and CAS semantics, legacy RPC results, and acknowledged pairing bootstrap. Document the complete routed CLI/API contracts and retained raw and legacy writer boundaries. Cover the real two-process routes and native transaction rollback, including refusal and unknown-outcome behavior.
What Problem This Solves
Pairing list/approve and default approval edits could access the selected installation's SQLite state directly while its Gateway was serving it. Listing pairing requests also mutates state by pruning expired or excess requests.
Solution
Reuse the merged physical-root owner routing and offline custody helper. Each operation requires its own capability and expected owner identity; a refusal or lost acknowledgement never triggers local fallback or replay. Pairing's code-based CLI variants require admin authority and preserve the existing code-free UI RPC shapes. Explicit blank account selectors are rejected. Approval writes keep their existing input normalization, compare-and-set hashes, and execution policy semantics; default reads preserve an absent approval document.
Native mutation owners recheck current authority inside their synchronous transaction and before commit. Pairing command-owner config bootstrap and optional notification run only after an acknowledged approval through their existing owners. The approvals CLI's local snapshot helpers now live in a focused sibling module, included in compiled-subprocess preparation.
Impact
New CLI commands use the same-root live owner, or retain exclusive offline custody. Older Gateways lacking the operation capability require an update or an intentional stop through their service owner. Explicit approval
--gatewayand--nodetargets retain their existing contracts. No schema, protocol version, configuration, retention, durability, or execution-grant policy changes.The docs cover routing 1–2 and these commands, wire/result compatibility, refusal states, and retained bootstrap, credential, configuration, plugin, client-preference, raw SDK, and legacy-writer boundaries. This is not a claim that the Gateway is the only SQLite writer. Agent creation remains census debt because its staged auth/plugin/config commit cannot be represented by today's
agents.createrequest. Session cleanup/agent deletion routing and the SDK workspace gate remain outside this PR.Overlap checked: #137878 and #123867 touch other approvals CLI presentation/normalization functions; #163969 is incidental infrastructure cleanup. The routing hunks preserve those separate responsibilities.
Evidence
Initial review base:
d5c4c19fe1863dc84badedec8cbbbec4906a4855; final PR base:c0c8363730facee6e6df6ee159e60f3e0e9e4fd9. Conflict-free main mergesd9360fb95f8b602af5e8f28a77813ec3f75a8becand7cd771fe5fa0f02667a2fd4ac39df20d45a25b29incorporated two already-landed published-driver fixture repairs. Route4 added/removed lines are unchanged; all 30 PR files at the final head are byte-identical to the fresh P2-reviewed candidate.Handwritten production LOC: +273 / −61 / net +212 (334 changed lines) across 12 files. Tests/support, docs, and fixture inventory are separate.
T1 inventory: 1336 → 1336 globally; touched native owners remain 7 → 7. Routing removes no counted Gateway SQL sites. The six routed CLI operations execute zero caller-thread pairing/approval SQL.
Real two-process proof: 25 cases covering live/offline routing, each missing operation capability, owner refusal, lost acknowledgements, durable state, and absent-document read parity. One suite-level authenticated mock Gateway uses the real handlers and stores; each command runs in another process. Original CLI bodies fail all six live zero-SQL assertions (24 pairing, 16 approval-get, and 20 approval-write observations); baseline wall time 36.15s.
Final CLI/process proof: 69 tests passed,
pnpm test src/cli/admin-state-owner.process.test.ts src/cli/exec-approvals-cli.test.ts src/cli/exec-approvals-cli.allowlist-json.test.ts --maxWorkers=1, 226.59s wall on the loaded host. This includes legacy string allowlist input, which failed at the strict RPC schema before normalization moved ahead of dispatch. Separate processes are required to prove the ownership/SQL boundary; the Gateway fixture is reused. The compiled-wrapper suite's 17 tests passed in the earlier combined 86-test / 138.66s command; its import closure is unchanged by the normalization follow-up.Approval handler/store plus process proof: 71 tests passed, 110.43s wall. Pairing store: 10 passed, 15.91s wall. Pairing handler: 12 passed, 5.13s wall; both new blank-selector cases failed before the fix. Pairing CLI's 20 focused cases also passed.
node scripts/worktree-setup.mjs gateway, protocol registry/generation, Swift/Kotlin contract checks, docs link audit (0 broken links), andgit diff --check: passed.Madge: 0 cycles. Database-worker ratchet: passed against the pinned base.
OPENCLAW_*: 477/477, zero new names.node scripts/check-changed.mjs --base d5c4c19fe1863dc84badedec8cbbbec4906a4855: passed. The final normalization follow-up also passed focused lint and core typechecking. Initial failures were CLI line-cap growth (resolved by extraction), a missing version field, and an inefficient map/spread in test fixtures (fixed). The initial process fixture root mismatch was fixed by restoring its environment before each case; it did not require a product workaround.Codex autoreview through P2, pinned base: scoped-clean, no accepted/actionable findings.
Prior author proof: actual published SDK
[email protected]: passed in 6.642s using the npm artifact and its own dependencies. A released SDK child persisted pairing state while the candidate held a real Gateway lock; an independent read-only SQLite query verified the rows. Released async/synchronous pairing reads and synchronous approval snapshot/policy shapes remained intact. This confirms retained old-SDK direct-write behavior.Prior author proof: actual published CLI
2026.9.8→ candidate-held root passed; approvals save 28.370s, pairing-list pruning 16.604s, and pairing approval 10.482s, with durable rows verified while the candidate lock stayed current. The reverse CLI cell also passes on the final head, as detailed below.Published-driver
2026.9.8× final candidate update cell: PASS at7cd771fe5fa0f02667a2fd4ac39df20d45a25b29on Blacksmith Testbox. The full canonical cell completed; see final landing validation below.Final exact-head CI run 37109826487: PASS at
7cd771fe5fa0f02667a2fd4ac39df20d45a25b29, 21,528 summed job-seconds, no failed checks. No admin CI exception was needed.Released SDK surface check against
v2026.9.8: passed. The added optional authority callbacks belong to internallistChannelPairingRequests,approveChannelPairingCode, andupdateExecApprovals[Sync]; their sync/async return shapes are unchanged. Releasedchannel-pairing,conversation-runtime, the explicitly pinnedinfra-runtimeexports, andapi.runtime.channel.pairingdo not expose those changed functions. Public pairing read/upsert and approval snapshot/policy signatures remain unchanged; no deprecation compatibility boundary is required.Final landing validation
2026.9.8updater completed in 171.630s. The canonical Docker cell verified successful durable update status, exact installed build identity, managed-service replacement, authenticated serving-version probe,readyz=200, and absence of startup/authority or canary/identity/lease failures. It used two synthetic agents and Doctor-seeded state. Main’s canonical fixture relabels the2026.9.7candidate metadata to2026.9.8when main lags npm latest; package integrity verification stays enabled.2026.9.8Gateway. Pairing list/approve and approvals get/set/allowlist add/remove all refused the missing owner capability without changing independently queried pairing/approval rows or ownership. After an orderly stop and ownership release, candidate pairing list/approve and approvals get/set succeeded offline, with expected durable row changes and custody release. All ten cases passed and all owned processes settled.scripts/crabbox-wrapper.mjsandopenclaw-testbox-envon leasetbx_01m40fad7npxgq3fb0ghc7rqdd, Testbox run 37111042578. The combined command took 15m54.229s, exited 0, and the lease is verified stopped. A workflow cancellation from external lease cleanup is not a payload failure. The wrapper verified source7cd771fe5fa0f02667a2fd4ac39df20d45a25b29, tree1ac888ec1ec91649a79cc91f8ad278c12ea14b15; build commit5554a69b7d7eba166e784a7c3b6c3262184318b3is its synthetic source carrier. The candidate tarball passed integrity/import checks, SHA-2566db990f61c7aa2dc79ed132a5d2601b1ed48aa95a803014db934c4200d3348a7.Investigated failures
What Problem This Solves; changing only the body heading fixed it.dist/build-info.jsonwithout refreshing its inventory hash, and then included diagnostic-onlyrelabeledFromin the expected installed identity. Existing main fixes65d5066c6e901d64e57c2786956132862816fe27(test(e2e): keep the relabeled candidate's dist content inventory truthful #164036) and3f3bbcfea0b1cwere integrated with merge commits. The final full cell passes without disabling integrity checks or weakening the build-identity assertion.d9360fb,android-test-playhad a five-second timeout atTalkModeManagerTest.withStartedTalk, line 3110, while joining the manager coroutine in cleanup. Since this is afinallyblock, the original log cannot establish the earlier test-body outcome. Android source and generated Kotlin protocol outputs are byte-identical betweend9360fband base04d2853; final head7cd771feretains that Android source tree. Five completed scheduled-main Android jobs passed. Exactly five full-class runs per ref passed (10 × 109 tests, 0 failures/errors) on macOS/ARM64 with JDK 21.0.12.1, one fork, and uncached test execution: 912s head + 917s base command wall time, 555.553s test execution. Setup-incomplete archive attempts were excluded. This is an unreproduced, apparently unrelated teardown timeout, not an independently proven main failure or a fixed defect. No assertions, timeouts, or retry policy changed. The failed prior-head job was not rerun; final-head Android CI passed after the required fixture integration.