session-runner has no host affinity: a ready-for-session ticket whose standing is host-specific is claimed by every host that cannot do it #89

Closed
opened 2026-08-26 01:35:49 +00:00 by matou-build-agent · 1 comment

The session queue has no host affinity, and a consumer repo just paid for it twice.

session-runner.sh picks from ?labels=ready-for-session and filters on
no-triage / deferred / agent-blocked / agent-working / open dependencies — and
nothing else. Whichever host ticks first claims the ticket. But ready-for-session
exists precisely for work that needs a particular session's standing: host
credentials, live droplet doors, a host's own evidence directories. The label records
that a host is needed; it cannot record which.

What it cost

Reported from the consumer side as Matou/idss#746, from a ticket (Matou/idss#743)
that wanted eyes on evidence living on one specific laptop — a host that runs Forgejo
Actions but no session-runner at all. So the ticket was unclaimable by the only host
that could do it, and claimable by every host that could not
:

  • attempt 1 — the workstation: no such evidence directory, no route to the laptop;
  • attempt 2 — a cloud dev server whose mesh holds only its siblings.

Two attempts is the runner's escalation cap, so a correctly-labelled ticket walks itself
to agent-blocked + a human ping without a human ever being the actual blocker.

Shape of a fix

The cheapest thing that would have worked: an opt-in host tag the picker honours —
a <!-- session-host: <name> --> body marker (the shape consumers' drive issues already
use for <!-- rehearsal-target: … -->) that the pick skips unless it matches this host,
with no marker meaning "any host" so every existing ticket is unaffected. The queue
read already carries .body, so the filter costs zero extra API calls.

Second half: the runner's fail-<n> counter cannot tell "this host can't do it" from
"this work is hard". A skip-for-wrong-host must not burn an attempt — i.e. the check
belongs at pick time, before the claim, before the attempt marker, before the counter.

Filed from the consumer side (Matou/idss#746) under the pull-only topology: the fix
belongs here, in the vendored root, not in a hand-edited consumer copy.

The session queue has **no host affinity**, and a consumer repo just paid for it twice. `session-runner.sh` picks from `?labels=ready-for-session` and filters on `no-triage` / `deferred` / `agent-blocked` / `agent-working` / open dependencies — and nothing else. Whichever host ticks first claims the ticket. But `ready-for-session` exists precisely for work that needs **a particular session's standing**: host credentials, live droplet doors, a host's own evidence directories. The label records *that* a host is needed; it cannot record *which*. ## What it cost Reported from the consumer side as `Matou/idss#746`, from a ticket (`Matou/idss#743`) that wanted eyes on evidence living on one specific laptop — a host that runs Forgejo Actions but no session-runner at all. So the ticket was **unclaimable by the only host that could do it, and claimable by every host that could not**: - attempt 1 — the workstation: no such evidence directory, no route to the laptop; - attempt 2 — a cloud dev server whose mesh holds only its siblings. Two attempts is the runner's escalation cap, so a correctly-labelled ticket walks itself to `agent-blocked` + a human ping without a human ever being the actual blocker. ## Shape of a fix The cheapest thing that would have worked: an **opt-in host tag the picker honours** — a `<!-- session-host: <name> -->` body marker (the shape consumers' drive issues already use for `<!-- rehearsal-target: … -->`) that the pick skips unless it matches this host, with **no marker meaning "any host"** so every existing ticket is unaffected. The queue read already carries `.body`, so the filter costs zero extra API calls. Second half: the runner's `fail-<n>` counter cannot tell "this host can't do it" from "this work is hard". A skip-for-wrong-host must **not** burn an attempt — i.e. the check belongs at pick time, before the claim, before the attempt marker, before the counter. Filed from the consumer side (`Matou/idss#746`) under the pull-only topology: the fix belongs here, in the vendored root, not in a hand-edited consumer copy.
Author
Member

Landed in 29c2c94.

What landed

  • session-host-lib.sh (new, vendored) — session_host_marker extracts the opt-in
    <!-- session-host: <name> --> body marker, session_host_match matches a comma/space
    list case-insensitively and tolerates an FQDN on our side (box1 matches box1.lan,
    never box10), session_host_self resolves this host as
    SESSION_RUNNER_HOST → SWARM_HOST → hostname (the order the rest of the factory
    already uses).
  • session-runner.sh — honours it FIRST in the pick loop, above the cooldown, fail-cap
    and dependency checks. sr_issue_body serves the body from the queue JSON already in
    hand, so the filter costs zero extra API calls; only the SESSION_RUNNER_PICK
    rollout path, which skips the queue read, pays a fetch. A body that cannot be read is
    empty — "any host", today's behaviour — never a hard fail.
  • Both halves of the ask: no marker means any host (nothing existing changes), and the
    skip lands before the claim, the attempt marker and fail-<n>, so a wrong-host
    skip cannot burn one of the two attempts.
  • docs/agents/triage-labels.md documents the marker; onboarding/vendor-manifest
    classifies the new lib (coverage test green); STATUS.md header + Host state row +
    the test-file count (69 → 70).

Proof

tests/session-host-lib-test.sh — 7 checks over the pure core. tests/session-runner-test.sh
group 19 for the wiring: 19a (wrong host: no claim, no session, no attempt marker, no
fail-<n>, no run row), 19b (named host works it), 19c (an unmarked ticket is picked
straight past a foreign pinned one), 19d (host list; the rule holds on the PICK path;
SESSION_RUNNER_HOST is the escape hatch). Red before green — without the wiring 19a fails
with the wrong host picking and closing the pinned ticket, i.e. the bug reproduced.

Full offline suite green bar heal-test.sh and claude-call-guards-test.sh, which red on a
clean tree at both 583e28e and 29c2c94 on a host with a live rehearsal-drive reservation —
diagnosed and filed as #90, not fixed here.

Consumer

Matou/idss re-vendored at 29c2c94 (FACTORY_REF 343d26f → 29c2c94, 3 files added /
10 updated), drift check OK, session-runner-test.sh 19 groups green from inside its
.sandcastle/ — which #87's fix made possible; it had been dying silently after group 1
there.

Ruled by agent under ADR 0174 — veto anytime.

Landed in `29c2c94`. **What landed** - `session-host-lib.sh` (new, vendored) — `session_host_marker` extracts the opt-in `<!-- session-host: <name> -->` body marker, `session_host_match` matches a comma/space list case-insensitively and tolerates an FQDN on our side (`box1` matches `box1.lan`, never `box10`), `session_host_self` resolves this host as `SESSION_RUNNER_HOST` → `SWARM_HOST` → `hostname` (the order the rest of the factory already uses). - `session-runner.sh` — honours it FIRST in the pick loop, above the cooldown, fail-cap and dependency checks. `sr_issue_body` serves the body from the queue JSON already in hand, so the filter costs **zero extra API calls**; only the `SESSION_RUNNER_PICK` rollout path, which skips the queue read, pays a fetch. A body that cannot be read is empty — "any host", today's behaviour — never a hard fail. - Both halves of the ask: no marker means any host (nothing existing changes), and the skip lands **before the claim, the attempt marker and `fail-<n>`**, so a wrong-host skip cannot burn one of the two attempts. - `docs/agents/triage-labels.md` documents the marker; `onboarding/vendor-manifest` classifies the new lib (coverage test green); STATUS.md header + Host state row + the test-file count (69 → 70). **Proof** `tests/session-host-lib-test.sh` — 7 checks over the pure core. `tests/session-runner-test.sh` group 19 for the wiring: 19a (wrong host: no claim, no session, no attempt marker, no `fail-<n>`, no run row), 19b (named host works it), 19c (an unmarked ticket is picked straight past a foreign pinned one), 19d (host list; the rule holds on the `PICK` path; `SESSION_RUNNER_HOST` is the escape hatch). Red before green — without the wiring 19a fails with the wrong host picking **and closing** the pinned ticket, i.e. the bug reproduced. Full offline suite green bar `heal-test.sh` and `claude-call-guards-test.sh`, which red on a clean tree at both `583e28e` and `29c2c94` on a host with a live rehearsal-drive reservation — diagnosed and filed as #90, not fixed here. **Consumer** `Matou/idss` re-vendored at `29c2c94` (`FACTORY_REF` `343d26f` → `29c2c94`, 3 files added / 10 updated), drift check OK, `session-runner-test.sh` 19 groups green from inside its `.sandcastle/` — which #87's fix made possible; it had been dying silently after group 1 there. Ruled by agent under ADR 0174 — veto anytime.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#89
No description provided.