The target build, the GDK and the target build's Ghidra results are a hard requirement: preflight adds a Ghidra results row (present and covering the target executable), setup --ghidra-results and --find save them, and an agent lacking any of the three does not work on the repo. Before investigating any problem the game shows, agents search open and merged pull requests and open issues, and work on a covering pull request's branch instead of writing a second fix. Signed-off-by: ates <ahmetrizaates@hotmail.com>
16 KiB
Working Method: Run, Fix, Pull Request
Status: in effect since 2026-11-29 (#662), together with AGENTS.md §0. The pinned ladder issue is #663.
BetterXen is built by collaborators who each have the project-authorized target build, the GDK and the target build's Ghidra results, and who work by pointing a coding agent at this repository and saying "work". This document answers one question for an agent that has just been told to work: what is the single most useful thing to do now, and how do I do it without colliding with the other agents?
The short answer: run the build, fix the first thing it stops on, and open a pull request. The pull request is the unit of work. There are no meetings, no rotating roles and no backlog to interpret.
What you must have
No agent works without all of these. bx-cli preflight checks them and fails if one is missing:
- an Apple Silicon Mac with CrossOver, D3DMetal and
mingw-w64; - the project-authorized target build;
- the GDK, headers and compilers, under the project's authorization;
- the Ghidra results of the target build: the static-analysis run (
RUN_REPORT.md,exports/,decompiled/) covering its executable; - at least 10 GiB of free disk space.
The target build, the GDK and the Ghidra results are a hard requirement: an agent that lacks even one of them does not work on the repository at all.
A collaborator only says "work". When preflight fails, the agent makes the machine ready itself: bx-cli setup --find searches the home folder, recognises the GDK by its header, the target build by its structure (never by name) and the Ghidra results by their layout and the program they cover, and saves all three in ~/.config/betterxen/local.conf, outside the repository, where every worktree and agent session on that machine finds them. It installs missing build tools with Homebrew and frees disk space by removing its own scratch.
Work here is found by running the build, located in the Ghidra results and checked against the GDK. Without all three an agent can only guess, and a guess that looks like a fix costs a reviewer more than it saves. An agent stops only for what it cannot supply: the host is not an Apple Silicon Mac, CrossOver is not installed, the build, the GDK or the Ghidra results are not on the machine, or more than one distinct build is (the choice is the collaborator's). Then it says exactly which, and does not write fixes, tests or reviews "for someone else to verify".
Why this shape
What the first target-build runs taught us:
- The build finds what tests cannot. With the start-up milestone verified complete, the build still stopped on a missing handle-duplication call, an instruction loop that trapped two million times and a page-remapping race. Nobody would have written an issue for any of them in advance.
- Guessing is expensive. A stall was blamed on network polling for a day; a thread sample found the real cause in minutes.
- A helpful workaround can hide the real path. Answering every pipeline call with success kept the frame loop alive and hid the build's fallback to shader containers.
- One run proves little. The build takes different start-up paths from run to run. Two blockers looked like one "intermittent stop" until runs were counted.
- Agents left alone drift. They wrote long documents, opened large stacked pull requests that nobody reviewed, investigated the same symptom twice, shared one game bottle and filled a disk.
So: the build decides what is next, the queue makes it unambiguous, and reviewing comes before new work.
The stages
The roadmap is a ladder of stages the target build reaches: Boot → Picture → Menus → World → Fidelity → Playable. Exactly one stage is current. Its exit gate is a ten-run check anyone can repeat.
Where the state lives
| What | Where |
|---|---|
| A blocker someone is fixing | An open pull request titled with its signature (a draft while in progress) |
| A blocker someone found and could not finish | A handoff issue (label handoff, plus stage: <name>) |
| The current stage and its latest gate result | The pinned ladder issue (label ladder) |
| What needs a person | Label needs-human |
| Rules | AGENTS.md and this document, changed by pull request |
Nothing about status is kept in files in the repository: agents editing one status file would conflict all day.
Why a blocker gets a pull request and not an issue
An agent that runs the build and sees what it stops on usually knows the fix a few minutes later. Writing an issue, claiming it and then opening a pull request that closes it is three steps where one does the job. And an issue of the form "the build stops at X" is a fact about one run on one machine: the build takes different start-up paths from run to run, so another collaborator may never see it.
What holds on every machine is the test: "the console does X for this call, and this test fails without the fix". The run is why you looked; the test is the proof.
So:
- You can fix it: open a draft pull request titled with the signature, before writing the fix. The draft is the claim.
- You cannot fix it (too large, out of session, needs a decision): file one handoff issue with what you saw, what you tried and what is unknown.
Signatures
A signature is the fixed string bx-cli report prints for something a run stopped on: unimplemented IXUser slot 3, fault in XCRDAPI.dll, exit status 5. Pull requests and handoff issues are titled with it ([Boot] unimplemented IXUser slot 3), so searching open pull requests for a signature tells you whether someone is already on it.
What an agent does when told "work"
AGENTS.md §0 has the binding version. In short, in strict order:
- Preflight.
bx-cli preflightmust pass. If it does not, stop. - Your own pull requests first. Requested changes, failing checks, conflicts, or a draft you have not finished.
- Then review. The oldest open, non-draft pull request from another person that has no current review. Merge it if it is approved, green and not your person's. Review comes before new work because unreviewed work is worth nothing to the next run.
- Then a handoff issue of the current stage that no pull request covers.
- Then run the build and fix the first thing it stops on that no open pull request covers.
- If the run stops on nothing, make the stage's ten-run gate check and post it on the ladder issue with
needs-human.
An agent stops and labels needs-human whenever it meets a decision that is not its to make: a decision gate, a licence or provenance question, a rule change, or two sources of truth that disagree.
Working one blocker
run → signature → draft pull request (the claim) → evidence → smallest fix + test → runs before and after → ready → someone else reviews and merges
- Claim with a draft pull request. Check open pull requests for the signature. If nobody has it, branch from
origin/main, push, and open a draft titled[<Stage>] <signature>. A draft with no push for 3 days may be taken over. - Is it already someone's? Before investigating any problem the game shows (the picked blocker or one met along the way), search open and merged pull requests and open issues for its log event, stub symbol, error code and the files a fix would touch. If an open pull request covers it, check that branch out, run with it and work there. If a merged one does, sync and run again. On 2026-11-30 a session fixed physical-page DirectStorage requests in parallel with an open pull request for the same problem (#707), and found the overlap only afterwards.
- Evidence before code. Find what the build asked for and what it got: the run report, then the diagnostics (thread sampler, fault context, call trace). Check the contract against the GDK where the GDK covers it. Do not guess a fix.
- Smallest fix. Only what removes this blocker. A new cross-DLL export still goes through an
[ABI]pull request first. - A test for the contract. It fails without the fix and passes twice in a row in the same bottle.
- Proof. Runs before and after on your machine, every run reported. Say which start-up path your runs took: another machine may take a different one.
- Mark it ready with the five-part description. Then stop: the next "work" starts from the top of the list.
If the blocker turns out to be more than you can finish, close the draft and file a handoff issue.
Pull-request description
Five parts and nothing else:
- Blocker:
Closes #<issue>and one sentence on what the build did. - Contract: what the console does, and which source says so (ranks below).
- Fix: what changed.
- Test: the conformance test, and that it fails without the fix.
- Proof: before and after over ten runs (for example "status-5 exits: 4/10 → 0/10"), with the machine and the
maincommit.
Review
The reviewing agent checks out the branch, runs the Section 8 commands and the new test, confirms the test fails without the fix, and reads the proof. It does not repeat the ten runs unless the proof looks wrong.
Deep review — re-deriving the contract from its source, by an agent working for a different person than the author — is required only for:
- a change under
abi/; - a new or changed translator instruction class;
- a contract from source rank 4 or 5;
- anything touching the sandbox, security or licensing.
Merging. The author's agent never merges its own person's pull request. Any other collaborator's agent merges once the pull request is approved and green. A pull request that is green and unreviewed after one working day gets the label needs-human.
Stacks. A pull request is based on main. One level of stacking is allowed when a fix truly needs an unmerged one; deeper stacks are not.
Run protocol
A run counts only if it is made this way. The launcher does it; agents do not hand-roll it.
Until the launcher does, the offline-run procedure and the diagnostic switches are in Target-Build Bring-Up: Development Cycle and Review. Where that document and this one differ on roles, the order of work or review, this one replaces it once accepted.
- Build: current
main, ormainplus exactly the one branch under test. - Sandbox: the offline runner, which refuses to start unless a probe confirms outbound network is blocked.
- Bottle: one per agent session, created by the launcher and named for the session. Never a shared one.
- One game at a time per machine. The launcher takes a machine-wide lock; a second run waits.
- Disk: at least 10 GB free, checked before the run; the session's scratch bottle and build directory are removed afterwards.
- Count and length: ten runs, each as long as the stage needs (five minutes for Boot).
- Machine: the report states chip and memory. Gates are judged on 16 GB machines.
The run report is generated, not written. Per run:
- outcome: frames presented, clean timeout, early exit with its status, or hang;
- the start-up path taken;
- every unimplemented call reached, counted;
- every fault inside a BetterXen module;
- pipelines drawn with: translated, passed through, skipped;
- on a stall: every thread's stack.
It ends with a ten-run summary and a list of signatures, the strings pull requests and handoff issues are titled with.
What exists today (#664): bx-cli report <log.jsonl>... produces the per-run report and the summary with signatures from run logs, and bx-cli run records how each run ended. Not yet in the launcher: the offline runner, per-session bottles, the machine-wide lock, thread stacks on a stall, and stall detection itself (frames are logged at powers of two, so a log cannot yet tell a stall from slow presentation).
Sources of truth
When a fix needs to know what the console does, use the strongest source available and name its rank in the pull request.
| Rank | Source | Notes |
|---|---|---|
| 1 | Authorized GDK documentation and headers | Derived facts may be committed. The files never are. |
| 2 | Our own compiler output for our own source | Built with the console compiler from the GDK. |
| 3 | Run-time observation of the target build | What it calls, with what, and what it does with the answer. |
| 4 | Call-site analysis of the target build (a disassembler such as Ghidra) | When observation cannot explain a wait or a branch. Local only. |
| 5 | The authorized upstream emulator's source | A hint about what the build needs, not a reference for correctness. Confirm with ranks 1–4 or with runs. |
Collaborators may install the GDK and a disassembler for this. AGENTS.md §6 is unchanged: nothing from the build enters git, issues or pull requests — no bytes, file names, hashes, addresses or decompiled code.
Evidence and references
- Private evidence store. Run logs, dumps, disassembly and captures go in a folder outside the repository on the collaborator's machine. Issues and pull requests carry counts, sizes, call shapes and the contract learned.
- Reference images (needed from the Picture stage on): a collaborator's own capture from a real console running the same content, or published footage. They live in the private store; a pull request says "matches reference screen 3".
Finding blockers once the game runs
From the Menus stage on, the build no longer stops by itself at the next missing piece: someone has to take it somewhere. Agents are poor players, so the method does not depend on an agent holding a controller. BetterXen owns both ends of the build's contact with the machine — input (GameInput) and graphics (d3d12_xs) — and records and replays both.
1. People play; the launcher records. A play session with recording on saves the input stream with timestamps and the save files it started from. A hotkey marks a moment ("texture wrong here", "audio cut out"). A crash or hang needs no mark: the run report has it.
2. Agents replay routes. A route is a starting save plus a short recorded input stream (about two minutes: load, walk somewhere, enter a vehicle). An agent replays it through the input shim and compares the run with the last good one. Replays drift, because the build is not deterministic, so routes stay short and start from a save. Each route is a regression test, run ten times like any gate.
3. Frame capture and offline replay. The graphics layer records every call the build makes for one frame, with the data it referenced. The frame is then redrawn without the build running, in seconds and identically every time. An agent fixing a picture bug replays that frame after each change instead of booting and travelling to the spot again.
How a problem is recognised, from most to least reliable without a person:
| Signal | Catches | Needs a person |
|---|---|---|
| Crash, hang, early exit | Stability | No |
| Run-report counters: skipped draws, stubbed shader instructions, unimplemented calls, failed storage requests | Missing pieces, even when the picture looks plausible | No |
| Frame compared with the last good capture of the same route | Regressions | No |
| Frame compared with a console reference image | Wrong rendering | To supply the reference |
| An agent looking at a capture | Obvious breakage: black screen, missing geometry, garbage textures | No; subtle errors are missed |
| A person's mark during play | Feel, audio sync, input lag, anything that "looks off" | Yes |
Findings become pull requests (or handoff issues, when they cannot be fixed at once) with signatures of the same kind: route 7: crash at 1:40 (3/10), capture 12: 340 draws skipped, capture 12: differs from reference in the sky. The order of work does not change.
Whether the game is good to play is a question only people answer. Their time goes into playing and marking, never into reproducing or bisecting.
What people do
People are needed for exactly four things, each marked needs-human:
- confirming a stage change after a gate passes;
- deciding a decision gate (for example the graphics back end);
- licence, provenance and legal questions;
- changing these rules.
Everything else is the queue.
The first handoffs
When this method started, the first target-build runs had already found more than could be fixed at once. Those were filed as issues #664–#680. The ones that were only "a blocker with a fix on the way" close as their pull requests merge; the ones that remain open as handoffs are the larger pieces: the run tooling, the D3DMetal capability checks, the translator, the reference images and the record-and-replay tools.