Skip to content

fix: return deterministic directory listings - #1309

Merged
vitali87 merged 2 commits into
vitali87:mainfrom
Whxuan0701:fix/deterministic-directory-listing
Aug 20, 2026
Merged

vitali87 merged 2 commits into
vitali87:mainfrom
Whxuan0701:fix/deterministic-directory-listing

Conversation

@Whxuan0701

@Whxuan0701 Whxuan0701 commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Sort directory entries before returning them to agent callers.
  • Add regression coverage for deliberately unordered filesystem results.

Type of Change

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring (no functional changes)
  • Documentation
  • CI/CD or tooling
  • Dependencies

Related Issues

No existing issue found.

Test Plan

  • Unit tests pass (make test-parallel or uv run pytest -n auto -m "not integration")
  • New tests added
  • Integration tests pass (make test-integration, requires Docker)
  • Manual testing (describe below)

Focused validation:

  • uv run pytest -q codebase_rag/tests/test_directory_lister.py (21 passed)
  • uv run ruff format --check codebase_rag/tools/directory_lister.py codebase_rag/tests/test_directory_lister.py
  • uv run ruff check codebase_rag/tools/directory_lister.py codebase_rag/tests/test_directory_lister.py
  • uv run ty check codebase_rag/tools/directory_lister.py
  • git diff --check

Repository-wide local unit tests were also attempted on the unchanged base and reached 7,161 passed / 142 skipped, with two unrelated failures and one collection error caused by optional dependencies and the Intel macOS environment. CI remains the authoritative full-suite result.

Checklist

  • PR title follows Conventional Commits format
  • All pre-commit checks pass (make pre-commit)
  • No hardcoded strings in non-config/non-constants files
  • No # type: ignore, cast(), Any, or object type hints
  • No new comments or docstrings (code should be self-documenting)

Summary by CodeRabbit

  • Bug Fixes

    • Directory listings are now consistently returned in alphabetical order, regardless of the underlying filesystem order.
  • Tests

    • Added coverage to verify deterministic sorting of directory contents.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bc22466a-2049-4c11-a687-e6ae76d085f1

📥 Commits

Reviewing files that changed from the base of the PR and between e5447ac and 4937fc6.

📒 Files selected for processing (2)
  • codebase_rag/tests/test_directory_lister.py
  • codebase_rag/tools/directory_lister.py

Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The directory lister now returns directory contents in alphabetical order. A test mocks an unsorted os.listdir response and verifies the sorted result.

Changes

Directory listing order

Layer / File(s) Summary
Sort directory contents
codebase_rag/tools/directory_lister.py, codebase_rag/tests/test_directory_lister.py
The directory lister sorts entries before returning them. The test mocks unsorted filesystem output and verifies alphabetical ordering.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 4937f

The change makes directory listings deterministic and adds focused regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: vitali87

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: deterministic directory listings, and it follows Conventional Commits format.
Description check ✅ Passed The description includes the required sections, summarizes the fix, documents tests, and identifies unrelated full-suite failures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Directory listings are now returned in a deterministic alphabetical order. Runtime validation confirmed that arbitrary filesystem entry order is normalized while empty and invalid-directory responses remain unchanged.

Confidence Score: 5/5

No blocking failure remains.

The directory-listing behavior correctly sorts arbitrary filesystem results and preserves existing error and empty-directory behavior.

T-Rex T-Rex Logs

What T-Rex did

  • A focused DirectoryLister validation script was prepared and run to exercise DirectoryLister.list_directory_contents.
  • The test compared the before and after directory orders, showing the parent order zeta.py, alpha.py, middle.py before and alpha.py, middle.py, zeta.py after.
  • The test also asserted that empty and missing-directory responses remained unchanged.
  • The results and the corresponding artifacts were uploaded for review.

View all artifacts

T-Rex Ran code and verified through T-Rex

Reviews (2): Last reviewed commit: "chore: retrigger Greptile review" | Re-trigger Greptile

@vitali87 vitali87 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a good fix: os.listdir order is filesystem-dependent and agents consuming the listing benefit from determinism, and the regression test pins it with a deliberately unordered mock. Two small things before merge: the Greptile Review check errored without posting findings (their side, not yours; an empty push or rebase retriggers it), and please confirm the branch is current with main. Substantively this looks merge-ready.

@Whxuan0701
Whxuan0701 force-pushed the fix/deterministic-directory-listing branch from 4937fc6 to 3dbe173 Compare August 19, 2026 10:03
@Whxuan0701

Copy link
Copy Markdown
Contributor Author

I rebased the branch onto the latest main and pushed the update. The focused tests and checks all pass. I also pushed an empty commit to retrigger Greptile, but the check has not appeared yet on the new commit.

@vitali87

Copy link
Copy Markdown
Owner

@greptile review

@vitali87

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vitali87

Copy link
Copy Markdown
Owner

@Whxuan0701 GOOD JOB!

@vitali87
vitali87 merged commit 3fe1062 into vitali87:main Aug 20, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants