namespace AcDream.App.Tests.Rendering.Walk;
///
/// Integrity tests for the FW0 walk-oracle fixtures: every checked-in
/// trace parses, and the load-bearing shapes recorded in the fixture
/// README hold. FW1's conformance suite builds on these parsed frames;
/// if a fixture is edited or recaptured, these goldens catch drift.
///
public sealed class WalkOracleTraceTests
{
private const uint FarBuilding = 0xF518002Eu;
private const string FwRoot = "docs/research/2026-08-30-fw-walk-oracle";
/// S3 chunk 1 (§11.2 B3): the OH capture directory. Its walk
/// logs are named <pose>.walk.log — the trailing
/// .walk below is the fixture-name half of that filename, not a
/// subdirectory (matching 's own
/// convention).
private const string OhRoot = "docs/research/2026-09-01-overhaul/oh-capture";
/// (root, fixture name) pairs. Every FW0 still/posed fixture
/// keeps its old bare name under ; the five OH
/// walk captures (§11.2 B3) join under with the
/// .walk filename-half suffix.
public static readonly TheoryData AllFixtures = new()
{
{ FwRoot, "terrace-center" },
{ FwRoot, "terrace-edge" },
{ FwRoot, "cathedral-arrival" },
{ FwRoot, "holtburg-doorway-still" },
{ FwRoot, "holtburg-walkout" },
{ FwRoot, "holtburg-street-porchcam" },
{ FwRoot, "holtburg-street-outdoor" },
{ FwRoot, "holtburg-walkabout" },
{ FwRoot, "foundry-entry" },
{ FwRoot, "foundry-deep" },
{ OhRoot, "holtburg-doorway-still.walk" },
{ OhRoot, "terrace-edge.walk" },
{ OhRoot, "cathedral-arrival.walk" },
{ OhRoot, "foundry-deep.walk" },
{ OhRoot, "cathedral-leak.walk" },
};
[Theory]
[MemberData(nameof(AllFixtures))]
public void Fixture_parses_with_complete_frames(string root, string name)
{
IReadOnlyList frames = WalkOracleTrace.Load(root, name);
Assert.NotEmpty(frames);
// Frame numbers are contiguous from 1; the truncated final frame is dropped.
Assert.Equal(1, frames[0].Number);
Assert.Equal(frames.Count, frames[^1].Number);
Assert.All(frames, f => Assert.NotEmpty(f.Events));
}
/// S3 chunk 1 fix round 1 (G8/G10): the "assert separately"
/// half of 's
/// own doc comment — that method's derivation never produces the
/// trailing weather OC (G8: GameSky::Draw @0x00506ff0's weather
/// branch calling DrawObjCellForDummies(after_sky_cell)
/// @0x005070da), so its presence/position is pinned here instead,
/// directly against the OH capture (the FW0 terrace-edge fixture
/// predates the OC breakpoint and carries none). Every complete outdoor
/// frame's LAST event is an OC whose cell id equals that SAME
/// frame's own P line cell id (the viewer's land cell).
[Fact]
public void Oh_terrace_edge_outdoor_frame_ends_with_the_weather_ObjectCellTurn()
{
IReadOnlyList frames = WalkOracleTrace.Load(OhRoot, "terrace-edge.walk");
Assert.NotEmpty(frames);
Assert.All(frames, f =>
{
Assert.NotNull(f.Pose);
WalkOracleEvent last = f.Events[^1];
Assert.Equal(WalkOracleEventKind.ObjectCellTurn, last.Kind);
Assert.Equal(f.Pose!.CellId, last.CellId);
});
}
[Fact]
public void Terrace_edge_draws_the_far_building_every_outdoor_frame()
{
// The #456 acceptance oracle: retail HIDES the vista by depth cover,
// not by omission — 0xF518002E is submitted every single frame.
IReadOnlyList frames = WalkOracleTrace.Load("terrace-edge");
Assert.All(frames, f =>
{
Assert.Null(f.InteriorRootCell);
Assert.True(f.HasLandscape);
Assert.Contains(FarBuilding, f.Buildings);
});
}
[Fact]
public void Cathedral_arrival_roots_interior_and_culls_the_far_building()
{
IReadOnlyList frames = WalkOracleTrace.Load("cathedral-arrival");
Assert.All(frames, f =>
{
Assert.Equal(0xF4180106u, f.InteriorRootCell);
Assert.True(f.HasLandscape); // drawn THROUGH the exit view
Assert.DoesNotContain(FarBuilding, f.Buildings);
});
}
[Fact]
public void Doorway_root_is_stable_across_every_frame()
{
IReadOnlyList frames = WalkOracleTrace.Load("holtburg-doorway-still");
Assert.All(frames, f => Assert.Equal(0xA9B4013Fu, f.InteriorRootCell));
}
[Fact]
public void Walkout_hands_over_between_interior_cells_in_one_frame()
{
IReadOnlyList frames = WalkOracleTrace.Load("holtburg-walkout");
uint?[] roots = frames.Select(f => f.InteriorRootCell).Distinct().ToArray();
Assert.Equal(new uint?[] { 0xA9B4013Fu, 0xA9B40150u }, roots);
// Exactly one handover: the root sequence is two contiguous runs.
int transitions = frames.Zip(frames.Skip(1))
.Count(pair => pair.First.InteriorRootCell != pair.Second.InteriorRootCell);
Assert.Equal(1, transitions);
}
[Fact]
public void Street_porchcam_roots_at_the_camera_cell_not_the_player()
{
// The player stood in the street; the chase camera sat inside the
// cottage porch — and retail rooted the frame at the CAMERA's cell.
IReadOnlyList frames = WalkOracleTrace.Load("holtburg-street-porchcam");
Assert.All(frames, f => Assert.Equal(0xA9B40150u, f.InteriorRootCell));
}
[Fact]
public void Street_outdoor_never_enters_an_interior_root()
{
IReadOnlyList frames = WalkOracleTrace.Load("holtburg-street-outdoor");
Assert.All(frames, f =>
{
Assert.Null(f.InteriorRootCell);
Assert.True(f.HasLandscape);
});
}
[Fact]
public void Foundry_entry_flips_outdoor_to_interior_and_drops_the_landscape()
{
IReadOnlyList frames = WalkOracleTrace.Load("foundry-entry");
WalkOracleFrame flip = frames.First(f => f.InteriorRootCell is not null);
Assert.Equal(0xA9B40178u, flip.InteriorRootCell);
// The frame before the flip is fully outdoor; the flip frame itself
// draws NO landscape and NO buildings — the pure-interior shape.
WalkOracleFrame before = frames[flip.Number - 2];
Assert.Null(before.InteriorRootCell);
Assert.True(before.HasLandscape);
Assert.False(flip.HasLandscape);
Assert.Empty(flip.Buildings);
}
[Fact]
public void Foundry_deep_draws_the_town_through_the_surviving_chain()
{
IReadOnlyList frames = WalkOracleTrace.Load("foundry-deep");
Assert.All(frames, f =>
{
Assert.Equal(0xA9B40176u, f.InteriorRootCell);
Assert.True(f.HasLandscape);
Assert.NotEmpty(f.Buildings);
});
}
[Fact]
public void Stationary_frames_repeat_their_event_sequence_exactly()
{
// README finding 6: while the camera is still, the whole-frame
// sequence repeats bit-for-bit. Assert it on the terrace fixture.
IReadOnlyList frames = WalkOracleTrace.Load("terrace-center");
WalkOracleFrame first = frames[0];
Assert.All(frames.Skip(1), f =>
{
Assert.Equal(first.Events.Count, f.Events.Count);
for (int i = 0; i < first.Events.Count; i++)
Assert.Equal(first.Events[i], f.Events[i], WalkOracleEventComparer.Instance);
});
}
private sealed class WalkOracleEventComparer : IEqualityComparer
{
public static readonly WalkOracleEventComparer Instance = new();
public bool Equals(WalkOracleEvent? x, WalkOracleEvent? y)
=> x is not null && y is not null
&& x.Kind == y.Kind
&& x.CellId == y.CellId
&& x.OutsideViewCount == y.OutsideViewCount
&& x.DeclaredCellCount == y.DeclaredCellCount
&& x.Cells.SequenceEqual(y.Cells);
public int GetHashCode(WalkOracleEvent obj)
=> HashCode.Combine(obj.Kind, obj.CellId, obj.Cells.Count);
}
}