Documentation
¶
Overview ¶
Command docs-guard bounds the size of the package overviews and keeps their heading structure honest.
Run via `make docs-guard`, wired into `make check`. Scans every .md file under docs/knowledge/features and exits non-zero on either of two faults: a file over the size cap, and a line that markdown reads as a heading only because a wrapped paragraph put a ticket reference first.
**Why the size cap.** QMD is the search surface every agent uses. It cuts a document into roughly 900-token chunks, and it does prefer a heading boundary: its break table scores an h1 at 100 down to a bare newline at 1. But it only looks for that boundary inside a narrow window around each 900-token mark. When a document's sections run much larger than one chunk, no heading falls inside the window, so the cut lands on a paragraph break and the chunk carries no heading with it.
Measured 2026-08-31 against the then-315KB v2-session-manager.md, whose sections averaged 7000 bytes: a semantic query, a hybrid query and a keyword query with reranking off, all aimed at a topic whose canonical home was a section of that file, and none of the three returned the file. What came back instead was the frozen docs/knowledge/codebase/ archive. After the split the owning section document ranks first on the same query.
So the cap is really a statement about section size: keep a document small enough that its sections are comparable to a chunk, and the chunker's heading preference starts working for you instead of being unreachable.
**Why the heading check.** A paragraph line that wraps with a ticket reference first, "#1840 (below), and published on...", is a top-level heading as far as markdown is concerned. 72 of them had accumulated across 23 overviews, corrupting every document outline.
**Why code and not a rule in a prompt.** Both faults are produced by the documentation agent, which already carries a prose rule against them. A prose rule is roughly 80% advisory, and the repo's own doctrine is that a safety net for one must be a different fabric: deterministic code, not a second rule that shares the first one's blind spot.