lab infocheck: false-positives on lib+bin crates (assumes src/main.rs exists for every cargo-metadata-discovered binary crate) #265
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_skills#265
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?
lab infocheckdiscovers binary crates viacargo metadata(correctly finds every crate with[[bin]]targets), then callscheck_crate(crate_dir)which assumes the crate hassrc/main.rs:For lib+bin crates (with
src/lib.rsand bins undersrc/bin/<name>.rs), there is nosrc/main.rs.unwrap_or_default()returns an empty string andcheck_main_rsproduces 3 false-positive findings atsrc/main.rs:0:macro service_base!() is missingvalidate_service_toml(SERVICE_TOML) is missinghandle_info_flag(SERVICE_TOML) is missingConcrete example
hero_osis/crates/hero_osis_server/ships:src/lib.rs— the domain code.src/bin/hero_osis.rs— auto-generated orchestrator (byhero_rpc::generator::generate_single_bin).src/bin/seed.rs— DB seed tool.src/bin/hero_bot.rs— ACP agent.All three bins correctly use the canonical pattern with inline SERVICE_TOML / BUILD_NR consts (Lesson #20 workaround, because
service_base!()macro'sinclude_str!("../service.toml")resolves wrong fromsrc/bin/<name>.rs). The runtime<bin> --info --jsonoutput deserialises cleanly intoServiceToml. The lab build post-build--info checkis green.But
lab infocheckreports 3 findings against a non-existentsrc/main.rs, so the crate looks "fail" in the source-side audit even though the runtime contract is met.Proposed fix
When
src/main.rsdoes not exist,check_crateshould:src/main.rs) are silently skipped — they don't need--infowiring."),src/bin/*.rsand applying the samecheck_main_rschecks to each. Forsrc/bin/bins, the canonical pattern is inline SERVICE_TOML/BUILD_NR consts (Lesson #20), so the source-side check should accept either:service_base!()macro call +validate_service_toml(SERVICE_TOML)+handle_info_flag(SERVICE_TOML), ORconst SERVICE_TOML: &str = include_str!("../../service.toml");+ same two API calls.Option 2 keeps the audit coverage while accommodating the
src/bin/shape.Repro
lab build --release --install --workspace --policy-mode warnis green: 4/4 built, 4/4--infocheck pass.Context
Filed during s123 hero_proc#102 D-10 closure for hero_osis. The hero_osis_server lib+bin shape is legitimate per Cargo conventions and necessary here (the auto-generated orchestrator must live alongside the library code it imports + the hand-written seed/bot tools). Splitting into 3 separate crates would be invasive and not warranted by the skill spec, which already documents the workaround.
Reference: hero_proc#102#33220 Session 123 update, hero_osis 7d8b3a2.