Repository navigation
fix: preserve operator access after Control UI restart recovery - #166553
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: blocked before merge. Reviewed October 7, 2026, 12:21 PM ET / 16:21 UTC (Revision 8). ClawSweeper reviewWhat this changesThe branch preserves authenticated operator permissions across Gateway restart recovery, adds live device-revocation fencing, and repairs the native-hook pressure fixture’s tool-output acknowledgments. Merge readiness⛔ Blocked before merge - 1 item remains This PR remains necessary: current main still reconstructs restricted System authority for restart recovery. No actionable introduced defect remains identified, and the prior generic compatibility blocker is resolved by the inspected source and upgrade evidence. Priority: P1 Review scores
Verification
How this fits togetherThe Gateway admits Control UI messages and stores interrupted-turn recovery claims. After restart, recovery reconstructs the caller’s current authority before resumed agent tools reach automation RPCs and persistence. flowchart TD
A[Authenticated Control UI message] --> B[Original operator admission]
B --> C[Private recovery claim]
C --> D[Gateway restart recovery]
D --> E[Current identity and permission checks]
E --> F[Resumed agent tools]
F --> G[Automation commit guard]
G --> H[Persisted job or refusal]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1121, Tests +1772, Docs +9. Total +2902 across 62 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Recover the exact authenticated input under current policy, preserving its original ceilings and rejecting revoked authority before persistence while retaining restricted legacy recovery. Do we have a high-confidence way to reproduce the issue? Yes: interrupt an authenticated automation turn after durable admission and allow startup recovery; current main reconstructs a restricted System principal that fails the admin RPC fence. The supplied baseline regression and real process-replacement evidence support this path; this review did not execute it. Is this the best way to solve the issue? Yes: exact-source re-admission through existing policy and commit owners repairs the lost authority without granting every recovery caller admin or deriving permission from session ownership. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fa8fc4242707. 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 (7 earlier review cycles)
|
00230a2 to
e9f6ca8
Compare
|
@clawsweeper re-review Addressed the final-effect concern and rank-up move at head Also repaired the two related CI test failures: canonical approved-scope normalization fixes the existing real WebSocket re-approval regression, and the SQLite lifecycle owner now retires the pairing-publication singleton. The original authority-worker → recovery order failed before that fix (1 failure/43 passes) and passes afterward (44 passes). Both lint findings are fixed. Fresh P0–P2 autoreview and targeted lint are clean. This follow-up is production-net-neutral; no new config or SQLite schema/version changes. Rebased without conflicts onto main's already-landed HTTP plugin-registry fix; range-diff confirms both repair commits unchanged. Exact-head CI is running; no merge requested or performed. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review New exact head All three held-dispatch cases failed before repair. After repair: 97/97 tests pass, including 13/13 real-Gateway spawn/MCP cases, pairing lifecycle siblings, recovered/original operator source checks, and actual automation held-write rejection after token/role/grant/claim revocation. Full build passed; fresh follow-up P0–P2 AutoReview is scoped-clean. Follow-up production net +32 LOC is the missing precise precommit boundary, reusing the existing receipt and admission owners with no added worker round-trip. Tests net +71 LOC. The prior compatibility checkpoint is addressed: 0 new/default config surfaces, 0 SQL DDL/schema-version changes, 0 new operator setup actions; private legacy source-less claims remain restricted. The PR body records the exact commands, transient diagnostic replay and named source-custody audit follow-up. Please review the prospective fencing behavior introduced after revision 3. Do not merge; this request is review-only. |
|
🦞👀 Re-review progress:
|
Narrow the repair to complete pairing binding publication. Ordinary database retirement keeps its existing revocation contract from openclaw#166553, and authority checks no longer stat the database path on the Gateway main thread.
…ing is being written (#169575) Backport of e158fc3 (#169575) adapted for 2026.10.3. 10.3 fenced in-flight writes via blocked ||= invalidatesAuthority; that fence is removed and finish() gains the unknown-settlement block main already had (from #166553), so a write that settles unknown still blocks until a fresh read. Regression uses 10.3's worker-operation spy. (cherry picked from commit e158fc3)
The native widget restart live proof reconnected its TEST observer with the original Control UI device identity and shared token. Since #166553, that reconnect changes the device token issuer, so restart recovery correctly revokes the interrupted turn ("Restart recovery operator authority changed; start a new user turn") and the session ends `failed` instead of `done`. Give the observer its own synthetic device identity, matching the deterministic twin fixed in 6b19665. Recovery assertions are unchanged. Deterministic proof: the e2e twin with the observer reusing the Control UI identity reproduces `status: "failed"` with the authority-revoked log line; with a separate identity it passes.
What Problem This Solves
Fixes automation creation failing with
missing scope: operator.adminwhen an authenticated Control UI turn automatically resumes after a Gateway restart.Closes #166542 — Control UI authority loss after restart recovery
Related, distinct: CLI bridge request-scope repair #157144 prevents one run from poisoning later callers; this change re-admits the interrupted operator turn itself. Org-wide automation disappearance #166336 reports fresh-run failures without a preceding restart and is not claimed fixed here.
User Impact
An interrupted authenticated operator turn can continue its authorized automation work after restart. Original scope/model ceilings remain in force, and credential rotation, device removal, profile/role changes, grant revocation, stale claims, or replacement/closed run owners stop privileged use.
No new configuration option, protocol version, SQLite schema/version, credential storage, or operator setup step. Older interrupted turns without the private source record remain restricted; send a fresh authenticated message to continue privileged work.
Why This Change Was Made
Recovery previously dispatched an unprofiled System principal with
operator.write; the real automation RPC correctly requiresoperator.admin. Giving every recovery/System caller admin or inferring it from session ownership would cross the authority boundary.The source admission now records bounded, credential-free authorization facts with its existing private recovery claim. Dashboard parent links are grouping ancestry, not delegation; actual spawned/delegated execution remains excluded by execution metadata. Gateway recovery re-admits that exact source under current policy and binds the replacement run to its current session, claim, runtime and registration. Automation management consumes that host-owned recovered admission, not attribution or a copied bearer value.
Original and recovered device-bound runs share the canonical pairing publication owner: the handshake pins the exact accepted/issued credential generation; public token rotation/removal/store closure revokes retained authority without per-use SQLite polling. Node host-stat updates preserve unrelated operator authority. The QA fixture now canonicalizes its allocated temp root so macOS
/tmpaliases agree with store-discovery custody; runtime custody guards are unchanged. Model preparation/restoration share one canonical predicate builder; cleanup retires the source with the claim. The legacy System path remains only for source-less claims, not a privileged fallback.Size and tradeoff
Production: +1273/-155 (net +1118); tests/test support (including QA setup and test routing): +1789/-14 (net +1775); docs: +9. No generated/lockfile changes. Growth is the missing cross-restart authority owner: bounded source capture/validation, exact claim re-admission, live revocation subscriptions and shared pairing-generation publication. Existing profile, role, grant, model, pairing and claim owners are reused; no second store, token cache, or admin bypass. A net-neutral blanket scope change cannot express this ownership/security boundary.
Evidence
9d33bbca28b3f0697ca32fdc042db13b59b02344failed with the exact admin scope error; the repaired runtime passes the same real authorization fence. Public device-rotation regressions also failed before repair (successor adoption during capture and restored authority remaining live).7423ac33520560with identical patch content (git range-diff); main’s crash-loop preparation gate is preserved.Follow-up review and CI repair
Earlier follow-up candidate:
23b6b42dab1e2a114ff65956ed12b7e6c2c1741b. The final test-only correction usesawaitGateBeforeSettlement/withinTestandit.forwith the real Vitest test signal, rather than a new wall-clock timeout. The timer ratchet passes; all 12 transport tests pass with unchanged final-effect assertions, and fresh P0–P2 autoreview is clean. Post-rebase runtime/transport sanity also passed 32 tests. ClawSweeper revision 2 rates the production repair platinum hermit, with sufficient proof and no actionable code/security finding. Config/upgrade compatibility was reviewed: the optional private source is persisted/reloaded and cleaned with its claim, omitted from public projection, and legacy source-less claims remain restricted; no new config/default, public API, SQL DDL, or schema-version change.silently repairs malformed persisted access lists on local re-approval.7a75498beb6ece381f483f7e194dd8665c77f3a1; both commits have identical content bygit range-diff. This incorporates the already-landed plugin-registry request-scope repair from #166523 — concurrent Gateway call authentication, which fixes the unrelated HTTP workspace-plugin reload gate. Two other initial test failures remain subject to exact-head CI verification; unchanged test text alone is not treated as proof that a failure is inherited.Commands for this follow-up:
The order configuration is a task-local temporary sequencer over the existing non-isolated database-worker suite; it only orders the two files alphabetically. The original full-suite CI run was
37603559803; a fresh run must cover the updated head.Commands
Proof scope and gaps
The UI proof uses a real isolated Gateway, real browser handshake/chat ingress, process replacement, SQLite persistence and actual tool/RPC authorization. Only model responses are deterministic local fixtures; this is not live-provider or live-Telegram proof. The operator's running Gateway/state are untouched.
The original report's exact historical failed tool call was unavailable in bounded history retrieval; restart recovery is an independently reproduced matching defect, not a conclusive attribution of that incident. The attached original screenshot is labeled reported symptom, not a newly captured pre-fix run.
Review dispositions, source audit, and provenance
AI-assisted. Final frozen-diff P0–P2 autoreview is clean with no accepted/actionable findings. Earlier review dispositions:
Removing current model restrictions means unrestricted current policy, not deny-all.
intersectOperatorRunModelPolicypreserves the original ceiling when current policy is absent and intersects when both exist. Ordinary/channel/recovered runs share it; recovery cannot widen the original ceiling.recoverTerminalSessionEntryForVisibleTurnclears both delivery/source run IDs alongside the operator source. Its caller prepares a later visible turn, not startup recovery of the old claim; the review's retained-claim premise was false.The lifecycle file already imports
InternalSessionEntry as SessionEntryat line 2; the final review overlooked that alias and incorrectly claimed it indexed a private field through the public type.Evidence map: chat admission (
chat-user-turn-recorder.ts/chat-restart-recovery.ts) -> private source claim (restart-recovery-claim.ts, commandsession-preparation.ts) -> recovery dispatch (main-session-restart-dispatch.ts,server-instance-runtime.ts) ->operator-run-recovery.ts-> existing operator/profile/grant/model/pairing owners -> real cron creator admission/RPC. Tests exercise source-boundary revocation and current-main System scope behavior. Core tests include ordinary/channel and source-less sibling paths; UI proof also exercises cross-channel automation-management authorization.The write-only recovery principal is present in shipped
v2026.9.8; blame traces it to53dcaaedec195fdaf5af06357557c706d3c0caf5(2026-08-24, Peter Steinberger; generic operator roles, #128548). This identifies the source of the restriction, not an unsupported claim about the exact first affected release or original incident.Direct sibling Codex contract inspection:
codex-rs/app-server/src/request_processors/thread_processor.rs:3479and:3902(resume configuration and persisted permission settings),codex-rs/rollout/src/recorder.rs:820and:953(resumed recorder ownership/recording). No Codex protocol change or live Codex proof claimed.Inspected browser proof
Before the dashboard-grouping correction (candidate live regression, not the original source baseline):
After correction: the recovered turn returns the persisted disabled automation:
19-second real isolated Gateway replacement recording. Only the model is deterministic; no recovery claim or user turn is injected:
[email protected]
Original reported symptom, separately labeled; exact historical tool call unavailable:
Pending-pairing authority CI repair
The exact-head run
37630477087failed three existing real-Gateway spawn cases before parent provider dispatch. The new pairing publication globally blocked retained operator sources during every pending pairing mutation. Same-token verification, token reuse, bootstrap issuance and reconnect metadata could therefore latch permanent run revocation without changing the accepted credential.The canonical worker now carries its existing prospective binding receipt into final commit admission. The publication checks that exact next identity/scope ceiling before granting COMMIT; unchanged and unrelated credentials stay live. Node mutation fencing is preserved; foreign revision mismatches and unknown native settlement remain fail-closed. No command-specific retry, keepalive, consumer guard or scope relaxation.
sessions.patchrefusal; that occurrence is not attributed to this repair. The final full spawn/MCP replay includes that path and passed with unchanged assertions; exact-head hosted CI remains the final gate.Commands:
node scripts/run-vitest.mjs src/infra/device-pairing-publication.test.ts -t 'keeps accepted operator' node scripts/run-vitest.mjs src/infra/device-pairing-publication.test.ts src/infra/device-pairing-worker.test.ts src/gateway/operator-run-recovery.test.ts src/gateway/operator-run-authority.worker.test.ts src/gateway/server-methods/cron-creator-transports.integration.test.ts src/gateway/server.visible-spawn-fallback.product-proof.test.tsFull build passed (
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build, 4m54s). Current follow-up candidate:067cd32300f69d9991b4f9fad9fecd35e2eb4b74.Final local gates
Head
f60d1fbafd85c51416c4e2763bbc7e628d89b01dadds only a lint-required local-variable rename after the scoped-clean behavioral review.git diff --check, targeted oxfmt and focused typed oxlint passed. The complete seven-filenode scripts/check-changed.mjs -- <changed paths>plan passed (exit 0): core production typing, all 27 core-test type graphs, plugin/root-test typing, dead-export scans, changed-file lint, schema/database-first and runtime guards. The 97-test owner/sibling proof and full build remain applicable; no behavior changed after those runs. Exact-head hosted CI remains pending.Node admission owner correction
CI run 37635826937 exposed an introduced owner-boundary defect: the new private
pairing-publicationreceipt was forwarded to node-specific domain admission callbacks, which intentionally reject non-node facts. The broker now consumes that fact privately; its callback type excludes publication facts and existing node-policy validation remains unchanged. No weaker validation or fallback was added.Pre-fix
node scripts/run-vitest.mjs src/infra/device-pairing-node-bins.worker.test.tsfailed withinvalid node pending admission facts. After the correction, 77/77 tests passed across publication authority, node bins, node handlers, local/SSH node pairing, device join and real-Gateway spawn fallback. The additional CI-failed approval-bypass, shutdown and message-event files also passed: 29 + 9 cases, bringing the expanded owner/sibling replay to 115/115. Fresh AutoReview P0–P2 is scoped-clean; focused typed oxlint, oxfmt andgit diff --checkpassed. Follow-up production delta is +5/-2, net +3 lines, for the missing private/domain boundary; no test growth. Headc33c1a925e8807648bc411a935b277dcf065bf90is pushed; changed checks passed. Exact-head CI run37638019958has one failing Node shard: the matched Linux Codex hook-pressure case expected 20 policy calls but observed zero; the other pressure cases and pairing/node shards passed. The PR is not RFR while the required CI gate is red.The final-head ClawSweeper review of the preceding head reported platinum hermit / diamond-lobster proof with no actionable code/security findings. Its retained generic config-compatibility checkbox is satisfied by the documented zero-option/zero-default/zero-DDL surface and optional-record reload/legacy proof; no compatibility policy is waived.
Current RFR follow-up — October 7, 2026
Current pushed head:
3136c308ef49cc59095c7244aecd7926f63fbf2f. The preceding head's exact CI had one failing Node shard: the matched Linux Codex hook-pressure case expected 20 policy calls and observed zero. Exact-head CI run 37646553490, attempt 1 completed successfully: all 111 jobs finished, including the previously failing Node shard, with no failing required check. Local owner/sibling proof, corrected Linux replay, changed checks and fresh AutoReview are complete. The PR is review-ready and remains unmerged.The configured Blacksmith Testbox could not dispatch (HTTP 500). Direct AWS ran the unchanged PR source through a real isolated Linux Gateway and Codex 0.160.0: 3/3 pressure cases passed, including matched 1/5/20/deny-1, unmatched and no-policy. No owned relay or zombie survived. Unchanged replay: test command exit 0; the wrapper subsequently failed signed-terminal-receipt persistence with HTTP 500 (wrapper exit 7). This infrastructure limitation is not described as a test failure or a verified signed receipt.
A separate deterministic reproduction confirmed an existing fixture defect:
issuedbecame true before a tool response was delivered, and the next request returned DONE without any tool-output acknowledgment. The fixture and transport were unchanged on inspected current maincb01febf9fa4fbda271d10b3adff3b384c6ece76. Injecting one shared-provider no-detailsresponse.failedevent before delivery into the existing matched count20 scenario made the old fixture fail its unchanged exact-count assertion: terminal ok, outputs empty, one unacknowledged retry, zero relays, zero of 20 policy calls. Pre-fix reproduction, command exit 1. This proves the fixture defect; it does not establish that the original CI failure used this path.The canonical repair replaces issuance state with exact
function_call_output.call_idacknowledgments: replay only missing calls and emit DONE only once every expected call has an output. The count20 fault injection is retained in the existing case. Original hook counts, successful command/output/workspace-file checks, deny/no-policy/unmatched assertions, and relay teardown remain intact; no timeout, runtime guard, transport, config, or dependency changed. Timing reports record the injected failure, rather than presenting retry latency as an unfaulted pressure baseline. Production delta 0; test delta +44/-6, net +38.Corrected real-Gateway replay: 3/3 cases passed (test command and wrapper exit 0): matched 1/5/20/deny-1, including exactly 20 policy calls after the dropped response and all workspace files/outputs; unmatched and no-policy still produced no policy work/relays. All cases finished with no retained relay or zombie. Verified source tree
8353a63295adaa89e55f9cbc5900f48bf5bfc775, test SHA-256439a6cd4cd92973cb3a6a86ec3363aee8ec260de4edb79188ddbedcddf60d1f2, identical to the pushed test bytes. Commands:CI=1 OPENCLAW_E2E_VERBOSE=1 OPENCLAW_VITEST_MAX_WORKERS=1 node scripts/run-vitest.mjs extensions/qa-lab/src/codex-native-hook-pressure.e2e.test.ts(pre-fix restricted with-t "records matched policy");node scripts/check-changed.mjs -- extensions/qa-lab/src/codex-native-hook-pressure.e2e.test.tspassed, including typing, formatting, guards, dead exports and typed lint;git diff --checkpassed. Fresh AutoReview--mode uncommitted --engine codex --max-priority P2is scoped-clean with no actionable findings.Personal sibling Codex source inspection at
rust-v0.160.0:codex-rs/core/src/tools/registry.rs:603(PreToolUse before execution),codex-rs/core/src/tools/handlers/unified_exec/exec_command.rs:520(Bash/cmd hook payload),codex-rs/core/src/session/turn.rs:1642andcodex-rs/core/src/responses_retry.rs:137(sampling retry),codex-rs/codex-api/src/sse/responses_error.rs:25andcodex-rs/protocol/src/error.rs:418(no-details failure is retryable Stream),codex-rs/core/src/session/turn.rs:2466(drain tool output into history before subsequent sampling).ClawSweeper revision 7 reviewed exact head
3136c308ef49cc59095c7244aecd7926f63fbf2f: diamond lobster, no actionable code/security finding; it accepts the repaired fixture proof and explicitly resolves the compatibility checkpoint. Compatibility confirmation remains unchanged: 0 new/removed config options/defaults, 0 SQL DDL/schema-version changes, optional private recovery facts persist/reload, source-less legacy claims stay restricted, public projections exclude private facts, and cleanup is claim-owned. No Rank-up moves or actionable findings remain. The retained generic Before merge compatibility checkbox is covered by the source/upgrade contract above and the review's own Compatibility checkpoint resolved evidence; no config/default/schema or public contract changed in the follow-up. No merge requested. Task-owned AWS lease is confirmed released.