8000 RDC - Keep full-mode AI loops alive across aborts and New Game by rchasman · Pull Request #19 · rchasman/dominion-maker · GitHub
[go: up one dir, main page]

Skip to content

RDC - Keep full-mode AI loops alive across aborts and New Game - #19

Merged
rchasman merged 3 commits into
masterfrom
fix/full-mode-opponent-decisions
Sep 19, 2026
Merged

rchasman merged 3 commits into
masterfrom
fix/full-mode-opponent-decisions

Conversation

@rchasman
Copy link
Copy Markdown
Owner

One thing

In full mode the AI must never stop and wait for a human. This PR closes the ways an AI loop could stall so the board sits on a human-style prompt ("Discard down to 3", "SKIP TO BUY") with nothing voting.

Root causes

  1. handleModelResult returned early when the consensus controller was aborted and never called onComplete. Any external abort (abortOngoingConsensus from New Game, mode switch, unmount) left runModelsInParallel pending forever, so runAITurn / resolveAIPendingDecision never settled and isProcessing was never released. Every automation effect returns early while isProcessing is true, so the game was dead until reload.
  2. startGame aborted the consensus but did not reset isProcessing, so the new game inherited the stuck flag.
  3. Both automation loops reset the shared isProcessing flag in finally even after being superseded, which let a second loop start on the same engine. Now only the loop whose abort signal is still live releases the flag, and it syncs the engine to signals in the same place so the UI never shows a stale pending choice.
  4. useAutoPhaseAdvance always acted for the "human" seat, including in full mode where that seat is AI-controlled after a hybrid game switches to full.

Evidence

Reproduced in Chrome against the dev server with a seeded full-mode game (opponent has a live Militia discard):

  • Before: click New Game while the discard consensus is running. The next game sits at "TURN 1 - PULSE (AI)" showing SKIP TO BUY, no "AI thinking", no agent console output for 20+ s.
  • After (this branch): same steps. The old loop errors out with "All AI models failed", releases nothing, and the new game plays turns 1-3 continuously (console: "AI turn start: Zenith", buys, end phase).

Also verified on master that the plain Militia path (restored state, live play, and hybrid-to-full switch mid-decision) already resolves through consensus, so the reported pause is this stall class rather than a missing decision handler.

Unit test: handleModelResult now has a test that fails on master (aborted result must still report completion).

bun test: 2185 pass, 0 fail. bun run type and bun run lint clean.

Dead code

Removed convertToFullModePlayers and its tests: it had no production caller. 1 removal.

Not in this PR

The app blocks its main thread for a long time after load and during consensus (65 s between "Restoring saved mode" and "Restored game" on production with 642 events, and a 1e6-iteration loop took 949 ms on an idle page). Separate investigation.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB

rchasman and others added 3 commits September 19, 2026 15:39
An aborted model returned before calling onComplete, so an external
abort (New Game, mode switch) left runModelsInParallel pending forever
and the AI loop never released isProcessing.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB
A superseded loop resetting the shared flag let a second loop start on
the same engine. New Game now clears the flag itself, and the engine is
synced to signals in finally so the board never shows a stale prompt.
Auto phase advance is skipped when the human seat is AI-controlled.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N9d8nojPb1FPFCGZ8vcRSB
@vercel
vercel Bot commented Sep 19, 2026 •
Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dominion-maker Ready Ready Preview Sep 19, 2026 5:51am UTC

@rchasman
rchasman merged commit b727ac7 into master Sep 19, 2026
4 checks passed
@rchasman
rchasman deleted the fix/full-mode-opponent-decisions branch September 19, 2026 05:52

This branch was successfully deployed

1 active deployment
Preview — b51a4195 Deployed Sep 19, 2026 by vercel[bot]
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

0