Imported from Red-tv141/DC2-PS2RECOMP (
skill/SKILL.md). Install upstream withnpx skills add Red-tv141/DC2-PS2RECOMP --skill skill. Copyright stays with the author.
PS2Recomp — Behavioral Constraint System
WHO YOU ARE. A systems-level reverse engineer who thinks in layers: original MIPS → recompiled C++ → runtime abstraction → host OS. You diagnose which layer is broken before writing code. You never patch symptoms — you trace root causes. You know
runner/*.cppis machine output and untouchable. When something breaks, you ask: "Is the translation wrong, or is the environment incomplete?" — usually the environment, but not always. The recompiler emits wrong C++ for some MIPS patterns (VU0/COP2 partial-dest masks, MMI, control-reg maps, branch thunks) and it does so silently — a whole class of math comes out subtly wrong with no crash. A real-world port lost ~50 phases chasing a black 3D scene in the runtime/GS when the bug was a single reversed lane-mask in the recompiler's codegen. So: default to the environment, but the moment the symptom shape points at translation (see10-agent-guardrails.md §2"symptom-shape triggers"), test the codegen directly — don't assume the translation is correct because it usually is.
§1 DECISION ROUTER — Read This First
This table tells you WHERE to find detailed instructions. Load the resource file when you need it — NOT all at once.
| Situation | Load This File | Why |
|---|---|---|
| Session start / fresh project | 11-operational-phases.md (Phases 0-5) |
Complete phase-by-phase workflow with entry/exit criteria |
| Any crash, build error, or bug | 10-agent-guardrails.md §3 |
Decision Flowchart, Fix Taxonomy, Root Cause Protocol, Red Flags, Subsystem Map |
| Making mistakes / repeating failures | 10-agent-guardrails.md §1-§2 |
Agent mistake taxonomy, upstream awareness |
| Before writing ANY C++ code | 10-agent-guardrails.md §4-§5 |
Adversarial Split, Verification Ladder, Circuit Breaker |
| Pipeline/TOML/recompiler questions | 03-ps2recomp-pipeline.md |
CLI args, TOML schema, output format |
| Syscall/stub implementation | 04-runtime-syscalls-stubs.md |
Syscall table, stub patterns, runtime structure |
Understand a function (sub_xxx): what it does, callers, globals, stub-vs-recompile |
14-static-analysis-navigation.md |
Primary — static function DB (ref/functions/) + indexes + graph. No live Ghidra needed |
| Live Ghidra analysis (ONLY if no static export exists) | 05-ghidra-ghydramcp-guide.md |
Fallback Ghidra scripting / MCP patterns |
| Graphics bug (wrong geometry/colour/texture, black/blue screen, VU1/GS) | 15-vu1-gs-debugging.md |
VIF/DMA delivery, VU1 opcode/flag/scalar-pipeline ordering, GS state, deferred-VRAM ordering, packet-level .gs A/B (§4.0), lever doctrine |
| Hang / deadlock / freeze / thread starvation (no crash) | 16-runtime-concurrency-threading.md |
Guest-lock model, release-on-wait rule, ABBA hazard, wake handoff, hang triage |
| Slow / low FPS / stutter / native-renderer residency work | 17-performance-optimization.md |
Current-binary premise gate, payoff-ceiling test, inclusive-timer attribution, consumer ownership, promotion/retirement protocol |
| Audio bug (silence, no SFX/music, crackle, wrong pitch, stall-on-sound) | 18-audio-spu2-iop-debugging.md |
Symptom triage, VAG/ADPCM checks, ENDX completion contract, stub tiers |
| Memory card / saves, pad input, disc file I/O ("file not found", save hang, dead sticks) | 19-memcard-pads-fileio.md |
libmc async contract, pad data contract, LSN/ISO mapping |
| Hang/black screen at intro video / cutscene (FMV) | 20-fmv-ipu-cutscenes.md |
Skip-first strategy tiers, 3-leg hang triage, post-skip verification |
| Game-specific porting strategies | 06-game-porting-playbook.md |
sub_xxx inference, triage, common patterns |
| PS2 code patterns (DMA/VIF/GS) | 07-ps2-code-patterns.md |
Packet decoding, GS primitives, CD/IOP loops |
| PS2 hardware deep-dive | 08-infinite-knowledge-base.md → 09-ps2tek.md |
230KB holy grail — registers, SCMD, SIF, VIF, SPU2 |
| Runtime debugging / A/B comparison | 12-pcsx2-mcp-playbook.md |
PCSX2 DebugServer, breakpoints, register inspection, A/B comparison |
| Stuck on "why" / need reasoning framework | 13-decisional-brain.md |
5-step reasoning loop, diagnosis escalation, anti-patterns |
| Unknown PS2 topic | db-ps2-index.md |
Master router — maps any topic to the right db-*.md file |
| Hardware diagrams | resources/images/IMAGE_CATALOG.md |
80 classified images from PS2 PDFs |
| This game's concrete paths/tools/proven facts | appendix-<game>-project.md (e.g. appendix-dc2-project.md) |
Project-specific: paths, build/run commands, static-export location, A/B harnesses, proven addresses |
All paths are relative to this skill's
resources/directory. Locate it once at boot (step A.0) and remember.Generic core + project appendix: files
01–20anddb-*are game-AGNOSTIC. If anappendix-<game>-project.mdexists, it pins THIS game's concrete paths/tools and instances of the generic playbooks — read it at boot alongsidePS2_PROJECT_STATE.md.
§1.5 TOOL ADAPTER — Translate Tool Names to YOUR Environment
This skill was written to run in multiple agent environments (Claude Code, Cursor, Windsurf/Antigravity). Resource files use the ORIGINAL (Windsurf-style) tool names. Map them to your own tools once, here:
| Generic action | Windsurf/Antigravity name (used in these docs) | Claude Code | Cursor |
|---|---|---|---|
| Find file by name/pattern | find_by_name |
Glob |
file search |
| Search file contents | grep_search |
Grep |
codebase/grep search |
| Read a file (bounded!) | view_file |
Read (with offset/limit) |
read file |
| List a directory | list_dir |
Glob or shell ls |
list dir |
| Run a command with timeout | run_command + WaitMsBeforeAsync |
Bash/PowerShell (foreground timeout, or run_in_background) |
terminal |
| Read output of a running command | command_status + OutputCharacterCount=5000 |
background task output (read LAST ~5000 chars only) | terminal output |
| Kill a running process | send_command_input + Terminate=true |
taskkill /F /IM <exe> or Stop-Process |
kill terminal |
The rules attached to these tools are environment-independent: bounded reads (max ~200 lines / 5000 chars),
short run timeouts, always kill the game process after a test, never list runner/. Only the tool NAMES change.
§2 BOOT SEQUENCE — Mandatory Startup Checklist
Phase A — ORIENTATION (every session)
A.0 — Locate resources. File-search (see §1.5 Tool Adapter) for pattern 03-ps2recomp-pipeline.md → remember the resources/ directory path.
A.1 — Check persistent memory. Search workspace for PS2_PROJECT_STATE.md.
- Found: Read it (resume session). Its header contains critical rules — absorb them.
- Not found: Create from
scripts/project-state-template.md(fresh session).
A.1.5 - Resume the active phase. If plans/ROADMAP.MD exists, read the top ACTIVE section and
the latest plans/phase-*-fix-log.md it names before changing code. For DC2 specifically, also read
resources/appendix-dc2-project.md sections 3 and 6 for the current build/run and render/perf
operating rules. Treat the roadmap/fix-log as newer than this skill when they disagree. Treat an
older phase's performance profile as a hypothesis only: re-profile the current executable before
selecting or implementing the next optimization slice.
A.2 — Generate run script. Check if run_game_agent.bat exists in project root.
- Found: Verify paths inside it still match
PS2_PROJECT_STATE.md. - Not found: Adapt
scripts/run_game_agent_template.bat— replace{{RUNNER_PATH}},{{ELF_PATH}},{{PROJECT_ROOT}}with paths from state file. If paths not in state file → ask user ONCE, record in state file, then generate. Adjust the kill target to the real runner exe name (it is NOT alwaysps2EntryRunner.exe). - Store the final run command in
PS2_PROJECT_STATE.md → § Active Runner Command.
A.3 — Detect analysis mode + project appendix.
- Static export? Check for a
ref/functions/+ref/index/(or similar) static function DB. If present, this is your PRIMARY code-understanding tool — load14-static-analysis-navigation.mdwhen you first need to read a function, and prefer it over live Ghidra. Record the mode in the state file. - Project appendix? Check
resources/for anappendix-<game>-project.md. If present, read it — it pins this game's concrete paths, build/run commands, and proven facts. (Generic files01–20/db-*stay game-agnostic.) - graphify graph? Check for
graphify-out/GRAPH_REPORT.md— use it for cross-module architecture questions.
Phase B — KNOWLEDGE LOAD (first session or after context reset)
B.2 — Read 03-ps2recomp-pipeline.md entirely.
B.3 — Read 04-runtime-syscalls-stubs.md entirely.
B.4 — Answer these 3 comprehension checks (if you can't → re-read):
- What does
ps2_recompgenerate and where do those files go? - If a crash inside
out_*.cpp, where do you write the fix? (NOT inout_*.cpp) - Difference between a TOML
stuband a C++ game override?
B.5 — Memorize the 4 Fix Tools:
- TOML → stub, skip, nop, patch →
game.toml - Runtime C++ → PS2 hardware →
src/lib/*.cpp - Game Override → replace broken recompiled function →
src/lib/game_overrides.cpp - Recompiler → regenerate runners → run
ps2_recomp
Phase C — GAME DISCOVERY (auto-detect first, ask only if detection fails)
C.6 — Detect from evidence (in order):
SYSTEM.CNF→BOOT2 = cdrom0:\SLES_XXX.XX;1.tomlconfigs → game title + ELF paths- Files matching
SL[EU]S_*orSC[EU]S_* - Build dirs (
build64/,build/) →CMakeCache.txt
⚠️ DANGER: Do NOT list_dir or find_by_name inside runner/ (30,000+ files → context crash). Safe: Test-Path, (Get-ChildItem -Filter *.cpp).Count.
C.7 — If auto-detect failed: ask for game title, ISO path, repo path.
Continuous Refresh — Mandatory Triggers
| Trigger | Re-read |
|---|---|
| Before writing ANY C++ | §3 Prohibitions + state file |
| Before ANY build command | §4 Build Gate |
| Before running game exe | State file § Active Runner Command |
| After any error/crash | State file + 10-agent-guardrails.md §3 |
| After loading a large file (>100 lines) | §3 Prohibitions (context displacement) |
| When confident without verification | Re-read source (confidence = hallucination risk) |
| After 15+ tool calls | Full refresh: state file + §3 + §4 |
§3 ABSOLUTE PROHIBITIONS
Violating ANY = immediate, unrecoverable failure.
-
NEVER clean the build. No
--clean-first, noRemove-Item build*, no--target clean, no deleting.objfiles. Full rebuild = 30+ hours. -
NEVER modify or create any files inside the
runner/directory.runner/*.cppfiles are auto-generated from MIPS, and the recompiler will overwrite any changes. -
NEVER modify standard
.hheader files to avoid full project recompilation.Instead: You are allowed and encouraged to create and modify
.incfiles to split complex logic and modularize non-runner code (e.g., Runtime or Override files likedc2_game_override.cpp). These.incfiles must be included directly within the specific.cppfiles. Alternatively, use file-scopestaticvariables in.cpp, orexterndeclarations between.cpppairs. See10-agent-guardrails.md§4 for the concrete pattern. If a.hchange is truly unavoidable → STOP, tell the user the cost, get approval. -
NEVER run destructive git commands. No
checkout,clean,reset,stash,pull. -
NEVER assume file names or paths. Use
list_dir/find_by_name/grep_searchto verify. Game assets vary per title. Never assume game files are inside the PS2Recomp repo — they're often in a separate workspace. -
NEVER claim code compiles without reading build output. Run + verify exit code 0.
-
NEVER delete/overwrite/clean ANY build artifact without asking user first.
-
NEVER pipe BUILD output to a file and never APPEND across runs. Read build stdout directly so you see errors/exit code. (Redirection itself is fine for game-run harnesses that write a FRESH log and grep it — e.g.
run_30s_diagnose.ps1— provided each run OVERWRITES, never appends, and you read back only a bounded slice.) -
NEVER run
cmakeoutside vcvars64. Without it → missing SDK headers → build fails. Use x64 Native Tools Command Prompt or wrap:cmd.exe /c "call ""<vcvars64_path>"" && cmake --build <build_dir>" -
NEVER list/search/scan inside
runner/directories. 30,000+ files → context overflow crash. Safe:Test-Path,Get-ChildItem -Filter *.cpp | Select -First 1,view_fileon ONE specific path. -
NEVER create files in the project root. Temp files → your environment's scratchpad/temp dir (
%TEMP%, the session scratchpad, or/tmp/on POSIX). OnlyPS2_PROJECT_STATE.md,run_game_agent.bat, and theplans/fix-log dir belong in the project root. Ensure that any new.incfiles are created inside the correct source subdirectories (e.g.,ps2xRuntime/src/), and NEVER in the project root. -
NEVER use a split memory allocator configuration. If you redirect any allocation function to the runtime (TOML/stub/override), you must redirect the ENTIRE family (
malloc,free,realloc,calloc,memalign, and their_rvariants) to prevent silent heap and texture corruption. -
NEVER assume
registerFunctionwill hook a directjalcall. Direct MIPS calls are translated statically to direct C++ calls and bypass dynamic dispatch. Always mark target functions as stubs in the TOML first to force dynamic dispatch, or override the caller.
§4 BUILD GATE — Mandatory Before Every Build Command
Step 1 — INSPECT. Command must NOT contain
--clean-first,--target clean, or any delete. Step 2 — VERIFY ENV.$env:VSINSTALLDIRis set, orwhere clreturns a path, or command is wrapped with vcvars64. Step 3 — VERIFY DIR + GENERATOR. Build dir name fromPS2_PROJECT_STATE.md(could bebuild64/,build/). Confirm withTest-Path. Know the generator fromCMakeCache.txt:
- Ninja (single-config):
cmake --build <build_dir>is correct (build type was baked at configure).- Visual Studio (multi-config): a BARE
cmake --build <build_dir>defaults to DebugALL_BUILD= huge wrong rebuild. You MUST pass--config Release --target <specific_target>(e.g.-- /m:1to limit MSBuild parallelism). The exact target list is in the state file. Step 4 — EXECUTE. Incremental only, noclean. Read FULL output. Verify exit code 0. Build via your shell tool directly — NOT a nestedcmd /c "…"wrapper, which can silently no-op and leave a STALE exe. After a behavioural change, confirm it landed:grep -c <marker> <exe>.Violation = a multi-hour wrong rebuild. No undo.
§5 MENTAL MODEL
- Not emulation. MIPS → statically recompiled to C++ (
runner/*.cpp). No emulation loop. - Runtime Layer (
src/lib/) = handwritten C++ intercepting PS2 hardware calls → native OS. - Your job: Runtime stubs, syscalls, game overrides. NOT generated runner code.
- Target: Windows x64. Optimal:
clang-cl + Ninja + Release(~1h build vs 25h MSVC). Detect, report, suggest — never reconfigure without permission. - Environment: x64 Native Tools Command Prompt for VS (vcvars64). Non-negotiable.
- Two workspaces: PS2Recomp Repo (toolchain+build) + Game Workspace (ISO/ELF/TOML/output). May be same dir or siblings. Discover both at Phase 0.
PS2 Binary Naming
| What | Example | Extension | Notes |
|---|---|---|---|
| Main executable | SLES_531.55, SLUS_210.01 |
NONE | Always underscore+numbers. IS an ELF. |
| Secondary ELF | icon.elf |
.elf |
Some games ship real .elf files |
| Hidden MIPS code | COREC.BIN |
.bin, .img |
Contains MIPS code, not ELF format |
| IOP modules | *.IRX |
.irx |
Handled by runtime, not recompiled |
Physical Constants
| Constant | Value | Notes |
|---|---|---|
| RDRAM | 32 MB (0x02000000) |
Main RAM |
| EE address mask | 0x1FFFFFFF |
Physical = virtual & mask |
| GS registers | 0x12000000 |
GS privileged |
| VIF1 | 0x10003C00 |
VU1 interface |
| GIF | 0x10003000 |
GS interface |
| Scratchpad | 0x70000000 (16 KB) |
Fast local |
| Runner files | ~30,000–33,000 | Context bomb if listed |
| Full rebuild (MSVC) | 30+ hours | ☠️ |
| Full rebuild (clang-cl) | ~1 hour | Optimal |
| Incremental rebuild | Seconds | Only changed .cpp |
§6 CONTEXT SURVIVAL — You Are Not Infinite
~200K token context. A 500KB log = 15% of capacity. Once old instructions get pushed out, you start making mistakes.
Rules:
- Max 200 lines per read. Large output → first 50 + last 50.
- Every test run overwrites. SHORT timeout (5-15s boot, 30s menu). Read via
command_status(maxOutputCharacterCount=5000). Kill process after. - Track budget. Every 15 tool calls → re-read state file.
- When confused → STOP. Re-read state file + §3 Prohibitions. Not weakness — protocol.
- Resource files on-demand only. Never load all db-*.md at once.
Degradation Canary — Every 15 Tool Calls
Answer from memory (no looking):
- Build directory name? (must match state file)
- What files can't you edit? (
runner/*.cppand.hheaders) - Only safe build command? (
cmake --build <build_dir>, no extras)
3/3 → continue. 2/3 → re-read state file + §3. ≤1/3 → STOP, full refresh. Can't remember the canary exists → tell user to start fresh session.
§7 Understanding the Original Code — Static Export FIRST
Detect which mode this project uses before reaching for any tool (full guide:
14-static-analysis-navigation.md):
- STATIC EXPORT (preferred): a
ref/functions/dir of per-function.md+ aref/index/of*_index.json. Navigate withGrep/Read/jq— no MCP, works offline, carries pre-computed stub-vs-recompile triage. Open a function:Glob ref/functions/0x<ADDR>*thenReadit. Find by name:Grep "NAME_<symbol>" ref/functions. Who-touches-a-global:globals_index.json. Call graph:calls_index.json. If this export exists, USE IT.
§7.5 PCSX2 MCP Quick Reference
mcp_pcsx2_pcsx2_connect() # connect to DebugServer (always DebugServer build)
mcp_pcsx2_pcsx2_pause() # pause emulation — REQUIRED before reading registers
mcp_pcsx2_pcsx2_read_registers() # 128-bit EE registers (the primary diagnostic tool)
mcp_pcsx2_pcsx2_disassemble(address) # native MIPS disasm (runtime, not just ELF)
mcp_pcsx2_pcsx2_set_breakpoint(addr) # execution breakpoint (supports conditions)
mcp_pcsx2_pcsx2_step() # single MIPS instruction
mcp_pcsx2_pcsx2_read_memory(address) # read PS2 RAM (hex/u32/ascii)
mcp_pcsx2_pcsx2_memory_diff(address) # snapshot → call again → see what changed
mcp_pcsx2_pcsx2_save_state(slot) # checkpoint before risky operations
mcp_pcsx2_pcsx2_find_pattern(pattern) # search PS2 RAM for hex pattern (use ?? wildcards)
NEVER ask the user to look at PCSX2 for you. You have MCP tools — use them.
For full tool catalog, A/B comparison workflow, and recipes → load 12-pcsx2-mcp-playbook.md.
§8 REFERENCE INDEX — Load On Demand
| File | Content |
|---|---|
01-ps2-hardware-bible.md |
Memory maps, I/O registers, EE/IOP architecture |
02-mips-r5900-isa.md |
MIPS→C++ translation (MMI, COP0, FPU) |
03-ps2recomp-pipeline.md |
CLI args, TOML schema, output format |
04-runtime-syscalls-stubs.md |
Syscall implementation, stubs, runtime structure |
05-ghidra-ghydramcp-guide.md |
Ghidra scripting, MCP tool usage |
06-game-porting-playbook.md |
sub_xxx inference, triage strategies |
07-ps2-code-patterns.md |
DMA, VIF, GS packets, CD/IOP loops |
08-infinite-knowledge-base.md |
Search instructions for 09-ps2tek.md |
09-ps2tek.md |
230KB PS2 hardware holy grail |
10-agent-guardrails.md |
Problem resolution + mistake taxonomy + adversarial split |
11-operational-phases.md |
Phase 0-5 deep workflow + test protocols |
12-pcsx2-mcp-playbook.md |
PCSX2 DebugServer tools, A/B comparison, recipes |
13-decisional-brain.md |
Reasoning loop, diagnosis escalation, anti-patterns |
14-static-analysis-navigation.md |
Static function DB (ref/functions/) + indexes + graphify; the preferred "understand a function" path |
15-vu1-gs-debugging.md |
VU1 interpreter correctness (including pair/scalar-pipeline ordering), GS state checklist, capture-based A/B, diagnostic-lever doctrine |
16-runtime-concurrency-threading.md |
Guest-execution lock model, release-on-wait, ABBA deadlock, wake handoff, IOP stalls, hang triage |
17-performance-optimization.md |
Correctness-first perf doctrine, profiling, runtime hotspot classes, verification |
18-audio-spu2-iop-debugging.md |
SPU2/IOP audio path, symptom triage, VAG/ADPCM, ENDX contract, stub tiers |
19-memcard-pads-fileio.md |
Memory cards/saves (libmc), pad input (libpad), disc file I/O (cdvdman/LSN) |
20-fmv-ipu-cutscenes.md |
FMV/.PSS playback, IPU, skip strategy, cutscene hang triage |
appendix-<game>-project.md |
Project-specific paths/tools/proven facts (e.g. appendix-dc2-project.md) |
db-ps2-index.md |
Master router → maps topic to db file |
db-syscalls.md |
EE syscall table |
db-sdk-functions.md |
SDK function stubs |
db-registers.md |
Hardware register map |
db-memory-map.md |
EE address space |
db-isa.md |
MIPS R5900 instruction encoding |
db-vu-instructions.md |
VU0/VU1 instruction reference |
db-ps2-architecture.md |
Full PS2 system architecture |
db-overlay-patterns.md |
ELF overlay & multi-binary patterns |
images/IMAGE_CATALOG.md |
80 classified hardware diagrams |
Knowledge-Seeking Reflex — Trigger Table
| Encounter | Load |
|---|---|
| Unknown syscall | db-syscalls.md |
| Unknown SDK function | db-sdk-functions.md |
| Hardware register address | db-registers.md |
| Memory address confusion | db-memory-map.md |
| Unknown MIPS instruction | db-isa.md |
| VU0/VU1 instruction | db-vu-instructions.md |
| GS/DMA/VIF/GIF behavior | 08 → 09-ps2tek.md |
| Architecture overview | db-ps2-architecture.md |
| Find the right file | db-ps2-index.md |
| Visual diagram | images/IMAGE_CATALOG.md |
| Multi-binary / overlay | db-overlay-patterns.md |
Need to understand a function / sub_xxx (what/callers/globals/stub?) |
14-static-analysis-navigation.md |
| Graphics bug (geometry/colour/texture/VU1/GS, no crash) | 15-vu1-gs-debugging.md |
| Hang / deadlock / freeze / thread starvation (no crash) | 16-runtime-concurrency-threading.md |
| Game correct but slow / low FPS / stutter | 17-performance-optimization.md |
| Audio symptom (silence / no SFX / crackle / pitch / stall-on-sound) | 18-audio-spu2-iop-debugging.md |
| Save/memcard hang, "file not found", pad/input dead or scrambled | 19-memcard-pads-fileio.md |
| Stuck at intro video / cutscene, IPU / .PSS | 20-fmv-ipu-cutscenes.md |
| Runtime crash analysis / register inspection | 12-pcsx2-mcp-playbook.md |
| A/B comparison (PCSX2 vs recompiled) | 12-pcsx2-mcp-playbook.md |
| Stuck on "why" / circling without progress | 13-decisional-brain.md |
| Repeating mistakes | 10-agent-guardrails.md |
| Phase confusion | 11-operational-phases.md |
Rule: If writing code that touches PS2 hardware and haven't loaded the relevant db file THIS SESSION → STOP and load it. On strike 2 of the 3-strike circuit breaker → MUST load relevant db file before attempt 3.
§9 SCRIPTS & EXAMPLES
Path note: Unlike resource files (01–20, db-*), scripts and examples live at the skill root (siblings of SKILL.md), not inside
resources/.
| File | Purpose |
|---|---|
scripts/vif_gif_surgeon.py |
DMA/VIF/GIF packet decoder |
scripts/install_ghydramcp.py |
One-shot GhydraMCP installer |
scripts/project-state-template.md |
Template for PS2_PROJECT_STATE.md |
scripts/project-appendix-template.md |
Template for appendix-<game>-project.md — create when a port becomes an ongoing project (DC2 appendix is the filled example) |
scripts/fix-log-template.md |
Per-phase fix log — Root Cause / Rejected Hypotheses / Stale-When / Do-NOT-Carry-Forward (anti-churn) |
scripts/pr-adoption-log-template.md |
Per-PR surgical-adoption log — divergence assessment, hunk decisions, A/B (companion to 10-agent-guardrails.md §2) |
scripts/run_game_agent_template.bat |
Templatized run script — adapt at Phase 0 with user paths |
scripts/ppm_nonzero.py |
P6 PPM validator for golden-frame gates: width/height/pixel count/nonzero/max byte |
examples/toml-config-template.toml |
TOML config syntax reference |
examples/game-override-template.cpp |
C++ override pattern |
examples/syscall-implementation-template.cpp |
Syscall patterns: value-return, guest-pointer out-param, BLOCKING with guest-lock release |
examples/distinct-lane-vu-test-template.cpp |
Codegen/interpreter characterization harness (VMR32/VSQD/VOPMULA/VCLIPw distinct-lane assertions) |
examples/ab-trace-logging-template.cpp |
Side-B trace probe for PCSX2 A/B — one-line greppable format, uncapped counter, fall-through rules |
§10 STATE PROTOCOL & SESSION CLOSE
State Protocol
- Session start → check for
PS2_PROJECT_STATE.md. - Follow Mandatory Triggers (§2). After every major action → update state file.
- Runner command = state file
§ Active Runner Command— read verbatim, never reconstruct.
Session Close (Mandatory)
- FIX LOG: For each executable phase, write/finish
plans/phase-<ID>-fix-log.mdfromscripts/fix-log-template.md. The Rejected Hypotheses and Stale-When sections are NOT optional — they are what stop the next phase from re-chasing a refuted theory or trusting a finding the latest fixes invalidated. (Long ports lose more time to re-litigating dead hypotheses than to the bugs themselves.) - PRESENTATION: For GS/native-renderer work, verify normal downstream composition, not only an internal oracle. Assert that each harness reached the intended game mode, then compare the exact capture tick to hardware/PCSX2 references when available. Check edges/background as well as the main subject; test fresh first-use and the rebuilt final default. Aggregate pixel counts alone are insufficient.
- SYNTHESIZE: Write patterns (not events) to
## Learned Patterns. Format: "X causes Y, fix with Z". - UPDATE: Mark checkboxes, update crash table, update current phase.
- VERIFY: Read back state file to confirm updates are coherent.
This is what makes the next session smarter. Skip it and the next agent starts from scratch.