refactor(server): split tool_risk into a package#725
Merged
Conversation
The get_risk MCP tool had grown to ~1034 lines: single-target risk scoring, post-assessment result enrichment, and PR-mode directive assembly (breaking-change, cross-repo, conformance, governance) all in one module alongside the tool entrypoint. Split it into a tool_risk/ package: - assessment.py single-target risk scoring helpers - enrichment.py cross-repo / health / dep-summary result enrichment - directives.py PR-mode directive assembly - get_risk.py the @mcp.tool() orchestrator Pure structural move: every symbol relocates verbatim, lazy imports stay function-local, and absolute sibling imports are preserved. The @mcp.tool() decorator on get_risk stays in get_risk.py and __init__.py imports it, so import-time registration fires exactly once. __init__.py re-exports get_risk plus the helpers routers/git.py and the tests import, so the public path repowise.server.mcp_server.tool_risk is unchanged.
|
✅ Health: 7.6 (unchanged) 📋 At a glance 🚨 Change risk: high (riskier than 88% of this repo's commits · raw 9.7/10)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-07-08 09:53 UTC |
swati510
approved these changes
Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
get_riskMCP tool had grown to ~1034 lines, covering single-target risk scoring, post-assessment result enrichment, and PR-mode directive assembly (breaking-change, cross-repo, conformance, governance) all in one module alongside the tool entrypoint.This splits it into a
tool_risk/package:assessment.pysingle-target risk scoring helpersenrichment.pycross-repo / health / dep-summary result enrichmentdirectives.pyPR-mode directive assemblyget_risk.pythe@mcp.tool()orchestratorWhy
The three phases (score, enrich, build directive) are now isolated and independently testable rather than interleaved in one long module.
Safety
Pure structural move: every symbol relocates verbatim, lazy imports stay function-local, and absolute sibling imports are preserved. The
@mcp.tool()decorator onget_riskstays inget_risk.pyand__init__.pyimports it, so import-time registration still fires exactly once.__init__.pyre-exportsget_riskplus the helpersrouters/git.pyand the tests import, so the public pathrepowise.server.mcp_server.tool_riskis unchanged. No importer or test needed an edit.Verified: the MCP tool registers once and the risk/budget/conformance/blast-radius suites (41 tests) pass.