feat: test-to-code mapping (tests_for/untested) + cgh impact CI mode#71
Merged
Conversation
Add two MCP tools and a CI-oriented CLI command, all computed on the fly
from existing IMPORTS / CALLS edges plus File.role. No new edge type, no
schema change.
FEAT-3 (server/tools_tests.py):
- tests_for(symbol_or_file): test files that import the target (or, for
a symbol, whose functions call it). Returns the inferred mapping with a
heuristic note, federated across parent + subrepos.
- untested(role, layer): non-test source files no test imports, filtered
by role/layer, capped at 200 with a truncation note.
FEAT-10 (cli/commands_impact.py): `cgh impact --since <ref>` for PR bots.
Diffs the working tree against a git ref, reads the graph read-only (no
MCP owner needed), and emits the changed symbols, the IMPORTS blast
radius grouped by role/layer, endpoints touched, and tests to run. JSON
on clean stdout (--json / --format json) or a markdown PR-comment
summary (--format md). Degrades gracefully when the index is missing or
the graph is locked. Banner and notes go to stderr.
Shared logic lives in analysis/impact.py (pure GraphDB-protocol helpers:
tests_for, untested_files, reverse_import_bfs, symbols_in_file,
endpoints_in_files) so the MCP tools and the CLI stay in lockstep.
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.
Batch D (FEAT-3, FEAT-10). Both built on a shared
analysis/impact.pyhelper. No new graph edge type / no schema change — the mapping is computed on the fly from IMPORTS/CALLS + role classification.FEAT-3 (
server/tools_tests.py)tests_for(symbol_or_file)— test-role files that import (or whose calls reach) the target. Inferred heuristic, not coverage (carries a note).untested(role=, layer=)— non-test source files no test imports, capped.FEAT-10 (
cgh impact --since <ref>,cli/commands_impact.py)Non-MCP CLI for CI/PR bots: diffs since a ref (leading-dash rejected), reports changed symbols, IMPORTS blast radius grouped by role/layer, endpoints touched, and tests to run.
--format md|json. Opens the graph read-only (no owner needed, cmd_status tier-2 path); clean stdout for--json, notes to stderr; exits 1 with a clear message when the index is missing/locked. Help notes the index should be fresh in CI.Test plan