feat(mcp): impact_analysis tool — variable-depth Cypher (T6)#680
Draft
DvirDukhan wants to merge 1 commit into
Draft
feat(mcp): impact_analysis tool — variable-depth Cypher (T6)#680DvirDukhan wants to merge 1 commit into
DvirDukhan wants to merge 1 commit into
Conversation
Adds the only MCP tool with no pre-existing AsyncGraphQuery backing, inlining a [:CALLS*1..depth] traversal with DISTINCT for cycle safety. api/mcp/tools/structural.py - impact_analysis(symbol_id, project, branch, direction='IN', depth=3) - direction='IN' returns transitive upstream callers (what breaks if you change this symbol); direction='OUT' returns transitive callees. - depth is clamped to [1, IMPACT_MAX_DEPTH=10]; values above 10 are silently clamped, not rejected, so agents can ask for "very deep" without worrying about the cap. - _clamp_depth helper accepts int / stringified int, rejects bool / None / non-numeric strings. - Direction must be 'IN' or 'OUT'; raises before issuing the query. tests/mcp/test_impact_analysis.py (9 tests) - Unit: _clamp_depth normalization + garbage rejection; direction validation; tool registered on the MCP app. - Integration vs the sample-project fixture: upstream(db) and downstream(entrypoint) match the expected.yaml contract; depth=1 from db excludes the 3-hop entrypoint. - Cycle safety: throwaway A-B + C-A graph; DISTINCT ensures no duplicates and the query terminates. - JSON serialisability. tests/mcp/fixtures/expected.yaml - New impact section with upstream_includes_any_of for db and downstream_includes_any_of for entrypoint. Out of scope (per ticket): cross-rel traversal (CALLS only for v1), ranking, cross-branch / cross-repo impact. Closes #654. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced May 27, 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.
Implements T6 (#654) — the only structural tool with no pre-existing
AsyncGraphQuerybacking. Inlines a variable-depth[:CALLS*1..depth]Cypher withDISTINCTfor cycle safety.Stacked on:
index_repo)Tool
impact_analysis(symbol_id, project, branch=None, direction='IN', depth=3):direction='IN'→ transitive upstream callers ("what breaks if I change X?").direction='OUT'→ transitive callees ("what does X reach?").depthclamped to[1, IMPACT_MAX_DEPTH=10]. Above-cap values are silently clamped so agents can ask for "very deep" without erroring.DISTINCT— no manual visited-set, no infinite loop.Tests
tests/mcp/test_impact_analysis.py— 9 tests:_clamp_depthnormalization + garbage rejection; direction validation; tool registered on the MCP app.dband downstream ofentrypointmatch contract entries inexpected.yaml;depth=1excludes the 3-hopentrypoint.Full MCP suite: 34 passed in 22.7s.
Out of scope
Per the ticket: cross-rel traversal (only CALLS in v1), ranking, cross-branch / cross-repo impact.
Closes #654.