Skip to content

refactor: split manifest.zig into focused sub-modules (behavior-preserving) - #543

Merged
apotema merged 1 commit into
mainfrom
refactor/split-manifest
Jul 5, 2026
Merged

apotema merged 1 commit into
mainfrom
refactor/split-manifest

Conversation

@apotema

@apotema apotema commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Turn the ~1600-line src/manifest.zig into a thin barrel that re-exports a new manifest/ sub-package, split along cohesive seams. Pure module extraction — no logic, signature, or output changes. Mirrors the codegen/scan.zig split in #539.

Sections extracted

Sub-module Section Public surface
manifest/parse.zig game/pack realm AST struct parsing Field, StructDecl, parseStructDir, parseStructFile (+ parse tests)
manifest/json.zig JSON emission (index + per-realm detail + pack realms + small writers) SCHEMA_VERSION, ManifestData, PackRealm, writeManifestJson, findRealm (+ writer round-trip tests)
manifest/emit.zig orchestration MANIFEST_FILENAME, PackInput, emitManifestSidecar, writeSidecar (+ sidecar tests)

manifest.zig is now a thin barrel re-exporting the unchanged public surface (MANIFEST_FILENAME, SCHEMA_VERSION, PackInput, emitManifestSidecar) and pulling every sub-module into analysis via test {}. The only external call sites (root.zig → pack_manifest.PackInput / emitManifestSidecar) are untouched.

Behavior preservation

  • Tests moved verbatim alongside their functions.
  • A normalized set-diff of every meaningful code line (original vs. the three new files combined) shows the only deltas are: added pub qualifiers for cross-module access, ../-rewritten import paths, per-file const aliases, and module-qualified calls (parse./json.). No output-affecting line changed.
  • A direct diff of the moved writer region (writeManifestJson … writeFieldObject) is byte-identical apart from the one added pub.

Bar

  • zig build — green
  • zig build test — green (golden/build.zig suite byte-identical)
  • zig fmt --check — clean

Pure extraction; any latent bug in the moved code is pre-existing and out of scope.

https://claude.ai/code/session_017pW3ifKf9wgxNg4viy6okw

Summary by CodeRabbit

  • New Features

    • Manifest generation now produces richer, more structured output, including clearer realm, contract, and component details.
    • Support was added for project and pack manifest data to be handled more consistently across the app.
  • Bug Fixes

    • Improved handling of missing or incomplete source definitions so manifest generation is more resilient.
    • Added coverage to help ensure generated manifest output stays valid and stable.

…rving) (#442 follow-up)

Turn the ~1600-line src/manifest.zig into a thin barrel that re-exports a
new manifest/ sub-package split along cohesive seams. Pure module
extraction: no logic, signature, or output changes. Every manifest.<Name>
call site is unchanged (same public names re-exported from the barrel).

Sub-modules:
  - manifest/parse.zig  game/pack realm struct parsing (Field, StructDecl,
                        parseStructDir, parseStructFile, extractSavePolicy)
  - manifest/json.zig   JSON emission (ManifestData, PackRealm,
                        SCHEMA_VERSION, writeManifestJson + all writers)
  - manifest/emit.zig   orchestration (MANIFEST_FILENAME, PackInput,
                        emitManifestSidecar, writeSidecar)

Tests moved verbatim alongside their functions; the barrel pulls every
sub-module into analysis so `zig build test` runs them all. The only
non-mechanical deltas vs the original are added `pub` qualifiers for
cross-module access, `../`-rewritten imports, and module-qualified calls
— a normalized set-diff confirms every output-affecting line is verbatim.

Mirrors the codegen/scan.zig split in #539.

zig build + zig build test green; zig fmt --check clean; manifest JSON
writer byte-identical (verified by diff of the moved writer region).

Claude-Session: https://claude.ai/code/session_017pW3ifKf9wgxNg4viy6okw
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 93fd94a9-ec61-43cf-b6d9-c8a043e347c8

📥 Commits

Reviewing files that changed from the base of the PR and between 990f68f and 9174bd4.

📒 Files selected for processing (4)
  • src/manifest.zig
  • src/manifest/emit.zig
  • src/manifest/json.zig
  • src/manifest/parse.zig

📝 Walkthrough

Walkthrough

The manifest generation logic previously contained entirely in src/manifest.zig has been split into three new submodules: parse.zig (AST-based struct/event parsing), json.zig (manifest JSON serialization for game/engine/plugin/pack realms), and emit.zig (sidecar orchestration and file writing). src/manifest.zig now re-exports these submodules' public symbols.

Changes

Manifest Module Split

Layer / File(s) Summary
Struct/event AST parsing
src/manifest/parse.zig
New Field/StructDecl types, parseStructDir/parseStructFile functions using std.zig.Ast, save/visibility extraction helpers, and unit tests covering fallback and extraction behavior.
Manifest JSON serialization
src/manifest/json.zig
New SCHEMA_VERSION, PackRealm/ManifestData types, writeManifestJson entrypoint, index and per-realm detail emitters for game/engine/plugin/pack realms, JSON helper writers, and round-trip tests.
Sidecar orchestration and writing
src/manifest/emit.zig
New MANIFEST_FILENAME, PackInput, emitManifestSidecar that AST-parses game/pack components and events and calls writeManifestJson, a writeSidecar helper for file output, and tests for empty-project and staged-pack emission.
Barrel re-export
src/manifest.zig
File reduced from ~1600 lines to a thin barrel importing the three submodules and re-exporting SCHEMA_VERSION, MANIFEST_FILENAME, PackInput, emitManifestSidecar, with a test block referencing submodule tests.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Poem

A file grew fat with code so vast,
Now split three ways, built to last —
parse, json, emit, each does its part,
While one small barrel binds the heart. 🐇
Hop, hop, the manifest's now neat and small!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: splitting manifest.zig into focused sub-modules while preserving behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/split-manifest

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors src/manifest.zig by splitting the single ~1600-line module into a thin barrel file that re-exports focused sub-modules under src/manifest/, specifically parse.zig for struct parsing, json.zig for JSON emission, and emit.zig for orchestration. This behavior-preserving split maintains all original symbol names and integrates the respective tests into the main barrel. There are no review comments, and 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.

@apotema
apotema merged commit bd01044 into main Jul 5, 2026
4 checks passed
@apotema
apotema deleted the refactor/split-manifest branch July 5, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant