Skip to content

Deepen four modules: Point Ledger, GameStore, loader harness, gameClient#1

Merged
gsiener merged 2 commits into
mainfrom
refactor/deepen-modules
Jul 11, 2026
Merged

Deepen four modules: Point Ledger, GameStore, loader harness, gameClient#1
gsiener merged 2 commits into
mainfrom
refactor/deepen-modules

Conversation

@gsiener

@gsiener gsiener commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Architecture review surfaced four shallow seams; this deepens all four. All 241 tests pass (52 shared + 189 bot) and the changes were verified end-to-end on wrangler dev.

What changed

  • Point Ledger (packages/shared/src/pointLedger.ts) — collapses three independent break/hold algorithms into one forward-pass module. calculateLineStats folds over it; web breakDetection.ts and the timestamp halftime heuristic are deleted; timeline, progression, lineup table, and StatsCalculator all read the ledger. Legacy behavior locked by a parity test against a verbatim copy of the old isBreakScore.
  • GameStore (packages/bot/src/store/GameStore.ts) — concentrates the DO↔D1 dual-write behind one seam. DO-first writes (ADR-0001), GameState converted to typed Durable Object RPC (ADR-0002, compatibility_date → 2025-10-01), router shrunk to a thin HTTP adapter. First tests for the sync logic via in-memory fakes. Fixes updateGame's fire-and-forget divergence and a broken cold-DO rehydration (chatId passed as gameId).
  • Loader harness (packages/bot/scripts/lib/loader.ts) — replaces 22 copy-pasted tournament scripts with loadTournament(spec). Real IANA timezone conversion, one env-driven API URL, replace mode. Old scripts moved to scripts/archive/ unchanged; load-example-spec.ts is the template.
  • gameClient (packages/web/src/api/gameClient.ts) — now the only web→API path. Four typed fetchers plus a poll() helper; one base URL, one error path. Game list standardized on limit=100.

Also adds CONTEXT.md (domain glossary), the two ADRs, and the HTML architecture review that motivated the work.

Before deploy

The compatibility_date bump (2024-01-01 → 2025-10-01) for the Durable Object RPC conversion is the one change local testing can't fully de-risk. ADR-0002 lists the post-deploy smoke checks; rollback is redeploying the old date.

🤖 Generated with Claude Code

gsiener and others added 2 commits July 11, 2026 09:29
Architecture review surfaced four shallow seams; this deepens all four.

Point Ledger (packages/shared/src/pointLedger.ts): collapse three
independent break/hold algorithms into one forward-pass module.
calculateLineStats folds over it; delete web breakDetection.ts and the
timestamp halftime heuristic; timeline, progression, lineup table, and
StatsCalculator all read the ledger. Legacy behavior locked by a parity
test against a verbatim copy of the old isBreakScore.

GameStore (packages/bot/src/store/GameStore.ts): concentrate the DO<->D1
dual-write behind one seam. DO-first writes (ADR-0001), GameState
converted to typed Durable Object RPC (ADR-0002, compat date bumped to
2025-10-01), router shrunk to a thin HTTP adapter. First tests for the
sync logic via in-memory fakes. Fixes updateGame's fire-and-forget
divergence and a broken cold-DO rehydration (chatId passed as gameId).

Loader harness (packages/bot/scripts/lib/loader.ts): replace 22
copy-pasted tournament scripts with loadTournament(spec). Real IANA
timezone conversion, one env-driven API URL, replace mode. Old scripts
moved to scripts/archive/ unchanged; load-example-spec.ts is the template.

gameClient (packages/web/src/api/gameClient.ts): make it the only
web->API path. Four typed fetchers plus a poll() helper; one base URL,
one error path. Game list standardized on limit=100.

Also adds CONTEXT.md (domain glossary), the two ADRs, and the HTML
architecture review that motivated the work. 241 tests passing
(52 shared + 189 bot); verified end-to-end on wrangler dev.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gsiener gsiener merged commit 3faa1d1 into main Jul 11, 2026
1 check passed
@gsiener gsiener deleted the refactor/deepen-modules branch July 11, 2026 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant