Repository navigation
feat(metrics): add Test gap Metric from LCOV and Cobertura XML Coverage reports - #432
Merged
Merged
Conversation
…dation, and reserved key
…lation, and doc accuracy
avidianity
marked this pull request as ready for review
November 24, 2026 09:45
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.
Summary
Adds the Test gap Metric (
test_gap), measuring the share of Production Function mass that tests do not execute, computed from user-named LCOV and Cobertura XML Coverage reports (ADR 0017).Adds zero-dependency LCOV and hardened Cobertura XML readers with content auto-detection, longest-trailing-segment path matching with Cobertura source roots,
coverage_reportsincodeint.json/codeint.jsoncand repeatable--coverage-reportoncodeint check, per-language and per-package Test gap across TOON/JSON/Markdown/SARIF/MCP,budgets.production.test_gapenforcement, Coverage report content hashing inResultCache,codeint diff/codeint trendomission notes, and user documentation.Leaves all reports for repositories without Coverage reports unchanged apart from the one-line
test_gap_note.Closes #223
Closes #266
Closes #267
Closes #268
Closes #269
Closes #270
Closes #271
Closes #272
Closes #273
Closes #274
Closes #275
Closes #276
Closes #277
Closes #278
Closes #279
Closes #280
Closes #281
Closes #282
Closes #283
Closes #284
Closes #285
Closes #286
Closes #287
Closes #288
Closes #289
Closes #290
Closes #291
Closes #292
Closes #293
Closes #294
Closes #295
Closes #296
Tier
Tier 3 from the tier check (
cargo run --locked -p xtask -- risk-tier --base origin/main): touches.rules(tier map rule".rules") andcrates/plugin-host/src/wasm_metric.rs(tier map rule"crates/plugin-host/**", reserving"test_gap"as a built-in Metric key).Task
Spec #223 (
Spec: Test gap, a Metric for the Function mass that tests do not execute) and sub-issues #266 through #296:coverage_reportsconfig key and schema, repeatable--coverage-reportCLI flag overriding config, Code model coverage filling before Metric plugins, line-beyond-EOF exit-2 error, unmatched paths note, Production-onlytest_gapMetric and reserved key, uncovered-file and 0-listed-line function rules, absent form with one-linetest_gap_note, per-language and per-package Test gap, heaviest-first Findings, JSON report schema (schema/codeint-report.schema.json) andcodeint schema, Markdown and SARIF output, MCP tools, ResultCache content hashing, anddocs/guide/test-gap.mdLCOV setup guide.sources and source elementspath matching, hostile input rejection (DTD, XXE, entity expansion, non-XML PIs, depth cap 64, size cap 64 MiB), and PHPUnit/Pest Cobertura setup guide.budgets.production.test_gap(under/equal pass, over exit 1 with full report, absent coverage exit 2), non-production Test gap budget exit-2 error naming key, MCP over-budget reporting,codeint initstarter mention,codeint diffandcodeint trendone-line omission notes, andregression_limitsTest gap exit-2 error naming key.Fail-first test
crates/metrics/src/coverage/tests.rs(10 unit tests covering LCOV, Cobertura XML, hostile XML rejection, auto-detection, path matcher, traversal rejection, line bounds),crates/metrics/src/test_gap/tests.rs(6 unit tests),crates/config/tests/test_gap.rs(8 tests),crates/plugin-host/src/wasm_metric/tests.rs(test_gapreserved key),crates/report/tests/report_schema.rs,crates/cli/tests/integration/test_gap.rs(12 process-boundary tests), andcrates/cli/tests/plugins.rs(coverage_reader_metric_plugin_receives_filled_function_and_language_coverage_facts).--coverage-reportand symlink escapes were not blocked; MCP relativecoverage_reportsresolved against ambient CWD before target repo;SF:../../...matched via suffix).Checks
cargo fmt --all --checkcargo clippy --workspace --all-targets --locked -- -D warningscargo test --locked -p codeint-config -p codeint-metrics -p codeint-report -p codeint-plugin-hostcargo test --locked -p codeint-cli --lib --test check --test plugins --test referencecargo test --locked -p codeint-cli --test integration -- test_gap::lefthookpre-commit: links, secrets, format, duplicates, markdown, repository; commit-msg)cargo run --locked -p xtask -- merged-result,no-comments --base origin/main,commit-message --range origin/maincargo run --locked -p codeint-cli -- diff origin/main --format toonSafety proof
codeint reportre-rendering of saved pre-Test-gap JSON, andResultCachebehavior, withtest_gapabsent and one-linetest_gap_note; (2) Coverage report loading is strictly contained within the Git repository (rejecting outside paths, symlinks, DTDs, XXE, entity expansion, non-XML PIs, depth > 64, and files > 64 MiB with exit 2 without reading outside files), and Test gap is consistent across LCOV, Cobertura XML, TOON, JSON, Markdown, SARIF,--package,--owner, Budgets, MCP, WASM Metric plugins, andResultCache.234abc4proved Safety Fact 1 across all commands, formats, and saved-report re-rendering; Round 2 clean-rerun Independent & Blast Radius verification on970e2eeempirically proved Safety Fact 2 across outside relative/absolute/prefix-collision/symlink probes,ResultCachesymlink isolation, MCP cross-repo CWD isolation,PathMatcherparent-traversal rejection, macOS/varcanonicalization, and schema/docs parity.interrogate:234abc4, FAIL): Blast Radius found 3 path-containment defects (outside--coverage-report/ MCPcoverage_reportstraversal and symlink escape incodeint.json) plusPathMatchermatching leading..; Independent Verifier found MCP CWD resolution bug (crates/cli/src/check/coverage.rs:54) and doc drift indocs/reference.md:1520,1556anddocs/guide/mcp.md:43. All fixed in970e2eewith regression tests.970e2ee, Independent & Blast Radius Verifier on isolated worktree): verified every Round 1 fix againsttarget/debug/codeint-> Safety Fact 2 PROVEN, Verdict: PASS (0 open verified findings).Runtime evidence
Build revision:
970e2eeonfeat/223-test-gap.Verified against built
target/debug/codeintbinary acrosscheck,diff,trend,report,init,schema,doctor, andmcp(JSON, TOON, Markdown, SARIF) with LCOV, Cobertura XML, mixed-format, hostile XML, outside-repo/symlink containment, WASM Metric plugin, andResultCacheprobes; verdict: PASS.Gaps