Phase 1 / Scene / Runtime loader .scene.bin → ECS#33
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Milestone brief:
briefs/M1.0.5-scene-load.mdRuntime loader
.scene.bin→ ECSWorld: open + integrity-check the cooked binary (reusing the M1.0.4accessorverbatim), remap on-disk schema identity to runtimeComponentIds, instantiate every entity per-entity (spawnDynamicWithValues), build the UUID→handle map, fireon_spawnedin a two-phase pass (every entity exists before any hook), and load resources (includingstringfields interned into the now-Tier-0 persistent heap). No new ECS storage primitive.Delivered across three review gates: E1 (open + schema-identity remap), E2 (per-entity instantiation + UUID map + two-phase
on_spawned+LoadResult+ bench), E3 (persistent heap → Tier 0, resource loading, Etch cook→load integration,CLAUDE.md).Closing notes
accessor(reused verbatim) + the existing M0.1 spawn surface + the M1.0.2ObserverRegistrywere sufficient to materialize a cooked scene into a liveWorldwith no new ECS storage primitive. The genuinely new code is small:loader.zig+ one public observer entry (dispatchOnSpawned). The two-phaseon_spawnedgives the "all entities exist before anyon_spawned" ordering cleanly. The persistent-heap move to Tier 0 was mechanical (tier-neutral,runDropa no-op).loadFromBytesbyte-level core;error.MalformedScene(authorized correction); persistent heap moved tosrc/core/memory(Claude.ai amendment); resource install is install-or-overwrite (spec-grounded,engine-spec.md§19.1); T6 inline ininterp.zig(brief-permitted);core/root.zigwires thememorysubmodule (single Zig module, notbuild.zig).scene_load_bench(zig build bench-scene-load -Doptimize=ReleaseFast, Apple M4 Pro): median 1.050 ms / 10 000 entities (min 0.907, max 2.111; 50 runs). Far under the spec ~10–50 ms/10k reference → per-entity confirmed; bulk SoA column-copy is a genuine YAGNI — no bulk-spawn milestone scheduled. The instantiate step keeps a clean boundary so a bulk path could later swap its body without touchingloadScene's signature.LoadResult.deinit== scene unload, not just mmap release: itdestroys theresource_stringsblocks the installed resources still reference. Safe in M1.0.5 (no unload, no post-deinitreads); to be framed at the unload/streaming milestone.World(only the loader's own heap allocations are reclaimed viaerrdefer); the caller deinits theWorld.std.debug.assert(stripped in ReleaseFast); the format-version gate is the real guard. M1.0.6 owns those tables.MalformedSceneon violation) + UUID→handle map is the seam, but no runtime hierarchy component is written (hierarchy milestone).Validation (Étape 4 — all green)
getOrCreateArchetype/appendRowFromBytes, no parent-link application,accessor.ziguntouched)load_roundtrip_test.zig) +loadScenemmap path, T4 (load_resources_test.zig), error invariants inline inloader.zig(CorruptScene / UnknownComponent / SchemaMismatch / MalformedScene — per the E1-gate decision to keep them inline), T6 integration inline ininterp.zigzig build,zig build test(debug + ReleaseSafe),zig fmt --check,zig build lintgreen;commit-msghook green on every commitCLAUDE.md§3.4 patched on the branchStatus: CLOSED, close date set, finaldocs(brief): close M1.0.5🤖 Generated with Claude Code