Session-runner fairness: one host-global lock lets one enrolled repo starve another #35

Closed
opened 2026-08-23 15:25:30 +00:00 by matou-build-agent · 7 comments

Follow-up from #3 (host state is factory-owned, ADR 0004) — Ben's observation on that ticket:

with two repos' runners on matou-workstation, /tmp/matou-session-runner.lock is host-global, so while one repo's session is in flight every other repo's tick logs session in flight — tick absorbed — one repo can starve the other for a whole SESSION_RUNNER_TIMEOUT (2 h) with no rotation.

#3 gave this question a home and deliberately did not answer it: the ownership move renders today's cadences unchanged so it stays behaviour-preserving. ADR 0004 point 6 records the lock namespace as host state owned by host-capacity-lib.sh, and the host registry (~/swarm/host-registry.conf) now declares which repos are enrolled and which of them run a session-runner — the input an arbiter needs.

What's needed

  • Decide the mechanism: a pooled slot count for session-runners (the host_capacity_acquire_heavy shape), or a round-robin/oldest-waiting pick across the registry's enrolled repos.
  • Whichever wins, the loser must still never camp (host-capacity-lib.sh's header rule: yield, exit 0, next tick re-fires).
  • Where the arbiter reads the enrolled set from: onboarding/host-state-lib.sh is factory-only (vendor-excluded), so a vendored consumer's session-runner.sh cannot source it today. Either lift a registry READER into a root vendored lib (ADR 0004's "Alternatives considered" names this as the expected first reason to), or have the rendered cron line pass the fairness inputs in.
  • Pairs with the per-repo SESSION_RUNNER=on|off policy (#6's ruling) deciding who is in the rotation, and with Matou/idss#577's host-scheduling design.

Same shape as the swarm's capacity question (idss #577 / ADR 0184) — the lock is a host resource, not a repo's.

Follow-up from #3 (host state is factory-owned, ADR 0004) — Ben's observation on that ticket: > with two repos' runners on matou-workstation, `/tmp/matou-session-runner.lock` is host-global, so while one repo's session is in flight every other repo's tick logs `session in flight — tick absorbed` — one repo can starve the other for a whole `SESSION_RUNNER_TIMEOUT` (2 h) with no rotation. #3 gave this question a **home** and deliberately did not answer it: the ownership move renders today's cadences unchanged so it stays behaviour-preserving. ADR 0004 point 6 records the lock namespace as host state owned by `host-capacity-lib.sh`, and the host registry (`~/swarm/host-registry.conf`) now declares which repos are enrolled and which of them run a session-runner — the input an arbiter needs. ## What's needed - Decide the mechanism: a pooled slot count for session-runners (the `host_capacity_acquire_heavy` shape), or a round-robin/oldest-waiting pick across the registry's enrolled repos. - Whichever wins, the loser must still never camp (`host-capacity-lib.sh`'s header rule: yield, exit 0, next tick re-fires). - Where the arbiter reads the enrolled set from: `onboarding/host-state-lib.sh` is factory-only (vendor-excluded), so a vendored consumer's `session-runner.sh` cannot source it today. Either lift a registry READER into a root vendored lib (ADR 0004's \"Alternatives considered\" names this as the expected first reason to), or have the rendered cron line pass the fairness inputs in. - Pairs with the per-repo `SESSION_RUNNER=on|off` policy (#6's ruling) deciding who is in the rotation, and with `Matou/idss#577`'s host-scheduling design. Same shape as the swarm's capacity question (idss #577 / ADR 0184) — the lock is a host resource, not a repo's.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime

This ticket asks for a mechanism choice ("pooled slot count, or round-robin across the registry's enrolled repos") and for where an arbiter reads the enrolled set from. Both are two-way doors, so triage rules rather than parks.

The ruling

Neither. Repo-scope session-runner's host-global state, and let the existing 2-slot host capacity pool remain the sole host-wide arbiter. No fairness arbiter, no registry reader, no new mechanism.

The reasoning is in the code. session-runner.sh:93-94 takes /tmp/matou-session-runner.lock — one path for the whole host — and only then, at session-runner.sh:105-116, joins the shared 2-slot pool via host_capacity_acquire_heavy. So the host-wide arbitration already exists and is already correct; the starvation Ben observed comes entirely from the extra host-global lock taken in front of it. Making that lock repo-scoped (/tmp/matou-session-runner-<repo-slug>.lock) preserves its actual intent — one session per repo — and hands host-wide contention to the pool that was built for exactly this (host-capacity-lib.sh:1-26, sized at 2 by the #577 / ADR 0184 ruling).

This answers all three bullets of "What's needed":

  • Mechanism — the pooled shape, and it is already shipped and already wired.
  • Never camp — unchanged and already true on both paths: flock -n then exit 0 at session-runner.sh:94 and :116.
  • Where the arbiter reads the enrolled set from — it does not need one. That bullet dissolves, which is the main reason to prefer this over round-robin: no registry READER has to be lifted out of the factory-only onboarding/host-state-lib.sh into a vendored root lib, and this ticket therefore does not block on #3.

Two same-commit siblings, same root cause

Repo-scoping the lock alone would leave two more host-global stores keyed per-repo, and one of them is an outright bug:

  • SESSION_RUNNER_STATE (session-runner.sh:47, $HOME/.local/state/matou-session-runner) is host-global, but its fail counters are keyed by issue number alone — fail-$n / attempt-$n (:163, :169, :258-259). Issue numbers are per-repo. So on a two-repo host, repo A's issue 3 failing twice escalates repo B's issue 3 to agent-blocked (:266) with a Mattermost alarm naming a ticket nobody touched. Same defect class as #36, different store. The rate-limit stamps (alarm-$sig, :71) collide the same way: repo B's dead-tick alarm is suppressed by repo A's stamp.
  • SESSION_RUNNER_DRIVE_DEFER_COUNT (:112) is one host-global path, so the "skipped N consecutive tick(s)" streak that #664 exists to make legible counts two repos' ticks as one repo's.

Fix all three in one commit. Splitting them means two tickets editing the same defaults block.

Why this is a two-way door

Three default values in one : "${VAR:=…}" block, revertible by a one-line commit. Nothing on the one-way-door list: no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no spend. Total host heavy-concurrency is unchanged — still capped at 2 by the pool, because the pool's slot paths are stable and pin-independent.

What proves it

  • tests/session-runner-test.sh — new case: two REPO_SLUGs resolve to two distinct lock paths and both ticks reach the pool; a second tick of the same repo is still absorbed.
  • tests/host-capacity-lib-test.sh — already proves the 2-slot cap and no-camp yield (host-capacity-lib-test.sh:32-67); unchanged and must stay green.
  • tests/swarm-lock-yield-test.sh — unchanged.

Residual, stated honestly

With more session-runner repos than pool slots, contention moves to the pool, which is first-fit with no rotation — so cross-repo waiting is not eliminated in general. What it stops is the specific failure reported: one repo monopolising a host-global lock for a whole SESSION_RUNNER_TIMEOUT (2 h) while the pool sits half free. Rotation across all heavy consumers is Matou/idss#577's host-scheduling design, not session-runner's private lock, and it should not be reinvented here.

Agent brief

Goal. No repo's session-runner can starve another's, and no repo's state can be attributed to another's issue numbers.

Change (session-runner.sh, root — not .sandcastle/):

  1. :50 — default SESSION_RUNNER_LOCK to a repo-scoped path derived from REPO_SLUG (already sourced at :45). Sanitise the slug: / cannot appear in a filename.
  2. :47 — same for SESSION_RUNNER_STATE, so fail-$n / attempt-$n / alarm-$sig are per-repo.
  3. :112 — same for SESSION_RUNNER_DRIVE_DEFER_COUNT.
  4. :20 — the example cron line in the header comment names /home/dev/swarm/rehearsal-env.sh and Matou/idss. Per CLAUDE.md's blast-radius rule no harness file carries a repo name or a host path, even illustratively. Generalise it. (The env path itself is #37's subject; only the comment is in scope here.)
  5. All four keep their ${VAR:=…} override form — a caller pinning the old path must still win.

Constraints.

  • Order is load-bearing: swarm-identity.sh is sourced at :45, so REPO_SLUG is available before :47 and :50. Do not move the identity source, and do not add a new symbol to the consumer-owned identity file — GOTCHAS 12 is exactly that hazard (identity_require at :85-90 is the guard).
  • Existing state does not migrate. A live host has fail-* / attempt-* under the old dir; after the change those are simply orphaned, which is the correct outcome (they carry no repo attribution). Say so in the commit message — do not write a migration.
  • Migration window is safe by construction: two repos are two independent pins, so no repo can race its own old and new lock path. Across repos, overlap is the intended new behaviour and stays capped at 2 by the pool.
  • Root harness file — GOTCHAS 4: this reaches the factory's own running copy only at a pin bump. Do not edit .sandcastle/session-runner.sh.

Acceptance. The tests above, plus the full offline suite:
for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done

STATUS.md updated in the same commit (CLAUDE.md).

Ben — if you want the round-robin arbiter instead, or want the state-dir sibling split into its own ticket, say so and this reverts to needs-triage.

> *This was generated by AI during triage.* ## Ruled by agent under ADR 0174 — veto anytime This ticket asks for a mechanism choice ("pooled slot count, or round-robin across the registry's enrolled repos") and for where an arbiter reads the enrolled set from. Both are two-way doors, so triage rules rather than parks. ### The ruling **Neither. Repo-scope session-runner's host-global state, and let the existing 2-slot host capacity pool remain the sole host-wide arbiter. No fairness arbiter, no registry reader, no new mechanism.** The reasoning is in the code. `session-runner.sh:93-94` takes `/tmp/matou-session-runner.lock` — one path for the whole host — and only *then*, at `session-runner.sh:105-116`, joins the shared 2-slot pool via `host_capacity_acquire_heavy`. So the host-wide arbitration already exists and is already correct; the starvation Ben observed comes entirely from the extra host-global lock taken *in front* of it. Making that lock repo-scoped (`/tmp/matou-session-runner-<repo-slug>.lock`) preserves its actual intent — *one session per repo* — and hands host-wide contention to the pool that was built for exactly this (`host-capacity-lib.sh:1-26`, sized at 2 by the #577 / ADR 0184 ruling). This answers all three bullets of "What's needed": - **Mechanism** — the pooled shape, and it is already shipped and already wired. - **Never camp** — unchanged and already true on both paths: `flock -n` then `exit 0` at `session-runner.sh:94` and `:116`. - **Where the arbiter reads the enrolled set from** — it does not need one. That bullet dissolves, which is the main reason to prefer this over round-robin: no registry READER has to be lifted out of the factory-only `onboarding/host-state-lib.sh` into a vendored root lib, and this ticket therefore does **not** block on #3. ### Two same-commit siblings, same root cause Repo-scoping the lock alone would leave two more host-global stores keyed per-repo, and one of them is an outright bug: - **`SESSION_RUNNER_STATE`** (`session-runner.sh:47`, `$HOME/.local/state/matou-session-runner`) is host-global, but its fail counters are keyed by **issue number alone** — `fail-$n` / `attempt-$n` (`:163`, `:169`, `:258-259`). Issue numbers are per-repo. So on a two-repo host, repo A's issue 3 failing twice escalates **repo B's** issue 3 to `agent-blocked` (`:266`) with a Mattermost alarm naming a ticket nobody touched. Same defect class as #36, different store. The rate-limit stamps (`alarm-$sig`, `:71`) collide the same way: repo B's dead-tick alarm is suppressed by repo A's stamp. - **`SESSION_RUNNER_DRIVE_DEFER_COUNT`** (`:112`) is one host-global path, so the "skipped N consecutive tick(s)" streak that #664 exists to make legible counts two repos' ticks as one repo's. Fix all three in one commit. Splitting them means two tickets editing the same defaults block. ### Why this is a two-way door Three default values in one `: "${VAR:=…}"` block, revertible by a one-line commit. Nothing on the one-way-door list: no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no spend. Total host heavy-concurrency is **unchanged** — still capped at 2 by the pool, because the pool's slot paths are stable and pin-independent. ### What proves it - `tests/session-runner-test.sh` — new case: two `REPO_SLUG`s resolve to two distinct lock paths and both ticks reach the pool; a second tick of the *same* repo is still absorbed. - `tests/host-capacity-lib-test.sh` — already proves the 2-slot cap and no-camp yield (`host-capacity-lib-test.sh:32-67`); unchanged and must stay green. - `tests/swarm-lock-yield-test.sh` — unchanged. ### Residual, stated honestly With more session-runner repos than pool slots, contention moves to the pool, which is first-fit with **no rotation** — so cross-repo waiting is not eliminated in general. What it stops is the specific failure reported: one repo monopolising a host-global lock for a whole `SESSION_RUNNER_TIMEOUT` (2 h) while the pool sits half free. Rotation across all heavy consumers is `Matou/idss#577`'s host-scheduling design, not session-runner's private lock, and it should not be reinvented here. ## Agent brief **Goal.** No repo's session-runner can starve another's, and no repo's state can be attributed to another's issue numbers. **Change** (`session-runner.sh`, root — **not** `.sandcastle/`): 1. `:50` — default `SESSION_RUNNER_LOCK` to a repo-scoped path derived from `REPO_SLUG` (already sourced at `:45`). Sanitise the slug: `/` cannot appear in a filename. 2. `:47` — same for `SESSION_RUNNER_STATE`, so `fail-$n` / `attempt-$n` / `alarm-$sig` are per-repo. 3. `:112` — same for `SESSION_RUNNER_DRIVE_DEFER_COUNT`. 4. `:20` — the example cron line in the header comment names `/home/dev/swarm/rehearsal-env.sh` and `Matou/idss`. Per CLAUDE.md's blast-radius rule no harness file carries a repo name or a host path, even illustratively. Generalise it. (The env path itself is #37's subject; only the comment is in scope here.) 5. All four keep their `${VAR:=…}` override form — a caller pinning the old path must still win. **Constraints.** - Order is load-bearing: `swarm-identity.sh` is sourced at `:45`, so `REPO_SLUG` is available before `:47` and `:50`. Do not move the identity source, and do not add a new symbol to the consumer-owned identity file — GOTCHAS 12 is exactly that hazard (`identity_require` at `:85-90` is the guard). - Existing state does not migrate. A live host has `fail-*` / `attempt-*` under the old dir; after the change those are simply orphaned, which is the correct outcome (they carry no repo attribution). Say so in the commit message — do not write a migration. - Migration window is safe by construction: two repos are two independent pins, so no repo can race its own old and new lock path. Across repos, overlap is the intended new behaviour and stays capped at 2 by the pool. - Root harness file — GOTCHAS 4: this reaches the factory's own running copy only at a pin bump. Do not edit `.sandcastle/session-runner.sh`. **Acceptance.** The tests above, plus the full offline suite: `for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done` `STATUS.md` updated in the same commit (CLAUDE.md). Ben — if you want the round-robin arbiter instead, or want the state-dir sibling split into its own ticket, say so and this reverts to `needs-triage`.
Author
Member

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: DEFERRED. The ticket cites "ADR 0004 point 6" as an already-settled
ruling and assumes onboarding/host-state-lib.sh and a
~/swarm/host-registry.conf reader already exist. Neither is present in
this repo yet — docs/adr/ stops at 0003, onboarding/host-state-lib.sh
doesn't exist, and no tracked file references host-registry.conf. The
prerequisite work is #3 (host-state ownership move — still open,
ready-for-session) and #6 (host registry + enrolment — still open,
ready-for-session). This ticket's own "decide the mechanism" and "where
the arbiter reads from" questions can't be answered against infrastructure
that doesn't exist yet, so an agent picking this up today would be building
against a fiction.

Why two-way door: purely a sequencing call, reversible the moment #3/#6
land — re-triage picks it back up, nothing is committed now.

What proves it: grep -rl host-registry.conf . and ls onboarding/host-state-lib.sh both come up empty in this repo today; either
landing (the file appearing, or docs/adr/0004-*.md existing) is the
revisit trigger.

Ruled: DEFERRED

Revisit when: onboarding/host-state-lib.sh (or an equivalent
registry-reader lib) exists AND ~/swarm/host-registry.conf's format is
committed to this repo (via #6), OR docs/adr/0004-*.md lands (via #3) —
whichever first gives this ticket a real registry to read.

Ruled by: agent, under ADR 0174, during headless /triage, 2026-08-23.

Note for whoever revisits: once unblocked, the mechanism choice
(pooled-slot vs. round-robin) and the registry-reader placement are
themselves two-way-door calls the assigned agent can rule under ADR 0174
when picking this up — mirroring how #25 ruled ADR 0003 for the analogous
per-host DRIVE_EXCLUSIVE question. This looks code-shaped (a
host-capacity-lib.sh-style arbiter, offline-testable) rather than
session-shaped, unlike #3/#6/#37.

Marked as blocked by #3 and #6 via Forgejo's issue dependencies.

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** Ruling: DEFERRED. The ticket cites "ADR 0004 point 6" as an already-settled ruling and assumes `onboarding/host-state-lib.sh` and a `~/swarm/host-registry.conf` reader already exist. Neither is present in this repo yet — `docs/adr/` stops at 0003, `onboarding/host-state-lib.sh` doesn't exist, and no tracked file references `host-registry.conf`. The prerequisite work is #3 (host-state ownership move — still open, `ready-for-session`) and #6 (host registry + enrolment — still open, `ready-for-session`). This ticket's own "decide the mechanism" and "where the arbiter reads from" questions can't be answered against infrastructure that doesn't exist yet, so an agent picking this up today would be building against a fiction. Why two-way door: purely a sequencing call, reversible the moment #3/#6 land — re-triage picks it back up, nothing is committed now. What proves it: `grep -rl host-registry.conf .` and `ls onboarding/host-state-lib.sh` both come up empty in this repo today; either landing (the file appearing, or `docs/adr/0004-*.md` existing) is the revisit trigger. ## Ruled: DEFERRED **Revisit when:** `onboarding/host-state-lib.sh` (or an equivalent registry-reader lib) exists AND `~/swarm/host-registry.conf`'s format is committed to this repo (via #6), OR `docs/adr/0004-*.md` lands (via #3) — whichever first gives this ticket a real registry to read. **Ruled by:** agent, under ADR 0174, during headless `/triage`, 2026-08-23. **Note for whoever revisits:** once unblocked, the mechanism choice (pooled-slot vs. round-robin) and the registry-reader placement are themselves two-way-door calls the assigned agent can rule under ADR 0174 when picking this up — mirroring how #25 ruled ADR 0003 for the analogous per-host `DRIVE_EXCLUSIVE` question. This looks code-shaped (a `host-capacity-lib.sh`-style arbiter, offline-testable) rather than session-shaped, unlike #3/#6/#37. Marked as blocked by #3 and #6 via Forgejo's issue dependencies.
Author
Member

This was generated by AI during triage.

Agent Brief

Category: enhancement
Summary: The session-runner's host-global lock lets one enrolled repo's in-flight session starve every other repo's ticks.

Current behavior: SESSION_RUNNER_LOCK defaults to a single host-global path (/tmp/matou-session-runner.lock). Every enrolled repo's session-runner.sh tick takes the same lock non-blocking (flock -n) and exits immediately ("session in flight — tick absorbed") when it's held. With two or more repos' session-runners on one host, whichever repo's session is in flight blocks every other repo's tick for up to a whole SESSION_RUNNER_TIMEOUT (2h), with no rotation — confirmed live on matou-workstation (ADR 0004 point 6, and the observation quoted on #3).

Desired behavior: No single enrolled repo can indefinitely starve another's session-runner. Either a pooled slot count for session-runners (same shape as host_capacity_acquire_heavy in host-capacity-lib.sh) or a round-robin/oldest-waiting pick across the host's enrolled repos — implementer's choice; both satisfy the fairness goal and either is a revertible two-way door. Whichever mechanism is chosen, a repo that loses the arbitration must still never camp: it yields and exits 0, and the same or next tick re-fires, per host-capacity-lib.sh's existing yield contract.

Key interfaces:

  • session-runner.sh's lock acquisition (SESSION_RUNNER_LOCK / flock) — needs to become fairness-aware instead of a single first-come host-global mutex.
  • The host's enrolled-repo set — now declared in host-registry.conf and parsed by onboarding/host-state-lib.sh (ADR 0004), which is factory-only/vendor-excluded, so a vendored consumer's session-runner.sh cannot source it directly today. Per ADR 0004's "Alternatives considered", this ticket is the expected first case for lifting a registry READER into a root vendored lib — or, alternatively, have the rendered cron line pass the fairness inputs (enrolled repo list / slot count) in as arguments or env.
  • Pairs with the per-repo SESSION_RUNNER=on|off kill switch (#6), which decides who is in the rotation; this ticket decides how the repos that are in share the lock.

Acceptance criteria:

  • With two or more repos' session-runners enrolled on one host and one repo's session in flight, another enrolled repo's tick is not unconditionally absorbed for the full SESSION_RUNNER_TIMEOUT — it gets a fair turn within a bounded time (implementer documents the bound chosen).
  • A repo that loses the arbitration still yields and exits 0 (never blocks/camps).
  • With only one repo enrolled, existing claim/cooldown/timeout behavior is unchanged (behavior-preserving for the common case, matching ADR 0004's "cadences unchanged" precedent).
  • Test coverage (tests/session-runner-test.sh or a new test) exercises the multi-repo fairness case.

Out of scope:

  • The SESSION_RUNNER=on|off enrollment policy itself (#6).
  • Matou/idss#577's broader host-scheduling/capacity design — scoped here to the session-runner lock specifically (ADR 0004 point 6).
  • /tmp/matou-swarm.lock (the worker pool lock) — this ticket is about the session-runner lock only.

Verification: Confirmed by reading session-runner.sh directly: SESSION_RUNNER_LOCK defaults to the single path /tmp/matou-session-runner.lock, taken via non-blocking flock, no repo-fairness logic present. ADR 0004 (landed closing #3 immediately prior to this triage pass) confirms this was deliberately left unruled as policy rather than ownership, and names this ticket as the follow-up and the likely first vendored reader of the new host registry.

> *This was generated by AI during triage.* ## Agent Brief **Category:** enhancement **Summary:** The session-runner's host-global lock lets one enrolled repo's in-flight session starve every other repo's ticks. **Current behavior:** `SESSION_RUNNER_LOCK` defaults to a single host-global path (`/tmp/matou-session-runner.lock`). Every enrolled repo's `session-runner.sh` tick takes the same lock non-blocking (`flock -n`) and exits immediately ("session in flight — tick absorbed") when it's held. With two or more repos' session-runners on one host, whichever repo's session is in flight blocks every other repo's tick for up to a whole `SESSION_RUNNER_TIMEOUT` (2h), with no rotation — confirmed live on matou-workstation (ADR 0004 point 6, and the observation quoted on #3). **Desired behavior:** No single enrolled repo can indefinitely starve another's session-runner. Either a pooled slot count for session-runners (same shape as `host_capacity_acquire_heavy` in `host-capacity-lib.sh`) or a round-robin/oldest-waiting pick across the host's enrolled repos — implementer's choice; both satisfy the fairness goal and either is a revertible two-way door. Whichever mechanism is chosen, a repo that loses the arbitration must still never camp: it yields and exits 0, and the same or next tick re-fires, per `host-capacity-lib.sh`'s existing yield contract. **Key interfaces:** - `session-runner.sh`'s lock acquisition (`SESSION_RUNNER_LOCK` / `flock`) — needs to become fairness-aware instead of a single first-come host-global mutex. - The host's enrolled-repo set — now declared in `host-registry.conf` and parsed by `onboarding/host-state-lib.sh` (ADR 0004), which is factory-only/vendor-excluded, so a vendored consumer's `session-runner.sh` cannot source it directly today. Per ADR 0004's "Alternatives considered", this ticket is the expected first case for lifting a registry READER into a root vendored lib — or, alternatively, have the rendered cron line pass the fairness inputs (enrolled repo list / slot count) in as arguments or env. - Pairs with the per-repo `SESSION_RUNNER=on|off` kill switch (#6), which decides who is *in* the rotation; this ticket decides how the repos that are in share the lock. **Acceptance criteria:** - [ ] With two or more repos' session-runners enrolled on one host and one repo's session in flight, another enrolled repo's tick is not unconditionally absorbed for the full `SESSION_RUNNER_TIMEOUT` — it gets a fair turn within a bounded time (implementer documents the bound chosen). - [ ] A repo that loses the arbitration still yields and exits 0 (never blocks/camps). - [ ] With only one repo enrolled, existing claim/cooldown/timeout behavior is unchanged (behavior-preserving for the common case, matching ADR 0004's "cadences unchanged" precedent). - [ ] Test coverage (`tests/session-runner-test.sh` or a new test) exercises the multi-repo fairness case. **Out of scope:** - The `SESSION_RUNNER=on|off` enrollment policy itself (#6). - `Matou/idss#577`'s broader host-scheduling/capacity design — scoped here to the session-runner lock specifically (ADR 0004 point 6). - `/tmp/matou-swarm.lock` (the worker pool lock) — this ticket is about the session-runner lock only. **Verification:** Confirmed by reading `session-runner.sh` directly: `SESSION_RUNNER_LOCK` defaults to the single path `/tmp/matou-session-runner.lock`, taken via non-blocking `flock`, no repo-fairness logic present. ADR 0004 (landed closing #3 immediately prior to this triage pass) confirms this was deliberately left unruled as policy rather than ownership, and names this ticket as the follow-up and the likely first vendored reader of the new host registry.
Author
Member

This was generated by AI during triage.

Correction — my "DEFERRED" ruling above is withdrawn

A second /triage pass ran concurrently with this one and reached the
issue first with a materially better ruling — I'm retracting mine in its
favour rather than leaving both standing.

My deferred ruling assumed a fairness arbiter needed a registry reader that
doesn't exist. The correct ruling (posted earlier in this thread) sidesteps
that entirely: the starvation is caused by session-runner.sh's
host-global lock taken in front of the existing 2-slot host capacity
pool, not by a missing arbiter. Repo-scoping that lock (and its
SESSION_RUNNER_STATE/defer-count siblings, same root cause) fixes it
using infrastructure that already exists — no registry, no dependency on
#3/#6 at all.

I've also independently confirmed #3 landed (docs/adr/0004-*.md,
onboarding/host-state-lib.sh now on origin/main) partway through this
triage run, which is a second, independent reason my "ADR 0004 doesn't
exist yet" premise no longer held even on its own terms.

Removed the deferred label and the #3/#6 dependency links I'd added.
The correct state is the one already on the issue: ready-for-agent, per
the earlier ruling and agent brief in this thread.

> *This was generated by AI during triage.* ## Correction — my "DEFERRED" ruling above is withdrawn A second `/triage` pass ran concurrently with this one and reached the issue first with a materially better ruling — I'm retracting mine in its favour rather than leaving both standing. My deferred ruling assumed a fairness arbiter needed a registry reader that doesn't exist. The correct ruling (posted earlier in this thread) sidesteps that entirely: the starvation is caused by `session-runner.sh`'s host-global lock taken *in front of* the existing 2-slot host capacity pool, not by a missing arbiter. Repo-scoping that lock (and its `SESSION_RUNNER_STATE`/defer-count siblings, same root cause) fixes it using infrastructure that already exists — no registry, no dependency on #3/#6 at all. I've also independently confirmed #3 landed (`docs/adr/0004-*.md`, `onboarding/host-state-lib.sh` now on `origin/main`) partway through this triage run, which is a second, independent reason my "ADR 0004 doesn't exist yet" premise no longer held even on its own terms. Removed the `deferred` label and the `#3`/`#6` dependency links I'd added. The correct state is the one already on the issue: `ready-for-agent`, per the earlier ruling and agent brief in this thread.
Author
Member

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

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

This was generated by AI during triage.

Correction: the "blocked by #6" dependency is wrong

This ticket carries a native Forgejo dependency on #6 ("onboard-host:
host registry + idempotent machine enrolment"), added by a concurrent
triage pass that conflated two different registries.

#6's own body describes a different registry — the worker-pool
capacity/scheduling registry (hosts/<name>.conf) feeding
Matou/ourcloud#577's semaphore — and explicitly excludes host-state
ownership: "Moving existing hosts' state wholesale — that's #3; this
ticket must not fight it, only converge."
The registry this ticket (#35)
actually needs for its fairness arbiter — the enrolled-repo/session set —
is the one #3 already shipped (host-registry.conf's repo/session
directives, parsed by onboarding/host-state-lib.sh, ADR 0004, landed on
main). #6 is unrelated to what #35 needs.

(Separately, the earlier comment on this ticket proposing to repo-scope
the session-runner's lock rather than build a registry-reading arbiter at
all — sidestepping the registry question entirely — looks like the
stronger fix; worth the assigned agent weighing both options against each
other rather than this comment picking a winner.)

Net effect: #35 is not blocked by #6. Its closed dependency on #3 is
harmless (closed dependencies don't block the picker). The ready-for-agent
label already on this ticket is correct and unblocked today.

Attempted fix, didn't land: tried removing the #6 dependency via
Forgejo's DELETE /issues/{index}/dependencies API (the documented
IssueMeta{index,owner,repo} body). It 500s with an empty message on this
instance (gitea 1.22.0-based) — reproduced on a control case with the same
failure, so this is a platform bug, not a payload mistake.

What this means operationally: list-ready-tasks.sh and
session-runner.sh both skip a ticket with an open dependency, so until
this stray edge is removed, #35 will not actually surface to the swarm
despite carrying the correct ready-for-agent label.

Ben — this needs your hands only because the tooling to fix it via API is
broken, not because of any judgement call; the correction itself (#35 is
not blocked by #6) stands under ADR 0174 as a two-way door, proven by #6's
own "explicitly out of scope" section and #3's already-landed ADR 0004.

> *This was generated by AI during triage.* ## Correction: the "blocked by #6" dependency is wrong This ticket carries a native Forgejo dependency on **#6** ("onboard-host: host registry + idempotent machine enrolment"), added by a concurrent triage pass that conflated two different registries. #6's own body describes a **different** registry — the worker-pool capacity/scheduling registry (`hosts/<name>.conf`) feeding `Matou/ourcloud#577`'s semaphore — and explicitly excludes host-state ownership: *"Moving existing hosts' state wholesale — that's #3; this ticket must not fight it, only converge."* The registry this ticket (#35) actually needs for its fairness arbiter — the enrolled-repo/session set — is the one #3 already shipped (`host-registry.conf`'s `repo`/`session` directives, parsed by `onboarding/host-state-lib.sh`, ADR 0004, landed on `main`). #6 is unrelated to what #35 needs. (Separately, the earlier comment on this ticket proposing to repo-scope the session-runner's lock rather than build a registry-reading arbiter at all — sidestepping the registry question entirely — looks like the stronger fix; worth the assigned agent weighing both options against each other rather than this comment picking a winner.) Net effect: #35 is **not** blocked by #6. Its closed dependency on #3 is harmless (closed dependencies don't block the picker). The `ready-for-agent` label already on this ticket is correct and unblocked today. **Attempted fix, didn't land:** tried removing the #6 dependency via Forgejo's `DELETE /issues/{index}/dependencies` API (the documented `IssueMeta{index,owner,repo}` body). It 500s with an empty message on this instance (gitea 1.22.0-based) — reproduced on a control case with the same failure, so this is a platform bug, not a payload mistake. **What this means operationally:** `list-ready-tasks.sh` and `session-runner.sh` both skip a ticket with an *open* dependency, so until this stray edge is removed, #35 will not actually surface to the swarm despite carrying the correct `ready-for-agent` label. Ben — this needs your hands only because the tooling to fix it via API is broken, not because of any judgement call; the correction itself (#35 is not blocked by #6) stands under ADR 0174 as a two-way door, proven by #6's own "explicitly out of scope" section and #3's already-landed ADR 0004.
Author
Member

close-report for #35 — status success

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

envelope
{
  "issue": 35,
  "status": "success",
  "commits": [
    "ce895db"
  ],
  "changed_files": [
    "STATUS.md",
    "session-runner.sh",
    "tests/session-runner-test.sh"
  ],
  "tests": [
    {
      "command": "bash tests/session-runner-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "With two+ repos' session-runners on one host and one repo's session in flight, another enrolled repo's tick is not unconditionally absorbed for the full SESSION_RUNNER_TIMEOUT — it gets a fair turn within a bounded time (bound documented)": "session-runner.sh now defaults SESSION_RUNNER_LOCK to /tmp/matou-session-runner-<REPO_SLUG-sanitised>.lock (was host-global), so a peer repo's tick is NEVER blocked by another repo's session-runner lock — bound = zero wait on the lock; host-wide heavy concurrency contention is bounded instead by the shared 2-slot host capacity pool (host_capacity_acquire_heavy) that already sits behind the lock. Ruled under ADR 0174 in the issue thread. Proven by tests/session-runner-test.sh case 13: while repo A's derived lock is held, repo B's tick sails past and picks a ticket (red against the old host-global lock).",
    "A repo that loses the arbitration still yields and exits 0 (never blocks/camps)": "Unchanged and still true on both paths: the lock is `flock -n 9` then `exit 0` (session-runner.sh:108-109), and the host capacity pool yields `exit 0` on exhaustion (session-runner.sh). Case 13 asserts an absorbed same-repo tick stops before any API call; case 8 (pool exhausted) still green.",
    "With only one repo enrolled, existing claim/cooldown/timeout behavior is unchanged": "The three defaults keep their ${VAR:=…} override form and merely gain a per-repo suffix; a single-repo host resolves one stable lock/state/defer path exactly as before (only the path string changed). All 12 pre-existing session-runner cases stay green; full offline suite (63 files) green.",
    "Test coverage exercises the multi-repo fairness case": "tests/session-runner-test.sh +case 13 — two REPO_SLUGs resolve to distinct default lock/state paths; repo A's own tick is absorbed while its lock is held, repo B's is not; verified red against the host-global lock (reverting the default reproduces the failure)."
  },
  "summary": "Repo-scoped session-runner's lock/state/defer-count by REPO_SLUG so one enrolled repo can no longer starve another's ticks nor attribute its fail counters to another's issue numbers.",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #35 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 35, "status": "success", "commits": [ "ce895db" ], "changed_files": [ "STATUS.md", "session-runner.sh", "tests/session-runner-test.sh" ], "tests": [ { "command": "bash tests/session-runner-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL; done", "exit_code": 0 } ], "criteria": { "With two+ repos' session-runners on one host and one repo's session in flight, another enrolled repo's tick is not unconditionally absorbed for the full SESSION_RUNNER_TIMEOUT — it gets a fair turn within a bounded time (bound documented)": "session-runner.sh now defaults SESSION_RUNNER_LOCK to /tmp/matou-session-runner-<REPO_SLUG-sanitised>.lock (was host-global), so a peer repo's tick is NEVER blocked by another repo's session-runner lock — bound = zero wait on the lock; host-wide heavy concurrency contention is bounded instead by the shared 2-slot host capacity pool (host_capacity_acquire_heavy) that already sits behind the lock. Ruled under ADR 0174 in the issue thread. Proven by tests/session-runner-test.sh case 13: while repo A's derived lock is held, repo B's tick sails past and picks a ticket (red against the old host-global lock).", "A repo that loses the arbitration still yields and exits 0 (never blocks/camps)": "Unchanged and still true on both paths: the lock is `flock -n 9` then `exit 0` (session-runner.sh:108-109), and the host capacity pool yields `exit 0` on exhaustion (session-runner.sh). Case 13 asserts an absorbed same-repo tick stops before any API call; case 8 (pool exhausted) still green.", "With only one repo enrolled, existing claim/cooldown/timeout behavior is unchanged": "The three defaults keep their ${VAR:=…} override form and merely gain a per-repo suffix; a single-repo host resolves one stable lock/state/defer path exactly as before (only the path string changed). All 12 pre-existing session-runner cases stay green; full offline suite (63 files) green.", "Test coverage exercises the multi-repo fairness case": "tests/session-runner-test.sh +case 13 — two REPO_SLUGs resolve to distinct default lock/state paths; repo A's own tick is absorbed while its lock is held, repo B's is not; verified red against the host-global lock (reverting the default reproduces the failure)." }, "summary": "Repo-scoped session-runner's lock/state/defer-count by REPO_SLUG so one enrolled repo can no longer starve another's ticks nor attribute its fail counters to another's issue numbers.", "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/dev-factory#35
No description provided.