Skip to content

fix(doctor): backport missing audit companion recovery to 2026.11.4 - #189935

Merged
RomneyDa merged 4 commits into
openclaw:release/2026.11.4from
amittell:backport/2026.10.10-config-audit-companion
Nov 12, 2026
Merged

RomneyDa merged 4 commits into
openclaw:release/2026.11.4from
amittell:backport/2026.10.10-config-audit-companion

Conversation

@amittell

@amittell amittell commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #186974
Backport of #186998 (4a0ab0928cc) to release/2026.11.4.

Current target — updated November 12, 2026

Retargeted from release/2026.10.10 because 2026.10.10 was published on November 3, 2026. This PR now proposes the audit-recovery fix for the upcoming 2026.11.4 release, not a change to the already published 10.10 artifact. The existing contributor commits and source head are preserved.

The comparison against 11.4 contains only the four intended audit source/test/documentation files. The evidence below was collected on the original 10.10-based branch; it is retained as historical reproduction and validation, not claimed as validation of integration with 11.4. Fresh target-specific CI and integration qualification are still required before landing.

Historical problem and evidence (original contributor report)

What Problem This Solves

Fixes: on 2026.10.10 betas, openclaw doctor --fix, and so an update, refuses at the audit-logs migration and blocks every later repair when an already-imported legacy config-audit archive is re-detected and its sanitized companion is gone.

User Impact

User impact: a 2026.10.10 update on a host in that state finishes instead of refusing and rolling back. Real unimported records still refuse with the backup-restoration guidance, as on main.

Why This Change Was Made

#186998 fixed this on main on 10-28, after release/2026.10.10 was cut. It is not in beta.4, beta.5 or the branch tip 1cdcfc00d84, by ancestry and by subject. The production change and docs here have the same patch-id as main's (051fd155b6deec28), and the release branch's two audit source files are identical to beta.4's, so they apply as is.

main refactored both audit test files after the cut. This keeps the release branch's state-migrations.audit-logs.test.ts and adds main's two missing-companion cases to state-migrations.audit-skips.test.ts. It also adds a case for the shape I hit (same bytes, size and mtime under a new file identity), and a Doctor-runner case for the other half of the rule: an unimported record with the companion gone still refuses.

Evidence

  • Hit on a real 2026.10.10-beta.4 update on one of my macOS gateways (2026-10-31 04:07Z). Doctor ran 434 s and exited 1:
    Failing check audit-logs (step-refused): Skipped config audit log recovery because its sanitized archive is missing or truncated
    Failing check managed-outgoing-images (blocked-by-prior-refusal): Migration step "managed-outgoing-images" was not run because prior step "audit-logs" refused execution.
    
    apns-registrations, exec-approvals and mcp-oauth were blocked the same way, and the update rolled back.
  • Cause, read-only on that host's state. The raw-archive checkpoint (migration.legacy-audit-raw) records dev 16777231, ino 19235396, size 478022, recordCount 0. The file now reads dev 16777230 with the same inode, size and mtime, and config-audit.jsonl.migrated.sanitized does not exist. Only the device number moved, so detection stopped matching and the step refused although nothing remained to import.
  • The same production change on the same data: with fix(doctor): skip config audit recovery when its sanitized companion is gone and nothing remains to import #186998 carried onto beta.4 (same patch-id as this PR), doctor on that host logged Skipped config audit log recovery because its sanitized companion is missing and no records remain to import; left ~/.openclaw/logs/config-audit.jsonl.migrated.raw in place., ran every later step, and the update finished with rc 0 at 07:30Z.
  • Installed-package upgrade, latest stable (npm [email protected], 8b18b55) to this branch's build at 23e85739821. Run with an isolated HOME, OPENCLAW_STATE_DIR, --profile upgradeproof and port 29789, and doctor --fix --non-interactive each time. No launchd label or LaunchAgent was added on the host.
    1. 2026.10.9 on a seeded legacy logs/config-audit.jsonl of 3 config.write records: exit 0, Migrated config audit log -> shared SQLite state (3 new row(s)). Afterwards the raw archive's sha256 is f6cc44861440c55a…, the checkpoint reads ino 185071743, size 423, recordCount 0, the config-audit history holds 5 rows (the 3 legacy rows hash to ab40ca823113eea8…), and openclaw.json hashes to 2ccd48ad6b26cc54….
    2. The raw archive is copied beside itself and renamed over (ino 185071743 -> 185071842, same size and mtime_ns), and the sanitized companion is removed.
    3. 2026.10.9 again: exit 1. audit-logs (step-refused): Skipped config audit log recovery because its sanitized archive is missing or truncated, and managed-outgoing-images, apns-registrations, exec-approvals and mcp-oauth are blocked by the prior refusal.
    4. This branch on the same state: exit 0, Skipped config audit log recovery because its sanitized companion is missing and no records remain to import; left <state>/logs/config-audit.jsonl.migrated.raw in place., and Doctor complete. A second run: exit 0, the same skip.
    5. After steps 3, 4 and 5, every value from step 1 is unchanged: the raw sha256, the checkpoint row, the 5 history rows with the same legacy hash, and the openclaw.json hash.
    6. This branch's doctor --lint over that state ran 39 checks. Its 3 findings are environment warnings (browser cookie import, a Codex route for the default model, no gateway auth token); none concern state or migrations.
  • Tests on this branch at 59047d2f789 (Node 26.12.1, Vitest on Node):
    • OPENCLAW_VITEST_RUNTIME=node pnpm test src/infra/state-migrations.audit-skips.test.ts src/infra/state-migrations.audit-logs.test.ts --maxWorkers=2: 53 passed, 0 failed.
    • Control: with state-migrations.audit-logs.ts and state-migrations.audit-sanitized.ts reverted to the branch tip, 5 failed and 10 passed in audit-skips. The three step-level skip rows and the Doctor skip row do not get a skip, and the refusal case gets the undifferentiated "sanitized archive is missing or truncated" message instead of the raw archive contains unimported records.
    • The refusal case also checks that nothing is imported, that the raw bytes and checkpoint are unchanged, and that later repairs stay blocked: exec-approvals is refused with blocked-by-prior-refusal and its legacy file is untouched. It fails if unimported rows are classified as imported, if the guard moves after registerLegacyMany, or if the step runner continues after audit-logs refuses.
    • pnpm tsgo:all exited 0 at 59047d2f789. oxlint and oxfmt are clean on the test file.
  • Test cost (pnpm test src/infra/state-migrations.audit-skips.test.ts --maxWorkers=1, Node 26.12.1, the release branch's local default, macOS arm64): 80.2 s and 81.9 s wall, 71.8 s and 72.1 s of tests over 15 tests, both warm. Before 59047d2f789 the same file ran 79.4 s of tests over 14 warm (87.5 s wall; 104.0 s on a cold worker cache). This PR's tests went from 21.0 s for 4 tests to 13.1 s for 5: the Doctor skip row 6.7 s, the refusal case 2.5 s, the three step-level rows 1.2 to 1.6 s each. CI: no run of this version yet; the previously pushed version took 73.1 s of tests in CI run 41263783798 (checks-node-changed-2).
  • Over 30 s: the file runs 71.8 s of tests, 58.6 s of it in the 10 tests that predate this PR. The three missing-companion shapes (empty, imported, moved file) run at the audit.migrate() layer: it calls the same migrateLegacyAuditLogs with the same detection Doctor uses, and that is where the skip is decided. Each asserts a skipped outcome with the recovery warning on two passes, with raw bytes, checkpoints and imported rows unchanged. Two tests still go through Doctor (autoMigrateLegacyState), because only Doctor sequences the steps: one skip row (imported) shows the skip lets exec-approvals complete and a second Doctor run leaves the archive in place, and the refusal case shows exec-approvals refused as blocked-by-prior-refusal.
  • Gap: a unit test cannot move st_dev, so the moved-file case changes the inode instead. The copy is written beside the original and renamed over it, so it cannot reuse the inode. The test asserts the premise: a different inode with the same size and mtime.

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

Backport to release/2026.10.10. The production change and docs are as merged on main.
main refactored both audit test files after the release branch was cut, so this keeps the
release branch's state-migrations.audit-logs.test.ts and adds main's two missing-companion
cases to state-migrations.audit-skips.test.ts, plus one case where the raw archive keeps its
bytes and mtime under a new file identity.

(cherry picked from commit 4a0ab09)
Copilot AI balanced review requested due to automatic review settings November 1, 2026 01:33
@clawsweeper

clawsweeper Bot commented Nov 1, 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 the docs Improvements or additions to documentation label Nov 1, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-01T01:38:57.029369Z 8b55f48 PR opened
ℹ️ 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The file-replacement fixture does not reliably isolate identity changes, and missing-companion coverage does not verify refusal without importing unprocessed records or altering raw data and checkpoints.

2 open issues
What changed in this PR

Backports the audit-recovery fix to release/2026.10.10, allowing Doctor and update finalization to continue when a checkpointed archive loses its sanitized companion but has no records left to import.

Changes:

  • Adds a warning-bearing skip for safe missing-companion cases while retaining refusal for unimported records.
  • Adds regression cases for empty, already-imported, and changed-file-identity archives.
  • Documents recovery behavior and moves archive hardening into the sanitized-archive module without changing its logic.
File Description
src/​infra/​state-migrations.audit-skips.test.ts Adds missing-companion cases that check later repairs continue.
src/​infra/​state-migrations.audit-sanitized.ts Houses the existing archive-hardening helper.
src/​infra/​state-migrations.audit-logs.ts Classifies missing companions before importing records.
docs/​cli/​update/​repair-and-recovery.md Explains safe skips and backup-restoration requirements.

Review effort: Balanced

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026

@roboclaw-bot roboclaw-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full four-file diff at 8b55f482b8288a1f87f0fcf014ac07955020461f against release base 1cdcfc00d84a63bd93954592a7778b7f3ab5d47c.

Verdict: the production backport is faithful to #186998, but the test coverage needs follow-up before release-owner acceptance.

  • The stable patch-id for both production files plus the documentation is exactly 051fd155b6deec28256668172fd52b2c8de71ac9 for this PR and main commit 4a0ab0928cc. This confirms the stated production-and-docs claim, rather than claiming the entire PR (including adapted tests) has the same patch-id.
  • Both release-base audit source blobs are identical to beta.4 and beta.5. They are not both identical to main's pre-fix files: audit-logs.ts on main additionally uses strict UTF-8 decoding and handles Utf8InputError. The relevant checkpoint/recovery/record owners are identical between the release base and main's parent; the backported missing-companion guard still runs after raw-prefix validation and before SQLite insertion.
  • After reading the full diff, ran only src/infra/state-migrations.audit-skips.test.ts and src/infra/state-migrations.audit-logs.test.ts through the repository wrapper with --maxWorkers=1, under timeout 300, in a separate checkout with isolated state/temp directories. 51/51 tests passed, exit 0; wrapper wall time 220.51 s (Node 26.12.1, Linux). This verifies the focused Linux boundary; it is not a new macOS live-upgrade proof or an independent rerun of the author's red-on-base control.

Two concrete coverage gaps remain:

  1. P2 — missing-companion refusal is untested. The three new rows all expect a skip. Existing refusal/recovery tests exercise different states. They would not catch changing the new classification to skip unimported rows, or moving its check after registerLegacyMany. Extend the Doctor-runner coverage with a checkpointed raw prefix, one unimported appended row, and an absent companion. Assert backup-restoration guidance, refusal and blocked later repairs, no new SQLite audit row, and unchanged raw bytes/checkpoint. This protects the explicit preservation/refusal contract in the PR description and docs.
  2. P2 — the moved-file fixture does not establish its claimed precondition. At lines 66–72, unlinking before replacement permits inode reuse, while round-tripping mtime through Date can lose sub-millisecond precision. The test can pass by exercising the existing mtime-change case instead of the reported identity-only change. Keep the original inode allocated while creating the replacement, use a reproducible mtime, and assert changed identity with equal bytes, size, and mtimeMs before migration.

These agree with the two existing Copilot findings after checking the actual owner and sibling tests. The main PR's recorded negative CLI control is useful prior evidence, but it does not put that regression contract into this release branch's tests. No production correctness defect was found in the backported guard. I have not merged or enabled auto-merge; release-branch acceptance and merging remain with the release owner.

…-file case

The moved-file case now writes its copy beside the original before renaming
it over, so the copy cannot reuse the inode. It starts from whole-second
timestamps so the mtime survives the utimes round trip exactly, and it asserts
its own premise: a different inode with the same size and mtime.

A Doctor-runner case covers the other half of the rule: with the sanitized
companion gone and an unimported record appended to the raw archive, audit-logs
refuses with the backup-restoration guidance, imports nothing, and leaves the
raw bytes and checkpoint unchanged.
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: ready, awaiting a maintainer decision.

What this changes

Backports warning-bearing skips for already-imported audit archives with missing sanitized companions while preserving refusal for unimported records.

Example: A 423-byte config-audit raw archive changes inode after its records were imported, and its sanitized companion is removed.

  • Before: Doctor refuses audit recovery and blocks subsequent repairs.
  • After: Doctor preserves the archive, checkpoint, history, and settings, reports a warning, and continues subsequent repairs.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused upstream backport with shipped-entry-point upgrade evidence, meaningful regression controls, successful exact-head CI, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Installed-package Doctor output shows npm 2026.10.9 refusing after archive replacement and companion loss, then candidate 23e8573 completing twice in isolated state with unchanged settings, raw bytes, checkpoint, and history; production code is unchanged at the reviewed head, and real macOS beta-update recovery supplements that proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor and update finalization stop when an already-imported legacy audit archive is rediscovered without its sanitized companion.
Reason: The reported release failure and accepted upstream fix justify the backport without changing configuration, retention, or stored formats.

Merge readiness

⏳ Ready, awaiting maintainer decision

Keep this PR open: it faithfully backports a verified Doctor fix to a release branch that still lacks it, and no actionable code findings remain.

Priority: P1
Reviewed head: 59047d2f78976c885214168fbfd8af8fa6df42f9
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this backport ship in a correction for release/2026.10.10, or move to the maintained October release line?
  • Recommendation: Select the maintained release target: Have the release owner select the supported October destination and carry this verified backport there.
  • Why: The contributor explicitly requested release-target guidance, and neither the inspected discussion nor the merged main fix settles that release choice.

Before merge

None.

Findings

None.

Agent review details

How this fits together

Doctor discovers legacy audit archives, verifies checkpointed bytes, compares their records with SQLite, and emits migration receipts that determine whether later repairs proceed.

flowchart TD
  A[Doctor or update] --> B[Legacy audit discovery]
  B --> C[Raw checkpoint verification]
  C --> D[SQLite record comparison]
  D --> E[Missing companion classification]
  E --> F[Warning skip or refusal]
  F --> G[Later repairs]
Loading

Technical review

Best possible solution:

Carry the existing audit-owner repair into the release line selected by its owner while preserving recovery evidence and refusal for unimported records.

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

Release-base discovery and recovery source establish the refusal after checkpointed archive identity changes and companion loss; the contributor supplies matching installed-package reproduction, which this read-only review did not rerun.

Is this the best way to solve the issue?

The narrow classification uses the existing migration owner before insertion, preserves prefix and companion-integrity checks, and follows the accepted upstream repair.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Missing-companion refusal changes intended behavior with a stated reason (9d97e10: The SQLite cutover required verified sanitized history before completing raw-archive recovery.)
  • Archive permissions and durability keeps the original intent (241911c: Writable update descriptors permit chmod and fsync on Windows; this backport moves that implementation unchanged.)
  • Recoverable skips and subsequent repairs keeps the original intent (db26660: Preserved recoverable audit sources should warn without blocking unrelated repairs, while unsafe recovery must refuse.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduced behavior: The missing-companion classification follows raw-prefix verification and record preparation, precedes registerLegacyMany, and skips only when every prepared record already exists in SQLite. (src/infra/state-migrations.audit-logs.ts:417, 59047d2f7897)
  • Main fix and release backport are distinct work: GitHub verifies fix(doctor): skip config audit recovery when its sanitized companion is gone and nothing remains to import #186998 merged the same production repair into main; current main retains it, whereas this PR targets release/2026.10.10 and its pinned base retains the missing-companion refusal. (src/infra/state-migrations.audit-logs.ts:418, 4a0ab0928cca)
  • Installed-package upgrade evidence: The complete PR body records npm 2026.10.9 reproducing refusal after archive replacement and companion removal, followed by candidate 23e8573 completing twice with unchanged config, raw bytes, checkpoint, and retained history; it also records recovery of a real macOS beta update. Captured body sourceRevision: 5d9b2fb8d644ae9d082fcbbe470ab817c0c8a06200fac438a26a072e019b6fcd. (23e857398210)
  • Proof remains applicable: The production files are unchanged since the installed-package proof revision; subsequent commits strengthen the moved-file fixture and refusal assertions and reduce redundant Doctor execution. (src/infra/state-migrations.audit-skips.test.ts:314, 59047d2f7897)
  • Earlier review concerns resolved: The replacement fixture establishes different inode with identical bytes, size, and mtime; the refusal case checks no import, unchanged recovery inputs, blocked exec-approvals receipts, and an untouched approvals file. Contributor controls report five failures with production changes reverted and 53 passing tests on the head. (src/infra/state-migrations.audit-skips.test.ts:345, 59047d2f7897)
  • Original recovery intent: The original SQLite cutover introduced companion verification to preserve sanitized history; subsequent skip and quarantine repairs distinguish recoverable archive conditions from unsafe recovery. GitHub commit inspection confirms the original companion guard. Local follow-history stopped on an unavailable historical object; the relevant introduction and changes were independently verified. (src/infra/state-migrations.audit-sanitized.ts:22, 9d97e10efe08)

PR surface

Source +18, Tests +132, Docs +10. Total +160 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 42 24 +18
Tests 1 133 1 +132
Docs 1 10 0 +10
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 185 25 +160

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: same_root_cause
Canonical: #186974
Summary: The canonical report was fixed on main, while this PR carries that repair to a release branch.

Members:

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

Labels

Label changes:

  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on maintainer.

Label justifications:

  • P1: The demonstrated release-branch failure blocks Doctor, subsequent state repairs, and update finalization on affected installations.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-01T02:22:01.519Z sha 23e8573 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-01T04:30:21.329Z sha 23e8573 :: needs maintainer review before merge. :: none

Reviewed November 9, 2026, 7:11 PM ET / November 10, 2026, 00:11 UTC (Revision 3).

@amittell

amittell commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Both P2s are addressed in 23e85739821, and the Evidence section is updated.

  • Refusal coverage: a Doctor-runner case with the companion removed and an unimported record appended. audit-logs refuses with the backup-restoration guidance. configRecords(), the raw bytes and the checkpoint entries are unchanged.
  • Moved-file precondition: the copy is written beside the original and renamed over it, starting from whole-second timestamps. The case asserts a different inode with the same size and mtime.

52/52 pass. With the two production files reverted to the branch tip, 4 fail: the three skip cases get refused, and the refusal case gets the old undifferentiated message instead of the raw archive contains unimported records.

@amittell

amittell commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added the installed-package upgrade proof to Evidence. npm [email protected] migrates a seeded legacy config-audit log, the raw archive then moves to a new file identity and loses its companion, 2026.10.9 refuses, and this branch at 23e85739821 skips and completes, twice. The raw bytes, the checkpoint, the imported history rows and openclaw.json are unchanged after every step.

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 1, 2026
@amittell

amittell commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@roboclaw-bot thanks for the review. Both test P2s are fixed in 23e85739821:

  • Refusal path: "refuses without importing when the companion is missing and raw records remain unimported" asserts:
    • outcome refused, with "the raw archive contains unimported records" and the "from a verified backup" guidance;
    • throwIfDoctorStateMigrationRefused throws "Doctor stopped";
    • configRecords(), the raw bytes and the checkpoint entries are unchanged, and the companion is still absent.
  • Moved-file fixture: it copies, sets a whole-second mtime (1_700_000_000) on the source and renames over the original, so the original inode is held during the copy. It asserts the premise: a new inode with the same size and mtimeMs.
  • One gap you may care about: "blocked later repairs" is asserted only through the runner's "Doctor stopped" throw, not by reading the later steps' blocked-by-prior-refusal receipts. I can add that if you want it before acceptance.

For the release owner: v2026.10.10 was tagged at 7dc3350cb9f (2026-11-03 01:32Z) without this fix, and npm latest is now 2026.10.10. git grep 'no records remain to import' v2026.10.10 -- src/infra docs returns nothing, while main has it in src/infra/state-migrations.audit-logs.ts. So an installed latest still stops at audit-logs when an imported archive comes back without its sanitized companion, as the upgrade proof in the description shows for 2026.10.9.

  • Branch: this PR still merges cleanly into release/2026.10.10 (git merge-tree exit 0 against 7dc3350cb9f). None of its 4 files changed in the 120 commits since its base.
  • Ask: is a 2026.10.10 point release planned that could take it, or should it target a different branch?

…panion refusal

The refusal case now seeds legacy exec approvals and asserts that the
exec-approvals step is refused as blocked by audit-logs and that its
source file is untouched. Before this, a runner that kept going after
audit-logs refused still passed the case: the "Doctor stopped" check
reads only the audit-logs receipt.

The moved-file case also asserts that the replacement keeps the
original bytes, beside the new inode and the same size and mtime.
The empty, imported and moved-file shapes now run against the audit-logs
step itself: a skipped outcome with the recovery warning on two passes,
with the raw bytes, checkpoints and imported rows unchanged and the
companion still absent. One Doctor-level row (imported) keeps proving
that the skip lets later repairs run and that a second Doctor run leaves
the archive in place. The refusal case is unchanged.
@amittell

amittell commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@roboclaw-bot pushed c34352c32fb for the gap I left open on 11-03 (blocked later repairs), plus the byte check you asked for on the moved-file fixture, and 59047d2f789, which moves the three skip shapes to the step itself.

  • Blocked later repairs: the refusal case now seeds legacy exec approvals and asserts the exec-approvals receipt is refused with blocked-by-prior-refusal naming audit-logs, and that exec-approvals.json is byte-identical afterwards. The old case could not see this: with state-migrations.steps.ts changed to keep running after audit-logs refuses, it still passed. The new case fails on that change, with exec-approvals completed and "Imported legacy exec approvals into shared SQLite state."
  • Moved-file bytes: the fixture now asserts the replacement holds the original bytes, next to the new inode and the same size and mtimeMs.
  • Cheaper skip rows: the empty, imported and moved-file shapes now run against the audit-logs step (audit.migrate(), the same migrateLegacyAuditLogs and detection Doctor calls): a skipped outcome with the recovery warning on two passes, with raw bytes, checkpoints and imported rows unchanged. One Doctor row (imported) still proves the skip lets exec-approvals complete and that a second Doctor run leaves the archive in place. This PR's tests in the file went from 21.0 s to 13.1 s.
  • The two regressions you named are still caught. Classifying unimported rows as imported fails the refusal case on outcome: "skipped", and moving the guard after registerLegacyMany fails it on a second SQLite audit row.

state-migrations.audit-skips.test.ts and state-migrations.audit-logs.test.ts on Node 26.12.1: 53 passed at 59047d2f789. With the two production files from 1cdcfc00d84, audit-skips gives 5 failed and 10 passed: the Doctor skip row, the three step rows and the refusal case.

@amittell

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 10, 2026
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 RomneyDa changed the title fix(doctor): 2026.10.10 update refuses when an imported audit archive lost its sanitized companion (backport #186998) fix(doctor): backport missing audit companion recovery to 2026.11.4 Nov 12, 2026
@RomneyDa
RomneyDa changed the base branch from release/2026.10.10 to release/2026.11.4 November 12, 2026 06:13
@RomneyDa
RomneyDa merged commit 66f0339 into openclaw:release/2026.11.4 Nov 12, 2026
151 of 157 checks passed
RomneyDa added a commit that referenced this pull request Nov 12, 2026
Integrate the exact canonical release commit for #189935 before fresh qualification.

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants