tests_covering
Answers the question “which tests exercise internal/foo/bar.go?” so the agent can scope run_tests or run_failing_tests to the minimum packages that matter — rather than rerunning the whole suite after every edit.
The session coverage index is populated by run_tests on every Go run and queried by tests_covering. No extra test run is needed.
Schema
Section titled “Schema”| Param | Type | Required | Default |
|---|---|---|---|
file | string | yes | Workspace-relative path to the source file (e.g. internal/tools/read.go). |
line | number | no | 1-based line. Omitted = any line in the file. |
Behaviour
Section titled “Behaviour”- If the coverage index isn’t configured on the server → error.
- If no
run_testscall has produced coverage yet in this session → text resultno coverage data yet — run run_tests first. - If
fileis missing or blank → error. - If
filehas no entry in the index → text resultno coverage found for <file>. - If
lineis set but no test covers that line in the file → text resultno coverage found for <file>:<line>. - Otherwise → a text block listing the covering tests, grouped by Go import path, capped at 200 entries with a
... (N more truncated)footer (same style aslast_test_failures).
Attribution model (v1)
Section titled “Attribution model (v1)”Attribution is package-level, not per-test.
Go’s standard -coverprofile=<path> is a per-run aggregate — it doesn’t split coverage per individual test. For each profile record that touched a source file, tests_covering attributes every test that ran in that file’s package during the same run. In practice this is the right unit of work for an agent: reruns happen per-package anyway via go test -run '^TestX$' <pkg>.
Splitting coverage per test would require running tests one-at-a-time with -run ^TestX$ -coverprofile, which is expensive and defeats the point of targeted reruns.
Language support
Section titled “Language support”- Go — supported. The Go detector’s
go test -json -count=1is augmented with-coverprofile=<tempfile>on everyrun_testsinvocation; the profile is parsed, ingested into the session index, and the tempfile is removed. - Node / Python / Rust — not yet wired.
run_testson these languages leaves the index empty, sotests_coveringreturnsno coverage data yet.
Examples
Section titled “Examples”After a passing Go run:
{"tool": "run_tests"}Find the tests covering a file:
{"tool": "tests_covering", "arguments": {"file": "internal/tools/read.go"}}Sample output:
3 test(s) cover internal/tools/read.go:
github.com/altairalabs/codegen-sandbox/internal/tools: TestRead_ReturnsNumberedLines TestRead_OffsetAndLimit TestRead_MarksFileAsReadScope to a specific line:
{"tool": "tests_covering", "arguments": {"file": "internal/tools/read.go", "line": 42}}Store semantics
Section titled “Store semantics”- Session-scoped. Process-local; no persistence across restarts.
- Overwritten on every
run_testscall (same contract as the structured-failure store). There is no merged history.
Related
Section titled “Related”- run_tests — produces the coverage profile this tool indexes.
- run_failing_tests — natural follow-up for reruns targeted at covering tests.
- last_test_failures — same session-scoped store pattern.