mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 18:34:04 +01:00
The module did two things: measure what a badge is compared against, and value each badge against it. Moved the first half to badgeBaseline.ts (185) -- the shared types, measureBaseline's 4,000-turn simulation, turnValue, bestThrowsValue, singleCharge, rankValue and the context defaults. badgeValue.ts (172) keeps valueBadge's per-effect switch and recommendBadges. The dependency runs one way, and valueBadge's default parameter still calls measureBaseline, so callers that omit a baseline behave as before. solve.ts and badgeValue.test.ts were repointed, import paths only. Coverage totals unchanged at 863/375/181/810, so every arm of the valuation switch is still exercised. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
57 lines
4.4 KiB
JSON
57 lines
4.4 KiB
JSON
{
|
|
"intent": "Bring kcd2_dice_solver/src/core/badgeValue.ts (334 lines) under the repo-wide 250-line cap with no change to any badge's estimated points per game.",
|
|
"scope": [
|
|
"kcd2_dice_solver/src/core/badgeValue.ts — reduced to valueBadge's per-effect switch, its format helper and recommendBadges",
|
|
"kcd2_dice_solver/src/core/badgeBaseline.ts — new: TURNS_PER_GAME, BADGE_SIMULATION_TURNS, BadgeValuation, BadgeRecommendation, BadgeContext, BadgeBaseline, turnValue, bestThrowsValue, measureBaseline, singleCharge, rankValue, DEFAULT_BADGE_CONTEXT",
|
|
"Import sites rewritten: core/solve.ts (BadgeRecommendation), core/badgeValue.test.ts (four helpers + BadgeContext)",
|
|
"Non-goal: any change to a valuation model, to TURNS_PER_GAME/BADGE_SIMULATION_TURNS, or to any seed"
|
|
],
|
|
"changes": [
|
|
"Split the module along the measurement/valuation seam: everything describing what a badge is compared against (the shared types, the baseline simulation, the throw and charge helpers, the ranking key and the context defaults) moved to badgeBaseline.ts, leaving badgeValue.ts holding only the per-effect valuation switch and the tier ranking that drives it.",
|
|
"turnValue and singleCharge moved with the baseline rather than staying beside their caller, since both describe how a measurement is set up rather than how an effect is valued; both were already independent of valueBadge's switch.",
|
|
"Repointed two import sites: solve.ts for the BadgeRecommendation type, and badgeValue.test.ts for bestThrowsValue, measureBaseline, rankValue, singleCharge and BadgeContext. Both are import-path-only edits — no assertion, test case or expected value changed, and the test file still imports valueBadge and recommendBadges from badgeValue.ts.",
|
|
"Function bodies moved verbatim; no statement was added, removed or reordered, which is why the coverage totals are unchanged rather than merely still 100%."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "npx vitest run",
|
|
"result": "pass",
|
|
"evidence": "Test Files 24 passed (24); Tests 288 passed (288) — unchanged, including the property tests that assert an optional badge is never worth less than nothing and a bigger tier is worth at least as much as a smaller one."
|
|
},
|
|
{
|
|
"command": "npx vitest run --coverage",
|
|
"result": "pass",
|
|
"evidence": "Statements 100% (863/863), Branches 100% (375/375), Functions 100% (181/181), Lines 100% (810/810) — identical totals to the baseline, so every arm of the valuation switch and every branch of singleCharge is still exercised."
|
|
},
|
|
{
|
|
"command": "npm run lint (tsc --noEmit && eslint src)",
|
|
"result": "pass",
|
|
"evidence": "Exit 0, no output. Confirms the six types moved across the module boundary still typecheck at both import sites."
|
|
},
|
|
{
|
|
"command": "wc -l src/core/badgeValue.ts src/core/badgeBaseline.ts",
|
|
"result": "pass",
|
|
"evidence": "badgeValue.ts 172, badgeBaseline.ts 185 — both under the 250-line cap, down from a single 334-line file."
|
|
},
|
|
{
|
|
"command": "bash ~/utils/scripts/check_file_length.sh --all",
|
|
"result": "pass",
|
|
"evidence": "src/core/badgeValue.ts no longer appears in the over-cap listing; App.tsx (306) is the only kcd2 file left."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files <changed files>",
|
|
"result": "pass",
|
|
"evidence": "All configured hooks pass on the touched files."
|
|
}
|
|
],
|
|
"risks": [
|
|
"badgeValue.ts and badgeBaseline.ts now have a one-way dependency (valuation imports baseline). valueBadge's default parameter still calls measureBaseline, so a caller that omits the baseline gets the same fresh measurement as before — the 'computed once per solve' optimisation in recommendBadges is preserved and still passes its baseline explicitly.",
|
|
"Consumers importing BadgeRecommendation now name badgeBaseline.ts, which reads slightly oddly for a result type. It travels with BadgeValuation, which the baseline module's rankValue operates on, so splitting the two would have created a circular import.",
|
|
"kcd2_dice_solver has no CI workflow and is not covered by pre-commit, so the vitest and lint runs above are the only gate on this change."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit — three edited files and one added file, with no data, config or schema migration.",
|
|
"After rollback, re-run npx vitest run --coverage and npm run lint; expect 288 tests passing at 100% coverage and lint exit 0."
|
|
]
|
|
}
|