Skip to content

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

Closed

Description

@fdaviddpt

Found while fixing #263, outside that PR's blast radius. Not user-reported — NTFS hides it completely, which is why it can sit here indefinitely.

The divergence

scripts/lib-slug.sh:session_dir_slug() folds the drive letter. pipeline/slug.py does not: it is a faithful transcription of Claude Code's own JXA slug routine and carries no drive normalisation at all.

On Windows the Python side receives CLAUDE_PROJECT_DIR as exported by resolve-paths.sh, which is the native Win32 form with an upper-case drive (C:\\Users\\…). So:

Side Computes
bash session_dir_slug c--Users-…
pipeline/slug.py C--Users-…

extract.py:50 uses the Python slug to locate the session directory, so it reads a differently-cased path than the store is named after. On NTFS both resolve, nothing fails, and nothing anywhere reports a difference.

Why the existing guard does not catch it

tests/test_slug_parity.py exists precisely to keep these two implementations identical, and it is the reason this is worth filing rather than shrugging at: the test is doing its job for every step except the one where they now differ. The drive-letter fold is not among its cases, so parity is asserted and the assertion does not reach the divergence.

This is the same shape as #263 one layer over: a check that answers a narrower question than the one it appears to answer.

Blast radius

Currently benign, and it is worth being precise about why rather than claiming damage:

  • On NTFS, a case-only difference resolves to the same directory, so reads succeed.
  • On macOS/Linux the fold does not fire at all (no drive letter), so the two agree.

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 exactly what #263 turned out to be, in git rather than in the filesystem. Any future consumer that keys, indexes or matches on the slug inherits a mismatch that no platform will surface.

Suggested scope

  1. Give pipeline/slug.py the same drive-letter fold, in the same direction (lower-case — Git for Windows ships cygpath, so the working majority already has that spelling on disk; see A lowercase drive letter in CLAUDE_PROJECT_DIR makes git add match nothing, and the backup reports success #263's PR for why the direction is not a free choice).
  2. Extend tests/test_slug_parity.py to cover drive-letter inputs in both cases and both shapes (C:\\…, c:/…, /c/…), so the parity guarantee actually spans the step where the two most recently drifted.

The second half matters more than the first. A parity test that does not cover the normalisation step will let the next divergence through in the same silence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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