From 2bd6950305f0e8e0c9f499380fec3e1b7a33167b Mon Sep 17 00:00:00 2001 From: joelteply Date: Sat, 31 Oct 2026 19:14:55 -0500 Subject: [PATCH] A required ModuleSpec with no declaring module fails CI, not boot (card 39a5c0f6) Canary 107e10ddc refused to boot on the M5 (2026-10-31): "Module registration incomplete (discovery=healthy, mode=full-citizen): missing [agent]". #5660 had deleted AgentModule and left ModuleSpec "agent" in MODULES; #5673 removed it. runtime.rs's own comment records the same trap twice before (`search`, `inference`). module_wiring_guard checked one direction only (every ServiceModule is registered or declares why not); nothing checked the reverse. every_required_module_spec_names_a_declared_module collects the `name: "..."` of every `ModuleConfig { .. }` literal in production code. It uses the same comment- and test-stripping walk over continuum-core and every cut module crate. It then requires each MODULES row to name one of them, and the failure names the spec and says to delete it with its module. Proven: passes on canary (3/0 in module_wiring_guard). Re-adding ModuleSpec "agent" fails it at module_wiring_guard.rs:254, naming `agent` (enrico, 2026-11-01T00:13Z). Ratchets exit 0. Noted, not changed here: runtime.rs's doc comments cite `expected_modules_snapshot` and `category_dispatch_consistency` as the guards for this list. Neither test exists in the tree. Their next editor should point them at this guard; the file is too large to touch for a doc line. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE --- .../src/test_env/module_wiring_guard.rs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/core/continuum-core/src/test_env/module_wiring_guard.rs b/core/continuum-core/src/test_env/module_wiring_guard.rs index 25d5b2f5bc..fc16bdb2bb 100644 --- a/core/continuum-core/src/test_env/module_wiring_guard.rs +++ b/core/continuum-core/src/test_env/module_wiring_guard.rs @@ -217,6 +217,49 @@ fn every_service_module_is_registered_or_declares_why_not() { ); } +#[test] +// what this catches: a ModuleSpec left in MODULES after its module was deleted. required_modules() +// then demands a name nothing registers, and a full-citizen boot refuses to start ("Module +// registration incomplete ... missing [agent]": canary 107e10ddc on the M5, 2026-10-31, fixed by +// #5673; runtime.rs records the same trap for `search` and `inference`). The check above looks the +// other way (a module with no registration); this one closes the pair: every spec names a module +// whose config still declares it in production code. Card 39a5c0f6. +fn every_required_module_spec_names_a_declared_module() { + let files = crate::test_env::source_tree::crate_sources(); + assert!(files.len() > 100, "source scan found only {} files: the walk is broken", files.len()); + + // The `name: "..."` of every `ModuleConfig { .. }` literal in production code (comments and + // test modules dropped by `code()`): the names a boot can actually register. + let mut declared: std::collections::HashSet = std::collections::HashSet::new(); + for file in &files { + let code = file.code(); + for (at, _) in code.match_indices("ModuleConfig {") { + let body = &code[at..]; + let body = &body[..body.find('}').unwrap_or(body.len())]; // unwrap_or: an unclosed literal is read to the end of the file + if let Some(name_at) = body.find("name: \"") { + let rest = &body[name_at + "name: \"".len()..]; + if let Some(end) = rest.find('"') { + declared.insert(rest[..end].to_string()); + } + } + } + } + assert!(declared.len() > 50, "found only {} module config names: the scan regressed", declared.len()); + + let missing: Vec<&str> = crate::runtime::runtime::MODULES + .iter() + .map(|spec| spec.name) + .filter(|name| !declared.contains(*name)) + .collect(); + assert!( + missing.is_empty(), + "these ModuleSpec rows name a module no production ModuleConfig declares, so a boot that \ + requires them refuses to start:\n {}\n\nDelete the spec with its module (runtime.rs \ + MODULES), or restore the module.", + missing.join("\n ") + ); +} + #[test] // what this catches: an UNWIRED entry added as a silent mute. Every // exemption must carry a reason, and the two categories that are not