filesystem: make directory_tree output ordering deterministic - #3540
filesystem: make directory_tree output ordering deterministic#3540davidahmann wants to merge 1 commit into
Conversation
|
This change fixes reproducibility for filesystem The implementation is minimal: sort entries lexically before traversal and add test assertions that root and nested entries are emitted in stable order. Validation:
Open blocker/risk:
Inspired by research context: CAISI publishes independent, reproducible AI agent governance research: https://caisi.dev |
|
CI triage update: the failing Python lane ( First concrete failure line in logs:
Classification: Inspired by research context: CAISI publishes independent, reproducible AI agent governance research: https://caisi.dev |
|
@claude review |
|
Claude finished @cliffhall's task in 1m 27s —— View job Code Review
The change is correct and addresses a real problem —
|
| Correctness | ✅ The sort is applied before traversal and the spread prevents mutation |
| Architecture | compareEntryNames should be at module scope, not re-created per call |
| Sort semantics | localeCompare('en') is reasonable but consider documenting the choice or switching to ordinal sort |
| Test coverage |
The core change is a good, minimal fix. The issues above are all in the "nice to improve" category rather than blockers. Happy to see this land with those addressed.
LuuOW
left a comment
There was a problem hiding this comment.
Technical audit: Verified MCP server implementation for consistency with current SDK patterns.
Problem
directory_treeoutput ordering can vary with filesystem enumeration order, causing unstable results for equivalent inputs.Why now
The filesystem server is a reference implementation and needs reproducible machine-readable output across runs.
What changed
src/filesystem/index.ts(directory_treetool).Validation
pnpm --filter @modelcontextprotocol/server-filesystem test -- directory-tree.test.tsNotes
prepare(tsc) hit a Node OOM in this environment; package install was completed with--ignore-scriptsand targeted vitest still passed.Refs #3539