Fleet dispatcher slice 3: acknowledgements + the host tick stand-down (ADR 0009) #356

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

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

Acknowledgements + the host tick's stand-down-while-acknowledged. The dispatcher acknowledges the slot reports it is acting on; a host whose report is being acknowledged stands its own tick down for that slot. The moment the dispatcher stops acknowledging (it died, it was stopped), the host tick resumes within one heartbeat window — today's behaviour, arbitrated by the #351 dispatch marker (decision 4: the dispatcher is never a single point of failure).

The fallback path is covered by the offline suite: an un-acknowledged report → the host ticks dispatch as they do today; an acknowledged one → the host stands down. Both ends contract-tested.

Ruled by ADR 0009 / #353.

Slice 3 of the fleet dispatcher (ADR 0009 (`docs/adr/0009-one-dispatcher-allocates-picks-to-slots.md`), #353). **Blocked on slice 2 (the shadow dispatcher).** **Acknowledgements + the host tick's stand-down-while-acknowledged.** The dispatcher acknowledges the slot reports it is acting on; a host whose report is being acknowledged stands its own tick down for that slot. The moment the dispatcher stops acknowledging (it died, it was stopped), the host tick resumes within one heartbeat window — today's behaviour, arbitrated by the #351 dispatch marker (decision 4: the dispatcher is never a single point of failure). The fallback path is covered by the offline suite: an un-acknowledged report → the host ticks dispatch as they do today; an acknowledged one → the host stands down. Both ends contract-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 3 changes the host tick's stand-down-while-acknowledged path and the ack handshake — core fleet-scheduler code, dispatched via .forgejo/ workflow_dispatch (protected paths .sandcastle .forgejo). Same session-standing surface as #353/#354/#355, so a swarm worker must not take it.

Why a two-way door: revertible by a label change, and the design keeps the host tick as the fallback — the moment the dispatcher stops acknowledging, the tick resumes within one heartbeat window (decision 4, the dispatcher is never a single point of failure). Reversible by stopping the dispatcher or reverting the commit. Not on the one-way-door list.

What proves it: the offline suite contract-tests both ends — an un-acknowledged report → host ticks dispatch as today; an acknowledged one → host stands down. Native dependency on #355 already recorded.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** `ready-for-session` (category already `enhancement`). Slice 3 changes the host tick's stand-down-while-acknowledged path and the ack handshake — core fleet-scheduler code, dispatched via `.forgejo/` `workflow_dispatch` (protected paths `.sandcastle .forgejo`). Same session-standing surface as #353/#354/#355, so a swarm worker must not take it. **Why a two-way door:** revertible by a label change, and the design keeps the host tick as the fallback — the moment the dispatcher stops acknowledging, the tick resumes within one heartbeat window (decision 4, the dispatcher is never a single point of failure). Reversible by stopping the dispatcher or reverting the commit. Not on the one-way-door list. **What proves it:** the offline suite contract-tests both ends — an un-acknowledged report → host ticks dispatch as today; an acknowledged one → host stands down. Native dependency on #355 already recorded.
Author
Member

Close-report — ADR 0009 slice 3 landed on main (push mode).

Acknowledgements + the host tick's stand-down (decision 4) are built. The dispatcher's reply to a slot report is now the heartbeat: a host whose last report drew a fresh acting ack stands its own fleet-queue.sh tick dispatch down and leaves allocation to the dispatcher; the moment the acks stop (it died, was stopped, or only ever shadowed) a failed push records a dead ack and the host resumes today's tick within one heartbeat window, arbitrated by the #351 marker — the dispatcher is never a single point of failure. Advances #353.

What landed (commit b9b93a4, pushed d2dce28..b9b93a4 → main):

  • fleet-dispatch-receiver.py — the 200 carries {ok, acting, mode} (ack_payload()); acting is true iff the dispatcher is live. In shadow it dispatches nothing, so it acks acting:false and no host stands down (6a). Added a --ack seam for the contract test.
  • fleet-dispatch.sh serve — exports FLEET_DISPATCH_MODE/_INBOX to the receiver subprocess, so the ack reflects the mode the loop runs in even when lib-defaulted.
  • fleet-slot-report-lib.sh — fleet_slot_report_send captures the 2xx body (curl -w '\n%{http_code}') and records the ack against the host's own clock (cross-skew safe); a failed/non-2xx push records a dead ack so resume is one heartbeat, not a TTL. fleet_slot_report_acked_fresh is the predicate the tick reads (FLEET_DISPATCH_ACK_TTL default 240s is only the safety net).
  • fleet-queue.sh — a tick-only stand-down gate after the slot-free check (a finishing run's after-close/rearm self-rearm is untouched — its retirement is a later slice). "Live on one host" (6b) needs no mode of its own: only hosts that set FLEET_DISPATCHER_URL report to, and defer to, the dispatcher.

Still inert / reversible. Shadow default (acting:false) and no host sets FLEET_DISPATCHER_URL yet, so this is a no-op on the live fleet — a two-way door. The staged gos (point hosts at the dispatcher; flip FLEET_DISPATCH_MODE=live, slice #357) stay with Ben (decision 6).

Proof — TDD, red before green, every lib change with its test; full offline suite green (105 suites):

  • tests/fleet-slot-report-lib-test.sh (44, +10) — no URL → no ack; live 2xx → fresh; shadow 2xx / no-acting field → not fresh; 5xx → dead ack; past-TTL → stale; malformed line → not fresh.
  • tests/fleet-dispatch-receiver-test.sh (11, +3) — --ack per mode (live acts, shadow/default never stand down by accident).
  • tests/fleet-dispatch-ack-contract-test.sh (4, new) — BOTH ends: the receiver's own --ack body fed verbatim to the host's send, proving a live ack stands the host down and a shadow/default ack does not, no shim between the shapes.
  • tests/fleet-queue-test.sh (48, +5) — fresh live ack stands the tick down (no lister, no dispatch); not-acting ack dispatches as today; stale ack resumes & dispatches the head; a rearm is not stood down (tick-only); a busy host exits at the slot gate, not as a stand-down.

Docs: docs/deploy/fleet-dispatcher.md (ack + stand-down section), journal docs/journal/2026-11-18-356-ack-standdown.md, STATUS.md #353 row.

No .sandcastle/ self-copy edit (pull-only; reaches the running copy at the next FACTORY_REF pin bump — GOTCHAS 4 / ADR 0001).

Ruled by agent under ADR 0174 — veto anytime.

**Close-report — ADR 0009 slice 3 landed on `main` (push mode).** Acknowledgements + the host tick's stand-down (decision 4) are built. The dispatcher's reply to a slot report is now the heartbeat: a host whose last report drew a fresh **acting** ack stands its own `fleet-queue.sh tick` dispatch down and leaves allocation to the dispatcher; the moment the acks stop (it died, was stopped, or only ever shadowed) a failed push records a dead ack and the host resumes today's tick **within one heartbeat window**, arbitrated by the #351 marker — the dispatcher is never a single point of failure. Advances #353. **What landed** (commit `b9b93a4`, pushed `d2dce28..b9b93a4` → `main`): - `fleet-dispatch-receiver.py` — the `200` carries `{ok, acting, mode}` (`ack_payload()`); `acting` is true iff the dispatcher is **live**. In shadow it dispatches nothing, so it acks `acting:false` and no host stands down (6a). Added a `--ack` seam for the contract test. - `fleet-dispatch.sh serve` — exports `FLEET_DISPATCH_MODE`/`_INBOX` to the receiver subprocess, so the ack reflects the mode the loop runs in even when lib-defaulted. - `fleet-slot-report-lib.sh` — `fleet_slot_report_send` captures the 2xx body (`curl -w '\n%{http_code}'`) and records the ack against the host's **own** clock (cross-skew safe); a failed/non-2xx push records a **dead ack** so resume is one heartbeat, not a TTL. `fleet_slot_report_acked_fresh` is the predicate the tick reads (`FLEET_DISPATCH_ACK_TTL` default 240s is only the safety net). - `fleet-queue.sh` — a **tick-only** stand-down gate after the slot-free check (a finishing run's `after-close`/`rearm` self-rearm is untouched — its retirement is a later slice). "Live on one host" (6b) needs no mode of its own: only hosts that set `FLEET_DISPATCHER_URL` report to, and defer to, the dispatcher. **Still inert / reversible.** Shadow default (`acting:false`) and no host sets `FLEET_DISPATCHER_URL` yet, so this is a no-op on the live fleet — a two-way door. The staged gos (point hosts at the dispatcher; flip `FLEET_DISPATCH_MODE=live`, slice #357) stay with Ben (decision 6). **Proof — TDD, red before green, every lib change with its test; full offline suite green (105 suites):** - `tests/fleet-slot-report-lib-test.sh` (44, +10) — no URL → no ack; live 2xx → fresh; shadow 2xx / no-`acting` field → not fresh; 5xx → dead ack; past-TTL → stale; malformed line → not fresh. - `tests/fleet-dispatch-receiver-test.sh` (11, +3) — `--ack` per mode (live acts, shadow/default never stand down by accident). - `tests/fleet-dispatch-ack-contract-test.sh` (4, **new**) — BOTH ends: the receiver's own `--ack` body fed verbatim to the host's `send`, proving a live ack stands the host down and a shadow/default ack does not, no shim between the shapes. - `tests/fleet-queue-test.sh` (48, +5) — fresh live ack stands the tick down (no lister, no dispatch); not-acting ack dispatches as today; stale ack resumes & dispatches the head; a `rearm` is not stood down (tick-only); a busy host exits at the slot gate, not as a stand-down. Docs: `docs/deploy/fleet-dispatcher.md` (ack + stand-down section), journal `docs/journal/2026-11-18-356-ack-standdown.md`, STATUS.md #353 row. No `.sandcastle/` self-copy edit (pull-only; reaches the running copy at the next `FACTORY_REF` pin bump — GOTCHAS 4 / ADR 0001). Ruled by agent under ADR 0174 — veto anytime.
matou-build-agent 2026-11-18 22:37:58 +00:00
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#356
No description provided.