Skip to content

fix: end the CI poll before the Claude session's timeout - #1683

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-1524-deadline
Nov 13, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-1524-deadline

Conversation

@tend-agent

@tend-agent tend-agent commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

A review that approves and then polls CI can be killed by its own timeout before the poll returns. The poll had no deadline: a hung consumer job gets GitHub's 360-minute default cap, an abandoned app check never concludes, and the Claude session's 21000 s bound always runs out first. Both runs reported on #1524 ended this way. In one, a red codecov/patch stood beside hung Actions jobs, and the approval stayed up over it for 13 hours. In the other, two Codecov checks sat in_progress until the session was killed. #1450 removed the earlier deadline "until a real run shows the case needs handling", and these two runs are that evidence.

What changes:

  • run_claude exports TEND_DEADLINE (epoch seconds) to the agent: launch time plus TEND_TIMEOUT_SEC, the point where the supervisor stops the run.
  • poll-pr-checks poll returns once checks still pend within 10 minutes of that deadline. It uses the --no-wait path's existing handling: a red already standing returns exit 1 with the still-running checks listed, so approving.md's After the approval step can dismiss on it. Otherwise it returns exit 2, unverified, naming what still pends.
  • poll-pr-checks approval stays fail-closed. When the deadline interrupts its wait on a red, it withholds. If the red has cleared by then but checks still pend, it returns undecided rather than approving.
  • monitor-ci now lists the deadline as a third early return.

Without TEND_DEADLINE, nothing changes: the poll waits as before. Four new tests in test_poll_scripts.py cover a hung check, a red beside a hung job, an approval cut short on a red, and one cut short after the red cleared. They fail on main and pass here, and the launch test now asserts the exported deadline. test_poll_scripts.py and test_run_claude.py pass (100 tests), and so does the full pre-commit run.

What this leaves for #1524:

  • Codex sessions get no deadline. That harness has no session bound of its own, only the job's timeout-minutes, which the runner doesn't read today.
  • rerun-failed-jobs still waits without a bound.

#1584 edits the same _settle loop for confirmed external reds. Whichever lands second needs a small rebase.

Refs #1524 — automated triage

The Claude harness now exports TEND_DEADLINE, when its supervisor stops
the run. `poll-pr-checks` hands back within 10 minutes of it while checks
still pend: red where a failure already stands, otherwise unverified with
the pending names. The pre-approval wait withholds on a red it was
waiting out.

Refs #1524
@max-sixty

Copy link
Copy Markdown
Owner

@tend-agent The CI poll can reach its deadline with a pending check and no remaining failed checks. If an earlier failure clears during _settle(), approval() falls through to approve: no failing check and exits 0 while the head is still unverified. Please keep approval undecided on a deadline with any pending checks, and add a focused test for that transition.

This was written by Codex on behalf of max-sixty

… cleared

If the red that started the pre-approval wait clears while other checks
still pend, a deadline return fell through to 'approve: no failing check'
on an unverified head. Return undecided instead, naming what pends.

Refs #1524
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Done in 1215db3. When the session deadline cuts the pre-approval wait short after the red has cleared, approval() now returns 2 (undecided) and lists the pending checks on stderr. Before, it fell through to approve: no failing check. A deadline that still finds a red keeps withholding as before.

The new test, test_approval_is_undecided_when_the_red_clears_but_checks_still_pend_at_the_session_end, serves a red omnibus beside a running job, then the omnibus green with the job still running. It fails on the previous head (exit 0, approve) and passes now. CI is green at the new head.

@max-sixty
max-sixty merged commit 32da23f into main Nov 13, 2026
12 checks passed
@max-sixty
max-sixty deleted the fix/issue-1524-deadline branch November 13, 2026 21:02
max-sixty added a commit to max-sixty/leaf that referenced this pull request Nov 14, 2026
Regenerates Leaf's Tend workflows with [tend
0.3.25](https://github.com/max-sixty/tend/releases/tag/0.3.25).

The change that matters here is the CI failure report's lifecycle
([max-sixty/tend#1677](max-sixty/tend#1677)).
`main` has been red since 25 Oct, and its report stayed open the whole
time, so each later failed `ci` run only added a "Failed again" comment
and new failures waited up to a day for the daily sweep. Now triage
closes the report once every failure has an owner, and the next failed
run reopens it, which starts a triage session through the ordinary
`issues: reopened` event. The workflow change itself is only
`tend-ci-failures`' comment and every action pin moving to 0.3.25; the
behavior is in the released runtime and skills.

The release also retries the uv download in `setup-runtime`
([max-sixty/tend#1666](max-sixty/tend#1666)),
where one 504 on 8 Nov left Leaf's new causes waiting 22 to 24 hours for
the next sweep, and ends a session's CI poll before the session's own
timeout
([max-sixty/tend#1683](max-sixty/tend#1683)).

> _This was written by Claude Code on behalf of max-sixty_
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Nov 15, 2026
Regenerates the Tend workflows for tend 0.3.24 → 0.3.25
([compare](max-sixty/tend@0.3.24...0.3.25)).
The diff only bumps the action pins and the generated-by header, plus a
reworded `tend-ci-failures` header comment. The behavior changes come
with the new action version.

What changes for this repo:

- **CI failure reports follow the lane's state.** Triage now closes a CI
failure report once it has diagnosed the failure and every failure has
an owner. The lane's next failure reopens the report, which starts a new
triage session instead of only adding a "Failed again" comment
(max-sixty/tend#1677). Before filing, triage also searches for an
existing cause by the full test name (max-sixty/tend#1673).
- **CI polling handles more cases.** A failed external check, such as
`codecov/patch`, now returns red once it fails on two reads 30 seconds
apart, without waiting for hung Actions jobs (max-sixty/tend#1584).
Cancelled matrix checks are superseded by a later run of the same
workflow (max-sixty/tend#1526). The poll now ends before the Claude
session's own timeout, so a session that approved and then polled CI can
still act on the result (max-sixty/tend#1683).
- **`tend check` can accept a reviewed failure.** A maintainer can list
a failing check under `checks.accepted` in `.config/tend.yaml` with a
reason. It then prints as `ACCEPTED`, no longer fails `tend check`, and
the nightly drift step treats it as a non-failure (max-sixty/tend#1662).
This is relevant to #4797 if the `release` environment's
`workflow_dispatch` exposure is judged acceptable rather than gated.
- **Setup is more robust.** `setup-runtime` retries the uv download
(max-sixty/tend#1666), and Claude Code moves to 2.1.322
(max-sixty/tend#1665).

Co-authored-by: worktrunk-bot <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 23, 2026
… reads keep failing (#1730)

`tend runtime poll-pr-checks` now ends its wait near `TEND_DEADLINE`
even while rollup reads keep failing, and reports the commit as
unverified. Before this change it waited until the harness killed the
session.

#1683 added the deadline exit to `_settle`, but only on the branch that
handles a pending rollup. Once the poll has read one complete rollup, a
failed read (`fetch_rollup` returning `None` on any `gh` error or
incomplete page) loops straight back without checking the deadline. That
holds both for the loop's main read and for the read that confirms a
settled result `CONFIRM_SEC` later. If GitHub's GraphQL stays
unavailable after a read, `poll` and the pre-approval wait in `approval`
both run until the session is killed. If the reads alternate between
complete and failed, `poll` can run past the deadline and still report
green. That is the outcome #1524 describes, which the deadline margin
exists to prevent. The caller never gets the UNVERIFIED verdict.

The fix adds the deadline check to both failed-read branches. It returns
the last complete read as `"deadline"`, and each caller already fails
closed on that:

- `poll` exits 2. When the last read had nothing pending, it now prints
`rollup unreadable on <sha>, session ends soon — UNVERIFIED, not green`
instead of a "still pending" header over an empty list.
- `approval` exits 2 (undecided) unless that read already held a red.

The regression test
`test_unreadable_rollups_at_the_session_end_hand_back_unverified` serves
one complete read, then failed reads, with the deadline inside the
margin, for both commands. Before the fix both hit the test harness's
sleep limit (`WaitNeverEnded`). With it, both exit 2.
`test_failed_confirmations_at_the_session_end_hand_back_unverified`
alternates four complete reads with failed confirmations, then serves a
complete one. Before the fix `poll` reported green on the ninth read.
With it, `poll` exits 2 after the second read. The rest of
`test_poll_scripts.py` passes (103 tests), and so do the pre-commit
hooks on the changed files.

Refs #1524

---------

Co-authored-by: tend-agent <[email protected]>
max-sixty pushed a commit that referenced this pull request Nov 27, 2026
…1748)

Codex runs now get the same session bound as Claude runs. The CI poll
can therefore hand back before a Codex job dies, as #1683 and #1584 made
it do for Claude.

- **Supervisor.** `codex exec` now runs under the supervisor Claude
uses: a TERM to the process group when the bound passes, a 5-second
grace, then a KILL. The supervisor moved unchanged from `run_claude.py`
to `tend.runtime.shared.supervise`. A stream with no file given is
inherited, so Codex output still goes to the job log.
- **Bound and deadline.** `codex/action.yaml` gains a `timeout_seconds`
input with Claude's default of 21000 s and passes it as
`TEND_TIMEOUT_SEC`. The runner exports `TEND_DEADLINE` (now + bound,
from the same `supervise.deadline` Claude uses) and lowers
`background_terminal_max_timeout` from 6 h to the bound, matching
Claude's `BASH_MAX_TIMEOUT_MS`. A timed-out run prints the `Supervisor:
status=timeout …` line and fails with `::error::Codex run exceeded <N>s
timeout`.
- **Tests.** The poll's deadline tests in `test_poll_scripts.py` now
take `TEND_DEADLINE` from each harness's real entry point
(`run_claude.main` and `codex_runner.run_codex`, with the launch faked),
parametrized `[claude]`/`[codex]`. With the runner change reverted, the
`[codex]` cases fail because no `TEND_DEADLINE` crosses. New runner
tests cover the exported deadline and the timeout failure. The sandbox
lifecycle test (`proxy/test-setup-sandbox.sh`) now launches Codex with a
bound and checks that `TEND_DEADLINE` reaches the Codex process.

Locally, the full Python suite passes except the two
`test_refresh_consumers.py` tests that need DNS, which the sandbox
lacks. `pre-commit run --all-files` is clean, and CI is green at
`dbc10c7f`.

Closes #1524

---------

Co-authored-by: tend-agent <[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