Skip to content

fix(cli): enforce Test gap new-file Budget - #769

Merged
avidianity merged 4 commits into
mainfrom
fix/issue-758
Dec 2, 2026
Merged

avidianity merged 4 commits into
mainfrom
fix/issue-758

Conversation

@avidianity

@avidianity avidianity commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Enforce new_file_budgets.production.test_gap on newly added Production files in codeint diff.
For an explicit --head, read Coverage reports from that ref and report any missing configured path.

Closes #758

Tier

Tier 2 from cargo xtask risk-tier --base origin/main. The CLI and report changes match the default tier.

Task

Enforce the Test gap new-file Budget specified in #513.

  • Exit 1 and report a Test gap new-file Budget failure when newly added Production files exceed the configured ratio.
  • Pass when the ratio meets the Budget or a diff only edits existing files.
  • Use the working-tree report for a working-tree diff and the selected ref's report for --head.
  • Exit 2 and name the configured path when the selected head ref lacks the report.

Fail-first test

  • Test test_gap::diff_enforces_test_gap_budget_on_new_production_files.
  • Before the change, the test ran and failed on main 2910ef78 with left: Some(0) and right: Some(1) for the exit code from codeint diff main.
  • After the change, the named test ran and passed alongside the other 18 targeted tests from the worktree's own Cargo target.

The mixed-language regression also ran and failed before its fix with left: Some(0) and right: Some(2).
It passed after the fix.

Checks

  • cargo test --locked -p codeint --test integration test_gap passed all 19 tests.
  • The Git snapshot symlink test ran and passed, including the committed blob size boundary.
  • Pre-commit and commit-message hooks passed.
  • The reference-example integration test and the repository self-check passed after addressing the initial CI failures.
  • cargo xtask merged-result passed.
  • GitHub checks for the rebased head.
  • Independent review passed at 07640295. Three diff tests ran and passed. The reference example test passed locally. The rebase preserved all four patches.

Safety proof

The Coverage report belongs to the snapshot measured by the new-file Budget.
The regression runs the same diff twice with different report contents on disk and in the selected ref.
The working-tree diff passes with full coverage, and the explicit ref fails with production test_gap ratio 1.0 from its committed report.
The test also removes the local report and confirms a diff with only an existing file edit passes.
A mixed-language fixture verifies that coverage on a functionless new file cannot yield a passing Budget for an uncovered new Function.
The committed-report path checks the Git blob size before reading the contents and preserves the unmatched-source-path diagnostic.

Runtime evidence

PASS on the reviewed patch and its final rebase 07640295 using a temporary Python Git repository and LCOV report.
The diff feature map defines the exit 1 contract for new-file Budget violations.
In the reproduction, codeint check --format text reports worker.py:1 run untested=100%.
After the fix, codeint diff HEAD --format text exits 1 and prints the new-file production test_gap ratio 1 is over its new-file Budget 0.
The integration test asserts the JSON result, successful recovery with updated coverage, and exit 2 when the explicit ref lacks coverage.
Temporary repositories and caches contain synthetic fixtures only.

Metric versions

No Metric changes its Finding IDs or values on unchanged code.
The fix applies the existing Test gap calculation to the new-file Budget.

Gaps

  • Deferred coverage: none.
  • Pre-existing failures: none in the targeted suite. Rename detection on main already reads generic added and deleted Git blobs before metric evaluation. The Coverage report loader enforces its own per-report limit.
  • Environmental failures: none in the final local run.

@avidianity avidianity closed this Dec 2, 2026
@avidianity avidianity reopened this Dec 2, 2026
@github-actions github-actions Bot added the tier-2 Tier 2 from the tier check label Dec 2, 2026
@avidianity avidianity closed this Dec 2, 2026
@avidianity avidianity reopened this Dec 2, 2026
@avidianity avidianity closed this Dec 2, 2026
@avidianity avidianity reopened this Dec 2, 2026
@avidianity avidianity closed this Dec 2, 2026
@avidianity avidianity reopened this Dec 2, 2026
@avidianity
avidianity merged commit f6f910d into main Dec 2, 2026
19 checks passed
@avidianity
avidianity deleted the fix/issue-758 branch December 2, 2026 18:41
@avidianity avidianity mentioned this pull request Dec 2, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tier-2 Tier 2 from the tier check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new_file_budgets.production.test_gap is never enforced

1 participant