fix(core): sort scan paths for deterministic dedup and stable refreshes#357
Open
crhan wants to merge 1 commit intojunhoyeo:mainfrom
Open
fix(core): sort scan paths for deterministic dedup and stable refreshes#357crhan wants to merge 1 commit intojunhoyeo:mainfrom
crhan wants to merge 1 commit intojunhoyeo:mainfrom
Conversation
scan_directory uses par_bridge() which is explicitly non-deterministic — items may arrive in any order. The global seen_keys dedup in parse_all_messages_with_pricing keeps the first occurrence of any messageId:requestId key, so when the same message appears in multiple session files (e.g. original + acompact session), a different copy is "kept" each run depending on file order. Sort the collected paths before returning so that: - dedup always picks the same winner across refreshes - data shown in the TUI daily/hourly views is stable when pressing 'r' Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
@crhan is attempting to deploy a commit to the Inevitable Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
scan_directoryusespar_bridge()to parallelizeWalkDirtraversal, which is explicitly non-deterministic — items may arrive in any order on each call.The global
seen_keysdedup inparse_all_messages_with_pricingkeeps the first occurrence of anymessageId:requestIdkey. When the same message appears in multiple session files (e.g. original session +acompactsnapshot), which copy is kept depends on file order. Since that order changes between runs, the deduplicated message set changes too, causing visible data fluctuations every time the user pressesrto refresh.Fix
Sort the collected paths before returning from
scan_directory. The parallel scan still runs at full speed; we sort only the result.Testing
Manually verified on a corpus with ~2,000+ session files: pressing
rrepeatedly in the TUI daily/hourly view now produces stable numbers across refreshes.🤖 Generated with Claude Code