Repository navigation
modified-block-currency: resolve N-writer ordering as a linear chain of declarations (#627) - #640
Conversation
`modified-block-currency-chains`, on the `-two-writers` tree's convention that one arrangement per capability cannot interfere with another. Seven: a declared chain of three; a chain whose last writer drops the first's addition, so the basis substitution is falsifiable; the REAL-CORPUS shape, where the last writer names a predecessor three links back as well as its own (OpsxFactory's `reanchor-keycloak-broker-to-syscore2` does exactly this, and a rule counting one predecessor per writer would report the compliant corpus as forked); a fork; a cycle; a chain with an unratified writer beside it; and a ratified writer whose only declaration names that unratified one. Inert on its own — the arm reads them in the next commit. Co-Authored-By: Claude Fable 5 <[email protected]>
…627) THE ARM COULD NOT READ A COMPLIANT CORPUS. `_arm_ordering` resolved a group of exactly TWO ratified writers from the declaration between them and reported every larger group as undecided "whatever they declare", recorded at the time as safe because "the population in the real corpus is ZERO". It is now five: OpsxFactory's `aks-administration-workflow` 'Bounded action classes for managed workloads' has five ratified writers, each declaring its predecessor by ratification date (PR #182), and `release-realization`'s "Ordered deltas and branch vocabulary" obligates that declaration from EVERY later writer. A checker that cannot read the shape the rule obliges is reporting its own limitation as a defect. THE SPEC PERMITS IT. `openspec/specs/doc-health/spec.md`'s "Title resolution and the two-writers rule" states ORDER IS BY DECLARATION and constrains the TWO-writer case ("EXACTLY ONE of two active RATIFIED writers SHALL declare"); its scenario opens "two or more active changes ... exactly one declares". No requirement anywhere says "no order for more than two" — that sentence lived only in this module. RESOLVED MEANS ONE TOTAL ORDER, not one edge per writer. `_chain` runs Kahn's algorithm over the declarations with a uniqueness demand at every step, so a REDUNDANT declaration the chain already implies by transitivity resolves rather than forks — which the real corpus needs: `reanchor-keycloak-broker-to-syscore2` names its predecessor AND, three links back, the change it re-anchors. Each later writer is then measured against its predecessor's block, link by link, on the pair path's own ruling that a `MODIFIED` block IS its writer's outcome. FAIL-CLOSED, AND THE DEFECT IS NAMED. Where the declarations state no single chain the group is still reported at the same class and severity, with a rule text saying which: `cycle`, `forked` (two writers declared later than a placed writer and neither later than the other), `unanchored` (more than one starting point), or `outside` — an unanchored group where a writer's only declaration names a writer of this requirement that is NOT ratified, which explains the missing anchor instead of leaving a reader to hunt for it. THE 2-WRITER PATH IS UNTOUCHED, structurally: its branch is still taken first and `test_the_two_writer_path_never_consults_the_chain_rule` makes `_chain` explode while every two-ratified-writer group in the `-two-writers` tree is evaluated. `TEMPLATE_ORDERING`, its class pattern, the shape mask and the report-section contract are all unchanged — only the interpolated `{why}` moves — so no finding class was added and none was re-banded. The three-writers pin is RE-AIMED, not deleted: that fixture never was a chain (one writer declares, one declares nothing), so it is the `unanchored` case, still reported against all three blocks. Its citation in the coverage audit follows it, the audit being a live reference. Measured: OpsxFactory ordering 5 -> 0 with no new finding in any class (carriage ledger 7 -> 3, the four blocks now measured against their predecessors); openxFactory's own family section byte-identical to origin/main's. Ten mutants, ten dead. Co-Authored-By: Claude Fable 5 <[email protected]>
One sentence in the `modified-block-currency` family paragraph: three or more active ratified writers of one requirement resolve where their declarations state a single linear chain, each later block measured against its predecessor's rather than against canon, and a group stating no such chain is still reported and now names the defect. 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.
🟢 Approval recommended
The ordering logic is updated in a narrowly scoped way with comprehensive new fixtures/tests that cover resolving chains, basis propagation, and all named failure modes while preserving the 2-writer path.
Pull request overview
This PR fixes modified-block-currency’s “title resolution and ordering” arm so it can resolve ordering for N≥3 active ratified writers when their proposal.md declarations form a single linear chain (unique topological order), while keeping the 2-writer behavior structurally unchanged. This brings the checker in line with the ratified reading that “the declaration is the ordering” and prevents the tool from reporting its former limitation as a corpus defect.
Changes:
- Implement
_chain(...)(unique-order Kahn/toposort) and extend_arm_ordering(...)to resolve N-writer chains, including specific failure reasons (cycle,forked,unanchored,outside). - Add a new fixtures tree (
modified-block-currency-chains) plus new tests covering resolving chains, basis propagation, redundant edges, and named failure modes; re-aim the prior 3-writer fixture to the now-specificunanchoredcase. - Update documentation and the fixture-coverage audit to reflect the renamed/re-aimed test and the new chain behavior.
File summaries
| File | Description |
|---|---|
| docs/doc-health.md | Documents the new N-writer chain ordering behavior and named failure modes. |
| scripts/doc_health/modified_block_currency.py | Adds _chain and updates ordering resolution to support N-writer declared chains and defect naming. |
| specs/020-modified-block-currency-fixtures/contracts/coverage-audit.md | Updates coverage audit references for the re-aimed 3-writer ordering test. |
| tests/doc-health/test_modified_block_currency.py | Adds chain tests/fixtures wiring and re-aims the preexisting 3-writer fixture test to unanchored. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/chain-basis/spec.md | New promoted spec fixture for chain-basis capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/chain-redundant/spec.md | New promoted spec fixture for chain-redundant capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/chain-three/spec.md | New promoted spec fixture for chain-three capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/cycle-three/spec.md | New promoted spec fixture for cycle-three capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/fork-branches/spec.md | New promoted spec fixture for fork-branches capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/mixed-unratified/spec.md | New promoted spec fixture for mixed-unratified capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/specs/outside-anchor/spec.md | New promoted spec fixture for outside-anchor capability. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-c3-a/proposal.md | New change fixture (proposal) for chain-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-c3-a/specs/chain-three/spec.md | New change fixture (delta) for chain-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-c3-b/proposal.md | New change fixture (proposal) for chain-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-c3-b/specs/chain-three/spec.md | New change fixture (delta) for chain-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-c3-c/proposal.md | New change fixture (proposal) for chain-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-c3-c/specs/chain-three/spec.md | New change fixture (delta) for chain-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cb-a/proposal.md | New change fixture (proposal) for chain-basis. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cb-a/specs/chain-basis/spec.md | New change fixture (delta) for chain-basis. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cb-b/proposal.md | New change fixture (proposal) for chain-basis. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cb-b/specs/chain-basis/spec.md | New change fixture (delta) for chain-basis. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cb-c/proposal.md | New change fixture (proposal) for chain-basis. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cb-c/specs/chain-basis/spec.md | New change fixture (delta) for chain-basis. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-a/proposal.md | New change fixture (proposal) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-a/specs/chain-redundant/spec.md | New change fixture (delta) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-b/proposal.md | New change fixture (proposal) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-b/specs/chain-redundant/spec.md | New change fixture (delta) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-c/proposal.md | New change fixture (proposal) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-c/specs/chain-redundant/spec.md | New change fixture (delta) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-d/proposal.md | New change fixture (proposal) for chain-redundant (includes redundant declaration). |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cr-d/specs/chain-redundant/spec.md | New change fixture (delta) for chain-redundant. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cy-a/proposal.md | New change fixture (proposal) for cycle-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cy-a/specs/cycle-three/spec.md | New change fixture (delta) for cycle-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cy-b/proposal.md | New change fixture (proposal) for cycle-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cy-b/specs/cycle-three/spec.md | New change fixture (delta) for cycle-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cy-c/proposal.md | New change fixture (proposal) for cycle-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-cy-c/specs/cycle-three/spec.md | New change fixture (delta) for cycle-three. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-fk-a/proposal.md | New change fixture (proposal) for fork-branches. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-fk-a/specs/fork-branches/spec.md | New change fixture (delta) for fork-branches. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-fk-b/proposal.md | New change fixture (proposal) for fork-branches. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-fk-b/specs/fork-branches/spec.md | New change fixture (delta) for fork-branches. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-fk-c/proposal.md | New change fixture (proposal) for fork-branches. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-fk-c/specs/fork-branches/spec.md | New change fixture (delta) for fork-branches. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-a/proposal.md | New change fixture (proposal) for mixed-unratified. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-a/specs/mixed-unratified/spec.md | New change fixture (delta) for mixed-unratified. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-b/proposal.md | New change fixture (proposal) for mixed-unratified. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-b/specs/mixed-unratified/spec.md | New change fixture (delta) for mixed-unratified. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-c/proposal.md | New change fixture (proposal) for mixed-unratified. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-c/specs/mixed-unratified/spec.md | New change fixture (delta) for mixed-unratified. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-d/proposal.md | New change fixture (proposal) for mixed-unratified (draft writer). |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-mx-d/specs/mixed-unratified/spec.md | New change fixture (delta) for mixed-unratified (draft writer). |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-a/proposal.md | New change fixture (proposal) for outside-anchor. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-a/specs/outside-anchor/spec.md | New change fixture (delta) for outside-anchor. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-b/proposal.md | New change fixture (proposal) for outside-anchor. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-b/specs/outside-anchor/spec.md | New change fixture (delta) for outside-anchor. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-c/proposal.md | New change fixture (proposal) for outside-anchor (declares to draft). |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-c/specs/outside-anchor/spec.md | New change fixture (delta) for outside-anchor. |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-d/proposal.md | New change fixture (proposal) for outside-anchor (draft writer). |
| tests/doc-health/fixtures/modified-block-currency-chains/alphaFactory/openspec/changes/add-oa-d/specs/outside-anchor/spec.md | New change fixture (delta) for outside-anchor (draft writer). |
Review details
- Files reviewed: 59/59 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Lane: doxbench-stewardship
The defect
scripts/doc_health/modified_block_currency.py's ordering arm resolved a group of exactly TWO ratified writers of one requirement from the declaration between them ("THE DECLARATION IS THE ORDERING", ruled 2026-08-27) and reported every group of three or more as undecided — "the ordering rule states no order for more than two" — regardless of what they declared. That was recorded at the time as safe because "the population in the real corpus is ZERO".The population is now five. OpsxFactory's
aks-administration-workflow'Bounded action classes for managed workloads' has five ratified writers, each declaring its predecessor by ratification date (opensoft/OpsxFactory#182, merged6ee0ed8e), andrelease-realization's "Ordered deltas and branch vocabulary" obligates that declaration from every later writer. The checker was reporting its own limitation as a corpus defect.Spec check — the ratified text permits this
Checked before designing.
openspec/specs/doc-health/spec.md's "Title resolution and the two-writers rule" states ORDER IS BY DECLARATION AND NEVER BY DATE and constrains the two-writer case ("EXACTLY ONE of two active RATIFIED writers SHALL declare: where neither does … where both declare …"). Its scenario opens "two or more active changes carry a MODIFIED block … and exactly one declares".release-realization's rule, as extended 2026-09-02 bygovern-sibling-added-modified-deltas, obliges the declaration and says nothing limiting it to a pair.The phrase "no order for more than two" appears nowhere in the corpus except this module's own f-string (grepped over every
.mdand every script). It is the arm's limitation, not a requirement — so this is a code fix, not an OpenSpec amendment.Design
_chain(changes, pairs)— an edge(a, b)means a's proposal names b, soais the later writer and the earliest writer names nobody inside the group.Resolved means one TOTAL ORDER, not one edge per writer, and that distinction is what the real corpus turns on.
reanchor-keycloak-broker-to-syscore2names both its predecessoradmit-secretproviderclass-to-aks-scopeand, three links back,adopt-keycloak-broker-qa— the change it re-anchors and could hardly discuss without naming. That edge states nothing transitivity does not already state, and a rule counting one predecessor per writer would report the compliant corpus as forked. So the arm runs Kahn's algorithm with a uniqueness demand at every step: resolved iff exactly one writer is placeable at each step.The basis runs along the chain: the earliest writer is measured against canon, every later writer against its immediate predecessor's block — the pair path's own substitution applied link by link, on the same ruling that a
MODIFIEDblock IS its writer's outcome. A resolved chain emits nothing, exactly like a resolved pair.Fail-closed, and the defect is named. Where the declarations state no single chain the group is still reported at the same finding class (
title resolution and ordering) and severity (warning), with the rule text naming which defect:cycleforkedunanchoredoutsideNo new finding class and no re-banding.
TEMPLATE_ORDERING, its_CLASS_PATTERNSentry, the shape mask andspecs/022-…/contracts/report-section.mdare all unchanged — only the interpolated{why}moves.The 2-writer path is untouched, and structurally so: its branch is still taken first, and
test_the_two_writer_path_never_consults_the_chain_rulemakes_chainexplode while every two-ratified-writer group in the-two-writerstree is evaluated.An unratified writer is still no link in the chain —
release-realizationscopes the obligation to an active RATIFIED change, the reading scope stays deliberately wider, and a declaration pointing at a draft orders nothing.Real-corpus positive control — OpsxFactory at
origin/main(65de75b1)python3 scripts/doc-health.py --single-repo <OpsxFactory> --family modified-block-currencyOrdering 5 → 0, no new finding in any class. The ledger drop is the chain working: four of the five blocks are now measured against their predecessors' blocks instead of against canon, and only the chain's earliest writer (
adopt-openxpki-fleet-certificate-authority) still reports the canon body unit it drops.openxFactory's own family section is byte-identical to
origin/main's (0 ordering findings before and after; whole-report diff shows only the word count moved by the one-sentencedocs/doc-health.mdedit).Mutation table — ten mutants, ten dead
test_a_declared_chain_of_three_ratified_writers_resolves_and_says_nothingtest_the_chain_basis_is_the_predecessor_s_block_and_carries_it_transitivelytest_a_declared_chain_of_three_ratified_writers_resolves_and_says_nothingtest_the_chain_basis_is_the_predecessor_s_block_and_carries_it_transitivelytest_a_group_of_three_writers_with_one_declaration_is_reported_as_unanchoredforkedandunanchoredare not told aparttest_two_writers_declaring_the_same_predecessor_are_reported_as_a_forktest_declarations_running_in_a_cycle_are_reported_as_a_cycletest_a_declaration_naming_an_unratified_writer_anchors_nothing_in_the_grouptest_an_unratified_sibling_creates_no_declaration_obligationtest_both_declaring_fires_tooFixtures
New tree
tests/doc-health/fixtures/modified-block-currency-chains/, one capability per arrangement on the-two-writerstree's convention:chain-three(declared chain, silent),chain-basis(the last writer drops the first's addition — oneinfonaming the SECOND writer's delta as the basis, which is what makes the substitution falsifiable),chain-redundant(the OpsxFactory shape, silent),fork-branches,cycle-three,mixed-unratified(a draft writer beside a resolving chain — its ledger finding is against canon, the chain's middle writers are silent),outside-anchor.test_a_group_of_three_writers_with_one_declaration_is_evaluated_over_the_groupis re-aimed, not deleted: its fixture never was a chain (one writer declares, one declares nothing), so it is theunanchoredcase — still three findings against three blocks, outcome unchanged, reason now specific. It is renamed to…_is_reported_as_unanchoredand its citation inspecs/020-…/contracts/coverage-audit.mdfollows it, that audit being a live reference (test_no_audit_row_cites_a_test_that_does_not_exist).Gates
python3 -m pytest tests/doc-health -q→ 1541 passed (1532 onorigin/main; +9 tests)OPENSPEC_TELEMETRY=0 openspec validate --all --strict→ 88 passed, 0 faileddocs/doc-health.mdfamily paragraph: one sentence added.specs/022-…/contracts/report-section.md: unchanged — its byte-level enumeration (class pattern, template text, class table) is untouched by this change.Closes #627