Skip to content

AntHill demo: fix the ReadsSnapshot<Genetics> schedule error, add an on-screen control reference and a README - #669

Merged
nockawa merged 1 commit into
mainfrom
fix/anthill-demo-schedule-and-help-hud
Aug 3, 2026
Merged

nockawa merged 1 commit into
mainfrom
fix/anthill-demo-schedule-and-help-hud

Conversation

@nockawa

@nockawa nockawa commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Why

The AntHill demo has failed to start for ~5 weeks:

System.InvalidOperationException: System 'FillRenderBuffer' declares ReadsSnapshot<Genetics>,
but 'Genetics' is a SingleVersion component. Snapshot reads require MVCC history — only
Versioned components have it. (CM-04 / runtime-scheduling.md AC-05)
   at Typhon.Engine.RuntimeSchedule.Build(...)

Not a recent regression — the two halves have simply been inconsistent since the validation landed:

Commit Date Event
a179e510 (#352) — added .ReadsSnapshot<Genetics>() to FillRenderBuffer
cbef4b61 (#392/#395) 2026-06-26 added the AC-05 validation → demo broke here
3f3b88b1 (#514) 2026-07-19 touched the demo (source-gen registry) but nobody ran it

The NullReferenceException flood that follows in Main._Process is pure cascade: _Ready() aborted before the HUD labels were assigned.

The fix

.ReadsSnapshot<Genetics>() → .Reads<Genetics>(). Behaviour-identical, not a compromise:

  • AntUpdate (the sole Genetics writer) is in the Simulation phase; FillRenderBuffer is in Render. AC-02 only forbids plain Reads against a same-phase writer, so this is legal.
  • Both variants trigger the identical cross-phase edge AntUpdate → FillRenderBuffer (deriver table row 1: sys_a.Writes<T> ∩ sys_b.{Writes,Reads,ReadsFresh,ReadsSnapshot}<T>). The DAG is unchanged.
  • Per RFC 07 "Semantic shift: cross-phase ReadsSnapshot", a snapshot read whose writer sits in an earlier phase already degenerated to ReadsFresh semantics. The observed value is the same this-tick value it was before.
  • It also removes a self-inconsistency: WorldBounds and AntState in that same system are written by the same AntUpdate and already used plain Reads. Only Genetics was the odd one out — leftover from when Phase 5 promoted it from Reads to Writes on the sim side.

Also in this PR

On-screen control reference (bottom-left, toggled with the debug HUD). Anchored rather than positioned — point-anchors at the bottom-left corner with GrowVertical = Begin / GrowHorizontal = End, so it stays pinned across window resizes (the demo persists window geometry). Kept to a narrow column because the minimap is anchored bottom-right at 256 px.

Single owner for debug-overlay visibility. SetDebugHudVisible() now drives both the stat HUD and the help panel; F1 and the settings checkbox both route through it. F1 additionally pushes state back into the checkbox via the new SettingsPanel.SetDebugToggle() — previously F1 mutated _hudRight directly and left the settings panel showing a stale tick. Mirrors how H/pheromone already worked.

Deleted the drifted startup control list. The GD.Print at Main.cs:114 claimed wheel=zoom, mid-drag=yaw and 1-4=speed — none of which are the current bindings (wheel sets camera move speed, right-drag is mouselook, [/] step the time scale, 1-5 select tools). Space/Ctrl altitude and Shift sprint were undocumented entirely. Replaced with a pointer to the on-screen panel rather than a second hand-maintained copy.

README.md for AntHill.Demo — what the demo is and what it simulates, how to run it, the full control reference, how to read the HUD (including LOD bands vs. simulation tiers), the four-phase tick pipeline, the sim→render handoff, profiling via ++ --trace / --live, and the headless harness. Every figure sourced from code; all 7 relative links verified to resolve.

Verification

  • AntHill.Harness --duration 3 (headless, no Godot): schedule builds, 181 ticks, clean shutdown, FillRenderBuffer at 526 µs p50.
  • AntHill.Demo and AntHill.Harness both build: 0 warnings, 0 errors.

Known gap, not addressed here

grep AntHill .github/workflows/ returns nothing. The demo is in Typhon.slnx so it compiles in CI, but no job ever calls RuntimeSchedule.Build() on it — which is exactly why this class of breakage survived five weeks. A ~1 s smoke test constructing the AntHill runtime and asserting Build() succeeds would surface every future AC-0x tightening on the PR that lands it. Left out of this PR deliberately; happy to file it separately.

There is no tracking issue for this — the commit is unprefixed rather than pointing at an invented number.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ETHnFHUeFTho3EAnXmXNdS

…on-screen control reference and a README

FillRenderBuffer declared ReadsSnapshot<Genetics> while Genetics is a SingleVersion component, which RuntimeSchedule.Build has rejected since cbef4b6 (AC-05 / CM-04, #392). The demo has failed to start for ~5 weeks; nothing caught it because no CI job ever calls Build() on the AntHill schedule, and the breakage is Build-time-only so the compiler can't see it.

Plain Reads is behaviour-identical here: the sole Genetics writer (AntUpdate) sits in the Simulation phase and FillRenderBuffer in Render, so the cross-phase deriver emits the same writer -> reader edge ReadsSnapshot did, and a snapshot read whose writer is in an earlier phase already degenerated to fresh semantics (RFC 07, "Semantic shift: cross-phase ReadsSnapshot"). It also makes Genetics consistent with WorldBounds and AntState, which the same system already read plainly and the same system writes. Verified with AntHill.Harness --duration 3: schedule builds, 181 ticks, clean shutdown.

Adds a bottom-left keybinding panel whose visibility is tied to the debug HUD, anchored rather than positioned so it stays pinned to the corner across window resizes. Both F1 and the settings checkbox now route through a single SetDebugHudVisible, and F1 pushes the new state back into the checkbox via SettingsPanel.SetDebugToggle — previously F1 mutated the HUD directly and left the panel showing a stale tick.

Replaces the startup GD.Print control list rather than duplicating it: that string had drifted and claimed wheel=zoom, mid-drag=yaw and 1-4=speed, none of which are the current bindings (wheel sets camera move speed, right-drag is mouselook, [ and ] step the time scale, 1-5 select tools). Space/Ctrl altitude and Shift sprint were undocumented entirely.

New README.md for AntHill.Demo: what the demo is, what it simulates, how to run it, the full control reference, how to read the HUD, the four-phase tick pipeline, the simulation-to-render handoff, profiling, and the headless harness.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ETHnFHUeFTho3EAnXmXNdS
@nockawa nockawa changed the title AntHill demo: fix the ReadsSnapshot&lt;Genetics&gt; schedule error, add an on-screen control reference and a README AntHill demo: fix the ReadsSnapshot<Genetics> schedule error, add an on-screen control reference and a README Aug 3, 2026
@nockawa
nockawa merged commit 81b9e7b into main Aug 3, 2026
13 checks passed
@nockawa
nockawa deleted the fix/anthill-demo-schedule-and-help-hud branch August 3, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant