Skip to content

Make filesystem directory-tree output ordering deterministic #3539

@davidahmann

Description

@davidahmann

Problem

Directory tree responses can vary by host filesystem enumeration order, causing unstable output for the same directory across runs.

Why now

The filesystem server is a reference implementation; deterministic output is required for reproducible comparisons and contract tests.

Expected behavior

For the same directory contents and exclude patterns, directory_tree should return a stable ordering across repeated runs and platforms.

Claim-to-codepath map

  • src/filesystem/index.ts
  • src/filesystem/lib.ts
  • src/filesystem/__tests__/directory-tree.test.ts
  • src/filesystem/__tests__/structured-content.test.ts

Validation requirements

  • Enforce deterministic sorting in recursive tree traversal.
  • Add test assertions for stable sibling ordering and nested ordering.
  • Run filesystem package tests.

Evidence packet

  • Commit under test: $(git -C /Users/davidahmann/Projects/agent-ecosystem/mcp-servers rev-parse HEAD)
  • Runtime: Node.js + vitest on macOS
  • Minimal repro: call directory_tree multiple times over same fixture and compare ordering of siblings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions