Repository navigation
Description
Summary
On Windows, session_dir_slug stops folding the drive letter once the project path crosses MAX_PATH (260 chars) — silently reintroducing #263 for long paths, and additionally emitting four leading dashes that make the slug miss Claude Code's own session directory.
The cause is that cygpath -w returns a \\?\-prefixed path for long paths, and the fold's case pattern only matches a bare drive letter.
Reproduction
Against the installed 0.12.3 tree (Git for Windows bash, cygpath present):
. "$PIPELINE_DIR/scripts/lib-slug.sh"
short='C:\dev\project'
long="C:\\dev\\$(printf 'a%.0s' $(seq 1 130))\\$(printf 'b%.0s' $(seq 1 130))"
session_dir_slug "$short" # -> c--dev-project (folded, correct)
session_dir_slug "$long" # -> ----C--dev-aaaa…-9ewsib (NOT folded, 4 leading dashes)Observed:
| path | length | cygpath -w |
session_dir_slug |
|---|---|---|---|
C:\dev\project |
14 | C:\dev\project |
c--dev-project |
C:\dev\aaa…\bbb… |
268 | \\?\C:\dev\aaa… |
----C--dev-aaa…-9ewsib |
Root cause
session_dir_slug runs cygpath -w first (lib-slug.sh:175-179), then folds the drive letter with:
case "$path" in
?:*)cygpath -w returns \\?\C:\... once the path exceeds MAX_PATH, and \\?\C:\dev\x does not match ?:*. Tested directly:
'C:\dev\x' -> MATCHES ?:* (drive letter folds)
'\\?\C:\dev\x' -> no match (drive letter does not fold)
Impact
Two distinct consequences, both on exactly the paths the 200-char truncation already exists to protect:
- The drive letter is not folded, so a long-path project can produce
C--…where every other project producesc--…. That is the A lowercase drive letter in CLAUDE_PROJECT_DIR makes git add match nothing, and the backup reports success #263 condition — a slug that cannot match its own tracked history — reintroduced for a subset of paths after fix(git-backup): a slug that cannot match its own history is not an empty store (#263) #267 fixed it for the rest. - The slug gains four leading dashes from
\\?\. Claude Code does not add that prefix when it names its own session directory, so the computed slug does not correspond to the transcript directory at all — the session_dir_slug does not truncate at 200 chars + hash, so deep project paths silently never save #157/fix(windows): non-ASCII paths silently disabled the whole pipeline (#144, #145) #156 class of silent miss.
Both are invisible on a case-insensitive filesystem until git is involved, which is what makes them worth catching in the function rather than downstream.
Suggested direction
Strip a \\?\ (and \\?\UNC\) prefix from the cygpath -w result before the fold, so the existing case sees the shape it was written for. That keeps the long-path handling that cygpath is doing for other reasons while restoring both the fold and the leading characters.
Happy to raise a PR with a test if that shape suits you — the existing bench-slug.sh/tests layout looks like the natural home.
How we found it, and one small ask
We (JQiT) drive remember from PowerShell on Windows and had to answer "what slug will the plugin compute?" from a non-bash caller. Calling session_dir_slug per tool call means a bash fork per call, so we maintain a small PowerShell port and verify it against the real function in our test suite — which is how the long-path divergence surfaced.
We would much rather not maintain a second implementation. If there is appetite for a documented canonical spec of the slug rules, or a cheap way to ask the plugin for a slug from another language, we would use it and delete ours. Entirely understood if that is out of scope — the defect above stands on its own either way.
Environment: remember 0.12.3 (installed tree), Windows 11, Git for Windows bash with cygpath present.
Activity
feat(slug): publish conformance vectors and write the slug once a ses…
fdaviddpt commentedon Aug 2, 2026
Both halves of this are now on
mainand released as v0.13.0.The defect. Fixed in #295. Your diagnosis was right and reproduced exactly — a stub emitting the long-path shape produced your slug character for character, hash included. The strip lives inside the
cygpathbranch on purpose, so it undoes only whatcygpathjust did: a directory literally named\\?\C:is legal on Linux and still slugs literally, because stripping unconditionally would rename those stores.\\?\UNC\maps back to\\rather than to nothing, since\\?\UNC\server\shareis\\server\shareand eating the separators would split one directory into two slugs.Reading that line also turned up a second failure:
cygpathcan exit 0 and print nothing, which emptied the path outright — and an empty slug is not a miss, it resolves to~/.claude/projects/itself, a directory that exists and holds every project's transcripts. Guarded now.The ask — we'd rather you deleted your port too. Two things shipped in #296:
docs/slug-vectors.json— 37 conformance vectors (input path, plain and base64, expected slug, and the environment each assumes). It covers the six Windows drive spellings, UNC both forms,\\?\and\\?\UNC\, the 200-char truncation on both sides of its boundary with the base36 hash, non-ASCII either side of the UTF-16 surrogate boundary, and ill-formed UTF-8. It is generated from the implementation and byte-compared against it on every CI run, so it cannot drift without our build going red. Point your PowerShell tests at that file and a divergence becomes our failure, not just yours. Vectors that depend oncygpathbeing present are marked, so a caller without it can tell which rows apply.We deliberately did not write a prose spec: it would drift from
scripts/lib-slug.shand be read as current long after it stopped being true.<REMEMBER_DIR>/tmp/session-slug— the slug is a pure function ofPROJECT_DIR, which does not change mid-session, so there is no reason to fork per tool call at all. Session start now writes it once askey=valuelines. Three states, not two: absent means it never ran,status=unavailable(with noslug=key) means it ran and could not answer,status=okmeans the value is usable. Staleness is decided byproject_dironly — a record from a dead session is still correct, so a timestamp would only offer a test that answers the wrong question. One documented hole: in external-storage mode with{slug}indata_dir,REMEMBER_DIRis itself named by the slug, so the file is unreachable without already knowing it. The vectors cover that case.The per-tool-call path is byte-identical to before, and a test asserts it.
Thank you for this one — the report was unusually complete, and the second implementation you did not want to maintain is exactly what made the divergence visible. If the vector format is missing something your port needs, say so and we will add it.
Note on delivery: v0.13.0 is tagged and released here, but the official plugin catalogue pins by commit sha and advances on its own automation, so it is not yet live for catalogue installs.
fix(slug): strip cygpath's \\?\ long-path prefix before the drive-let…
feat(slug): index project_dir -> slug at the store root, so the recor…
fix(#902): refuse unsafe REMEMBER_DIR without aborting log.sh
fix(#902): refuse an unsafe REMEMBER_DIR before mkdir; date+pid auton…