Skip to content

games_hub: each game owns its terms and their serde - #1678

Merged
aaylward merged 2 commits into
mainfrom
claude/hopeful-ramanujan-uwueor
Oct 19, 2026
Merged

aaylward merged 2 commits into
mainfrom
claude/hopeful-ramanujan-uwueor

Conversation

@aaylward

@aaylward aaylward commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

#1668 phase 1, terms. Built against the pins from #1677.

  • HostedTerms = variant<ChessTerms, PongTerms> beside HostedState. The hub, rows and TableContext carry it without reading it.
  • Each game with challenges or round robins declares Terms and owns its serde: TermsJson/TermsFromJson/TermsLine (kChallenges), RoundRobinBody(terms)/FromRoundRobinBody(body) (kRoundRobins). Chess's serde moved out of pg_hub_store.cc; its lobby line moved out of hub.cc.
  • ChessEventRow.pong_variant and .kind are gone: a round robin's terms say which game it is (RoundRobinKind). A static_assert holds every HostedTerms alternative to exactly one game's Terms.
  • A pairing's table waits on its round robin's terms exactly when its game takes challenges (the only case the store can read back); the RoundRobinTerms hook is gone.

Stored bytes: chess unchanged (pins green unedited). Pong's round robin body no longer writes chess's unused zeroed terms; bodies stored with them still load and rewrite in the new form (new pin). Rollback cost: a pre-change binary can't read pong round robins created, or updated, after this deploys, and drops them with a log line. Chess is unaffected.

Go's terms are not here: they have no reader until Go takes challenges (phase 2), so they land there.

Tests: //domains/games/... 225/225 with Postgres, no skips. The new pong pin was red before the change. Body refusals, waiting terms and the lobby line now have Postgres-free unit tests in adapters_test; mutation-check kills the named-body, "game" type, kChallenges and chess-missing-terms mutants. Breaking terms ownership fails the build.

Review panel ran; fixups in 1d9f58e (derived kind, pairing-terms rule, unit tests, comment drift). Not taken: folding the body hooks into TermsJson (adds an override mechanism to save Go a two-line wrapper).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xae1QBa2qHX32DPVGSq19F

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ast-lol 1d9f58e Commit Preview URL

Branch Preview URL
Oct 19 2026, 02:07 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
1d4-web 1d9f58e Commit Preview URL

Branch Preview URL
Oct 19 2026, 02:05 PM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
iili 1d9f58e Commit Preview URL

Branch Preview URL
Oct 19 2026, 02:06 PM

@github-actions github-actions Bot added the service:games_hub Changes the games_hub image label Oct 19, 2026
@cursor

cursor Bot commented Oct 19, 2026

Copy link
Copy Markdown

CI: 1d9f58ea

All checks green (build-and-test, asan, ubsan, tsan included). Approve unchanged.

@cursor

cursor Bot commented Oct 19, 2026

Copy link
Copy Markdown

Review: each game owns its terms and their serde

Verdict: Approve. Right phase-1 cut for #1668 against the #1677 pins: HostedTerms beside HostedState, adapters own serde, kind is derived from terms, chess bytes unchanged, pong drops the unused chess terms with a load-and-rewrite pin for legacy rows. Tip 1d9f58ea. All checks green.

What works

Ownership. ChessTerms / PongTerms → HostedTerms; TermsLineUp static_assert holds each alternative to exactly one game's Terms. Hub / TableContext / rows carry without reading. kChallenges gets TermsJson / TermsFromJson / TermsLine; kRoundRobins gets RoundRobinBody(terms) / FromRoundRobinBody(body). Chess serde moved out of pg_hub_store; lobby line via TermsLineOf.

Kind from terms. RoundRobinKind visits the terms alternative; ChessEventRow.kind / .pong_variant gone. Withdraw / list / play compare via RoundRobinKind. RoundRobinTermsOf returns the row's terms only when that game has kChallenges (chess waits; pong starts on fill via RoundRobinStart) — pinned in adapters_test.

Stored bytes. Chess waiting-state and RR body goldens unchanged (write + load→rewrite). Pong RR body is now game+variant only; kLegacyPongEventBody (unused zeroed chess terms) loads and rewrites to the new form through LoadRoom and LoadSnapshot. Rollback cost as stated: a pre-change binary drops post-deploy pong RRs; chess unaffected.

Tests. Unit coverage for body round-trip, malformed refusals (named-body / float clock / missing terms), pairing-terms rule, lobby line. Panel fixups in 1d9f58ea. Mutation-check claim covers the named mutants.

Non-blocking / ops

  • Go terms deferred until challenges (phase 2) — correct.
  • Disclosed non-act: folding body hooks into TermsJson — fine.
  • Deploy: prefer rolling readers that understand the new pong body before writers that emit it (or accept dropping in-flight legacy-binary pong RRs).

Tip 1d9f58ea. Part of #1668.

@aaylward
aaylward merged commit c890481 into main Oct 19, 2026
24 checks passed
@aaylward
aaylward deleted the claude/hopeful-ramanujan-uwueor branch October 19, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

service:games_hub Changes the games_hub image

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants