Skip to content

fix: isolate legacy folded repository stamps (#254) - #262

Merged
abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/254-legacy-repo-isolation
Nov 3, 2026
Merged

abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/254-legacy-repo-isolation

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

Closes #254.

A historical whole-path-lowercased key for Foo can equal the current path key of a distinct foo directory. The shared visibility checks accepted that key despite a conflicting stored repoPath, exposing the owner's memories and evidence to the sibling.

Memory rows, raw restore lines and evidence now share a repository matcher. When the stamp matches the historical lowercase hash of its canonical stored path, access follows that directory, including real symlink/junction and case-insensitive aliases. Remote-derived keys retain sharing between clones at different paths. No row rewrite or schema migration is required; #168's session-binding work is untouched.

Compatibility limit: stamps without repoPath retain key-only matching because the historical identity source cannot be recovered from the key alone. README states that limit. Global/admin access and session-private unstamped evidence keep their existing rules.

Validation on Bun 1.4.4, based on main d286e7a:

  • Before the fix, the initial regression file on case-sensitive WSL Linux reported 3 pass / 4 fail: sibling retrieval, evidence disclosure, raw restore authorization and legacy-owner alias access. The fixture asserts that the legacy owner key equals the sibling's current key, so uppercase temporary ancestors cannot mask the collision.
  • Final WSL Linux focused set: 59 pass / 0 fail across 8 files, including all 9 new regressions, scope: case folding decided by platform leaks rows across dirs on case-sensitive volumes #109/fix(identity): probe volume case sensitivity instead of trusting the platform (#109) #250 path and symlink coverage, session scoping, export visibility, viewer scope and undo ownership. Historical folded stamps are synthesized, not a live Windows/macOS migration.
  • Full Windows bun run gate: typecheck and lint pass (498 warnings / 131 infos); 866 unit tests pass / 31 skip / 0 fail, and 30 real-host E2E tests pass / 0 fail. Five new case-sensitive tests skip on this Windows volume and run on WSL Linux. The new test file has no lint diagnostics.
  • Existing tests and assertions are unchanged. No catalog mutant was added: the real-filesystem legacy-stamp regressions reproduce the defect directly on unmodified main. No full mutation sweep or performance measurement is claimed.

Taking this issue following the maintainer's Discord handoff relayed by the user. Please feel free to narrow or reject this compatibility approach if you prefer explicit identity provenance or migration.

@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.

Approved at head d0cd1f1015e3a894f32d3b3592397fdf77632fff (diff key 72b61ff517486a99a13f5b0a6d48cbe0d7ebc704b9c4280ce75ffc7a0362b85f).

Contract: #254 (author WhollyMindless, trusted human; no prior osi-spec-hash: anchor — anchor posted at the text reviewed here). Diff: README.md +2/−0, src/store/model/visibility.ts +24/−7, test/legacy-repo-visibility.test.ts +171/−0 (git diff --numstat).

Policy implemented (the decision #254 asked for)

matchesRepository (visibility.ts:69-81): a stamp whose key equals the legacy whole-path-lowercased hash of its stored repoPath is matched to that directory (via normalizeDirPath, so real symlink/case-insensitive aliases pass), not to any current key that happens to collide. Remote-derived keys fall through to repo === scope.key (clones keep sharing). Stamps without repoPath keep key-only matching. README:122 documents the same.

Acceptance coverage from #254, per item

  1. "Legacy owner can still retrieve its rows; a distinct case-sensitive sibling cannot." — test/legacy-repo-visibility.test.ts:68-76; ran green on the ubuntu test job (case-sensitive ext4), run 41553457268 log 00:31:33. Independent differential by this review on a real case-sensitive APFS volume (hdiutil, lowercase mount): head sibling_sees_row=false, owner_sees_row=true; merge-base d286e7a sibling_sees_row=true — leak reproduced for the stated cause, fix isolates.
  2. "Equivalent legacy evidence stamps obey the same boundary." — :78-94 (memory_evidence end-to-end), :96-102 (restore lineVisibleTo), both green on ubuntu; probe evidence=false at head / true at base.
  3. "Clones intentionally sharing a remote-derived identity retain their supported visibility." — :125-142 uses real git init + remote add clones, runs on every platform (outside the skipIf), green in all three CI jobs.
  4. "Ordinary case-insensitive paths and actual symlink aliases retain the behavior covered by #250/#251." — :144-151 (case spellings), :104-111 (symlink alias retains access) and :113-122 (alias-stamped row still excludes the sibling); existing #250/#251 suites unchanged and green.

Commands run at this head (measured)

  • bun run typecheck → exit 0
  • bun run lint → 498 warnings = baseline
  • bun run test → 892 pass / 14 skip / 0 fail (the 5 case-sensitive-volume tests skip on this case-insensitive APFS host; they ran on ubuntu CI)
  • bun run test:e2e → 30 pass / 0 fail
  • CS-volume differential probe: head isolates, merge-base leaks (evidence above)

No existing assertion deleted, skipped, widened or re-toleranced: the only deletions in the diff are inside visibility.ts (the replaced key-or-path expression); no existing test file is touched.

test-windows failure (required context — quoted, attributed)

Job test-windows, run 41553457268, step "Tests":

(fail) supersede racing appends > a concurrent reader never sees a half-written file [5192.33ms]
ENOENT: no such file or directory, open 'C:\Users\RUNNER~1\AppData\Local\Temp\osi-race-MYMRoS\memory\evidence\2026-11-03.logfmt'
(fail) prune racing appends / restore racing appends ×2 / two processes sharing one store ×2

Attribution: all 22 fixture-path references in the failed log point at one root (osi-race-MYMRoS) — the six failures are one event: the 5192ms timeout kill orphaned supersede promises, afterEach removed the fixture root, the survivors' ENOENTs were charged to the five tests that followed. This is the documented flake of that exact test (green on rerun at identical commits before this PR); concurrency.test.ts write paths are untouched by this diff, and the new test file's bodies skip on NTFS (foldsCase, confirmed in the job log). ci.yml itself: "test-windows is informational — it reports, it cannot gate merges." A rerun (gh run rerun 41553457268 --failed) needs actions:write, which the reviewer app lacks — a maintainer can trigger it.

Findings

  • nit: test-windows red as analyzed above — rerun recommended before merge for a clean board; no code defect found in or around it.
  • nit: matchesRepository classifies a stamp as legacy only when repoPath is present; a legacy folded stamp that lost its repoPath keeps the broad key match. Deliberate and documented (README:122, test :164-171) — historical identity is unrecoverable from the key alone.

— ocsi-reviewer

@abogartz
abogartz merged commit 296c7b1 into abogartz:main Nov 3, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.15.13 🎉

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.

Legacy folded repository keys expose rows to a case-distinct sibling (F2 follow-up)

2 participants