From c000091b7eef9e44a719c1c3d860c673ebed3455 Mon Sep 17 00:00:00 2001 From: danusha2345 Date: Wed, 21 Oct 2026 20:54:28 +0300 Subject: [PATCH] test(explore): a held run shorter than the dedup threshold may come back inside the block around it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2756. `explore-cross-call-dedup`'s handler case failed on main since #2655: call 1 now serves the 7-line `RunResult` struct of cycle.go (the struct references `Payslip` through its field), and call 2 re-sends those lines inside its render of the file's head. That is rule 3 of the range algebra, not a bookkeeping gap — the session record holds L31-37, and a held run shorter than MIN_COVERED_LINES is re-emitted whole rather than replaced by a pointer, so the block is not shredded. The test now fails only on a repeated run at least that long. Co-Authored-By: Claude Fable 5.1 --- __tests__/explore-cross-call-dedup.test.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/__tests__/explore-cross-call-dedup.test.ts b/__tests__/explore-cross-call-dedup.test.ts index ce208dc95..93e1eea53 100644 --- a/__tests__/explore-cross-call-dedup.test.ts +++ b/__tests__/explore-cross-call-dedup.test.ts @@ -265,11 +265,23 @@ describe('a second call against a real index', () => { // the pointer names it. expect(second).toContain(POINTER); for (const [file, lines] of before) { - const repeated = [...(after.get(file) ?? [])].filter((n) => lines.has(n)); + const repeated = [...(after.get(file) ?? [])].filter((n) => lines.has(n)).sort((a, b) => a - b); if (repeated.length === 0) continue; - // The only sanctioned repeat is the anti-abandonment restore, which fires - // ONLY when the call found nothing new to say — and this one did. - throw new Error(`call 2 re-sent ${file} lines ${repeated.slice(0, 5).join(',')}`); + // Two sanctioned repeats. The anti-abandonment restore fires ONLY when + // the call found nothing new to say — and this one did. And rule 3 of + // the range algebra: a held run shorter than MIN_COVERED_LINES is + // re-sent inside the block around it rather than replaced by a pointer + // (the 7-line `RunResult` struct of cycle.go, held by call 1, comes back + // whole inside call 2's render of the file's head — #2756). Any longer + // run is a duplicate. + const runs: number[][] = []; + for (const n of repeated) { + const run = runs[runs.length - 1]; + if (run && n === run[run.length - 1]! + 1) run.push(n); + else runs.push([n]); + } + const long = runs.find((run) => run.length >= EXPLORE_DEDUP.MIN_COVERED_LINES); + if (long) throw new Error(`call 2 re-sent ${file} lines ${long.slice(0, 5).join(',')}`); } }, 120_000);