You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/Game/index.ts has accumulated two related forms of tech debt that both need to be paid down in the same file. This epic tracks them together so the work is sequenced coherently rather than colliding.
refactor: split Game/index.ts god file into cohesive modules #132 — Structure: split the 2491-line god file (~40 static methods, six concerns) into cohesive modules (shared, guards, undo, cube, lifecycle, turnFlow, robot) behind a facade Game class, with no public-API change.
All three edit or protect the same file and touch the same weak spots — the undo stack and cube fields are simultaneously untyped (#96), scattered across concerns (#132), and untested (#134). Doing them blind to each other risks merge churn and rework; the coverage gap makes the refactor riskier precisely where it's largest.
Type changes are in-scope (authorized). The undo casts are removable outright: promote undo?: { frames: BackgammonGameMoving[] } from BackgammonPlayMoving to BasePlay in packages/types/src/play.ts, using a type-only import type for BackgammonGameMoving (defined in the same package at game.ts:193). Contrary to an earlier note, this is not a types→core dependency — it's only a play.ts ↔ game.ts file cycle inside the types package, which is harmless for an erased type-only import.
Either order works as long as the two are coordinated and not run in parallel on overlapping lines.
Epic:
Game/index.tsremediationsrc/Game/index.tshas accumulated two related forms of tech debt that both need to be paid down in the same file. This epic tracks them together so the work is sequenced coherently rather than colliding.The three parts
as anycasts in Game/index.ts with proper type definitions #96 — Type safety: eliminate theas anycasts (~46 onfeat/4.6.4-RC), including the untypedundostack and cubeofferedThisTurnBy. Requires additions to@nodots/backgammon-types.shared,guards,undo,cube,lifecycle,turnFlow,robot) behind a facadeGameclass, with no public-API change.Game/index.tsat ~54% stmt / ~46% branch, lowest exactly on the cube/undo/resign/restore methods refactor: split Game/index.ts god file into cohesive modules #132 moves.Why group them
All three edit or protect the same file and touch the same weak spots — the undo stack and cube fields are simultaneously untyped (#96), scattered across concerns (#132), and untested (#134). Doing them blind to each other risks merge churn and rework; the coverage gap makes the refactor riskier precisely where it's largest.
Sequencing
as anycasts in Game/index.ts with proper type definitions #96 first (or its type additions). Promote the undo/cube/stateVersion types in@nodots/backgammon-types, then remove the casts. This lets the decomposition land into already-typed code.undo.tshelper, then deletes the casts once the type is fixed.Type changes are in-scope (authorized). The undo casts are removable outright: promote
undo?: { frames: BackgammonGameMoving[] }fromBackgammonPlayMovingtoBasePlayinpackages/types/src/play.ts, using a type-onlyimport typeforBackgammonGameMoving(defined in the same package atgame.ts:193). Contrary to an earlier note, this is not a types→core dependency — it's only aplay.ts↔game.tsfile cycle inside the types package, which is harmless for an erased type-only import.Either order works as long as the two are coordinated and not run in parallel on overlapping lines.
Done when
as anyinsrc/Game/index.ts(chore: Eliminateas anycasts in Game/index.ts with proper type definitions #96)index.tsis a thin facade delegating to per-concern modules (refactor: split Game/index.ts god file into cohesive modules #132)Game/__tests__suite is green, and api + ai build unchanged