Skip to content

Pin the three action strings #484's corpus-wide count missed (152/155 -> 155/155) - #486

Merged
brettheap merged 1 commit into
mainfrom
tests/fix-485-action-pins
Aug 29, 2026
Merged

brettheap merged 1 commit into
mainfrom
tests/fix-485-action-pins

Conversation

@brettheap

Copy link
Copy Markdown
Contributor

Closes #485.

Summary

#484's nine per-family claims all held; its corpus-wide "155/155" summary
in the commit body was wrong — it was 152/155. Three action strings, all
in families listed as "already fully pinned by #448" (i.e. outside #484's
nine), could still be mutated with zero new test failures. This PR fixes all
three, plus the docstring nits from the same review. Tests-only, under
tests/doc-health/.

The three fixes

  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. mbc.CLASSES
    builds its unplaced class's action from that same constant at import
    time, so both sides of the comparison always move together — the exact
    tautology #448's review caught and fixed for _MARKER_ACTION. Replaced
    with the fresh literal typed out from _DRIFT_ACTION'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. 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.

Mutation proofs

Each fix was verified individually: mutate the string in the script source,
run the test file, confirm the new assertion reds, git checkout -- scripts/ to revert, confirm green again.

1. _DRIFT_ACTION — mutated "extend the class map in" ->
"MUTATED extend the class map in" in modified_block_currency.py:

FAILED tests/doc-health/test_modified_block_currency_reporting.py::test_the_class_registry_is_closed_ordered_and_states_a_band_per_class
AssertionError: assert {'scenario-ti...nothing', ...} == {'scenario-ti...nothing', ...}
  Differing items:
  {'unplaced': 'MUTATED extend the class map in `scripts/doc_health/modified_block_currency.py`, or fix the drifted rule text the finding names'} != {'unplaced': 'extend the class map in `scripts/doc_health/modified_block_currency.py`, or fix the drifted rule text the finding names'}
1 failed, 44 passed

2. client_identity_composition.py:256 — mutated "publish an entry" ->
"MUTATED publish an entry":

FAILED tests/doc-health/test_client_identity_composition.py::test_undeclared_cross_domain_reach_fires_and_names_both_sides
AssertionError: assert 'MUTATED publ... domain holds' == 'publish an e... domain holds'
1 failed, 20 passed

3. family_enumeration.py:409 — mutated "remove the entry" ->
"MUTATED remove the entry":

FAILED tests/doc-health/test_family_enumeration.py::test_the_runtime_phantom_check_still_guards_its_direction
AssertionError: assert 'MUTATED remo...er the family' == 'remove the e...er the family'
1 failed, 20 passed

All three reverted with git checkout -- scripts/ after proving the mutation
red; the working tree under scripts/ is unchanged in this PR.

Docstring/comment nits (tests/doc-health/action_pins.py, no behavior change)

  • ~line 50: the claim "(there are none today)" about non-literal
    actions was wrong — client_identity_composition.py (x2, lines 215/222),
    neutrality_dispatch.py:721, and semantic.py:250 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 it actually covers. Corrected the docstring, and added the
    empirically-verified relationship: static ⊇ behavioral holds for all
    nine families that go through harvest_static/harvest_behavioral
    (verified by instrumenting assert_actions_pinned for one full suite run:
    equal for 7 of 9, a proper superset for tag-hygiene (12 static vs 7
    behavioral) and ideation-routing (63 static vs 61 behavioral)).
  • ~lines 211-212: 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 ever run. Verified two of ideation-routing's
    pinned strings (ideation_routing.py:315, :319) are exactly this case:
    their only caller (_load_repo_records, ~line 1213) pre-filters every
    record to isinstance(data, dict) and data.get("kind") == RECORD_KIND
    before calling _shape_findings, so _shape_findings's own
    isinstance/kind guards can never fire — yet the static half still
    (correctly, by what it actually checks) counts them as covered.
  • ~lines 117-123: 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.

Optional: _action_param_index / kwonlyargs

Extended _action_param_index to also recognize a keyword-only action
parameter. Previously only posonly/regular params were checked, so a
module-local helper declaring action as keyword-only (def helper(..., *, action)) would never be registered as an action-taker at all — even a call
site passing action=... by keyword would go unmatched, because the
keyword-matching pass only runs for callees already in action_takers. No
such helper exists in the corpus today (checked via an AST scan across
scripts/doc_health/*.py), so this is forward-hardening rather than a fix
for an active gap. It met the task's "trivial and all tests still pass"
bar, so it's included rather than skipped.

Verification

python3 -m pytest tests/doc-health -q
# 1330 passed, 7 warnings in 181.32s

git diff --stat origin/main
#  tests/doc-health/action_pins.py                    | 103 +++++++++++++++------
#  .../doc-health/test_client_identity_composition.py |   9 ++
#  tests/doc-health/test_family_enumeration.py        |  10 +-
#  .../test_modified_block_currency_reporting.py      |  10 +-
#  4 files changed, 104 insertions(+), 28 deletions(-)

Only tests/doc-health/ touched; nothing under scripts/, openspec/, or
.github/.

🤖 Generated with Claude Code

… -> 155/155)

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: Claude Fable 5 <[email protected]>
Copilot AI lite review requested due to automatic review settings August 28, 2026 18:37

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

Pull request overview

This PR tightens the doc-health “action string pin” guarantees by adding three missing, non-tautological literal pins in the tests/doc-health/ suites (closing the remaining 152/155 → 155/155 gap) and clarifies/extends the shared action_pins harvester documentation + forward-hardening.

Changes:

  • Replace a constant-reference tautology with a fresh literal pin for modified-block-currency’s drift action.
  • Add fresh literal .action pins for previously-unpinned findings in client-identity-composition and family-enumeration.
  • Update tests/doc-health/action_pins.py docstrings and extend _action_param_index to recognize keyword-only action parameters.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/doc-health/test_modified_block_currency_reporting.py Replaces the drift action pin with an independently-typed literal to avoid constant-tautology.
tests/doc-health/test_family_enumeration.py Adds a literal pin for the phantom-registration finding’s distinct action string.
tests/doc-health/test_client_identity_composition.py Adds a literal pin for the undeclared-cross-domain-reach finding’s action string.
tests/doc-health/action_pins.py Clarifies harvester semantics and forward-hardens helper-signature detection (kw-only action).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +124 to +126
for arg in func_def.args.kwonlyargs:
if arg.arg == "action":
return 1 << 30 # unreachable via `node.args[idx]`; see above
@brettheap
brettheap merged commit 99a6ff8 into main Aug 29, 2026
4 checks passed
@brettheap
brettheap deleted the tests/fix-485-action-pins branch August 29, 2026 08:50
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.

Action pins: 3 strings still unpinned after #484 (152/155), one is a constant-reference tautology

2 participants