Skip to content

ci: label-driven merging on GitHub (shepherd:* labels, #4847 item 3) - #4853

Merged
squid-protocol merged 3 commits into
mainfrom
ci/4847-label-shepherd
Oct 10, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
ci/4847-label-shepherd

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

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: dispatch full-suite-gate.yml on 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.py reads the label).
  • Bot status labels: shepherd:needs-fix, shepherd:waiting-on-main, shepherd:retrying.

Logic: tests/tools/shepherd_gh.py (pure decide(), tested in test_shepherd_gh.py), reusing pr_check and ci_digest. Workflows: shepherd-event.yml (pull_request_target) and shepherd-reconcile.yml (workflow_run, cron, dispatch). Both check out main only 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 in run:, SHA-pinned actions, checkout of main only).

Label set: run shepherd-reconcile.yml by hand with ensure_labels: true after 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

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
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 2 commits October 10, 2026 12:52
- 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
@squid-protocol
squid-protocol marked this pull request as ready for review October 10, 2026 17:23
@squid-protocol
squid-protocol merged commit 9469e50 into main Oct 10, 2026
42 checks passed
@squid-protocol
squid-protocol deleted the ci/4847-label-shepherd branch October 10, 2026 17:23
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