Commit 2dc543d
test(portal): regression tests + INVARIANTS rows for correctness wave 2A (7 tests, mutation-verified)
The source fixes for all five wave-2A bugs landed in the parent commit; this
adds the regression coverage, invariant-catalog rows, and the fixed-gaps
provenance that make them a merge-gated package. Every test bites: reverting
the corresponding fix hunk (tests kept) fails the named test — verbatim
assertions recorded in INVARIANTS.md "Wave 2A".
FIX 1 (head-clamp, BUG-B) — two tests in portal.test.ts:
• a BOUNDED backfill whose toBlock is PAST the head is head-clamped so a later
interval over the newly-finalized tail is fetched, not blind-cache-hit. The
distinct shape vs the existing unbounded frontier-extend test: dataEnd() used
to return backfillEnd and ignore the head, recording phantom coverage to the
toBlock. Mutant (dataEnd = backfillEnd ?? head ?? ∞) → block 150's log lost.
• discovery variant: a factory child created in the newly-finalized tail is
discovered + its log fetched once the head advances (head-clamped discovery).
FIX 2 (construction-time discovery floor, BUG-A) — one test:
• an EARLY spanning-chunk fetch issued with requiredFactoryIntervals=[] still
runs discovery: the child log is fetched AND its address flushed. Mutant
(floor pinned only when requiredFactoryIntervals.length > 0) → the
strengthened INV-3 tripwire fires (through:-1) exactly where the old
discStartIdx===undefined escape used to hide the missed discovery.
FIX 3 (extend-local neededMissing, crash-loop) — a pair:
• an EVENT-LESS extend tail lacking a needed field over a data-bearing base is
TOLERATED (mutant → the whole-cd check throws over the tail: blocks [101,200]).
• an extend tail that DOES add matched rows while lacking a needed field STILL
fails LOUD (over-tolerance guard; passes on both versions).
FIX 4 (trace/transfer receipts) — one test:
• a trace filter with hasTransactionReceipt inserts a receipt for every matched
trace tx. Mutant (buildTraces called without onReceipt) → zero receipts.
FIX 5 (PORTAL_FINALIZED_HEAD pin) — one test in portal-shell.test.ts (INV-9 matrix):
• the pin survives ensureChunkSize probing the live head — an interval above the
pin but below the live head still DELEGATES to RPC. Revert-check
(unconditional portalHead = h) → the above-pin interval is served, not delegated.
INVARIANTS.md: INV-3/INV-9/INV-13/INV-15 rows updated (touched enforcement +
tests), INV-4's stale discStartIdx reference corrected, and five "Wave 2A"
fixed-gaps entries with the triple-blind provenance and mutation evidence.
Gates: sync-upstream.sh --test exit 0 on both 0.16.6 (160/160) and 0.15.17
(160/160); biome check portal/ 0 errors.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 8eaf1a2 commit 2dc543d
3 files changed
Lines changed: 903 additions & 32 deletions
0 commit comments