Swarm: concurrent fleet workers collide on STATUS.md — Sandcastle's merge-to-main dies with SyncError #1899
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#1899
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?
Filed by the swarm healer for run https://git.matou.nz/Matou/idss/actions/runs/32926 (signature
3d11ef9a924f, hostelitebook-distributed-server-03).Symptom
sandcastle run (workers)exits 1 at the post-iteration merge:The workdir is left mid-merge (
UU STATUS.md,MERGE_HEAD=c0583996), and asandcastle/worker/*branch is preserved forever. Two older orphans from the same shape are still sitting in the workdir:sandcastle/worker/20260826-041808-6b0e8f,sandcastle/worker/20260908-021709-1678bd.Root cause
Since
7e7282e8(2026-09-25 18:48, FACTORY_REF bump to 87e1b55)swarm.ymldeliberately carries no concurrency group — swarm runs no longer serialise, which was the right fix for the #1732 head-of-line stall. The fleet now works several tickets at once (runs.json:bens-mac-04,elitebook-03,matou-workstationall running swarm within the same minutes).Per-ticket claiming stops two workers taking the same ticket, but nothing keeps two workers on different tickets off the same file — and CLAUDE.md requires every state-changing commit to update
STATUS.md, each one inserting a new entry at the head of the milestone log. Two concurrent workers therefore write adjacent, conflicting lines by construction:elitebook-03run 32926 started 19:07:50 froma2f2e99a, worked #1892, committedc0583996at 20:02.bens-mac-04pushed0a5b4619(#1893, 19:19) andf911cc9f(#1887, 19:25) tomain.c0583996onto the advancedmainconflicts on STATUS.md line 1 —<<<<<<< HEAD#1887's entry vs>>>>>>>#1892's entry. Nothing else in either change overlaps.So this is not a one-off: with the fleet de-serialised, any two swarm runs whose workers both finish a state-changing ticket will collide on STATUS.md. Expect it roughly every time two tickets land close together.
What the healer did
git merge --abortin~/swarm/Matou/idss(swarm lock free, no swarm process running). Workdir is clean atf911cc9f=origin/main.c0583996is onorigin/agent/issue-1892as open PR #1898 (landing-pr, awaiting human merge). The sibling #1891 is likewise safe on PR #1897..forgejo/workflows/swarm.yml— dropping the concurrency group is a deliberate human decision and reverting it is outside the healer's remit.What needs deciding
The fleet wants to run concurrently and the repo rule wants every commit to touch STATUS.md. Something has to give. Options, roughly in increasing order of blast radius:
STATUS.mdamerge=unionentry in a root.gitattributes. Cheap; auto-keeps both entries. Risk: if two workers both edit the header line, union silently emits two header lines rather than conflicting — a corrupt status ledger that no one is told about. Would want a CI check that the header appears exactly once.docs/status/milestones/NNNN-*.md) with STATUS.md holding only the header + gate rows, so concurrent workers write disjoint files and only a genuine same-gate edit conflicts.SyncError, re-fetch, rebase the worker branch onto the newmainand re-attempt once, escalating only if a non-STATUS.md path conflicts. (Lives in vendored@ai-hero/sandcastle, so likely an upstream dev-factory change.)Options 1 and 2 are repo-local; 3 and 4 are factory changes. Whichever is chosen should also sweep the orphaned
sandcastle/worker/*branches the failed merges leave behind.Acceptance criteria
sandcastle/worker/*branches are cleaned or reported.Triage:
bug+ready-for-session. Ruled by agent under ADR 0174 — veto anytime.The ruling
Adopt Option 1 (root
.gitattributeswithSTATUS.md merge=union) as the STATUS.md-collision fix, guarded by a test/CI check for residual conflict markers, and pair it with the host-side orphan-branch sweep. Options 3 and 4 (harness merge-retry, re-serialised merge) are not needed if union holds, and Option 2 (splitting the log into per-file entries) is a larger, unnecessary blast radius.Why Option 1 is safe for this file specifically: the report flags one real hazard for
merge=union— if two workers both edit a rewritten header line, union silently emits two header lines. I checked: STATUS.md has no rewritten header line. It carries no#title and no table/gate rows — it is a prepend-only log of one-line dated entries (each state-changing commit inserts one long single-line**date (#NNNN …)**entry at line 1). Union merge on a set of distinct single-line entries keeps both and never conflicts; the only cost is that two same-window entries land in arbitrary relative order, which is harmless for a log. A CI/test assertion that a merged STATUS.md contains no<<<<<<</=======/>>>>>>>markers covers the residual.Why this is a two-way door (ADR 0174)
.gitattributesline (delete it to revert), a check script, and a test. No irreversible state.Why
ready-for-session, notready-for-agentTwo reasons a swarm worker must not take this:
sandcastle/worker/*branches are cleaned or reported" live in the vendored@ai-hero/sandcastleharness and host-side scripts — protected/live-infrastructure territory (ADR 0174 rule 5,.sandcastle//host standing), which the swarm queue (ready-for-agent-only) is built to keep workers out of.Why not
ready-for-humanNo one-way door and the whole call is revertible + provable, so under ADR 0174 this is a session ruling, not Ben's. Ben's veto stays asynchronous.
Note on the concurrency-group decision
The healer correctly left
swarm.yml's dropped concurrency group alone (the deliberate #1732 fix). This ruling does not touch it — union merge lets the fleet keep running concurrently and satisfies the every-commit-touches-STATUS.md rule, which was the whole tension.Related
Cross-reference #1739 (swarm harness: merge-to-head can fast-forward local main onto an unpushed orphan) — the same merge-to-main harness surface, but a distinct failure; not a duplicate. The orphan-branch sweep here should be reconciled with that work.
Ruled by agent under ADR 0174 — veto anytime
Ruling: took option 1 (the ticket's own lowest-blast-radius option) — a root
.gitattributesdeclaringSTATUS.md merge=union. It is a two-way door (revert = delete one line) and fully provable offline, so it needed no human gate.Why it works with the harness unchanged: Sandcastle's merge-to-main shells out to a plain
git merge "<worker-branch>"(execAsyncin@ai-hero/sandcastle,dist/chunk-VOG34SRF.js), so the CLI honours themerge=uniondriver from.gitattributeswith no factory change. Since STATUS.md is a prepend-only milestone log, union keeps both workers' line-1 entries instead of conflicting.Proof:
CONFLICT (content): Merge conflict in STATUS.md/ non-zerogit merge(the SyncError source); with it →Auto-merging STATUS.md, merge succeeds, both entries present, zero conflict markers.scripts/tests/status-md-union-merge-test.sh(run in ci's seam viascripts/seam-smoke.sh): pins the attribute viagit check-attr, drives the collision, asserts no entry lost and none duplicated (union's one hazard) and the workdir ends clean, and asserts the no-attribute control still conflicts. Red before the fix, green after.Close report
Landed:
ead4f1a5onmain..gitattributes(new) —STATUS.md merge=union.scripts/tests/status-md-union-merge-test.sh(new) — the guard test, auto-discovered by the seam'sscripts/tests/*.shloop.docs/GOTCHAS.md— entry #348 (symptom → cause → rule).STATUS.md— milestone entry prepended.Acceptance:
MERGE_HEAD, no preservedsandcastle/worker/*branch.Split to #1901 (dev-factory follow-up), the honest residual: a genuine conflict on a non-STATUS.md path still strands the workdir + leaves an orphan branch — that is
@ai-hero/sandcastlelibrary behaviour with no host hook (the same out-of-reach residual #1717 recorded), and covers options 3/4 (retry-merge / flock-the-merge) plus the orphan sweep.Orphans reported (not deleted — could hold un-pushed work; not reachable from this host): run 32926's
sandcastle/worker/20260826-041808-6b0e8f,20260908-021709-1678bd,20260925-190818-d08c0bonelitebook-distributed-server-03(~/swarm/Matou/idss); their work is already safe on PRs #1898/#1897. matou-workstation's swarm workdir carries no such orphans.