Design: should the fleet dispatcher allocate session work too, replacing the 10-minute per-repo session-runner ticks? (amends ADR 0009) #387

Open
opened 2026-11-20 20:04:59 +00:00 by ben · 0 comments
Owner

ADR 0009 left session work out of scope ("the session-runner … drains a different queue. Its slots are visible in the slot report; allocating session work is out of scope here"). Ben asked on 2026-11-20 to review that. This ticket is the design question; nothing here is decided.

How the session lane works today

  • Queue: ready-for-session tickets. The swarm lister and the dispatcher never see them.
  • Scheduler: one cron line per enrolled repo per host, every 10 minutes (7 lines on matou-workstation, 6 on bens-mac-04, 5 on elitebook-03 — 18 polls every 10 minutes fleet-wide).
  • One tick (session-runner.sh): kill switch → repo-scoped lock → limit park → pick the first workable ticket (priority, then oldest; skips blocked / cooling-down / wrong session-host) → claim (swarm-claim arbitration, #125) → take one of the host's two heavy slots → one headless session, up to SESSION_RUNNER_TIMEOUT (7200 s), in a dedicated checkout, with host standing (not a sandboxed workflow run). Two unadvanced attempts → agent-blocked.
  • Capacity: the heavy slot is the SAME pool the dispatcher allocates. If both are held the tick is absorbed.

What is wrong with it

  1. Two schedulers, one pool, no shared intent. The dispatcher sees a slot free and dispatches to it; a session tick can take that slot seconds earlier or later. The loser yields (a wasted leg, and for the dispatcher a marker TTL of delay). Neither side can prefer "swarm ticket X is higher priority than session ticket Y" — there is no fleet order across the two queues.
  2. Placement is by cron phase, not by which host is free. The host whose line fires first takes the ticket, even if it is the busiest host.
  3. Latency and waste. A ready session ticket waits up to 10 minutes for a poll. On matou-workstation over 7 days (2026-11-13→20): ~200 picks against ~12,000 quiet ticks and ~6,500 absorbed ticks (session in flight or pool exhausted) across six repos.
  4. No fleet view of why a session ticket is not running. On 2026-11-20 twelve ready-for-session tickets showed as ready on the floor while every one was blocked by an open dependency; the reason was only in per-repo host logs.

What makes it harder than the swarm lane

  • A session is started ON the host with host standing; there is no workflow run to dispatch. The dispatcher would need a start seam per host (the host's tick could become a thin "ask the dispatcher, run what it names" — the shape the fleet-queue tick already has with the ack).
  • Sessions have constraints the allocator must know, as #384 showed for swarm runs: one session per repo per host (repo-scoped lock), <!-- session-host: --> affinity (#89), the two-account usage-limit park, cooling-down and attempt counters kept in host state.
  • Fallback: ADR 0009 decision 4 (stop the dispatcher and the hosts' own ticks carry on) must hold for sessions too, so the cron tick has to remain as the fallback path, not be deleted.

Options

  • A. Leave as is and only fix visibility (surface the session runner's skip reasons fleet-wide). Cheapest; keeps problems 1–3.
  • B. Dispatcher allocates, host tick executes. One fleet order over both queues; the dispatcher names (ticket, host) for sessions as it does for swarm picks; the host's session tick stands down on an acting ack and otherwise runs as today. Reuses slices 3–4 of ADR 0009. The session tick still exists, so fallback is unchanged.
  • C. Event-driven start. As B, plus the dispatcher pokes the host to start the named session at once instead of waiting for the next cron poll (needs a host-side receiver or a faster poll of the ack). Removes the 10-minute latency; more moving parts and a new inbound path on each host.

Questions for the ruling

  1. Is one fleet order across swarm and session tickets wanted, and what is the tie-break between the two kinds?
  2. B or C — is up to 10 minutes of start latency for a session acceptable?
  3. Does the dispatcher learn the session constraints (affinity, per-repo lock, limit park) from the slot report, or does the host keep the veto and simply decline an offer?
  4. Staging: shadow first, as ADR 0009 decision 6 did?

Suggested order: after #384 is live and observed, and after the per-repo lock question, so the allocator's constraint model is settled before a second kind of work is added to it.

Written by an interactive session at Ben's request.

ADR 0009 left session work out of scope ("the session-runner … drains a different queue. Its slots are visible in the slot report; allocating session work is out of scope here"). Ben asked on 2026-11-20 to review that. This ticket is the design question; nothing here is decided. ## How the session lane works today - **Queue:** `ready-for-session` tickets. The swarm lister and the dispatcher never see them. - **Scheduler:** one cron line per enrolled repo per host, every 10 minutes (7 lines on `matou-workstation`, 6 on `bens-mac-04`, 5 on `elitebook-03` — 18 polls every 10 minutes fleet-wide). - **One tick** (`session-runner.sh`): kill switch → repo-scoped lock → limit park → pick the first workable ticket (priority, then oldest; skips blocked / cooling-down / wrong `session-host`) → claim (`swarm-claim` arbitration, #125) → take one of the host's two heavy slots → one headless session, up to `SESSION_RUNNER_TIMEOUT` (7200 s), in a dedicated checkout, with host standing (not a sandboxed workflow run). Two unadvanced attempts → `agent-blocked`. - **Capacity:** the heavy slot is the SAME pool the dispatcher allocates. If both are held the tick is absorbed. ## What is wrong with it 1. **Two schedulers, one pool, no shared intent.** The dispatcher sees a slot `free` and dispatches to it; a session tick can take that slot seconds earlier or later. The loser yields (a wasted leg, and for the dispatcher a marker TTL of delay). Neither side can prefer "swarm ticket X is higher priority than session ticket Y" — there is no fleet order across the two queues. 2. **Placement is by cron phase, not by which host is free.** The host whose line fires first takes the ticket, even if it is the busiest host. 3. **Latency and waste.** A ready session ticket waits up to 10 minutes for a poll. On `matou-workstation` over 7 days (2026-11-13→20): ~200 picks against ~12,000 quiet ticks and ~6,500 absorbed ticks (session in flight or pool exhausted) across six repos. 4. **No fleet view of why a session ticket is not running.** On 2026-11-20 twelve `ready-for-session` tickets showed as ready on the floor while every one was blocked by an open dependency; the reason was only in per-repo host logs. ## What makes it harder than the swarm lane - A session is started ON the host with host standing; there is no workflow run to dispatch. The dispatcher would need a start seam per host (the host's tick could become a thin "ask the dispatcher, run what it names" — the shape the fleet-queue tick already has with the ack). - Sessions have constraints the allocator must know, as #384 showed for swarm runs: one session per repo per host (repo-scoped lock), `<!-- session-host: -->` affinity (#89), the two-account usage-limit park, cooling-down and attempt counters kept in host state. - Fallback: ADR 0009 decision 4 (stop the dispatcher and the hosts' own ticks carry on) must hold for sessions too, so the cron tick has to remain as the fallback path, not be deleted. ## Options - **A. Leave as is** and only fix visibility (surface the session runner's skip reasons fleet-wide). Cheapest; keeps problems 1–3. - **B. Dispatcher allocates, host tick executes.** One fleet order over both queues; the dispatcher names (ticket, host) for sessions as it does for swarm picks; the host's session tick stands down on an `acting` ack and otherwise runs as today. Reuses slices 3–4 of ADR 0009. The session tick still exists, so fallback is unchanged. - **C. Event-driven start.** As B, plus the dispatcher pokes the host to start the named session at once instead of waiting for the next cron poll (needs a host-side receiver or a faster poll of the ack). Removes the 10-minute latency; more moving parts and a new inbound path on each host. ## Questions for the ruling 1. Is one fleet order across swarm and session tickets wanted, and what is the tie-break between the two kinds? 2. B or C — is up to 10 minutes of start latency for a session acceptable? 3. Does the dispatcher learn the session constraints (affinity, per-repo lock, limit park) from the slot report, or does the host keep the veto and simply decline an offer? 4. Staging: shadow first, as ADR 0009 decision 6 did? Suggested order: after #384 is live and observed, and after the per-repo lock question, so the allocator's constraint model is settled before a second kind of work is added to it. Written by an interactive session at Ben's request.
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#387
No description provided.