Skip to content

Share GitHub request and delivery evidence handling - #1787

Closed
eowca wants to merge 4 commits into
mainfrom
lean178/575-github-readers
Closed

eowca wants to merge 4 commits into
mainfrom
lean178/575-github-readers

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #1811, which carries the same net patch on current main for a fresh review under the review budget.

Share GitHub request and delivery evidence handling

Context and goal

Refs #575

Acceptance

  • Remove at least 50 net source lines from src/loopzero/github.py.
  • Pass the GitHub behavior suite and repository size caps.
  • Compare the original and refactored check evidence and API method results with deterministic inputs.

Validation

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

  • uv run --group dev ruff check src tests: exit 1

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

Review

eowca and others added 2 commits November 26, 2026 10:50
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; GitHub retains ownership of PR and check evidence, with the same endpoints and verification rules.

@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 claude on ee984493a1018ac994fa2254ec5f5060e0067b57, 51.6s: 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.

Comment thread src/loopzero/github.py
@@ -924,7 +903,13 @@ def _diff_map(repo: str, number: int, head_sha: str,
return commentable, anchor
missing = next((f.path for f in blocking if f.path in remaining), None)
if missing is not None and count >= PR_FILE_LIMIT:

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: Inlining _require_complete_file_list makes _diff_map longer

Moving the file-limit verification into _diff_map saves a few lines. The cost is that _diff_map now mixes paging the file list, building the anchor, and re-checking the PR head and changed-file count. The behaviour is the same: it still checks len(commentable) and uses the same error texts and request tuple. But the separate, named check is gone, and _diff_map is already a dense function. This doesn't block the change. If the line budget has room, keep the helper; otherwise this is fine.

Comment thread src/loopzero/github.py
message_tail=None if diagnostic_api else tail)
if diagnostic_api or patch_error else tail)

error_command, detail = (command if rate_limited else argv), tail

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: Post-loop error handling in _gh depends on the last delay being None

After the loop, the code reads rate_limited, response, tail and done without checking anything first. That only works because the last entry in delays is always None. _retry_pause(None) returns False, so the final attempt always returns, breaks or raises, and the loop never ends by running out of items after a continue. Before this change, the code checked done.exit_code != 0 after the loop. It now relies on this unstated rule. If delays ever gets a non-None last entry, the code will raise UnboundLocalError, or it will raise an error for a request that succeeded. A one-line comment, or an else: on the loop that re-raises, would make the rule explicit. Behaviour today is correct.

Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the API parsing and trust rules retain their behavior.

@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 claude on da308b7ba436c441e1f84f7317a5619995fee2c3, 5.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.

Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; both conflict resolutions preserve the existing GitHub evidence contract.
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

The two conflict resolutions preserve the approved behavior.

git range-diff --remerge-diff e2f12ec71514849f6c3969fcf1321b3c4718971f..da308b7ba436c441e1f84f7317a5619995fee2c3 3f60c7f9acb8960f678aa915cbfabe6ef450c745..21fee016eb56843d0ee919bec9c153c7ebdd3bb1

1:  9a172fad = 1:  9a172fad Share GitHub request and delivery evidence handling
2:  ee984493 = 2:  ee984493 Merge remote-tracking branch 'origin/main' into lean178/575-github-readers
3:  da308b7b = 3:  da308b7b Use the standard adjacent-pair iterator for API methods
-:  -------- > 4:  21fee016 Merge current main and retain shared PR parsing

git show --remerge-diff 21fee016eb56843d0ee919bec9c153c7ebdd3bb1

diff --git a/src/loopzero/github.py b/src/loopzero/github.py
remerge CONFLICT (content): Merge conflict in src/loopzero/github.py
index 469cdfef..e27216f2 100644
--- a/src/loopzero/github.py
+++ b/src/loopzero/github.py
@@ -600,14 +600,9 @@ def pr_from_rest(data: object) -> PR:
 
 
 def _pr_detail(repo: str, number: int) -> tuple[PR, dict]:
-<<<<<<< da308b7b (Use the standard adjacent-pair iterator for API methods)
     endpoint = f"repos/{repo}/pulls/{number}"
     data = api_get(endpoint)
-    pr = _pr_from_rest(data)
-=======
-    data = api_get(f"repos/{repo}/pulls/{number}")
     pr = pr_from_rest(data)
->>>>>>> 3f60c7f9 (Accept check receipts across host environments (#1772))
     if pr.number != number:
         raise GhError(("gh", "api", endpoint), f"PR detail number {pr.number} differs from requested {number}")
     return pr, data
@@ -751,12 +746,7 @@ def create_draft_pr(repo: str, branch: str, base: str, title: str, body: str) ->
     detail = _api(
         f"repos/{repo}/pulls", {"head": branch, "base": base, "title": title,
                                "body": body, "draft": True})
-<<<<<<< da308b7b (Use the standard adjacent-pair iterator for API methods)
-    pr = _pr_from_rest(detail)
-=======
     pr = pr_from_rest(detail)
-    source_repo = detail["head"].get("repo") or {}
->>>>>>> 3f60c7f9 (Accept check receipts across host environments (#1772))
     if (pr.state != "OPEN" or not pr.is_draft or pr.base_ref != base
             or not _matches_branch(detail["head"], repo, branch)):
         raise GhError(("gh", "api", f"repos/{repo}/pulls"), "created PR differs from request")

eowca added a commit that referenced this pull request Nov 26, 2026
Keep current GitHub paging, ref validation, and transport to avoid overlap with #1787. Preserve current receipt, locking, redaction, and wait behavior.

Architecture-Review: unchanged; the retained CLI and config simplifications preserve the current delivery interfaces.
Co-Authored-By: Codex <noreply@openai.com>
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Lean178 verification of the conflict-only refresh at 21fee01 (remerge diff rerun locally, no third review):

  • _pr_detail: keeps the endpoint variable for the error message and takes main's public pr_from_rest. Correct.
  • create_draft_pr: drops main's inline source_repo ref/full_name check in favour of _matches_branch(detail["head"], repo, branch). The rule is the same (ref equals branch, repo is a dict, full_name matches case-insensitively). Only a non-string full_name would behave differently, and GitHub does not send one. Correct.
    No other drift: commits 1-3 match the approved range. OK to land at exactly 21fee01 (it frees ~55 source lines for Observe passing source checks closer to the wait deadline #1743, then Restart Mergify backoff when admission is confirmed #1709).

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.

1 participant