factory: session-runner/healer join the host capacity semaphore (needs dev-factory edit + re-pin) #605

Closed
opened 2026-08-19 23:18:35 +00:00 by matou-build-agent · 3 comments

Follow-up from #577 (host capacity semaphore)

#577 (docs/adr/0184-*.md) replaced /tmp/matou-swarm.lock with a 2-slot
pooled host capacity semaphore (scripts/lib/host-capacity-lib.sh) and made
the rehearsal drive exclude everything heavy host-wide — but session-runner
and the healer only got EXCLUDED by the drive (their existing single-instance
locks are grabbed from the outside); neither became a participant in the
2-slot pool against swarm/triage. A live session-runner session and a live
swarm worker can still both run concurrently today, exactly as before #577.

Why this is separate

.sandcastle/session-runner.sh and .sandcastle/heal.sh are vendored
byte-identical from Matou/dev-factory (ADR 0180, FACTORY_MANIFEST).
Making either draw from HOST_CAPACITY_SLOTS means editing them in
Matou/dev-factory itself and re-vendoring via a FACTORY_REF bump — a
distinct two-way door from #577's per-repo workflow/script changes, and
touches a second repo's checkout. Scoped out of #577 to keep that ticket's
blast radius to files this checkout could safely edit and prove in one
session.

Suggested shape (not binding — re-derive from the code at pickup time)

  • Port scripts/lib/host-capacity-lib.sh's two primitives (or equivalent)
    into Matou/dev-factory, since swarm-identity.sh is the only file ADR
    0180 keeps deliberately per-repo — this lib is generic.
  • session-runner.sh: acquire a heavy slot (host_capacity_acquire_heavy)
    around the same span its own SESSION_RUNNER_LOCK already covers; yield
    (existing "tick absorbed" path) on exhaustion.
  • heal.sh: decide deliberately whether the healer should become pool-aware
    at all — today it's bounded (one Claude call per incident signature,
    hourly watchdog cadence, its own per-repo mutex already) and #577's ADR
    reasoned that folding it in was a bigger change for uncertain benefit.
    Re-litigate with fresh evidence rather than assuming yes.
  • Bump FACTORY_REF + re-run check-harness-drift.sh in ourcloud (and
    matou-app, once #572 lands) after the factory-side change merges.

Needs Ben: none identified yet — likely a two-way door under ADR 0174
once scoped, same as #577 was. Flag if the factory-repo edit surfaces a real
judgment call.

## Follow-up from #577 (host capacity semaphore) #577 (`docs/adr/0184-*.md`) replaced `/tmp/matou-swarm.lock` with a 2-slot pooled host capacity semaphore (`scripts/lib/host-capacity-lib.sh`) and made the rehearsal drive exclude everything heavy host-wide — but session-runner and the healer only got EXCLUDED by the drive (their existing single-instance locks are grabbed from the outside); neither became a **participant** in the 2-slot pool against swarm/triage. A live session-runner session and a live swarm worker can still both run concurrently today, exactly as before #577. ## Why this is separate `.sandcastle/session-runner.sh` and `.sandcastle/heal.sh` are vendored byte-identical from `Matou/dev-factory` (ADR 0180, `FACTORY_MANIFEST`). Making either draw from `HOST_CAPACITY_SLOTS` means editing them in `Matou/dev-factory` itself and re-vendoring via a `FACTORY_REF` bump — a distinct two-way door from #577's per-repo workflow/script changes, and touches a second repo's checkout. Scoped out of #577 to keep that ticket's blast radius to files this checkout could safely edit and prove in one session. ## Suggested shape (not binding — re-derive from the code at pickup time) - Port `scripts/lib/host-capacity-lib.sh`'s two primitives (or equivalent) into `Matou/dev-factory`, since `swarm-identity.sh` is the only file ADR 0180 keeps deliberately per-repo — this lib is generic. - `session-runner.sh`: acquire a heavy slot (`host_capacity_acquire_heavy`) around the same span its own `SESSION_RUNNER_LOCK` already covers; yield (existing "tick absorbed" path) on exhaustion. - `heal.sh`: decide deliberately whether the healer should become pool-aware at all — today it's bounded (one Claude call per incident signature, hourly watchdog cadence, its own per-repo mutex already) and #577's ADR reasoned that folding it in was a bigger change for uncertain benefit. Re-litigate with fresh evidence rather than assuming yes. - Bump `FACTORY_REF` + re-run `check-harness-drift.sh` in ourcloud (and matou-app, once #572 lands) after the factory-side change merges. **Needs Ben:** none identified yet — likely a two-way door under ADR 0174 once scoped, same as #577 was. Flag if the factory-repo edit surfaces a real judgment call.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: ready-for-session, not ready-for-agent or ready-for-human.

Context checks first:

  • Redundancy — confirmed scripts/lib/host-capacity-lib.sh and
    docs/adr/0184-host-capacity-is-a-two-slot-pool-not-a-single-lock.md
    landed via #577 (9c235a0). .sandcastle/session-runner.sh and
    .sandcastle/heal.sh do not reference HOST_CAPACITY_SLOTS or
    host_capacity_acquire_* anywhere — the gap this ticket describes is
    real, not already closed.
  • Prior rejection — no .out-of-scope/ directory exists in this repo
    yet, so nothing to match against.

Routing:

  • The work requires editing Matou/dev-factory directly (porting the two
    capacity primitives, editing the vendored session-runner.sh/heal.sh
    there, bumping FACTORY_REF) — a second repo's checkout, the same
    category of cross-repo work #572 hit. Verified live just now:
    swarm-bot's Forgejo token is still push:false on Matou/dev-factory
    (GET /repos/Matou/dev-factory → permissions.push: false), the same
    wall #572's close-report recorded (AGit PR was the only path in). A
    swarm ready-for-agent worker operates only within this repo's own
    checkout/branch/PR flow and has no standing to clone, branch, and open an
    AGit PR against a second repo; an interactive session does — #572's PR #5
    and #577 itself (this ticket's parent) both did exactly this kind of
    cross-repo/session work.
  • Not ready-for-human: no step here is Ben's-hands, Ben's-eyes, or a
    one-way-door ruling (personal credentials / security-posture widening /
    member-facing trust accept / data destruction / non-routine spend — none
    apply), and the ticket's own "Needs Ben: none identified yet" holds. The
    one open design question it flags — whether the healer should become
    pool-aware at all — is a two-way-door design call a session can make and
    record (bounded, single-purpose healer with its own mutex already;
    reversible by a later commit either way), not a Ben judgment call.

Two-way door: the label is revertible (a relabel costs nothing), and the
routing is provable by the precedent already on the tracker — push:false
confirmed live above, AGit PR the working path (#572 PR #5).

Category: enhancement — extends #577's concurrency-safety coverage to
the two vendored files it deliberately scoped out; nothing is broken today
that wasn't already excluded by design.

> *This was generated by AI during triage.* Ruled by agent under ADR 0174 — veto anytime. **Ruling: `ready-for-session`, not `ready-for-agent` or `ready-for-human`.** Context checks first: - **Redundancy** — confirmed `scripts/lib/host-capacity-lib.sh` and `docs/adr/0184-host-capacity-is-a-two-slot-pool-not-a-single-lock.md` landed via #577 (`9c235a0`). `.sandcastle/session-runner.sh` and `.sandcastle/heal.sh` do not reference `HOST_CAPACITY_SLOTS` or `host_capacity_acquire_*` anywhere — the gap this ticket describes is real, not already closed. - **Prior rejection** — no `.out-of-scope/` directory exists in this repo yet, so nothing to match against. Routing: - The work requires editing `Matou/dev-factory` directly (porting the two capacity primitives, editing the vendored `session-runner.sh`/`heal.sh` there, bumping `FACTORY_REF`) — a second repo's checkout, the same category of cross-repo work #572 hit. Verified live just now: `swarm-bot`'s Forgejo token is still `push:false` on `Matou/dev-factory` (`GET /repos/Matou/dev-factory` → `permissions.push: false`), the same wall #572's close-report recorded (AGit PR was the only path in). A swarm `ready-for-agent` worker operates only within this repo's own checkout/branch/PR flow and has no standing to clone, branch, and open an AGit PR against a second repo; an interactive session does — #572's PR #5 and #577 itself (this ticket's parent) both did exactly this kind of cross-repo/session work. - Not `ready-for-human`: no step here is Ben's-hands, Ben's-eyes, or a one-way-door ruling (personal credentials / security-posture widening / member-facing trust accept / data destruction / non-routine spend — none apply), and the ticket's own "Needs Ben: none identified yet" holds. The one open design question it flags — whether the healer should become pool-aware at all — is a two-way-door design call a session can make and record (bounded, single-purpose healer with its own mutex already; reversible by a later commit either way), not a Ben judgment call. **Two-way door:** the label is revertible (a relabel costs nothing), and the routing is provable by the precedent already on the tracker — `push:false` confirmed live above, AGit PR the working path (#572 PR #5). **Category:** `enhancement` — extends #577's concurrency-safety coverage to the two vendored files it deliberately scoped out; nothing is broken today that wasn't already excluded by design.
Author
Member

Ruled by agent under ADR 0174 — veto anytime

Two-way door: revertible (the FACTORY_REF bump + vendored-file changes
here, and the Matou/dev-factory commit itself, both plain commits), and
provable — offline tests plus check-harness-drift.sh.

session-runner.sh joins the pool. Ported host-capacity-lib.sh (the
pooled-slot/exclusive-acquire primitives from #577/ADR 0184) into
Matou/dev-factory as a generic, byte-identical vendored file (no repo
slug — any consumer's heavy host-side loop can source it, not just
workflow-triggered ones). session-runner.sh now calls
host_capacity_acquire_heavy immediately after its own
SESSION_RUNNER_LOCK acquire and yields ("host capacity pool exhausted —
tick absorbed") on exhaustion, exactly like its existing single-instance-
lock yield path — both fds release on process exit, no explicit teardown
needed. This closes the gap this ticket named: a live session-runner
session and a live swarm/triage worker could previously both run
unbounded at once.

heal.sh deliberately does not join this round. Re-litigated per the
ticket's ask rather than assuming yes: checked docs/GOTCHAS.md and this
repo's own healer history in STATUS.md for anything since #577 landed
(2026-08-19) — no contention evidence exists. The original bounded-
workload reasoning from ADR 0184 point 6 still holds: one Claude call per
incident signature, hourly watchdog cadence, its own per-repo mutex, and
it's already excluded from drives via host_capacity_acquire_exclusive
grabbing its lock from the outside. If a real session-runner/swarm-vs-
healer collision surfaces later, that's fresh evidence for a future
ticket to re-open this — not assumed here.

Proof:

  • Matou/dev-factory@e9aa0bd — host-capacity-lib.sh +
    tests/host-capacity-lib-test.sh (6 groups, ported from
    scripts/tests/host-capacity-lib-test.sh here) + session-runner.sh
    wiring + 1 new tests/session-runner-test.sh case (pool-exhaustion
    absorbs the tick before any API call). Full suite: 38/38 offline tests
    green standalone, no product checkout on PATH.
  • Here: FACTORY_REF bumped to e9aa0bd, host-capacity-lib.sh +
    its test added to FACTORY_MANIFEST, session-runner.sh +
    tests/session-runner-test.sh re-vendored byte-identical.
    bash .sandcastle/check-harness-drift.sh → OK. Every .sandcastle/tests/*.sh
    and scripts/tests/*.sh green.
  • Commits: Matou/dev-factory e9aa0bd; Matou/ourcloud f48ff68 +
    0db069b (mode-bit tidy).

No one-way door surfaced — nothing here touches personal credentials,
widens security posture, or is a member-facing trust accept. Advances
#605, #577.

## Ruled by agent under ADR 0174 — veto anytime Two-way door: revertible (the `FACTORY_REF` bump + vendored-file changes here, and the `Matou/dev-factory` commit itself, both plain commits), and provable — offline tests plus `check-harness-drift.sh`. **session-runner.sh joins the pool.** Ported `host-capacity-lib.sh` (the pooled-slot/exclusive-acquire primitives from #577/ADR 0184) into `Matou/dev-factory` as a generic, byte-identical vendored file (no repo slug — any consumer's heavy host-side loop can source it, not just workflow-triggered ones). `session-runner.sh` now calls `host_capacity_acquire_heavy` immediately after its own `SESSION_RUNNER_LOCK` acquire and yields ("host capacity pool exhausted — tick absorbed") on exhaustion, exactly like its existing single-instance- lock yield path — both fds release on process exit, no explicit teardown needed. This closes the gap this ticket named: a live session-runner session and a live swarm/triage worker could previously both run unbounded at once. **heal.sh deliberately does not join this round.** Re-litigated per the ticket's ask rather than assuming yes: checked `docs/GOTCHAS.md` and this repo's own healer history in `STATUS.md` for anything since #577 landed (2026-08-19) — no contention evidence exists. The original bounded- workload reasoning from ADR 0184 point 6 still holds: one Claude call per incident signature, hourly watchdog cadence, its own per-repo mutex, and it's already excluded from drives via `host_capacity_acquire_exclusive` grabbing its lock from the outside. If a real session-runner/swarm-vs- healer collision surfaces later, that's fresh evidence for a future ticket to re-open this — not assumed here. **Proof:** - `Matou/dev-factory@e9aa0bd` — `host-capacity-lib.sh` + `tests/host-capacity-lib-test.sh` (6 groups, ported from `scripts/tests/host-capacity-lib-test.sh` here) + `session-runner.sh` wiring + 1 new `tests/session-runner-test.sh` case (pool-exhaustion absorbs the tick before any API call). Full suite: 38/38 offline tests green standalone, no product checkout on `PATH`. - Here: `FACTORY_REF` bumped to `e9aa0bd`, `host-capacity-lib.sh` + its test added to `FACTORY_MANIFEST`, `session-runner.sh` + `tests/session-runner-test.sh` re-vendored byte-identical. `bash .sandcastle/check-harness-drift.sh` → OK. Every `.sandcastle/tests/*.sh` and `scripts/tests/*.sh` green. - Commits: `Matou/dev-factory` `e9aa0bd`; `Matou/ourcloud` `f48ff68` + `0db069b` (mode-bit tidy). No one-way door surfaced — nothing here touches personal credentials, widens security posture, or is a member-facing trust accept. Advances #605, #577.
Author
Member

Close report

What landed: session-runner and swarm/triage now draw from the same
2-slot host capacity pool; healer stays out (deliberate, re-litigated, see
the ruling comment above).

Commits:

  • Matou/dev-factory@e9aa0bd — host-capacity-lib.sh ported (generic),
    session-runner.sh wired to host_capacity_acquire_heavy, tests added.
  • Matou/ourcloud@f48ff68 — FACTORY_REF bump + re-vendor
    (host-capacity-lib.sh, session-runner.sh, both tests,
    FACTORY_MANIFEST), STATUS.md.
  • Matou/ourcloud@0db069b — vendored-file mode-bit tidy (content was
    already byte-identical; only the executable bit differed).

Proof:

  • bash .sandcastle/check-harness-drift.sh → OK — every vendored factory file matches https://git.matou.nz/Matou/dev-factory.git@e9aa0bd....
  • Matou/dev-factory: 38/38 offline tests green standalone
    (for t in tests/*.sh; do ...; done).
  • Matou/ourcloud: every .sandcastle/tests/*.sh and scripts/tests/*.sh
    green, including the new host-capacity-lib-test.sh (6 groups) and the
    new pool-exhaustion case in session-runner-test.sh (group 8: both
    slots pre-held → runner reports "host capacity pool exhausted — tick
    absorbed" before any API call).

Not done, on purpose: heal.sh does not join the pool — see the
ruling comment for the re-litigated reasoning.

Closing — advances #605 (and the #577/ADR 0184 point 6 follow-up).

## Close report **What landed:** session-runner and swarm/triage now draw from the same 2-slot host capacity pool; healer stays out (deliberate, re-litigated, see the ruling comment above). **Commits:** - `Matou/dev-factory@e9aa0bd` — `host-capacity-lib.sh` ported (generic), `session-runner.sh` wired to `host_capacity_acquire_heavy`, tests added. - `Matou/ourcloud@f48ff68` — `FACTORY_REF` bump + re-vendor (`host-capacity-lib.sh`, `session-runner.sh`, both tests, `FACTORY_MANIFEST`), `STATUS.md`. - `Matou/ourcloud@0db069b` — vendored-file mode-bit tidy (content was already byte-identical; only the executable bit differed). **Proof:** - `bash .sandcastle/check-harness-drift.sh` → `OK — every vendored factory file matches https://git.matou.nz/Matou/dev-factory.git@e9aa0bd...`. - `Matou/dev-factory`: 38/38 offline tests green standalone (`for t in tests/*.sh; do ...; done`). - `Matou/ourcloud`: every `.sandcastle/tests/*.sh` and `scripts/tests/*.sh` green, including the new `host-capacity-lib-test.sh` (6 groups) and the new pool-exhaustion case in `session-runner-test.sh` (group 8: both slots pre-held → runner reports "host capacity pool exhausted — tick absorbed" before any API call). **Not done, on purpose:** `heal.sh` does not join the pool — see the ruling comment for the re-litigated reasoning. Closing — advances #605 (and the #577/ADR 0184 point 6 follow-up).
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#605
No description provided.