Files
PaperClipAI/.github/scripts/tests/fixtures/runner-loss-rerun/run-43325855069.json
DottaandClaude Fable 5.2 c4f639ed1b fix(ci): re-run cancelled runs that lost a runner, and let runner-loss evidence win (#21291)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - PR CI runs about 50 jobs per run on AWS spot instances. AWS can
reclaim a machine mid-job, and the job dies.
> - `ci-runner-loss-rerun.yml` re-runs such a run once, automatically,
when every failed job lost its runner.
> - In a 17-hour sample, 42 runs lost a runner and were still the PR's
current head. The automation rescued only 14.
> - Two gaps caused most of the misses. A spot reclaim on RunsOn v3.2.3
usually ends the job, and the run, as `cancelled`; the workflow and
script only look at `failure`. Also, the Runner support suite always
carries `gateway_indexing_incomplete` error annotations from a passing
test, so a lost runner there reads as a real failure.
> - On-demand fallback for the fleet was turned off on 2026-11-13, so
reclaims will happen more often. About 20% of runs are expected to lose
at least one job.
> - This pull request makes the re-run act on cancelled runs and jobs,
but only with positive runner-loss evidence, and lets that evidence win
over other error annotations.
> - The benefit is fewer manual "Re-run failed jobs" clicks: an
estimated 34 of 42 instead of 14 of 42 in the sample.

## Linked Issues or Issue Description

No public issue exists.

**What happened?**
Run
[43285064435](https://github.com/paperclipai/paperclip/actions/runs/43285064435)
lost the runner of `ci / General tests (server (8/12))`. The job
concluded `cancelled` (its log has `##[error]The runner has received a
shutdown signal`). The run concluded `cancelled`, so the re-run
workflow's `if:` skipped it.

Run
[43325855069](https://github.com/paperclipai/paperclip/actions/runs/43325855069)
lost the runners of `ci / Runner support suite` and `ci / General tests
(server (2/12))`. Both logs have the shutdown signal. The re-run bot
([decision
log](https://github.com/paperclipai/paperclip/actions/runs/43327873358))
said "1 of 1 failed jobs did not lose their runner", with evidence
`gateway_indexing_incomplete`. It ignored the cancelled job. It read the
annotation as a real failure.

**Expected behavior**
Both runs get one automatic re-run of their failed jobs.

**Steps to reproduce**
The new tests replay trimmed snapshots of both runs
(`.github/scripts/tests/fixtures/runner-loss-rerun/run-43285064435.json`
and `run-43325855069.json`) through the script.

In a 17-hour sample on 2026-11-12, 42 runs lost a runner and were still
the PR's current head. Only 14 were re-run automatically. 16 stayed red
because the run concluded `cancelled`. 4 stayed red because an error
annotation in the lost job was read as a test failure.

**Additional context**
The `gateway_indexing_incomplete` annotation does not come from the
shutdown. `scheduled-gateway-indexing.test.ts` prints `::error` lines
while it passes, 84 seconds before the shutdown signal in this run.
Attempt 2 of the same run passed with the same two failure annotations.
So, before this change, a lost runner in the Runner support suite could
never be re-run.

## What Changed

- `ci-runner-loss-rerun.yml`: the job also runs when the PR run
concluded `cancelled`. The trigger type, `permissions`, the repository,
path, event and attempt-1 conditions do not change.
- `runner-loss-rerun.mjs`, `eligibleRun`: accepts `completed/cancelled`
as well as `completed/failure`.
- `runner-loss-rerun.mjs`, `decide()`: classifies jobs that concluded
`cancelled` as well as `failure`. It still skips the `ci / verify` and
`ci / e2e` aggregates, and a failed or cancelled routing gate still
blocks the re-run.
- `decide()` now runs `staleReason` (open PR, current head, no newer
run) before it reads any annotation or log, and again just before the
re-run, as on master. A run cancelled by a new push has about 40
cancelled jobs; it now costs two API listings and no log reads. The
final check closes the window where a push lands during the log reads: a
re-run of the old run would join the PR's `cancel-in-progress`
concurrency group (`pr-<number>` in `pr-trusted.yml`) and cancel the new
commit's CI.
- Following CONTRIBUTING.md ("Do not submit a PR that includes code
comments"), this PR adds no new code comments. The reasons for each rule
are in this description and in `doc/DEVELOPING.md`.
- `classifyJob`: runner-loss evidence wins. A lost-communication
annotation means lost. A cancellation annotation plus a shutdown signal
in the log means lost, even if the job also has other error annotations.
A cancelled job without this evidence (for example, a person cancelled
the run) counts as a real failure and blocks the re-run.
- Fixtures: two new trimmed snapshots from the example runs (jobs with
`id`, `name`, `status`, `conclusion`; failure annotations; `##[error]`
log lines only). The two older fixtures get the real annotations and log
error lines of their cancelled jobs. Those jobs were spot-reclaimed too
(each log has the shutdown signal), but the old code ignored them.
- `doc/DEVELOPING.md`: the runner-loss paragraph describes the new
rules.

## Verification

- Red first. Against the unchanged script, the new tests fail for the
reasons above: 43285064435 gives `run is completed/cancelled, not
completed/failure`; 43325855069 gives `1 of 1 failed jobs did not lose
their runner` with evidence `gateway_indexing_incomplete`, the same
decision the bot logged.
- Green: `node --test .github/scripts/tests/runner-loss-rerun.test.mjs`:
25 of 25 pass.
- Push during log reads: the PR head moves after the first log read.
With the final freshness check removed, this test fails (the script
re-runs); with it, there is no re-run and the reason is `no open pull
request still has this run's head commit`.
- Guard cases, all with no re-run and no POST:
- Superseded run: 52 jobs cancelled, the PR head moved. The test asserts
zero annotation and log reads.
- Person cancelled the run: cancelled jobs with only "The operation was
canceled." in the annotation and log, and some never-started jobs with
no annotation.
- Mixed: one cancelled lost job and one real test failure (`1 of 2
failed jobs did not lose their runner`).
- Once only: a cancelled run on attempt 2 is refused after one API read.
The workflow condition test still requires `run_attempt == 1`.
  - Cancelled routing gate: left for a person.
- Policy job command: `node --test '.github/scripts/tests/*.test.mjs'`:
806 of 806 pass.
- `pnpm verify`: exit 2 ("Global CI input changed:
.github/scripts/runner-loss-rerun.mjs"). It selects no local Vitest
files and asks for required CI coverage. I did not run `pnpm verify
--full`; required CI on this PR supplies that coverage.
- This workflow runs on `workflow_run` from the default branch. This
PR's own CI cannot exercise the new behavior. The fixture tests are the
evidence. I did not dry-run the script against live runs.

## Risks

- A test that really fails, and then a spot reclaim of the same job a
minute later, now gets one wasted re-run. Attempt 2 then fails for real.
It cannot loop: the workflow `if:` and `eligibleRun` both accept attempt
1 only.
- A run a person cancels on the current head now starts the re-run job.
The job reads the annotations, and the log of each job with a
cancellation annotation, and then does not re-run. This costs some API
calls on a GitHub-hosted runner.
- A concurrency cancel by a label event that does not request CI (the
newer run is `skipped`) passes the head check. Its cancelled jobs have
no runner-loss evidence, so it is not re-run.
- Trust: no change to `permissions`, the trigger, the accepted
repository, event, workflow path, attempt, or the routing-gate rule. A
cancelled run reuses its attempt-1 gate output, the same as a failed run
does today.
- Estimated effect, from a 17-hour sample: 14 of 42 rescued before; 16
cancelled runs and 4 runs with error-annotation noise become eligible
(about 34 of 42). The other 8 stay skipped on purpose (a real test
failure in the same run, a person re-ran first, or the PR closed).

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude (Anthropic), Claude Code agent. Model ID claude-opus-5-5, with
tool use (shell, GitHub CLI) and extended reasoning.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge

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

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-12 22:31:50 -06:00

364 lines
9.4 KiB
JSON

{
"source": "GET /repos/paperclipai/paperclip/actions/runs/43325855069/attempts/1 (+ jobs, annotations and job-log error lines), trimmed",
"run": {
"id": 43325855069,
"name": "PR",
"head_sha": "4b4f6b2ad0fac4ede9f4e20a56e3c93fac5577d5",
"path": ".github/workflows/pr.yml",
"event": "pull_request",
"status": "completed",
"conclusion": "failure",
"html_url": "https://github.com/paperclipai/paperclip/actions/runs/43325855069",
"run_attempt": 1,
"repository": {
"id": 1170821064,
"full_name": "paperclipai/paperclip"
},
"head_repository": {
"id": 1170821064,
"full_name": "paperclipai/paperclip"
}
},
"jobs": [
{
"id": 131557987038,
"name": "ci / gate / Select trusted runner",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292300,
"name": "ci / Docker context integrity",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292349,
"name": "ci / Canary Dry Run",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292381,
"name": "ci / Runner support suite",
"status": "completed",
"conclusion": "failure"
},
{
"id": 131558292405,
"name": "ci / Typecheck + Release Registry",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292466,
"name": "ci / policy",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292573,
"name": "ci / Build",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292627,
"name": "ci / Verify Paperclip Runner (vitest package (1/3))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292664,
"name": "ci / Verify Paperclip Runner (static checks)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292669,
"name": "ci / Verify Paperclip Runner (vitest package (2/3))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292679,
"name": "ci / e2e shard (8/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292686,
"name": "ci / Verify Paperclip Runner (vitest native server)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292707,
"name": "ci / Verify Paperclip Runner (vitest package (3/3))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292731,
"name": "ci / e2e shard (5/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292738,
"name": "ci / e2e shard (2/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292751,
"name": "ci / e2e shard (1/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292779,
"name": "ci / e2e shard (4/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292841,
"name": "ci / e2e shard (3/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558292887,
"name": "ci / e2e shard (7/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293043,
"name": "ci / e2e shard (6/8)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293328,
"name": "ci / Verify serialized server suites (4/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293330,
"name": "ci / Verify serialized server suites (2/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293380,
"name": "ci / Verify serialized server suites (7/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293389,
"name": "ci / Verify serialized server suites (3/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293399,
"name": "ci / Verify serialized server suites (8/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293420,
"name": "ci / Verify serialized server suites (1/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293433,
"name": "ci / Verify serialized server suites (5/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293450,
"name": "ci / Verify serialized server suites (6/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293683,
"name": "ci / Verify serialized server suites (9/9)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293690,
"name": "ci / General tests (server (12/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293701,
"name": "ci / General tests (server (11/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293710,
"name": "ci / General tests (server (8/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293784,
"name": "ci / General tests (server (3/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293818,
"name": "ci / General tests (server (2/12))",
"status": "completed",
"conclusion": "cancelled"
},
{
"id": 131558293819,
"name": "ci / General tests (workspaces-a (1/2))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293825,
"name": "ci / General tests (server (4/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293835,
"name": "ci / General tests (server (5/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293844,
"name": "ci / General tests (server (9/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293850,
"name": "ci / General tests (workspaces-a (2/2))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293852,
"name": "ci / General tests (server (1/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293858,
"name": "ci / General tests (chat (2/3))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293865,
"name": "ci / General tests (server (10/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293875,
"name": "ci / General tests (workspaces-b)",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293940,
"name": "ci / General tests (server (6/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558293992,
"name": "ci / General tests (chat (3/3))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558294007,
"name": "ci / General tests (chat (1/3))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558294057,
"name": "ci / General tests (server (7/12))",
"status": "completed",
"conclusion": "success"
},
{
"id": 131558294396,
"name": "ci / Sandbox provider tests",
"status": "completed",
"conclusion": "skipped"
},
{
"id": 131558294604,
"name": "ci / Select Vitest files",
"status": "completed",
"conclusion": "skipped"
},
{
"id": 131562309925,
"name": "ci / e2e",
"status": "completed",
"conclusion": "success"
},
{
"id": 131564602271,
"name": "ci / verify",
"status": "completed",
"conclusion": "failure"
}
],
"annotations": {
"131558292381": [
{
"annotation_level": "failure",
"message": "The operation was canceled."
},
{
"annotation_level": "failure",
"message": "gateway_indexing_incomplete"
},
{
"annotation_level": "failure",
"message": "gateway_indexing_incomplete"
}
],
"131558293818": [
{
"annotation_level": "failure",
"message": "The operation was canceled."
}
],
"131564602271": [
{
"annotation_level": "failure",
"message": "Process completed with exit code 1."
}
]
},
"logs": {
"131558292381": "2026-11-12T23:13:37.4339910Z ##[error]gateway_indexing_incomplete\n2026-11-12T23:13:37.4368921Z ##[error]gateway_indexing_incomplete\n2026-11-12T23:15:01.1805404Z ##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.\n2026-11-12T23:15:13.7401251Z ##[error]The operation was canceled.\n",
"131558293818": "2026-11-12T23:15:36.1981336Z ##[error]The runner has received a shutdown signal. This can happen when the runner service is stopped, or a manually started runner is canceled.\n2026-11-12T23:15:48.7226826Z ##[error]The operation was canceled.\n"
},
"total_count": 51
}