testsAndMisc/docs/superpowers/evidence/poker-stakes-file-length-2026-08-16.json
Krzysztof kuhy Rudnicki 73b85f5326 Split poker-stakes' four oversized files under the 250-line cap
useGame.test.tsx (494) splits by describe-block into reducer/session/debt
files; handEval.test.ts (269) splits at the evaluate7 boundary; useGame.ts
(268) sheds its state and reducer into gameState.ts; handFlow.ts (252) sheds
its betting-state helpers into handFlowBetting.ts.

useGame.ts and handFlow.ts re-export what they moved, so no importer changed.

The shared test helpers live in src/test/ rather than beside the source they
exercise. That is load-bearing: vite.config.ts already excludes src/test/ from
coverage, so no new exclusion entry was needed. Putting them next to the source
first dropped coverage to 98.57% because v8 counted the fixtures' unused
branches as production code -- fixed by moving them, not by excluding them.

Verified: 220 tests still pass, coverage back to 100% on statements, branches,
functions and lines, and npm run build succeeds. poker-stakes violations 4 -> 0;
repo total 196 -> 192.

invariants.test.ts hit its 5s timeout once mid-work. It passes standalone in
2.56s and on re-run, so it is a pre-existing contention flake under parallel
coverage load rather than a regression here -- noted, not papered over.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-16 15:26:18 +02:00

43 lines
2.7 KiB
JSON

{
"intent": "Bring poker-stakes' four over-250-line files under the shared cap without weakening its 100% coverage gate.",
"scope": [
"poker-stakes/src/ui/useGame.test.tsx (494) -> reducer/session/debt test files + shared fixtures",
"poker-stakes/src/engine/handEval.test.ts (269) -> rank5/compare test files + shared fixtures",
"poker-stakes/src/ui/useGame.ts (268) -> useGame.ts + gameState.ts",
"poker-stakes/src/engine/handFlow.ts (252) -> handFlow.ts + handFlowBetting.ts",
"Non-goal: any behaviour change; non-goal: violations outside poker-stakes/"
],
"changes": [
"Split useGame.test.tsx by describe-block into useGame.reducer/session/debt.test.tsx (75/219/156 lines).",
"Split handEval.test.ts at the evaluate7 boundary into handEval.rank5.test.ts (174) and handEval.compare.test.ts (67).",
"Extracted shared test helpers to src/test/useGameFixtures.tsx and src/test/handEvalFixtures.ts. Placed under src/test/ deliberately: vite.config.ts already excludes that directory from coverage, so no NEW exclusion entry was needed. An earlier attempt put the fixtures beside the source, where v8 counted their unused branches as production code and dropped coverage to 98.57%.",
"Extracted GameState/HandPhase/gameReducer/hasOutstandingDebt into gameState.ts; useGame.ts re-exports them so no importer changed.",
"Extracted the betting-state helpers into handFlowBetting.ts; handFlow.ts re-exports potFromBetting for its existing consumers."
],
"verification": [
{
"command": "cd poker-stakes && npm run check",
"result": "pass",
"evidence": "exit 0; 220 tests passed (unchanged count); Statements 100% (572/572), Branches 100% (299/299), Functions 100% (109/109), Lines 100% (542/542)."
},
{
"command": "cd poker-stakes && npm run build",
"result": "pass",
"evidence": "built in 84ms; dist/assets/index-zO7BhOW2.js 208.17 kB. Confirms the module graph still resolves after the extractions."
},
{
"command": "bash ~/utils/scripts/check_file_length.sh --all",
"result": "pass",
"evidence": "poker-stakes violations: 0. Repo total 196 -> 192."
}
],
"risks": [
"invariants.test.ts failed once on a 5s timeout during this work. Investigated rather than retried blindly: it passes standalone in 2.56s and passed on re-run of the full suite, so it is a pre-existing contention flake under parallel coverage load, not a regression from the split. Left unfixed as out of scope, but it will recur in CI.",
"The test splits move tests between files; a future reader must not assume a describe-block's tests are all in one file."
],
"rollback": [
"git revert this commit; the four original files return intact.",
"Validate with: cd poker-stakes && npm run check"
]
}