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(ci): restore deterministic Python checks (#2250)
Raghav Chamadiyab82953075ceb
diff --git a/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py b/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.pyindex 5ace74a91..ea0848733 100644--- a/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py+++ b/packages/server/src/repowise/server/mcp_server/tool_context/enrichment.py@@ -85,6 +85,11 @@ _SYMBOL_USE_EDGE_TYPES = sorted(SYMBOL_USE_EDGE_TYPES)#: callees for three hops. Keep it meaning what it is named._CALL_EDGE_TYPES = ["calls"]+#: Maximum caller/callee rows returned for one symbol. Kept as a named seam so+#: contract tests can force an omission without depending on response size or+#: platform-specific serialization details.+_SYMBOL_NEIGHBOR_LIMIT = 50+#: Rows carried per relation kind. Deliberately far below the call cap: the#: agent question these answer is "what else reaches this, and how", which the#: kind and the honest total answer. Naming them costs less than the@@ -153,7 +158,7 @@ async def _resolve_call_graph(repo_id = repository.id# 99.56% of symbols have <=50 callers (p99=31); the rare hub gets an# explicit `*_truncated` + `*_total` signal below rather than a silent cut.- limit = 50+ limit = _SYMBOL_NEIGHBOR_LIMIT# Resolve to a graph node (symbol)node = await get_graph_node(session, repo_id, target)diff --git a/packages/server/src/repowise/server/mcp_server/tool_risk/assessment.py b/packages/server/src/repowise/server/mcp_server/tool_risk/assessment.pyindex 3ebc804a6..461ad9b70 100644--- a/packages/server/src/repowise/server/mcp_server/tool_risk/assessment.py+++ b/packages/server/src/repowise/server/mcp_server/tool_risk/assessment.py@@ -54,16 +54,17 @@ def normalize_target_path(target: str, repo_root: str | None = None) -> str:# root when we know it. Uses a prefix check on the normalized forms, so a# path that is already repo-relative is left untouched.if repo_root:- root_norm = str(Path(repo_root).resolve()).replace("\\", "/")+ root_path = Path(repo_root).resolve()try:# Resolve against the repo root, not the process cwd: the MCP# server's cwd is not the repo, so a relative path that happens# to exist there could resolve somewhere unrelated.- resolved = Path(repo_root, normalized).resolve()- if str(resolved).startswith(root_norm.rstrip("/") + "/"):- normalized = str(resolved).replace("\\", "/")[len(root_norm.rstrip("/")) + 1 :]+ candidate = Path(normalized)+ resolved = (candidate if candidate.is_absolute() else root_path / candidate).resolve()+ normalized = resolved.relative_to(root_path).as_posix()except (OSError, ValueError):- # resolve() can raise ValueError on a malformed Windows path.+ # Resolution can fail for malformed paths; relative_to() also+ # rejects absolute paths outside the selected repository.pass# Strip a leading cwd-relative prefix and any leading slash left over.# A prefix strip, not lstrip: lstrip takes a character set, so it woulddiff --git a/packages/types/src/generated/http.ts b/packages/types/src/generated/http.tsindex 0996e2d81..d6ff499c6 100644--- a/packages/types/src/generated/http.ts+++ b/packages/types/src/generated/http.ts@@ -2273,6 +2273,7 @@ export interface RepoResponse {docs_skip_reason?: string | null;run_mode?: string | null;git_tier?: string | null;+ index_scope?: Record<string, unknown> | null;initial_job_id?: string | null;}diff --git a/tests/unit/server/mcp/conftest.py b/tests/unit/server/mcp/conftest.pyindex 571a0e2fd..188ea1a45 100644--- a/tests/unit/server/mcp/conftest.py+++ b/tests/unit/server/mcp/conftest.py@@ -71,13 +71,13 @@ async def vector_store():@pytest.fixture-async def repo_id(session: AsyncSession) -> str:+async def repo_id(session: AsyncSession, tmp_path) -> str:"""Create a test repository and return its ID."""repo = Repository(id="repo1",name="test-repo",url="https://github.com/example/test-repo",- local_path="/tmp/test-repo",+ local_path=str(tmp_path),default_branch="main",settings_json="{}",created_at=_NOW,@@ -564,7 +564,7 @@ async def populated_db(session: AsyncSession, repo_id: str) -> str:@pytest.fixture-async def setup_mcp(factory, fts, vector_store, populated_db):+async def setup_mcp(factory, fts, vector_store, populated_db, tmp_path):"""Configure the MCP module's global state for testing."""import repowise.server.mcp_server as mcp_modfrom repowise.server.mcp_server import _basis, _scope@@ -578,7 +578,7 @@ async def setup_mcp(factory, fts, vector_store, populated_db):mcp_mod._fts = ftsmcp_mod._vector_store = vector_storemcp_mod._decision_store = InMemoryVectorStore(embedder=MockEmbedder())- mcp_mod._repo_path = "/tmp/test-repo"+ mcp_mod._repo_path = str(tmp_path)yield populated_dbdiff --git a/tests/unit/server/mcp/test_cross_tool_reference_contracts.py b/tests/unit/server/mcp/test_cross_tool_reference_contracts.pyindex fe4e52c51..1ef7af4ed 100644--- a/tests/unit/server/mcp/test_cross_tool_reference_contracts.py+++ b/tests/unit/server/mcp/test_cross_tool_reference_contracts.py@@ -497,7 +497,15 @@ _CELL_LEDGER = tuple(@pytest.mark.asyncio-async def test_canonical_emitter_reference_inventory(reference_repo, health_data, session) -> None:+async def test_canonical_emitter_reference_inventory(+ reference_repo, health_data, session, monkeypatch+) -> None:+ from repowise.server.mcp_server.tool_context import enrichment++ # This inventory tests the public recovery reference, not the production+ # row cap. Force the seeded callers across that boundary deterministically.+ monkeypatch.setattr(enrichment, "_SYMBOL_NEIGHBOR_LIMIT", 2)+from repowise.server.mcp_server import (get_answer,get_change_risk,diff --git a/tests/unit/server/mcp/test_overview.py b/tests/unit/server/mcp/test_overview.pyindex 52f5454c2..71b030dd2 100644--- a/tests/unit/server/mcp/test_overview.py+++ b/tests/unit/server/mcp/test_overview.py@@ -46,10 +46,10 @@ async def test_get_overview(setup_mcp):@pytest.mark.asyncio-async def test_get_overview_with_repo_path(setup_mcp):+async def test_get_overview_with_repo_path(setup_mcp, tmp_path):from repowise.server.mcp_server import get_overview- result = await get_overview(repo="/tmp/test-repo")+ result = await get_overview(repo=str(tmp_path))assert result["title"] == "Test Repo Overview"diff --git a/tests/unit/server/mcp/test_risk.py b/tests/unit/server/mcp/test_risk.pyindex 1dbe3859d..6a5a7f6fb 100644--- a/tests/unit/server/mcp/test_risk.py+++ b/tests/unit/server/mcp/test_risk.py@@ -92,11 +92,11 @@ async def test_get_risk_normalizes_target_path(setup_mcp):@pytest.mark.asyncio-async def test_get_risk_repo_absolute_target_path(setup_mcp):+async def test_get_risk_repo_absolute_target_path(setup_mcp, tmp_path):"""A repo-absolute target is made repo-relative before the lookup (#1279)."""from repowise.server.mcp_server import get_risk- abs_target = "/tmp/test-repo/src/auth/service.py"+ abs_target = str(tmp_path / "src" / "auth" / "service.py")result = await get_risk([abs_target])t = result["targets"][abs_target]assert t["hotspot_score"] == 0.92