Campaign OVERHAUL S3 chunk 1 fix round 1 (docs/research/2026-09-01-overhaul/
s3-walk-ownership-map.md §11.5), applied on top of 079483bb6 after the
three-lens review. G1-G10, each verified against source and (where the item
adds a pin) mutation-checked.
G1 — the flag-off integration test was vacuous: Collect_TranscriptFlagOff_
ProducesNoConsoleOutput drove ONE frame, and WalkOracleTrace.Parse
structurally discards the last (open) frame, so it passed whether or not
the flag gate worked. Now drives TWO frames and asserts BOTH that Parse
sees zero frames AND that no captured line starts with any of the ten
transcript-kind prefixes (F /P /LS/LC /SC /BLD /DI /DC /EC /OC ) — robust
to unrelated console noise from parallel test classes.
G2 — LC/SC computed LodCellId before testing the flag (~1,300 land-cell
turns/frame of division/modulo/checked-conversion work paid even when the
flag is off). Both OnLandCellTurn and the new OnSortCellTurn now guard the
LodCellId call itself, not just WalkTranscriptDump's internal check.
G3 — the flag-on round trip never exercised LC/SC/BLD (the T2 fixture's
stub 1x1 landscape has zero blocks). New
OutdoorRoot_TranscriptFlagOn_PrintsLandscapeThenLandCellThenSortCellThen
Building_InOrder drives RetailFrameWalk.DrawLandscape directly (the same
deterministic "CY-only" admission technique the existing outdoor LandCell
test uses) over a landscape with one block + one building, and asserts
LS < LC < SC < BLD by position, with the exact cell/building ids.
G4 — the parts/alpha-depth smoke tests asserted FL/PC (Flushes/
DrawCellsSamples) but never AM/PM (MeshAdds/PortalPolyDraws) for the
alpha-depth log, even though PD/DM were already asserted for the parts
log. Added the missing Assert.Contains for MeshAdds and PortalPolyDraws.
G5 — launch-options.md's side-effects column now states the flag off/on
costs explicitly ("one bool read per print site, nothing else" / "one
console line per walk turn, ≈600-800 lines per outdoor frame").
G6 — removed the "DI f4180108... no, a9b4013f" self-correction in
Oh_doorway_still_first_frame_diff's comment; added a one-line note on why
it and Oh_foundry_deep_... stay bespoke Facts rather than folding into the
Theory (no functional reason, just history).
G7 — SC printed from OnLandscapeCellTurn, which RetailFrameWalk.
DrawLandscape calls AFTER DrawBuilding — retail's own order is
LC -> SC -> BLD (terrace-edge.walk.log:2331-2333), not LC -> BLD -> SC.
Fixed by adding IWalkEventSink.OnSortCellTurn, fired at the DrawSortCell
entry point (same alwaysDrawObjects||cellInView gate, before DrawBuilding);
the driver moves its SC print there and OnLandscapeCellTurn no longer
prints one.
G8 — the trailing "OC <viewer land cell>" retail prints once per complete
outdoor frame is GameSky::Draw's weather branch calling
DrawObjCellForDummies(after_sky_cell) @0x005070da, not a walk turn.
RetailPViewPassExecutor.DrawLandscapeSliceLate now prints it at the point
it actually calls RenderWeather; PrintObjectCellTurn's doc, which denied
this line existed, is corrected. New
Oh_terrace_edge_outdoor_frame_ends_with_the_weather_ObjectCellTurn pins
this directly against the OH capture: every complete outdoor frame's last
event is an OC whose cell id equals that same frame's own P-line cell id.
G9 — "EC and OC counts are always exactly equal per pose" was false
(terrace-edge: 12 EC vs 16 OC, the extra 4 being G8's weather OC, which
has no EC counterpart). The visit-scoped/stamp-dedupe conclusion was
right; only the count claim needed fixing. Both doc sites corrected.
G10 — the conformance signature dropped LC/SC/EC/OC entirely, which is
how G7 shipped green: no test ever compared their placement. Recorder now
tracks LC/SC via the new OnLandCellTurn/OnSortCellTurn hooks and derives
EC/OC per DC from PView::DrawCells's own two reverse loops (shell
far-to-near, then object-list far-to-near) — a look-in flood's DC derives
them immediately, the interior root's OWN flood defers to
OnInteriorFloodDrawTurn (verified against cathedral-leak.walk.log:4,1328,
where the root DC's own EC/OC print last). WalkTraceReplayContext.
Signature8 applies the identical derivation to oracle frames and never
produces the trailing weather OC (G8's own dedicated pin covers that
separately, matching the spec's "exclude from the comparison, assert
separately" instruction). Used ONLY for the four OH-capture-rooted
conformance rows (the older FW0 fixtures predate the LC/SC/EC/OC
breakpoints and carry none of those lines).
Applying the eight-kind check surfaced a real, separate bug: WalkLandscape
DatBuilder never set WalkLandBlock.LandblockId, so every LC/SC token any
DAT-built world ever produced read landblockId=0 — latent because the old
four-kind signature filtered LC/SC out. Fixed (one field, test-fixture-
only, no production behavior change). With that fixed, three of the four
OH rows (terrace-edge, cathedral-arrival, foundry-deep) reproduce EXACTLY
at the eight-kind level. Oh_doorway_still_first_frame_diff still diverges
by one extra LC/SC pair (token index 165: replay draws LC:a9c90001|
SC:a9c90001 that retail never does) — a real WalkLandscape.CheckBlocks
visibility question at a ring-2/ring-3 LOD boundary, out of this round's
print-only scope, needing the retail oracle to resolve. Marked
[Trait("Status","KnownFailure")] with the exact position recorded in its
own doc comment, matching TowerAscent's existing pattern — the InstalledDat
lane now shows FOUR known failures (the pre-existing two #383 layout tests
+ TowerAscent, plus this new finding), not three; never weakened the pin
itself.
Mutation checks (all four restored after observing the failure):
- G1: forcing WalkTranscriptDump.Enabled true made
Collect_TranscriptFlagOff_ProducesNoConsoleOutput fail with
"Assert.DoesNotContain() Failure: Filter matched in collection ... Collection:
[\"DI 00000100\", \"DC pv=00000000 ov=1 n=2: 00000100 00000101\", \"LS\", ...]".
- G3: deleting PrintLandCell's Console.WriteLine made the new outdoor test
fail with "expected an LC line".
- G4: making MeshAddPattern unmatchable made all five
Alpha_depth_log_parses_with_nonempty_samples rows fail with
"Assert.Contains() Failure: Filter not matched in collection".
- G7/G10: moving OnSortCellTurn back after DrawBuilding made the
terrace-edge conformance row fail with "walk diverged from retail
(terrace-edge.walk)", first divergence exactly at its first building
(f518002e): expected ...SC:f518002e|BLD:f518002e..., actual
...BLD:f518002e|SC:f518002e....
Gates: hermetic lane 6,816/0 (baseline 6,814 + G3's new test + G8's new
test); InstalledDat lane 244/4 known failures (two pre-existing #383
layout tests + TowerAscent + the new Oh_doorway_still_first_frame_diff
finding, documented above).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
431 lines
20 KiB
C#
431 lines
20 KiB
C#
using AcDream.App.Tests.Rendering;
|
||
using AcDream.App.Rendering.Walk;
|
||
using DatReaderWriter;
|
||
using DatReaderWriter.Options;
|
||
|
||
namespace AcDream.App.Tests.Rendering.Walk;
|
||
|
||
/// <summary>
|
||
/// FW1's conformance gate, first slice: replay pose-stamped oracle
|
||
/// fixtures through the ported walk and require the identical event
|
||
/// sequence. The projection-light interior fixtures gate first
|
||
/// (docs/research/2026-08-30-fw-walk-oracle/README.md, posed round);
|
||
/// the outdoor/landscape fixtures join as the landscape world build
|
||
/// lands.
|
||
/// </summary>
|
||
[Trait("Lane", "InstalledDat")]
|
||
public sealed class WalkTraceConformanceTests
|
||
{
|
||
/// <summary>S3 chunk 1 fix round 1 (G10): besides the plain
|
||
/// <see cref="WalkEvent"/> list the four-kind
|
||
/// <see cref="WalkTraceReplayContext.Signature(IEnumerable{WalkEvent})"/>
|
||
/// still uses, also builds the full eight-kind token stream — LS/BLD/
|
||
/// DI/DC/LC/SC/EC/OC — AS each hook fires, for
|
||
/// <see cref="WalkTraceReplayContext.Signature8(IReadOnlyList{string})"/>.
|
||
/// <see cref="_lookIn"/> mirrors <c>WalkFrameDriver</c>'s own private
|
||
/// <c>_currentDcStage</c>: null until the frame's first
|
||
/// <see cref="WalkEventKind.DrawInside"/> (the interior root's own
|
||
/// flood defers its EC/OC to <see cref="OnInteriorFloodDrawTurn"/>),
|
||
/// flips true forever once a building's portal pass begins
|
||
/// (<see cref="OnBuildingTurn"/>) — see
|
||
/// <see cref="WalkTraceReplayContext.Signature8(WalkOracleFrame)"/>'s own
|
||
/// doc comment for why this never resets mid-frame.</summary>
|
||
private sealed class Recorder : IWalkEventSink
|
||
{
|
||
public readonly List<WalkEvent> Events = new();
|
||
public readonly List<string> Tokens = new();
|
||
|
||
private bool? _lookIn;
|
||
|
||
public void Emit(in WalkEvent walkEvent)
|
||
{
|
||
Events.Add(walkEvent);
|
||
switch (walkEvent.Kind)
|
||
{
|
||
case WalkEventKind.Landscape:
|
||
Tokens.Add("LS");
|
||
break;
|
||
case WalkEventKind.Building:
|
||
Tokens.Add($"BLD:{walkEvent.CellId:x8}");
|
||
break;
|
||
case WalkEventKind.DrawInside:
|
||
Tokens.Add($"DI:{walkEvent.CellId:x8}");
|
||
_lookIn = false;
|
||
break;
|
||
case WalkEventKind.DrawCells:
|
||
Tokens.Add(
|
||
$"DC:ov={walkEvent.OutsideViewCount}:"
|
||
+ string.Join(',', walkEvent.Cells.Select(c => c.ToString("x8"))));
|
||
// A look-in flood's DC draws its EC/OC immediately
|
||
// (RetailFrameWalk.HandleDrawCellsTurn calls
|
||
// EmitFloodTurns right here for WalkDrawStage.
|
||
// LookInStatic); the interior root's OWN flood (stage
|
||
// CellStatic, _lookIn still false) defers to
|
||
// OnInteriorFloodDrawTurn below — see that method.
|
||
if (_lookIn == true)
|
||
WalkTraceReplayContext.AppendFloodTurns(Tokens, walkEvent.Cells);
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void OnLandCellTurn(uint landblockId, int sideCellCount, int cellIndex)
|
||
=> Tokens.Add(
|
||
$"LC:{WalkTranscriptDump.LodCellId(landblockId, sideCellCount, cellIndex):x8}");
|
||
|
||
public void OnSortCellTurn(uint landblockId, int sideCellCount, int cellIndex)
|
||
=> Tokens.Add(
|
||
$"SC:{WalkTranscriptDump.LodCellId(landblockId, sideCellCount, cellIndex):x8}");
|
||
|
||
public void OnBuildingTurn(WalkBuilding building) => _lookIn = true;
|
||
|
||
public void OnInteriorFloodDrawTurn(IReadOnlyList<uint> cells, int outsideViewCount)
|
||
=> WalkTraceReplayContext.AppendFloodTurns(Tokens, cells);
|
||
}
|
||
|
||
private static DatCollection OpenDats()
|
||
{
|
||
string? datDir = CornerFloodReplayTests.ResolveDatDir();
|
||
if (datDir is null)
|
||
{
|
||
Assert.Fail("Lane=InstalledDat requires an installed retail DAT directory; see docs/release-gate.md.");
|
||
}
|
||
return new DatCollection(datDir!, DatAccessType.Read);
|
||
}
|
||
|
||
[Fact]
|
||
public void Street_outdoor_first_frame_diff()
|
||
{
|
||
// The first landscape-involving conformance case: diff-first (the
|
||
// assert prints both signatures on mismatch for adjudication).
|
||
IReadOnlyList<WalkOracleFrame> frames =
|
||
WalkOracleTrace.Load("posed/holtburg-street-outdoor");
|
||
Assert.NotEmpty(frames);
|
||
using DatCollection dats = OpenDats();
|
||
WalkOracleFrame frame = frames[1]; // frame 2: pose settled (marker timing)
|
||
Assert.NotNull(frame.Pose);
|
||
WalkLandscapeDatBuilder.BuiltWorld world =
|
||
WalkLandscapeDatBuilder.Build(dats, frame.Pose!.CellId, frame.Pose.Origin);
|
||
var ctx = new WalkTraceReplayContext(frame.Pose, world.Cells)
|
||
{
|
||
Buildings = world.Buildings,
|
||
};
|
||
var walk = new RetailFrameWalk();
|
||
var recorder = new Recorder();
|
||
|
||
walk.WalkFrame(frame.Pose.CellId, null, world.Landscape, ctx, recorder);
|
||
|
||
string expected = WalkTraceReplayContext.Signature(frame);
|
||
string actual = WalkTraceReplayContext.Signature(recorder.Events);
|
||
Assert.True(
|
||
expected == actual,
|
||
$"walk diverged from retail\nEXPECTED: {expected}\nACTUAL: {actual}");
|
||
}
|
||
|
||
[Fact]
|
||
public void Doorway_still_first_frame_diff()
|
||
{
|
||
// Interior flood adjudication: DI + DC(ov=2, n=3) + the landscape
|
||
// through two exit views — tests the flood depth in isolation from
|
||
// the building look-in machinery.
|
||
IReadOnlyList<WalkOracleFrame> frames =
|
||
WalkOracleTrace.Load("posed/holtburg-doorway-still");
|
||
Assert.NotEmpty(frames);
|
||
using DatCollection dats = OpenDats();
|
||
WalkOracleFrame frame = frames[1];
|
||
Assert.NotNull(frame.Pose);
|
||
WalkLandscapeDatBuilder.BuiltWorld world =
|
||
WalkLandscapeDatBuilder.Build(dats, frame.Pose!.CellId, frame.Pose.Origin);
|
||
var ctx = new WalkTraceReplayContext(frame.Pose, world.Cells)
|
||
{
|
||
Buildings = world.Buildings,
|
||
};
|
||
WalkCell camera = Assert.Contains(frame.Pose.CellId, world.Cells);
|
||
// Render::deg_mul is DYNAMIC (auto-tuned by frame load), and this
|
||
// capture ran right after the heavy terrace-edge capture with the
|
||
// multiplier depressed: at mul ≤ 0 the degrade thresholds sit at or
|
||
// below each level's ideal, so 001e (eff 29.3), 0026 (27.1), and
|
||
// 002f (43.4) all select the portless level 1 — retail's zero
|
||
// look-in floods. Every other fixture pins ≈ +0.99 (thresholds at
|
||
// max). The recon session's live dump read −0.99 under the same cdb
|
||
// load. Re-dump deg_mul per capture at the next retail session.
|
||
var walk = new RetailFrameWalk { DegradeMultiplier = 0f };
|
||
var recorder = new Recorder();
|
||
|
||
walk.WalkFrame(frame.Pose.CellId, camera, world.Landscape, ctx, recorder);
|
||
|
||
string expected = WalkTraceReplayContext.Signature(frame);
|
||
string actual = WalkTraceReplayContext.Signature(recorder.Events);
|
||
Assert.True(
|
||
expected == actual,
|
||
$"walk diverged from retail\nEXPECTED: {expected}\nACTUAL: {actual}");
|
||
}
|
||
|
||
/// <summary>
|
||
/// PINNED RED 2026-09-03 (S3 chunk 1 fix round 1, G10 — un-skip with the
|
||
/// fix): the eight-kind signature is the FIRST comparison ever run at
|
||
/// LC/SC placement/content against a DAT-built world for this fixture
|
||
/// (the old four-kind Signature filtered LC/SC out entirely — how the
|
||
/// G7 SC-ordering regression shipped green). One real divergence
|
||
/// survives after fixing the LandblockId=0 fixture bug this same round
|
||
/// uncovered (WalkLandscapeDatBuilder.cs — a genuinely separate,
|
||
/// already-fixed defect): at token index 165, the replay draws ONE
|
||
/// EXTRA land-cell pair retail never does —
|
||
/// <c>…SC:a8c90001|LC:a8c90001|SC:a8c90001|</c> retail jumps straight to
|
||
/// <c>LC:95c60001</c>; the replay inserts <c>LC:a9c90001|SC:a9c90001</c>
|
||
/// first. A single spurious block admission at a ring-2/ring-3 LOD
|
||
/// boundary near this pose — a real <c>WalkLandscape.CheckBlocks</c>
|
||
/// visibility question, not a print-site or ordering bug, and out of
|
||
/// this round's print-only scope (§11.4) — needs the retail oracle
|
||
/// (decomp/cdb) to resolve. terrace-edge/cathedral-arrival/foundry-deep
|
||
/// all reproduce EXACTLY at this same eight-kind level; only this row's
|
||
/// specific pose hits the boundary.
|
||
/// </summary>
|
||
[Fact]
|
||
[Trait("Status", "KnownFailure")]
|
||
public void Oh_doorway_still_first_frame_diff()
|
||
{
|
||
// S3 chunk 1 (§11.2 B3): the OH kit pose's own doorway-still capture
|
||
// — DI a9b4013f, DC(ov=2, n=3) per §6b. Mirrors
|
||
// Doorway_still_first_frame_diff's own structure (this pose needs
|
||
// the interior camera cell, unlike the plain outdoor/theory rows).
|
||
// S3 chunk 1 fix round 1 (G6): kept as its own Fact rather than
|
||
// folded into Still_fixture_first_frame_reproduces_exactly's Theory
|
||
// — it and Oh_foundry_deep_... predate that Theory's OH rows and
|
||
// mirror their own FW0 siblings' structure; either shape works, no
|
||
// functional reason blocks merging them later.
|
||
IReadOnlyList<WalkOracleFrame> frames = WalkOracleTrace.Load(
|
||
"docs/research/2026-09-01-overhaul/oh-capture", "holtburg-doorway-still.walk");
|
||
Assert.NotEmpty(frames);
|
||
using DatCollection dats = OpenDats();
|
||
WalkOracleFrame frame = frames[1];
|
||
Assert.NotNull(frame.Pose);
|
||
WalkLandscapeDatBuilder.BuiltWorld world =
|
||
WalkLandscapeDatBuilder.Build(dats, frame.Pose!.CellId, frame.Pose.Origin);
|
||
var ctx = new WalkTraceReplayContext(frame.Pose, world.Cells)
|
||
{
|
||
Buildings = world.Buildings,
|
||
};
|
||
WalkCell camera = Assert.Contains(frame.Pose.CellId, world.Cells);
|
||
var walk = new RetailFrameWalk();
|
||
var recorder = new Recorder();
|
||
|
||
walk.WalkFrame(frame.Pose.CellId, camera, world.Landscape, ctx, recorder);
|
||
|
||
// S3 chunk 1 fix round 1 (G10): the OH kit pose carries LC/SC/EC/OC
|
||
// — compare at the full eight-kind level (see Signature8's own doc
|
||
// comment).
|
||
string expected = WalkTraceReplayContext.Signature8(frame);
|
||
string actual = WalkTraceReplayContext.Signature8(recorder.Tokens);
|
||
Assert.True(
|
||
expected == actual,
|
||
$"walk diverged from retail\nEXPECTED: {expected}\nACTUAL: {actual}");
|
||
}
|
||
|
||
private const string FwOracleRoot = "docs/research/2026-08-30-fw-walk-oracle";
|
||
|
||
/// <summary>S3 chunk 1 (§11.2 B3): the OH capture directory — its OWN
|
||
/// pose-stamped kit-pose captures, a DIFFERENT root than the FW0 still
|
||
/// fixtures above.</summary>
|
||
private const string OhCaptureRoot = "docs/research/2026-09-01-overhaul/oh-capture";
|
||
|
||
[Theory]
|
||
[InlineData(FwOracleRoot, "posed/terrace-center")]
|
||
[InlineData(FwOracleRoot, "posed/terrace-edge")]
|
||
[InlineData(FwOracleRoot, "posed/cathedral-arrival")]
|
||
// S3 chunk 1 (§11.2 B3): the OH kit poses, as NEW rows — the OH
|
||
// cathedral-arrival root is f4180108, NOT FW0's f4180106 (a new pose,
|
||
// not a replacement of the FW0 row above).
|
||
[InlineData(OhCaptureRoot, "terrace-edge.walk")]
|
||
[InlineData(OhCaptureRoot, "cathedral-arrival.walk")]
|
||
public void Still_fixture_first_frame_reproduces_exactly(string root, string fixture)
|
||
{
|
||
IReadOnlyList<WalkOracleFrame> frames = WalkOracleTrace.Load(root, fixture);
|
||
Assert.NotEmpty(frames);
|
||
using DatCollection dats = OpenDats();
|
||
WalkOracleFrame frame = frames[1];
|
||
Assert.NotNull(frame.Pose);
|
||
WalkLandscapeDatBuilder.BuiltWorld world =
|
||
WalkLandscapeDatBuilder.Build(dats, frame.Pose!.CellId, frame.Pose.Origin);
|
||
var ctx = new WalkTraceReplayContext(frame.Pose, world.Cells)
|
||
{
|
||
Buildings = world.Buildings,
|
||
};
|
||
WalkCell? camera = (frame.Pose.CellId & 0xFFFFu) >= 0x100
|
||
? Assert.Contains(frame.Pose.CellId, world.Cells)
|
||
: null;
|
||
var walk = new RetailFrameWalk();
|
||
var recorder = new Recorder();
|
||
|
||
walk.WalkFrame(frame.Pose.CellId, camera, world.Landscape, ctx, recorder);
|
||
|
||
// S3 chunk 1 fix round 1 (G10): the OH kit-pose rows carry
|
||
// LC/SC/EC/OC — compare THOSE two rows at the full eight-kind level
|
||
// (Signature8's own doc comment); the FW0 rows have none of those
|
||
// lines at all (captured before those breakpoints existed), so they
|
||
// stay on the original four-kind comparison.
|
||
string expected = root == OhCaptureRoot
|
||
? WalkTraceReplayContext.Signature8(frame)
|
||
: WalkTraceReplayContext.Signature(frame);
|
||
string actual = root == OhCaptureRoot
|
||
? WalkTraceReplayContext.Signature8(recorder.Tokens)
|
||
: WalkTraceReplayContext.Signature(recorder.Events);
|
||
Assert.True(
|
||
expected == actual,
|
||
$"walk diverged from retail ({fixture})\nEXPECTED: {expected}\nACTUAL: {actual}");
|
||
}
|
||
|
||
[Fact]
|
||
public void Foundry_entry_reproduces_every_frame_before_the_f67_order_segment()
|
||
{
|
||
// F67–F79 (the fixture's terminal standing segment) diverge in ONE
|
||
// aspect: the flood SET through building a9b40036 is exact, but
|
||
// retail orders its DCs 116,118,11d where the replay orders
|
||
// 11d,116,118. The microscope isolates the flip to the ROOT plane
|
||
// of 0036's drawing BSP (N=(0,0,−1) D=2.8): the replay's
|
||
// building-local eye z is 2.33 (d=+0.47 → NEG-subtree first), while
|
||
// retail behaves as d<0 (POS-first) — a structural ~0.5 m frame
|
||
// question (positionPush(2) / part-scale semantics), only
|
||
// adjudicable by a live cdb dump of FrameCurrent->viewer.viewpoint
|
||
// during 0036's build_draw_portals_only (script:
|
||
// tools/walk-oracle/fw1-f67-viewpoint-probe.cdb). Frames 1–66 must
|
||
// reproduce exactly.
|
||
MovingFixtureReplay("posed/foundry-entry", stopBeforeFrame: 67);
|
||
}
|
||
|
||
[Theory]
|
||
[InlineData("posed/holtburg-walkout")]
|
||
[InlineData("posed/holtburg-transitions")]
|
||
[InlineData("posed/holtburg-walkabout")]
|
||
public void Moving_fixture_reproduces_every_pairable_frame(string fixture)
|
||
=> MovingFixtureReplay(fixture);
|
||
|
||
private void MovingFixtureReplay(string fixture, int stopBeforeFrame = int.MaxValue)
|
||
{
|
||
// Marker timing: the pose stamped at frame N+1 is the camera state
|
||
// frame N drew with (fixture README) — pair events(N) with
|
||
// pose(N+1). One walk + one landscape carry state across frames,
|
||
// reproducing retail's cross-frame caches (the stale cell-order
|
||
// quirk included).
|
||
IReadOnlyList<WalkOracleFrame> frames = WalkOracleTrace.Load(fixture);
|
||
Assert.True(frames.Count >= 3);
|
||
using DatCollection dats = OpenDats();
|
||
WalkOraclePose anchor = frames[1].Pose!;
|
||
WalkLandscapeDatBuilder.BuiltWorld world =
|
||
WalkLandscapeDatBuilder.Build(dats, anchor.CellId, anchor.Origin);
|
||
var walk = new RetailFrameWalk();
|
||
|
||
for (int n = 1; n < frames.Count - 1; n++)
|
||
{
|
||
WalkOracleFrame frame = frames[n];
|
||
if (frame.Number >= stopBeforeFrame) break;
|
||
string expected = WalkTraceReplayContext.Signature(frame);
|
||
// The marker dumps the PREVIOUS frame's camera, so frame N's
|
||
// true camera state lies between pose(N) and pose(N+1) — a
|
||
// capture artifact, not a port ambiguity. A frame passes when
|
||
// the replay matches under either adjacent pose.
|
||
string? firstActual = null;
|
||
bool matched = false;
|
||
foreach (WalkOraclePose pose in new[] { frames[n + 1].Pose!, frame.Pose! })
|
||
{
|
||
Assert.NotNull(pose);
|
||
WalkLandscapeDatBuilder.SetViewer(world.Landscape, pose.CellId, pose.Origin);
|
||
var ctx = new WalkTraceReplayContext(pose, world.Cells)
|
||
{
|
||
Buildings = world.Buildings,
|
||
};
|
||
WalkCell? camera = null;
|
||
if ((pose.CellId & 0xFFFFu) >= 0x100)
|
||
{
|
||
Assert.True(
|
||
world.Cells.TryGetValue(pose.CellId, out camera),
|
||
$"frame {frame.Number}: interior camera cell {pose.CellId:x8} not loaded");
|
||
}
|
||
var recorder = new Recorder();
|
||
walk.WalkFrame(pose.CellId, camera, world.Landscape, ctx, recorder);
|
||
string actual = WalkTraceReplayContext.Signature(recorder.Events);
|
||
firstActual ??= actual;
|
||
if (actual == expected)
|
||
{
|
||
matched = true;
|
||
break;
|
||
}
|
||
}
|
||
Assert.True(
|
||
matched,
|
||
$"frame {frame.Number} diverged under both adjacent poses ({fixture})\n"
|
||
+ $"EXPECTED: {expected}\nACTUAL: {firstActual}");
|
||
}
|
||
}
|
||
|
||
[Fact]
|
||
public void Foundry_deep_reproduces_every_complete_frame_exactly()
|
||
{
|
||
IReadOnlyList<WalkOracleFrame> frames = WalkOracleTrace.Load("posed/foundry-deep");
|
||
Assert.NotEmpty(frames);
|
||
using DatCollection dats = OpenDats();
|
||
Dictionary<uint, WalkCell> cells =
|
||
WalkWorldDatAdapter.BuildInteriorCells(dats, 0xA9B40000u);
|
||
var landscape = new WalkLandscape { MidWidth = 1, Blocks = new WalkLandBlock?[1] };
|
||
|
||
foreach (WalkOracleFrame frame in frames)
|
||
{
|
||
Assert.NotNull(frame.Pose);
|
||
WalkCell camera = Assert.Contains(frame.Pose!.CellId, cells);
|
||
var ctx = new WalkTraceReplayContext(frame.Pose, cells);
|
||
var walk = new RetailFrameWalk();
|
||
var recorder = new Recorder();
|
||
|
||
walk.WalkFrame(frame.Pose.CellId, camera, landscape, ctx, recorder);
|
||
|
||
Assert.Equal(
|
||
WalkTraceReplayContext.Signature(frame),
|
||
WalkTraceReplayContext.Signature(recorder.Events));
|
||
}
|
||
}
|
||
|
||
[Fact]
|
||
public void Oh_foundry_deep_reproduces_every_complete_frame_exactly()
|
||
{
|
||
// S3 chunk 1 (§11.2 B3): the OH kit pose's own foundry-deep capture
|
||
// — DI a9b40176, DC(ov=1, n=2), 12 town buildings drawn through the
|
||
// surviving exit chain (§6b). UNLIKE the FW0 sibling above, this
|
||
// capture's own retail transcript shows real BLD content at that
|
||
// depth, so the stub 1x1 landscape (which has no blocks/buildings to
|
||
// walk at all) undershoots it — first divergence, run without the
|
||
// fix below: "DI:a9b40176|DC:ov=1:a9b40176,a9b40177|LS" (nothing
|
||
// after LS) vs retail's "…|LS|BLD:a9b40031|BLD:a9b…" (12 real
|
||
// buildings). The full landscape/building assembler
|
||
// (WalkLandscapeDatBuilder.Build — the SAME one the shared theory
|
||
// and Oh_doorway_still_first_frame_diff use) reproduces them; the
|
||
// camera is stationary across this still pose, so one build serves
|
||
// every frame in the loop, matching the FW0 sibling's "build once"
|
||
// shape.
|
||
IReadOnlyList<WalkOracleFrame> frames = WalkOracleTrace.Load(
|
||
"docs/research/2026-09-01-overhaul/oh-capture", "foundry-deep.walk");
|
||
Assert.NotEmpty(frames);
|
||
using DatCollection dats = OpenDats();
|
||
Assert.NotNull(frames[0].Pose);
|
||
WalkLandscapeDatBuilder.BuiltWorld world = WalkLandscapeDatBuilder.Build(
|
||
dats, frames[0].Pose!.CellId, frames[0].Pose!.Origin);
|
||
|
||
foreach (WalkOracleFrame frame in frames)
|
||
{
|
||
Assert.NotNull(frame.Pose);
|
||
WalkCell camera = Assert.Contains(frame.Pose!.CellId, world.Cells);
|
||
var ctx = new WalkTraceReplayContext(frame.Pose, world.Cells)
|
||
{
|
||
Buildings = world.Buildings,
|
||
};
|
||
var walk = new RetailFrameWalk();
|
||
var recorder = new Recorder();
|
||
|
||
walk.WalkFrame(frame.Pose.CellId, camera, world.Landscape, ctx, recorder);
|
||
|
||
// S3 chunk 1 fix round 1 (G10): full eight-kind comparison —
|
||
// see Signature8's own doc comment.
|
||
Assert.Equal(
|
||
WalkTraceReplayContext.Signature8(frame),
|
||
WalkTraceReplayContext.Signature8(recorder.Tokens));
|
||
}
|
||
}
|
||
}
|