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.
UnknownSchemaTypes
Unknown type names in a types selection passed to build_schema_payload_scoped — the caller raises a typed refusal naming the valid types (recovery-payload posture, never a silent empty section).

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.

Constants§

DEFAULT_SCHEMA_FULL_BUDGET
Default budget for the UNSCOPED full-verbosity schema reply, in estimated (bytes/4) tokens — ~60 KB of JSON. Calibrated against the primary client’s ~25k real-token response cap: dense JSON tokenizes well above bytes/4, so 15k estimated sits at the cap’s edge. The two measured packages land on the intended sides: default@1.3.0 (~52 KB) keeps serving in full — today’s behaviour on today’s reply sizes — while software@0.4.0 (60.2 KB, the observed harness spill, 2026-08-18 WOENENN ingest) degrades visibly to the per-type steer instead of overflowing the pipe.

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_schema_payload_scoped
build_schema_payload with the serving-shape controls (backlog-sweep plan 06a): type_selection scopes the heavy per-type prose to the named types — the reply carries the full package-level context, the selected types in full, and a types_omitted roster naming what was not served (visible scope, never silent truncation). An unknown name refuses with UnknownSchemaTypes. Under SchemaVerbosity::Lite the selection filters the skeleton the same way (coherent, though the full tier is the use case).
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_entity_markdown_with_signals
Serving-surface variant of render_entity_markdown: when the entity’s type declares signals, the headline (name, value, level per signal) rides in the frontmatter block — the one pre-body slot the format has — and the contributors in a ## Signals section appended after the body, in the style of ## Relations. When the mem’s schema declares labelling, the grounded label rides as _label in the frontmatter and the evidence in a ## Labelling section. None/None renders byte-identically to the canonical form.
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).