Repository navigation
Every action string the thin doc-health families can emit is pinned verbatim, table-driven, in each family's own suite - #484
Merged
Conversation
…pinned verbatim, table-driven 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: 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
Adds a shared, table-driven mechanism to pin (verbatim) the full reachable set of doc-health “action” strings per family, expanding beyond the single representative pins introduced in #448 and ensuring future action-text drift is caught by tests.
Changes:
- Introduces
tests/doc-health/action_pins.pywith behavioral + AST-based static harvesting and a two-directional “expected == reachable” assertion helper. - Adds
tests/doc-health/test_action_pins.pyto self-test the harvester and the assertion behavior. - Extends multiple existing doc-health test suites with per-family “all actions pinned” table tests.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/doc-health/action_pins.py | New shared harvester/assertion utilities for action-string pinning. |
| tests/doc-health/test_action_pins.py | New self-tests validating the harvester and pin assertion logic. |
| tests/doc-health/test_ideation_routing.py | Adds full action-string pin table for ideation-routing. |
| tests/doc-health/test_document_catalog.py | Adds full action-string pin table for document-catalog. |
| tests/doc-health/test_families.py | Adds full action-string pin tables for several families hosted in families.py. |
| tests/doc-health/test_proposal_origin.py | Adds full action-string pin table for proposal-origin (includes a git-backed scenario). |
| tests/doc-health/test_release_inventory.py | Adds full action-string pin table for release-inventory-drift. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+122
to
+129
| constants: dict[str, str] = {} | ||
| for node in ast.walk(tree): | ||
| if isinstance(node, ast.Assign): | ||
| value = node.value | ||
| if isinstance(value, ast.Constant) and isinstance(value.value, str): | ||
| for target in node.targets: | ||
| if isinstance(target, ast.Name): | ||
| constants[target.id] = value.value |
| def run(text): | ||
| doc = Doc("alpha", "docs/subject.md", text, | ||
| corpus.parse_status(text), corpus.parse_kind(text)) | ||
| ctx = Context(repo_paths={"alpha": Path("/nonexistent")}, docs=[doc], |
brettheap
added a commit
that referenced
this pull request
Aug 29, 2026
… -> 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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Steward follow-up to #448 (
cadc05ec), approved by Brett 2026-08-28 ("pins"). #448 pinned exactly one representative action string per family; this widens that to the whole reachable set, table-driven, for the four thin families #448's review measured thinnest and the five partials it also flagged.Shared helper
tests/doc-health/action_pins.py— one reusable harvester, not one per family:harvest_behavioral(family_fn, ctx)— runs the family over a realContextand collects{f.action for f in findings}(ground truth).harvest_static(module_or_path, *, functions=None)— reads the family's source withastand collects every string literal bound to anactionparameter, via two call shapes: a directFinding(...)call, or a call to a module-local helper whose own signature names anactionparameter (families.py::fam_tag_hygiene'shit(sev, doc, rule, action)wrapper). A module-level named constant (_CUT_ACTION) resolves to its text, not its name — the exact mistake Every doc-health family's action line is now pinned in its own suite #448's own review caught for_MARKER_ACTION.functions=scopes the walk to named top-level defs, needed becausefamilies.pyhouses several families in one module.assert_actions_pinned(expected, behavioral, static, family=...)— the two-directional check every table makes:behavioral | staticmust equalexpectedexactly.The helper itself is pinned in
tests/doc-health/test_action_pins.py(a known literal found via directFinding(), via a local wrapper, via a resolved constant; zero on a module with none; thefunctions=scoping; both directions of the failure message).Per-family table
test_ideation_routing.pytest_document_catalog.pytest_families.pytest_proposal_origin.pytest_release_inventory.pytest_families.pytest_families.pytest_families.pytest_families.pyThe two ideation-routing statics are structurally unreachable through
fam_ideation_routing's own entry point, not merely uncovered by a fixture:_collectonly appends a parsedrouting.yamltorecordswhen it is adictANDkind == RECORD_KIND, so the "not a YAML mapping" and "kind is not ..." literals inside_shape_findingscan never fire through the family's real call path. Documented in that table's own docstring.Corpus-wide (same harvester, mechanically counted): 155 distinct reachable action strings exist across all 22 families. 22 were already fully pinned outside this PR's scope (the families #448 covered completely) + 12 single pins #448 left inside these 9 families = 34/155 (22%) before. 155/155 (100%) after. (The task brief's "~25/118" was a rough manual estimate; precise AST counting finds more, especially in
ideation-routing, 63 vs. the ~42 guessed.)RED-first (tag-hygiene excerpt)
Mutated
"close the fence before the heading"→"CLOSE THE FENCE BEFORE THE MUTATED HEADING"before the table existed:Reverted, then the table written to match.
Mutation round
One string per family mutated (scratch edit,
git checkout --after, never committed) — always one#448did not already cover. Each mutation reds exactly the one new table test for that family and leaves every pre-existing test (including#448's own pins) green:"close the fence before the heading""align the Claim ID prefix with the record's Idea ID""regenerate the assignment under a controlled facet""declare kind: staged or kind: ad_hoc""declare a bundle whose inventory exists, or create the inventory...""keep exactly one: Ratified by: ...""create the proposal supporting-document manifest""restore the six-column register row shape""re-run with network access to the submodule remote"Gates
python3 -m pytest tests/doc-health -q— 1330 passed (was 1311 onorigin/mainbefore this branch mergedae04ba68; +19 new tests: 9 per-family tables + 10action_pinsself-tests).OPENSPEC_TELEMETRY=0 openspec validate --all --strictfromopenxFactory/— 79 passed, 0 failed.git diff --statagainstscripts/,openspec/,.github/is empty — this change touchestests/doc-health/only.🤖 Generated with Claude Code