perf(citator): batch alias expansion so one query opens the graph once

↗ view on GitHub · Eli Ziff · 2026-07-31 · 7da4f03d

`citationAliasKeys` wraps `withReadonlySqlite`, which opens and closes
the note-up graph per call. The product passage lane asks it about every
citation-shaped fragment of a query - the whole query, each comma /
semicolon split, and each detected citation - so a single citing query
reopened the 2.3 GB noteup.sqlite about seven times and recompiled two
statements each time, to run seven indexed lookups.

Added `citationAliasKeysBatch` beside it in the shared citation module
(the doctrine: expand the shared surface, never hand-roll a second one
in a consumer), and pointed `citationKeys` at it. Element i is exactly
what the single-citation call returns for citations[i], including the
degrade-to-literal-key behaviour when no graph is installed, so the
pinned-citation set and its order are unchanged.

Measured against the real 2.3 GB graph:
  one citing query, 7 keyed fragments   4.77 -> 1.35 ms (3.5x)
  200 real cited keys                    137 -> 20 ms  (6.9x)
Output identity checked both ways: the 200-key expansions are
JSON-identical, and a new test asserts batch == per-citation over the
built fixture graph and over an absent graph.

26 tests pass across caselawCitator, a2ajPassageSearch, a2ajPassageWiring,
citationKey, citatorExcerpts.

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 0cadfd44
Stats 3 files changed , +89 , -19
Part of Citator: note-up graph and attested case characterizations

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-7da4f03d.md from inside the repo you want the change in.

⬇ Download capture-commit-7da4f03d.md