Repository navigation
skills(review-runs): make the run census a second input to the stranded-trigger drain - #1069
tend-agent wants to merge 5 commits into
Conversation
…rigger drain The outage row is filed by a step inside the failing job, so a run that dies before reaching it — startup_failure, a job that never gets a runner, a wedged checkout, a failing setup: step — files no row and uploads no session log. The drain read only the outage issue, so those runs were invisible and their triggers stayed stranded: an issues-event triage is never re-fired by anything. Filter Step 1's census (it already carries every run's conclusion) as a second input, and fold the cancelled-eviction caveat into the existing re-run test so the new input doesn't turn into re-run spam. Closes #1066 Closes #1067
|
Triaging #1067 — a second consumer report of this root cause, filed a minute after #1066 — turned up one case the "Re-run only what won't recover" paragraph still drops. The census-input paragraph covers it ("a job that never gets a runner"), but the re-run test then says "a later push often re-triggers it" and names only an A On Verification |
tend-agent
left a comment
There was a problem hiding this comment.
The premise checks out: Report failure is a step inside the job (claude/action.yaml:391, codex/action.yaml:259, both gated on failure()), so a run that never enters the action files no row — and status=completed in Step 1's census does return startup_failure runs, so the census really is the surviving signal. The cancelled caveat and dropping --failed both follow.
One line doesn't hold up: the billable-time signature. Details inline.
… limit of the billing signature A tend-ci-fix run on a still-red default branch is never re-fired either: a later push only re-triggers it if CI fails again. And zero billable time proves the agent never started, not that anything was stranded — a designed cancellation bills zero too, so the trigger is the discriminator. Raised on #1067.
…oint, not billable time
tend-agent
left a comment
There was a problem hiding this comment.
The tend-ci-fix addition checks out against the workflow's own trigger — workflow_run on ci, gated conclusion == 'failure', so a push that turns CI green re-fires nothing and a red main nobody pushes to strands it indefinitely.
The billable-time line is the one still outstanding, and this push strengthened it rather than fixing it — "is the signature of" became "means", and the new clause builds the stranding/never-started distinction on top of the same premise. The premise doesn't hold: GitHub doesn't bill public-repo Actions minutes, so .billable reports zero for every run there, healthy ones included. PRQL's own successful 34-job run 32012160421 returns total_ms: 0 on both MACOS and UBUNTU — indistinguishable, in the field this line keys on, from the dead tend-ci-fix run the PR cites. Most consumers are public repos, so a session following this reads "the agent never started" on runs that ran fine.
The jobs endpoint separates all three shapes, on public and private repos alike. Inline suggestion folds this push's new distinction into that discriminator.
Verification
$ gh api repos/PRQL/prql/actions/runs/32012160421/jobs --jq '.jobs[0] | {conclusion, runner_name, steps: (.steps|length)}'
{"conclusion":"success","runner_name":"GitHub Actions 1000127903","steps":10}
$ gh api repos/PRQL/prql/actions/runs/32012160421/timing --jq .billable
{"MACOS":{...,"total_ms":0},"UBUNTU":{...,"total_ms":0}} # healthy, 34 jobs
$ gh api repos/PRQL/prql/actions/runs/32985756174/jobs --jq '.jobs[0] | {conclusion, runner_name, steps: (.steps|length)}'
{"conclusion":null,"runner_name":"","steps":0}
$ gh api repos/PRQL/prql/actions/runs/32985756174/timing --jq .billable
{"UBUNTU":{...,"total_ms":0}} # dead — same zero
$ gh api repos/max-sixty/tend/actions/runs/32984004073/jobs --jq .total_count
0
$ gh api repos/max-sixty/tend/actions/runs/32984004073/timing --jq .billable
{} # startup_failure — not a zero at all
…inned action ref The drain's remedy was a bare `gh run rerun`, which fails silently in two ways an adopter run has now hit: - A run that never got a runner has no attempt to replay. The command exits 0, `run_attempt` stays at 1, and `status` sits at `queued` — and a queued run is dropped by Step 1's `status=completed` census, so it never surfaces again. The row reads as drained forever. - A re-run replays the workflow file from the original run's commit, so it re-uses that commit's action pin. When the outage cause was an action-version regression, the fix ships as a pin bump on the default branch and every stranded run sits behind it by construction: the re-run reproduces the failure and files a fresh outage row. Adds the ref comparison before the re-run, the `run_attempt` re-read after it, and a per-trigger recovery table so a row with no re-run path is drained by naming what would recover it rather than by closing the issue.
tend-agent
left a comment
There was a problem hiding this comment.
The census-as-second-input argument holds, and both new failure modes are real — I re-checked the ref-replay one against the live API and the shape is present right now: main's tend-mention.yaml still pins max-sixty/tend/[email protected] at e4e6bf3, one release behind the 0.1.20 tag, so a run stranded across a pin bump would indeed replay the old ref.
Two of the three new recipes don't do what the prose beside them says, and both fail toward the wrong drain verdict:
- The
run_attemptre-read fires before the attempt record exists, so a re-run that did dispatch reads as "not drained". - The ref comparison fails open: when the hand-filled
<workflow>.yamldoesn't resolve, both sides of thediffare empty, it exits 0, and that reads as "refs match" — green-lighting exactly the re-run the guard exists to stop.
Details and suggestions inline. One aside on the comment in that block: every generated checkout sets fetch-depth: 0 (macros.yaml.j2, and tend-review-runs.yaml renders it), so "the runner's checkout is shallow" isn't the reason to prefer the contents API — the reason that survives is that the commit may simply not be reachable there (fork head, deleted branch).
Verification
# the runs API already returns the workflow file path — no name-to-file guess needed
$ gh api repos/max-sixty/tend/actions/runs/33129362265 --jq '{name, path, head_sha}'
{"head_sha":"e4e6bf3e...","name":"tend-mention","path":".github/workflows/tend-mention.yaml"}
# the guard as written, with a path that doesn't resolve: silent exit 0
$ diff <(gh api "repos/max-sixty/tend/contents/.github/workflows/nope.yaml?ref=main" \
-H 'Accept: application/vnd.github.raw' 2>/dev/null | grep 'uses: max-sixty/tend/') \
<(grep 'uses: max-sixty/tend/' .github/workflows/nope.yaml 2>/dev/null)
$ echo $?
0
# rerun-failed-jobs.sh, same plugin, on why one read isn't enough:
# "The new attempt record takes a few seconds to surface."
# for _ in $(seq 1 6); do sleep 5; ATTEMPT=$(gh api "$RUN_API" --jq '.run_attempt'); ...
The `run_attempt` re-read fired before the attempt record surfaced, so a re-run that did dispatch read as attempt 1 and the row was recorded as not drained; sleep first, matching `rerun-failed-jobs.sh`'s note that the new attempt record takes a few seconds to appear. The ref comparison hand-filled the workflow *path* from the census's workflow *name*. A wrong path 404s inside process substitution where the exit status is discarded, the local grep on the same missing file is empty too, and `diff` compares empty to empty and exits 0 — read by the caller as "refs match, safe to re-run". Take `.path` from the runs call that already returns `.head_sha`, and capture the fetch so an unreadable file is loud. Also: only `schedule` re-fires unaided, per the table's own rows, and the reason to prefer the contents API is reachability, not shallowness — every generated checkout sets `fetch-depth: 0`.
tend-agent
left a comment
There was a problem hiding this comment.
All three findings from the last round are fixed. I re-ran both reworked guards against the live API rather than reading them, and the fail-open case that motivated the ref guard now takes the else branch: grep's exit status governs the if, so an unreadable file reports needs a fresh trigger instead of diff-ing empty against empty and exiting 0. .path off the runs call removes the name-to-file guess the timeout-cap step warns against, and the sentence and the table under it now agree — schedule is the one row that recovers unaided. Taking the sleep as suggested is right: the non-dispatch case is by construction a run whose attempt 1 never ran, so the paragraph's "stays at 1" is the baseline the re-read needs, and rerun-failed-jobs.sh's poll would only be buying precision this recipe can't use (it passes --failed, which is the one flag here that can't be used).
One observation, not a blocker: the drain's two guards are now ~20 lines of branching bash living in a markdown fence, which is the shape /tend-ci-runner:running-in-ci sends to a script under Scripts over prose recipes ("when a skill's code block needs edge-case handling ... put the logic in a tested script"). The evidence is this PR's own history — the first version of the ref guard shipped fail-open and was caught by hand, twice over. A script in plugins/tend-ci-runner/scripts/ would get shellcheck at -S warning from pre-commit (files: ^(...|plugins/.*\.sh|...)$) and a test in the generator suite; the fence gets neither. Worth a follow-up rather than a fourth round here.
Both guard branches, run live
$ read -r WF HEAD_SHA < <(gh api "repos/max-sixty/tend/actions/runs/33129362265" --jq '"\(.path) \(.head_sha)"')
$ echo "$WF $HEAD_SHA"
.github/workflows/tend-mention.yaml e4e6bf3ed836c686bfa1b82d37378a8d28fb56ba
# readable: then branch, diff exits 0
-- then branch --
refs match (exit 0)
# the fails-open case from the last round, now closed
$ WF=.github/workflows/nope.yaml
ELSE branch taken — fails closed: .github/workflows/nope.yaml unreadable at e4e6bf3e...
|
Closing this version because it turns one missing census input into 52 lines of branching recovery instructions, including inline shell for action-pin comparison and rerun dispatch verification. The census signal is valid, but the recovery behavior needs a tested script or a smaller report-only change. Leaving #1066 and #1067 open for that simpler follow-up.
|
|
Report-only version opened as #1073: the census filter plus one paragraph saying a re-run is not proof of recovery. 14 lines added rather than 52, no recovery table, and the only shell is the one |
…aiting` (#1320) A scheduled run parked in GitHub's pre-job `waiting` state never concludes, so it holds its concurrency group indefinitely. Under `cancel-in-progress: false` — which every generated scheduled workflow carries, paired with `environment: tend` — each later tick takes the one pending slot and is replaced by its successor, and the workflow stops running with nothing red to show for it. Step 1's census admits a row only on a non-null `conclusion`, so the parked run is absent by construction and the replacements it causes read as ordinary concurrency. `review-runs`'s **Reconcile live work** now lists it beside the red-default-branch and Dependabot checks, since a workflow whose queue is dead is live work in the same sense. The remedy is `gh run cancel` on the parked run, after `pending_deployments` confirms the gate has no timer and no reviewers to release it. The wedge test covers event-driven runs too, not just cron ones: `environment: tend` comes from a shared template that every generated workflow but the secretless `tend-mention-relay` uses, and `tend-review`, `tend-mention`'s handle job and `tend-ci-fix` pair it with `cancel-in-progress: false`, so a parked run there strands a PR's review queue the same way. Those have no scheduling interval to measure staleness against, so the bullet names the event that created the run as the bound instead. The bullet also separates `queued`, which looks similar and needs the opposite handling. I reproduced that half here rather than taking it from the report: `tend-notifications` run `34748600612` has been `queued` since 2026-09-13, and `gh run cancel` on it answers `Cannot cancel a workflow run that is completed` while the runs API still reports `status: queued, conclusion: null`. Nothing is held — this repo's `tend-notifications` has run throughout — so the text says to leave it rather than fight it. Text only, and deliberately one bullet: #1069 established that the recovery half of this class of finding belongs in a small report-or-remedy step, not a branching instruction table. `uv run pytest -k skill` passes. Closes #1314 --------- Co-authored-by: tend-agent <[email protected]> Co-authored-by: tend-agent <[email protected]>
review-runs's Drain stranded triggers read only thetend-outageissue, but that row is filed by a step inside the failing job — so a run that dies before reaching it files nothing, uploads no session log, and is invisible to the drain, while stranding the same trigger. This adds Step 1's census as a second drain input (it already carries every run'sconclusion), and then fixes the remedy the drain reaches for once it has a row: a baregh run rerunsilently fails to drain in two distinct ways.Reported independently by two consumer repos within a minute of each other — #1066 (
max-sixty/worktrunk: astartup_failureonissues: openedleft a maintainer's bug report untriaged for 21 h) and #1067 (PRQL/prql: atend-ci-fixjob that never got a runner leftmainred for 19 h 40 m). Both windows' drains reported "nothing stranded".Why the census is the only surviving signal
Report failureinclaude/action.yamlis gated onfailure(), which covers everything from the rate-limit preflight onward — #857 widened it for exactly that reason. What it cannot cover is a job in which no step runs at all: astartup_failureexecutes zero steps, and a job that never gets a runner, a wedgedactions/checkout, or a failing adoptersetup:step die before the action is entered. Those runs also upload no artifact, so the drain's "Diagnose first" session-log path has nothing to key on either.Step 1's census emits
{databaseId, conclusion, createdAt, updatedAt, name}per run over the same window, so the signal is already in hand — the skill just never told a session to use it for this. The filter is onejqline, so no new mechanism is introduced and nothing new is fetched.The
cancelledcaveat is what keeps the new input from misfiring: withcancel-in-progress: false, a burst of events on one thread replaces the queued sibling, and the winning run answers the whole thread. Those runs record zero steps too, and re-running them would spam threads that already got their reply. The re-run test names that case.Why
gh run rerunis not the drainBoth failures were reported on #1066 by
max-sixty/worktrunk's next window and re-verified here against the live API.Exit 0 is not a dispatch. A run that never got a runner has no attempt to replay.
gh run rerunexits 0,run_attemptstays at 1, andstatussits atqueued— the stranded triage run from #1066's own report is still{"status":"queued","run_attempt":1,"conclusion":null}two days after its re-run was issued, and the issue it stranded still has no triage comment. This is worse than the original silence, because a queued run is notcompleted, so Step 1's census drops it and it never surfaces on a later window. The row reads as drained forever. The PR adds arun_attemptre-read after the re-run and says an unchanged value means not drained.A re-run replays the original commit's workflow file, so it re-uses whatever action ref that commit pinned. Where the outage cause was an action-version regression, the fix ships as a pin bump on the default branch and every stranded run sits behind it by construction — the re-run reproduces the failure verbatim and files a fresh outage row, so the drain re-opens what it is draining. Verified for the runs stranded by the 0.1.19
PATHregression (#1071): their commit pinsmax-sixty/tend/[email protected]while the default branch is on0.1.20. This is the shape where a re-run looks safest, because the census does show a later clean run. The PR adds the ref comparison before the re-run.The per-trigger recovery table follows from the two: for
issues: openedthere is no re-run path at all, so a row is drained by naming what would recover it — a mention or a human — rather than by closing the issue.Testing
Markdown-only change to a bundled skill; no test reads this file's contents and no code path changes. The
uvandpre-commitgates are not available inside the agent sandbox, so they went unrun locally — CI runs both on this PR. The twogh apirecipes added here were run against the live runs they describe before being written down.Closes #1066
Closes #1067