Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
refactor(test-impact): split analyze_test_impact into a session read and a pure assemble_test_impact (#2508)
Raghav Chamadiyaecc7934af930
diff --git a/packages/core/src/repowise/core/analysis/test_impact.py b/packages/core/src/repowise/core/analysis/test_impact.pyindex 6e485d3cf..2b1099e31 100644--- a/packages/core/src/repowise/core/analysis/test_impact.py+++ b/packages/core/src/repowise/core/analysis/test_impact.py@@ -9,7 +9,7 @@ from an empty recommendation population.from __future__ import annotationsfrom collections import defaultdict-from collections.abc import Mapping+from collections.abc import Iterable, Mapping, Sequencefrom typing import Anyfrom sqlalchemy import select@@ -98,25 +98,115 @@ async def analyze_test_impact("""Return one typed, untruncated recommendation population.The same result is consumed by MCP PR mode and the REST blast-radius route.- Coverage and graph inference are both evaluated; de-duplication keeps every- evidence basis on the surviving recommendation.-- *change_status* maps path to ``added``/``modified``/``deleted``/``renamed``.- A deleted path has no head side to cover, so "no measured tests" there is a- consequence of the deletion and not a coverage gap. Without it every path is- treated as present, which is the historical behaviour.+ Reads the coverage map and graph reachability for *changed_files*, then+ hands both to :func:`assemble_test_impact`."""from repowise.core.analysis.test_reachability import tests_reaching_by_tierfrom repowise.core.persistence.crud import get_test_coverage_summary, tests_covering- changed = sorted(+ changed = _changed_paths(changed_files, exclude_spec)+ fold = {+ "repository_id": repository_id,+ "repository": repository_alias,+ "exclude_spec": exclude_spec,+ "change_status": change_status,+ }+ if not changed:+ return assemble_test_impact([], {}, {}, {}, **fold)++ try:+ summary = await get_test_coverage_summary(session, repository_id)+ coverage_error: str | None = None+ except Exception as exc: # analysis must degrade without losing graph candidates+ summary = {}+ coverage_error = type(exc).__name__++ try:+ indexed_commit = (+ await session.execute(+ select(Repository.head_commit).where(Repository.id == repository_id)+ )+ ).scalar_one_or_none()+ except Exception:+ indexed_commit = None++ measured: dict[str, list[Mapping[str, Any]]] = {}+ if summary.get("pair_count", 0) > 0:+ for path in changed:+ try:+ measured[path] = await tests_covering(+ session, repository_id, path, lines=None+ )+ except Exception as exc:+ coverage_error = type(exc).__name__++ inference_error: str | None = None+ try:+ reached_by_file = await tests_reaching_by_tier(session, repository_id, changed)+ except Exception as exc:+ reached_by_file = {}+ inference_error = type(exc).__name__+ inferred = {+ path: {"tests": list(reached.all_tests or reached.tests), "via": reached.via}+ for path, reached in reached_by_file.items()+ }++ return assemble_test_impact(+ changed,+ measured,+ inferred,+ summary,+ indexed_commit=indexed_commit,+ coverage_error=coverage_error,+ inference_error=inference_error,+ **fold,+ )+++def _changed_paths(changed_files: Iterable[str], exclude_spec: Any) -> list[str]:+ return sorted({pathfor path in changed_filesif path and not (exclude_spec and is_excluded(path, exclude_spec))})- repository = repository_alias or repository_id+++def assemble_test_impact(+ changed_files: Iterable[str],+ measured_by_file: Mapping[str, Sequence[Mapping[str, Any]]],+ inferred_by_file: Mapping[str, Mapping[str, Any]],+ coverage_summary: Mapping[str, Any],+ *,+ repository_id: str,+ repository: str | None = None,+ indexed_commit: str | None = None,+ exclude_spec: Any = None,+ change_status: Mapping[str, str] | None = None,+ coverage_error: str | None = None,+ inference_error: str | None = None,+) -> dict[str, Any]:+ """Fold coverage and reachability evidence into the test-impact result.++ Pure: no I/O. *measured_by_file* maps a changed path to its coverage-map+ rows (``test_id``, optional ``test_file`` and ``source_format``), read only+ when *coverage_summary* reports pairs. *inferred_by_file* maps a changed path+ to ``{"tests": [...], "via": tier}``, both keys required, with ``tests`` the+ uncapped list (``ReachedBy.all_tests``, not the display-capped ``tests``);+ paths outside *changed_files* are ignored. *coverage_summary* carries+ ``pair_count``, ``test_count``, ``source_file_count``, ``ingested_at``,+ ``source_format`` and ``ingested_commit_sha``. The two ``*_error`` arguments+ are the exception type names of a failed read, which mark that side degraded.+ *changed_files* is filtered by *exclude_spec* here too.++ *change_status* maps path to ``added``/``modified``/``deleted``/``renamed``.+ A deleted path has no head side to cover, so "no measured tests" there is a+ consequence of the deletion and not a coverage gap. Without it every path is+ treated as present, which is the historical behaviour.+ """+ changed = _changed_paths(changed_files, exclude_spec)+ repository = repository or repository_idif not changed:return {"recommendations": [],@@ -164,43 +254,23 @@ async def analyze_test_impact("basis_categories": [],},}- measured_by_file: dict[str, list[str]] = {path: [] for path in changed}- inferred_by_file: dict[str, list[str]] = {path: [] for path in changed}+ measured_tests_by_file: dict[str, list[str]] = {path: [] for path in changed}+ inferred_tests_by_file: dict[str, list[str]] = {path: [] for path in changed}evidence: dict[tuple[str, str], list[dict[str, Any]]] = defaultdict(list)test_files: dict[tuple[str, str], set[str]] = defaultdict(set)- try:- summary = await get_test_coverage_summary(session, repository_id)- map_present = summary.get("pair_count", 0) > 0- coverage_error: str | None = None- except Exception as exc: # analysis must degrade without losing graph candidates- summary = {}- map_present = False- coverage_error = type(exc).__name__-- try:- indexed_commit = (- await session.execute(- select(Repository.head_commit).where(Repository.id == repository_id)- )- ).scalar_one_or_none()- except Exception:- indexed_commit = None+ summary = coverage_summary+ map_present = summary.get("pair_count", 0) > 0if map_present:for path in changed:- try:- rows = await tests_covering(session, repository_id, path, lines=None)- except Exception as exc:- coverage_error = type(exc).__name__- rows = []- for row in rows:+ for row in measured_by_file.get(path, ()):test_id = str(row["test_id"])test_file = row.get("test_file")runnable_file = str(test_file or test_id.split("::", 1)[0])if exclude_spec and is_excluded(runnable_file, exclude_spec):continue- measured_by_file[path].append(test_id)+ measured_tests_by_file[path].append(test_id)key = (repository_id, test_id)if test_file:test_files[key].add(str(test_file))@@ -213,32 +283,31 @@ async def analyze_test_impact(if detail not in evidence[key]:evidence[key].append(detail)- try:- inferred = await tests_reaching_by_tier(session, repository_id, changed)+ if inference_error:+ inference_status = "degraded"+ inference_reason: str | None = f"{inference_error}: test_reachability_failed"+ else:inference_status = "available"inference_reason = None- except Exception as exc:- inferred = {}- inference_status = "degraded"- inference_reason = f"{type(exc).__name__}: test_reachability_failed"inferred_totals_by_file: dict[str, int] = {}- for path, reached in inferred.items():- all_tests = list(reached.all_tests or tuple(reached.tests))+ for path, reached in inferred_by_file.items():+ if path not in inferred_tests_by_file:+ continuekept_tests = [test_id- for test_id in all_tests+ for test_id in reached["tests"]if not (exclude_spec and is_excluded(test_id, exclude_spec))]inferred_totals_by_file[path] = len(kept_tests)for test_id in kept_tests:- inferred_by_file[path].append(test_id)+ inferred_tests_by_file[path].append(test_id)key = (repository_id, test_id)test_files[key].add(test_id)detail = {"basis": "inferred","source_file": path,- "via": reached.via,+ "via": reached["via"],"source_format": None,}if detail not in evidence[key]:@@ -270,7 +339,7 @@ async def analyze_test_impact()recommendations.sort(key=_recommendation_sort_key)- matched_files = sum(bool(tests) for tests in measured_by_file.values())+ matched_files = sum(bool(tests) for tests in measured_tests_by_file.values())coverage_reason: str | Noneif coverage_error:coverage_status = "degraded"@@ -304,15 +373,15 @@ async def analyze_test_impact("status": inference_status,"reason": inference_reason,"changed_files_total": len(changed),- "changed_files_with_candidates": sum(bool(tests) for tests in inferred_by_file.values()),+ "changed_files_with_candidates": sum(bool(tests) for tests in inferred_tests_by_file.values()),"candidates_before_dedup": sum(inferred_totals_by_file.values()),}statuses = dict(change_status or {})files = []for path in changed:- measured_tests = sorted(set(measured_by_file[path]))- inferred_tests = sorted(set(inferred_by_file[path]))+ measured_tests = sorted(set(measured_tests_by_file[path]))+ inferred_tests = sorted(set(inferred_tests_by_file[path]))deleted = statuses.get(path) == "deleted"if measured_tests:status = "measured"diff --git a/tests/unit/analysis/test_assemble_test_impact.py b/tests/unit/analysis/test_assemble_test_impact.pynew file mode 100644index 000000000..a7c1353f8--- /dev/null+++ b/tests/unit/analysis/test_assemble_test_impact.py@@ -0,0 +1,62 @@+"""assemble_test_impact over plain records, with no session."""++from __future__ import annotations++from repowise.core.analysis.test_impact import assemble_test_impact++_SUMMARY = {+ "pair_count": 2,+ "test_count": 2,+ "source_file_count": 2,+ "ingested_commit_sha": "head",+ "source_format": "coverage.py",+}+++def _assemble(**kwargs):+ return assemble_test_impact(+ ["src/a.py", "src/gone.py", "src/b.py"],+ {"src/a.py": [{"test_id": "tests/test_a.py::t", "test_file": "tests/test_a.py"}]},+ {"src/b.py": {"tests": ["tests/test_b.py"], "via": "imports"}},+ _SUMMARY,+ repository_id="r1",+ indexed_commit="head",+ **kwargs,+ )+++def test_deleted_path_is_not_a_coverage_gap() -> None:+ impact = _assemble(change_status={"src/gone.py": "deleted"})+ gone = next(r for r in impact["files"] if r["source_file"] == "src/gone.py")+ assert (gone["status"], gone["head_present"], gone["change_status"]) == (+ "deleted",+ False,+ "deleted",+ )+ assert impact["deleted_files"] == ["src/gone.py"]+ assert impact["files_without_measured_tests"] == ["src/b.py"]+ assert impact["unknown_files"] == []+ assert [r["test_id"] for r in impact["recommendations"]] == [+ "tests/test_a.py::t",+ "tests/test_b.py",+ ]+ assert impact["recommendations"][0]["repository"] == "r1"+++def test_without_status_a_missing_path_is_unknown() -> None:+ impact = _assemble()+ assert impact["deleted_files"] == []+ assert impact["unknown_files"] == ["src/gone.py"]+++def test_read_failures_mark_each_side_degraded() -> None:+ impact = _assemble(coverage_error="OperationalError", inference_error="TimeoutError")+ assert impact["coverage"]["reason"] == "OperationalError: coverage_query_failed"+ assert impact["inference"]["reason"] == "TimeoutError: test_reachability_failed"+ assert impact["analysis"]["status"] == "degraded"+++def test_nothing_changed() -> None:+ impact = assemble_test_impact([], {}, {}, {}, repository_id="r1")+ assert impact["files"] == []+ assert impact["coverage"]["reason"] == "no_changed_files"diff --git a/tests/unit/persistence/golden/test_impact.json b/tests/unit/persistence/golden/test_impact.jsonnew file mode 100644index 000000000..dfc516631--- /dev/null+++ b/tests/unit/persistence/golden/test_impact.json@@ -0,0 +1,1802 @@+{+ "current": {+ "analysis": {+ "basis_categories": [+ "measured",+ "inferred"+ ],+ "degraded": false,+ "partial": true,+ "stale": false,+ "status": "partial"+ },+ "coverage": {+ "changed_files_total": 7,+ "changed_files_with_measured_tests": 4,+ "changed_files_without_measured_tests": 3,+ "freshness": {+ "indexed_commit": "fixture-head",+ "ingested_commit": "fixture-head",+ "reason": null,+ "status": "current"+ },+ "ingested_at": "<ingested_at>",+ "map_present": true,+ "pair_count": 15,+ "reason": "coverage_map_matches_only_part_of_change",+ "source_file_count": 4,+ "source_format": "coverage.py",+ "status": "partial",+ "test_count": 15+ },+ "deleted_files": [+ "app/removed_module.py"+ ],+ "files": [+ {+ "change_status": "deleted",+ "head_present": false,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "app/removed_module.py",+ "status": "deleted"+ },+ {+ "change_status": "modified",+ "head_present": true,+ "inferred_tests": [+ "tests/test_both_inferred.py"+ ],+ "inferred_tests_total": 1,+ "measured_tests": [+ "tests/test_both.py::test_measured"+ ],+ "measured_tests_total": 1,+ "source_file": "src/both.py",+ "status": "measured"+ },+ {+ "change_status": "added",+ "head_present": true,+ "inferred_tests": [+ "tests/test_inferred.py"+ ],+ "inferred_tests_total": 1,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/inferred.py",+ "status": "inferred"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [+ "tests/test_measured.py::test_measured"+ ],+ "measured_tests_total": 1,+ "source_file": "src/measured.py",+ "status": "measured"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/no_match.py",+ "status": "unknown"+ },+ {+ "change_status": "deleted",+ "head_present": false,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [+ "tests/test_seed.py::test_seed"+ ],+ "measured_tests_total": 1,+ "source_file": "src/seed.py",+ "status": "measured"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [+ "tests/test_truncate.py::test_00",+ "tests/test_truncate.py::test_01",+ "tests/test_truncate.py::test_02",+ "tests/test_truncate.py::test_03",+ "tests/test_truncate.py::test_04",+ "tests/test_truncate.py::test_05",+ "tests/test_truncate.py::test_06",+ "tests/test_truncate.py::test_07",+ "tests/test_truncate.py::test_08",+ "tests/test_truncate.py::test_09",+ "tests/test_truncate.py::test_10",+ "tests/test_truncate.py::test_11"+ ],+ "measured_tests_total": 12,+ "source_file": "src/truncate.py",+ "status": "measured"+ }+ ],+ "files_total": 7,+ "files_without_measured_tests": [+ "src/inferred.py",+ "src/no_match.py"+ ],+ "inference": {+ "candidates_before_dedup": 2,+ "changed_files_total": 7,+ "changed_files_with_candidates": 2,+ "reason": null,+ "status": "available"+ },+ "recommendations": [+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/both.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both.py",+ "test_id": "tests/test_both.py::test_measured"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/measured.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/measured.py"+ ],+ "test_file": "tests/test_measured.py",+ "test_id": "tests/test_measured.py::test_measured"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/seed.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/seed.py"+ ],+ "test_file": "tests/test_seed.py",+ "test_id": "tests/test_seed.py::test_seed"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_00"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_01"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_02"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_03"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_04"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_05"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_06"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_07"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_08"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_09"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_10"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_11"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/both.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both_inferred.py",+ "test_id": "tests/test_both_inferred.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/test_inferred.py",+ "test_id": "tests/test_inferred.py"+ }+ ],+ "recommendations_by_primary_basis": {+ "inferred": 2,+ "measured": 15+ },+ "recommendations_emitted": 17,+ "recommendations_omitted": 0,+ "recommendations_total": 17,+ "recommendations_truncated": false,+ "unknown_files": [+ "src/no_match.py"+ ]+ },+ "legacy_current": {+ "analysis": {+ "basis_categories": [+ "measured",+ "inferred"+ ],+ "degraded": false,+ "partial": true,+ "stale": false,+ "status": "partial"+ },+ "basis": "measured",+ "by_file": {+ "src/both.py": [+ "tests/test_both.py::test_measured"+ ],+ "src/measured.py": [+ "tests/test_measured.py::test_measured"+ ],+ "src/seed.py": [+ "tests/test_seed.py::test_seed"+ ],+ "src/truncate.py": [+ "tests/test_truncate.py::test_00",+ "tests/test_truncate.py::test_01",+ "tests/test_truncate.py::test_02",+ "tests/test_truncate.py::test_03",+ "tests/test_truncate.py::test_04",+ "tests/test_truncate.py::test_05",+ "tests/test_truncate.py::test_06",+ "tests/test_truncate.py::test_07",+ "tests/test_truncate.py::test_08",+ "tests/test_truncate.py::test_09",+ "tests/test_truncate.py::test_10",+ "tests/test_truncate.py::test_11"+ ]+ },+ "coverage": {+ "changed_files_total": 7,+ "changed_files_with_measured_tests": 4,+ "changed_files_without_measured_tests": 3,+ "freshness": {+ "indexed_commit": "fixture-head",+ "ingested_commit": "fixture-head",+ "reason": null,+ "status": "current"+ },+ "ingested_at": "<ingested_at>",+ "map_present": true,+ "pair_count": 15,+ "reason": "coverage_map_matches_only_part_of_change",+ "source_file_count": 4,+ "source_format": "coverage.py",+ "status": "partial",+ "test_count": 15+ },+ "inference": {+ "candidates_before_dedup": 2,+ "changed_files_total": 7,+ "changed_files_with_candidates": 2,+ "reason": null,+ "status": "available"+ },+ "map_present": true,+ "tests_to_run": [+ "tests/test_both.py::test_measured",+ "tests/test_measured.py::test_measured",+ "tests/test_seed.py::test_seed",+ "tests/test_truncate.py::test_00",+ "tests/test_truncate.py::test_01",+ "tests/test_truncate.py::test_02",+ "tests/test_truncate.py::test_03",+ "tests/test_truncate.py::test_04",+ "tests/test_truncate.py::test_05",+ "tests/test_truncate.py::test_06",+ "tests/test_truncate.py::test_07",+ "tests/test_truncate.py::test_08",+ "tests/test_truncate.py::test_09",+ "tests/test_truncate.py::test_10",+ "tests/test_truncate.py::test_11"+ ],+ "tests_to_run_emitted": 15,+ "tests_to_run_total": 15,+ "tests_to_run_truncated": false,+ "tests_to_run_with_basis": [+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/both.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both.py",+ "test_id": "tests/test_both.py::test_measured"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/measured.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/measured.py"+ ],+ "test_file": "tests/test_measured.py",+ "test_id": "tests/test_measured.py::test_measured"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/seed.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/seed.py"+ ],+ "test_file": "tests/test_seed.py",+ "test_id": "tests/test_seed.py::test_seed"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_00"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_01"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_02"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_03"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_04"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_05"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_06"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_07"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_08"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_09"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_10"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "alpha",+ "repository_id": "<current>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_11"+ }+ ]+ },+ "legacy_no_coverage": {+ "analysis": {+ "basis_categories": [+ "inferred"+ ],+ "degraded": false,+ "partial": true,+ "stale": false,+ "status": "partial"+ },+ "basis": "inferred",+ "by_file": {+ "src/both.py": [+ "tests/test_both_inferred.py"+ ],+ "src/inferred.py": [+ "tests/excluded/test_hidden.py",+ "tests/test_inferred.py"+ ]+ },+ "coverage": {+ "changed_files_total": 8,+ "changed_files_with_measured_tests": 0,+ "changed_files_without_measured_tests": 8,+ "freshness": {+ "indexed_commit": "fixture-head",+ "ingested_commit": null,+ "reason": "coverage_or_index_commit_unavailable",+ "status": "unknown"+ },+ "ingested_at": null,+ "map_present": false,+ "pair_count": 0,+ "reason": "no_per_test_coverage_map",+ "source_file_count": 0,+ "source_format": null,+ "status": "unavailable",+ "test_count": 0+ },+ "inference": {+ "candidates_before_dedup": 3,+ "changed_files_total": 8,+ "changed_files_with_candidates": 2,+ "reason": null,+ "status": "available"+ },+ "map_present": false,+ "tests_to_run": [+ "tests/excluded/test_hidden.py",+ "tests/test_both_inferred.py",+ "tests/test_inferred.py"+ ],+ "tests_to_run_emitted": 3,+ "tests_to_run_total": 3,+ "tests_to_run_truncated": false,+ "tests_to_run_with_basis": [+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<bare>",+ "repository_id": "<bare>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/excluded/test_hidden.py",+ "test_id": "tests/excluded/test_hidden.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/both.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<bare>",+ "repository_id": "<bare>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both_inferred.py",+ "test_id": "tests/test_both_inferred.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<bare>",+ "repository_id": "<bare>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/test_inferred.py",+ "test_id": "tests/test_inferred.py"+ }+ ]+ },+ "no_coverage": {+ "analysis": {+ "basis_categories": [+ "inferred"+ ],+ "degraded": false,+ "partial": true,+ "stale": false,+ "status": "partial"+ },+ "coverage": {+ "changed_files_total": 8,+ "changed_files_with_measured_tests": 0,+ "changed_files_without_measured_tests": 8,+ "freshness": {+ "indexed_commit": "fixture-head",+ "ingested_commit": null,+ "reason": "coverage_or_index_commit_unavailable",+ "status": "unknown"+ },+ "ingested_at": null,+ "map_present": false,+ "pair_count": 0,+ "reason": "no_per_test_coverage_map",+ "source_file_count": 0,+ "source_format": null,+ "status": "unavailable",+ "test_count": 0+ },+ "deleted_files": [],+ "files": [+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "app/removed_module.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [+ "tests/test_both_inferred.py"+ ],+ "inferred_tests_total": 1,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/both.py",+ "status": "inferred"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/excluded.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [+ "tests/excluded/test_hidden.py",+ "tests/test_inferred.py"+ ],+ "inferred_tests_total": 2,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/inferred.py",+ "status": "inferred"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/measured.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/no_match.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/seed.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/truncate.py",+ "status": "unknown"+ }+ ],+ "files_total": 8,+ "files_without_measured_tests": [+ "app/removed_module.py",+ "src/both.py",+ "src/excluded.py",+ "src/inferred.py",+ "src/measured.py",+ "src/no_match.py",+ "src/seed.py",+ "src/truncate.py"+ ],+ "inference": {+ "candidates_before_dedup": 3,+ "changed_files_total": 8,+ "changed_files_with_candidates": 2,+ "reason": null,+ "status": "available"+ },+ "recommendations": [+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<bare>",+ "repository_id": "<bare>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/excluded/test_hidden.py",+ "test_id": "tests/excluded/test_hidden.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/both.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<bare>",+ "repository_id": "<bare>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both_inferred.py",+ "test_id": "tests/test_both_inferred.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<bare>",+ "repository_id": "<bare>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/test_inferred.py",+ "test_id": "tests/test_inferred.py"+ }+ ],+ "recommendations_by_primary_basis": {+ "inferred": 3,+ "measured": 0+ },+ "recommendations_emitted": 3,+ "recommendations_omitted": 0,+ "recommendations_total": 3,+ "recommendations_truncated": false,+ "unknown_files": [+ "app/removed_module.py",+ "src/excluded.py",+ "src/measured.py",+ "src/no_match.py",+ "src/seed.py",+ "src/truncate.py"+ ]+ },+ "nothing_changed": {+ "analysis": {+ "basis_categories": [],+ "degraded": false,+ "partial": true,+ "stale": false,+ "status": "partial"+ },+ "coverage": {+ "changed_files_total": 0,+ "changed_files_with_measured_tests": 0,+ "changed_files_without_measured_tests": 0,+ "freshness": {+ "indexed_commit": null,+ "ingested_commit": null,+ "reason": "no_changed_files",+ "status": "unknown"+ },+ "ingested_at": null,+ "map_present": false,+ "pair_count": 0,+ "reason": "no_changed_files",+ "source_file_count": 0,+ "source_format": null,+ "status": "unavailable",+ "test_count": 0+ },+ "deleted_files": [],+ "files": [],+ "files_total": 0,+ "files_without_measured_tests": [],+ "inference": {+ "candidates_before_dedup": 0,+ "changed_files_total": 0,+ "changed_files_with_candidates": 0,+ "reason": null,+ "status": "available"+ },+ "recommendations": [],+ "recommendations_by_primary_basis": {+ "inferred": 0,+ "measured": 0+ },+ "recommendations_emitted": 0,+ "recommendations_omitted": 0,+ "recommendations_total": 0,+ "recommendations_truncated": false,+ "unknown_files": []+ },+ "stale": {+ "analysis": {+ "basis_categories": [+ "measured",+ "inferred"+ ],+ "degraded": false,+ "partial": true,+ "stale": true,+ "status": "partial"+ },+ "coverage": {+ "changed_files_total": 6,+ "changed_files_with_measured_tests": 3,+ "changed_files_without_measured_tests": 3,+ "freshness": {+ "indexed_commit": "moved-on",+ "ingested_commit": "fixture-head",+ "reason": "coverage_commit_differs_from_index",+ "status": "stale"+ },+ "ingested_at": "<ingested_at>",+ "map_present": true,+ "pair_count": 15,+ "reason": "coverage_map_matches_only_part_of_change",+ "source_file_count": 4,+ "source_format": "coverage.py",+ "status": "partial",+ "test_count": 15+ },+ "deleted_files": [],+ "files": [+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [+ "tests/test_both_inferred.py"+ ],+ "inferred_tests_total": 1,+ "measured_tests": [+ "tests/test_both.py::test_measured"+ ],+ "measured_tests_total": 1,+ "source_file": "src/both.py",+ "status": "measured"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/excluded.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [+ "tests/excluded/test_hidden.py",+ "tests/test_inferred.py"+ ],+ "inferred_tests_total": 2,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/inferred.py",+ "status": "inferred"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [+ "tests/test_measured.py::test_measured"+ ],+ "measured_tests_total": 1,+ "source_file": "src/measured.py",+ "status": "measured"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [],+ "measured_tests_total": 0,+ "source_file": "src/no_match.py",+ "status": "unknown"+ },+ {+ "change_status": null,+ "head_present": true,+ "inferred_tests": [],+ "inferred_tests_total": 0,+ "measured_tests": [+ "tests/test_truncate.py::test_00",+ "tests/test_truncate.py::test_01",+ "tests/test_truncate.py::test_02",+ "tests/test_truncate.py::test_03",+ "tests/test_truncate.py::test_04",+ "tests/test_truncate.py::test_05",+ "tests/test_truncate.py::test_06",+ "tests/test_truncate.py::test_07",+ "tests/test_truncate.py::test_08",+ "tests/test_truncate.py::test_09",+ "tests/test_truncate.py::test_10",+ "tests/test_truncate.py::test_11"+ ],+ "measured_tests_total": 12,+ "source_file": "src/truncate.py",+ "status": "measured"+ }+ ],+ "files_total": 6,+ "files_without_measured_tests": [+ "src/excluded.py",+ "src/inferred.py",+ "src/no_match.py"+ ],+ "inference": {+ "candidates_before_dedup": 3,+ "changed_files_total": 6,+ "changed_files_with_candidates": 2,+ "reason": null,+ "status": "available"+ },+ "recommendations": [+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/both.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both.py",+ "test_id": "tests/test_both.py::test_measured"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/measured.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/measured.py"+ ],+ "test_file": "tests/test_measured.py",+ "test_id": "tests/test_measured.py::test_measured"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_00"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_01"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_02"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_03"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_04"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_05"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_06"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_07"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_08"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_09"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_10"+ },+ {+ "bases": [+ "measured"+ ],+ "basis": "measured",+ "evidence": [+ {+ "basis": "measured",+ "source_file": "src/truncate.py",+ "source_format": "coverage.py",+ "via": "coverage-map"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/truncate.py"+ ],+ "test_file": "tests/test_truncate.py",+ "test_id": "tests/test_truncate.py::test_11"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/excluded/test_hidden.py",+ "test_id": "tests/excluded/test_hidden.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/both.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/both.py"+ ],+ "test_file": "tests/test_both_inferred.py",+ "test_id": "tests/test_both_inferred.py"+ },+ {+ "bases": [+ "inferred"+ ],+ "basis": "inferred",+ "evidence": [+ {+ "basis": "inferred",+ "source_file": "src/inferred.py",+ "source_format": null,+ "via": "import-graph"+ }+ ],+ "repository": "<stale>",+ "repository_id": "<stale>",+ "source_files": [+ "src/inferred.py"+ ],+ "test_file": "tests/test_inferred.py",+ "test_id": "tests/test_inferred.py"+ }+ ],+ "recommendations_by_primary_basis": {+ "inferred": 3,+ "measured": 14+ },+ "recommendations_emitted": 17,+ "recommendations_omitted": 0,+ "recommendations_total": 17,+ "recommendations_truncated": false,+ "unknown_files": [+ "src/excluded.py",+ "src/no_match.py"+ ]+ }+}diff --git a/tests/unit/persistence/test_test_impact_golden.py b/tests/unit/persistence/test_test_impact_golden.pynew file mode 100644index 000000000..1a956c0dd--- /dev/null+++ b/tests/unit/persistence/test_test_impact_golden.py@@ -0,0 +1,117 @@+"""analyze_test_impact output, byte-for-byte, over the sealed PR fixture.++Set ``REPOWISE_REGEN_GOLDEN=1`` to rewrite the golden after an intended change.+"""++from __future__ import annotations++import json+import os+from pathlib import Path++from repowise.core.analysis.test_impact import analyze_test_impact, legacy_guarding_tests+from repowise.core.exclusion import build_exclude_spec+from tests.unit.persistence.helpers import insert_repo+from tests.unit.persistence.test_pr_test_impact_semantics import _fixture, _seed++_GOLDEN = Path(__file__).parent / "golden" / "test_impact.json"+++async def _scenarios(session, tmp_path) -> dict:+ fixture = _fixture()+ (tmp_path / ".repowise").mkdir()+ (tmp_path / ".repowise" / "config.yaml").write_text(+ "exclude_patterns:\n - src/excluded.py\n - tests/excluded/**\n",+ encoding="utf-8",+ )+ current = await insert_repo(+ session, name="current", local_path="/tmp/current", head_commit="fixture-head"+ )+ await _seed(session, current.id, fixture)+ stale = await insert_repo(+ session, name="stale", local_path="/tmp/stale", head_commit="moved-on"+ )+ await _seed(session, stale.id, fixture)+ bare = await insert_repo(+ session, name="bare", local_path="/tmp/bare", head_commit="fixture-head"+ )+ await _seed(session, bare.id, fixture, with_coverage=False)++ changed = [*fixture["changed_files"], "app/removed_module.py", "src/seed.py"]+ status = {+ "app/removed_module.py": "deleted",+ "src/seed.py": "deleted",+ "src/inferred.py": "added",+ "src/both.py": "modified",+ }+ out = {+ "current": await analyze_test_impact(+ session,+ current.id,+ changed,+ repository_alias="alpha",+ exclude_spec=build_exclude_spec(tmp_path),+ change_status=status,+ ),+ "stale": await analyze_test_impact(session, stale.id, fixture["changed_files"]),+ "no_coverage": await analyze_test_impact(session, bare.id, changed),+ "nothing_changed": await analyze_test_impact(session, current.id, []),+ }+ out["legacy_current"] = legacy_guarding_tests(out["current"])+ out["legacy_no_coverage"] = legacy_guarding_tests(out["no_coverage"])+ text = json.dumps(out, indent=2, sort_keys=True, default=str)+ for repo, name in ((current, "current"), (stale, "stale"), (bare, "bare")):+ text = text.replace(repo.id, f"<{name}>")+ out = json.loads(text)+ for impact in out.values():+ if impact["coverage"]["ingested_at"] is not None:+ impact["coverage"]["ingested_at"] = "<ingested_at>"+ return out+++async def test_test_impact_matches_golden(async_session, tmp_path) -> None:+ got = await _scenarios(async_session, tmp_path)+ if os.environ.get("REPOWISE_REGEN_GOLDEN"):+ _GOLDEN.parent.mkdir(exist_ok=True)+ _GOLDEN.write_text(json.dumps(got, indent=2, sort_keys=True) + "\n", encoding="utf-8")+ assert got == json.loads(_GOLDEN.read_text(encoding="utf-8"))+++async def test_a_failed_per_file_coverage_read_degrades_coverage_only(+ async_session, monkeypatch+) -> None:+ fixture = _fixture()+ repo = await insert_repo(async_session, name="perfile", head_commit="fixture-head")+ await _seed(async_session, repo.id, fixture)++ async def _boom(*args, **kwargs):+ raise RuntimeError("coverage read failed")++ monkeypatch.setattr("repowise.core.persistence.crud.tests_covering", _boom)+ impact = await analyze_test_impact(async_session, repo.id, fixture["changed_files"])++ assert impact["coverage"]["status"] == "degraded"+ assert impact["coverage"]["reason"] == "RuntimeError: coverage_query_failed"+ assert impact["inference"]["status"] == "available"+ assert {r["basis"] for r in impact["recommendations"]} == {"inferred"}+++async def test_a_failed_reachability_read_degrades_inference_only(+ async_session, monkeypatch+) -> None:+ fixture = _fixture()+ repo = await insert_repo(async_session, name="noreach", head_commit="fixture-head")+ await _seed(async_session, repo.id, fixture)++ async def _boom(*args, **kwargs):+ raise TimeoutError++ monkeypatch.setattr(+ "repowise.core.analysis.test_reachability.tests_reaching_by_tier", _boom+ )+ impact = await analyze_test_impact(async_session, repo.id, fixture["changed_files"])++ assert impact["inference"]["status"] == "degraded"+ assert impact["inference"]["reason"] == "TimeoutError: test_reachability_failed"+ assert impact["analysis"]["status"] == "degraded"+ assert {r["basis"] for r in impact["recommendations"]} == {"measured"}