Repository navigation
Keep local receipts in the task worktree - #1589
Conversation
Architecture-Review: unchanged; The guide already assigns local receipts to the task worktree and describes atomic local evidence. Co-Authored-By: Codex <noreply@openai.com>
…eipts-in-worktree
There was a problem hiding this comment.
loopzero primary review by claude on bd247d175d7f2a03a91ee7b040ecdf8474c37466, 40.8s: 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.
| _write_json_atomically(path, data) | ||
| with _lock_task_state(wt) as directory: | ||
| os.fchmod(directory, 0o700) | ||
| if path.is_symlink(): |
There was a problem hiding this comment.
suggestion: Symlink pre-check uses the path, not the locked directory fd
Both receipts are now published with os.replace(..., src_dir_fd=directory, dst_dir_fd=directory). A rename replaces the directory entry itself and does not follow a symlink, so a symlinked receipt can no longer send the write somewhere else. The remaining path.is_symlink() check goes back through wt/.loopzero/... by path instead of using the fd that was opened and locked. That makes it a separate check that can drift from the one actually enforced. If you want to keep refusing a symlinked receipt, use stat.S_ISLNK(os.lstat(path.name, dir_fd=directory).st_mode) and handle FileNotFoundError, so the check uses the same directory handle. Otherwise drop the check, since the dir_fd rename already makes it unnecessary.
| path.parent.symlink_to(external, target_is_directory=True) | ||
| monkeypatch.setattr(cli.os, "replace", interrupt) | ||
| with pytest.raises(OSError, match="publication interrupted"): | ||
| with pytest.raises(OSError, match="Not a directory" if redirected else "publication interrupted"): |
There was a problem hiding this comment.
suggestion: Test expects one platform's error for a refused symlink
In the redirected case, the test matches "Not a directory". That message comes from Linux, which returns ENOTDIR when O_DIRECTORY | O_NOFOLLOW meets a symlink. Other systems such as macOS/BSD return ELOOP, so the test would fail there even though the code is correct. If the project only targets Linux this is fine. Otherwise accept either errno (for example match="Not a directory|Too many levels", or check exc.errno in {ENOTDIR, ELOOP}). The same applies to the _save_review assertion further down.
| def _lock_task_state(wt: Path) -> Iterator[None]: | ||
| def _lock_task_state(wt: Path) -> Iterator[int]: | ||
| directory = wt / ".loopzero" | ||
| directory.mkdir(parents=True, exist_ok=True) |
There was a problem hiding this comment.
suggestion: New review-state directory is not private until after creation
Before this change, _save_review created .loopzero with mode=0o700. Now _lock_task_state creates it with the umask default (usually 0o755), and _save_review only fixes it with fchmod(0o700) once the directory is open. Staged files are 0o600, so the exposure is small. Still, _lock_task_state could pass mode=0o700 to mkdir so a newly created directory starts out private for every caller.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Keep local receipts in the task worktree
Context and goal
Closes #1538
Acceptance
Base
main @ 89788a4
Base: 89788a4
Validation
Recorded for
bd247d175d7fuv 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