harness: swarm/triage matrix jobs race on the shared per-repo git workdir → intermittent early red (sig 096ffba7729c) #638
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#638
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?
Symptom
The
swarmworkflow intermittently reds one matrix job with no worker log, no run verdict, and noswarm.dbrow, paging the healer on the degraded workflow-name-only signature096ffba7729c. Latest: run 8467 (2026-08-21 19:45Z,swarm (1)/ task 16403). No work is lost — the sibling job (swarm (2)) completed cleanly (no-ready-tasks, exit 0), and the ready queue was empty.Root cause — concurrent git mutation of the shared per-repo workdir
.forgejo/workflows/swarm.ymlandtriage.ymlshare a 2-slot host-capacity semaphore (/tmp/matou-swarm.lock+/tmp/matou-host-slot-2.lock, two different lock files). After grabbing a slot, each job runsgit fetch / checkout -f / reset --hard origin/mainin the same workdir$HOME/swarm/$REPO_SLUG.The semaphore caps host load but does not give a job exclusive access to its repo's workdir. When two jobs for the same repo each hold a different slot (e.g.
swarm (1)+swarm (2), or swarm + triage — all three idss jobs fired within 3s at :45), they mutate the same.gitconcurrently and race onindex.lock/ ref locks. The loser's git step exits non-zero beforerun-swarm.shever starts → red job, healer paged, no run artifacts.Evidence
git reflogin the workdir: at 19:45:10 only onecheckout+resetpair landed (the winner); the losing job left no ref update — its git step failed. Contrast 17:30:10 / 16:00:10 where both same-repo jobs' pairs landed in the same second and both succeeded (the race is timing-dependent and usually benign).swarm.dbrun row for 8467:no-ready-tasks, exit 0 — only the winning job recorded.~/swarm/logs/run-swarm-verdicts.log: a single idssno-ready-tasksline at 19:45:15 (the loser wrote none).worker-logs.txtempty, norun-verdict.txt,seam-degradedmarker set (signature degraded to the workflow name)..sandcastle/.state/healer/096ffba7729c:repaired=1— the prior repair (7d836350, Claude auth-refusal classification) addressed a different early-fail cause that collapses onto the same degraded signature. So "recurred after repair" here is a false equivalence: the signature can't distinguish auth-dead from a git-race.Proposed fix (needs a human design call — do not auto-implement blind)
Give same-repo jobs exclusive workdir access. Options:
run-swarm.sh/run-triage.shblock (non-blockingflock -n, yield on contention — mirror the existing capacity-slot idiom; never-wcamp, per #238). Keyed on the workdir path so different hosts and different repos still run in parallel. Must be applied consistently toswarm.yml,triage.yml, andswarm-smoke.yml.$HOME/swarm/$REPO_SLUG-<worker>) — removes sharing entirely but loses the persistent-clone reuse and needs run-swarm.sh review.Secondary: the degraded signature conflates every early swarm fail (auth-dead, git-race, preflight) into
096ffba7729c, defeating the ledger's per-fault tracking. Worth keying early-fail incidents on a coarse stage tag even when no verdict exists.Blast radius / why escalated not auto-repaired
This changes the pipeline's core locking model across ≥3 workflow files; a wrong flock scope (camp/deadlock) breaks every swarm/triage run — far worse than the current rare, self-healing, no-work-lost red. Runtime-only behaviour, not unit-testable in-repo. Filed by the swarm healer (run 8467); recommend human review before merge.
Triage:
bug+ready-for-session.Verified the analysis:
.forgejo/workflows/swarm.ymlandtriage.ymleachgrab one of two independent host-capacity slot locks
(
/tmp/matou-swarm.lock,/tmp/matou-host-slot-2.lock) but neither acquiresany lock scoped to the shared per-repo workdir (
$HOME/swarm/$REPO_SLUG)before
git fetch/checkout -f/reset --hard. Confirmed no per-repo-workdirflock exists anywhere in
swarm.yml,triage.yml, orswarm-smoke.ymltoday— the race as described is real and unfixed.
Not ruling this under ADR 0174 rule 1: the proposed fix edits
.forgejo/workflow files, which are in the fingerprinted protected set (
.sandcastle/.forgejo/, per.sandcastle/protected-paths-lib.sh) — machinery a swarmworker must never touch, and machinery-change escalation is spelled out
verbatim as
ready-for-session, not agent-ruled orready-for-human, unlessa session finds a genuine one-way door. It also fails ADR 0174's provability
prong on its own: the issue itself notes this is "runtime-only behaviour, not
unit-testable in-repo" — a locking-scope choice across 3 shared CI workflows
can only be proven by watching live runs, and a wrong scope (camp/deadlock)
would stall every swarm/triage run repo-wide, including this triage
pipeline's own ability to recover. That's exactly the case
protected-paths-lib.shcarves out for an interactive session's standingrather than a swarm worker or a blind agent ruling.
No redundant/prior fix found (searched
.forgejo/workflows/*.ymlforexisting per-workdir locking; none exists) and no matching entry in
.out-of-scope/(directory doesn't exist yet in this repo).Labelling
bug+ready-for-session. A session picking this up shouldimplement option 1 (per-repo-workdir
flock -n, non-blocking, mirroring theexisting capacity-slot idiom, applied consistently across all three
workflow files) unless it finds a reason to prefer option 2, watch it across
live runs, and only escalate further to
ready-for-humanif it turns up anactual one-way door.
Ruled by agent under ADR 0174 — veto anytime
Ruling: this is a two-way door, not the human design call the ticket
flagged it as needing. (a) Revertible — the whole fix is a CI-config
commit to three workflow files, trivially revertible. (b) Provable
offline —
.sandcastle/tests/workdir-lock-yield-test.shpins theyield-not-camp lock semantics AND reproduces the actual documented race
(two concurrent guarded
fetch/checkout -f/reset --hardagainst a realgit clone, landing cleanly and serialized; 5/5 stable runs). (c) Not on
the one-way-door list — no personal credentials, no security-posture
widening, no member-facing trust surface, no data destruction, no spend.
What proves it:
b5a39930— non-blocking, per-repoflockon/tmp/matou-workdir-<repo-slug>.lock(keyed on$REPO_SLUG, never camping,mirroring #238's yield idiom and the #577/ADR-0184 precedent for exactly this
class of ruling) now wraps the
git fetch/checkout -f/reset --hard/cloneblock inswarm.yml,triage.yml, andswarm-smoke.yml. Contended→ yield (exit 0 in swarm/triage so the cron/backstop re-fires; exit 1 in
swarm-smoke since it has no re-fire schedule and a silent 0 there would read
as a false pass).
Where I narrowed the ticket's own Option 1: the ticket proposed locking
"around the git-setup +
run-swarm.sh/run-triage.shblock" — the WHOLErun, not just setup. I scoped the lock to just the git-setup step instead,
releasing before the run script starts. Reason: the evidence in this ticket
(the
git refloganalysis) is entirely about the checkout+reset step racing— nothing shows
run-swarm.sh's later worktree machinery racing. Locking thewhole run would additionally serialize the matrix workers' actual
ticket-claiming work whenever two same-repo jobs land on one host, and
docs/superpowers/specs/2026-08-11-multihost-swarm-design.mdexplicitlyflags that "intra-host parallelism" case as unverified for the claim
arbitration design (D6) — reaching into that with a blind lock-the-whole-run
change would have been the actual one-way-door-adjacent move here. The
narrower fix directly closes the documented race with no touch on that open
question.
Docs:
docs/GOTCHAS.md#46 records the hazard class.STATUS.mdupdated in the same commit. The ticket's "Secondary" ask (key the healer's
degraded-signature ledger on a coarse stage tag even absent a verdict) is
filed separately as #639 — it's healer classification logic, not the locking
model, and deserves its own scoping pass rather than riding this fix.
Closing — the fix is landed, proven offline, and documented. The next
same-repo matrix/triage collision on a live host is the field proof; #639
tracks the signature-granularity follow-up.
reset --hard origin/mainmid-run is attributed to the worker and DELETES main-owned machinery (run 57327 lost #2099) #2104