Repository navigation
Conversation
`evict()` ran from `store_inner` alone, so `retention_days` measured continued use rather than elapsed time: a machine that stops storing output — project finished, laptop shelved, filter disabled — kept every row forever while `rtk config recall` still advertised a 30-day window. Sweep from both connection entry points (`open`, `open_existing`) so any rtk invocation that touches the store — `recall`, `gain`, `config recall`, the tee stats path — bounds staleness by "rtk ran at all". Best-effort like `evict`: a read-only or locked store just keeps its rows, and the read path still never creates the database. Fixes rtk-ai#4144 Signed-off-by: dopaemon <[email protected]>
📊 Automated PR Analysis
SummaryFixes a retention bug where recall database rows were only expired on store/insert, so a machine that stopped storing output retained rows indefinitely past retention_days. The fix moves eviction into the two connection entry points (open() and open_existing()) via a new expire() helper, ensuring retention is enforced on every read/open, not just writes. Review Checklist
Linked issues: #4144 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Reporter of #4144 here — I verified this independently rather than just reading it, since it is my issue and an unverified "looks good" is worth nothing. Built and ran it on Windows 11, rtk at
On the shape you chose: option (2) is the one I would have picked, and for the reason you give — one sweep site instead of one per caller. I checked every path that opens the store ( Two observations, neither a blocker:
Thanks for picking this up so quickly, and for reproducing the gap on |
Fixes #4144
Problem
evict()was called from exactly one place —store_inner, right after an insert — soretention_daysmeasured continued use, not elapsed time. A machine that stops storing output (project finished, laptop shelved, filter disabled) kept every row indefinitely whilertk config recalland the documented default both promised 30 days.Demonstrated on
developwith an isolated store (RTK_RECALL_DB), one row aged 31 days, no new output stored:Fix
Option (2) from the issue, which also subsumes (1): sweep from the two connection entry points rather than from a command path, so every invocation that touches the store —
rtk recall,gain,config recall, the tee stats path — enforces retention.open()andopen_existing()both call the newexpire()right afterinit_schema, andexpireis justevict(conn, cfg, "")with no exempt hash (nothing is being protected on a sweep).Properties kept:
evictitself — a read-only or locked store keeps its rows instead of erroring.open_existingreturns early when the file is absent, sotest_stats_snapshot_never_creates_dbstill holds.DELETEplus aCOUNT(*)over at mostmax_entries(default 200) rows, on a connection that was being opened anyway.After:
Tests
New
test_retention_applies_without_a_new_store: two stored rows, one aged pastretention_days, then a read-onlyopen_existing()— the stale row must be gone and the fresh one untouched. The 48 existing retriever tests are unchanged and green (several of them open the store after inserting rows, which is what would break if the sweep were too eager).cargo fmt --all+cargo clippy --all-targetsclean;cargo test --bin rtk→ 3672 passed.Note
The issue also flags that
set_owner_onlyis a no-op off Unix, so on Windows the store carries whatever the profile ACL grants. That's a separate concern and isn't touched here — worth its own issue as the reporter suggests.