fix(memory): sweep orphaned reindex temp files#92972
Conversation
|
Codex review: needs maintainer review before merge. Reviewed June 14, 2026, 9:54 AM ET / 13:54 UTC. Summary PR surface: Source +100, Tests +62. Total +162 across 4 files. Reproducibility: yes. Source inspection shows current main creates memory reindex temp SQLite files and only removes them through in-process success/error cleanup paths that a hard kill cannot run. Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the focused memory-core startup sweep through normal maintainer review once merge gates are satisfied, keeping release-note text in the PR body and release process rather than Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main creates memory reindex temp SQLite files and only removes them through in-process success/error cleanup paths that a hard kill cannot run. Is this the best way to solve the issue? Yes. The startup sweep in memory-core before opening the manager is the narrow owner-boundary fix, while a config flag, doctor-only cleanup, or broad storage migration would be heavier than this source-backed bug requires. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fc6d448138fc. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +100, Tests +62. Total +162 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Superseded by #92891, landed as a42bda5. The landed canonical path uses a SQLite-exclusive owner guard shared by safe reindex, destructive aged-temp cleanup, and missing canonical-path creation. That preserves active reindexes and closes the Windows swap/create race. This PR's age-only sweep does not exclude an active long-running reindex, and landing both would duplicate startup cleanup behavior. Thanks for the focused cleanup proposal. |
What changed
<index>.sqlite.tmp-*, including-waland-shmsidecars.Why
A hard restart or SIGKILL during atomic memory reindex can bypass the in-process cleanup path and leave full-size SQLite temp triplets behind. Those orphaned files are not authoritative once the live index exists, but previously nothing reclaimed them on startup.
Fixes #92874
Real behavior proof
Behavior addressed: aged orphaned memory reindex temp SQLite triplets are removed on the startup cleanup path while the live memory index remains in place.
Real environment tested: local OpenClaw source checkout on macOS, using the PR branch code and a real temporary filesystem directory under
/var/folders/.../T/.Exact steps or command run after this patch: ran a one-off
npm exec -- pnpm exec tsx --evalscript that importedsweepMemoryIndexTempFilesfromextensions/memory-core/src/memory/manager-atomic-reindex.ts, createdmemory.sqliteplus an agedmemory.sqlite.tmp-proof/-wal/-shmtriplet, then invoked the production sweep helper with a 30-second grace window.Evidence after fix: terminal output from the real temporary directory run:
Observed result after fix: the aged temp base and both SQLite sidecars were removed, and the live
memory.sqlitefile remained as the only file in the directory.What was not tested: a destructive live SIGKILL against a running user agent was not performed; the proof uses the same real filesystem artifact shape and the production startup sweep helper directly.
How tested
CI=true npm exec -- pnpm test extensions/memory-core/src/memory/manager.atomic-reindex.test.tsfailed withTypeError: sweepMemoryIndexTempFiles is not a function.CI=true npm exec -- pnpm docs:listCI=true npm exec -- pnpm exec oxfmt --check --threads=1 extensions/memory-core/src/memory/manager-atomic-reindex.ts extensions/memory-core/src/memory/manager.ts extensions/memory-core/src/memory/manager.atomic-reindex.test.ts extensions/memory-core/src/memory/index.test.tsCI=true npm exec -- pnpm test extensions/memory-core/src/memory/manager.atomic-reindex.test.ts extensions/memory-core/src/memory/index.test.tsCI=true npm exec --package corepack -- corepack pnpm check:changednpm exec -- pnpm exec oxfmt --check --threads=1 CHANGELOG.mdgit diff --checkExisting PRs
Searched open PRs for memory reindex/temp SQLite cleanup terms and did not find an existing fix PR.