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
fix(perf): stop claiming hot_path_sync_io is request-reachable (#2969)
Raghav Chamadiyaec39f4eaa8ab
diff --git a/docs/agent/MCP_TOOLS.md b/docs/agent/MCP_TOOLS.mdindex e1100617e..ed189d307 100644--- a/docs/agent/MCP_TOOLS.md+++ b/docs/agent/MCP_TOOLS.md@@ -1239,10 +1239,12 @@ used to answer "which marker costs more" and had drifted apart on markers bothnamed, so a finding and the opportunity built from it could disagree about thesame evidence.-Request-reachability is read off the marker rather than a column:+Centrality is read off the marker rather than a column:`hot_path_sync_io` and `nested_loop_quadratic` are only ever emitted for a-function the perf ranker called hot (top-quintile call-graph in-degree, or a-churny/hotspot file), so their presence is already the proof. Deliberately not+function the perf ranker called hot (top-quintile call-graph in-degree), so+their presence is already the proof. It is not proof that a request reaches+the function, and neither marker claims that. `hot_path_sync_io` is never+emitted in tests, tooling, examples, or generated or vendored code. Deliberately not`severity` — that column grades `hot_path_sync_io` below `io_in_loop` and takesonly two values across a whole repo's perf findings.- **`refactoring`** also emits `suggestion_legend`: `biomarker_type` → the prosediff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.mdindex 6ec9ddc30..8c6c29a19 100644--- a/docs/layers/CODE_HEALTH.md+++ b/docs/layers/CODE_HEALTH.md@@ -514,8 +514,11 @@ churn, lock contention, serial awaits that could fan out, membership testsagainst lists, and language-specific shapes.Two markers use call-graph centrality as a *precision gate* rather than a sort-key, firing only in hot functions (top-quintile in-degree, or in a churny-hotspot file), which keeps a noisy shape reviewable.+key, firing only in a repo's most-called functions (at least the 80th-percentile+number of distinct direct callers, and never fewer than two), which keeps a+noisy shape reviewable. That shows how widely a function is called, not that a+request reaches it. The blocking-call marker is also skipped in tests, tooling,+examples, and generated or vendored code.**Standard linters do not find this class of problem.** On a 12,600-filebenchmark, clippy, ruff, ESLint and golangci-lint together found **0** of thediff --git a/packages/core/src/repowise/core/analysis/change_health/service.py b/packages/core/src/repowise/core/analysis/change_health/service.pyindex 4e2a94f2c..10e30b710 100644--- a/packages/core/src/repowise/core/analysis/change_health/service.py+++ b/packages/core/src/repowise/core/analysis/change_health/service.py@@ -425,7 +425,7 @@ def _limits() -> list[str]:def _is_test_perf(finding: HealthFindingData) -> bool:"""A performance finding on test code.- The perf model reasons about request-reachable hot paths, which a test file+ Performance findings are about code that serves requests, which a test fileis not, so these are dropped from both sides rather than ranked. Otherdimensions still report on tests; only their ordering is demoted."""diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/hot_path_sync_io.py b/packages/core/src/repowise/core/analysis/health/biomarkers/hot_path_sync_io.pyindex fbc64a24a..c3eb29280 100644--- a/packages/core/src/repowise/core/analysis/health/biomarkers/hot_path_sync_io.py+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/hot_path_sync_io.py@@ -1,16 +1,17 @@-"""Hot-path sync I/O — a blocking I/O call in a hot, request-reachable function.--A synchronous (non-awaited) database / network / filesystem / subprocess-round-trip blocks its thread for the duration of the call. Outside a loop that is-usually fine — but in a *hot, central* function (one on many request paths) the-blocking wait is paid on every request, a latency risk a loop-only detector never-sees. This generalizes the performance pillar beyond loops using the centrality-the engine already computes.--The walker emits every loop-depth-0 blocking sink as a candidate; the centrality-gate (``perf.gated.apply_centrality_gate``) keeps only those in a top-quintile--central or churny function. A ``performance`` dimension signal — this detector-lifts the (already-gated) hits into findings.+"""Hot-path sync I/O: a blocking I/O call in a hot, central function.++A synchronous (non-awaited) filesystem or subprocess call blocks its thread for+the duration of the call. Outside a loop that is usually fine, but in a *hot,+central* function (one many call sites go through) the wait is paid on every+one of those calls, a latency risk a loop-only detector never sees.++"Hot" is top-quintile direct-caller count in the execution graph+(``perf.ranking.PerfRanker``). That says the function is widely called, not+that a request reaches it: no request-handler entry set exists to prove that,+so the reason text claims only what the gate establishes. Code that serves no+request (tests, tooling, examples, generated or vendored code) never emits+(``perf.gated``). A ``performance`` dimension signal; this+detector lifts the (already-gated) hits into findings."""from __future__ import annotations@@ -39,6 +40,11 @@ class HotPathSyncIoDetector:if hit.kind != _KIND:continuephrasing = _BOUNDARY_PHRASING.get(hit.detail, "a blocking I/O call")+ details: dict[str, object] = {"boundary_kind": hit.detail}+ callers = ""+ if hit.callers:+ details["callers"] = hit.callers+ callers = f" ({hit.callers} direct callers)"out.append(BiomarkerResult(biomarker_type=self.name,@@ -46,10 +52,10 @@ class HotPathSyncIoDetector:function_name=hit.function,line_start=hit.line,line_end=hit.line,- details={"boundary_kind": hit.detail},+ details=details,reason=(- f"{phrasing} runs on a hot, request-reachable path; "- "its latency is paid on every call through this function"+ f"{phrasing} in one of the most-called functions in "+ f"this repo{callers}; every call through it waits for the I/O"),))diff --git a/packages/core/src/repowise/core/analysis/health/complexity/models.py b/packages/core/src/repowise/core/analysis/health/complexity/models.pyindex cd122d308..f661bea75 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/models.py+++ b/packages/core/src/repowise/core/analysis/health/complexity/models.py@@ -313,6 +313,9 @@ class PerfHit:# 1-indexed header line of the innermost data-dependent loop the hit runs# in (for a cross-function hit, the loop around the call site); 0 when none.loop_line: int = 0+ # Distinct direct callers of the enclosing function, set only on the+ # centrality-gated ``hot_path_sync_io`` hit; 0 everywhere else.+ callers: int = 0def loop_facts(self) -> dict[str, Any]:"""Loop facts for ``details``; absent when unset so old findings are unchanged."""diff --git a/packages/core/src/repowise/core/analysis/health/complexity/perf_walk.py b/packages/core/src/repowise/core/analysis/health/complexity/perf_walk.pyindex fc1f16238..5ab12a542 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/perf_walk.py+++ b/packages/core/src/repowise/core/analysis/health/complexity/perf_walk.py@@ -665,8 +665,8 @@ def _collect_perf_hits(# An inherently-blocking (non-awaited subprocess / fs /# sync-network) sink outside any loop. Noisy everywhere,# so record it as a fact; the engine emits- # ``hot_path_sync_io`` only for a hot, request-reachable- # function (centrality gate). ``db`` is excluded — see+ # ``hot_path_sync_io`` only for a hot, central function+ # (centrality gate). ``db`` is excluded — see# ``_HOT_PATH_SINK_KINDS``; point-sized reads/writes are# excluded per-dialect — see ``hot_path_excluded_methods``# (outside a loop their cost is bounded, so they belong todiff --git a/packages/core/src/repowise/core/analysis/health/engine.py b/packages/core/src/repowise/core/analysis/health/engine.pyindex 37a043bc7..f6f9adb2c 100644--- a/packages/core/src/repowise/core/analysis/health/engine.py+++ b/packages/core/src/repowise/core/analysis/health/engine.py@@ -1348,7 +1348,7 @@ class HealthAnalyzer:for path, hits in src.items():by_file.setdefault(path, []).extend(hits)ranker = PerfRanker(index)- for path, hits in collect_centrality_gated(walked, ranker).items():+ for path, hits in collect_centrality_gated(walked, ranker, self._origins).items():by_file.setdefault(path, []).extend(hits)for _pf, fcx in walked:extra = by_file.get(_pf.file_info.path)diff --git a/packages/core/src/repowise/core/analysis/health/perf/dialects/go.py b/packages/core/src/repowise/core/analysis/health/perf/dialects/go.pyindex 48059a3aa..90490dd82 100644--- a/packages/core/src/repowise/core/analysis/health/perf/dialects/go.py+++ b/packages/core/src/repowise/core/analysis/health/perf/dialects/go.py@@ -131,6 +131,9 @@ class GoPerfDialect(BasePerfDialect):"goroutine_in_unbounded_loop",})+ # ``exec.Command`` only builds a Cmd; the process runs at ``Run`` / ``Output``+ # / ``CombinedOutput`` / ``Start``, which are sinks of their own.+ hot_path_excluded_methods = frozenset({"Command"})def sink_kind(self,diff --git a/packages/core/src/repowise/core/analysis/health/perf/dialects/ts_js.py b/packages/core/src/repowise/core/analysis/health/perf/dialects/ts_js.pyindex dbb69ab3c..68822bab6 100644--- a/packages/core/src/repowise/core/analysis/health/perf/dialects/ts_js.py+++ b/packages/core/src/repowise/core/analysis/health/perf/dialects/ts_js.py@@ -206,6 +206,12 @@ class TsJsPerfDialect(TsJsMarkerHooks):string_literal_kinds = _TS_STRING_KINDSaug_assign_kinds = _TS_AUG_ASSIGN_KINDSswitch_kinds = frozenset({"switch_statement"})+ # Node's ``child_process`` launchers return a ChildProcess at once and report+ # through callbacks or events; only their ``*Sync`` forms wait for the child.+ # They stay sinks for the loop markers (one process per item is still a+ # cost) but are not blocking calls. Ceiling: shelljs's synchronous ``exec``+ # is excluded with them, a recall loss only.+ hot_path_excluded_methods = frozenset({"spawn", "exec", "execFile"})def is_string_concat(self, node: Node) -> bool:"""``s += "x"`` that can grow ``s`` across loop iterations.diff --git a/packages/core/src/repowise/core/analysis/health/perf/gated.py b/packages/core/src/repowise/core/analysis/health/perf/gated.pyindex c6e1fe801..bd68832b7 100644--- a/packages/core/src/repowise/core/analysis/health/perf/gated.py+++ b/packages/core/src/repowise/core/analysis/health/perf/gated.py@@ -24,10 +24,11 @@ Both are failure-isolated by their callers.from __future__ import annotations-from collections.abc import Iterable+from collections.abc import Iterable, Mappingfrom typing import TYPE_CHECKING, Any-from repowise.core.code_origin import is_build_file+from repowise.core.code_origin import code_origin, is_build_file+from repowise.core.support_paths import is_example_pathfrom .callgraph import CallGraphIndexfrom .sink_reach import collect_sink_reaching_hits@@ -39,6 +40,26 @@ if TYPE_CHECKING:# The boundary-kind detail convention shared with the cross-function N+1 pass.LOCK_IO_KIND = "blocking_io_under_lock"+# Origins whose code serves no request: tests, tooling (scripts, CI,+# benchmarks, migrations), docs examples, and code nobody here maintains by+# hand. A blocking call there is how the job is done, so it never becomes a+# ``hot_path_sync_io`` finding however many callers it has. A CLI is product+# code (``code_origin`` calls it production) and still fires.+_NON_SERVING_ORIGINS = frozenset({"test", "tooling", "docs_example", "generated", "vendored"})+++def _may_serve_requests(path: str, origins: Mapping[str, str] | None) -> bool:+ """Whether code at *path* can sit on a path that serves requests.++ *origins* is the content-aware ``code_origin`` the health pass already+ decided per file; a path missing from it falls back to the path-only answer.+ An example tree at any depth is excluded too: ``code_origin`` counts only a+ root-level one as ``docs_example``, but a nested ``examples/`` shows how to+ use the code rather than being it.+ """+ origin = (origins or {}).get(path) or code_origin(path)+ return origin not in _NON_SERVING_ORIGINS and not is_example_path(path)+def _in_rust_test_range(line: int, ranges: tuple[tuple[int, int], ...]) -> bool:"""True when *line* falls inside one of *ranges* (Rust test-only spans).@@ -56,20 +77,23 @@ def _in_rust_test_range(line: int, ranges: tuple[tuple[int, int], ...]) -> bool:def collect_centrality_gated(- walked: Iterable[tuple[Any, FileComplexity]], ranker: PerfRanker+ walked: Iterable[tuple[Any, FileComplexity]],+ ranker: PerfRanker,+ origins: Mapping[str, str] | None = None,) -> dict[str, list[PerfHit]]:"""Centrality-gated ``nested_loop_quadratic`` / ``hot_path_sync_io`` hits.Keyed by file path. For every function carrying the corresponding fact, a hit- is produced ONLY when ``ranker.is_hot(path, func_start)`` — so a quadratic- loop or a blocking sync sink ships only where it sits on a hot, central, or- churny path. Pure when neither graph nor git signal is available (nothing is- hot ⇒ no hits), which is the precision-first default. A fact whose function+ is produced ONLY when ``ranker.is_hot(path, func_start)``, so a quadratic+ loop or a blocking sync sink ships only in one of the repo's most-called+ functions. Pure when no graph is available (nothing is hot, so no hits),+ which is the precision-first default. A fact whose functionsits inside Rust inline test code (``_in_rust_test_range``) is skippedbefore the hotness check even runs — test code doing blocking I/O isnormal, not a finding, regardless of how central or churny its file is.A build file is never a hot path either: the build tool runs it, no- request does.+ request does. The same holds for a blocking sink in any file that serves+ no request (:func:`_may_serve_requests`)."""from ..complexity import PerfHit@@ -99,7 +123,7 @@ def collect_centrality_gated(func_start=fact.func_start,))- if fact.blocking_sink_kind is not None:+ if fact.blocking_sink_kind is not None and _may_serve_requests(path, origins):file_hits.append(PerfHit(kind="hot_path_sync_io",@@ -107,6 +131,7 @@ def collect_centrality_gated(function=fact.function,detail=fact.blocking_sink_kind,func_start=fact.func_start,+ callers=ranker.callers(path, fact.func_start),))if file_hits:diff --git a/packages/core/src/repowise/core/analysis/health/perf/ranking.py b/packages/core/src/repowise/core/analysis/health/perf/ranking.pyindex 30e85ab4c..ec422a0bb 100644--- a/packages/core/src/repowise/core/analysis/health/perf/ranking.py+++ b/packages/core/src/repowise/core/analysis/health/perf/ranking.py@@ -5,20 +5,20 @@ widely-called function matters more than the same hit in a cold leaf. Theranker is also used as a **precision gate**, not only a sort key. Some patternsare noisy when flagged everywhere (a bare O(n^2) nested loop; a blocking I/Ocall outside any loop) but become high-signal the moment they sit in a hot,-request-reachable function. The gate fires those markers *only there*.+widely-called function. The gate fires those markers *only there*."Hot" is one whole-program signal a file-local linter cannot compute:* **centrality** - the function's symbol node has a top-quintile number ofdistinct direct predecessors in the reliable execution graph (the- ``CallGraphIndex`` in-degree). A widely-reached function is on many request- paths, so a latency or quadratic cost there is paid often. Direct in-degree- is a deterministic, ``O(E)`` proxy for request-reachability; transitive- fan-in would be stronger but is quadratic to compute per function.+ ``CallGraphIndex`` in-degree). A latency or quadratic cost in a widely+ called function is paid at every one of those call sites. It is not proof+ that a request reaches the function (no request-handler entry set exists),+ so the markers it gates say "hot/central", never "request-reachable".Churn is deliberately not a second arm. How often a file is edited is not how-often it runs, so it cannot support the request-reachability these markers-assert in their own reason text. Churn still earns rank in+often it runs, so it cannot support the call-frequency claim these markers+make in their own reason text. Churn still earns rank in``opportunity_rank``; it does not decide whether a finding exists.Without a graph the gate degrades to "nothing is hot" - the markers behind it@@ -72,17 +72,19 @@ class PerfRanker:# -- the gate -------------------------------------------------------------- def is_central(self, path: str, func_start: int) -> bool:- """True if the function at ``(path, func_start)`` is top-quintile-called."""+ def callers(self, path: str, func_start: int) -> int:+ """Distinct direct callers of the function at ``(path, func_start)``; 0 if unknown."""if self._index is None:- return False+ return 0sid = self._index.resolve_function(path, func_start)- if sid is None:- return False- return self._index.in_degree.get(sid, 0) >= self._hot_in_degree+ return 0 if sid is None else self._index.in_degree.get(sid, 0)++ def is_central(self, path: str, func_start: int) -> bool:+ """True if the function at ``(path, func_start)`` is top-quintile-called."""+ return self.callers(path, func_start) >= self._hot_in_degreedef is_hot(self, path: str, func_start: int) -> bool:- """Central enough to carry a marker that claims request-reachability.+ """Central enough to carry a marker that claims a hot, widely-called function.Pure when no graph is available: nothing is hot, so nothing fires."""diff --git a/packages/core/src/repowise/core/analysis/health/suggestions.py b/packages/core/src/repowise/core/analysis/health/suggestions.pyindex 685e544f4..efbaa8504 100644--- a/packages/core/src/repowise/core/analysis/health/suggestions.py+++ b/packages/core/src/repowise/core/analysis/health/suggestions.py@@ -281,8 +281,8 @@ _TEMPLATES: dict[str, str] = {"asyncio subprocess), or run the blocking call in a thread executor."),"hot_path_sync_io": (- "Take the I/O off the hot path. Cache the result, move the call to "- "startup, or make it asynchronous."+ "If this function runs on a latency-sensitive path, cache the result, "+ "move the call to startup, or make it asynchronous."),"blocking_io_under_lock": ("Do the I/O outside the lock. Read or write first, then take the lock "diff --git a/packages/ui/src/health/biomarker-glossary.ts b/packages/ui/src/health/biomarker-glossary.tsindex c4116333e..7a3de223d 100644--- a/packages/ui/src/health/biomarker-glossary.ts+++ b/packages/ui/src/health/biomarker-glossary.ts@@ -324,7 +324,7 @@ export const BIOMARKER_GLOSSARY: Record<string, BiomarkerInfo> = {label: BIOMARKER_LABELS.hot_path_sync_io,category: "performance",description:- "A blocking subprocess or filesystem call in a hot, request-reachable function (top call-graph centrality or a churny file), even outside a loop. Its latency is paid on every call through the function. Advisory — a latency signal ranked by centrality, not always a defect.",+ "A blocking subprocess or filesystem call in one of the repo's most-called functions, even outside a loop. Every call through the function waits for it. Advisory: a latency signal ranked by call-graph centrality, not proof of a request path, and not always a defect. Tests, tooling, examples, and generated or vendored code are not flagged.",},blocking_io_under_lock: {label: BIOMARKER_LABELS.blocking_io_under_lock,diff --git a/tests/unit/change_health/test_comparison.py b/tests/unit/change_health/test_comparison.pyindex 548c285c9..a0d777a02 100644--- a/tests/unit/change_health/test_comparison.py+++ b/tests/unit/change_health/test_comparison.py@@ -268,7 +268,7 @@ def test_what_the_change_wrote_outranks_what_it_only_touched():def test_a_performance_finding_on_test_code_is_not_reported(make_repo):- """The perf model reasons about request-reachable paths; a test is not one."""+ """Performance findings are about code that serves requests; a test does not."""repo = make_repo()repo.commit("seed", {"tests/test_app.py": python_io_in_loop(in_loop=False)})repo.commit("loop", {"tests/test_app.py": python_io_in_loop(in_loop=True)})diff --git a/tests/unit/health/test_perf_phase7b.py b/tests/unit/health/test_perf_phase7b.pyindex 5f0bc51c9..3001e17f9 100644--- a/tests/unit/health/test_perf_phase7b.py+++ b/tests/unit/health/test_perf_phase7b.py@@ -226,6 +226,50 @@ def test_db_materializer_is_not_a_blocking_fact():assert fact is None or fact.blocking_sink_kind is None+ "src, kind",+ [+ # Node's async launchers return a ChildProcess at once: not blocking.+ ('import { spawn } from "child_process";\nfunction run(c) { return spawn(c); }\n', None),+ (+ 'import * as cp from "child_process";\nfunction run(c) { return cp.execFile(c); }\n',+ None,+ ),+ # Their *Sync forms wait for the child, and sync fs stays a sink.+ (+ 'import * as cp from "child_process";\nfunction run(c) { return cp.spawnSync(c); }\n',+ "subprocess",+ ),+ (+ 'import * as fs from "fs";\nfunction run(p) { return fs.readFileSync(p); }\n',+ "filesystem",+ ),+ ],+)+def test_ts_async_child_process_is_not_a_blocking_fact(src, kind):+ fact = _facts("typescript", src).get("run")+ assert (fact.blocking_sink_kind if fact else None) == kind+++def test_ts_async_spawn_in_a_loop_is_still_io_in_loop():+ src = 'import { spawn } from "child_process";\nfunction f(xs) { for (const x of xs) { spawn(x); } }\n'+ assert ("io_in_loop", "subprocess") in _hits("typescript", src)+++ "body, kind",+ [+ # ``exec.Command`` only builds a Cmd; no process runs.+ ('return exec.Command("git", "status")', None),+ ('out, _ := exec.Command("git", "status").Output()\n\t_ = out\n\treturn nil', "subprocess"),+ ],+)+def test_go_exec_command_constructor_is_not_a_blocking_fact(body, kind):+ src = f'package p\nimport "os/exec"\nfunc run() *exec.Cmd {{\n\t{body}\n}}\n'+ fact = _facts("go", src).get("run")+ assert (fact.blocking_sink_kind if fact else None) == kind++# ---------------------------------------------------------------------------# The centrality gate — emits the two markers ONLY for a hot function# ---------------------------------------------------------------------------@@ -274,11 +318,11 @@ def test_centrality_gate_silent_without_a_graph():assert collect_centrality_gated(walked, ranker) == {}-def test_centrality_gate_fires_for_a_central_function_end_to_end():- """The surviving arm still ships both gated markers."""+def _central_graph(path: str) -> nx.MultiDiGraph:+ """``hot`` at *path* (lines 2-6) with four distinct callers: top-quintile central."""g = nx.MultiDiGraph()g.add_node(- "svc.py::hot", node_type="symbol", name="hot", file_path="svc.py", start_line=2, end_line=6+ f"{path}::hot", node_type="symbol", name="hot", file_path=path, start_line=2, end_line=6)for i in range(4):cid = f"c.py::caller{i}"@@ -290,13 +334,54 @@ def test_centrality_gate_fires_for_a_central_function_end_to_end():start_line=10 + i,end_line=11 + i,)- g.add_edge(cid, "svc.py::hot", edge_type="calls")- walked = _walked("svc.py", _HOT_SRC)- out = collect_centrality_gated(walked, PerfRanker(CallGraphIndex(g)))- assert sorted(h.kind for h in out.get("svc.py", [])) == [- "hot_path_sync_io",- "nested_loop_quadratic",- ]+ g.add_edge(cid, f"{path}::hot", edge_type="calls")+ return g+++ "path, expected",+ [+ # The surviving arm still ships both gated markers.+ ("svc.py", ["hot_path_sync_io", "nested_loop_quadratic"]),+ ("pkg/svc.py", ["hot_path_sync_io", "nested_loop_quadratic"]),+ ("pkg/server/svc.py", ["hot_path_sync_io", "nested_loop_quadratic"]),+ # A CLI is product code (production origin): it still fires.+ ("pkg/cli/svc.py", ["hot_path_sync_io", "nested_loop_quadratic"]),+ # Code that serves no request: the blocking call is the idiom there.+ ("tests/test_svc.py", ["nested_loop_quadratic"]),+ ("scripts/svc.py", ["nested_loop_quadratic"]),+ ("examples/svc.py", ["nested_loop_quadratic"]),+ ("apps/examples/demo-app/svc.py", ["nested_loop_quadratic"]),+ ],+)+def test_centrality_gate_end_to_end(path, expected):+ ranker = PerfRanker(CallGraphIndex(_central_graph(path)))+ out = collect_centrality_gated(_walked(path, _HOT_SRC), ranker)+ assert sorted(h.kind for h in out.get(path, [])) == expected+++def test_centrality_gate_reads_the_stored_origin():+ # The content-aware origin the health pass decided wins over the path.+ path = "pkg/svc.py"+ ranker = PerfRanker(CallGraphIndex(_central_graph(path)))+ out = collect_centrality_gated(_walked(path, _HOT_SRC), ranker, {path: "generated"})+ assert [h.kind for h in out[path]] == ["nested_loop_quadratic"]+++def test_hot_path_sync_io_reason_claims_centrality_not_a_request_path():+ hit = PerfHit("hot_path_sync_io", 3, "f", "filesystem", callers=4)+ (finding,) = HotPathSyncIoDetector().detect(_ctx([hit]))+ assert "request" not in finding.reason+ assert "most-called functions in this repo (4 direct callers)" in finding.reason+ assert finding.details == {"boundary_kind": "filesystem", "callers": 4}+++def test_hot_path_sync_io_hit_carries_its_caller_count():+ path = "pkg/svc.py"+ ranker = PerfRanker(CallGraphIndex(_central_graph(path)))+ out = collect_centrality_gated(_walked(path, _HOT_SRC), ranker)+ (hot,) = [h for h in out[path] if h.kind == "hot_path_sync_io"]+ assert hot.callers == 4def test_centrality_gate_fires_for_a_central_function():diff --git a/tests/unit/server/mcp/test_perf_rank.py b/tests/unit/server/mcp/test_perf_rank.pyindex 8f4946273..f244d532c 100644--- a/tests/unit/server/mcp/test_perf_rank.py+++ b/tests/unit/server/mcp/test_perf_rank.py@@ -79,10 +79,10 @@ def test_a_cross_function_hit_outranks_the_same_hit_inside_one_function() -> Nondef test_the_gated_markers_carry_their_hotness_proof() -> None:- """``hot_path_sync_io`` is only ever emitted on a hot, reachable function.+ """``hot_path_sync_io`` is only ever emitted on a hot, central function.``perf.gated.collect_centrality_gated`` will not produce it otherwise, so- its presence *is* the request-reachability signal and needs no new column.+ its presence *is* the centrality signal and needs no new column.It therefore outranks the cheap in-loop CPU markers at the same boundary,while sitting level with a plain N+1 marker — it proves hotness and nomultiplier, the loop proves a multiplier and no hotness.