OschemaBuildConfig: expose extra_lib_modules knob so consumers can keep hand-written modules at the lib root #145
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_blueprint#145
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I saw
generate_lib_rs()atcrates/generator/src/build/builder.rs:444unconditionally rewritessrc/lib.rsevery build with content that lists only the configured domain modules. Any hand-written module declaration at the lib root (e.g.pub mod util;that a downstream consumer'scloud/rpc.rsimports viause crate::util::*) is silently stripped on every rebuild.For long-running consumers this is invisible — incremental compilation often skips re-checking the lib target, so the local dev loop doesn't surface the broken
crate::utilreference. The break only manifests on fresh checkouts (CI on every push), wherecargo check --workspaceruns against a freshly-regeneratedlib.rsand fails with:Same pattern surfaced on hero_compute today (workspace
lhumina_code/hero_compute). Worked around in that repo'sbuild.rswith a post-codegen patch that re-injectspub mod util;— seehero_compute@f05690f. Localized to that one consumer but the pattern will repeat for any other consumer that needs a hand-written module at the lib root.What I am asking for
Add a builder option to declare extra lib-root modules so the generator emits them alongside the domain modules:
generate_lib_rsthen emits:Shape suggestions (any of these is fine, ordered by least to most expressive):
extra_lib_modules: Vec<String>onOschemaBuildConfigplus awith_extra_lib_module(name: impl Into<String>)builder method. Modules are always public, no cfg gate. Covers the common case.cfgpredicate per module (e.g.with_extra_lib_module_cfg("util", Some("not(target_arch = "wasm32")"))).service.toml[[lib_modules]]so the consumer does not even need to touchbuild.rs. Optional, lower priority.Why this matters
The current behavior makes it impossible to maintain hand-written lib-root modules without a
build.rspost-process. Every consumer hitting this has to invent the same workaround independently, and the failure mode (silent erase, broken CI on fresh checkouts) is exactly the kind that bites once per CI run rather than during dev.The
nested_layout: trueconfig flag already documents an opt-out fromlib.rsgeneration entirely (config.rs:102-105), which suggests the project already recognizes the need.extra_lib_modulesis the lighter-weight counterpart for consumers using the flat layout.Acceptance
OschemaBuildConfigexposes the new knob (whichever shape above).generate_lib_rsemits declared extra modules before the feature-gated domain modules.cargo fmt --checkclean on the emitted output.build.rsworkaround can be replaced with the new builder call and the inline patch removed.Filed by mik-tf during home#238 admin/tester UX work; the workaround on
hero_compute@f05690funblocked the deployer arc while this lands. Happy to send the PR if it helps.