Skip to main content

Module summary

Module summary 

Source
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 summary length 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 --summary is normalized through (dbmd write/dbmd fm init): it must satisfy SUMMARY_MULTILINE without losing the agent’s content, matching the dbmd fm set path (which preserves the value verbatim) and the SPEC stance that the agent provides the ceiling. The validator surfaces an over-long value as a SUMMARY_TOO_LONG warning, not silent truncation.
compose_default
Compose a deterministic default summary for a file from its type, frontmatter, and body. If the store’s ## Schemas declares a summary_template for 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_LEN chars.
compose_from_body
The body fallback: the file’s first non-heading paragraph, truncated to MAX_SUMMARY_LEN chars (the truncation is applied by normalize).
normalize
Normalize a candidate summary to the full deterministic-floor contract: collapse whitespace (via collapse_whitespace) then truncate to MAX_SUMMARY_LEN chars (never splitting a UTF-8 codepoint). Used by compose_default for the tool-generated floor. Explicit agent summaries go through collapse_whitespace instead, so they are never silently cut.