Repository navigation
fix(update): restore Doctor-owned config includes on rollback - #160443
Conversation
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]>
|
🦞👀 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 September 28, 2026, 12:44 PM ET / 16:44 UTC (Revision 4). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherThe 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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +283, Tests +235, Docs +4. Total +522 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
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.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…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]>
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
$includefile.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 changedinfotowarn, but rollback leftwarn; 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 treeb0ec2a4a78410c890fecdbb392d425966e5e23d1. 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/ treefb51539370aa9d41a5a5ef69c65825bdedd399d3passed 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 setsplugins.enabled=falseto isolate the existing supported include-only write boundary; first-hop plugin coverage remains enabled. The fresh package SHA-256 isc06bc060c8277f17b9e254176a385413f748bd0dbf394cbfda7ab2bcaf7a3824, 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:changedpassed 16 stages before the unchanged 721-root UI budget gate; canonical52ae7e314dc2bf704449a3526abb4e3423649376fixes 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
d57b7da9702d4ac2c39777f9cf8512a59cb78e88has main parent3a300c650a5b87c4f84afeea7c2ff3a1df70e4eeand 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.