perf(a2ajPassageSearch): narrow + memoize the per-hit metadata row
The product passage lane pulled `SELECT * FROM document WHERE id = ?` once per pooled hit. That row carries unofficial_text_en and _fr, both unofficial_sections maps and both cases_cited lists - hundreds of KB - and the loop keeps a citation, a name, a date, a URL and a dataset, all short strings. The passage text itself comes from the hit, which searchPassages already sliced, so the bodies on that row were never read at all. Worse, the dedupe key is docId:start, so a document that supplies many hits (perDocCap 24 under rerank) refetched its whole payload once per hit. Same defect as 17884220, one module over: it was fixed for the text lookup in passageRetrieval and left standing here. Narrow column list + a per-call memo. Same rows, same values, same ordering; the memo dies with the call. Measured on 300 LegalBench mini queries (size 8, rerankHits 48) against a 69-document / 106 KB-mean bulk db: 157.93 -> 54.92 ms/query, 2.9x. Unchanged-output proof: sha256 of every returned A2AJPassageResult[] is byte-identical over all 300 queries (digest of digests e4f136fc8a327666447bafea8f873ecdda3aa72c9bf1a6e26d5410d56dadff31). The production A2AJ corpus populates both languages plus the section maps, which this bed leaves empty, so the real saving is larger. 28 tests pass across a2ajPassageSearch, a2ajPassageWiring, passageRetrieval. 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 | 1e73f86b |
| Stats | 1 file changed , +20 , -2 |
| Part of | A2AJ / CourtListener Canadian legal-source integration |
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-53d3bed8.md
from inside the repo you want the change in.