Civilization 1.1.0 Static Core Audit
====================================

Date: 2026-08-19
ROM: Civilization (USA), unheadered HiROM
ROM SHA-256: de2d5a952096c5f50368b9270d342aa6e7a39007ffbec27117e182e30ef4cf32
Result: NO REACHABLE S-CPU OR S-SMP STATIC CODE GAP OBSERVED THROUGH COLD BOOT,
        SETUP, WORLD GENERATION, TUTORIAL AND LIVE MAP GAMEPLAY; ONE AUDIO
        REPRODUCIBILITY GAP AND TWO CERTIFICATION/DOCUMENTATION GAPS REMAIN

Method and limits
-----------------

MesenCE is used only as an external observation oracle. Runtime observation
cannot prove every Civilization menu, map, combat, AI, diplomacy, ending, error,
or save path. Whole-core confidence therefore combines:

1. the offline fixed-point graph and its finite indirect/return proofs;
2. independent ROM candidate classification;
3. Mesen execution-address reconciliation for a long deterministic cold boot;
4. the static core running the matching 60,000,000-instruction cold/idle route;
5. S-SMP execution-address reconciliation against the finite audio AOT lookup;
6. the complete architecture, CPU, MMIO, PPU, DMA, audio, input, persistence,
   snapshot, and provenance test suite.

Static authority result
-----------------------

- 103,584 exact PBR:PC:E:M:X contexts
- 102,236 unique CPU instruction addresses
- 122,224 interprocedural proof states
- 2,425 procedures
- 100,591 direct edges and 8,939 call edges
- 69 finite indirect sites, all producer/value-set complete
- empty work queue and zero static-analysis frontiers
- no runtime opcode decoder, learned edge, interpreter, or emulator fallback
- 582 independent possible orphan-code candidates classified, zero unresolved

The four instruction starts in two dormant byte ranges remain intentionally
excluded. They occur after source-proved nonreturning calls:

- C0:222E-C0:2233
- C0:81AD-C0:81AF

They are exact dormant bytes, not unfinished reachable work.

Mesen S-CPU comparison
----------------------

Pinned Windows MesenCE executable SHA-256:
8ef403d6b9af32075416193914d7993ce8480b347fe1f20a0cfd9815374933e7

Bounded cold boot:
- 21,574 instructions / 3 frames
- 41 unique S-CPU PCs
- zero hits in all 582 independent candidates

Long cold/idle run:
- 60,000,000 instructions / 4,963 frames
- 5,198 unique S-CPU PCs
- all 5,198 belong to the closed 102,236-address static inventory
- zero missing Mesen PCs
- zero hits in all 582 independent candidates

The static core independently reached the same 60,000,000 instructions and
4,963 frames with no frontier. Its final visible frame hash was
4387978BE9904137. Full Static audio remained clock-synchronized, produced
2,646,154 PCM frames, and reported zero AOT failures and zero code barriers.

Mesen S-SMP comparison
----------------------

The compiled finite lookup contains 980 exact S-SMP/IPL instruction starts.
Across 4,963 frames Mesen executed:

- 21,517,030 S-SMP instructions
- 852 unique S-SMP PCs
- all 852 belong to the finite static-audio lookup
- zero missing S-SMP PCs

PPU observation
---------------

The 60,000,000-instruction Mesen PPU-domain capture used visible modes 1 and 3
and wrote $2106 MOSAIC only as $00. The renderer does not apply mosaic, but the
closed ROM writer inventory shows that 21 of 24 $2106 sites explicitly write
zero and the remaining three source their value from $18FC; every closed writer
of $18FC is also STZ. Mosaic is therefore disabled throughout the closed graph,
so this is not missing target behavior. $2133 SETINI was likewise observed only
as $00 on the long route.

Mesen emitted uninitialized-read warnings for WRAM $7E0100 and $7E0101 during
cold boot. The values did not create an execution divergence: all observed PCs
remained inside the closed graph and the Mesen/static instruction-to-frame ratio
matched at 60,000,000 instructions. This is recorded as a power-on-state
comparison point, not as evidence of missing static code.

Findings recorded during the audit
----------------------------------

F1 - Full Static audio cannot currently be regenerated from this source tree
     Severity: high for reproducibility; no observed runtime failure

The installed lookup says it was generated by:

  tools/audio/v20/generate_v20_static_smp_aot.py

and audio PROVENANCE.md says its authority comes from:

  static-recomp/generated/civilization_v08_spc700_closure.json

Neither file exists in the 1.1.0 source tree. The compiled lookup, dispatcher,
code bitmap, and runtime audio all pass and the long Mesen comparison found no
missing S-SMP PC, but another coder cannot independently regenerate those three
generated audio files from the stated proof input.

F2 - The official Mesen confirmation is too narrow
     Severity: medium for certification coverage; not a core failure

The previously maintained Mesen script stops at three frames and checks only the
582 suspicious candidate regions. This audit now includes a maintained,
input-driven cold-boot-to-live-map route and a generator that checks every
observed S-CPU and S-SMP PC against the finite authorities. The route covers New
Game setup, world generation, all tutorial pages, dismissal to the live map and
unit movement. It is not yet wired into CTest, and independent city, diplomacy,
combat, save/load and ending routes are still required for broad certification.

F3 - Current and historical documentation disagree
     Severity: medium for maintainability; no runtime effect

Current docs/STATIC-RECOMP-BOUNDARIES.md and docs/PROVENANCE.md still state the
older 103,576-context / 122,216-proof-state result and 33/69 indirect completeness.
The installed authority and later V35 reports contain 103,584 contexts, 122,224
proof states, and 69/69 producer/value-set completeness. The older intermediate
ROM-classification receipt also remains marked CLASSIFICATION_INCOMPLETE even
though the later reconciliation closed all 582 candidates. Historical receipts
may remain immutable, but current documents need an explicit supersession note.

Repair list
-----------

1. Restore the exact audio closure manifest and its generator. Pin their hashes,
   document the 948 uploaded-driver starts plus IPL entries, regenerate the AOT
   lookup/dispatcher/code bitmap in a clean directory, and require byte-identical
   output in CTest. Do not reconstruct the proof from runtime observations.

2. Promote the new whole-address Mesen comparators into maintained oracle tools:
   tools/scpu/emit_mesen_static_coverage_audit.py and
   tools/audio/emit_mesen_static_audio_coverage_audit.py. Add a compact receipt
   parser and fail the audit when any observed PC lies outside an authority.

3. Promote tools/oracle/civilization-coldboot-gameplay-route.json and
   tools/oracle/emit_mesen_gameplay_coverage_audit.py into an opt-in CTest gate,
   paired with civilization-static-gameplay-route.script. Then add independent
   city, diplomacy, combat, save/load and ending routes. Keep every observation
   as validation only; a divergence must be repaired by offline producer/target/
   hardware proof before changing generated authority.

4. Update current boundary/provenance documents to 103,584 contexts, 122,224
   proof states, and 69/69 indirect completeness. Mark incomplete V33/V35
   intermediate receipts as historical and superseded by the final V35 closure.

5. Add a static PPU value-domain receipt for renderer-affecting registers,
   including the complete $2106->$18FC writer proof and $2133 domain. This turns
   the current manually checked renderer assumptions into a repeatable gate.

No repair should add generic SNES emulation, a runtime decoder, learned targets,
or a fallback. No S-CPU or S-SMP generated context should be added solely from
this runtime trace, because the trace found no missing address.

Continued cold-boot-to-gameplay certification
----------------------------------------------

The Windows native V02 oracle was used to replace the earlier three-frame-only
confirmation with a deterministic 17,700-frame route. The route was derived
from the historical Version 34 input evidence, then corrected by observable
transition boundaries rather than fixed-delay guesses:

- title at frame 2,999;
- difficulty, competition, tribe and name setup at frames 3,700-4,580;
- narrative at frame 5,200;
- active world generation through at least frame 12,500;
- tutorial map by frame 16,450;
- all five tutorial pages advanced, followed by Start dismissal;
- live map at frame 17,390;
- changed live-map frame after Right input at frame 17,600;
- route completion at frame 17,700.

Mesen whole-address ownership result:

- 220,254,570 S-CPU instructions;
- 15,879 unique S-CPU instruction addresses;
- 15,879/15,879 owned by the 102,236-address closed static inventory;
- zero missing S-CPU addresses;
- 77,572,396 S-SMP instructions;
- 908 unique S-SMP instruction addresses;
- 908/908 owned by the 980-address finite Full Static audio lookup;
- zero missing S-SMP addresses.

The paired static-core route reached frame 17,700 without a frontier or failure:

- 220,249,197 S-CPU instructions (5,373 below Mesen, approximately 0.0024%);
- 77,577,301 S-SMP/AOT instructions (4,905 above Mesen, approximately 0.0063%);
- Full Static audio master clock exactly synchronized with the core;
- zero audio AOT failures and zero code barriers;
- valid live-map render with the tutorial panel dismissed and unit movement;
- final static frame hash 59591081225C93AF.

After adding the maintained route and generator, SOURCE-PROVENANCE.json was
intentionally regenerated (550 tracked files, 280 compact AOT shards). The full
Release regression suite passed 52/52. A clean regeneration of the 17,700-frame
Mesen comparator was byte-identical, SHA-256
BA0904A228A1E628E89DA5AE1F88B1CBE098DE575199D264DF1A8BF003E40EEF.

The small instruction-count differences are expected scheduler/input-edge
placement differences and did not produce a state-class, rendered-route or
ownership divergence. The two known Mesen power-on WRAM warnings at $7E0100 and
$7E0101 recurred and remain comparison points, not missing-code evidence.

This run confirms the observed cold-boot-to-gameplay execution is statically
owned. It does not prove unvisited systems complete; runtime trace absence is
never used as an unreachability proof.

Audit artifacts
---------------

Runtime logs are kept outside production source under the isolated Audit folder:

- mesen-v35-coldboot.txt
- mesen-long-candidates.txt
- mesen-static-coverage.txt
- mesen-static-audio-coverage.txt
- mesen-ppu-domain.txt
- headless-idle-60m.txt
- mesen-gameplay-coverage-certified-final.txt
- static-gameplay-route-certified-exact.txt
- static-gameplay-final.ppm / static-gameplay-final.png
- civilization-mesen-gameplay-coverage-certified-final.lua
- ctest-baseline.txt

The supplied MesenCE-2.2.1-SNES-Headless-Oracle-V02.zip was also inspected. It is
a richer Linux oracle with CDL, MMIO, audio, access, trace, checkpoint, and input
schedule commands plus source. Its archive SHA-256 is
b8a96ca1b934cd9247d43122a33075f1a5674eef68c608e2876607b8b8e06c27.
The local Ubuntu WSL installation cannot start because its ext4.vhdx is missing,
so no Linux-oracle result is claimed in this audit. The pinned Windows MesenCE
binary supplied all executable oracle results above.
