Skip to content

Resolve a turn from the whole game, not from the committer's view - #13

Merged
aburston merged 3 commits into
masterfrom
claude/game-adjudication-two-players-eiks0s
Aug 25, 2026
Merged

aburston merged 3 commits into
masterfrom
claude/game-adjudication-two-players-eiks0s

Conversation

@aburston

@aburston aburston commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Why

A two-player game played over the API ended on turn 1: whoever committed second was declared the winner, before an order had been given.

POST /commit resolves the turn during the request that closes the barrier, and it opened the resolving session as the committing player:

resolver = Game(_repository(gameno), int(number))   # ← the player, not the game
resolved = resolver.resolveWhenReady()

A player's session is built from that player's own published view — visibility requires exactly that — so it holds only the units that player may see and loads no other player's orders. Resolving from one applied a single player's orders, then republished that half-sighted board as units, the record of the game. Every other player's units were not moved and not fought but erased; elimination is derived from the board, so everybody else was found to have nothing standing and the game was decided in the committer's favour.

The local file transport and the command line roles always resolved as player 0, which is why a game played through bgcserver was never affected.

Two things kept it invisible:

  • the endpoint's tests used a one-player game — where the only player sees all of their own units, so the board they resolve from is the whole board — or stopped at the commit before the one that resolves;
  • every HTTP test is pinned @pytest.mark.backend('sqlite') and CI ran pytest with no BOARD_GAME_BACKEND set, which is YAML, so some fifty tests were skipped on every run. Nothing was failing; nothing was running.

What changes

  • http/app.py — the player branch of POST /commit resolves as identity.ADMINISTRATOR. Publishing stays the player's act; the resolution is the whole game's. The payload is built from the committing player's own reloaded session, so a player is still answered as they are entitled to be.
  • service/turn.py — resolve refuses any session not entitled to the whole game and allowed to change it, before anything is written. Which session resolves is now a rule of the game rather than something each caller is trusted to get right. The observer is refused too: resolving from one would be a read that wrote.
  • .github/workflows/python-app.yml — the build job becomes a matrix over yaml and sqlite, passing the backend through the env var tests/conftest.py already reads, so a pinned test is run by the job it is pinned to rather than by neither.

Nothing breaks: a single-player game, and every game played through bgcserver, behaved correctly before and behaves identically now.

Tests

  • tests/test_two_player_commit.py (new) — the scenario: board, two players, a unit each, commit 1 then commit 2. The first commit waits (202), the second resolves (200), both units are on the board, neither player is eliminated, the game is undecided, and it goes on to a second turn. It plays the same game against the service layer as a control. Deliberately unpinned, so it runs on whichever backend the job is for. 5 of its 7 tests fail without the fix.
  • tests/test_client_over_http.py — the same game end to end through two bgcclient subprocesses, beside the one-player test that missed this.
  • tests/test_turn_publication.py — a player's session and the observer's are each refused a resolution, and the turn is still there for the administrator.

Both backends green locally with the package installed as CI installs it: 658 passed (YAML), 630 passed (SQLite). flake8 . --select=E9,F63,F7,F82: 0.

Specs

  • openspec/specs/turn-commit/spec.md gains A Turn Is Resolved From The Whole Game.
  • SPEC_COVERAGE.md records it as divergence 30, including what let it through CI.
  • Archived under openspec/changes/archive/2026-08-25-resolve-a-turn-from-the-whole-game/ — proposal, design, tasks, and the turn-commit delta (checked word for word against the requirement now in the spec).

The design records one thing seen and deliberately not fixed here: the administrator branch of POST /commit still resolves without asking the barrier, which is what HttpSession.resolve_pending reaches over HTTP. Nothing reaches it today (bgcserver exits after setup in HTTP mode) and it cannot decide a game wrongly, since the board it republishes is the whole board.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VXonvopjxDEQ8YUXAu91ct

claude added 3 commits August 24, 2026 23:04
A two-player game played over the API ended on turn 1: whoever committed
second was declared the winner before an order had been given.

The commit endpoint resolves the turn during the request that closes the
barrier, and it opened the resolving session as the committing player. A
player's session is built from that player's own published view - it loads
no other player's orders and holds no other player's units - so the
resolution applied a single player's orders and then republished that
half-sighted board as the record of the game. Every other player was erased
from it, judged to have nothing standing, and eliminated.

The endpoint now resolves as the administrator, and still answers the player
who asked as they are entitled to be answered. `service/turn.py` refuses to
resolve from any session not entitled to the whole game and allowed to
change it, so which session resolves is a rule of the game rather than
something each caller is trusted to get right; `turn-commit` says so.

tests/test_two_player_commit.py plays the scenario over the endpoint and
against the service layer and holds both to one answer, on whichever backend
the run is for. test_client_over_http.py plays it end to end through two
`bgcclient` subprocesses, and test_turn_publication.py covers the refusal.
A one-player game could not show the defect, which is what the endpoint's
tests used.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VXonvopjxDEQ8YUXAu91ct
A test that is about one of the two backends is marked
`@pytest.mark.backend(...)` and is skipped by the run for the other. CI ran
`pytest` with no `BOARD_GAME_BACKEND` set, which is YAML, so every test
pinned to SQLite was skipped on every run - the whole HTTP tier, the SQLite
repository and its safety suite, some fifty tests. Nothing was failing;
nothing was running. That is what let a two-player game over the API be
decided on turn 1 with the suite green.

The job becomes a matrix over `yaml` and `sqlite`, with the backend passed to
pytest through the environment variable `tests/conftest.py` already reads, so
a pinned test is executed by the job it is pinned to rather than by neither.
`fail-fast: false` so one backend failing still reports the other.

Both jobs pass locally with the package installed as CI installs it: 658
passed under YAML, 630 under SQLite.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VXonvopjxDEQ8YUXAu91ct
The fix was made directly against the specs, so it had no change to be
recorded under; every other entry in SPEC_COVERAGE.md names one. This is the
proposal, the design and the tasks as they stood when the work was done, and
the `turn-commit` delta that produced the requirement now in the spec - which
is checked to be the requirement in the spec, word for word.

The design records two things worth knowing beyond the one line that fixed
it: why the refusal lives in `turn.resolve` rather than in the endpoint, and
that the administrator branch of POST /commit still resolves without asking
the barrier - unreachable today, harmless when reached, and seen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VXonvopjxDEQ8YUXAu91ct
@aburston
aburston merged commit 18e9bf3 into master Aug 25, 2026
2 checks passed
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.

2 participants