swarm: multi-project queue hygiene — flock -n fast-exit, per-repo /tmp namespacing, waiting-aware backstop #238
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#238
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?
Why (evidence from 2026-07-31 ~21:55 UTC)
Sandcastle now serves TWO repos (
Matou/ourcloud+Matou/matou-app) from one capacity-1 runner on matou-workstation, and the seams showed tonight:swarm.yml) + 10 on matou-app, all serialized behind one hour-class worker. Every issue event stacks anotherswarm.ymlrun, and each started run blocks up to 2h onflock -w 7200 /tmp/matou-swarm.lock(swarm.yml:37) instead of yielding. matou-app — whose queue positions are newest — is starved for hours even though its jobs would mostly no-op./tmpstate is shared across repos with repo-agnostic names:/tmp/matou-swarm-lastready(each repo overwrites the other's debounce stamp → the anti-storm coalescing from 2026-07-29 is defeated),/tmp/matou-healer.lock(one repo's healer makes the other's skip its incident),/tmp/matou-heal.*evidence dirs (no repo tag),/tmp/matou-swarm-claude-limit(notice dedupe suppresses the other repo's first notice).schedule-backstop.sh(now cron-driven every 15m via~/swarm/backstop-tick.sh, installed tonight after BOTH repos' Forgejo schedule rows died again) only counts started runs, so while the runner is busy it re-dispatches workflows whose earlier dispatch is stillwaiting— duplicates piled up 2× per workflow on matou-app within 20 minutes. The cron wrapper now carries a stopgap waiting-run guard; that logic belongs upstream in the script.sandcastle-*containers (44h and 2×2d old) are still up on an 8GB host — worker cleanup is leaking containers.Acceptance criteria
swarm.ymlyields instead of camping: replaceflock -w 7200withflock -n+ clean exit 0 ("another swarm run holds the host — yielding; the backstop/cron re-fires"). Queued swarm runs then drain in seconds instead of serializing hour-class waits. Same change in both repos (or via the shared-harness home, see #-note below)./tmpnamespacing: suffixmatou-swarm-lastready,matou-healer.lock, andmatou-heal.*evidence dirs with the repo slug./tmp/matou-swarm.lockSTAYS global by design (one heavy worker per host — that is the cross-repo serialization we want, made survivable by AC1) — document that intent where it's defined./tmp/matou-swarm-claude-limitstays global (one subscription) — document likewise.schedule-backstop.shcountsstatus=waitingruns for the workflow (see the guard in~/swarm/backstop-tick.shon matou-workstation) before dispatching; remove the wrapper stopgap once upstreamed.sandcastle-*containers older than a run-lifetime; the 3 stale ones get cleaned as part of landing this.Open question for Ben (not blocking the ACs)
The harness is now two diverging vendored copies (matou-app has
verify.yml/check-verifications.sh/schedule-backstop.sh; ourcloud hasgate.sh/git-hooks, and #235's healer fixes will land only here). Extracting.sandcastle/+ workflows into a shared repo consumed by both is the durable shape — needs a ruling on repo layout before anyone builds it.Pointers
.forgejo/workflows/swarm.yml(both repos),.sandcastle/run-swarm.sh,.sandcastle/heal.sh,.sandcastle/schedule-backstop.sh(matou-app copy is canonical),~/swarm/backstop-tick.sh+ crontab on matou-workstation (installed 2026-07-31)Blocks
depends_on: [#250] — the remaining half (matou-app mirror of AC1/AC2/AC4 + the AC3 backstop) rides #250's manifest+sync per the 2026-08-01 layout ruling (comment 3687). Native dependency API 404s on this instance; this block is the durable edge.
Landed the ourcloud-tree portion (commit
a47b900on main): AC1, AC2, AC4, and the AC1+AC4 offline tests.swarm.yml(andtriage.yml, which spins Sandcastle the same way) nowflock -n+exit 0instead offlock -w 7200on/tmp/matou-swarm.lock. A run that can't take the host lock yields and the cron re-fires, so queued runs drain in seconds. The lock stays global by design (one heavy worker per host — the cross-repo serialization we want, now survivable) — documented in place./tmp:matou-swarm-lastready, the healer lock, and thematou-heal.*evidence dir now carry the repo slug (run-swarm.sh,heal.sh).matou-swarm.lockandmatou-swarm-claude-limitstay global (one host / one subscription) — intent documented where each is defined.sweep-lib.shgrewreap_containers, run fromrun-swarm.sh's exit trap under the held lock; force-removes anysandcastle-*container older than a run-lifetime (3h > the 180-min job timeout). No-op where docker is absent.tests/swarm-lock-yield-test.shpins AC1 (held lock → second run yields 0 fast, never camps);tests/sweep-lib-test.shgains reap groups pinning AC4. All existing.sandcastle/tests/*still pass.Remaining — relabelled
ready-for-human(needs a human + the repo-layout ruling):schedule-backstop.shis matou-app's canonical copy andbackstop-tick.shis on matou-workstation. Neither is inMatou/ourcloud, so the ourcloud swarm cannot edit them. The AC3 offline test rides with that script..sandcastle/+ workflows into a shared home consumed by both "needs a ruling on repo layout before anyone builds it." That ruling is the natural gate for finishing this ticket's cross-repo half — henceready-for-humanrather than closed.git worktree repairkilled run 1649's sibling worker #239Cross-reference for whoever picks up the matou-app mirror half: matou-app commit
4342c01(2026-07-31 late, first manual harness sync — see #250) already carried the healer portion of AC2 to matou-app: itsheal.sh/heal-lib.sh/heal-prompt.mdnow match ourcloud canonical (per-repo healer lockmatou-healer-<slug>.lock, per-repomatou-heal-<slug>.*evidence prefix, #197 seam signatures, #235 run-window scoping; only transform = the repo slug). Still OUTSTANDING on the matou-app side: AC1 (swarm.yml/triage.ymlflock -n yield), AC2'srun-swarm.shlastready namespacing, AC4 (sweep-lib.shreap_containers) — those files were not in the synced set. Also note new sibling ticket #253: the triage + healer claude calls need the limit guard (globalmatou-swarm-claude-limitsemantics from this ticket's landed half). The repo-layout ruling this ticket is parked on is being decided against #250's canonical-copy proposal — one ruling will reconcile both.Layout ruling (the gate this ticket parked on): no shared home at n=2.
Sandcastle stays per-repo vendored harnesses, converged mechanically — the #250 model (ourcloud
.sandcastlecanonical for the manifest set; renderer pushes to matou-app; far-side drift-check red). Rationale, recorded so it isn't relitigated per-file:matou-swarm-claude-limitmarker, one subscription — per the landed half), code per-repo.Promotion path, not a dead end: the manifest boundary IS the extraction seam. If a third repo joins the swarm, or the harness wants its own release/test cadence, promote the manifest set into a dedicated harness repo then.
Consequences for this ticket's remaining half: the matou-app mirror of AC1/AC2/AC4 and the AC3 backstop ride #250's mechanism (heal.sh portion already delivered by matou-app
4342c01; see the cross-reference above). Dependency on #250 added accordingly; re-armingready-for-agent.Landed the manifest-riding slice of the remaining half (commit
a8e3e60on main).Per the 2026-08-01 layout ruling (comment above) — the mirror rides #250's manifest+sync — the swarm took the part it can reach from the ourcloud tree:
schedule-backstop.shis promoted from matou-app-only into ourcloud canonical with the fix. It now treats an in-flight run (status=waiting, i.e. queued behind the busy capacity-1 host, orrunning) as "already covered" and skips — not just a run STARTED within the window. The pre-#238 started-only count re-dispatched, every tick, a workflow whose earlier dispatch was still queued (the 2× duplicates in 20m). This is its upstream home; the hostbackstop-tick.shstopgap can be dropped once the fixed copy is installed.sweep-lib.sh(thereap_containersreaper) added toharness-manifest— verified byte-identical to matou-app's copy modulo the reaper (no slug refs → generic).harness-manifest, so #250'sharness-sync.ymlpropagates them to matou-app on push and the far-side drift check keeps them from rotting. The sync dry-run confirms both render and would sync to matou-app..sandcastle/tests/schedule-backstop-test.sh— 5 offline scenarios (waiting/running suppress dispatch; an idle scheduler still dispatches; a fresh started run suppresses; another workflow's waiting run does not).sync-harness-test.shstill green.Still off-repo — needs Ben's hands, relabelling
ready-for-human:backstop-tick.shwaiting-run stopgap (now upstreamed). ourcloud CI does not run the backstop, so this is a host action.swarm.yml/triage.yml(flock-w 7200→-nyield) andrun-swarm.sh(matou-swarm-lastready→-$repo_tag, and thereap_containersexit-trap call). These are workflow + repo-specific files, off-manifest by the ruling (the sync only carries generic.sandcastle/files) — so they can't ride the manifest and need either a matou-app-side ticket/commit or your hands. Confirmed still outstanding on matou-app tip today:flock -w 7200in both workflows, un-namespacedstamp="/tmp/matou-swarm-lastready", no reap call.Both remaining chores executed (2026-08-06, Ben's sweep ruling: agent does both) — closing.
~/swarm/backstop-tick.shrewritten (old copy atbackstop-tick.sh.bak-0806) — it now delegates to ourcloud's canonical.sandcastle/schedule-backstop.sh(both checkouts pulled; both copies verified waiting-aware froma8e3e60) and the local waiting-run stopgap is dropped, as upstreamed. Live run verified: the upstream suppression fired (swarm already in flight (waiting/running) … skipping) and idle workflows dispatched normally. Crontab entry unchanged (same path).054faaeon matou-app main — AC1 (swarm.yml/triage.ymlflock -n+ exit-0 yield, global-lock intent documented), AC2 (run-swarm.shdebounce stamp →/tmp/matou-swarm-lastready-Matou-matou-app; claude-limit marker documented global), AC4 (sweep_and_reportcalls the syncedreap_containers). Offline checks green:bash -n, workflow YAML parse,sweep-lib-test.sh,debounce-test.sh.Every AC is now live in both repos + on the host. The stale containers named in the body were already reaped by the landed AC4 half.
waiting, oldest 23h; ci, healer, triage, resume-asks and broker-deploy are all starved #878