Skip to content

Recall retention only applies on write: a quiet machine keeps rows past retention_days #4144

Open

Description

@Wilson421

What

retriever.retention_days (default 30) and max_entries (default 200) are enforced by evict(), and evict() is called from exactly one place: store_inner, immediately after inserting a new row (src/core/retriever.rs, the insert recall row path).

So retention is a property of continued use, not of elapsed time. A machine where rtk stops eliding — a project finished, a laptop set aside, a filter disabled, a contractor's box left on a shelf — keeps every stored row indefinitely, while rtk config recall and the documented default both say 30 days.

Nothing is wrong with the eviction logic itself; it is correct on an active machine. The gap is the claim.

Why it is worth a fix rather than a doc note

The stored rows are the output a filter hid, plus the command text, cwd and exit code. On a machine where that output is sensitive, "we keep it 30 days" is exactly the sentence a reviewer relies on, and it holds only while somebody keeps working. A stated retention that silently doesn't apply is the same shape as the two defects already fixed this week — #4141 (init exits 0 having installed nothing) and #4143 (discover reports "looks good" over zero sessions scanned): the tool reports a state it did not reach.

Possible fixes, in increasing cost

  1. Evict on read too — call evict() from the recall command path, and from gain/config recall. Cheap, and it makes "did anyone look at this machine" the trigger rather than "did anyone store on it".
  2. Evict on open — a sweep in open() behind a cheap guard (e.g. at most once per process, or when the newest row is older than the retention window). Bounds the staleness by "rtk ran at all".
  3. Document it honestly — change the wording to "entries are evicted when rtk next stores output", and say so in rtk config recall. Correct, cheapest, and worse than either of the above for anyone reasoning about data lifetime.

I would take (2) with (1) as the fallback, but this is your design call. Happy to send a PR for whichever you prefer.

Context

Found while documenting rtk's local stores for a two-machine deployment, after checking what rtk recall persists and where. The store itself is well-behaved: content-addressed, compressed, size-capped, and 0700/0600 on Unix. Worth noting separately that set_owner_only is #[cfg(not(unix))] {}, so on Windows the files carry whatever the profile ACL grants — I can raise that as its own issue if it isn't already known.

Activity

  1. added
    bug
    help wanted
    on Sep 20, 2026
  2. rtk-wshm-sync-bot commented on Sep 20, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 85%

    Summary

    Recall retention (retention_days/max_entries) is only enforced on write via evict() in store_inner, so an idle machine retains rows past the documented 30-day window; add eviction on read/open paths too.

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/core/retriever.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. dopaemon commented on Sep 20, 2026

    @dopaemon

    Can I take on this issue ?

  4. dopaemon commented on Sep 20, 2026

    @dopaemon

    Fixed in #4145, taking option (2) — which covers (1) as a side effect.

    Rather than calling evict() from each command path, the sweep now runs from the two connection entry points (open, open_existing), so anything that touches the store — rtk recall, gain, config recall, the tee stats path — enforces retention_days. Staleness is bounded by "rtk ran at all" instead of "rtk stored something", and there's one sweep site rather than one per caller to keep in sync.

    It keeps the properties that made the current code well-behaved: best-effort like evict (a read-only or locked store keeps its rows), and the read path still never creates the database, since open_existing returns early when the file is absent.

    Reproduced the gap on develop first with an isolated store and a row aged 31 days: rtk recall --list listed it and left it in place. With the fix that same read-only listing drops it and keeps the fresh row.

    On the Windows note — set_owner_only being #[cfg(not(unix))] {} is a real and separate concern; I left it out of this PR, so please do raise it as its own issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:securitybughelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions