Repository navigation
[quality] the e2e region fold's same-key max arm has no unit coverage #1141
Description
Finding
getRegionCoverage (tests/tools/e2e-coverage-report.mjs:344-365) keys an e2e
region on its original line:startColumn:endLine:endColumn and keeps the higher
of two counts recorded against one key:
const count = counts?.[index] ?? 0;
const existing = regions.get(key);
if (!existing || count > existing.count) {
regions.set(key, { line, endLine, count });
}The count > existing.count arm at line 360 has no unit coverage, and it is
not a corner case. normalizeRanges rewrites a V8 record into a flat,
non-overlapping run of ranges, so an inner zero-count range in the middle of a
line splits that line into an uncovered range and a covered remainder. Both
halves map back through the source map to the same original span — the
generated columns they begin at carry no mapping of their own, so each resolves
to the mapping that precedes it — and v8-to-istanbul emits one branch for
each. Keyed by branch id they would be two regions, one of them permanently
zero; keyed by coordinates they are one region that the covered half carries.
That fold is therefore load-bearing for every file the e2e report measures, not
only for the two-build union it was written for. Drop it and the report invents
an uncovered region in each one.
Evidence and provenance
-
Unit — not covered.
npm run test:unit:coverage
(TZ=UTC node tests/tools/coverage-report.mjs, node v26.10.0) run locally on
2026-10-07 atmain=7ab301e:tests/tools/e2e-coverage-report.mjs | 100.00 | 92.89 | | 193 260-261 306 308 331 346-347 350-351 354 356 358 360 437 ...Line 360 is in that list.
collectE2ECoverage unions the two builds of one source file(tests/e2e-coverage-report.test.mjs:403) pins the union across
scripts and the!existingarm, but every region in its fixture lands on a
key only one of the two builds emits, so the max arm is never taken. -
End-to-end — not applicable.
tests/tools/is the harness the suite runs
on, not shippedsrc/**; the e2e reporter measuressrc/**only, so no
end-to-end evidence exists or is claimed for this path. Stated as a limitation
rather than inferred as a gap. -
Priority 2.
Recommendation
- a test drives a V8 record whose inner zero-count range stops short of the
end of its line, so the two halves resolve to one original span with
counts0and1, and asserts the file reports 2 regions both
covered rather than 3 regions with line 2 named - the same fixture measured by the real build and the
/e2e-coverage-variant/build folds to the same two regions instead of
four -
tests/tools/e2e-coverage-report.mjsline 360 leaves the uncovered-region
list
The PR below lands all three: the file moves 92.89% → 93.15% and line 360 is
gone from the list. Both cases were mutation-checked — replacing the guard with
if (!existing) (first wins) and adding branchId to the key each turn both
red.
Coordination
The change is one new file, tests/e2e-coverage-region-union.test.mjs. It does
not edit tests/e2e-coverage-report.test.mjs (occupied by #1114),
tests/e2e-coverage-scripts.test.mjs (#1128),
tests/e2e-data-fixture-loader.test.mjs (#1130), or
tests/tools/e2e-coverage-report.mjs itself. A separate test file beside
tests/e2e-coverage-run.test.mjs and tests/e2e-coverage-scripts.test.mjs
follows the repository's existing split. No workflow file is involved:
.github/workflows/ci.yml already runs test:unit:coverage:check, which stays
green (exit 0) with the new file.
This is distinct from #1066 / #1079, which are about whether the two builds
emit matching coordinates in a real run. This issue is about the fold that runs
once those coordinates do match — a property reachable today, from a unit
fixture, with no variant build.
Priority
- Impact: medium (an unpinned invariant in the reporter every coverage gate in
the repository reads) - Effort: low
🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-5n31 | SHA: 7ab301e
— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88
Activity