Skip to content

review-runs: detect near-timeout jobs and fix lookback window - #224

Merged
max-sixty merged 2 commits into
mainfrom
review-runs-timeout-detection
Apr 10, 2026
Merged

max-sixty merged 2 commits into
mainfrom
review-runs-timeout-detection

Conversation

@max-sixty

@max-sixty max-sixty commented Apr 10, 2026 •

Copy link
Copy Markdown
Owner

The review-runs sweep currently can't see two related problems: its lookback window was shorter than its cron interval, and it never inspects job duration. Both come up in the same place, so bundled.

Window fix

The window was 12 hours ago but the cron runs daily at 07:47 UTC. Runs completing between 12–24 hours before the sweep were silently skipped forever. Widened to 24 hours (and the same change in the token-report.sh call so its window matches).

Long-running job detection

Added a scan after the Step 1 run listing: for each run, pull its jobs via /runs/{id}/jobs and flag any that ran over 30 minutes. Tend workflows typically finish in single-digit minutes, so anything past 30 is anomalous. At GitHub Actions' 360-min default cap (after #223 dropped the timeout-minutes constant), a ~360-min failure is the runner-kill signature.

Flagged jobs feed into the existing Step 3 session-log download and Step 6 summary. Treated as structural failures per review-gates.md — one occurrence is enough to act.

Motivated by worktrunk run 24254014913: a tend-mention handle job that ran 58:51 on a legitimate multi-commit review (shell-integration fix, docs, codecov gaps, capitalization snapshot), most of the tail spent in background Task polls waiting on slow codecov/patch. conclusion: success, exit code 0 — indistinguishable from a 3-minute happy path in today's sweep.

This was written by Claude Code on behalf of max-sixty

max-sixty and others added 2 commits April 10, 2026 12:45
The window was 12 hours despite the cron running daily, silently skipping
runs from 12–24 hours before the sweep. Widen to 24.

Add a near-timeout scan to Step 1: pull each run's jobs and flag any that
used ≥85% of the 60-min cap (51 min). Catches both near-miss (success at
the cap) and runner-kill (failure with no failed step at the cap).
Motivated by worktrunk run 24254014913, which ran 58:51 of a 60-min cap on
legitimate multi-commit work — a clean near-miss the current sweep wouldn't
notice.

The 3060s threshold is coupled to tend's `timeout-minutes` constant in
`generator/src/tend/workflows.py`. The pending raise-to-120 work will need
to update it.

Co-Authored-By: Claude <[email protected]>
…etection

# Conflicts:
#	plugins/tend-ci-runner/skills/review-runs/SKILL.md
@max-sixty
max-sixty merged commit b5c0f8f into main Apr 10, 2026
5 checks passed
@max-sixty
max-sixty deleted the review-runs-timeout-detection branch April 10, 2026 20:02
max-sixty pushed a commit that referenced this pull request Apr 10, 2026
#234)

## Summary

Every `/tend-ci-runner:review` invocation has been **silently broken**
since PR #217 merged at 2026-04-10 20:07 UTC. PRs #225–#233 all received
**zero reviews from the bot** — the review runs report `success` but the
session artifacts show no assistant turn at all. This PR removes the
poison and restores reviews.

## Root cause

PR #217 (`fix(ci-runner): replace if-not polling loop with || to avoid
bash escaping`) added an explanatory comment inside the CI-polling code
block:

```markdown
# Use `||` rather than `if \!` — the Bash tool escapes `\!` as `\\!`, which
# prevents bash from recognizing the pipeline-negation reserved word...
```

Claude Code's slash-command preprocessor scans the loaded file for ``
\!` `` (a prefix that means "execute the next backticked string as a
shell command") **regardless of markdown code fences**. It found `` \!`
`` inside `` `if \!` ``, consumed text through the next backtick, and
ran `` — the Bash tool escapes ` `` as bash. The em-dash is not a
command, so bash reported:

```
Error: Shell command failed for pattern "\!` — the Bash tool escapes `":
/bin/bash: line 1: —: command not found
```

When the preprocessor fails, the prompt body is not delivered. Every
`/review <N>` session in this window produced the same 5-line trace —
two internal `queue-operation` messages, the command caveat, the command
invocation, the stderr — and then nothing. The model was never given
instructions to follow.

## Evidence

All tend-review sessions in the past hour's window ran this preprocessor
and failed identically:

| Run | PR | Branch | Session size | Review posted |
|---|---|---|---|---|
| 24261252532 | #224 | `review-runs-timeout-detection` | ~120 lines | ✅
APPROVED (ran **before** #217 merged at 20:07Z) |
| 24262024783 | #225 | `tend-mention-dedup-review-events` | 5 lines | ❌
|
| 24262028666 | #226 | `hourly/review-24261599977` | — | ❌ (checkout
failure — infra race, separate issue) |
| 24262305841 | #226 | `hourly/review-24261599977` | 5 lines | ❌ |
| 24262406137 | #227 | `raise-job-timeouts` | 5 lines | ❌ |
| 24262970448 | #228 | `mention-verify-paginate` | 5 lines | ❌ |
| 24262987799 | #229 | `tend-claude-md-workflow-update-note` | 5 lines |
❌ |
| 24263043865 | #230 | `raise-job-timeouts` | 5 lines | ❌ |
| 24263117206 | #231 | `mention-review-inline-reply-prompt` | 5 lines |
❌ |
| 24263177723 | #232 | `raise-job-timeouts` | 5 lines | ❌ |
| 24263220447 | #233 | `tend-mention-dedup-review-events` | 5 lines | ❌
|

Sample JSONL from run 24262987799 (PR #229):
```json
{"type":"queue-operation"}
{"type":"queue-operation"}
{"type":"user","content":"<local-command-caveat>..."}
{"type":"user","content":"<command-name>/review</command-name>\n<command-args>229</command-args>"}
{"type":"user","content":"<local-command-stderr>Error: Shell command failed for pattern \"\!` — the Bash tool escapes `\": [stderr]\n/bin/bash: line 1: —: command not found</local-command-stderr>"}
```

No assistant turn. No Skill loads. No tool calls. No review.

Confirmation via the target PRs: `gh pr view <N> --json reviews` returns
`[]` for every one of PRs #225–#233. PR #224, reviewed before #217
landed, has the bot's APPROVED review.

The same preprocessor error is also visible in the `tend-mention` run
24261917519 when it loaded `running-in-ci` via the Skill tool — there
the error appeared as a tool_result and the model continued working,
because skill-load failures are non-fatal. Only the top-level
slash-command invocation is lethal.

## Gate assessment

- **Evidence level**: Critical (wrong outcome — reviews 100%
non-functional)
- **Classification**: Structural (deterministic; every invocation fails
the same way)
- **Occurrences this run**: 9 (plus 1 non-fatal skill-load collision in
tend-mention)
- **Historical evidence**: N/A — this regression was introduced by #217
earlier today and has no prior tracking entries
- **Change type**: Targeted fix (two-line comment rephrase in two files)
- **Both gates**: pass

## Fix

Rephrase the comments in
`plugins/tend-ci-runner/skills/review/SKILL.md:294` and
`plugins/tend-ci-runner/skills/running-in-ci/SKILL.md:142` to avoid any
`` \!` `` sequence. The guidance content is unchanged: "Use `||` rather
than `if`-based negation; the Bash tool escapes the exclamation mark to
a literal backslash-exclamation." No `\!` now appears adjacent to a
backtick anywhere in `plugins/`.

`grep '\!\`' plugins/` after the fix returns zero matches.

## Test plan

- [ ] A tend-review run on this PR completes with an assistant session
longer than 5 lines and posts an actual review (self-approval blocked,
but the bot must at least read the diff and comment)
- [ ] `grep -r '\!\`' plugins/` returns no matches
- [ ] `tend-mention` and `tend-notifications` skill loads of
`running-in-ci` no longer show `Shell command failed for pattern` in
tool_results

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: continuous-bot <[email protected]>
Co-authored-by: Claude Opus 4.6 <[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.

2 participants