Skip to content

Check size budgets against current target before queue admission - #1309

Closed
eowca wants to merge 3 commits into
mainfrom
lean178/1293-prequeue-size-budget
Closed

eowca wants to merge 3 commits into
mainfrom
lean178/1293-prequeue-size-budget

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Check size budgets against current target before queue admission

Goal

Keep a green source PR out of Mergify when its clean integration with the current target exceeds the existing size budget.

Problem

In #1293, PR #1230 passed its fork-point check at 7,482 source lines and measured 7,508 against a cap of 7,500 after integration with the main SHA already live at queue admission.

Acceptance

  • Run the existing checker on a temporary integration of the exact PR head with a freshly fetched configured target, using that target as baseline.
  • Replay Serialize updates to the pull request body #1230 offline. Ready and new merge requests report the failed budget, count and cap. An existing queue request uses the existing wait path.
  • Preserve source, tests, documentation and hold-or-shrink semantics, caps, command options, receipts and review evidence.

Base

2ef0b72

Notes

Use Git plumbing to integrate as data and execute only the checker tracked by the target. Keep integration objects, index and checkout in a private scratch repository. Opt in through the existing exact checker command.

Closes #1293

Validation

Recorded for d64bb949dd0d

  • 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

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 f07389d9d0bf4088872dd5691961ff19dc5c8729, 64.8s: approve (0 critical, 0 important, 3 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
origin, f"refs/heads/{config.base_branch}")
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: Merge conflict with the fresh target gives an unclear error

If the PR head no longer merges cleanly with the freshly fetched target, git merge-tree --write-tree exits 1. It writes the conflict details to stdout, not stderr. _git builds its error from the stderr tail, so the user sees only git merge-tree --write-tree <base> <head> failed: with nothing after it. This can happen even when GitHub's mergeable is still UNKNOWN or stale and readiness passed. It fails closed, so nothing unsafe gets through, but the user isn't told why. Smallest fix: run merge-tree with _proc.run and, when it exits 1, raise CliError("PR head conflicts with current <base_branch>; update the branch").

Comment thread src/loopzero/cli.py
"GIT_ATTR_NOSYSTEM": "1", "GIT_NO_REPLACE_OBJECTS": "1", "PYTHON": sys.executable}
git = partial(_git, root, extra_env=env)
git("clone", "--shared", "--no-checkout", "--template=", str(wt), ".")
_git(root, "fetch", "--no-tags", "--no-recurse-submodules", "--",

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 skips the hardened scratch environment without saying why

Every other git call in the scratch repo goes through the git partial with GIT_CONFIG_NOSYSTEM, GIT_CONFIG_GLOBAL=/dev/null and the related settings. The fetch calls _git(root, ...) directly. That is probably on purpose, so the user's credential helper can authenticate to origin, but the code doesn't say so. A later edit could 'fix' it to use git and break private-repo fetches. Add a one-line comment explaining that the fetch needs the user's global config for credentials.

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 re-runs the budget for PRs already in the queue

In cmd_ready, the check runs whenever readiness is ready and the strategy is mergify. It doesn't look at Mergify markers or queue membership. So if loopzero ready is run again on a PR that is already requested or queued, and the target has moved since, it now exits 1 with a budget failure. The PR stays in the queue, so the output contradicts the queue state. The acceptance asks for this only for ready and new merge requests, and merge already sends existing requests to the wait path. If ready should report on candidates before admission only, skip the check when mergify.markers shows a request. Otherwise, document that ready always re-checks against the current target.

Architecture-Review: unchanged; queue preview keeps the same baseline and checker.

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 claude on 67cea96c397609a4556c2eed82f4a184ccc44eb8, 10.0s: 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.

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