Skip to content

fix(doctor): skip config audit recovery when its sanitized companion is gone and nothing remains to import - #186998

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1944
Oct 28, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1944

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Fixes #186974

What Problem This Solves

Doctor and update finalization permanently refuse when a checkpointed legacy config-audit raw archive has lost its sanitized companion, even though the raw bytes still match the checkpoint and no records remain to import. Thanks @AlyaKoni for the report and preserved-history evidence.

User Impact

Doctor now records a warning-bearing skip, preserves the raw archive and checkpoint, and continues later repairs when there are zero records or every raw record already exists in SQLite. A missing companion with unimported records still refuses before importing, with instructions to restore the named companion from a verified backup and rerun Doctor against the same state directory. Truncated or modified companions retain their existing checks.

Why This Change Was Made

The audit migration owner already verifies the checkpointed raw prefix and parses records. It now uses its existing pre-write SQLite keys to classify the missing companion before attempting recovery. Existing migration receipts carry the warning through Doctor and update finalization. This complements #145376 and #150425 without reconstructing historical bytes or changing the schema, retention, configuration, dependencies, or CLI options. The candidate must include this fix; the installed update driver needs no change.

The existing archive-hardening function moved unchanged into the neighboring sanitized-archive module to meet the 700-line owner limit. Shared checkpoint-control setup was consolidated and exec-approvals verification now reads the production store instead of querying its SQL layout. Production: +42/-24 (net +18); tests: +71/-71 (net 0); docs: +10.

Evidence

  • The exact committed regression fixtures fail against the original audit owner: both missing-companion cases receive refused instead of skipped. Frozen final source: 84 tests passed, one Windows-only test skipped, across both selected projects; total wrapper wall time 223.48 s.
  • Real local source CLI: isolated HOME, OPENCLAW_STATE_DIR, profile, and port; pnpm openclaw doctor --fix --non-interactive. Before: exit 1, audit-logs step-refused, and later migrations blocked. After: exit 0, “Doctor complete,” warning surfaced, exec-approvals JSON removed, and SQLite policy is allowlist.
  • Production-shaped synthetic fixture: 56,180 whitespace bytes, checkpoint sanitizedSize 55,656, recordCount 0, recordOrdinalBase 57, and absent sanitized companion. Raw SHA-256 stayed 5f80de1ad2afd477ce838f2d636b374c922bffb9d31ada53ac3343874bfe1290; the raw file and checkpoint remained unchanged, and the companion stayed absent.
  • Negative real CLI control: append one unimported row while retaining the verified checkpoint prefix. Doctor exits 1 with backup-restoration guidance, retains all 56,259 raw bytes and the original checkpoint, imports no new legacy audit rows, and keeps later repairs blocked.
  • Regression cases run through discovery and the serial Doctor migration runner, verify later exec-approvals migration, repeated skip receipts/warnings, and byte-identical recovery inputs. The already-imported case uses a real interrupted archive-hardening failure to retain committed SQLite rows. Existing quarantine, capacity, restoration, append, and backup controls remain covered.
  • Final command: node scripts/run-vitest.mjs src/infra/state-migrations.audit-backup.test.ts src/infra/backup-create.audit.test.ts src/infra/state-migrations.audit-logs.test.ts src/infra/state-migrations.audit-skips.test.ts src/infra/state-migrations.audit-logs.windows.test.ts test/scripts/ci-changed-node-test-plan.selection.test.ts --maxWorkers=1. The changed Doctor file used 110.34 s of test time; audit owner tests used 29.05 s; the slowest individual test was 16.18 s. CI timings are pending.
  • Core tsgo, infra-test tsgo, touched-file oxlint, oxfmt, madge (zero cycles), and git diff --check passed. Documentation audit: 16,114 internal links, zero broken. Full check:changed/SQLite inventory was skipped under the campaign's local gate budget; PR CI is the broad proof.
  • Fresh isolated Codex autoreview, complete local diff against 1b356b487d8e7eb5946af999eb4fe9517eaee2ef, P0–P2: scoped-clean, no actionable findings. Local ClawSweeper was unavailable because its shared checkout was dirty; marking this PR ready requests the hosted review.

Proof limitations: no installed-package upgrade was run. The isolated source CLI fixture reported the host's pre-repair recovery-copy warning because its external-volume staging ancestor permits replacement by another user; the archive preservation and later migration assertions above passed. No operator state, Gateway, or production data was used. Windows-only proof is left to CI.

Preserve verified raw audit archives and record a warning-bearing skip when their sanitized companion is gone and every record is already imported. Keep unimported data refusing with backup restoration guidance so independent Doctor repairs and update finalization can continue safely.

Fixes #186974. Thanks @AlyaKoni for the report.
@clawsweeper

clawsweeper Bot commented Oct 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 size: M labels Oct 28, 2026
@steipete
steipete marked this pull request as ready for review October 28, 2026 19:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T19:50:45.448713Z cfdbf31 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Doctor skips missing-companion audit recovery when all raw records are already imported, while preserving recovery inputs and refusing unimported records.

Example: A checkpointed config-audit archive contains 56,180 whitespace bytes and its sanitized companion is absent.

  • Before: Doctor refuses recovery and blocks later migrations.
  • After: Doctor preserves the archive and checkpoint, records a warning-bearing skip, and continues independent repairs.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and distinct runner regressions support correctness, but upgrade compatibility remains unproven.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor and update finalization stop permanently on an exhausted legacy audit archive whose sanitized companion is missing.
Reason: The maintainer-authored direction restores the established best-effort recovery contract for a concrete stable-release failure while retaining refusal for unimported data.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a verified Doctor and update-finalization failure that remains on current main, and the pinned patch has no identified code defects.

Priority: P1
Reviewed head: cfdbf31bf9fafc877785841a74c777e0fea833bd

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a redacted v2026.10.8 installed-package upgrade to the candidate that preserves settings, SQLite history, raw bytes, and checkpoint, completes later repairs and finalization with warnings, and remains safe on repeat.
Agent review details

How this fits together

Doctor discovers retired audit files, verifies their checkpoints, and reconciles records with shared SQLite state; migration receipts determine whether later repairs and update finalization continue.

flowchart TD
  A[Doctor or update finalization] --> B[Legacy audit discovery]
  B --> C[Checkpoint and raw verification]
  C --> D[Existing SQLite record keys]
  D --> E[Missing companion classification]
  E --> F[Warning skip or refusal receipt]
  F --> G[Continue or block later repairs]
Loading

Technical review

Best possible solution:

Retain this narrow classification in the existing audit migration owner, preserving raw evidence and refusing recovery whenever an unimported record remains.

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

Current-main source establishes the refusal after discovery selects a verified checkpointed archive with a missing companion; the PR supplies matching regression fixtures and reports before/after source-CLI results, which this read-only review did not rerun.

Is this the best way to solve the issue?

The patch fixes the decision at its existing owner before database insertion, retains checkpoint, parsing, restoration, and companion-integrity checks, and introduces no competing state or recovery path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Missing sanitized-companion refusal changes intended behavior with a stated reason (9d97e10: The SQLite cutover required verified sanitized history before completing raw-archive recovery; this PR explains why absent historical projection bytes need not block independent repairs when no raw record needs importing.)
  • Archive permissions and durability keeps the original intent (241911c: Writable update descriptors allow chmod and fsync on Windows; the function relocation preserves that implementation unchanged.)
  • Recovery continuation and regression coverage keeps the original intent (db26660: Advisory skips must preserve recovery inputs and continue independent repairs while unsafe restoration still refuses; the expanded runner table retains those distinct controls.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +18, Tests 0, Docs +10. Total +28 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 42 24 +18
Tests 2 71 71 0
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 123 95 +28

Review metrics

Metric Value Why it matters
Production versus test LOC Production +42/-24; tests +71/-71 The net production growth adds the missing classification; archive hardening moves unchanged, and existing test tables absorb the regressions.

Root-cause cluster

Relationship: same_root_cause
Canonical: #186974
Summary: This PR implements the missing-companion repair reported in the canonical issue; the earlier merged recovery fixes cover distinct archive conditions.

Members:

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

Labels

Label changes:

  • add P1: Affected stable installations cannot complete Doctor repairs or update finalization, leaving plugin convergence blocked.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: Affected stable installations cannot complete Doctor repairs or update finalization, leaving plugin convergence blocked.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add the installed-package upgrade evidence described in the compatibility assessment.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 28, 2026, 4:05 PM ET / 20:05 UTC.

@steipete
steipete merged commit 4a0ab09 into main Oct 28, 2026
207 of 209 checks passed
@steipete
steipete deleted the upd/upd-l1944 branch October 28, 2026 20:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…is gone and nothing remains to import (openclaw#186998)

On 2026.10.8, openclaw update and doctor --fix refused permanently at the audit-logs migration when a legacy raw-archive checkpoint existed but its sanitized companion file was missing, blocking every later migration step and update finalization although nothing remained to import. When the raw archive still matches its checkpoint and no records remain unimported, the step now records a warning-bearing skip, keeps the raw file and checkpoint, and lets later repairs run; real unimported records still refuse with backup-restoration guidance. Fixes openclaw#186974. Thanks @AlyaKoni.
amittell pushed a commit to amittell/openclaw that referenced this pull request Oct 31, 2026
…is gone and nothing remains to import (openclaw#186998)

On 2026.10.8, openclaw update and doctor --fix refused permanently at the audit-logs migration when a legacy raw-archive checkpoint existed but its sanitized companion file was missing, blocking every later migration step and update finalization although nothing remained to import. When the raw archive still matches its checkpoint and no records remain unimported, the step now records a warning-bearing skip, keeps the raw file and checkpoint, and lets later repairs run; real unimported records still refuse with backup-restoration guidance. Fixes openclaw#186974. Thanks @AlyaKoni.

(cherry picked from commit 4a0ab09)

Carry note (v2026.10.10-beta.4): the production change applies unchanged. main had refactored
state-migrations.audit-logs.test.ts and audit-skips.test.ts well past beta.4, so both keep
beta.4's versions and the new state-migrations.audit-missing-companion.test.ts pins the case
that refused mac-mini's deploy: a raw archive re-detected after its file identity moved (st_dev
16777231 -> 16777230, same ino, mtime and size), its sanitized companion gone, every record
already imported.
amittell added a commit to amittell/openclaw that referenced this pull request Nov 11, 2026
Upstream head 59047d2 targets release/2026.10.10 (base
1cdcfc0). Its first commit 8b55f48 is the release-branch
cherry-pick of openclaw#186998; the branch already carries openclaw#186998 through the
fork's 419ff41, and the two are patch-identical outside tests
(git patch-id --stable over audit-logs.ts, audit-sanitized.ts and docs:
051fd155b6de for both). So only the PR's tests are carried:
- 8b55f48's missing-companion rows in audit-skips.test.ts, as
  reshaped by 23e8573 (the moved-file copy is written beside the
  original and renamed over it, so it cannot reuse the inode, and the
  case asserts that premise), c34352c (the refusal case: with an
  unimported record left in the raw archive, audit-logs refuses, imports
  nothing, and exec-approvals is refused blocked-by-prior-refusal with
  its file byte-identical) and 59047d2 (the empty, imported and
  moved-file shapes run against the audit-logs step twice; one Doctor
  row keeps proving later repairs run).

audit-skips.test.ts and audit.test-support.ts on this branch are
byte-identical to the PR's base, so the PR's test diff applies as is.

Removed: src/infra/state-migrations.audit-missing-companion.test.ts,
the fork's single test from 419ff41. It is the moved-file shape
above (re-detected raw archive, companion gone, every record imported,
skip with a warning), and it recreated the file with rm + writeFile,
which can reuse the inode it means to change; the carried row asserts
the new inode and checks more (two passes, checkpoints, imported rows).

Proof (M4, Node 26.12.1, --maxWorkers=1):
- audit-skips.test.ts and audit-logs.test.ts: 2 files, 53 tests passed
  (the PR reports 53 at its head on its own base).
- Red-before, the openclaw#186998 source hunks of audit-logs.ts and
  audit-sanitized.ts reverse-applied: audit-skips.test.ts 5 failed,
  10 passed of 15 (the Doctor imported row, the three step rows and the
  refusal case), the same split the PR reports on its base.
RomneyDa added a commit that referenced this pull request Nov 12, 2026
…189935)

Backport #186998 to release/2026.11.4. Preserve checkpointed raw audit archives when their sanitized companion is missing and no records remain to import; retain refusal for unimported records. Includes missing-companion and blocked-later-repair regressions by Alex Mittell.

Original implementation by Peter Steinberger; backport and regression coverage by Alex Mittell.

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Alex Mittell <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Nov 13, 2026
Refresh the complete v2026.11.3..09aa644
history: 99 in-range PRs, 35 issues, and direct-commit editorial coverage.
Preserve all 62 prior contribution records and original main PR credits.
Include typed Telegram callbacks, worker-heartbeat lease renewal, and the
narrow large-store startup adaptations without claiming post-ready recovery.

Source product: 09aa644
Source tree: f10a88c
Main metadata: 3577724
Notes tooling: 514a224

Release provenance: 3768440 -> openclaw#194840, openclaw#179219, openclaw#196984, openclaw#196337
Release provenance: 00275d2 -> openclaw#194362
Release provenance: 66f0339 -> openclaw#186998
Release provenance: 915956a -> openclaw#186998

Co-authored-by: vincentkoc <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M

Projects

None yet

1 participant