Repository navigation
Conversation
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; detached recovery still requires exact merged PR proof and now guards the local HEAD until removal. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on c2a3dac04826808f14696aabec960652e99e8e2c, 72.2s: approve (0 critical, 0 important, 4 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.
| return None | ||
|
|
||
|
|
||
| def _merged_pr_from_history(repo: str, branch: str, sha: str) -> PR | None: |
There was a problem hiding this comment.
suggestion: Closed-PR history paging duplicates merged_pr_for_branch with weaker validation
_merged_pr_from_history reimplements the pulls?state=closed&head=owner:branch paging loop that merged_pr_for_branch (github.py:750) already has. The new copy is missing some of the original's checks. It does not reject pages with more than PAGE rows, it does not dedupe repeated PR numbers, and it skips the row validation in _closed_history_number. Also, _matching_merged_pr raises a generic ("gh","api") error that does not name the endpoint. Because _pr_detail and the exact head/branch match recheck every candidate, this does not create a safety hole. It does mean two history readers can drift apart. Smallest fix: run the closed-history walk through the existing validation (_closed_history_number plus the page-size check), or add an optional exact-sha filter to merged_pr_for_branch instead of keeping a parallel loop.
|
|
||
| def _pr_readiness( | ||
| wt: Path, config: Config, *, allow_merged: bool = False, workflow_wait: bool = False | ||
| wt: Path, config: Config, *, allow_merged: bool = False, workflow_wait: bool = False, |
There was a problem hiding this comment.
suggestion: New branch parameter on _pr_readiness is an unneeded shim
_merge_pr_readiness calls worktree.branch(wt) and passes the result as branch=. Without the argument, _pr_readiness computes exactly the same value, and no other caller uses the new parameter. Remove the parameter and keep the original branch, head = worktree.branch(wt), worktree.head(wt) line. In _merge_pr_readiness, return the branch it already computed.
| raise WorktreeError("local checkout changed during merge cleanup") | ||
| _require_clean_worktree(wt) | ||
| _delete_merged_branch(gd, name, expected_head) | ||
| _require_no_ignored_user_files(wt) |
There was a problem hiding this comment.
suggestion: Ignored-file scan runs twice under the HEAD lock
_require_clean_worktree(wt) at line 345 already calls _require_no_ignored_user_files. Line 347 then runs the same scan again with nothing in between except the branch-ref deletion, which does not touch the working tree. Drop line 347, or keep it and add a comment explaining why the second scan is needed.
| def _merge_pr_readiness( | ||
| wt: Path, config: Config, *, workflow_wait: bool | ||
| ) -> tuple[str, github.PR, github.Readiness | None]: | ||
| if previous := worktree.detached_from(wt): |
There was a problem hiding this comment.
suggestion: Detached worktrees whose previous checkout is not a task branch now get a misleading error
Before this change, loopzero merge on any detached HEAD failed with "HEAD is detached. Switch to a branch and retry." Now detached_from returns whatever branch the reflog shows. If someone detached from the base branch at the same SHA, they get "branch 'main' is the configured base; use a task branch". For any other branch, the command makes GitHub API calls and then reports "no merged PR proves cleanup". This is safe, but the message points users the wrong way. Consider falling back to the original detached-HEAD error when the previous branch fails _require_task_branch or no proof is found.
Architecture-Review: unchanged; attached merge uses the captured branch and detached recovery still requires exact merged proof. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero delta review by claude on 8e40527651ca7b33f9e61280a44a7f3ffc6b94f7, 10.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.
|
Parked at b592248. Hosted CI caught a duplicate branch lookup on ordinary merges, and main added an assertion in the same cleanup test. The unpublished local commit 147fecc8 retains both tests and restores the single lookup. All 20 focused cases passed. This PR has used both review rounds, and integrating the advisory PR #1781 ahead of this repair would exceed the source cap. |
|
Closing on Lean's decision from the test-line supply audit (#575 (comment)): this PR's test and source cost on a full cap outweighs its measured benefit. The approved work stays in the branch history. Reopen or replace it only with new evidence of a material, measured saving or failure. |
Resume merged branch cleanup before removing the worktree
Context and goal
Closes #1116. Replaces #1724 with the reviewed cleanup design and fixes for all four findings.
Acceptance
Notes
Preserve the verified reference transaction and existing managed-worktree checks. The previous checkout name is a lookup hint. Only matching live merged-PR and ref evidence allows deletion.
Base
main @ 4e1c0a4
Validation
Recorded for
c2a3dac04826(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 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review