Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quick Start

This guide takes one repository from a fresh GitHub App and runtime to a queued pull request. It is written to be delegated verbally: run the steps in order. No webhook delivery is required at any point; Reconcile initializes a repository with zero config history and zero deliveries.

Installing the App on the repository is the enable/cutover action. Prepare the verification workflow, labels, and rulesets in step 2 first. If another merge queue is active, stop it before the installation in step 3; do not run two queues against the same base branch.

1. Deploy the runtime and create the GitHub App

  1. Create the GitHub App with the permissions and event subscriptions in GitHub App. Set its webhook URL to https://<worker-host>/webhook (active, JSON) and use the same secret as GITHUB_WEBHOOK_SECRET.
  2. Deploy the runtime from Self-Hosting. For the default Cloudflare Worker set:
    • GITHUB_APP_ID as a plain var;
    • GITHUB_APP_PRIVATE_KEY and GITHUB_WEBHOOK_SECRET as secrets;
    • the console OAuth bindings below.
  3. Do not install the App on the repository yet. Complete step 2 first so the repository is ready when installation enables MergeSpan.

For the console, the Worker needs GITHUB_APP_CLIENT_ID (plain var), GITHUB_APP_CLIENT_SECRET (secret), and SESSION_SECRET (secret, at least 32 bytes). The OAuth callback is https://<host>/auth/callback. The native runtime uses dashboard_origin, app_client_id, app_client_secret_file, and session_secret_file (or the default credential paths); see Self-Hosting.

Immediate errors at this stage:

  • GET /health is not 200: the runtime is not reachable; fix deployment before continuing.
  • /auth/* or /api/v1/* returns 503: the dashboard OAuth bindings are absent. Pages still serve, but sign-in and the API do not.

2. Prepare the repository before enabling

2.1 Add the verification workflow to the base branch

The workflow must run on push to mergespan/queue/** and skip the branch-creation push. A pull_request trigger alone does not verify the candidate. Use the exact shape in Configuration → Verification workflow requirements; the required check names are the caller-prefixed job names, for example verify / fast.

Merge the workflow to the base branch before queueing. The candidate is built from the base commit, so a workflow that exists only on a pull request head is not the base’s verification contract.

2.2 Create the labels

MergeSpan does not create labels. Create the names from the config (the defaults are queue and urgent), or reuse existing labels with those exact names:

gh label create queue --description "MergeSpan queue" --color 0E8A16
gh label create urgent --description "MergeSpan urgent" --color D93F0B

If a label already exists, keep it; do not create a duplicate. Adding a label that does not exist is rejected by GitHub and no queue entry is created.

2.3 Configure squash and rulesets

  • Repository settings: allow squash only (disable merge commits and rebase if you want the UI to enforce it).
  • Base branch ruleset: require a pull request, require the mergespan status check scoped to the MergeSpan App, leave strict up-to-date off, and use no bypass actors.
  • Require every check that must pass on the candidate by its exact name. With no config file, MergeSpan infers required_checks from the required status check contexts in the active rulesets that apply to main; the MergeSpan mergespan gate is excluded.
  • mergespan/queue/** ruleset: restrict creations, updates, and deletions to the MergeSpan App, with no human bypass.

Fileless inference reads rulesets only. Classic branch protection is not consulted, and MergeSpan does not request Administration read, change repository permissions, or change rulesets for you. If you only have classic branch protection, add a ruleset for the base branch. If the rulesets cannot be read, setup reports a failure and MergeSpan does not start.

If you are migrating from another queue and it is still merging, prepare the candidate-check requirements now but leave the mergespan gate requirement off until step 3. Inference ignores that gate; adding it early can block the old queue before you are ready to cut over.

See Sandbox Notes → Ruleset for the exact shape.

2.4 Optional: override the inferred configuration

If the defaults fit, you do not need a configuration file. The inferred defaults are base main, labels queue and urgent, timeout 60 minutes, same_repo_only = true, and the base ruleset’s candidate checks.

To override any value, add .github/mergespan.toml to the base branch:

base = "main"
queue_label = "queue"
urgent_label = "urgent"
required_checks = ["ci"]
timeout_minutes = 60
same_repo_only = true

An explicit file always wins over inference. If the file exists but is invalid, initialization stops and there is no fallback to inference: omitting required_checks is a TOML parse error, required_checks = [] is a validation error, and same_repo_only must be true. Merge the file to the base branch; it is read from the exact base commit, never from a branch name or the pull request head. See Configuration for every key and exact error.

Merge the workflow, labels, rulesets, and any config file to the base branch before installing the App. Installation starts processing; existing queue labels are not a safe staging area.

3. Install the App and enable MergeSpan

Before installing:

  • If Mergify, GitHub’s merge queue, or another queue is active on the base branch, disable/drain it first and wait for any in-flight merge to settle.
  • Remove queue and urgent (or your configured labels) from every open pull request so the new queue cannot pick one up before you are ready.

Then install the App on exactly the one target repository. This installation is the enable action; there is no separate on switch. A freshly installed App with no webhook deliveries is supported: Reconcile initializes it.

If you deferred the required mergespan gate while an old queue was still merging, add it now that the old queue is stopped. The gate must be scoped to the MergeSpan App.

After installation:

  • After sign-in, NotFound means the App is not installed on the repository or the signed-in user is not a collaborator.
  • Sign in as a collaborator with repository write or admin. write can Reconcile, dequeue, urgent, pause, and freeze; read can inspect but cannot mutate. GitHub maintain maps to admin and triage maps to write.

4. Sign in and inspect the initial setup

Open the console, sign in, and open the repository page. The setup evidence is on the repository’s Diagnostics page (also reachable from the setup banner).

repository_config has three possible outcomes:

  • explicit file valid: passed with the explicit configuration message;
  • file confirmed absent and inference valid: passed, stating that .github/mergespan.toml is absent, that the base was inferred from the active branch rules, and the exact required checks;
  • invalid file, or inference that cannot produce a safe list: failed with the reason and remediation.

A confirmed missing file is not “Not enabled” by itself: a fileless repository is a supported configuration. Do not add a file only to make the row green if inference already lists the checks you want.

When setup is not fully passed, the panel shows the full checklist. When everything passes, it keeps the base configuration evidence visible. Before setup is complete, you may see:

  • app_permissions and app_events: passed when the App matches GitHub App.
  • repository_config: passed for an explicit or inferred configuration, failed for an invalid explicit file or unusable inference.
  • config_loaded: unknown because no durable coordinator snapshot exists yet.
  • delivery_health: unknown with zero delivery attempts. This is not a failure and does not block initialization.
  • base_rules: passed if step 2.3 is applied.
  • base_bypass and queue_branch_rules: may be restricted because MergeSpan does not request Administration read; confirm those rules manually. A restricted result is not a failed setup.

The summary is Failed if any check failed, Unknown while evidence is missing, or Restricted if all readable checks passed but some need repository administrator confirmation. A fully green summary is not expected before the first candidate.

With the repository prepared in step 2, repository_config should be passed with either Base `main` configuration is valid: N required check(s), same_repo_only=true. for an explicit file or a message that .github/mergespan.toml is absent and the configuration was inferred from the active branch rules, with the exact required checks. If inference cannot produce a safe list, the row is failed with remediation instead of green. base_rules should be passed; config_loaded remains unknown until Reconcile; required_checks_observed may remain unknown until GitHub has check-run evidence; delivery_health remains unknown with zero deliveries.

5. Reconcile and verify the configuration loaded

On the repository page click Reconcile (write permission required). The click is asynchronous: the request is persisted first and the API returns accepted (HTTP 202); it does not mean initialization finished. On a later slice or alarm the runtime reads the base commit, then the explicit .github/mergespan.toml or the rulesets used for fileless inference, creates the coordinator, and scans queue-labeled pull requests. If a reconcile is already running or a merge is unresolved, the request waits; a failed pass is retried on a backoff and the Diagnostics page records the last result and next run.

Wait until Diagnostics shows a completed reconcile and config_loaded is passed with either the explicit loaded-configuration message or the inferred-configuration message (base, required-check count, and that the configuration came from active branch rules). The repository_config row lists the exact inferred check names. A 202 alone is not proof that the config loaded.

Immediate errors at this stage:

  • Any non-Reconcile write before initialization: HTTP 409 with MergeSpan has not received any events for this repository yet. Try Reconcile first.
  • Reconcile while the queue is safety-blocked: HTTP 409; resolve the safety pause first (resume requires admin).
  • Read-only session: HTTP 403; sign in with write or admin.
  • repository_config failed or an inference failure: Reconcile cannot initialize. Fix the explicit file or the base ruleset named in the message, then click Reconcile again. The setup diagnostic is the actionable evidence; config_loaded stays unknown.

Before labeling the test pull request, confirm the queue is empty: no queue/urgent labels and no active candidate.

6. Queue one test pull request and read the result

  1. Open a non-draft pull request from this repository targeting the configured base. Wait for its own CI to pass.
  2. Add the configured queue label (default queue): gh pr edit <number> --add-label queue, or comment @mergespan queue.
  3. Watch the mergespan check and the console. A green mergespan check is not, by itself, proof that a squash happened: the App can publish the gate as Success with Candidate verified; authorizing the guarded squash before the final freshness reads and merge. Confirm both:
    • GitHub shows the pull request merged with a merge commit; and
    • the console shows the Merged event with the merge SHA and post-merge evidence (or a post-merge mismatch pause).
  4. Only after that confirmation, clean up your local branch. If the check is Failure or the label was removed, read the newest mergespan[bot] comment; common reasons are in How It Works → What removes a pull request.

If the check is green but GitHub still shows the pull request open, wait and inspect the console; do not merge it yourself or re-add the label.

Next steps

  • How It Works — the full pipeline, failure surfaces, and recovery.
  • Configuration — every key, type, default, inference rule, and exact error.
  • GitHub App — permissions and event subscriptions.
  • Console — diagnostics, manual controls, and Reconcile.