Skip to main content

Module render

Module render 

Source
Expand description

Markdown rendering of Engine result types.

Shared by memstead-mcp (wraps output in MCP CallToolResult) and memstead-cli (prints directly to stdout).

Structs§

ListResultEnvelope
Envelope for a full ListResult. The engine-meta counters carry the same _-prefixed wire keys as SearchResultEnvelope (and as both surfaces’ markdown form) so an agent moving between memstead list --json and memstead search --json parses one envelope-meta convention. The _ prefix reads as “engine-meta, not entity content”.
SearchHitEnvelope
Envelope wrapping a SearchHit with precomputed summary fields.
SearchResultEnvelope
Envelope for a full SearchResult: _-prefixed engine-emitted counters at the top level, facets as a structured object (not a markdown blob), and the full per-hit shape (score, score_breakdown, matched_terms, expansion) inherited verbatim from SearchHit so the structured envelope is the branching surface — agents reading structured_content don’t have to parse the text channel’s rendered prose to recover scores or score components. CLI --json and MCP structured_content share this shape.

Enums§

OriginClass
Trust origin of a schema (or the mem that pins it), decided at adopt/write time and reported — never re-derived — on the read path.
SchemaVerbosity
Verbosity selector for build_schema_payload.

Functions§

build_entity_envelope
Build the structured memstead_entity envelope. Identity fields (_hash, id, mem, type, title, _stub_kind) come from the parsed Entity and live at the top level. Every schema-declared frontmatter key surfaces under a nested metadata: {...} map — its single home. Read a metadata value as envelope.metadata.<key>; generic consumers iterate the map without per-type branching. The prior shape additionally hoisted level/stability/created_date/last_modified to the top level, serialising those fields twice; that hoist is gone. The read-only identity triple (mem/id/type) is excluded from the nested map — it appears only top-level — and underscore-prefixed internal keys (_hash, _tokens*, _mem_schema, _stub_*) live in dedicated top-level slots and never appear inside the nested map. sections and relationships round-trip the engine’s internal IndexMap / Vec shapes verbatim. _tokens is computed from the rendered body (filter and opt-in inserts applied) so agents can pre-size before a follow-up token_budget-bounded read. _mem_schema rides when the workspace pinned a schema for the mem.
build_list_envelope
Build a ListResultEnvelope borrowing from result.
build_schema_payload
build_search_envelope
Build a SearchResultEnvelope borrowing from result.
manual_authoring_str
Stable wire string for the manual_authoring posture.
per_edge_description_str
Render a PerEdgeDescription to its wire literal — bit-identical to what the schema YAML accepts so consumers can echo the value back without case fiddling. forbidden (the default) is emitted explicitly rather than omitted so a schema without an explicit declaration still surfaces the resolved posture on the wire.
render_community_context_section
Render a ## Community Context section — cluster id + neighbor list — appended to memstead_entity output when include_context: true. No frontmatter; the entity body owns that.
render_context_markdown
Render context (community cluster) as markdown.
render_entity_markdown
Render a single entity as markdown with frontmatter metadata.
render_list_markdown
Render list results as markdown.
render_overview_markdown
Render overview (all clusters) as markdown. store provides entity titles for the on-the-fly auto-summary (title-join) — there is no stored summary.
render_relations_json
Render outgoing/incoming relations as a JSON envelope. Consumed by memstead-cli relations --json; no MCP path uses it.
render_relations_markdown
Render a ## Relations section as markdown — typed edges grouped by direction. Appended to memstead_entity output when include_relations: true. A JSON-shaped version is available via render_relations_json for the memstead-cli relations --json consumer.
render_search_markdown
Render search results as markdown.
render_type_catalog_markdown
Render the full schema catalog as markdown — built-in default types.
render_type_catalog_markdown_for
Render the type catalog for an arbitrary loaded Schema. Same shape as render_type_catalog_markdown; iterates the schema’s own types in name order so multi-mem workspaces can describe the schema pinned by the writable mem, not the engine’s hard-coded built-in.
render_type_info_markdown
Render a single type’s definition as agent-friendly markdown.
rendered_body_tokens
Token estimate for an entity’s rendered body (title + sections + relationships, filter applied) — the exact number render_entity_markdown embeds as its frontmatter _tokens. Use this when building a structured envelope so the envelope’s _tokens and the markdown channel’s frontmatter _tokens describe the same thing for a given _hash: the rendered body, not the full markdown document (which would additionally count frontmatter).