Repository navigation
Pin the three action strings #484's corpus-wide count missed (152/155 -> 155/155) - #486
Merged
Merged
Conversation
… -> 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]>
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 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
.actionpins for previously-unpinned findings inclient-identity-compositionandfamily-enumeration. - Update
tests/doc-health/action_pins.pydocstrings and extend_action_param_indexto recognize keyword-onlyactionparameters.
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 |
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.
Closes #485.
Summary
#484's nine per-family claims all held; its corpus-wide "155/155" summaryin 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'snine), 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
scripts/doc_health/modified_block_currency.py:1516(_DRIFT_ACTION).tests/doc-health/test_modified_block_currency_reporting.py:168did"unplaced": mbc._DRIFT_ACTION— a constant reference.mbc.CLASSESbuilds its
unplacedclass's action from that same constant at importtime, so both sides of the comparison always move together — the exact
tautology
#448's review caught and fixed for_MARKER_ACTION. Replacedwith the fresh literal typed out from
_DRIFT_ACTION's own definition.scripts/doc_health/client_identity_composition.py:256(theundeclared-cross-domain-reachaction). No test anywhere asserted on thisfinding's
.action. Added a fresh-literal pin totest_undeclared_cross_domain_reach_fires_and_names_both_sides.scripts/doc_health/family_enumeration.py:409(the phantom-registration action — distinct from the enumeration-drift action
#448already 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"inmodified_block_currency.py:2.
client_identity_composition.py:256— mutated"publish an entry"->"MUTATED publish an entry":3.
family_enumeration.py:409— mutated"remove the entry"->"MUTATED remove the entry":All three reverted with
git checkout -- scripts/after proving the mutationred; 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-literalactions was wrong —
client_identity_composition.py(x2, lines 215/222),neutrality_dispatch.py:721, andsemantic.py:250all build their actionwith 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 ⊇ behavioralholds for allnine families that go through
harvest_static/harvest_behavioral(verified by instrumenting
assert_actions_pinnedfor one full suite run:equal for 7 of 9, a proper superset for
tag-hygiene(12 static vs 7behavioral) and
ideation-routing(63 static vs 61 behavioral)).~lines 211-212: rewordedassert_actions_pinned's"reachable"/"unreachable" language to "statically present"/"neither
statically present nor behaviorally emitted" —
harvest_staticprovesonly that a literal reaches an
actionparameter syntactically, not thatthe branch holding it can ever run. Verified two of
ideation-routing'spinned strings (
ideation_routing.py:315,:319) are exactly this case:their only caller (
_load_repo_records, ~line 1213) pre-filters everyrecord to
isinstance(data, dict) and data.get("kind") == RECORD_KINDbefore calling
_shape_findings, so_shape_findings's ownisinstance/kindguards 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 inharvest_static— it walks the WHOLE module tree viaast.walk(not justmodule-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 reacheswins the dict entry.
Optional:
_action_param_index/kwonlyargsExtended
_action_param_indexto also recognize a keyword-onlyactionparameter. Previously only posonly/regular params were checked, so a
module-local helper declaring
actionas keyword-only (def helper(..., *, action)) would never be registered as an action-taker at all — even a callsite passing
action=...by keyword would go unmatched, because thekeyword-matching pass only runs for callees already in
action_takers. Nosuch helper exists in the corpus today (checked via an AST scan across
scripts/doc_health/*.py), so this is forward-hardening rather than a fixfor an active gap. It met the task's "trivial and all tests still pass"
bar, so it's included rather than skipped.
Verification
Only
tests/doc-health/touched; nothing underscripts/,openspec/, or.github/.🤖 Generated with Claude Code