Part of #839 — [Audit][Round 2] A++ umbrella.
Phase: P3 · Finding: R2-10 · Priority: HIGH (grade D critical glue)
Problem
world-runtime — the world facade that ties streaming, rendering, mutation, lighting, save, LOD, and GPU buffers together — has 165 pub fns and 14 tests (ratio 0.08). This is the system's critical glue; defects here cascade into every gameplay system.
Also: engine-input and engine-ecs violate the AGENTS.md "tests alongside modules" rule by relying on test files in src/ (src/input_tests.zig, src/ecs_tests.zig).
Evidence
Coverage table (Round 2 audit):
world-runtime: 165 pub fns, 14 tests, ratio 0.08 (grade D)
engine-input: 44 pub fns, 0 internal tests, 6 in src/input_tests.zig (grade C, violates co-location)
engine-ecs: 28 pub fns, 0 internal tests, 7 in src/ecs_tests.zig (grade C, violates co-location)
For contrast: world-core ratio 2.33, world-meshing ratio 2.09.
The 14 existing world-runtime tests are scattered (world.zig, world_streamer.zig, world_renderer.zig, gpu_mesher.zig, lighting_engine.zig, lpv_grid_builder.zig, chunk_queue_coordinator.zig, world_mutation.zig). Coverage is shallow: most pub fns on the World facade (world.zig, 1112 LOC, 46 pub methods, 33-method vtable) have no test.
Fix
Tier 1 — world-runtime facade tests
Focus on the 33-method IWorld vtable (world.zig). For each method, add at least one happy-path test and one failure-path test using a mock-able world setup:
init / deinit lifecycle — assert resource cleanup ordering
setBlock / getBlock — round-trip; out-of-bounds error; chunk-not-loaded error
streamChunk / unloadChunk — assert streamer queue state before/after
render — assert it delegates to WorldRenderer without mutating state
save / load — round-trip; corrupt-save error; missing-save error
getStats / telemetry — assert counters increment on stream/load/save
- Simulation/Render/Telemetry role-interface views — assert they expose only their slice
Build a MockWorldSubsystems harness (modules/world-runtime/src/test_harness.zig): fake streamer, fake renderer, fake mutation coordinator. The facade orchestrates them; tests assert on the orchestration, not the subsystem internals.
Target: 60+ tests. Lifts ratio from 0.08 to ~0.4 (grade B).
Tier 2 — Co-locate engine-input tests
Move src/input_tests.zig → modules/engine-input/src/input_tests.zig. Update src/tests.zig aggregator to import from the new location. Re-run to confirm green.
Tier 3 — Co-locate engine-ecs tests
Move src/ecs_tests.zig → modules/engine-ecs/src/ecs_tests.zig. Same aggregator update.
Tier 4 — Subsystem tests
For each sibling file in world-runtime/src/ (world_streamer.zig, world_renderer.zig, gpu_mesher.zig, lighting_engine.zig, lpv_grid_builder.zig, chunk_queue_coordinator.zig, world_mutation.zig), add 5–10 tests focused on edge cases (empty input, max-size input, error propagation, threading invariants).
Verification
nix develop --command zig build test -- --test-filter "World" runs the new suite
nix develop --command zig build test overall green
- Coverage targets:
world-runtime: ratio ≥ 0.4 (currently 0.08). Stretch: ≥ 0.7 (grade A−)
engine-input: ratio ≥ 0.3, tests co-located
engine-ecs: ratio ≥ 0.3, tests co-located
- AGENTS.md co-location:
find modules -name '*_tests.zig' | xargs grep -l '^test ' includes the new files
Constraints
- Tests must run without a GPU (mock RHI from R2-4) for facade/subsystem orchestration tests.
- Coordinate with R2-1 (
LODManager decomposition) — tests written against the new extracted interfaces are more durable than tests against the current fat orchestrator.
- Conventional commits:
test(world-runtime): add IWorld facade lifecycle tests, refactor(engine-input): co-locate tests per AGENTS.md, etc.
Notes
- The
MockWorldSubsystems harness built here is reusable for game-core/game-ui tests (R2-9).
- R2-1's
LODManager extraction will make World facade testing tractable — the LOD subsystem will be mockable.
- Out of scope but worth noting:
world-core (ratio 2.33, grade A) is the gold standard — new tests should follow its style.
Tracking: #839
Part of #839 — [Audit][Round 2] A++ umbrella.
Phase: P3 · Finding: R2-10 · Priority: HIGH (grade D critical glue)
Problem
world-runtime— the world facade that ties streaming, rendering, mutation, lighting, save, LOD, and GPU buffers together — has 165 pub fns and 14 tests (ratio 0.08). This is the system's critical glue; defects here cascade into every gameplay system.Also:
engine-inputandengine-ecsviolate the AGENTS.md "tests alongside modules" rule by relying on test files insrc/(src/input_tests.zig,src/ecs_tests.zig).Evidence
Coverage table (Round 2 audit):
world-runtime: 165 pub fns, 14 tests, ratio 0.08 (grade D)engine-input: 44 pub fns, 0 internal tests, 6 insrc/input_tests.zig(grade C, violates co-location)engine-ecs: 28 pub fns, 0 internal tests, 7 insrc/ecs_tests.zig(grade C, violates co-location)For contrast:
world-coreratio 2.33,world-meshingratio 2.09.The 14 existing
world-runtimetests are scattered (world.zig,world_streamer.zig,world_renderer.zig,gpu_mesher.zig,lighting_engine.zig,lpv_grid_builder.zig,chunk_queue_coordinator.zig,world_mutation.zig). Coverage is shallow: most pub fns on theWorldfacade (world.zig, 1112 LOC, 46 pub methods, 33-method vtable) have no test.Fix
Tier 1 —
world-runtimefacade testsFocus on the 33-method
IWorldvtable (world.zig). For each method, add at least one happy-path test and one failure-path test using a mock-able world setup:init/deinitlifecycle — assert resource cleanup orderingsetBlock/getBlock— round-trip; out-of-bounds error; chunk-not-loaded errorstreamChunk/unloadChunk— assert streamer queue state before/afterrender— assert it delegates toWorldRendererwithout mutating statesave/load— round-trip; corrupt-save error; missing-save errorgetStats/ telemetry — assert counters increment on stream/load/saveBuild a
MockWorldSubsystemsharness (modules/world-runtime/src/test_harness.zig): fake streamer, fake renderer, fake mutation coordinator. The facade orchestrates them; tests assert on the orchestration, not the subsystem internals.Target: 60+ tests. Lifts ratio from 0.08 to ~0.4 (grade B).
Tier 2 — Co-locate
engine-inputtestsMove
src/input_tests.zig→modules/engine-input/src/input_tests.zig. Updatesrc/tests.zigaggregator to import from the new location. Re-run to confirm green.Tier 3 — Co-locate
engine-ecstestsMove
src/ecs_tests.zig→modules/engine-ecs/src/ecs_tests.zig. Same aggregator update.Tier 4 — Subsystem tests
For each sibling file in
world-runtime/src/(world_streamer.zig,world_renderer.zig,gpu_mesher.zig,lighting_engine.zig,lpv_grid_builder.zig,chunk_queue_coordinator.zig,world_mutation.zig), add 5–10 tests focused on edge cases (empty input, max-size input, error propagation, threading invariants).Verification
nix develop --command zig build test -- --test-filter "World"runs the new suitenix develop --command zig build testoverall greenworld-runtime: ratio ≥ 0.4 (currently 0.08). Stretch: ≥ 0.7 (grade A−)engine-input: ratio ≥ 0.3, tests co-locatedengine-ecs: ratio ≥ 0.3, tests co-locatedfind modules -name '*_tests.zig' | xargs grep -l '^test 'includes the new filesConstraints
LODManagerdecomposition) — tests written against the new extracted interfaces are more durable than tests against the current fat orchestrator.test(world-runtime): add IWorld facade lifecycle tests,refactor(engine-input): co-locate tests per AGENTS.md, etc.Notes
MockWorldSubsystemsharness built here is reusable forgame-core/game-uitests (R2-9).LODManagerextraction will makeWorldfacade testing tractable — the LOD subsystem will be mockable.world-core(ratio 2.33, grade A) is the gold standard — new tests should follow its style.Tracking: #839