pub fn module() -> ModuleDescriptorExpand description
The module’s one declaration: the five capabilities, their schemas and every projection of them.
This function is the canonical definition and not a registration of one made elsewhere. The HTTP routes, the MCP tools and resources, the OpenAPI components and the Cockpit cards are all derived from what is declared here, which is why none of them is editable on its own — a semantic definition repeated across projections is the design defect ADR 0004 names.
use majordomus_cli::capability::builtin::lifecycle::{self, EPISODES_URI, RECOVERY_URI};
let m = lifecycle::module();
assert_eq!(m.id.as_str(), "lifecycle");
assert_eq!(m.capabilities.len(), 5);
// the routes are derived from the declaration and written down nowhere else
let routes: Vec<&str> = m
.capabilities
.iter()
.filter_map(|e| e.capability.exposure.http.as_ref().map(|h| h.path.as_str()))
.collect();
assert_eq!(routes, [
"/api/v1/lifecycle/episodes",
"/api/v1/lifecycle/recovery",
"/api/v1/lifecycle/runtime",
"/api/v1/lifecycle/providers",
"/api/v1/lifecycle/closed",
]);
// and the two readable resources are addressed by the constants this module exports,
// so a caller never spells a URI that the declaration does not carry
let resources: Vec<&str> = m
.capabilities
.iter()
.filter_map(|e| e.capability.exposure.mcp.as_ref())
.filter_map(|x| x.resource.as_ref())
.map(|r| r.uri.as_str())
.collect();
assert!(resources.contains(&EPISODES_URI));
assert!(resources.contains(&RECOVERY_URI));