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:
| Binding | Kind | Notes |
|---|---|---|
GITHUB_APP_CLIENT_ID | plain var | OAuth client ID from the GitHub App settings. |
GITHUB_APP_CLIENT_SECRET | secret | OAuth client secret. |
SESSION_SECRET | secret, ≥ 32 bytes | Signs 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:
| Level | Allows |
|---|---|
read | All GET endpoints, including diagnostics and setup. |
write | Read plus dequeue, urgent, reconcile, and state.json. |
admin | Everything, 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:
- 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."). - On a later slice, the runtime attempts to load
.github/mergespan.tomlfrom 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. - A
reconcile_requestedevent 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 (
unknownif 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:
| Check | Status source | Remediation |
|---|---|---|
app_permissions | GET /app permissions vs documented set | Restore documented permissions manually; do not add Administration. |
app_events | GET /app event subscriptions vs required set | Add missing subscriptions in App settings. |
repository_config | .github/mergespan.toml on the base branch | Add the file if missing; fix invalid TOML and ensure same_repo_only = true. |
required_checks_observed | Recent candidate and base check runs | Confirm CI reports the exact check names listed in config. |
base_rules | Branch protection / ruleset on base | Require squash only; add mergespan as required check; disable strict up-to-date. |
config_loaded | Durable snapshot | Reconcile if no snapshot exists. |
delivery_health | Recent delivery attempts | Check App webhook URL and Recent Deliveries. |
manual_controls | Raw state flags | Clear manual pause/freeze through the console once investigation is complete. |
safety_pause | Coordinator pause reason | Read pause reason and expected/actual evidence; resolve it. Safety pause is not a manual control. |
stuck_candidate | Active candidate timeout | Inspect 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
| Action | Permission | Effect |
|---|---|---|
| Reconcile | write | Initialize or re-scan. |
| Dequeue | write | Remove queue and urgent from one PR. Cannot cancel an issued squash. |
| Urgent | write | Move a queued PR to front and preempt active candidate. |
| Pause | write | No new candidates, no merges. Queued PRs keep their place. |
| Freeze | write | Candidates still verified; nothing merged. |
| Resume | admin | Release 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
| Concern | File |
|---|---|
| Dashboard service | crates/engine/src/dashboard/service.rs |
| Build identity | crates/engine/src/build_info.rs (VERSION, GIT_COMMIT) |
| Routing | crates/engine/src/dashboard/route.rs |
| Policy / permissions | crates/engine/src/dashboard/policy.rs |
| Setup checks | crates/engine/src/dashboard/setup.rs |
| Static assets | web/ |
| Cloudflare dashboard integration | runtimes/cloudflare/src/dashboard/ |
| Native dashboard integration | runtimes/native/src/dashboard.rs |