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

Configuration

MergeSpan’s repository configuration is optional. It reads .github/mergespan.toml from the exact base commit at initialization and whenever it reloads the configuration, using ?ref=<base_sha>. The file is never read from a branch name or the pull request head.

The precedence is strict:

  1. Explicit file wins. If .github/mergespan.toml exists at the base commit, every value comes from that file.
  2. Confirmed absence is inferred. If the file is confirmed absent at the base commit, MergeSpan uses conservative defaults and infers the required candidate checks from the active branch rulesets on main.
  3. Invalid file halts. If the file exists but cannot be parsed or validated, initialization stops. MergeSpan never falls back to inference or defaults for an invalid file; fix the file and re-run Reconcile.

A 404 for the file is the only result that selects inference. A failed read, an unresolved ref, or an unreadable ruleset is unknown, not proof that the file is absent.

Inferred configuration (no file)

With no .github/mergespan.toml on the base commit, MergeSpan uses:

SettingInferred value
basemain
queue_labelqueue
urgent_labelurgent
timeout_minutes60
same_repo_onlytrue
required_checksExact required status check contexts from the active branch rulesets on main, excluding the MergeSpan mergespan gate.

required_checks inference works as follows:

  1. MergeSpan reads the effective branch rules for main, which layer every active ruleset that applies to the branch. It does not read classic branch protection, request Administration permission, or change any repository permission.
  2. It collects the exact context of each required status check across those rulesets, deduplicated. It does not guess, glob, or strip caller prefixes.
  3. It excludes the mergespan check that MergeSpan itself publishes on the pull request head. That gate is not a candidate check and can never pass on candidate C.
  4. Unbound contexts are treated as GitHub Actions check runs; contexts bound to GitHub Actions are kept the same way. They must pass from GitHub Actions on the exact candidate SHA; another source cannot satisfy them.
  5. Inference fails closed if the rules cannot be read or interpreted, if no required-status-check rule applies, if no useful check remains, or if a required check is explicitly bound to an App other than GitHub Actions (MergeSpan matches only GitHub Actions check runs). The setup check reports the failure and remediation; MergeSpan does not queue with an empty or partial check list.

Fileless inference always uses base main. To use another base, custom labels, a different timeout, or an explicit check list, add .github/mergespan.toml to the base branch. An explicit file is an override, not a requirement.

Keys (explicit file)

The parser uses deny_unknown_fields. Any key not listed below produces a parse error.

KeyTypeDefaultRequiredNotes
basestring"main"noBranch candidates are built from and merged into. v0.1 bootstraps from main; the config must declare base = "main" at first initialization. A different base is rejected with ConfigMismatch.
queue_labelstring"queue"noLabel that enqueues a pull request. Must not be empty. Must differ from urgent_label.
urgent_labelstring"urgent"noLabel that moves a pull request to the front and preempts the active candidate. Must not be empty. Must differ from queue_label.
required_checksarray[string]—yes in an explicit fileNo default in an explicit file: omitting the key is a TOML missing field parse error; [] passes parsing but fails validation with “must list at least one check”. In a fileless repository this list is inferred instead. Exact GitHub Actions check run names, matched by name, source GitHubActions, and exact candidate SHA. Must not contain empty strings or duplicates.
timeout_minutesinteger60noMaximum time to wait for all required checks on a candidate. Must be > 0. Expressed in minutes; the runtime multiplies by 60,000 ms with saturation.
same_repo_onlybooleanfalse (parser) / required true by runtimeno (parser) / yes (runtime)When true, only pull requests whose head branch lives in this repository are queued. The v0.1 runtime rejects any explicit config with false or omitted (SameRepoOnlyRequired). Inference sets it to true.

Example explicit file

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

A minimal explicit override on main only needs the values you are changing plus same_repo_only = true:

required_checks = ["ci / fast", "ci / integration"]
same_repo_only = true

Exact errors (explicit file)

A missing file does not produce these errors; it selects inference. These come from Config::from_toml and Config::validate when the file exists.

TriggerError message (user-facing)
Unknown key in TOMLinvalid mergespan.toml: unknown field <key>, expected one of base, queue_label, urgent_label, required_checks, timeout_minutes, same_repo_only
base empty or whitespaceinvalid mergespan.toml: `base` must not be empty
queue_label empty or whitespaceinvalid mergespan.toml: `queue_label` must not be empty
urgent_label empty or whitespaceinvalid mergespan.toml: `urgent_label` must not be empty
queue_label == urgent_labelinvalid mergespan.toml: `queue_label` and `urgent_label` must differ
required_checks omittedTOML parse error containing missing field `required_checks` ; this happens before validation
required_checks = []invalid mergespan.toml: `required_checks` must list at least one check
required_checks contains empty stringinvalid mergespan.toml: `required_checks` must not contain an empty name
required_checks contains duplicateinvalid mergespan.toml: `required_checks` contains `<name>` more than once
timeout_minutes == 0invalid mergespan.toml: `timeout_minutes` must be greater than zero

Runtime bootstrap constraints (additional to parser validation)

ConditionResultWhere
config.base != base_ref (the branch read during bootstrap)ConfigMismatch { declared, expected }QueueSession::load
same_repo_only != true in an explicit fileSameRepoOnlyRequiredQueueSession::load
.github/mergespan.toml confirmed absent at the base commitinferred configuration, not an errorconfiguration load
Inference cannot produce a safe check listhard stop; setup failure and remediationconfiguration load / setup
File is not valid UTF-8Invalid("mergespan.toml is not valid UTF-8")load_config_at
File parse error (above)propagated from Config::from_toml; no inference fallbackload_config_at

The console setup check repository_config reports a fixed diagnostic rather than the parser’s full error text:

  • explicit valid file: passed, Base `main` configuration is valid: N required check(s), same_repo_only=true.
  • fileless inference succeeded: passed. The Base configuration row says .github/mergespan.toml is absent, that the base was inferred from the active branch rules, and lists the exact required checks. config_loaded later reports the inferred configuration with its base and check count, and notes that adding a file would pin it.
  • confirmed missing file with unusable inference: failed, .github/mergespan.toml is absent and the effective configuration could not be inferred from the base branch's GitHub rules: <reason>. The remediation is either an active base ruleset that requires at least one GitHub Actions check, or a valid explicit file with required_checks.
  • invalid or incomplete file: failed, .github/mergespan.toml on the base branch cannot be used: configuration is missing fields or is invalid.
  • explicit parser default left unchanged: same_repo_only is false on base `main`; MergeSpan requires true.

config_loaded stays UNKNOWN until a durable coordinator snapshot exists. A successful setup row is not proof that the queue initialized; Reconcile is.

Because branch rules are live and are not part of the base commit, an inferred configuration is re-derived before candidate creation and again immediately before the final merge gate. A changed ruleset therefore makes an in-flight candidate fail closed instead of merging under a stale check list; if inference becomes unusable, the queue blocks. An explicit configuration change while a candidate is active is deferred: the old configuration stays effective until the candidate finishes. After changing the file or the rulesets that inference reads, re-run Reconcile and confirm config_loaded before queueing more work. A running v0.1 queue cannot be retargeted in place: bootstrap is fixed to main, so a different base is a ConfigMismatch, not a live reload.

Verification workflow requirements

The required check names, explicit or inferred, must match the exact GitHub Actions check-run names produced on the candidate. With a reusable verification workflow, that means caller-prefix qualified names: if the workflow is called verify and its jobs are fast and integration, the required names are verify / fast and verify / integration.

The workflow must run on push to mergespan/queue/** with github.event.created == false:

on:
  push:
    branches: ["mergespan/queue/**"]
  pull_request:
    branches: [main]
concurrency:
  group: verify-pr-${{ github.ref }}-${{ github.event.created }}
  cancel-in-progress: true
jobs:
  verify:
    name: verify
    if: >-
      (github.event_name == 'push' &&
       github.event.created == false &&
       startsWith(github.ref, 'refs/heads/mergespan/queue/')) ||
      (github.event_name == 'pull_request' &&
       github.event.pull_request.head.repo.full_name == github.repository)
    uses: ./.github/workflows/verify.yml

Only the candidate push C (created == false) produces the required check runs. A same-repository pull request run is also allowed; fork pull requests are skipped because their head repository differs. See Sandbox Notes for the exact workflow used in the sandbox deployment.

Source map

FunctionFile
Config::from_toml / Config::validatecrates/core/src/config.rs
Configuration load and fileless inferencecrates/engine/src/queue_api.rs
Setup evidencecrates/engine/src/dashboard/setup.rs
Coordinator::new_with_source / on_config_with_sourcecrates/engine/src/coordinator.rs