Skip to content

fix(config): support Windows backslash paths in categorize_memory_dir (#316)#716

Merged
memtomem merged 1 commit intomainfrom
fix/categorize-memory-dir-windows-paths
May 2, 2026
Merged

fix(config): support Windows backslash paths in categorize_memory_dir (#316)#716
memtomem merged 1 commit intomainfrom
fix/categorize-memory-dir-windows-paths

Conversation

@memtomem
Copy link
Copy Markdown
Owner

@memtomem memtomem commented May 2, 2026

Summary

categorize_memory_dir (config.py:1342-1355) matched provider patterns against str(path) directly. On Windows the stringified Path is backslash-separated, so the forward-slash regex table (r"/\.claude/projects/[^/]+/memory/?$", etc.) never matched and every Windows provider directory silently fell through to "user". User-visible symptom: mm init's wizard could not auto-detect Claude Code / Codex memory folders for Windows users, so the preset namespace rules from #312 were never applied.

Fix

-    s = str(path).rstrip("/")
+    s = str(path).replace("\\", "/").rstrip("/")

Input normalisation only — the regex table, the vocabulary lock (#313), the ProviderCategory Literal, and the _CATEGORY_TO_PROVIDER map all stay untouched. RFC #304 (axis/wire-format) is unaffected.

Tests

test_categorize_memory_dir_accepts_windows_separators covers 7 parametrized cases:

Path Expected category
C:\Users\foo\.claude\projects\abc\memory claude-memory
C:\Users\foo\.claude\plans claude-plans
C:\Users\foo\.codex\memories codex
C:\Users\foo\Documents\notes user (fallback)
C:\Users\foo/.claude/plans claude-plans (mixed sep)
C:\Users\foo\.claude\plans\ (trailing) claude-plans
\\server\share\.codex\memories codex (UNC)

Raw-string fixtures execute on the Ubuntu CI host without needing a Windows runner — this matches the testing-notes pattern in #316.

Existing POSIX-path tests in test_init_cmd.py (TestCategorizeMemoryDir, TestDetectProviderDirsRoundtrip) continue to pass — no behaviour change for forward-slash paths.

Cascade with #714

PR #714 flagged two test_detect_provider_dirs_* cases as "still failing — pending #316". With this PR landed alongside the set_home migration, those two cases should go green on the Windows informational job. Tracked in the next Windows fail-count delta.

Test plan

  • uv run pytest packages/memtomem/tests/test_config_overrides.py -m "not ollama" -q — 35 passed locally
  • uv run pytest packages/memtomem/tests/test_init_cmd.py -m "not ollama" -k "categorize or provider_dirs" — 12 passed (POSIX regression guard)
  • uv run ruff check + ruff format --check on the 2 changed files — clean
  • CI Windows informational job: confirm Windows fail count drops by ≥3 (the two test_detect_provider_dirs_* plus any cascade from _detect_provider_dirs callers). macOS / Ubuntu pass count unchanged (negative pin).

Closes #316.

🤖 Generated with Claude Code

`categorize_memory_dir` matched provider patterns against `str(path)`
directly. On Windows the stringified `Path` is backslash-separated
(`C:\Users\foo\.claude\projects\bar\memory`), so the forward-slash
regexes (`r"/\.claude/projects/[^/]+/memory/?$"`, etc.) never matched
and every Windows provider directory silently fell through to "user".
The user-visible symptom: `mm init`'s wizard could not auto-detect
Claude Code / Codex memory folders for Windows users, so the preset
namespace rules from #312 (`claude:{ancestor:1}`, etc.) were never
applied to those installs.

Fix: normalise separators by replacing `\` with `/` before matching.
The regex table, the vocabulary lock (#313), and the Literal type stay
untouched — only the input form is normalised. RFC #304 is unaffected.

Tests: 7 parametrized cases in test_categorize_memory_dir_accepts_-
windows_separators covering one path per provider category, the
"user" fallback, mixed separators, UNC paths, and trailing backslash.
Raw-string fixtures execute on the Linux CI host without needing a
Windows runner. Existing POSIX-path tests in test_init_cmd.py
(TestCategorizeMemoryDir / TestDetectProviderDirsRoundtrip) continue
to pass.

Side effect: the two `test_detect_provider_dirs_*` cases that #714
flagged as "still failing — pending #316" should now pass on Windows
once this lands together with the set_home migration.

Closes #316.

Co-Authored-By: Claude <[email protected]>
@memtomem memtomem merged commit 82feed1 into main May 2, 2026
8 of 9 checks passed
@memtomem memtomem deleted the fix/categorize-memory-dir-windows-paths branch May 2, 2026 06:38
@github-actions github-actions Bot locked and limited conversation to collaborators May 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: wizard fails to auto-detect Claude/Codex memory dirs (backslash path regex)

2 participants