Dispatcher: one allocator for picks → slots across the fleet, with the host ticks as fallback (ADR 0009) #353

Open
opened 2026-11-18 20:04:58 +00:00 by ben · 2 comments
Owner

Problem

Every pool host runs its own fleet queue watcher and decides alone. No host sees another host's slots or dispatches, so the one allocation decision is made N times from N partial views. The patches so far — the dispatch stamp (#301), strikes and stand-down (#315), the starvation yield (#213), the dispatch marker (#351) — each close one symptom of that.

What the current design cannot do:

  • send a pick to the host best placed to run it (it goes to whichever host ticks first);
  • refill an idle slot on another host before that host's next tick;
  • explain "why was this not picked up?" in one place;
  • notice, after a run has ended, that a ticket closed without landing.

Proposal

docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md (status: proposed). In short:

  1. One dispatcher allocates. A single loop holds the fleet-wide view (every host's heavy slots + the fleet queue), assigns the head pick to a free slot on a named host, and dispatches as the watcher does today (inputs.ticket + inputs.host). Reuses fleet-queue-lib.sh.
  2. No state of its own. Rebuilt every pass from the tracker and host slot reports.
  3. Slot truth stays on the host. An assignment is an offer; the leg still takes the flock and stands down if it cannot.
  4. Hosts fall back to their own tick when the dispatcher stops acknowledging their slot reports — today's behaviour, arbitrated by the #351 marker. The dispatcher is never a single point of failure.
  5. Detect bad landings, do not repair them. Closed-but-not-on-main, agent-working with no live run, an un-relanded rescue branch, a green unmerged agent PR → a ticket at the front of the fleet queue. Existing machinery does the repair.
  6. Staged rollout: shadow (log only) → one host → fleet-wide.

Ruled (Ben, 2026-11-18 — recorded in the ADR)

  • A. Slot reports are event-driven: a host pushes its full slot state when a run takes a slot, when a run ends (the end-of-ticket action), and on its two-minute tick. The events make it fast; the periodic report makes it correct when a host dies without sending an end event.
  • B. The dispatcher runs on matou-workstation. No standby in v1; the host-tick fallback is the standby. (#340, that box's disk, is now a fleet-wide risk rather than a one-host one.)
  • C. Built before #204, on workflow_dispatch, behind one "start a run for pick P on host H" seam that #204 later replaces.
  • D. All four detection cases in v1.
  • E. Drives take priority: a host with a drive reservation is offered nothing.

What it makes obsolete (each retirement is its own later ticket)

  • Fallback-only: the per-host fleet queue tick, the dispatch stamp, strikes/stand-down (#315), the dispatch marker (#351), the host cache, the after-close self-rearm.
  • Retire once live fleet-wide: the swarm workflow's :15/:45 cron and closed trigger as a pickup path; the swarm half of schedule-backstop.sh; the starvation yield (#213); the janitor/landing-sweep calls at the start of every run (the functions stay as the repair); fleet-tui's ssh slot probe.
  • Stays: the claim, the host capacity flock, the scheduler canary, the healer watchdog, close-report gates, land-after-verify, the rescue ladder, the session-runner, the drive reservation.

Proposed slices

  1. Host slot report: the report shape (shared with fleet-tui's collector) and the three send points — slot taken, run ended, tick. Offline-tested.
  2. Dispatcher in shadow mode on matou-workstation: receives reports, computes assignments, logs them, dispatches nothing. Compare with the host ticks for a few days.
  3. Acknowledgements + the host tick's stand-down-while-acknowledged. Fallback path covered by the offline suite.
  4. Dispatcher live on one host's slots, then fleet-wide.
  5. Landing detection (scope per D), filing to the front of the fleet queue.

Acceptance

  • With N hosts idle and N tickets ready, N runs start within one dispatcher pass, one per host, no duplicate dispatch.
  • Stopping the dispatcher: within one heartbeat window the host ticks resume and tickets keep being picked up.
  • A ticket closed with its commits absent from main is surfaced within one detection pass, with the evidence named.
  • One log answers, for any ready ticket, which slot it was offered and why not sooner.

#301 (ADR 0007), #351, #315, #213, #204, #283/#328 (stranded-close reopen), #114 (idle landing sweep).

## Problem Every pool host runs its own fleet queue watcher and decides alone. No host sees another host's slots or dispatches, so the one allocation decision is made N times from N partial views. The patches so far — the dispatch stamp (#301), strikes and stand-down (#315), the starvation yield (#213), the dispatch marker (#351) — each close one symptom of that. What the current design cannot do: - send a pick to the host best placed to run it (it goes to whichever host ticks first); - refill an idle slot on another host before that host's next tick; - explain "why was this not picked up?" in one place; - notice, after a run has ended, that a ticket closed without landing. ## Proposal `docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md` (status: proposed). In short: 1. **One dispatcher allocates.** A single loop holds the fleet-wide view (every host's heavy slots + the fleet queue), assigns the head pick to a free slot on a named host, and dispatches as the watcher does today (`inputs.ticket` + `inputs.host`). Reuses `fleet-queue-lib.sh`. 2. **No state of its own.** Rebuilt every pass from the tracker and host slot reports. 3. **Slot truth stays on the host.** An assignment is an offer; the leg still takes the flock and stands down if it cannot. 4. **Hosts fall back to their own tick** when the dispatcher stops acknowledging their slot reports — today's behaviour, arbitrated by the #351 marker. The dispatcher is never a single point of failure. 5. **Detect bad landings, do not repair them.** Closed-but-not-on-`main`, `agent-working` with no live run, an un-relanded rescue branch, a green unmerged agent PR → a ticket at the front of the fleet queue. Existing machinery does the repair. 6. **Staged rollout:** shadow (log only) → one host → fleet-wide. ## Ruled (Ben, 2026-11-18 — recorded in the ADR) - **A.** Slot reports are event-driven: a host pushes its full slot state when a run takes a slot, when a run ends (the end-of-ticket action), and on its two-minute tick. The events make it fast; the periodic report makes it correct when a host dies without sending an end event. - **B.** The dispatcher runs on `matou-workstation`. No standby in v1; the host-tick fallback is the standby. (#340, that box's disk, is now a fleet-wide risk rather than a one-host one.) - **C.** Built before #204, on `workflow_dispatch`, behind one "start a run for pick P on host H" seam that #204 later replaces. - **D.** All four detection cases in v1. - **E.** Drives take priority: a host with a drive reservation is offered nothing. ## What it makes obsolete (each retirement is its own later ticket) - **Fallback-only:** the per-host fleet queue tick, the dispatch stamp, strikes/stand-down (#315), the dispatch marker (#351), the host cache, the `after-close` self-rearm. - **Retire once live fleet-wide:** the swarm workflow's `:15/:45` cron and `closed` trigger as a pickup path; the swarm half of `schedule-backstop.sh`; the starvation yield (#213); the janitor/landing-sweep calls at the start of every run (the functions stay as the repair); `fleet-tui`'s ssh slot probe. - **Stays:** the claim, the host capacity flock, the scheduler canary, the healer watchdog, close-report gates, land-after-verify, the rescue ladder, the session-runner, the drive reservation. ## Proposed slices 1. Host slot report: the report shape (shared with `fleet-tui`'s collector) and the three send points — slot taken, run ended, tick. Offline-tested. 2. Dispatcher in shadow mode on `matou-workstation`: receives reports, computes assignments, logs them, dispatches nothing. Compare with the host ticks for a few days. 3. Acknowledgements + the host tick's stand-down-while-acknowledged. Fallback path covered by the offline suite. 4. Dispatcher live on one host's slots, then fleet-wide. 5. Landing detection (scope per D), filing to the front of the fleet queue. ## Acceptance - With N hosts idle and N tickets ready, N runs start within one dispatcher pass, one per host, no duplicate dispatch. - Stopping the dispatcher: within one heartbeat window the host ticks resume and tickets keep being picked up. - A ticket closed with its commits absent from `main` is surfaced within one detection pass, with the evidence named. - One log answers, for any ready ticket, which slot it was offered and why not sooner. ## Related #301 (ADR 0007), #351, #315, #213, #204, #283/#328 (stranded-close reopen), #114 (idle landing sweep).

Routed to ready-for-human by a session-runner standing session (ADR 0174 — veto anytime).

Concurrent-work note (honest audit)

This ticket was worked twice in parallel. A swarm run on bens-mac-04 (run 1754460, the swarm-claim above) landed ADR 0009 (docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md, status proposed) on main as commit d468efc — Ben's five rulings A–E, the landing-check inventory, and the obsolescence groups. That is the authoritative design.

This session picked the same ticket up from the session lane before the lane cleared, independently wrote the same ADR, and found d468efc already on main at push time. I did not overwrite the peer's ADR — I reset my duplicate and kept only the non-overlapping contribution below. (This double-pickup is itself an instance of the N-hosts-decide-alone collision ADR 0009 exists to remove.)

What this session added — the decomposition (two-way door, done)

The epic is split into five build slices, each naming the ADR ruling/decision it carries, with a dependency DAG so they are worked in order:

  • #354 — slice 1: the host slot report (ruling A / decision 3). Root of the DAG; two-way door, offline-testable, workable once the posture is accepted.
  • #355 — slice 2: the allocator in shadow mode on matou-workstation (decision 6a, ruling B). Blocked on #354.
  • #356 — slice 3: acknowledgements + the host-tick stand-down (decision 4). Blocked on #355.
  • #357 — slice 4: the dispatcher live, one host then fleet-wide (decision 6b/c). Blocked on #356. Each live stage is a Ben go (routed to a human at build time).
  • #358 — slice 5: landing detection, all four cases, filing to the front of the fleet queue (decision 5 / ruling D). Blocked on #355, parallel to #356/#357.

The slices are filed enhancement-only (not ready-for-session) — deliberately un-queued until the proposed posture is accepted (below), so the fleet does not start pouring concrete toward an un-accepted design.

Why human

The two-way-door work on this epic is complete: the ADR is on main and the build is decomposed into #354–#358. What remains is a one-way door reserved for Ben by ADR 0174 and by the ADR itself ("the go ... is Ben's at each stage"):

  • Accept or veto the proposed ADR 0009 posture — a single central allocator for fleet dispatch, with the host ticks demoted to a tested fallback. Adopting a new scheduling posture across the fleet is an architecture ruling, not an agent's.
  • Authorise the staged rollout gos — shadow → one host → fleet-wide. The live stages change how every run on every host is started.
  • Note (ruling B): the dispatcher's home is matou-workstation, whose disk is open blocker #340; clearing #340 is a prerequisite before it goes live, and its outage now degrades allocation fleet-wide (to the tested fallback, not a stop).

On acceptance, un-blocking proceeds by labelling #354 onto a work lane; the slice DAG carries the build from there. Left ready-for-human and open as the tracking epic — not closed, because the posture decision is still owed.

**Routed to `ready-for-human` by a session-runner standing session (ADR 0174 — veto anytime).** ### Concurrent-work note (honest audit) This ticket was worked twice in parallel. A swarm run on `bens-mac-04` (run `1754460`, the `swarm-claim` above) landed **ADR 0009** (`docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md`, status **proposed**) on `main` as commit `d468efc` — Ben's five rulings A–E, the landing-check inventory, and the obsolescence groups. That is the authoritative design. This session picked the same ticket up from the session lane before the lane cleared, independently wrote the same ADR, and found `d468efc` already on `main` at push time. I **did not** overwrite the peer's ADR — I reset my duplicate and kept only the non-overlapping contribution below. (This double-pickup is itself an instance of the N-hosts-decide-alone collision ADR 0009 exists to remove.) ### What this session added — the decomposition (two-way door, done) The epic is split into five build slices, each naming the ADR ruling/decision it carries, with a dependency DAG so they are worked in order: - **#354** — slice 1: the host slot report (ruling A / decision 3). Root of the DAG; two-way door, offline-testable, workable once the posture is accepted. - **#355** — slice 2: the allocator in shadow mode on `matou-workstation` (decision 6a, ruling B). Blocked on #354. - **#356** — slice 3: acknowledgements + the host-tick stand-down (decision 4). Blocked on #355. - **#357** — slice 4: the dispatcher live, one host then fleet-wide (decision 6b/c). Blocked on #356. **Each live stage is a Ben go (routed to a human at build time).** - **#358** — slice 5: landing detection, all four cases, filing to the front of the fleet queue (decision 5 / ruling D). Blocked on #355, parallel to #356/#357. The slices are filed `enhancement`-only (not `ready-for-session`) — deliberately un-queued until the proposed posture is accepted (below), so the fleet does not start pouring concrete toward an un-accepted design. ### Why human The two-way-door work on this epic is complete: the ADR is on `main` and the build is decomposed into #354–#358. What remains is a **one-way door** reserved for Ben by ADR 0174 and by the ADR itself ("the go ... is Ben's at each stage"): - **Accept or veto the proposed ADR 0009 posture** — a single central allocator for fleet dispatch, with the host ticks demoted to a tested fallback. Adopting a new scheduling posture across the fleet is an architecture ruling, not an agent's. - **Authorise the staged rollout gos** — shadow → one host → fleet-wide. The live stages change how every run on every host is started. - **Note (ruling B):** the dispatcher's home is `matou-workstation`, whose disk is open blocker **#340**; clearing #340 is a prerequisite before it goes live, and its outage now degrades allocation fleet-wide (to the tested fallback, not a stop). On acceptance, un-blocking proceeds by labelling #354 onto a work lane; the slice DAG carries the build from there. Left `ready-for-human` and open as the tracking epic — not closed, because the posture decision is still owed.
Author
Owner

Accepted — Ben, in session, 2026-11-18. ADR 0009's posture stands: one dispatcher allocates fleet-queue picks to heavy slots fleet-wide, and the per-host fleet queue tick becomes the tested fallback. Rulings A–E as recorded in the ADR.

What this acceptance does and does not cover:

  • Covers: the design, and building slices 1–3 and 5 (#354, #355, #356, #358), including the shadow-mode dispatcher on matou-workstation.
  • Does not cover: the two live stages. Each is still its own go from Ben on #357 (one host, then fleet-wide).

Tracker changes made with this comment:

  • #354 (slice 1, the root of the DAG) labelled ready-for-session, and its dependency on this epic removed — the epic stays open as the tracker, and an open dependency would have kept the whole chain blocked.
  • This epic: ready-for-human removed (nothing is owed by a human here any more), no-triage added so triage and the session-runner leave the tracking ticket alone.

Close this epic when #357 and #358 have landed and the acceptance list in the body is proven.

**Accepted — Ben, in session, 2026-11-18.** ADR 0009's posture stands: one dispatcher allocates fleet-queue picks to heavy slots fleet-wide, and the per-host fleet queue tick becomes the tested fallback. Rulings A–E as recorded in the ADR. What this acceptance does and does not cover: - **Covers:** the design, and building slices 1–3 and 5 (#354, #355, #356, #358), including the shadow-mode dispatcher on `matou-workstation`. - **Does not cover:** the two live stages. Each is still its own go from Ben on #357 (one host, then fleet-wide). Tracker changes made with this comment: - #354 (slice 1, the root of the DAG) labelled `ready-for-session`, and its dependency on this epic removed — the epic stays open as the tracker, and an open dependency would have kept the whole chain blocked. - This epic: `ready-for-human` removed (nothing is owed by a human here any more), `no-triage` added so triage and the session-runner leave the tracking ticket alone. Close this epic when #357 and #358 have landed and the acceptance list in the body is proven.
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.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#353
No description provided.