fix(claude): exact path/UUID discovery without broad project scans (#19) - #107
Conversation
Prefer direct approved projects/<slug>/<uuid>.jsonl candidates and basename probes so large ~/.claude/projects trees no longer exhaust discovery bounds before an exact reference is considered. Recorded cwd validation and graph semantics stay unchanged.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bffcad3c35
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| direct = _direct_uuid_under_slugs(root, exact_uuid, prefer_slugs) | ||
| if direct: | ||
| return direct |
There was a problem hiding this comment.
Fall back when the direct UUID candidate fails cwd validation
When the guessed cwd-slug contains this UUID but its transcript records a different primary cwd, this early return prevents probing the other project buckets. If a relocated copy of the same UUID elsewhere records the requested cwd, _summary rejects the direct candidate and show <uuid> --cwd ... reports E_NO_MATCH even though the eligible session exists; the broad basename fallback therefore needs to run when the direct candidate fails recorded-cwd validation, not only when its file is absent.
Useful? React with 👍 / 👎.
Address Codex P2: a cwd-mismatched file under the guessed project slug must not block basename probing of other buckets for an eligible copy.
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ab6f5aa45
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if error.code == "E_UNSAFE_PATH" and not os.path.lexists(os.path.abspath(ref)): | ||
| raise DiagnosticError("E_NO_MATCH", source="claude", provider=FORMAT_ID) from error |
There was a problem hiding this comment.
Preserve unsafe diagnostics for unapproved missing paths
When an absolute ref is outside the approved root—or traverses a symlinked directory—and its final leaf does not exist, require_regular_no_symlinks correctly raises E_UNSAFE_PATH, but lexists returns false and this branch converts it to E_NO_MATCH. This bypasses the established fail-closed path classification used by select_session, so callers can no longer distinguish an unapproved path from a missing approved transcript; only convert the error after first proving the missing path is lexically within the approved root and has no unsafe parent components.
Useful? React with 👍 / 👎.
Only map missing absolute refs to E_NO_MATCH when they are lexically under the approved Claude root; outside or traversal failures stay unsafe.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3da7b4e6d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Absolute approved path: validate/read that file only (#19). | ||
| exact_path = _exact_path_candidate(root, query) | ||
| if exact_path is not None: | ||
| paths: list[str] = [exact_path] |
There was a problem hiding this comment.
Apply the exact-path fast path before probing the store
When the requested absolute transcript has more than 2,000 sibling entries, reader.run calls probe before this branch; the probe performs non-exact _session_paths enumeration, _bounded_names raises E_LIMIT_EXCEEDED, and the probe reports unsupported, so the reader exits before _exact_path_candidate can read the requested file. Thus the installed show <absolute-path> flow still fails on precisely the high-cardinality directories this fast path is intended to handle; probe needs an equivalent exact-reference path or must otherwise avoid enumerating that directory.
Useful? React with 👍 / 👎.
| try: | ||
| summary = _summary(candidate, root, query, budget) | ||
| except DiagnosticError: | ||
| continue |
There was a problem hiding this comment.
Propagate validation errors instead of treating them as cwd misses
When a direct UUID transcript has more than scanned_records metadata lines in the metadata window, _summary raises E_LIMIT_EXCEEDED here even though the transcript remains within the separate transcript_records show limit; this blanket handler suppresses the error, excludes the already-tried direct path from fallback, and returns E_NO_MATCH. The same transcript succeeds when source_path is supplied, so only an actual None summary should be treated as a cwd mismatch, while limit/source-busy/corruption diagnostics should propagate.
Useful? React with 👍 / 👎.
Probe accepts absolute path / UUID+slug without project enumeration so high-sibling dirs stay supported before list/show. Show no longer swallows limit/busy/corrupt diagnostics as soft cwd misses.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4278df91bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if _lexical_under_root(absolute, root) and not os.path.lexists(absolute): | ||
| raise DiagnosticError("E_NO_MATCH", source="claude", provider=FORMAT_ID) from error |
There was a problem hiding this comment.
Preserve unsafe errors for missing leaves under symlinked parents
Fresh evidence on the current HEAD: when projects/<slug> is a symlink and the requested UUID leaf does not exist, require_regular_no_symlinks rejects the symlinked parent, but this condition sees only that the final leaf fails lexists and rewrites E_UNSAFE_PATH to E_NO_MATCH. The reader consequently reports an ordinary missing transcript for an unapproved path; verify every existing parent component is safe before converting a missing leaf to no-match.
Useful? React with 👍 / 👎.
| if exact is not None and prefer: | ||
| for path in _direct_uuid_under_slugs(root, exact, prefer): | ||
| report = _probe_path(path) | ||
| if report is not None: | ||
| return report |
There was a problem hiding this comment.
Carry exact UUID discovery through the probe fallback
When the UUID is absent from the cwd-slug directory but exists in a relocated bucket, this fast path finds no direct candidate and falls through to the non-exact _session_paths call; if the cwd-slug directory has more than scanned_records sibling files, _bounded_names raises and probe returns unsupported. Since reader.run invokes probe before list, the basename-only UUID fallback in list is never reached, so keep the exact UUID constraint when probing after a direct miss.
Useful? React with 👍 / 👎.
Keep E_UNSAFE_PATH when a missing leaf sits under a symlink parent, and probe exact UUIDs with basename-only discovery so large cwd-slug dirs no longer mark the store unsupported before list can fall back.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f516aa9c4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if _missing_under_safe_parents(absolute, root): | ||
| raise DiagnosticError("E_NO_MATCH", source="claude", provider=FORMAT_ID) from error |
There was a problem hiding this comment.
Restrict no-match conversion to valid missing session paths
When an absolute ref is missing but lies inside the root outside the approved projects/<slug>/<uuid>.jsonl layout, this condition converts require_regular_no_symlinks's fail-closed E_UNSAFE_PATH into E_NO_MATCH; the same happens when an intermediate lstat fails with an error such as EACCES, because _missing_under_safe_parents treats every OSError as evidence of absence. Existing paths with the same invalid layout are rejected by _session_layout_ok below, so validate the lexical session layout and distinguish ENOENT from other filesystem errors before performing this conversion.
Useful? React with 👍 / 👎.
Require projects/<slug>/<uuid>.jsonl shape and ENOENT-only parent absence before converting missing absolute refs to no-match; invalid layout and permission errors stay E_UNSAFE_PATH.
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c1fdebefc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| except DiagnosticError as error: | ||
| if error.code in {"E_UNSAFE_PATH", "E_SOURCE_BUSY"}: | ||
| return CapabilityReport(self.key, FORMAT_ID, "unsafe", root=root) | ||
| exact_path = None |
There was a problem hiding this comment.
Short-circuit probing after a missing exact path
When an approved absolute transcript path is missing and its cwd-slug directory contains more than scanned_records siblings, _exact_path_candidate raises E_NO_MATCH, but this handler discards that result and falls through to the non-exact _session_paths scan. The scan then exceeds its membership limit, so reader.run stops at probe with E_UNSUPPORTED_FORMAT instead of allowing list to report E_NO_MATCH; treat a safely classified missing absolute ref as evidence of a supported store without enumerating unrelated sessions.
Useful? React with 👍 / 👎.
A safely classified missing projects/<slug>/<uuid>.jsonl ref keeps the store supported without falling through into non-exact sibling enumeration.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2931d8394
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| current = os.lstat(path) | ||
| except OSError: | ||
| return False |
There was a problem hiding this comment.
Preserve errors from exact UUID candidate probes
When an exact UUID's preferred project directory exists but is not searchable (for example, its execute permission is removed), lstat(candidate) raises EACCES here and this helper reports the candidate as absent. The new basename-only discovery paths then return an empty list—and probe can still report supported—whereas the previous directory scan surfaced E_SOURCE_BUSY, so non-absence errors should not be converted into E_NO_MATCH.
Useful? React with 👍 / 👎.
| if os.path.lexists(absolute): | ||
| return False |
There was a problem hiding this comment.
Preserve final-leaf lookup errors during missing-path checks
Fresh evidence after the current safe-parent fix: on POSIX, when the slug directory exists but lacks search permission, lexists returns false for the final leaf without exposing the EACCES, while the subsequent lstat calls on the parent directories can still succeed. This makes _missing_under_safe_parents return true and converts an inaccessible absolute ref from E_UNSAFE_PATH to E_NO_MATCH; explicitly lstat the leaf and classify only FileNotFoundError as missing.
Useful? React with 👍 / 👎.
Merge disposition (exact HEAD
|
Summary
Closes #19. Claude exact-reference discovery no longer needs to enumerate unrelated
~/.claude/projectsbuckets before considering a direct candidate.projects/<slug>/<uuid>.jsonlpaths are validated/read without calling broad_project_dirs().Test plan
PYTHONPATH=src python3 -m unittest tests.adapters.test_claude_codex_cursor.ClaudeAdapterTests -vPYTHONPATH=src python3 -m unittest discover -s tests -q(617)python3 scripts/self_verify.pypython3 scripts/check_secrets.pyPYTHONPATH=src python3 scripts/smoke_installed_matrix.py(81/81)