Bound the c8 coverage merge with its incremental mode and a 3 GiB heap
Every pm-github PR's release gate fails after all tests pass, because the c8 merge runs out of its 12 GiB heap on hosted runners (for example #213, run 41575208429). Tracked by pm-github-vhi6.
Cause
c8 12's default merge holds every raw child-process receipt. The sync-pipeline tests spawn real pm CLI children, and almost all of each receipt is code outside the inventory. On 10e9fdd there were 3,839 receipts (10.07 GB), and peak RSS reached 12.2 GiB.
| Component | Serialized bytes |
|---|---|
| Inventory-matching script entries | 4,689,282 |
| Other script entries | 9,004,210,507 |
| Other source-map cache values | 1,059,962,540 |
Change
scripts/coverage-gate.tspasses c8's native--merge-async, which folds one receipt at a time into its accumulator. c8's remapping and inclusion logic are unchanged, and there are no custom URL filters.- The heap ceiling drops from 12288 to 3072 MiB. Measured peak RSS on the full gate is 1.59 GiB, about 1.4 GiB under the ceiling.
- The 28-module inventory, the four 100 % thresholds,
--all,--exclude-after-remap, includes and the test set are unchanged.
Proof
- The real-c8 test writes 512 excluded receipts (158 MB serialized), and the gate must pass with a 128 MiB merge heap. Removing
--merge-asyncreproduces the out-of-memory failure. - The same test checks that an included source keeps its executed counts and still fails on an uncovered line, and that an unloaded module still fails.
- Full
npm run release:checkin an independent clone passes 1609/1609 tests, with 100 % lines, statements, functions and branches. - Measurements and reproduction commands: docs/bounded-coverage-merge.md.
pm-github-privacy-store-followup is closed. The unreachable commit identity it reported came from #214's re-authored agent commits, and that object is gone from the local store.
Summary by Sourcery
Bound c8 coverage aggregation memory and preserve release-gate correctness under large test suites.
Bug Fixes:
- Prevent coverage release gates from exhausting memory when aggregating large numbers of c8 receipts.
- Preserve inherited Node heap limits for test workers without allowing them to raise the coverage merge ceiling.
- Resolve the unrelated unreachable commit identity reported by whole-store privacy checks.
Enhancements:
- Use c8’s incremental merge mode while retaining the existing coverage inventory, remapping, inclusion rules, thresholds, and test set.
Documentation:
- Add documentation covering coverage-memory measurements, validation, reproduction steps, and the bounded merge behavior.
Tests:
- Expand coverage regression tests to validate bounded receipt aggregation, coverage failures for uncovered lines and branches, unloaded modules, and inherited heap-option handling.
Summary by cubic
Fixes the release gate failing after all tests pass, because c8's default merge retained every raw child-process receipt and exhausted its 12 GiB heap. The coverage gate now uses c8's native --merge-async to fold one receipt at a time into its accumulator, and the heap ceiling drops from 12288 to 3072 MiB; measured peak RSS on the full gate is 1.65 GiB, about 1.4 GiB under the ceiling.
c8's remapping and inclusion logic are unchanged, with no URL filters added. The 28-module inventory, the four 100% thresholds, --all, --exclude-after-remap, includes, and the test set are unchanged. Inherited NODE_OPTIONS heap limits keep working for test workers: the gate removes them from the c8 merge environment so the merge stays under the 3072 MiB ceiling, then passes them to the nested node --test command, which forwards them to its workers. The sanitizer tokenizes like Node (splitting on spaces only, honoring quoted parts and escapes) and preserves unrelated options byte-for-byte.
Regression coverage
- The real-c8 test writes 512 excluded receipts (158 MB serialized) and also runs a branch-only fixture, so fully covered lines with an untaken branch must still fail; removing
--merge-asyncreproduces the out-of-memory failure. - The heap-routing test asserts the literal
--max-old-space-size=3072ceiling, so changing the constant fails the test. - Tests pin the sanitized
NODE_OPTIONSand the heap limits re-injected for the nested test command (dropping the re-injection fails them), cover bare, quoted, and percentage forms plus options containing tabs, and a probe checks that a worker keeps an inherited limit while the merge stays bounded; the probe spawns the same Node executable the gate nests, so it passes under both Node and Bun. - Full
npm run release:checkin an independent clone passes 1629/1629 tests with 100% lines, statements, functions, and branches; measurements and reproduction commands are indocs/bounded-coverage-merge.md. - The unreachable commit identity reported by
pm-github-privacy-store-followupis resolved: it came from #214's re-authored agent commits and the object is gone from the store.