Skip to content

fix(update): restore Doctor-owned config includes on rollback - #160443

Merged
steipete merged 2 commits into
mainfrom
codex/complete-update-recovery
Sep 28, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/complete-update-recovery

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Related: #158491, #144005, #145169.

What Problem This Solves

A failed package update could restore Doctor's changes in the root config, but could not restore changes Doctor made in a $include file.

User Impact

Automatic rollback can restore the exact original include bytes while preserving later operator edits and changed symlink targets. Missing, malformed, or concurrently changed includes still reach Doctor; an incomplete capture warns that automatic config rollback is unavailable. Config capture also works when the candidate has already advanced the database schema beyond the parent updater.

Doctor repairs still follow the existing single-owner include write boundary; mixed root/include repairs refuse before writing. This covers package Doctor and the existing guarded rollback path. Full-state capture, legacy/adopted Doctor continuity, and preservation across recovered-generation publication remain open requirements in the predecessor PRs.

Why This Change Was Made

Extend the existing config snapshot with raw include preimages, and have the actual include writer record its input/output hashes through the existing Doctor result. Rollback uses the existing executor and writer locks, checks the captured graph, and restores only contiguous Doctor-owned changes. Path facts survive the existing JSON finalizer handoff; they grant no write authority. Archive capture retains its stricter alias policy.

Capture uses the existing core-only config reader, avoiding unrelated plugin-state reads. Typed capture conflicts disable restoration after read work settles; other errors still propagate. No manager, ledger, SQLite schema, dependency, or public option is added. This continues the recovery work by @steipete and @fuller-stack-dev.

The optional include-write receipt uses the existing Doctor IPC. The published 2026.9.6 reader ignores unknown fields; its root-only updater still refuses rollback after include changes. A candidate cannot retroactively give an already-running older updater include preimages it never captured.

Evidence

  • The original regression failed on base db566b09398198eb39a1ebb10748df2a25b2a1db: the real include writer changed info to warn, but rollback left warn; the operator-edit control passed.

  • Crabbox / Blacksmith Testbox Linux proof: 74 selected tests passed across six owners at tree 9ccf3c9f09d6411c90537947cee218ef7dd614ac. Missing-receipt and unresolved-include negative controls failed for their intended reasons before correction. Schema-mode delta: seven selected tests passed at tree b0ec2a4a78410c890fecdbb392d425966e5e23d1. These overlapping results are not summed or represented as final-head execution.

  • The final correction has local RED→GREEN for two real boundaries: a schema-20 SQLite file inspected by schema-19 code, and an include edited after discovery but before the actual capture reader. Doctor is reached, the database/operator bytes remain unchanged, and uncertain capture cannot acquire rollback ownership. The final committed head 69ff071f8c2b482a8515484c030127f40450069e / tree fb51539370aa9d41a5a5ef69c65825bdedd399d3 passed all eight selected Crabbox cases across two files in 103.34 s, with the native wrapper joined at exit 0. Installed-updater qualification also passed in the separate scenario below.

  • Installed Crabbox / Blacksmith Testbox proof passed the unmodified published 2026.9.6 first hop, real schema migrations, state survival, Gateway health, agent turn, plugin checks, and no-op update. The newly installed repaired updater then drove a distinct private same-schema target; Doctor changed the real include, the fixture refused the target service start, and the updater restored exact original root/include bytes and the previous package/build. The previous Gateway was healthy, the same run ended rolled-back, and the command retained exit code 1. This second fixture sets plugins.enabled=false to isolate the existing supported include-only write boundary; first-hop plugin coverage remains enabled. The fresh package SHA-256 is c06bc060c8277f17b9e254176a385413f748bd0dbf394cbfda7ab2bcaf7a3824, built from the final reviewed source/tree without skipping the build.

  • Production and selected source test-type checks pass, with the final delta's affected test graph rechecked. Formatting, scoped lint, line-cap, whitespace, unused exports, and runtime import-cycle checks pass. The earlier source type selection contains 17 graphs; its initial alias-fixture typing error was fixed and the affected graph rechecked.

  • The old-base check:changed passed 16 stages before the unchanged 721-root UI budget gate; canonical 52ae7e314dc2bf704449a3526abb4e3423649376 fixes that gate. Remaining affected guards passed separately. No broad-check success is claimed for that base.

  • Independent review completed through P2. Verified unresolved-include and capture-race findings were fixed. The combined compatibility/race correction is scoped-clean. An earlier schema-invalid-graph concern was rejected with source evidence: its ownership refusal belongs to archive discovery, which update capture does not call.

  • Previous-head CI recorded 148 successful jobs, one UI motion test failure plus the aggregate failure, and fail-fast cancellations. The browser-mocked desktop/multiline cases observed two scroll positions where the test requires more than two. Their UI/harness/toolchain inputs match tested main, and they do not invoke the updater changes; animation versus sampling timing remains unproven. The failure is retained and routed to its UI owner, without a passing-rerun claim.

  • Final-head CI recorded 152 successful jobs, two heartbeat delivery-confirmation timeouts in one job, its aggregate failure, six fail-fast cancellations, and 21 skipped jobs. The actual tested merge d57b7da9702d4ac2c39777f9cf8512a59cb78e88 has main parent 3a300c650a5b87c4f84afeea7c2ff3a1df70e4ee and this PR head. Independently inspected failure inputs match that main parent; explicit config and injected reply/transport fixtures bypass the changed updater and Doctor paths. The timeout cause remains unknown, with no baseline replay or passing rerun claimed. The operator-authorized native pre-existing-failure route retains failed/cancelled results and enforces security and required review gates.

The rollback matrix mocks service/package actions; config capture, include writes, JSON receipt transport, locks, and restoration are real. The installed proof distinguishes the published first-hop compatibility check from include rollback driven by the newly installed repaired updater. Its service manager is synthetic; the package, updater, Doctor, and Gateway run for real.

Measured with one worker: the six-owner command took 228.92 s including preparation; its selected rollback cases took 82.929 s, with the four new include/alias cases totaling 12.172 s. The Doctor receipt case took 2.100 s; missing/malformed cases took 47.5/11.4 ms. The newer-schema and capture-race GREEN cases took 1.432 s and 277.8 ms respectively; cold local wrapper preparation is reported separately in the retained logs. The successful installed scenario took 1,021.94 s; its fresh canonical package build and tarball integrity check took 511.89 s. The automatic artifact collector failed after scenario success (collector exit 9, wrapper exit 7); native download recovered all raw evidence and the package hash was independently verified. Both task-owned leases are completed; wrapper success is not claimed.

The retained earlier installed attempt hit the documented mixed root/include write refusal during plugin-cohort repair before any config write. Its healthy package rollback did not qualify the intended include scenario. A subsequent corrected attempt was terminated by the provider: the Actions runner recorded cancellation by its service bot and stopped Docker with SIGTERM; no product failure is attributed to that interruption. The original build also reported a Control UI startup gzip ratchet warning (374,117 B versus 372,347 B); package build/integrity succeeded, but no clean UI performance gate is claimed.

Retain raw include preimages with the existing config snapshot and attribute
changes to the actual Doctor writer. Restore only contiguous owned writes while
preserving later edits and alias changes. Incomplete include graphs still reach
Doctor, with automatic config restoration disabled and an explicit warning.

Related: #144005, #145169

Co-authored-by: Jason (Json) <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 28, 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 cli CLI command changes size: L labels Sep 28, 2026
@steipete steipete self-assigned this Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 12:26
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 28, 2026, 12:44 PM ET / 16:44 UTC (Revision 4).

ClawSweeper review

What this changes

The branch captures configuration include files before update-time Doctor runs, records Doctor’s writes, and restores verified original include bytes during a failed package update.

Merge readiness

⛔ Blocked before merge - 1 item remains

Current main still cannot restore Doctor-written config includes, so this PR remains useful. The updated PR body describes an installed, source-bound rollback scenario that addresses the prior review’s proof request; source review found no new blocking defect.

Priority: P1
Reviewed head: 69ff071f8c2b482a8515484c030127f40450069e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch follows existing owners and supplies focused boundary tests plus a source-bound installed recovery account, with no actionable finding from this review.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body ties the final-head updater and Doctor include path to an installed published-updater first hop and a repaired-updater failed activation, reporting restored original include bytes and a healthy previous Gateway. Operator-edit and changed-alias controls exercise refusal at the config boundary. The added Doctor result field is optional temporary IPC, with no durable stored-data schema change.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body ties the final-head updater and Doctor include path to an installed published-updater first hop and a repaired-updater failed activation, reporting restored original include bytes and a healthy previous Gateway. Operator-edit and changed-alias controls exercise refusal at the config boundary. The added Doctor result field is optional temporary IPC, with no durable stored-data schema change.
Evidence reviewed 8 items Current main remains root-only: The current-main rollback checks included content but restores only the root config file; this PR’s central behavior is not on main.
Introduced capture path: The pinned merge-base-to-head diff adds complete include preimages and path facts to the existing update snapshot, with incomplete capture disabling rollback ownership.
Doctor write attribution: The actual include writer records its input and output hashes in the existing Doctor result context; the updater requires matching captured paths and hashes.
Findings None None.
Security None None.

How this fits together

The package updater captures configuration before the candidate version’s Doctor repairs it. If activation fails, rollback checks the captured files and current update ownership before restoring configuration, the previous package, and service.

flowchart LR
  A[Package update] --> B[Capture config and includes]
  B --> C[Candidate Doctor repairs]
  C --> D[Write receipts and path checks]
  D --> E{Activation succeeds?}
  E -->|Yes| F[Keep new package]
  E -->|No, safe to restore| G[Restore previous config and package]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +283, Tests +235, Docs +4. Total +522 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 356 73 +283
Tests 4 256 21 +235
Docs 1 10 6 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 622 100 +522

Review metrics

Metric Value Why it matters
Production and test growth production +283 net lines; tests and support +235 net lines The production growth implements capture and guarded restoration; the added tests cover the original failure and operator-edit controls.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/flows/doctor-health.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep include restoration within the existing updater and config writer owners, preserving the old driver’s root-only behavior and refusing restoration after operator edits or path changes.

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

Yes, current-main source still restores only the root file, and the PR records a failing base scenario where Doctor changed an include. This read-only review did not execute current main.

Is this the best way to solve the issue?

Yes. The patch extends the existing snapshot, Doctor writer receipt, and guarded rollback owners without introducing a competing recovery owner.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 202336dcd5f7.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body ties the final-head updater and Doctor include path to an installed published-updater first hop and a repaired-updater failed activation, reporting restored original include bytes and a healthy previous Gateway. Operator-edit and changed-alias controls exercise refusal at the config boundary. The added Doctor result field is optional temporary IPC, with no durable stored-data schema change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P1: A failed update can leave Doctor-edited includes outside automatic rollback, affecting recovery of an existing workflow.
  • merge-risk: 🚨 compatibility: The new Doctor receipt crosses the installed-updater boundary, whose published-reader behavior and first hop were specifically checked.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body ties the final-head updater and Doctor include path to an installed published-updater first hop and a repaired-updater failed activation, reporting restored original include bytes and a healthy previous Gateway. Operator-edit and changed-alias controls exercise refusal at the config boundary. The added Doctor result field is optional temporary IPC, with no durable stored-data schema change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body ties the final-head updater and Doctor include path to an installed published-updater first hop and a repaired-updater failed activation, reporting restored original include bytes and a healthy previous Gateway. Operator-edit and changed-alias controls exercise refusal at the config boundary. The added Doctor result field is optional temporary IPC, with no durable stored-data schema change.

Evidence

What I checked:

  • Current main remains root-only: The current-main rollback checks included content but restores only the root config file; this PR’s central behavior is not on main. (src/cli/update-cli/update-command-rollback.ts:225, 202336dcd5f7)
  • Introduced capture path: The pinned merge-base-to-head diff adds complete include preimages and path facts to the existing update snapshot, with incomplete capture disabling rollback ownership. (src/cli/update-cli/update-command-config-snapshot.ts:47, 69ff071f8c2b)
  • Doctor write attribution: The actual include writer records its input and output hashes in the existing Doctor result context; the updater requires matching captured paths and hashes. (src/config/mutate.include-io.ts:292, 69ff071f8c2b)
  • Final restoration guards: Rollback rechecks file hashes and path facts, takes config writer locks, and checks the live executor before file replacement. (src/cli/update-cli/update-command-rollback.ts:447, 69ff071f8c2b)
  • Published-reader compatibility: The v2026.9.6 Doctor IPC reader parses an object without the new optional receipt field. The PR body reports that the published updater completed its first hop and retained its existing root-only rollback limit. (src/infra/update-doctor-result.ts:45, eb377ac59e6c)
  • Installed behavior proof: The updated PR body binds its installed scenario to final head 69ff071 and reports exact original root/include bytes, the previous package, a healthy previous Gateway, and a rolled-back outcome after an injected service-start failure. The linked Testbox run’s outer job was canceled after the reported scenario; its raw logs were unavailable through this review environment’s network allowlist. This inspection limit does not negate the source-bound account. (69ff071f8c2b)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: 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 (3 earlier review cycles)
  • reviewed 2026-09-28T12:45:05.943Z sha 1f15810 :: blocked before merge. :: [P1] Let Doctor run after a recoverable include-capture conflict
  • reviewed 2026-09-28T13:58:06.501Z sha 69ff071 :: blocked before merge. :: none
  • reviewed 2026-09-28T14:07:27.399Z sha 69ff071 :: blocked before merge. :: none

Inspect include ownership without reading the candidate's newer plugin state.
Treat typed capture conflicts as a rollback-unavailable snapshot after read
work settles, allowing Doctor to inspect the current configuration. Preserve
strict schema, authority, and cleanup failures outside that narrow fallback.

Exercise real newer-schema SQLite state and a real include edit during capture.
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@steipete
steipete merged commit 82bd51a into main Sep 28, 2026
251 of 260 checks passed
@steipete
steipete deleted the codex/complete-update-recovery branch September 28, 2026 19:19
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…aw#160443)

* fix(update): restore Doctor-owned config includes on rollback

Retain raw include preimages with the existing config snapshot and attribute
changes to the actual Doctor writer. Restore only contiguous owned writes while
preserving later edits and alias changes. Incomplete include graphs still reach
Doctor, with automatic config restoration disabled and an explicit warning.

Related: openclaw#144005, openclaw#145169

Co-authored-by: Jason (Json) <[email protected]>

* fix(update): keep Doctor available when include capture is incomplete

Inspect include ownership without reading the candidate's newer plugin state.
Treat typed capture conflicts as a rollback-unavailable snapshot after read
work settles, allowing Doctor to inspect the current configuration. Preserve
strict schema, authority, and cleanup failures outside that narrow fallback.

Exercise real newer-schema SQLite state and a real include edit during capture.

---------

Co-authored-by: Jason (Json) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant