Skip to content

fix(glob): actually sort results by modification time#34

Open
T0mSIlver wants to merge 1 commit into
microsoft:mainfrom
T0mSIlver:fix/glob-sort-mtime
Open

fix(glob): actually sort results by modification time#34
T0mSIlver wants to merge 1 commit into
microsoft:mainfrom
T0mSIlver:fix/glob-sort-mtime

Conversation

@T0mSIlver

Copy link
Copy Markdown

Problem

glob.md states: "Returns matching file paths sorted by modification time." But the command was rg --files <dir> --glob <pattern> with no --sort flag. ripgrep's default is --sort=none, so results came back in arbitrary traversal order — the documented ordering was never applied.

Fix

Pass --sort modified so results are genuinely ordered by modification time (oldest → newest), matching the prompt's contract. Adds tests/test_glob_sort.py which stamps three files with known mtimes and asserts the returned order.

Paper reference

Confirmed by the paper: Glob "returns matching file paths sorted by modification time", so the sort is intentional and the missing --sort flag was the bug. — FastContext paper (arXiv:2606.14066), Appendix E "FastContext Explorer: Tool Schemas", p. 19

glob.md promises 'matching file paths sorted by modification time', but
the rg --files invocation passed no --sort flag, so ripgrep returned
results in arbitrary traversal order (default --sort=none). Add
--sort modified so the output matches the documented contract, and add
a test that stamps mtimes and asserts the resulting order.
@T0mSIlver T0mSIlver closed this Jun 27, 2026
@T0mSIlver T0mSIlver deleted the fix/glob-sort-mtime branch June 27, 2026 11:31
@T0mSIlver T0mSIlver restored the fix/glob-sort-mtime branch June 27, 2026 11:56
@T0mSIlver T0mSIlver reopened this Jun 27, 2026
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.

1 participant