The build coordinator: one CI run per HANDOFF round, never twice on a workflow and tree (martha#258) #267

Manually merged
terra merged 6 commits from saturnus/258-dispatch-coordinator into main 2026-11-26 22:29:34 +00:00
Member

Refs martha-ai/martha#258

Purpose (cost): CI runs once per HANDOFF round, never twice on the same workflow and tree. DECIDED 2026-11-26 "Build coordinator".

What it is. npm run dispatch:a-round-of-ci is one tick of the build coordinator, run on the lander's box by a timer. It reads the crew's HANDOFF lines from its spool. For each line it finds the open pull request whose head is the tip, from the same repository (never a fork) and in an allowlisted repository. Then it dispatches each listed workflow once, on that branch, with the round's base (the merge base) and pr.

Never twice. A finished, non-cancelled run on the tip, or on a commit with the same tree that the coordinator dispatched, settles the workflow, green or red. A run still in flight keeps the request waiting. Runs are paced to the capacity file's limit per runner label.

Path lists. A workflow line flagged paths is dispatched only when base..tip changes a path its list names. The list is .github/dispatch_paths/<workflow file>.txt at the tip.

  • A line names a path or a folder above it; there are no globs.
  • A ! line excludes a path, and beats a named line. A list of ! lines only means "everything but these" (the docs-only skip).
  • A MISSING list file means the workflow runs on every round.
  • An EMPTY list file, or one with only comments, names nothing, so it NEVER dispatches. Don't mistake an empty list for "run always".

Repo-wide guards. The whole npm test named two that the slice's own file does not run, and 4c82f579 meets both:

  • the directory is a program (npm run dispatch:a-round-of-ci), so it may reach fs, child_process and fetch;
  • its git runs in its own clones, never in a member's tree, so it is named outside Martha's git settings.

Not in this PR. The workflows still trigger on pull_request. They move to dispatch in the trigger PR (saturnus/258-dispatch-triggers), after the credential step.

Threat model. The coordinator holds one forge token: user ci-dispatch, not an admin; Write on martha-ai/martha only; scopes write:repository and write:issue; in a 0600 file. It dispatches only on an allowlisted repository's open, same-repo pull request. Tag protection on v* and installer-v* keeps the token from starting a release.

Reviews: r=1 FAIL → r=2 PASS; r=3 PASS (paths); r=4 PASS (! lines). The merge of main 052e5471 and 4c82f579 go to the reviewer diff-only.

🤖 Generated with Claude Code

Refs martha-ai/martha#258 Purpose (cost): CI runs once per HANDOFF round, never twice on the same workflow and tree. DECIDED 2026-11-26 "Build coordinator". **What it is.** `npm run dispatch:a-round-of-ci` is one tick of the build coordinator, run on the lander's box by a timer. It reads the crew's HANDOFF lines from its spool. For each line it finds the open pull request whose head is the tip, from the same repository (never a fork) and in an allowlisted repository. Then it dispatches each listed workflow once, on that branch, with the round's `base` (the merge base) and `pr`. **Never twice.** A finished, non-cancelled run on the tip, or on a commit with the same tree that the coordinator dispatched, settles the workflow, green or red. A run still in flight keeps the request waiting. Runs are paced to the capacity file's limit per runner label. **Path lists.** A workflow line flagged `paths` is dispatched only when `base..tip` changes a path its list names. The list is `.github/dispatch_paths/<workflow file>.txt` at the tip. - A line names a path or a folder above it; there are no globs. - A `!` line excludes a path, and beats a named line. A list of `!` lines only means "everything but these" (the docs-only skip). - A MISSING list file means the workflow runs on every round. - An EMPTY list file, or one with only comments, names nothing, so it NEVER dispatches. Don't mistake an empty list for "run always". **Repo-wide guards.** The whole `npm test` named two that the slice's own file does not run, and 4c82f579 meets both: - the directory is a program (`npm run dispatch:a-round-of-ci`), so it may reach fs, child_process and fetch; - its git runs in its own clones, never in a member's tree, so it is named outside Martha's git settings. **Not in this PR.** The workflows still trigger on pull_request. They move to dispatch in the trigger PR (saturnus/258-dispatch-triggers), after the credential step. **Threat model.** The coordinator holds one forge token: user `ci-dispatch`, not an admin; Write on martha-ai/martha only; scopes write:repository and write:issue; in a 0600 file. It dispatches only on an allowlisted repository's open, same-repo pull request. Tag protection on `v*` and `installer-v*` keeps the token from starting a release. Reviews: r=1 FAIL → r=2 PASS; r=3 PASS (paths); r=4 PASS (`!` lines). The merge of main 052e5471 and 4c82f579 go to the reviewer diff-only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A timer's oneshot tick on the machine that holds the spool. A HANDOFF writes its first line to the spool; the tick finds
the open pull request whose head is the HANDOFF's tip in a repository its config lists, dispatches each workflow listed
for that repository once for the round, with the pull request's merge base and number as dispatch inputs, and comments
the run id on the pull request.

- Never twice: a finished, non-cancelled run of the workflow on the tip, or on a commit the coordinator dispatched with
  the tip's tree, settles the round, green or red. A run in flight keeps it waiting; a cancelled run settles nothing.
- A heavy workflow is dispatched only when base..tip changes a path .github/heavy_paths.txt names; a tip without the
  list runs it.
- Paced: a dispatch waits while the label's runs in flight are at its capacity, oldest request first.
- A tip no open pull request has as its head ends the request after 5 ticks, telling the package issue when its
  repository is listed. A branch that moves during the dispatch ends it.
- It never reruns.

Refs martha#258
- R1: only a pull request whose head branch lives in the repository itself is a round's; a fork's can carry a member's
  pushed commit as its head, and its branch name means another branch here.
- R2: a dispatched workflow is marked pending before any call after the dispatch can throw, and a tick that throws keeps
  those marks, so the next tick never dispatches it again.
- A tick that throws counts toward the request's ticks, so an error that persists ends it (N1); a progress file that
  cannot be read ends its request instead of stopping the spool or starting over (N2); blocked runs count toward a
  label's load (N3); a branch name with a slash is taken raw by the forge's branch route (N4, read on the forge).

Refs martha#258
A workflow line marked `paths` is dispatched only when the round's base..tip changes a path its own
.github/dispatch_paths/<workflow file>.txt names at the tip; a tip without that list runs it. This replaces the one
heavy_paths.txt per repository: on martha, advisories, engine-drift and host-drift filter pull_request by paths of
their own, and heavy.yml is a fourth.

Refs martha#258
A list of ! lines only names what never runs the workflow: suite.yml, c4-model.yml and standalone.yml skip a
docs-only change with paths-ignore today, and a dispatched workflow has no paths-ignore. A ! line beats a named
one. A list of comments only still names nothing; a path left off a ! list runs the workflow, costing a run,
never a test.
The build coordinator is a program package.json runs, and its git is named as outside Martha's own (martha#258)
All checks were successful
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (container) (pull_request) Has been skipped
c4 model / c4-model-1 (pull_request) Successful in 7s
c4 model / c4-model (pull_request) Successful in 0s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 10s
dependency advisories / node in installer (pull_request) Successful in 12s
dependency advisories / node in . (pull_request) Successful in 13s
dependency advisories / advisories (pull_request) Successful in 0s
CI / links resolve, workflows are valid (pull_request) Successful in 7s
heavy / installer (pull_request) Successful in 2m19s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 31s
suite / the ring reaches the owner on the live run's tmux (pull_request) Successful in 13s
CI / checks (pull_request) Successful in 3m35s
suite / gate coverage (pull_request) Successful in 9m21s
heavy / the relay loads in the recorded host (pull_request) Successful in 14m47s
heavy / the clean-install proof removes its container (pull_request) Successful in 21m27s
4c82f57909
The whole npm test on the merge named two guards the slice's own test file never ran: the coordinator
reaches node:fs, node:child_process, process and fetch, which a program may and a slice may not, so
`npm run dispatch:a-round-of-ci` runs it; and it starts git in its own clones on the lander's box, never in a
member's tree, so the git-settings test names it outside.
terra manually merged commit d6073d14bb into main 2026-11-26 22:29:34 +00:00
Sign in to join this conversation.
No reviewers
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!267
No description provided.