Phase 1 / Scene / Prefabs, entity cross-references & extensions#34
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.6-prefabs-crossrefs-extensions.mdThird and final sub-milestone of the scene track (M1.0.4–6): prefab flattening, entity→entity cross-references, and extension activation. One branch, one tag (
v0.10.6-prefabs-crossrefs-extensions).Scope delivered (E1–E6)
.prefab.bincook: standalone +ofvariants (field-merge over the base's flattened components, read back through the accessor).tools/scene_cookdrives.prefab.etch → .prefab.bin(--prefab-dirresolver).instance offlattening at scene cook: both override forms (Comp { field: v }field-merge +Comp.field = vper-field); an override-free instance is byte-identical to the hand-authored equivalent. Mono-entity prefabs (MultiEntityInstanceUnsupported).FieldKind.entity_(8 BEntityId, component-only, defaultdead=0xFF). By name (likeparent:), two-phase cook (forward refs), resolved at load (resolveCrossRefs, bounds-checked →MalformedScene). Absent target →UnresolvedCrossRefat cook.extensions:grammar clause (entity + instance, by name) + theextensions_offsetregion (Entity Extensions Table + dedup Prefab ID Table + hooks sub-section, SHAPE A);extendscook (components +requiresvalidated against X +on_attach/on_detachrendered as text).format_version1 → 2 (region restructured; v1 →BadVersion, re-cook).applyExtensions(resolve by name →addComponentDynamic, conflict →ExtensionComponentConflict) + the Tier-0on_attachdispatch seam (World.registerOnAttach/dispatchOnAttach; the loader never calls the VM).Re-scoped out (→ M1.0.9)
on_attach/on_detachhook EXECUTION — the interpreter is compile-once from the AST with no runtime text-execution surface, and the text-vs-bytecode storage choice is unsettled. E6 fires the seam; the cooked hook text is the metadata M1.0.9 consumes. The E6 test asserts the boundary (Health.maxstays 100).ExtensionComponentConflictat load).Closing notes
What worked: E1 seam-reconfirmation caught the
extensions:parse-gap + grounded D-B before coding; the M1.0.4/5 codec was reusable verbatim (.prefab.bin=.scene.bin); the cross-ref side-table mirrored the resource-string pass; the gate-split surfaced both frozen-format decisions to review instead of improvising.What deviated:
extensions:clause added (grammar amendment, option a); hooks-section SHAPE A +format_version1→2 (the day-1 "additive" prediction held for cross-refs, not for the Entity Extensions Table); E6 hook execution re-scoped → M1.0.9;ofoverride =Component { field: v }field-merge; mono-entity prefab instantiation.Flag in review: the
format_version1→2 break (no v1 back-compat — re-cook; deterministic, no Phase-1 prod files); the M1.0.9 boundary (seam fires, hook not executed); the §30.5 warning decision;registry.zig(FROZEN) gainedFieldKind.entity_(sanctioned by the E4 file-list); mechanical out-of-list edits (diff_runner.zigswitch arms;parser/ast/descriptor/lowerfor the clause), all journaled.Final measurements: scene load median 1.111 ms / 10k (M4 Pro, ReleaseFast, 50 runs) vs M1.0.5 ~1.05 ms — +~6%, within noise;
resolveCrossRefs/applyExtensionsare O(entries) and no-op for extension-free scenes.Residual debt (deliberate): hook execution → M1.0.9; §30.5 warning (open); multi-entity prefab instantiation + hierarchy (D-D) → hierarchy milestone;
Entityon extension-added components / resource→entity / cross-scene refs → future additive.Validation (all green)
prefab_integration_test.zig)zig build,zig build test(844/861, 17 skip, 0 fail),zig fmt --check,zig build lintgreenStatus: CLOSED, close date setdocs(brief): close M1.0.6🤖 Generated with Claude Code