Skip to content

epic: Game/index.ts remediation (types #96 + decomposition #132 + coverage #134) #133

Description

@nodots

Epic: Game/index.ts remediation

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.

The three parts

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

  1. chore: Eliminate as any casts 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.
  2. refactor: split Game/index.ts god file into cohesive modules #132 second. Phase 2 of the split consolidates undo-stack access into a single undo.ts helper, 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[] } 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.tsgame.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.

  1. test: expand core coverage, starting with Game/index.ts extraction targets #134 interleaves ahead of refactor: split Game/index.ts god file into cohesive modules #132. For each extraction phase in refactor: split Game/index.ts god file into cohesive modules #132 that moves an under-covered method (cube, undo, resign, restore, switchDice), the matching characterization tests from test: expand core coverage, starting with Game/index.ts extraction targets #134 land first, so a green suite after extraction proves behavior was preserved. The broader coverage lift + threshold gate in test: expand core coverage, starting with Game/index.ts extraction targets #134 can follow independently.

Done when

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions