Skip to content

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

fix(health): keep migrations, startup, shutdown and recovery out of the perf queue (#3258)

Raghav Chamadiya20faeaa3bc05
diff --git a/docs/architecture/code-health.md b/docs/architecture/code-health.md
index d35c9463f..2b9d739d4 100644
--- a/docs/architecture/code-health.md
+++ b/docs/architecture/code-health.md
@@ -719,7 +719,11 @@ through, or `<file>::__module__` for top-level code. Sinks, call sites and
same-family co-signals (`io_in_loop` with `nested_loop_with_io`) are members. Two
loops in one function are one site, because findings carry the sink's line. Each
carries one `actionability` state (`plan_ready`, `advisory`, `investigate`,
-`expected`). The default queue holds production `plan_ready` and `advisory`, ranked
+`expected`). A group every member's name or file stem marks as a migration,
+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 identity
+kernel'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`.
diff --git a/docs/layers/CODE_HEALTH.md b/docs/layers/CODE_HEALTH.md
index 2283bd1c1..fd4461071 100644
--- a/docs/layers/CODE_HEALTH.md
+++ b/docs/layers/CODE_HEALTH.md
@@ -246,10 +246,12 @@ Findings group into **opportunities**, one per place you would edit (the functio
holding the loop, or a helper every caller goes through). Each opportunity carries
one state: `plan_ready` (a proven fix strategy), `advisory` (a strategy with
unproven prerequisites), `investigate` (no supported strategy) or `expected` (the
-repetition is real and nothing should change, such as deleting N files, or the
-function that holds it is switched off by a constant flag, reason `gated_off`). 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.
+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 is
+named for a migration, startup, shutdown or crash recovery and so runs once per
+deploy, 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.
Performance analysis covers Python, TypeScript/JavaScript (including Vue and Svelte
scripts), Java, Go, C# (including Razor), Rust, Kotlin, Scala, Ruby, C++, Dart and
diff --git a/packages/core/src/repowise/core/analysis/change_health/service.py b/packages/core/src/repowise/core/analysis/change_health/service.py
index eaa42ba6b..85e573035 100644
--- a/packages/core/src/repowise/core/analysis/change_health/service.py
+++ b/packages/core/src/repowise/core/analysis/change_health/service.py
@@ -488,6 +488,7 @@ _EXPECTED_TEXT: dict[str | None, str] = {
"inherent_to_boundary": _INHERENT,
"loop_already_chunked": _INHERENT,
"gated_off": "Nothing to change while a constant-False flag switches this function off.",
+ "cold_path": "Runs once per deploy, boot or incident; not worth scheduling.",
None: _INHERENT,
}
diff --git a/packages/core/src/repowise/core/analysis/health/fix_first/model.py b/packages/core/src/repowise/core/analysis/health/fix_first/model.py
index ae59daa3a..cfbe532e4 100644
--- a/packages/core/src/repowise/core/analysis/health/fix_first/model.py
+++ b/packages/core/src/repowise/core/analysis/health/fix_first/model.py
@@ -54,6 +54,7 @@ FixExclusion = Literal[
"docs_example",
"deprecated",
"gated_off",
+ "cold_path",
"unreachable",
"inherent_dispatch",
"small_function",
diff --git a/packages/core/src/repowise/core/analysis/health/perf/actionability.py b/packages/core/src/repowise/core/analysis/health/perf/actionability.py
index 8054a3530..41e19b3dc 100644
--- a/packages/core/src/repowise/core/analysis/health/perf/actionability.py
+++ b/packages/core/src/repowise/core/analysis/health/perf/actionability.py
@@ -21,17 +21,19 @@ from dataclasses import dataclass, replace
from typing import Any, Literal
from ..worth import dormant
+from .cold_paths import is_cold_path
FixSafety = Literal["proven", "advisory"]
OpportunityConfidence = Literal["high", "medium", "low"]
# ``expected``: the repetition is real and there is nothing to change, either
# by its nature or for a reason :func:`expected_reason` reads off the group
-# (``gated_off``: a constant-false flag switches the function off).
+# (``gated_off``: a constant-false flag switches the function off;
+# ``cold_path``: it runs once per deploy, boot or incident).
ActionabilityState = Literal["plan_ready", "advisory", "investigate", "expected"]
#: Reasons :func:`expected_reason` gives, in precedence order. The default
#: queue counts each under its own name rather than as ``expected``.
-EXPECTED_REASONS: tuple[str, ...] = ("gated_off",)
+EXPECTED_REASONS: tuple[str, ...] = ("gated_off", "cold_path")
# Refusals that are facts about the code, not missing proofs: nothing to investigate.
_EXPECTED_REFUSALS = frozenset({"inherent_to_boundary", "loop_already_chunked"})
@@ -293,10 +295,17 @@ def expected_reason(members: Sequence[Any]) -> str | None:
"""Why a group needs no change whatever its strategy, or ``None``.
``gated_off``: every member sits in a function a constant-false flag in
- its own file switches off. Reasons are checked in precedence order.
+ its own file switches off. ``cold_path``: every loop owner is named for a
+ migration, startup, shutdown or crash recovery (:mod:`.cold_paths`), so it
+ runs once per deploy, boot or incident. Reasons are checked in precedence
+ order.
"""
- if members and all(dormant(facts.details) for facts in members):
+ if not members:
+ return None
+ if all(dormant(facts.details) for facts in members):
return "gated_off"
+ if all(is_cold_path(facts.file_path, facts.function_name) for facts in members):
+ return "cold_path"
return None
diff --git a/packages/core/src/repowise/core/analysis/health/perf/cold_paths.py b/packages/core/src/repowise/core/analysis/health/perf/cold_paths.py
new file mode 100644
index 000000000..f63f0602a
--- /dev/null
+++ b/packages/core/src/repowise/core/analysis/health/perf/cold_paths.py
@@ -0,0 +1,91 @@
+"""Code that runs once per deploy, boot or incident, read off its name.
+
+A loop in a schema migration, a startup or shutdown step, or crash recovery
+repeats for real, but nobody waits on it per request, so batching it is not
+work to schedule. :func:`~.actionability.expected_reason` makes a group whose
+every loop owner is cold ``expected`` with reason ``cold_path``.
+
+Names and file stems only, compared as whole words. Ceiling: a helper whose
+only caller is a migration (``_rebuild_drifted_tables``) and a scheduled job
+carry no such word; telling them apart needs execution roles propagated over
+the call graph. Known false positives: request code in a module named for a
+phase (``startup.py``) whose function name carries no request word, and a
+per-request function whose name leads with ``migrate`` beside no user or
+request word. Not an identity input: ``execution_context`` stays path-only,
+so no opportunity id moves.
+"""
+
+from __future__ import annotations
+
+import re
+from pathlib import PurePosixPath
+from typing import Any
+
+_WORD_BREAK = re.compile(r"[^A-Za-z0-9]+|(?<=[a-z0-9])(?=[A-Z])")
+
+# A module named for its phase: ``workspace_startup``, ``session_recovery``.
+# A stem the word leads (``startup-trace-segment``) is about the phase, and
+# may run at any time.
+_STEM_PHASES = frozenset({"startup", "shutdown", "migration", "migrations", "recovery"})
+# A function named for its phase leads or ends with it: ``on_shutdown``,
+# ``_migrate_add_optional_columns``, ``cmd_migrate``. ``apply_migration_step``
+# is a helper anything may call.
+_NAME_PHASES = frozenset({"startup", "shutdown", "migrate"})
+# ``startPluginServices``: the verb leads, a long-lived process is the object,
+# and a qualifier names it. A bare ``start_server`` is as often a per-job helper.
+_LIFECYCLE_VERBS = frozenset({"start", "stop"})
+_LIFECYCLE_OBJECTS = frozenset({"service", "services", "server", "servers", "daemon", "daemons"})
+_RECOVERY_WORDS = frozenset({"recover", "recovery"})
+_CRASH_WORDS = frozenset({"interrupted", "orphaned", "abandoned", "crashed", "aborted"})
+# Per-user or per-request work: beside one of these a phase word is a request
+# (``recover_password``, ``migrate_user_settings``, ``recover_aborted_upload``).
+_WARM_WORDS = frozenset(
+ {
+ "password",
+ "passwd",
+ "account",
+ "login",
+ "credential",
+ "credentials",
+ "user",
+ "users",
+ "request",
+ "requests",
+ "middleware",
+ "handler",
+ "route",
+ "endpoint",
+ "upload",
+ "download",
+ }
+)
+
+
+def _words(text: str) -> list[str]:
+ return [word.lower() for word in _WORD_BREAK.split(text) if word]
+
+
+def is_cold_path(file_path: str, function_name: Any) -> bool:
+ """Whether this function's name or its module's says it runs once.
+
+ Called per member by ``opportunities._assemble``: a group is cold only
+ when every loop owner is.
+ """
+ name = str(function_name or "").replace("::", ".").rsplit(".", 1)[-1]
+ words = _words(name)
+ stem = _words(PurePosixPath(file_path.replace("\\", "/")).stem)
+ found = set(words)
+ if (found | set(stem)) & _WARM_WORDS:
+ return False
+ if stem and stem[-1] in _STEM_PHASES:
+ return True
+ if not words:
+ return False
+ if words[0] in _NAME_PHASES or words[-1] in _NAME_PHASES:
+ return True
+ if len(words) >= 3 and words[0] in _LIFECYCLE_VERBS and words[-1] in _LIFECYCLE_OBJECTS:
+ return True
+ return bool(found & _RECOVERY_WORDS and found & _CRASH_WORDS)
+
+
+__all__ = ["is_cold_path"]
diff --git a/packages/core/src/repowise/core/ingestion/languages/specs/typescript.py b/packages/core/src/repowise/core/ingestion/languages/specs/typescript.py
index a0e306c3f..d921e75c6 100644
--- a/packages/core/src/repowise/core/ingestion/languages/specs/typescript.py
+++ b/packages/core/src/repowise/core/ingestion/languages/specs/typescript.py
@@ -58,7 +58,10 @@ SPEC = LanguageSpec(
import_support="full",
# ``.test-d.`` is the type-test convention tsd and vitest's typecheck mode
# collect (``index.test-d.ts``): assertions on types, run by the test runner.
- test_infixes=(".test.", ".spec.", ".test-d."),
+ # ``.suite.`` holds ``describe`` blocks a ``.test.ts`` file registers.
+ # Infixes apply to every source extension, so a benchmark.js
+ # ``array.suite.js`` reads as test too: accepted, none seen in the corpora.
+ test_infixes=(".test.", ".spec.", ".test-d.", ".suite."),
extensions=frozenset({".ts", ".tsx", ".mts", ".cts"}),
grammar_package="tree_sitter_typescript",
grammar_loader="language_typescript",
diff --git a/packages/types/src/fix-first.ts b/packages/types/src/fix-first.ts
index 08960c04a..1b0af9842 100644
--- a/packages/types/src/fix-first.ts
+++ b/packages/types/src/fix-first.ts
@@ -38,6 +38,7 @@ export type FixExclusion =
| "docs_example"
| "deprecated"
| "gated_off"
+ | "cold_path"
| "unreachable"
| "inherent_dispatch"
| "small_function"
diff --git a/packages/types/src/health.ts b/packages/types/src/health.ts
index 1dca711f2..8f5fad5c6 100644
--- a/packages/types/src/health.ts
+++ b/packages/types/src/health.ts
@@ -603,6 +603,7 @@ export type PerformanceQueueExclusion =
| "tooling"
| "unknown"
| "gated_off"
+ | "cold_path"
| "expected"
| "no_strategy";
diff --git a/packages/ui/__tests__/health/fixtures/fix-first.ts b/packages/ui/__tests__/health/fixtures/fix-first.ts
index 4b56672f2..c6a8a377e 100644
--- a/packages/ui/__tests__/health/fixtures/fix-first.ts
+++ b/packages/ui/__tests__/health/fixtures/fix-first.ts
@@ -617,6 +617,7 @@ export const FIX_FIRST_QUEUE: FixFirstQueue = {
"docs_example": 0,
"deprecated": 0,
"gated_off": 0,
+ "cold_path": 0,
"unreachable": 0,
"inherent_dispatch": 0,
"small_function": 0,
diff --git a/packages/ui/src/health/fix-first/scope.ts b/packages/ui/src/health/fix-first/scope.ts
index b08cbf59e..558dede3c 100644
--- a/packages/ui/src/health/fix-first/scope.ts
+++ b/packages/ui/src/health/fix-first/scope.ts
@@ -44,6 +44,7 @@ export const EXCLUSION_LABEL: Record<FixExclusion, string> = {
history_only: "history only",
deprecated: "deprecated",
gated_off: "switched off by a constant flag",
+ cold_path: "run once per deploy, boot or incident",
unreachable: "in dead code (delete it)",
inherent_dispatch: "one long dispatch on a value",
small_function: "small functions",
@@ -65,6 +66,7 @@ const EXCLUSION_ORDER: FixExclusion[] = [
"history_only",
"deprecated",
"gated_off",
+ "cold_path",
"unreachable",
"inherent_dispatch",
"small_function",
diff --git a/packages/web/src/components/code-health/fix-first-section.test.tsx b/packages/web/src/components/code-health/fix-first-section.test.tsx
index d899f0432..024b0bb2f 100644
--- a/packages/web/src/components/code-health/fix-first-section.test.tsx
+++ b/packages/web/src/components/code-health/fix-first-section.test.tsx
@@ -71,6 +71,7 @@ function queue(items: FixItem[]): FixFirstQueue {
docs_example: 0,
deprecated: 0,
gated_off: 0,
+ cold_path: 0,
unreachable: 0,
inherent_dispatch: 0,
small_function: 0,
diff --git a/tests/fixtures/perf_corpus/golden_opportunities.json b/tests/fixtures/perf_corpus/golden_opportunities.json
index 136dd556a..fed20cc67 100644
--- a/tests/fixtures/perf_corpus/golden_opportunities.json
+++ b/tests/fixtures/perf_corpus/golden_opportunities.json
@@ -129,45 +129,45 @@
"evidence": [
{
"biomarker_type": "io_in_loop",
- "file_path": "src/app/migrate.py",
- "finding_id": "finding_99e6a402db90eaf9544e",
+ "file_path": "src/app/ledger.py",
+ "finding_id": "finding_bb8108f2272355e7bb47",
"function_name": "apply",
"line_end": 587,
"line_start": 587,
"path": [
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_move"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_move"
],
"provenance": "call-site",
- "reason": "one_loop_many_sinks: io_in_loop at src/app/migrate.py:587 repeats work per iteration."
+ "reason": "one_loop_many_sinks: io_in_loop at src/app/ledger.py:587 repeats work per iteration."
},
{
"biomarker_type": "io_in_loop",
- "file_path": "src/app/migrate.py",
- "finding_id": "finding_9b7378f919d4c62c71b6",
+ "file_path": "src/app/ledger.py",
+ "finding_id": "finding_6679c8c4aeba8ea75c58",
"function_name": "apply",
"line_end": 590,
"line_start": 590,
"path": [
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_fold_one"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_fold_one"
],
"provenance": "call-site",
- "reason": "one_loop_many_sinks: io_in_loop at src/app/migrate.py:590 repeats work per iteration."
+ "reason": "one_loop_many_sinks: io_in_loop at src/app/ledger.py:590 repeats work per iteration."
},
{
"biomarker_type": "io_in_loop",
- "file_path": "src/app/migrate.py",
- "finding_id": "finding_bcbd5e05d77811ea7695",
+ "file_path": "src/app/ledger.py",
+ "finding_id": "finding_b80478e54b854ac7d586",
"function_name": "apply",
"line_end": 591,
"line_start": 591,
"path": [
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_write_alias"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_write_alias"
],
"provenance": "call-site",
- "reason": "one_loop_many_sinks: io_in_loop at src/app/migrate.py:591 repeats work per iteration."
+ "reason": "one_loop_many_sinks: io_in_loop at src/app/ledger.py:591 repeats work per iteration."
}
],
"evidence_truncated": false,
@@ -186,10 +186,10 @@
"strategy": "batch_or_prefetch_io"
},
"intervention_kind": "function",
- "intervention_symbol": "src/app/migrate.py::apply",
+ "intervention_symbol": "src/app/ledger.py::apply",
"may_lead": true,
"observations_total": 3,
- "opportunity_id": "perf3_b03c60fe41fa017130c6",
+ "opportunity_id": "perf3_2719b6813419ad35948b",
"performance_model_version": 3,
"prerequisites": [
"batch_api_contract",
@@ -212,9 +212,9 @@
"siblings": [],
"terminal_sink": null,
"terminal_sinks": [
- "src/app/migrate.py::_fold_one",
- "src/app/migrate.py::_move",
- "src/app/migrate.py::_write_alias"
+ "src/app/ledger.py::_fold_one",
+ "src/app/ledger.py::_move",
+ "src/app/ledger.py::_write_alias"
],
"why_ranked": [
{
diff --git a/tests/fixtures/perf_corpus/golden_plans.json b/tests/fixtures/perf_corpus/golden_plans.json
index 5c358f4b5..0cc1204d2 100644
--- a/tests/fixtures/perf_corpus/golden_plans.json
+++ b/tests/fixtures/perf_corpus/golden_plans.json
@@ -111,7 +111,7 @@
"call_sites": 3,
"file_count": 1,
"files": [
- "src/app/migrate.py"
+ "src/app/ledger.py"
]
},
"confidence": "medium",
@@ -138,7 +138,7 @@
"rationale": "The shared I/O sink is proven; no concrete batch API or result-equivalence proof is available.",
"reliable_entry_reachability": true
},
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"impact_delta": 0.0,
"line_end": 587,
"line_start": 587,
@@ -146,21 +146,21 @@
"affected_locations": [
{
"call": "_move",
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"function_name": "apply",
"line_end": 587,
"line_start": 587
},
{
"call": "_fold_one",
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"function_name": "apply",
"line_end": 590,
"line_start": 590
},
{
"call": "_write_alias",
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"function_name": "apply",
"line_end": 591,
"line_start": 591
@@ -169,22 +169,22 @@
"affected_locations_total": 3,
"api": null,
"evidence_truncated": false,
- "intervention_symbol": "src/app/migrate.py::apply",
+ "intervention_symbol": "src/app/ledger.py::apply",
"judgment_steps": 3,
"mechanical_steps": 0,
- "opportunity_id": "perf3_b03c60fe41fa017130c6",
+ "opportunity_id": "perf3_2719b6813419ad35948b",
"paths": [
[
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_move"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_move"
],
[
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_fold_one"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_fold_one"
],
[
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_write_alias"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_write_alias"
]
],
"paths_total": 3,
@@ -193,7 +193,7 @@
{
"action": "Collect the keys before the loop and replace the per-key _move call with one batched call",
"applicability": "judgment",
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"line": 587,
"order": 1,
"symbol": "apply"
@@ -201,7 +201,7 @@
{
"action": "Collect the keys before the loop and replace the per-key _fold_one call with one batched call",
"applicability": "judgment",
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"line": 590,
"order": 2,
"symbol": "apply"
@@ -209,7 +209,7 @@
{
"action": "Collect the keys before the loop and replace the per-key _write_alias call with one batched call",
"applicability": "judgment",
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"line": 591,
"order": 3,
"symbol": "apply"
@@ -219,7 +219,7 @@
},
"refactoring_type": "performance_fix",
"source_biomarker": "io_in_loop",
- "target_symbol": "src/app/migrate.py::apply"
+ "target_symbol": "src/app/ledger.py::apply"
},
{
"blast_radius": {
diff --git a/tests/fixtures/perf_corpus/observations.json b/tests/fixtures/perf_corpus/observations.json
index 4e3716cce..80fdbea7a 100644
--- a/tests/fixtures/perf_corpus/observations.json
+++ b/tests/fixtures/perf_corpus/observations.json
@@ -680,16 +680,16 @@
"boundary_kind": "db",
"case": "one_loop_many_sinks",
"extra": {},
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"finding_ref": "one_loop_many_sinks-00",
"function_name": "apply",
"line_end": 587,
"line_start": 587,
"path": [
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_move"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_move"
],
- "reason": "one_loop_many_sinks: io_in_loop at src/app/migrate.py:587 repeats work per iteration.",
+ "reason": "one_loop_many_sinks: io_in_loop at src/app/ledger.py:587 repeats work per iteration.",
"reliable_entry_reachability": true,
"resolution_basis": "call-site"
},
@@ -698,16 +698,16 @@
"boundary_kind": "db",
"case": "one_loop_many_sinks",
"extra": {},
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"finding_ref": "one_loop_many_sinks-01",
"function_name": "apply",
"line_end": 590,
"line_start": 590,
"path": [
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_fold_one"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_fold_one"
],
- "reason": "one_loop_many_sinks: io_in_loop at src/app/migrate.py:590 repeats work per iteration.",
+ "reason": "one_loop_many_sinks: io_in_loop at src/app/ledger.py:590 repeats work per iteration.",
"reliable_entry_reachability": true,
"resolution_basis": "call-site"
},
@@ -716,16 +716,16 @@
"boundary_kind": "db",
"case": "one_loop_many_sinks",
"extra": {},
- "file_path": "src/app/migrate.py",
+ "file_path": "src/app/ledger.py",
"finding_ref": "one_loop_many_sinks-02",
"function_name": "apply",
"line_end": 591,
"line_start": 591,
"path": [
- "src/app/migrate.py::apply",
- "src/app/migrate.py::_write_alias"
+ "src/app/ledger.py::apply",
+ "src/app/ledger.py::_write_alias"
],
- "reason": "one_loop_many_sinks: io_in_loop at src/app/migrate.py:591 repeats work per iteration.",
+ "reason": "one_loop_many_sinks: io_in_loop at src/app/ledger.py:591 repeats work per iteration.",
"reliable_entry_reachability": true,
"resolution_basis": "call-site"
},
diff --git a/tests/unit/health/test_fix_first_build.py b/tests/unit/health/test_fix_first_build.py
index 0d7a0bcb6..e26c730c3 100644
--- a/tests/unit/health/test_fix_first_build.py
+++ b/tests/unit/health/test_fix_first_build.py
@@ -52,6 +52,7 @@ def test_each_exclusion_is_counted_by_reason() -> None:
"docs_example": 0,
"deprecated": 0,
"gated_off": 0,
+ "cold_path": 0,
"unreachable": 0,
"inherent_dispatch": 0,
"small_function": 0,
diff --git a/tests/unit/health/test_perf_cold_paths.py b/tests/unit/health/test_perf_cold_paths.py
new file mode 100644
index 000000000..a439f9a37
--- /dev/null
+++ b/tests/unit/health/test_perf_cold_paths.py
@@ -0,0 +1,139 @@
+"""Migrations, startup, shutdown and crash recovery run once, so a cause there
+is ``expected`` with reason ``cold_path``, not queued work.
+
+The positives are the dogfood rows that led real performance queues; the
+negatives are request-path names that share a word with them.
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from repowise.core.analysis.health.models import HealthFindingData, Severity
+from repowise.core.analysis.health.perf.causal import execution_context
+from repowise.core.analysis.health.perf.cold_paths import is_cold_path
+from repowise.core.analysis.health.perf.opportunities import build_performance_opportunities
+from repowise.core.analysis.health.perf.opportunity_rank import default_queue_exclusion
+
+
+def _finding(path: str, function: str) -> HealthFindingData:
+ return HealthFindingData(
+ biomarker_type="io_in_loop",
+ severity=Severity.MEDIUM,
+ file_path=path,
+ function_name=function,
+ line_start=10,
+ line_end=10,
+ details={"boundary_kind": "db", "cross_function": False, "path": []},
+ health_impact=0.0,
+ dimension="performance",
+ )
+
+
+ ("path", "function"),
+ [
+ ("hermes_cli/kanban_db.py", "_migrate_add_optional_columns"),
+ ("plugins/memory/honcho/cli.py", "cmd_migrate"),
+ ("src/plugins/services.ts", "startPluginServices"),
+ ("src/gateway/mcp-http.ts", "startMcpLoopbackServer"),
+ ("packages/server/src/repowise/server/workspace_startup.py", "_open_member_dbs"),
+ ("hermes_cli/session_recovery.py", "_reconstruct_missing_sessions"),
+ ("cron/executions.py", "recover_interrupted_executions"),
+ ("src/agents/subagent-orphan-recovery.ts", "recoverOrphanedSubagentSessions"),
+ ("gateway/run.py", "GatewayRunner::_on_shutdown"),
+ ],
+)
+def test_cold_names(path: str, function: str) -> None:
+ assert is_cold_path(path, function)
+
+
+ ("path", "function"),
+ [
+ ("app/views/auth.py", "recover_password"),
+ ("app/account_recovery.py", "send_reset_link"),
+ ("gateway/session.py", "SessionStore::_recover_session_from_db"),
+ ("extensions/telegram/src/network-errors.ts", "isRecoverableTelegramNetworkError"),
+ ("src/agents/chat.ts", "startConversation"),
+ ("src/gateway/server/plugins-http.ts", "createGatewayPluginRequestHandler"),
+ ("app/api/orders.py", "list_orders"),
+ ("app/settings.py", "migrate_user_settings"),
+ ("app/db/schema.py", "apply_migration_step"),
+ ("app/db/schema.py", "_load_migration_state"),
+ ("app/testing.py", "start_server"),
+ ("app/workers.py", "stop_service"),
+ ("app/db.py", "teardown"),
+ ("app/startup.py", "auth_middleware"),
+ ("app/shutdown.py", "handle_request"),
+ ("app/uploads.py", "recover_aborted_upload"),
+ ("src/plugins/startup-trace-segment.ts", "encodeStartupTraceSegment"),
+ ("app/api/orders.py", None),
+ ],
+)
+def test_request_path_names_stay_warm(path: str, function: str | None) -> None:
+ assert not is_cold_path(path, function)
+
+
+def test_a_migration_loop_leaves_the_default_queue_as_expected() -> None:
+ opportunity = build_performance_opportunities(
+ [_finding("hermes_cli/kanban_db.py", "_migrate_add_optional_columns")]
+ )[0]
+
+ assert opportunity.execution_context == "production"
+ assert opportunity.actionability_state == "expected"
+ assert opportunity.actionability_reason == "cold_path"
+ assert opportunity.fix is None
+ assert default_queue_exclusion(opportunity) == "cold_path"
+
+
+def test_a_request_handler_named_recover_password_stays_queued() -> None:
+ opportunity = build_performance_opportunities(
+ [_finding("app/views/auth.py", "recover_password")]
+ )[0]
+
+ assert opportunity.actionability_state == "advisory"
+ assert default_queue_exclusion(opportunity) is None
+
+
+def test_one_warm_member_keeps_a_shared_group_queued() -> None:
+ sink = ("store.py::save", "db.py::execute")
+ rows = [
+ _finding("app/startup.py", "warm_cache"),
+ _finding("app/api/orders.py", "create_order"),
+ ]
+ owners = ("app/startup.py::warm_cache", "app/api/orders.py::create_order")
+ for row, owner in zip(rows, owners, strict=True):
+ row.details.update(cross_function=True, path=[owner, *sink])
+
+ opportunity = build_performance_opportunities(rows)[0]
+
+ assert opportunity.intervention_symbol == "store.py::save"
+ assert opportunity.actionability_state == "advisory"
+
+
+def test_a_cold_name_does_not_move_the_identity_kernel() -> None:
+ assert execution_context("hermes_cli/session_recovery.py") == "production"
+
+
+def test_vitest_suite_modules_are_test_code() -> None:
+ assert execution_context("src/gateway/server.auth.default-token.suite.ts") == "test"
+
+
+def test_a_cold_group_with_no_strategy_is_expected_too() -> None:
+ row = _finding("hermes_cli/kanban_db.py", "_migrate_add_optional_columns")
+ row.details["loop_key_unused"] = True
+
+ opportunity = build_performance_opportunities([row])[0]
+
+ assert opportunity.actionability_reason == "cold_path"
+
+
+def test_gated_off_takes_precedence_over_cold_path() -> None:
+ row = _finding("hermes_cli/kanban_db.py", "_migrate_add_optional_columns")
+ row.details["gated_off"] = True
+
+ opportunity = build_performance_opportunities([row])[0]
+
+ assert opportunity.actionability_reason == "gated_off"
+ assert default_queue_exclusion(opportunity) == "gated_off"
diff --git a/tests/unit/ingestion/test_language_capabilities.py b/tests/unit/ingestion/test_language_capabilities.py
index eb2a599d8..26ad0b3ad 100644
--- a/tests/unit/ingestion/test_language_capabilities.py
+++ b/tests/unit/ingestion/test_language_capabilities.py
@@ -65,8 +65,9 @@ class TestParityGoldens:
}
def test_test_infixes_match_historical_set(self) -> None:
- # `.test-d.` is the TypeScript type-test infix (`*.test-d.ts`).
- assert set(REGISTRY.test_infixes()) == {".test.", ".spec.", ".test-d."}
+ # `.test-d.` is the TypeScript type-test infix (`*.test-d.ts`), `.suite.`
+ # a vitest suite module (`*.suite.ts`).
+ assert set(REGISTRY.test_infixes()) == {".test.", ".spec.", ".test-d.", ".suite."}
def test_test_fixture_stems_match_historical_set(self) -> None:
assert frozenset(
diff --git a/tests/unit/server/test_performance_opportunities.py b/tests/unit/server/test_performance_opportunities.py
index 8848c22a0..f49e0728a 100644
--- a/tests/unit/server/test_performance_opportunities.py
+++ b/tests/unit/server/test_performance_opportunities.py
@@ -327,6 +327,7 @@ async def test_the_default_queue_reports_what_it_leaves_out(app, client: AsyncCl
"tooling": 0,
"unknown": 0,
"gated_off": 0,
+ "cold_path": 0,
"expected": 1,
"no_strategy": 1,
},
diff --git a/tests/unit/test_test_paths.py b/tests/unit/test_test_paths.py
index 8902f9ef0..c472af8b7 100644
--- a/tests/unit/test_test_paths.py
+++ b/tests/unit/test_test_paths.py
@@ -199,6 +199,12 @@ _CORPUS: tuple[tuple[str, str | None, str], ...] = (
("src/components/__snapshots__/Button.test.tsx.snap", None, "support"),
# tsd / vitest type tests
("src/types/index.test-d.ts", None, "test"),
+ # vitest suite modules a `.test.ts` file registers
+ ("src/gateway/server.auth.default-token.suite.ts", None, "test"),
+ ("src/gateway/suite.ts", None, ""),
+ # infixes apply to every source extension (no per-extension infix rule), so a
+ # benchmark.js suite reads as test: a known false positive, accepted
+ ("bench/array.suite.js", None, "test"),
# a bare `test`/`tests` stem is a suite in Python and Rust only; `test.ts` in an
# examples folder is an example, and `scripts/test.sh` runs the suite
("examples/basic/src/test.ts", None, ""),