Skip to content

Windows: Path canonicalization in indexing — kind detection + memory_dir comparisons #647

@memtomem

Description

@memtomem

Background

Indexing-related tests fail on Windows where path comparisons across different canonicalization layers (drive letter case, short-name vs long-name, separator) don't match. Symptoms include `kind=None` where `'memory'` was expected, chunks not getting deleted because their source paths don't compare equal to `memory_dirs`, etc.

Symptoms

```
FAILED test_web_routes.py::TestSources::test_kind_set_when_source_under_memory_dir
AssertionError: assert None == 'memory'

FAILED test_web_routes.py::TestRemoveMemoryDirChunkCleanup::test_delete_chunks_true_removes_matching_source_files
assert 0 == 4

FAILED test_web_routes.py::TestUploadsUsage::test_populated
assert 0 == 2
```

The pattern: chunks have a source path stored at index time; later code compares against a configured `memory_dir`. On POSIX both go through `Path.resolve()` consistently. On Windows, the resolution may differ (drive case, `\\?\\` long-path prefix, short `8.3` form) so equality fails.

Affected files (estimated)

  • `packages/memtomem/tests/test_indexing_engine.py` — 11 failures
  • `packages/memtomem/tests/test_web_routes.py::TestSources` / `TestRemoveMemoryDirChunkCleanup` / `TestUploadsUsage`
  • Possibly: `test_dirty.py`, `test_index_debounce.py`

Fix direction

  1. Audit the production code that compares `chunk.metadata.source_file` against `memory_dirs` — confirm both go through identical canonicalization (`Path.resolve()` after a consistent normalization).
  2. Consider storing canonical paths at index time so later comparison is just `==`, no resolve-on-read race.
  3. Test fixtures may need to use `tmp_path.resolve()` consistently to avoid `8.3` vs long-path mismatches.

Refs

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions