sandcastle: the claim mechanism handed #536 to two hosts — both fully implemented it, one duplicate discarded #541
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#541
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
Issue #536 was handed to my Sandcastle run as its claimed ticket (top-of-prompt ready list, my
SWARM_RUN_ID=6236on hostfd9d69e4d645), and I implemented the full three-part fix. On push,git rebase origin/mainconflicted across all 8 files with commit293097a— a near-identical independent #536 implementation landed by another host, which had already closed the issue. The claim comment on the issue readsswarm-claim host=elitebook-distributed-server-03 run=6236with the note "(automated multi-host claim — lowest live claim id works this ticket)".So two hosts fully implemented the same ticket (same
ServiceHealth.Detail, samedroplet-units.txtharvest, same co-host closure pin, same GOTCHAS #35) — one landed, one was discarded. I aborted the rebase and reset to origin/main; no duplicate was pushed.Likely cause (for a human to confirm)
The claim resolution — "lowest live claim id works this ticket" — appears not to have fenced my host out before it started work. Either the tiebreak did not deduplicate across hosts, or both hosts started before either claim was visible to the other. The
.sandcastle/claim machinery is a protected path, so I did not touch it.Suggested direction
Have the executor confirm a single live claim owner (and re-verify the issue is still open +
ready-for-agent) immediately before the agent begins work, so a losing claimant exits early instead of implementing a full duplicate. At minimum, a pre-flight re-check of issue state right before the agent starts would have caught that #536 was already closed.Found while working #536 (2026-08-14); the fix itself is fine and merged as
293097a.Relabelled
ready-for-sessionunder ADR 0174: the likely-cause confirmation is an investigation against the claim-lib code and the two runs' timestamps (provable, not a judgement call), and the fix touches.sandcastle/protected paths — session work. The suggested pre-work re-check (single live claim owner + issue still open/ready right before the agent starts) is the obvious two-way-door shape.Ruled by agent under ADR 0174 — veto anytime
Ruling: root-caused and fixed in code, not a one-way door.
claim-lib.sh'sclaim_alive_runs()filtered/actions/taskswith an exact.name == "swarm"match (
39c5a23, 2026-08-11), predatingswarm.yml's 2-wide worker matrix(
strategy.matrix.worker:[1,2],44fe333, the "POOL CUTOVER"). Forgejo nameseach matrix job
swarm (1)/swarm (2), never bareswarm— live-probed2026-08-15 against the real
/actions/tasksresponse: every current task inthe last 40 entries checked is suffixed, none bare. That means
claim_alive_runs()has returned[]in production since the matrix landed:claim_won's own-id short-circuit was the only signal any host ever had for"is my claim the lowest live one", so a racing host always saw the OTHER
host's earlier claim as dead (never in the always-empty alive set) and
declared itself the sole winner too — both hosts "win" independently. That's
exactly the reported symptom:
fd9d69e4d645andelitebook-distributed-server-03both fully implemented #536.Why a two-way door: a one-line jq filter change, reverted by a commit;
proved by two new offline
claim-lib-test.shcases that reproduce the exactdouble-win (fail red against the pre-fix filter — confirmed before the fix —
and pass green after). No credentials, no security-posture widening, no
trust-surface accept, no data destroyed, no hardware touched.
What proves it:
a3324a8—.name == "swarm" or (.name | test("^swarm \\("))wins under matrix-suffixed alive runs / later claim correctly loses — no
double-win" (the second is the direct #541 regression test).
.sandcastle/tests/*.shsweep: all 34 suites green on this host.GET /actions/tasks?limit=100&page=1on 2026-08-15 — realentries are
"swarm (1)"/"swarm (2)", confirming the filter's exactmatch could never have matched production traffic since the matrix landed.
Scope note:
schedule-backstop.sh's in-flight check forswarm.ymlhasthe identical
.name == $nexact-match blind spot (a different symptom —redundant backstop dispatches, not duplicate ticket implementations). Left
unfixed here to keep this diff scoped to the reported/proven bug; filed as
#588 (
ready-for-agent).The "confirm a single live claim owner right before the agent begins work"
direction in the original report turned out to be a symptom-level mitigation
of a bug that made EVERY claim-time check unreliable, not the root cause —
the actual fix restores the alive-runs check itself, so the existing
claim-then-verify flow (already the first thing
prompt.mddoes eachiteration) is now trustworthy again without needing a second re-check layer.
Close report
Landed:
a3324a8onmain(pushed toorigin/main)..sandcastle/claim-lib.sh:claim_alive_runs()now matches job nameswarmORswarm (N), not just the pre-matrix bareswarm..sandcastle/tests/claim-lib-test.sh: two new cases — matrix-suffixednames count as alive; a same-issue two-claim race under matrix-suffixed
alive runs resolves to exactly one winner (this second case is the direct
#541 regression test, confirmed red against the pre-fix filter before the
fix landed).
STATUS.mdupdated in the same commit (header + milestone entry).ready-for-agent) for the identical exact-match blind spot inschedule-backstop.sh'sswarm.ymlin-flight check — out of scope here.Proof:
bash .sandcastle/tests/claim-lib-test.sh— 28/28 pass (was 26/28 with thetwo new cases added pre-fix, confirming red-before-green).
.sandcastle/tests/*.shsweep (34 suites) — all green on this host.GET /actions/tasks?limit=100&page=1on 2026-08-15 confirmedthe real API returns
"swarm (1)"/"swarm (2)", never bare"swarm",matching
swarm.yml'sstrategy.matrix.worker:[1,2](44fe333) andexplaining why the pre-fix filter always saw zero live runs.
Ruling posted above under ADR 0174 (two-way door: revertible commit, provable
by the new regression test + the live probe). No credentials, security
widening, trust-surface accept, data destruction, or hardware involved.
Closing.