# cargo-coverage-gate implementation
This guide describes how the crate turns LCOV records into deterministic
failure diagnostics. The user-visible behavior is defined by the
[design](design/README.md).
## Diagnostic pipeline
1. The LCOV parser merges reports by source path and line number. A line is
coverable when it has a distinct `DA:` record. Hit counts determine the
covered subset, while sorted coverable and uncovered line numbers remain
available for diagnostics.
2. Attribution maps each source file to the most specific workspace member
whose manifest directory contains it. Aggregation computes exact package
counters from the attributed files.
3. Verdict evaluation selects diagnostic locations by status. Numeric failures
select uncovered lines, unexpected-coverable-lines failures select all
coverable lines, and passing or no-data outcomes select none. Paths are made
relative to the package manifest directory when possible, then diagnostics
are ordered by package, path, and line.
4. The terminal and Markdown renderers share the same detail and range
formatting. Each renderer emits at most 100 locations per package and
computes the omitted count from the complete diagnostic set, so truncation
does not alter aggregate counts or conceal how much output was omitted.
## Invariants
- Coverable line numbers are unique because the parser merges records by line
number, and ascending because `FileReport` construction explicitly sorts
them.
- Uncovered lines are a subset of coverable lines.
- Package counters describe the complete attributed input, independent of the
rendered location limit.
- Both renderers consume the same status-specific diagnostics and preserve
deterministic ordering.
- A no-data outcome is explanatory rather than location-bearing because there
are no attributed LCOV records to name.
## Display bound
The 100-location limit keeps a package's failure detail to a few kilobytes
while retaining enough context to show multiple clusters of missed code. The
limit is a presentation bound rather than a coverage-data bound: exact totals
and the omitted count still describe the full report. Reevaluate it when real
failure reports show that useful first clusters are routinely omitted or that
the resulting CI summaries are still too large.