Skip to content

fix: preserve operator access after Control UI restart recovery - #166553

Merged
RomneyDa merged 7 commits into
mainfrom
fix/restart-recovery-operator-authority
Oct 7, 2026
Merged

RomneyDa merged 7 commits into
mainfrom
fix/restart-recovery-operator-authority

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes automation creation failing with missing scope: operator.admin when 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 requires operator.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 /tmp aliases 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

  • Live dashboard restart testing also exposed parent-linked depth-zero roots being rejected at source capture. The grouping regression failed before removing that incorrect delegation check; all recovery fixtures now carry the real dashboard grouping shape.
  • Pre-fix boundary regression against 9d33bbca28b3f0697ca32fdc042db13b59b02344 failed 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).
  • 277 core/sibling tests passed before the additional device-publication repair. Final post-handoff rerun: 104 passed across seven files, covering original/recovered/source-less cron admission, exact dispatch identity, retained registration loss, profile/role/grant/device changes, model-ceiling intersection and pairing/node lifecycle siblings.
  • Post-rebase runtime sanity: 20 passed across the recovery and canonical Gateway runtime suites, including the current preparation gate.
  • Final grouped-dashboard recovery/runtime rerun: 37 passed across two files.
  • Final fixture/runtime rerun: 62 passed, one existing skip across the runtime recovery and QA Gateway-child suites.
  • Final correction changed checks passed (exit 0), including all 27 core-test type graphs and zero runtime import cycles. Rebased once onto 7423ac33520560 with identical patch content (git range-diff); main’s crash-loop preparation gate is preserved.
  • Changed format/lint/guards, core and plugin production/test typechecks passed. The dead-export scan caught one unnecessary type export; after making it file-local, all three export scans passed with zero entries. Full build passed; fresh review dispositions are below.
  • Both real-Gateway UI scenarios passed. An ordinary authenticated Control UI turn survives SIGKILL/process replacement, automatically creates one disabled hourly automation through the actual tool/RPC scope fence, preserves the original session and one user input, and clears/settles the original claim. The cross-channel fixture confirms owners/admin can manage a synthetic Telegram-origin job while a non-owner cannot.

Follow-up review and CI repair

Earlier follow-up candidate: 23b6b42dab1e2a114ff65956ed12b7e6c2c1741b. The final test-only correction uses awaitGateBeforeSettlement/withinTest and it.for with 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.

  • Addressed ClawSweeper's final-effect proof concern and its rank-up move at the existing real Cron/automation boundary, not by adding production guards. Recovered callers first create an allowed disabled job, then start another actual automation write held inside awaited channel validation. Device-token rotation, profile-role downgrade, access-grant revocation, and recovery-claim retirement each reject that held write before persistence; the complete persisted job list remains unchanged. All four revocation cases passed, alongside fresh/recovered/source-less admission and existing transport cases.
  • Reused the existing approved-device-scope normalizer for both token verification and retained authority. The raw pairing-binding projection previously attempted to trim malformed persisted approval elements before the existing local re-approval repair could run. The existing real WebSocket regression now passes: silently repairs malformed persisted access lists on local re-approval.
  • Registered the pairing-publication singleton with the existing SQLite test-lifecycle retirement owner. Forced the original CI order (authority-worker tests before recovery tests): pre-fix 1 failed, 43 passed; post-fix 44 passed. No consumer-only environment override or weaker assertion.
  • Fixed both reported lint errors; targeted core, test-support, and QA lint passed. Fresh follow-up P0–P2 autoreview clean, with no accepted/actionable findings. Follow-up production net 0 LOC; tests/test support net +123 LOC.
  • Rebased cleanly onto 7a75498beb6ece381f483f7e194dd8665c77f3a1; both commits have identical content by git 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.
  • Compatibility reaffirmed: 0 new/removed config options, 0 SQL DDL/schema-version changes, 0 new setup actions. Original policy/model ceilings remain bounded; old source-less interrupted claims remain restricted. The private optional source is cleared with the existing claim and is not projected to public session data.

Commands for this follow-up:

node scripts/run-vitest.mjs src/gateway/server-methods/cron-creator-transports.integration.test.ts
node scripts/run-vitest.mjs src/gateway/server-methods/cron-creator-transports.integration.test.ts -t 'device token rotation'
node scripts/run-vitest.mjs src/gateway/server.auth.control-ui.test.ts -t 'silently repairs malformed persisted access lists on local re-approval' --maxWorkers=1
node scripts/run-vitest.mjs run --config .artifacts/pr166553/order.config.ts --configLoader runner src/gateway/operator-run-authority.worker.test.ts src/gateway/operator-run-recovery.test.ts

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

node scripts/run-vitest.mjs src/gateway/operator-run-recovery.test.ts src/gateway/operator-run-authority.worker.test.ts src/infra/device-pairing-publication.test.ts src/infra/device-pairing-identity.test.ts src/infra/device-pairing-worker.test.ts src/gateway/server-instance-runtime.operator-recovery.test.ts src/gateway/server-methods/cron-creator-transports.integration.test.ts
node scripts/run-vitest.mjs src/gateway/server-instance-runtime.operator-recovery.test.ts extensions/qa-lab/src/gateway-child.test.ts
node scripts/run-vitest.mjs src/gateway/server-instance-runtime.operator-recovery.test.ts src/gateway/server-instance-runtime.test.ts
node scripts/check-changed.mjs
node scripts/check-changed.mjs -- src/agents/operator-run-recovery-source.ts src/gateway/operator-run-recovery.test-support.ts
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build
OPENCLAW_CAPTURE_UI_PROOF=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner extensions/qa-lab/src/control-ui-automation-management.real-gateway.e2e.test.ts

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. intersectOperatorRunModelPolicy preserves 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.

  • recoverTerminalSessionEntryForVisibleTurn clears 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 SessionEntry at 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, command session-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 to 53dcaaedec195fdaf5af06357557c706d3c0caf5 (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:3479 and :3902 (resume configuration and persisted permission settings), codex-rs/rollout/src/recorder.rs:820 and :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):

Restart recovery without automation authority

After correction: the recovered turn returns the persisted disabled automation:

Recovered operator turn creates its 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:

Original reported operator.admin error

Pending-pairing authority CI repair

The exact-head run 37630477087 failed 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.

  • Deterministic held-dispatch owner regression: 3 failed before repair (verification, token reuse, bootstrap issuance); all pass afterward.
  • Final focused owner/sibling proof: 97 passed across six files, including 13/13 real-Gateway spawn/MCP scenarios, pairing read/commit/foreign-write/close paths, original/recovered operator authority, and the real automation final-effect fence after token/role/grant/claim revocation.
  • A separate diagnostic replay also reported a CLI sessions.patch refusal; 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.
  • Fresh follow-up AutoReview: P0–P2 scoped-clean, no accepted/actionable findings. Review covers this follow-up diff; surrounding transaction/publication helpers were personally inspected by the lead.
  • Follow-up production +48/-16 (net +32); tests +73/-2 (net +71). Growth is the missing precise precommit authority boundary, reusing the existing binding producer, worker admission and receipt owner. No new store, config, environment option, SQL DDL or schema version; no extra worker round-trip.
  • ClawSweeper's prior compatibility checkpoint was reviewed: 0 new/default config surfaces, 0 SQL DDL/schema-version changes, 0 new operator setup actions. Private legacy source-less claims stay restricted and source data remains private.
  • Named follow-up: pairing-source custody audit for admission-generation invalidation independent of physical file identity and handshake store capture versus later ambient path resolution. These are structural observations, not demonstrated causes of this CI failure; no speculative compatibility or keepalive changes were made.

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.ts

Full build passed (OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build, 4m54s). Current follow-up candidate: 067cd32300f69d9991b4f9fad9fecd35e2eb4b74.

Final local gates

Head f60d1fbafd85c51416c4e2763bbc7e628d89b01d adds 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-file node 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-publication receipt 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.ts failed with invalid 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 and git diff --check passed. Follow-up production delta is +5/-2, net +3 lines, for the missing private/domain boundary; no test growth. Head c33c1a925e8807648bc411a935b277dcf065bf90 is pushed; changed checks passed. Exact-head CI run 37638019958 has 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: issued became 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 main cb01febf9fa4fbda271d10b3adff3b384c6ece76. Injecting one shared-provider no-details response.failed event 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_id acknowledgments: 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-256 439a6cd4cd92973cb3a6a86ec3363aee8ec260de4edb79188ddbedcddf60d1f2, 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.ts passed, including typing, formatting, guards, dead exports and typed lint; git diff --check passed. Fresh AutoReview --mode uncommitted --engine codex --max-priority P2 is 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:1642 and codex-rs/core/src/responses_retry.rs:137 (sampling retry), codex-rs/codex-api/src/sse/responses_error.rs:25 and codex-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.

@clawsweeper

clawsweeper Bot commented Oct 7, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: qa-lab size: XL labels Oct 7, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review October 7, 2026 09:52
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 3136c308ef49cc59095c7244aecd7926f63fbf2f
  • Maintainer: @RomneyDa
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/operator-role-source-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/cron-creator-authority-admission.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-operator-access.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-session.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-admission.types.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-binding.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-dispatch.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-identity.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-mutation.worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-publication.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-read.types.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-tokens.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-worker.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 7, 2026, 12:21 PM ET / 16:21 UTC (Revision 8).

ClawSweeper review

What this changes

The 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
Reviewed head: 3136c308ef49cc59095c7244aecd7926f63fbf2f

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong production-boundary proof, exact-head CI, and coherent authority ownership support readiness with no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Recorded isolated real-Gateway/browser process replacement exercises recovery admission through actual automation persistence, and the authorized production-path harness proves allowed creation plus rejection after token, role, grant, and claim revocation. Optional-source persistence/reload, claim cleanup, private projection, and restricted legacy claims establish existing-state compatibility without migration; media was not independently viewed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): Recorded isolated real-Gateway/browser process replacement exercises recovery admission through actual automation persistence, and the authorized production-path harness proves allowed creation plus rejection after token, role, grant, and claim revocation. Optional-source persistence/reload, claim cleanup, private projection, and restricted legacy claims establish existing-state compatibility without migration; media was not independently viewed.
Evidence reviewed 12 items Pinned introduction and continuing necessity: Reviewed the merge-base-to-head introduced delta. Current fetched main still dispatches recovery with a System principal and has no original-operator restoration in this path; this PR’s operator restoration remains distinct useful work. The stale test merge was not used to infer removal of base-only behavior.
Compatibility checkpoint resolved: The only Gateway config-schema hunk exports an existing validator; it changes no validation rule, option, or default. The persisted addition is an optional private recovery-source record, excluded from public session projection and cleared with its claim. No SQL DDL or schema-version change is introduced.
Persisted-source and legacy compatibility: Inspected coverage persists and reloads the bounded source, preserves a write-only original ceiling, and verifies that source-less legacy claims receive no restored operator authority. Different source turns, sessions, and lifecycle identities are rejected. The captured body reports passing owner and runtime replays.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
Agent review details

Security

None.

PR surface

Source +1121, Tests +1772, Docs +9. Total +2902 across 62 files.

View PR surface stats
Area Files Added Removed Net
Source 48 1277 156 +1121
Tests 13 1785 13 +1772
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 62 3071 169 +2902

Review metrics

Metric Value Why it matters
Configuration and upgrade surface 0 new options or defaults; 1 optional private recovery record The validator export adds no configuration surface, and persisted-source reload plus restricted legacy behavior clear the previous compatibility checkpoint.
Production versus test growth production net +1118; tests and support net +1775 Production growth is explicitly justified by exact cross-restart authority ownership and live revocation rather than a blanket scope expansion.

Stored data model

Persistent data-model change detected: serialized state: src/auto-reply/reply/restart-recovery-claim.ts, unknown-data-model-change: src/auto-reply/reply/restart-recovery-claim.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #166542
Summary: This PR directly owns the restart-recovery admission repair; the CLI bridge scope leak and fresh-run automation disappearance have different reported mechanisms.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: Automatic restart recovery currently blocks already-admitted operator automation work.
  • merge-risk: 🚨 security-boundary: The patch restores privileged authority across restart; exact-source admission and recorded allowed/revoked final-effect proof cover the accepted boundary.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): Recorded isolated real-Gateway/browser process replacement exercises recovery admission through actual automation persistence, and the authorized production-path harness proves allowed creation plus rejection after token, role, grant, and claim revocation. Optional-source persistence/reload, claim cleanup, private projection, and restricted legacy claims establish existing-state compatibility without migration; media was not independently viewed.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded isolated real-Gateway/browser process replacement exercises recovery admission through actual automation persistence, and the authorized production-path harness proves allowed creation plus rejection after token, role, grant, and claim revocation. Optional-source persistence/reload, claim cleanup, private projection, and restricted legacy claims establish existing-state compatibility without migration; media was not independently viewed.

Evidence

What I checked:

  • Pinned introduction and continuing necessity: Reviewed the merge-base-to-head introduced delta. Current fetched main still dispatches recovery with a System principal and has no original-operator restoration in this path; this PR’s operator restoration remains distinct useful work. The stale test merge was not used to infer removal of base-only behavior. (src/gateway/server-instance-runtime.ts:195, fa8fc4242707)
  • Compatibility checkpoint resolved: The only Gateway config-schema hunk exports an existing validator; it changes no validation rule, option, or default. The persisted addition is an optional private recovery-source record, excluded from public session projection and cleared with its claim. No SQL DDL or schema-version change is introduced. (src/config/zod-schema.gateway.ts:82, 3136c308ef49)
  • Persisted-source and legacy compatibility: Inspected coverage persists and reloads the bounded source, preserves a write-only original ceiling, and verifies that source-less legacy claims receive no restored operator authority. Different source turns, sessions, and lifecycle identities are rejected. The captured body reports passing owner and runtime replays. (src/gateway/operator-run-recovery.test.ts:303, 3136c308ef49)
  • Allowed and revoked final effects: The existing production-path automation harness first persists an allowed disabled job, then pauses another actual write during awaited validation. Token rotation, role downgrade, access-grant revocation, and claim retirement each reject the pending write with the complete persisted job list unchanged. The body and follow-up comment report all four cases passing; injected principals use the real restoration, tool dispatch, RPC, and persistence owners. (src/gateway/server-methods/cron-creator-transports.integration.test.ts:205, 3136c308ef49)
  • Real Control UI process replacement: Recorded proof exercises ordinary browser handshake/chat ingress against an isolated real Gateway, SIGKILL/process replacement, automatic recovery, and a persisted disabled automation. Source assertions verify the original session, exactly one original user input, and settled/cleared recovery custody. Only model responses are deterministic fixtures. Local downloaded media was not found, so no claim of independently inspecting the screenshots or recording is made. (extensions/qa-lab/src/control-ui-automation-management.real-gateway.e2e.test.ts:188, 3136c308ef49)
  • Complete captured body inspected: Read the omitted body ranges through the read-only pull endpoint and verified SHA-256 6d7f9db87fd70f8e1b21fe2c97234039ea84f36ceaaa88e46593f486360cd941, matching the supplied snapshot. It records the allowed/revoked automation results, compatibility evidence, corrected Linux real-Gateway replay, and explicit limits on attribution of the original incident. (3136c308ef49)

Likely related people:

  • Peter Steinberger: Raw commit 49c1815 adds src/gateway/server-instance-runtime.ts:164 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 49c18152c8bf; files: src/gateway/server-instance-runtime.ts)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-07T09:58:26.577Z sha 00230a2 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-07T13:35:51.831Z sha e9f6ca8 :: blocked before merge. :: none
  • reviewed 2026-10-07T13:46:56.979Z sha 23b6b42 :: blocked before merge. :: none
  • reviewed 2026-10-07T14:28:25.441Z sha f60d1fb :: blocked before merge. :: none
  • reviewed 2026-10-07T14:42:46.912Z sha c33c1a9 :: blocked before merge. :: none
  • reviewed 2026-10-07T15:37:44.878Z sha c33c1a9 :: blocked before merge. :: none
  • reviewed 2026-10-07T15:57:07.389Z sha 3136c30 :: blocked before merge. :: none

@RomneyDa
RomneyDa force-pushed the fix/restart-recovery-operator-authority branch from 00230a2 to e9f6ca8 Compare October 7, 2026 13:30
@RomneyDa

RomneyDa commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Addressed the final-effect concern and rank-up move at head e9f6ca8cfdf82d3406f11b3a13900aa7849ac4ce. Recovered callers attempt a real automation write while Cron validation awaits; token rotation, role downgrade, access-grant revocation, and claim retirement each reject it with the complete persisted job list unchanged. Fresh/recovered/source-less and sibling transports are preserved. Commands and observed results are now in the PR body.

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.

@clawsweeper

clawsweeper Bot commented Oct 7, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 7, 2026
@RomneyDa

RomneyDa commented Oct 7, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

New exact head 067cd32300f69d9991b4f9fad9fecd35e2eb4b74 fixes the related real-Gateway spawn CI regression in the pairing publication owner. Global pending-mutation blocking could permanently revoke an accepted operator run during same-token verification, token reuse or bootstrap issuance. The existing worker now carries exact prospective bindings through final commit admission; changed credentials are fenced before COMMIT is granted, while unchanged sources remain live. Node mutation fences, foreign-revision refusal and unknown-settlement fail-closed behavior remain.

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.

@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

RomneyDa added a commit to Oldrich333/openclaw that referenced this pull request Oct 11, 2026
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.
RomneyDa pushed a commit that referenced this pull request Oct 13, 2026
…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)
RomneyDa added a commit that referenced this pull request Oct 17, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed size: XL 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.

Control UI turns lose operator.admin after automatic restart recovery

1 participant