Repository navigation
fix(update): successful updates leave full database copies in the npm global root - #160348
Conversation
Capture the database snapshot leak after ordinary and journaled verified activation, while preserving snapshots for rollback, refusal, and unverified completion. Cover maintenance advisories and leave older snapshots untouched. Both success regressions fail on the original production code. This is regression coverage only; the candidate implementation still needs a safe post-settlement cleanup boundary before landing.
Report older npm-global pre-migration snapshots with bounded size inspection and quoted manual removal commands. Keep discovery warning-only and defer updater-driven Doctor passes using existing markers. Preserve the flow environment in structured checks.
|
🦞👀 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, 7:53 AM ET / 11:53 UTC (Revision 5). ClawSweeper reviewWhat this changesThe branch retires pre-migration SQLite snapshots after verified npm package activation and adds warning-only Doctor discovery and recovery guidance for retained copies. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: current main still retains database snapshots after successful updates. The latest head addresses the earlier Doctor discovery finding, leaving a distinct, coherent fix under review. Priority: P2 Review scores
Verification
How this fits togetherThe package updater captures database snapshots before migrations, swaps the installed package, and settles the result after Gateway activation or rollback. Standalone Doctor reports leftover snapshots to operators without removing them. flowchart LR
A[Installed updater] --> B[Package swap and snapshots]
B --> C{Verified outcome?}
C -->|Successful activation| D[Retire obsolete copies]
C -->|Rollback or uncertain| E[Keep recovery copies]
E --> F[Standalone Doctor warning]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +169, Tests +264, Docs +20. Total +453 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep snapshot retirement inside verified transaction completion, preserve uncertain recovery material, and use standalone Doctor to guide inspection of older copies. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main returns from the activation retirement path without deleting the snapshot sibling. I did not execute an update in this read-only review. Is this the best way to solve the issue? Yes, the retained package transaction is the owner of snapshot lifetime, and warning-only Doctor discovery avoids deleting older copies whose outcomes cannot be established. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3a306a430eae. LabelsLabel changes:
Label justifications:
EvidenceWhat 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)
|
|
CI note: the only failure on 5e197d5 was |
|
Merged via squash.
|
… global root (openclaw#160348) * test(update): cover database snapshot retirement Capture the database snapshot leak after ordinary and journaled verified activation, while preserving snapshots for rollback, refusal, and unverified completion. Cover maintenance advisories and leave older snapshots untouched. Both success regressions fail on the original production code. This is regression coverage only; the candidate implementation still needs a safe post-settlement cleanup boundary before landing. * fix(update): retire database snapshots after verified activation * fix(doctor): report retained update database snapshots Report older npm-global pre-migration snapshots with bounded size inspection and quoted manual removal commands. Keep discovery warning-only and defer updater-driven Doctor passes using existing markers. Preserve the flow environment in structured checks. * test(doctor): avoid unbound snapshot repair assertion * fix(doctor): warn when snapshot discovery is incomplete * fix(doctor): report snapshots retired after failed cleanup
What Problem This Solves
Fixes: every successful package update leaves a full copy of every SQLite database in the npm global root (
<global node_modules>/.openclaw.package-backup-<pid>-<ts>.databases), and nothing ever removes it. This came from #158163 (d780fdc), which deliberately retained pre-migration snapshots after success "until the operator removes them". In practice nobody finds them, and disk grows by the full state size on every update.Release gate context: 2026.9.7 Full Release Validation (release-checks 36381536769) failed
update-first-hop-compat-2026.9.2..9.5with "update left transaction residue … .openclaw.package-backup-*.databases" after the candidate-driven hop. The snapshot code is an ancestor of the release/2026.9.7 cut.Retention change approved by Peter (maintainer): retire the snapshot sibling after verified-success activation, and keep it on rollback, unverified, or failed outcomes.
User Impact
core/doctor/update-snapshots, warning only, never removed even with--fix) with their count, total size, and exact per-directory removal commands, plus a reminder to confirm no update or recovery needs them. Updater-driven Doctor passes skip this check, so an in-flight update's own snapshot is not reported.Why This Change Was Made
Automatic database restoration is only eligible before the candidate Gateway is admitted. After verified activation the old package backup is already retired, so the snapshots no longer serve automatic recovery. They now share that backup's lifetime in
retireVerifiedPackageSwap, on both the activation and non-activation paths. Cleanup uses the originaldatabaseBackupRoot, not activation's rewritten backup path, and goes through the same authority- and identity-checkeddiscardPackageUpdateBackuphelper. The Doctor discovery is a bounded, read-only scan of the npm global root: one directory level, capped entries, depth, and a 200 ms budget, with no symlink following. The structured Doctor contribution runner now forwardsctx.env, so the update-phase marker check sees the real environment. Docs for update recovery and Doctor checks are updated.Evidence
package-update-swap.test.tsandpackage-update-activation-lifetime.test.ts(ordinary and journaled success remove the sibling; rollback and unverified completion retain it) fail on the original code. Newsrc/flows/doctor-update-snapshots.test.tscovers discovery, sizes, commands, no-finding, and update-pass skip. Removing the registration makes it fail.tbx_01m3kjnp1b8xdt9ckdwary2247,tbx_01m3kn3k8x1gycsaybdar7erhb): 164 focused update tests passed (6 platform skips).pnpm test src/infra/package-update-swap.test.ts --maxWorkers=17.4 s;package-update-activation-lifetime.test.ts31.7 s (existing process-death suite; the added case is 0.37 s); the Doctor test runs in ~80 ms of test time.pnpm tsgo:core, core test type shards, oxfmt, and scoped oxlint passed.update-first-hop-compat-2026.9.2..9.6against merged main) follows after landing.