# Provenance Audit of 2026-11-13 (provenance audit wave 1), against the family charter's "Licences and provenance" section and the rules of the November 2026 sound-core restart: GPL/LGPL code is never copied or transcribed; GPL/LGPL programs are used as closed boxes only; facts about the chip are usable with their source recorded; permissive sources keep their notice. ## What changed since the core was written The HG51B169 (Cx4) has no manufacturer document. The core and its documents were written (2026-11-06/07) from fullsnes (research) and three emulator models, under the older rule "GPL sources are read and cited, never copied": bsnes (GPL-3), Mesen2 (GPL-3) and the MiSTer FPGA Cx4 (no licence seen) were open, and line numbers into them are cited throughout `docs/undocumented-behavior.md` and in `src/` comments. That rule is superseded: **bsnes, Mesen2, snes9x and MAME's `snescx4.cpp` (GPL-2.0+) are closed boxes; the MiSTer sources (no licence) are not opened either.** `docs/handoff-brief.md` still states the old rule (see "Owed"). What keeps most of this repository clean despite that history: - **byuu's HG51B model is also published under ISC.** ares (`ares/component/processor/ hg51b`, ISC, "Copyright (c) 2004-2025 ares team, Near et al") carries the same core as bsnes (token similarity 0.956 after normalising type names, measured 2026-11-13 by a count-only comparison that printed no source; the project's own pin records "type-name changes only, measured with diff -w 2026-11-06"). Every default the core takes from "bsnes" is therefore available from a permissive source and is cited to ares below. The ares board glue (`sfc/coprocessor/hitachidsp`) is likewise ISC; bsnes' version adds the embedded data-ROM table, which this core does not use. - **No copying found.** `pcengine-python/scripts/provenance_check.py` was run against ares' `hg51b` (ISC) and, because reading them was this project's documented practice when it was written, bsnes' `processor/hg51b` and `sfc/coprocessor/hitachidsp`, Mesen2's `Core/SNES/Coprocessors/CX4` and MiSTer's `rtl/chip/CX4`. Hits: the constant-register index list (`3 8 12 19 28 ...`, fullsnes' table too); the S-CPU I/O addresses $7F4E-$7F51 in `host.py` (fullsnes "I/O Map"); two short quotations of Mesen2 source *comments* in the docs (below); a hex-constant list in `docs/start-here.md` (the sixteen constant registers, fullsnes). No code shape, no transcribed statement. - **The data ROM is computed, not copied** (`data_rom.py`): fullsnes' six formulas evaluated exactly; equality with a real chip's dump (MAME `hash/snes.xml` SHA-1) is checked, and no image is committed or fetched. ## Verdicts | Piece | Behaviour from | Licence of source | Verdict | |---|---|---|---| | `data_rom.py` | fullsnes "CX4ROM" formulas; dump SHA-1 from MAME `hash/snes.xml` | facts | clean | | `_decode.py` (encoding, operation classes, constant registers) | fullsnes "Opcodes"; byuu's decode table (ares `instruction.cpp`) | facts / ISC | cite: name ares for the table's grouping (bsnes cited today), keep ISC notice | | `_alu.py` defaults (shift limit "bsnes", truncation, V formula `~(x^y)&(x^z)`, MUL) | fullsnes; byuu's model (ares) | facts / ISC | cite: re-point "bsnes" to ares; the quoted expressions appear identically in ares | | `_alu.py` non-default branches: `SHIFT_LIMIT = "mesen2"`, `"mod32"`; `TRUNCATE_SHIFTED_OPERAND = False` (incl. Z of the untruncated difference) | Mesen2 source (GPL-3), MiSTer source (no licence), read under the old rule | GPL-3 / none | **rewrite**: remove, or re-establish each by a closed-box Mesen2 run (the repo's `scripts/mesen_cx4_trace.py` can) and cite the measurement; the MiSTer variant has no closed-box route (not runnable here) | | `_flow.py` defaults (stack "bsnes", far "bit9", HALT/IRQ, SKIP) | byuu's model (ares); fullsnes | ISC / facts | cite | | `_flow.py` non-default branches: `STACK_MODEL = "circular"`, `FAR_SELECT = "either"` | Mesen2 source | GPL-3 | **rewrite** (as above) | | `cpu.py` defaults (main loop, cache pages, bus port, DMA lock "bsnes", bus delay 0, C10 CLEAR, C11, C16 operand 00h reads A) | byuu's model (ares); fullsnes register table (C16) | ISC / facts | cite | | `cpu.py` non-default branches: `DMA_LOCK = "mesen2"`, `BUS_DELAY_EXTRA = 1`, C10 "NOP", `LD_P_SOURCE = "mesen2"` | Mesen2 source | GPL-3 | **rewrite** (as above) | | `host.py` (S-CPU side, $7F40-$7FFF) | fullsnes "I/O Map", "Exception Vectors"; byuu's glue (ares `hitachidsp`) | facts / ISC | cite; `IRQ_DISABLE_SETS_FLAG = True` (C18) was observed in a closed-box Mesen2 replay: clean as a closed-box measurement | | `harness.py`, `replay.py`, `trace.py`, `state.py`, `debug.py`, `console.py`, `disasm.py`, `__main__.py` | own tooling; `replay.py` replays Mesen2 trace-logger output (closed-box run of MesenCore.so) | own work | clean | | `scripts/mesen_cx4_trace.py`, `record_mesen_windows.py`, `mame_cx4_host.py`, `survey_program.py`, `fetch_references.py` | Mesen2 and MAME run as closed boxes; game program read in place (BYOR) | own work | clean | | `scripts/survey_data_rom.py` | parses the data-ROM tables out of bsnes `data-rom.cpp`, Mesen2 `Cx4.Instructions.cpp` and MiSTer `drom.mif` to compare with the computed table | reads GPL/unlicensed files as data | cite, with a change owed: the table is a chip ROM (a fact) and nothing is shipped, but the script opens GPL files; compare against a BYOR `cx4.bin` (by SHA-1) only | | `tests/` | own; Mesen2 windows recorded locally, not committed | own work | clean | | `docs/timing.md` l.54-57, `docs/undocumented-behavior.md` C14 | quote Mesen2 source comments ("TODO: CPU shouldn't have access to PRG ROM ...", "Timings are apparently not perfect (desync in MMX2 intro)") | GPL-3 | cite: paraphrase without quoting, and mark as "read from source under the old rule" | | `docs/start-here.md`, `undocumented-behavior.md`, `validation.md`, `claims.md` | fullsnes; emulator entries cite bsnes/Mesen2/MiSTer line numbers | mixed | cite: re-point bsnes to ares (ISC); mark Mesen2/MiSTer-only entries (U14 one-model, U17, U18, C1-C18 alternatives) as read from source, to be re-established closed-box before any default rests on them | | `docs/handoff-brief.md` | policy text, and decision 3's mention of reading the table from emulator source | n/a | **rewrite** the line "GPL sources are read and cited, never copied" | | `scripts/pinned_repos.json` | reference pins | n/a | cite: bsnes/Mesen2/snes9x/MAME `snescx4.cpp` to "closed box only"; MiSTer to "not opened (no licence)" | Counts: clean 8, cite 10, rewrite 4 (the Mesen2/MiSTer-only switch branches in three modules, and one policy sentence), unclear 0. Every default the core ships rests on fullsnes, ares (ISC) or a closed-box measurement; only non-default switch positions rest on GPL or unlicensed source. No ROM, program image or data-ROM image is committed. Git history at the audit (11 commits, one branch, no remote): no file was ever deleted; nothing in history differs in provenance from the tree. ## Owed 1. Remove or re-establish (closed-box) the Mesen2/MiSTer-only switch branches listed above. 2. `docs/handoff-brief.md`, `scripts/pinned_repos.json`: the closed-box rule; ares (ISC) as the citable form of byuu's model. 3. Keep the ares ISC notice ("Copyright (c) 2004-2025 ares team, Near et al", ISC permission text) with what was taken from byuu's model (this file suffices until code carries per-file headers). 4. `scripts/survey_data_rom.py`: compare against a BYOR dump instead of parsing emulator sources. 5. SPDX headers: no source file has one yet (family-wide pass owed). 6. Not provenance, but a house rule: a mirror's name and machine paths appear in `docs/mame-oracle.md`, several scripts and `tests/conftest.py`; use `MAME_ROMPATH`. ## Wave 2 (2026-11-19) In place, not a restart: the flagged pieces were the non-default positions of a few switches, one script and some doc wording; every default already rested on fullsnes, ares (ISC) or a closed-box run. Rules: emulator-lineage's docs/sources.md (bsnes, Mesen2, snes9x, MAME `snescx4.cpp`: closed box only; MiSTer: no licence, not opened). How the flagged code was removed: each switch was found by its name; only the lines of the non-default branch were looked at to cut them (they were seen while cutting, not studied); the tests that exercised only those positions were moved, unread, to the git-ignored `trash/tests-set-aside/`. `scripts/survey_data_rom.py` was moved unread to `trash/scripts/`. Closed-box route: `scripts/cx4_probe.py` (new) builds homebrew LoROM cartridges with the Cx4 header bytes (F3h/10h), a few HG51B words each and an S-CPU stub, runs them on Mesen2 2.1.1 `b9fa69dd` through `scripts/mesen_cx4_trace.py`, and replays them on the core. 20 recordings (`tests/mesen_probes/`, gitignored); `tests/test_mesen_probes.py` pins the result. A position came back only where the rows alone describe it. | Item | Was | Now | New source | Verdict | | --- | --- | --- | --- | --- | | C1 `SHIFT_LIMIT = "mesen2"` | Mesen2 source | `"mesen2-observed"`: counts 24-31 leave A, N/Z from A | `shift` probes (12 rows differ from ares at count 24) | re-established, OBSERVED | | C1 `SHIFT_LIMIT = "mod32"` | MiSTer source | removed | none (no closed-box route) | removed | | C1 default `"bsnes"` | bsnes | renamed `"ares"` | ares `instructions.cpp` l.46-81 | cite | | C2 `TRUNCATE_SHIFTED_OPERAND = False` (incl. Z of the untruncated difference) | Mesen2 source | removed; the switch is gone (24 bits always) | `truncate` probes: 64 of 120 rows differ in C/Z; recorded, not modelled | removed (observation recorded) | | C3 `DMA_LOCK = "mesen2"` | Mesen2 source | removed; switch gone | `dma-*` probes: Mesen2 locks ROM-ROM, RAM-RAM, RAM-ROM, none-RAM, not ROM-RAM; five cases do not make a rule | removed (observation recorded) | | C4 `STACK_MODEL = "circular"` | Mesen2 source | `"ring-observed"` | `stack` probe: ten calls, the ninth return comes back to the newest | re-established, OBSERVED | | C17 `FAR_SELECT = "either"` | Mesen2 source | `"either-observed"` | `far` probe: 0910h with P = 1 runs page 1 | re-established, OBSERVED | | C7 `BUS_DELAY_EXTRA = 1` | Mesen2 source | kept, cited to the run | `bus` probe: WAIT lasts 1 + ROM wait | re-established, OBSERVED | | C10 `CLEAR_IS_NOP = True` | Mesen2 source | kept, cited to the run | `clear` probe: A, P, DPR unchanged | re-established, OBSERVED | | C11 `LD_P_SOURCE = "mesen2"` | Mesen2 source | `"operand-observed"` | `ldp` probe: twelve operand codes | re-established, OBSERVED | | C8 `INTERNAL_ACCESS_COST = 1` (not listed in wave 1; same pattern) | Mesen2 source | kept, cited to the run | `dma-cost-w0/-w7`: 32 vs 141 busy polls, 2 vs 9 clocks a byte | re-established, OBSERVED | | C9 `CACHE_PRELOAD = "mesen2"` (not listed in wave 1) | Mesen2 source | removed; switch gone | `preload`, `preload-cold`: no load when cached, a load when nothing is, none after PB = 1; not enough to model | removed (observation recorded) | | C13 `STATUS_MIRROR = "mesen2"` (not listed in wave 1) | Mesen2 source | `"all-observed"` | `mirror` probe: $7F53-$7F5F all read C2h | re-established, OBSERVED | | C16 default (operand 00h reads A) | fullsnes + Mesen2 source | fullsnes + `ldp` probe | fullsnes register table; OBSERVED | cite | | C18 `IRQ_DISABLE_SETS_FLAG` | closed-box replay (the docstring named a Mesen2 function) | unchanged; docstring cites the replay | rung 4, every probe | clean | | "a locking DMA ends", "busy on fetch loads" (defaults that differ from ares) | Mesen2 source | unchanged | `dma-ram-ram` probe (after $7F53 the next start runs); every host stream (C2h during a start's load) | re-established, OBSERVED | | `scripts/survey_data_rom.py` | parsed bsnes/Mesen2/MiSTer table files | moved aside unread; `scripts/check_data_rom.py` | a player's `cx4.bin` via `HG51B_DATA_ROM`/`MAME_ROMPATH`, SHA-1 from MAME's CC0 `hash/snes.xml` | rewritten | | "bsnes" citations in src/, tests/, scripts/, docs/ | bsnes file:line | ares file:line, found by searching ares | ares (ISC), NOTICE | cite | | Mesen2/MiSTer source statements in docs | read under the old rule | replaced by OBSERVED probe results, or marked "read from source under the old rule; closed box from now on; never a default" (C12, C14), or dropped | probes; ares; fullsnes | rewritten | | timing.md and undocumented-behavior.md C14 quotations of Mesen2 comments | quoted | paraphrased without quotation, marked old-rule | none | rewritten | | MAME `snescx4.cpp` and `snes.cpp` quotations (mame_cx4_host.py, mame-oracle.md) | quoted | removed | MAME binary search (no HG51B device) | rewritten | | U5 "verified" | bsnes comment taken as a hardware hint | ares comment, **provisional** (rule 7) | ares `registers.cpp` l.62; `ldp` probe | cite | | `docs/handoff-brief.md`, `start-here.md`, pin list | "GPL sources are read and cited, never copied" | "closed box only"; ares the citable form; MiSTer not opened; closed-box pins carry `"fetch": false` | sources.md | rewritten | | Machine paths, mirror name | conftest, record_mesen_windows, survey_program, mame_cx4_host, mesen_cx4_trace, pin "local" fields, docs | `NO_INTRO_DIR`/`SNES_NO_INTRO`, `MAME_ROMPATH`, `MESEN_CORE`, `MAME`, repo-relative paths | house rule | fixed | | NOTICE, SPDX | none | NOTICE (ares ISC text, MAME CC0 credit); SPDX on every src/test/script file (`MIT AND ISC` on `_decode.py`, `harness.py`) | | done | **Unclear (for the owner):** `scripts/mesen_cx4_trace.py` declares Mesen2's C API for ctypes (the CPU-type number 5, the `SnesConfig` offsets, the `TraceOptions` and controller-state layouts). Those declarations were taken from Mesen2's headers when the harness was written (old rule): interface facts, not behaviour, but read from GPL files. Driving a closed box needs them; they were not re-read in Wave 2. A clean route would be to re-derive them from Mesen2's documented interop (its C# front end's declarations are also GPL) or from probing the library; the owner may prefer to rule on it. **Settled 2026-11-19 (charter session; the owner deferred the call):** the harness is a GPL tool, not part of this repository. `mesen_cx4_trace.py` moved out to the local `hg51b-mesen-harness` (GPL-3.0-or-later LICENSE and README, never shipped), the same treatment as m68000-python's WinUAE referee. (Since then: folded into emu-tools-gpl on 2026-11-23 as `tools/hg51b-python/mesen_cx4_trace.py`, a shim over its `tools/mesen2`, which the scripts run at `$EMU_TOOLS_GPL/tools/hg51b-python/mesen_cx4_trace.py`; on 2026-11-24 the separate repository's one commit was merged into emu-tools-gpl's history and the repository archived as `zzz-hg51b-mesen-harness`. Nothing this repository runs points at it. On 2026-11-24, with mesen2-runner 0.2.0's `--input` for `snes-cx4`, both scripts moved off the shim to `$EMU_TOOLS_GPL/tools/mesen2/run.py --machine snes-cx4`, with recordings identical up to the last requested frame: docs/validation.md.) `cx4_probe.py` and `record_mesen_windows.py` run it as a separate program and read only its output; the recorded windows and probe results stay here as closed-box measurements (OBSERVED; from 2026-11-24 OBSERVED (Mesen2 b9fa69d via mesen2-runner 0.2.0), each run's `manifest.json`). The file was in this repository's local history (never pushed) until 2026-11-22, when the history clean-up (wave E) reset the repository to one commit of this tree; the old history is kept privately as the record, and commit hashes cited in these documents refer to it. **Gates** (PyPy 7.3, `PYPY_GC_NURSERY=1M`): before 122 passed, 1 skipped; after 163 passed, 1 skipped (14 set-aside cases out, `test_switches.py` +35, `test_mesen_probes.py` +20). Rung 3: all eight items "OK." on X2 under the defaults and under each of the 11 remaining alternatives (2026-11-19). Rung 4: the five Mesen2 windows replay with 0 instruction divergences, as before. **No default changed behaviour.** Downstream: snes-python uses this core (no Rust transcription exists yet). No default changed; the switch values renamed ("bsnes" -> "ares") and removed (`TRUNCATE_SHIFTED_OPERAND`, `DMA_LOCK`, `CACHE_PRELOAD`) matter only to code that set them; snes-python sets none (searched). ## Closed-box pins removed (2026-11-24) Aubrey's rule of 2026-11-24: an MIT repository does not download or keep the source of anything the family's `sources.md` marks closed box only. Three entries that were already never fetched (`"fetch": false`) but listed source paths left `scripts/pinned_repos.json`; they are cited by URL and commit only: bsnes (https://github.com/bsnes-emu/bsnes @ `78474e5d39f58872dc21aca18cf9eb583b147fe7`, GPL-3.0), snes9x (https://github.com/snes9xgit/snes9x @ `1bcc369e89f08243e0a462882fb1f3e42e51de3a`, non-commercial) and SNES_MiSTer (https://github.com/MiSTer-devel/SNES_MiSTer @ `23026830ff8108fda0f32c0616296845f586b8ce`, no licence in the sources). The MAME pin's `/src/devices/bus/snes/` now excludes that directory's GPL-2.0+ files (`rom.cpp`, `rom21.cpp`, `spc7110.*`, by their `license:` lines), so a fetch with `--no-local` no longer brings them (`snescx4.*` sits in `src/mame/nintendo/`, outside the pin); `has_sparse` skips exclusion patterns. The Mesen2 entry stays: it fetches only the LICENSE, as the revision the closed-box library is built from. Nothing was moved: no closed-box tree was in this repository (the in-place copies are snes-python's). Later the same day snes-python stopped keeping closed-box trees, so the in-place copy of Mesen2 this entry read (`../snes-python/reference/src/Mesen2`, for its LICENSE only) is gone. The entry is now `"fetch": false`, with no `local` and no sparse paths: Mesen2 is cited by URL and commit (https://github.com/SourMesen/Mesen2 @ `b9fa69ddc6d0a331fb103fdb5eef6904305703c2`, GPL-3.0) and built and run only by mesen2-runner (emu-tools-gpl). What this repository still reads from snes-python's checkout is unchanged: ares (ISC), MAME's BSD-3 `bus/snes/` and `snes.cpp` and `hash/snes.xml` (CC0), and fullsnes. `fetch_references.py --verify` passes, and the tests give the same counts before and after (155 passed, 1 skipped quick; 8 slow).