Skip to content

Wait for CI to settle instead of a 9-minute cap, and replace other guessed limits - #1448

Merged
max-sixty merged 10 commits into
mainfrom
poll-budget-constants
Sep 29, 2026
Merged

max-sixty merged 10 commits into
mainfrom
poll-budget-constants

Conversation

@max-sixty

@max-sixty max-sixty commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

The CI poll gave up after 9 minutes. That figure came from #695, which trimmed the poll loop to fit Claude Code's default 10-minute ceiling on one Bash call; #876 then forbade re-running it. So a harness default set how long every session waits for a consumer's CI. On the last 30 merged PRs of each consumer, the slowest check outlasted it on every PR in leaf (15 min), numbagg (17 min) and worktrunk, and on about a third of PRQL's and Faber2026's. There the poll reports UNVERIFIED, so under merge: yolo the bot never merges (leaf-agent has merged none of its PRs), and a red check never dismisses a bot approval.

This PR removes the limit, and fixes the other places where a guessed count or window bounded a decision.

The CI poll waits for the checks, not a fixed time

poll_pr_checks.py now waits until the checks settle, however long the repo's CI runs: a running check ends by its own job timeout. Three states have no such end, and each is ended by the event that shows it:

  • checks still pend and the PR head moves off the pinned commit: exit 3, UNVERIFIED. The commit can no longer merge, and a review of the new head is queued behind this session. review/SKILL.md already asked for this.
  • no check registers within 5 minutes: exit 2. A docs-only PR whose workflows are all path-filtered looks the same as checks not registered yet; the margin covers GitHub's registration lag, not CI.
  • the session nears its end: exit 3, UNVERIFIED. A check that registers and never finishes (a CLA status left pending, a job waiting on an environment approval) would otherwise hold the wait until the session is killed, with nothing reported on the PR and an outage issue filed. Each harness exports TEND_DEADLINE, when the session will be stopped: Claude's supervisor bound, or for Codex GitHub's 6-hour job cap less 10 minutes. The poll hands back 10 minutes before it, so the session can still report.

The harness ceiling was configurable all along. Claude runs set BASH_MAX_TIMEOUT_MS to the run's timeout, and Codex runs raise background_terminal_max_timeout. Codex's instructions (codex/agents-tail.md) now say to wait on a running command in one write_stdin call: leaf's session polled every 30 s, 19 model turns of ~100k cached tokens for one 9-minute wait. The skills give the poll the longest command timeout the harness allows, and a test keeps a numeric one from coming back.

approval() loses its cancelled-run heuristic, which existed only to decide a red still standing at the cap; waiting now reaches the replacement run's result. rerun_failed_jobs.py waits for its jobs the same way, and ends at the same deadline.

Other fixed caps

  • Dedup by search, not a recent-N scan. ci-fix, triage, review-runs and review-reviewers listed the newest 200 issues or PRs and scanned the titles. On leaf the newest 200 PRs reach back two days, so ci-fix's "was this fix already rejected?" check missed anything older, and triage's open-issue list already truncates on PRQL (234 open). They now search by keyword, which matches titles and bodies at any age. ground-claims states the rule. open-pr's sibling recheck keeps its recency listing, with a projection small enough to show in full.
  • bot_review_state.py read the first 100 review threads, oldest first; it now follows every page.
  • review_runs_corrections.py took the newest 200 bot PRs and then filtered to those closed in the window, missing an older PR a maintainer closed that day. It now searches closed:>=<since>.
  • nightly reviewed git log --since='24 hours ago' main: a skipped night lost its commits, and a repo whose default branch isn't main reviewed nothing. It now reviews from the last successful nightly's head.
  • review-runs paginates its waiting-run and Dependabot-alert reads, and ci-fix's tracker lookups read 100 rather than 10.

Tests pin each change; the poll tests run on a fake clock that raises if a wait never ends. A local codex exec probe confirmed a 400 s command waited out in 3 tool calls rather than about 13.

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

🤖 Generated with Claude Code

max-sixty and others added 8 commits September 28, 2026 18:50
…ault timeout

The CI poll's 9-minute budget came from #695, which trimmed the loop to fit
Claude Code's default 10-minute Bash-tool ceiling; #876 then made that budget
terminal. So one harness default became the longest any session waits for a
consumer's CI. Measured on the last 30 merged PRs of each consumer, the
slowest check exceeds it on every PR in leaf (15 min), numbagg (17 min), and
worktrunk, and on a third of PRQL's and Faber2026's — the poll reports
UNVERIFIED there, so yolo never merges and a red check never dismisses an
approval.

The ceiling was configurable all along. Both harnesses now let one foreground
command run for the whole session: Claude through BASH_MAX_TIMEOUT_MS set to
the run's timeout, Codex through background_terminal_max_timeout, with the
Codex instructions telling the agent to wait on a running command in one
write_stdin call rather than 30-second polls that each cost a model turn.

The wait itself becomes WAIT_SEC = 30 minutes, shared with
rerun_failed_jobs.py, above the slowest gating check measured across
consumers (26 min). The skills pass a 40-minute command timeout, and a test
keeps every skill-named timeout above the script's own bound.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bot_review_state.py read the first 100 review threads, oldest first, so on a
PR past 100 the bot's newest findings dropped out of both its feedback and
its unresolved-thread list. It now follows every page with
`gh api graphql --paginate`.

review_runs_corrections.py listed the bot's newest 200 PRs and then kept the
ones closed inside the window, so an older PR a maintainer closed that day
was never seen; on worktrunk the 200th bot PR is two months old. It now
searches `closed:>=<since>` directly, and both searches read to GitHub's
1000-result search ceiling.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ting

Several dedup checks listed the newest 200 issues or PRs and scanned their
titles. That window is measured in bot throughput: on leaf the newest 200 PRs
reach back two days, so ci-fix's "was this fix already rejected?" check
missed any rejection older than that, and triage's open-issue list already
truncates on PRQL (234 open issues). The review-runs and review-reviewers
lists also carried every body, overflowing what the harness shows inline.

ci-fix, triage, review-runs, and review-reviewers now search by keyword,
which matches titles and bodies at any age; ci-fix still lists open PRs,
which stay few. ci-fix's tracker lookups read up to 100 instead of 10, and
its 7-day transient count moves the window into the search, where a
truncated page can no longer read as a short one. ground-claims states the
rule, and open-pr's sibling recheck drops to the projection ground-claims
sizes for 200 rows. review-runs paginates its waiting-run and Dependabot
alert reads.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
A 30-minute wait holds the session's concurrency group, and a review of a
newly pushed head queues behind it. review/SKILL.md already said to stop
polling a stale commit, which one foreground command couldn't do. The poll
now re-reads the head after each read that still has checks pending, and
exits 4 (UNVERIFIED) once it has moved: a merge requires the pinned commit
to be the head, and the new head is its pusher's to verify. A rollup that
settles is still reported as the pinned commit's, with the move noted.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…he last 24 hours

Step 4 reviewed `git log --since='24 hours ago' main`, so a night that was
skipped, failed, or paused under TEND_ENABLED dropped its commits for good,
and a consumer whose default branch isn't `main` reviewed nothing. It now
diffs from the previous successful tend-nightly run's head to the default
branch, falling back to the last 24 hours when there is no earlier success
or its commit has left history.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The 30-minute WAIT_SEC was still a guess at how long a consumer's CI runs,
and any guess strands the repos whose CI outlasts it. No limit is needed:
each running check ends by its own job timeout, so the poll now waits until
the checks settle, however long that takes. Only two states have no such
end, and each ends at the event that shows it:

- checks pend and the PR head has moved off the pinned commit (exit 3):
  the commit can no longer merge, and a review of the new head is queued;
- no complete rollup for five minutes: the commit has no check coming.
  That margin covers GitHub's registration lag, not CI.

A check that registers and never finishes holds the wait until the
session's own timeout, which then reads as a timed-out run.

approval() drops its cancelled-run heuristic, which existed only to decide
a red still standing at the cap: the wait now reaches the replacement run's
result. rerun_failed_jobs.py waits for its jobs the same way. The skills
give the poll the longest command timeout the harness allows instead of a
number, and a test keeps a numeric one from coming back.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

A check that never settles now costs a 6-hour runner and an outage issue, and the session never reports the unverified state on the PR.

launch_argv sets BASH_MAX_TIMEOUT_MS to TEND_TIMEOUT_SEC, which is the same bound supervise() kills at. So when the poll takes the longest timeout the harness allows, the command timeout can't fire before the supervisor kills the whole session. Take a check that registers and never finishes. Examples: a CLA status left PENDING on an external contributor's PR, a deploy job WAITING on environment approval, or a job queued for a runner label nobody serves. In each case the flow runs like this:

  • The post-approval poll never returns, so the session never gets to report what it couldn't verify. monitor-ci's "any other exit or command timeout is unverified" path is now unreachable under Claude.
  • The supervisor kills the session at ~5h50m. The step goes red, and report_failure.py files or appends to a "Bot temporarily unavailable" tend-outage issue for what was really a stuck consumer check.
  • The concurrency group stays held the whole time: per PR for tend-review and tend-mention, and repo-wide for tend-notifications. Later events on that PR queue up behind it. Since only one run can wait in the pending slot, each newer event replaces the one already waiting.

Part of what the old cap covered is still needed: returning control to the agent while it still has time to act. A bound that isn't a guess would be the session's own deadline. Export the run's deadline into the agent's env, and have _settle / rerun_failed_jobs return exit 3 ("still pending at the session deadline — UNVERIFIED") with a margin of a few minutes left. That keeps the long waits this PR is after for leaf/numbagg/worktrunk, and still lets a stuck check end the way it did before: reported on the PR, not as an outage.

A check that registers and never finishes held the poll until the harness
killed the session: nothing reported on the PR, an outage issue filed, the
concurrency group held. Each harness now exports TEND_DEADLINE, when the
session will be stopped, and the poll and the rerun wait end 10 minutes
before it, reporting the checks still pending as unverified.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@tend-agent tend-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

TEND_DEADLINE fixes the concern from the earlier review. One case in the new approving.md bullet still needs a decision.

When the post-approval poll reaches the deadline, its exit 3 can also list "failures observed so far" next to the check that never settled. For example, a test job goes red while a CLA status stays PENDING. The poll waits about 5h40m and then returns exit 3. The new bullet says the approval stands "as for a cancelled check", so the bot's approval stays up over a red test, and the session only names the stuck check as unverified.

The "unconfirmed" label on those failures exists for cancellation cascades, where a replacement run is expected to supersede the red. A failure that has stood for hours next to a stuck check almost certainly isn't one of those. The suggestion sends those failures back through the existing red-check handling.

@max-sixty
max-sixty merged commit bb5ca16 into main Sep 29, 2026
13 checks passed
@max-sixty
max-sixty deleted the poll-budget-constants branch September 29, 2026 08:27
max-sixty added a commit that referenced this pull request Sep 29, 2026
…rotate nightly's issue sweep, name relayed mention runs, drop the session deadline (#1450)

Follow-ups to #1448, which dropped the fixed CI-wait budget. Five
changes:

**Overlays can leave checks out of the CI gate.** `poll_pr_checks.py
poll` and `approval` take trailing `--skip '<check name>'` pairs; a
skipped check is neither waited for nor read, so an advisory red neither
blocks the CI verdict nor withholds the approval. The default is
unchanged — every check gates — and `monitor-ci` tells the session to
pass `--skip` only where the repo's overlay names checks; `approving.md`
passes the same ones.

**code-review ranks by severity, not a count.** The "up to 4/6
candidates" and "at most 10" caps are gone; the reviewer returns every
finding the author would change the code for, most severe first, and the
bar is severity rather than list length.

**nightly's issue sweep covers every open issue.** Step 5 read the
newest 200 open issues, so older ones were never revisited. It now
paginates all open issues: the bot's own every run, so a transient
report it filed still closes the night after its fix, and the rest by
the bucket `number % 7 == GITHUB_RUN_NUMBER % 7`, visiting each at least
once a week.

**Relayed mention runs are named for their PR.** A review event relayed
to `tend-mention` ran with the display title `tend-mention-review`,
which `active_subject_runs.py` couldn't tie to the PR, so the
notifications poll booted a session for a subject a live run already
held. The relay now passes the PR title in `client_payload`, and
`tend-mention` sets `run-name` from it. `run-name` also replaces the
run's `name` in the Actions REST API, so everything that identified a
workflow by its run name now reads `path` (`active_subject_runs.py`) or
`workflowName` (`token_report.py`, `list_recent_runs.py`,
`debug-tend-run`, `review-runs`). The notifications check's 10-minute
grace stays, with a comment giving its actual purpose: not booting a
session that would only defer to the event run still holding its
subject.

**The session deadline from #1448 is removed.** `TEND_DEADLINE`,
`session_end.py`, and the poll's deadline exit are gone. A check that
registers and never finishes now holds the wait until the session's own
timeout ends the run, which reads as timed out. This keeps the machinery
minimal until a real run shows the case needs handling.

> _This was written by Claude Code on behalf of max-sixty_

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Sep 29, 2026
#1451)

The weekly integration test waited for the integration-secrets,
tend-triage, and tend-review runs by polling a fixed number of times (5
minutes for the secrets reseed, 10 for each session), so a session that
ran longer read as a failure. Each of those waits now polls until the
run completes, with no count cap. The recipe says to run each wait in
the foreground with the longest command timeout the harness allows, the
same contract `monitor-ci` gives `poll_pr_checks.py`. Once a release
carries #1448's `BASH_MAX_TIMEOUT_MS`, that ceiling is the session's own
timeout.

The loops keep polling rather than using `gh run watch`: `run-tend`'s
bundled **Hanging commands** rule forbids it, and it exits non-zero on a
transient API error, which would report a flaky read as a failed run. A
failed `gh run view` in the loop leaves the status empty and it reads
again.

§1 also drops its baseline-and-poll registration loop: since gh 2.87,
`gh workflow run` prints the dispatched run's URL when piped (the
ubuntu-24.04 image ships 2.101). The triage and review registration
loops stay, since an issue or PR event returns no run id. §6's single
budget is unchanged: it covers the relay hop plus a session that exits
immediately.

> _This was written by Claude Code on behalf of max-sixty_

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Sep 30, 2026
Upgrades the generated Tend workflows from 0.3.4 to 0.3.5
([compare](max-sixty/tend@0.3.4...0.3.5)).
The regenerated YAML changes little on its own: the action pin moves to
`max-sixty/tend/[email protected]`, and most of the behavior change arrives
through the new action's bundled skills and scripts.

What maintainers will notice:

- **Bot PRs get their review findings applied.** The review workflow now
decides whether to apply its own findings by who authored the PR, so a
review on a bot-authored PR follows through with a fix instead of
stopping at the comment (max-sixty/tend#1433).
- **Relayed PR-review mentions are named after the PR.** `tend-mention`
runs triggered through `tend-mention-relay` now get the PR title as
their run name rather than the event type, and the notifications poll
uses that name to tell which PR a live run is handling
(max-sixty/tend#1450). The relay job also skips when `TEND_ENABLED` is
`false`, instead of dispatching a run that does nothing
(max-sixty/tend#1452).
- **CI waits run to completion instead of a fixed cap.** CI polling and
integration-test waits now wait for checks to settle instead of timing
out at about 9 minutes, so a slow matrix reports its real result rather
than "unverified" (max-sixty/tend#1448, max-sixty/tend#1451).
- **Fewer truncated listings.** Pagination now reads every page of
notifications, failed-run jobs, and workflow listings
(max-sixty/tend#1435, max-sixty/tend#1442, max-sixty/tend#1457). The
inline pagination helpers in `tend-mention` and `tend-notifications` now
use `gh api --paginate --slurp`.
- **Weekly dependency review matches Dependabot and Renovate PRs
again.** It now matches on the `app/…` author login that `gh` reports
(max-sixty/tend#1441).
- **Nightly and review behavior.** Repo overlays can now skip advisory
checks, review findings are ranked by severity, and the nightly issue
sweep rotates across issues (max-sixty/tend#1450). `ci-fix` recurrence
comments now lead with what changed (max-sixty/tend#1446).

Also bumps the pinned `uv` from 0.12.17 to 0.12.19 in the pre-check
steps. `.config/tend.yaml` has no model pin, so there was no model to
update.

Co-authored-by: worktrunk-bot <[email protected]>
max-sixty added a commit to max-sixty/leaf that referenced this pull request Oct 1, 2026
#1162)

Update the generated Tend workflows from 0.3.2 to 0.3.5. The 0.3.3
refresh workflow moves credential rotation into a dedicated
`tend-codex-refresh` environment, separate from agent jobs. The 0.3.4
action update makes feature-request triage replies more useful and marks
notifications read after answered relayed PR reviews. It also improves
repository-specific refresh PAT setup and handles shells that force
colored `gh` output. The obsolete `control_plane_owner` generator
setting is removed; the existing CODEOWNERS rule still requires a fresh
owner approval.

0.3.5's CI poll waits for checks to settle rather than giving up after 9
minutes, which [#1441](#1441)
depends on; it also names relayed mention runs for their PR and stops
the relay while Tend is paused.

The refresh credentials are already provisioned: `tend-codex-refresh`
admits only `main` and holds `CODEX_REFRESH_AUTH_JSON` and
`CODEX_REFRESH_PAT`, and `tend` no longer holds copies. Fresh
control-plane owner approval is required.

[Upstream
changes](max-sixty/tend@0.3.2...0.3.5),
including
[max-sixty/tend#1418](max-sixty/tend#1418),
[max-sixty/tend#1448](max-sixty/tend#1448),
[max-sixty/tend#1450](max-sixty/tend#1450), and
[max-sixty/tend#1457](max-sixty/tend#1457).

---------

Co-authored-by: leaf-agent <[email protected]>
Co-authored-by: Maximilian Roos <[email protected]>
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
max-sixty added a commit that referenced this pull request Nov 27, 2026
… harness meets them (#1751)

Follows #1676: tend's instructions should say what a session must
achieve and leave out how a harness gets it there, since harness
mechanics go stale between releases. This removes six passages that
describe harness mechanics, and adds the rule that keeps new ones out.

- **The `.claude/skills/` write workaround** in propose-instructions and
review-runs (read-only mount, harness write-guard, write to `$TMPDIR`
then `mv`) no longer holds. anthropics/claude-code#37157 was fixed in
2.1.126 and tend pins 2.1.330. A probe on 2.1.332 wrote into
`.claude/skills/` with no denial, and the mount went with the sandbox
runtime in #1354. If that probe misled us, the edit fails visibly.
Tend's own running-tend overlay loses its pointer to the workaround too.
- **ground-claims' 32 KB threshold** was measured on Claude only. The
rule to project narrowly stays.
- **run-tend's "the harness does not load them…" clause** explains a
rule that stays.
- **Three asides** that the tools' own descriptions already carry.

propose-instructions' "What the text carries" gains the rule.
AGENTS.md's "Mechanics ship freely" narrows to match: it is the clause
that let #1676's first draft through.

Kept: Codex's `yield_time_ms` waits (#1448, #1641), reading skills in
full with `cat` (#551), absolute paths for file-writing tools, and the
command timeouts.

pre-commit passes locally; CI runs the suite.

> _This was written by Claude Code 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.

2 participants