Repository navigation
Check size budgets against the current target before queuing - #1750
Conversation
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>
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
| 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: |
There was a problem hiding this comment.
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.
| return 3 | ||
| pr, readiness, kicked = waited | ||
| assert readiness is not None | ||
| _prequeue_size_budget(wt, config, pr, readiness) |
There was a problem hiding this comment.
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.
| 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( |
There was a problem hiding this comment.
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.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Check size budgets against the current target before queuing
Acceptance
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
5930601cc254uv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review