Repository navigation
fix: reclaim abandoned archive backup scratch - #154199
Conversation
|
🦞👀 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 21, 2026, 7:09 AM ET / 11:09 UTC (Revision 5). ClawSweeper reviewWhat this changesArchive backups gain transaction-protected scratch cleanup, abandoned-directory recovery through subsequent backups and Doctor, and explicit cleanup outcomes. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 5 items remain The cleanup work remains useful and is absent from current main. The already-reclaimed correction is sound, but the previously reported Windows retirement defect remains unresolved. Priority: P2 Review scores
Verification
How this fits togetherArchive creation stages configuration and database copies before publishing a backup. The scratch lifecycle owner coordinates writers and cleanup, while Doctor discovers abandoned directories and reports or repairs them. flowchart TD
A[Backup creation] --> B[Private scratch directory]
B --> C[SQLite lifetime transaction]
D[Next backup or Doctor] --> E[Inspect layout and acquire custody]
C --> E
E --> F[Preserve live or unknown scratch]
E --> G[Retire and remove abandoned scratch]
G --> H[Report cleanup outcome]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +492, Tests +356, Docs +18, Other +2. Total +868 across 13 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Use portable, identity-checked retirement within the shared scratch owner, with Windows recovery and published-updater compatibility demonstrated before landing. Do we have a high-confidence way to reproduce the issue? Yes, from source: a Windows backup reaches a rename onto an existing directory, which the pinned dependency and Windows API reject. This review did not execute a Windows reproduction. Is this the best way to solve the issue? The shared lifetime owner is appropriate, but the retirement operation must be portable; the already-reclaimed correction does not address that failure. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6e70aff09276. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
33d98e3 to
f540823
Compare
Record scratch cleanup warnings and protect live archive scratch with the existing SQLite staging lifetime primitive. Reclaim retired scratch through the backup and Doctor owners, preserving package rollback material and tokenless legacy directories. Related: #154114 (part B). Thanks @agebreak0083 for the report.
Add the new backup scratch and SQLite staging token modules to the curated wrapper source set so extracted wrapper processes resolve their eager imports. The three requested wrapper test files pass on Blacksmith Testbox (95 passed, one platform skip).
The staging-token extraction introduced six direct SQLite calls outside the approved execution boundary, failing lint:kysely in check:architecture. Compile the fixed statements through Kysely and execute synchronously on the same connection, preserving transaction admission and retirement. Testbox reproduced the six violations before the fix. Afterward, check:architecture, 52 selected scratch/lifetime/Kysely/wrapper tests, core typecheck, and targeted lint passed. Independent review found no actionable issues. No guard policy or baseline changes.
f540823 to
8c7f9c9
Compare
* fix: reclaim abandoned archive backup scratch Record scratch cleanup warnings and protect live archive scratch with the existing SQLite staging lifetime primitive. Reclaim retired scratch through the backup and Doctor owners, preserving package rollback material and tokenless legacy directories. Related: openclaw#154114 (part B). Thanks @agebreak0083 for the report. * style: avoid reassigning scratch cleanup parameters * fix(ci): include backup modules in PR wrapper inventory Add the new backup scratch and SQLite staging token modules to the curated wrapper source set so extracted wrapper processes resolve their eager imports. The three requested wrapper test files pass on Blacksmith Testbox (95 passed, one platform skip). * fix(infra): execute staging tokens through Kysely The staging-token extraction introduced six direct SQLite calls outside the approved execution boundary, failing lint:kysely in check:architecture. Compile the fixed statements through Kysely and execute synchronously on the same connection, preserving transaction admission and retirement. Testbox reproduced the six violations before the fix. Afterward, check:architecture, 52 selected scratch/lifetime/Kysely/wrapper tests, core typecheck, and targeted lint passed. Independent review found no actionable issues. No guard policy or baseline changes. * fix: avoid warnings for already reclaimed backup scratch
Related: #154114 (part B). Thanks @agebreak0083 for the report.
What Problem This Solves
Interrupted archive backups can leave large temporary config and database captures behind, and failed cleanup was silently swallowed, consuming space needed by later updates.
User Impact
New archive backups report cleanup failures with the scratch path. The next backup run and
openclaw doctor --fixreclaim abandoned scratch while preserving scratch held by a live transaction. Ordinary Doctor reports candidates without opening or changing their tokens.If a scanned scratch directory disappears before reclamation, the lifecycle owner records
alreadyReclaimedand reports “Backup scratch already reclaimed.” It neither emits a warning nor claims that this pass removed the directory. Every such candidate was previously observed, so this is an already-reclaimed outcome, not a never-created claim. A missing child file alone does not qualify.Legacy tokenless directories are reported for manual inspection, not automatically deleted: older backup writers have no lifetime records that can distinguish them from abandoned scratch. Stop older backup processes before removing those reported directories. Published archives and package rollback backups remain outside this cleanup.
Why This Change Was Made
Archive scratch uses the existing SQLite staging transaction primitive shared with private snapshots. Reclamation requires exclusive transaction custody and validates the scratch layout and filesystem identity. Retirement is committed before deleting payloads. A retired scratch name survives partial cleanup, allowing a later pass to retry even after the token is removed. Recorded archive destinations locate fallback scratch roots; completed outcome records do not grant cleanup authority.
The r3 correction uses the shared missing-path classifier for both Node errors and fs-safe’s
not-foundresult, then confirms the scratch root itself is absent. Cleanup records removed, already-reclaimed, and failed outcomes separately. Genuine cleanup failures, live transactions, unknown contents, and substituted paths retain their existing protections.There are no new options, dependencies, or canonical database schemas. Candidate Doctor uses its existing repair flow; an already-running older backup is not retrofitted with a token. The separate unattended update authorization fix is outside this PR.
Evidence
root dir not foundfalse warning. They cover disappearance before lstat, before the real fs-safe root boundary, and at removal, plus a vanished child whose scratch root remains.cc93169068686341dc173960a9020fc2cda45013, including the canonical native-process fixture admission-clock fix9247701e7ae351dc71e81e51d6628b49e2e13dee. The rebase preserved production behavior.tbx_01m31s6cae5rspn22kx9a4vpktpassed all 34 tests across scratch retention, archive publication, vanished-file backup/restore, Doctor, and native-process authority in 121.63 s. Infrastructure tests took 42.86 s; Doctor took 3.07 s (208 ms test time); native-process authority took 70.24 s. The formerly failingreplace-around-opencase passed in 447 ms. Testbox run.f540823810d: +51/-16 (net +35); tests +77/-0; docs +2/-0. Whole PR: production +566/-74, tooling +2/-0, tests +356/-0, docs +18/-0.Focused Testbox command:
node scripts/run-vitest.mjs src/infra/backup-scratch.test.ts src/infra/backup-create.publication.test.ts src/infra/backup-create.vanished.test.ts src/commands/doctor-backup-scratch.test.ts extensions/codex/src/app-server/run-attempt-native-process-authority.test.ts --maxWorkers=1.No end-to-end package installation or Gateway restart was performed for this correction. Auto-merge remains disabled; this revision is for r3 review.