Skip to content

fix(health): exclude Rust inline test code from perf findings - #1855

Open
NullSense wants to merge 1 commit into
repowise-dev:mainfrom
NullSense:fix/rust-inline-test-perf-false-positives
Open

fix(health): exclude Rust inline test code from perf findings#1855
NullSense wants to merge 1 commit into
repowise-dev:mainfrom
NullSense:fix/rust-inline-test-perf-false-positives

Conversation

@NullSense

Copy link
Copy Markdown

Summary

  • The Phase-7b centrality gate (perf.gated.collect_centrality_gated) flags Rust test helpers as production perf findings. It decides a hot_path_sync_io / nested_loop_quadratic hit from only the walker's per-function facts and whether the file is hot/churny, and neither of those knows a function is test-only.
  • Adds FileComplexity.rust_test_line_ranges, computed once from the tree walk_file already parses, and checks it at the one place both gated markers are produced.
  • Measured on a real corpus: hot_path_sync_io findings went from 122 to 56. All 66 removed findings were test code; all 56 remaining findings were production code, unchanged.

Related Issues

None.

Test Plan

  • uv run pytest tests/unit/health/test_perf_rust_test_filter.py -q — 9 passed
  • uv run pytest tests/unit/health/ -q — 1213 passed
  • uv run ruff check .
  • uv run repowise risk main..HEAD:
    Change risk for main..HEAD: touches files that have broken before · 0th percentile of this repo's fix-bearing files
      fix(health): exclude Rust inline test code from perf findings
      +277 / -2 lines · 4 files · 3 dirs · 2 subsystems · entropy 1.36 · author exp 0  (fix)
    
    File                                                                    Lines   Prior fixes
    packages/core/src/repowise/core/analysis/health/complexity/walker.py      61            2.6
    packages/core/src/repowise/core/analysis/health/complexity/models.py      11            0.9
    
    Diff shape: Typical · 53rd percentile of recent commits by size and spread
      About as risky as a typical commit in this repo.
    
    (impacted-tests / health --file need a completed repowise init against this clone; that indexing run did not finish in time and is omitted rather than faked.)

Checklist

  • My code follows the project's code style
  • I have added tests for new functionality
  • All existing tests still pass
  • I have updated documentation if needed

Out of scope

perf.gated.collect_blocking_io_under_lock (the cross-function lock-to-I/O pass) reads the same PerfFnFacts.lock_call_targets / bare_sink_kind and could plausibly hit the identical false-positive shape for a test helper that locks and calls into a sink. I didn't extend the filter there. No measurement backs it, and it's a separate cross-function reachability pass, not the same choke point. Worth a follow-up if it turns out to matter in practice.


Written with AI assistance; measurements and tests were run and verified locally.

@repowise-bot

repowise-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

✅ Health of changed files: 5.3 → 6.2 (+0.9)
⚠️ Change risk: moderate, riskier than 51% of this repo's commits.

📋 At a glance
3 hotspots touched · 2 files with recent fix history. Scoped to packages.

✅ Health gate: passed

📌 Before you merge

  • Run .../health/test_ff_track_iljk_structural.py, .../health/test_file_nloc.py, .../health/test_refactoring_extract_class.py: they import the changed files
🔎 More signals (2)

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (3 with dependents)"]
    f_packages_core_src_repowise_core_analysis_health_complexity_models_py[".../complexity/models.py 🔥"]:::changed
    f_packages_core_src_repowise_core_analysis_health_complexity_walker_py[".../complexity/walker.py 🔥"]:::changed
    f_packages_core_src_repowise_core_analysis_health_perf_gated_py[".../perf/gated.py 🔥"]:::changed
  end
  f_packages_core_src_repowise_core_analysis_health_complexity_class_analysis_py[".../complexity/class_analysis.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_class_analysis_py
  f_packages_core_src_repowise_core_analysis_health_complexity_cyclomatic_py[".../complexity/cyclomatic.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_cyclomatic_py
  f_packages_core_src_repowise_core_analysis_health_complexity_error_handling_py[".../complexity/error_handling.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_error_handling_py
  f_packages_core_src_repowise_core_analysis_health_complexity_perf_walk_py[".../complexity/perf_walk.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_models_py --> f_packages_core_src_repowise_core_analysis_health_complexity_perf_walk_py
  f_packages_core_src_repowise_core_analysis_health_biomarkers_base_py[".../biomarkers/base.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_walker_py --> f_packages_core_src_repowise_core_analysis_health_biomarkers_base_py
  f_packages_core_src_repowise_core_analysis_health_biomarkers_registry_py[".../biomarkers/registry.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_walker_py --> f_packages_core_src_repowise_core_analysis_health_biomarkers_registry_py
  f_packages_core_src_repowise_core_analysis_health_complexity___init___py[".../complexity/__init__.py"]
  f_packages_core_src_repowise_core_analysis_health_complexity_walker_py --> f_packages_core_src_repowise_core_analysis_health_complexity___init___py
  f_packages_core_src_repowise_core_analysis_health_engine_py[".../health/engine.py"]
  f_packages_core_src_repowise_core_analysis_health_perf_gated_py --> f_packages_core_src_repowise_core_analysis_health_engine_py
  f_packages_core_src_repowise_core_analysis_health_perf___init___py[".../perf/__init__.py"]
  f_packages_core_src_repowise_core_analysis_health_perf_gated_py --> f_packages_core_src_repowise_core_analysis_health_perf___init___py
  t_tests_unit_health_test_ff_track_iljk_structural_py(["✅ .../health/test_ff_track_iljk_structural.py"]):::guard
  t_tests_unit_health_test_ff_track_iljk_structural_py -.-> f_packages_core_src_repowise_core_analysis_health_complexity_walker_py
  classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Solid arrows: code that imports the changed files (9 direct dependents, from the last indexed snapshot). Dashed: history/tests.

🔥 Hotspots touched (3)

  • .../perf/gated.py: 5 commits/90d, 2 dependents · primary owner: Raghav Chamadiya (100%)
  • .../complexity/walker.py: 21 commits/90d, 9 dependents · primary owner: Raghav Chamadiya (91%)
  • .../complexity/models.py: 9 commits/90d, 5 dependents · primary owner: Raghav Chamadiya (96%)

👀 Suggested reviewers @RaghavChamadiya


📊 See the full report for this PR
Your repo map with this PR's blast radius lit up, every caller of the contracts it changes, and health before and after. No sign-in. · ⭐ Star Repowise · 📥 Install bot · Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot · Updated 2026-08-22 15:45 UTC

@Ayush7614 Ayush7614 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: pytest tests/unit/health/test_perf_rust_test_filter.py -q 9 passed, full tests/unit/health/ -q 1213 passed. Correctly adds rust_test_line_ranges via same-tree walk and gates collect_centrality_gated at the single choke point — measured 122→56 findings with only test-code hits removed. Shared attr helper _eh_rust_attr_is_test keeps perf and error-handling in sync, and span suppression avoids double-counting. LGTM.

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.

2 participants