Repository navigation
ci: label-driven merging on GitHub (shepherd:* labels, #4847 item 3) - #4853
Merged
Merged
Conversation
A maintainer's label on a pull request is the merge queue, run by GitHub instead of a local shepherd: - shepherd:merge mark ready + auto-merge (squash, pinned to the head); GitHub merges once the required checks on main are green - shepherd:hold never auto-merge - shepherd:matrix dispatch full-suite-gate.yml on the head; auto-merge waits for a green run on that head (same-repo branches only) - shepherd:full det sweep plans mode=full (det_sweep_plan.py reads it) - status labels (set by the bot): needs-fix, waiting-on-main, retrying Logic is tests/tools/shepherd_gh.py: a pure decide() over a snapshot, gather()/apply() around it through gh. Reuses pr_check and ci_digest. Rules: a request label from a non-writer is removed with a comment; new commits drop shepherd:merge (the bot's own update-branch leaves a marker first); "Depends on #N" blocks auto-merge; infra/flake reruns up to 3x, 15 min apart (run_attempt is the counter); one digest comment per head; behind + green -> update-branch. Workflows check out main only and never run PR code: shepherd-event.yml (pull_request_target) and shepherd-reconcile.yml (workflow_run, cron, dispatch). The PAT reaches only the module. A test lints both for the rules (no expression in run:, pinned actions, checkout of main only). docs/ci.md, a CONTRIBUTING section, and the PR worker rules point at the labels. Label set: `shepherd-reconcile.yml` with ensure_labels=true. Co-Authored-By: Claude Haiku 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV
Contributor
- Approval comes from GitHub's timeline: the latest labeled event of shepherd:merge names its actor and the commit it was added on. A label from a non-writer, or with no labeled event, is removed on any pass (reconcile included), not only on the event that added it. - A head that moved since the label (new commits, force-push) drops the label, whatever the trigger. The bot's own update-branch is carried over only through a marker pair (from=<approved> before the push, to=<head> after it) and a first-parent check. - While the bot's update is between its two markers, nothing is decided (no drop, no auto-merge). - Event concurrency is per PR (no event is dropped by another PR's). - reconcile on workflow_run only processes the PRs of that run's head; cron and dispatch still scan every labelled PR. - Full Suite Gate added to the workflow_run list; its dispatched runs count as a trigger. - Tests: non-writer and unknown labelers, unapproved push with no synchronize event, bot update carried, force-push after it not carried, pending update, head-scoped lookup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV
GitHub's labeled timeline events carry commit_id null, so the commit a label was added on is not available there. The approval now comes from the labeled event itself: - On labeled shepherd:merge from a writer, the bot posts `<!-- shepherd:approved sha=<head> by=<login> -->`, with the head from the event payload, before gather() reads the PR. - Trust: only comments by the bot's own account count (resolved with `gh api user`); the newest trusted marker decides. - Newest trusted marker == current head -> approved. The bot's own update-branch (from=/to= pair plus first-parent check) carries it, and the bot records a fresh marker for the carried head. - No trusted marker -> awaiting: no drop, no auto-merge, one quiet log line (the label event may still be in flight). - Head moved some other way after a trusted marker -> the label is dropped, on any trigger. - The last labeled actor must still be a writer (timeline). Tests: approval from the payload head; a marker by another user is ignored; no marker -> quiet, no drop, no merge; unapproved push after the marker -> dropped; bot update carried. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 3 of #4847 (the label-driven merge queue that follows the shepherd-logging PR; #4790 leftovers).
A maintainer's label on a pull request is the merge queue, run by GitHub:
shepherd:merge: mark ready and enable auto-merge (squash, pinned to the head). GitHub merges once the required checks on main are green.shepherd:hold: never auto-merge.shepherd:matrix: dispatchfull-suite-gate.ymlon the head; auto-merge waits for a green run on that head (same-repo branches only).shepherd:full: the det sweep plans a full sweep (det_sweep_plan.pyreads the label).shepherd:needs-fix,shepherd:waiting-on-main,shepherd:retrying.Logic:
tests/tools/shepherd_gh.py(puredecide(), tested intest_shepherd_gh.py), reusingpr_checkandci_digest. Workflows:shepherd-event.yml(pull_request_target) andshepherd-reconcile.yml(workflow_run, cron, dispatch). Both check outmainonly and never run PR code; the PAT reaches only the module. Docs:docs/ci.md, a CONTRIBUTING section, and the PR-worker rules.Security: non-writer request labels are removed; new commits drop
shepherd:merge(the bot's own update-branch is marked first); "Depends on #N" blocks auto-merge; a test lints both workflows (no expression inrun:, SHA-pinned actions, checkout of main only).Label set: run
shepherd-reconcile.ymlby hand withensure_labels: trueafter merge.Co-Authored-By: Claude Haiku 5.5 [email protected]
Claude-Session: https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV
🤖 Generated with Claude Code
https://claude.ai/code/session_01TBJdDBRtJis5hzE244NQKV