Skip to content

fix(slug): fold the Windows drive letter on the Python side too (#268) - #282

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/268-slug-drive-parity
Jul 31, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/268-slug-drive-parity

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

scripts/lib-slug.sh has folded a leading drive letter to lower case
unconditionally since #263. pipeline/slug.py did not fold at all — it is a
transcription of Claude Code's own JXA routine, which never sees a raw drive
letter because the host normalises first. On Windows resolve-paths.sh hands
both sides the native Win32 form with an UPPER-case drive, so bash computed
c--Users-… and Python computed C--Users-…, and extract.py located the
session directory by the Python spelling.

NTFS resolves a case-only difference, so nothing failed and nothing reported a
difference. The exposure is that it stops being benign the moment anything
compares the two slugs as strings rather than using them as paths — which is
precisely what #263 turned out to be, in git rather than in the filesystem.

The direction is not a free choice (#263's PR): Git for Windows ships cygpath,
so the working majority's on-disk stores already carry the lower-case spelling,
and folding the other way would fix one reporter while renaming every other
store. The fold is anchored at position 0, matching bash's ?:* case, so an
embedded X: mid-path is left alone. It runs before the slug characters and
before path_hash, mirroring bash capturing _orig after its own fold — so
the over-long-path branch agrees too.

tests/test_slug_parity.py existed to keep these two implementations
identical and was doing its job for every step except the one where they
drifted. It now spans both cases and all three shapes (C:\…, c:/…, /c/…),
pins the direction so the two cannot agree on the wrong case, and guards
against the fold overreaching into an ordinary mid-path colon.

Two pre-existing tests in tests/test_path_resolution.py hardcoded the old
upper-case slug as expected — stale fixtures never updated when bash's fold
shipped in #263. Corrected.

Closes #268

Co-Authored-By: Max

`scripts/lib-slug.sh` has folded a leading drive letter to lower case
unconditionally since #263. `pipeline/slug.py` did not fold at all — it is a
transcription of Claude Code's own JXA routine, which never sees a raw drive
letter because the host normalises first. On Windows `resolve-paths.sh` hands
both sides the native Win32 form with an UPPER-case drive, so bash computed
`c--Users-…` and Python computed `C--Users-…`, and `extract.py` located the
session directory by the Python spelling.

NTFS resolves a case-only difference, so nothing failed and nothing reported a
difference. The exposure is that it stops being benign the moment anything
compares the two slugs as strings rather than using them as paths — which is
precisely what #263 turned out to be, in git rather than in the filesystem.

The direction is not a free choice (#263's PR): Git for Windows ships cygpath,
so the working majority's on-disk stores already carry the lower-case spelling,
and folding the other way would fix one reporter while renaming every other
store. The fold is anchored at position 0, matching bash's `?:*` case, so an
embedded `X:` mid-path is left alone. It runs before the slug characters and
before `path_hash`, mirroring bash capturing `_orig` after its own fold — so
the over-long-path branch agrees too.

`tests/test_slug_parity.py` existed to keep these two implementations
identical and was doing its job for every step except the one where they
drifted. It now spans both cases and all three shapes (`C:\…`, `c:/…`, `/c/…`),
pins the direction so the two cannot agree on the wrong case, and guards
against the fold overreaching into an ordinary mid-path colon.

Two pre-existing tests in `tests/test_path_resolution.py` hardcoded the old
upper-case slug as expected — stale fixtures never updated when bash's fold
shipped in #263. Corrected.

Closes #268

Co-Authored-By: Max <noreply>
…hird copy

Four ubuntu legs went red while macOS and Windows passed. `_make_real_session`
re-implemented the slug inline — `re.sub(r'[^a-zA-Z0-9]', '-', project_dir)`,
with no drive-letter fold — so it created `.../projects/D--Users-dev-project`
while `_session_dir` now looks up `d--Users-dev-project`. On a case-sensitive
filesystem that is a miss; on macOS and Windows it resolves, which is why the
suite was green everywhere the fix was written and developed.

The case was the symptom. The defect is that this was a *third* implementation
of `session_dir_slug` — bash, Python, and one hand-rolled in a test helper —
which is the exact drift `tests/test_slug_parity.py` exists to prevent, sitting
in the test suite where the parity guard cannot see it. Patching the literal to
lower case would have restored green and left the next divergence free to
happen the same way.

The helper now calls `session_dir_slug`, so the fixture path and the lookup path
are the same string by construction and cannot drift again.

Verified platform-independently rather than by re-running on a machine that
cannot show the failure: for all three fixture paths the helper's slug now
equals the directory `_session_dir` resolves, and the old regex differed in
every one.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 8879ca3 into main Jul 31, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/268-slug-drive-parity branch July 31, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python and bash session_dir_slug disagree on the Windows drive letter, and test_slug_parity does not cover the step where they differ

1 participant