fix: sort glob results for deterministic load order across all callers#14626
Open
kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
Open
fix: sort glob results for deterministic load order across all callers#14626kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
kevinWangSheng wants to merge 2 commits intoanomalyco:devfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Found Related PR:PR #14547: fix(config): sort plugin paths for deterministic load order Why it's related: This is the exact alternative approach mentioned in the PR description. PR #14626 fixes the root cause by adding |
6 tasks
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.
Issue for this PR
Closes #14492
Type of change
What does this PR do?
Glob.scanandGlob.scanSyncreturn results in filesystemreaddirorder, which varies across platforms and runs. This affects all callers — not justloadPlugin, but alsoloadAgent,loadMode,loadCommand(inconfig.ts), and custom tool loading (intool/registry.ts).This PR adds
.sort()to bothGlob.scanandGlob.scanSyncinutil/glob.ts, fixing the root cause at the utility level so all current and future callers get deterministic alphabetical order.Also removes redundant
.sort()calls in the existing glob tests — these were workarounds for the nondeterministic output and now serve as regression tests.Note: This is an alternative to #14547, which only sorts in
loadPlugin. This PR fixes the same issue at the source so all 5+ call sites benefit.How did you verify your code works?
Glob.scan/Glob.scanSyncto confirm none depend on filesystem ordering.sort()in 6 test assertions)Array.prototype.sort()is stable and deterministic for string arraysScreenshots / recordings
N/A — no UI changes.
Checklist