Repository navigation
fix(sessions): honor total entry cap with protected history - #123081
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 10:42 AM ET / 14:42 UTC. ClawSweeper reviewWhat this changesThe PR changes session maintenance so protected rows consume the total entry cap while remaining ineligible for automatic eviction. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessNo blocking correctness finding remains: the final head fixes the prior malformed-JSON SQLite probe failure and consistently applies total-row accounting. This maintainer-labeled PR should remain open for normal exact-head CI and maintainer handling. Priority: P1 Review scores
Verification
How this fits togetherSession maintenance runs after persisted-session writes and manual cleanup to prune stale history and bound stored sessions. The same retention rule must agree across file-backed stores, SQLite writes, previews, warnings, and transcript cleanup. flowchart LR
A[Session write or cleanup] --> B[Maintenance trigger]
B --> C[Count live session rows]
C --> D[Preserve protected rows]
D --> E[Evict oldest eligible rows]
E --> F[Persist sessions and clean transcripts]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -27, Tests +88, Docs +4. Total +65 across 16 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the single total-cap rule after exact-head checks pass, retaining the guarded SQLite stale probe and parity coverage for file-backed and SQLite maintenance. Do we have a high-confidence way to reproduce the issue? Yes, from source: the focused tests construct protected history plus ordinary overflow and exercise file-backed and SQLite write-triggered maintenance; no local execution was performed in the read-only review. Is this the best way to solve the issue? Yes: total-row triggering plus one protected-aware victim selector is the narrowest shared owner-boundary repair, avoiding new settings or separate quota policies. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 493a3e46b3f2. LabelsLabel changes:
Label 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 (6 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
45ec66c to
15ef8ee
Compare
92c4f04 to
527002c
Compare
527002c to
77970b5
Compare
62f08e7 to
d83511b
Compare
…#123081) * fix(sessions): count protected rows toward entry cap * perf(sessions): defer maintenance snapshot loading * test(sessions): assert total maintenance cap * fix(sessions): align warning preservation * fix(sessions): guard malformed maintenance rows
Related: #123014
What Problem This Solves
Fixes an issue where users with protected session history could retain more ordinary sessions than configured by
session.maintenance.maxEntries, because archived, pinned, active, locked, and durable conversation rows stopped contributing to the capacity calculation.Why This Change Was Made
maxEntriesis again a total-row cap: every live session row consumes capacity, while protection determines only which rows may be evicted. Maintenance computes total overflow and removes that many oldest unprotected rows; if protected rows alone exceed the cap, it preserves them and leaves the store above the limit.The file, SQLite write-triggered, cleanup-preview, and active-session warning paths use the same accounting model. SQLite writes use lightweight total-count and stale-candidate probes, then load the full session payload snapshot only when maintenance must run. This removes the eligible-entry counter and adds no public SDK surface. Operator docs and config help now describe the same behavior.
User Impact
Protected sessions remain immune from automatic deletion without granting unlimited extra capacity. For example, at a 500-row cap, 200 pinned plus 400 ordinary rows retain every pin and the newest 300 ordinary rows. If 499 rows are archived and three are ordinary, the two oldest ordinary rows are removed.
This corrects unreleased behavior from #123014; no release tag contains that change.
Evidence
origin/main: protected-history overflow removed 0 rows instead of 2/100, and the active-session warning missed the same pressure (run).45ec66c7d7f: local-container Crabboxcbx_35394760e7aepassed targeted formatting and 117/117 owner-boundary tests covering total overflow, protected rows/transcripts, stale pruning, and SQLite write-triggered maintenance.Production source: +85/-128 (net -43). Tests: +71/-65. Documentation: +20/-16.
AI-assisted: implementation, tests, documentation, and validation were prepared with Codex; the maintainer directed the retention model and reviewed the tradeoff.