run-swarm.sh never consults the drive reservation (host_capacity_drive_wanted) — only session-runner yields, so a swarm worker starves a rehearsal drive under a held reservation #30

Closed
opened 2026-08-23 12:31:27 +00:00 by ben · 2 comments
Owner

Symptom (idss #652, elitebook-03, 2026-08-23 03:58–04:40Z)

The rehearsal executor declared its drive reservation (/tmp/matou-drive-wanted, re-touched every 2-min tick) and then logged host capacity busy … skipped 11 consecutive tick(s); reservation held so new heavy work yields to the drive — while a swarm worker started at 04:10:23Z, twelve minutes into the held reservation, and held the slot for 40+ min. The drive starved behind work that was supposed to yield to it.

Cause

idss #664 (ADR 0184's consumer half) wired host_capacity_drive_wanted (host-capacity-lib.sh:147, TTL 900 s) into session-runner.sh only (session-runner.sh:76). run-swarm.sh acquires its two-slot pool (the #577 flock, ~line 418 region) without ever consulting the reservation, so a swarm run that is about to claim a NEW ticket does not decline. The healer/triage entry points have the same gap (they are named in the executor's log line as classes that should yield).

Fix

  • In run-swarm.sh, before claiming a NEW ticket (the per-ticket claim loop, not mid-ticket), source host-capacity-lib.sh and if host_capacity_drive_wanted; then echo "run-swarm: drive reservation held — yielding this run"; exit 0; fi — the same posture as session-runner: yield, never camp (host-capacity-lib.sh header rule). A worker already inside a ticket finishes it.
  • Same predicate in the triage and healer entry points that take a slot.
  • tests/host-capacity-lib-test.sh (or a new run-swarm seam test): a declared, fresh reservation makes run-swarm exit 0 before any claim; an expired one (mtime > TTL) does not.
  • Log the yield with the reservation's age so the executor's "skipped N ticks" line and the swarm's "yielded" line corroborate.

Consumer repos pick it up at their next FACTORY_REF bump (idss re-vendors via #666's rail).

## Symptom (idss #652, elitebook-03, 2026-08-23 03:58–04:40Z) The rehearsal executor declared its drive reservation (`/tmp/matou-drive-wanted`, re-touched every 2-min tick) and then logged `host capacity busy … skipped 11 consecutive tick(s); reservation held so new heavy work yields to the drive` — while a **swarm worker started at 04:10:23Z**, twelve minutes *into* the held reservation, and held the slot for 40+ min. The drive starved behind work that was supposed to yield to it. ## Cause idss #664 (ADR 0184's consumer half) wired `host_capacity_drive_wanted` (`host-capacity-lib.sh:147`, TTL 900 s) into **`session-runner.sh` only** (`session-runner.sh:76`). `run-swarm.sh` acquires its two-slot pool (the #577 flock, ~line 418 region) without ever consulting the reservation, so a swarm run that is about to claim a NEW ticket does not decline. The healer/triage entry points have the same gap (they are named in the executor's log line as classes that should yield). ## Fix - In `run-swarm.sh`, before claiming a NEW ticket (the per-ticket claim loop, not mid-ticket), source `host-capacity-lib.sh` and `if host_capacity_drive_wanted; then echo "run-swarm: drive reservation held — yielding this run"; exit 0; fi` — the same posture as session-runner: yield, never camp (`host-capacity-lib.sh` header rule). A worker already inside a ticket finishes it. - Same predicate in the triage and healer entry points that take a slot. - `tests/host-capacity-lib-test.sh` (or a new `run-swarm` seam test): a declared, fresh reservation makes `run-swarm` exit 0 before any claim; an expired one (mtime > TTL) does not. - Log the yield with the reservation's age so the executor's "skipped N ticks" line and the swarm's "yielded" line corroborate. Consumer repos pick it up at their next `FACTORY_REF` bump (idss re-vendors via #666's rail).

swarm-claim host=elitebook-distributed-server-03 run=182
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=182 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #30 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 30,
  "status": "success",
  "commits": [
    "44e32eb"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "heal.sh",
    "host-capacity-lib.sh",
    "run-swarm.sh",
    "run-triage.sh",
    "tests/heal-test.sh",
    "tests/host-capacity-lib-test.sh",
    "tests/run-swarm-drive-yield-test.sh",
    "tests/run-triage-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/host-capacity-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/run-triage-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/run-swarm-drive-yield-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/heal-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\"; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "run-swarm.sh sources host-capacity-lib.sh and yields (exit 0) on a fresh reservation before claiming a NEW ticket": "run-swarm.sh: new drive-yield gate before the EXIT trap/verdict/preflight/pnpm/docker, sourcing host-capacity-lib.sh; proven by tests/run-swarm-drive-yield-test.sh (yields before any curl call)",
    "Same predicate in the triage and healer entry points that take a slot": "run-triage.sh (after the limit gate, before the /triage skill) and heal.sh (after the per-repo lock, before evidence/ledger) both check host_capacity_drive_wanted and yield",
    "Test: a declared fresh reservation makes the consumer exit 0 before any claim; an expired one (mtime > TTL) does not": "tests/run-swarm-drive-yield-test.sh (fresh yields before any curl / expired proceeds / count resets), plus whole-script fresh+expired cases in tests/run-triage-test.sh and tests/heal-test.sh",
    "Log the yield with the reservation's age so the executor and swarm lines corroborate": "new host_capacity_drive_wanted_age (host-capacity-lib.sh, tested in host-capacity-lib-test.sh); every yield line prints 'reservation age Ns — skipped N consecutive tick(s)'",
    "Each consumer bumps its OWN defer counter": "/tmp/matou-{swarm,triage,healer}-drive-defer-count via host_capacity_consumer_defer_bump/_reset; asserted in the run-triage/heal/run-swarm-drive-yield tests"
  },
  "summary": "run-swarm.sh, run-triage.sh and heal.sh now yield to a held rehearsal-drive capacity reservation before claiming new work, closing the starvation gap idss #664 left when it wired the predicate into session-runner only.",
  "blockers": []
}
**close-report** for #30 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 30, "status": "success", "commits": [ "44e32eb" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "heal.sh", "host-capacity-lib.sh", "run-swarm.sh", "run-triage.sh", "tests/heal-test.sh", "tests/host-capacity-lib-test.sh", "tests/run-swarm-drive-yield-test.sh", "tests/run-triage-test.sh" ], "tests": [ { "command": "bash tests/host-capacity-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/run-triage-test.sh", "exit_code": 0 }, { "command": "bash tests/run-swarm-drive-yield-test.sh", "exit_code": 0 }, { "command": "bash tests/heal-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\"; done", "exit_code": 0 } ], "criteria": { "run-swarm.sh sources host-capacity-lib.sh and yields (exit 0) on a fresh reservation before claiming a NEW ticket": "run-swarm.sh: new drive-yield gate before the EXIT trap/verdict/preflight/pnpm/docker, sourcing host-capacity-lib.sh; proven by tests/run-swarm-drive-yield-test.sh (yields before any curl call)", "Same predicate in the triage and healer entry points that take a slot": "run-triage.sh (after the limit gate, before the /triage skill) and heal.sh (after the per-repo lock, before evidence/ledger) both check host_capacity_drive_wanted and yield", "Test: a declared fresh reservation makes the consumer exit 0 before any claim; an expired one (mtime > TTL) does not": "tests/run-swarm-drive-yield-test.sh (fresh yields before any curl / expired proceeds / count resets), plus whole-script fresh+expired cases in tests/run-triage-test.sh and tests/heal-test.sh", "Log the yield with the reservation's age so the executor and swarm lines corroborate": "new host_capacity_drive_wanted_age (host-capacity-lib.sh, tested in host-capacity-lib-test.sh); every yield line prints 'reservation age Ns — skipped N consecutive tick(s)'", "Each consumer bumps its OWN defer counter": "/tmp/matou-{swarm,triage,healer}-drive-defer-count via host_capacity_consumer_defer_bump/_reset; asserted in the run-triage/heal/run-swarm-drive-yield tests" }, "summary": "run-swarm.sh, run-triage.sh and heal.sh now yield to a held rehearsal-drive capacity reservation before claiming new work, closing the starvation gap idss #664 left when it wired the predicate into session-runner only.", "blockers": [] } ``` </details>
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#30
No description provided.