# QA-PLAN.md — the format

`QA-PLAN.md` lives at the GAME repo's root. The agent authors and maintains it;
the developer owns it and approves every commit. Agents parse it by reading —
keep it exactly this shape, nothing fancier.

## Plan frontmatter

YAML at the very top of the file:

```yaml
---
game: Solar Drift
game_slug: solar-drift                          # the issue board's id — minted ONCE, never renamed
build_command: ./scripts/package.sh --release   # the ONE command that produces a shippable build
platforms: [windows]                            # windows | macos | ios | web
input: XInput gamepad                           # optional; default keyboard+mouse
---
```

`game_slug` is minted once from the game name — lowercase, every run of
non-alphanumerics collapsed to a single `-`, no leading or trailing `-`, ≤64
characters — and is then permanent, exactly like a check id: it names the
game's issue board, and renaming it orphans every issue filed under the old
one. Every playtest round is filed with it as `game`.

`build_command` is recorded once at setup so every future run can build without
asking. `platforms: [web]` means a browser-playable game — its "build" is a
static directory, not a zip. `input` declares the hardware the
first-15-minutes check (and any check that needs it) is played on — rounds
must ask playtesters to confirm what they actually used.

## Checks

One `##` section per check; the heading is the check's short name. The section
opens with a fenced yaml block, then the steps as prose:

```yaml
id: save-loads            # stable slug — never reused, never renamed
rung: human               # human | code
origin: authored          # "authored", or the round id that minted/last changed it
setup: "?save=campaign-mid"  # optional: the link/flag that forces this check's precondition
```

- **Steps are prose for a person**: numbered, imperative, written so a
  playtester who has never seen the game can follow them. At filing time each
  check becomes ONE id-tagged step with typed verdict options, so end the
  steps in an observation ask ("describe what you saw"), never a
  confirmation ("confirm it appears").
- **Execution history lives on the server.** Read typed outcomes from
  `qaping rounds --processed --game <game_slug> --json`. Old `state` and
  `last_verified` annotations in existing plans are historical only; stop
  updating or consulting them as live facts. No status synchronization is needed.
- **`setup` names the test affordance** that forces the check's precondition —
  a URL param (`?fresh=1`, `?state=<checkpoint>`), a flag, a bundled-fixture
  load control. At filing time the hook rides the ROUND's `url` — the review
  interface loads it itself; testers cannot open links or type URLs — and
  the filed step states only the player-visible expectation, never the
  mechanism. A check
  whose precondition can be neither forced nor verified is testimony-only —
  say so in its prose.
- **Fixtures are provisioned by the dev's repo**: a previous-version save
  ships inside the build (or seeds via URL param on web) and is named in the
  check's steps — an anonymous playtester in a fresh browser cannot possess
  it.
- **Order the file critical-path first**: boots to menu, previous-version save
  loads, first 15 minutes on the declared input hardware, core loop, settings
  persist — then game-specific checks.
- A `rung: code` check keeps its prose (it documents intent) and adds one
  `test:` line naming the repo test that now asserts it, e.g.
  `` test: `tests/save_compat.test.ts` ``. Mechanically-assertable checks
  enter at `rung: code` on day one — human rounds are for judgment.

## Example section

````markdown
## A previous-version save loads

```yaml
id: save-loads
rung: human
origin: authored
setup: "?save=campaign-mid"
```

1. The game opens already loaded into the save "campaign-mid.sav" (made on
   the previous release; the round's link forces it — no action needed).
2. Play for one minute in the desert outpost.
3. Describe what you saw: where you resumed, what the inventory held, and
   anything missing, corrupted, or visually wrong.
````

## Bugs live on the issue board; checks live here

A check is what the game must ALWAYS do — it belongs in this file, forever. A
bug is what the game does wrong right now — it belongs on the game's issue
board (`qaping issues <game_slug>`, moved by the agent through the
`qaping_issues` tool), where it is numbered, carried across rounds, and
retired when it is gone. Do not write bugs into `QA-PLAN.md`: a check written
to describe one bug ("the shop does not close when you press B twice") ages
into a puzzle the moment the bug is fixed.

The board is what makes a fix provable. The agent may CLAIM a fix (with the
exact build URL the next round will play); only a playtester answering
"Gone" on a round filed after that claim — against that same build — turns the
issue *verified*, and a "Still here" on a claimed fix regresses it. A blocker
or a major needs TWO playtesters to say "Gone" before it turns green; a minor
or cosmetic needs one.

Because every round is filed with `game`, the board's live issues ride it as
the playtester's checklist — no step budget spent, no bug forgotten between
patches. The checklist is sized to the session (8 issues on a 5-minute round,
18 on a 30-minute one, 20 at the ceiling) and it rotates, so a minor filed
weeks ago comes back round instead of starving behind the blockers. Each
issue gets one of four answers: **Still here**, **Gone**, **Couldn't test**
(reached it, still could not tell) or **Didn't reach** (never got to that part
of the game).

A check and the bug that came from it stay linked through the issue's
`check_id`: the same id this file gives the check. Each issue also carries an
optional `area` — one or two words a player recognises, like "camp screen" —
which is how the checklist groups itself into a route through the game.

## Round state and history live on the server

Every successfully filed playtest is recorded automatically. Send private
`qa_context` at filing time so context and round are saved atomically:

```json
{"checks":["save-loads"],"note":"Save format migration", "commit":"<git SHA>",
 "pr_url":"https://github.com/example/game/pull/42"}
```

The fields are optional; include the selected check ids for every QA-plan
round. The server's `game`, build URL, filing time, deadline, player results
and billing remain the original facts. Patch notes are private to the developer
and never appear in player instructions or the public feed.

`qaping rounds --game <slug>` lists unprocessed work. Use `--all` for all
history (`--remote` remains an alias) or `--processed` for completed agent
reports. `qaping rounds show <id>` includes context, the current report,
previous reports, imported history and current `response_ids`. Follow
`next_cursor` for older pages (50 by default, `--limit 1-100`). Omit `--game`
for old rounds without a slug. A failed fetch is an error, not an empty queue.

Player completion and agent processing are separate. Read-only results do
not mark a report processed. Claim a ready or expired round before collecting:

```sh
qaping rounds claim <id>
qaping results <id>
qaping rounds complete <id> --token <token> --revision <revision> --responses <id,id|none> --report report.json
```

The claim returns the token, revision and response ids. Keep those from BEFORE
reading results. A claim lasts 30 minutes; repeat `claim --token <token>` to
renew it, or `release <id> --token <token>` to stop collecting. Another agent
cannot take a live claim. An expired claim can be recovered after a crash.

The report is the agent's interpretation, stored separately from player evidence:

```json
{"evidence_grade":"testimony only (web round)","verdict":"PASS",
 "checks":[{"id":"save-loads","outcome":"Pass"}],
 "follow_ups":["Add a controller check"],"external_refs":[],"summary":"The report text"}
```

Outcomes are `Pass | Fail | Blocked | NOT-ASKED`. A VOID precondition is
`Blocked` with a `note` explaining why. Every selected check appears exactly
once. `follow_ups` contains unresolved NON-BUG work; bugs belong on the issue
board. `external_refs` and `summary` are optional. Report links are obtained
from the server listing; build and billing facts are not copied into this record.
Signed recording URLs expire, so use durable report or issue links in reports.

Completion saves the report and marks work processed in one transaction.
Retry the exact request after an uncertain reply. A conflict requires fresh
results and workflow state; never overwrite it blindly. New results or a changed
transcript reopen work without discarding earlier reports. Use the round id
as a stable marker in external PR comments so recovery updates an existing
comment instead of posting it twice.

## Importing older local files

`qa-open-rounds.json` and `qa-rounds.jsonl` are retired. To move existing records:

```sh
qaping rounds import --dry-run
qaping rounds import
```

The import validates both files before any write and imports each owned round
once. It retains original metadata and history under `workflow.legacy`, including
old verdicts and follow-ups, without overwriting server builds, statuses, reports
or newer context. Completed historical records mark terminal rounds processed;
pending player work stays unprocessed. A missing/wrong-account id is an error:
check `qaping whoami`, fix it and retry. Old rounds without a game remain unassigned.
Both files remain byte-for-byte intact as backups; never delete them automatically.
After a successful import, stop reading and writing them. A fresh repo needs neither.

## Maintenance rules

- Save execution outcomes and follow-ups on the server. Only definition changes
  edit the plan; findings-driven edits record the round id as `origin`.
- New checks start `rung: human` (unless mechanically assertable — then
  `rung: code` with a repo test written at entry), `origin: authored`.
- Promotion (human → code) and any deletion/demotion happen only with the
  developer's explicit agreement.
- **QA memory**: the plan accretes from conversation, not just QA runs — when
  the developer mentions something that should always be tested, a fragile
  area, or a lesson learned, the agent offers to record it as a check (or a
  note on an existing check) right then.
