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:
- Explicit file wins. If
.github/mergespan.tomlexists at the base commit, every value comes from that file. - 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. - 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:
| Setting | Inferred value |
|---|---|
base | main |
queue_label | queue |
urgent_label | urgent |
timeout_minutes | 60 |
same_repo_only | true |
required_checks | Exact required status check contexts from the active branch rulesets on main, excluding the MergeSpan mergespan gate. |
required_checks inference works as follows:
- 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. - It collects the exact
contextof each required status check across those rulesets, deduplicated. It does not guess, glob, or strip caller prefixes. - It excludes the
mergespancheck that MergeSpan itself publishes on the pull request head. That gate is not a candidate check and can never pass on candidate C. - 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.
- 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.
| Key | Type | Default | Required | Notes |
|---|---|---|---|---|
base | string | "main" | no | Branch 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_label | string | "queue" | no | Label that enqueues a pull request. Must not be empty. Must differ from urgent_label. |
urgent_label | string | "urgent" | no | Label that moves a pull request to the front and preempts the active candidate. Must not be empty. Must differ from queue_label. |
required_checks | array[string] | — | yes in an explicit file | No 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_minutes | integer | 60 | no | Maximum 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_only | boolean | false (parser) / required true by runtime | no (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.
| Trigger | Error message (user-facing) |
|---|---|
| Unknown key in TOML | invalid mergespan.toml: unknown field <key>, expected one of base, queue_label, urgent_label, required_checks, timeout_minutes, same_repo_only |
base empty or whitespace | invalid mergespan.toml: `base` must not be empty |
queue_label empty or whitespace | invalid mergespan.toml: `queue_label` must not be empty |
urgent_label empty or whitespace | invalid mergespan.toml: `urgent_label` must not be empty |
queue_label == urgent_label | invalid mergespan.toml: `queue_label` and `urgent_label` must differ |
required_checks omitted | TOML 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 string | invalid mergespan.toml: `required_checks` must not contain an empty name |
required_checks contains duplicate | invalid mergespan.toml: `required_checks` contains `<name>` more than once |
timeout_minutes == 0 | invalid mergespan.toml: `timeout_minutes` must be greater than zero |
Runtime bootstrap constraints (additional to parser validation)
| Condition | Result | Where |
|---|---|---|
config.base != base_ref (the branch read during bootstrap) | ConfigMismatch { declared, expected } | QueueSession::load |
same_repo_only != true in an explicit file | SameRepoOnlyRequired | QueueSession::load |
.github/mergespan.toml confirmed absent at the base commit | inferred configuration, not an error | configuration load |
| Inference cannot produce a safe check list | hard stop; setup failure and remediation | configuration load / setup |
| File is not valid UTF-8 | Invalid("mergespan.toml is not valid UTF-8") | load_config_at |
| File parse error (above) | propagated from Config::from_toml; no inference fallback | load_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 configurationrow says.github/mergespan.tomlis absent, that the base was inferred from the active branch rules, and lists the exact required checks.config_loadedlater 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 withrequired_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
| Function | File |
|---|---|
Config::from_toml / Config::validate | crates/core/src/config.rs |
| Configuration load and fileless inference | crates/engine/src/queue_api.rs |
| Setup evidence | crates/engine/src/dashboard/setup.rs |
Coordinator::new_with_source / on_config_with_source | crates/engine/src/coordinator.rs |