Build coordinator: CI runs once per HANDOFF round and once per landing batch, dispatched by a queue paced to runner capacity #258

Open
opened 2026-11-26 10:37:30 +00:00 by saturnus · 1 comment
Member

Purpose (cost): CI runs once per HANDOFF round and once per landing batch, never twice on the same workflow and tree, and never more at once than the runners can take. Today a push is a run: ~5,375 jobs and ~105 runner-h a day (forge-setup#75).

Decision: DECIDED 2026-11-26 "Build coordinator" (Raf's lean-CI menu, via the Supervisor; placed by Mars). It replaces macula-io/macula-sponsors#85: once a push starts no run, there is nothing to count per push. It sits in the lift order of the lean-CI design (step 3), beside DECIDED 2026-11-26 "M2: path-filtered".

Design r2 (r1 FAIL by Mars on fable: F1-F4 and notes N5-N14 folded; the change list is in the r2 comment)

1. Triggers. Every crew workflow triggers on workflow_dispatch and on push to main, and on nothing else. With pull_request gone, a push to a member branch starts nothing.

  • Dispatch inputs (F1). base (40 hex: the PR's base sha) and pr (its number). The range jobs read inputs.base on a dispatch and github.event.before on a push: ci.yml:871, 948-949, 1058-1059 and 1174-1175 are "no test the base passed goes missing", "pictures change only with the version", "nothing private" and the literal check. So a dispatched run judges the same range a PR run did. Dispatched run 4499 showed that without it they fail, skip or pass vacuously.
  • No path filter on push to main (F2). The landing run carries everything, the heavy three included, as M2 says.
  • The PR-side heavy path list (F2). It lives in one file in each repo that has one, .forgejo/heavy_paths.txt. The coordinator dispatches heavy.yml for a round only when git diff --name-only base..tip hits it.
  • One trigger PR per repo. Each also teaches judge_the_checks.ts (:9, :89) the dispatch shape (N13).

2. Requests. The mod writes one request per HANDOFF to the coordinator's spool on host00, one file per request (the lander-spool pattern):
<org/repo> pr=<n> <branch> <base40>..<tip40> <package> r=<N>
A landing needs no request. A batch is one push of N merges to main (N14), and that push is its one run.

3. The queue script (src/dispatch_a_round_of_ci/, beside the land script). A user timer on host00 starts it as a oneshot service, about every minute (N8). Per request:

  • Check. The repo is on the allowlist. The shas are 40 hex. The PR exists, and its branch head equals the tip. If the head is not the tip yet, the request is kept up to 5 ticks; after that it is dropped with the reason on the PR (N7). A request whose PR does not exist is dropped, with a comment on the package's issue for the dispatcher (N7).
  • Never twice (F3, N6). The key is (workflow file, tip^{tree}). A FINISHED, non-cancelled run of that workflow on a commit with that tree settles the request, green or red. The coordinator comments that run's id on the PR and dispatches nothing. A red is not redispatched on a re-sent HANDOFF: the flake rule stands (one job rerun, by the lander). A RUNNING run keeps the request waiting, because a concurrency group can still cancel it (ci.yml:37-39). A cancelled run settles nothing.
  • Paced. It dispatches only while the waiting plus running jobs on the target runner label stay under that label's capacity. Otherwise the request waits, first in first out.
  • Dispatch. POST /repos/{o}/{r}/actions/workflows/{file}/dispatches with ref=<branch> and inputs={base, pr}. Then it reads the run back by head_sha. If the branch moved in between, the run is not this round's: it says so on the PR and does not redispatch.
  • The PR comment is the mechanism (N5). A dispatched run's commit status does not show on the PR (8f43cb5d: 87 statuses, all pull_request). So the coordinator comments the run id on the PR. The readers already go by the runs API (skipped_ci_jobs.ts:41,49, handoff_commits.ts:199). The HANDOFF goes before the run exists and carries the ci= form for owed CI; the VERDICT names the run.
  • Config (N11). The capacity file (one line per label, e.g. martha-bwrap 1) and the allowlist live on host00 beside the token, in the coordinator user's config directory, not in martha's tree.

4. The landing skip reads a dispatched run (F4). crew-code/core/skip_ci_on_landing.ts:211 turns the landing skip off for any workflow that triggers on push without pull_request. After the trigger PRs that is every repo. The reader now accepts a green, finished, dispatched run on the PR tip as that tip's evidence, so "a land whose tree equals a green PR tip runs nothing on main" still holds. martha keeps it off under M2, as the lean-CI design says.

5. Owner. The lander owns it: Terra, Pluto as backup, Pallas during the cooldown. Their jobs are to start and stop the timer, edit capacity and the allowlist, and drain or clear a stuck request. The coordinator never reruns.

6. Threat model. The coordinator holds a forge token, and a token that can dispatch can also write to the repo. Forgejo has no dispatch-only scope.

  • The token is a dedicated bot account's (ci-dispatch), with write only on the allowlisted repos.
  • Its file is mode 0600 under host00's coordinator user, outside every repo and session dir. It is read by path, never through the environment.
  • Protected main (landers only) means it cannot land code. Release tags (v*, installer-v*, which release.yml and installer.yml publish from) get the same tag protection, to the landers (N9). That forge setting goes in the cred menu with the bot.
  • The script calls four endpoints (PR, branch head, dispatch, runs) plus the PR comment. It passes no request text to a shell, and it checks every field against a pattern before use.
  • The spool is writable by crew sessions only, and the crew is trusted. An outsider needs host00 or a member session first, and then has more than this token.
  • The harm left over is a forged request running CI on an existing branch. That costs runner minutes, and the capacity cap bounds it.

7. Order and rollout (N13).

  1. The coordinator and the mod line land first: the mod's HANDOFF-to-spool line, and the landing-skip reader (§4).
  2. Then each repo's trigger PR, with its allowlist entry, one repo at a time in the lift order, martha first, each with one proving run.
  3. Proof on martha:
    • two HANDOFFs of one tip give one run;
    • a branch push gives none;
    • a full label holds a request until it frees up;
    • the range jobs on the dispatched run judge inputs.base..tip, not an empty base.
  4. The mod change installs canary-first: one session, and the proof is its request line plus the one run.

Pieces

  1. src/dispatch_a_round_of_ci/: script, oneshot unit and timer. It gets a C4 box and a README row.
  2. crew-code (macula-sponsors):
    • the HANDOFF writes the spool line;
    • skip_ci_on_landing.ts reads a dispatched run.
    • The HANDOFF/VERDICT tip marks in #85's branch saturnus/85-push-round are reused where they fit.
  3. One trigger PR per repo: dispatch inputs, the range jobs reading inputs.base, heavy_paths.txt where there is a heavy.yml, and judge_the_checks.ts.
  4. The cred step, in one menu with the first land: the ci-dispatch bot, its token, and tag protection to the landers.

Refs forge-setup#75, macula-io/macula-sponsors#85

Purpose (cost): CI runs once per HANDOFF round and once per landing batch, never twice on the same workflow and tree, and never more at once than the runners can take. Today a push is a run: ~5,375 jobs and ~105 runner-h a day (forge-setup#75). Decision: DECIDED 2026-11-26 "Build coordinator" (Raf's lean-CI menu, via the Supervisor; placed by Mars). It replaces macula-io/macula-sponsors#85: once a push starts no run, there is nothing to count per push. It sits in the lift order of the lean-CI design (step 3), beside DECIDED 2026-11-26 "M2: path-filtered". ## Design r2 (r1 FAIL by Mars on fable: F1-F4 and notes N5-N14 folded; the change list is in the r2 comment) **1. Triggers.** Every crew workflow triggers on `workflow_dispatch` and on `push` to `main`, and on nothing else. With `pull_request` gone, a push to a member branch starts nothing. - **Dispatch inputs (F1).** `base` (40 hex: the PR's base sha) and `pr` (its number). The range jobs read `inputs.base` on a dispatch and `github.event.before` on a push: ci.yml:871, 948-949, 1058-1059 and 1174-1175 are "no test the base passed goes missing", "pictures change only with the version", "nothing private" and the literal check. So a dispatched run judges the same range a PR run did. Dispatched run 4499 showed that without it they fail, skip or pass vacuously. - **No path filter on push to main (F2).** The landing run carries everything, the heavy three included, as M2 says. - **The PR-side heavy path list (F2).** It lives in one file in each repo that has one, `.forgejo/heavy_paths.txt`. The coordinator dispatches heavy.yml for a round only when `git diff --name-only base..tip` hits it. - **One trigger PR per repo.** Each also teaches `judge_the_checks.ts` (:9, :89) the dispatch shape (N13). **2. Requests.** The mod writes one request per HANDOFF to the coordinator's spool on host00, one file per request (the lander-spool pattern): `<org/repo> pr=<n> <branch> <base40>..<tip40> <package> r=<N>` A landing needs no request. A batch is one push of N merges to main (N14), and that push is its one run. **3. The queue script** (`src/dispatch_a_round_of_ci/`, beside the land script). A user timer on host00 starts it as a oneshot service, about every minute (N8). Per request: - **Check.** The repo is on the allowlist. The shas are 40 hex. The PR exists, and its branch head equals the tip. If the head is not the tip yet, the request is kept up to 5 ticks; after that it is dropped with the reason on the PR (N7). A request whose PR does not exist is dropped, with a comment on the package's issue for the dispatcher (N7). - **Never twice (F3, N6).** The key is (workflow file, `tip^{tree}`). A FINISHED, non-cancelled run of that workflow on a commit with that tree settles the request, green or red. The coordinator comments that run's id on the PR and dispatches nothing. A red is not redispatched on a re-sent HANDOFF: the flake rule stands (one job rerun, by the lander). A RUNNING run keeps the request waiting, because a concurrency group can still cancel it (ci.yml:37-39). A cancelled run settles nothing. - **Paced.** It dispatches only while the waiting plus running jobs on the target runner label stay under that label's capacity. Otherwise the request waits, first in first out. - **Dispatch.** `POST /repos/{o}/{r}/actions/workflows/{file}/dispatches` with `ref=<branch>` and `inputs={base, pr}`. Then it reads the run back by `head_sha`. If the branch moved in between, the run is not this round's: it says so on the PR and does not redispatch. - **The PR comment is the mechanism (N5).** A dispatched run's commit status does not show on the PR (8f43cb5d: 87 statuses, all pull_request). So the coordinator comments the run id on the PR. The readers already go by the runs API (skipped_ci_jobs.ts:41,49, handoff_commits.ts:199). The HANDOFF goes before the run exists and carries the `ci=` form for owed CI; the VERDICT names the run. - **Config (N11).** The capacity file (one line per label, e.g. `martha-bwrap 1`) and the allowlist live on host00 beside the token, in the coordinator user's config directory, not in martha's tree. **4. The landing skip reads a dispatched run (F4).** `crew-code/core/skip_ci_on_landing.ts:211` turns the landing skip off for any workflow that triggers on push without pull_request. After the trigger PRs that is every repo. The reader now accepts a green, finished, dispatched run on the PR tip as that tip's evidence, so "a land whose tree equals a green PR tip runs nothing on main" still holds. martha keeps it off under M2, as the lean-CI design says. **5. Owner.** The lander owns it: Terra, Pluto as backup, Pallas during the cooldown. Their jobs are to start and stop the timer, edit capacity and the allowlist, and drain or clear a stuck request. The coordinator never reruns. **6. Threat model.** The coordinator holds a forge token, and a token that can dispatch can also write to the repo. Forgejo has no dispatch-only scope. - The token is a dedicated bot account's (`ci-dispatch`), with write only on the allowlisted repos. - Its file is mode 0600 under host00's coordinator user, outside every repo and session dir. It is read by path, never through the environment. - Protected `main` (landers only) means it cannot land code. Release tags (`v*`, `installer-v*`, which release.yml and installer.yml publish from) get the same tag protection, to the landers (N9). That forge setting goes in the cred menu with the bot. - The script calls four endpoints (PR, branch head, dispatch, runs) plus the PR comment. It passes no request text to a shell, and it checks every field against a pattern before use. - The spool is writable by crew sessions only, and the crew is trusted. An outsider needs host00 or a member session first, and then has more than this token. - The harm left over is a forged request running CI on an existing branch. That costs runner minutes, and the capacity cap bounds it. **7. Order and rollout (N13).** 1. The coordinator and the mod line land first: the mod's HANDOFF-to-spool line, and the landing-skip reader (§4). 2. Then each repo's trigger PR, with its allowlist entry, one repo at a time in the lift order, martha first, each with one proving run. 3. Proof on martha: - two HANDOFFs of one tip give one run; - a branch push gives none; - a full label holds a request until it frees up; - the range jobs on the dispatched run judge `inputs.base..tip`, not an empty base. 4. The mod change installs canary-first: one session, and the proof is its request line plus the one run. ## Pieces 1. `src/dispatch_a_round_of_ci/`: script, oneshot unit and timer. It gets a C4 box and a README row. 2. crew-code (macula-sponsors): - the HANDOFF writes the spool line; - `skip_ci_on_landing.ts` reads a dispatched run. - The HANDOFF/VERDICT tip marks in #85's branch `saturnus/85-push-round` are reused where they fit. 3. One trigger PR per repo: dispatch inputs, the range jobs reading `inputs.base`, `heavy_paths.txt` where there is a heavy.yml, and `judge_the_checks.ts`. 4. The cred step, in one menu with the first land: the `ci-dispatch` bot, its token, and tag protection to the landers. Refs forge-setup#75, macula-io/macula-sponsors#85
Author
Member

Design r2: the r1 FAIL (Mars, fable) folded. The body above is now r2. Each finding and where it went:

  • F1 dispatch inputs base + pr. The range jobs (ci.yml:871, 948-949, 1058-1059, 1174-1175) read inputs.base on a dispatch, and the spool line carries pr=<n> and base..tip. §1, §2. It is also a proof item in §7.
  • F2 no path filter on push to main; the landing run carries the heavy three. The PR-side list lives in .forgejo/heavy_paths.txt, and the coordinator diffs base..tip against it. §1.
  • F3 the never-twice key is (workflow file, tree). Only a finished, non-cancelled run settles a request; a running one keeps it waiting. §3.
  • F4 skip_ci_on_landing.ts:211: the reader accepts a green, finished, dispatched run on the tip. §4, and §7 step 1.
  • N5 the PR comment is the mechanism; readers go by the runs API. §3.
  • N6 a red finished run settles too, with no redispatch. §3.
  • N7 a request is kept up to 5 ticks while the head is not the tip. With no PR it goes to the package issue for the dispatcher. §3.
  • N8 the timer starts a oneshot unit. §3, pieces.
  • N9 v* and installer-v* tag protection to the landers goes in the cred menu. §6.
  • N11 the capacity and allowlist files live on host00 beside the token. §3.
  • N13 the order: coordinator + mod line first, then the per-repo trigger PRs with their allowlist entry and judge_the_checks.ts. §1, §7.
  • N14 a batch is one push of N merges. §2.
Design r2: the r1 FAIL (Mars, fable) folded. The body above is now r2. Each finding and where it went: - **F1** dispatch inputs `base` + `pr`. The range jobs (ci.yml:871, 948-949, 1058-1059, 1174-1175) read `inputs.base` on a dispatch, and the spool line carries `pr=<n>` and `base..tip`. §1, §2. It is also a proof item in §7. - **F2** no path filter on push to main; the landing run carries the heavy three. The PR-side list lives in `.forgejo/heavy_paths.txt`, and the coordinator diffs `base..tip` against it. §1. - **F3** the never-twice key is (workflow file, tree). Only a finished, non-cancelled run settles a request; a running one keeps it waiting. §3. - **F4** `skip_ci_on_landing.ts:211`: the reader accepts a green, finished, dispatched run on the tip. §4, and §7 step 1. - **N5** the PR comment is the mechanism; readers go by the runs API. §3. - **N6** a red finished run settles too, with no redispatch. §3. - **N7** a request is kept up to 5 ticks while the head is not the tip. With no PR it goes to the package issue for the dispatcher. §3. - **N8** the timer starts a oneshot unit. §3, pieces. - **N9** `v*` and `installer-v*` tag protection to the landers goes in the cred menu. §6. - **N11** the capacity and allowlist files live on host00 beside the token. §3. - **N13** the order: coordinator + mod line first, then the per-repo trigger PRs with their allowlist entry and `judge_the_checks.ts`. §1, §7. - **N14** a batch is one push of N merges. §2.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha#258
No description provided.