Don't generate empty src/services/ placeholder (subsumes #68) #75

Closed
opened 2026-05-19 16:47:01 +00:00 by timur · 1 comment
Owner

Problem

Every scaffolded service has an empty crates/<name>/src/services/mod.rs placeholder. Contributor sees a folder with one empty mod.rs and has to guess what it's for.

The placeholder also causes the #68 collision: if your domain is named services, the generator and the placeholder both try to own src/services/.

What to do

Pick one:

  • Remove the placeholder entirely. If the scaffolder doesn't need a services module for anything, just don't emit it. Cleanest fix. Also closes #68 as a side effect.
  • Only emit it when there's content to put there. If it's meant to hold hand-written service-method impls eventually, generate it lazily the first time content is added.

My lean: remove it. The preserved trait impl already lives in crates/<name>_server/src/<domain>/rpc.rs; there's no need for a separate services namespace in the core lib.

What to do

  • Locate the services/mod.rs emission in the scaffolder.
  • Remove it.
  • Verify scaffolded services build without it.
  • Close #68 as resolved-by-this once landed.

Acceptance

  • Fresh scaffold has no src/services/ directory.
  • A scaffold using services as the domain name works without manual fix-up.
  • Existing hero_service, recipe_server rebuild cleanly post-fix.
## Problem Every scaffolded service has an empty [`crates/<name>/src/services/mod.rs`](https://forge.ourworld.tf/lhumina_code/hero_service/src/branch/development/crates/hero_service/src/services) placeholder. Contributor sees a folder with one empty `mod.rs` and has to guess what it's for. The placeholder also causes the [#68](https://forge.ourworld.tf/lhumina_code/hero_rpc/issues/68) collision: if your domain is named `services`, the generator and the placeholder both try to own `src/services/`. ## What to do Pick one: - **Remove the placeholder entirely.** If the scaffolder doesn't need a `services` module for anything, just don't emit it. Cleanest fix. Also closes #68 as a side effect. - **Only emit it when there's content to put there.** If it's meant to hold hand-written service-method impls eventually, generate it lazily the first time content is added. My lean: remove it. The preserved trait impl already lives in `crates/<name>_server/src/<domain>/rpc.rs`; there's no need for a separate `services` namespace in the core lib. ## What to do - Locate the `services/mod.rs` emission in the scaffolder. - Remove it. - Verify scaffolded services build without it. - Close [#68](https://forge.ourworld.tf/lhumina_code/hero_rpc/issues/68) as resolved-by-this once landed. ## Acceptance - Fresh scaffold has no `src/services/` directory. - A scaffold using `services` as the domain name works without manual fix-up. - Existing `hero_service`, `recipe_server` rebuild cleanly post-fix.
Author
Owner

Fix landed on branch issue-75-remove-services-placeholder-v2 (1c2993df4b).

Changes

  • crates/generator/src/build/scaffold.rs — drop src/services/mod.rs emission, drop pub mod services; from the src/lib.rs stub, update test_scaffold_core_and_sdk_crates_have_lib_rs to assert the placeholder is absent.
  • crates/generator/src/build/builder.rs — drop generate_services_placeholder call + the pub mod services; push in generate_lib_rs.
  • crates/generator/src/build/emit/services.rs — deleted; removed from emit/mod.rs.
  • example/recipe_server/crates/hero_recipes + crates/server/examples/recipe_server — removed committed placeholder dirs and corresponding pub mod services;.

Acceptance verification

  1. Fresh scaffold (cargo run -p hero_rpc_generator -- --name hero_smoke75 --schemas-dir schemas) — no src/services/ directory, no pub mod services; line in any emitted file.
  2. Scaffold with domain services (hero_svctest workspace) builds clean. The only pub mod services; in lib.rs is the feature-gated one for the domain itself; src/services/ is populated entirely by codegen (mod.rs, openrpc.json, types.rs, types_generated.rs, types_wasm_generated.rs).
  3. example/recipe_server full workspace rebuilds clean.
  4. cargo test -p hero_rpc_generator build::scaffold — 18 passed.

This subsumes #68 — the placeholder is the only thing that collided with a services domain name, and removing it eliminates the collision at the source.

Ready for review.

Fix landed on branch `issue-75-remove-services-placeholder-v2` (1c2993df4b8f88a87fae3aa43aa5de9573b6ebed). **Changes** - `crates/generator/src/build/scaffold.rs` — drop `src/services/mod.rs` emission, drop `pub mod services;` from the `src/lib.rs` stub, update `test_scaffold_core_and_sdk_crates_have_lib_rs` to assert the placeholder is absent. - `crates/generator/src/build/builder.rs` — drop `generate_services_placeholder` call + the `pub mod services;` push in `generate_lib_rs`. - `crates/generator/src/build/emit/services.rs` — deleted; removed from `emit/mod.rs`. - `example/recipe_server/crates/hero_recipes` + `crates/server/examples/recipe_server` — removed committed placeholder dirs and corresponding `pub mod services;`. **Acceptance verification** 1. Fresh scaffold (`cargo run -p hero_rpc_generator -- --name hero_smoke75 --schemas-dir schemas`) — no `src/services/` directory, no `pub mod services;` line in any emitted file. 2. Scaffold with domain `services` (`hero_svctest` workspace) builds clean. The only `pub mod services;` in lib.rs is the feature-gated one for the domain itself; `src/services/` is populated entirely by codegen (`mod.rs`, `openrpc.json`, `types.rs`, `types_generated.rs`, `types_wasm_generated.rs`). 3. `example/recipe_server` full workspace rebuilds clean. 4. `cargo test -p hero_rpc_generator build::scaffold` — 18 passed. This subsumes #68 — the placeholder is the only thing that collided with a `services` domain name, and removing it eliminates the collision at the source. Ready for review.
timur closed this issue 2026-05-19 23:43:41 +00:00
Sign in to join this conversation.
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#75
No description provided.