Skip to content

fix(identity): reject case-variant symlink probes (#250 F1) - #251

Merged
abogartz merged 2 commits into
abogartz:fix/case-sensitive-volume-probe-109from
WhollyMindless:fix/pr250-f1-local
Nov 2, 2026
Merged

abogartz merged 2 commits into
abogartz:fix/case-sensitive-volume-probe-109from
WhollyMindless:fix/pr250-f1-local

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

Companion to #250, targeting fix/case-sensitive-volume-probe-109 rather than main. This addresses F1 from the review only; it does not close #109 or resolve F2's legacy-key compatibility policy.

On a case-sensitive filesystem, distinct Foo and foo directories plus FoO -> Foo fooled the case probe: statSync followed the alias and treated matching inodes as permission to lowercase the path. Both repositories could receive the same key and retrieve each other's newly written memories.

The probe now uses lstatSync at the exact component whose case changes and refuses symlinks there. Uncased descendants are trimmed before probing: checking only lstat(FoO/123) would still follow an ancestor symlink. Existing realpath canonicalization remains in place, so using a genuine alias as the input still resolves to its target.

Two regressions cover the direct alias and a numeric child. They assert distinct keys, owner retrieval, exclusion of the foreign row, and preservation of genuine alias identity. These cases explicitly skip when an independent filesystem oracle says case-variant directories cannot coexist.

Validation on Bun 1.4.4:

  • Case-sensitive WSL Linux: both new regressions fail against the unchanged fix(identity): probe volume case sensitivity instead of trusting the platform (#109) #250 head e079003; all 11 focused identity tests pass with the fix.
  • Windows full merge gate: typecheck and lint pass (498 warnings); 848 unit tests pass, 26 skip, 0 fail; all 30 real-host E2E tests pass. The two new case-sensitive regressions skip on this Windows volume.
  • git diff --check clean.

Limits: no live macOS APFS or case-sensitive NTFS validation; this is the reproduced symlink-alias fix, not a claim to settle all mixed-volume semantics or filesystem races. F2 remains a separate finding on #250.

Please feel free to merge this into your branch, cherry-pick, adapt, defer, or reject it. This is an optional contribution to your PR; scope and merge decisions remain yours.

@abogartz abogartz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head d97a19fbb5a90c559d861ccdfa036dd62f596966.

Commands run (macOS, Bun 1.4.x):

  • gh pr checks 251: lint / test / test-windows / smoke all pass
  • bun run typecheck: clean
  • bun run lint: 498 warnings = baseline
  • bun run test: 860 pass / 14 skip / 0 fail (874 total; the 2 new alias tests skip on this case-insensitive APFS root by oracle design)
  • bun run test:e2e: 30 pass / 0 fail (src/ changed)
  • bun test test/repokey-path.test.ts: 11 tests, 9 pass / 2 skip / 0 fail — matches the body's "11 focused identity tests" claim

Red/green differential on a real case-sensitive APFS volume (hdiutil image mounted at an all-lowercase mountpoint):

  • At merge-base e079003: with Foo/, foo/, and symlink FoO -> Foo, isCaseInsensitivePath(Foo) returned true and resolveRepo(Foo).key === resolveRepo(foo).key — the collision reproduced for exactly the stated reason, for both suffix variants "" and "123".
  • At head d97a19f: probe returns false, keys are distinct, and resolveRepo(FoO).key === resolveRepo(Foo).key — genuine alias canonicalization preserved.
  • Note: the collision requires an all-lowercase ancestor path; an uppercase ancestor component masks it because flipping it yields a missing path (definitive false). This matches the test file's own oracle-parent comment.

Findings:

  • No P0/P1. The lstatSync + symlink-refusal at the changed component closes the alias hole; trimming uncased descendants before probing is correct since the flipped index is the last cased character by construction.
  • nit src/identity/repokey.ts:86-88: the rewrapped comment breaks mid-thought ("the probe accepts case folding." reads as a new sentence); cosmetic.
  • nit test/repokey-path.test.ts:247: uses global crypto.randomUUID() while the file imports createHash from node:crypto; works on Bun, just inconsistent.

Verified the body's claims against the tree, not the commit messages. F2 deferral on #250 is the branch owner's call.

@WhollyMindless

Copy link
Copy Markdown
Contributor Author

Thanks for independently checking both suffix variants on case-sensitive APFS. Addressed the two nits in df90d5f: rewrapped the probe comment and imported randomUUID from node:crypto. No runtime logic or assertion changes. Typecheck and focused Windows identity tests pass (9 pass, 2 capability skips); hosted checks will rerun on the new head. F2 remains separate on #250.

@abogartz abogartz left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head df90d5ff544fa8c79564c35c7177f8cc8e34e31b (incremental over d97a19f, which I already verified red/green on a case-sensitive APFS volume).

Incremental diff verification. d97a19f..df90d5f touches 2 files, +5/-5: comment rewrap in src/identity/repokey.ts:69-72 and crypto.randomUUID() → imported randomUUID in test/repokey-path.test.ts:9,245. Both nits from my prior review, resolved as described. Author's claim 'no runtime logic or assertion changes' verified true against the tree.

Commands run at this head (measured):

  • bun run typecheck — clean
  • bun run lint — 498 warnings = baseline, 131 infos
  • bun run test — 874 tests: 860 pass / 14 skip / 0 fail
  • bun run test:e2e — 30 pass / 0 fail
  • git diff --check — clean
  • CI: lint / test / test-windows / smoke all pass

Body claims verified against tree:

  • lstatSync at exact flipped component with symlink refusal: src/identity/repokey.ts:122-126 (!original.isSymbolicLink() && !flipped.isSymbolicLink() + dev/ino equality)
  • Uncased-descendant trimming: caseProbePair slices at first separator after the flipped char (src/identity/repokey.ts:88-91)
  • Realpath canonicalization kept: src/identity/repokey.ts:150
  • Two regressions (test.each(['', '123'])) with independent filesystem-oracle skip (test/repokey-path.test.ts:238-243)

Findings: no P0, no P1, no nits. Prior 2 nits resolved.

Base is fix/case-sensitive-volume-probe-109 as stated. Human merges.

@abogartz
abogartz merged commit 4a4a9c5 into abogartz:fix/case-sensitive-volume-probe-109 Nov 2, 2026
4 checks passed
@abogartz abogartz added the review:requested Human-admitted for autonomous review by ocsi-reviewer label Nov 2, 2026

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Head reviewed: df90d5ff544fa8c79564c35c7177f8cc8e34e31b (diff key 9f3be56e…42d4), base e079003c87b29c4c55156a389c7069ea933d922d (fix/case-sensitive-volume-probe-109).

Contract: closingIssuesReferences is empty, so there is no issue to verify against and approval is withheld per policy (comment-only verdict). The de-facto contract is the F1 acceptance text from review 5736756460 on #250, quoted verbatim below. F2 is explicitly out of scope for this PR and is treated as such.

Criteria (verbatim from #250 F1) and evidence

  1. "the alternate spelling must not establish case-insensitivity merely by following an alias" — MET. src/identity/repokey.ts:123-126 probes with lstatSync and rejects a symlink at either spelling (!original.isSymbolicLink() && !flipped.isSymbolicLink()). On a case-sensitive APFS volume (hdiutil, Case-sensitive APFS, mountpoint /Volumes/osi251cs) with distinct Foo/foo dirs and FoO -> Foo, isCaseInsensitivePath returns false at this head (test/repokey-path.test.ts:260 green); at base e079003 the same assertion fails Expected: false / Received: true — the exact F1 mechanism (statSync following the alias).
  2. "Pin two distinct real directories plus a case-variant symlink, and verify the foreign row is excluded." — MET. test/repokey-path.test.ts:243-274 creates Foo, foo, FoO -> Foo; asserts distinct keys (:261), owner retrieval via appendMemory/relevantKnowledge, and foreign-row exclusion (:270 not.toContain). Green at head on the case-sensitive volume; red at base for the stated reason.
  3. "one component's result should not justify folding case-sensitive ancestor components" — MET for the stated mechanism. caseProbePair (src/identity/repokey.ts:89-101) trims uncased descendants so lstat targets the exact changed component; the test.each(["", "123"]) numeric-child variant covers lstat("FoO/123") following an ancestor alias — green at head, red at base. Mixed-volume / per-directory NTFS semantics are outside what the finding itself exercised (the finding says so) and are not judged here.

Preserved behavior: genuine alias input still canonicalizes to the target (test/repokey-path.test.ts:264, realpathSync at src/identity/repokey.ts:150 unchanged) — green.

Commands run (measured)

  • bun run typecheck — 0 errors.
  • bun run lint — 498 warnings = baseline.
  • bun run test — 860 pass / 14 skip / 0 fail (the 2 new skips are the case-variant regressions on this folding boot volume, by design).
  • bun run test:e2e (src/ changed) — 30 pass / 0 fail.
  • Differential on real case-sensitive APFS (hdiutil Case-sensitive APFS volume; test parent pointed at the mount for the run, not committed): head df90d5f → bun test test/repokey-path.test.ts 11 pass / 0 fail (new tests executed, not skipped); base e079003 + the new test file → 9 pass / 2 fail, failing at :260 with Expected: false / Received: true — the stated alias-following reason. Differential valid: fixed side clean, broken side fails for the stated reason.
  • CI at this head: lint / test / test-windows / smoke all pass.

Test integrity

Diff to test/repokey-path.test.ts is purely additive (46 insertions, 1 import line). No deleted assertions, no .skip added to existing tests, no widened tolerance. describe.skipIf(aliasVolumeFolds) (:243) is guarded by volumeFoldsCase (:40), an independent filesystem oracle that never calls the probe under test; it skips only where case-variant directories cannot coexist.

Findings

  • P0: none.
  • P1: none.
  • nit (src/identity/repokey.ts:125): on Windows, whether a case-variant junction alias is rejected depends on lstatSync(...).isSymbolicLink() reporting junctions as symlinks; this cannot be mechanically checked from this machine (no case-sensitive NTFS available), and the PR body already declares case-sensitive NTFS unvalidated. The test already creates the alias as a junction on win32 (test/repokey-path.test.ts:253), so a real case-sensitive-NTFS run would cover it. Not a blocker.

Verdict: APPROVE-equivalent, posted as COMMENTED — every F1 criterion is evidenced at this head, but closingIssuesReferences is empty so no approve event is filed, and the base-branch/merge decision (this targets fix/case-sensitive-volume-probe-109, not main) remains the human's.

@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

released review:requested Human-admitted for autonomous review by ocsi-reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants