server: BuildDispatcher — coa-builds workflow_dispatch (phase-3 plan Task 4) #71

Closed
opened 2026-08-31 05:20:18 +00:00 by ben · 3 comments
Owner

Plan

docs/superpowers/plans/2026-08-31-coa-phase-3.md Task 4.

Deliverable

server/src/build-dispatcher.ts: DispatchRequest {slug, build, kitUrl, configUrl, callbackUrl}, BuildDispatcher.dispatch(req) → {ok:true} | {ok:false, error}; githubDispatcher({repo, workflow, ref, token, fetch}) → POST https://api.github.com/repos/<repo>/actions/workflows/<workflow>/dispatches {ref, inputs:{slug, kit_url, build:String, config_url, callback_url}} with authorization: Bearer, accept: application/vnd.github+json, x-github-api-version: 2022-11-28; 204 → ok. noopDispatcher() records calls. AppDeps.dispatcher; defaultDeps() uses github when GITHUB_DISPATCH_TOKEN set (COA_BUILDS_REPO default matou-collective/coa-builds, COA_BUILDS_WORKFLOW build.yml, COA_BUILDS_REF main), else noop. Test server/test/build-dispatcher.test.ts (plan text).

Acceptance

  • Plan tests pass verbatim; pnpm -r typecheck && pnpm -r test green.

depends_on

  • schema (Task 1)

Phase gate

Feature toggles / nav order in builds are phase 4. Never delete or rewrite anything under communities/ (ADR 0002/0003); phase 3 rewrites only kit.json, status.json, index.html. No test reaches the real network, sends real mail, dispatches a real build or provisions a real tenant.

## Plan `docs/superpowers/plans/2026-08-31-coa-phase-3.md` **Task 4**. ## Deliverable `server/src/build-dispatcher.ts`: `DispatchRequest {slug, build, kitUrl, configUrl, callbackUrl}`, `BuildDispatcher.dispatch(req) → {ok:true} | {ok:false, error}`; `githubDispatcher({repo, workflow, ref, token, fetch})` → `POST https://api.github.com/repos/<repo>/actions/workflows/<workflow>/dispatches` `{ref, inputs:{slug, kit_url, build:String, config_url, callback_url}}` with `authorization: Bearer`, `accept: application/vnd.github+json`, `x-github-api-version: 2022-11-28`; 204 → ok. `noopDispatcher()` records `calls`. `AppDeps.dispatcher`; `defaultDeps()` uses github when `GITHUB_DISPATCH_TOKEN` set (`COA_BUILDS_REPO` default `matou-collective/coa-builds`, `COA_BUILDS_WORKFLOW` `build.yml`, `COA_BUILDS_REF` `main`), else noop. Test `server/test/build-dispatcher.test.ts` (plan text). ## Acceptance - Plan tests pass verbatim; `pnpm -r typecheck && pnpm -r test` green. ## depends_on - schema (Task 1) ## Phase gate Feature toggles / nav order in builds are phase 4. Never delete or rewrite anything under `communities/` (ADR 0002/0003); phase 3 rewrites only `kit.json`, `status.json`, `index.html`. No test reaches the real network, sends real mail, dispatches a real build or provisions a real tenant.

This was generated by AI during triage.

Ruled by agent under ADR 0174 (two-way-door doctrine) — veto anytime

Ruling: ready-for-agent. BuildDispatcher (github + noop); AppDeps.dispatcher wired env-gated.

Why this is a two-way door: it is revertible by a later commit or label change, and provable by the tests the plan specifies — which never reach the real network, send real mail, dispatch a real build or provision a real tenant. It is not on the one-way-door list: the credential bytes, real GitHub dispatch/release and live coa-shared tenant are already carved out into the human ticket #79 and the session tickets #80/#81; env-gated defaults keep the wired code inert (noop/static, 503/unconfigured) until those land.

What proves it: server/test/build-dispatcher.test.ts with fetch injected — no real dispatch, and noopDispatcher is the default when GITHUB_DISPATCH_TOKEN is unset.

The ticket body is a complete agent brief (Deliverable / Acceptance / depends_on). The native Forgejo dependency links already mirror the plan's graph, so the swarm ready-list filter holds this ticket until its blockers close.

> *This was generated by AI during triage.* ## Ruled by agent under ADR 0174 (two-way-door doctrine) — veto anytime **Ruling:** `ready-for-agent`. BuildDispatcher (github + noop); AppDeps.dispatcher wired env-gated. **Why this is a two-way door:** it is revertible by a later commit or label change, and provable by the tests the plan specifies — which never reach the real network, send real mail, dispatch a real build or provision a real tenant. It is not on the one-way-door list: the credential bytes, real GitHub dispatch/release and live coa-shared tenant are already carved out into the human ticket #79 and the session tickets #80/#81; env-gated defaults keep the wired code inert (noop/static, 503/unconfigured) until those land. **What proves it:** `server/test/build-dispatcher.test.ts` with `fetch` injected — no real dispatch, and `noopDispatcher` is the default when `GITHUB_DISPATCH_TOKEN` is unset. The ticket body is a complete agent brief (Deliverable / Acceptance / depends_on). The native Forgejo dependency links already mirror the plan's graph, so the swarm ready-list filter holds this ticket until its blockers close.

Ruled by agent under the two-way-door doctrine — veto anytime.

Deviation from "plan tests pass verbatim": the plan test constructs new Response('', { status: 204 }) in its stub helper. In this repo's Node 22 / undici, 204 is a null-body status and the Response constructor throws Invalid response status code 204 for any non-null body (incl. '') — so the test throws inside its own stub, before githubDispatcher runs, and cannot pass verbatim here (CI runs the same Node).

Ruling: the stub returns a null body for null-body statuses (204/205/304), leaving every assertion untouched ({ ok: true }, URL, headers, request body, non-204/error cases). One-line comment records why.

Why two-way: revertible by a later commit; provable by pnpm --filter @coa/server test (46 passing, dispatcher included). Touches only test scaffolding, not the production surface (build-dispatcher.ts is byte-for-byte the plan implementation). Not on the one-way-door list — no network, mail, real build, or tenant.

Ruled by agent under the two-way-door doctrine — veto anytime. **Deviation from "plan tests pass verbatim":** the plan test constructs `new Response('', { status: 204 })` in its `stub` helper. In this repo's Node 22 / undici, 204 is a null-body status and the Response constructor throws `Invalid response status code 204` for any non-null body (incl. `''`) — so the test throws inside its own stub, before `githubDispatcher` runs, and cannot pass verbatim here (CI runs the same Node). **Ruling:** the stub returns a null body for null-body statuses (204/205/304), leaving every assertion untouched (`{ ok: true }`, URL, headers, request body, non-204/error cases). One-line comment records why. **Why two-way:** revertible by a later commit; provable by `pnpm --filter @coa/server test` (46 passing, dispatcher included). Touches only test scaffolding, not the production surface (`build-dispatcher.ts` is byte-for-byte the plan implementation). Not on the one-way-door list — no network, mail, real build, or tenant.
Author
Owner

Ruled by agent under the two-way-door doctrine — veto anytime. The deliverable is fully on main (worker commit 4319da5; files + tests + AppDeps wiring verified; seam green on 1724dcb), but the worker died before its close-report and its PR was a fully-merged shell (now closed). Closing so the ready list unblocks #74. Proof: pnpm -r typecheck && pnpm -r test green on the main head.

Ruled by agent under the two-way-door doctrine — veto anytime. The deliverable is fully on `main` (worker commit `4319da5`; files + tests + `AppDeps` wiring verified; seam green on `1724dcb`), but the worker died before its close-report and its PR was a fully-merged shell (now closed). Closing so the ready list unblocks #74. Proof: `pnpm -r typecheck && pnpm -r test` green on the main head.
ben 2026-08-31 21:42:13 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/coa#71
No description provided.