Decouple the per-document cap from reranking in the product passage lane

↗ view on GitHub · Eli Ziff · 2026-07-31 · 74831c08

perDocCap was spelled `rerankModel ? 24 : undefined`, so you could not change
reranking without also changing document diversity - a confound sitting under
every rerank measurement this codebase has taken. Now an explicit `perDocCap`
argument with the defaults spelled out.

Behaviour preserved, measured not assumed: over 160 real queries on the
LegalBench LF index, `undefined` and explicit `2` produce byte-identical hit
sets at k=8 (sha 7ffcbdef5cd13bf4) and k=48 (bb4d61780de876b8). The existing
tests never exercised perDocCap at all, so they were no evidence either way.

Recorded honestly in the comment: the reranked 24 is deliberate, but the
un-reranked 2 is searchPassages' own `?? 2`, which entered in 3997cf12 with
the benchmark ablation harness and carries no rationale - unlike every other
default in that function. The cap binds hard (k=8: cap 2 -> 4.54 documents per
query, cap 24 -> 1.49), so it is a real search-policy question, and the
benchmark's answer must NOT be copied: uncapping wins there only because every
LegalBench query names its one gold document. Owed: a measurement on a
text-bearing product corpus; the local A2AJ store is metadata_only today.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H9ToHYJVDxfeJcJwdzrP2H
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents 1d220fce
Stats 1 file changed , +26 , -1
Part of Legal grounding and retrieval research

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-74831c08.md from inside the repo you want the change in.

⬇ Download capture-commit-74831c08.md