You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drive ZigCraft from current B+/A− across SOLID & maintainability to A++ across the board. This is the Round 2 umbrella — successor to #776 (Round 1, M1–M21 + m1–m6, all closed) and parallel to #834 (production-readiness / CI / tooling, still open).
Round 1 closed the worst seams (split lod_mesh.zig, killed src/engine/ dead tree, extracted LightingEngine/LpvGridBuilder, dispatcher at RenderSystem.init, comptime generator registry, role interfaces, etc.). Round 2 picks up the debt that either survived Round 1 or was introduced/exposed by it.
The audit re-ran 5 parallel deep-dives (RHI abstraction, world-lod God-objects, dependency graph, error handling/tests, readability) against current dev. Every finding below cites a file:line verified at HEAD.
Round 2 scorecard (current state)
Principle
Round 1 close
Round 2 finding
Worst area
SRP
Weak → Adequate
Adequate
lod_manager.zig (2,715 LOC, ~10 concerns) — new God object exposed by Round 1's lod_mesh.zig split
OCP
Weak → Strong
Strong
Residual: adding a new RHI interface still touches rhi.zig in 5 places
LSP
Adequate
Weak
lpv_backend.zig:13 still downcasts rhi.ptr → *VulkanContext; ComputePipeline/ComputeBuffer still raw u64
ISP
Adequate → Strong
Strong
19 segregated I*Context vtables; RenderContext re-bundles 7 of them (35 pub fn)
DIP
Weak → Adequate
Adequate
One minor leak: world-runtime/world.zig:42,54 imports 2 POD structs from engine-ui
Use existing architecture (RHI vtables, job tokens, LODGPUBridge, role interfaces) — no parallel systems.
Small reviewable PRs targeting dev; conventional commits (refactor:, feat:, test:, docs:); never push to dev directly.
Preserve current gameplay/rendering behavior except where a sub-issue explicitly changes it.
All build/test commands wrapped in nix develop --command.
Verification baseline for every PR: nix develop --command zig build test (includes shader validation); rendering-touching PRs also run headless crash/screenshot/benchmark skill checks with -Dskip-present.
P1 RHI work must keep the existing Vulkan path green end-to-end.
Key risks
[R2-1][P1] Decompose LODManager God-object (2,715 LOC → ~500) #840 (LODManager decomposition) is the highest-value, highest-risk Round 2 work. 87 lock acquisitions across ~25 functions; documented cross-lock deadlock-avoidance rules mean locking must move with each extracted subsystem. Pin a headless screenshot baseline before/after.
Goal
Drive ZigCraft from current B+/A− across SOLID & maintainability to A++ across the board. This is the Round 2 umbrella — successor to #776 (Round 1, M1–M21 + m1–m6, all closed) and parallel to #834 (production-readiness / CI / tooling, still open).
Round 1 closed the worst seams (split
lod_mesh.zig, killedsrc/engine/dead tree, extractedLightingEngine/LpvGridBuilder, dispatcher atRenderSystem.init, comptime generator registry, role interfaces, etc.). Round 2 picks up the debt that either survived Round 1 or was introduced/exposed by it.The audit re-ran 5 parallel deep-dives (RHI abstraction,
world-lodGod-objects, dependency graph, error handling/tests, readability) against currentdev. Every finding below cites afile:lineverified at HEAD.Round 2 scorecard (current state)
lod_manager.zig(2,715 LOC, ~10 concerns) — new God object exposed by Round 1'slod_mesh.zigsplitrhi.zigin 5 placeslpv_backend.zig:13still downcastsrhi.ptr→*VulkanContext;ComputePipeline/ComputeBufferstill rawu64I*Contextvtables;RenderContextre-bundles 7 of them (35 pub fn)world-runtime/world.zig:42,54imports 2 POD structs fromengine-uiengine-rhi0 tests / 263 pub fn ·game-ui0 tests / 108 pub fn ·world-runtimeratio 0.08std.logleaks · 4 TODOs total ·build.zig:build668 LOC · pub-fn docs at 14.6%Scope & method
devHEADP1 — Architectural (highest leverage)
Goal: kill the remaining God-object and close the LSP/DIP gap that prevents a hypothetical second GPU backend.
LODManager(2,715 LOC → ~500) by extracting 5 subsystems + encapsulatingLODMesh/LODChunkLODMesh/LODChunkbehind behavior methods to kill the dual-consumer open-struct patternlpv_backend.zig:13,ComputePipelinerawu64,imgui_backendconsuming 6 native handles)engine-rhiunit-test contract suite (the central rendering contract has zero unit tests today)P2 — Contracts & error discipline
Goal: remove shotgun-surgery signatures and silent failures that mask real bugs.
updateGlobalUniforms13-parameter signature to aGlobalUniformsstructcatch unreachablein worldgen lighting withtry+ error-aware generator interfaceworld-runtime → engine-uiDIP leak (move 2 POD structs toworld-core)game-ui/screens/world_list.zig,player.zig,save_manager.zig)P3 — Test coverage (the bimodal problem)
Goal: lift D/F-grade modules to A/B. Half the codebase is exemplary (math 4.00, world-core 2.33, meshing 2.09); the other half is dangerously thin.
game-uitest coverage (108 pub fns, 0 tests — grade F)world-runtimetest coverage (165 pub fns, 14 tests, ratio 0.08 — grade D); also co-locateengine-input/engine-ecstests per AGENTS.mdP4 — Hygiene & docs
Goal: alignment between AGENTS.md and the code; doc coverage target ≥ 40%.
AGENTS.mdfunction-casing rule (mandatesinit_renderer, code is 99.3% camelCase per Zig stdlib) + normalize 4 mixed-style filesbuild.zig:build(668-line function — largest in repo)///doc coverage from 14.6% → ≥ 40% (AGENTS.md violation)Suggested wave order
Strengths to preserve (do not regress)
Round 1 left these in excellent shape — Round 2 must not break them:
src/game/app.zig) — textbook manual constructor injection witherrdeferpin()/unpin()disciplineengine-rhiimports no Vulkan headers — true abstract layer for the dominant resource/render surfaceRenderGraph.addPass()OCP — purely additive pass extension,execute()is 14 linesstd.logleaks across 93K LOCFIXME/HACK/XXXlod_geometry,lod_ingest,lod_scheduler, meshing*_mesher) — pure, lock-free, single-shapeConstraints
LODGPUBridge, role interfaces) — no parallel systems.dev; conventional commits (refactor:,feat:,test:,docs:); never push todevdirectly.nix develop --command.nix develop --command zig build test(includes shader validation); rendering-touching PRs also run headless crash/screenshot/benchmark skill checks with-Dskip-present.Key risks
LODManagerdecomposition) is the highest-value, highest-risk Round 2 work. 87 lock acquisitions across ~25 functions; documented cross-lock deadlock-avoidance rules mean locking must move with each extracted subsystem. Pin a headless screenshot baseline before/after.imgui_backend,lpv_backend, and the compute pipeline struct — surface used by multiple consumers. Behavior-preserving refactor must keep all current call sites working.Out of scope (covered elsewhere)
Subissue index
LODManagerGod-objectLODMesh/LODChunkengine-rhiunit-test contract suiteupdateGlobalUniformsinto structcatch unreachableworld-runtime → engine-uiDIP leakgame-uitest coverageworld-runtimetest coveragebuild.zig:build///doc coverage