Skip to content

Route pull requests to an agent (.stamp/routing.yml) ​

A pull request an agent opens through Stamp has an author Stamp knows. One opened anywhere else, a dependabot update or a pull request a person opens on GitHub, has nobody in Stamp looking after it. .stamp/routing.yml names the agent that should.

The file ​

Put a file at .stamp/routing.yml on the branch pull requests merge into:

yaml
routes:
  - author: dependabot[bot]   # GitHub login, exact, any case
    to: "@Scout"
  - label: needs-agent        # a label on the pull request
    to: "@Scout"
  - paths: ["docs/**"]        # any changed file matches
    to: "@docs-bot"
  • The first matching route wins. Put specific routes first.
  • A route may combine author, label and paths: every one it gives must match. paths matches when any changed file (or a renamed file's previous name) matches any of its patterns, with the same patterns as .stamp/CODEOWNERS.
  • to is the @handle of an agent of your Stamp server (quote it: YAML reads a leading @ as reserved). A person, a GitHub team, a name on another server (@name@server) or an e-mail address is not a route target.
  • The file is read strictly: an unknown key, a route with no condition or no to, a pattern Stamp cannot read, more than 50 routes or a file over 64 KiB makes the whole file unusable, and no pull request is routed until it is fixed. Stamp logs the reason (.stamp/routing.yml cannot be used).

Like .stamp/CODEOWNERS, the file is read at the pull request's base commit: a pull request that edits it does not route itself.

Which pull requests are routed ​

Only pull requests Stamp did not open, that is, with no creation receipt on any Stamp server. A pull request an agent opened through Stamp is never routed: it already has an author.

Stamp checks a pull request when GitHub tells it the pull request was opened, reopened, marked ready for review, or labeled. A draft is skipped until it is ready for review. The check runs in the background, a few seconds after the event.

What a route does ​

The route's agent is asked to review the pull request through Stamp's review requests, exactly as stamp pr review-request @handle would ask it: the agent gets a notice and the pull request in its Needs you list. The notice names the route, for example "routed by .stamp/routing.yml: author dependabot[bot]". On the pull request page and in stamp pr view the request names Stamp and the route (.stamp/routing.yml, its rule) as the requester, not a person or agent; --json carries route (source: routing, the route's 1-based index, its rule).

  • Once per pull request and agent. A repeated event, a retry or a restart asks nobody twice. An agent that already has an open review request on the pull request is not asked again.
  • A new label can route again. When a later label makes another route win, that route's agent is asked, once.
  • Several servers. Each Stamp server whose GitHub App covers the repository resolves to among its own agents and asks its own agent of that handle. A server where the handle is nobody, a person, or several principals asks no one, and Stamp logs why.

Reminder ​

When the routed agent does nothing on the pull request through Stamp (a review, comment, approval, push, close or merge) for 3 days after it was asked, and the request is still pending, Stamp sends the request's notice once more. It does not send a third. The reminder rides the daily digest.

The daily digest's idle pull requests and their escalation to owners and admins cover only pull requests opened through Stamp, so a routed pull request that stays idle after the reminder is not escalated.

Auto-merge by the routed agent ​

By default only the agent that opened a pull request through Stamp registers it for auto-merge, unless the repository lets approvers do it (Settings › Reviews, "approvers may register auto-merge"). A routed pull request has no such agent, so Stamp makes one deliberate exception: the routed agent may register auto-merge as an approver even where that setting is off.

  • Only for a pull request whose head branch is in the repository itself. A pull request from a fork is still routed for review, but its auto-merge stays with its author.
  • Only for a pull request with no Stamp creation receipt, and only while .stamp/routing.yml at the pull request's current base still routes it to that agent. Stamp reads the file again when the agent registers.
  • Everything else about an approver's registration holds: the agent needs its own approval of the exact head and must not be an author (it must not have pushed to the branch through Stamp).
  • The merge itself is unchanged: it still needs an approval that counts, green required checks and every rule of the repository.

Next ​