Repository navigation
Preserve PR body sections across checkouts - #1922
Conversation
Co-Authored-By: Codex <noreply@openai.com>
|
The regression runs real check and review commands against one fake GitHub PR from separate Git checkouts. It pauses check just before its full-body PATCH. With main’s original source, review publishes and the delayed check erases the Review entry. With this change, review waits for the existing |
There was a problem hiding this comment.
loopzero primary review by claude on 2b4a38b225fc261e35407702b6d35e3a15fd2164, 54.4s: approve (0 critical, 0 important, 2 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.
| pr = github.pr_for_branch(config.repo, branch, open_only=True) | ||
| if pr is None or pr.head_sha != head: | ||
| return | ||
| with github.pr_lock(config.repo, pr.number): |
There was a problem hiding this comment.
suggestion: PR body writers can now publish another check's in-progress checkpoint from the same worktree
_refresh_pr_checks and cmd_pr (line 734) used to read checks.json through _validation_section while holding worktree.lock_local_state. That stopped them from seeing the partial reports that sandbox.run_checks writes through checkpoint=partial(_save_report, ...) while a check is running. They now hold only github.pr_lock.
How it fails: in one worktree, check A finishes and releases the worktree lock (line 684). Check B starts and writes a partial checkpoint. A's refresh, or a concurrent loopzero pr, then puts B's incomplete results into the Validation section. Before this change, both would have waited for B's final receipt. B's own refresh normally overwrites it later. But that refresh is best-effort, so if it fails, or B is interrupted, the PR keeps the partial Validation.
Smallest fix: take the worktree lock around the PR lock in both places (with worktree.lock_local_state(wt), github.pr_lock(...)). This can't deadlock, because review takes only pr_lock and no path takes pr_lock before the worktree lock. Alternatively, document that body writers may publish checkpoints. Either way, the docstring of worktree.lock_local_state (worktree.py:131) still says it serializes "PR-body updates for this worktree", which is no longer true and should be updated.
| proceed, flock, update = Event(), github.fcntl.flock, github.update_body | ||
|
|
||
| def acquire(fd, op): | ||
| if current_thread() is not main_thread() and op == github.fcntl.LOCK_EX: |
There was a problem hiding this comment.
suggestion: Pause hook in the acceptance test patches the process-wide fcntl.flock
github.fcntl is the shared fcntl module, so monkeypatch.setattr(github.fcntl, "flock", acquire) also changes every worktree and state lock taken in the review thread. The test only works because review's first contended LOCK_EX happens to be the PR lock. If review later takes a contended worktree lock first, proceed would be set at the wrong point, and the test could still pass without proving it paused at the PR-lock handoff. Consider scoping the hook to the PR-lock path, for example by checking that fd.name is under github.PR_LOCK_DIR.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Preserve PR body sections across checkouts
Context and goal
Closes #1371
Acceptance
Base
Base: c21528b
Validation
Recorded for
2b4a38b225fcuv 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