Skip to content

feat: test-to-code mapping (tests_for/untested) + cgh impact CI mode#71

Merged
joy-software merged 1 commit into
developfrom
feat/test-mapping-ci
Jun 7, 2026
Merged

feat: test-to-code mapping (tests_for/untested) + cgh impact CI mode#71
joy-software merged 1 commit into
developfrom
feat/test-mapping-ci

Conversation

@joy-software

Copy link
Copy Markdown
Contributor

Batch D (FEAT-3, FEAT-10). Both built on a shared analysis/impact.py helper. 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

  • test_tests_mapping.py (4) + test_impact.py (2); server/cli/indexer suites: 141 passed, 2 skipped
  • ruff + no-ai-tells clean

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.
@joy-software joy-software merged commit ba02caf into develop Jun 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant