# Proposal: the method for the late eras (N64, PlayStation, Saturn and after) Status: **draft** 2026-11-26, Aubrey's to accept, change or refuse. Nothing here edits the charter or the methodology; suggested texts are at the end. Written with the N64 and PlayStation execution-architecture documents (n64-python and psx-python `docs/execution-architecture.md`), which hold the numbers this rests on. ## The question Aubrey, 2026-11-26: the family should "construct a comprehensible, testable model of the machine, and then find the fastest way to execute that model". The N64 is where the method as written meets a wall. The gate chain is: Python is the authority, and Rust is held to it per bus cycle over whole cases, usually boots or game runs with scripted input. That works while Python runs the cases in minutes. | Board | Python speed (basis) | Real-time need | Python per emulated second | | --- | --- | --- | --- | | sega32x-python | about 2.4 frames/s on PyPy (sega32x-rust README; MEASURED) | 60 frames/s | about 25 s | | psx-python (estimate) | 0.1-0.2 M R3000A instructions/s (psx-python domains.md; HYPOTHESIS) | 17-34 M/s | 85-340 s | | saturn-python (estimate) | sh2-python 1.33-2.38 M/s on its minimal harness, far less on a board (saturn-python domains-and-speed.md) | 57 M/s for the pair | minutes | | n64-python (estimate) | VR4300 0.02-0.2 M/s, before the RSP and RDP (n64-python domains-and-speed.md; HYPOTHESIS) | 50-94 M/s, plus the RSP's 20-45 M and the RDP's 3-14 M pixels | 250-4,700 s for the CPU alone: an hour-scale boot, minutes per frame | The 32X still fits the method (sega32x-rust's rung 3 holds 16,360 frames in lockstep). The PlayStation fits it for test EXEs and short windows. The N64 does not fit it for games at all. The problem is not the specification: a readable specification is still the right authority. The problem is that **"the specification runs the gate case from power-on" stops being possible**, so the gate has to start somewhere else. ## 1. The Python specification validates on test ROMs and short slices The specification's own proof (axis A) is unchanged: test ROMs with hardware-captured verdicts, documents, die where it exists. What changes is what a **gate case** for the tier chain is. **A gate case becomes one of two kinds:** - **Test-ROM case** (as now): a program from power-on or a side-loaded entry, run for its stated length. Most N64 and PlayStation test ROMs finish in a few frames. - **Slice case** (new): a **start state** (by SHA-256), an input script, a length in the board's time base, and a trace period. The start state is produced by a faster tier running the game (section 3), and the case records which tier and commit produced it. Python loads the state and runs the slice. Each Rust tier runs the same slice from the same state. The trace lines must be identical, exactly as in today's lockstep. **How long a slice is.** The budget is a few minutes of one PyPy core per case, within the machine-sharing rules (HYPOTHESIS until measured): - A 10-minute N64 slice at 0.02-0.2 M VR4300 instructions/s covers 12-120 M instructions. At 60 M a second that is 0.2-2 emulated seconds of CPU. With the RSP and the RDP sharing the time, it is more like 2-30 frames. - A PlayStation slice of the same length is 0.5-7 emulated seconds. **The slice list is curated**, by the smoke rules the family already keeps. It holds problem moments and representative ones: a game's first 3D frame, an FMV start, a microcode switch, a save. A full sweep's failures become slices, never the reverse. There is no library sweep in Python, ever, for these boards. The sweep runs in Rust (section 2). **Coverage by sampling.** A Rust tier runs a game with scripted input and writes a state every K emulated seconds. Any of those states can become a slice. A nightly-style job (by need, not by schedule: CI minutes stay minimal) picks a few at random, and Python checks them. A whole game is then covered by many short witnesses rather than one long run. **Chained slices.** Where two slices are adjacent, Python's end state from the first must equal the Rust tier's state at the same moment. State equality is a stronger check than trace equality, and it catches state that a trace never shows. **Bisection.** When a slice diverges, the Rust tier writes denser states inside it, and the first divergent sub-slice is found in log time. It becomes the case for the upstream fix. ## 2. The Rust transcription is the first runnable tier - `x-rust` is where the board first **runs games**, by the same transcription rule as now (names, order, structure, comments). It is the first tier that boots a commercial game, takes a sweep, and is played by hand. - **Its gate** is test ROMs plus the slice list, both in per-bus-cycle lockstep against Python. That is the same proof obligation as today ("every bus cycle identical"), applied to cases Python can reach. - **The chain below it keeps whole runs.** - `x-rust` against `x-rust-fast`: per-cycle lockstep over whole games. Rust against Rust is cheap. - `x-rust-fast` against turbo: the observable contract over whole games. - So only the first link is sampled. Every later link is held over full runs. - **Fixes still start upstream.** A bug seen when playing in Rust is reproduced by saving a state just before it, transplanting that state into Python, and running the slice. The fix lands in Python first and travels down by merge. The transplant is what keeps "fixes start upstream" practical when Python cannot reach the moment by itself. - **What `x-rust` claims** is said plainly in its README: "identical to the specification on N slices and M test ROMs", never "identical to the specification" alone. ## 3. State transplant between tiers Today each tier serialises its own structures, and **states are not portable between tiers by design**. megadrive-python's save-states.md, "For the Rust tiers (provisional, 2026-11-23)", says so: "the Python walk is tied to Python's object graph", and the famicom line says the same. That was right while Python could reach every moment itself. For era-3 boards built from now on, this proposal makes **one state format shared by `x-python` and `x-rust`** (and readable by every tier) part of the specification. **What the format must hold:** - **Everything that changes as the machine runs, at one cut instant, and nothing derived.** - Every domain's own clock in the common time base. On the N64 that is the half-PClock; on the PlayStation, CPU cycles. - The event queue, every FIFO and every DMA in flight (start time, position, rate). - Pipeline state: the VR4300's interlock and scoreboard state, the RSP's latencies, the RDP's one-pixel lag registers that the hazards come from. - Caches and tags, the TLB and the micro-TLB, the write buffer. - All memories, with RDRAM's hidden plane (packed one bit per byte: 1 MiB for 8 MiB), TMEM, IMEM/DMEM and VRAM. - Every register, every pin level. - **The cut point is the order of record's step boundary**: between two instructions of the board's lead CPU (the VR4300 or the R3000A), with every other domain at the time the order of record leaves it there. The specification defines this, as megadrive-python's save-states.md does ("between two 68000 steps"). - A threaded or speculative Rust tier must **quiesce** to the canonical state before saving: conservative domains brought to their order-of-record times, speculative ones rolled back to them. - **Producers are drained**: the RDP and GPU back ends finished up to the front end's time, so memory holds what a reader at the cut would see. - **Not held:** decoded-instruction caches, compiled blocks, memoized timing, hazard maps, rollback logs, host settings. Each tier rebuilds these from the state. A state written by turbo must equal the one `x-rust-fast` writes at the same cut, and that is part of turbo's proof. **The shape, tier-neutral:** ``` MAGIC 8 bytes per board, e.g. b"N64STATE" LENGTH 4 bytes header length, big-endian HEADER JSON {"format", "schema": n, "machine", "rom_sha1", "wiring", "devices": {...}, "parts": {"vr4300": v, "rsp": v, "rdp": v, ...}, "cut": {"time": t, "unit": "half-pclock"}, "producer": {"tier": "n64-rust-fast", "commit": "..."}} CHUNKS repeated name (UTF-8, length-prefixed), version, length, zlib bytes ``` - **Each chunk's layout is declared in the specification**, in a schema file in the x-python repository, for example `state-schema.toml`: for every part, its fields in order, with type, width and unit. Large arrays are raw bytes in a stated byte order. The schema file is data, not generated code. - Python's encoder and Rust's are written by hand, each in its own tier's style. Each tier's tests **assert that its encoder's layout equals the schema file**, field by field. Python stays readable, and Rust stays a transcription. - The **header refuses before the body is read**, as megadrive-python's does: another format, schema, machine, cartridge, wiring, or a part or device version. **Versioning:** - `schema` rises whenever any field anywhere is added, removed, renamed or changes meaning. Each part carries its own version too, so a core's change names the part that moved. - A schema change in Python is a behaviour-neutral change for the gate. Python and x-rust must both pass the round-trip tests at the new version before any slice runs. - **Gate states are regenerated, never migrated.** They are cheap: the Rust tier replays its scripted run to the same moments. Old states are moved aside, as the reference caches are today. - **Player states** (a site's save slots) follow today's rule: refused at a new version, unless the site ships a migrator. That is the site's choice, recorded in its docs. **How it fits the existing rules:** - **The save-state rung** (`--save-at-half`; "save states in the gate") stays as it is, per tier: save, load into a fresh machine, continue identically. - **The transplant adds two rungs.** - *Cross-tier round trip:* a state written by Python loads into x-rust, is written again, and is byte-identical. The same holds in the other direction. - *Cross-tier continuation:* each slice case, run from the transplanted state. - **The device-state socket work** (megadrive-python branch `device-state`, socket 10, state version 3) already has the right shape for parts. A socket device answers `SavedDevice` (`state_version`, `save_state`, `load_state`), and the header's `devices` names each one with its version and refuses another before anything changes. This proposal generalises that from add-on devices to **every part**: each core and each board block is a saved part with a name and a version. The difference is the body. In the shared format each part's value is a schema-declared record, not a walk of Python's object graph. Existing boards (Mega Drive, Sega CD, 32X) keep their formats. Moving one would be its own decision. - **Seeded faults reach the transplant too:** a field dropped from one tier's encoder, two fields swapped, a part's version not raised, a producer not drained before saving, a speculative domain saved before its rollback. Each must be caught by the cross-tier rungs. **Trust, stated honestly.** A slice tests the specification's step function from a state that the specification did not reach by itself. That state can be one no real console reaches, if the Rust tier had a bug before the cut. A slice that passes says "Python and Rust agree from here", not "the game was right up to here". The two mitigations are chained slices and the sampled coverage above. The claim is written that way. ## 4. GPU backends are turbo, under the observable contract - A GPU-compute implementation of a rasteriser (the N64's RDP; perhaps the Saturn's VDP1) is a **turbo fast path**, the same shape as recompilation: the software rasteriser of `-fast` stays as the fallback, the host can turn the GPU off, and "prune what does not pay" holds. - **Its proof is the observable contract, per pixel.** That means every memory byte (and hidden bit) the rasteriser writes, as seen at every join (a CPU or DMA read, a scan-out line), compared against the software rasteriser over the same command lists. Timing observables (busy bits, interrupts, counters) come from the CPU-side front end, never from the GPU. - **It is proven per device**, because drivers differ (parallel-rdp's README records AMD drivers failing its conformance tests without a workaround). The host runs a short conformance set on start-up and uses the GPU path only on a pass. The capability record gains `gpu_backend: verified | failed | absent`, beside `recompile`. - **Upscaling, texture replacement and other enhancements are concessions**: named, off by default, with their costs recorded, because they change the video output. - **A GPU backend written by someone else** (parallel-rdp, MIT) is judged like our own: it passes the per-pixel gate or its differences become named concessions. Its lineage is recorded (n64-python execution-architecture.md: validated against angrylion, not hardware). - **Recorded as a capability** (charter, 2026-11-27): `render: software | gpu`, beside `recompile: native | wasm | none`. ### Reading guide: which tier carries which era (added 2026-11-27) A summary, not a rule: tiers are marked by their promise (`-rust` every bus cycle identical, `-fast` every cycle, `-turbo` every observable), never by technique, so recompilation and GPU rendering are switchable fast paths inside `-turbo`, not tiers of their own. Which tier a machine needs to reach its target: | Tier | What it adds | Where it is enough | | --- | --- | --- | | `-python` | the executable specification | every era, as the authority (CPU and bus logic in the late eras, with slices) | | `-rust` | the line-by-line transcription | the verification baseline everywhere | | `-rust-fast` | the same cycles, faster | desktop and browser 8- and 16-bit boards | | `-rust-turbo` | catch-up scheduling, whole-line (span) paths | handheld and ARM 8- and 16-bit, the 32X, Saturn, PlayStation | | `-rust-turbo` + `recompile` | block caching, then a code generator | N64, Dreamcast, PSP, PS2, GameCube, where the target allows it | | `-rust-turbo` + `render: gpu` | command-list rendering on the host GPU, the software renderer as fallback and judge | Dreamcast, PSP, PS2, GameCube/Wii and later | Other projects (Dolphin, PPSSPP and the like) put these backends in one codebase with switches. That matches "fast paths inside one tier"; what the family adds is the ladder of proven promises above it. ## 5. What stays the same - **x-python is the authority.** Hardware behaviour is defined and fixed there first, and carried down by merges. The transplant exists to keep this true. - **Evidence tags** on every behaviour. "Matches the Python on N slices" is not "matches the hardware". - **Every gate proves it can fail** (seeded faults), including the new rungs and every backend's shortcuts. - **Prune what does not pay.** A cached interpreter, a GPU backend or a thread split is kept only when it wins on every layout and on the real target. The SH-2 pilot's cached interpreter is the precedent: exact, about 10 % slower, recorded in not-kept.md. - **Determinism** at any thread count; licences and author respect; romsets by environment variable. ## 6. What the pilot taught, as a rule of method The SH-2 pilot measured where an exact interpreter's time goes. In sh2-rust-fast's profile, decode is 3.6 %, the stage scheduler 37 %, per-step checks 25 % and the fetch path 13 % (sh2-rust-fast docs/status.md and docs/cached-interpreter.md). Proposed as a standing practice for era-3 cores: **profile the time-keeping before building a block cache or a compiler.** A specification that states timing as data (the JIT proposal's "timing as data", already accepted) lets `-fast` charge time from tables and memoized blocks instead of simulating it. That is where these boards' speed will mostly come from. ## 7. Earlier boards that would benefit - **Saturn** (saturn-python, Phase 0). Two SH-2s at 28.6 MHz, an SH-1 if the CD block is low-level, and CD games that spend minutes in the BIOS and loading. Python will not reach a game's moments in minutes. Slice cases from transplanted states are the gate it needs. VDP1 is a command-list rasteriser with CPU-visible frame buffers, so the same front/back split and join rules apply, and a GPU backend would be turbo under the same contract. - **32X** (sega32x-python, -rust, -rust-fast). It fits today: Python at about 2.4 frames a second, 16,360 frames in lockstep. The transplant would let bugs found deep in a game (Doom's later levels, Virtua Racing's tracks) be reproduced in Python without replaying minutes of play. The SH-2 pair's speed work is where the time-keeping rule was learned. sh2-rust-turbo's "memoize the scheduler" plan is the first application. - **Sega CD** (segacd-python), for the same reason as the Saturn: minutes of loading before the moments that matter. - **The PlayStation** (psx-python) is the second board, after the N64, to be specified with the shared state format from M1. ## Suggested text (for Aubrey, if accepted) For the charter, the era table's row 3, "What changes": > ... Python too slow for long runs: gate cases are test ROMs and **slices from states > transplanted from a Rust tier** in a format the specification declares; `x-rust` is the > first tier that runs games; threaded `-fast` needed; turbo likely, GPU backends for > rasterisers included. For the methodology, under "Gates": > - **Slices (era 3 on):** where the specification cannot reach a moment in minutes, a gate > case is a start state (by SHA-256, with the tier and commit that wrote it), an input > script and a length. The state is in the board's shared format (its schema file in the > specification), and the slice runs in lockstep in every tier. Coverage comes from > sampled states along Rust runs and from chained slices. A slice proves agreement from > its state, never correctness up to it. > - **Cross-tier state rungs:** a state round-trips between Python and Rust byte for byte, > and every slice continues identically from a transplanted state. ## Decisions for Aubrey - **L1. Slice cases** as gate cases for boards whose specification cannot reach a moment in minutes (the N64 now; the Saturn and the PlayStation as they need it). *Recommend* yes. - **L2. x-rust as the first runnable tier** for those boards. Its claim is "identical on N slices and M test ROMs", and the later links of the chain are held over whole runs. *Recommend* yes. - **L3. A shared, schema-declared state format** between x-python and x-rust for era-3 boards started from now on (n64-python, psx-python, saturn-python). This reverses, for them only, the 2026-11-23 "not shared between tiers" rule of the Mega Drive line. *Recommend* yes. The existing boards keep their formats unless moved one by one. - **L4. The schema as a data file** in the x-python repository, with hand-written encoders in each tier that are tested against it, rather than generated code. *Recommend* yes, in keeping with "x-rust is a transcription" and the JIT proposal's J3 (generated interpreters) staying deferred. - **L5. Gate states regenerated, never migrated;** player states refused at a new version unless a site ships a migrator. *Recommend* yes. - **L6. GPU backends as turbo**, proven per pixel and per device, with `gpu_backend: verified | failed | absent` in the capability record. *Recommend* yes. - **L7. "Profile the time-keeping first"** as an era-3 practice in the methodology. *Recommend* yes. - **L8. Exact idle-loop fast-forward** (one channel input, a known next change, a fixed iteration cost) recorded as turbo, distinct from the JIT proposal's inexact idle-loop skipping, which stays a concession. *Recommend* yes.