Repository navigation
feat(packs): @import("pack").Registry — the sanctioned string-keyed surface (#498 PR 3) - #545
Conversation
…urface (#498 PR 3) Every __pack_root.zig now tails with the Registry bridge: resolved via @import("root") to the <prefix>_pack_view main.zig emits (PR 1) — the pack's own <pack>__ names + .global components, foreign-private names @CompileError in the engine's ComponentView. Root modules with no generated views (tests target, preview shells) fall back to a registry of the pack's own components only via the @hasDecl guard; lazy decl analysis keeps root↔pack non-circular. Component-less packs get the empty fallback so the authoring surface is uniform. emitPackModules wires the self-import — overrideImport(mod, "pack", mod) — so authored code writes @import("pack").Registry without ever hardcoding its prefix. docs/packs.md declares the wall + sanctioned surfaces (import table, Registry semantics, the deliberate anytype/scene/prefab holes, and the generator invariants). Smoke-proven on the real two-pack project: a citizens script comptime- asserts Registry.getType("citizens__Counter") == its relatively- imported Counter type (builds green); a production script calling getType("citizens__Counter") dies at comptime. Part of #498 Claude-Session: https://claude.ai/code/session_01P7YLw4hXFCCaY2LAUt4G1j
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds documentation for the Packs architecture and implements a generated per-pack ChangesPack Registry Bridge
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request implements the self-import and Registry bridge mechanism for packs, allowing pack code to uniformly access its own module root and sanctioned string-keyed registry via @import("pack").Registry. This is achieved by generating a Registry bridge in the pack root that resolves to the root module's generated PackView or falls back to a local ComponentRegistry of the pack's own components. The build system is updated to inject the self-import override, and corresponding documentation and tests have been added. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
PR 3 of the #498 train — the Registry bridge + self-import, making
@import("pack").Registrythe sanctioned string-keyed surface.What lands
__pack_root.zigRegistry tail:pub const Registry = if (@hasDecl(root, "<prefix>_pack_view")) root.<prefix>_pack_view else <own-components fallback>— the@import("root")bridge (thestd_optionsmechanism; lazy analysis keeps root↔pack non-circular). In a generated game it resolves to the PR 1PackView(own<pack>__names +.globalcomponents; foreign-private names@compileErrorin the engine'sComponentView); under the tests target / preview shells the@hasDeclguard falls back to the pack's own components, no globals. Component-less packs get the empty fallback — uniform authoring surface.overrideImport(pack__<p>_mod, "pack", pack__<p>_mod)so authored code never hardcodes its prefix.docs/packs.md— first assembler-side packs doc: the wall's import table, Registry semantics, the deliberately-open holes (game.ComponentRegistryviaanytypestays lint territory; scenes/prefabs are data), and the generator invariants.Proof on the real two-pack project
comptime { if (Registry.getType("citizens__Counter") != Counter) @compileError(...) }— builds green, so the bridge resolves through the root view to the exact type the relative import reaches.Registry.getType("citizens__Counter")— dies at comptime (here via the component-less fallback; a components-bearing consumer routes through the engine'sComponentViewvisibility message — PR 6's fixture pins that wording).Tests
Suite 46/46 steps, 1268/1272 (4 skipped, 0 failed): renderer asserts for the bridge (root-view resolution + namespaced fallback fields + empty fallback for prefab-only packs), the build-wiring self-import, and the contracts direction check tightened to tolerate every pack's own
"pack"self-import while still forbidding contracts←dependent wiring.Next: PR 4 (
exposessurface modules +depends_on), PR 5 (lint demotion + doc truth-up + theroot.zig/build_files.zig>1000 splits), PR 6 (examples/packs-demo + CI e2e).Part of #498
https://claude.ai/code/session_01P7YLw4hXFCCaY2LAUt4G1j
Summary by CodeRabbit
Documentation
Bug Fixes
Tests