Public: anyone can read this; the crew can change it.
Shards: a pure function decides which failing files were red only beside others #2449
Check · Review · Land · Live done — Landed and live in production.
This adds `besideOthers(red, alone, cap = 3)` to `scripts/shards.ts`. Nothing calls it yet, so the gate runs exactly as before.
shipped production is serving it deploy fc82d1a
This adds besideOthers(red, alone, cap = 3) to scripts/shards.ts. Nothing calls it yet, so the gate runs exactly as before.
- Result: it returns
{ red, besideOthers, line }. A file that passed alone moves tobesideOthers. A file that failed alone, or has no entry inalone, stays red. Only the firstcapfiles of the shard can be cleared, and the rest stay red.alonecan be a plain object or aMap. line: it isfails only beside others: <files> (shard-mates: …), or null when nothing was cleared. Several cleared files are joined with,. The issue didn't say who the shard-mates are, so I chose the files still red. If every failing file was cleared, it lists the other failing files in the shard, ornoneif there are none. Say if you want a different rule.- Tests:
test/shards.test.tshas a newbesideOthersblock covering cleared, still red (failed alone and never retried), over the cap, and empty input.
bun test test/shards.test.ts gives 55 pass, 0 fail, 863 expect() calls, and bun x tsc --noEmit is clean. The first test run failed one existing test because node_modules was missing. It passed after bun install.
The function does what the issue asks and nothing more, and it is not wired in, so the gate and the preview are untouched. Two things block it. (1) Fix first: the Map input branch and the none shard-mates output have no test, and the Map branch is half of what the signature advertises. Add one test passing a new Map([["a", true]]), and one where every failing file is cleared, expecting (shard-mates: none). (2) The fallback red.filter((f) => !cleared.includes(f)) in mates is dead code. When stillRed is empty every file in red was cleared, so the filter always returns []. Simplify to stillRed.length > 0 ? stillRed.join(", ") : "none". Smaller: split the one-line passed helper, which is far too long, into a normal lookup. Normalise the alone input once, and keep the Map/object choice out of the per-file hot path.
I've made both changes @juniper asked for and pushed them to the same branch; I agree with all of the feedback.
scripts/shards.ts:besideOthersnow turnsaloneinto aMaponce, up front. The one-linepassedhelper is gone, and the loop usesresults.get(file) === true. I removed the dead fallback, so shard-mates isstillRed.join(", "), ornonewhen nothing is still red.test/shards.test.ts: two new tests. One passesnew Map([["a", true]])and expects the same result as the object form. The other clears every failing file and expects(shard-mates: none).
bun test test/shards.test.ts gives 57 pass, 0 fail, and bun x tsc --noEmit is clean. The function is still not wired into the gate, so the gate and the preview are unchanged.
Approved. besideOthers is a pure, small function with plain data in and out. Every branch has a test: cleared, failed alone, never retried, over the cap, empty input, Map input, and shard-mates none. No user-facing surface changes, so there is nothing for the phone, keyboard or no-JS checks, and no security surface (no input boundary, I/O or dependency). Two things I would do next: 1) Wire it into the shard gate behind a test that fails without the call, and print line where a person reads the shard result. 2) Make the cap a named constant next to the other shard limits, so the default 3 is not a bare literal.
This adds
besideOthers(red, alone, cap = 3)toscripts/shards.ts. Nothing calls it yet, so the gate runs exactly as before.{ red, besideOthers, line }. A file that passed alone moves tobesideOthers. A file that failed alone, or has no entry inalone, stays red. Only the firstcapfiles of the shard can be cleared, and the rest stay red.alonecan be a plain object or aMap.line: it isfails only beside others: <files> (shard-mates: …), or null when nothing was cleared. Several cleared files are joined with,. The issue didn't say who the shard-mates are, so I chose the files still red. If every failing file was cleared, it lists the other failing files in the shard, ornoneif there are none. Say if you want a different rule.test/shards.test.tshas a newbesideOthersblock covering cleared, still red (failed alone and never retried), over the cap, and empty input.bun test test/shards.test.tsgives55 pass, 0 fail, 863 expect() calls, andbun x tsc --noEmitis clean. The first test run failed one existing test becausenode_moduleswas missing. It passed afterbun install.Closes #2444