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(health): never lead or queue a performance cause whose loop size is unmeasured (#3276)
Raghav Chamadiyae756cc98d2d4
diff --git a/docs/agent/MCP_TOOLS.md b/docs/agent/MCP_TOOLS.mdindex df4b50a31..c78ab05ce 100644--- a/docs/agent/MCP_TOOLS.md+++ b/docs/agent/MCP_TOOLS.md@@ -334,7 +334,7 @@ Code-health scores and findings from the stored analysis, across defect risk, ma| `refactoring_type`, `refactoring_confidence`, `refactoring_effort` | string | none | Refactoring queue filters || `performance_view` | string | `detail` | `detail` or `summary` || `performance_context` | string | `production` | `production`, `tooling`, `test`, `unknown` or `all` |-| `performance_boundary`, `performance_confidence`, `performance_actionability`, `performance_sort` | string | none | Performance queue filters |+| `performance_boundary`, `performance_confidence`, `performance_actionability`, `performance_sort` | string | none | Performance queue filters. The queue lists causes whose cost is measured; unproven ones (loop size unknown) are counted in the `proof` facet and `default_queue.excluded.unmeasured_cost` || `scope` | string | `"all"` | `production` drops test files from every figure || `counts` | string | `"everything"` | `code_shape` drops the git-derived half of the score || `repo` | string | default repo | Workspace repo alias. `"all"` is not supported |diff --git a/docs/architecture/code-health.md b/docs/architecture/code-health.mdindex 2b9d739d4..b62c49a5e 100644--- a/docs/architecture/code-health.md+++ b/docs/architecture/code-health.md@@ -723,9 +723,11 @@ carries one `actionability` state (`plan_ready`, `advisory`, `investigate`,startup, shutdown or crash recovery (`perf/cold_paths.py`) is `expected` with reason`cold_path`, with or without a strategy; `gated_off` takes precedence. The identitykernel's `execution_context` stays path-only.-The default queue holds production `plan_ready` and `advisory`, ranked-by `rank_score`; actionability only breaks ties. Excluded reasons are counted in-`default_queue`.+The default queue holds production `plan_ready` and `advisory` with+`cost_proof = proven`, ranked by `rank_score`; actionability only breaks ties.+Excluded reasons are counted in `default_queue`. A cause whose loop size nothing+measured is stored as `cost_proof = unproven`: it never leads, and the `proof`+filter and facet expose it.**Plans.** Proven means the transformation, not the runtime: parallelizing awaitsagainst a DB or network client is advisory with a `bounded_concurrency`diff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.mdindex 1a6d8be0e..31fd79c24 100644--- a/docs/layers/CODE_HEALTH.md+++ b/docs/layers/CODE_HEALTH.md@@ -256,8 +256,10 @@ repetition is real and nothing should change, such as deleting N files; reason`gated_off` when a constant flag switches the function off, `cold_path` when it isnamed for a migration, startup, shutdown or crash recovery and so runs once perdeploy, boot or incident). The default queue holds production `plan_ready` and-`advisory` opportunities, ranked by cost first; state only breaks ties. Everything-left out is counted by reason.+`advisory` opportunities whose cost is measured, ranked by cost first; state only+breaks ties. Everything left out is counted by reason. A loop whose size nothing+measured never leads and stays out of the list unless you ask for it with the+`proof=unproven` filter.Performance analysis covers Python, TypeScript/JavaScript (including Vue and Sveltescripts), Java, Go, C# (including Razor), Rust, Kotlin, Scala, Ruby, C++, Dart anddiff --git a/docs/reference/MCP_RESPONSE_FIELDS.md b/docs/reference/MCP_RESPONSE_FIELDS.mdindex b6c224d14..8ece49c35 100644--- a/docs/reference/MCP_RESPONSE_FIELDS.md+++ b/docs/reference/MCP_RESPONSE_FIELDS.md@@ -383,6 +383,8 @@ Performance findings carry `health_impact: 0`; the pillar never blends into theA bare `get_health()` ranks performance work inside `fix_first` as `perf_fix` items. `get_health(opportunity_id="perf...")` adds `plan_steps`, `validation` and `siblings`; `only=["performance_evidence"]` with `cursor` pages the evidence. Ids are stable within a performance model version; an id from an older model resolves to `model_state.state: "stale_model"` with `refresh_required`. `lifecycle_status` is `open` or `resolved`. Evidence rows carry a public `finding_id`.+The `performance_opportunities` list holds causes whose cost is measured (`cost_proof` `proven`). A cause whose loop size nothing measured is `unproven`: it never sets `may_lead`, and every list leaves it out. `performance_summary.default_queue.excluded.unmeasured_cost` counts the ones the default queue drops, `performance_summary.proof` counts both values, and the `proof` facet counts them under the current filters. REST lists them with `proof=unproven` on `/api/repos/{id}/health/performance-opportunities`.+### Coverage`include=["coverage"]` returns per-file rows (`covered_line_count`, `total_coverable_lines`; targeted mode adds `covered_lines`) and a `summary`. `freshness.status` is `current` (measured at the indexed commit), `stale` or `unknown`. `report_paths` says how the report's entries mapped at ingest (`total`, `matched`, `unmatched`, `ambiguous`, `unmatched_sample`). `source_formats` lists merged formats. Dashboard mode adds `history`, one point per complete ingest, newest 10. Targeted rows add `decay`: `confirmed_lines`, `invalidated_lines` (now unknown, not uncovered), and `drifted` once a fifth of a file's measurement has moved.diff --git a/packages/api-client/src/code-health.ts b/packages/api-client/src/code-health.tsindex aeea7634d..01899ee36 100644--- a/packages/api-client/src/code-health.ts+++ b/packages/api-client/src/code-health.ts@@ -133,6 +133,7 @@ export async function getPerformanceOpportunities(boundary: opts.boundary,confidence: opts.confidence,actionability: opts.actionability,+ proof: opts.proof,view: opts.view,sort: opts.sort,file_paths: opts.file_paths?.length ? opts.file_paths.join(",") : undefined,diff --git a/packages/core/alembic/versions/0099_performance_cost_proof.py b/packages/core/alembic/versions/0099_performance_cost_proof.pynew file mode 100644index 000000000..5957d4711--- /dev/null+++ b/packages/core/alembic/versions/0099_performance_cost_proof.py@@ -0,0 +1,38 @@+"""Persist ``performance_opportunities.cost_proof`` so the default queue can filter it.++A cause whose loop nobody measured to grow is ``unproven``: it never leads and+leaves the default performance queue, listed under its own filter. The queue+filters in SQL, so the verdict is a column. Rows written before it read+``proven`` until the next analysis rewrites them.++Local SQLite stores get the column from ``init_db``'s additive reconciler; this+migration covers managed Postgres.++Revision ID: 0099+Revises: 0098+Create Date: 2026-10-10+"""++from __future__ import annotations++from collections.abc import Sequence++import sqlalchemy as sa+from alembic import op++# revision identifiers+revision: str = "0099"+down_revision: str | None = "0098"+branch_labels: str | Sequence[str] | None = None+depends_on: str | Sequence[str] | None = None+++def upgrade() -> None:+ op.add_column(+ "performance_opportunities",+ sa.Column("cost_proof", sa.String(16), nullable=False, server_default="proven"),+ )+++def downgrade() -> None:+ op.drop_column("performance_opportunities", "cost_proof")diff --git a/packages/core/src/repowise/core/analysis/health/fix_first/build.py b/packages/core/src/repowise/core/analysis/health/fix_first/build.pyindex cd9dd6dfe..96ea46661 100644--- a/packages/core/src/repowise/core/analysis/health/fix_first/build.py+++ b/packages/core/src/repowise/core/analysis/health/fix_first/build.py@@ -63,7 +63,7 @@ from repowise.core.analysis.health.models import primary_finding, split_by_origifrom repowise.core.analysis.health.perf.causal import code_contextfrom repowise.core.analysis.health.perf.opportunity_rank import (DEFAULT_QUEUE_CONTEXTS,- default_queue_exclusion,+ strategy_exclusion,)from repowise.core.analysis.health.rows import detail_map, field, json_fieldfrom repowise.core.analysis.health.scoring import biomarker_dimension@@ -74,6 +74,7 @@ from repowise.core.analysis.health.worth import (WORTH_MAGNITUDE,dispatch_shaped,dormant,+ lead_reason,low_priority,magnitude,measure,@@ -927,13 +928,7 @@ GROWS_ONLY_MARKERS = frozenset({"string_concat_in_loop"})def _perf_worth(row: Any) -> bool:"""Whether a planned cause is worth an item at all."""- if field(row, "biomarker_type") not in GROWS_ONLY_MARKERS:- return True- facets = detail_map(row).get("facets") or {}- return (- field(row, "execution_context") == "production"- and facets.get("loop_magnitude") == "grows_with_data"- )+ return field(row, "biomarker_type") not in GROWS_ONLY_MARKERS or perf_low_priority(row) is Nonedef _perf_value(row: Any, facets: Mapping[str, Any]) -> int:@@ -942,19 +937,19 @@ def _perf_value(row: Any, facets: Mapping[str, Any]) -> int:work Fix first holds, so it shares the top band with the largestfunctions; capped below it, it never reached a top ten that size fills."""production = field(row, "execution_context") == "production"- grows = facets.get("loop_magnitude") == "grows_with_data"- unknown = facets.get("loop_magnitude") in (None, "unknown")+ reachable = facets.get("exposure") == "entry_reachable"+ reason = lead_reason(field(row, "biomarker_type"), facets)if (production- and facets.get("exposure") == "entry_reachable"- and grows+ and reachable+ and facets.get("loop_magnitude") == "grows_with_data"and field(row, "boundary_kind") in ("db", "network")):return VALUE_MAX- value = 2 if production and (grows or unknown) else 1+ value = 2 if production and reason is None else 1# No traffic data: a loop of unknown size that no entry point reaches is# most often an admin or maintenance path, where an N+1 is cheap.- if unknown and facets.get("exposure") != "entry_reachable":+ if reason == "unmeasured_cost" and not reachable:value -= 1return value@@ -1484,15 +1479,16 @@ def build_fix_first(if _open(row):path = field(row, "file_path") or ""groups[(path, field(row, "intervention_symbol") or path)].append(row)- # The performance default queue decides which causes are work (context and- # actionability, one predicate for every surface); Fix first adds its path- # rules and needs a stored plan to quote.+ # The performance queue's context and actionability rule decides which+ # causes are work; an unproven cost stays in, tiered later by+ # ``perf_low_priority``. Fix first adds its path rules and needs a stored+ # plan to quote.perf_contexts = DEFAULT_QUEUE_CONTEXTS | {"test"} if keep_tests else DEFAULT_QUEUE_CONTEXTSfor (path, symbol), rows in groups.items():if out_of_scope(path, "production"):continuerows.sort(key=lambda r: (field(r, "rank_position") or 0, field(r, "opportunity_id")))- reasons = [default_queue_exclusion(r, perf_contexts) for r in rows]+ reasons = [strategy_exclusion(r, perf_contexts) for r in rows]queued = [r for r, reason in zip(rows, reasons, strict=True) if reason is None]ready = [r for r in queued if _has_plan(r)]if not ready:diff --git a/packages/core/src/repowise/core/analysis/health/perf/opportunities.py b/packages/core/src/repowise/core/analysis/health/perf/opportunities.pyindex 313600932..fafc7f15a 100644--- a/packages/core/src/repowise/core/analysis/health/perf/opportunities.py+++ b/packages/core/src/repowise/core/analysis/health/perf/opportunities.py@@ -191,6 +191,14 @@ def _assemble(key: Any, members: list[Any], cap: int) -> PerformanceOpportunity:provenance=provenance,magnitude=magnitude,)+ facets = {+ "actionability_confidence": acted.confidence,+ "exposure": exposure(reachable),+ "amplification": amplification(marker),+ "leverage": leverage(len(sites)),+ "change_risk": change_risk(len(files)),+ "loop_magnitude": magnitude,+ }return PerformanceOpportunity(opportunity_id=stable_id(key),performance_model_version=PERFORMANCE_MODEL_VERSION,@@ -214,14 +222,7 @@ def _assemble(key: Any, members: list[Any], cap: int) -> PerformanceOpportunity:reliable_entry_reachability=reachable,provenance=provenance,confidence=evidence_confidence,- facets={- "actionability_confidence": acted.confidence,- "exposure": exposure(reachable),- "amplification": amplification(marker),- "leverage": leverage(len(sites)),- "change_risk": change_risk(len(files)),- "loop_magnitude": magnitude,- },+ facets=facets,actionability_state=acted.state,actionability_reason=acted.reason,prerequisites=acted.prerequisites,@@ -240,7 +241,7 @@ def _assemble(key: Any, members: list[Any], cap: int) -> PerformanceOpportunity:},),fix=acted.fix,- may_lead=may_lead(marker, {facts.details.get("orm") for facts in members}),+ may_lead=may_lead(marker, {facts.details.get("orm") for facts in members}, facets),)diff --git a/packages/core/src/repowise/core/analysis/health/perf/opportunity_rank.py b/packages/core/src/repowise/core/analysis/health/perf/opportunity_rank.pyindex 547bbced8..127849777 100644--- a/packages/core/src/repowise/core/analysis/health/perf/opportunity_rank.py+++ b/packages/core/src/repowise/core/analysis/health/perf/opportunity_rank.py@@ -16,10 +16,12 @@ own, per opportunity or otherwise.from __future__ import annotations+from collections.abc import Mappingfrom math import log2from typing import Anyfrom ..rows import detail_map, field+from ..worth import cost_proof, lead_reasonfrom .actionability import EXPECTED_REASONSBOUNDARY_POINTS = {"subprocess": 5, "network": 4, "db": 4, "lock": 3, "filesystem": 2}@@ -83,12 +85,15 @@ Wilson LB 75.8%); SQLAlchemy has fewer than 30 labels and stays non-leading."""-def may_lead(marker: str, orms: set[Any]) -> bool:+def may_lead(marker: str, orms: set[Any], facets: Mapping[str, Any]) -> bool:"""Whether a group of *marker* with members on *orms* may lead the directive.- Every member has to be on an ORM that cleared the bar: one unmeasured member- is enough to keep the group from leading.+ Its cost has to be proven to matter (:func:`worth.lead_reason`), and every+ member has to be on an ORM that cleared the bar: one unmeasured member is+ enough to keep the group from leading."""+ if lead_reason(marker, facets) is not None:+ return Falseif marker not in NON_LEADING_MARKERS:return Truereturn bool(orms) and orms <= LEADING_ORMS.get(marker, frozenset())@@ -101,9 +106,9 @@ CROSS_FUNCTION_POINTS = 1the loop, so it earns a point that an intra-function hit does not."""CONTEXT_POINTS = {"production": 3, "tooling": 2, "test": 1, "unknown": 1}-MAGNITUDE_POINTS = {"grows_with_data": 2, "unknown": 1, "n/a": 1, "bounded": 0}+MAGNITUDE_POINTS = {"grows_with_data": 2, "n/a": 1, "bounded": 0, "unknown": 0}"""A loop over a query result is paid again as the data grows; a retry loop or a-constant-width slice is not. Unknown sits between, so a guess never outranks a fact."""+constant-width slice is not. Unknown earns nothing, so a guess never outranks a fact."""PROVENANCE_POINTS = {"call-site": 3, "direct": 3, "reliable-edge": 2, "name-fallback": 0}AMPLIFICATION = {@@ -134,15 +139,26 @@ what kept a generic sink's volume from crowding out actionable work.DEFAULT_QUEUE_CONTEXTS = frozenset({"production"})DEFAULT_QUEUE_STATES = frozenset({"plan_ready", "advisory"})-"""What the queue holds when a caller names no filter: production work with a strategy.+DEFAULT_QUEUE_PROOFS = frozenset({"proven"})+"""What the queue holds when a caller names no filter: production work with a+strategy whose cost is measured.-Test, tooling and unclassified code, ``expected`` repetition, and causes with no+Test, tooling and unclassified code, ``expected`` repetition, causes with nosupported strategy (``investigate``, whose plan state is always ``no_safe_plan``)-are true and stay one filter away, but none of them is work to schedule. Each is-counted by :func:`default_queue_exclusion` so leaving it out is never silent.+and causes whose loop nobody measured (``worth.cost_proof``) are true and stay one+filter away, but none of them is work to schedule. Each is counted by+:func:`default_queue_exclusion` so leaving it out is never silent."""-DEFAULT_QUEUE_EXCLUSIONS = ("test", "tooling", "unknown", *EXPECTED_REASONS, "expected", "no_strategy")+DEFAULT_QUEUE_EXCLUSIONS = (+ "test",+ "tooling",+ "unknown",+ *EXPECTED_REASONS,+ "expected",+ "no_strategy",+ "unmeasured_cost",+)"""Every reason the default queue leaves a cause out, in the order it is checked."""_LEVERAGE_BANDS = ((1, "isolated"), (3, "local"), (9, "shared"))@@ -277,15 +293,15 @@ def why_ranked(factors: dict[str, int], values: dict[str, Any], limit: int = 3))-def default_queue_exclusion(+def strategy_exclusion(item: Any, contexts: frozenset[str] = DEFAULT_QUEUE_CONTEXTS) -> str | None:- """Why the default queue leaves *item* out, or ``None`` when it is queued.+ """Why *item* is no work to schedule, by context and state, or ``None``.- One reason per cause, context first, so the counts of every reason and the- queue add up to the whole. Reads an opportunity, an ORM row or a plain row.- *contexts* widens the queue for a caller that asked for more (Fix first's- ``scope="all"`` keeps test code); the state rule never moves.+ Reads an opportunity, an ORM row or a plain row. *contexts* widens it for a+ caller that asked for more (Fix first's ``scope="all"`` keeps test code);+ the state rule never moves. Fix first reads this rather than the default+ queue because it keeps an unproven cause, as a ``later`` item."""context = field(item, "execution_context")if context not in contexts:@@ -299,6 +315,18 @@ def default_queue_exclusion(return reason if reason in EXPECTED_REASONS else "expected"+def default_queue_exclusion(item: Any) -> str | None:+ """Why the default queue leaves *item* out, or ``None`` when it is queued.++ One reason per cause, context first and proof last, so the counts of every+ reason and the queue add up to the whole.+ """+ reason = strategy_exclusion(item)+ if reason is None and cost_proof(item) not in DEFAULT_QUEUE_PROOFS:+ return "unmeasured_cost"+ return reason++def default_queue_counts(items: list[Any]) -> dict[str, Any]:"""The default queue's size and what it leaves out, by reason."""excluded = dict.fromkeys(DEFAULT_QUEUE_EXCLUSIONS, 0)@@ -333,6 +361,7 @@ __all__ = ["CROSS_FUNCTION_POINTS","DEFAULT_QUEUE_CONTEXTS","DEFAULT_QUEUE_EXCLUSIONS",+ "DEFAULT_QUEUE_PROOFS","DEFAULT_QUEUE_STATES","LEADING_ORMS","MAGNITUDE_POINTS",@@ -353,6 +382,7 @@ __all__ = ["observation_rank","rank_factors","rank_sort_key",+ "strategy_exclusion","weakest_provenance","why_ranked",]diff --git a/packages/core/src/repowise/core/analysis/health/perf/serving.py b/packages/core/src/repowise/core/analysis/health/perf/serving.pyindex 69dad7088..337a59212 100644--- a/packages/core/src/repowise/core/analysis/health/perf/serving.py+++ b/packages/core/src/repowise/core/analysis/health/perf/serving.py@@ -21,10 +21,10 @@ from repowise.core.analysis.health.finding_identity import finding_public_idfrom repowise.core.analysis.health.fix_first.text import perf_costfrom repowise.core.analysis.health.queue_rules import NULL_VALUE, Facet, FilterRule, SortKeysfrom repowise.core.analysis.health.rows import detail_map, field, json_field-from repowise.core.analysis.health.worth import LOW_PRIORITY_LABEL, perf_low_priority+from repowise.core.analysis.health.worth import COST_PROOFS, LOW_PRIORITY_LABEL, perf_low_priorityfrom .opportunities import PERFORMANCE_MODEL_VERSION-from .opportunity_rank import DEFAULT_QUEUE_STATES, NON_LEADING_MARKERS+from .opportunity_rank import DEFAULT_QUEUE_PROOFS, DEFAULT_QUEUE_STATES, NON_LEADING_MARKERSif TYPE_CHECKING:from .opportunities import PerformanceOpportunity@@ -109,6 +109,7 @@ FILTERS: tuple[FilterRule, ...] = (FilterRule("boundary", "boundary_kind", "eq_or_null", "set"),FilterRule("confidence", "evidence_confidence", "eq", "set"),FilterRule("actionabilities", "actionability_state", "in", "set"),+ FilterRule("proofs", "cost_proof", "in", "set"),FilterRule("file_paths", "file_path", "in", "set"),)@@ -120,6 +121,7 @@ FACETS: tuple[Facet, ...] = (("confidence", "evidence_confidence", "confidence"),("actionability", "actionability_state", "actionabilities"),("plan_state", "plan_state", None),+ ("proof", "cost_proof", "proofs"),)FACET_FIELDS = tuple(column for _, column, _ in FACETS)@@ -140,8 +142,8 @@ def row_sort_key(row: Any, sort: str | None = None) -> tuple[Any, ...]:def _facet_selection(query: PerformanceQuery) -> dict[str, Any]:- """What a caller chose, per facet. The default queue states are not a- choice, so an unfiltered actionability control still shows every state."""+ """What a caller chose, per facet. The default queue states and proof are+ not a choice, so an unfiltered control still shows every value."""return {"contexts": query.contexts,"boundary": query.boundary,@@ -149,6 +151,7 @@ def _facet_selection(query: PerformanceQuery) -> dict[str, Any]:"actionabilities": (None if query.actionability is None else frozenset({query.actionability})),+ "proofs": None if query.proof is None else frozenset({query.proof}),}@@ -196,6 +199,7 @@ class PerformanceQuery:boundary: str | None = Noneconfidence: str | None = Noneactionability: str | None = None+ proof: str | None = Noneview: str = "detail"sort: str = DEFAULT_SORTfile_paths: tuple[str, ...] | None = None@@ -220,6 +224,15 @@ class PerformanceQuery:return DEFAULT_ACTIONABILITIESreturn frozenset({self.actionability})+ @property+ def proofs(self) -> frozenset[str]:+ """``unproven`` when asked for; else the measured causes, so every+ surface lists what the default queue counts. The ``proof`` facet says+ how many unproven ones sit one filter away."""+ if self.proof is None:+ return DEFAULT_QUEUE_PROOFS+ return frozenset({self.proof})+def _resolve_context(context: str | None, ignored: dict[str, str]) -> PerformanceContext:if not context:@@ -240,6 +253,7 @@ def parse_query(boundary: str | None = None,confidence: str | None = None,actionability: str | None = None,+ proof: str | None = None,view: str | None = None,sort: str | None = None,file_paths: tuple[str, ...] | None = None,@@ -269,6 +283,7 @@ def parse_query(boundary=pick("performance_boundary", boundary, BOUNDARIES),confidence=pick("performance_confidence", confidence, CONFIDENCES),actionability=pick("performance_actionability", actionability, ACTIONABILITIES),+ proof=pick("performance_proof", proof, COST_PROOFS),view=pick("performance_view", view, CANONICAL_VIEWS) or "detail",sort=pick("performance_sort", sort, CANONICAL_SORTS) or DEFAULT_SORT,file_paths=file_paths,@@ -445,6 +460,7 @@ def summary_payload(row: Any | None) -> dict[str, Any]:"actionability": payload.get("actionability", {}),"context": payload.get("context", {}),"boundary": payload.get("boundary", {}),+ "proof": payload.get("proof", {}),"with_plan_total": payload.get("with_plan_total", 0),**({"default_queue": payload["default_queue"]} if "default_queue" in payload else {}),**(@@ -468,9 +484,10 @@ def rescope_summary(actionability: dict[str, int] = {}context: dict[str, int] = {}boundary: dict[str, int] = {}+ proof: dict[str, int] = {}total = 0with_plan = 0- for execution_context, boundary_kind, _confidence, state, plan_state, count in groups:+ for execution_context, boundary_kind, _confidence, state, plan_state, cost, count in groups:if execution_context not in contexts:continuetotal += count@@ -478,6 +495,7 @@ def rescope_summary(context[execution_context] = context.get(execution_context, 0) + countkey = boundary_kind or NULL_VALUEboundary[key] = boundary.get(key, 0) + count+ proof[cost] = proof.get(cost, 0) + countif plan_state == "available":with_plan += countreturn {@@ -486,6 +504,7 @@ def rescope_summary("actionability": actionability,"context": context,"boundary": boundary,+ "proof": proof,"with_plan_total": with_plan,}diff --git a/packages/core/src/repowise/core/analysis/health/worth.py b/packages/core/src/repowise/core/analysis/health/worth.pyindex 6c9dedebe..56c54005e 100644--- a/packages/core/src/repowise/core/analysis/health/worth.py+++ b/packages/core/src/repowise/core/analysis/health/worth.py@@ -271,33 +271,65 @@ def finding_priorities(findings: Sequence[Any]) -> list[LowPriority | None]:#: Performance causes that cost once per call, not once per loop iteration:#: they lead when an entry point reaches them.-_PER_CALL_MARKERS = frozenset({"hot_path_sync_io", "blocking_sync_in_async", "blocking_io_under_lock"})+_PER_CALL_MARKERS = frozenset(+ {+ "hot_path_sync_io",+ "blocking_sync_in_async",+ "blocking_io_under_lock",+ "unbounded_read_reduced_in_memory",+ }+)#: Causes whose cost grows with the data by their shape alone._GROWING_MARKERS = frozenset({"goroutine_in_unbounded_loop", "sql_cartesian_join"})+CostProof = Literal["proven", "unproven"]+COST_PROOFS: tuple[str, ...] = ("proven", "unproven")-def perf_low_priority(row: Any) -> LowPriority | None:- """Why a performance opportunity can wait. In production code a loop cause- leads when its loop grows with the data, a per-call cause when an entry- point reaches it, and an unbounded goroutine loop or a cartesian join- always; the reason names whichever fact is missing."""- context = field(row, "execution_context")- if context != "production":- return "unknown_context" if context in (None, "unknown") else "not_production"- marker = field(row, "biomarker_type")- facets = detail_map(row).get("facets") or {}++def perf_facets(row: Any) -> Mapping[str, Any]:+ """A performance cause's facets, in memory or stored in its details."""+ return field(row, "facets") or detail_map(row).get("facets") or {}+++def lead_reason(marker: str | None, facets: Mapping[str, Any]) -> LowPriority | None:+ """Why a performance cause may not lead, or ``None`` when it may.++ The one rule the performance queue, its lead, its rank and Fix first read.+ A cause leads when its loop grows with the data, when it is a per-call+ cause an entry point reaches, or when its shape grows by itself (an+ unbounded goroutine loop, a cartesian join). A cause with no loop+ (magnitude ``n/a``) is judged as a per-call one. ``unmeasured_cost`` is+ the unproven case: nothing measured the loop, so it is a guess, not a cost.+ """if marker in _GROWING_MARKERS:return None- if marker in _PER_CALL_MARKERS:- return None if facets.get("exposure") == "entry_reachable" else "unreached_call"magnitude_ = facets.get("loop_magnitude")+ if marker in _PER_CALL_MARKERS or magnitude_ == "n/a":+ return None if facets.get("exposure") == "entry_reachable" else "unreached_call"if magnitude_ == "grows_with_data":return Nonereturn "bounded_loop" if magnitude_ == "bounded" else "unmeasured_cost"+def cost_proof(row: Any) -> CostProof:+ """``unproven`` when nothing measured whether the cause's cost grows: kept+ out of the default queue, listed under its own filter."""+ reason = lead_reason(field(row, "biomarker_type"), perf_facets(row))+ return "unproven" if reason == "unmeasured_cost" else "proven"+++def perf_low_priority(row: Any) -> LowPriority | None:+ """Why a performance opportunity can wait: it runs outside production+ code, or :func:`lead_reason` holds it back."""+ context = field(row, "execution_context")+ if context != "production":+ return "unknown_context" if context in (None, "unknown") else "not_production"+ return lead_reason(field(row, "biomarker_type"), perf_facets(row))++__all__ = ["CHAIN_SHARE",+ "COST_PROOFS","EXTREME_MAGNITUDE","LOW_PRIORITY_LABEL","SIZE_CCN",@@ -307,13 +339,17 @@ __all__ = ["TANGLED_CCN","TANGLED_NESTING","WORTH_MAGNITUDE",+ "CostProof","LowPriority",+ "cost_proof","dispatch_shaped","dormant","finding_priorities",+ "lead_reason","low_priority","magnitude","measure",+ "perf_facets","perf_low_priority","worth_size",]diff --git a/packages/core/src/repowise/core/persistence/crud/analysis/performance.py b/packages/core/src/repowise/core/persistence/crud/analysis/performance.pyindex fcad7f2c2..146699253 100644--- a/packages/core/src/repowise/core/persistence/crud/analysis/performance.py+++ b/packages/core/src/repowise/core/persistence/crud/analysis/performance.py@@ -102,6 +102,7 @@ def _row_kwargs(plan: dict[str, Any] | None = None,) -> dict[str, Any]:from ....analysis.health.perf.serving import intervention_file+ from ....analysis.health.worth import cost_prooffix = opportunity.fixreturn {@@ -116,6 +117,7 @@ def _row_kwargs("actionability_state": opportunity.actionability_state,"evidence_confidence": opportunity.confidence,"plan_state": plan_state,+ "cost_proof": cost_proof(opportunity),"fix_strategy": fix.strategy if fix else None,"fix_safety": fix.safety if fix else None,"file_path": intervention_file(opportunity),@@ -140,15 +142,19 @@ def _summary_payload(default_queue_exclusion,)from ....analysis.health.perf.serving import intervention_file+ from ....analysis.health.worth import cost_proofcounts: dict[str, int] = {}contexts: dict[str, int] = {}boundaries: dict[str, int] = {}+ proofs: dict[str, int] = {}for item in opportunities:counts[item.actionability_state] = counts.get(item.actionability_state, 0) + 1contexts[item.execution_context] = contexts.get(item.execution_context, 0) + 1key = item.boundary_kind or "none"boundaries[key] = boundaries.get(key, 0) + 1+ proof = cost_proof(item)+ proofs[proof] = proofs.get(proof, 0) + 1# The lead is the head of the default queue, so it is production work with a# strategy; never a marker whose measured precision is below the bar for leading.lead = next(@@ -164,6 +170,7 @@ def _summary_payload("actionability": counts,"context": contexts,"boundary": boundaries,+ "proof": proofs,"with_plan_total": sum(1 for state in plan_states.values() if state == "available"),"lead": Noneif lead is None@@ -453,6 +460,7 @@ async def list_performance_opportunities(boundary: str | None = None,confidence: str | None = None,actionabilities: frozenset[str] | None = None,+ proofs: frozenset[str] | None = None,file_paths: tuple[str, ...] | None = None,sort: str = "rank",limit: int = 20,@@ -471,6 +479,7 @@ async def list_performance_opportunities(boundary=boundary,confidence=confidence,actionabilities=actionabilities,+ proofs=proofs,file_paths=file_paths,)total = int(@@ -501,7 +510,7 @@ async def performance_facet_counts(repository_id: str,*,file_paths: tuple[str, ...] | None = None,-) -> list[tuple[str, str | None, str, str, str, int]]:+) -> list[tuple[str, str | None, str, str, str, str, int]]:"""Grouped counts over every open opportunity, in one aggregate statement.Returned pre-aggregation, one ``(*FACET_FIELDS, count)`` tuple per group,diff --git a/packages/core/src/repowise/core/persistence/models.py b/packages/core/src/repowise/core/persistence/models.pyindex 9907f557d..9922733b1 100644--- a/packages/core/src/repowise/core/persistence/models.py+++ b/packages/core/src/repowise/core/persistence/models.py@@ -1938,6 +1938,12 @@ class PerformanceOpportunity(Base):# ``available`` | ``no_safe_plan`` | ``not_persisted``, decided once by the# writer that also decides whether a plan row exists.plan_state: Mapped[str] = mapped_column(String(16), nullable=False, default="no_safe_plan")+ # ``proven`` | ``unproven`` (``worth.cost_proof``): whether anything measured+ # that the cost grows. A store written before the column reads ``proven``+ # until its next analysis, as it was served then.+ cost_proof: Mapped[str] = mapped_column(+ String(16), nullable=False, default="proven", server_default="proven"+ )fix_strategy: Mapped[str | None] = mapped_column(String(64), nullable=True)fix_safety: Mapped[str | None] = mapped_column(String(16), nullable=True)# The file holding the symbol worth editing, so target scoping is a column.diff --git a/packages/server/src/repowise/server/routers/code_health/performance_routes.py b/packages/server/src/repowise/server/routers/code_health/performance_routes.pyindex 636311204..bc52793a7 100644--- a/packages/server/src/repowise/server/routers/code_health/performance_routes.py+++ b/packages/server/src/repowise/server/routers/code_health/performance_routes.py@@ -64,6 +64,13 @@ async def list_performance_opportunities(boundary: str | None = Query(None),confidence: str | None = Query(None),actionability: str | None = Query(None),+ proof: str | None = Query(+ None,+ description=(+ "proven (the default) or unproven: causes whose loop nobody measured "+ "to grow, kept out of the default queue and counted in its summary."+ ),+ ),view: str = Query("detail"),sort: str = Query("rank"),file_paths: str | None = Query(@@ -87,6 +94,7 @@ async def list_performance_opportunities(boundary=boundary,confidence=confidence,actionability=actionability,+ proof=proof,view=view,sort=sort,file_paths=_paths(file_paths),diff --git a/packages/server/src/repowise/server/services/performance_health.py b/packages/server/src/repowise/server/services/performance_health.pyindex b2c5a237f..52e55085a 100644--- a/packages/server/src/repowise/server/services/performance_health.py+++ b/packages/server/src/repowise/server/services/performance_health.py@@ -96,6 +96,7 @@ class PerformanceHealthService:boundary=query.boundary,confidence=query.confidence,actionabilities=query.actionabilities,+ proofs=query.proofs,file_paths=query.file_paths,sort=query.sort,limit=query.limit,diff --git a/packages/types/src/health.ts b/packages/types/src/health.tsindex 8f5fad5c6..a693a501f 100644--- a/packages/types/src/health.ts+++ b/packages/types/src/health.ts@@ -561,7 +561,15 @@ export type PerformanceFacetKey =| "boundary"| "confidence"| "actionability"- | "plan_state";+ | "plan_state"+ | "proof";++/**+ * Whether anything measured that a cause's cost grows with the data+ * (`worth.COST_PROOFS`). The queue holds `proven` causes unless asked for+ * `unproven` ones, which never lead.+ */+export type PerformanceCostProof = "proven" | "unproven";export type PerformanceFacets = Partial<Record<PerformanceFacetKey, PerformanceFacetCount[]>>;@@ -584,6 +592,8 @@ export type PerformanceOpportunityQuery = {/** Evidence confidence, requested apart from fix safety and actionability. */confidence?: PerformanceOpportunityConfidence;actionability?: PerformanceActionabilityState;+ /** Absent means `proven`; `unproven` lists the causes the default queue leaves out. */+ proof?: PerformanceCostProof;/** `summary` drops the explanatory fields and keeps identity and counts. */view?: "detail" | "summary";sort?: "rank" | "leverage" | "observations";@@ -605,7 +615,8 @@ export type PerformanceQueueExclusion =| "gated_off"| "cold_path"| "expected"- | "no_strategy";+ | "no_strategy"+ | "unmeasured_cost";export interface PerformanceDefaultQueue {total: number;@@ -629,6 +640,8 @@ export interface PerformanceOpportunitySummary {actionability?: Partial<Record<PerformanceActionabilityState, number>>;context?: Partial<Record<PerformanceExecutionContext, number>>;boundary?: Record<string, number>;+ /** Causes by cost proof; `unproven` ones sit outside the default queue. Absent on an older store. */+ proof?: Partial<Record<PerformanceCostProof, number>>;with_plan_total: number;/** The queue a caller gets with no filter (production work with a strategy),* and how many causes it leaves out per reason. Absent on an older store. */diff --git a/packages/ui/__tests__/health/performance-query.test.ts b/packages/ui/__tests__/health/performance-query.test.tsindex 3524b1ed5..3ce117522 100644--- a/packages/ui/__tests__/health/performance-query.test.ts+++ b/packages/ui/__tests__/health/performance-query.test.ts@@ -25,12 +25,22 @@ describe("performance filter state", () => {boundary: "filesystem",confidence: "high" as const,actionability: "plan_ready" as const,+ proof: "unproven" as const,sort: "leverage" as const,offset: 40,};expect(parseFilters(serializeFilters(state))).toEqual(state);});+ it("asks for unproven causes only when chosen", () => {+ // Absent means the server's default: causes whose cost is measured.+ expect(toQuery(INITIAL_FILTERS, { limit: 20 }).proof).toBeUndefined();+ const unproven = withFilter(INITIAL_FILTERS, "proof", "unproven");+ expect(toQuery(unproven, { limit: 20 }).proof).toBe("unproven");+ expect(narrowingCount(unproven)).toBe(1);+ expect(clearNarrowing(unproven).proof).toBeNull();+ });+it("round trips the expected actionability state", () => {// expected sits out of the default queue but is still a real, selectable// state: the round trip must not treat it as unrecognized.diff --git a/packages/ui/src/health/performance/filters.tsx b/packages/ui/src/health/performance/filters.tsxindex 70c91da3c..90896fac8 100644--- a/packages/ui/src/health/performance/filters.tsx+++ b/packages/ui/src/health/performance/filters.tsx@@ -96,6 +96,8 @@ const NARROWING: NarrowingSpec[] = [{ key: "actionability", facet: "actionability", anyLabel: "All but expected" },{ key: "boundary", facet: "boundary", anyLabel: "Any" },{ key: "confidence", facet: "confidence", anyLabel: "Any" },+ // Unproven causes (loop size unknown) are counted but never queued by default.+ { key: "proof", facet: "proof", anyLabel: "Measured only" },];/**diff --git a/packages/ui/src/health/performance/presentation.ts b/packages/ui/src/health/performance/presentation.tsindex 70cad4578..32bcc10b7 100644--- a/packages/ui/src/health/performance/presentation.ts+++ b/packages/ui/src/health/performance/presentation.ts@@ -1,6 +1,7 @@import {PERF_BOUNDARY_LABEL,type PerformanceActionabilityState,+ type PerformanceCostProof,type PerformanceExecutionContext,type PerformanceFacetKey,type PerformanceOpportunity,@@ -63,6 +64,12 @@ export const FACET_LABEL: Record<PerformanceFacetKey, string> = {confidence: "Evidence confidence",actionability: "Actionability",plan_state: "Plan",+ proof: "Cost",+};++const PROOF_LABEL: Record<PerformanceCostProof, string> = {+ proven: "Measured",+ unproven: "Unproven: loop size unknown",};const PLAN_STATE_LABEL: Record<string, string> = {@@ -180,6 +187,7 @@ export function facetValueLabel(facet: PerformanceFacetKey, value: string): striif (facet === "confidence") return CONFIDENCE_LABEL[value as PerformanceOpportunityConfidence] ?? humanizeToken(value);if (facet === "actionability")return ACTIONABILITY_LABEL[value as PerformanceActionabilityState] ?? humanizeToken(value);+ if (facet === "proof") return PROOF_LABEL[value as PerformanceCostProof] ?? humanizeToken(value);return PLAN_STATE_LABEL[value] ?? humanizeToken(value);}diff --git a/packages/ui/src/health/performance/query.ts b/packages/ui/src/health/performance/query.tsindex 378c81456..d0592492d 100644--- a/packages/ui/src/health/performance/query.ts+++ b/packages/ui/src/health/performance/query.ts@@ -1,6 +1,7 @@import type {PerformanceActionabilityState,PerformanceContextFilter,+ PerformanceCostProof,PerformanceOpportunityConfidence,PerformanceOpportunityQuery,} from "@repowise-dev/types/health";@@ -21,6 +22,7 @@ export interface PerformanceFilterState {boundary: string | null;confidence: PerformanceOpportunityConfidence | null;actionability: PerformanceActionabilityState | null;+ proof: PerformanceCostProof | null;sort: PerformanceSort;offset: number;}@@ -36,12 +38,13 @@ export const INITIAL_FILTERS: PerformanceFilterState = {boundary: null,confidence: null,actionability: null,+ proof: null,sort: "rank",offset: 0,};/** The narrowing filters, apart from context, which is a permanent tab row. */-const NARROWING_KEYS = ["boundary", "confidence", "actionability"] as const;+const NARROWING_KEYS = ["boundary", "confidence", "actionability", "proof"] as const;export type NarrowingKey = (typeof NARROWING_KEYS)[number];const SORTS: readonly PerformanceSort[] = ["rank", "leverage", "observations"];@@ -52,6 +55,7 @@ const ACTIONABILITIES: readonly PerformanceActionabilityState[] = ["investigate","expected",];+const PROOFS: readonly PerformanceCostProof[] = ["proven", "unproven"];const CONTEXTS: readonly PerformanceContextFilter[] = ["all","production",@@ -83,6 +87,7 @@ export function toQuery(if (state.boundary) query.boundary = state.boundary;if (state.confidence) query.confidence = state.confidence;if (state.actionability) query.actionability = state.actionability;+ if (state.proof) query.proof = state.proof;return query;}@@ -102,6 +107,7 @@ export function serializeFilters(state: PerformanceFilterState): string {if (state.boundary) params.set("boundary", state.boundary);if (state.confidence) params.set("confidence", state.confidence);if (state.actionability) params.set("actionability", state.actionability);+ if (state.proof) params.set("proof", state.proof);if (state.sort !== INITIAL_FILTERS.sort) params.set("sort", state.sort);if (state.offset > 0) params.set("offset", String(state.offset));return params.toString();@@ -124,6 +130,7 @@ export function parseFilters(search: string | URLSearchParams): PerformanceFilteboundary: params.get("boundary") || null,confidence: oneOf(params.get("confidence"), CONFIDENCES),actionability: oneOf(params.get("actionability"), ACTIONABILITIES),+ proof: oneOf(params.get("proof"), PROOFS),sort: oneOf(params.get("sort"), SORTS) ?? INITIAL_FILTERS.sort,offset: Number.isFinite(offset) && offset > 0 ? offset : 0,};@@ -140,7 +147,7 @@ export function withFilter<K extends keyof PerformanceFilterState>(}export function clearNarrowing(state: PerformanceFilterState): PerformanceFilterState {- return { ...state, boundary: null, confidence: null, actionability: null, offset: 0 };+ return { ...state, boundary: null, confidence: null, actionability: null, proof: null, offset: 0 };}export function narrowingCount(state: PerformanceFilterState): number {diff --git a/tests/fixtures/perf_corpus/golden_opportunities.json b/tests/fixtures/perf_corpus/golden_opportunities.jsonindex fed20cc67..e1c5d5a82 100644--- a/tests/fixtures/perf_corpus/golden_opportunities.json+++ b/tests/fixtures/perf_corpus/golden_opportunities.json@@ -67,7 +67,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/jobs.py::drain",- "may_lead": true,+ "may_lead": false,"observations_total": 3,"opportunity_id": "perf3_d41b04897cfde2a9eed6","performance_model_version": 3,@@ -81,11 +81,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 6,"provenance": 3},- "rank_score": 24,+ "rank_score": 23,"reliable_entry_reachability": true,"resource_fingerprints": [],"shared_path_suffix": [@@ -187,7 +187,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/ledger.py::apply",- "may_lead": true,+ "may_lead": false,"observations_total": 3,"opportunity_id": "perf3_2719b6813419ad35948b","performance_model_version": 3,@@ -201,11 +201,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 22,+ "rank_score": 21,"reliable_entry_reachability": true,"resource_fingerprints": [],"shared_path_suffix": [],@@ -294,7 +294,7 @@},"intervention_kind": "shared_helper","intervention_symbol": "src/app/entry.py::_hit",- "may_lead": true,+ "may_lead": false,"observations_total": 2,"opportunity_id": "perf3_6690af4c5e3f269c266e","performance_model_version": 3,@@ -308,11 +308,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 21,+ "rank_score": 20,"reliable_entry_reachability": true,"resource_fingerprints": [],"shared_path_suffix": [@@ -402,7 +402,7 @@},"intervention_kind": "shared_helper","intervention_symbol": "src/app/repo.py::fetch_page",- "may_lead": true,+ "may_lead": false,"observations_total": 2,"opportunity_id": "perf3_8456a319d03ac90c6041","performance_model_version": 3,@@ -416,11 +416,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 21,+ "rank_score": 20,"reliable_entry_reachability": true,"resource_fingerprints": [],"shared_path_suffix": [@@ -511,7 +511,7 @@},"intervention_kind": "shared_helper","intervention_symbol": "src/app/reindex.py::_write",- "may_lead": true,+ "may_lead": false,"observations_total": 2,"opportunity_id": "perf3_a123c4c38fdb1cabaa6a","performance_model_version": 3,@@ -525,11 +525,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 6,"provenance": 3},- "rank_score": 20,+ "rank_score": 19,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -559,6 +559,88 @@}]},+ {+ "actionability_reason": "proven_strategy",+ "actionability_state": "plan_ready",+ "affected_call_sites_total": 1,+ "affected_files_total": 1,+ "biomarker_type": "io_in_loop",+ "biomarker_types": [+ "io_in_loop"+ ],+ "boundary_kind": "db",+ "confidence": "high",+ "evidence": [+ {+ "biomarker_type": "io_in_loop",+ "file_path": "src/app/owners.py",+ "finding_id": "finding_c7e0cff49d2e4944af6c",+ "function_name": "load_owners",+ "line_end": 22,+ "line_start": 20,+ "path": [],+ "provenance": "direct",+ "reason": "batch_form_equivalent: io_in_loop at src/app/owners.py:20 repeats work per iteration."+ }+ ],+ "evidence_truncated": false,+ "execution_context": "production",+ "facets": {+ "actionability_confidence": "high",+ "amplification": "per_iteration",+ "change_risk": "contained",+ "exposure": "unknown",+ "leverage": "isolated",+ "loop_magnitude": "grows_with_data"+ },+ "fix": {+ "api": ".in_(\"repo_id\", keys)",+ "rationale": "Every call filters on the loop's own key, so .in_(\"repo_id\", keys) covers the same rows, and nothing else in the loop can observe the difference.",+ "safety": "proven",+ "strategy": "batch_or_prefetch_io"+ },+ "intervention_kind": "function",+ "intervention_symbol": "src/app/owners.py::load_owners",+ "may_lead": true,+ "observations_total": 1,+ "opportunity_id": "perf3_83d258547498bed60226",+ "performance_model_version": 3,+ "prerequisites": [],+ "provenance": "direct",+ "rank_factors": {+ "affected_call_sites": 2,+ "boundary_kind": 4,+ "entry_reachability": 0,+ "execution_context": 3,+ "loop_magnitude": 2,+ "multiplier_shape": 4,+ "provenance": 3+ },+ "rank_score": 18,+ "reliable_entry_reachability": null,+ "resource_fingerprints": [],+ "shared_path_suffix": [],+ "siblings": [],+ "terminal_sink": null,+ "terminal_sinks": [],+ "why_ranked": [+ {+ "factor": "boundary_kind",+ "points": 4,+ "value": "db"+ },+ {+ "factor": "multiplier_shape",+ "points": 4,+ "value": "io_in_loop"+ },+ {+ "factor": "execution_context",+ "points": 3,+ "value": "production"+ }+ ]+ },{"actionability_reason": "no_supported_strategy","actionability_state": "investigate",@@ -615,7 +697,7 @@"fix": null,"intervention_kind": "shared_helper","intervention_symbol": "src/app/store.py::flush_all",- "may_lead": true,+ "may_lead": false,"observations_total": 2,"opportunity_id": "perf3_d3dace3672249fc9bd03","performance_model_version": 3,@@ -628,11 +710,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 5,"provenance": 3},- "rank_score": 19,+ "rank_score": 18,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -662,88 +744,6 @@}]},- {- "actionability_reason": "proven_strategy",- "actionability_state": "plan_ready",- "affected_call_sites_total": 1,- "affected_files_total": 1,- "biomarker_type": "io_in_loop",- "biomarker_types": [- "io_in_loop"- ],- "boundary_kind": "db",- "confidence": "high",- "evidence": [- {- "biomarker_type": "io_in_loop",- "file_path": "src/app/owners.py",- "finding_id": "finding_c7e0cff49d2e4944af6c",- "function_name": "load_owners",- "line_end": 22,- "line_start": 20,- "path": [],- "provenance": "direct",- "reason": "batch_form_equivalent: io_in_loop at src/app/owners.py:20 repeats work per iteration."- }- ],- "evidence_truncated": false,- "execution_context": "production",- "facets": {- "actionability_confidence": "high",- "amplification": "per_iteration",- "change_risk": "contained",- "exposure": "unknown",- "leverage": "isolated",- "loop_magnitude": "grows_with_data"- },- "fix": {- "api": ".in_(\"repo_id\", keys)",- "rationale": "Every call filters on the loop's own key, so .in_(\"repo_id\", keys) covers the same rows, and nothing else in the loop can observe the difference.",- "safety": "proven",- "strategy": "batch_or_prefetch_io"- },- "intervention_kind": "function",- "intervention_symbol": "src/app/owners.py::load_owners",- "may_lead": true,- "observations_total": 1,- "opportunity_id": "perf3_83d258547498bed60226",- "performance_model_version": 3,- "prerequisites": [],- "provenance": "direct",- "rank_factors": {- "affected_call_sites": 2,- "boundary_kind": 4,- "entry_reachability": 0,- "execution_context": 3,- "loop_magnitude": 2,- "multiplier_shape": 4,- "provenance": 3- },- "rank_score": 18,- "reliable_entry_reachability": null,- "resource_fingerprints": [],- "shared_path_suffix": [],- "siblings": [],- "terminal_sink": null,- "terminal_sinks": [],- "why_ranked": [- {- "factor": "boundary_kind",- "points": 4,- "value": "db"- },- {- "factor": "multiplier_shape",- "points": 4,- "value": "io_in_loop"- },- {- "factor": "execution_context",- "points": 3,- "value": "production"- }- ]- },{"actionability_reason": "strategy_requires_validation","actionability_state": "advisory",@@ -804,7 +804,7 @@},"intervention_kind": "shared_helper","intervention_symbol": "src/app/sync.py::_load",- "may_lead": true,+ "may_lead": false,"observations_total": 2,"opportunity_id": "perf3_8845956c083937dad1ec","performance_model_version": 3,@@ -818,11 +818,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 18,+ "rank_score": 17,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -896,7 +896,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/cache.py::refresh",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_600194da489eff07f26a","performance_model_version": 3,@@ -909,11 +909,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 5,"provenance": 3},- "rank_score": 18,+ "rank_score": 17,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -985,7 +985,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/fetch.py::fetch_each",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_877f87ea6dac79fd92fc","performance_model_version": 3,@@ -996,11 +996,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -1067,7 +1067,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/commits.py::first_commit_each",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_2a6f52da25a5ede16116","performance_model_version": 3,@@ -1080,11 +1080,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -1150,7 +1150,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/fanout.py::gather_all",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_445b62193f1ff0db3cb4","performance_model_version": 3,@@ -1163,11 +1163,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -1236,7 +1236,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/job.py::run",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_4e3feb071c73aa51a6a4","performance_model_version": 3,@@ -1250,11 +1250,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -1327,7 +1327,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/lone.py::run",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_919d91fe15e89966b389","performance_model_version": 3,@@ -1341,11 +1341,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -1428,11 +1428,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -1498,7 +1498,7 @@},"intervention_kind": "function","intervention_symbol": "app/issues/views.py::issue_list",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_942cceadc50a644175e4","performance_model_version": 3,@@ -1511,11 +1511,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -1584,7 +1584,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/orders.py::handle",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_95567b0824b33141361d","performance_model_version": 3,@@ -1598,11 +1598,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": false,"resource_fingerprints": [],"shared_path_suffix": [@@ -1676,7 +1676,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/reports.py::handle",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_a0ebb8db3cb33a2c555f","performance_model_version": 3,@@ -1690,11 +1690,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": false,"resource_fingerprints": [],"shared_path_suffix": [@@ -1724,6 +1724,90 @@}]},+ {+ "actionability_reason": "strategy_requires_validation",+ "actionability_state": "advisory",+ "affected_call_sites_total": 1,+ "affected_files_total": 1,+ "biomarker_type": "io_in_loop",+ "biomarker_types": [+ "io_in_loop"+ ],+ "boundary_kind": "network",+ "confidence": "high",+ "evidence": [+ {+ "biomarker_type": "io_in_loop",+ "file_path": "src/app/retry.py",+ "finding_id": "finding_0e8c0794491c7384f4c4",+ "function_name": "post_with_retry",+ "line_end": 52,+ "line_start": 50,+ "path": [],+ "provenance": "direct",+ "reason": "retry_loop: io_in_loop at src/app/retry.py:50 repeats work per iteration."+ }+ ],+ "evidence_truncated": false,+ "execution_context": "production",+ "facets": {+ "actionability_confidence": "medium",+ "amplification": "per_iteration",+ "change_risk": "contained",+ "exposure": "unknown",+ "leverage": "isolated",+ "loop_magnitude": "bounded"+ },+ "fix": {+ "rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.",+ "safety": "advisory",+ "strategy": "batch_or_prefetch_io"+ },+ "intervention_kind": "function",+ "intervention_symbol": "src/app/retry.py::post_with_retry",+ "may_lead": false,+ "observations_total": 1,+ "opportunity_id": "perf3_bd36a05060a6d02a1245",+ "performance_model_version": 3,+ "prerequisites": [+ "batch_api_contract",+ "result_equivalence"+ ],+ "provenance": "direct",+ "rank_factors": {+ "affected_call_sites": 2,+ "boundary_kind": 4,+ "entry_reachability": 0,+ "execution_context": 3,+ "loop_magnitude": 0,+ "multiplier_shape": 4,+ "provenance": 3+ },+ "rank_score": 16,+ "reliable_entry_reachability": null,+ "resource_fingerprints": [],+ "shared_path_suffix": [],+ "siblings": [],+ "terminal_sink": null,+ "terminal_sinks": [],+ "why_ranked": [+ {+ "factor": "boundary_kind",+ "points": 4,+ "value": "network"+ },+ {+ "factor": "multiplier_shape",+ "points": 4,+ "value": "io_in_loop"+ },+ {+ "factor": "execution_context",+ "points": 3,+ "value": "production"+ }+ ]+ },{"actionability_reason": "strategy_requires_validation","actionability_state": "advisory",@@ -1768,7 +1852,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/billing.py::handle",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_debc1e358c095e5fd0d8","performance_model_version": 3,@@ -1782,11 +1866,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": false,"resource_fingerprints": [],"shared_path_suffix": [@@ -1853,7 +1937,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "src/app/clients.py::each_varying",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_0bf2ff36ef95d9cf96f2","performance_model_version": 3,@@ -1866,11 +1950,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -1932,7 +2016,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "src/app/fanout.py::gather_seq",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_350ba04f50fc0faf0d81","performance_model_version": 3,@@ -1945,11 +2029,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -2011,7 +2095,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "src/app/clients.py::each",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_c6604021414ce017f289","performance_model_version": 3,@@ -2024,11 +2108,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -2139,7 +2223,7 @@"fix": null,"intervention_kind": "shared_helper","intervention_symbol": "src/app/parse.py::_get_query",- "may_lead": true,+ "may_lead": false,"observations_total": 4,"opportunity_id": "perf3_a20111da61b63349e305","performance_model_version": 3,@@ -2150,11 +2234,11 @@"boundary_kind": 2,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2184,90 +2268,6 @@}]},- {- "actionability_reason": "strategy_requires_validation",- "actionability_state": "advisory",- "affected_call_sites_total": 1,- "affected_files_total": 1,- "biomarker_type": "io_in_loop",- "biomarker_types": [- "io_in_loop"- ],- "boundary_kind": "network",- "confidence": "high",- "evidence": [- {- "biomarker_type": "io_in_loop",- "file_path": "src/app/retry.py",- "finding_id": "finding_0e8c0794491c7384f4c4",- "function_name": "post_with_retry",- "line_end": 52,- "line_start": 50,- "path": [],- "provenance": "direct",- "reason": "retry_loop: io_in_loop at src/app/retry.py:50 repeats work per iteration."- }- ],- "evidence_truncated": false,- "execution_context": "production",- "facets": {- "actionability_confidence": "medium",- "amplification": "per_iteration",- "change_risk": "contained",- "exposure": "unknown",- "leverage": "isolated",- "loop_magnitude": "bounded"- },- "fix": {- "rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.",- "safety": "advisory",- "strategy": "batch_or_prefetch_io"- },- "intervention_kind": "function",- "intervention_symbol": "src/app/retry.py::post_with_retry",- "may_lead": true,- "observations_total": 1,- "opportunity_id": "perf3_bd36a05060a6d02a1245",- "performance_model_version": 3,- "prerequisites": [- "batch_api_contract",- "result_equivalence"- ],- "provenance": "direct",- "rank_factors": {- "affected_call_sites": 2,- "boundary_kind": 4,- "entry_reachability": 0,- "execution_context": 3,- "loop_magnitude": 0,- "multiplier_shape": 4,- "provenance": 3- },- "rank_score": 16,- "reliable_entry_reachability": null,- "resource_fingerprints": [],- "shared_path_suffix": [],- "siblings": [],- "terminal_sink": null,- "terminal_sinks": [],- "why_ranked": [- {- "factor": "boundary_kind",- "points": 4,- "value": "network"- },- {- "factor": "multiplier_shape",- "points": 4,- "value": "io_in_loop"- },- {- "factor": "execution_context",- "points": 3,- "value": "production"- }- ]- },{"actionability_reason": "strategy_requires_validation","actionability_state": "advisory",@@ -2312,7 +2312,7 @@},"intervention_kind": "function","intervention_symbol": "scripts/backfill.py::run",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_d5225971c0220c77ee7b","performance_model_version": 3,@@ -2326,11 +2326,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 2,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 16,+ "rank_score": 15,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2404,7 +2404,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/edge.py::run",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_dc2d9734ec9693504602","performance_model_version": 3,@@ -2418,11 +2418,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 2},- "rank_score": 16,+ "rank_score": 15,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2496,7 +2496,7 @@},"intervention_kind": "function","intervention_symbol": "tests/test_job.py::run",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_91d25fc7b3e4e8ad00c1","performance_model_version": 3,@@ -2510,11 +2510,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 1,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 15,+ "rank_score": 14,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2584,7 +2584,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "src/app/walker.py::index",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_9c136e77dd1c7e4e69bf","performance_model_version": 3,@@ -2595,11 +2595,11 @@"boundary_kind": 2,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 15,+ "rank_score": 14,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2669,7 +2669,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "src/app/walker.py::scan",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_9fea1c21a0c25dd7af23","performance_model_version": 3,@@ -2680,11 +2680,11 @@"boundary_kind": 2,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 15,+ "rank_score": 14,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2758,7 +2758,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/guess.py::run",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_b4b1621506e7231c520b","performance_model_version": 3,@@ -2773,11 +2773,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 0},- "rank_score": 14,+ "rank_score": 13,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [@@ -2844,7 +2844,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "bootstrap.py::main",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_b328704ea27ecd3de70a","performance_model_version": 3,@@ -2855,11 +2855,11 @@"boundary_kind": 2,"entry_reachability": 0,"execution_context": 1,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 13,+ "rank_score": 12,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -2921,7 +2921,7 @@"fix": null,"intervention_kind": "function","intervention_symbol": "docs/snippets/walk.py::demo",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_b3b3f1bd1707d53f5d6e","performance_model_version": 3,@@ -2932,11 +2932,11 @@"boundary_kind": 2,"entry_reachability": 0,"execution_context": 1,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 13,+ "rank_score": 12,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -3002,7 +3002,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/filters.py::select",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_68f6614ac285d1e8cb4a","performance_model_version": 3,@@ -3016,11 +3016,11 @@"boundary_kind": 0,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 3,"provenance": 3},- "rank_score": 12,+ "rank_score": 11,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],@@ -3086,7 +3086,7 @@},"intervention_kind": "function","intervention_symbol": "src/app/render.py::to_csv",- "may_lead": true,+ "may_lead": false,"observations_total": 1,"opportunity_id": "perf3_ea095ac8d3d612777176","performance_model_version": 3,@@ -3099,11 +3099,11 @@"boundary_kind": 0,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 3,"provenance": 3},- "rank_score": 12,+ "rank_score": 11,"reliable_entry_reachability": null,"resource_fingerprints": [],"shared_path_suffix": [],diff --git a/tests/fixtures/perf_corpus/golden_plans.json b/tests/fixtures/perf_corpus/golden_plans.jsonindex 0cc1204d2..d16ce5ca1 100644--- a/tests/fixtures/perf_corpus/golden_plans.json+++ b/tests/fixtures/perf_corpus/golden_plans.json@@ -25,11 +25,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 6,"provenance": 3},- "rank_score": 24,+ "rank_score": 23,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": true},@@ -130,11 +130,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 22,+ "rank_score": 21,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": true},@@ -245,11 +245,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 21,+ "rank_score": 20,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": true},@@ -351,11 +351,11 @@"boundary_kind": 4,"entry_reachability": 3,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 21,+ "rank_score": 20,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": true},@@ -458,11 +458,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 6,"provenance": 3},- "rank_score": 20,+ "rank_score": 19,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -635,11 +635,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 18,+ "rank_score": 17,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -741,11 +741,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 5,"provenance": 3},- "rank_score": 18,+ "rank_score": 17,"rationale": "I/O under the lock is proven, but shared-state ordering must be validated before moving it.","reliable_entry_reachability": null},@@ -818,11 +818,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "Iterations are independent and each await already runs under self._sem.","reliable_entry_reachability": null},@@ -889,11 +889,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "Every call filters on the loop's own key, so .in_(\"repo_id\", keys) is the bulk form; the per-key call limits, orders or shares the loop with other I/O.","reliable_entry_reachability": null},@@ -960,11 +960,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "Iteration independence is proven; the concurrency the fan-out would create is not bounded by anything this group can see.","reliable_entry_reachability": null},@@ -1031,11 +1031,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -1116,11 +1116,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -1199,11 +1199,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The relationship is declared lazy and the query that produced the rows does not load it; whether every iteration reaches the access, and whether another layer loads it first, is not proven.","reliable_entry_reachability": null},@@ -1261,11 +1261,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The relationship is declared lazy and the query that produced the rows does not load it; whether every iteration reaches the access, and whether another layer loads it first, is not proven.","reliable_entry_reachability": null},@@ -1323,11 +1323,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": false},@@ -1408,11 +1408,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": false},@@ -1474,7 +1474,7 @@"call_sites": 1,"file_count": 1,"files": [- "src/app/billing.py"+ "src/app/retry.py"]},"confidence": "medium",@@ -1484,82 +1484,68 @@"biomarker_types": ["io_in_loop"],- "boundary_kind": "db",+ "boundary_kind": "network","execution_context": "production","observations_total": 1,- "provenance": "call-site",+ "provenance": "direct","rank_factors": {"affected_call_sites": 2,"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 17,+ "rank_score": 16,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.",- "reliable_entry_reachability": false+ "reliable_entry_reachability": null},- "file_path": "src/app/billing.py",+ "file_path": "src/app/retry.py","impact_delta": 0.0,- "line_end": 13,- "line_start": 11,+ "line_end": 52,+ "line_start": 50,"plan": {"affected_locations": [{- "call": "get_session",- "file_path": "src/app/billing.py",- "function_name": "handle",- "line_end": 13,- "line_start": 11+ "file_path": "src/app/retry.py",+ "function_name": "post_with_retry",+ "line_end": 52,+ "line_start": 50}],"affected_locations_total": 1,"api": null,"evidence_truncated": false,- "intervention_symbol": "src/app/billing.py::handle",- "judgment_steps": 2,+ "intervention_symbol": "src/app/retry.py::post_with_retry",+ "judgment_steps": 1,"mechanical_steps": 0,- "opportunity_id": "perf3_debc1e358c095e5fd0d8",- "paths": [- [- "src/app/billing.py::handle",- "src/app/db.py::get_session"- ]- ],+ "opportunity_id": "perf3_bd36a05060a6d02a1245",+ "paths": [],"paths_total": 1,"safety": "advisory","steps": [{- "action": "Add a form of get_session that takes every key at once",+ "action": "Collect the keys before the loop and replace the per-key call with one batched call","applicability": "judgment",- "file_path": "src/app/db.py",- "line": null,+ "file_path": "src/app/retry.py",+ "line": 50,"order": 1,- "symbol": "src/app/db.py::get_session"- },- {- "action": "Collect the keys before the loop and replace the per-key get_session call with one batched call",- "applicability": "judgment",- "file_path": "src/app/billing.py",- "line": 11,- "order": 2,- "symbol": "handle"+ "symbol": "post_with_retry"}],"strategy": "batch_or_prefetch_io"},"refactoring_type": "performance_fix","source_biomarker": "io_in_loop",- "target_symbol": "src/app/billing.py::handle"+ "target_symbol": "src/app/retry.py::post_with_retry"},{"blast_radius": {"call_sites": 1,"file_count": 1,"files": [- "src/app/retry.py"+ "src/app/billing.py"]},"confidence": "medium",@@ -1569,10 +1555,10 @@"biomarker_types": ["io_in_loop"],- "boundary_kind": "network",+ "boundary_kind": "db","execution_context": "production","observations_total": 1,- "provenance": "direct",+ "provenance": "call-site","rank_factors": {"affected_call_sites": 2,"boundary_kind": 4,@@ -1584,46 +1570,60 @@},"rank_score": 16,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.",- "reliable_entry_reachability": null+ "reliable_entry_reachability": false},- "file_path": "src/app/retry.py",+ "file_path": "src/app/billing.py","impact_delta": 0.0,- "line_end": 52,- "line_start": 50,+ "line_end": 13,+ "line_start": 11,"plan": {"affected_locations": [{- "file_path": "src/app/retry.py",- "function_name": "post_with_retry",- "line_end": 52,- "line_start": 50+ "call": "get_session",+ "file_path": "src/app/billing.py",+ "function_name": "handle",+ "line_end": 13,+ "line_start": 11}],"affected_locations_total": 1,"api": null,"evidence_truncated": false,- "intervention_symbol": "src/app/retry.py::post_with_retry",- "judgment_steps": 1,+ "intervention_symbol": "src/app/billing.py::handle",+ "judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf3_bd36a05060a6d02a1245",- "paths": [],+ "opportunity_id": "perf3_debc1e358c095e5fd0d8",+ "paths": [+ [+ "src/app/billing.py::handle",+ "src/app/db.py::get_session"+ ]+ ],"paths_total": 1,"safety": "advisory","steps": [{- "action": "Collect the keys before the loop and replace the per-key call with one batched call",+ "action": "Add a form of get_session that takes every key at once","applicability": "judgment",- "file_path": "src/app/retry.py",- "line": 50,+ "file_path": "src/app/db.py",+ "line": null,"order": 1,- "symbol": "post_with_retry"+ "symbol": "src/app/db.py::get_session"+ },+ {+ "action": "Collect the keys before the loop and replace the per-key get_session call with one batched call",+ "applicability": "judgment",+ "file_path": "src/app/billing.py",+ "line": 11,+ "order": 2,+ "symbol": "handle"}],"strategy": "batch_or_prefetch_io"},"refactoring_type": "performance_fix","source_biomarker": "io_in_loop",- "target_symbol": "src/app/retry.py::post_with_retry"+ "target_symbol": "src/app/billing.py::handle"},{"blast_radius": {@@ -1649,11 +1649,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 2,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 3},- "rank_score": 16,+ "rank_score": 15,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -1734,11 +1734,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 2},- "rank_score": 16,+ "rank_score": 15,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -1819,11 +1819,11 @@"boundary_kind": 4,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 4,"provenance": 0},- "rank_score": 14,+ "rank_score": 13,"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.","reliable_entry_reachability": null},@@ -1904,11 +1904,11 @@"boundary_kind": 0,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 3,"provenance": 3},- "rank_score": 12,+ "rank_score": 11,"rationale": "The collection is proven list-backed; element hashability and ordering/identity use still require validation.","reliable_entry_reachability": null},@@ -1975,11 +1975,11 @@"boundary_kind": 0,"entry_reachability": 0,"execution_context": 3,- "loop_magnitude": 1,+ "loop_magnitude": 0,"multiplier_shape": 3,"provenance": 3},- "rank_score": 12,+ "rank_score": 11,"rationale": "Repeated string accumulation is proven; intermediate accumulator observations still require validation.","reliable_entry_reachability": null},diff --git a/tests/unit/health/test_fix_first_precision.py b/tests/unit/health/test_fix_first_precision.pyindex 07910d084..8b6f31760 100644--- a/tests/unit/health/test_fix_first_precision.py+++ b/tests/unit/health/test_fix_first_precision.py@@ -334,12 +334,13 @@ def test_only_a_loop_known_to_grow_leads() -> None:def test_an_unknown_loop_no_entry_reaches_drops_a_step() -> None:- assert _value(loop_magnitude="unknown", exposure="not_entry_reachable") == "1"- assert _value(loop_magnitude="unknown") == "1"+ assert _value(loop_magnitude="unknown", exposure="not_entry_reachable") == "0"+ assert _value(loop_magnitude="unknown") == "0"-def test_reach_or_a_known_loop_keeps_the_step() -> None:- assert _value(loop_magnitude="unknown", exposure="entry_reachable") == "2"+def test_reach_keeps_an_unknown_loop_a_step_below_a_known_one() -> None:+ # An unproven cost never earns the value a loop known to grow does.+ assert _value(loop_magnitude="unknown", exposure="entry_reachable") == "1"assert _value(loop_magnitude="grows_with_data", exposure="not_entry_reachable") == "2"diff --git a/tests/unit/health/test_perf_cold_paths.py b/tests/unit/health/test_perf_cold_paths.pyindex a439f9a37..41aa03c3b 100644--- a/tests/unit/health/test_perf_cold_paths.py+++ b/tests/unit/health/test_perf_cold_paths.py@@ -24,7 +24,12 @@ def _finding(path: str, function: str) -> HealthFindingData:function_name=function,line_start=10,line_end=10,- details={"boundary_kind": "db", "cross_function": False, "path": []},+ details={+ "boundary_kind": "db",+ "cross_function": False,+ "path": [],+ "loop_magnitude": "grows_with_data",+ },health_impact=0.0,dimension="performance",)diff --git a/tests/unit/health/test_perf_corpus_golden.py b/tests/unit/health/test_perf_corpus_golden.pyindex 712557211..81230d532 100644--- a/tests/unit/health/test_perf_corpus_golden.py+++ b/tests/unit/health/test_perf_corpus_golden.py@@ -319,4 +319,6 @@ def test_a_lazy_load_leads_only_where_its_orm_cleared_the_bar() -> None:item.evidence[0]["file_path"]: item.may_leadfor item in build_performance_opportunities(rows_for("lazy_load_by_orm"))}- assert by_orm == {"app/issues/views.py": True, "app/incidents/service.py": False}+ # Neither loop is measured to grow, so neither leads whatever its ORM;+ # the ORM gate over a growing loop is covered in test_perf_opportunities.+ assert by_orm == {"app/issues/views.py": False, "app/incidents/service.py": False}diff --git a/tests/unit/health/test_perf_opportunities.py b/tests/unit/health/test_perf_opportunities.pyindex 951c4c51f..5b6499bd2 100644--- a/tests/unit/health/test_perf_opportunities.py+++ b/tests/unit/health/test_perf_opportunities.py@@ -556,13 +556,28 @@ def test_a_plan_lists_its_edits_and_marks_only_proven_ones_mechanical():)def test_a_lazy_load_may_lead_only_on_an_orm_that_cleared_the_bar(orms, leads):rows = [- _finding("app/views.py", 10 + index, marker="lazy_load_in_loop", orm=orm)+ _finding(+ "app/views.py",+ 10 + index,+ marker="lazy_load_in_loop",+ orm=orm,+ loop_magnitude="grows_with_data",+ )for index, orm in enumerate(orms)](opportunity,) = build_performance_opportunities(rows)assert opportunity.may_lead is leads-def test_every_other_marker_may_lead():- (opportunity,) = build_performance_opportunities([_finding("a.py", 1)])+def test_every_other_marker_may_lead_over_a_loop_that_grows():+ (opportunity,) = build_performance_opportunities(+ [_finding("a.py", 1, loop_magnitude="grows_with_data")]+ )assert opportunity.may_lead is True++[email protected]("magnitude", [None, "bounded"])+def test_a_loop_not_known_to_grow_never_leads(magnitude):+ details = {"loop_magnitude": magnitude} if magnitude else {}+ (opportunity,) = build_performance_opportunities([_finding("a.py", 1, **details)])+ assert opportunity.may_lead is Falsediff --git a/tests/unit/health/test_perf_serving.py b/tests/unit/health/test_perf_serving.pyindex 36269924f..adf32a0f8 100644--- a/tests/unit/health/test_perf_serving.py+++ b/tests/unit/health/test_perf_serving.py@@ -99,9 +99,9 @@ def test_summary_payload_names_absence_and_staleness() -> None:def test_rescope_summary_recounts_one_context() -> None:groups = [- ("production", None, "high", "advisory", "available", 2),- ("production", "db", "low", "plan_ready", "no_safe_plan", 1),- ("test", "db", "low", "advisory", "available", 5),+ ("production", None, "high", "advisory", "available", "proven", 2),+ ("production", "db", "low", "plan_ready", "no_safe_plan", "unproven", 1),+ ("test", "db", "low", "advisory", "available", "proven", 5),]scoped = rescope_summary({"total": 8, "x": 1}, groups, frozenset({"production"}))assert scoped == {@@ -110,6 +110,7 @@ def test_rescope_summary_recounts_one_context() -> None:"actionability": {"advisory": 2, "plan_ready": 1},"context": {"production": 3},"boundary": {"none": 2, "db": 1},+ "proof": {"proven": 2, "unproven": 1},"with_plan_total": 2,}@@ -121,26 +122,27 @@ def test_rescope_summary_recounts_one_context() -> None:_SEEDS: list[dict[str, Any]] = [{"execution_context": "production", "boundary_kind": "db", "evidence_confidence": "high","actionability_state": "plan_ready", "plan_state": "available", "file_path": "a.py",- "affected_call_sites_total": 4, "observations_total": 9},+ "affected_call_sites_total": 4, "observations_total": 9, "cost_proof": "proven"},{"execution_context": "production", "boundary_kind": None, "evidence_confidence": "medium","actionability_state": "advisory", "plan_state": "no_safe_plan", "file_path": "b.py",- "affected_call_sites_total": 4, "observations_total": 2},+ "affected_call_sites_total": 4, "observations_total": 2, "cost_proof": "unproven"},{"execution_context": "test", "boundary_kind": "network", "evidence_confidence": "low","actionability_state": "advisory", "plan_state": "not_persisted", "file_path": "a.py",- "affected_call_sites_total": 7, "observations_total": 2},+ "affected_call_sites_total": 7, "observations_total": 2, "cost_proof": "proven"},{"execution_context": "tooling", "boundary_kind": None, "evidence_confidence": "high","actionability_state": "expected", "plan_state": "no_safe_plan", "file_path": "c.py",- "affected_call_sites_total": 1, "observations_total": 9},+ "affected_call_sites_total": 1, "observations_total": 9, "cost_proof": "unproven"},{"execution_context": "production", "boundary_kind": "db", "evidence_confidence": "high","actionability_state": "investigate", "plan_state": "no_safe_plan", "file_path": "c.py",- "affected_call_sites_total": 0, "observations_total": 5},+ "affected_call_sites_total": 0, "observations_total": 5, "cost_proof": "proven"},{"execution_context": "unknown", "boundary_kind": "filesystem", "evidence_confidence": "medium","actionability_state": "plan_ready", "plan_state": "available", "file_path": "b.py",- "affected_call_sites_total": 7, "observations_total": 1},+ "affected_call_sites_total": 7, "observations_total": 1, "cost_proof": "proven"},# Resolved: in no queue and no facet.{"execution_context": "production", "boundary_kind": "db", "evidence_confidence": "high","actionability_state": "plan_ready", "plan_state": "available", "file_path": "a.py",- "affected_call_sites_total": 99, "observations_total": 99, "status": "resolved"},+ "affected_call_sites_total": 99, "observations_total": 99, "status": "resolved",+ "cost_proof": "proven"},]_QUERIES: list[dict[str, Any]] = [@@ -154,6 +156,8 @@ _QUERIES: list[dict[str, Any]] = [{"context": "all", "file_paths": ("a.py", "b.py")},{"context": "all", "file_paths": ()},{"boundary": "network"},+ {"proof": "unproven"},+ {"context": "all", "proof": "unproven", "actionability": "expected"},]@@ -226,6 +230,7 @@ async def test_keep_and_sort_agree_with_the_store(store, args, sort) -> None:boundary=query.boundary,confidence=query.confidence,actionabilities=query.actionabilities,+ proofs=query.proofs,file_paths=query.file_paths,sort=query.sort,limit=query.limit,@@ -240,7 +245,7 @@ async def test_keep_and_sort_agree_with_the_store(store, args, sort) -> None:def _reference_facets(groups: list[tuple], query: PerformanceQuery) -> dict[str, Any]:"""The cross-filtered fold as the service wrote it before the rules were data."""dimensions = {"context": 0, "boundary": 1, "confidence": 2, "actionability": 3,- "plan_state": 4}+ "plan_state": 4, "proof": 5}selected = {"context": query.contexts,"boundary": None if query.boundary is None else frozenset({query.boundary}),@@ -249,6 +254,7 @@ def _reference_facets(groups: list[tuple], query: PerformanceQuery) -> dict[str,None if query.actionability is None else frozenset({query.actionability})),"plan_state": None,+ "proof": None if query.proof is None else frozenset({query.proof}),}facets = {}for name, index in dimensions.items():@@ -260,7 +266,7 @@ def _reference_facets(groups: list[tuple], query: PerformanceQuery) -> dict[str,for other, values in selected.items()):continue- counts[row[index] or "none"] = counts.get(row[index] or "none", 0) + row[5]+ counts[row[index] or "none"] = counts.get(row[index] or "none", 0) + row[6]facets[name] = [{"value": v, "total": t}for v, t in sorted(counts.items(), key=lambda item: (-item[1], item[0]))diff --git a/tests/unit/health/test_worth.py b/tests/unit/health/test_worth.pyindex cce42f560..f356fe6e4 100644--- a/tests/unit/health/test_worth.py+++ b/tests/unit/health/test_worth.py@@ -195,6 +195,11 @@ def test_a_perf_cause_leads_only_on_a_loop_that_grows(context, facets, expected)("blocking_sync_in_async", {}, "unreached_call"),("goroutine_in_unbounded_loop", {}, None),("sql_cartesian_join", {"loop_magnitude": "unknown"}, None),+ ("unbounded_read_reduced_in_memory", {"exposure": "entry_reachable"}, None),+ ("unbounded_read_reduced_in_memory", {"loop_magnitude": "n/a"}, "unreached_call"),+ # A marker with no loop is judged per call, never as an unmeasured loop.+ ("some_new_marker", {"loop_magnitude": "n/a", "exposure": "entry_reachable"}, None),+ ("some_new_marker", {"loop_magnitude": "n/a"}, "unreached_call"),],)def test_a_perf_cause_is_judged_by_its_kind(marker, facets, expected) -> None:@@ -203,3 +208,50 @@ def test_a_perf_cause_is_judged_by_its_kind(marker, facets, expected) -> None:row = {"execution_context": "production", "biomarker_type": marker,"details": {"facets": facets}}assert perf_low_priority(row) == expected+++ ("marker", "facets", "proof"),+ [+ ("io_in_loop", {"loop_magnitude": "unknown"}, "unproven"),+ ("io_in_loop", {}, "unproven"),+ ("io_in_loop", {"loop_magnitude": "bounded"}, "proven"),+ ("io_in_loop", {"loop_magnitude": "grows_with_data"}, "proven"),+ ("hot_path_sync_io", {"exposure": "not_entry_reachable"}, "proven"),+ ("sql_cartesian_join", {}, "proven"),+ ("unbounded_read_reduced_in_memory", {"loop_magnitude": "n/a"}, "proven"),+ ("some_new_marker", {"loop_magnitude": "n/a"}, "proven"),+ ],+)+def test_only_an_unmeasured_loop_is_unproven(marker, facets, proof) -> None:+ from repowise.core.analysis.health.perf.opportunity_rank import default_queue_exclusion+ from repowise.core.analysis.health.worth import cost_proof++ row = {"execution_context": "production", "actionability_state": "advisory",+ "biomarker_type": marker, "details": {"facets": facets}}+ assert cost_proof(row) == proof+ # The default queue leaves an unproven cause out under the shared reason.+ assert default_queue_exclusion(row) == ("unmeasured_cost" if proof == "unproven" else None)+++def test_an_unknown_loop_ranks_no_higher_than_a_bounded_one() -> None:+ from repowise.core.analysis.health.perf.opportunity_rank import MAGNITUDE_POINTS++ assert MAGNITUDE_POINTS["unknown"] <= MAGNITUDE_POINTS["bounded"]+ assert MAGNITUDE_POINTS["unknown"] < MAGNITUDE_POINTS["grows_with_data"]+++def test_the_default_queue_counts_an_unproven_cause_and_still_adds_up() -> None:+ from repowise.core.analysis.health.perf.opportunity_rank import default_queue_counts++ def row(context: str, magnitude: str) -> dict:+ return {"execution_context": context, "actionability_state": "advisory",+ "biomarker_type": "io_in_loop",+ "details": {"facets": {"loop_magnitude": magnitude}}}++ rows = [row("production", "grows_with_data"), row("production", "unknown"),+ row("test", "unknown")]+ counts = default_queue_counts(rows)+ assert counts["total"] == 1+ assert counts["excluded"]["unmeasured_cost"] == 1 and counts["excluded"]["test"] == 1+ assert counts["total"] + sum(counts["excluded"].values()) == len(rows)diff --git a/tests/unit/persistence/test_performance_materialization.py b/tests/unit/persistence/test_performance_materialization.pyindex 73c11ed53..6dfa5393b 100644--- a/tests/unit/persistence/test_performance_materialization.py+++ b/tests/unit/persistence/test_performance_materialization.py@@ -49,6 +49,7 @@ def _finding(path: str, line: int, *, marker: str = "serial_await_in_loop", **de"path": [node.format(caller=path) for node in _SHARED],"resolution_basis": "call-site","dataflow_verified": True,+ "loop_magnitude": "grows_with_data",**details,},health_impact=0.0,@@ -94,6 +95,7 @@ async def test_one_pass_materializes_the_queue_its_plans_and_its_headline(assert row.plan_state == "available"assert row.performance_model_version == PERFORMANCE_MODEL_VERSIONassert row.analyzed_commit == "b" * 40+ assert row.cost_proof == "proven"# Filter and order live in columns; the rest stays in the open payload, and# nothing appears in both.@@ -384,8 +386,23 @@ def test_a_non_leading_marker_never_leads_the_summary():terminal_sink=None, evidence=[{"file_path": "a.py"}], observations_total=1,affected_call_sites_total=1, affected_files_total=1, why_ranked=[],prerequisites=(), actionability_reason="", may_lead=may_lead,+ facets={"loop_magnitude": "grows_with_data"},)ranked = [_opp("lazy", "lazy_load_in_loop", False), _opp("io", "io_in_loop", True)]assert _summary_payload(ranked, {})["lead"]["opportunity_id"] == "io"assert _summary_payload(ranked[:1], {})["lead"] is None+++async def test_an_unmeasured_loop_is_stored_unproven_and_never_leads(async_session) -> None:+ repo = await insert_repo(async_session)+ await _write(async_session, repo.id, [_finding("src/a.py", 10, loop_magnitude="unknown")])++ (row,) = await _rows(async_session, repo.id)+ assert row.cost_proof == "unproven"+ assert json.loads(row.details_json)["may_lead"] is False+ summary = json.loads((await crud.get_performance_summary(async_session, repo.id)).summary_json)+ assert summary["lead"] is None+ assert summary["default_queue"]["total"] == 0+ assert summary["default_queue"]["excluded"]["unmeasured_cost"] == 1diff --git a/tests/unit/server/mcp/test_perf_rank.py b/tests/unit/server/mcp/test_perf_rank.pyindex f244d532c..2a5cd32f0 100644--- a/tests/unit/server/mcp/test_perf_rank.py+++ b/tests/unit/server/mcp/test_perf_rank.py@@ -296,6 +296,7 @@ async def test_narrow_projection_leads_with_one_shared_causal_opportunity("cross_function": True,"path": [f"{caller}::run", "src/shared.py::load", "src/db.py::fetch"],"resolution_basis": "call-site",+ "loop_magnitude": "grows_with_data",}),health_impact=0.0,diff --git a/tests/unit/server/mcp/test_performance_levels.py b/tests/unit/server/mcp/test_performance_levels.pyindex d39a17392..9ddc5acc6 100644--- a/tests/unit/server/mcp/test_performance_levels.py+++ b/tests/unit/server/mcp/test_performance_levels.py@@ -37,6 +37,7 @@ def _row(repo_id: str, caller: str, line: int) -> HealthFinding:"cross_function": True,"path": [f"{caller}::run", "src/shared.py::load", "src/db.py::fetch"],"resolution_basis": "call-site",+ "loop_magnitude": "grows_with_data","dataflow_verified": True,}),@@ -51,8 +52,9 @@ def _row(repo_id: str, caller: str, line: int) -> HealthFinding:async def materialized(session, health_data: str) -> str:"""Five callers behind one shared helper, plus the base fixture's own row.- The fixture contributes a second production cause, which is why the totals- below are two rather than one.+ The fixture contributes a second production cause whose loop nobody+ measured, so the default queue holds one and counts the other as+ ``unmeasured_cost``."""for index, caller in enumerate(_CALLERS, start=10):session.add(_row(health_data, caller, index))@@ -142,7 +144,7 @@ async def test_the_queue_filters_before_it_caps(setup_mcp, materialized):performance_context="production",performance_boundary="db",)- assert result["performance_opportunities_total"] == 2+ assert result["performance_opportunities_total"] == 1assert {item["execution_context"] for item in result["performance_opportunities"]} == {"production"}@@ -187,6 +189,7 @@ async def test_performance_actionability_threads_through_and_defaults_off_expect"cross_function": True,"path": ["src/fs.py::run", "src/fs.py::read"],"resolution_basis": "reliable-edge",+ "loop_magnitude": "grows_with_data",}),health_impact=0.0,@@ -227,7 +230,7 @@ async def test_an_unrecognized_filter_value_is_named_not_silently_empty(only=["performance_opportunities"],performance_context="staging",)- assert result["performance_opportunities_total"] == 2+ assert result["performance_opportunities_total"] == 1assert result["ignored_arguments"] == {"performance_context": "staging (accepted: production, tooling, test, unknown, all)"}diff --git a/tests/unit/server/test_performance_opportunities.py b/tests/unit/server/test_performance_opportunities.pyindex f49e0728a..0e7c72fd2 100644--- a/tests/unit/server/test_performance_opportunities.py+++ b/tests/unit/server/test_performance_opportunities.py@@ -18,7 +18,15 @@ from repowise.core.persistence.models import PerformanceOpportunityfrom tests.unit.server.conftest import create_test_repo-def _finding(path: str, line: int, path_nodes: list[str], *, marker: str = "io_in_loop"):+def _finding(+ path: str,+ line: int,+ path_nodes: list[str],+ *,+ marker: str = "io_in_loop",+ magnitude: str | None = "grows_with_data",+):+ """A queue mechanics fixture: its loop is measured to grow unless told otherwise."""return HealthFindingData(biomarker_type=marker,severity=Severity.MEDIUM,@@ -31,6 +39,7 @@ def _finding(path: str, line: int, path_nodes: list[str], *, marker: str = "io_i"cross_function": True,"path": path_nodes,"resolution_basis": "reliable-edge",+ **({"loop_magnitude": magnitude} if magnitude else {}),},health_impact=0.0,reason="Database work repeats for every loop iteration.",@@ -260,6 +269,7 @@ def _filesystem_finding(path: str, line: int, path_nodes: list[str]) -> HealthFi"cross_function": True,"path": path_nodes,"resolution_basis": "reliable-edge",+ "loop_magnitude": "grows_with_data",},health_impact=0.0,reason="A file is read for every loop iteration.",@@ -306,15 +316,17 @@ async def test_the_default_queue_reports_what_it_leaves_out(app, client: AsyncClfunction_name="each",line_start=5,line_end=5,- details={"boundary_kind": "network"},+ details={"boundary_kind": "network", "loop_magnitude": "grows_with_data"},health_impact=0.0,reason="A client is built for every loop iteration.",dimension="performance",)+ unmeasured = _finding("src/d.py", 50, ["src/d.py::run", "src/db.py::fetch"], magnitude=None)findings = [*_findings(),no_strategy,_filesystem_finding("src/fs.py", 1, ["src/fs.py::run", "src/fs.py::read"]),+ unmeasured,]repo_id, _ = await _seed(app, client, findings)@@ -330,10 +342,17 @@ async def test_the_default_queue_reports_what_it_leaves_out(app, client: AsyncCl"cold_path": 0,"expected": 1,"no_strategy": 1,+ "unmeasured_cost": 1,},}+ proof = {entry["value"]: entry["total"] for entry in default["facets"]["proof"]}+ assert proof["unproven"] >= 1asked = await _page(client, repo_id, actionability="investigate")assert [item["intervention_symbol"] for item in asked["items"]] == ["src/clients.py::each"]+ # Left out of the default queue, listed under its own filter, never leading.+ unproven = await _page(client, repo_id, proof="unproven")+ assert [item["file_path"] for item in unproven["items"]] == ["src/d.py"]+ assert unproven["items"][0]["may_lead"] is Falseasync def test_an_expected_row_never_leads(app, client: AsyncClient) -> None:diff --git a/tests/unit/server/test_wire_vocabulary_parity.py b/tests/unit/server/test_wire_vocabulary_parity.pyindex 1e3d1696f..7bdb2fa18 100644--- a/tests/unit/server/test_wire_vocabulary_parity.py+++ b/tests/unit/server/test_wire_vocabulary_parity.py@@ -121,6 +121,12 @@ def test_performance_queue_exclusions_match_python() -> None:assert _union_members("PerformanceQueueExclusion", "health.ts") == set(DEFAULT_QUEUE_EXCLUSIONS)+def test_performance_cost_proofs_match_python() -> None:+ from repowise.core.analysis.health.worth import COST_PROOFS++ assert _union_members("PerformanceCostProof", "health.ts") == set(COST_PROOFS)++def test_agent_prompt_flavors_match_python() -> None:from repowise.core.agent_prompts import FLAVORS