Repository navigation
fix(sessions): unblock cold history during unrelated cleanup - #156338
Conversation
Scope archive admission to each canonical or legacy removal unit while retaining archive-before-writer ordering and the original lifetime. Cold restores in other stores can progress between page-reclamation units. Preserve current authority, conditional deletion, and native settlement.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 5:55 AM ET / 09:55 UTC. ClawSweeper reviewWhat this changesThe PR lets archived conversation history load between unrelated SQLite cleanup units while keeping each archive deletion serialized and cancellable. Merge readiness✅ Ready for maintainer review This remains a useful fix: current main still holds archive admission across the entire cleanup sweep. The reviewed patch has no blocking correctness findings. Priority: P2 Review scores
Verification
How this fits togetherSession storage restores archived transcripts for chat-history requests and reclaims disk space during maintenance. Both operations share archive admission, so cleanup scheduling affects how quickly older conversations open. flowchart TD
A[Chat history request] --> B[Cold transcript restoration]
C[Disk budget cleanup] --> D[Reclaim SQLite pages]
C --> E[Archive removal unit]
B --> F[Shared archive queue]
E --> F
F --> G[Store writer and authority checks]
G --> H[Restored history or completed deletion]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +3, Tests +193, Docs +3. Total +199 across 6 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep cleanup admission scoped to individual removal units while preserving shared FIFO ordering, live authority checks, and settlement before permit release. Do we have a high-confidence way to reproduce the issue? Yes: the two-store scenario pauses cleanup after a page unit and requests cold history from the other store; current-main source retains the blocking global permit. This reviewer did not execute the scenario. Is this the best way to solve the issue? Yes: moving admission into the existing reclamation owner removes the unnecessary sweep-wide hold while preserving deletion ordering and existing storage contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2dd3b8a589b1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…156338) Scope archive admission to each canonical or legacy removal unit while retaining archive-before-writer ordering and the original lifetime. Cold restores in other stores can progress between page-reclamation units. Preserve current authority, conditional deletion, and native settlement.
What Problem This Solves
Opening a cold archived conversation can wait for another store's entire archive cleanup, even while that cleanup is only reclaiming SQLite pages.
User Impact
Cold history restoration can proceed between unrelated reclamation units. Archive deletion order, retained data, and database formats stay unchanged.
Why This Change Was Made
The page-reclamation owner now supplies archive-before-writer admission for each removal unit. It retains both permits across the pressure recheck, canonical selection, derived-file removal, and conditional row deletion. The global archive FIFO still protects publication and removal, while page reclamation and filesystem inventory run outside it. This removes the whole-sweep hold and the caller's separate writer wrapper while preserving cancellation and settlement ownership.
Evidence
The real cross-store history regression fails on the original code: history finishes only after the paused unrelated sweep is released. With the fix, the same history read finishes while the sweep remains paused, preserving message IDs, complete transcript bytes, foreground writer progress, retention, and the final disk budget.
35 focused tests passed, including queued retirement, admitted-work settlement, live authority and CAS checks, native maintenance/incognito behavior, physical alias binding, and WAL/close-receipt fencing.
Measured local serial cost (
--maxWorkers=1, loaded macOS host):session-history-eviction.writer-fairness.test.tssession-history-archive-pruning.admission.test.tsThese files exercise real SQLite workers, cold restoration, physical-store identity, and retirement. A queue mock cannot prove those ownership boundaries. Wall time includes imports and worker compilation; it is not a production performance comparison. Exact-head CI run 35835926746 passed. Its verbose test output and job timestamps report:
session-history-eviction.writer-fairness.test.tssession-history-archive-pruning.admission.test.tsThe test column sums the reporter's individual case durations. The containing-job times include setup, compilation, and other test files; they are not this PR's marginal cost or per-file wall time. These Linux CI measurements and the loaded macOS local measurements are separate environments, not a before/after performance comparison.
Independent managed review found no actionable P0–P2 findings. The full changed-file gate passed, including core and test typechecks, lint, dead-export scans, and storage/authority guards. Production deployment and whole-server CPU improvement are not claimed.