Skip to content

feat(health): answer "what tests this" from the call graph, not imports - #1755

Merged
swati510 merged 1 commit into
mainfrom
feat/call-graph-test-map
Aug 19, 2026
Merged

swati510 merged 1 commit into
mainfrom
feat/call-graph-test-map

Conversation

@RaghavChamadiya

Copy link
Copy Markdown
Member

The inferred test map shipped in #1749 walks import edges one hop. That was
the best of the import-based options and still the wrong graph: a test importing
a module is weak evidence it runs it. This swaps it to the call graph, which
0.44.0 finally made good enough to lead with.

Dogfooded against a real coverage run --contexts=test over a slice where
per-test attribution is complete, both sides seeing the same 37 test files:

forward signal (feeds untested_hotspot) precision recall
import graph, 1 hop (what shipped) 72.1% 19.5%
call graph, 3 hops 91.7% 27.7%
call graph, 3 hops, filtered 95.7% 27.7%
both unioned 78.9% 28.3%

Recall of 27.7% is not the graph falling short

coverage marks a line as run whether a test called into it or Python merely
evaluated the module body on import, so the truth set cannot tell an imported
file from an exercised one. Split the 159 truth files by how much of what ran
was actually inside a function body:

what actually ran in the file files found recall
nothing inside any function body 39 0 0%
under a quarter inside bodies 19 0 0%
a quarter to three quarters 45 3 7%
over three quarters inside bodies 56 43 77%

A quarter of the "covered" files never ran a single line inside a function.
Missing those is correct: nothing called them, and claiming otherwise is exactly
the import graph's error. Of the 13 missed in the bottom row, 11 are
alembic/versions/* migrations, whose upgrade/downgrade the framework
invokes by naming convention with no static caller anywhere in the repo.

Excluding those, this finds 43 of the 45 files a test genuinely exercised
and that anything statically calls. The headline number is a floor set by the
measuring instrument, and lifting it means re-claiming imported-but-never-called
files, which is the 16.8 precision points the union column above gives away.

Three measured choices

Depth 3 is where the call walk saturates: 3, 4 and 5 hops return the same 48
claims and 44 confirmations. The ceiling is the graph's capture rate, not depth.

The tiers combine differently per direction, because the numbers differ.
Forward is call edges only, since a false "something reaches this" hides a real
gap. Reverse falls back rather than unions, spending the import tier only on
targets the call graph left silent, which answers one more target at identical
precision (97.5% either way, against 94.8% for imports alone).

resolution_origin becomes the first accuracy lever anything reads.
global_unique binds a name to the only symbol carrying it repo-wide, which the
vocabulary itself scores 0.50. Dropping it buys 4.0 points of forward precision
at zero cost to recall. A confidence floor of 0.90 was tried instead and cut
recall to 23.3%.

Impact here

Against the 80 standing untested_hotspot findings the filename convention
leaves behind, the call graph clears 32 (22 high, 3 critical) where the one-hop
import walk clears 11.

Unchanged

The inferred labelling, the basis contract, and the rule that no percentage
is ever derived from this. Nothing is persisted. impacted-tests gains
via: call-graph beside import-graph so a reader can tell the tiers apart,
and HEALTH_ANALYZER_VERSION moves to 3 so an index stamped 2 re-scores.

New EXECUTION_EDGE_TYPES in ingestion/models.py: the reachability view minus
references and reads, which record a mention rather than a transfer of
control. Dead code asks "is this used", which a mention answers; this asks "is
this run", which it does not.

Tests

tests/unit/{health,analysis,persistence} plus the rescore gate and the change
risk tool: 2439 passed. cli/server/ingestion: 6953 passed. ruff check
clean. The two Pascal failures in health are pre-existing and environmental
(no local grammar).

The inferred test map shipped walking import edges one hop, which was the best
of the import-based options and still the wrong graph. A test file that imports
a module is weak evidence it runs it; a test whose calls reach the module is
much stronger, and release 0.44.0 made that graph good enough to lead with.

Dogfooded against a real `coverage run --contexts=test` over a slice where
per-test attribution is complete, both sides seeing the same 37 test files and
159 provably-executed production files:

  forward (untested_hotspot suppression)   claims  correct   prec  recall
    import graph, 1 hop (what shipped)         43       31  72.1%   19.5%
    call graph, 3 hops                         48       44  91.7%   27.7%
    call graph, 3 hops, filtered               46       44  95.7%   27.7%
    both unioned                               57       45  78.9%   28.3%

  reverse (tests_to_run / impacted_tests) targets      hit    prec
    import graph, 1 hop (what shipped)          32    96.9%   94.8%
    call graph, 3 hops, filtered                46   100.0%   97.5%
    both unioned                                47   100.0%   95.8%
    call graph, else import graph               47   100.0%   97.5%

The call graph wins on both axes, so it leads. The two are combined differently
per direction, because the measurements differ: unioning costs the forward walk
16.8 points of precision for 0.6 of recall, and a false "something reaches this"
hides a real gap, so forward is call edges only. Reverse falls back instead of
unioning, spending the import tier only on targets the call graph left silent,
which answers one more target at identical precision.

Depth 3 is where the call walk saturates: 3, 4 and 5 hops return the same 48
claims and 44 confirmations, so the ceiling is the call graph's capture rate,
not the depth. The import tier keeps its measured default of 1.

`graph_edges.resolution_origin` becomes the first accuracy lever anything reads.
`global_unique` binds a name to the only symbol carrying it repo-wide, which the
vocabulary itself scores 0.50, and dropping it buys 4.0 points of forward
precision and 1.1 of reverse at no cost to recall. A confidence floor of 0.90
was tried instead and cut recall from 27.7% to 23.3%.

On repowise's own index, against the 80 standing untested_hotspot findings the
filename convention leaves behind, the call graph clears 32 (22 high, 3 critical)
where a one-hop import walk clears 11.

Unchanged: the `inferred` labelling, the `basis` contract, and the rule that no
percentage is ever derived from this. Nothing is persisted. `impacted-tests`
gains `via: call-graph` beside `import-graph` so a reader can tell the tiers
apart, and HEALTH_ANALYZER_VERSION moves to 3 so an index stamped 2 re-scores.

New `EXECUTION_EDGE_TYPES` in ingestion.models: the reachability view minus
`references` and `reads`, which record a mention rather than a transfer of
control. Dead code asks "is this used", which a mention answers; this asks "is
this run", which it does not.

Why recall reads low at 27.7%: `coverage` records a line as run whether a test
called into it or Python merely evaluated the module body on import, so the
truth set cannot tell an imported file from an exercised one. Splitting the 159
truth files by how much of what ran was inside a function body: 39 ran nothing
inside one at all (0% recall, correctly), 19 ran under a quarter inside (0%), 45
a quarter to three quarters (7%), and 56 over three quarters (77%). Of the 13
missed in that last group, 11 are alembic migrations the framework invokes by
naming convention with no static caller anywhere. Excluding those, the walk
finds 43 of the 45 files a test genuinely exercised and anything statically
calls. Widening the walk to lift the headline number trades that away.
@repowise-bot

repowise-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

✅ Health of changed files: 4.5 → 4.7 (+0.2)
🚨 Change risk: high, riskier than 72% of this repo's commits.

📋 At a glance
1 file changed health · 5 hotspots touched · 3 new findings introduced · 2 co-change pairs left out · 5 files with recent fix history.

Files & modules (2)
  • packages (7 files)
    • .../analysis/test_reachability.py
    • .../mcp_server/tool_change_risk.py
    • .../ingestion/models.py
    • .../biomarkers/untested_hotspot.py
    • .../health/engine.py
    • .../tool_risk/assessment.py
    • .../analysis/pr_blast.py
  • tests (1 file)
    • .../health/test_reachability_wiring.py

✅ Health gate: passed

📌 Before you merge

  • Run .../persistence/test_impacted_tests_resolution.py, .../health/test_code_age_volatility.py, .../health/test_error_handling.py, .../health/test_ff_track_d_exceptions.py (+15 more): they import the changed files
  • .../ingestion/parser.py changed together with .../ingestion/models.py in 14 past commits and isn't in this PR
  • .../ingestion/call_resolver.py changed together with .../ingestion/models.py in 12 past commits and isn't in this PR
🔎 More signals (3)

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (2 modules)"]
    m_packages["packages (7 files)"]:::changed
    m_tests["tests (1 file)"]:::changed
  end
  d_packages["packages"]
  m_tests -->|1 file| d_packages
  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 (168 direct dependents, from the last indexed snapshot). Dashed: history/tests.

🔥 Hotspots touched (5)

  • .../mcp_server/tool_change_risk.py: 9 commits/90d, 5 dependents
  • .../ingestion/models.py: 27 commits/90d, 212 dependents
  • .../biomarkers/untested_hotspot.py: 1 commits/90d, 2 dependents
2 more
  • .../health/test_reachability_wiring.py: 1 commits/90d, 0 dependents
  • .../health/engine.py: 37 commits/90d, 12 dependents

🔗 Hidden coupling (1 file)

  • .../ingestion/models.py co-changes with these files (not in this PR):
    • .../ingestion/parser.py (14×, 🟡 notable)
    • .../ingestion/call_resolver.py (12×, 🟡 notable)

📊 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-19 16:56 UTC

@swati510
swati510 merged commit 68b29bd into main Aug 19, 2026
6 of 9 checks passed
@swati510
swati510 deleted the feat/call-graph-test-map branch August 19, 2026 16:58
swati510 pushed a commit that referenced this pull request Aug 19, 2026
…ed (#1757)

The core has answered "does a test reach this file" from the graph since
#1749, and from the call graph since #1755. None of it reached the web layer:
`/health/coverage` read only the measured `test_coverage` table, so a repo with
no ingested report got an empty summary on a question the graph could already
answer.

The route now falls back to the inferred map under `basis: "inferred"`.

The two bases never share a field. On the inferred basis `summary`, `files` and
`modules` come back empty and the answer rides in `inferred`, so a consumer
cannot render derived data through the measured code path by accident, and
`basis` is the only thing that distinguishes "nothing measured this" from
"measured at zero". Nothing derives a percentage from it: reaching is a
file-level fact with no line attribution, so a ratio would be a coverage figure
the data cannot support. A test asserts that over the serialized payload rather
than field by field, so a future field under a different name fails it too.

The repo-wide question reuses the forward walk `files_reached_by_tests` rather
than seeding the attributed reverse walk with every file. That walk runs a query
per level per seed and is built for a change's files; this is the batch question
and is one multi-source search. Sharing the walk also means the map can never
disagree with the `untested_hotspot` biomarker, which reads the same function.
`call_graph_from_db` is the loader that gets it the same `CallGraphView` from
SQL that the health engine builds from NetworkX - a loader, not a second walk.

`/health/tests-reaching?file_path=` answers which tests reach one file, with
`via` separating `call-graph` from the weaker `import-graph`. One seed, which is
the shape the attributed walk was built for.

Counts stay repo-wide when `limit` trims the list, matching `modules_total`.
Test files are dropped from their own map. Both degrade to `basis: "none"` -
the honest unknown - rather than raising, as `pr_blast` already does.
swati510 pushed a commit that referenced this pull request Aug 20, 2026
…r sources (#1762)

Main has been red since #1755. Two generated artefacts were edited at their
output rather than at their source, and both have a guard test that says so.

`repowise-impacted-tests.md` is rendered from `plugins/shared/` by
`scripts/gen_plugin_content.py`. #1755 added `call-graph` to the generated copy
but left the shared source saying `import-graph`, so the render check found
drift. Fixed at the source and regenerated, which also updates the claude-code
copy that was missed the same way and reflows a paragraph #1755 had hand-wrapped.

The CLI bundles `docs/CHANGELOG.md` as package data so `whats-new` works offline.
#1755 rewrote the entry in `docs/` only, leaving the bundled copy describing the
import-graph version of the feature, including the superseded 27 ms figure and
the "six tests import" wording. Resynced with the copy the test prescribes.

Worth knowing when running these locally: the plugin content tests write to the
working tree, so a failing run leaves the generated file reverted on disk rather
than only reporting drift.
swati510 pushed a commit that referenced this pull request Aug 20, 2026
… benchmarks page (#1766)

* docs: surface the enterprise story, add a roadmap, and restructure the benchmarks

Enterprises evaluating the repo were bouncing before they reached anything that
answers a procurement question, and the benchmarks page had grown into an essay
where every caveat carried the same weight as every result.

README:
- trust strip in the hero, and Enterprise + Roadmap in the top nav
- a real enterprise section: deployment, data boundary, compliance and audit,
  and contract, each pointing at the GA / in development / planned detail rather
  than flattening it into checkmarks
- promote test intelligence, which answers "what tests reach this file" from the
  call graph with no coverage report at all, and was one bullet
- replace the 19-language badge wall with the five-rung ladder, which covers 35
  languages and is the honest answer to "do you support X"

ROADMAP.md, new:
- languages first, and stated plainly as never gated behind the licence
- no dates, because twelve minor releases in thirty-one days makes any quarter
  wrong in the slow direction; status is the commitment and the changelog is the
  evidence
- what we are not building, including an LLM PR reviewer

BENCHMARKS.md:
- lead with the graph results, which a compiler we do not control graded
- verdict, then table, then a fold per section; every caveat and every losing
  row is preserved, nothing moved out that changes a headline
- 777 visible lines down to 456, with 348 behind folds

Fixes, all discrepancies against the current measurements:
- COMMERCIAL quoted -33.5% cost per question, a metric our own prompt-caching
  control retired; it now quotes -31.6% output tokens (n=43)
- COMMERCIAL said both ten and eleven MCP tools, forty lines apart
- COMMERCIAL described the docs layer as LLM-generated, which predates the
  keyless wiki and undersells the zero-LLM story enterprises care about
- docs/README described BENCHMARKS without either graph result

* docs: lead language support with 19 parsed and 35 on the ladder, and claim test intelligence

The five docs disagreed on how much language support to claim: README led 35,
LANGUAGE_SUPPORT led 19, COMMERCIAL led 13 with 35 buried fourteen lines down.
Standardise the shape rather than the number, since either count alone misleads
in a different direction. 13 understates by excluding the five Good-tier
languages that get everything except the health suite; 35 alone would let an
evaluator assume their Zig service is parsed when it is git history only.

- lead everywhere with 19 parsed to a full AST and 35 on the ladder, keeping 13
  where health-tier depth is the actual subject
- mark the AST boundary inside both ladder tables, so a reader can see what a
  lower rung does and does not buy before they ask
- leave the 19s that are specifically about the graph and AST alone; those were
  already correct and are a different claim from ladder breadth

Also add test intelligence to what ships in open source, which was missing from
COMMERCIAL entirely. Coverage ingestion is a product category of its own, and
the differentiator is the half a coverage service structurally cannot do: a
service only ever sees the report, so with no report there is no answer, while
the call graph answers either way.

* docs: correct the test-intelligence and decision-layer claims against the code

TEST_INTELLIGENCE.md still documented the one-hop import walk that #1755
replaced with a filtered three-hop call-graph walk, so every number on the page
was the superseded tier's, and the README and COMMERCIAL summaries inherited
them. Audited INTELLIGENCE_LAYERS.md against the source while there.

Test intelligence, now matching test_reachability.py:
- the call graph leads and the import graph fills silence, with the forward and
  reverse tables as measured: 95.7% forward precision and 97.5% on the run list,
  against 72.1% and 94.8% for the import walk
- why the two tiers combine differently per direction, since unioning costs the
  forward walk 16.8 points of precision for 0.6 of recall
- what "filtered" means: dropping global_unique, which the graph's own
  vocabulary scores 0.50, buys 4.0 points of forward precision at no recall cost
- why recall reads low at 27.7%, which is a property of the truth set
- the untested-hotspot figure was the import tier's: 32 of 80 cleared, not 74
  of 110

Decision layer:
- there are seven sources, not eight, and three retired ones the docs never
  mentioned; six are deterministic and comment archaeology is the one that
  reads prose with a model, not "the one harvested during doc generation"
- INTELLIGENCE_LAYERS opened by claiming everything is computed without model
  calls, which comment archaeology contradicts; both exceptions are now named

Dead code: _DEFAULT_DYNAMIC_PATTERNS holds 14 patterns, not 17. All of them are
now listed rather than sampled, since the list is short enough to print.

Verified as still correct and left alone: 29 resolution origins, 22 framework
detectors, the six receiver-typing languages including Swift, 19 languages to a
full AST, and the 49/26 detector split.

* docs: add source control beyond git to the roadmap, and Apex and Ada to languages

Plenty of the code most worth indexing has never been near a git remote. It sits
in Perforce, in Subversion, or on a mainframe under a change-management system
older than the people maintaining it, and the docs had nothing to say to any of
that.

The useful part is that most of it already works. Verified against a plain
directory with no git: the graph and wiki build normally and only git_commits
comes back empty, because one of the five layers is history-derived and the other
four are computed from the working tree. So the entry leads with what ships today
rather than with a promise, and scopes the gap to the history layer.

- new roadmap section covering Perforce Helix Core and Subversion as planned,
  with TFVC, Mercurial, CA Endevor and ChangeMan ZMF exploring
- Endevor and ChangeMan are named as what they are, promotion hierarchies rather
  than a commit DAG, so the shape is an export plus a history adapter reading
  element or package history
- a line in the README enterprise section, since "we are not on git" otherwise
  reads as a hard no
- Apex for Salesforce estates, and Ada, which turns up in the same defense and
  aerospace estates that ask about COBOL
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