Pause and resume a maintenance duty (#11205)
Each duty the forge's maintenance runner runs (src/maintain/registry.ts) has an on/off switch, kept in maintenance_duty_state. A paused duty is skipped by every tick. After three errored runs in a row (it threw, timed out or had a finding refused) the runner pauses the duty itself and says why: "paused after 3 errors in a row; last error: …". Resuming starts the count again, so one more error does not pause it at once. The pause also files one issue on the forge's own repository (FORGE_REPO) naming the duty and its last error (src/maintain/park.ts); it carries a Maintenance key: parked/<duty> line, so while it is open no second is filed, restarts included. Closed, the next park files a new one.
All doors are for a forge admin and call one function, switchDuty in src/maintain/pause.ts, so they say the same words.
- On the web.
/maintenancelists each duty once; the ones the runner runs carry their state ("on", or "paused since … ; why") and one Pause / Resume button (POST /maintenance/duties/:name, same-origin only, form body bounded,pausedisyesorno). - In the terminal. Ctrl-K, Pause, resume or dismiss a maintenance duty (an admin who is a person):
j/kchoose, Enter or Space flips,ddismisses its finding for seven days (see duty-dismiss.md), Esc closes. It writes the same row, so a web viewer sees it on its next load. - Over the API.
GET /api/v1/maintenance/dutieslists the states;POST /api/v1/maintenance/duties/:namewith{"paused": true|false}needs anadmin-scope token. - In the MCP. The
maintenancetool:pause-dutyandresume-dutywithduty.
An unknown duty name is 404 (a flash on the page); a paused that is not a boolean is 422.
Tests: test/maintain-parked-issue.test.ts (one issue for three failures and a fourth tick), test/maintain-pause.test.ts (the three errors, resume from the API, the page and the terminal, the gates).
Merged branches (#13321)
The merged-branches duty finds branches of pulls that merged over seven days ago and whose tip is still the head they merged with. Never listed: the default branch, a branch an open pull uses, a branch that moved since, a fork's branch. It reads refs from the repository's files in one pass (no git process per branch) and lists at most 100 (MERGED_CAP), oldest first.
- On the web.
/maintenancefolds the list (name, short head, merge day) with a required confirm box and Delete all (POST /maintenance/branches/delete, same-origin, a forge admin who is a person). A branch not on the list any more is left alone; the flash receipt names each deleted branch with its full head. - In the terminal. Ctrl-K, Branches of pulls merged over 7 days ago: the same rows;
ddeletes them all after a confirm, with the same receipt.
Tests: test/maintain-merged-branches.test.ts, test/maintain-merged-web.test.ts.
Wait split (#13635)
The wait-split duty finds where a slow public page waits. Every six hours, from the forge's own host, it does three things for each of /healthz, /, /pricing, /terms and /privacy: it times a TCP+TLS handshake with the public origin (the edge), a GET of the public URL (to first byte and to the last byte), and a GET of the same path on 127.0.0.1:<port>, which skips the edge and the tunnel. It also reads the app;dur= the forge wrote in Server-Timing. src/maintain/wait_split.ts splits the first-byte time into edge = connect, tunnel = first byte − connect − loopback, accept = loopback − app, and app. The largest share names the layer. A page under 1 s waits in none. It sends GET only, and its timeout is the proof's own 15 s. A slow or unanswered page is a finding, and every page is one line on /maintenance. Inside a cell, the bare handshake cannot pass the egress proxy: that line says so and counts the handshake as 0 ms.
Tests: test/maintain-wait-split.test.ts.
Duty idle (#13406)
The duty-idle duty watches the other duties for silence. Hourly, it looks at when each duty last started (budget stops do not count as a start). A duty whose last start is more than twice its interval ago is idle; exactly 2x is not. A duty that has never run is skipped, because there is no last run to name. The watcher never watches itself.
For each idle duty it files one issue, once (an open one is not filed again), titled The maintenance duty <name> has not run in twice its interval. The body gives the last run time and the interval. It spends no money.
There is no terminal screen for it: it files an issue, and both doors (the web and the terminal) already show issues.
Tests: test/duty-idle.test.ts.