Skip to content

feat(coverage): test<->source mapping via coupling + MCP tool (bo-u5z2)#35

Merged
scbrown merged 2 commits into
mainfrom
bo-u5z2-coverage-mapping
Jun 28, 2026
Merged

feat(coverage): test<->source mapping via coupling + MCP tool (bo-u5z2)#35
scbrown merged 2 commits into
mainfrom
bo-u5z2-coverage-mapping

Conversation

@scbrown

@scbrown scbrown commented Jun 28, 2026

Copy link
Copy Markdown
Owner

What

Infer test↔source coverage from temporal coupling. A test and the source it exercises co-change in git, so the existing FileCoupling table already encodes the link — this surfaces it explicitly:

  • Source file → the test files that cover it
  • Test file → the source files it covers

Adds a bobbin coverage CLI command and a test_coverage MCP tool. Editing auth.rs can now auto-surface test_auth.rs.

How

  • src/index/coverage.rsderive_coverage() is a pure function: takes the rows from get_coupling(file) and keeps only the ones on the opposite side of the test/source divide, using the existing path-based classify_file() heuristic. Fully unit-tested (4 cases), no DB needed.
  • CLI mirrors bobbin related (canonicalize → verify indexed → query coupling → derive → JSON/human output).
  • MCP test_coverage tool mirrors the related tool; 26 → 27 registered tools.
  • Docs: primer tool list, book/src/mcp/tools.md, new book/src/cli/coverage.md + SUMMARY entry.

Design note (scope)

The bead mentioned "AST-based test detection at index time." I used the existing path-based classify_file() (filename + directory conventions: test_*, *_test.*, *_spec.*, tests/, spec/, __tests__/, …) instead. Rationale: it's the mechanism already used across the codebase, requires zero index-time/schema changes, and is robust for the common case. Coverage is derived purely at query time from stored coupling — a co-change heuristic, not execution tracing. If true AST-level (per-function) test detection is wanted later, it's an additive follow-up.

Tests

cargo test --bin bobbin coverage:: — 4/4 green. Build + clippy clean. No tool-name/count assertion exists in the suite to update.

🤖 Generated with Claude Code

scbrown and others added 2 commits June 27, 2026 22:42
Infer test<->source coverage from temporal coupling: a test and the source
it exercises co-change, so the existing FileCoupling table already encodes
the link. Derive it at query time — no index-time schema change.

- New src/index/coverage.rs: derive_coverage() filters get_coupling() rows
  by the test/source divide (classify_file path heuristic). Source file ->
  coupled test files; test file -> coupled source files. Pure + unit-tested.
- `bobbin coverage <FILE>` CLI command (mirrors `related`).
- `test_coverage` MCP tool (26 -> 27 tools).
- Docs: primer tool list, book mcp/tools.md, new cli/coverage.md + SUMMARY.

Detection is path-based (test_*, *_test.*, *_spec.*, tests/, ...) reusing
classify_file — robust for the common case and zero new storage. Coverage is
a co-change heuristic, not execution tracing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GuQ96t4m1vzFQ6v72btayV
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GuQ96t4m1vzFQ6v72btayV
@scbrown
scbrown merged commit 43f4226 into main Jun 28, 2026
5 checks passed
@scbrown
scbrown deleted the bo-u5z2-coverage-mapping branch June 28, 2026 03:06
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