fix(api): stop asserting which fiber won in the turn-retry test - #366
Merged
Conversation
The fixture emits 8 chars — under DELTA_BATCH_SIZE — then fails the stream, so whether that text ever reached a consumer is a race between the provider failure and the 16ms DELTA_BATCH_WINDOW. groupedWithin drops a pending buffer on upstream failure, but a window that fires first ships it. Locally the failure always won; on a loaded CI runner the timer won and retractChars was a correct 8 against an asserted 0. Assert the invariant instead: retractChars equals exactly the text flushed before the marker, and the reader's fold lands on the retry's text alone. Holds on either side of the race. The deterministic exact-retraction case is still pinned by the neighbouring test, which fills a whole batch and flushes on the size cap regardless of timing.
🍁 Maple PR previewWarning Preview cleanup could not be confirmed. The Alchemy teardown outcome was Final commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CI on
mainhas been red since 4977476. One job failed — TypeScript — on one test:It's a flaky assertion, not a product bug. The fixture emits
textDelta("Hello wo")— 8 chars, underDELTA_BATCH_SIZE— then fails the stream, so whether that text ever reached a consumer is a race between the provider failure and the 16 msDELTA_BATCH_WINDOW.Stream.groupedWithindrops a pending buffer on upstream failure, but a window that fires first ships it. Locally the failure always wins; on a loaded CI runner the timer won andretractCharswas a correct8against an asserted literal0. Both outcomes are correct behaviour — the assertion was pinning which fiber won.This asserts the invariant that actually matters instead:
retractCharsequals exactly the text flushed before the marker, and the reader'sfoldlands on the retry's text alone. That holds on either side of the race.Coverage is unchanged — the deterministic exact-retraction case is still pinned by the neighbouring test, which fills a whole batch and flushes on the size cap regardless of timing.
Verified:
vitest run src/chat/loop/turn.test.ts→ 27 passed;bun typecheckinapps/apiclean.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.