Skip to content

fix(generator): cap every generated job with timeout-minutes - #1023

Closed
tend-agent wants to merge 4 commits into
mainfrom
fix/issue-962-job-timeouts
Closed

tend-agent wants to merge 4 commits into
mainfrom
fix/issue-962-job-timeouts

Conversation

@tend-agent

@tend-agent tend-agent commented Aug 20, 2026 •

Copy link
Copy Markdown
Collaborator

No generated job declared timeout-minutes, so a step that wedged rather than ended was bounded only by GitHub's 360-minute default — and on a job with cancel-in-progress: false it held the concurrency queue for the same six hours. This stamps a job-level cap on all eleven generated jobs, using the measured values from PRQL/prql#6215, and derives the Claude harness's own session budget from each cap so the two kills stay ordered. Verified by rendering every workflow and asserting each job's cap and each agent step's budget (uv run pytest, 572 passed; pre-commit run --all-files clean).

A job cap is the only bound that reaches the whole job. The harness supervisor's timeout_seconds starts once the action is entered, so checkout, the adopter's setup:, and the CLI installers sit outside it — which is exactly where the five observed six-hour wedges in #962 landed, in an adopter setup composite's unbounded apt-get update. timeout-minutes is not accepted on a step inside a composite action, so the generated job is the only lever that reaches there.

The cap alone would have made the supervisor unreachable, since every value sits below the claude action's 21000s timeout_seconds default — and the two kills are not equivalent. The supervisor exits 1, so the job is failure and the action's failure()-gated Report failure step files the tend-outage row that review-runs drains to re-run stranded triggers; GitHub's timeout-minutes kill yields cancelled, where failure() steps are skipped and the overrun goes unreported. So the cap is also threaded into agent_step, which emits timeout_seconds 10 minutes under it: the supervisor still owns an agent-session overrun, and the job cap backstops the pre-agent region it cannot reach.

Adopter overrides are unchanged and still win: workflows.<name>.jobs.<job>.timeout-minutes now replaces the default in place rather than appending, so an override lands next to the comment documenting what it replaced. It moves the job cap alone — step inputs take no override, so the generated supervisor budget stays put, which degrades to the reported kill rather than the silent one.

Closes #962.

Caps, budgets, and how they're wired
workflow job timeout-minutes timeout_seconds (claude)
tend-ci-fix fix-ci 60 3000
tend-notifications notifications 60 3000
tend-weekly weekly 60 3000
tend-review review 120 6600
tend-mention handle 120 6600
tend-triage triage 120 6600
tend-review-runs review-runs 120 6600
tend-nightly nightly 180 10200
tend-mention relay 10 —
tend-mention verify 10 —
tend-install-test install-test 10 —

Both numbers come from a single _JOB_TIMEOUT_MINUTES entry per workflow in workflows.py, so the cap and the budget cannot drift apart. A job_timeout(minutes) macro in macros.yaml.j2 emits the cap plus a two-line override pointer, and agent_step takes the same value and emits the derived budget inside its claude branch; codex emits nothing, having no supervisor timeout. The three jobs with no agent step take a literal cap in their template.

The ordering the derivation buys holds while the steps ahead of the agent fit inside the 10-minute margin; past that the job cap wins and the kill is silent again — but that is the pre-agent region timeout-minutes exists to bound in the first place, and it is the case this PR was written for.

Test changes:

  • test_every_job_declares_a_timeout — every generated job must carry a cap under 360, since at or above that GitHub's default is the operative bound again. The corpus opts in ci-fix and install-test and asserts it is every workflow, so a skipped one can't quietly fall out of coverage.
  • test_agent_budget_expires_before_the_job_cap — every claude agent step's timeout_seconds must be under its job's cap, with the corpus pinned to GENERATORS.
  • test_codex_agent_step_takes_no_supervisor_budget — the codex branch emits no timeout_seconds.
  • test_mention_job_extras_target_specific_job probed "extras hit only the named job" by asserting timeout-minutes was absent from verify. With a default on both jobs, untouched now means the default survives, so it asserts verify is still 10 while handle takes the override's 180.

Snapshot churn is the eleven caps, the eight budgets, and their comments; the one non-additive line is the extras snapshot, where the override moved from the end of the job to the base key's position.

This repo's own .github/workflows/tend-*.yaml are deliberately not regenerated here — per CLAUDE.md the action ref pins the generator's own version, so regenerating in-tree would stamp an unreleased tag. They pick this up at the next release plus nightly regen.

No generated job declared `timeout-minutes`, so a wedged step was bounded
only by GitHub's 360-minute default — and on a job with
`cancel-in-progress: false` it held the concurrency queue for the same six
hours. The harness supervisor's `timeout_seconds` doesn't reach it: it
starts once the action is entered, leaving checkout, the adopter's
`setup:`, and the CLI installers outside any bound.

Caps come from the measured values in PRQL/prql#6215: 60 for ci-fix,
notifications and weekly; 120 for review, triage, review-runs and
mention's handle; 180 for nightly; 10 for mention's relay and verify.
Adopter overrides still win via workflows.<name>.jobs.<job>.timeout-minutes.

Closes #962.

@tend-agent tend-agent 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.

The caps themselves look right — every one sits well above what this repo actually runs (recent maxima: nightly 52 min, review-runs 57, triage 25, weekly 25, review 23, mention 13). One interaction is worth resolving before this lands.

A capped-out job is cancelled, not failed, so it files no outage row. Generated workflows never pass timeout_seconds, so the claude action's default of 21000s (5h50m) applies and every new cap sits below it — the supervisor's timeout) branch is now unreachable at defaults. That matters because the two kills produce different job conclusions: the supervisor exits 1 (job failure), while GitHub's timeout-minutes kill yields cancelled with failure() steps skipped. The Report failure step in both claude/action.yaml and codex/action.yaml is gated if: failure() && steps.security.outcome != 'failure', and it's what runs report-failure.sh — the script that files or appends the tend-outage row that review-runs later drains to re-run stranded triggers.

So for a claude agent session that overruns its cap, this swaps a reported failure (outage row, stranded trigger re-run) for a silent cancellation. For the case the PR is actually written for — a wedge in checkout/setup:/installers — nothing is lost: that region was always outside the supervisor, so it was already a silent 360-minute cancel, and cutting it to 60/120/180 and freeing the concurrency queue is the whole win. It's only the agent-session overrun that regresses, and only on claude (codex has no supervisor timeout to preempt).

The fix that keeps both purposes is one parameter: thread the cap into agent_step and emit timeout_seconds: <(cap - 10) * 60>, so the supervisor kills the agent first (job red, row filed) and timeout-minutes stays a true backstop for the region it can't reach. Alternatively, accept the silence and say so in the macro comment — but flipping the step's gate to catch cancellations isn't an option, since triage runs cancel-in-progress: true and would file an outage row on every superseded run.

How the conclusion was verified

Probed on tend-agent/tend-integration (probe workflow since removed): a job with timeout-minutes: 1 and a sleep 300 step.

run conclusion:  cancelled
job conclusion:  cancelled
  wedge        cancelled
  on-failure   skipped     # if: failure()
  on-always    success     # if: always()

always() steps do run, so the log upload and the eyes-reaction removal survive a capped-out job — it's specifically the failure()-gated failure report that doesn't.

Supporting reads: timeout_seconds default and the supervisor's timeout) branch in claude/action.yaml; Report failure in both action files; the header of shared/steps/report-failure.sh on what the row is for; rg timeout_seconds generator/ returns only the new macro comment, confirming nothing passes it.

`generate_all` skips install-test unless `with_install_test=True`, so the
new every-job-has-a-cap test never saw it and the job shipped uncapped.
It runs `uvx tend init` behind `setup-uv` — the same pre-agent install
region the observed wedges came from.

Caps it at 10 and builds the test's corpus with the flag set, asserting
the corpus is every workflow, matching test_operational_secrets_imply_
environment.

@tend-agent tend-agent 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.

The install-test cap and the corpus assertion both look right — generate_all really did skip that job, and pinning the corpus to GENERATORS is what keeps the next added workflow from slipping past the invariant silently. One wording point on the comment that ships with it.

# validation isn't worth special-casing.
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-24.04
# Bounds the whole job, adopter `setup:` included. Override with

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.

install-test is the one generated job that renders no adopter setup: — its steps are a fixed checkout + setup-uv + the drift check, with no _setup_yaml interpolation — so the clause points at something that isn't in this file. Keeping the macro's wording identical everywhere is the right call for the eight jobs that do render setup:; this f-string copy is the one place where trimming it costs nothing.

Suggested change
# Bounds the whole job, adopter `setup:` included. Override with
# Bounds the whole job. Override with

Every new job cap sits below the claude action's 21000s `timeout_seconds`
default, so the supervisor's timeout branch became unreachable in a
generated workflow. The two kills are not equivalent: the supervisor exits
1, so the job is `failure` and the action's `failure()`-gated `Report
failure` step files the `tend-outage` row that review-runs drains to re-run
stranded triggers. GitHub's `timeout-minutes` kill yields `cancelled`,
where `failure()` steps are skipped and the overrun goes unreported.

Threads the job cap into `agent_step` and emits `timeout_seconds` 10
minutes under it, so the supervisor still owns an agent-session overrun and
the job cap backstops the pre-agent region it cannot reach. Both bounds now
come from one `_JOB_TIMEOUT_MINUTES` entry per workflow, so they cannot
drift apart; `_SCHEDULED_TIMEOUT_MINUTES` folds into it.

@tend-agent tend-agent 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.

The derivation itself holds up: agent_step takes the cap positionally at every call site, _JOB_TIMEOUT_MINUTES keys match GENERATORS exactly (so a new workflow with no entry is a loud KeyError, not a silent default), and the rendered budgets are 3000/6600/10200s under the 60/120/180-minute caps. Two holes in the new invariant tests, and one doc-scope point, all inline.

The test suggestions are verified — I applied both against this head and ran uv run pytest generator/tests/test_generate.py -k "budget or supervisor", 2 passed. Worth noting for the codex one: pinning that corpus to GENERATORS the way the claude test does fails, because generate_all skips ci-fix without watched_workflows; pinning to what generate_all actually yielded is what works there.

Comment thread generator/tests/test_generate.py Resolved
Comment thread generator/tests/test_generate.py Resolved
Comment thread docs/tend.example.yaml Resolved
…corpus

The budget invariant only pinned the upper bound, so a _JOB_TIMEOUT_MINUTES
entry of 10 or less renders a zero-or-negative budget that passes: that value
inverts the supervisor rather than disabling it, firing its poll on the first
iteration. The codex test could pass vacuously if the step's shape moved, so
pin its corpus to GENERATORS the way the claude test does — which needs the
same watched_workflows extra, since generate_all skips ci-fix without it.

Both example.yaml copies and the job_timeout macro comment covered only the
raise direction of a timeout-minutes override; lowering it under the generated
budget is the direction that puts the supervisor out of reach again.
@max-sixty

Copy link
Copy Markdown
Owner

Closing because #1024 now classifies distributed timeout settings as a configuration scheme, and PRQL/prql#6216 reverted the adopter change used to derive these values.

This was written by Codex on behalf of max-sixty

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.

review: cancel-in-progress: false with no timeout-minutes lets a wedged run hold the per-PR queue for the full 360-min job cap

2 participants