fix(core): stable id tiebreaker in conversation list sort (kills the CI flake)#69
Merged
Merged
Conversation
…flake) `BaseConversationStore.list` sorted newest-first by `updatedAt` alone, so two conversations touched in the same millisecond compared equal and the order was non-deterministic — the `handler-list.test.ts` flake that tripped ~25-50% of CI node jobs (a forced re-run on PRs #66 and #68). Add `id` as a stable secondary key (`|| b.id.localeCompare(a.id)`). Ids carry a monotonic counter (`conv-<ts>-<n>-<rand>`), so id-descending ≈ creation order — the tiebreak stays newest-first. Covers both stores (the sort lives in the shared base). New contract test freezes the clock so both conversations share `updatedAt` and asserts deterministic order; the previously-flaky handler-list test now passes 10/10 in a loop.
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.
The flake
handler-list.test.tsfailed ~25-50% of CI node jobs — it forced are-run on PR #66 and PR #68. Root cause:
BaseConversationStore.listsorted newest-first by
updatedAtalone:Two conversations created/touched in the same millisecond compare equal,
so the resulting order is non-deterministic (
['c1','c2']vs['c2','c1']).Fix
Add
idas a stable secondary key:Ids carry a monotonic counter (
conv-<ts>-<n>-<rand>), so id-descending≈ creation order — the tiebreak stays newest-first. The sort lives in the
shared
BaseConversationStore, so bothInMemoryConversationStoreandFileConversationStoreare covered.Verification
updatedAt, then asserts deterministic order (id-2beforeid-1) —runs for both stores.
handler-list.test.tsnow passes 10/10 in aloop (was intermittently failing).