swarm harness: a worker works an UNCLAIMED ticket via the # Done staleness re-check — duplicate work, and the orphan commit poisons local main into a SyncError #1717

Closed
opened 2026-09-22 04:38:38 +00:00 by matou-build-agent · 2 comments

Harness (factory-vendored fix — upstream dev-factory, FACTORY_REF 834ec681).

A worker whose iteration-start claim came back EMPTY re-runs the listing
script on the "queue may be stale" path, finds a ticket another host already
claimed, and works it with no claim at all — burning a duplicate
implementation and poisoning the host's local main, which reds the run's
Merging to main sync.

What happened (swarm run 29782, host elitebook-distributed-server-03)

.sandcastle/logs/main-sandcastle-worker-20260922-034615-fddb1b-worker.log,
iteration 1:

Expanding shell expressions
  bash .sandcastle/claim-next-task.sh -> ~1 tokens        <- EMPTY: nothing claimable
Agent started
The ready-tasks list came in empty. Per the workflow, I need to re-check ...
Bash(bash .sandcastle/list-ready-tasks.sh)
A fresh task appeared: #1713. Let me read the full issue and its comments.

It then implemented #1713 for ~16 minutes. But #1713 was already claimed by the
OTHER pool host 19 s after this run started — #1713 carries exactly ONE
swarm-claim comment (id 53028, host=matou-dev-server-01 run=29782,
03:46:34Z). elitebook-...-03 never posted a claim for #1713; its first claim
this run is on #1715 (id 53046, 04:11:32Z).

Consequences, in order:

  1. Duplicate work. matou-dev-server-01 landed #1713 as 66e6eb4c (04:05:17Z,
    closed 04:08:47Z). elitebook committed its own rival be0ca791 (04:02:25Z)
    — never pushed, superseded, ~16 min of worker slot wasted.
  2. Poisoned local main. Sandcastle still fast-forwarded the shared workdir's
    main onto the orphan (git reflog main: be0ca791 ... merge sandcastle/worker/20260922-034615-3c0f43: Fast-forward, 04:10:36).
    Local main became ahead 1, behind 3 of origin/main.
  3. Red run. Iteration 2 legitimately claimed #1715, landed it (b4ab8902), and
    closed the issue at 04:28:22 — then Sandcastle's Merging to main merged
    that branch (tip == origin/main) onto the poisoned local main. Two rival
    #1713 implementations over the same 9 files + append-conflicting
    STATUS.md/GOTCHAS.md ⇒ SyncError, exit 1, after all work had landed.

Root cause

.sandcastle/prompts/prompt.md (FACTORY_MANIFEST line 43), # Done:

bash .sandcastle/list-ready-tasks.sh

list-ready-tasks.sh lists; it does not claim. The prompt's own next
sentence is right — "otherwise end the iteration normally and the next
iteration will pick the fresh task up"
(the next iteration re-enters via
claim-next-task.sh) — but the agent is handed a claimable-looking work order
and skips the stand-down. Nothing mechanical refuses work on a ticket this
run never claimed: close-report.sh's claim check only runs at close time, so
a worker that loses the push race (as here) never reaches a gate at all.

The same bypass is visible, harmless-by-luck, in the 21:03:36 run — re-check
returned [], so no ticket was there to grab.

Asks

  1. Mechanical gate (the real fix). Refuse to commit/push for an issue
    whose swarm-claim host=... run=$SWARM_RUN_ID comment does not exist —
    fail loud, at the start of the work, not at close-report.
  2. Correct the # Done instruction. The staleness re-check should not hand
    the agent a bare listing. Either re-run claim-next-task.sh (which claims,
    and returns empty when another host owns it) or state the stand-down as the
    only permitted action on a non-empty result.
  3. Don't fast-forward local main onto an unpushed orphan. A worker commit
    that never reached origin must not be merged into the shared workdir's
    main; that is what converts a lost race into a red run. git-setup.sh's
    next-tick reset --hard origin/main is what masks this most of the time.

Not affected

No work or ticket was lost: #1713, #1715, #1716 are all closed and on
origin/main. The red is bookkeeping only.

Healer incident: signature 2d4d471673eb, run 29782. The healer cleaned the
stuck workdir state (merge --abort + reset --hard origin/main; the orphan is
preserved as tag heal/superseded-1713-be0ca791) and verified the failing merge
now reports Already up to date.

**Harness (factory-vendored fix — upstream `dev-factory`, FACTORY_REF `834ec681`).** A worker whose iteration-start claim came back EMPTY re-runs the *listing* script on the "queue may be stale" path, finds a ticket another host already claimed, and works it **with no claim at all** — burning a duplicate implementation and poisoning the host's local `main`, which reds the run's `Merging to main` sync. ## What happened (swarm run 29782, host `elitebook-distributed-server-03`) `.sandcastle/logs/main-sandcastle-worker-20260922-034615-fddb1b-worker.log`, iteration 1: ``` Expanding shell expressions bash .sandcastle/claim-next-task.sh -> ~1 tokens <- EMPTY: nothing claimable Agent started The ready-tasks list came in empty. Per the workflow, I need to re-check ... Bash(bash .sandcastle/list-ready-tasks.sh) A fresh task appeared: #1713. Let me read the full issue and its comments. ``` It then implemented #1713 for ~16 minutes. But #1713 was already claimed by the OTHER pool host 19 s after this run started — `#1713` carries exactly ONE `swarm-claim` comment (id 53028, `host=matou-dev-server-01 run=29782`, 03:46:34Z). `elitebook-...-03` never posted a claim for #1713; its first claim this run is on #1715 (id 53046, 04:11:32Z). Consequences, in order: 1. Duplicate work. `matou-dev-server-01` landed #1713 as `66e6eb4c` (04:05:17Z, closed 04:08:47Z). `elitebook` committed its own rival `be0ca791` (04:02:25Z) — never pushed, superseded, ~16 min of worker slot wasted. 2. Poisoned local `main`. Sandcastle still fast-forwarded the shared workdir's `main` onto the orphan (`git reflog main`: `be0ca791 ... merge sandcastle/worker/20260922-034615-3c0f43: Fast-forward`, 04:10:36). Local `main` became `ahead 1, behind 3` of `origin/main`. 3. Red run. Iteration 2 legitimately claimed #1715, landed it (`b4ab8902`), and closed the issue at 04:28:22 — then Sandcastle's `Merging to main` merged that branch (tip == `origin/main`) onto the poisoned local `main`. Two rival #1713 implementations over the same 9 files + append-conflicting STATUS.md/GOTCHAS.md ⇒ `SyncError`, exit 1, **after all work had landed**. ## Root cause `.sandcastle/prompts/prompt.md` (FACTORY_MANIFEST line 43), `# Done`: bash .sandcastle/list-ready-tasks.sh `list-ready-tasks.sh` **lists**; it does not claim. The prompt's own next sentence is right — *"otherwise end the iteration normally and the next iteration will pick the fresh task up"* (the next iteration re-enters via `claim-next-task.sh`) — but the agent is handed a claimable-looking work order and skips the stand-down. Nothing **mechanical** refuses work on a ticket this run never claimed: `close-report.sh`'s claim check only runs at *close* time, so a worker that loses the push race (as here) never reaches a gate at all. The same bypass is visible, harmless-by-luck, in the 21:03:36 run — re-check returned `[]`, so no ticket was there to grab. ## Asks 1. **Mechanical gate (the real fix).** Refuse to *commit/push* for an issue whose `swarm-claim host=... run=$SWARM_RUN_ID` comment does not exist — fail loud, at the start of the work, not at close-report. 2. **Correct the `# Done` instruction.** The staleness re-check should not hand the agent a bare listing. Either re-run `claim-next-task.sh` (which claims, and returns empty when another host owns it) or state the stand-down as the only permitted action on a non-empty result. 3. **Don't fast-forward local `main` onto an unpushed orphan.** A worker commit that never reached `origin` must not be merged into the shared workdir's `main`; that is what converts a lost race into a red run. `git-setup.sh`'s next-tick `reset --hard origin/main` is what masks this most of the time. ## Not affected No work or ticket was lost: #1713, #1715, #1716 are all closed and on `origin/main`. The red is bookkeeping only. Healer incident: signature `2d4d471673eb`, run 29782. The healer cleaned the stuck workdir state (`merge --abort` + `reset --hard origin/main`; the orphan is preserved as tag `heal/superseded-1713-be0ca791`) and verified the failing merge now reports `Already up to date`.
Owner

Ruled (Ben, 2026-09-22): all three asks approved

  1. Mechanical claim gate: refuse to commit or push for an issue unless this run has its own swarm-claim host=… run=$SWARM_RUN_ID comment on it. The refusal fails loud at the START of work, not at close-report.
  2. # Done staleness re-check goes through claim-next-task.sh, never a bare list-ready-tasks.sh listing. A result that another host owns means standing down.
  3. Never fast-forward local main onto an unpushed orphan: a worker commit that is not on origin is never merged into the shared workdir's main.

Protected harness paths, so this is session work, landed upstream in dev-factory and then vendored by FACTORY_REF bump, alongside #1732/#1733. Tests: a worker with no claim that tries to commit is refused; a re-check against a ticket another host claimed yields stand-down; a merge of an orphan branch not on origin is refused.

## Ruled (Ben, 2026-09-22): all three asks approved 1. **Mechanical claim gate:** refuse to commit or push for an issue unless this run has its own `swarm-claim host=… run=$SWARM_RUN_ID` comment on it. The refusal fails loud at the START of work, not at close-report. 2. **`# Done` staleness re-check** goes through `claim-next-task.sh`, never a bare `list-ready-tasks.sh` listing. A result that another host owns means standing down. 3. **Never fast-forward local `main` onto an unpushed orphan:** a worker commit that is not on `origin` is never merged into the shared workdir's `main`. Protected harness paths, so this is **session work**, landed upstream in dev-factory and then vendored by FACTORY_REF bump, alongside #1732/#1733. Tests: a worker with no claim that tries to commit is refused; a re-check against a ticket another host claimed yields stand-down; a merge of an orphan branch not on origin is refused.
Author
Member

close-report — ruled and landed by agent under ADR 0174 (veto anytime)

What this ticket asked was a mechanical refusal so a worker can never work/land a ticket its run never claimed (ask 1), a corrected # Done staleness re-check (ask 2), and no fast-forward of local main onto an unpushed orphan (ask 3).

What landed (asks 1 + 2 — the two-way, offline-provable core):

  • Mechanical gate (ask 1): new git-hooks/commit-msg (vendored). It refuses a swarm worker's commit whose subject cites a #<n> carrying no swarm-claim host=… run=$SWARM_RUN_ID, at the first revertible moment — the commit, not at close. Built on a new pure claim_owned_by_run in claim-lib.sh (rc 0 owned / 1 tracker-read-but-no-claim → fail CLOSED, block / 3 tracker-unreachable → fail OPEN, so a forge blip never wedges an honestly-claimed worker). Inert when SWARM_RUN_ID is unset (session-runner, human, host reconcile) or the subject cites no ticket. Because no orphan is ever committed, none can fast-forward local main either — the run-29782 SyncError's true cause.
  • Prompt (ask 2): prompts/prompt.md's # Done staleness re-check is now stated as a COMPLETION TEST, never a work order — nothing the lister prints is the worker's to work; only the claim-next-task.sh-claimed ticket may be worked; a non-empty re-run means stand down for the next iteration.

Ask 3 (fast-forward-onto-orphan defense-in-depth): routed as follow-up #1739. That fast-forward is inside Sandcastle's own merge-to-head (@ai-hero/sandcastle), between iterations, with no host hook to intercept — out of the vendored harness's reach, and moot now that asks 1+2 stop any unclaimed orphan from existing. Details + a proposed default in #1739.

How it landed (all FACTORY_MANIFEST files → the dev-factory door):

  • dev-factory main: dc9b3e0 (full change).
  • dev-factory backport branch backport/1717-unclaimed-commit-gate: 4616347 (cheap backport onto idss's pin 0c0cae34, no main catch-up — the #1733 pattern).
  • idss: cf0ed11f on origin/main — re-vendored FACTORY_REF 0c0cae34 → 4616347 (2 added, 3 updated, 180 unchanged), re-rendered .sandcastle/prompt.md, STATUS.md.

Proof (offline, red-before-green where applicable):

  • tests/commit-msg-gate-test.sh — 9 pass: real git commits through the hook covering inert(no run)/owned/blocked/BLOCKED (#1717) loud/run-29782 #1713 shape/fail-open/no-ticket/run-0.
  • tests/claim-lib-test.sh — 83 pass (+7 for claim_owned_by_run: owned / read-but-unclaimed / no-comments / other-host / unreachable→rc3 / run-0).
  • check-harness-drift.sh — OK against 4616347; onboard-lib.sh render byte-identity re-proven (235 pass); vendor-manifest coverage green.

This is a two-way door (revertible commit + config, proven by existing offline tests) — ruled and acted per ADR 0174. Veto anytime; a veto reverts these commits and re-pins.

## close-report — ruled and landed by agent under ADR 0174 (veto anytime) **What this ticket asked** was a mechanical refusal so a worker can never work/land a ticket its run never claimed (ask 1), a corrected `# Done` staleness re-check (ask 2), and no fast-forward of local `main` onto an unpushed orphan (ask 3). **What landed (asks 1 + 2 — the two-way, offline-provable core):** - **Mechanical gate (ask 1):** new **`git-hooks/commit-msg`** (vendored). It refuses a swarm worker's commit whose *subject* cites a `#<n>` carrying no `swarm-claim host=… run=$SWARM_RUN_ID`, at the **first revertible moment — the commit**, not at close. Built on a new pure `claim_owned_by_run` in `claim-lib.sh` (rc 0 owned / 1 tracker-read-but-no-claim → **fail CLOSED, block** / 3 tracker-unreachable → **fail OPEN**, so a forge blip never wedges an honestly-claimed worker). Inert when `SWARM_RUN_ID` is unset (session-runner, human, host reconcile) or the subject cites no ticket. **Because no orphan is ever committed, none can fast-forward local `main` either — the run-29782 `SyncError`'s true cause.** - **Prompt (ask 2):** `prompts/prompt.md`'s `# Done` staleness re-check is now stated as a **COMPLETION TEST, never a work order** — nothing the lister prints is the worker's to work; only the `claim-next-task.sh`-claimed ticket may be worked; a non-empty re-run means stand down for the next iteration. **Ask 3 (fast-forward-onto-orphan defense-in-depth):** routed as follow-up **#1739**. That fast-forward is *inside Sandcastle's own `merge-to-head`* (`@ai-hero/sandcastle`), between iterations, with no host hook to intercept — out of the vendored harness's reach, and moot now that asks 1+2 stop any unclaimed orphan from existing. Details + a proposed default in #1739. **How it landed (all FACTORY_MANIFEST files → the dev-factory door):** - dev-factory `main`: `dc9b3e0` (full change). - dev-factory backport branch `backport/1717-unclaimed-commit-gate`: `4616347` (cheap backport onto idss's pin `0c0cae34`, no main catch-up — the #1733 pattern). - idss: `cf0ed11f` on `origin/main` — re-vendored `FACTORY_REF 0c0cae34 → 4616347` (2 added, 3 updated, 180 unchanged), re-rendered `.sandcastle/prompt.md`, STATUS.md. **Proof (offline, red-before-green where applicable):** - `tests/commit-msg-gate-test.sh` — **9 pass**: real `git commit`s through the hook covering inert(no run)/owned/blocked/`BLOCKED (#1717)` loud/run-29782 `#1713` shape/fail-open/no-ticket/run-0. - `tests/claim-lib-test.sh` — **83 pass** (+7 for `claim_owned_by_run`: owned / read-but-unclaimed / no-comments / other-host / unreachable→rc3 / run-0). - `check-harness-drift.sh` — **OK** against `4616347`; `onboard-lib.sh` render byte-identity re-proven (235 pass); vendor-manifest coverage green. This is a two-way door (revertible commit + config, proven by existing offline tests) — ruled and acted per ADR 0174. Veto anytime; a veto reverts these commits and re-pins.
matou-build-agent 2026-09-22 17:07:32 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1717
No description provided.