Skip to content

feat(health): serve the inferred test map when no coverage was ingested - #1757

Merged
swati510 merged 1 commit into
mainfrom
feat/coverage-basis-api
Aug 19, 2026
Merged

swati510 merged 1 commit into
mainfrom
feat/coverage-basis-api

Conversation

@RaghavChamadiya

@RaghavChamadiya RaghavChamadiya commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Repowise has been able to answer "does a test reach this file" from the call graph since #1755, with 95.7% precision. That answer never reached the API, so a repository with no coverage report still got an empty response on a question we could already answer.

/health/coverage now falls back to the graph-inferred test map, tagged basis: "inferred".

The two bases stay apart

basis is measured (a coverage report), inferred (the dependency graph), or none (genuinely unknown).

They are never merged and never averaged, because they are different claims. On the inferred basis summary, files and modules come back empty and the answer rides in a separate inferred object, so a client cannot render derived data through the measured code path by accident.

Nothing derives a percentage from the inferred map. Reaching is a file-level fact with no line attribution behind it, so a ratio built from it would be a coverage figure the data cannot support. You get counts: files_reached and files_not_reached, deliberately two numbers rather than one fraction.

Cost

The repo-wide question reuses the existing forward walk (files_reached_by_tests) rather than seeding the attributed reverse walk with every file in the repository. It is one multi-source search over the graph instead of a query per level per seed. call_graph_from_db is a loader that builds the same view from SQL that the health engine builds in memory, so this can never disagree with the untested_hotspot biomarker.

include_inferred=false declines the fallback for callers that only want the measured summary, such as a tab badge.

New endpoint

GET /health/tests-reaching?file_path= names which tests reach one file, with via separating call-graph (a test's calls run into it) from the weaker import-graph (it is only imported).

Notes

Counts stay repo-wide when limit trims the list. Test files are dropped from their own map. Both endpoints degrade to basis: "none" rather than raising.

New TypeScript types are optional on the response, so a frontend ahead of its backend degrades rather than rendering NaN.

14 new tests in tests/unit/server/test_health_coverage_basis.py.

Found while testing this, not fixed here

graph_nodes.is_test is true for packages/core/src/repowise/core/analysis/test_reachability.py — a source module classified as a test because its filename starts with test_. Across all 1,215 is_test nodes there are 4 such cases, 3 of them source files that seed the forward walk, so everything they call is claimed as reached. Worth a separate fix.

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.
@repowise-bot

repowise-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

✅ Health of changed files: 6.5 → 7.3 (+0.8)
🚨 Change risk: high, riskier than 77% of this repo's commits.

📋 At a glance
1 file changed health · 3 hotspots touched · 3 new findings introduced · 1 file with recent fix history. Scoped to packages.

✅ Health gate: passed

📌 Before you merge

  • Run .../analysis/test_test_reachability.py, .../persistence/test_test_reachability_walk.py, .../src/hosted.fixtures.test.ts, .../__tests__/health.test.ts (+1 more): they import the changed files
  • Docs that usually track this code: docs/architecture/code-health.md, .../health/README.md
🔎 More signals (2)

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (3 with dependents)"]
    f_packages_server_src_repowise_server_routers_code_health_coverage_routes_py[".../code_health/coverage_routes.py 🔥"]:::changed
    f_packages_types_src_health_ts[".../src/health.ts 🔥"]:::changed
    f_packages_core_src_repowise_core_analysis_test_reachability_py[".../analysis/test_reachability.py"]:::changed
  end
  f_packages_server_src_repowise_server_routers_code_health___init___py[".../code_health/__init__.py"]
  f_packages_server_src_repowise_server_routers_code_health_coverage_routes_py --> f_packages_server_src_repowise_server_routers_code_health___init___py
  f_packages_api_client_src_code_health_ts[".../src/code-health.ts"]
  f_packages_types_src_health_ts --> f_packages_api_client_src_code_health_ts
  f_packages_api_client_src_hosted_ts[".../src/hosted.ts"]
  f_packages_types_src_health_ts --> f_packages_api_client_src_hosted_ts
  f_packages_server_src_repowise_server_mcp_server_tool_health_py[".../mcp_server/tool_health.py"]
  f_packages_types_src_health_ts --> f_packages_server_src_repowise_server_mcp_server_tool_health_py
  f_packages_types_package_json["packages/types/package.json"]
  f_packages_types_src_health_ts --> f_packages_types_package_json
  f_packages_cli_src_repowise_cli_commands_impacted_tests_cmd_py[".../commands/impacted_tests_cmd.py"]
  f_packages_core_src_repowise_core_analysis_test_reachability_py --> f_packages_cli_src_repowise_cli_commands_impacted_tests_cmd_py
  f_packages_core_src_repowise_core_analysis_health_engine_py[".../health/engine.py"]
  f_packages_core_src_repowise_core_analysis_test_reachability_py --> f_packages_core_src_repowise_core_analysis_health_engine_py
  f_packages_core_src_repowise_core_analysis_pr_blast_py[".../analysis/pr_blast.py"]
  f_packages_core_src_repowise_core_analysis_test_reachability_py --> f_packages_core_src_repowise_core_analysis_pr_blast_py
  f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py[".../mcp_server/tool_change_risk.py"]
  f_packages_core_src_repowise_core_analysis_test_reachability_py --> f_packages_server_src_repowise_server_mcp_server_tool_change_risk_py
  more(["+40 more dependents"])
  PR --> more
  t_packages_api_client_src_hosted_fixtures_test_ts(["✅ .../src/hosted.fixtures.test.ts"]):::guard
  t_packages_api_client_src_hosted_fixtures_test_ts -.-> f_packages_types_src_health_ts
  t_tests_unit_analysis_test_test_reachability_py(["✅ .../analysis/test_test_reachability.py"]):::guard
  t_tests_unit_analysis_test_test_reachability_py -.-> f_packages_core_src_repowise_core_analysis_test_reachability_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 (49 direct dependents, from the last indexed snapshot). Dashed: history/tests.

🔥 Hotspots touched (3)

  • .../analysis/test_reachability.py: 2 commits/90d, 7 dependents
  • .../src/health.ts: 14 commits/90d, 51 dependents
  • .../code_health/coverage_routes.py: 3 commits/90d, 1 dependents

📊 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 18:00 UTC

@swati510
swati510 merged commit 9f637d2 into main Aug 19, 2026
6 of 9 checks passed
@swati510
swati510 deleted the feat/coverage-basis-api branch August 19, 2026 18:07
RaghavChamadiya added a commit that referenced this pull request Aug 19, 2026
…a report

The core answers "does a test reach this file" from the call graph, and #1757
carries that to the API as a `basis`. The UI was the last layer still assuming
a coverage report is the only way to know, and in two places it contradicted
the product: the empty state told people to go ingest one while claiming
"Nothing is inferred: we read the lines your tests really executed", and the
lede repeated the claim. Both now read as they should.

Coverage -> Tests on the health tab, the file-page tab and the breadcrumb. The
URL stays `/coverage`. One tab, two bases: splitting them would put one
question ("is this tested?") in two places and make the reader check both to be
sure. Inside the tab "coverage" keeps meaning the measured thing, which is why
the health drawer's metric cell stays "Coverage" - a "Tests" cell already sits
four rows under it carrying the paired-file flag.

The chart is the same component with a prop, not a second chart. On the
inferred basis X collapses from a 0-100 continuum to two positions, which is
the honest statement about the evidence: two columns read as coarser than a
measurement without a disclaimer nobody reads, ingesting a report becomes "the
axis gains focus" rather than the price of entry, and a gradient that is never
drawn cannot be misread as one. The columns are beeswarmed because X carries
one bit there, so horizontal space is otherwise dead and a thousand files stack
into two lines; the jitter is seeded off the file path so a re-render does not
move the field.

Column grounds are the sunset pair, plum and orange, not green and red. Health
bands are reserved for health readouts, and painting a static reading in band
colours would make it look like a measurement. The dots keep their health band,
which is a different mark on a different object, so nothing collides.

Nothing on the inferred basis is a percentage or a bar. The hero is a small
integer - risky files nothing reaches - because "1,074 of 2,185 reached" begs
for a bar and a bar is a percentage. A test asserts no `%` appears anywhere in
the rendered view.

The file page is the piece that works on install: it names the tests that reach
this file, with `via` separating a test whose calls run into it from one that
only imports it. Its no-report state stops being a dead end.

Also fixes a false tab description ("Line coverage, once a test report has been
ingested") which the tab's own docstring requires to stay true above the empty
state, and a "1 are reached" plural bug the tests caught.

12 new tests; full packages/ui suite green (1,208).
swati510 pushed a commit that referenced this pull request Aug 19, 2026
…a report (#1758)

* feat(health): make the Coverage tab a Tests tab that answers without a report

The core answers "does a test reach this file" from the call graph, and #1757
carries that to the API as a `basis`. The UI was the last layer still assuming
a coverage report is the only way to know, and in two places it contradicted
the product: the empty state told people to go ingest one while claiming
"Nothing is inferred: we read the lines your tests really executed", and the
lede repeated the claim. Both now read as they should.

Coverage -> Tests on the health tab, the file-page tab and the breadcrumb. The
URL stays `/coverage`. One tab, two bases: splitting them would put one
question ("is this tested?") in two places and make the reader check both to be
sure. Inside the tab "coverage" keeps meaning the measured thing, which is why
the health drawer's metric cell stays "Coverage" - a "Tests" cell already sits
four rows under it carrying the paired-file flag.

The chart is the same component with a prop, not a second chart. On the
inferred basis X collapses from a 0-100 continuum to two positions, which is
the honest statement about the evidence: two columns read as coarser than a
measurement without a disclaimer nobody reads, ingesting a report becomes "the
axis gains focus" rather than the price of entry, and a gradient that is never
drawn cannot be misread as one. The columns are beeswarmed because X carries
one bit there, so horizontal space is otherwise dead and a thousand files stack
into two lines; the jitter is seeded off the file path so a re-render does not
move the field.

Column grounds are the sunset pair, plum and orange, not green and red. Health
bands are reserved for health readouts, and painting a static reading in band
colours would make it look like a measurement. The dots keep their health band,
which is a different mark on a different object, so nothing collides.

Nothing on the inferred basis is a percentage or a bar. The hero is a small
integer - risky files nothing reaches - because "1,074 of 2,185 reached" begs
for a bar and a bar is a percentage. A test asserts no `%` appears anywhere in
the rendered view.

The file page is the piece that works on install: it names the tests that reach
this file, with `via` separating a test whose calls run into it from one that
only imports it. Its no-report state stops being a dead end.

Also fixes a false tab description ("Line coverage, once a test report has been
ingested") which the tab's own docstring requires to stay true above the empty
state, and a "1 are reached" plural bug the tests caught.

12 new tests; full packages/ui suite green (1,208).

* perf(health): have the tab badge decline the graph fallback

Pairs with the server side. The badge reads one number off `summary`, so it
already declines file rows and modules; it now also declines the inferred map,
which it could not render anyway - the inferred basis has no percentage, by
design.

* perf(health): let a caller decline the graph fallback

The code-health page badges the Tests tab from a deliberately cheap request:
`limit=1, module_limit=0`, which its own comment measures at 0.7 KB against the
tab's 442 KB. The inferred fallback made that call read every call edge in the
repository plus every health metric, on any repo without a coverage report.

`include_inferred=false` declines it. Not a third cap: the other two bound how
much of an answer comes back, this one decides whether an expensive second
answer is computed at all.

A declined response omits `basis` rather than reporting "none". The graph was
not consulted, which is not the same as the graph having nothing to say, and
collapsing the two would leave a consumer unable to tell a repo with no tests
from a request that never asked.

* fix(health): put the sunset pair on the dots, not a wash behind them

The inferred chart painted its two columns as a 6% ground and left the dots on
the health ramp. On screen that failed twice over: plum at that opacity is
indistinguishable from grey on a light background, so the split was invisible,
and the health-banded dots took the entire visual budget to re-say what their
own vertical position already said.

Health is the Y axis. Colouring a dot by health band is therefore redundant,
and it left nothing carrying the one fact the chart exists to show. The dots now
take plum for "no test reaches it" and orange for "a test reaches it", and the
grounds are gone rather than competing with them.

This also keeps green/amber/red off inferred data, which is the point: those
carry a measured band, and a static reading should not borrow them.
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