# Handoff brief: pokey-rust > **Lineage:** pokey-python → **pokey-rust** · fixes start in pokey-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-14, for Aubrey: transcribe the restarted POKEY core `pokey-python` into Rust, line by line, proven equivalent to it, so that Rust boards for the Atari 5200 and 7800 can use it. Local repository only (no remote, nothing pushed, no tag). The family charter (`emulator-lineage/docs/charter.md`) overrides anything here that conflicts with it. ## What it is A Rust POKEY (C012294) core transcribed from [pokey-python](https://github.com/alewman/pokey-python) at **`6ed1ffa`** ("Rungs 9 and 10: the conformance kit, all faults, measured status"; its `docs/status.md` names it as the commit boards pin; the next commit, `34a541c`, changes documents only, so a checkout at either has the same `src/`, `tests/`, `scripts/` and `validation/`). Proven equivalent to it at every tick: the four channel codes, `mix()`, /IRQ, the pins out, every read, every call the chip makes to the board's wiring, and the whole chip state. The crate is `pokey` (the reference's name without `_python`, the family convention for Rust ports). Tier `x-rust` of the charter: a faithful transcription, not a second design. ## What to transcribe From `src/pokey_python/` at `6ed1ffa`, module for module, with the same names, the same order and the comments and evidence tags (rule numbers B0.1-B7.4 of the reference's `docs/behaviour.md`, DOC, OBSERVED, FITTED, HYPOTHESIS) carried over: - `chip.py` -> `src/chip.rs`: `POKEY`, the register numbers, the class constants (`TAP4`, `TAP5`, `TAP17`, `AUDC_DELAY`, `STIMER_FF_LEAD`, `HP_LATE`, `HP_OLD`, the three key codes), `power_on(seed)`, `read`, `write`, `tick`, `run`, the pins out, `levels`, `mix`, `take_outputs`, `snapshot`, `restore`. - `variants.py` -> `src/variants.rs`: `POKEYVariant` rows as data; `C012294` (the fitted curve) and `LINEAR`. - `rc.py` -> `src/rc.rs`: the optional board-side `PotRC` helper; the chip never uses it. Where Rust forces a difference the module header says so. Expected ones: the wiring callbacks cannot borrow the chip, so those that read chip state (`pot_level`, `on_dump`, which `PotRC` needs) are handed it; `read` takes `&mut self` because it may call the board's `pot_level`; `power_on(seed)` needs Python's Mersenne Twister and its integer seeding, transcribed so that a seed gives the same state on both cores; `snapshot()` is a struct, not a dict. ## 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. 1. **The reference's unit tests, transcribed** where they test behaviour (`tests/test_*.py` -> `tests/*.rs`, the AcidSAP harness on 6502-rust, which is transcribed from the same 6502-python commit, `741419a`, the reference's `acid` extra pins). All pass; the reference's two strict xfails (`twotone`) stay expected failures. 2. **Seeded lockstep**: random register, tick, pot, key, SID and BCLK streams, seeded power-ons, snapshots restored mid-run, `record=True` and both variants, run on both cores; per-tick lines (levels, `mix()` bits, /IRQ, pins, reads, every wiring call) and periodic full-state lines compared byte for byte, the reference's traces written by `scripts/lockstep_ref.py` on the reference's own venv. 3. **The conformance kit**: `validation/conformance.txt` reproduced exactly from the reference's own case generators (exported once, checked to be the reference's at the pin), plus the reference's validation stream generators (rungs 2, 3, 4, 6 of `scripts/streams.py`) played on both cores without the closed box. 4. **Seeded faults**: the reference's 64, each applied to the Rust code and caught by a rung, plus faults of our own for what is Rust-specific (seeding, snapshot, wiring, variants, the helper). Not run here: the closed-box VHDL rungs (the reference's business; the VHDL source is never read and never run by this repository). ## Working rules - Never modify pokey-python. If the reference looks wrong, stop on that point and report it with a repro; never fix behaviour downstream. - Provenance: a transcription of our own MIT code, which inherits the reference's restart rules (`docs/restart.md` there). Not read: anything under `/data/backup/`, any older installed `pokey_python`, Nick Mikstas's VHDL (`reference/src/atari_pokey/`), any GPL POKEY source. - Outside paths by environment variable (`scripts/env.sh`); nothing third-party committed. - CI: fmt, clippy `-D warnings`, test, on main and pull requests, concurrency cancel, a timeout. Rungs 2-4 need the private reference and run locally. - Speed against the PyPy reference, in multiples of real time at 1.79 MHz.