swarm janitor sweeps a LIVE session-runner claim (its run= is a pid, never an alive swarm run) — two hosts then work one ready-for-session ticket #348

Closed
opened 2026-11-18 04:54:14 +00:00 by ben · 3 comments
Owner

Symptom

Two hosts ran a full standing session on the same ready-for-session ticket at once (Matou/policy-generators#32, 2026-11-18):

UTC event
04:31:09 matou-workstation picks the ticket, adds agent-working, wins the cross-host claim (comment 73000), starts its session
04:31:55 agent-working removed and the claim comment deleted — the session is still running
04:40:23 bens-mac-04 sees a free ticket, picks it, wins the claim (73015), starts a second session
04:45:51 agent-working removed again
04:51 the workstation's session lands its commit; the other host's session had a competing local commit

Cause

janitor_sweep (claim-lib.sh) visits every open agent-working issue and judges each swarm-claim comment by its run=: live if that number is in claim_alive_runs (in-progress swarm Actions runs), dead after CLAIM_ABSENCE_THRESHOLD (2) successful polls without it.

The session-runner posts its claim with claim_post "$pick" "$sr_host" "$$" — run= is the runner's pid. A pid is never an alive swarm run, so the janitor proves a live session "dead" on its second pass, deletes the claim comment and removes the label. With swarm ticks arriving every few seconds (a label event on another ticket was fanning runs out to three hosts), that took 45 seconds. A pid can also collide with a real run number in the verdict log (claim_run_terminal).

Evidence: on matou-workstation, ~/swarm/state/claim-absence (the janitor's streak files, one per run id, removed when it sweeps) was modified at 04:45:50Z, one second before the 04:45:51 label removal. The directory on both hosts holds files named for pids (3635452, 1380771, 763718…), not run numbers.

A second, narrower race sits beside it: the runner adds the label ~4 s before it posts the claim comment, and the janitor reclaims a label with no claim comment at once.

Fix (in progress, by a session at Ben's request)

  • A session claim says what it is and how long it can live: swarm-claim host=<h> run=<pid> session-ttl=<seconds>. The janitor treats such a claim as live until it is older than its ttl, and never tests its pid against swarm runs or the verdict log. Past the ttl it is swept as before, so a dead host does not strand the ticket.
  • The session-runner re-asserts agent-working after it wins the claim.
## Symptom Two hosts ran a full standing session on the same `ready-for-session` ticket at once (https://git.matou.nz/Matou/policy-generators/issues/32, 2026-11-18): | UTC | event | | --- | --- | | 04:31:09 | `matou-workstation` picks the ticket, adds `agent-working`, wins the cross-host claim (comment 73000), starts its session | | 04:31:55 | `agent-working` removed and the claim comment deleted — the session is still running | | 04:40:23 | `bens-mac-04` sees a free ticket, picks it, wins the claim (73015), starts a second session | | 04:45:51 | `agent-working` removed again | | 04:51 | the workstation's session lands its commit; the other host's session had a competing local commit | ## Cause `janitor_sweep` (`claim-lib.sh`) visits **every** open `agent-working` issue and judges each `swarm-claim` comment by its `run=`: live if that number is in `claim_alive_runs` (in-progress **swarm** Actions runs), dead after `CLAIM_ABSENCE_THRESHOLD` (2) successful polls without it. The session-runner posts its claim with `claim_post "$pick" "$sr_host" "$$"` — `run=` is the runner's **pid**. A pid is never an alive swarm run, so the janitor proves a live session "dead" on its second pass, deletes the claim comment and removes the label. With swarm ticks arriving every few seconds (a label event on another ticket was fanning runs out to three hosts), that took 45 seconds. A pid can also collide with a real run number in the verdict log (`claim_run_terminal`). Evidence: on `matou-workstation`, `~/swarm/state/claim-absence` (the janitor's streak files, one per run id, removed when it sweeps) was modified at 04:45:50Z, one second before the 04:45:51 label removal. The directory on both hosts holds files named for pids (`3635452`, `1380771`, `763718`…), not run numbers. A second, narrower race sits beside it: the runner adds the label ~4 s **before** it posts the claim comment, and the janitor reclaims a label with no claim comment at once. ## Fix (in progress, by a session at Ben's request) - A session claim says what it is and how long it can live: `swarm-claim host=<h> run=<pid> session-ttl=<seconds>`. The janitor treats such a claim as live until it is older than its ttl, and never tests its pid against swarm runs or the verdict log. Past the ttl it is swept as before, so a dead host does not strand the ticket. - The session-runner re-asserts `agent-working` after it wins the claim.

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime

Ruling: keep bug + priority, add ready-for-session (not ready-for-agent).

Why a two-way door: a label choice, reverted by a later label edit, provable by the code and by the ticket body. Not on the one-way-door list (no credentials, security widening, trust accept, data destruction, or spend).

What proves the routing:

  1. The ticket body states a fix is already in progress by a session at Ben's request. Routing to the swarm queue (ready-for-agent) would put a second actor on one ticket — the exact double-work this ticket reports (two hosts, one ready-for-session ticket). ready-for-session keeps it out of the swarm queue (list-ready-tasks.sh reads only ready-for-agent) while the session finishes.
  2. The fix is confirmed not yet landed: claim-lib.sh has CLAIM_ABSENCE_THRESHOLD but no session-ttl handling in janitor_sweep, and session-runner.sh posts its claim with the runner pid as run= with no ttl marker. The change is to the session-runner's own cross-host claim protocol — session-domain coordination.

priority is additive and stays, so the session queue surfaces it first.

Agent Brief (for a session)

Category: bug
Summary: janitor_sweep sweeps a live session-runner claim — its run= is a pid, never an alive swarm run — so two hosts work one ready-for-session ticket.

Current behavior:
janitor_sweep (claim-lib.sh) judges every swarm-claim comment by its run= number: live only if that number is in claim_alive_runs (in-progress swarm Actions runs), else swept dead after CLAIM_ABSENCE_THRESHOLD successful polls. The session-runner posts claim_post "$pick" "$sr_host" "$$", so its run= is the runner pid — never an alive swarm run. The janitor therefore proves a live session "dead" on its second pass, deletes the claim comment, and removes agent-working; another host then picks the free ticket and runs a second full session. A narrower race sits beside it: the runner adds the label several seconds before it posts the claim comment, and the janitor can reclaim a label that has no claim comment yet. (A pid can also collide with a real run number in the verdict log via claim_run_terminal.)

Desired behavior:

  • A session claim is self-describing and time-bounded, e.g. swarm-claim host=<h> run=<pid> session-ttl=<seconds>. The janitor treats such a claim as live until it is older than its ttl and never tests its pid against swarm runs or the verdict log; past the ttl it is swept as today so a dead host does not strand the ticket.
  • The session-runner re-asserts agent-working after it wins the cross-host claim, closing the label-before-comment gap.

Key interfaces:

  • The claim comment format emitted by claim_post / consumed by janitor_sweep — extend it with a session-ttl= field and teach the sweep to branch on its presence.
  • janitor_sweep liveness logic — a ttl-bearing claim is judged by age vs ttl, not by claim_alive_runs / claim_run_terminal.
  • The session-runner claim+label sequence — re-assert agent-working after winning the claim.

Acceptance criteria:

  • A live session claim within its ttl is never swept by janitor_sweep (not tested against swarm runs or the verdict log).
  • A session claim older than its ttl is still swept (a dead host does not strand the ticket).
  • The session-runner re-asserts agent-working after winning its claim.
  • Offline tests cover: ttl-claim-within-ttl survives a sweep; ttl-claim-past-ttl is swept; the label-reassert closes the label-before-comment window. Lib change ships with its test in the same commit.

Out of scope:

  • The swarm (non-session) claim path, which legitimately keys on real run numbers — leave its behavior unchanged.
> *This was generated by AI during triage.* ## Ruled by agent under ADR 0174 — veto anytime **Ruling:** keep `bug` + `priority`, add `ready-for-session` (not `ready-for-agent`). **Why a two-way door:** a label choice, reverted by a later label edit, provable by the code and by the ticket body. Not on the one-way-door list (no credentials, security widening, trust accept, data destruction, or spend). **What proves the routing:** 1. The ticket body states a fix is **already in progress by a session at Ben's request**. Routing to the swarm queue (`ready-for-agent`) would put a second actor on one ticket — the *exact* double-work this ticket reports (two hosts, one `ready-for-session` ticket). `ready-for-session` keeps it out of the swarm queue (`list-ready-tasks.sh` reads only `ready-for-agent`) while the session finishes. 2. The fix is confirmed not yet landed: `claim-lib.sh` has `CLAIM_ABSENCE_THRESHOLD` but **no** `session-ttl` handling in `janitor_sweep`, and `session-runner.sh` posts its claim with the runner pid as `run=` with no ttl marker. The change is to the session-runner's own cross-host claim protocol — session-domain coordination. `priority` is additive and stays, so the session queue surfaces it first. ## Agent Brief (for a session) **Category:** bug **Summary:** `janitor_sweep` sweeps a *live* session-runner claim — its `run=` is a pid, never an alive swarm run — so two hosts work one `ready-for-session` ticket. **Current behavior:** `janitor_sweep` (`claim-lib.sh`) judges every `swarm-claim` comment by its `run=` number: live only if that number is in `claim_alive_runs` (in-progress swarm Actions runs), else swept dead after `CLAIM_ABSENCE_THRESHOLD` successful polls. The session-runner posts `claim_post "$pick" "$sr_host" "$$"`, so its `run=` is the runner **pid** — never an alive swarm run. The janitor therefore proves a live session "dead" on its second pass, deletes the claim comment, and removes `agent-working`; another host then picks the free ticket and runs a second full session. A narrower race sits beside it: the runner adds the label several seconds *before* it posts the claim comment, and the janitor can reclaim a label that has no claim comment yet. (A pid can also collide with a real run number in the verdict log via `claim_run_terminal`.) **Desired behavior:** - A session claim is self-describing and time-bounded, e.g. `swarm-claim host=<h> run=<pid> session-ttl=<seconds>`. The janitor treats such a claim as live until it is older than its ttl and never tests its pid against swarm runs or the verdict log; past the ttl it is swept as today so a dead host does not strand the ticket. - The session-runner re-asserts `agent-working` after it wins the cross-host claim, closing the label-before-comment gap. **Key interfaces:** - The claim comment format emitted by `claim_post` / consumed by `janitor_sweep` — extend it with a `session-ttl=` field and teach the sweep to branch on its presence. - `janitor_sweep` liveness logic — a ttl-bearing claim is judged by age vs ttl, not by `claim_alive_runs` / `claim_run_terminal`. - The session-runner claim+label sequence — re-assert `agent-working` after winning the claim. **Acceptance criteria:** - [ ] A live session claim within its ttl is never swept by `janitor_sweep` (not tested against swarm runs or the verdict log). - [ ] A session claim older than its ttl is still swept (a dead host does not strand the ticket). - [ ] The session-runner re-asserts `agent-working` after winning its claim. - [ ] Offline tests cover: ttl-claim-within-ttl survives a sweep; ttl-claim-past-ttl is swept; the label-reassert closes the label-before-comment window. Lib change ships with its test in the same commit. **Out of scope:** - The swarm (non-session) claim path, which legitimately keys on real run numbers — leave its behavior unchanged.
Author
Owner

Landed on main as 9f0a19f, by a session at Ben's request.

  • claim_post takes an optional 4th argument and writes session-ttl=<seconds> on the claim's first line.
  • janitor_sweep ages a session claim against that ttl and never tests its pid against the alive swarm runs or the verdict log. Past the ttl it is swept.
  • session-runner.sh posts its ttl and re-asserts agent-working after it wins the claim.

Proof. tests/claim-lib-test.sh T8b (6 of its checks fail without the fix) and tests/session-runner-test.sh 24b; the whole offline suite passes. No shellcheck was available where this was written, so ci / static is the first lint of it.

Reach. Matou/policy-generators is pinned to this commit (its 114f62f). Every other consumer, and this repo's self-pin, is still exposed until bumped. Not yet seen live: the next ready-for-session ticket a host claims will show a claim comment carrying session-ttl= and surviving janitor passes.

GOTCHAS #348 and docs/journal/2026-11-18-348-janitor-session-claims.md.

**Landed on `main`** as [9f0a19f](https://git.matou.nz/Matou/dev-factory/commit/9f0a19f46add55165589136260cea05a717bd9fa), by a session at Ben's request. - `claim_post` takes an optional 4th argument and writes ` session-ttl=<seconds>` on the claim's first line. - `janitor_sweep` ages a session claim against that ttl and never tests its pid against the alive swarm runs or the verdict log. Past the ttl it is swept. - `session-runner.sh` posts its ttl and re-asserts `agent-working` after it wins the claim. **Proof.** `tests/claim-lib-test.sh` T8b (6 of its checks fail without the fix) and `tests/session-runner-test.sh` 24b; the whole offline suite passes. No shellcheck was available where this was written, so `ci / static` is the first lint of it. **Reach.** `Matou/policy-generators` is pinned to this commit (its `114f62f`). Every other consumer, and this repo's self-pin, is still exposed until bumped. Not yet seen live: the next ready-for-session ticket a host claims will show a claim comment carrying `session-ttl=` and surviving janitor passes. GOTCHAS #348 and `docs/journal/2026-11-18-348-janitor-session-claims.md`.
ben closed this issue 2026-11-18 05:09:30 +00:00

No action taken — the fix is already landed and this ticket is already closed. Ruled by agent under ADR 0174 — veto anytime.

A standing session-runner tick on matou-workstation picked this ticket from a checkout that was at 152a748 when the tick began. On investigation the fix had already landed on main as 9f0a19f (right on top of 152a748) and Ben had already closed the ticket with a close-report.

Verified the landed fix covers every acceptance criterion:

  • claim_post takes an optional 4th arg and writes session-ttl=<seconds> on the claim's first line.
  • janitor_sweep reads claims through _claim_comments_kinded: a session claim (session-ttl=) is live until older than its ttl and is never tested against the alive swarm runs or the verdict log; past the ttl it is swept.
  • session-runner.sh posts the ttl and re-asserts agent-working after winning the claim.
  • session-ttl appears 6× in claim-lib.sh on origin/main; tests claim-lib-test.sh T8b and session-runner-test.sh 24b ship with it.

To avoid the exact double-work this ticket reports, the session landed nothing — my independent reimplementation was discarded (a two-way door, cleanly reverted). Dropping the vestigial ready-for-session label so the completed ticket leaves the session lane. No commit, no push.

**No action taken — the fix is already landed and this ticket is already closed.** Ruled by agent under ADR 0174 — veto anytime. A standing session-runner tick on `matou-workstation` picked this ticket from a checkout that was at `152a748` when the tick began. On investigation the fix had already landed on `main` as [9f0a19f](https://git.matou.nz/Matou/dev-factory/commit/9f0a19f46add55165589136260cea05a717bd9fa) (right on top of `152a748`) and Ben had already closed the ticket with a close-report. **Verified the landed fix covers every acceptance criterion:** - `claim_post` takes an optional 4th arg and writes ` session-ttl=<seconds>` on the claim's first line. - `janitor_sweep` reads claims through `_claim_comments_kinded`: a session claim (`session-ttl=`) is live until older than its ttl and is never tested against the alive swarm runs or the verdict log; past the ttl it is swept. - `session-runner.sh` posts the ttl and re-asserts `agent-working` after winning the claim. - `session-ttl` appears 6× in `claim-lib.sh` on `origin/main`; tests `claim-lib-test.sh` T8b and `session-runner-test.sh` 24b ship with it. To avoid the exact double-work this ticket reports, the session landed nothing — my independent reimplementation was discarded (a two-way door, cleanly reverted). Dropping the vestigial `ready-for-session` label so the completed ticket leaves the session lane. No commit, no push.
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/dev-factory#348
No description provided.