DocsRuns

Runs

A run is one step on one tree of the code: a command, the paths that it reads (its inputs) and the steps that must pass first (its needs). The design is #32 and #64. Buck2 with NativeLink as its cache runs inside a step (#97); this page covers the queue, the record and the runner.

Where each part lives

Part Store Why
The queue of the steps NATS JetStream, stream DESK_RUNS, subject desk.runs.<repo id> A work queue: a message stays until a runner acknowledges it, and a delivery that is not acknowledged within the ack wait goes to the next runner.
The record of each run Postgres, table runs What ran, its status, its attempts, who ran it, its result and the key of its log.
The log of a run The object store (S3), key repo-<id>/logs/<row id>, and the parts repo-<id>/logs/<row id>/part-<from> while it runs Bytes. The parts let a person read the log while the run goes on (#213).

The decision of the owner of 2026-10-17 on #32 sets this split: NATS is the queue, and Postgres keeps the record.

The run id

The run id is the SHA-256 of the command, the tree id of the inputs and the sorted run ids of the needs (runIdOf in src/server/runs.ts). A change in a file that the inputs do not name keeps the id. A request for a step whose run is queued or running gets that run, and nothing new is queued. A step that ran before runs again; the build inside it (Buck2) takes the results that did not change from NativeLink, the cache of #97, so a run of the same code takes seconds.

The queue

src/server/run-queue.ts has two queues with the same rules:

  • NatsQueue: the stream is a work queue on file storage, at most 512 MiB (1.5 GiB with 3 replicas). When it is full, a new step is refused, and its run ends as an error with 503. Each repository has one durable pull consumer, runners-<repo id>, with explicit acknowledgement and an ack wait of 60 s. The message id is run-<row id>, so JetStream drops a second publish of the same run within its duplicate window.
  • MemoryQueue: the queue in the memory of one server process. A server with no NATS_URL uses it, and the tests use it.

With NATS_URL, the server connects the queue in the background and tries again, from 1 s up to every 30 s, until it works (ConnectingQueue). Until then the server serves its code, a new step answers 503 with its record as an error, and a claim finds no step; the log names each failed attempt. On 2026-10-17 a start that waited on NATS, while NATS loaded the new account of desk, ended with "timeout" and the server was down for about 17 minutes.

At each start the server publishes its queued runs again (with NATS, when the queue connects), so a crash between the record and the publish loses no step; with the memory queue it publishes the running runs too. A second message of a run is skipped: the record keeps the sequence of the message that it runs (delivery_seq), and a claim takes a run only when it is queued or when the delivery is of that same message.

A claim takes the next delivery. The run record then holds a lease token and the address of the delivery ($JS.ACK.…). A heartbeat sends +WPI to that address and the ack wait starts again; a completion sends +ACK. Any server process can do this, because the address is in Postgres. A new delivery of the same step replaces the lease, so the runner before it gets 409 on its next call. A step that comes a fourth time ends as error and gets +TERM.

The claim records the runner (#182): claimedBy is the name of the identity, and claimedHost is the value of the header x-desk-host that the runner sends, the same host that runner list shows from runner_seen. Both stay null for a run that no runner claimed. The runner writes one line for each claimed run, before it runs the step: run <id> (<run id prefix>): <kind> in <owner/repo>, lane <lane>. The line names the kind (command, image, promote, publish or deploy), so the log of a deployer names the run and the lane that it took.

The routes

All routes are under /v1/runs/<owner>/<repo>/ and need Authorization: Bearer <token>.

Route Right Answer
POST steps {"name","command","inputs","needs","timeoutMs","tree"} merge 201 with the new run, or 200 with the run of the same id that waits. 503 when the queue refuses the step; the record then ends as error.
POST claim {"waitMs"} run {"run": <claim> | null}. The server waits up to waitMs (at most 20 s) for a step.
POST runs/<id>/heartbeat {"lease"} run 409 when the lease is lost.
POST runs/<id>/complete {"lease","reason","exitCode","durationMs","log","error"} run The record. 409 when the lease is lost.
PUT runs/<id>/artifacts/<name> with the bytes and the header x-desk-lease run {"name","blob","size"}: one file of a check with artifacts (#162). 409 when the lease is lost or the run is not a check with artifacts; 413 for a file over 32 MiB.
GET runs/<id> read The record, with artifacts: the files of the run, [{"name","blob","size"}], and with claimedBy and claimedHost, the runner that took the run (#182).
GET runs/<id>/log read The log.
POST runs/<id>/log {"lease","from","text"} run {"next"}, the byte after the part: one part of a log while the run goes on (#213). 409 when the lease is lost, when the part starts after the end of the log, or when it covers a byte that the log was written; a part that the log already holds is not an error and answers the end of the log. 413 when the log is full at 8 MiB.
GET runs/<id>/log?from=<byte> read The log from the byte from: the parts of a running run, and the whole final log of a run that ended. The headers x-desk-run-status and x-desk-log-next give the status of the run and the byte after the text, so a reader takes each part once. A running run with no output answers 200 with no text.
GET landings/<seq> read The loop of the landing seq of the log: checks (the newest run of each check), images (the builds that this landing queued, and their promotions) and deploys that it queued, each with name, run, runId, kind, lane, status, error, artifact, createdAt, waitedMs, durationMs, startedAt and finishedAt; and totalMs, the time from the landing to the end of its last step. A time is null while the run waits or runs. It names only the runs that the landing queued, so a run of an older landing on the same tree stays out (#151). 404 when the log has no such entry.
GET landings?limit=<n>&before=<seq> read The newest landings, newest first: each answer is the one of landings/<seq>, and next is the seq to pass as before for the page after it. limit is 10 by default and at most 100. 400 when before is not a seq (#151).
GET budget?landings=<n>&since=<iso> read For each step name and kind: n, medianMs, p90Ms, maxMs, medianWaitMs and medianStartOffsetMs, the time from the landing to the start of the step; and for the landing medianTotalMs and medianWaitMs (the landing to its first step that starts), with landings, first and last. It reads the newest landings entries (20 by default, at most 200), or those that landed since since (#143, #151). 400 when since is not a time.

waitedMs is startedAt − createdAt: the wait in the queue before the runner took the step. The lane is the queue that the run waited in (runs, deploy, base, mobile or ios), so a deploy is not counted with a check. A promotion is matched to the build of its digest, so it shows under the landing whose image it tags.

desk runs reads these routes, so an agent needs no call of the API by hand:

  • desk runs lists the newest runs, and desk runs checks the newest run of each check of main.
  • desk runs view <id> prints one run, and desk runs log <id> [--tail n] prints its log. With --follow it prints the parts that arrive while the run goes on, and it stops when the run ends (the status of the run is in the x-desk-run-status header of each answer).
  • desk runs landing <seq> [--wait] prints the loop of a landing, with the wait and the time of each run and, when every run ended, the time from the landing to its last step. With --wait it prints each change of a run, until no run waits or runs for 15 s.
  • desk runs landings [--limit n] [--before <seq>] prints the newest landings with the steps that each queued, so one answer says what a landing did and where its time went.
  • desk runs budget [--landings n] [--since <iso>] prints the median, the p90 and the max of each step, its median wait and its median start after the landing; and the median of the landing to its last step.
  • desk land --wait does the same for the landing that it made. The exit code is 0 when every run of the landing passed (the checks, the images, their promotions and the deploys), and 1 otherwise. A failed check ends the wait at once, and the last line names the last line of the log of the run that did not pass.
  • In a work folder, these commands use its server, repository and token. Elsewhere, --repo owner/name uses the server of ~/.config/desk/policy.json and DESK_TOKEN.

A step runs its command on the runners, so queueing one needs merge, the right that lands code.

The right run also reads the objects of the code (GET /v1/code/<owner>/<repo>/objects/…), because a runner writes the tree of each step. It reads nothing else of the repository.

The log of a run while it runs (#213)

The runner sends the output of a step while the step runs, so a person reads the log before the run ends. The parts and the final log are separate:

  1. The runner takes each chunk of output of the command and of each step of an image, a publish, a promote or a deploy, as it arrives (onOutput in src/server/sandbox.ts and in the options of each run of src/server/).
  2. src/server/log-stream.ts holds the text and sends a part every 2 s, or as soon as the part holds 64 KiB. It sends one part at a time, in order, and each part names the byte where it starts.
  3. The stream replaces each value of a secret with [secret] before it cuts a part. It keeps the last n − 1 characters of the text, where n is the length of the longest secret, so a value that the command writes in two pieces never reaches the store.
  4. POST runs/<id>/log writes the part at logs/<row id>/part-<from> and adds from to log_parts. The row keeps log_bytes, the byte after the newest part, so a second part at the same byte is not an error and a gap is refused with 409.
  5. A reader calls GET runs/<id>/log?from=<byte>, and the answer gives the byte after its text in x-desk-log-next. A run that ended answers with its final log, so the reader needs no second route.
  6. runs/<id>/complete writes the final log as before, and then removes each part. A part that stays needs no sweep: the final log takes its place, and the store drops the bytes.
  7. The log of one run is at most 8 MiB (MAX_LIVE_LOG_BYTES in src/server/runs.ts). A part beyond it is refused with 413, and the run goes on: the log of the run keeps what it wrote before the limit.

A failed send of a part is named once in the server log, and the stream stops. The final log of the run then holds the output as before, so a fault of the transport loses no result.

The CLI follows the log with desk runs log <id> --follow, the MCP tool runs_log takes follow, and the run page of the UI polls the route every 2 s while the run waits or runs. A plain desk runs log <id> reads the log of a run that still runs: it prints the parts that arrived, and it names on stderr that the log continues until the run ends. desk land --wait names the last line of the log of a run that did not pass.

A run whose runner is gone (#149)

A runner that stops leaves its run in the status running. Its delivery comes back to the queue after the ack wait, but GET /v1/runner/next lists only the queued runs (runnerNext in src/server/repo-http.ts). A runner therefore claims a repository only for a queued run, and the step that came back waits in its consumer. The sweep ends such a run.

Each server process runs the sweep (src/server/lost-runs.ts) at its start and every 30 s. The sweep calls endLostRuns (src/server/runs.ts). A running run is lost when one of these rules holds:

  1. Its last heartbeat is more than 5 minutes old. The row keeps heartbeat_at: the time of the claim, then of each heartbeat.
  2. It passed its time limit (timeoutMs) plus 5 minutes. This rule also ends a run whose runner still heartbeats, so a command that hangs ends too.

A lost run ends with the status error, the reason lost and one of these texts:

  • the run was lost: no heartbeat for 300000 ms
  • the run was lost: no result within <timeoutMs> ms plus the grace of 300000 ms

The sweep clears the lease. A late heartbeat or complete of the runner gets 409. The sweep acknowledges the delivery, so the queue gives no second copy. Then the sweep runs the steps that follow the end of any run (afterRunOutcome in src/server/run-http.ts): the next bisect step of a landing, the result of a proposal check, and the next image build. A build of an image waits while another build of the same image is queued or running. When the lost build ends, the build of the head of main starts.

desk runs view <id> prints "reason": "lost" and the text of the error. A lost check counts as an error of the infrastructure: it runs again on the same tree, and three errors end the check.

A run that waits with no runner (#185)

A run waits in the status queued until a runner of its lane claims it. The server cannot claim it for a runner that no right and no lane reaches. A run that waits for 5 minutes or more is then a fault that the person must see.

waitingRuns (src/server/runs.ts) reads the queued runs of a repository that are older than 5 minutes, and names one of three causes for each row:

  1. flag: the lane of the repository is off. The text says that a person set the lane off, and the row is a decision.
  2. right: no identity that is not revoked has the right run on the repository. The text names the pool membership of the org of the repository.
  3. silence: no runner of the lane claimed a run in the last 5 minutes. The runner of that lane is not up.

GET /v1/runs/<owner>/<repo>/failed answers {"failed": […], "waiting": […]}. Each row of waiting holds id, runId, name, lane, waitedMs, cause and detail. desk runs failed prints the rows after the changes that did not land, and desk runs log <id> reads the log. desk state puts the first run that waits at the top of its work, in the section ## Runs that wait for a runner. desk doctor warns about each row of the work folder.

The checks after a landing

A proposal runs the same checks on its own tree when it is created, and shows their results before the merge (docs/server.md, "Proposals, reviews and checks").

When a change lands on main, the server reads .desk/config.json of the new main and queues one step for each entry of validation (queueChecks in src/server/runs.ts):

  • The command of the step is setup, then command, in the folder cwd: cd '<cwd>' && <setup> && <command>.
  • paths says when a check runs, as for desk validate: the landing queues the check when it changed a file that paths match (against the tree before the landing), and always when the check has no paths. A glob with no / matches the file name in any folder, so /package.json names the one at the root and package.json matches ui/package.json too.
  • The input of the run is the whole tree, because a command reads files outside its paths (the tests of desk read server/migrations). The build inside the check (Buck2) takes from NativeLink the actions whose inputs did not change.
  • The time limit is timeoutMinutes, 30 by default, at most 120.
  • stage says when the check runs: main (the default) on main after the landing, or land before it (the next section). The checks after a landing skip the land checks.
  • lane names the queue that runs the check (#164): runs (the default), mobile or ios. A check of the lane mobile or ios waits for a runner of that lane, after the landing. A check of the lane runs never waits for a Mac.
  • secrets maps a variable of the command to a secret of the runner (#131): {"NODE_AUTH_TOKEN": "npmtoken"} gives the command the runner's DESK_BUILD_SECRET_NPMTOKEN as NODE_AUTH_TOKEN, for example to publish a package. Only the check on main after a landing gets them. A proposal, a bisect and desk validate run the same command without them, and a land check cannot have them. The runner replaces each value with [secret] in the log, and a runner without the secret ends the run as an error that names it.
  • artifacts lists the files that the check builds, as globs from the root of the checkout, for example ["dist/macos/*"] (#162). The next section says how they reach a release, and docs/release-signing.md how a release is signed.
  • A check that the queue refuses names its error in the answer, and the other checks are still queued.

The files of a check: artifacts (#162)

A check on main can build files for a release, for example the signed binaries of munhq/sealkeep. artifacts names them:

{ "name": "release-macos", "command": "./scripts/build-macos.sh dist/macos", "artifacts": ["dist/macos/*"], "secrets": { "APPLE_P12": "apple_p12" } }
  1. Each entry is a glob of files from the root of the checkout, not from cwd: * and ? stay inside one folder, ** crosses folders, and {a,b} is an alternation. An entry has no leading / and no . or .. segment, a check has 1 to 20 entries, and the config refuses artifacts on a check of stage land.
  2. Only the check on main after a landing uploads its files. A proposal, the gate of a landing, a bisect and desk validate run the same command and upload nothing.
  3. When the command passes, the runner reads the regular files that the globs match. It never follows a link and never leaves the checkout. It uploads each file with PUT runs/<id>/artifacts/<name>, where the name is the base name of the file. It sends the token of the runner and the lease of its claim: the right run alone attaches nothing, so a runner adds files only to the run that it holds. No extra token reaches the runner. The log names each file with its size and its blob.
  4. The limits: at most 100 files for each check, each at most 32 MiB (the largest blob of the code routes). A name is 1 to 200 letters, digits, ., _, + or -, as a file of a release.
  5. The run ends as an error, and keeps no file, when a glob matches no file, when two files have one base name, when a limit is passed, or when an upload fails. An error runs the check again on the same tree, up to three times, as any error of the infrastructure does.
  6. A check that fails uploads nothing. A run that does not pass keeps no file, and a new delivery of a run starts with none.

The bytes are blobs in the object store of the repository (table run_artifacts, migration 038_run_artifacts.sql). desk runs view <id> shows them as artifacts, and GET /v1/code/<owner>/<repo>/objects/blob/<blob> gives the bytes back.

A check can read other repositories of the server. checkouts of .desk/config.json lists them. An example is [{"repo": "acme/lib", "path": "../lib"}] for an app that builds acme/lib by path. The rules:

  1. The landing puts the tree of main of each one at that moment into the run record (extra_trees, migration 008_run_checkouts.sql) and into the run id. So a new main of acme/lib gives a new run, and a landing of acme/lib starts it (rule 7).
  2. The runner writes each tree at its path next to the checkout. It reads the objects with its right run on that repository.
  3. A path must stay in the scratch folder of the run, and away from its home and tmp.
  4. The author of the landing needs the right read on each repository of checkouts, because the log of a check shows what it read.
  5. A repository with no main, or one that the author cannot read, gives each check an error. The landing stands.
  6. The log of a run needs the right read on the repository of the run and on each repository of its checkouts.
  7. A landing of acme/lib queues the checks on main of each other repository whose config of main lists acme/lib in checkouts without at (#259, advanceDependents in src/server/dependents.ts). A check is due when it has no paths, or when its paths match a file that the landing changed, at the path of the checkout: with {"repo": "acme/lib", "path": "lib"}, a change of src/a.ts in acme/lib is lib/src/a.ts. A checkout with subpath counts only the files of that folder. A landing that changes no file of the checkout queues nothing. The checks of stage land do not run. The runs read the new main of acme/lib in extra_trees, and their author is desk (acme/lib log entry <n>). They join the head landing of the other repository, as the checks of its own landing do: its images wait for them, an error runs a check again, and desk runs landing shows them. Then the images of that repository advance (see "Build arguments, other repositories, and builds on their landings").
  8. A run that rule 7 queues lands nothing, so it starts no further round: a repository that lists itself, or two repositories that list each other, queue each check once for each landing.

A shared workflow is a folder of a repository that other repositories read at a fixed landing (#245). An entry of checkouts has two more keys for it:

Key Meaning
at A log entry number of the other repository (desk log). The run reads the tree of that entry, not the tree of main. A later landing there changes no run until the config names the new entry.
subpath A folder of the other repository. The runner writes only that folder at path.

An example: {"repo": "munhq/desk", "path": ".desk/workflows/buck-rust", "at": 560, "subpath": "workflows/buck-rust"}. The run id holds the tree of the folder, so a change of a file of the workflow gives a new run, and an unchanged workflow keeps the ids. A repository takes a new version of the workflow with one change of at. A log entry or a folder that does not exist gives each check an error that names it. The images of a repository do not build again when the repository of a pinned checkout lands.

The secrets of a check on main or of an image come from the runner pod (DESK_BUILD_SECRET_<ID>) or from the secrets of the repository or of its org (desk secret, docs/secrets.md, #246). A secret of the repository wins over one of the org, and its value reaches the run in the claim.

The answer of the landing lists the checks (checks: name, run, status, and whether it was queued now); desk land prints them. A fault while the checks are queued, for example a config that is not JSON, does not undo the landing: the answer names it in checksError, and the server log names it too. A tree with no config queues nothing.

The budget of a landing (#143)

The owner's budget: a change is validated, built and released in under two minutes, and under one minute in the usual case. Measured from desk change and desk runs view:

desk runs budget --repo <slug> --landings 5 (GET budget) reads the newest five landings and prints the median, the p90 and the max of each step, its median wait and its median start after the landing, and the median time from the landing to its last step. desk runs landing <seq> and desk runs landings show the steps of one landing or of the newest ones, each with the runs that it queued. A step of an older landing on the same tree stays out, so landing 274 (a revert) names its own three builds and not the desk-ui build of landing 272 (#151).

Landing Change Landed Check Image Last push
255, server code 11:08:16.9 11:08:25.0 root 71.4 s three images, 7.6–8.4 s each, in parallel 11:09:46.7
256, UI and docs 09:24:02.0 09:24:13.6 root 2.7 s (cache) desk-ui 68.3 s 09:25:33.7

The images no longer wait for the checks (#145). These are the landings before and after that change, measured with desk runs landing <seq>:

Landing Change Checks Images Promotions Landing to last step
260 the times of desk runs landing docs 55 ms, root 124 s desk-ui 61 s and the three server and runner images 7.7–8.2 s, after the check — 172 s
261 the promotion itself docs 45 ms, root 116 s desk-ui 64 s and the three server and runner images 8.2–9.2 s, after the check — 130 s
262 the promotion as a step of the landing root 85 s desk-server 8.2 s, desk-runner-rust 8.3 s, desk-runner-base 7.7 s, beside the check 1.3 s each 90 s
263 a page of docs/ docs 43 ms desk-ui 46 s, beside the check — 48 s

A landing waits for its check: an image adds its promotion, not its build. The build of an image with needs runs beside the check, and its tags follow in a promotion once the check passed (1.3 s on landing 262). An image with waitForChecks holds its build until its checks passed (#237). So a server landing is the time of root plus about a second, and the repositories over 60 s of #145 are the ones whose check or image is long.

A build starts with the landing, and not after its checks. On landing 274 the check root (run 2487) was queued at 16:20:36.5 and started 1.0 s later; the three server and runner images (runs 2488–2490) were queued 2–3 s after the landing, and desk-server started at 16:20:40.7, while root ran until 16:20:42.5. Only the promotions (runs 2491–2493) wait, for the check to pass and for the digest of their build: they were queued from 16:20:49.1, when desk-server ended.

What a change runs:

  • docs/** and README.md: the docs check (scripts/check-docs.mjs), in about a second. They are not a path of root, so a docs landing no longer queues the Buck2 suite. Since the UI serves the docs at /docs (#144), a docs change also builds the desk-ui image.
  • ui/**: the desk-ui image. scripts/image-ui.sh builds the Buck2 target //:ui_image (BUCK): next build (which type checks the app), the unit tests of the console and the production packages are cached actions on NativeLink, so an image of an unchanged console is a hit in the cache and no runner keeps a build cache or a claim (munhq/desk#244).
  • src/**, test/**, skills/** and the other paths of root: the Buck2 check, and the images that need it build beside it. Their tags follow in a promotion once the check passed (#145), so the check is not on the path of the image and a check that failed publishes no tag.
  • The check of root lasts as long as its slowest action. test/server-history.test.mjs runs one test in each action since #143 (it was two groups of 5 and 4, and the group of 5 held landing 255 for 57 s). A PGlite file groups its tests by 5, because each process pays about 4 CPU-seconds to start PGlite.

The roll of the image is Keel and the Deployment, outside this repository; it adds about a minute.

The measured cost, in seven repositories (#190)

scripts/pipeline-times.mjs reads runs landings, runs view and runs landings of the desk server and writes, for each landing, the queue wait of every run (created to started), the duration of every run, the lane, and the time from the landing to the last step. It ranks the steps by their total time and by their 90th percentile. To measure again:

node scripts/pipeline-times.mjs --repos munhq/desk,munhq/axon,munhq/munbot --days 7

Seven days to 2026-11-10, in seconds:

Repository Landings Median p90
munhq/desk 128 89 345
munhq/axon 134 341 695
munhq/munbot 16 324 841
munhq/chat-recall 30 145 410
munhq/launchkit 21 138 276
munhq/agentfetch 6 83 490
munhq/houseking 6 3 192

The twelve largest steps, by their total time over all landings of the seven days (n is the number of runs):

Step Med p90 n Total
axon root 269 474 134 8.5 h
axon image axon 208 362 91 5.6 h
axon image proxium-web 82 185 110 2.8 h
desk root 81 138 93 1.8 h
chat-recall image cloud 141 348 28 1.5 h
axon deploy proxium-dev-web 40 47 63 1.4 h
desk image desk-ui 69 92 50 0.9 h
munbot root 125 612 15 0.9 h
launchkit test 133 209 21 0.9 h
munbot image munbot 219 1013 8 0.7 h
munbot image agentyard-api 209 700 9 0.7 h
desk image desk-runner-rust-base 98 314 15 0.7 h

The queue wait is not a cost: its median is between 0.1 s and 0.8 s in every repository, because the runners take the next run at once. No check with stage: "land" takes 30 s (the type check of desk is 5.8 to 6.2 s). The cost after a landing is a check that runs on a change that cannot affect it, and the build of an image.

The target: the median of munhq/desk goes from 89 s to under 60 s. On 2026-11-10 the build of desk-ui (69 s) is most of that median, and root (81 s) is the rest.

The checks before a landing: stage: "land" (#66)

A check with "stage": "land" in validation runs before main moves, on the tree that would land: the change itself, or the merge of the change onto a main that moved. Keep this stage for fast checks, such as a type check; the full tests run after the landing.

  1. POST /v1/code/<owner>/<repo>/land runs the gate (landGate in src/server/runs.ts) right before main moves. The land checks come from the config of main, as desk merge reads the config of the base branch, so a change cannot switch off or edit the gate that judges it. The first landing of a repository has no main, so its own config holds the gate. When the config of main does not load, only a change whose own config loads lands: it repairs main, and its own config judges it. A land check whose paths match a change against the tree of main is due. With no due check, the gate passes and reads no checkout.
  2. A check whose run id passed before passes at once. A check with no run is queued, and the answer is 202 with status: "checking" and the runs. A run that ended with an error is queued again, up to 3 times.
  3. When every due check passed, main moves to that tree, and the checks after the landing are queued.
  4. When one failed, the answer is 422 with status: "refused", and main does not move.
  5. desk land asks again every 2 seconds while the answer is checking, for at most 2 hours, and prints the runs once. If main moves in between, the tree that would land changes, and its checks run again.

A revert of desk (next section) lands with no gate, because it restores the tree from before the broken change.

The lane of a check: lane (#164)

A check that needs a Mac, or the tools of a mobile build, names its lane in validation:

{ "name": "mac", "command": "./scripts/test-mac.sh", "lane": "ios", "stage": "main" }
  1. lane is runs (the default), mobile or ios. The config refuses base and deploy: those lanes hold the build of an own base image and a deploy, not a check.
  2. The server reads the lane of the step one time, when it queues the run, and writes it to the column lane of runs (migration 039_run_lane.sql). The run waits in the queue of that lane.
  3. A runner claims only the runs of its DESK_RUNNER_LANE. A runner of the lane runs never claims a check of the lane mobile or ios, and a runner of the lane mobile or ios never claims a check of the lane runs.
  4. A check of the lane mobile or ios runs after the landing, on main, as a check of stage main does. The config refuses stage: "land" with a lane other than runs, because the gate of a landing waits for a run runner, not for a Mac.
  5. A check of another lane runs with no secrets of the lane runs and uploads no artifact. The server log names the lane of the check, and desk runs view shows it.

The checks on the author's machine: preLand (#157)

A check that takes 80 to 300 s on a runner does not belong in the gate before a landing, because every landing waits for it. preLand in .desk/config.json lists commands that run on the machine of the author, where the cargo cache or the type cache is warm:

{ "preLand": ["cargo fmt --check", "cargo clippy --all-targets -- -D warnings"] }
  1. desk change runs each command in the work folder, in order, before it sends the change. The MCP tool change runs the same code, so every client has the same gate.
  2. A command that exits with a code other than 0 stops the change. Nothing is sent, and the answer names the command and its exit code. The limit of one command is 15 minutes.
  3. The commands run with /bin/sh -c and the environment of the author. A command that needs a tool that the machine lacks fails the change, so keep the list to tools that the repository needs to build.
  4. desk init, desk repo move and desk init --validation write preLand from the fast checks of the stack: the format, then the lint, then the type check, each in the folder of its stack (#174). A command that is in the list stays. desk doctor warns when a repository has checks before the landing and no preLand. A cold work folder builds the code once for the lint, so the first desk change there is slow.
  5. preLandEnv in ~/.config/desk/policy.json gives the commands a variable from sealkeep, for example {"preLandEnv": {"NODE_AUTH_TOKEN": "<sealkeep name>"}}, so npm ci can read the private packages of a registry (#175). The names stay on the machine of the author. A land check on the runner gets no secret, so the type check of such a repository runs here.
  6. preLand is a check of the author. The checks of validation still run on the server, before the landing (stage: "land") or after it.

Before desk land (#187)

npm test runs at most 4 test files at once (--test-concurrency, set DESK_TEST_CONCURRENCY to change it): each file starts its own PGlite database of 550 to 860 MB, and the default of one file per CPU took the suite of one run past 10 GB on a machine of 16 CPUs. With 4, the peak of the whole suite was 5.3 GB on 2026-11-13.

A landing of desk runs the full test suite in buck2 build //:check, and a check that fails reverts the landing. A test that passes with node --test can fail in that sandbox, because the sandbox holds only the files that BUCK declares. Run these commands in the work folder before desk land:

  1. npm ci --no-audit --no-fund --ignore-scripts installs the tools. Skip this step when node_modules exists.
  2. npm run build builds dist/ and writes build/test_deps.bzl again.
  3. node scripts/buck-test-deps.mjs --check confirms that the map is fresh.
  4. buck2 build //:test-deps-fresh runs the check of the map in the Buck sandbox, with the same action as the land check.
  5. buck2 build //:check runs every test in the sandbox. It is slow on a cold cache, so it stays out of preLand.

desk change runs the preLand of this repository: it installs the tools, writes the map from the current dist/ (node scripts/buck-test-deps.mjs), checks the map, and runs step 4. Run step 2 before it when you changed src/, because the map is written from dist/.

The map of build/test_deps.bzl holds the files of dist/ that each test reaches and the data folders that it reads. scripts/buck-test-deps.mjs reads the imports of each test, the calls that start a program (spawn, execFile, fork, execa), new URL(..., import.meta.url), join(__dirname, ...) and the reads of a path under dist/, docs/, skills/ or src/. When a test builds a path in a way that the script cannot read, the script stops with the test name and the line, and npm run build stops. Write the path as a literal of dist/<file>, or join it from __dirname with literal parts.

Two faults stay invisible to node --test:

  1. A test that reads a file of the repository that the map does not list. The sandbox holds no such file.
  2. A test that writes an extensionless node script into a temporary folder. Node reads the module type from the nearest package.json, so a package.json above that folder turns require into an error. Write a package.json with {"type": "commonjs"} into that folder, or name the script *.cjs.

The fast checks by default (#157)

desk init --validation adds the fast checks of the stack to the validation of an existing .desk/config.json. It keeps every entry that exists, so a check of the repository with the same name stays as it is, and it adds no test command.

Stack Check Stage
Rust (Cargo.toml) format: cargo fmt --check land
Rust clippy: cargo clippy --all-targets -- -D warnings main
Go (go.mod) gofmt: test -z "$(gofmt -l .)" land
Go vet: go vet ./... main
Python with ruff in pyproject.toml, ruff.toml or .ruff.toml ruff: ruff check . land
TypeScript (tsconfig.json and typescript in package.json) typecheck: npx tsc --noEmit, with the install of the package manager as setup land
A Node package with no type check syntax: node --check on each .js, .mjs and .cjs file, without node_modules land
A Python project (requirements.txt or pyproject.toml) with no ruff pysyntax: each .py file must parse land
  1. A check that only reads the files (a format, a lint, a syntax check) runs before the landing, and so does the type check of TypeScript (about 20 s with the install, as in leon). A check that compiles the workspace (clippy, go vet) runs after the landing. A repository moves a check to land when it wants it there.
  2. desk validate runs the checks of stage land for the changed paths. desk validate --all runs every command.
  3. desk init and desk repo move write the same checks, and write the test commands with "stage": "main".
  4. A stack in a folder gets the same checks with cwd set to the folder, the paths of that folder, and the name <folder>:<check>, for example svc:format. The folders are every folder up to three levels under the root, except the hidden ones and the ones that hold installed or built files (node_modules, target, dist, build, vendor). A folder inside a Rust workspace or a Go module that the root holds is left to the check of the root.
  5. A check at land gets no secret of the runner (secrets run on main only), so a package from a private registry cannot be installed there. A check at land must run on the runner image. Test a new command as a main check first, and move it to land after a run passed. An entry that the image cannot run refuses every landing, and a change cannot demote it, because the gate reads the config of main.

What did not land (#166, #165)

  1. desk runs failed (the MCP tool runs_failed, the route GET /v1/runs/<owner>/<repo>/failed) lists what did not stay on main, newest first: the changes that the gate refused, with the failed checks and their runs (table land_attempts, migration 037), the changes that conflicted with main, and the landings that desk reverted. ?author=<name> keeps one author.
  2. desk runs reverts lists the reverts only.
  3. The guard hook of desk (desk hook guard) tells the session. Before a tool call it asks the server at most once a minute for the work folder, and when a change of the identity of the folder failed since the last question, it hands the session a notice as context. The first call of a folder only records the time. The state is in ~/.cache/desk/notices/.
  4. desk reland <entry> puts the change of a reverted landing back into the work folder. The entry is the landing that desk reverted, or its revert. The folder must be at main (desk sync). The files that the change made are written from the change. A file that the folder holds in another version stays, and the version of the change goes next to it as a .desk-main copy. Then fix the fault, run desk change with the same message, and desk land.

Production pins (#241)

A repository can name pins in .desk/config.json: "pins": [{"name": "proxium-prod", "repo": "munhq/k3s-gpu", "file": "ansible/argocd/config/proxium/values.yaml", "key": "image.digest", "image": "axon", "approve": "auto"}]. When every check, image and deploy of a landing passed, the server sets the line of key (a dotted path of YAML keys) in file of repo to the digest of the image image of the landing, writes that change as desk and lands it, as it lands a revert, and queues the checks of repo on it (src/server/pins.ts). The repository of the pin then rolls it out (Argo CD for the charts). The table landing_pins (migration 056_landing_pins.sql) makes each pin of a landing happen once and keeps its state: landed, present (main already held the digest), waiting (approve: owner writes a question on the issue of the change) or failed with its reason.

e2e checks with twins (#264)

A headless e2e check drives the product through its API, the way a user does, against twins of its outside services. A twin is a stateful copy of the API of a vendor: the package @munhq/twins of munhq/launchkit has Stripe, an SMTP relay, the OpenAI API and the Anthropic API. The check needs no secret and no network, so it gives the same result on each run, and Buck2 can keep its result in the cache.

  1. The test starts its twins: const twins = await startTwins(seed). Each call opens a session of its own, with its own Stripe account, mailbox and model vendors, so the tests run in parallel. The answer holds the base URLs, the keys and env, the variables that @munhq/product-kit, @munhq/billing and the vendor SDKs read (STRIPE_API_BASE, SMTP_HOST, OPENAI_BASE_URL, ANTHROPIC_BASE_URL and the others).
  2. The product changes only its base URL. A test drives it, then acts as the vendor: twins.stripe.completeCheckout(<session>) pays a checkout and returns after each signed webhook, twins.nextMail() returns the next mail, and twins.fault({...}) makes a twin answer an error or cut a stream.
  3. A test in another language starts twins serve, reads the control URL from its first line, and uses the control API (the README of the package).
  4. The suite is a check of its own with stage: "main", so the landing does not wait for it. A repository with a production pin (the section above) holds production until it passes. A repository that deploys an image tag names the check in needs of the image, so the promotion pushes the tag only after the check passed.
  5. desk init writes the check <unit>:e2e for a package with the script e2e.
  6. twins drift stripe sends the same calls to the twin and to the test mode of Stripe, and fails when they do not agree. desk has no scheduled check, so it runs when the package changes.

The first suite is packages/server/src/e2e/billing.e2e.test.ts of munhq/chat-recall: a team, a checkout, the payment, the signed webhooks, a refused signature, a delivery that comes twice, and a cancel, with no mock.

The report of a landing on its issue

When every check, image build and deploy of a landing ended, the server writes one comment on the issue of the change (desk change --intent <n>): the log entry, the change and its first line, and a table of the runs with their results and times (src/server/landing-report.ts). The end of each run reports the landings of that run. The table landing_reports (migrations 047_landing_reports.sql and 054_landing_report_posted.sql) claims each report, so two replicas write it once; the landings before the table get none. The column posted_at is set after the post, so a claim that the server did not finish (it stopped between the claim and the post) is a row with no posted_at. The resume posts such a row again when its attempt (claimed_at) is older than 5 minutes. A post that fails removes the claim, so the next end of a run or the resume writes the report again. The periodic resume of the server writes a report that no end of a run wrote, and gives a landing with no step after 10 minutes its row with no comment. A person or an agent then ticks the lines of "Done when" that the runs prove.

Land first, test after: bisect and revert (#66)

A change lands with no wait, and its checks run on main after it. The server records the landing of each check run (landing_checks, migration 009_landing_checks.sql). When a run of a check ends, the server takes the next step for that check (src/server/bisect.ts):

  1. The newest result of the check decides. If it passed, nothing happens.
  2. If it failed, the server finds the newest landing where the check passed. If no landing passed it, nothing happens.
  3. That pass and the first failure after it mark a range. If the failure is the next landing after the pass, that landing broke the check.
  4. If not, the server runs the check on the landing in the middle of the range. It uses the config of that landing and ignores the paths of the check.
  5. The run in the middle reads the same other repositories as the failed run. A landing whose config has no such check counts as passed.
  6. Each run that ends takes the next step, so the range halves until one landing is left.
  7. The server reverts that landing with a new change of the author desk on the main of now. The change takes back the files of that landing and keeps the landings after it.
  8. The revert runs the check again. The issue of the broken change (its --intent) gets a message: the check, the landing, the revert and the run of the failure.

A landing is reverted once (reverts, keyed by the entry of the log). The bisect stops, and nothing is reverted, in these cases:

  • The landing is a revert of desk, because its revert lands the broken change again.
  • The revert conflicts with main. The row is conflict, and the issue tells the author to revert by hand.
  • A run in the range ended with an error 3 times (CHECK_ERRORS), or hit its time limit. Those results say nothing about the code. The server log names the run.

A check of a landing that ends with an error (a fault of the runners or of the build infrastructure, such as exit 75) or on its time limit runs again on the same tree, with the same run id, until it has ended in one of these ways 3 times. Block-builder run 415 waited 30 min, until its time limit, on a cache pod that was Pending. The landing then points to the new run, so the bisect, desk runs landing and the images follow it. Axon run 333 ended with "broken pipe" when a rollout restarted the NativeLink scheduler; the next run passes, with no step by hand.

  • The passing run and the failed run read different trees of the other repositories. One of those repositories can be the cause. The server log names both runs.

GET /v1/runs/<owner>/<repo>/reverts lists the reverts, newest first, with the right read.

A server that stops in the middle of a revert leaves it open. Every server, at its start and then every 5 minutes, finishes each open revert that is older than 5 minutes. A revert or a check that fails there is logged, and the others go on. It also takes the bisect steps that no server took. A live replica works on a younger revert, so a second replica leaves it alone.

The live proof on hotmun (2026-10-22): log entry 95 added a test that fails, and log entry 96 changed only this page. The result of the proof is in #66.

Replays of old fixed bugs (#207)

A replay asks the checks of a repository about a bug that they should catch. The command returns an old fix to its state before the fix, and the checks run on that state. A review of the replay counts in the same way. A failed check counts as a find only when its log names a replayed path at a line and the same check passes on main at the tree of the replay.

  1. desk verify bugs --repo <owner/repo> --last <n> reads the log from the newest landing back, and takes the landings whose message starts with fix:, fix(…) or fix!:, and the landings that desk reverted (their revert entry). n counts the replays that the run makes: a bug that does not apply is skipped, and the run reads further until it made n replays. n is 10 by default, and 50 is the most.
  2. The command reverses the fix on main as it is now: it returns each path of the fix to the blob of the landing before it. A fix that main changed after it does not apply. The row says skipped and the reason, for example main changed a.txt after the fix, so the replay does not apply.
  3. The replay becomes a change of the author desk-replay, with the message replay: <the message of the fix>. The server opens a proposal of the label replay for it, and the checks of the repository run on that proposal as on any other proposal (src/server/proposal-checks.ts).
  4. Before the replay, the run queues the same checks on main at the tree that the replay uses: that run is the baseline of the checks. A proposal check runs without the secrets of a landing, so a check that needs a secret fails on main and on the replay in the same way, and the baseline tells that failure from a find. The baseline of a check is in the table replay_baselines, keyed by the tree and the name of the check, so a second run of the same tree queues no second baseline.
  5. A failed check gives one of three verdicts about a replayed bug:
    • found: the baseline of the check passed, and the log names one of the replayed paths at a line (path:12, path:12:5 or path(12,5)). The row shows the line of the log as the reason.
    • passed: the check passed on the replay, so it missed the bug.
    • inconclusive: the check judged nothing about the bug. The reason says why: no baseline for the tree, a baseline that has not ended, a baseline that also fails on main at the same tree, a log that desk cannot read, or a failure that names no replayed path at a line (the reason gives the first fault of the log).
  6. A replay never lands and never merges. land refuses a change of the author desk-replay (src/server/land.ts), and mergePr refuses a proposal with the label replay (src/server/forge.ts). The hook of the branch also refuses it.
  7. Each row records the fix landing, its paths, the replay change and the proposal, with the results of the checks and of the reviews. A review is a row of reviews of the replay change, and it finds the bug when a comment names one of the replayed paths.
  8. desk verify bugs --report reads the rows that exist, and --json writes them. --dry-run makes no change and no proposal, and it lists the rows that a run would make. --refresh makes again the rows that did not apply.
  9. The report gives the count of the bugs, the found ones and the inconclusive ones, then the share of each check (<name>: <found>/<ran> found (<share>), then , <n> inconclusive when a check judged nothing) and of each review profile. The rows that became a replay come first, each with found by <check or profile>, inconclusive, missed or the checks have not ended, and the skipped rows follow with their reason. A row whose checks all passed and whose reviews found nothing is a missed bug: the checks and the reviews of the repository should catch it. A row whose failed checks all judged nothing is not a missed bug, and the report counts it as inconclusive.

The routes are POST /v1/code/<owner>/<repo>/replays (the merge right) and GET /v1/code/<owner>/<repo>/replays (the read right). The rows are in the table replay_runs (migration 050_replays.sql), keyed by the fix landing, so a second run makes nothing twice. The baselines are in the table replay_baselines (migration 052_replay_baselines.sql), keyed by the tree and the name of the check. The code is in src/server/replay.ts, and the command is in src/replay-cmd.ts.

The check of desk is sh scripts/check.sh. It runs buck2 build //:check, with these actions (BUCK, build/defs.bzl):

  • //:node_modules: npm ci --include=dev from package.json and package-lock.json.
  • //:dist: npm run build from the sources.
  • One action for each test, with only the files of dist/ that its file reaches (build/test_deps.bzl, made by scripts/buck-test-deps.mjs). A file whose tests share state (a before or after hook, a top-level let) runs as one action, unless it says // buck: each test makes its own state. A named test must run exactly once.
  • Each test action gets only the data roots of BUCK (DATA_ROOTS) that its test file or its helpers name as a path (TEST_DATA in build/test_deps.bzl); a test that runs desk install or desk update gets every root. Before, each test took all data files, so a change of .desk/config.json ran about 160 of 370 actions again on each landing (runs 143 to 163). A root that a test reads and the map leaves out is missing in the folder of the action, so the test fails.
  • //:test-deps-fresh: fails when build/test_deps.bzl is out of date.

On a runner, DESK_CACHE_ADDRESS names NativeLink, and check.sh writes it into .buckconfig.local, with the versions of node and npm, which go into the key of every action. An action whose inputs did not change comes from NativeLink and does not run. Every action copies its inputs into a folder of DESK_ACTION_TMP (the TMPDIR of the run), outside the checkout.

A machine on the mesh reads the results of the runners and writes none: DESK_CACHE_ADDRESS=grpc://cache.int.hotmun.com:443 DESK_CACHE_TLS=true DESK_CACHE_UPLOAD=false sh scripts/check.sh. The private Traefik of hotmun (traefik-internal, VIP 10.200.0.210, which the vRack and the NetBird mesh reach) serves that host with TLS and sends it to the Service desk-nativelink-mesh: a second listener of NativeLink with a read-only action cache and a content store that checks each digest. DESK_CACHE_UPLOAD=false writes cache_uploads = false into .buckconfig.local, and platforms/defs.bzl then turns off the uploads.

Measured on 2026-10-17 on a machine with 16 cores and a local NativeLink, from an empty buck-out:

Case Time Actions from the cache
No cache 204 s 0 of 39 (one action for each test file)
The same code 1.4 s 276 of 276
One test file changed 16.7 s all but that test
src/server/merge.ts changed 231 s 134 of 276; the slowest action was test-cli, 133 s

The time of a changed check is the time of its slowest test and of the queue of its actions on the cores of the runner.

Remote execution on all the nodes (#97)

The actions of a check that the cache does not hold run on the workers of NativeLink, not only on the runner that took the check. The runner has DESK_RUNNER_RE (the scheduler, grpc://desk-nativelink-scheduler:50051 on hotmun) and gives it to each step as DESK_RE_ADDRESS; scripts/check.sh then sets desk.remote_exec, and the platform of Buck2 (platforms/defs.bzl, and buck/rust/platforms.defs.bzl for the Rust repositories) sends every action to the scheduler with the properties OSFamily=linux and container-image=desk-runner.

  • The scheduler is one pod: its queue of actions is in memory. Its content store and action cache are the NativeLink cache (desk-nativelink, S3 and Dragonfly), through grpc stores.
  • The workers are a DaemonSet, one pod on each node (desk-re-worker), on the image of the runners: Node, the Rust toolchain, git and the static nativelink binary (docker/base/runner-rust.Dockerfile). A worker runs 20 actions at once, and has the grace period of the runners; the limit of its memory is 32Gi (munhq/k3s-gpu).
  • A worker gives the inputs of an action read-only, so an action makes its copies writable (chmod -R u+w in BUCK and build/defs.bzl).
  • The first check of a repository with remote execution uploads all the inputs of its actions, also node_modules, to the cache; OVH S3 answers such a burst with "SlowDown", so the S3 stores of the cache retry each write with a backoff (munhq/k3s-gpu#199). Later checks upload only what changed.
  • An error of the infrastructure of Buck2 (exit 2, 4, 5, 11 or 12) makes scripts/check.sh exit 75 (EXIT_INFRA): the run is an error, and desk starts no bisect and reverts nothing.
  • Without DESK_RE_ADDRESS, DESK_CACHE_ADDRESS is the cache and the actions run on the machine of the check.
  • A worker names itself in the first line of the log of each action: worker=<hostname>. After the build, scripts/check.sh prints the count of actions for each worker, so the log of a check says how the actions spread over the pods (#235). An action that the cache gave keeps the log of the worker that ran it first.
  • The time of a check is the time of its slowest action and of the queue of its actions on the slots of the workers. Measure it with desk runs budget --landings 10: it prints the median, the p90 and the max of each step. A check spreads only when the number of its actions is more than the number of its slots, and each action is shorter than the time of the check.
  • The pods of desk have a CPU request and no CPU limit (munhq/k3s-gpu#217, #218). A worker or a runner takes the idle CPU of its node. When the node is busy, the requests set the share of each pod, so the databases of the node keep theirs. On 2026-10-25 the namespace desk peaked at 19 cores in 6 hours, with an average of 0.9 cores for the three workers.

The rules for a fast check, for every repository (#145, #235)

The goal is a check of under 60 s with ten agents at once, on the nodes that exist, and no node above 90% CPU. These rules come from the measurements of 2026-11-13 (desk root, cold: 188 test actions, 1,019 CPU-seconds in all, 195 s before the changes of this section).

Parallelism limit per core

  • One remote action holds one core (cpu_count 1, workflows/buck-base/platforms/defs.bzl), and a worker holds 20 actions (tasksPerWorker), so the slots follow the cores and the I/O waits of the actions overlap.
  • A worker has no CPU limit, by the decision of the owner on 2026-11-13 (munhq/desk#235): the cluster takes no new cap. Without a limit, a check of desk takes 8.2 cores of one worker, and two cold checks at the same time put the three nodes at 97% to 98% CPU (kubectl top nodes, 2026-11-13; idle is 17% to 25%). So run one cold check at a time, and read kubectl top nodes before you start more: a warm check (most actions from the cache) is cheap, and a cold one is not.
  • Admission control is the queue, not a refusal: the actions of any number of runs wait in the scheduler for a slot, and a run that cannot start waits in the run queue of its repository. The pool of runners has a floor of 3 and a ceiling of 6 (KEDA), so no more than 6 checks run at once. Do not raise the limit, the slots or the ceiling to make a queue shorter: the owner's rule is that the cluster is never above 90%.
  • To prove a change of the limits, run 2, 4, 6 and then 10 checks at once, read kubectl top nodes between the steps, and stop a step when a node passes 90%.

Shard size

  • The time of a cold check is its CPU-seconds divided by the cores that it gets, and not less than its longest action. scripts/check.sh prints the CPU of the actions, the actions with the most CPU seconds, the CPU seconds of each test file and the slowest tests after the build. Read them before a change.
  • No action takes more than about 20 CPU-seconds. A file whose tests share state (a before hook or a top-level let) runs as one action, so it sets the floor: split such a file into files with their own setup.
  • A test that waits is no test of CPU: two tests of server-runs waited 90 s each for the retry window of the client (RETRY_TOTAL_MS) because they expect a 503. A test that expects a refusal gives the client { totalMs: 0 }.
  • A build that checks types is not in the path of every test: dist/ is built with tsc --noCheck (npm run build:dist:fast, 43 s to 9 s), and the check of types is the validation typecheck (stage land).

Cache keys

  • An action declares only the files that it reads: a test gets the files of dist/ that its file reaches (build/test_deps.bzl) and the data roots that it names. A change of one source file runs again only the tests that reach it.
  • A command or an environment variable that changes between runs (a time, a path, a host name) is part of the key of the action: keep them out of the command. The worker name and the times go to the log, which is an output, and not to the key.
  • A result is shared by every run, every agent and every landing that has the same inputs: the second run of the same tree takes 2 to 4 s.

The shape of a test file (measured on desk, 2026-11-13: a change of a widely used file went from 91 to 108 s to 53 s)

  • The time of a check after a change that makes most tests run again is the build of dist (9 s), the longest single action, and the start of the run (about 9 s). Find the longest action in the log of the run: the last Waiting on root//:test-... line names it. the slowest tests of scripts/check.sh lists tests of the logs in the build folder of the runner, so it can show a time of an older run: read the tail of the run first.
  • A test file that has a top-level before() runs as one action. Split such a file into files that each build their own fixture, and keep together the tests that need the state that an earlier test makes (a test that fails alone names the state it needs).
  • Make the setup of a test cheap, not the check that it makes: a history of 120 commits was made with 360 processes of the version control tool, and the test waited 41 s for them; one fast-import process made the same commits in 6 s. A test that calls 100 tools, one process each, waits for 100 processes in a row: call 8 at a time (35 s to 3 s). Keep the assertions.
  • Do not lower a number that a test proves (120 commits, 16 MiB) to make it faster.

The time budget, so the pipeline does not drift (#243)

  • Every check has a budget in seconds: budget.checkSeconds in .desk/config.json (default 60) and budget.checks.<name> for one check. A landing judges the median of the newest 5 runs of each check that has at least 3 runs. The median, not the p90, so one cold run does not stop the pipeline and a sustained slowdown does.
  • budget.mode says what a landing does while a check is over: off checks nothing, warn (the default) lands the change and names each check in the answer (overBudget), and refuse stops every change that is not a change of the pipeline (type perf, build, ci, test or revert). A change of the pipeline is the way back, so it lands.
  • The guard reads the config of the parent of the change, so a change cannot turn off the budget that judges it.
  • desk runs budget --check [--landings n] [--limit s] exits 1 and names each check over its budget; use it in a hook or a scheduled check.
  • A change that adds time to a check is a change to its test or its build first: measure with desk try, read the CPU of the actions, and keep the check inside its budget. Do not raise a budget to make a landing pass: a higher budget is a decision of the owner.

Queue rules

  • The scheduler of NativeLink (v1.8.1) takes the queued action with the highest priority first and, among equals, the oldest one. The priority is the field execution_policy.priority of the request; Buck2 sets it from meta_internal_extra_params = {"remote_execution_policy": {"priority": N}} of ctx.actions.run.
  • build/defs.bzl gives node_modules, dist and pglite_template (priority = 5) and the longest tests (LONG_TESTS, +2) a higher priority, so the actions that every other action waits for, and the longest ones, start first. DESK_RE_PRIORITY (default 0) moves a whole run: a run that is small or warm sets a higher value and goes before the hundreds of actions of a cold run of another repository.
  • The scheduler has no fair share per client. Priority is the only tool, so give a high value to a short run and a low value to a long cold run, and never the same high value to both.

Builds as Buck2 targets: block-builder, codeindex and chat-recall (#244)

The builds and the tests of these three repositories are Buck2 actions on NativeLink. They read the workflows of this repository through checkouts (buck-base, buck-rust, buck-node, buck-zig), and no runner pod keeps a cache folder, a lock or a variable for a build cache.

Repository What builds Time
munhq/block-builder //:check, //:test-runs and, for node/ (784 crates), //node:check, //node:test-runs and //node:node-help node 8 s from the cache (run 12149), 4 to 5 minutes cold; the six checks together 32 s from the cache
munhq/codeindex the Zig build and tests, //:check of buck-zig 3 s, 100% cache hits (a fresh desk try, 2026-11-14)
munhq/chat-recall the tests, the site stage with Chromium (site_overlay) and the targets selfhost-image and cloud-image image cloud 50 s after a change of the Dockerfile (run 11972), median 55 s in 6 runs

How a second workspace works (node/ of block-builder): workflows/buck-rust/README.md, "A second Cargo workspace". The crates that node/ takes from the root build as <crate>-node rules in the root package.

A build script of a -sys crate (librocksdb-sys, libgit2-sys) gets no DEP_*_INCLUDE of the crates under it from Buck2, so its headers (zlib.h, bzlib.h, lz4.h, zstd.h, jemalloc/jemalloc.h) come from the image of the runner and the worker (docker/base/runner-rust.Dockerfile). cc-rs prints the text of a compiler error to the standard output of the build script, which the log of Buck2 does not show: a genrule that runs the same compile prints it.

Images: BuildKit builds with the landing, and a promotion applies the tags (#67, #145)

images in .desk/config.json lists the images of a repository. Each entry has name, image (the name with no tag), dockerfile (default Dockerfile), context (default .), needs (names of checks of stage main), tags, waitForChecks (the build waits for the checks of needs, #237), paths, changeArg, secrets, target (the stage of a multi-stage Dockerfile; without it, the last stage) and timeoutMinutes.

  1. After a landing, and after each run that ends, the server looks at the head of main (advanceImages, src/server/images.ts). An image is due when its landing is on main, when no check of needs failed on that landing, and when its paths match (step 4). A check that the landing did not queue counts as passed, as in the bisect. An image with waitForChecks is due only when every check of its needs passed on that landing (#237).
  2. A build starts with the landing, and not after its checks: the check and the build wait in the queue side by side, so the check is not on the critical path of the image (#145). A check that failed blocks the build of that landing. An image with waitForChecks does not start with the landing: it waits for its checks, so it compiles nothing that a check compiles after it (#237, munhq/axon#595).
  3. A build is a run of kind image (migration 011_images.sql). Its run id holds the tree and the image spec. The whole tree is its input.
  4. With paths, the build starts only when a file that they match changed since the last image that was pushed.
  5. Only the head of main is built, and one build of an image waits or runs at a time (a unique index). A landing during a build is built when that build ends, so an older landing never replaces the tag of a newer one.
  6. A build that failed is not queued again by itself, and a build that ended with an error is queued again 3 times. A new landing builds again.
  7. A runner with BuildKit takes the run, writes the tree, and runs buildctl (src/server/image-build.ts). An image with needs and tags and no waitForChecks pushes only image:<change id>: its own tags (main, latest) come in a promotion (step 9). An image with waitForChecks pushes image:<change id> and each of tags, because its build started after the checks of the landing passed. An image with no check, or with no tags, pushes image:<change id> and each of tags in the build. changeArg gives the change id to the build as a build argument. Each id of secrets (for example npmtoken) is a BuildKit secret: the runner writes the value of its variable DESK_BUILD_SECRET_<ID> to a file of the scratch folder and passes --secret id=<id>,src=<file>. The Dockerfile reads it with RUN --mount=type=secret,id=<id>. A runner that does not have the variable ends the run with an error that names it, and the server queues the build again for another runner.
  8. The digest of the push is the artifact of the run.
  9. A promotion is a run of kind promote (migration 031_promote.sql, src/server/promote-run.ts). An image with waitForChecks has no promotion: its build pushes the tags (step 7). A promotion starts when each check of needs passed on the landing, copies the manifest of the pushed digest to each tag of the step with the registry API, and tells Keel of each tag. The manifest does not change, so no layer moves: the three promotions of landing 262 took 1.3 s each. A promotion reads the digest that each tag holds now, and it moves the tag only when that digest differs from the digest of the build (Registry.tagDigest in src/server/oci.ts, #179). A tag that already holds the digest stays as it is, and the promotion does not tell Keel of it. A landing of an unchanged tree therefore moves no tag, and no Deployment rolls. Each landing queues its own promotion, so the comparison runs for each landing. A promotion belongs to the landing of its build: it runs when the last check of that landing passed, also when a newer landing is the head of main by then (#192). An older landing names the newest promotion of its image, and the newest promotion decides the tag: when a newer landing promoted first, the older landing records superseded and writes no tag, so a tag never moves back to older code. desk runs landing <seq> names the state of each promotion of the landing: promoted, superseded by <seq>, skipped (no file of its paths changed) or blocked, so no landing stays silent. The state is a row of landing_promotions (migration 044_landing_promotions.sql), and the command reads it from the promote runs when a server of an older version wrote no row. A tag never names a change whose check did not pass, and a check that failed leaves the tag of the change in the registry, as the record of what the build pushed. The run waits in the lane runs, as a check does; a runner without a registry login ends it with an error that names the login, and the server queues it again 3 times. One promotion of an image on one tree waits or runs at a time (a unique index).
  10. A row of deploys records the push: change, image, digest. The row is written for the build of an image that does not promote, and for the promotion of one that does. A Deployment that follows a tag (:latest) rolls through Keel; a Deployment that runs a digest rolls through a target of deploys (below), and that target takes the digest of the promotion, so a Deployment never rolls a change that a check has not passed.

On landing 262 of munhq/desk (2026-11-02) the root check took 85 s, the three builds of the server and the two runners 7.7 to 8.3 s each beside it, and the three promotions 1.3 s each after it: 90 s from the landing to the last step. The check is what a landing waits for, and the image adds only its promotion.

Only the config makes an image run: POST steps refuses to set one. A runner that has no DESK_BUILDKIT_HOST or no login ends an image run with an error that names the missing setting.

Variable of the runner Use
DESK_BUILDKIT_HOST The BuildKit daemon, for example tcp://buildkitd:1234.
DESK_KEEL_WEBHOOK The native webhook of Keel, for example http://keel-metrics.keel.svc.cluster.local:9300/v1/webhooks/native. After a push, the runner sends {"name": image, "tag": tag} for each tag that the build pushed, and after a promotion for each tag that it set, as the image workflows of GitHub Actions did: Keel cannot poll ghcr.io/munhq. A failed call is a line of the run log.
DESK_REGISTRY_USER, DESK_REGISTRY_TOKEN The login of the registry of the images. Both or none. The runner writes them into a Docker config file in the scratch folder of the run. They are in no command line and not in the environment of the command.
DESK_BUILD_SECRET_<ID> The value of the build secret <id> of an image step, for example DESK_BUILD_SECRET_NPMTOKEN for npmtoken. It goes to a file of the run for BuildKit, and to no command line and no environment of a command.

Tested on 2026-10-21 against BuildKit v0.34.1 and registry:2 on one machine: DESK_TEST_BUILDKIT_HOST=tcp://127.0.0.1:1299 DESK_TEST_REGISTRY=127.0.0.1:5077 node --test test/server-images.test.mjs builds a tree, and both tags in the registry have the digest of the run.

Build arguments, other repositories, and builds on their landings

  • args gives a Dockerfile build fixed build arguments, for example {"VITE_CLOUD": "1"}. They come before changeArg, sorted by name, and are part of the run id.
  • An image build reads the checkouts of the repository, as a check does: the runner writes each one at its path. A path inside the checkout (for example product) puts that repository in the BuildKit context. The trees of the checkouts are part of the run id.
  • A landing in a repository advances the images of each other repository whose checkouts name it without at (advanceDependents), after the checks of rule 7 of the checkouts. The image of chatrecall.dev, which munhq/chat-recall-site builds from munhq/chat-recall, is built again when the product lands.
  • The paths of an image count the files of its checkouts at the path of each checkout (#259). The server compares the trees of the checkouts of the last build that passed with the trees of now. An image with site-src/** in its paths and the checkout {"repo": "acme/site", "path": "site-src"} builds again when a landing of acme/site changes a file.

Images with a base and no Dockerfile (#116)

An image step with base (an image pinned by its digest, registry/name@sha256:<hex>) and build (a command) has no Dockerfile and needs no BuildKit. The runner runs build in the checkout with the variables of a check (a Buck2 build takes its actions from NativeLink) and DESK_IMAGE_ROOT, a folder that build fills with the files of the image. The runner makes one layer of that folder (src/server/image-assemble.ts): a tar with the names sorted, the time 0 and the owner 0, compressed with no name and no time, so the same files give the same layer. Then it pushes with the registry API (src/server/oci.ts): the layers of the base (mounted from the repository of the base on the same registry, copied from another registry), the layer, the config of the base with the layer, a history entry, the label org.opencontainers.image.revision and the settings entrypoint, cmd, env, user and workdir, then the manifest under each tag. The digest of the manifest is the artifact of the run. target and secrets go with a Dockerfile only.

Own base images: BuildKit for one build (#116)

An image step with a Dockerfile builds an own base image (the owner's decision on #116: public bases as they are where they fit, own bases built only when their Dockerfile changes). With DESK_BASE_LANE=true on the server, its run waits in the lane base (<stream>.<repo id>.base, the consumer base-builders-<repo id>). A runner with DESK_RUNNER_LANE=base and no DESK_BUILDKIT_HOST runs buildctl-daemonless.sh: BuildKit starts for the one build and ends with it, with BUILDKITD_FLAGS=--oci-worker-no-process-sandbox. The cache of the build is in the registry (--import-cache and --export-cache type=registry,ref=<image>:buildcache,mode=max), so a base that did not change is built from the cache: on 2026-10-24 a fresh BuildKit built a Debian base with apt-get in 31 s, then the same base in 4 s from the registry cache. The pod needs the settings of rootless BuildKit (seccomp and AppArmor unconfined).

A runner of the pool asks GET /v1/runner/next?lane=runs|base|mobile|ios&waitMs=<n> for the repository of the oldest run that waits in its lane, among the repositories where it has the right run, and claims there. The server reads the waiting runs in Postgres every 0.5 s for at most 20 s (index runs_queued, migration 025_runs_queued.sql); NATS still delivers each run. Before this, a runner polled the repositories one after another, so a new run waited up to 20 s for its turn: the images of desk waited 16 s each on 2026-10-25. A server without the route answers 404, and the runner then takes the repositories in turn.

A runner of the lane base serves the repositories with base set (GET /v1/runner/repos?lane=base). When the server queues a Dockerfile image of a repository that is not in that lane, it puts the repository in the lane and gives the runners the right run (src/server/lanes.ts), so the build never waits for a lane that no runner serves. On 2026-10-25 the images of axon waited for 3 hours: its move did not set the lane.

An image step with a base gets the secrets that it names as files: the runner writes each one to a file of the run and gives build its path in DESK_BUILD_SECRET_<ID>_FILE. build gets the landed change in DESK_IMAGE_REVISION, for a binary that stamps its commit; changeArg names the variable of the image that holds it.

Deploys: the Deployments follow the pushed digests (#115)

A Deployment that follows the tag :latest needs no entry here: Keel polls the registry and rolls it. docs/deploying.md gives the two models, the order of a landing, and the commands that prove each step. The rest of this section is the digest model.

deploys in .desk/config.json lists the targets. Each entry has name, namespace, deployments (names, or withContainer with an optional except), containers (a container name and the name of an image of images) and timeoutMinutes (default 15).

  1. After each run that ends, the server looks at each target (advanceDeploys, src/server/deploys.ts). A target waits while a build or a promotion of one of its images is queued, runs or waits for a check, so one landing rolls each Deployment once.
  2. The deploy run sets each container to the newest digest that a build of its image pushed, or the digest that its promotion set (#145). It is a run of kind deploy (migration 016_deploys.sql); its run id is the target and the images, so the same digests are never deployed twice, and one deploy of a target waits or runs at a time.
  3. A deploy run waits in its own lane of the queue (<stream>.<repo id>.deploy, the consumer deployers-<repo id>). Only a runner with DESK_RUNNER_LANE=deploy takes it. That runner runs no code of the repository, so the token of its service account is never in a pod that runs a check: the sandbox of a check does not isolate files (src/server/sandbox.ts).

One deployer pool serves every repository (#179). A runner of the lane deploy with no DESK_REPOS reads GET /v1/runner/repos?lane=deploy every minute. The answer lists each repository whose config has a deploys target and where the identity of the runner has the right run, and the runner claims the deploy runs of any of them, as a runner of the lane runs or base does. The server sets repos.deploy after each landing (migration 041_deploy_lane.sql), so a repository joins the pool when its config gets a deploys target, and it leaves the pool when the config loses the targets. A runner with DESK_REPOS or DESK_REPO claims the deploy runs of those repositories only, so a deployer Deployment per repository keeps its work. 4. The runner (src/server/deploy-run.ts):

  • reads the Deployments of the namespace, and the containers whose image is not the one of the run;
  • starts one pod on each node that runs a pod of such a Deployment, with each new image and a command that does not exist: the kubelet pulls each image, the pod runs nothing, and the runner deletes it. A pull that fails changes no Deployment;
  • with canary (container, command, timeoutMinutes, default 5), starts one pod with the pod template of the first Deployment that changes, on the node of its pod and with its volumes, with only the container container on its new image and command as its command, no probe, no port, no init container, and TMPDIR in an empty folder. A pod that does not succeed in time changes no Deployment, and its last 40 log lines are in the run log. munbot runs munbot db check-migrations: the migrations of the new image on a VACUUM INTO copy of the tenant database (2026-10-23, an image without migration 0111 stopped six tenants);
  • patches each Deployment once with all its new images (application/strategic-merge-patch+json), so a Deployment that recreates its pod stops once, and not during a pull;
  • waits until each rollout has the new generation, all pods updated and available, or its time limit ends. A Deployment whose new pod is in CrashLoopBackOff fails at once; a Deployment that fails or does not end in time gets its old images back in one patch (on 2026-10-23 six tenants crashed on a new image and waited for a rollback by hand).
  1. A deploy that passed writes a row of deploys for each Deployment that it set: the change of the newest landing whose image it set, <namespace>/<Deployment>, and container=<image>@<digest>.

The service account of the deploy runner needs a Role in the namespace of the target: get, list, patch on deployments, get, list, create, delete on pods, get on pods/log, and list on events. The runner starts only with that token (KUBERNETES_SERVICE_HOST, /var/run/secrets/kubernetes.io/serviceaccount).

Publish: a bundle for Google Play (#161)

publish in .desk/config.json lists the bundles that a runner of the lane mobile builds and uploads to Google Play. Each entry names one Android application:

"publish": [{
  "name": "android",
  "platform": "android",
  "package": "com.ziggybb.app",
  "cwd": "mobile",
  "needs": ["app"],
  "build": "scripts/build-android-release.sh",
  "artifact": "android/app/build/outputs/bundle/release/app-release.aab",
  "signer": "AB:CD:…",
  "track": "internal",
  "secrets": { "PLAY_SERVICE_ACCOUNT_JSON": "play", "ANDROID_KEYSTORE_B64": "ziggybb-keystore" },
  "timeoutMinutes": 40
}]
  1. name is the name of the entry, unique among the entries. platform is android here; ios is the next section.
  2. package is the application id of Google Play. cwd is the folder of the build, and build the script in it that writes the bundle: a relative path, as artifact is. The runner runs the script in cwd, with the environment of secrets.
  3. signer is the SHA-256 of the certificate of the signing key, in the shape that keytool -printcert -jarfile prints it, with or without :.
  4. track is the track of a publish that names no other: internal, alpha, beta or production.
  5. needs names the checks of validation that must pass on the head of main first. A check of stage land cannot be in it: the landing already waited for it.
  6. secrets maps the environment variables of build to secrets of the runner, as a check on main does (#131). PLAY_SERVICE_ACCOUNT_JSON is always there: the upload reads the service account of Play from it.
  7. timeoutMinutes limits the build. It defaults to 40, which the first Gradle build of a runner needs.

A publish is a run of kind publish (migrations 035_publish.sql and 036_release_publish.sql, and src/server/publish-run.ts in the runner). It reads the whole tree of its change, so a new main is a new run: one publish of an entry on one tree and one track waits or runs at a time (a unique index). A second request for the same tree and track gets the run that waits, not a second run, so desk publish twice does not upload a versionCode twice. The notes and the rollout of a release are not part of the run id. The run waits in its own lane of the queue (<stream>.<repo id>.mobile, the consumer publishers-<repo id>), and only a runner with DESK_RUNNER_LANE=mobile takes it: that runner holds the Java and the Android SDK, and it takes a check of the lane mobile too (#164). A runner of another lane ends a publish with an error that names the lane, because it cannot build the bundle.

The runner takes these steps, and stops at the first one that fails:

  1. It runs build in cwd, with the secrets of the entry, and fails when the script ends with no 0. A build that ends with 0 and writes no artifact is a failure of the config.
  2. It reads the certificate of the bundle with keytool -printcert -jarfile. A certificate that is not the one of signer fails the publish before anything leaves the runner: a bundle of another key cannot replace the application on Play.
  3. It reads the versionCode and the versionName of the bundle with java -jar $DESK_BUNDLETOOL dump manifest --bundle <artifact> --xpath <path>, because an .aab is not an .apk, so apkanalyzer cannot read it. It fails when Play holds a release with that versionCode already, or with one above it.
  4. It records the release on the desk server (/v1/releases/<slug>), with the tag <name>-<versionName>-<versionCode> and the bundle as a file. A bundle over 32 MiB goes up as <file>.part-<n>, because one object of the store holds 32 MiB at most.
  5. It opens an edit of the application on Play (edits.insert), uploads the bundle to it, and reads the tracks. It writes the release on the track: completed, or inProgress with userFraction when the request names a rollout. It adds the notes, and it commits the edit.
    • The bytes go to the media path of Google, /upload/androidpublisher/v3/applications/<package>/edits/<id>/bundles?uploadType=media. On the path without /upload, Google reads the body as JSON and answers 400 Invalid JSON payload received. Unexpected token. PK… (#168).
    • The part of a multi-part upload is named by the store object id of its bytes, objectId("blob", bytes) in src/server/objects.ts, which is sha256("blob <len>\0" + bytes). A plain sha256 makes Google answer the bytes are not the blob …: they have another id (#167).
  6. It records where the bundle went on the release (PATCH /v1/releases/<slug>/<tag>, migration 036_release_publish.sql): the track, the versionCode, the state of the track and the edit. desk release view <tag> then prints published: <track>, versionCode <n>, <state>. The bundle is in the store at that point, so a release that refuses the record does not fail the publish: the run logs the fault.
  7. If a step of Play fails, it deletes the edit, so no half-finished edit waits on the application. A publish of another rollout than the one that waits is a second run.

The log of the run holds the output of the build, the certificate, the versionCode, and the track with its status. The values of the secrets never reach it: the runner replaces each one with [secret], as a check on main does.

Publish: an iOS app for TestFlight and App Review (#170)

An entry with "platform": "ios" builds an .ipa on a runner of the lane ios, a Mac with Xcode, and uploads it to App Store Connect. No paid build service is in the path: the runner is a Mac of the owner, and another Mac joins the lane by starting the same runner.

{
  "name": "ios",
  "platform": "ios",
  "package": "com.ziggybb.app",
  "cwd": "app",
  "needs": ["app"],
  "build": "scripts/publish-ios.sh",
  "artifact": "artifacts/ZiggyBB.ipa",
  "signer": "A698GH43QC",
  "track": "testflight",
  "secrets": { "ASC_KEY_P8": "asc-key-p8", "ASC_KEY_ID": "asc-key-id", "ASC_ISSUER_ID": "asc-issuer-id", "IOS_DIST_P12_BASE64": "ios-dist-p12", "…": "…" },
  "timeoutMinutes": 90
}
  • package is the bundle id. signer is the Apple team of the distribution certificate, ten upper case letters or digits.
  • track is testflight (upload; the build reaches TestFlight once Apple processed it) or review (upload, then submit the App Store version for App Review). A rollout is refused: App Store Connect phases a release in its own settings.
  • secrets must give ASC_KEY_P8, ASC_KEY_ID and ASC_ISSUER_ID, an App Store Connect API key with the role App Manager. The signing material of the build (the Apple Distribution .p12 and the App Store profiles) is for the script of the repository, which the entry maps too.
  • The field platform goes into the run id only for iOS, so the run ids of Android publishes are the ones of #161.

The run waits in the lane ios (<stream>.<repo id>.ios, the consumer ios-publishers-<repo id>); only a runner with DESK_RUNNER_LANE=ios takes it. That runner takes a check of the lane ios too (#164). src/server/ios-publish-run.ts takes these steps and stops at the first one that fails:

  1. It runs build in cwd with the secrets, and the script writes artifact.
  2. It unpacks the .ipa and reads the Info.plist with plutil: the bundle id must be package. A missing ITSAppUsesNonExemptEncryption is noted in the log, because App Store Connect then holds the build for the question of export compliance.
  3. It reads codesign -dvv of the app and of each .appex: the team must be signer, and the authority an Apple Distribution certificate.
  4. It asks App Store Connect for the app of the bundle id and its builds: the build must be above the greatest one, since Apple refuses a build number twice and only after the upload. All the calls carry an ES256 JWT of the key, valid for 20 minutes.
  5. It records the release ios-<version>-<build> with the .ipa, as for Android.
  6. It uploads with xcrun altool --upload-package <ipa> --api-key --api-issuer --p8-file-path; the .p8 is in a file of the run that the run removes, pass or fail. Then it reads the build every 30 s, for at most 45 minutes, until Apple has processed it (VALID); INVALID or FAILED fails the run.
  7. testflight: the notes become the "What to Test" of the build (en-US). review: the App Store version of the version string (made when the app has none) must be in PREPARE_FOR_SUBMISSION, DEVELOPER_REJECTED, REJECTED, METADATA_REJECTED or INVALID_BINARY; it gets the build and the notes as "What's New" in each language, and goes into the open review submission of the app, or a new one, which is submitted. A version that waits for review or is on sale fails the run with that state: a submission then needs a new version.
  8. It records on the release the track, the build number as versionCode, the build id of App Store Connect as edit, and completed (TestFlight) or submitted (App Review).

Releases: a new version is tagged after its checks

release in .desk/config.json makes the server record the release of a landing whose version is new:

"release": { "versionFile": "packages/cli/package.json", "tagPrefix": "v", "needs": ["unit"] }
  1. versionFile is a package.json (its version), a Cargo.toml (the version of [package]) or a text file that holds only the version.
  2. tagPrefix defaults to v. needs defaults to every check of validation that runs on main.
  3. After each landing and after each run that ends, advanceRelease (src/server/auto-release.ts) reads the version at the head of main. When no release has the tag, and each check of needs passed on that landing, it records the release with the section ## [<version>] of CHANGELOG.md as its notes. The author is desk.
  4. The release takes as its files the artifacts of the runs of the checks of needs that passed on that landing (#162), so the binaries that a check built are the files of the release. Two checks may give the same file. Two different files with one name are a fault of the config: the server log names it, and the release takes the file of the first check in needs. A check of needs that the landing did not run (its paths matched no change) gives no file.
  5. The mirror pushes the tag to the copy at its next round. A repository that publishes from GitHub workflows on a tag (desk repo move --keep-actions) releases with no step of a person.

For example, munhq/sealkeep tags its version of Cargo.toml once its checks passed, with the binaries of release-macos:

"release": { "versionFile": "Cargo.toml", "tagPrefix": "v", "needs": ["fmt", "clippy", "test", "release-macos"] }

A landing with the same version records nothing, and a check that failed blocks the release of that landing. test/server-auto-release.test.mjs covers the config, the version files, the notes and the landings, and test/server-artifacts.test.mjs the files of the checks.

The runner

Four images run a runner. ghcr.io/munhq/desk-runner-base (the stage runner of the Dockerfile) has Node, git, Buck2 and buildctl, and it runs the checks of the repositories that need nothing else. ghcr.io/munhq/desk-runner-mobile is the app layer over ghcr.io/munhq/desk-runner-mobile-base. ghcr.io/munhq/desk-server (the stage runtime) also runs the runner, because the Deployments desk-deployer-* start it from that image (#189). ghcr.io/munhq/desk-runner-rust (the stage runtime-rust, on Debian trixie for the Python 3.12 of the Buck2 prelude) adds gcc, g++, lld, python3 and the Rust toolchain of munbot (nightly-2026-10-23, rustc 1.101.0-nightly (7189d39d9 2026-10-22)), installed with a rustup that is checked by its hash. A repository with another toolchain sets the build argument RUST_TOOLCHAIN. The check of munbot passed in it on 2026-10-23: cold, with no cache, 6 min 44 s for 3,234 actions.

desk runner <server> [<owner/repo> ...] [--lane NAME] [--token-env NAME] [--dir DIR] [--once] and node dist/server/runner-main.js (the pod, with the variables below) take a step, write its tree into an empty folder, run the command with sh -c in that folder, and report the exit code, the time and the log. The same program runs as a pod on hotmun and on any other machine with Node 20 or later, started on demand (decision of the owner, 2026-10-17).

A runner of an org (#171)

An admin of an org adds a runner with one command, and needs no server admin:

desk runner add mac-runner --org acme

The command makes an agent identity with the role runner in the org (POST /v1/orgs/<org>/runners). It keeps the token in sealkeep under personal/desk/<server>/runners/<name>/DESK_TOKEN, or under the name that --secret gives. A name that exists gets 409. desk runner remove mac-runner --org acme removes the runner, and its tokens and keys stop. The command prints the line that starts the runner, and it never prints the token:

DESK_RUNNER_LANE=runs sealkeep run personal/desk/<server>/runners/mac-runner/DESK_TOKEN -- desk runner <server> acme/example-app --token-env DESK_TOKEN

--lane sets the lane (default runs). A lost token comes from POST /v1/orgs/<org>/runners/<name>/token, which stops the old tokens of the runner.

The runner of the lane mobile (#161) publishes an Android bundle, so its image holds the tools of that build: ghcr.io/munhq/desk-runner-mobile (the app layer over ghcr.io/munhq/desk-runner-mobile-base) adds the Eclipse Temurin JDK 21 (/opt/java, the java and the keytool of a publish), the Android SDK command line tools with platform-tools, platforms;android-35 and build-tools;35.0.0 (/opt/android-sdk, on PATH with apksigner and zipalign), and bundletool 1.18.3 at /opt/bundletool/bundletool.jar (DESK_BUNDLETOOL), because the version of an .aab is in the manifest of the archive and apkanalyzer reads only an .apk. Each download is pinned by its hash in docker/base/runner-mobile.Dockerfile. The deployment starts it with DESK_RUNNER_LANE=mobile, and it claims a publish and a check of the lane mobile.

The pool of hotmun has a floor of 3 runners and a ceiling of 6. KEDA reads the gauge desk_runs of /metrics every 15 s and counts the runs of the lane runs that wait or run. It holds one runner for each of them, so the pool stays at its floor while the repositories are quiet and grows when landings overlap (charts/desk/templates/runner-scaledobject.yaml of munhq/k3s-gpu, munhq/desk#155). A runner that gets SIGTERM takes no new run and finishes the one that it holds, so a scale-down does not end a run.

What each pod holds, and what a step costs (#195)

The owner asked to see the runners, what they run and what they take, so that we can improve it constantly, and to know why a step of a repository with a cache takes a minute. The name of a runner is the identity that it signed in with, and the pool of hotmun has nine pods on one identity, so a list by name showed one row. The view is now by pod.

The runner sends a sample to POST /v1/runner/sample every 15 s. The sample names the pod (DESK_RUNNER_POD, or the host name, which is the pod name in a cluster), the lane, the state (idle or running), the run that the pod holds, and the counters of the cgroup of the pod: usage_usec of /sys/fs/cgroup/cpu.stat and the bytes of /sys/fs/cgroup/memory.current. The server keeps the samples in the table runner_samples (migration 045_runner_samples.sql), and a runner deletes the rows older than 7 days, at most once an hour. A machine without cgroup v2, such as a Mac, sends no counter, and the cost of its runs stays empty instead of wrong.

The claim records the wait of the run in queueWaitMs, from created_at to the claim. The end of the run records cpuSeconds and peakMemoryBytes. The CPU seconds are the difference of usage_usec between the start and the end of the run. The peak memory is the largest memory.current that the samples of the run saw, not memory.peak of the cgroup, because memory.peak covers the whole life of the pod and would name an earlier run. desk runs view <id> shows the three fields.

desk runner list [--org <org>] prints one row for each pod: its pod, its lane, its state (idle, running or gone), the run that it holds (repository, step and age), its share of the time that it was busy over 1 h and over 24 h, the CPU time and the memory of its cgroup, and the age of its last sample. A pod with no sample for 60 s is gone: it stopped, or its image changed.

A runner that a desk version from before the samples started (a service on a Mac that runs for weeks, for example) sends no sample. Each poll of GET /v1/runner/next writes the table runner_polled (migration 064_runner_polled.sql: the identity, the lane, the host of x-desk-host and the time, at most one write in 10 s). For a row with no sample, the list takes the last poll: the runner is idle while it polls, and gone 60 s after its last poll. Before this, such a runner showed gone with the age of its last claim, for days, while it polled every 20 s (the ios runner of munhq, 2026-11-20).

Before you say that a runner is offline, read two facts. desk runner list says gone only when the server got no sample and no poll for 60 s. To see the side of the runner, run desk runner service status <name> on its machine: it prints whether the service is loaded and running, and the last 5 lines of its log. An idle runner writes no log line, so a quiet log is no fault.

desk runner stats [--org <org>] [--days n] [--repo <owner/repo>] [--sort time|cpu|memory|wait] ranks the finished steps of the org over n days (1 by default, at most 90) by their total time, their CPU seconds, their peak memory or their queue wait. It prints the count, the total, the average and the three costs of each step, and --json prints the rows. GET /v1/orgs/<org>/runners answers the pods, and GET /v1/orgs/<org>/runners/stats?days=1&sort=cpu&repo=<owner/repo> answers the ranking; the page of the org shows the same table. The MCP endpoint of desk answers the same rows with the tools runner_list and runner_stats, which take the org, the window of days, the repository and the cost that orders the ranking.

A network fault, and a stop of a runner (#188)

A runner retries every call to the server when the call fails with a fault of the network: a connection reset, a fetch failed, or a 502, a 503 or a 504. The runner waits 1 s, then doubles the wait up to 15 s, and it gives up after 90 s. A 4xx answer retries nothing. A check that fails retries nothing either: only a fault of the network or of the server retries. A run that still cannot load its tree after the retries ends as error with the last cause, and the server queues it again.

A SIGTERM stops the claim of new runs, and the runner lets the run in progress finish, for DESK_RUNNER_DRAIN_MS at most (600 s by default). Then the runner exits with the code 0. A second signal, or the end of the limit, ends the run at once: the runner reports the run as error, so the server starts it again, and the runner exits with the code 75. A claimed run that a stop ends before it starts is reported as error too, so the server starts it again.

Variable Use
DESK_SERVER The address of the server. Required.
DESK_REPOS The repositories, owner/repo, separated by commas. The runners of hotmun are one shared pool: each runner claims from each repository in turn, and each claim waits its share of DESK_RUNNER_WAIT_MS (at least 2 s), so a step of any repository is taken within about one wait. The identity of the runner needs the right run on each repository.
DESK_REPO One repository, owner/repo. With neither DESK_REPOS nor DESK_REPO, a runner of any lane reads the repositories of its lane from the server every minute (GET /v1/runner/repos, #125), so a moved repository needs no change of the deployment. The lane deploy lists each repository whose config has deploys, so one deployer pool serves them all (#179).
DESK_RUNNER_TOKEN The token of an identity with the right run. Required.
DESK_RUNNER_DIR The folder of the scratch folders of the runs. Required.
DESK_RUNNER_WAIT_MS How long one claim waits on the server; default and most 20000.
DESK_RUNNER_DRAIN_MS How long a stop waits for the run in progress; default 600000 (600 s). Set it below terminationGracePeriodSeconds of the pod. A stop that takes longer than the limit ends the run as an error (#188).
DESK_RUNNER_LOG_BYTES The largest log of a run; default 2 MiB.
DESK_RUNNER_CACHE The remote cache of the build, grpc://host:port (NativeLink); each step gets it as DESK_CACHE_ADDRESS. desk runner --cache sets it.
DESK_RUNNER_LANE runs (default), deploy, base, mobile or ios. A deploy runner takes only the deploy runs (#115) and needs the service account token of its pod. With no DESK_REPOS, it serves every repository whose config has deploys (#179). A base runner builds the base images of the lane base. A mobile runner takes the publishes of the lane mobile (#161) and the checks of that lane, and holds the Java and the Android SDK. An ios runner (#170) runs on a Mac with Xcode and takes the iOS publishes and the checks of the lane ios. A runner of another lane ends a publish with an error that names its lane.

Before the command, the runner writes the code tree of the run into an empty checkout. The objects of the tree stay in a cache on the volume of the runner (objects/, at most 4 GiB; src/server/object-cache.ts): an object id is the SHA-256 of its bytes, so the runner checks each object that it reads, and fetches only the objects that the cache does not hold, 16 at a time. Without the cache, the 2,047 files of munbot took 26 s of each run.

A command that exits with 75 (EX_TEMPFAIL) reports that its infrastructure failed, not the code that it checks: the run ends as an error, and a bisect stops at it and reverts nothing, as it does for a time limit. The check of munbot exits with 75 when Buck2 reports an infrastructure error (exit 2), for example a remote cache that does not answer; a compile error (exit 3) or a failed test (exit 32) stays a failure.

The sandbox (src/server/sandbox.ts) is the process level only: the command runs in its own process group, a time limit or a log limit kills the group, and the command gets only PATH, HOME, TMPDIR, DESK_ACTION_TMP, LANG, CI, the npm cache and the toolchain folders of the image (RUSTUP_HOME, CARGO_HOME). A command with a new HOME and no RUSTUP_HOME made rustup install the toolchain of the repository again in each run. It does not isolate the network or the file system outside the scratch folder. A runner runs only the code of a repository that the owner trusts.

Every run gets its own tmp folder in the scratch folder of the run, and TMPDIR and DESK_ACTION_TMP point into it: a check, an image build and a publish. The scripts of a repository must write their temporary files there, in ${DESK_ACTION_TMP:-${TMPDIR:-/tmp}}, and never to /tmp. The pod of a runner has a small /tmp, and image builds of munhq/chat-recall filled it: on 2026-12-05 the pods were evicted 17 times in 16 h with emptydirfs.limit (#271). The tmp folder of a check stays at the volume of the runner until the next check of the same repository clears it, and the files of one check never count against the next check.

A service of the OS: a machine that stays a node (#176)

desk runner add mac-runner --org acme --service makes the runner and then installs it as a service of this machine. The service starts when the machine starts. It starts the runner again when the runner stops. It starts desk runner under sealkeep run, so the token stays in the keyring of sealkeep and never enters a file.

  1. desk runner service install <name> --lane <lane> (--org <org> | --repos <a,b>) [--secret <name>] [--server <url>] writes the file of the service and loads it.
  2. desk runner service status <name> prints whether the service is loaded and running, and the last 5 lines of its log.
  3. desk runner service uninstall <name> stops the service and removes the file.
  4. desk runner list [--org <org>] lists one row for each pod of the org, with its lane, its state, the run that it holds, its busy share, its CPU time, its memory and the age of its last sample (#195).

Both views take the org of the work folder when --org is absent, so a session that works in a work folder runs desk runner list and desk runner stats --days 1 as they are.

On macOS the file is ~/Library/LaunchAgents/com.munhq.desk-runner.<name>.plist, launchctl bootstrap gui/<uid> loads it, and the log is ~/Library/Logs/desk-runner-<name>.log. On Linux the file is ~/.config/systemd/user/desk-runner-<name>.service, systemctl --user enable --now starts it, and the log is ~/.local/state/desk-runner-<name>/runner.log. The server records the host, the lane and the time of each claim in runner_seen, so desk runner list shows the last claim of each runner.

The service serves the lane that it names. A service with --org and no --repos asks the server for the repositories of the org that its identity can run, so a new repository of the org needs no change of the service. A service of the lane ios runs on a Mac with Xcode: it takes the iOS publishes and the checks of lane: "ios" (#164). The steps of a Mac are in docs/mac.md.

The run history in ClickHouse (#65)

Postgres keeps the record of a run while it waits and runs. When a run ends, the server writes its history to ClickHouse every 10 seconds (src/server/run-history.ts) and marks the run with history_at. A ClickHouse that does not answer stops neither the server nor the runs: the pass is in the log, and the next pass tries again. The tables are ReplacingMergeTree on their sorting key, so a row that a pass writes twice stays one row (read with FINAL).

Table One row for Columns
steps each run that ended: a check, a bisect run, an image build, a promotion or a deploy the repository, the run, the name, the kind, the status and the reason, the exit code, the runner, the landing (seq, change) and whether it was a bisect run, the times of the queue, the start and the end, and wait_ms
tests each test that a step reported the run, the step, the test, the status, the time, and whether the cache gave it
runs each landing whose checks all ended: the checks of a landing as one run the landing, the count of checks and of failed checks, the status, and the time from the first queue to the last end

A step reports its tests in the file DESK_TEST_REPORT that the runner gives it: one JSON object for each line, {"test", "status", "durationMs", "cached"}, the status passed, failed or skipped. The runner sends at most 20,000 tests, and names in the log the lines that are not a test. Postgres holds them in runs.tests until they are in ClickHouse. The check of desk writes one line for each Buck2 test action, from buck2 log what-ran (scripts/test-report.mjs): failed when what-ran --failed lists it, cached when the executor is Cache.

The cache of a step is NativeLink (#97): the key of an action is the hash of its command, its environment (with the versions of the tools) and its declared inputs.

The tables are made at the start of the server, ON CLUSTER of DESK_HISTORY_CLUSTER on the storage policy of DESK_HISTORY_STORAGE_POLICY. On hotmun the policy hot_cold of the cluster has the volume hot on the local disk and the volume cold on the S3 disk (the prefix tiered/ of the bucket hotmun-gra1-clickhouse-cold). The TTL of each table follows the settings at each start:

  • DESK_HISTORY_HOT_DAYS: a part moves to the volume cold after these days (TTL toDateTime(finished_at) + INTERVAL <n> DAY TO VOLUME 'cold'). The table stays one table, and a query reads both volumes.
  • DESK_HISTORY_RETENTION_DAYS: a row is deleted after these days (… DELETE). 0, the default, deletes nothing, as git keeps its history (the owner, 2026-10-17).

A part on the S3 volume is not a backup, because a dropped table removes its parts. The backup of the cluster runs every day to the bucket hotmun-gra1-clickhouse-backups (clickhouse-backup, chart clickhouse of munhq/k3s-gpu); it holds the database desk with the others.

scripts/test-run-history.sh runs test/server-run-history.test.mjs against ClickHouse 26.8.27.9 in Docker, the version of hotmun, with a policy hot_cold of two local disks.

The guard of a landing (#206)

A landing must not weaken the checks that judge it. The server compares the tree of the change with the tree of main, and it reports a weak spot of five kinds:

  1. The change removes a check of validation.
  2. The change narrows the paths of a check, so the check runs on fewer files.
  3. The change deletes a test file, or it adds a skip marker to a test.
  4. The change removes an assertion from a test file.
  5. The change moves a line of a ledger in the wrong direction, or it removes a ledger.

A ledger is an entry of land.ledgers in .desk/config.json: {"paths": [globs], "only": "remove" | "add", "match": "<regex>", "why": "<text>"}. With only: "remove", an added line is a weak spot: a list of known faults, of exceptions or of tools can only get shorter. With only: "add", a removed line is a weak spot: a list of rules or of deployed binaries can only get longer. match keeps the lines that it matches (for example rules: allow R\d in **/*.rs); without it, every line that is not empty and does not start with # counts. The guard reads the ledgers and land.tests from the config of main, so a change cannot drop the ledger that judges it, and a dropped ledger is a weak spot of its own. land.tests replaces the globs of the test files whose skip markers and assertions the guard counts: a Rust repository keeps its tests in the #[cfg(test)] modules of its source files.

The setting land.weakening of .desk/config.json decides the result. A repository can replace the setting with POST /v1/repos/<slug>/settings ({"land": {"weakening": "hold"}}), with desk repo lanes --weakening hold, with the MCP tool land_weakening, or from the config tab of the workspace.

Value Result
off The landing continues. The report says nothing about the weak spot.
warn The landing continues. The report names each weak spot. This is the default.
hold The landing stops. The server writes a question in the "Questions for the owner" section of the issue of the change. The owner approves or refuses the question on the decisions page, or in a chat: there the agent records the answer with desk approve --issue <n> --change <id> [--refuse]. Then the author runs desk land again.

The guard runs before the tree of the change reaches main. A landing in the hold mode therefore leaves main as it was. desk land prints Not landed: the change <id> weakens the checks that judge it, each weak spot, and the issue that holds the question.

After a landing, the checks that run on main are the union of the checks of the landed tree and the checks of main. A check that the change removes therefore still runs on the landing that removed it.

The "Done when" lines of an issue are locked while the loop of the issue is active. If an agent changes one of those lines, the server keeps the lines and writes a question for the owner. An agent cannot mark its own work done.

A verdict on a line of the loop does not tick the line when its evidence names a run that did not pass. The checker of a loop must be of another model family than the worker, and desk loop set --checker-model refuses a checker of the family of the worker.

An answer in a chat: desk approve

The owner can answer the question of a held landing in the chat with the agent (munhq/arb#23). desk approve --issue <n> --change <id> writes the same decision comment as the decisions page, and quotes the answer with its time and session. It refuses when no answer of the owner on this machine names the change: the answer of a question dialog of the agent (AskUserQuestion) whose question holds the first 12 characters of the change id and whose answer starts with "Approve" or "yes" (or "Refuse" or "no" with --refuse), or a typed prompt that holds those 12 characters and the word. The client writes the result of a question dialog, so an agent cannot make one; the same text in the result of another tool does not count.

When the owner answered in the chat and did not name the change, the agent quotes the owner's words: desk approve --issue <n> --change <id> --said "<the exact words>" [--refuse] (MCP tool approve, field said). desk checks that the owner typed those words, at least 12 characters, in a prompt on this machine in the last 24 hours. Text that the owner pasted from another place and an instruction file do not count. The decision comment shows the quote, so the owner can read what an agent recorded. The agent chooses which held change the words answer, and the quote is the record of that choice. desk land on a held change prints both steps: record an answer that exists, or ask one question in the chat and work on the next item. The owner never needs the decisions page.

Cancel your own held change: desk withdraw

An agent replaces its drafts, and an old draft that the guard holds stays held. The owner is not asked about it. The author runs desk withdraw [--change <the 64 hex characters>] (MCP tool withdraw; route POST /v1/code/<owner>/<repo>/withdraw with {"change"}; the right write). Without --change it takes the last change of the work folder. The server accepts only the author of the change. It closes the hold as a refusal (answer_by is <author> (withdrawn)) and writes a closing comment with the pick B and the heading "Decision of the owner () (withdrawn by the author)", so the question leaves the list of the owner. A change that never lands weakens nothing, so no answer of the owner is needed. A change with no pending hold answers {"withdrawn": false}.

The server settings

Variable Use
DESK_RUNNER_TOKEN The token of the runners of the cluster (Vault managed/desk/runner). The server keeps the identity desk-runner on it; a new token replaces the old one.
DESK_RUNNER_REPOS The repositories of those runners, owner/repo separated by commas. desk-runner gets the right run on each that exists; the log names a missing one. This is a transition path from the per-repo model.
DESK_RUNNER_ORGS The orgs those runners serve, separated by commas (#158). The server makes each org when it is missing and adds desk-runner as a runner member, so it has run on every repository of the org, also one made later, with no per-repo grant. An existing member or admin role of desk-runner is never downgraded.
NATS_URL The NATS of the queue with its login, nats://user:pass@host:4222; the Secret desk-nats of the platform-data registry gives it. Without it the queue is in memory.
DESK_NATS_STREAM The stream; default DESK_RUNS.
DESK_NATS_REPLICAS The replicas of the stream, 1 to 5; default 1.
CLICKHOUSE_URL, CLICKHOUSE_USER, CLICKHOUSE_PASSWORD, CLICKHOUSE_DATABASE The ClickHouse of the run history; the Secret desk-clickhouse of the registry gives them. Without CLICKHOUSE_URL the history stays in Postgres.
DESK_HISTORY_CLUSTER, DESK_HISTORY_STORAGE_POLICY The cluster of the replicated tables and their storage policy (main and hot_cold on hotmun).
DESK_HISTORY_HOT_DAYS, DESK_HISTORY_RETENTION_DAYS The days before a part moves to the volume cold, and before a row is deleted; 0 is no rule.

Tests

The lost runs (#149) are in test/server-runs.test.mjs: a run whose heartbeat stopped ends as lost, a running run that passed its time limit and its grace ends as lost, and a heartbeat moves the time that the sweep reads. test/server-images.test.mjs has a build whose runner is lost ends as lost, and the build of the head of main starts at once.

test/server-runs.test.mjs runs the routes and the runner against PGlite and the memory queue: the run id, the needs, a step that runs again after it passed, two runners on one step, a step that comes back after the ack wait, a second message of a run, the publish again at a start, a refused publish, the end after three attempts, a claim that waits for a step, the rights, the outcomes of the runner (pass, fail, timeout, output limit, a link out of the checkout), a change that lands and runs node --test on its tree, the checks that a landing queues from .desk/config.json (only for changed paths, with the whole tree as input), one refused check among others, a bad config, the right merge for a step, the identity desk-runner, a restart with the memory queue, and desk runner --once. With DESK_TEST_NATS_URL set, one more test runs the claim, the heartbeats, the return of a step of a silent runner and the acknowledgement on a real NATS JetStream; on 2026-10-17 it passed on nats:2.15.0-alpine, the version of hotmun.