Repository navigation
feat: add compact file-level impact context - #1144
Merged
2 commits merged intoNov 9, 2026
Merged
2 commits merged into
2 commits merged into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Path handling omits unindexed changes and misrepresents cwd-relative graph paths, while Windows separator mismatches disconnect test edges and cause the new assertions to fail.
3 open issues
What changed in this PR
Adds an opt-in compact impact response so agents can identify affected files without receiving full graph records.
Changes:
- Adds ranked file paths, counts, and truncation markers with a display limit independent of traversal.
- Exposes compact mode through MCP and CLI, plus minimal mode through CLI.
- Documents the response format and adds regression coverage.
| File | Description |
|---|---|
| tests/test_compact_impact.py | Tests compact responses, limits, ordering, and API integration. |
| tests/test_cli_tool_commands.py | Updates expected impact CLI arguments. |
| docs/COMMANDS.md | Documents compact output and CLI controls. |
| code_review_graph/tools/query.py | Builds compact file-level impact responses. |
| code_review_graph/main.py | Exposes compact options through MCP. |
| code_review_graph/cli.py | Adds detail-level and file-limit flags. |
Review effort: Balanced
Comment on lines
+211
to
+214
| return Path(path).relative_to(root).as_posix() | ||
| except ValueError: | ||
| # A graph may include an external file: retain its identity. | ||
| return path |
Contributor
Author
There was a problem hiding this comment.
Fixed in 341f543, with a regression test where applicable.
|
|
||
| if detail_level == "compact": | ||
| compact_response = _compact_impact_response( | ||
| result, root, abs_files, max_files, resolution, |
Contributor
Author
There was a problem hiding this comment.
Fixed in 341f543, with a regression test where applicable.
Comment on lines
+43
to
+44
| kind="CALLS", source=f"{path}::{name}", | ||
| target=f"{paths[0]}::execute", file_path=str(path), line=1, |
Contributor
Author
There was a problem hiding this comment.
Fixed in 341f543, with a regression test where applicable.
- Display requested changed files, not only the ones found in the graph - Map cwd-relative graph paths onto the repository root - Use POSIX qualified names in the fixture's CALLS edges (Windows) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d01c1fd
HengYangDS
pushed a commit
to HengYangDS/code-review-graph
that referenced
this pull request
Nov 9, 2026
…irth8205#1144) A changed file deleted by the change, or a graph row whose file has gone since the build, lost a leading directory that shared the checkout's name: django/x.py in a checkout called django came back as x.py. The cwd-relative fix now applies only to paths the graph stored relative; the caller's own paths are shown as given. The compact changed_files list echoed every requested file, so a whole-repo diff made the compact answer as long as the repository. It now gets the max_files limit with changed_file_count and changed_files_omitted, and the response carries the unmatched_files marker standard and minimal already have. Adds a compact entry to the token budget table and a CHANGELOG entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Linked issue
No separate issue: this is a focused, opt-in response-format improvement found while evaluating impact queries on a large TypeScript repository.
What & why
An agent asking which files to inspect currently chooses between a standard impact response containing full node/edge records and a minimal summary without affected file paths. The CLI also cannot select the existing minimal mode.
Add
detail_level="compact"to the impact tool andimpact --detail-level compact --max-files 25to the CLI. The compact response contains repository-relative paths in the graph's best-first order, counts, omission/truncation markers, and the existing uncertainty/unresolved-call-site information. It skips serialization of full graph records. The new file display limit is independent ofmax_results, so asking to see fewer files does not shrink the graph traversal. The existing standard and minimal responses remain unchanged.On four local impact queries, compact responses used 375–426 tokens versus 27,833–33,901 in standard mode (
cl100k_base, compact native JSON serialization). These are 25-file previews, not lossless replacements for full graph responses: all expected direct production importers appeared on three tasks; the high-fanout task returned 23 of 69 in the preview, versus 31 of 69 in the bounded standard response. Both formats expose omitted context. These application-specific measurements are observational; the included synthetic tests independently verify that the complete affected file set is preserved when it fits the display limit and that the serialized response is less than one quarter of standard size.How it was tested
The full-suite failure is
test_worst_case_args_stay_in_budget[get_affected_flows_tool]: the fallback counter measures 40,129 against a 40,000 ceiling on this macOS temporary-directory layout. It also fails in a separate, unchanged checkout of base commitd72e8fb. This PR does not change that tool or its budget. With optionaltiktokeninstalled, the token-budget module has five failures; the same five reproduce on the unchanged base (cross-repo search, callers-of default/worst, affected flows, review context). No budget thresholds were relaxed.The new tests cover the real graph-store path through Python, MCP, and CLI, file/graph limit independence, hard display bounds, best-first ordering, skipped graph-record serialization, empty changes, an unindexed file's uncertainty marker, and unchanged standard output.
Checklist