# Build record What happened when `docs/handoff-brief.md` ran, in order. The README says where things stand; this says how they got there. ## 2026-09-08, milestone 1 - Toolchain: rustup here is a snap whose `rustup run` leaves `/usr/bin/rustc` first on `PATH`, so a build "with" the 1.93.1 toolchain used the system compiler and had no wasm32 target. `scripts/build-wasm.sh` calls the toolchain's `cargo` and `rustc` by path. `wasm-bindgen-cli` 0.2.128 was installed with `cargo install --locked`; binaryen version_132 unpacked under `~/.local/binaryen`. - Data: the three rung 1 manifests and traces and the ten rung 5 manifests and traces were taken with `git show cab1598:...` from the z80-python clone, so they are the pinned commit's bytes and not the working tree's. The rung 1 files are byte-identical to z80-rust-fast's `tests/data/`, the rung 5 manifests to its `conformance/interrupts/`. - The comparison is a transcription of `tests/rung1.rs` into a function that takes strings, so the wasm export and the native test share it. `manifest_from_json(&value, None)` worked unchanged for inline-data manifests; no change to z80-rust-fast was needed. - Result: 13/13 identical natively and under Node 22.19 on the first run of each. Stop reasons: rung 1 all `halted`, rung 5 all `max_steps`, as the manifests specify. - Sizes: 237,916 bytes built, 194,403 after `wasm-opt -Oz`. ## 2026-09-08, milestone 2 - The page is three files and no framework; `app.js` fetches each manifest and trace, calls `check_manifest`, and appends a row. The manifest list is `conformance/index.json`, written by `build-dist.sh`, so the page needs no directory listing. - Rendering check: no browser is installed system-wide, but a Playwright headless shell (chromium 1194) was under `~/.cache/ms-playwright`; `--dump-dom --virtual-time-budget=15000` lets the async check finish. First render: 13 identical rows, gated sections opened. Screenshot matched. CI uses the runner's `google-chrome` the same way. - Deploy: `deploy/galaxian.yml` is `galaga.yml` with `s/galaga/galaxian/` (seven lines differ, all names). Container created and started at 22:59; the first curl returned 200 `text/html` for the page and 200 `application/wasm` for the module with no nginx configuration. The live page rendered 13 identical rows headlessly. ## 2026-09-08, milestone 3 - The runner is `z80-bench`'s loop with a budget argument and the stop reason kept across calls; `tests/runner.rs` checks ten slices of 100,000 give the same totals and output as one of 1,000,000. - `zexall.com`: my first fetch script pointed at z80-python's tree, but z80-python does not commit the GPL binary either (its `tests/zex/` is ignored); `docs/validation.md` names agn453/ZEXALL, and that file's SHA-256 is the one z80-rust-fast pins. Fixed before anything was committed. - Node, first full run, pinned to CPU 4: 32.077 s, 179.70 M instructions/s, exact totals, `cpm_exit`, 67 OK, 0 ERROR, "Tests complete". The 50 M-instruction smoke read 156 M/s; the full run is faster per instruction because the slices amortize. - The page's ZEXALL could not be read with `--dump-dom`: Chromium's virtual-time budget returns before a worker's real computation ends (0.3 s, "loading…"). `web/zex-browser.mjs` drives the headless shell over the DevTools protocol with Node's built-in WebSocket and polls the result line. Headless Chromium 141: 33.633 s, 171.39 M/s, exact totals, every test OK. Firefox is not on this machine and cannot be installed without sudo; left as not measured. - Wasm at about 52% of native. The core is the same source; the gap is the wasm target itself (V8's codegen from wasm, bounds-checked linear memory), not the JS boundary, which is crossed once per 25 M instructions. Not pursued: the brief measures the wasm build, it does not optimize it. ## 2026-09-08, milestone 4 - galemu pins `z80-python==0.3.0` from PyPI, 24 commits before `cab1598`, and every file of the installed package differs from the pinned commit. The oracle must run on the pinned core, so the local z80-python clone (`d1ec9c7`, core identical to `cab1598`) was installed into galemu's venv with `--no-deps`. galemu's own 5,000-instruction headless run is byte-identical under both, so the two cores agree on this workload too. - galemu's headless CLI never schedules the vblank NMI (only `--display` does) and records every RAM write; the display does the opposite. `oracle/galemu_run.py` configures galemu's unchanged `GalaxianBoard` either way and adds inputs at stated instruction counts or frames. Runs are defined in frames where game time matters: a halted CPU takes four T-states per boundary, so 600,000 "instructions" of attract mode turned out to be 47 frames. - The one design problem: an event's PC. z80-rust-fast's `Bus` has four methods and no view of the CPU; a raw pointer from the bus into the CPU's `pc` would be undefined behaviour under `&mut`; a new trait method would re-open the core's rung 3. Derived instead: pre-step PC plus `last_instruction_bytes().len()` (the core resets that counter at each decode), pre-step PC for an NMI acceptance. All six runs identical on the first try, natively and under Node; the two runs with every RAM write recorded (1,564 and 3,300 events) are what test the stamping. - Attract mode and a keyboard game verified in headless Chromium over the DevTools protocol (`DOM.setFileInputFiles` for the zip, `Input.dispatchKeyEvent` for the controls): 8 files verified, 60.0 frames/s emulated and keeping up, score 340 after 20 s of scripted play with the formation, the ship, the starfield and the level flag drawn. - Deviation from the brief: the game runs on the main thread, not in the worker. Reason in the README: a frame costs under 0.1 ms. ## 2026-09-08, milestones 5 and 6 - A second headless game run collided with the first one's ports and screenshotted a blank page; the browser scripts now take `PORT` and `DEVTOOLS` from the environment. A `pkill` pattern that matched the shell running it killed that shell: a lesson in patterns, not in the project. - Gamepad: no pad can be attached headlessly, so `demo-browser.mjs` installs a simulated standard-mapping pad over `navigator.getGamepads` and presses its buttons; the page detected it, took the coin and the start, and drew the game. Inputs from keyboard, pad and touch are merged per control so releasing one source does not release another's hold. - Sound: the transcription matched galemu's PCM exactly on the first run, natively and under wasm (1.2 million samples, none differing). Two things had to be right for that: Python's `round` is half-to-even (`round_ties_even`), and the reference's per-frame event list is reconstructed from raw (address, value) pairs by `decode_sound_write`, which the Rust side does identically from its own events. - Deviation kept from milestone 4: still no worker. ## 2026-09-08, milestone 7: done - The keyboard game to game over: a four-minute scripted session (`web/game-browser.mjs`, fire every second, alternating left and right) ended with the score 340 on the high-score line, "WE ARE THE GALAXIANS" and the score advance table back on screen, CREDIT 0: three lives lost and the attract mode resumed, 100.8 million instructions, 61.0 frames/s emulated and keeping up throughout. - Three of the attempts at that run failed before this one for reasons outside the game: a port collision, a shared Chromium profile between two concurrent runs (an evaluate against a page that never loaded), and the page awaiting `AudioContext.resume()` under a strict autoplay policy. The last one was a real bug for visitors and is fixed; the drivers now use a profile per run. - Live: https://galaxian.supertux.com at the final commit; the live page renders the thirteen rows headlessly after each deploy. - Left to the user: the Firefox column of the speed table (no Firefox on the build machine), and measurements on other machines. ## 2026-11-26, ZEXALL out of the tree - `external/zexall.com` (GPL-2.0, tracked since milestone 3 despite the README) is untracked; `external/` is git-ignored; the old working copy is kept aside at `/data/backup/z80-wasm-zexall-2026-11-26/`. - `scripts/fetch_zexall.sh` now pins agn453/ZEXALL commit `8f71d418` instead of `main`, downloads to a `.part` file and keeps a mismatching download as `zexall.com.bad` rather than leaving it in place. - Checks: fresh fetch 8704 bytes, SHA-256 verified, and identical to the old tracked file and to `dist/zex/zexall.com`; a second run says "present and verified"; `cargo test --release --test runner` 2 passed; `node web/zex.mjs --limit 2000000` prints the banner and the first test line, 2,000,000 instructions, 16,168,594 T-states. No full ZEXALL run, no deploy, `dist/` not rebuilt. - The file is still in history from `7f17854`; not rewritten.