Skip to content

modified-block-currency: resolve N-writer ordering as a linear chain of declarations (#627) - #640

Merged
brettheap merged 3 commits into
mainfrom
fix/627-ordering-linear-chains
Sep 4, 2026
Merged

brettheap merged 3 commits into
mainfrom
fix/627-ordering-linear-chains

Conversation

@brettheap

@brettheap brettheap commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

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, merged 6ee0ed8e), and release-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 by govern-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 .md and 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, so a is 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-syscore2 names both its predecessor admit-secretproviderclass-to-aks-scope and, 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 MODIFIED block 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:

defect shape
cycle no writer is placeable — the declarations run in a cycle
forked one root, but two writers are each declared later than a placed writer and neither later than the other
unanchored more than one starting point: two writers declare relative to nothing inside the group
outside an unanchored group where a writer's only declaration names a writer of this requirement that is not ratified — it explains the missing anchor instead of leaving a reader to hunt for it

No new finding class and no re-banding. TEMPLATE_ORDERING, its _CLASS_PATTERNS entry, the shape mask and specs/022-…/contracts/report-section.md are 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_rule makes _chain explode while every two-ratified-writer group in the -two-writers tree is evaluated.

An unratified writer is still no link in the chain — release-realization scopes 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-currency

class before after
scenario-title completeness 0 0
carriage ledger 7 3
title resolution and ordering 5 0
marker defects 0 0
sibling-pairing declaration 0 0
added-over-canon collision 0 0
unplaced-finding drift 0 0

Ordering 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-sentence docs/doc-health.md edit).

Mutation table — ten mutants, ten dead

# mutation verdict first test to die
M1 the chain never resolves (pre-#627 behaviour) DIED test_a_declared_chain_of_three_ratified_writers_resolves_and_says_nothing
M2 basis stays canon instead of the predecessor's block DIED test_the_chain_basis_is_the_predecessor_s_block_and_carries_it_transitively
M3 the chain runs the wrong way (earlier measured by later) DIED test_a_declared_chain_of_three_ratified_writers_resolves_and_says_nothing
M4 the basis skips to the chain's root, not the predecessor DIED test_the_chain_basis_is_the_predecessor_s_block_and_carries_it_transitively
M5 ambiguity is ignored (first placeable writer wins) DIED test_a_group_of_three_writers_with_one_declaration_is_reported_as_unanchored
M6 forked and unanchored are not told apart DIED test_two_writers_declaring_the_same_predecessor_are_reported_as_a_fork
M7 a cycle is not detected DIED test_declarations_running_in_a_cycle_are_reported_as_a_cycle
M8 an out-of-group declaration is never named DIED test_a_declaration_naming_an_unratified_writer_anchors_nothing_in_the_group
M9 an UNRATIFIED writer becomes a link in the chain DIED test_an_unratified_sibling_creates_no_declaration_obligation
M10 the pair path is routed through the chain rule DIED test_both_declaring_fires_too

Fixtures

New tree tests/doc-health/fixtures/modified-block-currency-chains/, one capability per arrangement on the -two-writers tree's convention: chain-three (declared chain, silent), chain-basis (the last writer drops the first's addition — one info naming 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_group is re-aimed, not deleted: its fixture never was a chain (one writer declares, one declares nothing), so it is the unanchored case — still three findings against three blocks, outcome unchanged, reason now specific. It is renamed to …_is_reported_as_unanchored and its citation in specs/020-…/contracts/coverage-audit.md follows 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 on origin/main; +9 tests)
  • OPENSPEC_TELEMETRY=0 openspec validate --all --strict → 88 passed, 0 failed
  • docs/doc-health.md family 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

brettheap and others added 3 commits September 4, 2026 00:09
`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]>
Copilot AI lite review requested due to automatic review settings September 4, 2026 04:11

@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 ✨

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.

🟢 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-specific unanchored case.
  • 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.

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.

modified-block-currency ordering arm resolves only 2-writer groups — a 5-writer ratified chain stays 'undecided' even when fully declared

2 participants