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

Console

The MergeSpan console is a static single-page application served by the default Cloudflare Worker or the native runtime. It exposes per-repository state, events, diagnostics, setup checks, and operator controls. The ingress-only Worker does not serve the console.

Authentication

The console uses GitHub OAuth. Required bindings on the default Worker:

BindingKindNotes
GITHUB_APP_CLIENT_IDplain varOAuth client ID from the GitHub App settings.
GITHUB_APP_CLIENT_SECRETsecretOAuth client secret.
SESSION_SECRETsecret, ≥ 32 bytesSigns sessions and derives the internal dashboard relay key with purpose mergespan/dashboard-do/v1.

The OAuth callback is https://<host>/auth/callback. Without these bindings, pages still serve but /auth/* and /api/v1/* answer 503.

Permissions are resolved per request from GitHub and never inferred from the repository name or installation:

LevelAllows
readAll GET endpoints, including diagnostics and setup.
writeRead plus dequeue, urgent, reconcile, and state.json.
adminEverything, including resume.

GitHub’s maintain maps to admin; triage maps to write. A repository the App is not installed on, or where the user is not a collaborator, is reported as NotFound; the caller must not disclose whether the repository exists.

Repository discovery

Repository discovery uses at most 30 outgoing GitHub calls per page and reserves 10 for backend summaries (40 total, below the Workers Free 50-subrequest limit). Denied candidates count against the same budget. When work remains, GET /api/v1/repos returns a same-origin relative Link: </api/v1/repos?cursor=...>; rel="next" with a signed, expiring, user-bound cursor; the JSON body stays the RepoSummary[] array.

Pages and routes

The console serves four page routes via SPA fallback; every route returns index.html:

  • / — repository list.
  • /repos/:owner/:name — state, queue, active candidate, manual controls.
  • /repos/:owner/:name/events — append-only event timeline.
  • /repos/:owner/:name/diagnostics — deliveries, outbox, reconcile, raw state.

API routes live under /api/v1/. See crates/engine/src/dashboard/route.rs for the full routing table.

Reconcile

Reconcile is the one write that initializes a repository before any webhook arrives. From the repository page, click Reconcile:

  1. The request is persisted before any network call, and the API answers accepted (HTTP 202). That response acknowledges the request; it does not mean the repository is initialized yet. A repository with no coordinator may only be initialized by a Reconcile panel action; every other write is rejected as NotInitialized (HTTP 409 with message "MergeSpan has not received any events for this repository yet. Try Reconcile first.").
  2. On a later slice, the runtime attempts to load .github/mergespan.toml from the current base commit, create the coordinator, and scan queue-labeled pull requests through the same path as the first webhook. If another reconcile is already running or a merge is unresolved, the request waits rather than cancelling that work. A failed pass is retried on a backoff; the Diagnostics page records the last result and next scheduled run.
  3. A reconcile_requested event is recorded with the actor and request ID.

Reconcile is also used after configuration changes or to re-scan queue labels without waiting for the periodic reconciliation alarm. Reconcile is rejected with HTTP 409 while the queue is safety-blocked; resolve the pause first. Confirm completion from the Diagnostics Reconcile row and the config_loaded setup check, not from the 202 response alone.

Diagnostics

The diagnostics page exposes:

  • Deliveries — recent webhook delivery attempts with event, action, result, and timestamp.
  • Outbox — pending durable commands with phase, attempts, and last error.
  • Reconcile — last reconcile time, result, attempt count, and next scheduled run.
  • Build — running version and compiled full Git commit (unknown if the workspace had no Git metadata at build time).
  • State JSON — raw coordinator snapshot for advanced debugging.

Diagnostics are read-only (read permission). They do not expose secrets, tokens, or raw payloads.

Setup checks

The setup page runs a series of checks against the App, repository, and configuration:

CheckStatus sourceRemediation
app_permissionsGET /app permissions vs documented setRestore documented permissions manually; do not add Administration.
app_eventsGET /app event subscriptions vs required setAdd missing subscriptions in App settings.
repository_config.github/mergespan.toml on the base branchAdd the file if missing; fix invalid TOML and ensure same_repo_only = true.
required_checks_observedRecent candidate and base check runsConfirm CI reports the exact check names listed in config.
base_rulesBranch protection / ruleset on baseRequire squash only; add mergespan as required check; disable strict up-to-date.
config_loadedDurable snapshotReconcile if no snapshot exists.
delivery_healthRecent delivery attemptsCheck App webhook URL and Recent Deliveries.
manual_controlsRaw state flagsClear manual pause/freeze through the console once investigation is complete.
safety_pauseCoordinator pause reasonRead pause reason and expected/actual evidence; resolve it. Safety pause is not a manual control.
stuck_candidateActive candidate timeoutInspect candidate SHA and checks; let timeout dequeue or reconcile after fixing the underlying failure.

Setup checks are read-only and never mutate state. When the repository is readable and its base .github/mergespan.toml returns 404, the setup panel shows Not enabled and setup instructions instead of unrelated checks. The repository selector marks only repositories confirmed this way by a setup read in the current console session. Other read failures do not mean the file is absent. Unparseable TOML and a false same_repo_only are failures; config_loaded passes only after a Reconcile creates a durable coordinator snapshot.

A zero-delivery repository is supported: delivery_health is UNKNOWN with no attempts, not failed. required_checks_observed is UNKNOWN until GitHub has recent candidate or base check-run evidence, and bypass-list checks may be RESTRICTED without Administration read. The summary is failed if any check failed, otherwise unknown if any evidence is missing, otherwise restricted if any check needs administrator confirmation, and passed only when all checks pass. No first webhook is required; use Reconcile.

Manual controls

ActionPermissionEffect
ReconcilewriteInitialize or re-scan.
DequeuewriteRemove queue and urgent from one PR. Cannot cancel an issued squash.
UrgentwriteMove a queued PR to front and preempt active candidate.
PausewriteNo new candidates, no merges. Queued PRs keep their place.
FreezewriteCandidates still verified; nothing merged.
ResumeadminRelease a fail-closed safety pause after investigation.

Manual pause and freeze are independent of safety pauses. A safety pause is caused by post-merge mismatch or critical command failure; it requires investigation and cannot be cleared by the manual resume button alone.

Security headers

Every page and asset response carries CSP, nosniff, and referrer headers. The Worker serves assets through the ASSETS binding with run_worker_first = true so these headers are attached even when Workers Static Assets serves the file. The console loads no external assets; everything is bundled in web/.

Source map

ConcernFile
Dashboard servicecrates/engine/src/dashboard/service.rs
Build identitycrates/engine/src/build_info.rs (VERSION, GIT_COMMIT)
Routingcrates/engine/src/dashboard/route.rs
Policy / permissionscrates/engine/src/dashboard/policy.rs
Setup checkscrates/engine/src/dashboard/setup.rs
Static assetsweb/
Cloudflare dashboard integrationruntimes/cloudflare/src/dashboard/
Native dashboard integrationruntimes/native/src/dashboard.rs