Skip to main content

Module health

Module health 

Source
Expand description

Shared health composer used by the memstead_health MCP tool and any non-MCP caller (CLI, a future HTTP surface).

Lifted from memstead-mcp/src/server.rs::memstead_health_unified so the health read-envelope is produced by one transport-neutral builder with no rmcp type in the path — the MCP wrapper handles drift collection, the schema anchor, the mem_changed notice channel, and CallToolResult wrapping; none of that lives here.

The composer returns the complete health payload as a serde_json::Value (warnings embedded, every include detail section applied). Surface state the engine does not own — the [mutations] posture and the opaque [plugin.*] map — is passed in via HealthConfig as prebuilt JSON so this crate stays free of the MCP server’s config types and the wire bytes stay identical to the pre-lift handler.

Structs§

HealthArgs
Composer input — packed from the MCP HealthParams (or a CLI Args) at the call site. Mirrors the field set the pre-lift handler read off HealthParams.
HealthConfig
Surface-owned config the engine does not carry — supplied prebuilt so the composer inserts the bytes verbatim. mutations is {"require_notes": …}; plugin is the opaque [plugin.*] pass-through object. Only consulted when args.include_config is set.

Enums§

ComposeHealthError
Typed input failures the composer surfaces. The MCP wrapper maps each variant to its existing envelope (UNKNOWN_MEM, INVALID_INPUT) and the engine fault to its typed translator, so the wire code stays put.

Functions§

compose_health
Build the complete health payload. drift_warnings are the reload warnings the wrapper collected before calling in; the composer extends them with the health report’s own warnings, the limit-clamp notice, and unknown-include notices, then embeds the lot under warnings.
render_health_markdown
Render a composed health payload as a human-readable markdown report for the MCP text channel. structured_content remains the source of truth (this is never parsed back); the markdown exists so the text channel is chunkable like memstead_overview instead of a wall of JSON that overflows the response cap under several includes. The size-driving include arrays each render as their own section so the chunker can split a large report cleanly.