Skip to main content

Module parser

Module parser 

Source
Expand description

parser — read and write db.md markdown files.

Parses the YAML frontmatter block, the markdown body, wiki-links, standard markdown links, ## sections, and the structured sections of the DB.md config file. Also the atomic writer that round-trips a file while preserving the operator-edited body verbatim and emitting frontmatter in canonical key order.

Strict on required fields, lenient on unknowns: any frontmatter key the spec doesn’t recognize is preserved in Frontmatter::extra as ambient context and round-tripped untouched.

Structs§

Config
The parsed structured content of a store’s DB.md config file.
FieldSpec
One field declaration inside a Schema: - <name> (<modifiers>).
Frontmatter
The parsed YAML frontmatter of a db.md file.
MarkdownLink
A standard markdown link [text](url) — an external reference, kept in a stream separate from WikiLink so external targets are visible to the toolkit without being conflated with in-store edges. Not graph-validated.
ParsedFile
The result of splitting a raw file into its frontmatter block and body.
Schema
A custom (or canonical-override) type schema parsed from a DB.md ### <type> sub-section.
Section
A ##/### section of a markdown body: the heading text plus the byte slice of the body it spans (heading line through the line before the next heading of equal-or-shallower depth).
WikiLink
A wiki-link reference inside the store: [[target]] or [[target|display]].

Enums§

ParseError
Errors produced while parsing a markdown file or the DB.md config.
Shape
A recognized shape modifier for a schema field. Validate enforces the corresponding value shape (SCHEMA_SHAPE_MISMATCH on violation).

Functions§

detect_flow_form_link_lists
Detect the frontmatter wiki-link-list mis-encoding: a wiki-link list written so YAML parses it as nested sequences instead of a clean list of strings. Returns the offending keys so validate can emit WIKI_LINK_FLOW_FORM_LIST.
extract_markdown_links
Extract every standard markdown link [text](url) from a body into a separate stream, kept distinct from wiki-links.
extract_sections
Extract the ##/### sections of a markdown body into a flat list with body slices.
extract_wiki_links
Extract every wiki-link from a body (and inline frontmatter), returning the structured WikiLink stream with short-form / .md-extension flags and (file, line, col) locations set.
parse_db_md
Parse a store’s DB.md file into a Config: the ## Agent instructions prose, ## Policies (### Frozen pages + ### Ignored types), and ## Schemas (### <type> field-bullet blocks). Unrecognized sections are ignored; absent sections leave their Config fields at default.
parse_field_spec
Parse a single ## Schemas field-bullet line — - <name> (<modifiers>) — into a FieldSpec, capturing recognized modifiers and stashing the rest in FieldSpec::unknown_modifiers.
read_file
Read a file from disk and parse it into typed Frontmatter plus the verbatim body string.
split_frontmatter
Split a file’s full text into its frontmatter block and body. The frontmatter block must be the very first thing in the file, delimited by --- on its own line at start and end. Returns ParseError::MissingFrontmatter if absent.
write_file
Atomically write a markdown file from frontmatter + body: emit the frontmatter in canonical key order, then the body verbatim, via a temp-file-rename so a reader never sees a half-written file. Preserves the operator-edited body exactly as given.