Split The code is public; the app answers only to the crew.
The check fails on a busy machine: `db.test.ts` times one cold `standings` call against a 10 ms wall clock #241
Sign in to join this conversation.
Split The code is public; the app answers only to the crew.
Intent: the test that guards the standings query proves the cost does not grow with the table, and it proves that the same way on a loaded CI runner as on an idle laptop.
Why now. #126 was parked twice on 2026-09-23 (01:35, 01:42). Both runs found nothing to build, and the second reported
bun run checkred onsrc/db.test.ts:236: standings answers in a budget that does not grow with the table: 20,000 matches in under 10ms. It passed on a rerun. The test times a single first call, so the statement compile and a cold page cache are inside the 10 ms, with no warm-up and no repeats (src/db.test.ts:241-243). A check that fails on load fails previews for pulls that never toucheddb.ts.The property the test title claims is structural.
standingsreads thestandingtable throughstanding_by_rank(src/db.ts:147,:232). The query plan can pin that deterministically, and the plan is what keeps the cost from growing with the table.Done looks like:
EXPLAIN QUERY PLANfor the statementstandingsruns uses thestanding_by_rankindex. It has noSCAN match, and it has noUSE TEMP B-TREE FOR ORDER BY. Export the SQL as a constant fromdb.tsif the test needs it; do not duplicate the string.src/client/textures.test.ts:55-63already does it: one warm-up call, then the median (or mean) of several calls, with a bound that has headroom. A comment says why the bound has that value.standing_by_rankin a scratch run: the plan assertion goes red.bun run checkpasses 20 times in a row locally (for i in $(seq 20); do bun run check || break; done), and the pull says so.db.tsbehaviour does not change, apart from exporting the SQL if that is needed.Files:
src/db.test.ts, and possiblysrc/db.ts(one exported constant).Risks: SQLite's plan text wording differs between versions. Match on
standing_by_rankand the absence ofSCAN match/TEMP B-TREE, not on the whole line. Do not loosen the bound to 100 ms and call it fixed: that leaves the flake in place, only rarer.Suggested builder: scout, who found it while on #126. A person assigns.