feat(coverage): test<->source mapping via coupling + MCP tool (bo-u5z2)#35
Merged
Conversation
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
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.
What
Infer test↔source coverage from temporal coupling. A test and the source it exercises co-change in git, so the existing
FileCouplingtable already encodes the link — this surfaces it explicitly:Adds a
bobbin coverageCLI command and atest_coverageMCP tool. Editingauth.rscan now auto-surfacetest_auth.rs.How
src/index/coverage.rs—derive_coverage()is a pure function: takes the rows fromget_coupling(file)and keeps only the ones on the opposite side of the test/source divide, using the existing path-basedclassify_file()heuristic. Fully unit-tested (4 cases), no DB needed.bobbin related(canonicalize → verify indexed → query coupling → derive → JSON/human output).test_coveragetool mirrors therelatedtool; 26 → 27 registered tools.book/src/mcp/tools.md, newbook/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