Skip to content

Reuse the PR reads that bracket hosted eligibility - #1766

Merged
mergify[bot] merged 2 commits into
mainfrom
lean178/1404-reuse-hosted-pr-snapshots
Nov 26, 2026
Merged

mergify[bot] merged 2 commits into
mainfrom
lean178/1404-reuse-hosted-pr-snapshots

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Reuse the PR reads that bracket hosted eligibility

Context and goal

  • Goal: Cut duplicate GitHub reads in hosted source and candidate refreshes.
  • Problem: The caller already reads PR details before and after evaluation, and eligibility repeats both reads.
  • Context: Let the caller supply the established source snapshot while retaining its final identity and metadata comparison.

Closes #1404

Acceptance

  • Green one-page source and two-source candidate replays use at most five and sixteen REST calls respectively.
  • The same verdicts and status writes are preserved. Source head or eligibility-relevant metadata drift cannot publish success.
  • Preserve candidate retry when a source lands during attestation.

Base

Base: 3973d04

Notes

Carries the snapshot reuse from #1456. Keep the current typed candidate retry, trusted review publisher logic, and outage handling.

Validation

Recorded for 94ae8dff3fc0

  • 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, claude, 6e91c77, request_changes
  • delta, claude, 94ae8df, approve

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 claude on 6e91c778eb37c9bed5390c02200504183b017c06, 66.7s: request_changes (0 critical, 1 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/hosted.py Resolved
Comment thread src/loopzero/candidate.py Outdated
source.get("number"),
source.get("merged"),
source.get("mergeable") is False,
tuple(label["name"] for label in source.get("labels", [])),

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: Malformed labels in the candidate source fingerprint escape as an untyped exception

tuple(label["name"] for label in source.get("labels", [])) raises a bare TypeError or KeyError if labels is null or a label lacks name. It runs at line 532, before source_policy, outside the typed CandidateError path. A malformed payload should be rejected as a CandidateError, which is how every other malformed field in _attest_source is handled. github._pr_labels has the same shape but is wrapped into a GhError by pr_from_rest. Validate labels as a list of objects with string names via _require, or build the fingerprint after the snapshot has been normalized.

return latest


def source_fingerprint(pr: github.PR) -> tuple[object, ...]:

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: Two independent source fingerprints encode the same eligibility-relevant fields

eligibility.source_fingerprint (for PR: state, base_ref, conflict, hold) and candidate._source_fingerprint (for raw JSON: merged, mergeable is False, all labels, state, base ref) now separately define what must not drift before publication. Hosted candidate safety relies on the candidate fingerprint being a superset of the eligibility one, but nothing enforces that. If a field is later added to one, the other can silently stop covering it.

Consider deriving the candidate's eligibility-relevant part from eligibility.source_fingerprint(github.pr_from_rest(source)) and keeping only the repository and body extras locally. At minimum, add a comment cross-referencing the two functions.

Architecture-Review: unchanged; hosted eligibility stays bound to the same live source and skips merged sources.

Co-Authored-By: Codex <codex@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 claude on 94ae8dff3fc072580b584b1263d4bfa6079d6b77, 20.7s: 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/hosted.py
ready, message = result.ready, "; ".join(result.reasons) or "Reviewed source head"
if github.pr_view(cfg.repo, number).head_sha != head:
raise LoopZeroError("head changed before publication; refresh eligibility")
if _landed_before_publication(cfg.repo, number, head, snapshot):

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: Landed-source skip leaves a self-written pending status on the merged head

When the source merges while eligibility is being evaluated, _landed_before_publication returns True and _run exits 0. By then _run has already written pending (line 80). If an earlier run had published success for this head, the commit now shows pending for good, and with fast-forward or rebase merges that commit is on main. The early return at line 74 does not have this problem because it runs before anything is published. The skip only needs to stop a late refresh from turning a landed head red. Smallest fix: when ready is true, publish the computed verdict as usual, and skip only the non-success states. Otherwise, document that a merged head may keep pending.

Comment thread src/loopzero/candidate.py
base = source.get("base")
base_repo = base.get("repo") if isinstance(base, dict) else None
labels = source.get("labels", [])
if not isinstance(labels, list) or any(not isinstance(label, dict) or not isinstance(label.get("name"), str) for label in labels):

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: New label validation in candidate fingerprint has no test

_source_fingerprint now raises CandidateError("invalid source PR labels") for malformed labels. Before this change it failed with a bare KeyError/TypeError. No test in this diff covers the new path, so a regression could reintroduce an unclassified exception and skip the typed candidate error handling. Add a small case to the candidate tests with labels like [{}] or "x" that expects CandidateError. The 120+ character line could also be wrapped to match the surrounding style.

@eowca
eowca marked this pull request as ready for review November 26, 2026 10:12
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as a6403fe at 10:18 UTC

5 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 10:13 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1798
  • ✅ Merged 10:18 · a6403fe · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit a6403fe into main Nov 26, 2026
17 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1404-reuse-hosted-pr-snapshots branch November 26, 2026 10:18
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.

Reuse the PR reads that already bracket hosted eligibility

1 participant