Skip to content

skills(running-tend): poll rerun jobs, not the parent run - #2449

Merged
max-sixty merged 3 commits into
mainfrom
daily/review-runs-25042752926
Apr 28, 2026
Merged

max-sixty merged 3 commits into
mainfrom
daily/review-runs-25042752926

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Summary

Add a section to running-tend/SKILL.md covering the gh run rerun --failed + until status == completed polling pattern. Two long sessions across consecutive review-runs windows blocked for 2-2.5 hours each because the bot polled the parent CI run's status instead of the specific rerun job(s).

Evidence

This is the second occurrence of the same structural pattern across two consecutive review-runs windows. Last review's tracking entry (Run 24986870769) flagged it as below threshold pending recurrence: "If a second occurrence appears within the next two windows, file as a structural-fix PR to running-tend."

Run Workflow Duration What blocked it
24975304574 (2026-04-27) tend-review 155 min benchmarks on parent CI run 24975304781 ran 03:35→06:02 (147 min)
25025555994 (2026-04-28) tend-mention 158 min benchmarks on parent CI run 25015241976 ran 23:50→02:21 (150 min)

In both cases the bot ran:

gh run rerun <run-id> --failed
until [ "$(gh run view <run-id> --json status --jq .status)" = "completed" ]; do sleep 15; done

The --failed rerun's actual job (test (linux)) finished in ~5 min. The until loop kept polling because the parent run's status is in_progress until every job — including the unrelated, still-running benchmarks sibling — completes. Net wallclock cost: ~2.5h × 2 incidents = ~5h of bot time blocked on a job it didn't care about.

Classification

  • Confidence: High (structural — same conditions reproduce the same wait every time)
  • Magnitude: Targeted fix (new section in existing skill, ~40 lines)
  • Gates: Both passed — structural failures need 1 occurrence for a targeted fix; we have 2.

Fix

The new section instructs the bot to poll the specific rerun job ID(s) via gh api repos/.../actions/jobs/<id>, not the parent run's .status. It also notes that the bundled running-in-ci pending() recipe doesn't help here since benchmarks is itself a check-run on the head SHA.

🤖 Generated with Claude Code

After `gh run rerun --failed`, polling the parent run's `.status` blocks
the bot for the duration of the slowest sibling job, even though the
rerun itself finishes in minutes. Two recent occurrences each blocked
~150 min waiting on `benchmarks` while the actually-rerun job was green
within minutes.

@worktrunk-bot worktrunk-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One blocking concern in the new recipe — see inline suggestion.

Two smaller observations on the same block:

  • Race window between rerun and query. gh run rerun --failed returns immediately, but the new attempt records may not be visible from runs/<id>/jobs?filter=latest for a second or two. If the query lands in that window, every job still shows the prior completed/failure status, JOB_IDS is empty, and the bot moves on without waiting at all. A 5–10s sleep between the rerun and the query closes the race.
  • Sequential per-job polling. With one rollup-style loop (length of the not-yet-completed set) the bot polls all reran jobs in parallel and exits when the last one terminates. The current per-job nested loop is correct but pays a 15-min cap per job; for 2–3 reran jobs that compounds. Optional structural simplification, not a blocker.

Comment thread .claude/skills/running-tend/SKILL.md Resolved
… poll

Address self-review feedback on the rerun-polling section:

- Replace `select(.status \!= "completed")` with
  `select((.status == "completed") | not)`. The Bash tool rewrites `\!` to
  `\\!` before bash parses the command, so the original filter would fail
  every time the recipe is copy-pasted into a Bash call — defeating the
  whole point of the section.
- Add a `sleep 10` between `gh run rerun --failed` and the
  `jobs?filter=latest` query. The new attempt records take a few seconds
  to surface; without the sleep the query can see only the prior
  `completed`/`failure` rows and exit without waiting.
- Switch the polling loop from sequential per-job to a rollup that polls
  all reran jobs together each minute, matching the pattern used by the
  bundled `running-in-ci` `pending()` recipe.
@max-sixty

Copy link
Copy Markdown
Owner

these skills should be less verbose. they should not reference specific past runs, because that's not helpful for the consuming repos.

so:

  • fix here
  • open a new PR with this guidance in CLAUDE.md and audit the existing skills

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Done.

  • Fix here: trimmed in 5d73766 — dropped the past-run links, the run-duration anecdote, and the multi-paragraph framing; kept the recipe.
  • Follow-up PR: skills(running-tend): drop dated baseline reference #2451 — adds an Authoring skills subsection to CLAUDE.md (brief, no specific past-run references, date-stamp only when the value depends on time, prefer recipe over narrative) and applies one audit fix in running-tend (the dated Baseline as of 2026-04-13 line). The other skills don't reference specific runs.

@max-sixty
max-sixty merged commit 26addd9 into main Apr 28, 2026
23 checks passed
@max-sixty
max-sixty deleted the daily/review-runs-25042752926 branch April 28, 2026 16:17
@max-sixty

Copy link
Copy Markdown
Owner

sorry: @tend-agent & @worktrunk-bot I think this guidance should go into tend's guidance

@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Got it — moved the CLAUDE.md change out of #2451 (force-pushed skills/author-guidance-and-audit to drop commit 585ece7). The PR is now just the running-tend audit fix.

The skill-authoring guidance itself belongs in max-sixty/tend — likely added to the existing "Skill design: bundled for everyone, overlay for one" section in that repo's CLAUDE.md. I don't have push access to max-sixty/tend from this bot account, so I haven't opened that PR. Happy to draft the wording here for you to paste, if useful.

@max-sixty

Copy link
Copy Markdown
Owner

can we also remove the ## Polling gh run rerun --failed section we added in this PR? @tend-agent will hopefully pick it up

worktrunk-bot added a commit that referenced this pull request Apr 28, 2026
Per PR #2449 maintainer feedback, this guidance is general-purpose and
belongs in tend's bundled skills (where tend-agent can pick it up across
consumer repos), not in worktrunk's overlay.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@worktrunk-bot

Copy link
Copy Markdown
Collaborator Author

Done — pushed ea7513bb to #2451 dropping the ## Polling gh run rerun --failed section. The audit PR now removes both worktrunk-overlay items prompted by the original review (the dated baseline reference + the rerun polling recipe), leaving the structural rerun-polling guidance for tend-agent to land in the bundled skill.

max-sixty pushed a commit that referenced this pull request Apr 28, 2026
## Summary

Per #2449 maintainer feedback, this PR was originally going to add
skill-authoring guidance to `CLAUDE.md` and apply an audit to existing
skills. The follow-up comment clarified that the *guidance itself*
belongs in tend's repo (where `tend-ci-runner` skills are bundled and
shared across consumers), not in worktrunk's `CLAUDE.md` — so I've
dropped the `CLAUDE.md` commit.

What's left is the audit fix the guidance prompted: the `running-tend`
skill no longer cites the dated `Baseline as of 2026-04-13 ... (see PR
#2209)` reference, just the structural rule (`~29 baseline, jump above
~32 warrants investigation`).

The skill-authoring guidance itself needs to land in max-sixty/tend
(likely under "Skill design: bundled for everyone, overlay for one" in
that repo's CLAUDE.md). The bot doesn't have push access there, so
that's a separate manual change.

---------

Co-authored-by: worktrunk-bot <[email protected]>
Co-authored-by: Claude Opus 4.7 <[email protected]>
@tend-agent

Copy link
Copy Markdown

Picked up the rerun-polling recipe in tend #350 — added it as a subsection under "CI Monitoring" in the bundled running-in-ci skill, trimmed to the structural rule + recipe.

max-sixty pushed a commit to max-sixty/tend that referenced this pull request Apr 28, 2026
## Summary

Add an "Authoring skills" subsection to `CLAUDE.md` codifying the four
rules max-sixty raised in
[worktrunk#2449](max-sixty/worktrunk#2449 (comment)):
be brief, no specific past-run references, date-stamp only when
time-dependent, prefer recipe over narrative.

## Context

The same guidance was originally drafted into worktrunk's `CLAUDE.md`
([commit
585ece7e](max-sixty/worktrunk@585ece7e), since
force-pushed away). Per max-sixty's note in
[worktrunk#2449](max-sixty/worktrunk#2449 (comment))
(`I think this guidance should go into _tend_'s guidance`), the rule
belongs here — `tend-ci-runner` skills are bundled and shared across
consumers, so the authoring style applies to every consumer's overlays
as well as tend's own bundled skills.

Placed under the existing "Skill design: bundled for everyone, overlay
for one" heading. Scoped to `plugins/tend-ci-runner/skills/` (bundled)
and `.claude/skills/` (overlays).

Co-authored-by: tend-agent <[email protected]>
max-sixty pushed a commit to max-sixty/tend that referenced this pull request Apr 28, 2026
## Summary

After `gh run rerun <run-id> --failed`, the bot has been polling the
parent run's `.status` for `completed`. That status stays `in_progress`
until every sibling job finishes — including unrelated long-running ones
— so the rerun loop blocks waiting on jobs the bot does not care about.

Add a recipe to bundled `running-in-ci` showing how to poll the rerun
job IDs via `repos/.../actions/jobs/<id>`, and note that the existing
`pending()` (statusCheckRollup) recipe doesn't help because sibling
check-runs on the head SHA still appear pending.

## Context

Per max-sixty's request in
[worktrunk#2449](max-sixty/worktrunk#2449 (comment))
and
[worktrunk#2451](max-sixty/worktrunk#2451 (comment)):
the same recipe was originally landed as a worktrunk overlay, but the
rule is universal across consumers, so it belongs in the bundled skill.
The overlay is being removed in worktrunk#2451.

---------

Co-authored-by: tend-agent <[email protected]>
Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants