Skip to content

test(explore): make the cross-call dedup assertion line-ending independent - #2767

Closed
LuisAlbertoMK wants to merge 1 commit into
colbymchenry:mainfrom
LuisAlbertoMK:fix/explore-dedup-sliver-assertion
Closed

LuisAlbertoMK wants to merge 1 commit into
colbymchenry:mainfrom
LuisAlbertoMK:fix/explore-dedup-sliver-assertion

Conversation

@LuisAlbertoMK

Copy link
Copy Markdown

What

__tests__/explore-cross-call-dedup.test.ts fails on an LF checkout — i.e. on Linux/macOS CI. It passes on Windows only because CRLF pushes the fixture past the first call's byte budget.

Why it fails

The test asserts that call 2 re-sends no line from call 1. That is stronger than what dedup promises. In dedupeRange, only covered runs of at least EXPLORE_DEDUP.MIN_COVERED_LINES (8) are withheld; shorter runs are emitted deliberately ("cut chunks, not slivers" — an 8-line run is the shortest pointer worth its own ~140 chars).

With LF fixtures the byte budget fits the whole payroll-go fixture into call 1, so call 2 has nothing fresh to send. It falls back to the anti-abandonment restore (suppressedFallback), which puts one withheld file back in full — 5 lines of internal/usecase/payroll/cycle.go — alongside the pointer. CRLF versions of the same 19 fixture files add ~19 bytes each, truncating call 1 and leaving real work for call 2, which hides the problem.

Reproduction on efff7457 with LF fixtures:

AssertionError: call 2 re-sent payroll-go internal/usecase/payroll/cycle.go lines 31,32,33,34,35

What this changes

Test-only. The assertion now matches the contract:

  • a served run of at least MIN_COVERED_LINES is never re-sent;
  • shorter runs may reappear (they are emitted by design);
  • when a call found nothing new (freshLines === 0), exactly one file comes back — the restore, not a dedup leak.

The pointer assertion is unchanged.

Verification

  • Pristine efff7457 worktree, 3× LF and 3× CRLF: 26/26 passed in all six runs.
  • Mutation check: with the covered.length === 0 guard short-circuited in dedupeRange (dedup effectively off), the suite fails with expected [] to deeply equal [ { start: 100, end: 140 } ] and the missing "Already sent earlier in this conversation" pointer.
  • No source changes; nothing else in the suite touched.

…hreshold

The test fails on an LF checkout. The budget is bytes, not files, so the
payroll-go fixture fits whole into the first call there and the second call
has nothing new to send; the anti-abandonment restore then returns one
withheld file — five lines, under MIN_COVERED_LINES (8), which dedupeRange
emits on purpose ("cut chunks, not slivers"). CRLF adds ~19 bytes per file,
truncating the first call, which is why it only passed by accident.

Assert the contract instead of the accident: a served run is never re-sent
whole, runs shorter than the threshold may reappear, and a call that found
nothing new restores exactly one file.
@colbymchenry

Copy link
Copy Markdown
Owner

Thanks for tracking this down, @LuisAlbertoMK, and for the clear write-up of why only LF checkouts failed. The same fix landed as #2772 shortly after you opened this: it allows a held run shorter than MIN_COVERED_LINES just as you proposed, and also gives the suite's fixture copy LF line endings so every platform tests the same bytes. It's a test-only change, so nothing ships; we're closing this as covered by #2772.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants