Skip to content

fix(recall): default the memory_recall window to 5 rows, not 20 (#409) - #416

Merged
abogartz merged 2 commits into
mainfrom
fix/409-recall-limit-5
Nov 17, 2026
Merged

abogartz merged 2 commits into
mainfrom
fix/409-recall-limit-5

Conversation

@abogartz

@abogartz abogartz commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

What

Changes the memory_recall default window from 20 rows to 5. No flag: this changes behaviour for every user on upgrade. An explicit limit still overrides, and the header still reports the full match count.

Why 5

The live audit (#409 §12) joined 1,090 recall events to their session transcripts: a rank-1 row goes on to be referenced at 3.4x the rate of a random store row, ranks 2–3 at 2.4x, ranks 4–10 at 1.4x, ranks 11–20 at 1.16x — statistically noise. The tool returned 17.7 rows per call.

The honest cost — per query, not as a precision ratio

The first version of this body led with "precision rises 4.1% → 13.1%". That was denominator arithmetic: precision rises mostly because fewer rows are returned. Re-measured through the shipped handler over the 404 case-bank queries with adjudicated full-text labels (poc-409/casebank/limit-windows.ts), the question is whether the window still holds an answer:

limit 20 limit 5 McNemar
queries whose window holds an answer (all 404) 231 216 15 lost / 0 gained, p < 0.001
queries whose window holds an answer (held-out 227) 131 125 6 lost / 0 gained, p = 0.031
rows returned (all 404) 5,092 1,597 −69%
non-answering rows (all 404) 4,673 1,226 −74%

This is a disclosed trade, not a free win: 69% less context per call, paid for with the answer in ~6.5% of the queries that had one (they reach it only at ranks 6–20). The use-audit says those ranks are referenced at noise level; the label audit says a few queries genuinely need them. Both are true at different sample sizes.

Two disclosures the first version missed:

  • Use-ledger and frontier-tap accounting. noteHits and the frontier-tap counters only see returned rows. At limit 5, rows at ranks 6–20 stop accumulating use signals, which feeds back into the use-boost ranking over time. Not measured here; flagged as a known feedback path.
  • Interaction with feat(recall): suppress near-duplicates inside a memory_recall window (#409) #415. Both PRs edit the same slice line in src/tools/recall.ts; whichever merges second needs a rebase. If both ship, the window is deduped and narrowed — the per-lane numbers above do not compose; they must be re-measured together before both are on.

Fixes in this push

  • limit is clamped: non-positive, NaN or fractional values coerce to the default (slice(0, -n) silently returned more rows than the default — pinned by a test).
  • Test header and this body now carry the per-query numbers above; the precision-ratio framing is gone.

Tests

5 tests: default 5, header count, explicit override, negative/zero clamp, filter-only path keeps newest. bun run gate (tsc + biome + unit + e2e) green.

Decision this PR now asks for

Ship-as-disclosed-trade (context is the binding constraint) or close (recall is). The lane is no longer claimable as harm-free.

@abogartz

Copy link
Copy Markdown
Owner Author

Composition note. Measured alone, and this one changes the default rather than hiding behind a flag. It is also the reason #415 exists: a shorter window makes near-duplicate crowding more expensive, because copies take slots that distinct facts would otherwise use. r1 and r3 unchanged, precision 4.1% → 13.1%, 74% of returned characters removed. Combined numbers against #415 and #418 are not yet measured.

@abogartz

Copy link
Copy Markdown
Owner Author

Repushed (a3a2b1c-series, see latest commit); the body now carries per-query numbers — the precision headline quoted here before this comment is void.

Two changes: limit is clamped (an unclamped negative made slice(0, -n) return MORE rows than the default — pinned by a test), and the lane is re-priced honestly. Through the shipped handler over the 404 case-bank queries with adjudicated full-text labels: the window holds an answer for 216/404 at limit 5 vs 231/404 at limit 20 (15 lost, 0 gained, p<0.001; held-out 125 vs 131, p=0.031), in exchange for 69% fewer rows and 74% fewer non-answering rows.

The "precision 4.1% → 13.1%" framing was denominator arithmetic hiding that gold loss, and the PR now says so. Also disclosed: at limit 5, ranks 6–20 stop feeding the use ledger and frontier-tap counters (a slow feedback into ranking), and this PR conflicts with #415 on the same line — if both ship they must be re-measured together.

This PR is now a disclosed trade (context vs recall in ~6.5% of answered queries), not a harm-free win. Ship-as-trade or close — maintainer's call.

A live audit joined 1,090 recall events to their session transcripts: a returned
row at rank 1 shows up in a later tool call at 3.4x the rate of a random store
row, ranks 11-20 at 1.16x, which is noise against a 0.129 null. At 17.7 rows per
call, 62% of the window was context nobody read.

The tighten sweep (limit x admission floor, stores 52/200/400) shows the cut is
free at the top: r1 and r3 identical to limit 20, precision 4.1% -> 13.1%, 74% of
returned characters gone, and every dropped gold row sitting at ranks 6-20. Limit
3 is rejected because it starts evicting ranks 4-5, which still carry signal. An
explicit limit still overrides and the header still reports the full match count.
- limit is coerced: non-positive, NaN or fractional values fall back to
  the default. An unclamped negative limit made slice(0, -n) return
  MORE rows than the default, not fewer.
- the PR framing is corrected with adjudicated per-query numbers: at
  limit 5 the window holds an answer for 216 of 404 queries versus 231
  at limit 20 (15 lost, 0 gained, p<0.001; held-out 131 -> 125,
  p=0.031), for 69% fewer rows and 74% fewer non-answering rows. The
  earlier 'precision rises 4.1% -> 13.1%' headline was denominator
  arithmetic that hid the gold loss.
- disclosures added: rows at ranks 6-20 stop feeding the use ledger and
  frontier-tap counters at limit 5, and #415 edits the same line, so the
  two lanes must be re-measured together if both ship.
@abogartz
abogartz force-pushed the fix/409-recall-limit-5 branch from 72a0326 to 2961a7e Compare November 17, 2026 05:24
@abogartz
abogartz merged commit 8e86df4 into main Nov 17, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.26.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant