# Handoff brief: w65c02-rust > **Lineage:** w65c02-python → **w65c02-rust** → (w65c02-rust-fast) → lynx-rust · > fixes start in w65c02-python and flow down by merges · > [family charter](https://github.com/alewman/emulator-lineage/blob/main/docs/charter.md) ## The request The coordinator, 2026-11-13, for Aubrey: bring the Atari family (5200, 7800, Lynx) to the shape the 2600 line already has: Python reference, a Rust transcription held in lockstep against it, a speed fork, a browser site. The first consumer of this crate is a future `lynx-rust` board. Decisions given: local repository only (no remote, nothing pushed); the model to follow is `6502-rust`; the family charter (`emulator-lineage/docs/charter.md`, agreed 2026-11-14) overrides anything here that conflicts with it. ## What it is A Rust CMOS 65C02 core transcribed from [w65c02-python](https://github.com/alewman/w65c02-python) at **`9ca4a2f`** (main, "Add docs/provenance.md: provenance audit, wave 1"; rungs 0 to 8 passed; repinned on 2026-11-14 to `e49aceb`, which changes comments and documents only, its evidence tags carried down) and proven equivalent to it at every processor boundary: boundary kind, cycles, every bus access in order with its kind (`rs` an opcode fetch, `rf` another read at PC, `r`, `w`), and all of `CPUState`. The crate is `w65c02` (the reference's name without `_python`; Cargo does not allow a package name that starts with a digit, and the family convention for Rust ports drops the suffix). It is tier `x-rust` of the charter: a faithful transcription, not a second design. The reference is built on 6502-python's `CPUFrame`; this crate is built on 6502-rust's `frame::Frame` and `frame::Part` (crate `sixfiveohtwo`, pinned by git revision `71747eb`, the last pushed commit; its source is the same as `129e742`), exactly as the reference depends on `6502-python` at `741419a`. If the frame lacks something the CMOS core needs, 6502-rust is **not** modified: the request is written in `docs/requests.md` and worked around here, said so in the module header. ## What to transcribe From `src/w65c02_python/` at `9ca4a2f`, module for module, with the same names, the same per-row data, the same dispatch table and the hardware and source comments carried over (CAP, DS, GDS, CL, LK, GF, LT, SST; U and C entries of the reference's `docs/undocumented-behavior.md`): - `cpu.py`: `CMOS65C02` and the four rows `W65C02S`, `R65C02`, `G65SC02`, `Lynx2Cell`. In Rust a row is a value (`Row`), not a subclass: the same attributes (`bit_instructions`, `wai_stp`, `reset_writes_stack`, `one_cycle_nops_poll`, `nop_5c_reads`, `nop_dc_fc_reads`), so a board can make its own. - `_core.py`, `_alu.py`, `_loads.py`, `_shifts.py`, `_bits.py`, `_control.py`, `_nops.py`, `_dispatch.py` (`OPCODES`, `opcodes_for`, `FORM_BYTES`, the table built per row). - The signals the Lynx board needs inside a bus callback: `sync` (the opcode fetch, and the first cycle of an interrupt entry and reset), `fetch` (every read at PC), `opcode` (the instruction in progress). In Rust the bus cannot reach the CPU while the CPU calls it, so these are handed to every callback with the frame (Rust-forced; said in the module header). - `state.py` (`CPUState`, with `waiting` and `stopped`) and the trace writer in the family JSON Lines schema (6502-python `docs/trace-schema.md`, version 1, with this core's kinds `wai` and `stp` and its access kinds), so both cores write the same traces; `debug.next_boundary`. Not transcribed (Python-side tooling, as 6502-rust did not transcribe its equivalents): `debug.py`'s session, `console.py`, `disasm.py`, `__main__.py`. A trace record carries each instruction's address and bytes; the reference's reader disassembles them for the row. ## The ladder Each rung has a script in `scripts/` that passes only when its output says so; `scripts/ladder.sh` runs them all and is the single gate (charter). 1. **Trace lockstep, short programs, every row**: hand-assembled programs and the first boundaries of Dormann's extended test, his NMOS functional test and Clark's decimal test, on `W65C02S`, `R65C02`, `G65SC02` and `Lynx2Cell`, traces compared by the reference's own `w65c02_python.trace.first_trace_divergence` (read for the row). Plus the dispatch table of every row against the reference's `opcodes_for`. 2. **SingleStepTests 65x02**, the three CMOS sets per row exactly as the reference's rung 1 runs them (`tests/single_step.py`: B dropped going in and not compared, the named contradictions C1, C2, C3, C10, C13 to C18 with their reduced comparisons). Exit: 0 fail, and every per-set count equal to the reference's (`reference/build/final_sst.txt` at `9ca4a2f`). The corpus is read in place from the reference's `reference/src/65x02`. 3. **Dormann's 65C02 extended test, his NMOS functional test and Clark's decimal test natively** per row: the same trap addresses, instruction and cycle counts as the reference's rungs 2 and 3. 4. **The real-chip capture lockstep** (the reference's rung 4, tier 1): the G65SC12 and R65C02 captures and Foot's data-only capture, replayed with the reference's method (`tests/capture_replay.py` transcribed): no mismatch, no model difference, and the same counts as the reference. Plus **interrupt, WAI and STP scenarios traced against the reference**: seeded random requests between steps and inside bus cycles, stalled reads and writes (`note_stall`), resets, `WAI` with and without I, `STP` then reset, one-cycle NOPs before a pending IRQ, random programs on every row. 5. **The frame carries the rows with no NMOS code linked**: tests that every row steps on `Frame`/`Part` alone, and a check that no `Mos6502` symbol is in the built binaries. 6. **Seeded faults**: every class of the reference's 44 that applies to a transcription, each a one-line change in a copy of `src/`, each shown caught by a named rung. CI (`.github/workflows/ci.yml`) as 6502-rust's: `cargo fmt --check`, `cargo clippy -D warnings`, `cargo test` (rung 5), on main and pull requests, concurrency cancel, a job timeout. The reference repository is private, so the lockstep rungs and the corpus rungs run locally only. ## Working rules - Never modify w65c02-python or 6502-rust. If the reference looks wrong, stop on that point and report the divergence; the captures and the vectors are the authority, not either core. - Transcribe; do not redesign. Where Rust forces a difference, say so in the module header. - Provenance: a transcription of our own MIT code. No GPL emulator source is opened; MAME and `decode6502` may be run as black boxes only. Nothing third-party is committed; outside data is found by environment variable (`W65C02_PYTHON`, `SST_65X02`), never a machine path in the repository. - Local git only; one rung per commit; `docs/build-progress.md` and `docs/status.md` current after every rung. - At most 4 processes, `nice -n 19`, `PYPY_GC_NURSERY=1M` for parallel PyPy. - Commit trailer: `Co-Authored-By: Claude Opus 5.5 `.