Repository navigation
Every doc-health family's action line is now pinned in its own suite - #448
Conversation
Two independent reviewers measured that mutating scripts/doc_health/promotion_fidelity.py's _ACTION constant reds nothing: an action line is operator guidance rendered in every ranked-plan row, and until now nothing in this repository noticed it changing for most families. Brett approved a steward follow-up (2026-08-27): one verbatim action-text pin per family, each landing in that family's own test suite. Of the 22 families, two already carried a genuine verbatim pin (duplicate-packet's test_the_near_miss_fires_on_the_remedial_pair, and modified-block-currency's F4 suite) and are left untouched. The other 20 get one new pin each: 13 in tests/doc-health/test_families.py (the families.py fam_* functions), plus one each in test_document_catalog.py, test_ideation_routing.py, test_proposal_origin.py, test_client_identity_composition.py, test_promotion_fidelity.py, test_release_inventory.py, and test_family_enumeration.py. Where an existing fixture already produces several distinct action strings for free (status-validity, succession-integrity, staged-candidate-aging, register-lifecycle- consistency, ideation-routing), all of them are pinned rather than just one. RED-first evidence: mutating promotion_fidelity._ACTION before this change reds 0 of 1209 tests. After, the same mutation reds exactly test_promotion_fidelity.py::test_the_codex_regression_shape_fires. Two more spot-mutations confirm the pattern: release_inventory.py's _CUT_ACTION reds test_release_inventory.py's new verbatim pin (plus its pre-existing substring check); families.py's record-immutability action string reds test_families.py::test_record_immutability. All mutations were applied to scratch copies and reverted before commit. tests/doc-health -q: 1209 passed, unchanged (assertions were added to existing tests, not new test functions). Co-Authored-By: Claude Sonnet 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
This PR strengthens the doc-health test suites by adding per-family verbatim pins of each finding’s action text, ensuring action-line mutations now trigger test failures within the owning family’s suite (rather than relying on shared/central coverage).
Changes:
- Added verbatim
finding.action == "<exact text>"assertions across multiple existing doc-health tests. - Upgraded some suites from substring-only assertions to full-string pins for operator-facing action guidance.
- Added fixture-specific pins for families that emit multiple action literals, selecting representative findings where appropriate.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/doc-health/test_release_inventory.py | Adds a verbatim pin for the release-inventory drift action line in an existing test. |
| tests/doc-health/test_proposal_origin.py | Pins the proposal-origin action guidance verbatim for missing origin declarations. |
| tests/doc-health/test_promotion_fidelity.py | Pins promotion_fidelity’s operator action guidance verbatim in the regression-shape test. |
| tests/doc-health/test_ideation_routing.py | Pins two distinct action literals emitted by the ideation-routing fixture. |
| tests/doc-health/test_family_enumeration.py | Pins the single action string used by the family-enumeration findings. |
| tests/doc-health/test_families.py | Adds multiple verbatim pins across several families implemented via FAMILIES[...]. |
| tests/doc-health/test_document_catalog.py | Pins a representative action string for a specific document-catalog finding class. |
| tests/doc-health/test_client_identity_composition.py | Pins the operator action guidance for shared-identity material findings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` was | ||
| # mutated and 85 tests stayed green — no doc-health family's action line | ||
| # was pinned anywhere). An action line is operator guidance rendered in | ||
| # every ranked-plan row; nothing else in this repository notices it | ||
| # changing, so each family gets one verbatim pin in its own suite. |
| got = FAMILIES["standard-backing"](make_ctx("standard-backing")) | ||
| assert [(f.severity, f.path) for f in got] == [ | ||
| (CRITICAL, "docs/unbacked.md")] | ||
| # PIN, see test_status_validity's docstring comment. |
| # VERBATIM PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` | ||
| # was mutated and 85 tests stayed green — no doc-health family's action | ||
| # line was pinned anywhere VERBATIM; the two substring checks above do not | ||
| # catch a mutation that preserves both phrases). An action line is | ||
| # operator guidance rendered in every ranked-plan row; nothing else in | ||
| # this repository notices it changing. |
| # PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` was | ||
| # mutated and 85 tests stayed green — no doc-health family's action line | ||
| # was pinned anywhere). An action line is operator guidance rendered in | ||
| # every ranked-plan row; nothing else in this repository notices it | ||
| # changing, so each family gets one verbatim pin in its own suite. |
| # PIN (commissioned 2026-08-27, after this exact constant — | ||
| # `promotion_fidelity._ACTION` — was mutated and 85 tests stayed green). | ||
| # An action line is operator guidance rendered in every ranked-plan row; | ||
| # nothing else in this repository notices it changing. |
| # PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` was | ||
| # mutated and 85 tests stayed green — no doc-health family's action line | ||
| # was pinned anywhere). An action line is operator guidance rendered in | ||
| # every ranked-plan row; nothing else in this repository notices it | ||
| # changing, so each family gets one verbatim pin in its own suite. This | ||
| # family passes literals at many construction sites; the two this fixture | ||
| # already produces are pinned here rather than duplicated. |
| scope_action = next(f.action for f in got if "scope 'totally-made-up'" in f.rule) | ||
| status_action = next(f.action for f in got if "routing_status 'archived'" in f.rule) |
| # PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` was | ||
| # mutated and 85 tests stayed green — no doc-health family's action line | ||
| # was pinned anywhere). An action line is operator guidance rendered in | ||
| # every ranked-plan row; nothing else in this repository notices it | ||
| # changing, so each family gets one verbatim pin in its own suite. This | ||
| # family uses ONE action string for every finding it raises, regardless | ||
| # of rule shape. |
| # PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` was | ||
| # mutated and 85 tests stayed green — no doc-health family's action line | ||
| # was pinned anywhere). An action line is operator guidance rendered in | ||
| # every ranked-plan row; nothing else in this repository notices it | ||
| # changing, so each family gets one verbatim pin in its own suite. This | ||
| # family emits twelve finding classes, each with its own action text; | ||
| # `coverage`'s is pinned here as the family's representative one. |
| # PIN (commissioned 2026-08-27, after `promotion_fidelity._ACTION` was | ||
| # mutated and 85 tests stayed green — no doc-health family's action line | ||
| # was pinned anywhere). An action line is operator guidance rendered in | ||
| # every ranked-plan row; nothing else in this repository notices it | ||
| # changing, so each family gets one verbatim pin in its own suite. |
Review of #448 found that this family's second action string, _MARKER_ACTION, was pinned only tautologically: test_the_marker_class_keeps_its_own_action_and_not_the_arms_one compared a finding's action to mbc._MARKER_ACTION itself, which passes whatever the constant had been mutated to. The reviewer mutated it ("does not restate" -> "does not carry") and the whole suite, this file included, stayed green. Adds _MARKER_ACTION_TEXT, a fresh literal typed out independently beside _ARMS_ACTION (the same argument that constant's own docstring already makes for _ACTION), and a new behavioural assertion comparing the TREE_MARKERS fixture's marker-defect finding action against it. RED-first, with the reviewer's exact mutation applied to a scratch copy and reverted before commit: before: 1 failed, 1208 passed FAILED test_modified_block_currency_reporting.py:: test_the_marker_class_keeps_its_own_action_and_not_the_arms_one tests/doc-health -q: 1209 passed, unchanged. Co-Authored-By: Claude Sonnet 5 <[email protected]>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (9)
tests/doc-health/test_release_inventory.py:216
- Avoid hardcoding a specific test-count ("85 tests") in this explanatory comment; it will drift as the suite grows. Prefer wording that doesn’t include a number (e.g., "the suite stayed green").
# was mutated and 85 tests stayed green — no doc-health family's action
tests/doc-health/test_proposal_origin.py:94
- Avoid embedding a specific test-count ("85 tests") in this comment; it will become inaccurate over time. Use wording that doesn’t rely on an exact number.
# mutated and 85 tests stayed green — no doc-health family's action line
tests/doc-health/test_promotion_fidelity.py:105
- This comment hardcodes a test-count ("85 tests"). That number is likely to drift; consider wording that stays accurate without a specific count.
# `promotion_fidelity._ACTION` — was mutated and 85 tests stayed green).
tests/doc-health/test_ideation_routing.py:228
- Avoid hardcoding a specific test-count ("85 tests") in this comment; it will drift. Prefer a count-free description (e.g., "the suite stayed green").
# mutated and 85 tests stayed green — no doc-health family's action line
tests/doc-health/test_family_enumeration.py:70
- The "85 tests" count in this comment is likely to go stale. Consider removing the number and describing it as "the suite" instead.
# mutated and 85 tests stayed green — no doc-health family's action line
tests/doc-health/test_families.py:35
- This comment hardcodes "85 tests" which is likely to drift as tests are added/parametrized. Prefer count-free wording so the comment remains accurate.
# mutated and 85 tests stayed green — no doc-health family's action line
tests/doc-health/test_document_catalog.py:218
- Avoid hardcoding a specific test-count ("85 tests") in this comment; it will become inaccurate over time. Prefer wording like "the suite stayed green".
# mutated and 85 tests stayed green — no doc-health family's action line
tests/doc-health/test_client_identity_composition.py:128
- This comment includes a specific test-count ("85 tests") which is likely to become stale. Consider removing the number and referring to the suite generically.
# mutated and 85 tests stayed green — no doc-health family's action line
tests/doc-health/test_families.py:50
- This reference says "docstring comment", but the referenced note in
test_status_validityis a regular#comment (not a docstring). Updating the wording avoids confusion.
# PIN, see test_status_validity's docstring comment.
…pinned verbatim, table-driven (#484) Steward follow-up to #448 (cadc05e), approved by Brett 2026-08-28 ("pins"): #448 pinned exactly one representative action string per family. Two independent reviewers had measured that mutating an action-line constant reds nothing, and #448 fixed that for one string per family — but a family that raises several distinct finding classes still had every OTHER action string free to drift silently, which is the same blind spot recurring inside families #448 itself touched. This widens the pin to the WHOLE reachable set, table-driven, for the four thin families #448 measured thinnest (ideation-routing 2/42, document-catalog 1/21, tag-hygiene 1/13, proposal-origin 1/11) and the five partials it also flagged (release-inventory-drift, ratified-provenance, location-conformance, register-lifecycle- consistency, submodule-pin-drift). Shared helper: tests/doc-health/action_pins.py One reusable harvester, not one per family. `harvest_behavioral` runs a family function over a real Context and collects `{f.action}` — ground truth. `harvest_static` reads a family's source with `ast` and collects every string literal bound to an `action` parameter, via two call shapes: a direct `Finding(...)` call, or a call to a module-local helper (`families.py::fam_tag_hygiene`'s `hit(sev, doc, rule, action)` wrapper) whose own signature names an `action` parameter — resolving a module-level named constant (`_CUT_ACTION`) to its TEXT rather than leaving it unmatched, which is exactly the mistake #448's own review caught and fixed for `_MARKER_ACTION` (comparing a finding's action to the module's constant passes whatever that constant is mutated to). `families.py` houses several families, so `harvest_static` accepts an optional `functions=` scope (a set of top-level def names) so one family's walk cannot mix in another's literals. `assert_actions_pinned(expected, behavioral, static, family=...)` is the two-directional check every table makes: `behavioral | static` must equal `expected` exactly — nothing the source can emit is missing from the table, and nothing in the table is unreachable dead weight. Per-family table (strings pinned behaviourally / statically, of total reachable; all totals mechanically derived, exceeding the ~25/118 rough manual estimate #448's review made): ideation-routing 61 / 2 of 63 (test_ideation_routing.py) document-catalog 23 / 0 of 23 (test_document_catalog.py) tag-hygiene 7 / 5 of 12 (test_families.py) proposal-origin 11 / 0 of 11 (test_proposal_origin.py) release-inventory-drift 5 / 0 of 5 (test_release_inventory.py) ratified-provenance 4 / 0 of 4 (test_families.py) location-conformance 10 / 0 of 10 (test_families.py) register-lifecycle-consistency 3 / 0 of 3 (test_families.py) submodule-pin-drift 2 / 0 of 2 (test_families.py) ------------------ TOTAL 133 / 133 (100%) The two ideation-routing statics are structurally UNREACHABLE through `fam_ideation_routing`'s own collection path, not merely uncovered by a fixture: `_collect` only appends a parsed routing.yaml to `records` when it is a dict AND `kind == RECORD_KIND`, so the "not a YAML mapping" and "kind is not ..." literals inside `_shape_findings` can never fire through the family's real entry point. Documented in that table's own docstring rather than silently worked around. Across the whole 22-family doc-health corpus (mechanically counted, same harvester): 155 distinct reachable action strings exist; 22 were already fully pinned outside this change's scope (families #448 covered completely: status-validity, staged-topic-template, standard- backing, succession-integrity, staged-candidate-aging, record- immutability, contract-copy-drift, notebook-projection-drift, client- identity-composition, promotion-fidelity, duplicate-packet, family- enumeration, modified-block-currency) plus the 12 single pins #448 left in these 9 families = 34/155 (22%) before this change. After: 155/155 (100%). RED-first, one excerpt (tag-hygiene, families.py::fam_tag_hygiene): mutated "close the fence before the heading" to "CLOSE THE FENCE BEFORE THE MUTATED HEADING" before this table existed — E AssertionError: tag-hygiene: EXPECTED_ACTIONS is out of sync ... E emitted but NOT pinned: ['CLOSE THE FENCE BEFORE THE MUTATED HEADING (document-lifecycle grammar)'] E pinned but NOT reachable: ['close the fence before the heading (document-lifecycle grammar)'] 1 failed, 40 passed — then reverted and the table written to match. Mutation round (scratch edits, `git checkout --` after each, never committed): one string per family mutated, always one #448's own pin did NOT cover, confirming this table — not the pre-existing one — is what catches it. Every mutation reds exactly the ONE new table test for that family and leaves every pre-existing test (including #448's own pins) green: tag-hygiene "close the fence before the heading" ideation-routing "align the Claim ID prefix with the record's Idea ID" document-catalog "regenerate the assignment under a controlled facet" proposal-origin "declare kind: staged or kind: ad_hoc" release-inventory-drift "declare a bundle whose inventory exists, or ..." ratified-provenance "keep exactly one: Ratified by: ..." location-conformance "create the proposal supporting-document manifest" register-lifecycle-consistency "restore the six-column register row shape" submodule-pin-drift "re-run with network access to the submodule remote" The harvester itself is pinned in tests/doc-health/test_action_pins.py: a known literal found via a direct Finding(...) call, via a local wrapper function, via a module constant resolved to its text, zero reported on a module with no action literal, the `functions=` scoping, and both directions of `assert_actions_pinned`'s own failure message. Gates: `python3 -m pytest tests/doc-health -q` — 1330 passed (was 1311 on origin/main before this branch merged ae04ba6; +19 new tests: 9 per-family tables + 10 action_pins self-tests). `OPENSPEC_TELEMETRY=0 openspec validate --all --strict` from openxFactory/ — 79 passed, 0 failed. `git diff --stat` against scripts/, openspec/, .github/ is empty — this change touches tests/doc-health/ only. Co-authored-by: brettheap <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
… -> 155/155) (#486) Follow-up to the adversarial review of #484 (b021c37). That PR's nine per-family claims all held, but its "155/155" corpus-wide summary was wrong — it was 152/155. Three action strings, all in families #448 already listed as "fully pinned", could still be mutated with zero new failures across the full 1330-test suite: 1. scripts/doc_health/modified_block_currency.py:1516 (_DRIFT_ACTION). tests/doc-health/test_modified_block_currency_reporting.py:168 did "unplaced": mbc._DRIFT_ACTION — a constant reference, the same tautology #448's review already caught and fixed for _MARKER_ACTION (both sides of the comparison read the same mutated constant at import time, so no mutation of it could ever fail the assertion). Replaced with the fresh literal typed out from the constant's own definition. 2. scripts/doc_health/client_identity_composition.py:256 (the undeclared-cross-domain-reach action). No test anywhere asserted on this finding's `.action` at all — added a fresh-literal pin to test_undeclared_cross_domain_reach_fires_and_names_both_sides. 3. scripts/doc_health/family_enumeration.py:409 (the phantom- registration action, distinct from the enumeration-drift action #448 already pinned in the same file). No test asserted on it — added a fresh-literal pin to test_the_runtime_phantom_check_still_guards_its_direction. Each fix was mutation-proven individually: mutate the string in the script, confirm the newly-added assertion reds, `git checkout -- scripts/` to revert, confirm green again. All three proofs are in the PR description. Also, per the same review, three docstring/comment nits in tests/doc-health/action_pins.py (no behavior change): - The "(there are none today)" claim about non-literal actions was wrong — client_identity_composition.py (x2), neutrality_dispatch.py, and semantic.py all build their action with an f-string. None of those three modules uses this harvester, so the static harvester's skip of non-literal actions is still correct for every family that does; corrected the docstring to say so, and to state the verified static ⊇ behavioral relationship that holds for all nine families the harvester actually covers. - Reworded assert_actions_pinned's "reachable"/"unreachable" language to "statically present"/"neither statically present nor behaviorally emitted" — harvest_static proves only that a literal reaches an `action` parameter syntactically, not that the branch holding it can run. Verified two of ideation-routing's pinned strings (ideation_routing.py:315, :319) are exactly this: their only caller pre-filters every record on isinstance(dict) and kind == RECORD_KIND, so _shape_findings's own matching guards can never fire, yet the static half still (correctly, by what it actually checks) counts them as covered. - Corrected the constant-map comment in harvest_static: it walks the WHOLE module tree via ast.walk (not just module-level statements, so it also picks up same-named assignments nested in function/class bodies), and on a name assigned more than once anywhere in the module, the LAST assignment ast.walk's traversal order reaches wins the dict entry. Also extended _action_param_index to recognize a keyword-only `action` parameter (previously only posonly/regular params were checked, so a module-local helper declaring `action` as keyword-only would never be registered as an action-taker at all, even for a call site passing action=... by keyword). No such helper exists in the corpus today, so this is forward-hardening rather than a fix for an active gap; it was "trivial and all tests still pass" per the task's optional-fix criterion, so it is included rather than skipped. git diff --stat origin/main touches only tests/doc-health/. Full suite: 1330 passed. Closes #485 Co-authored-by: brettheap <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
Summary
Two independent reviewers measured that mutating
scripts/doc_health/promotion_fidelity.py's_ACTIONconstant reds nothing anywhere intests/doc-health. An action line is operator guidance rendered in every ranked-plan row (action="…"), and nothing else in the repository notices it changing for most families. Brett approved a steward follow-up (2026-08-27): one verbatim action-text pin per family, each landing in that family's own test suite — not a shared/central test.RED-first evidence (0-red baseline, then confirmed kills)
Baseline, before any pin was added —
promotion_fidelity._ACTIONmutated to a nonsense string, full suite run:After this change, the identical mutation:
Two more spot-mutations, different homes, both now killed:
release_inventory.py's_CUT_ACTIONtest_release_inventory.py::test_non_editorial_drift_is_an_error(new verbatim pin) and the pre-existingtest_every_finding_names_the_cut_and_forbids_the_hand_editsubstring checkfamilies.py's record-immutability action literaltest_families.py::test_record_immutability(new pin)All three mutations were applied to the working tree, run, and reverted (
git diff --stat scripts/is clean on this branch) — nothing mutated was ever committed.Per-family table
Of the 22 families (
scripts/doc_health/families.py:FAMILIES), 2 already carried a genuine verbatim pin and were left untouched (do-not-duplicate, per the commissioning note):duplicate-packettest_duplicate_packet.py::test_the_near_miss_fires_on_the_remedial_pairmodified-block-currencytest_modified_block_currency_reporting.py(F1/F4,_ACTION+_MARKER_ACTION) —_MARKER_ACTION's half was tautological until review; see "Fix from review" belowThe other 20 get one new pin each, all behavioural (
finding.action == "<verbatim>"against an existing fixture) except where noted:_ACTION's verbatim text_CUT_ACTION's verbatim text (upgrades a pre-existing substring-only check)No new test files and no new test functions — every pin is an added assertion inside an existing test.
tests/doc-health -qcount is therefore unchanged: 1209 passed (baseline 1209).Fix from review
Review of this PR found that
modified-block-currency's SECOND action string,_MARKER_ACTION(scripts/doc_health/modified_block_currency.py), was pinned only tautologically:test_modified_block_currency_reporting.pycompared a finding's action tombc._MARKER_ACTIONitself, which passes whatever the constant had been mutated to. The reviewer mutated it ("does not restate" → "does not carry") and the whole suite — this file included — stayed green.Fixed by adding a fresh literal,
_MARKER_ACTION_TEXT, typed out independently beside_ARMS_ACTION, and a new behavioural assertion intest_the_marker_class_keeps_its_own_action_and_not_the_arms_onecomparing the marker-defect fixture finding's action against that literal.Re-proved RED-first with the reviewer's exact mutation:
Reverted;
git diff --stat scripts/is clean on this branch.Coverage
This PR pins one representative action string per family — not the full set. Counting every distinct action-string literal across all 22 families' construction sites: ≈25 of ~118 distinct action strings are pinned (roughly a fifth). The families with the widest gap between "pinned" and "exists":
Follow-up, not a merge condition: a table-driven full-set pin per family — enumerate every distinct action string a family's Finding-construction sites can emit and assert each one verbatim, rather than one representative string standing in for the rest. Tracked as separate follow-up work.
Gates
python3 -m pytest tests/doc-health -q→ 1209 passed, unchangedOPENSPEC_TELEMETRY=0 openspec validate --all --strict→ 74 passed, 0 failed. (Expected 75 per the commissioning note; this branch's baseb5fb03f3is now 6 commits behindorigin/main, and the discrepancy traces to that upstream drift, not to this change —scripts/andopenspec/are untouched here, confirmed viagit diff --stat scripts/clean.)Test plan
python3 -m pytest tests/doc-health -qpasses (1209/1209)OPENSPEC_TELEMETRY=0 openspec validate --all --strictpasses (0 failed)git diff --stat scripts/clean on this branch🤖 Generated with Claude Code