Skip to content

test(explore): the cross-call dedup test passes with LF and CRLF checkouts alike - #2772

Merged
colbymchenry merged 1 commit into
mainfrom
claude/issue-2756-dedup-test-line-endings
Oct 22, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
claude/issue-2756-dedup-test-line-endings

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Summary

__tests__/explore-cross-call-dedup.test.ts › "a second call against a real index › never re-sends a line it already sent, and points at every line it withholds" has failed on every LF checkout (Linux, macOS, CI) since #2655. It kept passing on Windows only because core.autocrlf writes the fixture with CRLF. This makes the case's expectation match the range algebra's deliberate re-send of a short held run, and makes the suite index the same fixture bytes on every checkout. Test only: what agents receive doesn't change.

Root cause

  • Since fix(go): a struct links the types its fields are declared with #2655 the payroll fixture's RunResult struct (internal/usecase/payroll/cycle.go lines 31-37) references Payslip through its Payslips []payroll.Payslip field, so call 1 renders it.
  • Call 2 renders the file's head, and that 7-line held run comes back inside it. dedupeRange keeps a covered run shorter than EXPLORE_DEDUP.MIN_COVERED_LINES (8) in the emit set on purpose: rule 3 of the algebra, "cut chunks, not slivers", pinned by the unit test "withholds nothing when the overlap is smaller than a chunk worth pointing at". The handler case counted any repeated line as a duplicate.
  • Why Windows passed: explore splits a file on \n, so on a CRLF checkout each line keeps its \r and the per-file character budget counts it. cycle.go then rendered fewer lines, and the case never met the short run. The suite tested a different scenario on each platform.

Fix

  • The case groups the repeated lines into consecutive runs and fails on a run of EXPLORE_DEDUP.MIN_COVERED_LINES lines or more. The threshold is read from the module, so the two can't drift apart. A shorter run is the sanctioned re-send, beside the anti-abandonment restore the comment already named.
  • beforeAll gives its copy of the fixture LF line endings (normalizeLineEndings, a byte-exact latin1 rewrite of \r\n only), so every checkout indexes and renders the same bytes, and the other cases' thresholds (fresh > 20, savedChars > 1000, …) are measured on one scenario everywhere.

Validation

Windows 11, CODEGRAPH_KERNEL=0 and CODEGRAPH_KERNEL_EXPECT=1, base 0abae11:

test file fixture line endings result
main's LF fails: call 2 re-sent internal/usecase/payroll/cycle.go lines 31,32,33,34,35 (wasm and kernel)
main's CRLF passes 26/26 (the false green this machine saw)
this PR's CRLF passes 26/26 (wasm and kernel)
this PR's LF passes 26/26 (wasm and kernel)
  • The normalisation makes the scenario platform-independent. With it in place but main's strict assertion put back, a CRLF checkout fails the way an LF one does, on lines 31-37 (the 7-line struct).
  • The new assertion still catches a real duplicate. With dedupeRange mutated to re-send held runs of 8-23 lines while longer ones still get pointers, the case fails: call 2 re-sent internal/usecase/payroll/cycle.go lines 42-51 (10 lines).
  • tsc with the repo's strict options on the test file (temporary tsconfig extending the repo's): clean.
  • Full suite on this commit (kernel built, CODEGRAPH_KERNEL_EXPECT=1 npx vitest run --maxWorkers=4 --minWorkers=1): 696 files passed, 6 skipped; 8,347 tests passed, 0 failed, 82 skipped; vitest exit 0.

No CHANGELOG entry: this is a test-only change with nothing user-facing.

Fixes #2756

Notes

🤖 Generated with Claude Code

…kouts alike

explore-cross-call-dedup's "never re-sends a line it already sent" case
has failed on every LF checkout (Linux, macOS, CI) since PR #2655. It
passed on Windows only because core.autocrlf writes the fixture with CRLF.

Root cause. Since PR #2655 the payroll fixture's RunResult struct
(cycle.go lines 31-37) references Payslip through a field, so call 1
renders it. Call 2 renders the file's head, and that 7-line held run comes
back inside it: dedupeRange keeps a covered run shorter than
MIN_COVERED_LINES (8) in the emit set on purpose, rule 3 of the range
algebra, which its own unit test pins. The handler case counted any
repeated line as a duplicate. On a CRLF checkout explore's per-file
character budget also counts each line's carriage return, so cycle.go
rendered fewer lines and the case never met the short run.

Fix, test only:
- The case groups the repeated lines into consecutive runs and fails on a
  run of MIN_COVERED_LINES lines or more, read from EXPLORE_DEDUP. A
  shorter run is the algebra's deliberate re-send. What agents receive is
  unchanged.
- The suite gives its copy of the fixture LF line endings, so every
  checkout indexes and renders the same bytes.

Validation on Windows, with the kernel and with CODEGRAPH_KERNEL=0:
- main's test fails with an LF fixture ("call 2 re-sent
  internal/usecase/payroll/cycle.go lines 31,32,33,34,35") and passes with
  the CRLF one. The new test passes 26/26 with both.
- With the normalisation and main's assertion, a CRLF checkout fails the
  way an LF one does (lines 31-37): both checkouts now test one scenario.
- Teeth: an algebra mutated to re-send held runs of 8-23 lines fails the
  new case ("call 2 re-sent internal/usecase/payroll/cycle.go lines 42-51
  (10 lines)").
- tsc on the test file is clean.

Contributor PR #2758 by @danusha2345 reached the same diagnosis. This
change was written separately and also normalises the fixture.

Fixes #2756

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

explore-cross-call-dedup test fails on main since #2655 (struct field refs): call 2 re-sends cycle.go lines 31-35

1 participant