You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sessions from different repositories are mixed when encoded paths collide #894
OCR derives the session-storage directory by replacing path separators with hyphens. This causes different repository paths such as:
/tmp/.../team/service-api
/tmp/.../team-service/api
to map to the same session directory.
After reviewing both repositories with the same HOME directory, ocr session list --repo returns sessions from both repositories. This can expose or mix session history in the session list, resume flow, or viewer.
Steps to Reproduce
Create two repositories whose paths collide after replacing / with -:
/tmp/.../team/service-api
/tmp/.../team-service/api
Configure OCR to use a local deterministic OpenAI-compatible mock server.
Build OCR from source.
Run a review for the first repository: ocr review --repo <repo-a> --commit HEAD --format json --audience agent
Run a review for the second repository using the same HOME directory.
Run: ocr session list --repo <repo-a> --json
Observe that sessions for both repositories are returned and stored under the same session directory.
Expected Behavior
Each repository should have an isolated session-storage directory. Running:
ocr session list --repo <repository> --json
should return only sessions belonging to that repository. Sessions from another repository should never appear in its list, resume flow, or viewer.
Logs / Error Output
Observed output showed two different repositories using the same session directory:
- `/tmp/.../team/service-api`
- `/tmp/.../team-service/api`
Both were stored under:
`.../.opencodereview/sessions/...-team-service-api/`
Running `ocr session list --repo <repository> --json` returned sessions for both repositories. No API keys or sensitive credentials were included.
@stay-foolish-forever@lizhengfeng101 I’ve reproduced this repository session-isolation issue locally and documented the behavior above. If you consider it worth addressing, I’d be happy to work on the fix. Please feel free to assign the issue to me.
@amh1k Thanks a lot for your detailed analysis and the extra work for reproducing it locally. I believe that you have a thorough understanding of this issue and can solve this issue for sure. Hope to see your PR soon :)
Additional impact: scan resume can cross repository boundaries.
loadScanResumeState finds a session through the collision-prone directory and then calls ValidateScanOptions. That validator checks mode and scan paths, but does not compare ResumeState.RepoDir with the current repository. With a collision such as /home/a/b vs /home/a-b, ocr scan --resume <id> can therefore accept a session from the other repository; matching item fingerprints may reuse its comments.
Suggested defense in depth: use a collision-resistant key such as basename + hash(canonical path), and independently reject resume when the canonical current repo differs from session_start.cwd. A regression test should cover the two paths above.
Thanks for the thorough analysis and reproduction, @amh1k, and the additional findings on the scan resume path, @EveEveeee.
After reviewing this, I think we'll hold off on a fix for now. The path-encoding collision is real, but the probability of hitting it in practice is quite low — it requires two repositories whose paths differ only by a separator-vs-hyphen boundary, sharing the same HOME directory.
More importantly, any fix here has a non-trivial blast radius: encodeRepoPath is used across 6 call sites (session write, list, resume, raw writer, viewer), and changing the encoding scheme introduces a backward-compatibility problem — existing session directories would need migration or dual-lookup logic, which adds complexity that's hard to justify for such a narrow edge case.
We'd prefer to revisit this when we have a cleaner migration path or a solution that doesn't require backward-compatibility shims. If anyone comes up with an approach that handles the existing-directory problem elegantly, we're happy to reconsider.
Activity
amh1k commentedon Aug 13, 2026
@stay-foolish-forever @lizhengfeng101 I’ve reproduced this repository session-isolation issue locally and documented the behavior above. If you consider it worth addressing, I’d be happy to work on the fix. Please feel free to assign the issue to me.
stay-foolish-forever commentedon Aug 14, 2026
@amh1k Thanks a lot for your detailed analysis and the extra work for reproducing it locally. I believe that you have a thorough understanding of this issue and can solve this issue for sure. Hope to see your PR soon :)
EveEveeee commentedon Sep 20, 2026
Additional impact: scan resume can cross repository boundaries.
loadScanResumeStatefinds a session through the collision-prone directory and then callsValidateScanOptions. That validator checks mode and scan paths, but does not compareResumeState.RepoDirwith the current repository. With a collision such as/home/a/bvs/home/a-b,ocr scan --resume <id>can therefore accept a session from the other repository; matching item fingerprints may reuse its comments.Suggested defense in depth: use a collision-resistant key such as
basename + hash(canonical path), and independently reject resume when the canonical current repo differs fromsession_start.cwd. A regression test should cover the two paths above.Source: scan_cmd.go, resume.go, persist.go.
AI/LLM disclosure: Prepared with OpenAI Codex (GPT-5) for source inspection and drafting; no project code was modified.
lizhengfeng101 commentedon Sep 24, 2026
Thanks for the thorough analysis and reproduction, @amh1k, and the additional findings on the scan resume path, @EveEveeee.
After reviewing this, I think we'll hold off on a fix for now. The path-encoding collision is real, but the probability of hitting it in practice is quite low — it requires two repositories whose paths differ only by a separator-vs-hyphen boundary, sharing the same HOME directory.
More importantly, any fix here has a non-trivial blast radius:
encodeRepoPathis used across 6 call sites (session write, list, resume, raw writer, viewer), and changing the encoding scheme introduces a backward-compatibility problem — existing session directories would need migration or dual-lookup logic, which adds complexity that's hard to justify for such a narrow edge case.We'd prefer to revisit this when we have a cleaner migration path or a solution that doesn't require backward-compatibility shims. If anyone comes up with an approach that handles the existing-directory problem elegantly, we're happy to reconsider.