Repository navigation
Derive the family enumeration instead of trusting it: the check that verified itself - #340
Merged
Merged
Conversation
…verified itself Brett commissioned this on 2026-08-25, verbatim: "commission the §5.5 enumeration check" - the variant add-duplicate-packet-check recorded and left named at its archive. doc-health's own "Deterministic check families" requirement names every family and counts them three times in prose, and every new family must restate the whole requirement to add itself. A requirement every new family must restate is a requirement every new family can truncate. It broke THREE TIMES IN THREE DAYS and a human caught it every time: three sibling changes each restated ONE of its EIGHT scenarios, and because MODIFIED replaces a requirement wholesale each would have destroyed seven on promotion with the file-level scenario count never moving. The enumeration half had drifted more quietly before that - staged-topic-template registered 2026-08-15 and stayed uncounted until the 23rd. The twenty-first family derives the enumeration and all three numerals from families.FAMILIES. Two halves: CANON compares the promoted requirement, and the ACTIVE-DELTA half - the real prevention - compares every in-flight change that restates it, so a truncation is reported at authoring time rather than at an archive gate. Where two or more active deltas restate it, each is checked independently, because whichever archives last is the one canon keeps. Canon is exempt from the count comparison while an active delta restates the requirement, and that is the load-bearing rule rather than a hole: a change registering family N+1 leaves canon at N until it archives, so canon is PENDING there, not divergent. Without it this family would fire on every legitimate family-adding branch including its own, and a check that reports healthy work is a check someone disables. A fixture pins that negative quiet. THE IRONY IS THE ACCEPTANCE TEST, and it was run as two steps. Adding the check as a new family forced exactly the enumeration restatement it polices. With the family registered and no delta written it reported THREE findings against canon, each naming what diverged: the omitted 'family-enumeration', the stale total 'twenty' where twenty-one are registered, and the stale subset total. With this change's delta written the same call reports ZERO. Its own restatement was verified by its own check before it could be committed. Two tests pin it - one asserts the zero, one asserts the delta half actually read this delta so the first cannot pass vacuously. The archive lesson was heeded: the MODIFIED block restates all EIGHT scenarios, verified scenario-by-scenario against canon - seven byte-identical, the eighth differing by exactly one AND bullet, this change's own - and the three notes canon already carries about its own past repairs are restated verbatim, because dropping them would be the same destruction class in a new coat. Nineteen of canon's twenty prose names normalize to registry ids mechanically. ONE does not, and it is a declared alias rather than an absorbed looseness: canon's "client identity roster composition" is registered client-identity-composition, without roster. A test asserts every alias still fails to normalize mechanically, so a rename that makes one redundant fails loudly instead of leaving a private dictionary of forgiveness behind. The whitespace flattening in the parser was found by failing rather than designed: canon wraps this requirement mid-phrase across six lines, so matching raw prose found no total at all and would have reported a healthy requirement as unreadable. Caught on the first run against the real tree. Advisory at launch in both halves - warning severity and deliberate absence from FAMILY_RESOLUTION - kept even though the corpus measures clean, because the population this gate would red is every FUTURE family-adding branch and cannot be measured in advance. Sequencing the flip behind a measured population is the rule this campaign has applied twice; treating it as an obstacle because today's reading is zero would be learning the wrong lesson from two easy flips. Two adjacent gaps recorded rather than folded in. §5.2: FAMILY_IDS carries nineteen entries against a registry of twenty-one, so proposal-origin and staged-topic-template report findings with no section of their own; this family checks only the other direction, and a test pins the count at exactly those two so a third cannot join them silently. §5.3: the scenario-completeness half is the one that actually destroyed text, and this check does not cover it - a block restating the enumeration perfectly and still dropping scenarios would pass. Measured clean today, so the box is prevention rather than backlog. doc-health 888 passed / 7 skipped against main's 868/7. openspec --all --strict 76 items against 75. Single-repo report differs from main by exactly four lines, all the new family's own empty section, headline unchanged at 5 critical, 8 error, 73 warning, 4 info. Both enforcing families read this branch clean at --fail-on error, exit 0. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
Hi @brettheap! 👋
Your private repo does not have access to Sourcery.
Please upgrade to continue using Sourcery ✨
There was a problem hiding this comment.
Pull request overview
Adds an advisory family-enumeration doc-health family that validates registered family names and counts in canon and active deltas.
Changes:
- Implements enumeration parsing, validation, and reporting.
- Registers the new family and updates lifecycle/reporting metadata.
- Adds fixtures, tests, documentation, and OpenSpec change files.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Reviewed change / final comments |
|---|---|
tests/doc-health/test_lifecycle_scan_set.py |
Classifies the new family as a non-reader. |
tests/doc-health/test_family_enumeration.py |
Adds enumeration checker and self-gate tests. |
tests/doc-health/fixtures/family-enumeration-unknown-name/alphaFactory/openspec/specs/doc-health/spec.md |
Unknown-name fixture. |
tests/doc-health/fixtures/family-enumeration-thin-delta/alphaFactory/openspec/specs/doc-health/spec.md |
Thin-delta canon fixture. |
tests/doc-health/fixtures/family-enumeration-thin-delta/alphaFactory/openspec/changes/add-something/specs/doc-health/spec.md |
Thin active-delta fixture. |
tests/doc-health/fixtures/family-enumeration-stale-numeral/alphaFactory/openspec/specs/doc-health/spec.md |
Stale-numeral fixture. |
tests/doc-health/fixtures/family-enumeration-pending/alphaFactory/openspec/specs/doc-health/spec.md |
Pending canon fixture. |
tests/doc-health/fixtures/family-enumeration-pending/alphaFactory/openspec/changes/add-something/specs/doc-health/spec.md |
Complete pending-delta fixture. |
tests/doc-health/fixtures/family-enumeration-no-spec/betaFactory/openspec/specs/solo/spec.md |
No-spec skip fixture. |
tests/doc-health/fixtures/family-enumeration-missing-name/alphaFactory/openspec/specs/doc-health/spec.md |
Missing-name fixture. |
tests/doc-health/fixtures/family-enumeration-clean/alphaFactory/openspec/specs/doc-health/spec.md |
Clean enumeration fixture. |
scripts/doc_health/family_enumeration.py |
Implements the checker. Critical (1 vote): only genuine MODIFIED Requirements headings should suppress canon checking. Moderate: missing remainder claims can pass (4 votes); missing canon requirements are silently ignored (2 votes); multiple active deltas lack coverage (3 votes); duplicate-name handling lacks coverage (3 votes); number-word parsing stops at thirty-five without a supported-range guard (2 votes). |
scripts/doc_health/families.py |
Registers the new family. |
scripts/doc_health/__init__.py |
Adds reporting registration. |
README.md |
Documents the active change. |
openspec/changes/add-family-enumeration-check/tasks.md |
Records implementation tasks and evidence. |
openspec/changes/add-family-enumeration-check/specs/doc-health/spec.md |
Defines the requirement delta. |
openspec/changes/add-family-enumeration-check/proposal.md |
Documents scope and rationale. |
openspec/changes/add-family-enumeration-check/design.md |
Documents implementation design. |
openspec/changes/add-family-enumeration-check/.openspec.yaml |
Records change metadata. |
Suppressed comments (2)
scripts/doc_health/family_enumeration.py:328
- The diagnostic is required to name the omitted families, but this caps the list at four and replaces the rest with
+N more. The shipped thin-delta case omits 19 of 21, so the finding does not name 15 of the actual divergence. Emit the complete list (or one finding per missing id) so the rule is actionable.
missing = [f for f in registry if f not in set(resolved)]
if missing:
shown = ", ".join(repr(f) for f in missing[:4])
if len(missing) > 4:
shown += f", +{len(missing) - 4} more"
tests/doc-health/test_family_enumeration.py:164
- This is described as a real-corpus check of both halves, but the current tree contains this active restatement, so
fam_family_enumeration()takes the non-emptydeltasbranch and intentionally skips canon. The assertion therefore proves only that the delta is clean; it would still pass if the canonical requirement were stale or malformed. Add a separate no-active-delta/snapshot assertion for the canon half.
assert fe.fam_family_enumeration(Ctx()) == []
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+357
to
+361
| if st.remainder_word is not None and st.readers_word is not None: | ||
| remainder = word_to_int(st.remainder_word) | ||
| readers = word_to_int(st.readers_word) | ||
| if remainder is None: | ||
| add(f"{where} states a remainder this check cannot read: " |
Comment on lines
+423
to
+425
| canon = _canon_statement(root) | ||
| if canon is not None: | ||
| findings.extend(_check(canon, registry, repo)) |
Comment on lines
+417
to
+419
| deltas = _delta_statements(root) | ||
| for st in deltas: | ||
| findings.extend(_check(st, registry, repo)) |
Comment on lines
+332
to
+335
| duplicates = sorted({f for f in resolved if resolved.count(f) > 1}) | ||
| if duplicates: | ||
| add(f"{where} names {', '.join(repr(d) for d in duplicates)} more " | ||
| f"than once") |
Comment on lines
+114
to
+118
| "twenty": 20, "twenty-one": 21, "twenty-two": 22, "twenty-three": 23, | ||
| "twenty-four": 24, "twenty-five": 25, "twenty-six": 26, | ||
| "twenty-seven": 27, "twenty-eight": 28, "twenty-nine": 29, | ||
| "thirty": 30, "thirty-one": 31, "thirty-two": 32, "thirty-three": 33, | ||
| "thirty-four": 34, "thirty-five": 35, |
Comment on lines
+269
to
+273
| for path in sorted(changes.glob("*/specs/doc-health/spec.md")): | ||
| if "archive" in path.relative_to(changes).parts[:1]: | ||
| continue | ||
| st = parse_statement(path.relative_to(tree_root).as_posix(), "delta", | ||
| path.read_text(encoding="utf-8", errors="replace")) |
This was referenced Aug 25, 2026
brettheap
added a commit
that referenced
this pull request
Aug 27, 2026
… 8) (#419) The packet's § 2.5 was the last open build box and it named its own gate: merge-plus-green, with the MODIFIED block re-verified scenario-by-scenario against the canon of the day. Both halves hold. WHY NOW. `add-modified-block-currency-check` (ratified 2026-08-27, PR #407, merge d03c03c) registers doc-health's twenty-second family, and its D5 plus its tasks.md § 2.1 price this archive as a precondition: fam_family_enumeration checks every ACTIVE change's restatement of "Deterministic check families" against the live registry, and this packet's own delta says twenty-one. The twenty-second family's enumeration block is owed at ITS realization, relative to this outcome. REALIZATION, re-verified ancestors of origin/main at the gate rather than read out of a PR body: PR #340 -> 253c5e8 (the family, advisory at launch; its own commit bc779dc) and PR #343 -> 1bf1653 (§ 5.2's ruled FAMILY_IDS repair). The advisory launch is intact in the live tree: family-enumeration registered in FAMILIES (21), present in FAMILY_IDS (21), ABSENT from FAMILY_RESOLUTION. GATE NUMBERS, all measured in this worktree at base 501a3ae. Before: pytest tests/doc-health 980 passed / 0 failed; openspec validate --all --strict 76 passed, 0 failed (76 items) = 24 active + 52 specs; doc-health --single-repo 5 critical, 8 error, 42 warning, 6 info, 0 new regressions; the family alone 0/0/0/0. After: pytest 980 passed / 0 failed; validate 75 passed, 0 failed (75 items) = 23 active + 52 specs; the severity headline BYTE-IDENTICAL. The whole report diff is eight non-finding lines: canon words 203344 -> 204720 (+1376, the promoted block), governance words 656227 -> 657603 (+1376, the same words moving from active-change prose to promoted prose), canon share 31.0% -> 31.1%, and the promoted-specs row of the per-source table. PER-REQUIREMENT PROMOTION VERIFICATION, before the act. Canon's "Deterministic check families" requirement is byte-IDENTICAL between fe34b73 — the branch point the delta was written against — and 501a3ae: extracted from both trees and diffed, 0 hunks. Canon did not move under this packet, so the block reverts nothing. Scenarios 8 -> 8: identical title set and order; `A run executes the check families` 11 -> 12 bullets, the twelfth this change's own family- enumeration AND bullet; the other seven byte-identical bullet for bullet. THE TWO BODY-UNIT DIFFERENCES, named rather than glossed — both this packet's declared numeral rewording, which is the count chain § 1.3 says it moves: (1) `SHALL implement twenty check families ... release-inventory drift, and duplicate packet.` -> `twenty-one ... duplicate packet, and family enumeration.` (2) `Four of the twenty ... the other sixteen families` -> `Four of the twenty-one ... the other seventeen families` Verified against the LIVE registry rather than re-typed: len(FAMILIES) = 21, block total `twenty-one`, 21 enumerated names with 0 failing to resolve (one declared alias, client-identity-roster-composition -> client-identity- composition), and 21 - 4 = 17. CANON AFTER THE ACT is what the block implies and nothing else: 128 insertions, 6 deletions — every deletion a re-wrapped line of those two sentences plus the continuation line the new figure sentence extends. Requirements 32 -> 33, file scenarios 133 -> 141 (+8, the ADDED requirement's own eight), per-requirement counts unchanged everywhere else. ONE TEST RE-AIMED BY THE ACT, NOT DELETED, and recorded as a consequence rather than a defect. test_this_changes_own_delta_is_the_statement_under_test was the anti-vacuity guard on § 4.1's self-gate: it asserted the DELTA half found this change's own active delta. The act promoted that block, so no active change restates the requirement and _delta_statements legitimately returns nothing — the guard's subject moved into canon with the statement. It is now test_canon_is_the_statement_under_test, the same three assertions one document over, with the history in its docstring. The delta half's own discovery stays covered by § 1's fixture tests. § 5.3 IS TICKED AS DISCHARGED-ELSEWHERE, not as work done here: add-modified-block-currency-check is exactly the scenario-completeness half this box named, and its spike found two ledger units on this packet's own block — the two dispositioned above. § 5.1, the flip to enforcing, stays UNTICKED: it is owed on a measured population that by construction cannot be taken in advance, and leaving the box open is what keeps that visible. Co-authored-by: brettheap <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The commission
Brett commissioned this on 2026-08-25, verbatim:
The variant
add-duplicate-packet-checkrecorded and left named at its archive.Why
doc-health's own "Deterministic check families" requirement names every check family and counts them three times in prose — the total, the scan-set subset ("Four of the twenty"), and the remainder ("the other sixteen"). Every new family must restate the whole requirement to add itself. A requirement every new family must restate is a requirement every new family can truncate.It broke three times in three days, and a human caught it every time.
add-release-inventory-drift-check,add-promotion-fidelity-checkandadd-duplicate-packet-checkeach restated ONE of that requirement's EIGHT scenarios. BecauseMODIFIEDreplaces a requirement wholesale, each would have destroyed seven scenarios on promotion — and the file-level scenario count would never have moved, because the seven lost exactly offset the seven the change's own ADDED requirement brought.The enumeration half had drifted more quietly before that:
staged-topic-templateregistered 2026-08-15 and stayed uncounted until the 23rd.families.py's own docstring already had the lesson in one line — "a number that only a human re-reads is a number that drifts."Architecture: the twenty-first family — and the irony decided it
Chosen: a new family (
scripts/doc_health/family_enumeration.py), not a checker folded into an existing family or a standalone validator. Three reasons from the code, in decreasing abstraction:(family, repo, path). This family reports againstopenspec/specs/doc-health/spec.md, a pathdocument-catalogalso reports against — so folding it in would let one citation buy silence for two unrelated governance decisions.families.FAMILIES". No existing family's action string says anything like that, and a family carries one.But the deciding reason is the irony. A twenty-first family forces exactly the enumeration restatement it polices. A checker hidden inside an existing family would not have forced it, and would therefore never have exercised its delta half on real text. Because it is a family, this change's own restatement became the check's first live subject.
The commissioning ruling covers the decision to build. These four were taken by the orchestrating session under standing patterns.
D1 — Canon half: the name-set AND every numeral
The promoted enumeration must name exactly the registered families, each once, and its three numerals must be arithmetically true of that set. Each divergence class fires separately and names precisely what diverged. The three numerals are checked as a system, so a stale total does not also report as a broken remainder — fixtures prove the classes separate, because a build that reported every numeral for one root cause would bury the defect.
The scan-set count (
Four) is canon's own claim and is deliberately NOT derived. No runtime registry of scan-set readers exists; that boundary is already pinned structurally bytest_lifecycle_scan_set.py, which asserts_lifecycle_scopeappears in exactly the four declared readers' source. This family verifies the arithmetic around that number rather than inventing a second authority for it — the two-readers-disagree problem this codebase keeps paying for.D2 — The active-delta half is the real prevention
Any ACTIVE change whose delta restates the requirement must carry the complete enumeration, consistent with the registry in its own tree. A change registering family N+1 also states N+1 in its delta, so the comparison is self-consistent and the truncation is reported at authoring time instead of at an archive gate. Where two or more active deltas restate it, each is checked independently — whichever archives last is the one canon keeps.
Canon is exempt from the count comparison while an active delta restates it. This is the load-bearing half, not a hole: a change registering family N+1 leaves canon at N until it archives — canon is pending, not divergent. Without it this family would fire on every legitimate family-adding branch including its own, and a check that reports healthy work is a check someone disables. A fixture pins that negative quiet.
D3 — Advisory at launch, and BOTH halves
warningseverity, and deliberate absence fromFAMILY_RESOLUTIONso a resolved finding cannot become anerrorvia the uncited-resolution rule. Both pinned by test; flip together, by ruling, in a recorded task box.Kept advisory even though the corpus measures clean — worth stating because the temptation runs the other way. Two of the three siblings have flipped and flips are cheap. But the population this gate would red is not today's canon; it is every future family-adding branch, which cannot be measured in advance. Sequencing behind a measured population is the rule this campaign has applied twice.
D4 — Acceptance both directions, with the self-gate as one of them
Every divergence class fires on its own fixture, asserted on rule text rather than counts; the lawful patterns stay quiet; and the real corpus reads zero on both halves — asserted by a test, through the family itself.
🎯 The self-gate: the check verifying its own restatement
Run as two steps, and this is the acceptance evidence the architecture bought:
Step 1 — family registered, delta not yet written. Three findings against canon, each naming exactly what diverged:
Step 2 — this change's delta written. The same call:
Its own restatement was verified by its own check before it could be committed. A wrong restatement here could not have landed, because the thing it would have corrupted was standing at the gate. Two tests pin it —
test_the_real_corpus_reads_zero_on_both_halvesasserts the zero, andtest_this_changes_own_delta_is_the_statement_under_testasserts the delta half actually read this delta, so the first cannot pass vacuously.The archive lesson, heeded
The MODIFIED block restates all eight of the requirement's scenarios. Verified scenario-by-scenario against canon:
The three notes canon already carries about its own past repairs are restated verbatim — dropping them would be the same destruction class in a new coat.
Real-corpus figures, both halves
twenty, splitFour of the twenty, remaindersixteen(20−4)twenty-one, 21 names, splitFour of the twenty-one, remainderseventeenFixture evidence, both directions
family-enumeration-missing-name'family-enumeration'family-enumeration-stale-numeralfamily-enumeration-unknown-name'phantom check'reported, not approximated'seventeen'family-enumeration-thin-deltafamily-enumeration-cleanfamily-enumeration-pendingfamily-enumeration-no-specTwo things decided beyond the brief, both recorded not fixed
FAMILY_IDSis missing two entries. Nineteen entries against a registry of twenty-one:proposal-origin(a defect that capability already records) andstaged-topic-templaterun and report findings with no report section of their own. I choseFAMILIESas the enumeration authority —families.py's own docstring says "FAMILIES… is the count" — and this family checks only the other direction (no section promised for a family that does not run). A test pins the count at exactly those two so a third cannot join silently. Not repaired here: it would put unrelated report output on this feature's evidence.MODIFIEDblock restating the enumeration perfectly and still dropping scenarios would pass it — and dropping scenarios is exactly what all three siblings did. Measured clean today, so the box is prevention rather than backlog. Flagging it plainly: this change does not close the class, it closes the half that was commissioned.Also: one declared alias. Nineteen of canon's twenty prose names normalize to registry ids mechanically; one does not — canon's "client identity roster composition" is registered
client-identity-composition, withoutroster. Declared rather than absorbed into a looser matcher, because a normalization loose enough to bridgerosterwould also bridge a genuine mismatch.test_every_alias_is_load_bearingasserts each entry still fails to normalize mechanically.And one bug found by failing rather than by design: the parser's whitespace flattening. Canon wraps this requirement mid-phrase across six lines, so matching raw prose found no total at all and would have reported a healthy requirement as unreadable. Caught on the first run against the real tree, recorded in tasks § 2.2.
Verification
Baselines re-measured on a clean
ffdca83fworktree after merging main (which landed mid-work and touched no file of mine):ffdca83fpython3 -m pytest tests/doc-healthopenspec validate --all --strictopenspec validate add-family-enumeration-check --strictscripts/doc-health.py --single-repo .5 critical, 8 error, 73 warning, 4 infoSingle-repo report differs by exactly four lines — the new family's own empty section:
All three of doc-health's own now-registered self-checking families read this branch clean at
--fail-on error:Exit codes direct:
PYTEST_EXIT=0,ALL_STRICT_EXIT=0,ONE_STRICT_EXIT=0,BRANCH_HEALTH_EXIT=0,MERGE_EXIT=0.Branch point and collisions
Branched from
fe34b73c, mergedorigin/mainatffdca83f. Collision-checked before building and again before pushing — no enumeration check module or change exists on main, and no PR claims one.🤖 Generated with Claude Code