fix(621): make an unparseable decision record loud instead of silently invisible

A file under the record wings that the dependency-free frontmatter reader cannot
parse returned [] and simply vanished from the corpus: decisions_validate.py printed
OK, build_decisions_catalog.py --check said "up to date", the record was absent, and
nothing anywhere errored. Reproduced end-to-end with a YAML block scalar (`rule: >-`),
which is the natural thing to reach for on this corpus's very long rule: values and
which parsed fine under PyYAML before #610's dependency-free reader.

An EXISTING record disappearing was already loud (the no-vanish diff check). The hole
was a NEWLY ADDED record, which that check structurally cannot see — no base state to
diff against — so the author's own PR looks clean. Hence a per-PATH check, not a
per-construct or diff-driven one: asserting "this path yields exactly one keyed
record" turns any present or future reader limitation from silent to loud in one move.

Adds record_wing_files/record_wing_faults to decisions_validate.py, surfaced through
validate() as ERRORS (a file in the record wings that is not a record is a mistake by
definition) and reported first, since a file that failed to parse leaves every
downstream check silently evaluating an incomplete corpus. The five top-level stripped
legacy archive files are exempt — they are generated "Records formerly in this file"
indexes, keyless by construction, and are what keeps older date-based pointers
resolvable.

_read_frontmatter is deliberately NOT extended to accept block scalars; rationale in
the new docs.record-wing-parse-guard record.

8 tests, mutation-verified: with the check neutered 5 go red, restored all 119 pass.
A live-corpus positive control asserts the wings are non-empty so a clean result can
never be vacuous.

Refs #621
This commit is contained in:
2026-07-26 12:03:43 +02:00
parent caf3ca72c1
commit 0f565b1f7e
5 changed files with 243 additions and 1 deletions
+5 -1
View File
@@ -579,7 +579,11 @@ Enforces decision-record lifecycle invariants (ersatztv#521, supersedes the ersa
append-only mechanic): well-formed 5-field metadata, exactly one `active` record per `key`,
reciprocal `supersedes`/`superseded-by` links, no record vanishing from the active set without an
archive copy, no rationale-prose rewrite without a `Decisions-Edit: yes` trailer on a non-merge commit
in the range (ersatztv#609),
in the range (ersatztv#609), a structural per-path check that every `*.md` under
`docs/decisions/records/**` and `docs/decisions/archive/<area>/` parses to **exactly one keyed
record** (ersatztv#621 — without it, a file the dependency-free frontmatter reader cannot parse,
such as one using a YAML block scalar, yields `[]` and vanishes from the corpus with every check
still reporting green; the top-level stripped legacy archive indexes are exempt),
and the generated active catalog (`docs/decisions/README.md`) in sync with source. Two steps:
`scripts/decisions_validate.py --base origin/<base> --head HEAD` (the merge-base diff checks, which
need a base/head range — CI-only) and `scripts/build_decisions_catalog.py --check` (catalog drift).
+1
View File
@@ -66,6 +66,7 @@ the link for rationale. Superseded/retired history lives in `archive/`. Regenera
| `docs.decision-lifecycle` | every decision `##` record (active or archived) carries a 5-field metadata block (`key`, `status`, `since`, `supersedes`, `superseded-by`) checked by `scripts/decisions_validate.py`; a record is never deleted or line-edited to reverse a call — it is moved to `docs/decisions/archive/` with `status: superseded`/`retired` and a reciprocal `superseded-by`/`supersedes` key pair to its replacement. | 2026-07-21 | [link](records/docs/decision-lifecycle.md) |
| `docs.decision-one-file-per-record` | Each decision record is its own file at `docs/decisions/records/<area>/<topic>.md` (archived ones at `docs/decisions/archive/<area>/<topic>.md`) with YAML frontmatter; the filename IS the key, so one-active-record-per-key is a filesystem property rather than a validator check, and supersession is a `git mv`. | 2026-07-25 | [link](records/docs/decision-one-file-per-record.md) |
| `docs.decision-optional-provenance` | Decision records gain two OPTIONAL fields — `stale-after: YYYY-MM-DD` on the metadata line and a `**Sources:**` line in the metadata block; the Open Knowledge Format (OKF) itself is NOT adopted as the record format. | 2026-07-25 | [link](records/docs/decision-optional-provenance.md) |
| `docs.record-wing-parse-guard` | `decisions_validate.py` asserts, per PATH, that every `*.md` under `docs/decisions/records/**` and `docs/decisions/archive/<area>/*.md` parses to exactly one record carrying a `key` — an ERROR, not a warning, since a file in the record wings that is not a record is a mistake by definition. The top-level `docs/decisions/archive/*.md` stripped legacy files and `_NON_DECISION_FILES` are exempt (they are generated indexes, not records). `_read_frontmatter` is deliberately NOT extended to accept YAML block scalars: every record value goes on ONE quoted line, and the structural check is what makes that limitation loud instead of silent. | 2026-07-26 | [link](records/docs/record-wing-parse-guard.md) |
| `docs.tracker-comment-retrofit` | When the knowledge exporter flags an over-cap tracker issue and excludes it from ingestion, triage its comments instead of assuming a retrofit is owed — and for each decision-shaped item check the **worked issue first**, because a tracker session comment is by construction a précis of the fuller closing record posted on the issue it narrates. Applied to #237 (111 comments) this yielded **zero** records, so server-management#642's "a fact found only in a #237 comment" retrieval row has no valid subject and its interim target (an already-migrated record) is permanent. | 2026-07-21 | [link](records/docs/tracker-comment-retrofit.md) |
| `ffmpeg.external-logo-graphics-engine` | External-URL channel logos pass through to the graphics engine like any other watermark source; `WatermarkSelector` must never gate them on `File.Exists` (always false for a URL) and never route them through the ffmpeg-native overlay shortcut. | 2026-07-20 | [link](records/ffmpeg/external-logo-graphics-engine.md) |
| `ffmpeg.hls-cold-start-burst` | HLS cold-start latency is fixed with a bounded `-readrate_initial_burst` (gated on FFmpeg ≥6.1 capability detection), not by raising `work_ahead_limit`, which would remove the concurrency guarantee it exists for. | 2026-07-20 | [link](records/ffmpeg/hls-cold-start-burst.md) |
@@ -0,0 +1,50 @@
---
key: docs.record-wing-parse-guard
title: '2026-07-26 — Every file in the record wings must parse to exactly one keyed record; the frontmatter reader stays flat-scalar-only (#621)'
status: active
since: '2026-07-26'
supersedes: none
superseded-by: none
rule: '`decisions_validate.py` asserts, per PATH, that every `*.md` under `docs/decisions/records/**` and `docs/decisions/archive/<area>/*.md` parses to exactly one record carrying a `key` — an ERROR, not a warning, since a file in the record wings that is not a record is a mistake by definition. The top-level `docs/decisions/archive/*.md` stripped legacy files and `_NON_DECISION_FILES` are exempt (they are generated indexes, not records). `_read_frontmatter` is deliberately NOT extended to accept YAML block scalars: every record value goes on ONE quoted line, and the structural check is what makes that limitation loud instead of silent.'
signals: 'record silently invisible, parsed to 0 records, block scalar rule >- , unterminated frontmatter, file vanishes from corpus, validator OK but record absent, catalog up to date but missing, one keyed record per file, stripped legacy archive index exempt · paths: `scripts/decisions_validate.py`, `scripts/decisions_lib.py`, `scripts/tests/test_decisions_validate.py` · issues: #621, #610, #609, #603'
mechanics: '`scripts/decisions_validate.py` -> `record_wing_files` / `record_wing_faults`; `docs/ci-cd.md` -> "`decisions-guard` job"'
---
Found in adversarial review of #610 / PR #619. Nothing enforced that a file under the record wings
is actually a record. A file the dependency-free frontmatter reader cannot parse returns `[]` and
simply **vanishes** — `decisions_validate.py` prints OK, `build_decisions_catalog.py --check` says
up to date, the record is absent from the corpus, and there is no error anywhere.
**This is the corpus's own failure mode turned on itself.** The whole point of the decision system is
retrievability; the one thing worse than a missing record is a missing record that reports success.
Same family as the #609 marker that printed `OK` while doing nothing and the #603 `stale-after` field
that silently never fired.
**What was already safe, and what wasn't.** An *existing* record disappearing was always loud — the
no-vanish diff check catches it. The hole is a **newly added** record, which the diff check
structurally cannot see because there is no base state to compare against, so the author's own PR
looks clean. That asymmetry is why the fix had to be path-driven rather than diff-driven.
**Why per-path rather than per-construct.** Enumerating the YAML the reader rejects would have to be
re-done every time the reader meets something new. Asserting *"this path must yield exactly one keyed
record"* converts **any** present or future reader limitation from silent to loud in one move —
block scalars, indented structure, unterminated frontmatter, a stray note file, an empty file.
**The block-scalar decision: NO.** `rule: >-` is the natural thing to reach for on this corpus's very
long `rule:` values, and under PyYAML it parsed fine — so #610's dependency-free reader *widened* a
hole rather than creating it. Teaching `_read_frontmatter` to fold block scalars was still declined:
- Correct folding is a real subset of YAML (`>` vs `|`, strip/clip/keep chomping, indentation-relative
continuation). A subtly wrong folder is *worse* than a rejection, because it would silently alter
rule text — the exact class of failure this record exists to close — while
`test_frontmatter_reader_matches_pyyaml` (which compares against PyYAML on real records) would keep
passing on the flat records that make up the entire corpus.
- The reader must stay dependency-free: it runs in CI's `decisions lifecycle` job, in the Husky
pre-commit hook, and on every contributor's machine, none of which install anything.
- With the structural check in place the cost of not supporting block scalars is a **loud error
naming the fix**, and all 167 existing records already use single quoted lines. There is no
value a flat scalar cannot hold.
Verified by mutation, not by a green tick: with `record_wing_faults` neutered, five of the new tests
go red; restored, all pass. `test_real_repo_record_wings_are_all_parseable` additionally asserts the
wings are non-empty (>100 files) so a clean result can never be vacuous.