Skip to content

test(e2e-coverage): pin attribution to converter.branches and drop the dead functions arm - #1305

Merged
mrbobbytables merged 2 commits into
mainfrom
quality/e2e-coverage-attribution-functions-arm
Oct 11, 2026
Merged

mrbobbytables merged 2 commits into
mainfrom
quality/e2e-coverage-attribution-functions-arm

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

convertScript (tests/tools/e2e-coverage-report.mjs) built attributedPaths
from two arms, each behind a ?? {} guard. Three of those regions can never be
evaluated:

  • the converter.functions arm. v8-to-istanbul writes this.functions[path]
    only under a truthy block.functionName (lib/v8-to-istanbul.js:167,178), and
    normalizeRanges rebuilds every script's V8 record as exactly one block with
    functionName: ''. converter.functions is therefore permanently {}.
  • both ?? {} guards. this.branches = {} and this.functions = {} are set
    in the converter's constructor (lib/v8-to-istanbul.js:36-37) and never
    reassigned.

This reduces the set to the arm that actually decides attribution and records
why the others are gone, so they are not restored later as defensiveness.

Removing a guard is only safe while the premise under it holds, and nothing in
this repository held v8-to-istanbul — a pinned, Dependabot-bumped dependency —
to it. So the same change adds tests/e2e-coverage-attribution.test.mjs, which
states the premises against the installed converter rather than its source,
plus the end-to-end consequence:

  1. branches and functions are {} after load() and object-valued after
    applyCoverage, so neither needs a nullish guard;
  2. an anonymous block attributes both sources of a two-source map through
    branches and none through functions;
  3. a named block does populate functions, for its first range's source only
    — non-vacuity for (2), and the reason that arm would be the weaker signal
    even if normalizeRanges ever named a block;
  4. a two-source bundle keeps both sources in report.sources, including one
    whose coverage is a single uninterrupted covered range — the case
    collectE2ECoverage:786-791 would drop silently, with no diagnostic, if
    attribution ever stopped naming it.

No production code and no workflow changes: both files are under tests/.

Verification

At 4184f33, clean clone, npm ci, node v26.10.0, TZ=UTC:

  • node --test tests/e2e-coverage-attribution.test.mjs → 4 tests, 0 failures.
  • npm run test:unit:coverage:check → 2321 tests, 0 failures, exit 0.
  • Harness region coverage 99.32% → 99.53% (1471/1481 → 1467/1474);
    tests/tools/e2e-coverage-report.mjs 97.98% → 98.57%, its uncovered
    region lines going from 244 627 686 689 691 782 793 1017 1096 to
    244 627 796 807 1031 1110 — the 686/689/691 trio, and nothing else.
  • npx prettier --check clean on both files.

Scope and overlap

Claims exactly one cluster: the attributedPaths expression in convertScript
(tests/tools/e2e-coverage-report.mjs) and the new
tests/e2e-coverage-attribution.test.mjs. Disjoint from #1303, which is on
splitRangeAtBoundaries and its line-627 [range] fallback in the same file,
and from #1294 (tests/tools/coverage-report.mjs, tests/helpers*.mjs scoring)
and #1298 (threshold floors in package.json / tests/coverage-gate-thresholds.test.mjs).

Related Issue

Closes #1304


Filed by quality agent (hold-gated mode). Human review required.

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88

…e dead functions arm

convertScript built attributedPaths from converter.branches and
converter.functions, each behind a '?? {}' guard. Three of those regions
cannot be evaluated: v8-to-istanbul writes this.functions[path] only for a
named block (lib/v8-to-istanbul.js:167,178) and normalizeRanges rebuilds
every script's record as one block with functionName: '', so functions is
permanently {}; and both maps are initialised to {} in the constructor
(lib/v8-to-istanbul.js:36-37), so neither guard can fire.

Reduce the set to the arm that decides attribution and record why the
others are gone. Removing a guard is only safe while its premise holds and
nothing held v8-to-istanbul to this one, so tests/e2e-coverage-attribution
.test.mjs states the premises against the installed converter -- both maps
empty after load() and object-valued after applyCoverage, an anonymous
block attributing both sources through branches and none through
functions, a named block populating functions for its first range's source
only -- plus the end-to-end consequence, that a two-source bundle keeps
both sources in report.sources.

Harness region coverage 99.32% -> 99.53%; tests/tools/e2e-coverage-report
.mjs 97.98% -> 98.57%.

Closes #1304

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

…sidual note and re-record the ceiling

The header list and tests/coverage-gate-thresholds.test.mjs both said 10
unreachable regions capped the file at 97.98%. With the convertScript guards
gone the residual is 7 regions and the ceiling is 98.57%
(harness files 3925/3925 lines, 1467/1474 regions).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 11, 2026
Merged via the queue into main with commit 6685cdc Oct 11, 2026
7 checks passed
mrbobbytables added a commit that referenced this pull request Oct 11, 2026
Rebased onto main: src is 2777/2777 regions, the harness row now includes
tests/helpers*.mjs (5336/5336 lines, 1867/1875 regions, lowest file
helpers-script-sandbox.mjs at 97.06), and e2e-coverage-report.mjs's ceiling
is 98.57 with 7 residual regions. All three ratcheted floors still clear.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Bob Killen <bkillen@linuxfoundation.org>
@mrbobbytables
mrbobbytables deleted the quality/e2e-coverage-attribution-functions-arm branch October 12, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] the e2e coverage attributedPaths set carries a converter.functions arm that can never contribute a path

1 participant