Skip to content

Check the local receipt before fetching remote readiness evidence - #1808

Closed
eowca wants to merge 5 commits into
mainfrom
lean178/1405-receipt-before-readiness
Closed

eowca wants to merge 5 commits into
mainfrom
lean178/1405-receipt-before-readiness

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Check the local receipt before fetching remote readiness evidence

Context and goal

  • Context: Ready and merge require a valid local check receipt for the pushed head.
  • Problem: A missing or invalid receipt still triggers remote review, CI and queue lookups.
  • Goal: Stop after PR, head and hold validation when the receipt needs repair.

Closes #1405

Acceptance

  • Missing, stale, dirty or failing receipts and receipts for a different check plan block ready and merge --wait after at most three REST requests. No writes, polling, GraphQL or Mergify calls.
  • Passing matching receipts still evaluate every gate. Hold handling, merged cleanup and status retain their diagnostics.

Notes

Base

main @ 1e5711a
Base: 1e5711a

Validation

Recorded for 1ba887c3d732 (not current head) (unverified, run loopzero check)

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, codex, 4d64916, request_changes
  • delta, codex, eac1be9, request_changes

eowca and others added 4 commits November 26, 2026 04:14
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; this clean base update preserves both the receipt-first behavior and the current review rules.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by codex on 4d6491636003e59bf590d5ba0f643c83e4a8fadc, 43.1s: request_changes (0 critical, 1 important, 1 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: 8fd82ab77667ba4fc45523888cdfa17864f362758a282d6f1a06a102308f8429

Comment thread docs/ARCHITECTURE.md
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

Copy link
Copy Markdown

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 ready and merge --wait call _require_pr before reaching the new receipt check. If the remote branch exists but its commit has no matching open PR association, pr_for_branch reads 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 uses arm_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.

Comment thread src/loopzero/cli.py
return github.Readiness(False, (hold,))
report = _load_report(wt)
receipt_problem = _check_report_problem(report, wt, config, head)
if reviews is None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Make status diagnostic behavior explicit

Whether _readiness collects remote diagnostics for an invalid receipt now depends on whether its caller supplied cached reviews. If status later lets _readiness fetch reviews, it will silently lose diagnostics. Give status an explicit diagnostic option and use reviews is None only to decide whether reviews need fetching.

Architecture-Review: unchanged; the readiness short circuit retains branch detail, pushed head, and merge-authority verification.

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero delta review by codex on eac1be9605cc492b8019ce6a6ad18f62738bb269, 42.9s: request_changes (0 critical, 3 important, 0 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: dbacf16f0050db0cac9cbd22928de06440f9369f62ded4def671a147065e2e62

Comment thread docs/ARCHITECTURE.md
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

Copy link
Copy Markdown

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:290 is not in the diff; anchored here.

important: Preserve the receipt check on every readiness poll

_wait_for_checks calls _readiness directly on subsequent polls for both ready --wait and merge --wait. If another check replaces a passing receipt with a failing one while the command waits, the next poll now fetches reviews, CI, and potentially Mergify configuration before returning the receipt failure. A remote error can also mask the repair diagnostic. Restore the receipt check immediately after hold validation when reviews is None. Status supplies reviews explicitly and can still collect all diagnostics.

Comment thread src/loopzero/cli.py
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 _require_pr makes PR diagnostics and merged cleanup depend on the local receipt being readable. For example, if the receipt path is a directory, _load_report raises IsADirectoryError before ready can report a hold or merge can clean up an already merged PR. Use a bounded PR lookup first, validate the pushed head, and handle merged and held PRs before opening the receipt.

Comment thread src/loopzero/github.py
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

important: Include REST retries in the three-request limit

list_only bounds the number of endpoints, but _gh retries each GET independently. With a missing receipt and an open PR, one transient 503 on the list request and one on the detail request produce four REST requests even when both retries succeed. Apply a shared three-attempt budget or disable retries for this bounded lookup, and cover a transient response in the request-count replay.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1842, which merged and delivers receipt-first readiness for #1405.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check the local receipt before fetching remote readiness evidence

1 participant