Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions doc/decisions/FDR-0014-c2-event-pipeline-topology.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# FDR-0014 — C2 event pipeline: Worker intake, per-kind queues over the events log, threshold drain signals

- **Date:** 2026-11-30
- **Status:** proposed
- **Owner:** Fleet queue maintainers
- **Decision maker:** Drew, by programme directive — #9570 (C2 — Event pipeline)
is the fleet's standing event-pipeline programme; the design record was
reviewed and merged as PR #15450 (2026-11-26). This record is the proposal
the design record names: "This record is the proposal for the FDR that
#9570 asks for. Its entry in the #9180 decision index is filed with slice
C2-S1." Filed by lane 2347-R-N under #17075, the C2-S1 build-slice issue,
whose last unlanded acceptance item is this index entry.
- **Scope:** how webhook events become fleet work — intake of record, kind
derivation, per-kind queue semantics over the `events` log, drain-signal
thresholds, and the integration topology between the github-ci Worker,
the fleet-queue Turso store, the PM stack, and the agent hosts.
- **Supersedes:** none
- **Superseded by:** none
- **Related records:** FDR-0001 (resume-by-session — the drain ensures tasks;
it does not claim them), FDR-0007 (justified count caps — the per-kind
thresholds below state their reasons), FDR-0010 (completion requires
evidence)
- **Implementation:** design record
[`doc/2026-11-26T07-52-58Z_design_c2_event_pipeline/`](../2026-11-26T07-52-58Z_design_c2_event_pipeline/2026-11-26T07-52-58Z_design_c2_event_pipeline.md)
(PR #15450); slice C2-S1 in PR #15834 (`pkgs/github-ci/worker/src/derive.ts`,
`src/drain.ts`, `src/thresholds.ts`, the `*/5 * * * *` age cron in
`wrangler.toml`, registered in
[`doc/fleet-schedule-registry.md`](../fleet-schedule-registry.md));
follow-on slices #17077 (C2-S2, drain runner), #17078 (C2-S3, drain
actions), #17079 (C2-S4, cron conversions).

## Context and problem

Before C2, a GitHub webhook event and the fleet work it should cause were
connected by per-host machinery: each host polled, scraped, or was woken by
its own path, so the same event could wake nobody (a failed default-branch
run nobody saw) or everybody, and there was no single log a lane could
replay to learn what it had missed. #9570 specifies the replacement: one
intake of record, one append-only event log, and queues that are cursors
over that log rather than separate stores.

## Source links

- Originating issue(s): #9570 (C2 programme), #17075 (C2-S1 build slice,
which carries this filing as an acceptance item)
- Design record: PR #15450, decisions D1–D8 (D6 is the topology this record
carries into the index)
- PRs / commits: PR #15834 (C2-S1 implementation, merged 2026-11-27,
commit d13d1cbb4)
- Dated ruling or other authority: the #9570 programme and the merged
design record; the design record's D6 note assigns this filing to slice
C2-S1
- Evidence artifacts (audits, runbooks, logs): the design record's §6
oracles, executed as `pkgs/github-ci/worker/test/derive.test.ts` and
`test/drain.test.ts`

## Options considered

| Option | What it means | Assessment |
| --- | --- | --- |
| A. Worker intake + derived rows over one events log (D1–D6) | The github-ci Worker appends each raw event and, beside it, the per-kind queue rows it implies, under the same delivery id; a queue is the derived rows past a `drain:<kind>` cursor; thresholds raise `drain-due:<kind>` signals | Chosen in the design record: one intake, one log, replayable, and the signal path runs on the always-on Worker rather than on any host that can be down |
| B. Per-host polling of GitHub | Each host keeps discovering work itself | Rejected in the design record: duplicated discovery, missed events while a host is down, no shared replayable history |
| C. PM stack raises the work directly | The projection layer that reports events also creates the work | Rejected (D6): the PM stack is a projection and reports surface; making it an actor couples reporting to acting and raises work nobody queued |
| Do nothing | Events keep arriving with no derived queues or drain signals | Not a real option: #9570's threshold-drain behaviour is the programme's core ask |

## Decision

1. **One intake of record.** The github-ci Worker (`pkgs/github-ci/worker`)
is the intake for the fleet-queue `events` log. Beside each raw event it
appends the derived per-kind queue rows the event implies, under the
same GitHub delivery id, so raw history stays intact and derivable rows
are traceable to their event.
2. **Kind derivation at intake (D3).** Derived kinds are `issue_new`
(issues opened/reopened), `pr_open` (pull requests opened/reopened/
ready_for_review), `ci_failure` (a `workflow_run` completed with
conclusion `failure` on the repository's default branch), `mention`
(an issue-comment or review body naming a configured fleet identity),
and `pr_review` (a review submitted with changes requested). All other
events are log-only and derive nothing.
3. **A queue is a cursor, not a store (D2).** Queue K is the `events` rows
with kind = K and id greater than the `drain:K` watermark in
`agent_watermarks`. Nothing copies queue rows elsewhere.
4. **Threshold drain signals (D4).** A kind drains when its depth reaches
its count threshold (count leg, evaluated on append) OR its oldest
queued item reaches its age threshold (age leg, evaluated by the
Worker's 5-minute cron). Either leg sets `drain-due:<kind>` to the
current time unless already set — a standing signal is never moved.
Thresholds live in the one checked-in file
(`pkgs/github-ci/worker/src/thresholds.ts`): `issue_new`/`pr_open`/
`pr_review` at 10 items or 15 minutes; `ci_failure`/`mention` at
1 item or 5 minutes, because someone is waiting on those. Log-only
kinds have no thresholds and never signal. Per FDR-0007, a threshold
change states its reason in the same change.
5. **Topology (D6).** Cloudflare Workers: intake, derivation, threshold
signals, age cron (always on; already the webhook target). Turso
(fleet-queue): the event log, cursors, and signals (reachable from the
Worker, the laptop, and sandboxes). PM stack: projection and reports;
it raises nothing new. Muse (OpenClaw): woken by the detector to run
the drain and write the report. OpenChamber and OpenCode: run the tasks
the drain ensures, through the normal pick. The drain makes no claim,
merges nothing, and closes nothing; judgement happens in the tasks it
ensures.
6. **Mention identities are checked-in configuration.** The identities
whose naming derives a `mention` row live in the same thresholds file;
extending the list is a reviewed change to that file, never a per-host
edit.

## Rationale and evidence

**Measured / sourced facts:** the design record (PR #15450) worked the
options and recorded D1–D8 with §6 oracles; slice C2-S1 (PR #15834) landed
the derivation, the count and age signal legs, the thresholds file, and
the 5-minute age cron on 2026-11-27, with the oracle tests in
`derive.test.ts` and `drain.test.ts`. The cron is registered in
`doc/fleet-schedule-registry.md`.

**Inference:** because the signal legs run on the Worker and the log is
the Turso store every surface can reach, a kind becoming due is recorded
even while every agent host is down; the hosts' job is reduced to reading
signals and draining. What is not yet proven is end-to-end drain behaviour
— that is slices C2-S2/C2-S3 (#17077/#17078), still open at filing.

## Consequences

- Behavior changes: webhook deliveries now produce derived queue rows and
drain signals; consumers read queues as cursors over `events` instead of
polling GitHub.
- Compatibility / migration: additive — raw event appends are unchanged;
the derived rows and `drain-due:*` watermarks are new keys beside them.
- New failure modes: a derivation bug manufactures or drops work items
fleet-wide from one place (mitigated by the D3 kind-table oracle tests);
a stuck `drain-due:<kind>` signal with no drain runner yet (C2-S2) is
visible but inert.
- Monitoring and tests required: the design §6 oracles stay as the worker
test suite; the drain report (C2-S2/S3) is the operational readout.

## Revisit triggers

A derived kind's volume makes its threshold wrong in practice (measured:
signals firing with empty real work, or waiting work ageing past its
threshold repeatedly); a second intake surface needs the same derivation
(which would force derivation out of the Worker into a shared library);
or the events log's store moves off the fleet-queue Turso instance.

## Open questions

- **OQ-1 — When does this record become `accepted`?** Default: it stays
`proposed` while the chain it describes is partial; the topology is
nevertheless what C2-S1 shipped and what C2-S2–S4 build against.
Settled by: C2-S2 (#17077) and C2-S3 (#17078) landing, at which point the
fleet queue maintainers accept, amend, or supersede this record in the
periodic design-register review.
2 changes: 2 additions & 0 deletions doc/decisions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ the decision; `Implementation` is where the decision lands in code, docs, or iss
| [FDR-0011](FDR-0011-implementation-target-and-work-window.md) | Implementation target and usable work window | `accepted` | Fleet queue maintainers | Drew request, 2026-11-18; code#10415/task 20592 | Claim repo filter + existing #3418 budget gate |
| [FDR-0012](FDR-0012-no-ownership-handoff-park-gates.md) | No ownership-handoff park gates (supersedes FDR-0011 in part) | `accepted` | Fleet queue maintainers | Drew rulings, 2026-11-20 and 2026-11-21 | [#12061](https://github.com/developing-today/code/pull/12061), [#12074](https://github.com/developing-today/code/pull/12074), [#12155](https://github.com/developing-today/code/pull/12155); queue checkpoints reset 2026-11-21 |
| [FDR-0013](FDR-0013-no-owner-decision-gates.md) | No owner-decision gates: agents decide; only a hands item may wait on a person (settles FDR-0012 OQ-1) | `accepted` | Fleet queue maintainers | Drew ruling, 2026-11-21 | [#12216](https://github.com/developing-today/code/pull/12216); `fleet queue block`/`park` guard |
| [FDR-0014](FDR-0014-c2-event-pipeline-topology.md) | C2 event pipeline: Worker intake, per-kind queues over the events log, threshold drain signals | `proposed` | Fleet queue maintainers | [#9570](https://github.com/developing-today/code/issues/9570) programme; C2 design record D1–D6 via [#15450](https://github.com/developing-today/code/pull/15450), 2026-11-26 (its D6 note files this entry with slice C2-S1) | C2-S1 [#15834](https://github.com/developing-today/code/pull/15834) (`pkgs/github-ci/worker` derive/drain/thresholds + age cron); follow-ons [#17077](https://github.com/developing-today/code/issues/17077), [#17078](https://github.com/developing-today/code/issues/17078), [#17079](https://github.com/developing-today/code/issues/17079); filed under [#17075](https://github.com/developing-today/code/issues/17075) |

### Package-scoped records (not in this namespace)

Expand All @@ -184,3 +185,4 @@ the decision; `Implementation` is where the decision lands in code, docs, or iss
| FDR-0005 | Fleet queue maintainers | A decision issue answering #9178 §5's five questions (scope, init contract, GitHub carriage, transaction log, adoption boundary), recorded here | The proposal is **not** adopted; no fleet-init implementation is authorized by #9178 |
| FDR-0009 | Fleet queue maintainers | [#9177](https://github.com/developing-today/code/issues/9177) stopper root-cause findings land | A park whose trigger is unchanged is delay, not remediation |
| FDR-0010 | Fleet queue maintainers | [#9177](https://github.com/developing-today/code/issues/9177) identifies the closing automation; [#9221](https://github.com/developing-today/code/issues/9221) lands reason-required closes | No automation may mark done/close work that has an active bound task and no completion record |
| FDR-0014 | Fleet queue maintainers | C2-S2 ([#17077](https://github.com/developing-today/code/issues/17077)) and C2-S3 ([#17078](https://github.com/developing-today/code/issues/17078)) land, completing the drain chain the record describes | The C2-S1 implementation (PR #15834) is what ships and what the follow-on slices build against |