AGENT SKILL

babysit-pull-requests

Babysit open pull requests in THIS repository through the magus merge queue, spending agent work only where code must change. Use when asked to babysit, merge or ship open pull requests until they reach main. hack/ci/pull-requests.buzz decides each one's action; this skill chains the hack/dev scripts that act on it. Hand-authored, never shipped.

License 许可
GPL-3.0
所属仓库
egladman/magus
最近更新
2026-11-14
Stars
★ 3
Forks
0

01 前言 Front Matter

name
babysit-pull-requests
metadata
{ "source": "workspace" }
description
Babysit open pull requests in THIS repository through the magus merge queue, spending agent work only where code must change. Use when asked to babysit, merge or ship open pull requests until they reach main. hack/ci/pull-requests.buzz decides each one's action; this skill chains the hack/dev scripts that act on it. Hand-authored, never shipped.

03 SKILL.md 正文

Babysitting pull requests

hack/ci/pull-requests.buzz decides; the orchestrator acts on what it prints. Never derive a state, an action or a model from gh yourself. When a record looks wrong, fix the pure function that produced it and its test, then run it again.

The loop

  1. Read the board. The queue's own page is the run summary of the latest queue-apply.yaml run, written by its queue dashboard job. It lists every open pull request's place in the queue, with its reason and a person's command. ./magus buzz hack/ci/pull-requests.buzz -- dashboard --all --preview --out dashboard.md renders the same page locally. The status records are what you act on:

    ./magus buzz hack/ci/pull-requests.buzz -- status [--pr <n>]... [--author <login>]
    

    With no selector it reads your own open pull requests; --all reads everyone's. It prints one JSON record per pull request: state, stage, reason, action, model, evidence, and sometimes merge.

    state is what the checks on the head say:

    • running: a check has not finished, or none has reported yet.
    • green: every check finished and passed.
    • red-inherited: every failing check and failing Go test also fails on main's latest completed CI run; evidence names both runs.
    • red: anything else; evidence names the failures main does not have.

    The merge-queue status is the queue, not CI, and state leaves it out. It stays pending on every pull request outside the queue. Its description says why: not queued: CI has not passed, not queued: waiting for an approving review, or ready: ... once only merge intent is missing. Never count it as a running check or wait for it to pass.

    stage is what else stands before a merge: merged, closed, draft, waiting-below, conflicting, kicked-back, behind, queued, needs-queue.

    merge appears only on a green or red-inherited record whose stage allows a merge. It is the person's command: hand it over, never run it.

  2. Take the actions that change no code, with the same selectors:

    ./magus buzz hack/ci/pull-requests.buzz -- apply [--pr <n>]... [--author <login>]
    

    It queues a green stack by the label on its top and reruns a red that is not the change's, once per head. It prints each command it ran.

    • It never enables auto-merge. For a green pull request in no stack it prints the command under for_person; you tell the person to run it.
    • It never acts on red-inherited. Nothing in the change is broken, and the queue would refuse it for main's failures.
  3. Run the script chain for a record yourself, without asking the person. Each step is one script. Never stand in for one with raw git, gh or a hand-run gate: each script already absorbs the failure that recurs there.

    1. hack/ci/pull-requests.buzz -- status names the action.
    2. ./magus buzz hack/dev/bootstrap-checkout.buzz -- --here --verify-ready makes the checkout verify-ready. It builds ./magus at HEAD, stops pool parents of other builds, removes untracked stamped skill installs, and builds the graph and symbol digest. The scripts below run it themselves. An MGS7003 naming a binary built at another commit means this step did not run.
    3. Refresh the branches the action names:
      • rebase-branches-onto-base: run the record's evidence.rebase line. The branch still carries the commits of a pull request that squash-merged below it (evidence.squashed_base). The script rebases its own commits onto the base in a fresh checkout job, gates, and force-pushes with a lease.
      • a branch behind its base with nothing squash-merged below it: run ./magus buzz hack/dev/merge-base-into-branches.buzz -- --branches <a,b,c>. It merges the base into each independently. Add --stack when each branch sits on the one before. Both scripts take local branches origin lacks.
      • When either stops at a source conflict, it names the files and the checkout; hand those to an agent of the record's model as below.
    4. ./magus buzz hack/dev/bootstrap-checkout.buzz -- --here --verify-ready, then ./magus affected ci, which waits for the build budget itself, gates the result once; on failure it closes with each failed target's ref and cause. Fix from those, never rerun.
    5. ./magus buzz hack/dev/land-commits.buzz -- --branch <name> --from <ref> --title <text> --body-file <file> opens a pull request for commits that have none, after CI's hygiene checks pass locally.

    For every record the chain cannot finish whose model is sonnet or opus, spawn one agent of that model:

    • in its own worktree cut from the pull request's branch (head), never in your checkout;
    • with the record's action, reason and evidence as its brief;
    • told to commit there and stop: it never pushes, queues or reruns.

    An opus agent may fan out sonnet agents for mechanical parts of its work (a regeneration, an import block), each in its own worktree.

  4. When an agent reports, check its branch with a narrow test of what it changed. Then you, and only you, push it. Queuing it again is the person's: tell them gh pr merge <n> --auto --squash, which you never run, or for a stack the merge-queue: <method> label on its top pull request. A queue: <state> label is the queue's answer, never intent.

  5. Schedule the next pass with the host's wakeup about every 20 minutes (the queue's validation time), or with its pull request monitor. Repeat from 1.

    • A record with action: none needs no agent. It is queued, waiting on the pull request below it, running, or red-inherited with a merge for the person.
    • A draft or closed stage never merges on its own. Tell the person and drop it from the selection.

Stop when every selected record's stage reads merged. That status output is the proof; a green check or the queue's comment is not.

The magus advice comment

The bot's advice comment runs the same advisors ./magus diff --impact runs locally (localAdvisors in cmd/magus/diff.go). It never blocks a merge, so it is not a review comment to answer. Read it locally: ./magus diff --no-tui --impact --rev origin/main...HEAD -o json. A section the comment shows and the local run does not is a bug in that advisor. Fix the advisor in .github/actions/advice/; don't rename code to quiet it.

Never

  • Never admin-merge (gh pr merge --admin) yourself. It skips the queue's validation and ordering, so nothing checked the combination that merges. The record's merge is for the person to run.
  • Never enable auto-merge (gh pr merge --auto, or the enablePullRequestAutoMerge mutation through gh api). A person enables it; the repo's guard denies it. Tell the person the command. --disable-auto and reading autoMergeRequest are yours.
  • Never force-push a pull request branch. Reviews and the queue's candidates name commits, and a rewrite orphans both. The one rewrite is rebase-branches-onto-base.buzz on a rebase-branches-onto-base record: the squash already orphaned the commits it drops.
  • Never run two agents on one pull request branch at a time. One branch has one agent until you have pushed its result.
  • Never rerun a red by hand after apply declined to. It reruns a head once; red again on the same head is a real failure, and the record then says fix.

04 同仓库更多 Skills