Repository navigation
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on 171175017ce86c18f5ba434d38c234ed4aeb2b8e, 102.7s: 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.
|
|
||
|
|
||
| def read_local_state(wt: Path, name: str) -> str: | ||
| with _local_state_directory(wt) as fd, os.fdopen( |
There was a problem hiding this comment.
suggestion: Symlinked state files surface as a bare ELOOP error with only the relative name
read_local_state opens the file with O_NOFOLLOW but does not translate the resulting OSError(ELOOP). Paths that skip the local_state_files pre-check therefore show [Errno 40] Too many levels of symbolic links: 'checks.json' with no worktree path. That covers ready/status via _load_report, and pr/review via task_text. The directory-level and _regular_state paths raise a WorktreeError that names the full .loopzero/... path. In _load_review, the same ELOOP is reported as "not runner-produced: invalid saved review", which hides the real cause. The command still exits 1, so this is not a safety gap. Smallest fix: in read_local_state, catch OSError with errno.ELOOP and re-raise WorktreeError(f"local state file is a symbolic link: {wt / '.loopzero' / name}"). That gives every caller one consistent diagnostic.
| 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 lock/refresh paths no longer absorb directory-level rejections
Before this change, _lock_task_state failures were plain OSErrors, which _refresh_pr_checks (line 504) and the PR review-summary append in cmd_review (line 820) catch and print as notes. _local_state_directory now raises WorktreeError for tracked or symlinked state, and WorktreeError is not an OSError. _refresh_existing_pr_checks (line 519) can also receive WorktreeError from _load_report/task_text. The up-front checks make this reachable only if the state is swapped during the command. Even so, in cmd_review the review has already been posted at that point, so the command ends with an error instead of the review's verdict exit code. Smallest fix: add worktree.WorktreeError to the except tuples at lines 504, 519 and 820 so these steps stay best-effort.
| @contextmanager | ||
| def _local_state_directory(wt: Path, *, create: bool = False, lock: bool = False): | ||
| path = wt / ".loopzero" | ||
| if _git(wt, "ls-files", "-z", "--", ".loopzero"): |
There was a problem hiding this comment.
suggestion: Every local-state access runs another git ls-files subprocess
_local_state_directory runs git ls-files on every read, write, check and lock. The diff's own test changes show the cost: review goes from 14 to 18 git calls, and ready and status each gain one. cmd_check also pays this on every partial-report checkpoint during run_checks. This is correct, but the git cost keeps growing with each new state access. Possible fix: check tracked status once per command, or pass the open directory descriptor through within a command. Then repeated accesses only re-check the directory's file type, which is cheap.
|
@Mergifyio queue |
❌ Left the queue ·
|
|
No description provided. |
|
Parked at approved head |
…ktree Co-Authored-By: Codex <noreply@openai.com> Architecture-Review: unchanged; the existing worktree-local state and review authority boundaries apply to the resolved receipt paths.
Co-Authored-By: Codex <noreply@openai.com> Architecture-Review: unchanged; reviewer diagnostics follow the existing worktree-local receipt boundary.
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero delta review by claude on 325d9cc5d5c908a6d71f9240b1b4ed6aa4bbc00d, 29.1s: approve (0 critical, 0 important, 1 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.
| monkeypatch.setattr(cli.runners, "review_with", malformed) | ||
| if not save: | ||
| def fail(*args): | ||
| def fail(*args, **kwargs): |
There was a problem hiding this comment.
suggestion: Diagnostic-failure test never reaches the new WorktreeError branch
The test replaces the whole worktree.write_local_state with a stub that raises PermissionError. That only covers the OSError half of the new except (OSError, worktree.WorktreeError) in _save_review_failure_output (cli.py:1137). The case this branch was added for never runs: an unsafe .loopzero directory, a symlinked or non-regular reviewer-output-*.json, or tracked local state. Each of these raises WorktreeError. If that exception were dropped from the tuple, a malformed-review run with a redirected state directory would crash. It would no longer report "Could not save reviewer output", and every test would still pass. Smallest fix: add a parametrized case that creates wt/.loopzero/reviewer-output-<head12>-primary.json as a symlink to an external file, without stubbing the writer. Then assert that the error output contains "Could not save reviewer output" and "symbolic link", and that the external file is unchanged.
Confine local task state to the worktree
Context and goal
Closes #1027
Acceptance
Notes
Reject tracked state before using it as evidence. Check the state directory and direct child at the point of use. Use a directory descriptor for reads, writes and chmod so path replacement cannot redirect them.
This replaces #1356 and #1306. It carries their local-state change and routes the PR-body updates added by #1230 through the same guarded directory lock as receipt publication.
Validation
Recorded for
171175017ce8(not current head) (unverified, runloopzero check)uv 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 0The previous full-suite rerun passed, including the earlier intermittent readiness case. The conflict resolution passed the size budget and 16 focused cases.
Base
Base: c5232bb
Review
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.