Repository navigation
fix(sessions): speed up database cleanup and find transcript archives consistently - #144232
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 11, 2026, 11:30 AM ET / 15:30 UTC (Revision 3). ClawSweeper reviewWhat this changesSpeeds up local session cleanup, makes SQLite and legacy selectors locate the same transcript artifacts, and documents safe cleanup on copied databases. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful on the pinned main revision, and no blocking defect was found. The verified test merge resolves the previous conflict concern; the supplied storage and runtime evidence supports proceeding through normal merge gates. Priority: P2 Review scores
Verification
How this fits togetherSession maintenance applies retention settings to OpenClaw’s conversation databases and transcript artifacts. It measures disk usage, protects retained conversations, and archives or removes eligible history. flowchart TD
A[CLI cleanup] --> C[Session maintenance]
B[Gateway cleanup] --> C
C --> D[Measure database and artifacts]
D --> E[Check retention and protection]
E --> F[Existing reclamation transaction]
F --> G[Canonical archive and derived file]
G --> H[Remeasure and report]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +37, Tests +166, Docs +77. Total +280 across 18 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one archive-directory resolver and the existing reclamation transaction, with connection reuse limited to local cleanup and unchanged retention and archive formats. Do we have a high-confidence way to reproduce the issue? Yes, from source: explicit SQLite selectors scan the wrong directory on pinned main, and local historical cleanup selects a fresh reclamation Worker per candidate. This review did not execute a reproduction. Is this the best way to solve the issue? Yes. The patch reuses existing transaction machinery and consolidates artifact-directory selection without adding a competing retention policy or stored format. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 21a5c1830211. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
d751a16 to
e49a091
Compare
|
Merged via squash.
|
… consistently (openclaw#144232) * fix(sessions): speed up local cleanup and resolve archive paths consistently * test(sessions): verify custom archive directory ownership
Closes #144212
What Problem This Solves
Fixes an issue where users cleaning large session databases would wait through repeated whole-database validation for individual historical transcripts. Explicit SQLite store selectors could also measure or prune the wrong artifact directory, missing archives and prompt blobs while counting SQLite shared-memory files.
Why This Change Was Made
Local CLI cleanup now reuses its admitted database connection through the existing in-process reclamation path. Gateway and background cleanup retain Workers, and the existing transaction, snapshot, admission, retention, and per-candidate disk checks remain. Archive staging batches small UTF-8 JSONL writes, and successful archive INSERTs skip redundant blob rereads while preserving conflict verification.
A shared directory resolver aligns measurement, pruning, preview exclusions, and archive publication for equivalent legacy and SQLite selectors. Selected SQLite SHM files are excluded from budget totals. Documentation clarifies archive storage, copied-state validation, and Doctor's explicit agent selector.
User Impact
Local cleanup avoids a full integrity scan for every historical victim and consistently finds the owning session artifacts. Existing session protection and retention behavior is preserved. This PR does not add file-only cold storage, new configuration, or a schema migration.
Evidence
sessions.cleanupreclaimed exactly one historical window, retained the current session, and reduced measured storage from 2,732,032 to 667,648 bytes. The current transcript remained byte-identical and visible throughsessions.preview; SQLite integrity and foreign-key checks passed.Stored-data compatibility
No migration is required: this PR leaves the agent/state DDL and schema versions (19/17), archive names, encoding, decoder, and reclamation transaction format unchanged. The serialized-state flag reflects a writer implementation change, not a stored-format change.
Fresh cross-version proof compared the exact pre-change and PR-head staging, zstd encoding, persistence, and decoder implementations using 1,803 synthetic rows (675,176 JSONL bytes), including Unicode, escaping, preserved whitespace, and a row larger than 64 KiB. Both writers produced identical plaintext and compressed hashes (5,154 compressed bytes). All four old/new writer-reader combinations passed plain-file, compressed-file, and SQLite-blob round trips; duplicate writes were accepted and conflicting same-generation blobs rejected in both versions.
The existing exact-byte archive-worker and conflict rollback tests remain regression coverage. Earlier native Gateway and copied-database validation also preserved retained transcript bytes and session metadata. The separate file-only archival/schema proposal is not included in this PR.