Repository navigation
Check the local receipt before fetching remote readiness evidence #1808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cffba38
c58f677
1ba887c
4d64916
eac1be9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,9 @@ loading the delivery [commands](../src/loopzero/cli.py), which implement the con | |
| 5. `ready` derives readiness from the current head, its check receipt, an eligible review at that | ||
| head or an eligible review covering an ancestor, blocking findings | ||
| (unresolved threads a review publisher opened with a head-bound marker line), | ||
| target branch and required CI. The receipt must record a clean passing run | ||
| target branch and required CI. Ready and merge stop on an invalid receipt | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reviewer location src/loopzero/cli.py:290 is not in the diff; anchored here. important: Preserve the receipt check on every readiness poll
|
||
| after checking the pushed head and merge-authority hold. Status still gathers | ||
| remote gates for its diagnostics. The receipt must record a clean passing run | ||
| at that head with the current commands and check settings digest. A settings | ||
| change or an older receipt without the digest requires a fresh check. The | ||
| digest covers execution and stage reuse settings without recording raw | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -193,8 +193,8 @@ def _require_task_branch(config: Config, branch: str) -> None: | |
| ) | ||
|
|
||
|
|
||
| def _require_pr(config: Config, branch: str, *, allow_merged: bool = False) -> github.PR: | ||
| pr = github.pr_for_branch(config.repo, branch) | ||
| def _require_pr(config: Config, branch: str, *, allow_merged: bool = False, list_only: bool = False) -> github.PR: | ||
| pr = github.pr_for_branch(config.repo, branch, list_only=list_only) | ||
| if pr is None: | ||
| raise CliError(f"no pull request for {branch}; run `loopzero pr` first") | ||
| if pr.state != "OPEN" and not (allow_merged and pr.state == "MERGED"): | ||
|
|
@@ -311,12 +311,9 @@ def _readiness( | |
| ) | ||
| report = _load_report(wt) | ||
| receipt_problem = _check_report_problem(report, wt, config, head) | ||
| if receipt_problem: | ||
| result = github.Readiness( | ||
| ready=False, | ||
| reasons=(*result.reasons, receipt_problem), | ||
| ) | ||
| elif announce_receipt: | ||
| result = (github.Readiness(False, (*result.reasons, receipt_problem)) | ||
| if receipt_problem else result) | ||
| if announce_receipt and not receipt_problem: | ||
| _print_receipt(wt, report, "accepted") | ||
| if config.merge_strategy == "mergify" and pr.state == "OPEN": | ||
| behind = github.behind_reason(pr, head if review else None) | ||
|
|
@@ -1250,10 +1247,13 @@ def _pr_readiness( | |
| """PR plus readiness; readiness is None only for an already merged PR (allow_merged).""" | ||
| head = worktree.head(wt) | ||
| _require_task_branch(config, branch) | ||
| pr = _require_pr(config, branch, allow_merged=allow_merged) | ||
| problem = _check_report_problem(_load_report(wt), wt, config, head) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. important: Keep receipt read failures from masking holds and merged cleanup Reading the receipt before |
||
| pr = _require_pr(config, branch, allow_merged=allow_merged, list_only=bool(problem)) | ||
| _require_pushed(pr, head) | ||
| if pr.state == "MERGED": | ||
| return pr, None | ||
| if problem: | ||
| return pr, github.Readiness(False, (github.merge_hold(pr.number, pr.labels) or problem,)) | ||
| return pr, _readiness(wt, config, pr, head, workflow_wait=workflow_wait, | ||
| announce_receipt=True) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -671,9 +671,9 @@ def _confirm_branch_pr(repo: str, branch: str, endpoint: str, number: int, state | |
| return pr | ||
|
|
||
|
|
||
| def pr_for_branch(repo: str, branch: str, *, open_only: bool = False) -> PR | None: | ||
| def pr_for_branch(repo: str, branch: str, *, open_only: bool = False, list_only: bool = False) -> PR | None: | ||
| """Return the open PR, falling back to the most recent closed PR unless open_only.""" | ||
| endpoint, matches = _commit_branch_prs(repo, branch) | ||
| endpoint, matches = ("", ()) if list_only else _commit_branch_prs(repo, branch) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. important: Include REST retries in the three-request limit
|
||
| open_matches = [row for row in matches if row["state"] == "open"] | ||
| if open_matches: | ||
| newest = max(open_matches, key=lambda row: (row["created_at"], row["number"])) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewer location src/loopzero/cli.py:1253 is not in the diff; anchored here.
important: Bound PR discovery before checking the receipt
Both
readyandmerge --waitcall_require_prbefore reaching the new receipt check. If the remote branch exists but its commit has no matching open PR association,pr_for_branchreads the branch, commit associations, the open PR list, and PR detail. That takes four REST requests even when the receipt is missing. A full page of commit associations also triggers another request. The new merge replay usesarm_pr, which returns 404 for the branch lookup and skips the association path. Use a bounded head-filtered PR lookup for these commands, retaining detail validation and the closed-PR fallback for merged cleanup. Cover the existing-branch fallback and pagination cases in the request-budget tests.