Skip to content

fix(doctor): quarantine changed audit archives and continue repairs - #150425

Merged
steipete merged 2 commits into
mainfrom
upd/doctor-audit-archive-mismatch
Sep 17, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/doctor-audit-archive-mismatch

Conversation

@steipete

@steipete steipete commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Doctor stopping on malformed rewrites of legacy audit archives, repeating mismatch warnings, or erasing a sanitized companion beside an empty checkpointless raw archive. Reported by an Ubuntu operator on Discord using 2026.9.3. The quarantine path also needs to preserve the existing backup privacy boundary: its retained raw arguments must not enter portable archives.

Related: #145376, which already made valid-JSON archive mismatches recoverable warnings on main.

User Impact

Doctor and update finalization preserve mismatched raw archives beside themselves with a dated quarantine suffix and continue later repairs. The operator note names the quarantine once; subsequent runs stay quiet. Existing SQLite rows, sanitized history, and operator backups remain intact.

Portable backups omit quarantined raw files and their derivatives while leaving the local originals untouched. Sanitized companions and normal sanitized replacements for recoverable audit sources remain included.

Why This Change Was Made

The raw file is a checkpointed append landing pad for older writers. Doctor now checks its prefix before parsing and quarantines mismatches without importing changed bytes. Empty checkpointless raw files cannot overwrite retained sanitized history.

The backup cutover has one lightweight owner, backup-audit-paths.ts. Discovery, tar exclusion, and volatile/stat-cache filtering use its predicate. Quarantined names inherit the original basename's classification; there is no second quarantine regex. The volatile adapter preserves its normalized state anchor before native path interpretation. Migration discovery continues to ignore quarantines so they cannot be re-imported.

The related audit-export tests now live together in backup-create.audit.test.ts, with shared real-tar inspection helpers. No coverage was removed to satisfy the existing file-size gate. The assertion baseline shrinks exactly from 2 to 1 after replacing the moved error cast with the existing errno guard.

Evidence

  • The Doctor → portable-backup regression failed before the backup fix with the current runtime and pinned fs-safe 0.13.1: the archive contained a .quarantined-* entry.
  • The fixed regression verifies that neither raw nor quarantined entries are archived, a synthetic sensitive argument is absent from every regular archive file, local originals are byte-identical, and the archived sanitized companion remains byte-identical.
  • Final current-runtime focused tests: 135 passed (71 unit-fast + 64 infra), covering portable audit backups, backup discovery/exclusion, the volatile filter, and the original 38 Doctor tests.
  • pnpm check:changed: passed, including types, formatting, lint, and runtime/import guards. No nested-checkout extension-lint substitution was needed.
  • OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build passed. The rebased worktree was restored with pnpm install --frozen-lockfile; no dependency pin or lockfile changed. Rebuilding removed stale pre-rebase runtime chunks that forced native mode off. Results from those mixed-version diagnostic runs are not used as final proof.
  • Additional broad backup-suite limitation: the candidate run hit three 120-second configured-agent snapshot timeouts and a subsequent owner-error assertion failure. The unchanged backup implementation and original full test order also timed out on the managed-state snapshot at 120.025 seconds; its preceding workspace case took 103.367 seconds. Both diagnostic runs were stopped; the full backup suite is not claimed green. The required focused suite above passed.
  • Fresh Codex review at P0/P1: staged code and final committed branch scoped-clean with no accepted/actionable findings. Final command: --mode branch --base origin/main --max-priority P1.
  • The original published 2026.9.3 Doctor driver proof below demonstrated exit 1 → exit 0 for both reported shapes, preservation of 1,557 sanitized records and 1,558 existing SQLite audit rows, later repairs, and quiet repeat runs. The original 38 Doctor tests are included in the refreshed suite.

ClawSweeper follow-up

Applied the P1 correction and the sole Rank-up move from the reviewed-head comment: the backup owner excludes the complete raw audit family, and a real Doctor-to-archive regression verifies absence of a synthetic sensitive argument while retaining local originals. No Rank-up move was skipped.

Rebased onto 90b421ae252 before final validation. Follow-up head: 3e459215e6c9bc9ae160e4fd927f69729782fe52. Follow-up LOC: production +68 / -63 (net +5); tests/support +420 / -294 (net +126); docs +8. The only baseline change is the exact shrink described above.

Original stop chain and sanitized terminal excerpts

In 2026.9.3, state-migrations.audit-logs.ts:380 returned failure, state-migrations.messages.ts:66 classified the warning as a refusal, state-migrations.doctor.ts:2867 blocked later steps, and state-migrations.messages.ts:107 threw the stop. An empty raw archive is shorter than its checkpoint; rewritten bytes fail the prefix hash. .bak files are not recovery inputs. A missing raw file is not selected for recovery.

Published 2026.9.3, before:

Skipped config audit log recovery because <fixture>/state/logs/config-audit.jsonl.migrated.raw changed other than by append; left the raw archive in place
Doctor stopped because a state migration refused to continue. Resolve the reported migration failure before retrying. Later repairs were not run.
exit=1; exec-approvals source retained; SQLite approvals rows=0

Published driver invoking the candidate, after (empty raw):

Imported legacy exec approvals into shared SQLite state.
Quarantined config audit log recovery archive → <fixture>/state/logs/config-audit.jsonl.migrated.raw.quarantined-2026-09-17T00-37-39-552Z-bce3edb4-86fb-471f-88ed-067062bc11fd: expected append-only growth; observed archive changed other than by append (0 bytes; checkpoint 223098 bytes). Kept sanitized history and existing SQLite records; other repairs can continue.
Doctor complete.
exit=0; exec-approvals source removed; SQLite approvals rows=1

The deleted-line case quarantined 222,957 bytes against the same 223,098-byte checkpoint. Both repeats completed without a mismatch warning.

@clawsweeper

clawsweeper Bot commented Sep 17, 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 size: M maintainer Maintainer-authored PR labels Sep 17, 2026
@steipete
steipete marked this pull request as ready for review September 17, 2026 00:56
@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. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 17, 2026, 12:09 AM ET / 04:09 UTC (Revision 2).

ClawSweeper review

What this changes

Doctor preserves changed legacy audit archives in quarantine, continues repairs, and excludes quarantined raw data from portable backups while retaining sanitized history.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix beyond the earlier merged recovery change. The prior backup privacy finding and its rank-up request are addressed; no blocking defects were found.

Priority: P1
Reviewed head: 3e459215e6c9bc9ae160e4fd927f69729782fe52

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful runtime evidence, meaningful regressions, and the previous blocking finding resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured published-driver terminal trace exercises Doctor recovery on existing state and shows successful later repairs, preserved history, and quiet repeats. The refreshed Doctor-to-real-tar regression addresses the backup follow-up; unit tests remain supplemental.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured published-driver terminal trace exercises Doctor recovery on existing state and shows successful later repairs, preserved history, and quiet repeats. The refreshed Doctor-to-real-tar regression addresses the backup follow-up; unit tests remain supplemental.
Evidence reviewed 10 items Current main still needs the fix: Current main prepares and parses records before checking checkpoint compatibility, so malformed rewrites still return a refusal. It also lacks the empty checkpointless archive guard and quarantine handling.
Recovery preserves existing history: Checkpoint mismatches are checked before parsing; empty checkpointless raw archives with retained sanitized history are quarantined before database insertion or companion rewriting. Unsafe interrupted restoration still refuses.
Previous privacy finding resolved: The shared predicate classifies quarantined names using their original audit basename. Backup discovery, tar filtering, and volatile/stat-cache filtering consume it; migration discovery continues to ignore quarantines.
Findings None None.
Security None None.

How this fits together

Doctor repairs legacy audit files into OpenClaw’s SQLite state. The backup subsystem combines sanitized legacy files with database snapshots to produce portable archives.

flowchart TD
  A[Legacy audit archives] --> B[Doctor integrity check]
  B -->|Valid append| C[Sanitized history and SQLite]
  B -->|Changed archive| D[Local quarantine]
  D --> E[Warning and continued repairs]
  C --> F[Portable backup filter]
  D -->|Excluded| F
  F --> G[Portable archive]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +207, Docs +18, Other 0. Total +230 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 6 117 112 +5
Tests 6 517 310 +207
Docs 3 23 5 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 16 658 428 +230

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +5 lines; tests/support net +207 lines Production growth stays small by consolidating classification, while added coverage protects recovery and export privacy.

Technical review

Best possible solution:

Keep recovery with Doctor and raw-file exclusion with the shared backup classifier, preserving local evidence and portable sanitized history.

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

Yes: current-main source establishes that a malformed rewrite reaches parsing before checkpoint rejection, and an empty checkpointless raw archive can replace its sanitized companion. This review did not execute those paths.

Is this the best way to solve the issue?

Yes: the patch repairs the existing recovery owner and shares backup classification across its consumers without adding another import path or changing database schemas.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b2e5694f50ea.

Labels

Label justifications:

  • P1: The reported archive shapes interrupt Doctor/update repair or erase retained sanitized history on existing installations.
  • 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 (terminal): The captured published-driver terminal trace exercises Doctor recovery on existing state and shows successful later repairs, preserved history, and quiet repeats. The refreshed Doctor-to-real-tar regression addresses the backup follow-up; unit tests remain supplemental.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured published-driver terminal trace exercises Doctor recovery on existing state and shows successful later repairs, preserved history, and quiet repeats. The refreshed Doctor-to-real-tar regression addresses the backup follow-up; unit tests remain supplemental.

Evidence

What I checked:

  • Current main still needs the fix: Current main prepares and parses records before checking checkpoint compatibility, so malformed rewrites still return a refusal. It also lacks the empty checkpointless archive guard and quarantine handling. (src/infra/state-migrations.audit-logs.ts, b2e5694f50ea)
  • Recovery preserves existing history: Checkpoint mismatches are checked before parsing; empty checkpointless raw archives with retained sanitized history are quarantined before database insertion or companion rewriting. Unsafe interrupted restoration still refuses. (src/infra/state-migrations.audit-logs.ts:366, 3e459215e6c9)
  • Previous privacy finding resolved: The shared predicate classifies quarantined names using their original audit basename. Backup discovery, tar filtering, and volatile/stat-cache filtering consume it; migration discovery continues to ignore quarantines. (src/infra/backup-audit-paths.ts:22, 3e459215e6c9)
  • Doctor-to-backup regression: The regression invokes Doctor and the real archive creator, extracts the tar archive, checks every regular file for a synthetic sensitive argument, and verifies byte-identical local originals and archived sanitized history. Existing restore-ordinal coverage was moved, not discarded. (src/infra/backup-create.audit.test.ts:104, 3e459215e6c9)
  • Captured runtime and validation evidence: The supplied body at sourceRevision c2d47e084e3f52924a17259c10ab376c513e9a5a48f17c3b8477cbf20278aae2 records a published 2026.9.3 Doctor driver invoking the candidate: exit 1 became exit 0, later approvals repair completed, 1,557 sanitized records and 1,558 SQLite rows survived, and repeat runs were quiet. The follow-up reports 135 focused tests and changed checks passing, including the previously failing archive exclusion regression. Broad backup-suite completion is expressly not claimed; baseline snapshot timeouts are documented. No target code or tests were executed during this review.
  • Earlier merged work only partially overlaps: GitHub confirms fix(doctor): continue past skipped legacy audit-log recovery instead of stopping as a refusal #145376 merged on September 12. Its recoverable-skip change preserves archives in place; it does not supply this PR’s pre-parse quarantine or empty-companion protection. (db2666090f19)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • gaoanze888: 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 (1 earlier review cycle)
  • reviewed 2026-09-17T01:03:22.475Z sha b17adfaa68f7572cdbf55a65046ba9baf15455d2 :: blocked before merge. :: [P1] [P1] Keep quarantined audit files behind the backup sanitizer

Keep the append-only integrity check ahead of parsing, preserve mismatched raw archives beside themselves, and continue later repairs with a recoverable warning. Preserve sanitized history when a checkpointless raw archive is empty, and keep existing SQLite audit rows and operator backups intact.

Reported by an Ubuntu operator on Discord. Verified with 38 focused tests, the changed-file gate, and the published 2026.9.3 Doctor finalization driver invoking the built candidate.
@steipete
steipete force-pushed the upd/doctor-audit-archive-mismatch branch from b17adfa to 3e45921 Compare September 17, 2026 04:02
@clawsweeper clawsweeper Bot added 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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 17, 2026
@steipete
steipete merged commit 6be8905 into main Sep 17, 2026
216 of 218 checks passed
@steipete
steipete deleted the upd/doctor-audit-archive-mismatch branch September 17, 2026 04:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 18, 2026
…penclaw#150425)

Doctor now quarantines a config-audit archive that changed other than by append and continues later repairs. Check checkpoint integrity before parsing, preserve existing SQLite rows and sanitized history, and keep repeat runs quiet. Empty checkpointless raw archives cannot erase retained sanitized companions.

Portable backups exclude quarantined raw bytes and their derivatives through the shared audit-path classifier, preserving local originals and sanitized archive content. This completes the backup privacy boundary across discovery, tar exclusion, and volatile filtering.

Reported by an Ubuntu operator on Discord using OpenClaw 2026.9.3. Related: openclaw#145376.

Validation: exact-head CI passed; 135 focused tests, changed checks, and build passed in the fix lane. Published 2026.9.3 driver proof demonstrated exit 1 to exit 0, preserved history, later repairs, and quiet repeats. The fix lane's broad local backup-suite diagnostic was incomplete; hosted CI is the completed full gate. The scoped Codex review and current-head ClawSweeper review have no actionable findings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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: M 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