Skip to content

fix(report): retain Baseline coverage for regrouped clones - #773

Merged
avidianity merged 8 commits into
mainfrom
fix/765-duplication-baseline
Dec 2, 2026
Merged

avidianity merged 8 commits into
mainfrom
fix/765-duplication-baseline

Conversation

@avidianity

@avidianity avidianity commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Duplication Baselines cover hashed clone line occurrences, so a surviving duplicate keeps its coverage when overlapping Clone groups combine.
A normal codeint baseline update records occurrence anchors for existing Clone group IDs at the same Metric version.
codeint state check verifies the upgrade against the base commit and rejects added coverage.

Closes #765

Tier

Tier 3 from cargo xtask risk-tier --base origin/main.
The check detects the assertion changed to expect the new measurement cache version.

Task

  • Cover surviving clone lines when removing a copy changes or combines the groups.
  • Fail a zero Duplication Budget on genuinely new clone lines.
  • Upgrade a legacy Baseline without adding a Finding ID or changing the Metric version.
  • Accept the verified upgrade in codeint state check and reject widened coverage.

Fail-first test

  • baseline::duplication_baseline_covers_surviving_overlapping_clone_spans ran before the fix and failed on main at bf7df913.
    codeint: the production duplication ratio 0.7018 is over its Budget 0
  • baseline::duplication_baseline_update_upgrades_legacy_groups_without_adding_finding_ids ran before the upgrade implementation and failed with plain Baseline update must add clone line anchors.
  • Both named tests pass after the fix.

Checks

Check Result
cargo test --locked -p codeint --test integration baseline:: 18 passed, including all four named Duplication regressions
Targeted commit cache integration tests 3 passed
cargo test --locked -p codeint-config --lib state_check:: 7 passed
Commit and merge hooks Passed
Merged-result check on d71f39529cabb9eebd60f04f74a4c04b48f4e5e1 Passed
Self-check (codeint check and codeint diff origin/main) Passed after extracting state comparison from the CLI entry point
GitHub CI Running on the refreshed head
Independent review Approved on a6096a65. Two subsequent base merges needed no conflict resolution.

Safety proof

  • Safety fact: Extending a legacy Baseline entry with clone occurrence anchors cannot cover a line outside the base commit's existing matching groups.
  • Proof: The upgrade test preserves both old IDs, keeps the Metric version, and passes state check.
    It then adds an occurrence under an unchanged ID and verifies that state check rejects it.
    Adding a new copy also fails its zero Budget and reports only its uncovered line share.
  • Adversarial checks: The same-ID widened upgrade and the already-upgraded Baseline tamper both fail state check.

Runtime evidence

PASS at d71f39529cabb9eebd60f04f74a4c04b48f4e5e1.
The integration tests run the real CLI in temporary Git repositories with the three-file reproduction and a zero Duplication Budget.
The Baseline passes before the edit, then clone lines fall from 56 to 40 and the check and diff both pass.
The legacy upgrade test reads the written Baseline, confirms unchanged Finding IDs and Metric version, and exercises the state gate against a committed legacy file.
Temporary Git repositories are removed by the test harness.
Reproduce with cargo test --locked -p codeint --test integration baseline::duplication_baseline.

Gaps

  • Deferred coverage: Legacy upgrade verification uses built-in Language plugins to measure the base commit.
  • Pre-existing failures: None in scoped checks.
  • Environmental failures: None in scoped checks.
  • Metric changes: No Metric values or Finding IDs change on unchanged code.

Record hashed clone line occurrences so deleting a copy cannot expose surviving duplicates to the Budget. Count each uncovered line once, and reject Baseline edits that grant new coverage.

Closes #765
Convert unchanged group IDs to line coverage. Verify the upgrade against the base commit before accepting it in state check.
@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
@github-actions github-actions Bot added the tier-3 Tier 3 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 merged commit 1aeca75 into main Dec 2, 2026
20 checks passed
@avidianity
avidianity deleted the fix/765-duplication-baseline branch December 2, 2026 19:33
@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-3 Tier 3 from the tier check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codeint check flags surviving duplicates after duplication decreases

1 participant