rehearsal-cycle.sh: DRIVE_EXCLUSIVE=all|slot per-host knob (dev-factory ADR 0003, per-host drive exclusivity) #706

Closed
opened 2026-08-23 13:24:09 +00:00 by matou-build-agent · 3 comments

Ask

rehearsal-cycle.sh currently always excludes everything heavy on the host
for a drive's whole run (host_capacity_acquire_exclusive over both pooled
slots + the session-runner lock + the repo's healer lock — ADR 0184). Make
that a per-host knob instead of the only mode:

DRIVE_EXCLUSIVE=all|slot, read from the environment (set in the host's own
rehearsal-env.sh, the file already sourced by the cron line ahead of
rehearsal-cycle.sh — see onboarding/README.md's token-sync.yml note in
Matou/dev-factory for the existing precedent of a host-local, untracked env
file in this role).

  • all (default, unset falls back here): today's exact behaviour —
    host_capacity_acquire_exclusive /tmp/matou-swarm.lock /tmp/matou-host-slot-2.lock /tmp/matou-session-runner.lock /tmp/matou-healer-Matou-idss.lock, byte-identical to the current call
    right after host_capacity_drive_reserve in scripts/rehearsal-cycle.sh.
  • slot: host_capacity_acquire_heavy (one pooled slot, first-fit) —
    scripts/lib/host-capacity-lib.sh already has this primitive, no change
    needed there. The drive's own /tmp/matou-rehearsal-drive.lock is already
    held earlier in the script and stays as-is. Session-runner and the healer
    are deliberately NOT excluded under this mode.

No new primitive is needed in host-capacity-lib.sh — both
host_capacity_acquire_heavy and host_capacity_acquire_exclusive already
exist and are already tested (scripts/tests/host-capacity-lib-test.sh).
This ticket is purely the rehearsal-cycle.sh call-site branch plus its
offline test.

Why

elitebook-03 (8 CPU / 14 GB, ~12 GB free) starved standing-drive #657 for
43 consecutive */2 ticks (86 min, 2026-08-22) behind ordinary dev-factory
swarm workers, while sitting at load ≈0.2 the whole time — the drive itself
then ran GREEN in 11½ minutes. ADR 0184's all-four-locks exclusivity was
sized for matou-workstation (4 vCPU / 7 GB, also the product dev server);
it does not fit a headroom host like elitebook-03, where a drive (Playwright

  • SSH to a droplet, no local build) plus one pooled worker plus base services
    fit comfortably in observed free RAM. Full reasoning and the RAM numbers:
    Matou/dev-factory ADR docs/adr/0003-drive-exclusivity-is-a-per-host-knob.md
    (ticket Matou/dev-factory#25).

Acceptance

  • rehearsal-cycle.sh branches on DRIVE_EXCLUSIVE right where it currently
    calls host_capacity_acquire_exclusive; unset/all is byte-identical to
    today.
  • Offline test (new or extended scripts/tests/) proves both modes: all
    calls the four-lock exclusive acquire exactly as before; slot calls the
    one-slot heavy acquire and does NOT touch the session-runner or healer
    locks.
  • Live: with DRIVE_EXCLUSIVE=slot set in elitebook-03's
    rehearsal-env.sh (a human/session step, not this ticket's own scope), a
    ready drive fires within one */2 tick while one dev-factory worker is
    running on that host.

Ruled by agent under ADR 0174 — veto anytime. Two-way door: a per-host env
knob defaulting to today's exact behaviour, provable by an offline test.

## Ask `rehearsal-cycle.sh` currently always excludes everything heavy on the host for a drive's whole run (`host_capacity_acquire_exclusive` over both pooled slots + the session-runner lock + the repo's healer lock — ADR 0184). Make that a per-host knob instead of the only mode: `DRIVE_EXCLUSIVE=all|slot`, read from the environment (set in the host's own `rehearsal-env.sh`, the file already sourced by the cron line ahead of `rehearsal-cycle.sh` — see `onboarding/README.md`'s `token-sync.yml` note in `Matou/dev-factory` for the existing precedent of a host-local, untracked env file in this role). - `all` (default, unset falls back here): today's exact behaviour — `host_capacity_acquire_exclusive /tmp/matou-swarm.lock /tmp/matou-host-slot-2.lock /tmp/matou-session-runner.lock /tmp/matou-healer-Matou-idss.lock`, byte-identical to the current call right after `host_capacity_drive_reserve` in `scripts/rehearsal-cycle.sh`. - `slot`: `host_capacity_acquire_heavy` (one pooled slot, first-fit) — `scripts/lib/host-capacity-lib.sh` already has this primitive, no change needed there. The drive's own `/tmp/matou-rehearsal-drive.lock` is already held earlier in the script and stays as-is. Session-runner and the healer are deliberately NOT excluded under this mode. No new primitive is needed in `host-capacity-lib.sh` — both `host_capacity_acquire_heavy` and `host_capacity_acquire_exclusive` already exist and are already tested (`scripts/tests/host-capacity-lib-test.sh`). This ticket is purely the `rehearsal-cycle.sh` call-site branch plus its offline test. ## Why `elitebook-03` (8 CPU / 14 GB, ~12 GB free) starved standing-drive #657 for 43 consecutive `*/2` ticks (86 min, 2026-08-22) behind ordinary dev-factory swarm workers, while sitting at load ≈0.2 the whole time — the drive itself then ran GREEN in 11½ minutes. ADR 0184's all-four-locks exclusivity was sized for `matou-workstation` (4 vCPU / 7 GB, also the product dev server); it does not fit a headroom host like `elitebook-03`, where a drive (Playwright + SSH to a droplet, no local build) plus one pooled worker plus base services fit comfortably in observed free RAM. Full reasoning and the RAM numbers: `Matou/dev-factory` ADR `docs/adr/0003-drive-exclusivity-is-a-per-host-knob.md` (ticket `Matou/dev-factory#25`). ## Acceptance - `rehearsal-cycle.sh` branches on `DRIVE_EXCLUSIVE` right where it currently calls `host_capacity_acquire_exclusive`; unset/`all` is byte-identical to today. - Offline test (new or extended `scripts/tests/`) proves both modes: `all` calls the four-lock exclusive acquire exactly as before; `slot` calls the one-slot heavy acquire and does NOT touch the session-runner or healer locks. - Live: with `DRIVE_EXCLUSIVE=slot` set in `elitebook-03`'s `rehearsal-env.sh` (a human/session step, not this ticket's own scope), a ready drive fires within one `*/2` tick while one dev-factory worker is running on that host. Ruled by agent under ADR 0174 — veto anytime. Two-way door: a per-host env knob defaulting to today's exact behaviour, provable by an offline test.
Author
Member

This was generated by AI during triage.

Triage

Category: enhancement
Verification: redundancy check — DRIVE_EXCLUSIVE does not exist in rehearsal-cycle.sh today; the call site still unconditionally uses the four-lock exclusive acquire. No .out-of-scope/ entry matches. No UX flow/wireframe is referenced (not design-tier work). No ## Why human line and nothing on the ADR 0174 one-way-door list — this is a per-host env knob defaulting to today's exact behaviour, provable by an offline test, so it's a two-way door: agent-actionable.

Agent Brief

Category: enhancement
Summary: Make the rehearsal drive's host-capacity exclusivity mode a per-host knob (DRIVE_EXCLUSIVE=all|slot) instead of always acquiring full exclusivity.

Current behavior:
The rehearsal drive cycle always acquires full host exclusivity before running a drive — it holds the pooled-slot lock, the session-runner lock, and the repo's healer lock simultaneously, for the drive's entire run. This is sized for a small/shared host, but starves ordinary work on a larger host that has enough headroom to run a drive alongside other work.

Desired behavior:
The exclusivity mode is controlled by a DRIVE_EXCLUSIVE environment variable, read at the point the cycle currently acquires exclusivity:

  • Unset or all (the default): identical behavior to today — full exclusivity across all four locks (pooled slots + session-runner + healer).
  • slot: acquire only one pooled capacity slot (the existing single-slot, first-fit, non-blocking primitive) — session-runner and the healer lock are deliberately left unexcluded. The drive's own drive-lock (already acquired earlier in the flow) is unaffected either way.

Both underlying primitives already exist and are already tested; this is purely a branch at the existing call site, controlled by the new env var.

Key interfaces:

  • The rehearsal cycle's capacity-acquisition call site — branches on DRIVE_EXCLUSIVE right where it currently does the unconditional exclusive acquire.
  • The two existing host-capacity primitives (one full multi-lock exclusive acquire, one single pooled-slot acquire) — no new primitive needed, no change to their signatures.

Acceptance criteria:

  • DRIVE_EXCLUSIVE unset or all produces byte-identical lock acquisition to today (all four locks, exclusive).
  • DRIVE_EXCLUSIVE=slot acquires exactly one pooled capacity slot and does NOT touch the session-runner or healer locks.
  • An offline test proves both branches (which primitive gets called, and with which locks, for each mode).
  • The drive's own drive-lock acquisition (already happening earlier in the flow) is unchanged in both modes.

Out of scope:

  • Adding the primitive itself to the host-capacity library (both already exist).
  • Setting DRIVE_EXCLUSIVE=slot in any specific host's environment config — that's a separate operational step, not part of this change.
  • Any change to the drive's own top-level lock.
> *This was generated by AI during triage.* ## Triage **Category:** enhancement **Verification:** redundancy check — `DRIVE_EXCLUSIVE` does not exist in `rehearsal-cycle.sh` today; the call site still unconditionally uses the four-lock exclusive acquire. No `.out-of-scope/` entry matches. No UX flow/wireframe is referenced (not design-tier work). No `## Why human` line and nothing on the ADR 0174 one-way-door list — this is a per-host env knob defaulting to today's exact behaviour, provable by an offline test, so it's a two-way door: agent-actionable. ## Agent Brief **Category:** enhancement **Summary:** Make the rehearsal drive's host-capacity exclusivity mode a per-host knob (`DRIVE_EXCLUSIVE=all|slot`) instead of always acquiring full exclusivity. **Current behavior:** The rehearsal drive cycle always acquires full host exclusivity before running a drive — it holds the pooled-slot lock, the session-runner lock, and the repo's healer lock simultaneously, for the drive's entire run. This is sized for a small/shared host, but starves ordinary work on a larger host that has enough headroom to run a drive alongside other work. **Desired behavior:** The exclusivity mode is controlled by a `DRIVE_EXCLUSIVE` environment variable, read at the point the cycle currently acquires exclusivity: - Unset or `all` (the default): identical behavior to today — full exclusivity across all four locks (pooled slots + session-runner + healer). - `slot`: acquire only one pooled capacity slot (the existing single-slot, first-fit, non-blocking primitive) — session-runner and the healer lock are deliberately left unexcluded. The drive's own drive-lock (already acquired earlier in the flow) is unaffected either way. Both underlying primitives already exist and are already tested; this is purely a branch at the existing call site, controlled by the new env var. **Key interfaces:** - The rehearsal cycle's capacity-acquisition call site — branches on `DRIVE_EXCLUSIVE` right where it currently does the unconditional exclusive acquire. - The two existing host-capacity primitives (one full multi-lock exclusive acquire, one single pooled-slot acquire) — no new primitive needed, no change to their signatures. **Acceptance criteria:** - [ ] `DRIVE_EXCLUSIVE` unset or `all` produces byte-identical lock acquisition to today (all four locks, exclusive). - [ ] `DRIVE_EXCLUSIVE=slot` acquires exactly one pooled capacity slot and does NOT touch the session-runner or healer locks. - [ ] An offline test proves both branches (which primitive gets called, and with which locks, for each mode). - [ ] The drive's own drive-lock acquisition (already happening earlier in the flow) is unchanged in both modes. **Out of scope:** - Adding the primitive itself to the host-capacity library (both already exist). - Setting `DRIVE_EXCLUSIVE=slot` in any specific host's environment config — that's a separate operational step, not part of this change. - Any change to the drive's own top-level lock.
Author
Member

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

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

close-report for #706 — status success

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

envelope
{
  "issue": 706,
  "status": "success",
  "commits": [
    "e83a8eda9608504784ce3654f13817e16962fb3c"
  ],
  "changed_files": [
    "STATUS.md",
    "scripts/rehearsal-cycle.sh",
    "scripts/tests/rehearsal-drive-exclusive-test.sh"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/host-capacity-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n scripts/rehearsal-cycle.sh",
      "exit_code": 0
    }
  ],
  "criteria": {
    "rehearsal-cycle.sh branches on DRIVE_EXCLUSIVE right where it currently calls host_capacity_acquire_exclusive; unset/all is byte-identical to today": "scripts/rehearsal-cycle.sh: a `case \"${DRIVE_EXCLUSIVE:-all}\" in` branch replaces the bare acquire immediately after host_capacity_drive_reserve; the *) (all/unset) arm keeps the four-lock host_capacity_acquire_exclusive call verbatim (/tmp/matou-swarm.lock /tmp/matou-host-slot-2.lock /tmp/matou-session-runner.lock /tmp/matou-healer-Matou-idss.lock), asserted byte-for-byte by test check 6",
    "Offline test proves both modes: all calls the four-lock exclusive acquire exactly as before; slot calls the one-slot heavy acquire and does NOT touch the session-runner or healer locks": "scripts/tests/rehearsal-drive-exclusive-test.sh checks 1-2 (unset & all -> exclusive with the four locks unchanged, no heavy), check 3 (slot -> host_capacity_acquire_heavy only, log never names session-runner or healer), checks 4-5 (busy-yield paths bump skip counter without crossing modes); exit 0",
    "Live: DRIVE_EXCLUSIVE=slot on elitebook-03 fires a ready drive within one */2 tick beside a dev-factory worker": "explicitly a human/session step outside this ticket's scope per the acceptance clause; the ticket's own scope is the call-site branch plus its offline test, both delivered and proven"
  },
  "summary": "rehearsal-cycle.sh's host-capacity acquire is now a per-host DRIVE_EXCLUSIVE=all|slot knob (all/unset byte-identical to ADR 0184's four-lock exclusive; slot takes one pooled heavy slot), proven by a new offline test.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #706 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 706, "status": "success", "commits": [ "e83a8eda9608504784ce3654f13817e16962fb3c" ], "changed_files": [ "STATUS.md", "scripts/rehearsal-cycle.sh", "scripts/tests/rehearsal-drive-exclusive-test.sh" ], "tests": [ { "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/host-capacity-lib-test.sh", "exit_code": 0 }, { "command": "bash -n scripts/rehearsal-cycle.sh", "exit_code": 0 } ], "criteria": { "rehearsal-cycle.sh branches on DRIVE_EXCLUSIVE right where it currently calls host_capacity_acquire_exclusive; unset/all is byte-identical to today": "scripts/rehearsal-cycle.sh: a `case \"${DRIVE_EXCLUSIVE:-all}\" in` branch replaces the bare acquire immediately after host_capacity_drive_reserve; the *) (all/unset) arm keeps the four-lock host_capacity_acquire_exclusive call verbatim (/tmp/matou-swarm.lock /tmp/matou-host-slot-2.lock /tmp/matou-session-runner.lock /tmp/matou-healer-Matou-idss.lock), asserted byte-for-byte by test check 6", "Offline test proves both modes: all calls the four-lock exclusive acquire exactly as before; slot calls the one-slot heavy acquire and does NOT touch the session-runner or healer locks": "scripts/tests/rehearsal-drive-exclusive-test.sh checks 1-2 (unset & all -> exclusive with the four locks unchanged, no heavy), check 3 (slot -> host_capacity_acquire_heavy only, log never names session-runner or healer), checks 4-5 (busy-yield paths bump skip counter without crossing modes); exit 0", "Live: DRIVE_EXCLUSIVE=slot on elitebook-03 fires a ready drive within one */2 tick beside a dev-factory worker": "explicitly a human/session step outside this ticket's scope per the acceptance clause; the ticket's own scope is the call-site branch plus its offline test, both delivered and proven" }, "summary": "rehearsal-cycle.sh's host-capacity acquire is now a per-host DRIVE_EXCLUSIVE=all|slot knob (all/unset byte-identical to ADR 0184's four-lock exclusive; slot takes one pooled heavy slot), proven by a new offline test.", "reason": "", "blockers": [], "no_code_change": "" } ``` </details>
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/idss#706
No description provided.