Skip to content

Reuse candidate validation and simplify hosted publication guards - #1863

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/575-candidate-hosted-cut
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/575-candidate-hosted-cut

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Reuse candidate validation and simplify hosted publication guards

Context and goal

  • Goal: Recover at least 30 source lines in the candidate and hosted modules.
  • Problem: Candidate validation repeats object checks and batch lookups. Hosted refresh parses the PR number twice and nests publication race guards.
  • Context: Reuse the existing validators and indexed batch IDs while preserving fail-closed errors, GitHub call ordering, verdicts, and publication safeguards.

Refs #575

Acceptance

  • Only candidate.py and hosted.py change, with at least 30 source lines removed.
  • Tests and supported behavior are unchanged.
  • Open work on hosted default base and mergeability retains its own hunks.

Base

main @ f227668
Base: f227668

Validation

Recorded for 0661d58486e6

  • 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

(filled by loopzero check)

Review

(filled by loopzero review)


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

  • primary, claude, 0661d58, approve

Coverage comparison

Architecture-Review: unchanged; hosted dispatch and candidate attestation preserve their trust boundaries, checks, and call ordering.
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 0661d58486e6f03368638348a87c6071ff28f767, 20.1s: 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
return True
if eligibility.source_fingerprint(current) != eligibility.source_fingerprint(snapshot):
raise LoopZeroError("source metadata changed before publication; refresh eligibility")
if snapshot is None or current.state == "MERGED":

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: Merged-guard rewrite is behaviour-preserving but harder to read

I traced all four cases (snapshot None or present × MERGED or not) and the result matches the old code: without a snapshot it returns False, a MERGED PR with a snapshot returns True, and otherwise the fingerprint check runs. The problem is readability. if snapshot is None or current.state == "MERGED": return snapshot is not None mixes two separate guards, so a reader has to work out the truth table to see that a MERGED PR without a snapshot returns False. A smaller and clearer fix is to keep the guards flat: if snapshot is None: return False, then if current.state == "MERGED": return True. That costs one extra line and makes the publication-race safeguard obvious.

Comment thread src/loopzero/candidate.py
_require(app.get("id") == MERGIFY_APP_ID and app.get("slug") == "mergify"
and isinstance(app_owner, dict) and app_owner.get("login") == MERGIFY_APP_OWNER,
"Could not resolve the official Mergify GitHub App")
expected_identity = _identity(_object(github_get("/users/mergify%5Bbot%5D"), "GitHub bot lookup is invalid"))

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: Combined lines go past the configured 100-column width

Three joined lines are longer than line-length = 100 in pyproject.toml: the expected_identity = _identity(_object(github_get(...), ...)) call (about 112 columns), the sub_batches _require (about 103), and the pull_requests _require (about 104). The lint rule set doesn't select E501, so CI won't fail, and the file already has longer lines. Still, cutting line count by going over the formatter width will get undone the next time someone runs ruff format, and that would bring back the removed lines. Either confirm that ruff format isn't used in this repo, or keep these calls within 100 columns.

@eowca
eowca marked this pull request as ready for review November 26, 2026 12:07
@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 09d75eb at 12:14 UTC

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

So far

  • ✅ Entered the queue Thu 26 Nov, 12:08 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1869
  • ✅ Merged 12:14 · 09d75eb · 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 09d75eb into main Nov 26, 2026
20 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/575-candidate-hosted-cut branch November 26, 2026 12:16
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