factory design: host scheduling — capacity semaphore, per-repo fairness, drive-vs-worker serialization #577
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#577
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem — the host lock is the multi-project wall
/tmp/matou-swarm.lockadmits one heavy worker per host across ALL repos. Two repos already produced documented hour-class starvation (the yield-don't-camp fix inswarm.yml:46-59mitigates, doesn't remove); project #3 triples the queue behind one mutex.Separately, nothing serializes a 1–3 h rehearsal drive against the other workstation workers:
rehearsal-cycle.sh:12-13's comment claims "never beside a swarm run", but the code only takes/tmp/matou-rehearsal-drive.lock— the hourly healer and the */10 session-runner can land mid-drive on the same host, sharing nothing but the Claude-limit marker.Design to rule on
Needs Ben: the concurrency policy is a genuine ruling (capacity per host, what coexists with a drive), and it interacts with the two-account token reality. Survey:
docs/research/2026-08-15-factory-reengineering-survey.md§scheduling.Ben ruled (2026-08-19, live session): the factory block is delegated under ADR 0174 — dispatched to the agent/session lanes with dependency edges wired; veto via the tracker anytime.
Ruled by agent under ADR 0174 — veto anytime.
Ben's delegation on this ticket ("the factory block is delegated under ADR
0174 — dispatched to the agent/session lanes with dependency edges wired;
veto via the tracker anytime") made the concurrency policy itself a two-way
door: revertible by commit/config, provable by offline tests plus a live
probe. Full reasoning:
docs/adr/0184-host-capacity-is-a-two-slot-pool-not-a-single-lock.md.Capacity semaphore: 2 pooled heavy slots (
/tmp/matou-swarm.lockkept asslot 1 for cross-repo backward compatibility, new
/tmp/matou-host-slot-2.lockas slot 2), first-fit non-blocking, still yield-don't-camp (#238). Sized to
the #510 two-account reality — never more concurrent heavy Claude-burners than
accounts — not to RAM headroom alone.
Per-repo fairness: rides the pool itself. The documented starvation
pattern was sequential re-triggering of one slot (a deep queue's cron ticks +
label/close events out-racing a sibling repo's tick), which 1→2 pooled slots
fixes directly with no repo-affinity logic. A dedicated-lane-per-repo registry
was considered and rejected — no existing home (workflow YAML is copy-per-repo,
.sandcastle/vendoring is deliberately repo-agnostic per ADR 0180) and morecomplexity than the evidence calls for. Named fallback if this proves
insufficient: cap
swarm.yml's matrix width to structurally limit one repo to1 held slot.
Drive-vs-worker serialization: a drive now excludes EVERYTHING heavy,
host-wide, for its whole run —
scripts/lib/host-capacity-lib.sh'shost_capacity_acquire_exclusivegrabs both pooled slots plussession-runner's and the ourcloud healer's own existing locks, all-or-nothing,
non-blocking. This closes the exact gap named in the ticket (drive shared
nothing with the healer/session-runner but the Claude-limit marker) without
touching either vendored file — it grabs their existing lock files from the
outside.
Proof:
scripts/tests/host-capacity-lib-test.sh(6 offline groups: first-fit,fallthrough, pool-exhausted yield, release-and-reacquire, exclusive-acquire-
all-free, exclusive-acquire-partial-failure-releases-everything — all green),
.sandcastle/tests/host-capacity-yield-test.sh(4 groups mirroring theworkflow-embedded snippet, all green), plus two live probes this session on
matou-workstation: a real
flock -non both real slot paths, andrehearsal-cycle.sh's exclusive-acquire correctly detecting THIS session'sown live
/tmp/matou-session-runner.lockand yielding in <1s with zeroresidue.
Deferred, filed as #605: session-runner and the healer formally joining
the pool as participants (not just exclusion targets) against swarm/triage —
needs editing
.sandcastle/session-runner.sh/heal.sh, both vendoredbyte-identical from
Matou/dev-factory(ADR 0180), a separate cross-repotwo-way door out of this ticket's safe blast radius.
Close-report
Landed (
9c235a0, pushed to main):scripts/lib/host-capacity-lib.sh(new),
scripts/tests/host-capacity-lib-test.sh(new, 6 groups green),.sandcastle/tests/host-capacity-yield-test.sh(new, 4 groups green),.forgejo/workflows/swarm.yml+triage.yml(2-slot lock block),scripts/rehearsal-cycle.sh(exclusive-acquire wired in),docs/adr/0184-*.md(this ruling),
docs/GOTCHAS.md#44 (new — the #469 restart procedure onlyheld slot 1, silently stopped proving quiescence once slot 2 exists; fixed in
the same commit,
.forgejo/runner/README.md's restart command now nests bothflocks),
docs/agents/swarm-atlas.md+.sandcastle/README.mdupdated,STATUS.mdupdated. No vendored.sandcastle/files touched (ADR 0180respected).
git pull --rebasewas clean, pushed tomaindirectly (noconflicts).
Not done, tracked as #605: session-runner/healer pool participation
(needs
Matou/dev-factory).Closing #577 — the three items in "Design to rule on" are addressed (capacity
semaphore, per-repo fairness, drive-vs-worker serialization); the remaining
residue is scoped, tested-as-far-as-possible, and tracked separately.