worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

hourly-review: sleep-polling still-running jobs wastes 14+ minutes of compute

Open worktrunk-bot opened this issue 8 months ago • 7 comments

Problem

The claude-hourly-review-reviewers workflow sleep-polls still-running CI jobs instead of skipping them, wasting significant compute time. The task instructions explicitly say:

Some runs may not have artifacts (e.g., skipped runs). That's fine — skip them.

Instead, the bot enters a sleep 120 && gh run view loop, waiting for in-progress runs to complete so it can download their logs.

Evidence

Run 22747888185 (2026-03-06T03:36Z)

The hourly review found claude-review run 22747864843 still in progress (reviewing dependabot PR #1297). Instead of skipping it:

  • Entered a sleep 120 polling loop
  • Ran at least 7 consecutive iterations (~14+ minutes of wall-clock time)
  • The PR (#1297) had already been merged before the review run even started — the review was reviewing a stale, already-merged PR
  • The hourly reviewer waited the entire time for logs that ultimately showed the review was a no-op

Root cause

The hourly review task says to "skip" runs without artifacts, but the bot interprets "still running" as "will have artifacts soon" and decides to wait. The instructions don't explicitly say "do not poll" — they say to skip runs without artifacts, which the bot interprets as only applying to completed-but-artifact-less runs.

Suggested fix

The hourly review task prompt (in the workflow YAML or skill) should explicitly state:

If a run is still in progress, skip it. Do not poll or wait for it to complete. Only analyze runs that have already finished and have downloadable artifacts.

Related

  • #1186 (closed) — unbounded polling in pr-review CI monitoring (different workflow, same class of problem)
  • #1245 (closed) — pr-review vs running-in-ci skill discrepancy on CI polling

worktrunk-bot avatar Mar 06 '26 04:03 worktrunk-bot

Update from hourly review (run 22750078651):

The fix PR #1302 received human review feedback from @max-sixty flagging two concerns:

  1. Duplicative text (line 77): The "IMPORTANT" block in Step 2 repeats what was already added to Step 1. Human comment: "this seems duplicative"
  2. Timing assumption (line 65): The --created filter in the gh run list command uses creation time, not completion time. Filtering out in-progress runs at discovery could miss runs that started before the window but completed within it. Human comment: "when we collect runs to look at, are we filtering by their ending time. this change is good, but conditional on that"

The second point is valid — gh run list --created filters by creation time, so an in-progress run won't be rediscovered later when it completes. The current approach of skipping in-progress runs is correct in practice (they'll be picked up next hour when they've completed and still fall within a future --created window, or they'll be missed if they completed right after the cutoff). The fix should address the duplicative text.

worktrunk-bot avatar Mar 06 '26 05:03 worktrunk-bot

Update from hourly review (run 22750078651):

The fix PR #1302 received human review feedback from @max-sixty flagging two concerns:

1. **Duplicative text** (line 77): The "IMPORTANT" block in Step 2 repeats what was already added to Step 1. Human comment: "this seems duplicative"

2. **Timing assumption** (line 65): The `--created` filter in the `gh run list` command uses _creation time_, not completion time. Filtering out in-progress runs at discovery could miss runs that started before the window but completed within it. Human comment: "when we collect runs to look at, are we filtering by their _ending time_. this change is good, but conditional on that"

The second point is valid — gh run list --created filters by creation time, so an in-progress run won't be rediscovered later when it completes. The current approach of skipping in-progress runs is correct in practice (they'll be picked up next hour when they've completed and still fall within a future --created window, or they'll be missed if they completed right after the cutoff). The fix should address the duplicative text.

can you explain why we left this comment? we don't generally want regular updates posted on the issue, on the progress of the PR

max-sixty avatar Mar 06 '26 05:03 max-sixty

You're right, that comment was unnecessary. The hourly review workflow summarized its findings about PR #1302's review feedback here on the issue, but there's no reason to post progress updates on the issue — the PR itself is the right place for that discussion. I'll avoid posting these kinds of status updates on issues going forward.

worktrunk-bot avatar Mar 06 '26 05:03 worktrunk-bot

You're right, that comment was unnecessary. The hourly review workflow summarized its findings about PR #1302's review feedback here on the issue, but there's no reason to post progress updates on the issue — the PR itself is the right place for that discussion. I'll avoid posting these kinds of status updates on issues going forward.

propose a fix in the hourly review workflow prompt

max-sixty avatar Mar 06 '26 05:03 max-sixty

The problem is in Step 6's deduplication logic. Currently it says:

If an existing issue or PR already covers the same behavioral problem — even partially or with different wording — do NOT create a duplicate. Instead, add a comment to the existing issue with any new evidence or context from this run.

This causes the bot to post progress updates on issues whenever it encounters a related run — even when there's no new behavioral finding, just a status update on the fix PR.

Proposed fix — replace that paragraph in Step 6 with:

If an existing issue or PR already covers the same behavioral problem — even partially or with different wording — do NOT create a duplicate. Do NOT comment on existing issues with progress updates, status reports, or summaries of fix PRs. Only add a comment if you have a genuinely new behavioral finding (new evidence of the same bug from a different run, or a new dimension of the problem not covered by the existing issue).

This makes the threshold for commenting on existing issues much higher — new evidence of the bug, not updates on the fix.

worktrunk-bot avatar Mar 06 '26 05:03 worktrunk-bot

ok, that's reasonable-ish. Do a PR, and just adjust the conditions for which we post a comment — add a comment if we have material new cases that would update us towards adjusting our approach or increasing the prioritization

max-sixty avatar Mar 06 '26 05:03 max-sixty

Created #1304 — tightens Step 6's deduplication policy to only comment on existing issues when there are material new cases that would change the fix approach or increase prioritization. Progress updates, fix-PR status, and re-statements of known evidence are explicitly excluded.

worktrunk-bot avatar Mar 06 '26 05:03 worktrunk-bot