OpenTPW

Review ORACLE-V: PowerPC differential oracle (16bb38e)#

October 10, 2026. Independent review of 16bb38e (base c6c19ea): the user-mode PowerPC interpreter tools/ppc-analysis/oracle/, its targets, the C# bridge and docs/reverse/ORACLE.md. Merge checks against fork main 8a000d8.

Method:

Witness: tools/ppc-analysis/lanes/review/test_oracle_v1.py. It pins inputs, decoded fields and results only. No original bytes or listings are pinned.

Verdict: ACCEPT-WITH-FIXES#

Findings#

OV-1 (medium, docs/reverse/ORACLE.md §5 F1/F3): the writers are traced, and they refute both "open readings" of each finding.

F1 writer: the ride build 0xda874 stores +46 = 0 (0xda8f0). The fragment 0xdab6c..0xdacbc then ORs in one bit per boolean of the type record (r28 = 0xdc320 → 0x118018 lookup). The economy lane's schema.py names each record field:

Record offsetFieldRide +46 bit
+244UsageInfo.ProvidesRelief0x1
+252UsageInfo.ChillsYouOut0x2
+60Info.IsChoosable0x4
+64Info.HasQueue0x8
+240UsageInfo.ProvidesSecurity0x10
+260UsageInfo.RideHandlesSprite0x20
+248UsageInfo.HoldsLitter0x40
+272UsageInfo.IsFireworks0x80
+72Info.RunsContinuously0x100

The witness runs the fragment and confirms every bit. The other sth +46 sites are the save byte swap 0x9c7fc (it preserves the bits) and unrelated structs.

So bit 0x8 is Info.HasQueue, not inverted and not "no queue path". 0xdcb74 returns 100 for objects without HasQueue and the QWTC formula for HasQueue rides. The formula path also asserts "No queue constant entered in SAM file" when QWTC ≤ 0, which fits rides that carry a QWTC.

Example: Belly Bounce (QWTC 130, CAP 5, DUR 30, G = 1) gets limit 21, not 100. The witness pins this.

Fix in QUEUE-I:

F3 writer: data:0x84b2c has one TOC slot (−27980). The only code that writes through it is 0x84ea4, the line tool:

  1. It stores 0 at entry.

  2. For each intermediate cell it calls 0x80c50 with the word still 0.

  3. It stores 1 just before the final cell's 0x80c50 call.

  4. It stores 0 again on every exit.

The other users only read the word (0x80c50, 0x84154, 0x8408c). The witness runs 0x84ea4 on four drags with the calls stubbed. The word is [0, …, 0, 1] per placed cell and 0 afterwards.

PATH-plan's name "last-cell flag" is therefore right. Rule 7 has the wrong polarity: queue over path is allowed on every cell except the last cell of a drag.

Fix:

OV-2 (medium-low, oracle/harness.py:47-52): a stale shell variable switches the oracle on. bin_root() reads OPENTPW_MAC_BIN first. run_evidence_checks.py neither sets nor strips it: FIXTURE_VARIABLES has only OPENTPW_PPC_BIN_ROOT. With OPENTPW_MAC_BIN exported and no --mac-bin, the runner reported oracle: 46 ran, 0 skipped, C# bridge included.

That breaks the runner's contract that a stale shell variable cannot change the result. Fix one of these:

OV-3 (medium, oracle/bridge.py:20-73, test_oracle.py:93-101): an unusable SDK fails the plan pins too. bridge.get() accepts any dotnet it finds. The bridge targets net10.0 under global.json 10.0.401.

With a net8-only SDK (OPENTPW_DOTNET=~/.local/share/opentpw-dotnet/dotnet, or a PATH dotnet on CI or Windows), Bridge.build() raises RuntimeError inside Oracle.setUpClass. Every binary-vs-plan test then errors, not only the C# sides.

Two related problems:

Fixes:

OV-4 (low-medium, oracle/bridge.py:40-51): the cache digest misses inputs. _source_digest hashes source/OpenTPW, source/OpenTPW.Files, oracle/dotnet and EconomyTestData.cs. OpenTPW.csproj also references OpenTPW.Common, OpenTPW.ModKit and OpenTPW.Online. Directory.Build.* and global.json are not hashed either.

A change that touches only those inputs reuses a stale bridge, so "C# on this checkout" would compare old code. Fix:

OV-5 (low, oracle/targets.py:86-91): run_binary turns every Unsupported into UNDEFINED. That covers sc, tw and any unmodelled opcode. The run still stops, so the policy holds. But an interpreter gap in a future target would become a counted value instead of a hard error.

Today only det-rse-rand (bound −1 → divw by 0) relies on this. Fix: raise a dedicated Undefined(Unsupported) for architecturally undefined results only (divw, divwu by 0, INT_MIN / −1), and catch only that.

OV-6 (low, oracle/ppc32.py:151-152, 179, 194, 784): floating-point nits. No current target reaches them: none changes FPSCR[RN], and no target feeds two NaNs to a multiply-add.

Both deviations are expected failures in the witness.

OV-7 (low, docs, ORACLE.md §5 F7 table vs targets.coast_step_plan): the reference reproduces the binary only because the previous force and bank are always zero. ORACLE.md labels +812 as "GForceSickness × |ΔF|₁" and +832 as "BankExcitement × |Δbank|". The binary does subtract the previous vector data:0x57784 and the previous bank data:0x57780 (fsub in double, then fabs/frsp).

The reference uses |F|₁ and |bank|, and the inputs write zeros to both previous values. This is faithful to the game. COAST-plan says they are cleared at reset and never written afterwards. A TOC scan agrees: only 0x4154c/0x41568 (reset) and the step read those slots. The witness pins this.

A probe with nonzero previous values gave:

ReferenceMismatches
plan-stale-fz309 / 309
A Δ-aware reference0 / 309

Say in §4/§5 that the target relies on previous = 0, or add the Δ-aware reading. Then a later writer of those words cannot hide behind the pin.

OV-8 (nit, oracle/ppc32.py:384-403): a branch to a fragment's stop address must lie inside allowed. _transfer validates the target before the loop tests stop. RAND reaches its stop by fall-through and is unaffected. Either document this or check stop in _transfer.

OV-9 (info): coverage. The target pins alone do not catch these interpreter mutations:

test_ppc32.py catches all of them. It misses only these: SO stickiness, fsel with a NaN operand, stfs bit selection of a non-single double, a fmadds double-rounding tie and the NaN operand order. test_oracle_v1.py covers the first four and pins the NaN order as OV-6.

The mutation checks in test_oracle.py are meaningful:

The unbounce inputs never have start > now (negative elapsed). The C-remainder sign path is therefore not exercised. That is harmless while start ≤ now holds in the game.

F1–F8#

FindingRe-derivedResult
F1 queue limit 0xdcb740xdcba4 lhz +46, rlwinm. bit 28, bf eq → formula at 0xdcbb8; clear bit → li 100Confirmed. Writer: bit 0x8 = Info.HasQueue (OV-1). Correct fix: 100 when not HasQueue
F2 saturationnot re-derived; the csharp-flag-clear run reproduces 6/515as reported
F3 CanChangeCellType 0x8408c0x84124..0x84148: new 3, old 1, word via TOC −27980; == 0 → allowConfirmed. Writer 0x84ea4: 1 only on the drag's last cell. Correct fix: !lastCell
F4 SetCellType boundariesnot re-derivedas reported (2/511)
F5 UNBOUNCE 0xae020cmpw deadline, now; bf lt (strict); /1000 and /200 by multiply-high, add. must be 0Confirmed. C# TakeExpired (Until <= now, no window) differs
F6 smoothing0xe6b9c fmadds; 0xe6bbc mulli 99, sth u16, mulhwu/srwi /100Confirmed
F7 coaster step 0x415b4single caller 0x3ffa8. f0 = last fmuls stored to sample+40. Nothing writes f0 in 0x3ff94..0x3ffa4, and the step defines f0 only on the inverted pathConfirmed (and see OV-7)
F8 coaster final 0x419000x419d0/0x419d8 rlwinm. bits 25/24 (0x40/0x80), each bt eq skips the incrementConfirmed: counts sections with both bits

Interpreter (spot checks, all pass)#

Sandbox#

Every escape stops the run:

Imports resolve to unmapped trap vectors. Only SimThemePark.data is read, the PC executable is never touched, and only stdlib is used. Building the bridge restores NuGet packages that the project already has; on a cold cache that restore needs the network. No original code runs while it does.

Git hygiene, tests and merge#

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