Skip to content

fix(pr-review): test-detection + risk calibration — v0.19.1#8

Merged
anvanster merged 4 commits into
mainfrom
fix/pr-review-test-detection
Jul 1, 2026
Merged

fix(pr-review): test-detection + risk calibration — v0.19.1#8
anvanster merged 4 commits into
mainfrom
fix/pr-review-test-detection

Conversation

@anvanster

Copy link
Copy Markdown
Member

Summary

Calibration fixes to the codegraph_pr_context PR-review tool (the bot that comments on every PR), plus a partial parser fix. Prompted by the bot's own review of #7 misreporting coverage and risk.

codegraph_pr_context

  • Structural test detection. Test-caller detection used only name/path heuristics (test_*, /tests/), missing idiomatic Rust unit tests with descriptive names inside #[cfg(test)] mod tests. Now prefers the is_test node property (falling back to the heuristics).
  • Proportionate risk. Was direct_callers > 20 || untested > 5 → high, so any sizeable PR tripped "high" on raw caller count even for body-only changes that break nothing. Risk is now driven by breaking_callers (callers of signature-changed functions) and the untested ratio. breaking_callers is surfaced in the JSON, message, and blast-radius line.
  • Example/bench coverage. Callers under examples/ and benches/ exercise a function at runtime but were counted as breakable production callers (inflating blast radius, flagging eval-driven code as untested). They now count as coverage.

Parser (partial)

  • ir_to_graph wrote is_async/is_static/is_abstract but not is_test, so the graph never carried the marker the visitor computes. Added it, with a regression test for a descriptively-named #[test] inside #[cfg(test)] mod tests.
  • Known-incomplete: end-to-end, is_test still isn't reaching the queried nodes in the full indexing pipeline (root cause not yet isolated; not a cache artifact). Tracked as follow-up.

Version bumped to 0.19.1.

🤖 Generated with Claude Code

anvanster and others added 4 commits June 30, 2026 17:34
codegraph_pr_context classified a caller as a test only when its name
matched test_*/*_test* or its path contained /tests/. Idiomatic Rust unit
tests live in `#[cfg(test)] mod tests` with descriptive names (e.g.
`weighted_mean_l2_math`, `loads_potion_f32_no_weights`), so they were
invisible and every function they cover was reported as "0 coverage".

The indexer already records `is_test` on each function node (from the
language's #[test]/@test marker; helpers.rs:112). Read it via a new
node_props::is_test accessor and prefer it over the name/path heuristics,
which remain as a fallback for languages that don't populate the marker.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ir_to_graph wrote is_async/is_static/is_abstract but not is_test, so the
graph never carried the marker the visitor already computes. Add it, plus a
regression test that a #[test] fn with a descriptive name inside
`#[cfg(test)] mod tests` sets is_test.

NOTE: insufficient on its own — end-to-end pr_context still misreports
coverage; is_test is not reaching the queried nodes in the real indexing
pipeline (cause not yet isolated; not a cache artifact).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…overage

Two calibration fixes to codegraph_pr_context:

- Risk was `total_direct > 20 || untested > 5 → high`, so any sizeable PR
  tripped "high" purely on caller count — even when every change was
  body-only and broke nothing. Base risk instead on `breaking_callers`
  (callers of signature-changed functions) and the untested *ratio*
  (untested / functions_touched). Surface `breaking_callers` in JSON, the
  message, and the blast-radius line.

- Callers under `examples/` and `benches/` exercise a function at runtime
  but were counted as breakable production callers, inflating blast radius
  and leaving example-driven code flagged as untested. Count them as
  coverage instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🔍 CodeGraph PR Review

9 files changed (+100/−24, 4 functions) · Risk: 🟡 medium

Blast radius

6 direct callers affected across codegraph-server/src/domain, codegraph-server/src/mcp, crates/codegraph-rust/src

⚠️ Test gaps (1 function, 0 coverage)

  • execute_tool_inner (crates/codegraph-server/src/mcp/server.rs) — body_changed

Suggested reviewers

Andrey Vasilevsky (78 lines), anvanster (1 lines)

Suggested commit: feat(domain): <describe the change> · 16 tests cover the changes
🤖 Generated by CodeGraph

@anvanster anvanster merged commit 17540f9 into main Jul 1, 2026
1 check passed
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