Expand description
summary — the deterministic default-summary composer.
Used by dbmd fm init and dbmd write when the agent doesn’t supply a
summary. compose_default renders the type’s summary_template (from
the store’s DB.md ## Schemas) when one is declared, and otherwise falls
back to the body’s first non-heading paragraph. No type carries a built-in
template — the template, like the schema, is the store’s to declare.
Contract: deterministic (same (type, frontmatter, body) → same
string), single-line (newlines collapsed to spaces), and capped at 200
chars (the SPEC readability bound). The tool generates a deterministic
floor; the agent provides the ceiling via dbmd fm set <file> summary='…'.
Constants§
- MAX_
SUMMARY_ LEN - The SPEC’s
summarylength bound, in characters.
Functions§
- collapse_
whitespace - Collapse a candidate summary to the single-line half of the contract:
runs of whitespace (including newlines) become single spaces and the result
is trimmed — but the length is not truncated. This is what an explicit
agent-supplied
--summaryis normalized through (dbmd write/dbmd fm init): it must satisfySUMMARY_MULTILINEwithout losing the agent’s content, matching thedbmd fm setpath (which preserves the value verbatim) and the SPEC stance that the agent provides the ceiling. The validator surfaces an over-long value as aSUMMARY_TOO_LONGwarning, not silent truncation. - compose_
default - Compose a deterministic default
summaryfor a file from itstype, frontmatter, and body. If the store’s## Schemasdeclares asummary_templatefor the type, it is rendered with{field}interpolation; otherwise the default is the body’s first non-heading paragraph. The result is always single-line and ≤MAX_SUMMARY_LENchars. - compose_
from_ body - The body fallback: the file’s first non-heading paragraph, truncated to
MAX_SUMMARY_LENchars (the truncation is applied bynormalize). - normalize
- Normalize a candidate summary to the full deterministic-floor contract:
collapse whitespace (via
collapse_whitespace) then truncate toMAX_SUMMARY_LENchars (never splitting a UTF-8 codepoint). Used bycompose_defaultfor the tool-generated floor. Explicit agent summaries go throughcollapse_whitespaceinstead, so they are never silently cut.