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): class schema migrations as tooling in the performance context (#2814)
Raghav Chamadiya8b2f151b3d7e
diff --git a/docs/agent/MCP_TOOLS.md b/docs/agent/MCP_TOOLS.mdindex 020be7f7d..976cf5911 100644--- a/docs/agent/MCP_TOOLS.md+++ b/docs/agent/MCP_TOOLS.md@@ -1300,8 +1300,8 @@ materialized the analysis yet, or did so under an older model.get_health() # the leadget_health(include=["performance"], only=["performance_summary"])get_health(include=["performance"], only=["performance_opportunities"], performance_context="all")-get_health(opportunity_id="perf2_...") # the cause, its plan, its evidence-get_health(opportunity_id="perf2_...", only=["performance_evidence"], cursor=3)+get_health(opportunity_id="perf3_...") # the cause, its plan, its evidence+get_health(opportunity_id="perf3_...", only=["performance_evidence"], cursor=3)```Ids are stable within a performance model version and are never translateddiff --git a/packages/core/src/repowise/core/analysis/health/engine.py b/packages/core/src/repowise/core/analysis/health/engine.pyindex 188ba2f96..31af5870e 100644--- a/packages/core/src/repowise/core/analysis/health/engine.py+++ b/packages/core/src/repowise/core/analysis/health/engine.py@@ -104,7 +104,14 @@ log = structlog.get_logger(__name__)# Not a licence to move a calibrated scoring weight — those are frozen# independently of this stamp.#-# Current stamp: which files are tests changed (``repowise.core.test_paths``).+# Current stamp (v37): schema migrations are ``tooling`` in the performance+# ``execution_context`` (any ``migrations/`` directory, Rails ``db/migrate``,+# Alembic ``alembic/versions``). The context is stored on every performance+# opportunity and is a kernel input to its id, so ``PERFORMANCE_MODEL_VERSION``+# moved 2 -> 3 with it: every performance id now carries the ``perf3_`` prefix,+# and a held ``perf2_`` id reports ``stale_model`` instead of a silent miss.+#+# v36 (also): which files are tests changed (``repowise.core.test_paths``).# Compound directories headed by a test word (``e2e-tests/``, ``pkg_tests/``,# ``integration_test/``) became test trees, and ``test``/``.test.`` filenames# stopped counting on configuration (``tsconfig.test.json``, a workflow's@@ -333,7 +340,7 @@ log = structlog.get_logger(__name__)# forms. Files that were counted untested and are not become tested, which# moves untested-hotspot findings and the scores that carry them, on every# language with a prefix or spec convention rather than Ruby alone.-HEALTH_ANALYZER_VERSION = 36+HEALTH_ANALYZER_VERSION = 37def walked_functions(diff --git a/packages/core/src/repowise/core/analysis/health/perf/causal.py b/packages/core/src/repowise/core/analysis/health/perf/causal.pyindex f3ea5192b..235f66520 100644--- a/packages/core/src/repowise/core/analysis/health/perf/causal.py+++ b/packages/core/src/repowise/core/analysis/health/perf/causal.py@@ -17,13 +17,14 @@ import hashlibimport jsonimport refrom collections import defaultdict+from itertools import pairwisefrom typing import Any, Literalfrom repowise.core.test_paths import is_test_related_pathfrom .facts import ObservationFacts, detail_map, is_performance, observation_facts-PERFORMANCE_MODEL_VERSION = 2+PERFORMANCE_MODEL_VERSION = 3"""Version of the identity, grouping, actionability, and ranking semantics.From version 2 the version is the id prefix rather than a hash input, so a@@ -31,6 +32,9 @@ stale id is recognisable without a lookup and :func:`model_state` can answerfrom the string alone. Version 1 ids carry no digit and remain readable asversion 1. Moving this constant means bumping ``HEALTH_ANALYZER_VERSION`` withit, which forces the rescore that restamps every stored finding.++Version 3 classes schema migrations as ``tooling`` in :func:`execution_context`,+a kernel input. Digests of every other path are unchanged; only the prefix moved."""ExecutionContext = Literal["production", "tooling", "test", "unknown"]@@ -41,9 +45,30 @@ _ID_PREFIX = "perf"_ID_PATTERN = re.compile(rf"^{_ID_PREFIX}(\d*)_[0-9a-f]{{20}}$")_TOOLING_PARTS = frozenset(- {".github", "benchmarks", "build", "devtools", "scripts", "tooling", "tools"}+ {+ ".github",+ "benchmarks",+ "build",+ "devtools",+ # Schema migrations run once per deploy, not per request: Django and+ # Flask-Migrate ``migrations/``, EF Core ``Migrations/``.+ "migrations",+ "scripts",+ "tooling",+ "tools",+ })+_TOOLING_DIR_PAIRS = frozenset({("db", "migrate"), ("alembic", "versions")})+"""Adjacent directories that mark migrations where neither name does alone.++Rails keeps them in ``db/migrate``. Alembic keeps them in ``versions/`` under+its script directory; a bare ``versions/`` is too common (API versions) to+class on its own. Ceiling: an Alembic script directory with another name is+recognised only by its sibling ``env.py``, which a path-only classifier cannot+see.+"""+_UNCLASSIFIABLE_PARTS = frozenset({"demo",@@ -78,9 +103,12 @@ def execution_context(file_path: str) -> ExecutionContext:return "unknown"if is_test_related_path(file_path):return "test"- parts = {part.lower() for part in normalized.split("/")}+ segments = normalized.lower().split("/")+ parts = set(segments)if parts & _TOOLING_PARTS or "/cli/" in f"/{normalized.lower()}/":return "tooling"+ if any(pair in _TOOLING_DIR_PAIRS for pair in pairwise(segments[:-1])):+ return "tooling"if parts & _UNCLASSIFIABLE_PARTS or "/" not in normalized:return "unknown"return "production"diff --git a/tests/fixtures/perf_corpus/golden_opportunities.json b/tests/fixtures/perf_corpus/golden_opportunities.jsonindex 52131eed7..b24d53608 100644--- a/tests/fixtures/perf_corpus/golden_opportunities.json+++ b/tests/fixtures/perf_corpus/golden_opportunities.json@@ -42,8 +42,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_e1734c647c3b26b6dfc4",- "performance_model_version": 2,+ "opportunity_id": "perf3_e1734c647c3b26b6dfc4",+ "performance_model_version": 3,"prerequisites": [],"provenance": "direct","rank_factors": {@@ -121,8 +121,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_cc802c5285ea0c31b02a",- "performance_model_version": 2,+ "opportunity_id": "perf3_cc802c5285ea0c31b02a",+ "performance_model_version": 3,"prerequisites": [],"provenance": "direct","rank_factors": {@@ -218,8 +218,8 @@},"intervention_symbol": "src/app/entry.py::_hit","observations_total": 2,- "opportunity_id": "perf2_0673587e7abbea99fc0b",- "performance_model_version": 2,+ "opportunity_id": "perf3_0673587e7abbea99fc0b",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -321,8 +321,8 @@},"intervention_symbol": "src/app/repo.py::fetch_page","observations_total": 2,- "opportunity_id": "perf2_89348be6c2ba0311a0e8",- "performance_model_version": 2,+ "opportunity_id": "perf3_89348be6c2ba0311a0e8",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -425,8 +425,8 @@},"intervention_symbol": "src/app/reindex.py::_write","observations_total": 2,- "opportunity_id": "perf2_3d62fcebb00bdf408f2c",- "performance_model_version": 2,+ "opportunity_id": "perf3_3d62fcebb00bdf408f2c",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -528,8 +528,8 @@},"intervention_symbol": "src/app/sync.py::_load","observations_total": 2,- "opportunity_id": "perf2_af29fc10103a555c8652",- "performance_model_version": 2,+ "opportunity_id": "perf3_af29fc10103a555c8652",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -615,8 +615,8 @@},"intervention_symbol": "src/app/cache.py::refresh","observations_total": 1,- "opportunity_id": "perf2_9dfe577bc9c8b799355e",- "performance_model_version": 2,+ "opportunity_id": "perf3_9dfe577bc9c8b799355e",+ "performance_model_version": 3,"prerequisites": ["shared_state_ordering"],@@ -698,8 +698,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_182b2a7c053167959285",- "performance_model_version": 2,+ "opportunity_id": "perf3_182b2a7c053167959285",+ "performance_model_version": 3,"prerequisites": ["bounded_concurrency"],@@ -781,8 +781,8 @@},"intervention_symbol": "src/app/billing.py::handle","observations_total": 1,- "opportunity_id": "perf2_3d4056f8405c9313d004",- "performance_model_version": 2,+ "opportunity_id": "perf3_3d4056f8405c9313d004",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -868,8 +868,8 @@},"intervention_symbol": "src/app/orders.py::handle","observations_total": 1,- "opportunity_id": "perf2_5abe869788cb2cebf6cf",- "performance_model_version": 2,+ "opportunity_id": "perf3_5abe869788cb2cebf6cf",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -955,8 +955,8 @@},"intervention_symbol": "src/app/reports.py::handle","observations_total": 1,- "opportunity_id": "perf2_7d6b729c3f43753626f2",- "performance_model_version": 2,+ "opportunity_id": "perf3_7d6b729c3f43753626f2",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1042,8 +1042,8 @@},"intervention_symbol": "src/app/job.py::run","observations_total": 1,- "opportunity_id": "perf2_811bb33b8d8f9e744638",- "performance_model_version": 2,+ "opportunity_id": "perf3_811bb33b8d8f9e744638",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1127,8 +1127,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_820a695aba4fe3a6496a",- "performance_model_version": 2,+ "opportunity_id": "perf3_820a695aba4fe3a6496a",+ "performance_model_version": 3,"prerequisites": ["result_equivalence"],@@ -1209,8 +1209,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_f349f0c0ac6827ebfd86",- "performance_model_version": 2,+ "opportunity_id": "perf3_f349f0c0ac6827ebfd86",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1295,8 +1295,8 @@},"intervention_symbol": "scripts/backfill.py::run","observations_total": 1,- "opportunity_id": "perf2_626e6b4848d036aede65",- "performance_model_version": 2,+ "opportunity_id": "perf3_626e6b4848d036aede65",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1382,8 +1382,8 @@},"intervention_symbol": "src/app/edge.py::run","observations_total": 1,- "opportunity_id": "perf2_cf3653d0149e79f7a1fb",- "performance_model_version": 2,+ "opportunity_id": "perf3_cf3653d0149e79f7a1fb",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1466,8 +1466,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_dc58f1a585a816ec37e9",- "performance_model_version": 2,+ "opportunity_id": "perf3_dc58f1a585a816ec37e9",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1550,8 +1550,8 @@},"intervention_symbol": "tests/test_job.py::run","observations_total": 1,- "opportunity_id": "perf2_b17b10884d21aeeb4df0",- "performance_model_version": 2,+ "opportunity_id": "perf3_b17b10884d21aeeb4df0",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence"@@ -1637,8 +1637,8 @@},"intervention_symbol": "src/app/guess.py::run","observations_total": 1,- "opportunity_id": "perf2_a817f9001be1d323f8a2",- "performance_model_version": 2,+ "opportunity_id": "perf3_a817f9001be1d323f8a2",+ "performance_model_version": 3,"prerequisites": ["batch_api_contract","result_equivalence",@@ -1722,8 +1722,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_6b8f8be1ab10062f0a19",- "performance_model_version": 2,+ "opportunity_id": "perf3_6b8f8be1ab10062f0a19",+ "performance_model_version": 3,"prerequisites": ["element_hashability","ordering_and_identity_use"@@ -1803,8 +1803,8 @@},"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_e82f5ad0e9c24fe3d1a1",- "performance_model_version": 2,+ "opportunity_id": "perf3_e82f5ad0e9c24fe3d1a1",+ "performance_model_version": 3,"prerequisites": ["accumulator_not_observed"],@@ -1898,8 +1898,8 @@"fix": null,"intervention_symbol": "src/app/store.py::flush_all","observations_total": 2,- "opportunity_id": "perf2_bb39bb7c7b9f0b1fe7a1",- "performance_model_version": 2,+ "opportunity_id": "perf3_bb39bb7c7b9f0b1fe7a1",+ "performance_model_version": 3,"prerequisites": ["single_lock_owner"],@@ -1977,8 +1977,8 @@"fix": null,"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_266b6dd67d9b9e93e201",- "performance_model_version": 2,+ "opportunity_id": "perf3_266b6dd67d9b9e93e201",+ "performance_model_version": 3,"prerequisites": ["loop_invariant_construction_proof"],@@ -2053,8 +2053,8 @@"fix": null,"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_386a99aa2876c0dd31bd",- "performance_model_version": 2,+ "opportunity_id": "perf3_386a99aa2876c0dd31bd",+ "performance_model_version": 3,"prerequisites": ["loop_invariant_construction_proof"],@@ -2129,8 +2129,8 @@"fix": null,"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_64fbd03504c61c115894",- "performance_model_version": 2,+ "opportunity_id": "perf3_64fbd03504c61c115894",+ "performance_model_version": 3,"prerequisites": ["loop_carried_dependence_proof"],@@ -2254,8 +2254,8 @@"fix": null,"intervention_symbol": "src/app/parse.py::_get_query","observations_total": 4,- "opportunity_id": "perf2_a445d6f2d021ddf6a425",- "performance_model_version": 2,+ "opportunity_id": "perf3_a445d6f2d021ddf6a425",+ "performance_model_version": 3,"prerequisites": [],"provenance": "call-site","rank_factors": {@@ -2334,8 +2334,8 @@"fix": null,"intervention_symbol": "src/app/walker.py::scan","observations_total": 1,- "opportunity_id": "perf2_19a89b391403e23aed4d",- "performance_model_version": 2,+ "opportunity_id": "perf3_19a89b391403e23aed4d",+ "performance_model_version": 3,"prerequisites": [],"provenance": "call-site","rank_factors": {@@ -2414,8 +2414,8 @@"fix": null,"intervention_symbol": "src/app/walker.py::index","observations_total": 1,- "opportunity_id": "perf2_68583bf925fadb4f4731",- "performance_model_version": 2,+ "opportunity_id": "perf3_68583bf925fadb4f4731",+ "performance_model_version": 3,"prerequisites": [],"provenance": "call-site","rank_factors": {@@ -2491,8 +2491,8 @@"fix": null,"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_8ffbe99d8409ad899a72",- "performance_model_version": 2,+ "opportunity_id": "perf3_8ffbe99d8409ad899a72",+ "performance_model_version": 3,"prerequisites": [],"provenance": "direct","rank_factors": {@@ -2565,8 +2565,8 @@"fix": null,"intervention_symbol": null,"observations_total": 1,- "opportunity_id": "perf2_91e5b79c0937ef51ec73",- "performance_model_version": 2,+ "opportunity_id": "perf3_91e5b79c0937ef51ec73",+ "performance_model_version": 3,"prerequisites": [],"provenance": "direct","rank_factors": {diff --git a/tests/fixtures/perf_corpus/golden_plans.json b/tests/fixtures/perf_corpus/golden_plans.jsonindex 4068da69a..9431a4b3d 100644--- a/tests/fixtures/perf_corpus/golden_plans.json+++ b/tests/fixtures/perf_corpus/golden_plans.json@@ -51,7 +51,7 @@"intervention_symbol": null,"judgment_steps": 0,"mechanical_steps": 1,- "opportunity_id": "perf2_e1734c647c3b26b6dfc4",+ "opportunity_id": "perf3_e1734c647c3b26b6dfc4","paths": [],"paths_total": 1,"safety": "proven",@@ -122,7 +122,7 @@"intervention_symbol": null,"judgment_steps": 0,"mechanical_steps": 1,- "opportunity_id": "perf2_cc802c5285ea0c31b02a",+ "opportunity_id": "perf3_cc802c5285ea0c31b02a","paths": [],"paths_total": 1,"safety": "proven",@@ -199,7 +199,7 @@"intervention_symbol": "src/app/entry.py::_hit","judgment_steps": 3,"mechanical_steps": 0,- "opportunity_id": "perf2_0673587e7abbea99fc0b",+ "opportunity_id": "perf3_0673587e7abbea99fc0b","paths": [["src/app/entry.py::a",@@ -303,7 +303,7 @@"intervention_symbol": "src/app/repo.py::fetch_page","judgment_steps": 3,"mechanical_steps": 0,- "opportunity_id": "perf2_89348be6c2ba0311a0e8",+ "opportunity_id": "perf3_89348be6c2ba0311a0e8","paths": [["src/app/api.py::list_users",@@ -408,7 +408,7 @@"intervention_symbol": "src/app/reindex.py::_write","judgment_steps": 3,"mechanical_steps": 0,- "opportunity_id": "perf2_3d62fcebb00bdf408f2c",+ "opportunity_id": "perf3_3d62fcebb00bdf408f2c","paths": [["src/app/reindex.py::one",@@ -512,7 +512,7 @@"intervention_symbol": "src/app/sync.py::_load","judgment_steps": 3,"mechanical_steps": 0,- "opportunity_id": "perf2_af29fc10103a555c8652",+ "opportunity_id": "perf3_af29fc10103a555c8652","paths": [["src/app/sync.py::sync_one",@@ -610,7 +610,7 @@"intervention_symbol": "src/app/cache.py::refresh","judgment_steps": 1,"mechanical_steps": 0,- "opportunity_id": "perf2_9dfe577bc9c8b799355e",+ "opportunity_id": "perf3_9dfe577bc9c8b799355e","paths": [["src/app/cache.py::refresh",@@ -686,7 +686,7 @@"intervention_symbol": null,"judgment_steps": 1,"mechanical_steps": 0,- "opportunity_id": "perf2_182b2a7c053167959285",+ "opportunity_id": "perf3_182b2a7c053167959285","paths": [],"paths_total": 1,"safety": "advisory",@@ -757,7 +757,7 @@"intervention_symbol": "src/app/billing.py::handle","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_3d4056f8405c9313d004",+ "opportunity_id": "perf3_3d4056f8405c9313d004","paths": [["src/app/billing.py::handle",@@ -841,7 +841,7 @@"intervention_symbol": "src/app/orders.py::handle","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_5abe869788cb2cebf6cf",+ "opportunity_id": "perf3_5abe869788cb2cebf6cf","paths": [["src/app/orders.py::handle",@@ -925,7 +925,7 @@"intervention_symbol": "src/app/reports.py::handle","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_7d6b729c3f43753626f2",+ "opportunity_id": "perf3_7d6b729c3f43753626f2","paths": [["src/app/reports.py::handle",@@ -1009,7 +1009,7 @@"intervention_symbol": "src/app/job.py::run","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_811bb33b8d8f9e744638",+ "opportunity_id": "perf3_811bb33b8d8f9e744638","paths": [["src/app/job.py::run",@@ -1093,7 +1093,7 @@"intervention_symbol": null,"judgment_steps": 1,"mechanical_steps": 0,- "opportunity_id": "perf2_820a695aba4fe3a6496a",+ "opportunity_id": "perf3_820a695aba4fe3a6496a","paths": [],"paths_total": 1,"safety": "advisory",@@ -1164,7 +1164,7 @@"intervention_symbol": null,"judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_f349f0c0ac6827ebfd86",+ "opportunity_id": "perf3_f349f0c0ac6827ebfd86","paths": [["src/app/db.py::only_sink"@@ -1247,7 +1247,7 @@"intervention_symbol": "scripts/backfill.py::run","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_626e6b4848d036aede65",+ "opportunity_id": "perf3_626e6b4848d036aede65","paths": [["scripts/backfill.py::run",@@ -1331,7 +1331,7 @@"intervention_symbol": "src/app/edge.py::run","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_cf3653d0149e79f7a1fb",+ "opportunity_id": "perf3_cf3653d0149e79f7a1fb","paths": [["src/app/edge.py::run",@@ -1415,7 +1415,7 @@"intervention_symbol": null,"judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_dc58f1a585a816ec37e9",+ "opportunity_id": "perf3_dc58f1a585a816ec37e9","paths": [],"paths_total": 1,"safety": "advisory",@@ -1494,7 +1494,7 @@"intervention_symbol": "tests/test_job.py::run","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_b17b10884d21aeeb4df0",+ "opportunity_id": "perf3_b17b10884d21aeeb4df0","paths": [["tests/test_job.py::run",@@ -1578,7 +1578,7 @@"intervention_symbol": "src/app/guess.py::run","judgment_steps": 2,"mechanical_steps": 0,- "opportunity_id": "perf2_a817f9001be1d323f8a2",+ "opportunity_id": "perf3_a817f9001be1d323f8a2","paths": [["src/app/guess.py::run",@@ -1662,7 +1662,7 @@"intervention_symbol": null,"judgment_steps": 1,"mechanical_steps": 0,- "opportunity_id": "perf2_6b8f8be1ab10062f0a19",+ "opportunity_id": "perf3_6b8f8be1ab10062f0a19","paths": [],"paths_total": 1,"safety": "advisory",@@ -1733,7 +1733,7 @@"intervention_symbol": null,"judgment_steps": 1,"mechanical_steps": 0,- "opportunity_id": "perf2_e82f5ad0e9c24fe3d1a1",+ "opportunity_id": "perf3_e82f5ad0e9c24fe3d1a1","paths": [],"paths_total": 1,"safety": "advisory",diff --git a/tests/fixtures/perf_corpus/manifest.json b/tests/fixtures/perf_corpus/manifest.jsonindex 8b43bc5ea..3df7d592d 100644--- a/tests/fixtures/perf_corpus/manifest.json+++ b/tests/fixtures/perf_corpus/manifest.json@@ -1,6 +1,6 @@{"corpus_version": 2,- "performance_model_version": 2,+ "performance_model_version": 3,"purpose": "characterization of grouping, identity, actionability, confidence facets and ranking","runner": "uv run pytest tests/unit/health/test_perf_corpus_golden.py -v","rewrite_env": "REPOWISE_REWRITE_PERF_GOLDEN=1",diff --git a/tests/unit/health/test_model_version_coupling.py b/tests/unit/health/test_model_version_coupling.pyindex 94437190a..db03c4bbd 100644--- a/tests/unit/health/test_model_version_coupling.py+++ b/tests/unit/health/test_model_version_coupling.py@@ -22,7 +22,7 @@ from repowise.core.analysis.health.refactoring.identity import (# The three stamps as they stand together. Moving either identity model means# moving the analyzer with it, and updating this tuple in the same commit.-_STAMPS = (36, 2, 2)+_STAMPS = (37, 3, 2)def test_the_identity_models_and_the_analyzer_stamp_are_pinned_together() -> None:diff --git a/tests/unit/health/test_perf_execution_context.py b/tests/unit/health/test_perf_execution_context.pynew file mode 100644index 000000000..ac4f4861d--- /dev/null+++ b/tests/unit/health/test_perf_execution_context.py@@ -0,0 +1,44 @@+"""Schema migrations run at deploy time, so they are tooling, not production.++A migration's loop over rows is not a request path, and classing it+``production`` ranked it beside the code users wait on. A bare ``versions/``+directory stays production: API version packages use the same name.+"""++from __future__ import annotations++import pytest++from repowise.core.analysis.health.perf.causal import execution_context+++ "path",+ [+ "app/migrations/0001_initial.py", # Django+ "blog/migrations/0012_backfill.py",+ "migrations/versions/3f2a_add_index.py", # Flask-Migrate+ "alembic/versions/3f2a_add_index.py", # Alembic+ "src/db/alembic/versions/3f2a_add_index.py",+ "db/migrate/20240101000000_create_users.rb", # Rails+ "src/Data/Migrations/20240101_Init.cs", # EF Core+ "src\\Data\\Migrations\\20240101_Init.cs",+ ],+)+def test_migrations_are_tooling(path: str) -> None:+ assert execution_context(path) == "tooling"+++ "path",+ [+ "app/versions/api.py",+ "api/versions/v2/handlers.py",+ "app/db/migrate.py", # a module named migrate, not the Rails directory+ "app/migrate/runner.py",+ "app/alembic_utils.py",+ "app/migrations_helper.py",+ ],+)+def test_lookalikes_stay_production(path: str) -> None:+ assert execution_context(path) == "production"diff --git a/tests/unit/health/test_perf_identity_contract.py b/tests/unit/health/test_perf_identity_contract.pyindex 8717f27d7..35043753d 100644--- a/tests/unit/health/test_perf_identity_contract.py+++ b/tests/unit/health/test_perf_identity_contract.py@@ -29,9 +29,9 @@ from repowise.core.analysis.health.refactoring.performance_fix import (performance_fix_suggestions,)-# The v2 kernel, pinned. A change to either string is a model-version change.-CROSS_FUNCTION_ID = "perf2_5662c38bc84c9a677164"-LOCAL_ID = "perf2_f13beed790fd3cb29ac1"+# The v3 kernel, pinned. A change to either string is a model-version change.+CROSS_FUNCTION_ID = "perf3_5662c38bc84c9a677164"+LOCAL_ID = "perf3_f13beed790fd3cb29ac1"def _row(**overrides):@@ -71,7 +71,7 @@ def test_the_model_version_is_pinned_and_is_carried_by_the_id_prefix() -> None:alias table cannot: an id says which model minted it, so a caller holding astale one is told to refresh instead of being handed the wrong group."""- assert PERFORMANCE_MODEL_VERSION == 2+ assert PERFORMANCE_MODEL_VERSION == 3assert opportunity_id_for_finding(_row()) == CROSS_FUNCTION_IDassert opportunity_id_for_finding(_local_row()) == LOCAL_IDassert CROSS_FUNCTION_ID.startswith(f"perf{PERFORMANCE_MODEL_VERSION}_")@@ -80,7 +80,8 @@ def test_the_model_version_is_pinned_and_is_carried_by_the_id_prefix() -> None:@pytest.mark.parametrize(("opportunity_id", "state", "version"),[- (CROSS_FUNCTION_ID, "current", 2),+ (CROSS_FUNCTION_ID, "current", 3),+ ("perf2_5662c38bc84c9a677164", "stale_model", 2),("perf_e358397251b660183fdd", "stale_model", 1),("perf9_e358397251b660183fdd", "stale_model", 9),("not-an-opportunity-id", "unrecognized", None),