Refactor Generator per-target emission into modules (#59) #64

Merged
timur merged 1 commit from issue-59-generate-modular into development 2026-05-19 15:28:16 +00:00
Owner

Closes #59.

Splits crates/generator/src/generate.rs (1785 LOC) into 12 per-target modules under generate/: rust_types, rust_server, rust_rpc (legacy), openrpc, js, rhai, python (stub), plus auxiliary (examples, e2e, tests_emit, wasm_build_script). All files ≤500 LOC. Byte-identical output: diff -r baseline/recipes example/recipe_server/src/recipes empty, diff -r baseline/petstore_src example/petstore_server/src empty. cargo test -p hero_rpc_generator --lib: 125 passed. Generator public API unchanged.

Closes #59. Splits `crates/generator/src/generate.rs` (1785 LOC) into 12 per-target modules under `generate/`: `rust_types`, `rust_server`, `rust_rpc` (legacy), `openrpc`, `js`, `rhai`, `python` (stub), plus auxiliary (`examples`, `e2e`, `tests_emit`, `wasm_build_script`). All files ≤500 LOC. **Byte-identical output**: `diff -r baseline/recipes example/recipe_server/src/recipes` empty, `diff -r baseline/petstore_src example/petstore_server/src` empty. `cargo test -p hero_rpc_generator --lib`: 125 passed. Generator public API unchanged.
refactor(generate): split Generator monolith into per-target emit modules (#59)
Some checks failed
Test / test (push) Failing after 2m15s
Test / test (pull_request) Failing after 2m22s
9b1d6b4246
Convert crates/generator/src/generate.rs (1785 LOC) into a directory of
per-target emission modules orchestrated by a thin Generator dispatcher.
Pure refactor — recipe_server and petstore_server regenerate byte-for-byte
identical output, all 125 generator tests pass unchanged.

Per #59 acceptance: no file under crates/generator/src/generate/ exceeds
500 LOC; public surface (Generator::from_dir, .core/.server/.client/etc.,
.generate, GenerationResult) unchanged; each module carries a 1-line doc
comment naming the target and the source OSchema fields it consumes.

Layout:

- generate/mod.rs           — Generator struct, builders, generate() dispatch,
                              GenerationResult, shared helpers (~470 LOC).
- generate/rust_types.rs    — types_generated.rs, types_wasm_generated.rs,
                              types.rs wrapper, domain core mod.rs.
- generate/rust_server.rs   — osis_server_generated.rs + nested server mod.rs.
- generate/rust_rpc.rs      — Legacy OSIS client (osis_client_generated.rs
                              + client mod.rs). The hero_rpc2 macro path
                              lives in build::emit::rust_rpc2 (#60).
- generate/openrpc.rs       — openrpc.json (shared between core + server dirs).
- generate/js.rs            — JS SDK types_generated.js.
- generate/rhai.rs          — rhai_types_generated.rs.
- generate/python.rs        — Empty per-target slot; populated by hero_rpc2
                              work in build::emit::python_sdk (#60).
- generate/examples.rs      — basic_crud + run.sh + README scaffolding.
- generate/e2e.rs           — End-to-end client_server.rs example.
- generate/tests_emit.rs    — Per-domain tests.rs CRUD round-trips.
- generate/wasm_build_script.rs — Existing dead-code WASM helper, isolated.

Verification:

- diff -r baseline/recipes example/recipe_server/src/recipes → empty.
- diff -r baseline/petstore_src example/petstore_server/src   → empty.
- cargo test -p hero_rpc_generator --lib: 125 passed, 1 ignored.
- cargo build -p recipe_server / -p petstore_server: green.
- cargo fmt --check on generate/: clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
timur merged commit 008ec55180 into development 2026-05-19 15:28:16 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_blueprint!64
No description provided.