Expand description
Section-body reduction — the markdown half of the section-format vocabulary (agent-toolbox plan 08).
Reduces a section body to its top-level block sequence with a
real CommonMark parser (pulldown-cmark, no default features,
GFM tables via the runtime Options flag). A line-scanner
disagrees with CommonMark on exactly the constructs agents produce
— lazy continuation lines, mixed bullet markers (- then * is
two lists), indented code blocks containing - , GFM tables
degrading to paragraphs on a malformed delimiter row — and a
validator that disagrees with the renderer every agent uses sends
repair loops that cannot converge. The parser is the referee.
The reduction carries, per block kind, exactly the material the
declaration surface checks: list items (text a renderer shows —
lazy continuations joined by a single space), paragraph source
lines, table header + row cells. The expression matching itself
lives in memstead_schema::content_expr — this module only
observes.
Structs§
- Reduced
Block - One top-level block of a section body: what it is, where it starts, and the per-kind material the format checks consume.
- Reduced
Section - The reduced view of one section body.
- Setext
Reserved Heading - A setext heading of depth 1–2 found anywhere in the body. The
byte-class line guard (
^#/^##) cannot see these — only the real parser can — so the reduction reports them for the format-checked-section refusal. - Table
Row - One body row of a reduced table.
Enums§
- Block
Detail - Per-kind check material.
- Section
Format Violation - One violation of a section’s declared format. The serde shape is
the wire
detailspayload of the corresponding refusal code —SECTION_CONTENT_MISMATCH/SECTION_ITEM_PATTERN_MISMATCH/INVALID_TABLE_COLUMNS— plus the reserved-setext case, which rides the pre-existingSECTION_CONTENT_INVALIDfamily.
Functions§
- check_
section_ format - Evaluate one section body against its declared format. Returns
every violation in document order (the write path refuses with the
first; health reports all). A section declaring no
content— or one whose expression failed to compile, which the loader refuses anyway — produces no violations (free-form). - reduce_
section - Reduce a section body to its top-level block sequence.