Fleet dispatcher slice 2: the allocator in shadow mode on matou-workstation (ADR 0009) #355

Closed
opened 2026-11-18 20:09:54 +00:00 by matou-build-agent · 2 comments

Slice 2 of the fleet dispatcher (ADR 0009 (docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md), #353). Blocked on slice 1 (the slot report).

Dispatcher in shadow mode on matou-workstation (ruling B). The single loop receives the hosts' slot reports (slice 1), holds the fleet-wide view (every host's heavy slots + the fleet queue via fleet-queue-lib.sh), computes the allocation — head pick → a free slot on a named host — logs each assignment, and dispatches nothing. Rebuilt every pass from the tracker + the reports, no state of its own (decision 2). Drives take priority (ruling E: a host holding a drive reservation is offered nothing).

Run it alongside the live host ticks for a few days and compare: the log must answer, for any ready ticket, which slot it would have been offered and why not sooner (acceptance).

Built on workflow_dispatch behind one "start a run for pick P on host H" seam that #204 later replaces (ruling C). Offline-tested.

Ruled by ADR 0009 / #353.

Slice 2 of the fleet dispatcher (ADR 0009 (`docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md`), #353). **Blocked on slice 1 (the slot report).** **Dispatcher in shadow mode on `matou-workstation`** (ruling B). The single loop receives the hosts' slot reports (slice 1), holds the fleet-wide view (every host's heavy slots + the fleet queue via `fleet-queue-lib.sh`), computes the allocation — head pick → a free slot on a named host — **logs** each assignment, and **dispatches nothing**. Rebuilt every pass from the tracker + the reports, no state of its own (decision 2). Drives take priority (ruling E: a host holding a drive reservation is offered nothing). Run it alongside the live host ticks for a few days and compare: the log must answer, for any ready ticket, which slot it would have been offered and why not sooner (acceptance). Built on `workflow_dispatch` behind one "start a run for pick P on host H" seam that #204 later replaces (ruling C). Offline-tested. Ruled by ADR 0009 / #353.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: ready-for-session (category already enhancement).

Slice 2 builds the dispatcher loop that dispatches via workflow_dispatch and reuses fleet-queue-lib.sh — it touches the fleet scheduler and .forgejo/ (this repo's protected paths are .sandcastle .forgejo). The swarm queue reads only ready-for-agent, so handing this to a swarm worker is exactly what ready-for-session exists to prevent. This also matches the standing ruling on the parent #353 and slice 1 #354, both already ready-for-session.

Why a two-way door: the label is revertible by a later label change, and the slice itself is shadow-mode — it logs what it would assign and dispatches nothing (ADR 0009 ruling 6a), reversible by stopping the loop or reverting the commit. Not on the one-way-door list.

What proves it: the offline suite (the slice is offline-tested) plus the shadow-log acceptance — the log must answer, for any ready ticket, which slot it would have been offered and why not sooner. Native dependency on #354 is already recorded; stays blocked until slice 1 lands.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** `ready-for-session` (category already `enhancement`). Slice 2 builds the dispatcher loop that dispatches via `workflow_dispatch` and reuses `fleet-queue-lib.sh` — it touches the fleet scheduler and `.forgejo/` (this repo's protected paths are `.sandcastle .forgejo`). The swarm queue reads only `ready-for-agent`, so handing this to a swarm worker is exactly what `ready-for-session` exists to prevent. This also matches the standing ruling on the parent #353 and slice 1 #354, both already `ready-for-session`. **Why a two-way door:** the label is revertible by a later label change, and the slice itself is shadow-mode — it logs what it *would* assign and dispatches nothing (ADR 0009 ruling 6a), reversible by stopping the loop or reverting the commit. Not on the one-way-door list. **What proves it:** the offline suite (the slice is offline-tested) plus the shadow-log acceptance — the log must answer, for any ready ticket, which slot it would have been offered and why not sooner. Native dependency on #354 is already recorded; stays blocked until slice 1 lands.
Author
Member

Close report — ADR 0009 slice 2 landed on main (d2dce28, push mode).

The fleet dispatcher's allocator in shadow mode (decision 6a). One loop holds the fleet-wide view — the fleet queue (fleet-queue-lib.sh) and every host's slot report (slice 1, #354) — allocates the head pick to a free slot on a named host, logs each would-be assignment, and dispatches nothing. Rebuilt every pass from the tracker + the reports; no state of its own (decision 2).

What landed (993d238..d2dce28), three new vendored harness files:

  • fleet-dispatch-lib.sh — fleet_dispatch_ingest (validate + key a report by host, refuse junk/unsafe host), fleet_dispatch_drain_inbox, fleet_dispatch_free_slots (fresh non-drive hosts only — ruling E; a session / usage-limit-parked slot is busy so never free; a report older than two ticks → host unknown, decision 3, measured against our receipt time so cross-host skew can't fake freshness), fleet_dispatch_allocate (walk the order, i-th pick → i-th free slot, the rest QUEUEd with a reason that answers why not sooner), and fleet_dispatch_start_run — the single "start a run for pick P on host H" seam (ruling C): shadow logs, live rides fleet_queue_dispatch (slice 4 / #357 flips the mode; #204 later replaces the body).
  • fleet-dispatch.sh — once / loop / serve (receiver + loop, trap-cleaned) / ingest.
  • fleet-dispatch-receiver.py — the small authenticated mesh endpoint ruling A's push terminates at: bearer check, then spool the body verbatim; all validation/keying stay in tested bash.

Scoped OUT (later slices, per the #353 decomposition): acks + host-tick stand-down (decision 4 / #356), live dispatch (decision 6b/c / #357), landing detection (decision 5 / ruling D / #358).

Proof. tests/fleet-dispatch-lib-test.sh (33), tests/fleet-dispatch-test.sh (11), tests/fleet-dispatch-receiver-test.sh (8); the full offline suite green; a bounded live serve smoke confirmed the receiver auth (POST→200, wrong bearer→401) and the loop allocating the head to a free slot in shadow while dispatching nothing. onboarding/vendor-manifest classifies the three files (coverage test green); STATUS.md #353 row + docs/journal/2026-11-18-355-shadow-allocator.md + docs/deploy/fleet-dispatcher.md updated.

Owed, operational (not landable in a two-way-door session): the acceptance named in the ticket — running the dispatcher alongside the live host ticks for a few days and comparing the log — needs two staged gos ADR 0009 decision 6 reserves for Ben (one-way doors, left untouched): (1) set each pool host's FLEET_DISPATCHER_URL so its slot report POSTs to the receiver; (2) start the dispatcher on matou-workstation (ruling B) as a user service (runbook: docs/deploy/fleet-dispatcher.md). The slice ships complete and inert; FLEET_DISPATCH_MODE stays shadow.

Ruled by agent under ADR 0174 — veto anytime. Proof: the commit d2dce28 on main, the three test files above, and the live smoke.

**Close report — ADR 0009 slice 2 landed on `main` (`d2dce28`, push mode).** The fleet dispatcher's **allocator in shadow mode** (decision 6a). One loop holds the fleet-wide view — the fleet queue (`fleet-queue-lib.sh`) and every host's slot report (slice 1, #354) — allocates the head pick to a free slot on a named host, **logs** each would-be assignment, and **dispatches nothing**. Rebuilt every pass from the tracker + the reports; no state of its own (decision 2). **What landed** (`993d238..d2dce28`), three new vendored harness files: - `fleet-dispatch-lib.sh` — `fleet_dispatch_ingest` (validate + key a report by host, refuse junk/unsafe host), `fleet_dispatch_drain_inbox`, `fleet_dispatch_free_slots` (fresh non-drive hosts only — ruling E; a session / usage-limit-parked slot is `busy` so never free; a report older than two ticks → host `unknown`, decision 3, measured against our receipt time so cross-host skew can't fake freshness), `fleet_dispatch_allocate` (walk the order, i-th pick → i-th free slot, the rest QUEUEd with a reason that answers *why not sooner*), and `fleet_dispatch_start_run` — the single "start a run for pick P on host H" seam (ruling C): shadow logs, live rides `fleet_queue_dispatch` (slice 4 / #357 flips the mode; #204 later replaces the body). - `fleet-dispatch.sh` — `once` / `loop` / `serve` (receiver + loop, trap-cleaned) / `ingest`. - `fleet-dispatch-receiver.py` — the small authenticated mesh endpoint ruling A's push terminates at: bearer check, then spool the body verbatim; all validation/keying stay in tested bash. Scoped OUT (later slices, per the #353 decomposition): acks + host-tick stand-down (decision 4 / #356), live dispatch (decision 6b/c / #357), landing detection (decision 5 / ruling D / #358). **Proof.** `tests/fleet-dispatch-lib-test.sh` (33), `tests/fleet-dispatch-test.sh` (11), `tests/fleet-dispatch-receiver-test.sh` (8); the full offline suite green; a bounded **live `serve` smoke** confirmed the receiver auth (POST→200, wrong bearer→401) and the loop allocating the head to a free slot in shadow while dispatching nothing. `onboarding/vendor-manifest` classifies the three files (coverage test green); STATUS.md #353 row + `docs/journal/2026-11-18-355-shadow-allocator.md` + `docs/deploy/fleet-dispatcher.md` updated. **Owed, operational (not landable in a two-way-door session):** the acceptance named in the ticket — running the dispatcher alongside the live host ticks for a few days and comparing the log — needs two staged gos ADR 0009 decision 6 reserves for **Ben** (one-way doors, left untouched): (1) set each pool host's `FLEET_DISPATCHER_URL` so its slot report POSTs to the receiver; (2) start the dispatcher on `matou-workstation` (ruling B) as a user service (runbook: `docs/deploy/fleet-dispatcher.md`). The slice ships complete and inert; `FLEET_DISPATCH_MODE` stays `shadow`. Ruled by agent under ADR 0174 — veto anytime. Proof: the commit `d2dce28` on `main`, the three test files above, and the live smoke.
Sign in to join this conversation.
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.

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