| name | self-play-fix |
| description | Run a two-agent Terraforming Mars CLI self-play match, triage defects, reproduce candidates in parallel, resume confirmed agents to fix them, and review the result. |
| argument-hint | [generations; default 5] |
| disable-model-invocation | true |
Self-play, reproduce, and repair
Run the whole workflow. $ARGUMENTS may specify completed generations; default to 5.
Defaults:
- Create a fresh conservative two-player game unless an existing game or variants are requested.
- Discover current CLI syntax from repository help/docs.
- Preserve unrelated changes and never expose private player IDs in the final report.
- Commit fixes locally; never push unless explicitly requested.
Phase 1: preflight
- Create phased todos for game, match, triage, red reproduction, green fixes, integration, and smoke verification. Add review/cleanup only after fixes work.
- Create the game and capture both private IDs plus game/spectator IDs.
- Define the boundary: a fresh
N-generation match stops at Generation N + 1, before any decision there; game end also stops play.
Phase 2: parallel self-play
Spawn exactly two gameplay agents in one batch. Each gets only its own private ID and MUST:
- play competitively through every prompt until the boundary;
- never inspect or submit through the opponent ID;
- prefer stable verbs and record any raw fallback;
- avoid tight polling and remain available while waiting;
- make no source, test, config, or git changes;
- treat ambiguous POST failure as unknown outcome and refresh before retrying;
- return final state/strategy, commands used, raw fallbacks, and issue evidence.
Issue evidence: severity, exact command/prompt, pre/post state, observed versus expected behavior, impact, workaround, blocker status, and CLI/upstream ownership guess.
Phase 3: close and gather
- Keep early-yielding agents running until both independently observe the boundary with all prior-generation prompts resolved.
- Confirm the stop read-only; submit nothing beyond it.
- Merge duplicate reports by suspected root cause and note when a defect changed the match.
Phase 4: shortlist and reproduce (red)
The main agent gathers and shortlists; it MUST NOT reproduce or fix candidates itself.
- Main defers obvious non-issues/P3s and publishes a preliminary candidate list with impact rationale.
- Create one worktree per independent candidate slice from the same untouched base.
- Spawn reproduction agents in one batch, record their handles, and keep each tied to its worktree.
- Each agent MUST NOT edit production code. It must produce a failing behavioral test or deterministic harness on baseline, trace responsible symbols/callsites, verify protocol claims against upstream source/docs, classify ownership/severity, and report exact red output. If unreproduced, report attempts and stop cleanly.
- Keep agents resumable after reporting. If tracked tests were intentionally removed, use a temporary/in-memory harness rather than restoring them.
- Main reviews all red reports and makes the final approved/unconfirmed/upstream/deferred selection. A shortlist is never automatic implementation scope.
Fix threshold:
- Fix reproduced P0/P1: corrupt/duplicate moves, wrong payment/state, credential crossover, or blocked play.
- Usually fix reproduced P2: misleading legal actions/payments, broken stable workflows, false success/wait state, or required raw protocol.
- Defer P3 by default when a documented stable path already works.
Phase 5: resume and fix (green)
- Resume the exact reproduction agent for each approved issue in its existing worktree; do not spawn replacements.
- Send the final behavior contract and ownership boundary.
- Require the red proof to turn green plus boundary/non-regression checks and before/after evidence.
- Preserve repository test conventions; remove temporary harnesses when tests are intentionally absent.
- Require one focused green commit per approved slice. Drop rejected candidate worktrees unchanged.
- Integrate approved commits deliberately and run combined behavioral smokes; isolated green branches are not integration proof.
Phase 6: independent review
Assign a read-only reviewer after combined smokes. Check selected contracts, slice interactions, upstream semantics, ordinary behavior, exactly-once submission, and missing coverage. Demand concrete reproductions for material claims.
Any P0-P2 finding re-enters Phase 4: delegate red reproduction, select again, then resume the same agent for green repair.
Phase 7: cleanup and report
- Remove every temporary worktree/branch, including rejected and review-correction slices.
- Run final compile/syntax checks, deterministic focused smokes, and read-only live checks without advancing the game.
- Confirm no temporary artifacts remain.
- Report match result, strategies, raw fallback count, fixed and deferred issues with rationale, review result, verification, commit tip, and push status.
Done means match, red gate, final selection, green fixes, integration, review corrections, verification, and cleanup are complete.