OpenTPW

Review PATH-V: the path builder on the shared cell map (d323398, d21fb4a)#

October 10, 2026. Independent review of the path stack on 952ab0f (fork main 5ec2622 + queue integration 025d410 + QUEUE-FIX; QUEUE-V2 re-reviews that base): d323398 (PATH-R research, docs/reverse/PATH-plan.md and lanes/path/) and d21fb4a (PATH-I implementation).

All binary results are static. Nothing original was executed. Claims are bounded to the decoded sites, the scratch harnesses and the runs listed here. The scratch copies (git archive of 952ab0f, 5ec2622 and d21fb4a) live outside the repository. Witness: tools/ppc-analysis/lanes/review/test_path_v1.py. It has its own PEF reader and PowerPC field decoder. It does not import pef.py, ppcdis.py or path_evidence.py. Its code section equals the repository loader's byte for byte (2,014,896 bytes), and its data section equals the loader's first 339,516 bytes. TOC slots are read as raw data words. They hold data-section offsets, which matched the repository's relocation addends for every slot used.

Merge blockers#

B1. The front-end smoke test is red, inherited from the queue base. On d21fb4a, bash scripts/run.sh --front-end --smoke-test fails with "Escape opens the pause menu". The cause is not PATH:

Exact fix, in source/OpenTPW/FrontEnd/FrontEndSmokeTest.cs, step "closed state":

            Require( !secondObject!.IsOpen, "HUD door closes the selected original object" );
            Require( flow.Level!.CellTool.Mode == CellToolMode.Queue, "placing a HasQueue ride from the menu enters the queue tool" );
            flow.InjectedInput = UiInput.Key( UiKeys.Back );
        } );
        Wait( "queue tool closed", 3 );
        Do( "queue tool closed", () =>
        {
            Require( !flow.Level!.CellTool.IsActive && !flow.Hud!.Paused, "the first Back leaves the queue tool, not the park" );
            flow.InjectedInput = UiInput.Key( UiKeys.Back );
        } );
        Wait( "pause opens", 3 );

With exactly this change, the scratch copy of d21fb4a passes (342 frames). If QUEUE-V2 fixes it on the base first, use flow.Level!.QueueToolRide != null instead of the CellTool checks.

B2. The ending click commits a line that the original skips. The original commit decodes as follows: at 0x7105c..0x71084, when the snapped end equals the start and the vertex count is not 1, bf eq jumps to 0x71174. That skips the push and every LayLine call, including the raw-mode commit at 0x710c0.

CellBuildTool.Click still calls Writer.Commit( start, start ) in that case. The start cell is already a path, so the commit bumps its placement counter. Probe P3: the counter goes 0 → 1, and the world hash changes. This happens at the end of every path session. The native smoke shows it on (52, 19). The BIN:STP-PPC:0x10070F84 comment states the skip for the push but not for the LayLine. Exact fix, in source/OpenTPW/World/CellBuildTool.cs:

        var end = ParkPathBuilder.SnapEnd( start, cell );
        if ( end == start && vertices.Count != 1 )
        {
            End();
            return null;
        }
        var pushed = false;
        if ( vertices.Count < VertexCapacity )
        {
            vertices.Add( end );
            pushed = true;
        }
        var result = Writer.Commit( start, end );

Keep the rest. The original ignores the push result (0x7bcf4's return is not read), so !pushed may stay in the end test as an OpenTPW guard. Reword the BIN comment: "push and LayLine(mode, start, end) unless the end equals the start with more than one vertex stored (then nothing is laid); end the tool (start −1, SetMode(0)) when end == start". The refusal part belongs to S2.

Tested in scratch: PathBuilderTests, QueueTests and DeterminismTests pass (91/91, no re-pin, because the synthetic park never uses the tool). The native jungle smoke also passes (4323 frames). ParkHud ignores the null result: result is { Completed: false }.

No other blockers.

Verdicts#

CheckVerdict
1. Seven CanChangeCellType rulesConfirmed, rule by rule (section 1)
1. SetCellType: Costs.PathCell +1472 / QueueCell +1468, money test, free counter bumpConfirmed
1. LayLine strict axis, tie keeps XConfirmed (preview 0x6f4d8 and commit 0x71010 snap the same way). An unlisted skip exists (N1)
1. 1024-entry vertex stackConfirmed as the buffer size. The guard is count > 1024 (N2)
1. Commit / end-of-tool sequencePartly. B2 (the skip) and S2 (the end flag reads the ghost-clear LayLine(0x81), not the commit)
1. InitialPath = path + NoModify; ClearCell NoModify and no refundConfirmed (N3, N5 are nuances)
1. Unowned flag check, HasQueue → mode 3, hover help 441–445Not re-decoded. Taken as the author's high/medium claims. Unowned is never set in OpenTPW (PATH-007), so NotOwned is reachable only in tests
1. "Bounded" labelling where scans do not follow branchesConfirmed for §3.3 (validator), §5.5 (slope) and §6 (bulldozer route). PATH-009's reading of data:0x7de2d is weaker than stated (S3)
2. Ownership flip preserves guestsConfirmed. Raw hashes 0x3622300C23D95AB8 (cross, 92 admissions) and 0x17B0E01EDEB2D4FB (jungle Easymode, 108) reproduce on both 952ab0f and d21fb4a
2. Version counter explains the pin moveConfirmed (section 2)
3. Validation order, CODE8, money boundary, extend, NoModify, bounds, objects, PreviewConfirmed (section 3). CODE8 is refused, labelled PATH-008
4. Path tool enter/leave, queue tool via shared tool, Back/Escape, right clickConfirmed, with S1 (remove tool) and S5 (paused clicks)
4. "Level.Update ignores HUD-captured clicks" keeps placement flowsConfirmed for placement: the sandbox smoke, the jungle smoke and the front-end placement steps pass. The front-end smoke itself is red for B1
5. Determinism guard, register, CRLF, whitespace, as_posixConfirmed (section 5)
6. NumbersReproduced exactly (section 5)

1. Operands (independent decode)#

Binary in test_path_v1.py asserts each operand below. That class needs OPENTPW_MAC_BIN, and SimThemePark.data must have SHA-256 04809cd4…e295f5.

2. Ownership flip and the pin (scratch)#

BuildCross raw (seed 5, 7200 ticks)Jungle Easymode raw (seed 1)HashOfAFixedRun…
952ab0f (scratch class added)0x3622300C23D95AB8, 92 admissions0x17B0E01EDEB2D4FB, 1080xE67AA45A94F4B20C (passes)
d21fb4asamesame0x10A80C328A477CBE (passes)
d21fb4a, no cell-map digest, SchemaVersion = 40x2EB8B824C2984A88
… and GuestPathGrid.Version bumped only by Invalidate() (old meaning)0xE67AA45A94F4B20C = base pin

So the simulation is unchanged. The whole pin move is the schema bump, the cell-map digest and the value of seenGridVersion, which is hashed in GuestSimulation.AddCanonicalState and now counts every map write. The flow-field cache now follows ParkCellMap.Version, so it also drops on writes that skip Invalidate(). That is more correct, and no guest run changed.

3. Behaviour probes (scratch MSTest class on d21fb4a, not committed)#

ProbeResult
P1 money boundaryCash 3·20: preview and commit lay 3 cells, balance 0, OtherCosts 60. Cash 3·20 − 1: the preview stops at the third cell with NotEnoughMoney (pending line cost, §3.3)
P2 Preview side effects20 tool hovers, previews and validates: world hash D1F8AC5D58EF78D5 unchanged, Cells.Version 11 → 11, balance and OtherCosts unchanged
P3 ending clickCounter 0 → 1 on the start, hash changed (B2)
P4 orderWater with no money → Terrain; plus an object → Occupied; queue with an object → QueueCell; a queue end (code 8) → QueueCell (PATH-008); (−1, 0) and (16, 0) → OutsideTerrain
P5 off the edge(13,3) → (19,3) on a 16-wide grid builds 3 cells for $60 and stops at (16,3). The original would skip only outside 128 (N1)
P6 extendFrom an existing end: 4 built, 1 existing (counter +1, free), $80, tool continues. A click back onto existing path ends the tool, and Undo is then unavailable (PATH-002/003 behaviour)
P7 NoModify with 0x55 links and no neighboursRemoved (N3)

The author's tests cover the rest: the order with Unowned first, every refused type, NoModify with neighbours, no refund and the queue mode. I read them and they assert what their names say.

4. Findings to fix with or after the blockers#

Notes (plan accuracy, no code change needed now):

5. Builds, tests and checks#

Tools: .NET SDK 10.0.401 at /Users/sander/.local/share/opentpw-dotnet10 (non-symlinked), Release. libveldrid-spirv.dylib was copied into the ignored native/ folder and not committed.

Checkd21fb4aAuthor
OpenTPW.Tests, no assets975 passed / 250 skipped / 0 failed975/250/0
OpenTPW.Tests, OPENTPW_GAME_PATH1154 / 71 / 0 (12 min 26 s)1154/71/0
Native jungle smokepassed, 4329 frames; "laid 6 cells (52, 14) -> (52, 19) for $120 through ParkHud clicks"same
Native sandbox smokepassed, 1105 frames—
Native front-end smokefailed: "Escape opens the pause menu" (B1). With the B1 fix: passed, 342 frames. 952ab0f fails the same way; 5ec2622 passes (338 frames)not reported
Evidence runner (--mac-bin, --pc-data)OK: 13 Python suites, 832 tests, 108 skipped (before this witness)832 OK
--m3-gate (jungle, 30 min)13 pass / 2 fail (build.paths, build.queue) / 1 unresolved, exit 1. Unchanged as expected: the gate is not yet wired to the builder (GATE-UPD)—
fidelity_register.py --checkOK, 186 unresolved unique IDs (176 on 952ab0f + PATH-001..010), "ten configured C# registers"same
CRLFgit diff 952ab0f --stat and --ignore-cr-at-eol --stat are identical (23 files, +3082/−134). Game.cs and SandboxSmokeTest.cs stay CRLF—
Whitespacegit diff --check only flags the CR of those two CRLF files. No added line ends in a space or tab—
Python pathspath_evidence.py uses relative_to(REPO).as_posix()—
Determinism guardThe source-guard tests pass. They scan top-level World/*.cs, which holds the new files. New code has no Random, clock or GetHashCode. The HashSet/Dictionary uses are render-only lookups—
test_path_v1.py21 tests OK with OPENTPW_MAC_BIN; 11 run (10 binary skipped) without it. Evidence runner with the witness: OK, 853 tests, 118 skipped (the runner does not export OPENTPW_MAC_BIN, as for the earlier review witnesses)—

Round 2: the fixes on 267c420#

October 10, 2026. Re-review of 3d78a8a (ESC-FIX, PATH-011) and 267c420 (fixes for B2 and S1–S5), on top of the round-1 commit ea10b25. The same rules apply: static reading only, nothing original was executed, and every claim is bounded to the sites, scratch runs and checks listed here. Scratch copies (git archive of 267c420 and of the merge tree) live outside the repository. New witness: tools/ppc-analysis/lanes/review/test_path_v2.py. It reuses the round-1 witness's own PEF reader and decoder.

Merge-ready: yes. Every round-1 blocker and finding is fixed or answered. The notes below need no change before merge. The gate stack (39ccda4) conflicts in two files; the recipe is at the end of this section.

Verdicts#

FindingVerdictEvidence
B1 front-end smokeFixed by 3d78a8aNative front-end smoke passes, 342 frames, "Escape out of the queue tool". QueueToolRide is read through CellTool.Writer, which is the same check as the one proposed in round 1
B2 ending click lays a lineFixedClick returns null before the push and Commit when end == start and the count is not 1. Operands re-decoded (below). TheEndingClickLaysNothing passes. Mutation: restoring the commit and deleting every other assertion (IsNull, LastCommit, counter, version, balance) still fails, on the hash assertion alone (6101474226486134394 ≠ 18094232359882903757). The jungle smoke asserts the end counter and the state hash too
S1 remove toolFixedUpdateCellTool stands aside for IsRemovingObjects. Mutation: removing that guard fails the jungle smoke with "with the remove tool on, a park click is left to Level.RemoveAt". The extra HandleObjectClick reorder (remove before the cell tool) only differs when the remove tool and the cell tool are both on. Placement keeps working: the setters keep BuildEntry and IsRemovingObjects exclusive (ObjectBuildPanel.cs:41-44, :59-63; ParkHud.cs:361-364). All three smokes pass, including placement, sale, removal and the queue tool. The reorder itself has no test (N2-3)
S2 end flagFixed (relabelled)BIN comment, PATH-plan §4.3 and PATHS.md now say the flag is the ghost-clear LayLine(0x81). The refusal rule is APPROX:PATH-012
S3 PATH-009 citationsFixedParkPathBuilder.cs, the register text and PATH-plan §3.2/§10 cite 0x6f5f4, 0x71330 (mode 4 hover / click), 0x71cb8 (mode 59), and the clears at 0x70ca4, 0x71c94, 0x722ec. These match the round-1 decode, which re-ran here (test_free_byte_is_a_transient_tool_flag). The scan bound is stated
S4 queue ghostFixedEvery preview cell goes through check( x, y, built ), which is Level.CheckQueueCell → QueuePaths.CheckExtend with the pending cells plus CanSpendCell( Queue, pending ). BuildQueueCell runs the same check with no pending cells after RecomputeQueue, then TrySpendCell. Mutations, run with PathBuilderTests + QueueTests (81 tests): restoring the old preview fails the new test; so do ignoring pending cells in the length limit (25 ≠ 35), using the ride's back cell instead of the last pending one (two tests), and ignoring pending cells in CanSpendCell (3 ≠ 8). Removing pending.Contains survives (N2-1)
S5 paused clicksAuthor is right; my round-1 premise was wrongSince d21fb4a, ParkHud.Update sets overUi = … || Stack.Screens.Count > 1 and returns it. GameFlow stores that in Level.UiCapturesMouse, and Level.Update calls HandleObjectClick only when it is false. So an open pause menu already blocked the park click. Only the economy's speed pause lets tool clicks through, and that is now an explicit choice (APPROX:PATH-013, asserted by the sandbox part of the jungle smoke)
PATH-012 / PATH-013 honestyHonestBoth are APPROX entries with evidence-needed text, and neither claims a trace. PATH-012 could add that the flag is read only when end != start (0x7121c..0x71238, below); this changes no behaviour

Operands (independent decode, test_path_v2.py)#

Re-run of the round-1 probes#

Notes (no change needed for merge)#

Merge with the gate stack (GATE-FIX2 39ccda4, on d21fb4a)#

git merge-tree --write-tree 267c420 39ccda4 gives tree e757b694, with conflicts in exactly two files.

  1. source/OpenTPW/World/Level.Objects.cs. There are two hunks, both in the new static BuildQueueCell( grid, economy, ride, x, y, isBlocked, out message ).

    • Keep the gate's static helper and the instance wrapper.

    • Make the queue check static too:

      public QueueBuildResult CheckQueueCell( RideVisitorBridge ride, int x, int y, IReadOnlyList<(int X, int Y)> pending )
      {
          if ( IsReadOnlyVisit || Guests == null )
              return QueueBuildResult.Refused;
          return CheckQueueCell( Guests.Grid, Park?.Economy, ride, x, y, pending, IsQueueBlocked );
      }
      
      internal static QueueBuildResult CheckQueueCell( GuestPathGrid grid, ParkEconomy? economy, RideVisitorBridge ride, int x, int y, IReadOnlyList<(int X, int Y)> pending, Func<int, int, bool> isBlocked )
      {
          var check = QueuePaths.CheckExtend( grid, ride, x, y, pending, isBlocked );
          if ( check != QueueBuildResult.Ok )
              return check;
          if ( economy != null && !economy.CanSpendCell( CellPurchase.Queue, pending.Count ) )
              return QueueBuildResult.Refused;
          return QueueBuildResult.Ok;
      }
    • In the static BuildQueueCell, resolve the two hunks as:

      ride.RecomputeQueue( grid );
      var check = CheckQueueCell( grid, economy, ride, x, y, Array.Empty<(int X, int Y)>(), isBlocked );
      if ( check is not (QueueBuildResult.Ok or QueueBuildResult.Refused) )
      …
      if ( check == QueueBuildResult.Refused || (economy != null && economy.TrySpendCell( CellPurchase.Queue ) != ParkEconomy.PurchaseResult.Ok) )
    • Point the helper's <see cref="QueuePaths.CheckExtend"/> at CheckQueueCell.

    • The QueueTests source scan still holds: the instance CheckQueueCell comes before the static one, which calls CheckExtend, and RecomputeQueue → CheckQueueCell( → TrySpendCell stay in order.

  2. docs/FIDELITY-REGISTER.md. Only line numbers conflict. Take either side, then run python3 tools/fidelity_register.py --write. That gives 189: 186 + PATH-011..013, with GATE-002 → GATE-003 count-neutral. --check passes.

Tested on the resolved scratch tree: Release build, and OpenTPW.Tests without assets 978 / 250 / 0. The extra test is the gate's. Not run on the merged tree: the assets tests, the smokes and --m3-gate.

Builds, tests and checks (267c420)#

CheckResultAuthor
OpenTPW.Tests, no assets (SDK 10, Release)977 / 250 / 0977/250/0
OpenTPW.Tests, OPENTPW_GAME_PATH1156 / 71 / 0 (11 min 49 s)1156/71/0
Native front-end smokepassed, 342 frames342
Native sandbox smokepassed, 1108 frames1108
Native jungle smoke (--load-original-level jungle)passed, 4328 frames; "laid 6 cells (52, 14) -> (52, 19) for $120"4318 (frame counts vary run to run)
Evidence runner (--mac-bin, --pc-data)OK: 13 Python suites, 861 tests, 119 skipped. lanes/review ran 356 tests, 78 skipped. Includes test_path_v2.py (8 tests; its Binary class skips because the runner does not export OPENTPW_MAC_BIN)—
test_path_v2.py with OPENTPW_MAC_BIN11 tests OK—
fidelity_register.py --checkOK, 189189
CRLFgit diff d21fb4a --stat = --ignore-cr-at-eol --stat (16 files, +1093/−87)—
Whitespacegit diff d21fb4a --check empty; no added line ends in a space or tab—
libveldrid-spirv.dylibalready in the ignored native/osx-arm64/; copied into the scratch tree only—

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