host-capacity: HOST_CAPACITY_DRIVE_MODE=single-slot on hosts with headroom — the drive stops idling an 8-core box (design) #46

Closed
opened 2026-08-24 01:33:57 +00:00 by ben · 3 comments
Owner

Design question — do NOT pick up as agent work until the mode below is ruled on (Ben)

Blocked by: design decision; also wants #45 + the pool-aware workflow cutover (matou-app PR #81) live for a soak period first, so the drive's exclusive mode is no longer confounded with the single-lock starvation bug.

Observation (2026-08-23)

The rehearsal drive takes ALL host-capacity slots (host_capacity_acquire_exclusive, ADR 0184's "coexist with nothing heavy") for its whole 1–2 h lifetime. On elitebook-03 that reserved an 8-core/14 GB host that sar shows 90–97% CPU idle every hour of the day, ~12 GB free — a drive is mostly network waits (release-asset downloads, nixos-anywhere over SSH to a droplet, polling), with short nix-build bursts. ~12 drives ran there today; every swarm/triage tick on every repo yielded to them. The exclusivity rule was sized for the 7 GB workstation when it was genuinely swapping; applied to elitebook it idles a machine.

Proposal

A per-host knob in the identity layer (beside SWARM_GIT_NAME etc., or swarm-policy.sh if per-repo is ever wanted): HOST_CAPACITY_DRIVE_MODE=exclusive|single-slot, default exclusive (today's behaviour, byte-identical when unset). Under single-slot the drive acquires slot 1 only, leaving slot 2 for one worker. Enable on elitebook-03 only, after the soak.

Why NOT to just do it (the reasons to weigh)

  1. Timing-sensitive drive measurements. Drives carry tuned ceilings/budgets (idss #697 per-row budgets, #698 enroll-copy 10m→90m). A worker + sandbox container beside a drive adds noisy-neighbour jitter; one flaky drive red triggers healer churn that likely costs more than a day of idle cores saves. Mitigation to evaluate: single-slot could exclude container-building workers, or drives could stamp host-load into their verdicts so a jitter-red is attributable.
  2. Claude account budget, not RAM, sized the pool. 2 slots ≈ 2 OAuth tokens. A drive's healer already calls Claude; drive + worker = 2 callers, at the budget, fine — but drive + worker during a drive-red heal = 3, and a limit-park parks the whole host. Needs a ruling on whether the heal path counts as the drive's own slot.
  3. Correctness assumptions. Sweep logic (sweep-lib.sh) was already ported to pool semantics, but audit for any remaining "drive implies nothing else is live" assumption (ports, docker networks, kanidm fixtures) before enabling.

Acceptance (if approved)

  • host-capacity-lib-test.sh: single-slot acquires exactly slot 1; exclusive unchanged; unset = exclusive.
  • Soak: 1 week of elitebook drives under single-slot with drive red-rate no worse than the trailing week; revert is flipping the knob.
## Design question — do NOT pick up as agent work until the mode below is ruled on (Ben) **Blocked by:** design decision; also wants #45 + the pool-aware workflow cutover (matou-app PR #81) live for a soak period first, so the drive's exclusive mode is no longer confounded with the single-lock starvation bug. ## Observation (2026-08-23) The rehearsal drive takes ALL host-capacity slots (`host_capacity_acquire_exclusive`, ADR 0184's "coexist with nothing heavy") for its whole 1–2 h lifetime. On elitebook-03 that reserved an 8-core/14 GB host that sar shows **90–97% CPU idle every hour of the day, ~12 GB free** — a drive is mostly network waits (release-asset downloads, nixos-anywhere over SSH to a droplet, polling), with short nix-build bursts. ~12 drives ran there today; every swarm/triage tick on every repo yielded to them. The exclusivity rule was sized for the 7 GB workstation when it was genuinely swapping; applied to elitebook it idles a machine. ## Proposal A per-host knob in the identity layer (beside `SWARM_GIT_NAME` etc., or `swarm-policy.sh` if per-repo is ever wanted): `HOST_CAPACITY_DRIVE_MODE=exclusive|single-slot`, default **exclusive** (today's behaviour, byte-identical when unset). Under `single-slot` the drive acquires slot 1 only, leaving slot 2 for one worker. Enable on elitebook-03 only, after the soak. ## Why NOT to just do it (the reasons to weigh) 1. **Timing-sensitive drive measurements.** Drives carry tuned ceilings/budgets (idss #697 per-row budgets, #698 enroll-copy 10m→90m). A worker + sandbox container beside a drive adds noisy-neighbour jitter; one flaky drive red triggers healer churn that likely costs more than a day of idle cores saves. Mitigation to evaluate: `single-slot` could exclude container-building workers, or drives could stamp host-load into their verdicts so a jitter-red is attributable. 2. **Claude account budget, not RAM, sized the pool.** 2 slots ≈ 2 OAuth tokens. A drive's healer already calls Claude; drive + worker = 2 callers, at the budget, fine — but drive + worker during a drive-red heal = 3, and a limit-park parks the whole host. Needs a ruling on whether the heal path counts as the drive's own slot. 3. **Correctness assumptions.** Sweep logic (`sweep-lib.sh`) was already ported to pool semantics, but audit for any remaining "drive implies nothing else is live" assumption (ports, docker networks, kanidm fixtures) before enabling. ## Acceptance (if approved) - `host-capacity-lib-test.sh`: `single-slot` acquires exactly slot 1; `exclusive` unchanged; unset = exclusive. - Soak: 1 week of elitebook drives under `single-slot` with drive red-rate no worse than the trailing week; revert is flipping the knob.
Author
Owner

Ruling (Ben, 2026-08-24): approved — the drive gives up one slot on big hosts.

Scope as ruled:

  • HOST_CAPACITY_DRIVE_MODE=single-slot|exclusive, default exclusive (unset = byte-identical today). Under single-slot the drive acquires slot 1 only and leaves slot 2 to the pool.
  • Enable on big hosts only — concretely elitebook-03 (8 cores / 14 GB) now; the 7 GB workstation stays exclusive.
  • The open sub-questions resolve to implementer defaults: worker-beside-drive is allowed on single-slot hosts (that's the point); the drive's heal path rides the drive's own slot (a heal never takes slot 2); no container-worker carve-out in v1 — if drive reds go flaky on elitebook-03, the revert is flipping the knob back to exclusive, and THEN we discuss carve-outs.

Split of work:

  1. Factory (this ticket, agent-workable): host_capacity_acquire_exclusive honours the mode (env HOST_CAPACITY_DRIVE_MODE), host-capacity-lib-test.sh gains single-slot-acquires-exactly-slot-1 / exclusive-unchanged / unset-means-exclusive cases, plus the residual-exclusivity-assumption audit named in the ticket body (grep consumers for "drive implies nothing else live").
  2. Consumer chain (not this ticket): idss re-vendors the pin so its .sandcastle/host-capacity-lib.sh carries the knob, then the host half — HOST_CAPACITY_DRIVE_MODE=single-slot in elitebook-03's rehearsal-env.sh — is a one-line host edit (Ben/session), never a repo hardcode.

Watch item for the first soak week on elitebook-03: drive red-rate vs the trailing week. Flaky-red regression ⇒ flip the knob back, no code revert needed.

**Ruling (Ben, 2026-08-24): approved — the drive gives up one slot on big hosts.** Scope as ruled: - `HOST_CAPACITY_DRIVE_MODE=single-slot|exclusive`, default **exclusive** (unset = byte-identical today). Under `single-slot` the drive acquires slot 1 only and leaves slot 2 to the pool. - Enable on **big hosts only** — concretely elitebook-03 (8 cores / 14 GB) now; the 7 GB workstation stays exclusive. - The open sub-questions resolve to implementer defaults: worker-beside-drive is allowed on single-slot hosts (that's the point); the drive's heal path rides the drive's own slot (a heal never takes slot 2); no container-worker carve-out in v1 — if drive reds go flaky on elitebook-03, the revert is flipping the knob back to `exclusive`, and THEN we discuss carve-outs. Split of work: 1. **Factory (this ticket, agent-workable):** `host_capacity_acquire_exclusive` honours the mode (env `HOST_CAPACITY_DRIVE_MODE`), `host-capacity-lib-test.sh` gains single-slot-acquires-exactly-slot-1 / exclusive-unchanged / unset-means-exclusive cases, plus the residual-exclusivity-assumption audit named in the ticket body (grep consumers for "drive implies nothing else live"). 2. **Consumer chain (not this ticket):** idss re-vendors the pin so its `.sandcastle/host-capacity-lib.sh` carries the knob, then the host half — `HOST_CAPACITY_DRIVE_MODE=single-slot` in elitebook-03's `rehearsal-env.sh` — is a one-line host edit (Ben/session), never a repo hardcode. Watch item for the first soak week on elitebook-03: drive red-rate vs the trailing week. Flaky-red regression ⇒ flip the knob back, no code revert needed.

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

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

close-report for #46 — status success

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

envelope
{
  "issue": 46,
  "status": "success",
  "commits": [
    "3f86bd2"
  ],
  "changed_files": [
    "host-capacity-lib.sh",
    "tests/host-capacity-lib-test.sh",
    "STATUS.md"
  ],
  "tests": [
    {
      "command": "bash tests/host-capacity-lib-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": {
    "host-capacity-lib-test.sh: single-slot acquires exactly slot 1": "tests/host-capacity-lib-test.sh new case 'single-slot, only the pooled slots named' asserts fds=1, slot1 held (no LEAK), slot2-free — commit 3f86bd2",
    "host-capacity-lib-test.sh: exclusive unchanged": "new case 'exclusive, set EXPLICITLY' asserts both pooled slots held (fds=2, no LEAK on slot2) — commit 3f86bd2",
    "host-capacity-lib-test.sh: unset = exclusive": "new case 'UNSET == exclusive' asserts both pooled slots held (fds=2) after unset HOST_CAPACITY_DRIVE_MODE — commit 3f86bd2",
    "host_capacity_acquire_exclusive honours HOST_CAPACITY_DRIVE_MODE (env)": "host-capacity-lib.sh: acquire reads mode=${HOST_CAPACITY_DRIVE_MODE:-exclusive}; single-slot skips pooled slots past the first via _host_capacity_pool_slot_past_first — commit 3f86bd2",
    "residual-exclusivity-assumption audit (grep consumers for 'drive implies nothing else live')": "Audit reported in commit message + STATUS Host-capacity row: sweep-lib.sh already pool-safe (age-floor spares live sibling; reap_containers's 'no other swarm live' comment descriptive, 3h floor is the real guard, holds under single-slot); no port/docker-network/kanidm exclusivity assumption in the harness. No code change needed for the audit.",
    "byte-identical when unset (default exclusive)": "acquire default is exclusive; the unset==exclusive test proves both pooled slots still acquired — commit 3f86bd2"
  },
  "summary": "host_capacity_acquire_exclusive honours HOST_CAPACITY_DRIVE_MODE=single-slot|exclusive so a drive on a big host keeps slot 1 (and its sibling locks) but leaves slot 2 to the pool, per Ben's #46 ruling; lib + 4 test cases + STATUS, plus the residual-exclusivity audit (clean).",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #46 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 46, "status": "success", "commits": [ "3f86bd2" ], "changed_files": [ "host-capacity-lib.sh", "tests/host-capacity-lib-test.sh", "STATUS.md" ], "tests": [ { "command": "bash tests/host-capacity-lib-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": { "host-capacity-lib-test.sh: single-slot acquires exactly slot 1": "tests/host-capacity-lib-test.sh new case 'single-slot, only the pooled slots named' asserts fds=1, slot1 held (no LEAK), slot2-free — commit 3f86bd2", "host-capacity-lib-test.sh: exclusive unchanged": "new case 'exclusive, set EXPLICITLY' asserts both pooled slots held (fds=2, no LEAK on slot2) — commit 3f86bd2", "host-capacity-lib-test.sh: unset = exclusive": "new case 'UNSET == exclusive' asserts both pooled slots held (fds=2) after unset HOST_CAPACITY_DRIVE_MODE — commit 3f86bd2", "host_capacity_acquire_exclusive honours HOST_CAPACITY_DRIVE_MODE (env)": "host-capacity-lib.sh: acquire reads mode=${HOST_CAPACITY_DRIVE_MODE:-exclusive}; single-slot skips pooled slots past the first via _host_capacity_pool_slot_past_first — commit 3f86bd2", "residual-exclusivity-assumption audit (grep consumers for 'drive implies nothing else live')": "Audit reported in commit message + STATUS Host-capacity row: sweep-lib.sh already pool-safe (age-floor spares live sibling; reap_containers's 'no other swarm live' comment descriptive, 3h floor is the real guard, holds under single-slot); no port/docker-network/kanidm exclusivity assumption in the harness. No code change needed for the audit.", "byte-identical when unset (default exclusive)": "acquire default is exclusive; the unset==exclusive test proves both pooled slots still acquired — commit 3f86bd2" }, "summary": "host_capacity_acquire_exclusive honours HOST_CAPACITY_DRIVE_MODE=single-slot|exclusive so a drive on a big host keeps slot 1 (and its sibling locks) but leaves slot 2 to the pool, per Ben's #46 ruling; lib + 4 test cases + STATUS, plus the residual-exclusivity audit (clean).", "reason": "", "blockers": [], "no_code_change": "" } ``` </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#46
No description provided.