fleet-queue: every idle host dispatches the same fleet head to itself — arbitrate the dispatch on the tracker so one ticket goes to one host #351

Closed
opened 2026-11-18 06:44:56 +00:00 by ben · 4 comments
Owner

What happened

2026-11-18 06:10Z, Matou/idss#2200 became ready while all three pool hosts were idle. Each host's fleet-queue tick (*/2 * * * *, so all three fire in the same minute) dispatched the fleet head to itself: runs 66744 (bens-mac-04), 66745 (elitebook-03), 66746 (matou-workstation).

  • bens-mac-04 posted the only swarm-claim (06:16:27Z) and worked the ticket.
  • elitebook-03 and matou-workstation each booted a sandbox, got an empty claim, ran a throwaway agent session ("not mine to work"), and held a heavy slot for 600 s and 699 s.

No duplicate work landed, but two slots were tied up ~10 min each and the Floor showed #2200 on three machines.

Why

fleet-queue.sh has no cross-host view. The only duplicate guard is the dispatch stamp, a file local to the host. ADR 0007 accepted "two idle hosts whose ticks fire in the same window can dispatch the same head to themselves" as a one-off the claim resolves. With every host on the same cron minute it is the normal case for a lone ticket arriving at an idle fleet, and the claim only settles it in-sandbox, minutes later (dispatch → claim was 387 s here).

Fix

Arbitrate at dispatch, on the one channel every host shares (the tracker), with the primitive the claim already rests on (strictly increasing comment ids):

  • Before dispatching a ticket, the tick reads its comments. A live fleet-dispatch host=<h> marker from another host means that ticket is taken: move to the next ticket in fleet order.
  • Otherwise post a marker, re-read, and dispatch only if this host's marker is the lowest live one; a loser deletes its marker and moves to the next ticket.
  • Markers expire by age and the posting host deletes its own once expired.
  • A tracker read/write failure fails open (dispatch as before; the claim still guards).

Result: one ticket → one dispatch → one host; a second idle host takes the next ticket in line instead of racing for the head.

Acceptance

  • Offline tests: two hosts arbitrating one head → exactly one dispatch; the loser dispatches the next ticket; expired markers ignored and swept; forge failure fails open.
  • ADR 0007 amended, GOTCHAS row, journal entry.
  • Rollout is a pin bump per consumer (the host tick runs the first registered checkout's vendored copy); mixed pins behave as today.
## What happened 2026-11-18 06:10Z, `Matou/idss#2200` became ready while all three pool hosts were idle. Each host's fleet-queue tick (`*/2 * * * *`, so all three fire in the same minute) dispatched the fleet head **to itself**: runs 66744 (bens-mac-04), 66745 (elitebook-03), 66746 (matou-workstation). - bens-mac-04 posted the only `swarm-claim` (06:16:27Z) and worked the ticket. - elitebook-03 and matou-workstation each booted a sandbox, got an empty claim, ran a throwaway agent session ("not mine to work"), and held a heavy slot for 600 s and 699 s. No duplicate work landed, but two slots were tied up ~10 min each and the Floor showed #2200 on three machines. ## Why `fleet-queue.sh` has no cross-host view. The only duplicate guard is the dispatch stamp, a file local to the host. ADR 0007 accepted "two idle hosts whose ticks fire in the same window can dispatch the same head to themselves" as a one-off the claim resolves. With every host on the same cron minute it is the normal case for a lone ticket arriving at an idle fleet, and the claim only settles it in-sandbox, minutes later (dispatch → claim was 387 s here). ## Fix Arbitrate **at dispatch**, on the one channel every host shares (the tracker), with the primitive the claim already rests on (strictly increasing comment ids): - Before dispatching a ticket, the tick reads its comments. A live `fleet-dispatch host=<h>` marker from another host means that ticket is taken: move to the next ticket in fleet order. - Otherwise post a marker, re-read, and dispatch only if this host's marker is the lowest live one; a loser deletes its marker and moves to the next ticket. - Markers expire by age and the posting host deletes its own once expired. - A tracker read/write failure fails open (dispatch as before; the claim still guards). Result: one ticket → one dispatch → one host; a second idle host takes the next ticket in line instead of racing for the head. ## Acceptance - Offline tests: two hosts arbitrating one head → exactly one dispatch; the loser dispatches the next ticket; expired markers ignored and swept; forge failure fails open. - ADR 0007 amended, GOTCHAS row, journal entry. - Rollout is a pin bump per consumer (the host tick runs the first registered checkout's vendored copy); mixed pins behave as today.
Author
Owner

Claimed by Ben's interactive session (2026-11-18) — being worked now; swarm, skip this one.

Claimed by Ben's interactive session (2026-11-18) — being worked now; swarm, skip this one.
Author
Owner

Landed on main — 25e3123

  • fleet-queue-lib.sh: the dispatch marker (fleet_queue_arbitrate, fleet_queue_marks, fleet_queue_marks_sweep, fleet_queue_mark_release).
  • fleet-queue.sh: walks the fleet order from the head, skips a ticket a peer host holds, dispatches the first it wins (tick, after-close, rearm); sweeps this host's expired markers on every call.
  • ADR 0007 amendment, GOTCHAS #351, glossary Dispatch marker, journal 2026-11-18-351-dispatch-arbitration.md, STATUS row.

Proof (offline only): tests/fleet-queue-lib-test.sh 78/78, tests/fleet-queue-test.sh 43/43, the full offline suite (100 scripts) green, pinned shellcheck v0.11.0 clean on the four changed scripts.

Not yet proven live. Left open as ready-for-human for the rollout:

  1. FACTORY_REF bump on every consumer + the self-pin. A host arbitrates only once the FIRST checkout in its registry carries the change; a host on an older copy ignores markers.
  2. Acceptance: ready a ticket with two or more hosts idle → one fleet-dispatch marker on it, one run, and "taking the next ticket in line" in the other hosts' fleet-queue.log.

Known gap, not changed here: the per-host redispatch window (FLEET_QUEUE_REDISPATCH, 300 s) is shorter than the dispatch-to-claim latency seen on idss #2200 (387 s), so a host can still re-dispatch its OWN unclaimed pick to itself once. That is #315's probe behaviour; whether to lengthen the window is a separate call.

## Landed on `main` — `25e3123` - `fleet-queue-lib.sh`: the dispatch marker (`fleet_queue_arbitrate`, `fleet_queue_marks`, `fleet_queue_marks_sweep`, `fleet_queue_mark_release`). - `fleet-queue.sh`: walks the fleet order from the head, skips a ticket a peer host holds, dispatches the first it wins (`tick`, `after-close`, `rearm`); sweeps this host's expired markers on every call. - ADR 0007 amendment, GOTCHAS #351, glossary **Dispatch marker**, journal `2026-11-18-351-dispatch-arbitration.md`, STATUS row. **Proof (offline only):** `tests/fleet-queue-lib-test.sh` 78/78, `tests/fleet-queue-test.sh` 43/43, the full offline suite (100 scripts) green, pinned shellcheck v0.11.0 clean on the four changed scripts. **Not yet proven live.** Left open as `ready-for-human` for the rollout: 1. `FACTORY_REF` bump on every consumer + the self-pin. A host arbitrates only once the FIRST checkout in its registry carries the change; a host on an older copy ignores markers. 2. Acceptance: ready a ticket with two or more hosts idle → one `fleet-dispatch` marker on it, one run, and "taking the next ticket in line" in the other hosts' `fleet-queue.log`. **Known gap, not changed here:** the per-host redispatch window (`FLEET_QUEUE_REDISPATCH`, 300 s) is shorter than the dispatch-to-claim latency seen on idss #2200 (387 s), so a host can still re-dispatch its OWN unclaimed pick to itself once. That is #315's probe behaviour; whether to lengthen the window is a separate call.
Author
Owner

Live acceptance — passed 2026-11-19 13:52Z

Every consumer pins d468efc since 2026-11-19 (policy-generators cb88b49); all three pool hosts' first registry checkout (idss) carries the arbitration.

Matou/policy-generators#52 was re-armed at 13:51:31Z with all three hosts idle. The 13:52 tick on each host (~/swarm/logs/fleet-queue.log):

matou-workstation  13:52 dispatched Matou/policy-generators#52 to matou-workstation (fleet head; 1 ready fleet-wide)
elitebook-03       13:52 Matou/policy-generators#52 is being dispatched to matou-workstation — taking the next ticket in line
elitebook-03       13:52 the first 1 ready ticket(s) are already being dispatched to another host — nothing for elitebook-03 to dispatch (1 ready fleet-wide)
bens-mac-04        13:52 Matou/policy-generators#52 is being dispatched to matou-workstation — taking the next ticket in line
bens-mac-04        13:52 the first 1 ready ticket(s) are already being dispatched to another host — nothing for bens-mac-04 to dispatch (1 ready fleet-wide)

One workflow_dispatch run resulted (policy-generators run 638; before the fix the same situation produced three). The ticket carries one claim, swarm-claim host=matou-dev-server-01 run=638 at 13:52:52Z. The winner's marker comment is gone from the ticket and fleet-queue-marks on the winning host is empty, so the TTL sweep worked.

Not exercised live: a loser going on to dispatch a second ready ticket (only one was ready), and the fail-open path. Both are covered offline. Still owed: the self-pin (de5ebb8).

## Live acceptance — passed 2026-11-19 13:52Z Every consumer pins `d468efc` since 2026-11-19 (policy-generators `cb88b49`); all three pool hosts' first registry checkout (idss) carries the arbitration. `Matou/policy-generators#52` was re-armed at 13:51:31Z with all three hosts idle. The 13:52 tick on each host (`~/swarm/logs/fleet-queue.log`): ``` matou-workstation 13:52 dispatched Matou/policy-generators#52 to matou-workstation (fleet head; 1 ready fleet-wide) elitebook-03 13:52 Matou/policy-generators#52 is being dispatched to matou-workstation — taking the next ticket in line elitebook-03 13:52 the first 1 ready ticket(s) are already being dispatched to another host — nothing for elitebook-03 to dispatch (1 ready fleet-wide) bens-mac-04 13:52 Matou/policy-generators#52 is being dispatched to matou-workstation — taking the next ticket in line bens-mac-04 13:52 the first 1 ready ticket(s) are already being dispatched to another host — nothing for bens-mac-04 to dispatch (1 ready fleet-wide) ``` One `workflow_dispatch` run resulted (policy-generators run 638; before the fix the same situation produced three). The ticket carries one claim, `swarm-claim host=matou-dev-server-01 run=638` at 13:52:52Z. The winner's marker comment is gone from the ticket and `fleet-queue-marks` on the winning host is empty, so the TTL sweep worked. Not exercised live: a loser going on to dispatch a *second* ready ticket (only one was ready), and the fail-open path. Both are covered offline. Still owed: the self-pin (`de5ebb8`).
Author
Owner

Closing at Ben's instruction (2026-11-19). The fix is on every consumer and the live acceptance passed (comment above). The self-pin is not a condition of this ticket: each pool host's tick runs the copy vendored in the first repo of its registry, which is idss on all three hosts, so the factory's own vendored copy never arbitrates a dispatch. The change is in main's history (25e3123), so the next self-pin bump carries it.

Closing at Ben's instruction (2026-11-19). The fix is on every consumer and the live acceptance passed (comment above). The self-pin is not a condition of this ticket: each pool host's tick runs the copy vendored in the first repo of its registry, which is idss on all three hosts, so the factory's own vendored copy never arbitrates a dispatch. The change is in `main`'s history (`25e3123`), so the next self-pin bump carries it.
ben 2026-11-19 14:55:42 +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.

Dependencies

No dependencies set.

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