OpenTPW

Review DET-V: determinism research and world seed (471e4bb, d1813eb)#

October 10, 2026. Independent review of the stack on fork main efc090d: 471e4bb (research: docs/reverse/DET-plan.md, tools/ppc-analysis/lanes/det/) and d1813eb ("Make park runs reproducible from one explicit world seed"). The M3 gate commit f6ad99f is not on main. It was merged into scratch clones to check the integration. No original instruction was executed. Evidence is static decoding of the identified Feral Mac PEF (SimThemePark.data, SHA-256 04809cd4…5e295f5) and OpenTPW builds and tests in scratch clones under /tmp. Claims are bounded to this Mac build, to .NET 10 on one arm64 Mac, and to the code at d1813eb.

Merge blockers#

None for d1813eb on efc090d. git merge-tree --write-tree efc090d d1813eb is clean. Build, tests, register, evidence runner, CRLF and whitespace all pass (see Numbers).

Integration with f6ad99f (whichever lands second):

Verdicts#

CheckVerdict
1a. Four DET-plan claims decoded independentlyConfirmed (LCG + abs, RAND call site, 31 ms / &7 / cap 3, reseed 0xe79b8, two scans)
1b. "only"/scan claims labelled boundedConfirmed, one exception (N1: "the one simulation-relevant path")
1c. The 8 lane mutation tests biteConfirmed: each fails at its own site and reports the binary's true value; a 253-point sweep finds one dead table field (N3)
2. Remaining process-wide or unseeded simulation stateNo simulation leak found in the folders reviewed. One hash-scope defect (F1). The guard misses several forms (F3)
2b. Guard scans the right folders; catches a reintroduced new Random()Partly: catches new Random() and static int next…; misses target-typed new(), Level.Objects.cs and others (F3)
3. Default seed reproduces previous outcomesConfirmed for every previously seeded stream (gate hashes equal before/after); vacuous for formerly unseeded scripts
4. Save/loadRound-trip and old saves confirmed; the mid-run test is weaker than stated (F2: a no-op guest or script restore survives)
5. Hash fields, stability, orderingConfirmed for the headless sources; Level.ComputeStateHash includes a wall-clock-driven sound seed (F1); some missing fields are not listed (N5)
6. Merge readinessClean on efc090d; with f6ad99f see B1/B2

1. Research (471e4bb)#

1a. Independent decode#

tools/ppc-analysis/lanes/review/test_det_v1.py decodes the instruction words with its own field split. It does not import det_evidence.py; it uses only pef.py to load the container. Run with OPENTPW_PPC_BIN_ROOT: 11/11 pass. Without it: 4 run, 7 skip.

1b. Bounded language#

The plan defines scan as one instruction form ("only among sites of that form … never a claim about the only runtime route"). The "only"/"exactly" claims in §2.2/§2.3 sit under that label: address takers, one direct coaster call, one seed string, no ANSI multiplier, and no direct RNG call in the loop body.

1c. Mutation tests#

All 8 lane mutation tests fail with a PEFError at the mutated site, and the message shows the binary's true value. Examples: code:0x1c22e0: unexpected interpreted value (0, 3, 31), world RNG increment: unexpected interpreted value 1013904223, bounded scan world_rng_direct_calls: unexpected interpreted value 142. test_det_v1.LaneMutationsBite asserts those messages, so a mutation that trips an unrelated check would fail this review test. A wider sweep bumped every scalar in the 19 expectation tables, 253 mutations in all. 232 raise. 20 only change the output OWN_STATE_GENERATORS table: it is descriptive, and its facts are pinned by literal checks elsewhere. N3: one field, CLIB_RAND['code'] = 0x1e78c, is never read.

2. Implementation (d1813eb): remaining nondeterminism#

Searched source/OpenTPW (VM, Economy, World and its subfolders, Audio, Client/GameFlow and, after the merge, Client/M3Gate), OpenTPW.Common and OpenTPW.Files. The search covered Random, Random.Shared, Environment.TickCount, DateTime.Now, Stopwatch, Guid, GetHashCode, HashCode, Parallel/Task.Run/threads, Interlocked, mutable statics, static caches, Dictionary/HashSet iteration and libm calls.

Not simulation leaks:

Findings:

Checked and correct: the nextAttractionId static is gone. Ids now start at 1 per RideScriptWorld, and the prototype ride in visit mode joins the park world after the objects, so its id (N+1) is unchanged. Unseeded VMs draw a SplitMix64 seed from their world. Child seeds still come from the parent Random. GameAudio.EnterPark reseeds per park. The M3 gate after the merge constructs new RideScriptWorld() per run, with seed 0, which equals the default ScriptStream.

3. Default seed reproduces previous outcomes#

By construction, the default seed gives guests 0x5450574775657374, economy 1, object script key 0 (seeds 1, 2, 3, …) and script stream 0. These are the previous fixed values (DefaultWorldSeedKeepsThePreviousStreamSeeds). No existing test pins a numeric outcome of those seeds, so the evidence is the M3 gate. Results are 30 simulated minutes, jungle, default seed, f6ad99f merged into each base, two separate processes each:

Scratch mergeProcessRun-1 guest hashRun-2 guest hash (same process)Gate hash (both runs)Totals
efc090d + f6ad99f (before)1634BC7756C8C632694E148DBB92A1650B046FADB47BE93F313 pass, 2 fail, 1 unresolved
efc090d + f6ad99f (before)2634BC7756C8C632694E148DBB92A1650B046FADB47BE93F313 / 2 / 1
d1813eb + f6ad99f (after)1634BC7756C8C6326634BC7756C8C6326B046FADB47BE93F314 pass, 1 fail, 1 unresolved
d1813eb + f6ad99f (after)2634BC7756C8C6326634BC7756C8C6326B046FADB47BE93F314 / 1 / 1

The guest hash and gate hash are identical before and after d1813eb, and they equal the documented baseline. A comparison of the JSON reports shows that 15 of the 16 rows have the same verdict, evidence and first-violation tick before and after. Each side's two processes produce identical reports. The only row that changes is determinism.same-seed, from FAIL to PASS. Scripts that had no seed used new Random() before, so "reproduces" has no prior outcome for them (PrototypeRide in sandbox/visit mode, Ride).

4. Save and load#

5. Hash#

6. Notes for QUEUE-I (merging after d1813eb)#

QUEUE-I adds queue cells and positions and draws a sideways offset from the guests' RNG. When it lands after d1813eb:

  1. Draw only from GuestSimulation's random. The draws are then saved (WorldRandomState.GuestRandom) and hashed automatically. If QUEUE-I needs a stream of its own, derive it from WorldSeed (new key), add it to WorldRandomState, ParkSaveFile.WorldData and WorldStateHash, and bump SchemaVersion (this is the commit's Directive).

  2. Add every new per-guest or per-queue field to GuestSimulation.AddCanonicalState / RideVisitorBridge.AddCanonicalState by hand. The lists are explicit, so a missing field is silently left out of the hash. Bump WorldStateHash.SchemaVersion when the field list changes.

  3. Expect HashOfAFixedRunIsTheSameInEveryProcess (0x86B5046D497B900C) to change, because its synthetic park queues guests at a shop. Re-pin it deliberately and record why. The M3 gate's guest and gate hashes will change too; update M3-GATE.md's baseline.

  4. Iterate queue cells in a defined order: list order, or sorted. Do not rely on HashSet order of value tuples.

  5. Queue positions are not saved (DET-016). If QUEUE-I adds state that must survive a load, extend DET-016's wording.

  6. New files under World/Guests are covered by the source guard; elsewhere they are not (F3).

Numbers#

SDK 10 (/Users/sander/.local/share/opentpw-dotnet10/dotnet), Release, scratch clones, OPENTPW_GAME_PATH = the Theme Park World install for "with assets".

TreeBuildOpenTPW.Tests without assetsWith assets
efc090d (before)0 errors864 / 240 / 01033 / 71 / 0
d1813eb0 errors873 / 241 / 0 (author: same)1043 / 71 / 0 (author: same)
d1813eb + f6ad99f (B1 resolved as above)0 errors875 / 242 / 01046 / 71 / 0

Pass / skip / fail. Other checks on d1813eb unless noted:

CheckResult
git merge-tree --write-tree efc090d d1813ebclean (tree 4503195)
git merge-tree --write-tree f6ad99f d1813ebconflicts in tools/fidelity_register.py, docs/FIDELITY-REGISTER.md (B1)
fidelity_register.py --check146 IDs (d1813eb); 148 after B1 on the f6ad99f merge; 142 on efc090d + f6ad99f
test_fidelity_register.py8 / 8
run_evidence_checks.py --mac-bin … --dotnet <net8 SDK>OK: 10 Python suites, 564 tests (49 skipped) on d1813eb; 575 with this review's test (review lane 220 ran, 19 skipped)
lanes/det with OPENTPW_PPC_BIN_ROOT33 / 33
test_det_v1.py11 / 11 with the PEFs; 4 pass, 7 skip without
--m3-gate --minutes 30see §3 (two processes per side; 14 / 1 / 1 after)
Pinned 0x86B5046D497B900Creproduced in every test process of this review (arm64)
git diff efc090d d1813eb --stat vs --ignore-cr-at-eol --statidentical (28 files, +2159 / −55)
git diff --check efc090d d1813ebclean
C# mutation runs (scratch clone, DeterminismTests 9 tests)baseline 9/9; guard catches 2 of 6 forms (F3); restore no-ops for guests and scripts survive (F2); save-field swap, hash field drop and a static attraction counter are caught

Not tested: Windows/Linux hosts; x64 (the local x64 SDK has only net8); the interactive game with an audio device (F1 is from reading the code); Level.SavePark/LoadPark end to end (they need a GPU-backed Level).

Nothing from the game data or binaries is committed. Scratch work used git clone --shared copies under /tmp. Four temporary git worktree add entries were created at the start by mistake; they were removed and pruned before any build ran. git merge-tree --write-tree wrote unreferenced objects to the shared object store. No refs were created.

Round 2: fixes d620fb7 and the merge onto main 8a88379#

October 10, 2026. Review of the rebased stack b27babc → 89f2db9 → e4b256c (this review's round 1) → d620fb7 (fixes) on main 12992e8, and of its merge onto the current main 8a88379 (the M3 gate evaluator). Scratch clones under /private/tmp (git clone --shared; no worktrees). SDK 10 at /Users/sander/.local/share/opentpw-dotnet10/dotnet, Release, built and run from the non-symlinked /private/tmp path. Claims are bounded to .NET 10 on one arm64 Mac and to the code named. Nothing from the original was executed.

Round 2 merge blockers#

None. d620fb7 merges onto 8a88379 with the two expected conflicts (round 1's B1) and needs the doc updates of round 1's B2. With the resolution below, the build, both test runs, the register, the evidence runner, the gate, CRLF and whitespace all pass. One correction to the author's Directive: the run-2 raw guest hash on 8a88379 is 00E874A92846742F, not 634BC7756C8C6326 (that value belonged to the earlier gate base ea09cda), and the totals are 13 / 2 / 1, not 14 / 1 / 1, because main's gate already had 12 / 3 / 1.

Exact resolution for the merge onto 8a88379#

  1. git merge --no-ff d620fb7 (or the review head on top of it) on 8a88379. Conflicts: tools/fidelity_register.py, docs/FIDELITY-REGISTER.md. Every other file auto-merges (Level.Objects.cs and ParkObjects.cs included).

  2. tools/fidelity_register.py REGISTERS: keep both lines, DET then GATE: "DET": "source/OpenTPW/World/DeterminismApproximations.cs", "GATE": "source/OpenTPW/Client/M3GateApproximations.cs",. In render(), change from the seven configured C# registers to from the eight configured C# registers (git keeps "seven" from both sides).

  3. docs/FIDELITY-REGISTER.md: take either side, then python3 tools/fidelity_register.py --write and --check: 157 unresolved unique APPROX IDs (173 APPROX, 69 EXT, 70 DATA, 81 BIN; DET 6, GATE 2).

  4. docs/M3-GATE.md:

    • "Hashes" paragraph: the attraction ids are allocated per park by the park's RideScriptWorld, so a second scenario gets the same ids (4 5 6 in both runs), instead of "a process-wide counter in OriginalObjectRuntime … (run 1: 4 5 6; run 2: 10 11 12)".

    • Baseline row: | determinism.same-seed | PASS | raw guest hash matches in-process (00E874A92846742F both runs; attraction ids 4 5 6 in both, allocated per park); gate hash matches (C4D8D348D84FF042); no divergent minute |.

    • Totals: Totals: 13 pass, 2 fail, 1 unresolved; **exit code 1**. The --no-determinism sentence stays (12 / 2 / 2, exit 1, re-run).

    • "Which gameplay area the failures point at": rewrite the determinism bullet as resolved (it failed while nextAttractionId was static; run 2 had ids 10 11 12 and raw hash F9AB11FDA4D90B0F; ids are now per park).

  5. docs/DETERMINISM.md "For the M3 gate": drop ", not on main yet" and say the row passes.

  6. source/OpenTPW/Client/M3Gate.cs ComputeGateHash summary: "(the bridge ids come from a process-wide counter)" is stale; say the ids are allocated per park and the placement index only keeps the gate hash independent of their allocation. Comment only.

test_det_v2.MergedGateDocs checks steps 2, 4 (row and totals), 5 and 6 when docs/M3-GATE.md is present.

Round 2 verdicts#

CheckVerdict
F1 sound seed out of the hashFixed. WorldStateSources has no sound field, SchemaVersion is 2, ParkWorldStreams.ComputeStateHash passes no sound. Mutation "sound seed XORed back into the hash" fails SoundDrawsDoNotChangeTheCanonicalHash
F2 save/load tests biteFixed. Each mutation below fails at least one test; a LoadPark that skips the stream restore fails only the asset-gated test, as the author states
F3 guardFixed for every round-1 form (target-typed new(), Level.Objects.cs, static counters of any width, GetHashCode/HashCode). Inserted into real scanned files, each fails the guard. New known gaps, none present in the code today: N1
Presentation exclusion listHides no simulation code. In the 11 excluded files the guard finds only Advisor.cs new AdvisorMouth( new Random() ) (mouth mesh only; BIN 0x10007434 uses rand() there) and four camera tuning properties in LobbyCameraMode.cs/ParkCameraMode.cs. None of them names RideScriptWorld, WorldSeed, GuestSimulation or ParkWorldStreams
Rebase resolutions (89f2db9 vs d1813eb, git range-diff)Both sides kept. Level(…, ParkStartKind start, WorldSeed? seed) passes start and Seed to ParkEconomyRuntime.ForOriginalLevel( OriginalPark, start, Seed ); ForOriginalLevel keeps main's ParkStart.Resolve/ImportShippedSave/SeedResearcherStandIn flow and adds only the economy seed; Load keeps main's mode check and ForwardEvent and returns the world streams; GameFlow keeps start: and StartKind = level.Park?.Start.Kind and adds the sound seed to EnterPark. b27babc and e4b256c are identical to 471e4bb and 68e80d2
Pinned hash change in 89f2db9Justified, reproduced. 89f2db9 with the SeedResearcherStandIn key left out of the economy digest's canonical JSON gives exactly 0x86B5046D497B900C. d620fb7 with schema 1 and the two empty sound fields restored gives exactly 0xB55E94284EBFE91B. So the chain old → 89f2db9 → d620fb7 has no other cause
ParkWorldStreams extractionBehaviour-preserving. Capture, restore, save and load bodies are the old Level bodies with Objects.ScriptWorld → Scripts and GameAudio.Events → Sound; Level.Streams reads both at call time as before. The only intended change is the hash (F1). Level.SavePark/LoadPark still have no caller outside tests
Merge onto 8a88379Merge-ready with the resolution above
--m3-gate on the merge13 pass / 2 fail / 1 unresolved, exit 1, twice; reports identical apart from wallSeconds. Every row except determinism.same-seed has the same verdict and evidence as main's run on 8a88379 (12 / 3 / 1, gate hash C4D8D348D84FF042, also run twice here)

C# mutations (fix head, rebuilt each time; DeterminismTests + DeterminismAssetTests)#

MutationWithout assetsWith assets
guest restore no-op (ParkWorldStreams)fails LoadRestoresEveryStream…+ ParkSaveAndLoadThroughTheLevelPath…
script restore no-opfails LoadRestores…, SaveAndLoadMidRun…+ level-path test
sound reseed no-opfails LoadRestores…+ level-path test
LoadPark skips the stream restorepassesfails level-path test
sound seed back in the hashfails SoundDrawsDoNotChange…same
capture takes the sound seed from WorldSeedfails LoadRestores…+ level-path test
System.Random r = new(); in Level.Objects.csfails guardsame
private static long counter; in WorldSeed.csfails guardsame
s.GetHashCode() in ParkWorldStreams.csfails guardsame
public static int Next { get; set; } in Level.csfails guardsame

Baseline without mutation: 12 pass / 2 skip without assets, 14 / 0 with.

N1. Guard forms still not caught (not blocking)#

ForbiddenInSimulation at d620fb7 does not match: a static Random field, seeded or not, readonly or not (one stream shared by every park in the process); mutable static collections and arrays (static List<int>, static int[]); static enum or struct fields (static GameSpeed speed;); any line that contains the word readonly elsewhere, e.g. in a trailing comment; RandomNumberGenerator; DateTime.Today. A search of the scanned files at d620fb7 finds none of these in use (the only static members are get-only or readonly tables, and the only Guid.NewGuid is ParkSaveFile's temporary file name). DETERMINISM.md lists only Guid.NewGuid and Parallel as not forbidden. Fix when convenient: forbid static (readonly )?(System\.)?Random\b, widen the static-field rule to any non-readonly static field except bool flags (or list allowed types), strip // comments before matching, and list the remaining gaps in DETERMINISM.md. test_det_v2.GuardRound2.test_known_gaps_after_round2 pins the current behaviour so the fix shows up as a test change.

Round 2 numbers#

TreeOpenTPW.Tests without assetsWith OPENTPW_GAME_PATH
d620fb7925 / 245 / 0 (author: same)1099 / 71 / 0 (author: same)
main 8a88379915 / 244 / 01088 / 71 / 0
merge 8a88379 + d620fb7 (resolved as above)927 / 246 / 01102 / 71 / 0

Pass / skip / fail. Build of OpenTPW.sln: 0 errors on all three trees.

Check (merge unless noted)Result
fidelity_register.py --write / --check157 IDs; test_fidelity_register.py OK
run_evidence_checks.py --mac-bin … --dotnet <net8 SDK>OK: 11 Python suites, 758 tests, 106 skipped (includes test_det_v2.py)
test_det_v1.py with OPENTPW_PPC_BIN_ROOT (d620fb7 + this review)13 / 13
test_det_v2.py7 / 7 on the merge; 5 pass, 2 skip (no M3 gate) on d620fb7. Mutations: a Random r = new() in excluded Sky.cs, the gate row back to FAIL, and SchemaVersion = 1 each fail it
--m3-gate (30 min, two processes each)merge 13 / 2 / 1 exit 1; main 12 / 3 / 1 exit 1; --no-determinism on the merge 12 / 2 / 2
git diff --check 8a88379 (merge)clean
git diff --stat vs --ignore-cr-at-eol --stat against 8a88379identical (34 files, +3246 / −68, including this review's test); no file's CR count changed

Not tested: Windows/Linux and x64 hashes; a real audio device; Level.SavePark/LoadPark on a constructed Level (needs a renderer; the one-line delegation is read, and ParkWorldStreams is tested); Client/ code for unseeded randomness (not scanned by the guard).

Source: docs/reverse/REVIEW-DET.md in the project repository.