Repository navigation
fix(sessions): let idle compacted sessions enter cold storage - #157994
Conversation
…ge protection Legacy compaction checkpoint metadata records the session's own current id (the built-in compactor keeps session identity). Cold-storage eligibility added every checkpoint id to the protected set, so any session that was ever compacted before checkpoints were retired (openclaw#154131) kept its idle current window in SQLite forever, regardless of afterDays. Skip checkpoint references equal to the node's current session id, matching the existing usageFamilySessionIds handling and the function's documented rule that only activity and explicit cross-generation references protect bytes. Cross-generation checkpoint references remain protected; cleanup/disk-budget retention of legacy history is unchanged. Cold storage is lossless, and the current window is still protected by running status and recent activity. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
🦞👀 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: needs maintainer review before merge. Reviewed September 29, 2026, 12:48 AM ET / 04:48 UTC (Revision 3). ClawSweeper reviewWhat this changesThe branch lets idle current-session transcripts enter cold storage when legacy compaction checkpoints refer to that same session, while retaining protection for older referenced generations. Merge readiness✅ Ready for maintainer review Current main still has the reported cold-storage eligibility defect. This focused PR addresses it at the existing selector, and the linked issue remains open pending a fix. No actionable patch defect or additional before-merge action was identified. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s cold-storage worker reads session activity and history references from SQLite to select transcript payloads for archival. It checks eligibility again before replacing transcript rows with a recoverable archive. flowchart LR
A[Session activity] --> C[Cold-storage eligibility]
B[Legacy checkpoint references] --> C
C --> D{Current or older generation?}
D --> E[Protect active and older windows]
D --> F[Archive eligible idle window]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1, Tests +22. Total +23 across 2 files. View PR surface stats
Review metrics
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 cold-storage eligibility in its existing selector: let inactivity govern a current window’s checkpoint self-references, preserve distinct historical references, and retain the separate lossless archive and cleanup contracts. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main unconditionally protects a checkpoint ID even when it equals an idle node’s current ID. This read-only review did not execute target code. Is this the best way to solve the issue? Yes. The patch changes the existing eligibility selector at the faulty comparison while keeping distinct historical references protected. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 68834d21c435. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed in b578706. Thanks @anyech for reporting this and contributing the focused fix! Idle sessions with legacy checkpoint self-references can now move to cold storage without weakening protection for distinct referenced generations. The built Gateway comparison on published-release-created fixtures showed the negative control retaining both transcripts hot and the candidate archiving only the idle self-referencing transcript; maintenance preserved the database schema version. |
…aw#157994) Closes openclaw#157993 ## What Problem This Solves Fixes: idle sessions compacted before checkpoint retirement can remain in active SQLite indefinitely because their legacy checkpoint metadata references their own current ID. ## User Impact User impact: `coldStorage.afterDays` can archive those idle current windows as configured, while active windows and genuine cross-generation history remain protected. No migration or user action is required; cold storage remains lossless. ## Why This Change Was Made Ignore a legacy checkpoint ID only when it equals that node's `current_session_id`, matching the existing `usageFamilySessionIds` rule. Keep every distinct checkpoint ID protected. The change does not alter legacy history retention or destructive cleanup behavior. ## Evidence A focused regression covers idle self-references, distinct older-generation references, and recent activity. The contributor's seven targeted cold-storage suites passed 77 tests. A fresh run of the eligibility suite on the unchanged PR head passed 19/19 in 13.47 seconds wall time (added case: 1 ms). The contributor's read-only v2026.9.6 shadow comparison reduced protected IDs from 880 to 737, making 143 idle sessions totaling about 532 MiB eligible without newly protecting other IDs. That measurement describes one installation, not a general performance claim. A real Gateway archive comparison now also passes: - Published `[email protected]`, using an explicit isolated profile, created two sessions and transcript events through `sessions.create` and `chat.inject`. Offline fixture preparation added legacy checkpoint self-references plus a distinct referenced session ID and aged both windows ten days, beyond `coldStorage.afterDays: 1`. - The PR was integrated locally with main `48563f20cf22b25987fb727e52e6365c30a7d300`, without pushing the merge. Both Gateway builds used that same tree; the negative control restored only this PR's two files from that main revision. - Current main's existing Doctor upgrade converted the published agent database from schema 23 to 24 before cloning identical inputs for the comparison. This is not a schema change introduced by this PR. Both maintenance runs preserved `PRAGMA user_version = 24`. - Built CLI/Gateway processes used explicit separate profiles and ports, with resolved config and database paths checked before startup. `sessions.storage.status` confirmed completed maintenance without errors. - Negative control: **2 hot, 0 cold**, with both transcripts' two events retained in SQLite. Candidate: **1 hot, 1 cold**, with the self-referencing idle transcript's two events moved into a 788-byte `.jsonl.zst` archive; the genuinely referenced transcript retained both events in SQLite. Both Gateways were stopped. This proves synthetic published-state upgrade and actual archive writes, not an archive write against the contributor's production store. ## Test Cost The added regression checks the production SQLite eligibility selector at the self-reference/history boundary, which a narrower mock would not verify. On a cold local run, `pnpm test src/config/sessions/session-cold-storage-eligibility.test.ts --maxWorkers=1` passed 19/19 tests in 46.63 s wall time (Vitest duration 22.02 s); the added case took 3 ms. The cold-run wall time includes harness startup and transformation, not just the added case. On CI run [36107190601](https://github.com/openclaw/openclaw/actions/runs/36107190601) for head `0b63d8e8182484bb811877a606a0f780a1af90a8`, the added case passed in 1 ms. Its containing shard reported 532.98 s for 149 files; that shared shard duration is not the incremental cost of this regression. The CI workflow completed successfully. ## Attribution and maintainer intent Thanks to @anyech for reporting this bug and contributing the fix. No overlap with Pash/Sarah changes. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
Closes #157993
What Problem This Solves
Fixes: idle sessions compacted before checkpoint retirement can remain in active SQLite indefinitely because their legacy checkpoint metadata references their own current ID.
User Impact
User impact:
coldStorage.afterDayscan archive those idle current windows as configured, while active windows and genuine cross-generation history remain protected. No migration or user action is required; cold storage remains lossless.Why This Change Was Made
Ignore a legacy checkpoint ID only when it equals that node's
current_session_id, matching the existingusageFamilySessionIdsrule. Keep every distinct checkpoint ID protected. The change does not alter legacy history retention or destructive cleanup behavior.Evidence
A focused regression covers idle self-references, distinct older-generation references, and recent activity. The contributor's seven targeted cold-storage suites passed 77 tests. A fresh run of the eligibility suite on the unchanged PR head passed 19/19 in 13.47 seconds wall time (added case: 1 ms).
The contributor's read-only v2026.9.6 shadow comparison reduced protected IDs from 880 to 737, making 143 idle sessions totaling about 532 MiB eligible without newly protecting other IDs. That measurement describes one installation, not a general performance claim.
A real Gateway archive comparison now also passes:
[email protected], using an explicit isolated profile, created two sessions and transcript events throughsessions.createandchat.inject. Offline fixture preparation added legacy checkpoint self-references plus a distinct referenced session ID and aged both windows ten days, beyondcoldStorage.afterDays: 1.6f4c801c18f911625c971fa6cb7c3bd4de1d5e87, without pushing the merge. Both Gateway builds used that same tree; the negative control restored only this PR's two files from that main revision.PRAGMA user_version = 24.sessions.storage.statusconfirmed completed maintenance without errors..jsonl.zstarchive; the genuinely referenced transcript retained both events in SQLite.Both Gateways were stopped. This proves synthetic published-state upgrade and actual archive writes, not an archive write against the contributor's production store.
Test Cost
The added regression checks the production SQLite eligibility selector at the self-reference/history boundary, which a narrower mock would not verify. On a cold local run,
pnpm test src/config/sessions/session-cold-storage-eligibility.test.ts --maxWorkers=1passed 19/19 tests in 46.63 s wall time (Vitest duration 22.02 s); the added case took 3 ms. The cold-run wall time includes harness startup and transformation, not just the added case.On CI run 36107190601 for head
0b63d8e8182484bb811877a606a0f780a1af90a8, the added case passed in 1 ms. Its containing shard reported 532.98 s for 149 files; that shared shard duration is not the incremental cost of this regression. The CI workflow completed successfully.Attribution and maintainer intent
Thanks to @anyech for reporting this bug and contributing the fix. No overlap with Pash/Sarah changes.