Repository navigation
Confine local task state to the worktree - #1793
Conversation
Co-Authored-By: Codex <noreply@openai.com> Architecture-Review: unchanged; the local state and review trust boundaries remain the same.
There was a problem hiding this comment.
loopzero primary review by claude on 87c9ba01fcb86c5a6001e9d30ceafe6dc92c1ae8, 87.6s: approve (0 critical, 0 important, 3 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Native Claude output is retained in the restricted local review receipt.
| with _lock_task_state(wt): | ||
| with worktree.lock_local_state(wt): | ||
| _refresh_existing_pr_checks(wt, config) | ||
| except OSError as exc: |
There was a problem hiding this comment.
suggestion: Best-effort PR-body updates no longer catch the lock's refusal errors
_local_state_directory now reports a tracked .loopzero, a symbolic-link or non-directory state directory, and a failed git ls-files as WorktreeError/GitError. Neither of those subclasses OSError. The old _lock_task_state raised OSError(ENOTDIR) in the same situations, so these best-effort handlers used to catch it.
There are two places where the error now escapes:
_refresh_pr_checks(cli.py:550-555) only catchesOSError. If.loopzerois swapped or the git call times out after the receipt is saved,cmd_checkfails instead of printing the 'could not refresh PR checks' note.- In
cmd_review, the summary append after a successful post (cli.py:879-884) catches(GhError, ProcTimeout, OSError, ValueError). AWorktreeErrorthere turns a review that was already published into a non-verdict error exit.
The earlier pre-checks make this a race or git-failure edge case, not a common path. Smallest fix: add worktree.WorktreeError to both except tuples, as _save_review_failure_output already does.
|
|
||
| def read_local_state(wt: Path, name: str) -> str: | ||
| with _local_state_directory(wt) as fd, os.fdopen( | ||
| os.open(name, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK, dir_fd=fd), encoding="utf-8" |
There was a problem hiding this comment.
suggestion: A symbolic link at the file level produces a raw ELOOP error, unlike the directory-level WorktreeError
read_local_state opens the file with O_NOFOLLOW. When the artifact is a symbolic link, Python raises a plain OSError ("Too many levels of symbolic links") instead of a WorktreeError. This has inconsistent effects:
readyandstatusreach it through_load_report, which does not catch it, so the user sees the raw errno text._load_reviewturns it into the misleading "not runner-produced: invalid saved review".sandbox._previoussilently ignores it.
The new parametrized test for (ready, checks.json) passes only because the errno text happens to contain "symbolic link". Smallest fix: in read_local_state, catch OSError with errno.ELOOP (or call _regular_state before opening) and raise the same WorktreeError that _regular_state uses. Then every reader and writer reports the unsafe artifact the same way.
| @@ -958,7 +931,7 @@ def _has_recoverable_review( | |||
| if not _review_file(wt, head, kind).exists() or _review_file(wt, head, other_kind).exists(): | |||
There was a problem hiding this comment.
suggestion: _has_recoverable_review still checks for saved reviews with Path.exists()
cmd_review now gets saved_files from worktree.local_state_files, which checks for regular files without following symbolic links. _has_recoverable_review still uses _review_file(...).exists() for both kinds. That check follows symbolic links, and the second implementation can drift from the one in local_state_files.
The current behavior is safe because local_state_files already rejected symbolic links and _load_review reads through read_local_state. Still, a shared helper should be the only source of this check. Smallest fix: pass the saved_files existence flags (or a kind-to-exists dict) into _has_recoverable_review and remove its own .exists() calls.
Co-Authored-By: Codex <noreply@openai.com> Architecture-Review: unchanged; local state and hosted evidence retain their existing authority boundaries.
There was a problem hiding this comment.
loopzero delta review by claude on 730f28b0cdbf2fa1f23d2bfe3de025ce8d3e1fa8, 36.5s: approve (0 critical, 0 important, 0 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Native Claude output is retained in the restricted local review receipt.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Confine local task state to the worktree
Context and goal
Closes #1027
Replaces #1408. This carries its integrated, delta-reviewed code and updates the readiness test to account for the one Git index read that verifies local state is untracked.
Acceptance
Validation
Recorded for
730f28b0cdbfuv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review