Skip to main content

Module emit

Module emit 

Source
Expand description

emit — the whole-store structured dump (a SWEEP, off the loop).

compute walks every content file (sources/ + records/, per the same Store::walk discovery every SWEEP uses — derived index.md catalogs are skipped) plus the root DB.md, and projects each into an EmittedFile: the parsed frontmatter with values verbatim, the derived fields (layer, type, effective meta-type, title, summary, timestamps), the verbatim body, the normalized wiki-link targets, and the SHA-256 of the raw file bytes. The host-integration surface: a hub, an indexer, or a migration ingests a store as a pure consumer of dbmd output instead of reimplementing the parse.

Lenient by design. A dump must describe the store as it is, so a malformed file degrades instead of aborting the sweep: a file with no frontmatter block emits an empty frontmatter with the whole text as body; unparseable frontmatter YAML emits an empty frontmatter with the after-fence remainder as body; a bad created/updated scalar leaves the typed timestamp unset while the raw value still rides in frontmatter. (Reporting those defects is validate’s job, not the dump’s.) Only real failures — an unreadable file, a broken walk — error.

One notion, shared with the rest of the toolkit. Link extraction is store::extract_edge_targets (fence-aware, alias-stripped, whitespace-trimmed) with the .md extension appended — the same resolution graph applies, in the on-disk spelling a consumer can match against path directly. Scalar coercion and the YAML→JSON value projection are the index module’s (crate::index), so emit and query --json present identical value shapes. The effective meta-type mirrors Frontmatter::effective_meta_type: records only, absent ⇒ fact, declared values verbatim. Title derivation reuses the render module’s CommonMark ATX heading rules.

Structs§

Emit
A computed whole-store dump: every emitted file plus the per-layer tally.
EmittedFile
One file of the dump: the store-relative identity, the parsed frontmatter (values verbatim), the derived fields, the verbatim body, the normalized link targets, and the content hash.

Functions§

compute
SWEEP. Project the whole store into an Emit: every content file via Store::walk (both layers, derived catalogs skipped) plus the root DB.md, sorted by path. Read-only; errors only on real failures (an unreadable file, a broken walk) — malformed content degrades per the module contract, it never aborts the dump.