Skip to content

fix: symmetric move detection in PR-review rules#78

Open
smochan wants to merge 1 commit into
mainfrom
fix/moved-symbol-not-new
Open

fix: symmetric move detection in PR-review rules#78
smochan wants to merge 1 commit into
mainfrom
fix/moved-symbol-not-new

Conversation

@smochan

@smochan smochan commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Problem

A relocated function shows up in the graph diff as one node removed and another added sharing the same terminal name. A prior fix (PR #73, esc/pyvisHref) taught the removed-side removed-referenced rule to recognize a move and not flag it as a critical deletion — but the fix was one-sided. The added-side "new code" rules still misfired on the same relocation:

  • formatQn was reported as a new-untested-hotspot after moving app.jsui/helpers.js
  • moved orphans were reported as new-dead-code

A relocated symbol is not new code; its coverage and reachability state predate the PR that moved it.

Fix

Make move detection symmetric:

  • Extract the inline move check into a shared _is_moved(change, counterpart) helper plus precomputed added_names / removed_names sets in evaluate_rules.
  • removed_referenced now uses the helper (behavior unchanged).
  • new_dead_code and new_untested_hotspot now skip symbols whose terminal name + kind appears in the removed set.

Every built-in rule that treats a node as newly-added or removed code now accounts for moves. The generic added_node / removed_node whens have no built-in rule, so there is no remaining gap.

Tests

  • test_new_untested_hotspot_skips_moved_symbol (regression)
  • test_new_untested_hotspot_still_fires_for_genuinely_new (control — genuinely new high-fan-in untested fn still fires)
  • test_new_dead_code_skips_moved_symbol (regression)

pytest tests/ -k review40 passed.

🤖 Generated with Claude Code

…ction)

A relocated function appears in the graph diff as one node removed and
another added with the same terminal name. The removed-side
removed-referenced rule already recognized this; the added-side "new
code" rules did not, so a move flagged formatQn as a new-untested-hotspot
and moved orphans as new-dead-code.

Extract the move check into a shared _is_moved helper plus precomputed
added_names/removed_names sets, and apply it symmetrically: new_dead_code
and new_untested_hotspot now skip symbols whose terminal name exists in
the removed set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

codegraph PR review

Diff vs main · severity ≤ high

codegraph review (target: main)

Diff: +4 / -0 / ~0 nodes, +46 / -4 edges

Findings (0)

No findings.

Triggered by codegraph CI · last run

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.

1 participant