Skip to content

scope: case folding decided by platform leaks rows across dirs on case-sensitive volumes #109

Closed

Description

@abogartz

Problem

normalizeDirPath (from #101) folds case based on the platform:

if (process.platform === "win32" || process.platform === "darwin") r = r.toLowerCase();

A case-sensitive APFS volume is a legitimate macOS choice. There, Foo and foo really are two directories, but they now hash to one repo= key — and isVisibleHere (src/memory.ts) matches on m.repo === cur.key alone, so two unrelated projects read each other's rows. Silent cross-project visibility, the same class of leak #90 was about.

Fix options

Probe the volume once instead of trusting the platform: resolve r and a case-flipped spelling with realpathSync/statSync and compare the returned path or inode; or restrict the fold to win32. realpathSync already returns the true spelling on both volume types, so the probe is cheap and the fallback is the current behavior.

Smaller items from the same review

  • test/repokey-path.test.ts: expect(n.endsWith("/") ? n.length > 1 : true).toBe(true) cannot fail except for a literal /. Prefer expect(n).toBe(n.replace(/\/+$/, "")).
  • fix(scope): repo= is always a bare token - hash non-git dir keys (#92) #101's body claims the old raw-path key was "unmatchable-by-hash across machines". A path-derived key is machine-local either way; the hash fixed quoting and spelling stability, not portability. Correct the wording before someone builds on that reading.

Surfaced during the adversarial review of #101 (2026-10-25), which was approved with these nits.

Activity

  1. added
    bug
    severity:high
    on Oct 25, 2026
  2. abogartz commented on Oct 30, 2026

    @abogartz
    OwnerAuthor

    Severity triage 2026-10-30 — severity:high (not critical: four preconditions must hold at once)

    Reviewed against main @ 525ed89. Still present — src/repokey.ts:75 is unchanged:

    if (process.platform === "win32" || process.platform === "darwin") r = r.toLowerCase();

    I am deliberately not marking this critical even though it is a silent cross-project visibility leak, because reaching it needs all four of:

    1. macOS and a deliberately-created case-sensitive APFS volume (the default is case-insensitive);
    2. a path-derived repo key, i.e. a repo with no git origin (a git-origin repo keys off the remote, not the path);
    3. two directories differing only in case on that volume;
    4. colliding scope names between the two projects.

    isVisibleHere matching on m.repo === cur.key alone means the leak is real when those do hold, and it is silent — same class as #90. But #140 (the README overclaim) went first for exactly this reason: 100% exposure vs. a four-way conjunction.

    Why high rather than medium: the fix changes repo-key semantics, so it is not a hotfix — it needs a migration story for existing stores whose rows were stamped under the old fold. That is a design decision with a compat surface, which is what "high" is for here: needs thought and ownership, not a 5-line patch. Your realpathSync-vs-case-flipped-spelling probe is the right shape and cheap; the migration is the actual work.

    Also from your "smaller items" list, still unfixed: test/repokey-path.test.ts still has the tautological expect(n.endsWith("/") ? n.length > 1 : true).toBe(true), and #101's body still claims the old raw-path key was "unmatchable-by-hash across machines" (a path-derived key is machine-local either way).

  3. self-assigned this
    on Nov 2, 2026
  4. abogartz commented on Nov 2, 2026

    @abogartz
    OwnerAuthor

    Claiming #109. Plan: replace the platform-based fold in normalizeDirPath with a per-path volume probe (flip one cased character of the deepest existing component; same dev+inode under the flipped spelling = the volume folds names itself = fold is correct; undecided falls back to the current platform rule). Compat story: no re-stamp migration — rows written under the old fold carry repoPath (true spelling), and isVisibleTo already matches on it, so they stay visible to their own repo while the cross-case leak closes for old rows too. Also fixing the two smaller items from the body: the tautological assertion in test/repokey-path.test.ts and #101's 'unmatchable-by-hash across machines' wording.

  5. added
    agent:ready
    on Nov 2, 2026
  6. added a commit that references this issue on Nov 2, 2026
  7. abogartz-opencode-self-improvement commented on Nov 2, 2026

    @abogartz-opencode-self-improvement

    🎉 This issue has been resolved in version 0.15.7 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

  8. removed
    agent:ready
    on Nov 2, 2026
  9. abogartz commented on Nov 2, 2026

    @abogartz
    OwnerAuthor

    Closing: fixed by #250, merged 2026-11-02. isCaseInsensitivePath is on main (src/identity/repokey.ts). Ticket already carried released; the agent:ready label was stale and a fixer run had begun re-implementing the shipped fix.

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

Metadata

Metadata

Assignees

Labels

bugreleasedseverity:high

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions