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
perf(change-risk): skip the change blocks on a finding_id drill-down (#3925)
Raghav Chamadiya63e093010e06
diff --git a/packages/server/src/repowise/server/mcp_server/tool_change_risk.py b/packages/server/src/repowise/server/mcp_server/tool_change_risk.pyindex ce1487111..17a3841e3 100644--- a/packages/server/src/repowise/server/mcp_server/tool_change_risk.py+++ b/packages/server/src/repowise/server/mcp_server/tool_change_risk.py@@ -403,9 +403,19 @@ async def get_change_risk())try:- await _attach_change_blocks(- ctx, payload, result, revspec, extensions, (changed, changed_error), collector, includes- )+ # A drill-down returns one finding and nothing else, so the tests,+ # coverage, fix and cross-repo blocks would never reach the caller.+ if finding_id is None:+ await _attach_change_blocks(+ ctx,+ payload,+ result,+ revspec,+ extensions,+ (changed, changed_error),+ collector,+ includes,+ )independent = await _attach_branch_blocks(ctx, payload, changed, collector, revspec, finding_id)diff --git a/tests/unit/change_health/test_mcp_contract.py b/tests/unit/change_health/test_mcp_contract.pyindex 60b72a6e5..cfffa14e6 100644--- a/tests/unit/change_health/test_mcp_contract.py+++ b/tests/unit/change_health/test_mcp_contract.py@@ -134,6 +134,20 @@ async def test_a_surfaced_finding_can_be_expanded_by_its_id(tool, make_repo):assert "evidence" in detail["finding"]+async def test_a_drill_down_skips_the_blocks_it_never_returns(tool, make_repo, monkeypatch):+ module = tool(seeded(make_repo))+ listing = await module.get_change_risk("HEAD", baseline=0)+ row = listing["health_delta"]["top_findings"][0]++ async def _unexpected(*_a, **_k):+ raise AssertionError("a drill-down needs no tests, coverage or fix blocks")++ monkeypatch.setattr(module, "_attach_change_blocks", _unexpected)+ detail = await module.get_change_risk("HEAD", baseline=0, finding_id=row["id"])++ assert detail["finding"]["id"] == row["id"]++async def test_an_unknown_finding_id_says_so_and_lists_the_real_ones(tool, make_repo):module = tool(seeded(make_repo))