Repository navigation
fix(sessions): stop max-lines compaction backup leaks - #125183
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 5:36 AM ET / 09:36 UTC. ClawSweeper reviewWhat this changesThe PR makes max-lines session compaction permanently trim SQLite transcript rows, removes the obsolete archive response, and reclaims legacy compact backups before searchable history. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readinessNo blocking correctness findings on the updated head. It resolves the prior archive-reclamation concern; wait for exact-head CI before merging. Priority: P1 Review scores
Verification
How this fits togetherThe CLI sends manual compaction to the Gateway, which updates the agent’s SQLite transcript. Disk-budget maintenance removes recognized legacy artifacts before evicting searchable session history. flowchart LR
A[CLI max-lines request] --> B[Gateway compaction]
B --> C[SQLite transcript trim]
C --> D[Retained transcript]
E[Legacy bak artifacts] --> F[Archive-first disk sweep]
F --> G[Searchable session history]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -12, Tests -92, Docs -1. Total -105 across 12 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the canonical SQLite-only flow once exact-head checks are green: no new sidecars, explicit permanent-truncation docs, and archive-first cleanup of existing legacy backups. Do we have a high-confidence way to reproduce the issue? Yes: current main writes Is this the best way to solve the issue? Yes: removing file-era backup creation at the SQLite owner and sweeping existing backups before history eviction is cleaner than retaining parallel persistence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fbd910d417ec. LabelsLabel 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 (1 earlier review cycle)
|
|
Land-ready proof for head
Live built CLI/Gateway proof seeded seven transcript rows, compacted with Owner decision: max-lines truncation remains permanently destructive. The archive behavior reached beta but no stable release, and database-first ownership removes the OpenClaw-owned JSONL sidecar. Do not restore backup creation. The accepted ClawSweeper technical finding is fixed on this head: legacy |
|
Merged via squash.
|
* fix(sessions): stop max-lines compaction backup leaks * fix(sessions): reclaim legacy compact backups
Related: #111122
What Problem This Solves
Fixes an issue where users running
openclaw sessions compact <key> --max-lines Nwould create a new.baktranscript sidecar on every compaction. Session maintenance counted those files against the disk budget but could not reclaim them, so repeated manual compaction could evict other sessions' retained history while still leaving the store over budget.Why This Change Was Made
Manual max-lines compaction now trims the canonical SQLite transcript directly without creating or returning a backup sidecar. Existing legacy compact backups are eligible for the normal high-water archive sweep, so they are removed before searchable SQLite history under disk pressure. Historical
.bakfilename recognition remains intact so those artifacts are never mistaken for active transcripts. The CLI docs now state explicitly that max-lines truncation is permanent and does not create a backup archive.Owner decision: permanent max-lines truncation is intentional. The archive behavior from #111122 reached beta tags but no stable release, and keeping an OpenClaw-owned JSONL recovery sidecar would preserve the file-era runtime state that the database-first contract removes. The ClawSweeper request to restore archive creation is therefore deliberately skipped; its narrower cleanup finding is addressed by reclaiming existing legacy
.bakfiles before any session history.User Impact
Repeated manual compaction no longer accumulates disk-budget-charged backup files. Operators still get the retained-line count, but no
Archived transcript:path is reported because no archive is created. Existing legacy compact backups remain recognizable and are reclaimed by the disk-budget sweep before searchable session history.Evidence
sessions.compactreturned anarchivedpath and wrote a.jsonl.bak.*file.node scripts/run-vitest.mjs src/config/sessions/session-history-eviction.test.ts src/config/sessions/artifacts.test.ts src/config/sessions/disk-budget.test.ts src/config/sessions/session-accessor.test.ts src/gateway/server.sessions.compaction.test.ts src/commands/sessions-compact.test.ts(186 tests passed)..bakarchive caused one searchable history entry to be evicted; after the fix, the backup file is removed, zero session entries are removed, and searchable history remains.pnpm build.node scripts/check-changed.mjs -- <12 touched paths>passed, including formatting, production/test typechecks, lint, env/max-lines/assertion ratchets, database-first, dependency, dead-export, and import-cycle guards.pnpm docs:check-mdx,pnpm docs:check-links, andpnpm docs:check-i18n-glossary.openclaw sessions compact agent:main:main --max-lines 3, observedCompacted session agent:main:main (kept 3 lines)., verified the Gateway returned only the retained header plus the last two messages, found no.jsonl.bak.*artifact under the isolated state directory, and confirmed a second run reportedNo compaction needed for session agent:main:main.AI-assisted; maintainer-reviewed and live-verified.