Skip to content

Derive the family enumeration instead of trusting it: the check that verified itself - #340

Merged
brettheap merged 2 commits into
mainfrom
change/add-family-enumeration-check
Aug 25, 2026
Merged

brettheap merged 2 commits into
mainfrom
change/add-family-enumeration-check

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

The commission

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.

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-check and add-duplicate-packet-check each restated ONE of that requirement's EIGHT scenarios. Because MODIFIED replaces 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-template registered 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:

  1. Dispositions would collide. Entries key on (family, repo, path). This family reports against openspec/specs/doc-health/spec.md, a path document-catalog also reports against — so folding it in would let one citation buy silence for two unrelated governance decisions.
  2. The remedy is its own. Its action line is "restate the enumeration and its counts from families.FAMILIES". No existing family's action string says anything like that, and a family carries one.
  3. The machinery is free — report section, ranked-plan line, disposition keying, and inclusion in the suite that gates every PR.

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.

⚠️ Four orchestrator decisions — FLAGGED FOR VETO

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 by test_lifecycle_scan_set.py, which asserts _lifecycle_scope appears 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

warning severity, and deliberate absence from FAMILY_RESOLUTION so a resolved finding cannot become an error via 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:

[warning] openspec/specs/doc-health/spec.md
   the promoted requirement omits 1 of the 21 registered check families: 'family-enumeration'
[warning] openspec/specs/doc-health/spec.md
   the promoted requirement says 'twenty' check families, but 21 are registered — expected 'twenty-one'
[warning] openspec/specs/doc-health/spec.md
   the promoted requirement says 'Four' of 'twenty', but 21 families are registered

Step 2 — this change's delta written. The same call:

0 findings

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_halves asserts the zero, and test_this_changes_own_delta_is_the_statement_under_test asserts 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:

canon scenarios: 8 | delta: 8
missing: none
byte-identical scenarios: 7/8
  DIFFERS: #### Scenario: A run executes the check families   (one new AND bullet, this change's own)

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

half measurement findings
canon (branch point, before this change registers anything) 20 names, all resolving; total twenty, split Four of the twenty, remainder sixteen (20−4) 0
delta (this change's own, the only active restatement) total twenty-one, 21 names, split Four of the twenty-one, remainder seventeen 0

Fixture evidence, both directions

fixture expectation
family-enumeration-missing-name fires — names the omitted 'family-enumeration'
family-enumeration-stale-numeral fires on numerals only, names complete — proves the halves independent
family-enumeration-unknown-name fires — 'phantom check' reported, not approximated
impossible remainder (hand-built statement) fires — "does not add up", expected 'seventeen'
unreadable numeral fires — reported, not coerced to zero
family-enumeration-thin-delta fires on the DELTA's path — "omits 19 of the 21", canon not reported
family-enumeration-clean quiet
family-enumeration-pending quiet — canon at twenty, complete delta at twenty-one
family-enumeration-no-spec skip with notice

Two things decided beyond the brief, both recorded not fixed

  • § 5.2 — FAMILY_IDS is missing two entries. Nineteen entries against a registry of twenty-one: proposal-origin (a defect that capability already records) and staged-topic-template run and report findings with no report section of their own. I chose FAMILIES as 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.
  • § 5.3 — the scenario-completeness half, which is the half that actually destroyed text. This check derives the ENUMERATION and the COUNTS, which is what § 5.5 commissioned. A MODIFIED block 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, without roster. Declared rather than absorbed into a looser matcher, because a normalization loose enough to bridge roster would also bridge a genuine mismatch. test_every_alias_is_load_bearing asserts 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 ffdca83f worktree after merging main (which landed mid-work and touched no file of mine):

gate main ffdca83f this branch
python3 -m pytest tests/doc-health 868 passed, 7 skipped 888 passed, 7 skipped (+20)
openspec validate --all --strict 75 passed, 0 failed (75 items) 76 passed, 0 failed (76 items) (+1)
openspec validate add-family-enumeration-check --strict — valid, exit 0
scripts/doc-health.py --single-repo . 5 critical, 8 error, 73 warning, 4 info identical

Single-repo report differs by exactly four lines — the new family's own empty section:

139a140,143
> ### family-enumeration
>
> No findings.
>

All three of doc-health's own now-registered self-checking families read this branch clean at --fail-on error:

PROMOTION_FIDELITY_GATE_EXIT=0
DUPLICATE_PACKET_GATE_EXIT=0
FAMILY_ENUMERATION_GATE_EXIT=0

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, merged origin/main at ffdca83f. 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

brettheap and others added 2 commits August 25, 2026 09:06
…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]>
Copilot AI lite review requested due to automatic review settings August 25, 2026 13:09

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brettheap! 👋

Your private repo does not have access to Sourcery.

Please upgrade to continue using Sourcery ✨

@brettheap
brettheap merged commit 253c5e8 into main Aug 25, 2026
2 of 3 checks passed
@brettheap
brettheap deleted the change/add-family-enumeration-check branch August 25, 2026 13:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-empty deltas branch 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"))
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants