Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

feat(health): resolve a test's oracle across a file boundary (#2419)

Raghav Chamadiya8258a64fe2e9
diff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.md
index 3fc2cf78a..82c52d3f9 100644
--- a/docs/layers/CODE_HEALTH.md
+++ b/docs/layers/CODE_HEALTH.md
@@ -454,15 +454,16 @@ whether an assertion observes a double or production output, which is a dataflow
question the pass does not ask — and on the TypeScript sample that one question
accounted for every false positive.
-`assertion_free_test` measures **51%** on TypeScript (51 findings, the complete
-population of two corpora) and **86%** on Python (29 hand-labelled, a systematic
+`assertion_free_test` measures **71%** on TypeScript (31 findings, the complete
+population of two corpora; an earlier pass published 51% for the larger
+pre-change population, which re-labels to 43.1% against this rubric) and **86%** on Python (29 hand-labelled, a systematic
sample of 172), and does not report on Go or Java at all; the per-language
reasoning is in
-[LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md#code-health-coverage). The gap between
-the two is one fact: a test that delegates its oracle to a helper in the same
-file is resolved, and a JS/TS suite keeps its helpers in another file. The
-marker stays advisory on both, and twenty-nine items are too few to settle
-whether Python clears the bar.
+[LANGUAGE_SUPPORT.md](LANGUAGE_SUPPORT.md#code-health-coverage). A test that
+delegates its oracle to a helper is resolved in the same file by name, and in
+another file when the call graph binds the call, which is what closed most of
+the TypeScript gap. The marker stays advisory on both: neither population is large
+enough to settle the bar.
It asks a question with a yes-or-no answer rather than a
threshold, which is why it can be stated plainly: a test case whose assertion
diff --git a/docs/layers/LANGUAGE_SUPPORT.md b/docs/layers/LANGUAGE_SUPPORT.md
index 3600c9426..2b3d900f7 100644
--- a/docs/layers/LANGUAGE_SUPPORT.md
+++ b/docs/layers/LANGUAGE_SUPPORT.md
@@ -441,29 +441,121 @@ for Java. A language with no row classifies nothing. Go and Java are classified
and counted, which is how their precision below was measured, but the marker
does not report on them — the shipping set is a constant in the detector.
-Measured precision, hand-labelled: **51%** on TypeScript (51 findings, the
+Measured precision, hand-labelled: **71%** on TypeScript (31 findings, the
complete population of two corpora) and **86%** on Python (29 findings, a
-systematic sample of 172). The marker ships advisory on both, because the bar
-below is a property of the marker rather than of one language, and TypeScript
-is at 51%.
+systematic sample of 172). The marker ships advisory on both: the bar below is a
+property of the marker rather than of one language, and neither reading settles
+it on a population this size.
Twenty-nine items cannot settle a 70% bar: 86% on that sample carries a 95%
interval of roughly 68% to 96%, whose lower bound sits below the bar it appears
to clear. The reading is consistent with clearing it and does not demonstrate
it. What moved Python is that a test's oracle now reaches it from a function it
-calls in the same file, described below. The same change barely moved
-TypeScript, for a reason worth recording: a JS/TS suite keeps its helpers in a
-separate module, so 19 of its 25 remaining false positives delegate across a
-file boundary rather than within one.
+calls in the same file, described below. That barely moved TypeScript, because a
+JS/TS suite keeps its helpers in a separate module; resolving the same
+delegation *across* a file is what took TypeScript from 43% to 71%, and how it
+is done is in the section after next.
An earlier pass published 53% for Python. Re-labelling the pre-change findings
of the same corpus, drawn the same way and read against this pass's rubric,
gives 68.8% (22 of 32), so the gain below is that 68.8 to 86.2 and the 53% is
superseded rather than contradicted. The two passes are not reconciled: 15
points of the difference is labelling, on samples of about thirty, and the
-rubric behind the earlier number was not recorded. TypeScript read 52% then and
-51% here, which is the evidence that the two rubrics are close and Python's gap
-is sample noise rather than a changed standard.
+rubric behind the earlier number was not recorded. TypeScript read 52% then and 51% on
+the pass after it; re-labelled here it reads 43.1%, so the drift is on both
+languages and in the same direction rather than on Python alone. That withdraws
+the earlier reading of it as sample noise: what the three passes differ on is
+the rubric, and the only defence against that is to state the rubric and
+re-label both arms of a comparison together, which is what the section below
+does.
+
+### Resolving a test's oracle across a file boundary
+
+A test that hands its checks to a helper is not assertion-free, and the
+assertion count is per function, so the helper's checks are invisible from the
+test. Resolving that within one file took Python from 68.8% to 86.2%. A JS/TS
+suite keeps its helpers in another module, so the same question had to be asked
+of the call graph.
+
+It is asked in two lanes, because **a JS/TS test case is not a graph node**:
+every one of them is an anonymous callback handed to `it(...)`, and on one
+corpus 0 of 7,354 resolved to a symbol, against 5,212 of 5,212 for Python's
+named `def test_x`. Resolving from the enclosing module node instead would let
+one delegating test speak for every other test in its file, so it is not done.
+
+- **call-edge** — the test is a symbol; walk its own outgoing call edges, depth
+ bounded. Its job on Python is as much to answer *no* authoritatively as to
+ answer yes: while it answers, the looser lane below is never consulted.
+- **file-edge** — the test is a callback; require both that the *file* has a
+ resolved call edge to the asserting symbol and that the *function body* calls
+ it by name. The edge alone is file-scoped and the name alone is repo-scoped;
+ together they are neither.
+
+Only edges that bind **one** definition are read, which is a harder filter than
+the execution index applies. `import_merged` carries 0.85 confidence and means
+only "a function of this name exists in one of the files this file imports"; it
+was measured resolving `Silent().check()` to `Asserting.check` because the
+receiver could not be typed. An extra edge costs a performance pass a cheap
+false positive and costs this marker a hidden true finding, so the two filter
+differently on purpose.
+
+A suppression is available only where an edge is. An unresolved call is
+indistinguishable from a call to something that checks nothing, so it suppresses
+nothing and the marker fires — a missing edge leaves a false positive, where a
+wrong one would hide a real finding.
+
+Three consequences of that, all leaving findings in place rather than removing
+them, and all properties of a repository's layout as much as of the mechanism. A
+helper outside a test-named directory is not an oracle, so a suite keeping its
+helpers in `src/test-utils/` gets nothing from this while one using
+`src/testUtils.ts` does. A re-export is followed one hop, so a single barrel
+file works and a barrel of barrels does not. And an oracle living in a
+`beforeEach` is an anonymous callback with no symbol, so it is never in the sink
+set at all.
+
+Measured on the complete population of two corpora, both arms labelled in one
+pass against one rubric: **51 findings at 43.1% to 31 at 71.0%, with none of the
+22 true findings lost.** All 20 suppressions trace to three helpers, each read in
+full, and each does check something. The sharpest evidence that the oracle is
+per function rather than per file: `inspectTreeStructure` and
+`testParseSourceCodeDefinitions` live in the same helper module, and only the
+second asserts — the first's eleven callers all survive.
+
+An earlier pass published 51% for TypeScript. Re-labelling that same pre-change
+population against this pass's rubric gives 43.1%, so the gain is 43.1 to 71.0
+and the 51% is superseded rather than contradicted; the difference is that this
+pass counts a deliberate, commented "should not throw" as a false positive.
+
+Read that gain with its provenance. Both arms were labelled by one person in one
+unblinded pass, by the author of the change, and the re-label moved the baseline
+**down** -- the one direction that widens the reported gain. The post figure is
+the more defensible of the two, being a complete population rather than a
+sample; the 28-point delta is the part carrying the labeller. A second reader on
+the same population is the cheapest thing that would settle it. Note also that
+22 of 31 is a 95% interval of roughly 53% to 84%, whose lower bound sits below
+the 70% bar exactly as Python's 29-item reading does, so neither language
+demonstrates the bar on these populations. The
+four families that remain are a documented no-throw, a wait helper that throws
+rather than asserts, an `expect(...)` the walk does not count because it is
+bound to a name or nested inside another function, and a guard test whose body
+is a bare `throw`. None is reachable by resolving a call, and none was
+introduced by resolving one.
+
+Python moves on one corpus and not the other, and the split is the point. One
+corpus suppresses nothing: its tests keep their oracles inline or in the same
+file, where the existing rule already reaches them. The other goes from **501
+findings to 346**, and all 155 suppressions trace to just five helper methods --
+one of which, a `check_html` on a shared `SimpleTestCase` subclass, accounts for
+144 by itself. Every one of the five was read in full and every one asserts, so
+the verification is complete by oracle rather than sampled by finding.
+
+That is the base-class idiom listed below as Java's blocker, showing up in
+Python: the helper is inherited, so it is neither in the test's file nor named
+anything the assertion lexicon recognises. It is also why the depth is **2**
+rather than 1: depth 1 resolves only the single largest helper, missing eleven
+of the other four's callers, and depth 3 adds four more that reach
+`SimpleTestCase._assert_raises_or_warns_cm`, the framework's own `assertRaises`
+machinery, which is further than a test's oracle should have to be chased.
A **mock verification counts as an assertion for this marker and not for the one
above**, which is the deliberate inversion described in CODE_HEALTH.md. It
diff --git a/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py b/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py
new file mode 100644
index 000000000..6c3fe5bba
--- /dev/null
+++ b/packages/core/src/repowise/core/analysis/health/asserts/oracle_reach.py
@@ -0,0 +1,318 @@
+"""Cross-file oracle resolution for ``assertion_free_test``.
+
+A test whose own assertion count is zero has still checked something if it
+handed the job to a helper that asserts. ``_asserting_names`` resolves that
+within one file; a JS/TS suite keeps its helpers in another module and a
+class-based suite inherits them from a base class, so the same delegation is
+invisible to a same-file rule by construction.
+
+What this reaches is bounded by ``BINDING_ORIGINS``. An inherited helper called
+through ``self`` binds, which is the shape that moved Python. A Go
+package-level helper does **not**: its origins are ``same_package`` and
+``package_alias``, neither of which is admitted here, and Go does not ship this
+marker anyway. ``super().test_x(...)`` does not either, because the resolver
+has no ``super()`` receiver handling at all.
+
+This pass answers it from the call graph instead of from names.
+
+Two lanes, because a test case is not always a graph node
+---------------------------------------------------------
+A Python ``def test_x`` is a declared symbol, so the graph has a node for it and
+its call edges are attributed to it. A JS/TS test case is an anonymous callback
+handed to ``it(...)``; the graph has **no node for it at all**, and the calls
+inside it are attributed to the enclosing module. Resolving from the module node
+would make one delegating test suppress every other test in its file, so:
+
+* **call-edge** -- the test resolves to a symbol; walk its own outgoing edges.
+ Precise attribution, bounded depth. Python, Go, Java.
+* **file-edge** -- the test does not resolve; require both that *this file* has
+ a resolved edge to the asserting symbol and that *this function's body* calls
+ it by name **with no receiver**. The edge alone is file-scoped and the name
+ alone is repo-scoped; together, on an unqualified call that the file's own
+ imports bind, they are neither. One hop only, because it is already the
+ product of two approximations and a second hop would compound them.
+
+Each suppression records which lane answered, so the two are measured apart.
+
+Precision
+---------
+**Suppression only ever happens on a resolved edge**, and only on an edge that
+binds one definition. An unresolved call is indistinguishable from a call to
+something that checks nothing, so a call the graph could not bind suppresses
+nothing and the marker fires. That is the tolerable direction for an advisory
+marker: a missing edge leaves a false positive, a wrong edge hides a real
+finding.
+
+The edges are filtered harder than ``ExecutionGraphIndex`` filters them --
+see ``BINDING_ORIGINS`` -- because that index is tuned for performance
+reachability, where an extra edge costs a cheap false positive, and here it
+costs a hidden one.
+
+Why this needs nothing persisted
+--------------------------------
+An incremental run walks the changed files plus
+``ExecutionGraphIndex.affected_files``' bounded closure around them, and the
+closure's files are walked in full (``_performance_only_config`` disables their
+detectors, not the walk). The edges this pass reads are a **subset** of the ones
+that closure walks, so any callee it can resolve is a callee whose file was
+walked and whose assertion count is in hand. If the edge is missing, neither the
+closure nor this pass can see it and the marker fires either way. So an edited
+test file is judged identically by ``init`` and by ``update`` (issue #1484), and
+there is no repo-wide quantity to store. The subset relation holds only while
+``max_depth`` stays within the closure's forward bound, which is what
+``CLOSURE_FORWARD_DEPTH`` records and a test pins.
+
+**What that argument does not cover is the reverse edit.** This marker's verdict
+is now a function of another file's contents, and an incremental run re-reports
+only the files in its own changed set. A helper that loses its assertions leaves
+every test delegating to it stale until that test's own file is next edited: the
+closure walks those files, but ``_performance_only_config`` disables a
+``test_quality`` detector on them and the report is filtered back to the changed
+set afterwards. The perf passes this one is modelled on do not have that gap,
+because ``performance`` is the dimension both of those filters make an exception
+for. It is tolerable for an advisory marker that never scores, and the honest
+statement is that the staleness is bounded by the next edit to the test, not
+that it cannot arise.
+"""
+
+from __future__ import annotations
+
+from collections.abc import Iterable
+from dataclasses import dataclass
+from typing import TYPE_CHECKING, Any
+
+from ....test_paths import is_test_related_path
+from ...execution_graph import ExecutionGraphIndex, file_of_symbol, reachable_to_sink
+from ..coverage import is_test_file
+
+if TYPE_CHECKING:
+ from ..complexity import FileComplexity
+
+#: ``ExecutionGraphIndex.affected_files`` takes a forward closure of this depth
+#: when an incremental run decides which files to walk. Resolving deeper than it
+#: walks is what would make ``update`` disagree with ``init``, so this is a
+#: ceiling rather than a default.
+CLOSURE_FORWARD_DEPTH = 3
+
+#: Hops from the test to the asserting function on the call-edge lane. One
+#: covers the measured shape -- a test calling a helper that asserts -- and two
+#: covers a helper that delegates once more. Every extra hop widens what gets
+#: suppressed, and suppression is this rule's failure mode, so it sits below the
+#: ceiling above.
+DEFAULT_MAX_DEPTH = 2
+
+#: Resolution origins that bind a call to **one** definition. Everything the
+#: resolver reaches by matching a bare name against a set of candidates is
+#: absent, however high its confidence: ``import_merged`` (0.85) means only
+#: "a function of this name exists in one of the files this file imports", and
+#: it was measured resolving ``Silent().check()`` to ``Asserting.check`` because
+#: the receiver could not be typed. That is a wrong edge hiding a real finding,
+#: which is the one failure this rule must not have.
+BINDING_ORIGINS = frozenset(
+ {
+ "same_file",
+ "enclosing_class",
+ "self_scope",
+ "self_inherited",
+ "import_scoped",
+ "module_alias",
+ "receiver_same_file",
+ "receiver_typed_same_file",
+ "receiver_typed_same_package",
+ "receiver_typed_import",
+ "return_type_same_file",
+ "return_type_same_package",
+ "return_type_import",
+ }
+)
+
+
+@dataclass(frozen=True, slots=True)
+class OracleReach:
+ """Which asserting function answered for a test, and how it was reached."""
+
+ #: Graph node id of the asserting function, ``"{path}::{name}"``.
+ oracle: str
+ #: Its bare name, for reporting.
+ oracle_name: str
+ #: Call-graph hops from the test to it. 1 on the file-edge lane.
+ distance: int
+ #: Which lane answered: ``"call-edge"`` or ``"file-edge"``.
+ basis: str
+
+
+def collect_cross_file_oracles(
+ walked: Iterable[tuple[Any, FileComplexity]],
+ graph: Any,
+ *,
+ index: ExecutionGraphIndex | None = None,
+ max_depth: int = DEFAULT_MAX_DEPTH,
+) -> dict[str, dict[int, OracleReach]]:
+ """Test cases whose calls reach a function that asserts, keyed by file path.
+
+ The inner key is the test function's 1-indexed start line. Start line rather
+ than name: a file's same-named functions are one graph node but distinct
+ walked functions, and keying on the name would reintroduce the collision
+ #2408 removed.
+
+ Returns ``{}`` without a graph, without binding edges, or when no walked
+ file holds both a candidate and an oracle -- never a guess.
+ """
+ walked_list = list(walked)
+ if graph is None or not walked_list or max_depth < 1:
+ return {}
+
+ # Cheap pre-check over facts the walk already computed, before touching the
+ # graph: the work needs a test that checks nothing. A repo with none
+ # returns without building an index or reading an edge.
+ if not any(_candidates(pf, fcx) for pf, fcx in walked_list):
+ return {}
+
+ if index is None:
+ index = ExecutionGraphIndex(graph)
+
+ forward = _binding_adjacency(graph)
+ if not forward:
+ return {}
+ reverse: dict[str, list[str]] = {}
+ for caller, callees in forward.items():
+ for callee in callees:
+ reverse.setdefault(callee, []).append(caller)
+
+ # Sinks: functions that assert, restricted to test and test-support files.
+ # Without that gate a bare ``assert`` in production code is an oracle, and
+ # a test calling any such function would be suppressed -- a false
+ # suppression, the one direction this rule must not fail in.
+ oracle_name: dict[str, str] = {}
+ for pf, fcx in walked_list:
+ path = pf.file_info.path
+ if not is_test_related_path(path, pf.file_info.language):
+ continue
+ for fn in fcx.functions:
+ if not (fn.assertion_count or fn.verification_count):
+ continue
+ sid = index.resolve_function(path, fn.start_line)
+ if sid is not None:
+ oracle_name.setdefault(sid, fn.name)
+ if not oracle_name:
+ return {}
+
+ reach = reachable_to_sink(
+ oracle_name.keys(),
+ lambda node: reverse.get(node, ()),
+ max_depth=max_depth,
+ )
+ # file-edge lane: every binding edge this file has, by callee name.
+ by_file_name = _oracles_by_file_and_name(forward, oracle_name)
+
+ out: dict[str, dict[int, OracleReach]] = {}
+ for pf, fcx in walked_list:
+ path = pf.file_info.path
+ for fn in _candidates(pf, fcx):
+ found = _resolve_one(path, fn, index, reach, oracle_name, by_file_name)
+ if found is not None:
+ out.setdefault(path, {})[fn.start_line] = found
+ return out
+
+
+def _resolve_one(
+ path: str,
+ fn: Any,
+ index: ExecutionGraphIndex,
+ reach: dict[str, Any],
+ oracle_name: dict[str, str],
+ by_file_name: dict[str, dict[str, set[str]]],
+) -> OracleReach | None:
+ sid = index.resolve_function(path, fn.start_line)
+ if sid is not None:
+ info = reach.get(sid)
+ # ``distance == 0`` means this node IS an oracle, which happens when a
+ # same-named sibling in the file asserts and the two share a node id.
+ # That is the same-file case ``_asserting_names`` already answers by
+ # name; claiming it here would report a resolution that did not happen.
+ if info is not None and info.distance >= 1:
+ return OracleReach(
+ oracle=info.sink,
+ oracle_name=oracle_name.get(info.sink, ""),
+ distance=info.distance,
+ basis="call-edge",
+ )
+ # A test that IS a graph node and reaches no oracle has been answered.
+ # Falling through to the file lane would let a sibling's edge speak for
+ # it, which is exactly the over-suppression that lane exists to avoid.
+ return None
+
+ # file-edge lane, for a test case the graph has no node for.
+ named = by_file_name.get(path)
+ if not named:
+ return None
+ # Unqualified call sites only. ``called_names`` drops the receiver, so
+ # ``harness.checkOk()`` would otherwise pair a method on an unrelated
+ # object with the file's edge to an imported ``checkOk`` -- letting one
+ # delegating test license every same-named call beside it, which is the
+ # over-suppression this lane's two conjuncts exist to prevent. Sorted so
+ # the oracle recorded for a test calling two of them is reproducible.
+ for called in sorted(fn.bare_called_names):
+ targets = named.get(called)
+ if not targets:
+ continue
+ oracle = sorted(targets)[0]
+ return OracleReach(
+ oracle=oracle,
+ oracle_name=oracle_name.get(oracle, ""),
+ distance=1,
+ basis="file-edge",
+ )
+ return None
+
+
+def _binding_adjacency(graph: Any) -> dict[str, tuple[str, ...]]:
+ """Caller -> callees, over call edges that bind exactly one definition."""
+ out: dict[str, list[str]] = {}
+ try:
+ edges = graph.edges(data=True)
+ except Exception:
+ return {}
+ for source, target, data in edges:
+ if data.get("edge_type") != "calls":
+ continue
+ if data.get("resolution_origin") not in BINDING_ORIGINS:
+ continue
+ out.setdefault(source, []).append(target)
+ return {k: tuple(v) for k, v in out.items()}
+
+
+def _oracles_by_file_and_name(
+ forward: dict[str, tuple[str, ...]],
+ oracle_name: dict[str, str],
+) -> dict[str, dict[str, set[str]]]:
+ """Per file, the asserting symbols it has a binding edge to, by bare name.
+
+ Keyed by the callee's lowercased name so it meets ``called_names``, which
+ the walker lowercases. Only oracles in another file are kept: a same-file
+ one is ``_asserting_names``' job and reporting it here would claim a
+ cross-file resolution that did not happen.
+ """
+ out: dict[str, dict[str, set[str]]] = {}
+ for caller, callees in forward.items():
+ caller_path = file_of_symbol(caller)
+ for callee in callees:
+ if callee not in oracle_name:
+ continue
+ callee_path = file_of_symbol(callee)
+ if callee_path == caller_path:
+ continue
+ name = oracle_name[callee].lower()
+ out.setdefault(caller_path, {}).setdefault(name, set()).add(callee)
+ return out
+
+
+def _candidates(pf: Any, fcx: FileComplexity) -> list[Any]:
+ """Test cases in a test file that check nothing themselves."""
+ if not is_test_file(pf.file_info.path):
+ return []
+ return [
+ fn
+ for fn in fcx.functions
+ if fn.is_test_case and not (fn.assertion_count or fn.verification_count)
+ ]
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/assertion_free_test.py b/packages/core/src/repowise/core/analysis/health/biomarkers/assertion_free_test.py
index f14294838..f3a3ab771 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/assertion_free_test.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/assertion_free_test.py
@@ -34,10 +34,12 @@ from .base import BiomarkerResult, FileContext
#: Languages the marker reports on. Go and Java are classified by
#: ``complexity/test_case.py`` and counted like any other, and are deliberately
#: absent here: both conventionally hand the oracle to a helper the test calls.
-#: ``_asserting_names`` now resolves that within a file, but the idiom reaches
-#: across one in both languages, as a package-level Go helper handed ``*testing
-#: .T`` and a Java base-class method. Re-admitting either is a measurement of
-#: its own, not a consequence of this one.
+#: ``asserts/oracle_reach.py`` now resolves that across files too, and a
+#: base-class method reached through ``self`` is the shape it resolves best --
+#: but a Go package-level helper is still not reached, its resolution origins
+#: sitting outside that pass's admitted set. Re-admitting either language is a
+#: measurement of its own, on its own hand-labelled sample, not a consequence of
+#: this one.
#: Figures and the reasoning: LANGUAGE_SUPPORT.md#code-health-coverage.
SHIPPING_LANGUAGES = frozenset({"javascript", "python", "tsx", "typescript"})
@@ -63,6 +65,10 @@ class AssertionFreeTestDetector:
continue
if fn.called_names & oracles:
continue
+ # Resolved on a call edge by ``asserts.oracle_reach``, which the
+ # engine runs before this marker. Empty without a graph.
+ if fn.start_line in ctx.cross_file_oracle_lines:
+ continue
out.append(
BiomarkerResult(
biomarker_type=self.name,
@@ -94,9 +100,12 @@ def _asserting_names(ctx: FileContext) -> frozenset[str]:
free. A helper nested inside the test body is not collected as a function
at all, so it suppresses nothing.
- Same file only. ``super().test_x(...)``, a package-level Go helper and a
- shared JS fixture all live elsewhere and would need the call graph, which
- this pass does not consult, so those stay false positives.
+ Same file only, and by name. The cross-file half of the same question --
+ a shared JS fixture, an inherited base-class helper -- is answered from the
+ call graph by ``asserts.oracle_reach``, which resolves an edge rather than
+ a bare name and so carries none of the collisions above. What that pass
+ still cannot see it lists itself; ``super().test_x(...)`` is one of them,
+ the resolver having no ``super()`` receiver handling.
"""
return frozenset(
fn.name.lower()
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/base.py b/packages/core/src/repowise/core/analysis/health/biomarkers/base.py
index e49595d0b..f25ed5276 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/base.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/base.py
@@ -113,6 +113,12 @@ class FileContext:
# cross-function reachability; the same-function perf biomarkers read the
# already-resolved ``perf_hits`` instead.
io_boundary_names: set[str] = field(default_factory=set)
+ # Start lines of the test cases in this file that hand their oracle to an
+ # asserting function in ANOTHER file, resolved on a call edge by
+ # ``asserts.oracle_reach``. Lines rather than names: a name would collapse
+ # a file's same-named functions, which is the collision #2408 removed.
+ # Empty without a call graph, which leaves the marker as it was.
+ cross_file_oracle_lines: frozenset[int] = frozenset()
# A repo whose trailing-90-day window has at most this many active human
diff --git a/packages/core/src/repowise/core/analysis/health/complexity/assertions.py b/packages/core/src/repowise/core/analysis/health/complexity/assertions.py
index 197431e2f..0530f8f89 100644
--- a/packages/core/src/repowise/core/analysis/health/complexity/assertions.py
+++ b/packages/core/src/repowise/core/analysis/health/complexity/assertions.py
@@ -263,7 +263,7 @@ def _is_assertion_statement(
def _collect_assertion_facts(
body_node: Node, lmap: LanguageNodeMap, dialect: AssertDialect | None = None
-) -> tuple[list[tuple[int, int, int]], int, int, frozenset[str]]:
+) -> tuple[list[tuple[int, int, int]], int, int, frozenset[str], frozenset[str]]:
"""``(blocks, total, verifications, called)`` facts for one function body.
*blocks* are runs of ≥2 consecutive **narrow-tier** assertion statements,
@@ -285,6 +285,13 @@ def _collect_assertion_facts(
*verifications* counts mock verifications, on the same block-level gate as
*total* and in neither of the other two counts. See the module docstring.
+ *bare* is the subset of *called* whose call site carried no receiver, so
+ ``checkOk()`` is in it and ``harness.checkOk()`` is not. The oracle
+ resolution in ``asserts/oracle_reach.py`` pairs a name with a file-scoped
+ call edge, and only an unqualified call is the one the file's imports
+ actually bind; a qualified one names a method on something else that
+ happens to share the name.
+
*called* is every name called directly in this body, lowercased, excluding
nested function bodies on the same rule the assertion scan uses. It rides
along on this traversal because the traversal already reaches every call
@@ -294,11 +301,12 @@ def _collect_assertion_facts(
ships no language that takes it.
"""
if not lmap.assert_kinds and not lmap.assert_call_kinds:
- return [], 0, 0, frozenset()
+ return [], 0, 0, frozenset(), frozenset()
blocks: list[tuple[int, int, int]] = []
total = 0
verifications = 0
called: set[str] = set()
+ bare: set[str] = set()
call_kinds = lmap.call_kinds or lmap.assert_call_kinds
def _scan_siblings(parent: Node, *, count_total: bool) -> None:
@@ -342,6 +350,8 @@ def _collect_assertion_facts(
names = _callee_names(node)
if names is not None:
called.add(names[0])
+ if not names[1]:
+ bare.add(names[0])
for child in node.children:
if child.type in lmap.function_kinds:
continue # nested fn, not collected as its own entry either
@@ -361,4 +371,4 @@ def _collect_assertion_facts(
verifications += 1
elif tier != _NOT_ASSERTION:
total += 1
- return blocks, total, verifications, frozenset(called)
+ return blocks, total, verifications, frozenset(called), frozenset(bare)
diff --git a/packages/core/src/repowise/core/analysis/health/complexity/models.py b/packages/core/src/repowise/core/analysis/health/complexity/models.py
index d6973fbf4..e9770e65c 100644
--- a/packages/core/src/repowise/core/analysis/health/complexity/models.py
+++ b/packages/core/src/repowise/core/analysis/health/complexity/models.py
@@ -7,6 +7,10 @@ the health engine; see the per-class docstrings for the downstream reader.
from __future__ import annotations
from dataclasses import dataclass, field
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from ..asserts.oracle_reach import OracleReach
@dataclass
@@ -66,6 +70,13 @@ class FunctionComplexity:
# vocabulary row, because it rides on that traversal. It answers one
# question: did this function hand its work to something else in the file?
called_names: frozenset[str] = frozenset()
+ # The subset of ``called_names`` whose call site carried no receiver.
+ # ``checkOk()`` is in it, ``harness.checkOk()`` is not. Read only by the
+ # cross-file oracle pass, which pairs a name with a file-scoped call edge:
+ # a qualified call names a method on something else that happens to share
+ # the name, and pairing it with the file's edge would let one delegating
+ # test license every same-named call beside it.
+ bare_called_names: frozenset[str] = frozenset()
def __post_init__(self) -> None:
if self.complex_conditions is None:
@@ -312,6 +323,11 @@ class FileComplexity:
# function holds a bare (non-loop) I/O sink. Empty when the language opts
# out of the perf pass. Consumed by ``perf.crossfn``, not by a biomarker.
perf_fn_facts: list[PerfFnFacts] = field(default_factory=list)
+ # Test cases here whose call edges reach a function that asserts, keyed
+ # by the test's 1-indexed start line. Filled by a graph pre-pass after the
+ # walk (``asserts.oracle_reach``), never by the walker, so a cached walk
+ # neither carries nor stores one. Read by ``assertion_free_test``.
+ cross_file_oracles: dict[int, OracleReach] = field(default_factory=dict)
# True when the file carries co-located tests that the filename/dir
# heuristic cannot see — e.g. Rust ``#[cfg(test)] mod tests`` blocks,
# which live inside the source file itself. OR'd into ``has_test_file``
diff --git a/packages/core/src/repowise/core/analysis/health/complexity/walker.py b/packages/core/src/repowise/core/analysis/health/complexity/walker.py
index 7640885f1..a36a70a3b 100644
--- a/packages/core/src/repowise/core/analysis/health/complexity/walker.py
+++ b/packages/core/src/repowise/core/analysis/health/complexity/walker.py
@@ -161,9 +161,13 @@ def walk_file(
for fn_node in _collect_function_nodes(tree.root_node, lmap):
body = fn_node.child_by_field_name("body") or fn_node
ccn, max_nest, cognitive, bumps, conditions = _walk_function_body(body, lmap)
- assertion_blocks, assertion_count, verifications, called = _collect_assertion_facts(
- body, lmap, asserts
- )
+ (
+ assertion_blocks,
+ assertion_count,
+ verifications,
+ called,
+ bare_called,
+ ) = _collect_assertion_facts(body, lmap, asserts)
name = _find_function_entry_name(fn_node, lmap)
fc = FunctionComplexity(
name=name,
@@ -182,6 +186,7 @@ def walk_file(
mock_setup_count=_count_mock_setup(fn_node, body, lmap, mock_dialect, asserts),
is_test_case=is_test_case(fn_node, name, language),
called_names=called,
+ bare_called_names=bare_called,
)
functions.append(fc)
fc_by_node_id[fn_node.id] = fc
diff --git a/packages/core/src/repowise/core/analysis/health/engine.py b/packages/core/src/repowise/core/analysis/health/engine.py
index 3f7510902..325ddff8c 100644
--- a/packages/core/src/repowise/core/analysis/health/engine.py
+++ b/packages/core/src/repowise/core/analysis/health/engine.py
@@ -40,6 +40,7 @@ from ...ingestion.package_roots import scan_package_roots as _scan_package_roots
from ..graph_view import HasEdge, ImportEdgeView
from ..test_reachability import files_reached_by_tests
from .asserts.lexicon import AssertVocabulary
+from .asserts.oracle_reach import collect_cross_file_oracles
from .biomarkers import FileContext, detect_all
from .complexity import FileComplexity, FunctionComplexity, walk_file
from .coverage import is_test_file as _coverage_is_test_file
@@ -109,6 +110,16 @@ log = structlog.get_logger(__name__)
# walk itself is unchanged, but this stamp keys the walk and duplication-token
# caches, so bumping it re-walks and re-tokenizes anyway.
#
+# v19: ``assertion_free_test`` resolves a test's oracle across file
+# boundaries, on a call edge rather than by name, so a test that delegates its
+# checks to a helper in another module is no longer called assertion-free. The
+# resolution itself is a graph pre-pass, but the walker also records one new
+# ``FunctionComplexity`` field for it, ``bare_called_names``, which a cached
+# v18 walk does not carry at all: it is the subset of ``called_names`` whose
+# call site had no receiver, and the pass pairs it with a file-scoped call edge.
+# The marker also reports fewer findings than a v18 store holds, and nothing
+# re-mints those rows except this stamp. It counts nothing, so no score moves.
+#
# v17: the walker records one new ``FunctionComplexity`` field,
# ``called_names``, which a cached v16 walk does not carry at all. It feeds the
# advisory ``assertion_free_test``, which no longer calls a test assertion-free
@@ -171,7 +182,7 @@ log = structlog.get_logger(__name__)
# forms. Files that were counted untested and are not become tested, which
# moves untested-hotspot findings and the scores that carry them, on every
# language with a prefix or spec convention rather than Ruby alone.
-HEALTH_ANALYZER_VERSION = 18
+HEALTH_ANALYZER_VERSION = 19
def walked_functions(
@@ -631,6 +642,9 @@ class HealthAnalyzer:
# Cross-function N+1: augment perf_hits before the biomarker stage.
with timed(timings, "analysis.health.crossfn"):
self._apply_crossfn_perf(walked)
+ # Cross-file test oracles, same rule: resolve before the marker runs.
+ with timed(timings, "analysis.health.oracle_reach"):
+ self._apply_cross_file_oracles(walked)
# One shared dataflow service for the whole pass: the promotion pass
# and the Extract Method detector below read the same lazily parsed
# per-file object, so no file is parsed twice for dataflow.
@@ -846,6 +860,8 @@ class HealthAnalyzer:
# Cross-function N+1: augment perf_hits before the biomarker stage.
walked = list(walked)
self._apply_crossfn_perf(walked)
+ # Cross-file test oracles, same rule: resolve before the marker runs.
+ self._apply_cross_file_oracles(walked)
# One shared dataflow service per pass (see the sync path above).
dataflow_cache = FileDataflowCache(self.read_source)
# Dataflow promotion: mark advisory perf hits whose loop is provably
@@ -952,6 +968,28 @@ class HealthAnalyzer:
out[path] = 0.0
return out
+ def _apply_cross_file_oracles(self, walked: list[tuple[Any, FileComplexity]]) -> None:
+ """Resolve each test's oracle across file boundaries, in place.
+
+ A test that hands its checks to an asserting helper in another file is
+ not assertion-free, and the per-function count cannot see that. This
+ attaches the resolved lines so ``assertion_free_test`` stays a pure
+ function over its context. Failure-isolated and a no-op without a
+ graph, in which case the marker behaves exactly as it did before.
+ """
+ try:
+ index = self._execution_graph()
+ if self.graph is None or index is None:
+ return
+ by_file = collect_cross_file_oracles(walked, self.graph, index=index)
+ for _pf, fcx in walked:
+ resolved = by_file.get(_pf.file_info.path)
+ if resolved:
+ fcx.cross_file_oracles = resolved
+ except Exception as exc:
+ log.debug("health_cross_file_oracles_failed", error=str(exc))
+ return
+
def _apply_crossfn_perf(self, walked: list[tuple[Any, FileComplexity]]) -> None:
"""Run the graph-dependent perf passes over the walked files, in place.
@@ -1204,6 +1242,7 @@ class HealthAnalyzer:
error_handling_hits=fcx.error_handling_hits,
perf_hits=fcx.perf_hits,
io_boundary_names=set(fcx.io_boundary_names),
+ cross_file_oracle_lines=frozenset(getattr(fcx, "cross_file_oracles", ())),
)
biomarker_results = detect_all(ctx, disabled=disabled)
diff --git a/packages/ui/src/health/biomarker-glossary.ts b/packages/ui/src/health/biomarker-glossary.ts
index cb7315e65..1f8459dde 100644
--- a/packages/ui/src/health/biomarker-glossary.ts
+++ b/packages/ui/src/health/biomarker-glossary.ts
@@ -206,7 +206,7 @@ export const BIOMARKER_GLOSSARY: Record<string, BiomarkerInfo> = {
label: "Assertion free test",
category: "test_quality",
description:
- "A test case that runs the code under test and then checks nothing, so it passes whatever that code does. A mock verification counts as a check. Advisory: it costs this file no points.",
+ "A test case that runs the code under test and then checks nothing, so it passes whatever that code does. A mock verification counts as a check, and so does handing the check to a helper this test calls, in this file or, when the call graph resolves the call, in another one. Advisory: it costs this file no points.",
},
mock_saturated_test: {
label: "Mock saturated test",
diff --git a/tests/unit/health/test_cross_file_oracle.py b/tests/unit/health/test_cross_file_oracle.py
new file mode 100644
index 000000000..1f9e99903
--- /dev/null
+++ b/tests/unit/health/test_cross_file_oracle.py
@@ -0,0 +1,356 @@
+"""``assertion_free_test`` resolving a test's oracle across a file boundary.
+
+Driven through a real parse, a real graph and a real walk rather than a stubbed
+index: the thing under test is whether an edge exists between two files, and a
+hand-built index would assert only that a dict lookup works.
+
+The load-bearing cases are the negative ones. This rule *removes* findings, so
+a suppression that should not have happened is the failure mode, and the tests
+that matter are the ones pinning what still fires: a same-named helper on
+another class that does not assert, a bare ``assert`` in production code, and a
+call the graph could not resolve.
+"""
+
+from __future__ import annotations
+
+from pathlib import Path
+
+import pytest
+
+from repowise.core.analysis.health.asserts.oracle_reach import (
+ CLOSURE_FORWARD_DEPTH,
+ DEFAULT_MAX_DEPTH,
+ collect_cross_file_oracles,
+)
+from repowise.core.analysis.health.biomarkers.assertion_free_test import BIOMARKER
+from repowise.core.analysis.health.biomarkers.base import FileContext
+from repowise.core.analysis.health.complexity import walk_file
+from repowise.core.ingestion import ASTParser, FileTraverser, GraphBuilder
+
+
+def _require(language: str) -> None:
+ try:
+ from repowise.core.ingestion.parser import _get_language
+ except Exception:
+ pytest.skip(f"tree-sitter language pack missing for {language}")
+ if _get_language(language) is None:
+ pytest.skip(f"tree-sitter language pack missing for {language}")
+
+
+class _FI:
+ def __init__(self, path: str, language: str) -> None:
+ self.path = path
+ self.language = language
+
+
+class _PF:
+ def __init__(self, path: str, language: str) -> None:
+ self.file_info = _FI(path, language)
+
+
+def _build(tmp_path: Path, files: dict[str, str]):
+ """Write *files*, then parse, graph and walk them. Returns (walked, graph)."""
+ for rel, body in files.items():
+ dest = tmp_path / rel
+ dest.parent.mkdir(parents=True, exist_ok=True)
+ dest.write_text(body, encoding="utf-8")
+
+ parser = ASTParser()
+ gb = GraphBuilder()
+ parsed = []
+ for fi in FileTraverser(tmp_path).traverse():
+ pf = parser.parse_file(fi, Path(fi.abs_path).read_bytes())
+ gb.add_file(pf)
+ parsed.append(pf)
+ gb.build()
+
+ walked = []
+ for pf in parsed:
+ rel = pf.file_info.path
+ source = (tmp_path / rel).read_bytes()
+ walked.append((_PF(rel, pf.file_info.language), walk_file(rel, pf.file_info.language, source)))
+ return walked, gb.graph()
+
+
+def _flagged(walked, graph, path: str, *, max_depth: int = DEFAULT_MAX_DEPTH) -> list[str]:
+ """Names ``assertion_free_test`` reports for *path*, resolver applied."""
+ resolved = (
+ collect_cross_file_oracles(walked, graph, max_depth=max_depth) if graph is not None else {}
+ )
+ for pf, fcx in walked:
+ if pf.file_info.path != path:
+ continue
+ ctx = FileContext(
+ file_path=path,
+ language=pf.file_info.language,
+ nloc=fcx.file_nloc,
+ has_test_file=True,
+ module=None,
+ all_functions=tuple(fcx.functions),
+ cross_file_oracle_lines=frozenset(resolved.get(path, {})),
+ )
+ return sorted(r.function_name for r in BIOMARKER.detect(ctx))
+ raise AssertionError(f"{path} was not walked")
+
+
+# --------------------------------------------------------------------------
+# The shape this exists for
+# --------------------------------------------------------------------------
+
+
+def test_python_test_delegating_to_a_helper_in_another_file_is_not_assertion_free(
+ tmp_path: Path,
+) -> None:
+ _require("python")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "tests/helpers.py": (
+ "def check_ok(result):\n"
+ " assert result == 'ok'\n"
+ ),
+ "tests/test_thing.py": (
+ "from tests.helpers import check_ok\n"
+ "\n"
+ "def test_it_works():\n"
+ " check_ok(run())\n"
+ "\n"
+ "def test_it_checks_nothing():\n"
+ " run()\n"
+ ),
+ },
+ )
+ assert _flagged(walked, graph, "tests/test_thing.py") == ["test_it_checks_nothing"]
+
+
+def test_typescript_test_delegating_to_an_imported_helper_is_not_assertion_free(
+ tmp_path: Path,
+) -> None:
+ _require("typescript")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "tests/helpers.ts": (
+ "export function checkOk(v: string) {\n"
+ " expect(v).toBe('ok');\n"
+ "}\n"
+ ),
+ "tests/thing.test.ts": (
+ "import { checkOk } from './helpers';\n"
+ "\n"
+ "it('delegates', () => {\n"
+ " checkOk(run());\n"
+ "});\n"
+ "\n"
+ "it('checks nothing', () => {\n"
+ " run();\n"
+ "});\n"
+ ),
+ },
+ )
+ resolved = collect_cross_file_oracles(walked, graph)
+ lines = resolved.get("tests/thing.test.ts", {})
+ # The delegating callback starts on line 3, the silent one on line 7.
+ assert 3 in lines, f"the delegating test resolved nothing: {lines}"
+ assert 7 not in lines, f"the silent test must not resolve: {lines}"
+ assert lines[3].basis == "file-edge"
+ # And the marker must act on it.
+ assert _flagged(walked, graph, "tests/thing.test.ts") == ["it callback"]
+
+
+def test_a_receiver_qualified_call_does_not_borrow_a_sibling_test_s_edge(
+ tmp_path: Path,
+) -> None:
+ """The file-edge lane's name conjunct is about THIS call, not the file's.
+
+ One test delegating to an imported helper mints a file-level edge to it.
+ A second test calling a same-named method on something else must not be
+ suppressed by that edge: the call graph never bound it to anything, and
+ letting it through would be one test licensing its siblings, which is the
+ over-suppression the two conjuncts exist to prevent.
+ """
+ _require("typescript")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "tests/helpers.ts": (
+ "export function checkOk(v: string) {\n"
+ " expect(v).toBe('ok');\n"
+ "}\n"
+ ),
+ "tests/thing.test.ts": (
+ "import { checkOk } from './helpers';\n"
+ "\n"
+ "it('delegates', () => {\n"
+ " checkOk(run());\n"
+ "});\n"
+ "\n"
+ "it('checks nothing', () => {\n"
+ " harness.checkOk();\n"
+ "});\n"
+ ),
+ },
+ )
+ resolved = collect_cross_file_oracles(walked, graph)
+ lines = resolved.get("tests/thing.test.ts", {})
+ assert 3 in lines, f"the unqualified delegation must still resolve: {lines}"
+ assert 7 not in lines, f"a qualified call must not borrow the file's edge: {lines}"
+
+
+# --------------------------------------------------------------------------
+# The negative cases: what must still fire
+# --------------------------------------------------------------------------
+
+
+def test_a_same_named_helper_on_another_class_that_does_not_assert_suppresses_nothing(
+ tmp_path: Path,
+) -> None:
+ """The receiver hazard, across files.
+
+ Two classes in two files each expose ``check``. Only one asserts. The
+ name-keyed same-file rule would let either suppress; resolving on an edge
+ must suppress only the test that actually reaches the asserting one.
+ """
+ _require("python")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "tests/asserting.py": (
+ "class Asserting:\n"
+ " def check(self, v):\n"
+ " assert v\n"
+ ),
+ "tests/silent.py": (
+ "class Silent:\n"
+ " def check(self, v):\n"
+ " return v\n"
+ ),
+ "tests/test_pair.py": (
+ "from tests.asserting import Asserting\n"
+ "from tests.silent import Silent\n"
+ "\n"
+ "def test_reaches_the_asserting_one():\n"
+ " Asserting().check(1)\n"
+ "\n"
+ "def test_reaches_the_silent_one():\n"
+ " Silent().check(1)\n"
+ ),
+ },
+ )
+ flagged = _flagged(walked, graph, "tests/test_pair.py")
+ # Both halves. Asserting only that the silent one survives would pass just
+ # as well if nothing resolved at all, which is the state this test exists
+ # to tell apart from working discrimination.
+ assert "test_reaches_the_silent_one" in flagged
+ assert "test_reaches_the_asserting_one" not in flagged
+
+
+def test_a_bare_assert_in_production_code_is_not_an_oracle(tmp_path: Path) -> None:
+ """``assertion_count`` counts a production ``assert``; it must not suppress.
+
+ Without the test-related gate on the sink set, every test calling a
+ defensively-asserting production function would be silently suppressed.
+ """
+ _require("python")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "app/service.py": (
+ "def load(path):\n"
+ " assert path, 'path required'\n"
+ " return path\n"
+ ),
+ "tests/test_service.py": (
+ "from app.service import load\n"
+ "\n"
+ "def test_load_runs():\n"
+ " load('x')\n"
+ ),
+ },
+ )
+ assert _flagged(walked, graph, "tests/test_service.py") == ["test_load_runs"]
+
+
+def test_a_call_the_graph_cannot_resolve_suppresses_nothing(tmp_path: Path) -> None:
+ """An unresolved call is indistinguishable from a call that checks nothing."""
+ _require("python")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "tests/test_external.py": (
+ "import some_third_party\n"
+ "\n"
+ "def test_calls_out():\n"
+ " some_third_party.verify_everything()\n"
+ ),
+ },
+ )
+ assert _flagged(walked, graph, "tests/test_external.py") == ["test_calls_out"]
+
+
+def test_without_a_graph_the_marker_is_unchanged(tmp_path: Path) -> None:
+ _require("python")
+ walked, _graph = _build(
+ tmp_path,
+ {
+ "tests/helpers.py": "def check_ok(v):\n assert v\n",
+ "tests/test_thing.py": (
+ "from tests.helpers import check_ok\n"
+ "\n"
+ "def test_it():\n"
+ " check_ok(1)\n"
+ ),
+ },
+ )
+ assert collect_cross_file_oracles(walked, None) == {}
+ assert _flagged(walked, None, "tests/test_thing.py") == ["test_it"]
+
+
+# --------------------------------------------------------------------------
+# Depth
+# --------------------------------------------------------------------------
+
+
+def test_a_hop_beyond_max_depth_suppresses_nothing(tmp_path: Path) -> None:
+ """Depth bounds the walk, and the bound is the thing being pinned."""
+ _require("python")
+ walked, graph = _build(
+ tmp_path,
+ {
+ "tests/deep.py": "def deep(v):\n assert v\n",
+ "tests/mid.py": (
+ "from tests.deep import deep\n"
+ "\n"
+ "def mid(v):\n"
+ " deep(v)\n"
+ ),
+ "tests/test_chain.py": (
+ "from tests.mid import mid\n"
+ "\n"
+ "def test_two_hops():\n"
+ " mid(1)\n"
+ ),
+ },
+ )
+ assert _flagged(walked, graph, "tests/test_chain.py", max_depth=1) == ["test_two_hops"]
+ assert _flagged(walked, graph, "tests/test_chain.py", max_depth=2) == []
+
+
+def test_the_resolver_never_walks_past_the_incremental_closure(tmp_path: Path) -> None:
+ """The one coupling that keeps ``update`` agreeing with ``init``.
+
+ An incremental run walks the changed files plus
+ ``ExecutionGraphIndex.affected_files``' forward closure. Resolving deeper
+ than that closure walks would let an incremental run fail to see an oracle
+ a full index sees, which is the verdict flip #1484 exists to prevent.
+ """
+ assert DEFAULT_MAX_DEPTH <= CLOSURE_FORWARD_DEPTH
+
+ from repowise.core.analysis.execution_graph import ExecutionGraphIndex
+
+ assert (
+ ExecutionGraphIndex.affected_files.__defaults__ is None
+ ), "affected_files takes its depths keyword-only; re-read them below"
+ assert ExecutionGraphIndex.affected_files.__kwdefaults__["forward_depth"] == (
+ CLOSURE_FORWARD_DEPTH
+ )
diff --git a/tests/unit/health/test_model_version_coupling.py b/tests/unit/health/test_model_version_coupling.py
index 776c98b0b..06ed9b260 100644
--- a/tests/unit/health/test_model_version_coupling.py
+++ b/tests/unit/health/test_model_version_coupling.py
@@ -22,7 +22,7 @@ from repowise.core.analysis.health.refactoring.identity import (
# The three stamps as they stand together. Moving either identity model means
# moving the analyzer with it, and updating this tuple in the same commit.
-_STAMPS = (18, 2, 2)
+_STAMPS = (19, 2, 2)
def test_the_identity_models_and_the_analyzer_stamp_are_pinned_together() -> None: