Skip to content

fix: return confirmed external CI failures before Actions jobs finish - #1584

Merged
max-sixty merged 4 commits into
mainfrom
fix/issue-1524
Nov 14, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fix/issue-1524

Conversation

@tend-agent

@tend-agent tend-agent commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

A failed external check could leave the review waiting on hung Actions jobs until the harness killed it, preventing the review from handling the failure and dismissing its approval. The poll now returns RED when the same external failure survives two reads 30 seconds apart, naming the jobs still pending. The pre-approval guard uses the same confirmation and withholds approval.

External checks are commit statuses not linked to an Actions run, or checks from an identified non-Actions app with no workflow run. A status whose target URL is an Actions run stays on the wait path, since a cancelled run can only report it as failure or error. Missing provider metadata stays on the existing wait path. An early result includes only the confirmed external failures, so an Actions cancellation-cascade failure beside them is not presented as confirmed.

The new regression failed before the change for both commit statuses and Codecov-style app checks, in both polling and approval. All 99 poll and landing-helper tests pass, as does the full pre-commit suite. The GraphQL app/workflow fields were also exercised against the live API. A subsequent full Python run passed 1,589 tests; the two consumer-refresh tests failed because their subprocesses could not resolve PyPI, the sandbox limitation documented in AGENTS.md.

This implements option 2 in the report. A poll with only Actions failures and pending jobs still waits; a general session deadline remains outside this patch, so the issue stays open for that broader case.

Refs #1524 — automated triage

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

Every commit status counts as external here, but GitHub Actions workflows also post commit statuses. A gate step with if: always() that calls the statuses API is a common pattern, and statuses have no cancelled state: when a concurrency group cancels that run, the step can only report failure or error, and a replacement run then pends beside it. That status survives the 30-second confirmation, so the poll returns red and approval withholds, which is the cancellation cascade the wait exists to absorb. I'll push a fix that treats a status whose targetUrl points at an Actions run (/actions/runs/) as an Actions check, with a regression test.

#1526 also edits reduce_rollup and the rollup query (a different fix, not a duplicate), so whichever lands second will need a rebase.

max-sixty pushed a commit that referenced this pull request Nov 13, 2026
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

---------

Co-authored-by: tend-agent <[email protected]>
# Conflicts:
#	generator/src/tend/runtime/ci/poll_pr_checks.py
@max-sixty
max-sixty merged commit af5089e into main Nov 14, 2026
12 checks passed
@max-sixty
max-sixty deleted the fix/issue-1524 branch November 14, 2026 07:00
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 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