triage: silent yield loop starves a new consumer — 12 yields, 0 triaged, all rows green (observed on Matou/coa) #110

Closed
opened 2026-08-28 16:17:57 +00:00 by ben · 2 comments
Owner

What happened

Matou/coa filed 12 phase-1 tickets at 2026-08-28T15:06Z. Triage fired 12 times (11 issues.opened events, runs 25–35, plus the :35 cron, run 44). Every run reported success and finished within its own minute, and no ticket was touched — an hour later all 12 were still needs-triage. No coa triage log exists on either host for the window (run-triage.sh only logs once it reaches claude), so every run exited at a pre-work yield gate: the inline capacity gate in triage.yml (both host slots busy / workdir busy), or host_capacity_drive_wanted (a rehearsal drive reservation was live — the workstation's matou-swarm-drive-defer-count reached 3 at 15:45).

Context on the workstation at fire time: the capacity-1 runner picked up ~40 tasks between 15:05 and 15:40 (five repos' resume-asks re-dispatched by the backstop every 15 min, swarm :15/:45, watchdog, triage), and the two heavy slots (/tmp/matou-swarm.lock, /tmp/matou-host-slot-2.lock) are host-global across all consumers. A workflow_dispatch at 16:05, when the slots happened to be free, triaged all 12 in one pass (run 53).

Why it matters

  1. Yield loops are invisible. A yield is exit 0, so the run list reads as green health. Twelve consecutive yields for one repo look identical to twelve healthy no-op ticks. There is no per-repo "consecutive yields without work while untriaged issues exist" signal, and the watchdog does not see it.
  2. Issue events are wasted. Each issues.opened run yields once and is gone; the only retry is the 30-minute cron, which competes on the same slots. A new consumer with a burst of tickets can starve behind established repos' periodic traffic.
  3. Per-repo diagnosis needs job logs, which this Forgejo's API does not expose (coa GOTCHAS 3); the only evidence was the absence of a log file on the hosts.

Proposed (two-way-door, agent can rule)

  • run-triage.sh / triage.yml: when yielding, if preflight-triage.sh would list ≥1 untriaged issue, bump a per-repo consecutive-yield counter (e.g. /tmp/matou-triage-yield-<repo>) and, at N≥3, post one comment on the oldest untriaged issue and a Mattermost notice ("triage yielded 3 ticks with 12 untriaged") — same pattern as the drive-defer counter (#664). Reset on a real triage pass.
  • Optionally give issue-event runs a bounded wait (flock -w 120) instead of non-blocking, since they are serialised by the concurrency group anyway; or have the yield path re-dispatch itself once with a delay.
  • Record the yield reason as a one-line verdict row (there is already a verdict file) so a host inspection can tell "slots busy" from "drive reserved" from "nothing to triage".

Acceptance

  • A repo with untriaged issues whose triage yields 3 consecutive ticks produces a visible signal (issue comment or Mattermost) without a human reading host /tmp.
  • Existing yield semantics (never camp, exit 0) unchanged.

Observed from the coa onboarding session (Matou/coa #1, phase-1 tickets #7–#18). Related: Matou/dev-factory #108, #664 (drive-defer counter).

## What happened Matou/coa filed 12 phase-1 tickets at 2026-08-28T15:06Z. Triage fired 12 times (11 `issues.opened` events, runs 25–35, plus the :35 cron, run 44). Every run reported **success** and finished within its own minute, and no ticket was touched — an hour later all 12 were still `needs-triage`. No coa triage log exists on either host for the window (`run-triage.sh` only logs once it reaches `claude`), so every run exited at a pre-work yield gate: the inline capacity gate in `triage.yml` (both host slots busy / workdir busy), or `host_capacity_drive_wanted` (a rehearsal drive reservation was live — the workstation's `matou-swarm-drive-defer-count` reached 3 at 15:45). Context on the workstation at fire time: the capacity-1 runner picked up ~40 tasks between 15:05 and 15:40 (five repos' resume-asks re-dispatched by the backstop every 15 min, swarm :15/:45, watchdog, triage), and the two heavy slots (`/tmp/matou-swarm.lock`, `/tmp/matou-host-slot-2.lock`) are host-global across all consumers. A `workflow_dispatch` at 16:05, when the slots happened to be free, triaged all 12 in one pass (run 53). ## Why it matters 1. **Yield loops are invisible.** A yield is `exit 0`, so the run list reads as green health. Twelve consecutive yields for one repo look identical to twelve healthy no-op ticks. There is no per-repo "consecutive yields without work while untriaged issues exist" signal, and the watchdog does not see it. 2. **Issue events are wasted.** Each `issues.opened` run yields once and is gone; the only retry is the 30-minute cron, which competes on the same slots. A new consumer with a burst of tickets can starve behind established repos' periodic traffic. 3. **Per-repo diagnosis needs job logs**, which this Forgejo's API does not expose (coa GOTCHAS 3); the only evidence was the *absence* of a log file on the hosts. ## Proposed (two-way-door, agent can rule) - `run-triage.sh` / `triage.yml`: when yielding, if `preflight-triage.sh` would list ≥1 untriaged issue, bump a per-repo consecutive-yield counter (e.g. `/tmp/matou-triage-yield-<repo>`) and, at N≥3, post one comment on the oldest untriaged issue and a Mattermost notice ("triage yielded 3 ticks with 12 untriaged") — same pattern as the drive-defer counter (#664). Reset on a real triage pass. - Optionally give issue-event runs a bounded wait (`flock -w 120`) instead of non-blocking, since they are serialised by the concurrency group anyway; or have the yield path re-dispatch itself once with a delay. - Record the yield reason as a one-line verdict row (there is already a verdict file) so a host inspection can tell "slots busy" from "drive reserved" from "nothing to triage". ## Acceptance - A repo with untriaged issues whose triage yields 3 consecutive ticks produces a visible signal (issue comment or Mattermost) without a human reading host `/tmp`. - Existing yield semantics (never camp, exit 0) unchanged. Observed from the coa onboarding session (Matou/coa #1, phase-1 tickets #7–#18). Related: Matou/dev-factory #108, #664 (drive-defer counter).

This was generated by AI during triage.

Ruled by agent under ADR 0174 — veto anytime.

Ruling: ready-for-session (bug), replacing needs-triage.

Why not ready-for-agent: the fix cannot be done by a Sandcastle swarm worker. Every yield gate the bug is about lives in .forgejo/workflows/triage.yml and exit 0s before run-triage.sh is ever invoked — verified: the drive-defer gate, the two host-slot flock -n gates, and the workdir-lock gate all sit above bash .sandcastle/run-triage.sh in the workflow. Instrumenting "N consecutive yields while untriaged issues exist," giving issue-event runs a bounded flock -w, or self-re-dispatching all require editing triage.yml. .forgejo/ is a protected path: per the triage-label doc, edits to prompt skeletons, the vendored .sandcastle/ self-copy, and .forgejo/ need an interactive session's standing, not a swarm worker (the swarm queue reads only ready-for-agent, so these are invisible to workers by construction). That is what ready-for-session records.

Why it is still a two-way door (not ready-for-human): routing to a session, and the underlying change itself, are both fully revertible — a later commit or a label flip undoes them — and provable offline. No one-way-door residue: no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend. So this is an agent ruling, not a human escalation; a session executes it, Ben's veto stays asynchronous.

What proves it: the yield-counter side mirrors an already-offline-tested pattern — host_capacity_consumer_defer_bump / host_capacity_consumer_defer_reset in host-capacity-lib.sh, exactly as schedule_drive_yield uses it for the swarm's own drive-defer counter (#664). The counter, the threshold trip, and the reset-on-real-pass are all exercisable through shimmed tests with no docker/network; the workflow-level flock -w / re-dispatch changes are asserted by the existing offline triage.yml gate tests.


Session Brief

Category: bug
Summary: A repo whose triage keeps yielding on a busy host produces no visible signal — twelve consecutive exit 0 yields with zero tickets triaged read as green health, so a new consumer's ticket burst silently starves behind established repos' periodic traffic.

Why a session, not the swarm: the change edits .forgejo/workflows/triage.yml (protected path). A swarm worker must not touch .forgejo/; an interactive session holds the standing to.

Current behavior:
Triage yields are exit 0 in triage.yml, taken before run-triage.sh runs, so run-triage.sh (which only logs once it reaches claude) leaves no per-repo log for a yielded tick. Twelve consecutive yields for one repo are indistinguishable from twelve healthy no-op ticks. There is no per-repo "consecutive yields while untriaged issues exist" signal, the watchdog does not see it, and the only retry for a burst is the 30-minute cron competing on the same shared host slots.

Desired behavior:
When a triage run yields and preflight-triage.sh would list ≥1 untriaged issue, bump a per-repo consecutive-yield counter; at a threshold (N≥3), emit one visible signal — a comment on the oldest untriaged issue plus a Mattermost notice — without a human reading host /tmp. Reset the counter on any real triage pass. Existing yield semantics (never camp, exit 0) stay unchanged.

Key interfaces / mechanisms:

  • Mirror the swarm's drive-defer counter: host_capacity_consumer_defer_bump / host_capacity_consumer_defer_reset (host-capacity-lib.sh), a per-repo path under /tmp (e.g. /tmp/matou-triage-yield-<repo>), reset by run-triage.sh on a successful pass — the same shape schedule_drive_yield already uses (#664).
  • The yield gates to instrument are the drive-defer gate, the two flock -n host-slot gates, and the workdir-lock gate in triage.yml. Reuse the existing zero-token preflight-triage.sh to answer "are there untriaged issues right now" cheaply at the yield point.
  • Notifications reuse the workflow's existing Mattermost step (MATTERMOST_BOT_TOKEN) and forgejo_comment (forgejo-lib.sh); the issue comment must carry the standard AI-triage disclaimer if posted by automation.
  • Optional, reporter-suggested, agent's call at implementation time: give issue-event runs a bounded flock -w 120 (they are serialised by the concurrency group anyway) or a single delayed self-re-dispatch, and record the yield reason as a one-line verdict row so a host inspection can tell "slots busy" from "drive reserved" from "nothing to triage".

Acceptance criteria:

  • A repo with untriaged issues whose triage yields 3 consecutive ticks produces a visible signal (issue comment and/or Mattermost) with no human reading host /tmp.
  • The counter resets on any real triage pass (a run that reaches run-triage.sh and triages).
  • Existing yield semantics unchanged: never camp, exit 0, no new blocking that could deadlock a slot.
  • Offline self-test (shimmed, no docker/network) for the counter bump / threshold trip / reset, in the same style as the drive-defer coverage, in the same commit.
  • STATUS.md updated in the same commit (changes triage yield/observability semantics).

Out of scope:

  • The swarm-side slot-holding that feeds this starvation — tracked separately as #111 (a queue-draining run holding the heavy slot across tasks). Fixing #111 reduces the starvation; this ticket is the observability/signal for when it still happens.
  • Changing the number of pooled host slots or the concurrency-group design.
  • Exposing Forgejo job logs (the API does not; out of reach here).

Related: #111 (swarm holds the slot across tasks — the upstream cause of much of this starvation), #108, #664 (drive-defer counter), coa onboarding incident (Matou/coa #1, phase-1 tickets #7–#18, 2026-08-28).

> *This was generated by AI during triage.* **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** `ready-for-session` (`bug`), replacing `needs-triage`. **Why not `ready-for-agent`:** the fix cannot be done by a Sandcastle swarm worker. Every yield gate the bug is about lives in `.forgejo/workflows/triage.yml` and `exit 0`s *before* `run-triage.sh` is ever invoked — verified: the drive-defer gate, the two host-slot `flock -n` gates, and the workdir-lock gate all sit above `bash .sandcastle/run-triage.sh` in the workflow. Instrumenting "N consecutive yields while untriaged issues exist," giving issue-event runs a bounded `flock -w`, or self-re-dispatching all require editing `triage.yml`. `.forgejo/` is a protected path: per the triage-label doc, edits to prompt skeletons, the vendored `.sandcastle/` self-copy, and `.forgejo/` need an interactive session's standing, not a swarm worker (the swarm queue reads only `ready-for-agent`, so these are invisible to workers by construction). That is what `ready-for-session` records. **Why it is still a two-way door (not `ready-for-human`):** routing to a session, and the underlying change itself, are both fully revertible — a later commit or a label flip undoes them — and provable offline. No one-way-door residue: no credentials, no security-posture widening, no member-facing trust accept, no data destruction, no non-routine spend. So this is an agent ruling, not a human escalation; a session executes it, Ben's veto stays asynchronous. **What proves it:** the yield-counter side mirrors an already-offline-tested pattern — `host_capacity_consumer_defer_bump` / `host_capacity_consumer_defer_reset` in `host-capacity-lib.sh`, exactly as `schedule_drive_yield` uses it for the swarm's own drive-defer counter (#664). The counter, the threshold trip, and the reset-on-real-pass are all exercisable through shimmed tests with no docker/network; the workflow-level `flock -w` / re-dispatch changes are asserted by the existing offline `triage.yml` gate tests. --- ## Session Brief **Category:** bug **Summary:** A repo whose triage keeps yielding on a busy host produces no visible signal — twelve consecutive `exit 0` yields with zero tickets triaged read as green health, so a new consumer's ticket burst silently starves behind established repos' periodic traffic. **Why a session, not the swarm:** the change edits `.forgejo/workflows/triage.yml` (protected path). A swarm worker must not touch `.forgejo/`; an interactive session holds the standing to. **Current behavior:** Triage yields are `exit 0` in `triage.yml`, taken before `run-triage.sh` runs, so `run-triage.sh` (which only logs once it reaches `claude`) leaves no per-repo log for a yielded tick. Twelve consecutive yields for one repo are indistinguishable from twelve healthy no-op ticks. There is no per-repo "consecutive yields while untriaged issues exist" signal, the watchdog does not see it, and the only retry for a burst is the 30-minute cron competing on the same shared host slots. **Desired behavior:** When a triage run yields *and* `preflight-triage.sh` would list ≥1 untriaged issue, bump a per-repo consecutive-yield counter; at a threshold (N≥3), emit one visible signal — a comment on the oldest untriaged issue plus a Mattermost notice — without a human reading host `/tmp`. Reset the counter on any real triage pass. Existing yield semantics (never camp, `exit 0`) stay unchanged. **Key interfaces / mechanisms:** - Mirror the swarm's drive-defer counter: `host_capacity_consumer_defer_bump` / `host_capacity_consumer_defer_reset` (`host-capacity-lib.sh`), a per-repo path under `/tmp` (e.g. `/tmp/matou-triage-yield-<repo>`), reset by `run-triage.sh` on a successful pass — the same shape `schedule_drive_yield` already uses (#664). - The yield gates to instrument are the drive-defer gate, the two `flock -n` host-slot gates, and the workdir-lock gate in `triage.yml`. Reuse the existing zero-token `preflight-triage.sh` to answer "are there untriaged issues right now" cheaply at the yield point. - Notifications reuse the workflow's existing Mattermost step (`MATTERMOST_BOT_TOKEN`) and `forgejo_comment` (`forgejo-lib.sh`); the issue comment must carry the standard AI-triage disclaimer if posted by automation. - Optional, reporter-suggested, agent's call at implementation time: give issue-event runs a bounded `flock -w 120` (they are serialised by the concurrency group anyway) or a single delayed self-re-dispatch, and record the yield reason as a one-line verdict row so a host inspection can tell "slots busy" from "drive reserved" from "nothing to triage". **Acceptance criteria:** - [ ] A repo with untriaged issues whose triage yields 3 consecutive ticks produces a visible signal (issue comment and/or Mattermost) with no human reading host `/tmp`. - [ ] The counter resets on any real triage pass (a run that reaches `run-triage.sh` and triages). - [ ] Existing yield semantics unchanged: never camp, `exit 0`, no new blocking that could deadlock a slot. - [ ] Offline self-test (shimmed, no docker/network) for the counter bump / threshold trip / reset, in the same style as the drive-defer coverage, in the same commit. - [ ] `STATUS.md` updated in the same commit (changes triage yield/observability semantics). **Out of scope:** - The swarm-side slot-holding that *feeds* this starvation — tracked separately as #111 (a queue-draining run holding the heavy slot across tasks). Fixing #111 reduces the starvation; this ticket is the observability/signal for when it still happens. - Changing the number of pooled host slots or the concurrency-group design. - Exposing Forgejo job logs (the API does not; out of reach here). **Related:** #111 (swarm holds the slot across tasks — the upstream cause of much of this starvation), #108, #664 (drive-defer counter), coa onboarding incident (`Matou/coa` #1, phase-1 tickets #7–#18, 2026-08-28).

Ruled by agent under ADR 0174 — veto anytime

Two-way-door throughout (new vendored scripts + a workflow edit, all revertible by a later commit; proven by offline tests), so ruled and landed rather than escalated. Close-report below.

What landed — commit 20e3b7c

The acceptance: a repo whose triage yields 3 consecutive ticks with untriaged issues produces a visible signal (issue comment + Mattermost) without a human reading host /tmp, and existing yield semantics (never camp, exit 0) are unchanged.

  • triage-yield-lib.sh (new, pure) — a per-repo consecutive-yield counter /tmp/matou-triage-yield-<repo> (triage_yield_count_path/_bump/_reset, threshold, once-per-episode marker). Distinct from the drive-defer counter (#664): that measures how long the drive held the host; this measures how long a repo's triage queue has starved.
  • triage-yield-signal.sh (new) — called at every yield site with the reason. When preflight-triage.sh still lists ≥1 untriaged issue it bumps the counter and, at N≥3, posts ONE comment on the oldest untriaged issue + a Mattermost notice, once per episode. A yield with an empty queue resets the counter; a preflight failure leaves it untouched (no false reset). Best-effort by contract — every caller invokes it || true, so it never changes the yield's clean exit.
  • Wired at all five yield sites: triage.yml's inline slots-busy / workdir-busy / drive-reserved gates (+ its template, kept in lockstep — self-workflows-drift-test green), and run-triage.sh's limit-parked + drive-reserved gates. A real triage pass (or nothing-to-triage) calls triage_yield_reset.

This covers the incident's primary yield (the inline capacity gate, which fires before run-triage.sh is reached). One honest gap, commented in-code: the inline gates run before this tick's checkout, so on a brand-new consumer's very first burst (no prior checkout) the vendored signal script isn't present yet — covered by run-triage.sh's own gates and the next tick once a checkout lands.

Proof

  • New tests/triage-yield-signal-test.sh — 6 scenarios green: lib bump/reset/clamp; nothing-untriaged resets; below-threshold bumps without posting; at-threshold comments on the oldest issue (#7 not #9) and marks the episode; no repeat while the marker stands; a preflight failure leaves the counter untouched.
  • tests/run-triage-test.sh — 18 scenarios green, incl. new #110 cases: a drive-yield bumps the counter; a real pass and a nothing-to-triage tick reset it.
  • Full offline suite: 78/78 relevant tests green. The one red — vendor-manifest-coverage-test.sh — fails only on two pre-existing stray .claude/worktrees/* gitlinks committed in 43be97c, unrelated to this ticket; my two new scripts are correctly covered. Filed as #112.
  • bash -n clean on all touched shell + the extracted triage.yml run block.

Scope / follow-ups (held deliberately — the acceptance is the signal)

The ticket's proposal #2 (issue-event runs take a bounded flock -w or self-redispatch) and #3 (record the yield reason as a one-line verdict row) are not in this change: #3 in particular would write a verdict on a clean exit 0, which the healer reads as a fault (verdict_write only writes on non-zero exit) — a behaviour change beyond the acceptance. Left open for a separate ticket if wanted.

Re-vendor lag (GOTCHAS 4/34): this reaches a running host only when its FACTORY_REF is bumped past 20e3b7c; the running self-copy and consumers carry the old behaviour until a human bumps the pin.

Closing — work landed and proven.

## Ruled by agent under ADR 0174 — veto anytime Two-way-door throughout (new vendored scripts + a workflow edit, all revertible by a later commit; proven by offline tests), so ruled and landed rather than escalated. Close-report below. ## What landed — commit `20e3b7c` The acceptance: **a repo whose triage yields 3 consecutive ticks with untriaged issues produces a visible signal (issue comment + Mattermost) without a human reading host `/tmp`, and existing yield semantics (never camp, `exit 0`) are unchanged.** - **`triage-yield-lib.sh`** (new, pure) — a per-repo consecutive-yield counter `/tmp/matou-triage-yield-<repo>` (`triage_yield_count_path`/`_bump`/`_reset`, threshold, once-per-episode marker). **Distinct from the drive-defer counter (#664):** that measures how long the *drive* held the host; this measures how long a repo's triage *queue* has starved. - **`triage-yield-signal.sh`** (new) — called at every yield site with the reason. When `preflight-triage.sh` still lists ≥1 untriaged issue it bumps the counter and, at **N≥3**, posts ONE comment on the **oldest** untriaged issue + a Mattermost notice, **once per episode**. A yield with an empty queue resets the counter; a preflight failure leaves it untouched (no false reset). Best-effort **by contract** — every caller invokes it `|| true`, so it never changes the yield's clean exit. - **Wired at all five yield sites:** `triage.yml`'s inline **slots-busy / workdir-busy / drive-reserved** gates (+ its template, kept in lockstep — `self-workflows-drift-test` green), and `run-triage.sh`'s **limit-parked** + **drive-reserved** gates. A real triage pass (or nothing-to-triage) calls `triage_yield_reset`. This covers the incident's primary yield (the inline capacity gate, which fires *before* `run-triage.sh` is reached). One honest gap, commented in-code: the inline gates run before *this* tick's checkout, so on a brand-new consumer's very first burst (no prior checkout) the vendored signal script isn't present yet — covered by `run-triage.sh`'s own gates and the next tick once a checkout lands. ## Proof - New `tests/triage-yield-signal-test.sh` — **6 scenarios** green: lib bump/reset/clamp; nothing-untriaged resets; below-threshold bumps without posting; at-threshold comments on the **oldest** issue (#7 not #9) and marks the episode; no repeat while the marker stands; a preflight failure leaves the counter untouched. - `tests/run-triage-test.sh` — **18 scenarios** green, incl. new #110 cases: a drive-yield bumps the counter; a real pass and a nothing-to-triage tick reset it. - Full offline suite: **78/78 relevant tests green.** The one red — `vendor-manifest-coverage-test.sh` — fails **only** on two pre-existing stray `.claude/worktrees/*` gitlinks committed in `43be97c`, unrelated to this ticket; my two new scripts are correctly covered. Filed as **#112**. - `bash -n` clean on all touched shell + the extracted `triage.yml` run block. ## Scope / follow-ups (held deliberately — the acceptance is the signal) The ticket's proposal **#2** (issue-event runs take a bounded `flock -w` or self-redispatch) and **#3** (record the yield reason as a one-line verdict row) are **not** in this change: #3 in particular would write a verdict on a *clean* `exit 0`, which the healer reads as a fault (`verdict_write` only writes on non-zero exit) — a behaviour change beyond the acceptance. Left open for a separate ticket if wanted. **Re-vendor lag (GOTCHAS 4/34):** this reaches a running host only when its `FACTORY_REF` is bumped past `20e3b7c`; the running self-copy and consumers carry the old behaviour until a human bumps the pin. Closing — work landed and proven.
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#110
No description provided.