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.mdconfig file. - Field
Spec - One field declaration inside a
Schema:- <name> (<modifiers>). - Frontmatter
- The parsed YAML frontmatter of a db.md file.
- Markdown
Link - A standard markdown link
[text](url)— an external reference, kept in a stream separate fromWikiLinkso external targets are visible to the toolkit without being conflated with in-store edges. Not graph-validated. - Parsed
File - 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). - Wiki
Link - A wiki-link reference inside the store:
[[target]]or[[target|display]].
Enums§
- Parse
Error - Errors produced while parsing a markdown file or the
DB.mdconfig. - Shape
- A recognized shape modifier for a schema field. Validate enforces the
corresponding value shape (
SCHEMA_SHAPE_MISMATCHon 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
WikiLinkstream with short-form /.md-extension flags and(file, line, col)locations set. - parse_
db_ md - Parse a store’s
DB.mdfile into aConfig: the## Agent instructionsprose,## Policies(### Frozen pages+### Ignored types), and## Schemas(### <type>field-bullet blocks). Unrecognized sections are ignored; absent sections leave theirConfigfields at default. - parse_
field_ spec - Parse a single
## Schemasfield-bullet line —- <name> (<modifiers>)— into aFieldSpec, capturing recognized modifiers and stashing the rest inFieldSpec::unknown_modifiers. - read_
file - Read a file from disk and parse it into typed
Frontmatterplus 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. ReturnsParseError::MissingFrontmatterif 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.