Skip to content

Check size budgets against the current target before queuing - #1750

Merged
mergify[bot] merged 4 commits into
mainfrom
lean178/1293-target-budget-proof
Nov 26, 2026
Merged

mergify[bot] merged 4 commits into
mainfrom
lean178/1293-target-budget-proof

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Check size budgets against the current target before queuing

Acceptance

  • For a ready source head, run the existing trusted checker on a disposable integration with the freshly fetched target and use that same commit as the baseline.
  • Show the measured count and cap through both readiness and new merge requests. Leave already submitted Mergify requests on the existing wait path.
  • Preserve source checkout, receipt, absolute caps and hold-or-shrink behavior.

Notes

The offline fixture tests ready, merge and an already submitted request with a stale source tracking ref. The test diff adds 15 net lines.

Base

main @ 0287f2b

Validation

Recorded for 5930601cc254

  • 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, 5930601, approve

eowca and others added 4 commits November 26, 2026 09:52
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the candidate is still counted with the trusted target checker.
Co-Authored-By: Codex <noreply@openai.com>
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 5930601cc254739123fbf5bef21585f6d0c5bcd3, 53.1s: approve (0 critical, 0 important, 4 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/cli.py
raise CliError(f"could not fetch {config.base_branch} from origin for the size budget check")
base = git("rev-parse", "FETCH_HEAD^{commit}")
script = git("show", f"{base}:{_SIZE_BUDGET}")
tree = git("merge-tree", "--write-tree", base, pr.head_sha)

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: A merge conflict with the current target gives an error with no cause

git merge-tree --write-tree exits 1 when the merge conflicts. It writes the conflict details to stdout and nothing to stderr. _git builds its error only from the stderr tail, so the user sees git merge-tree --write-tree <base> <head> failed: with nothing after it. This can happen when GitHub's mergeability is stale against a target that moved. Blocking is still correct here, so this is about the message. Smallest fix: run merge-tree through _proc.run and, on exit 1, raise CliError(f"PR head conflicts with current {config.base_branch}; rebase before queueing"). The fetch at lines 1235-1241 has the same problem: it throws away fetched.stderr, so a credential failure looks the same as a network failure. Add _proc.tail(fetched.stderr, 1) to that message.

Comment thread src/loopzero/cli.py
def _prequeue_size_budget(
wt: Path, config: Config, pr: github.PR, readiness: github.Readiness,
) -> None:
if not readiness.ready or config.merge_strategy != "mergify" or _SIZE_BUDGET not in config.checks:

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: The checker is detected by an exact string match

_SIZE_BUDGET not in config.checks only matches a check command that is exactly scripts/size_budget.sh. Commands like bash scripts/size_budget.sh or scripts/size_budget.sh origin/main skip the pre-queue check silently, and nothing tells the user. The repo's own workflow.toml uses the exact form, so this works today. Consider matching on the first shlex token, or say in the ARCHITECTURE note that the check only runs for that exact command.

Comment thread src/loopzero/cli.py
return 3
pr, readiness, kicked = waited
assert readiness is not None
_prequeue_size_budget(wt, config, pr, readiness)

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: ready --wait on a draft can mark the PR ready before the budget check fails

On the waiting path, github.mark_ready runs at line 1262 before _prequeue_size_budget at line 1278. So a draft PR that fails the current-target budget can still be flipped to ready-for-review before the command exits 1. This is not Mergify admission, so it is within the acceptance criteria. If you want draft PRs to stay draft when the budget fails, run the check before the kick, or note this behavior.

Comment thread src/loopzero/cli.py
git = partial(_git, root, extra_env=env)
git("clone", "--shared", "--no-checkout", "--template=", str(wt), ".")
# Fetch with the user's credential configuration for private origins.
fetched = _proc.run(

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: The fetch duplicates _git instead of reusing it

The fetch calls _proc.run directly and repeats the exit-code check, only to leave out extra_env. That is why its error message drops stderr. Calling _git(root, "fetch", ...) with no extra_env, the same environment the direct call uses, removes the duplication and keeps git's stderr tail in the error.

@eowca
eowca marked this pull request as ready for review November 26, 2026 09:39
@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 6c58d64 at 09:45 UTC

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

So far

  • ✅ Entered the queue Thu 26 Nov, 09:40 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1771
  • ✅ Merged 09:45 · 6c58d64 · 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 6c58d64 into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1293-target-budget-proof branch November 26, 2026 09:45
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.

Report current-main size budget failures before requesting Mergify

1 participant