Skip to content

feat(report)!: a repository that changed under the run is stale and requeues - #275

Merged
sweepies merged 2 commits into
mainfrom
feat/stale-repositories
Nov 12, 2026
Merged

sweepies merged 2 commits into
mainfrom
feat/stale-repositories

Conversation

@sweepies

@sweepies sweepies commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

A run that loses a race with the repository is no longer a failure: the repository is stale, and the server reruns it.

Report (breaking: schemaVersion 6 → 7, actions 2 → 3, no reading of old versions)

  • Status::Stale ("stale") for a repository that changed under the run; PullRequestStatus::Stale for the two publish races.
  • Validation: a stale repository needs a reason, a real run's actions, and never dryRun; a stale PR action needs a reason. The engine's interim lookup-phase report is checked before actions attach (a control or inventory read can race then), and the full check runs on from_json/run_at.
  • Invariant: a repository is stale exactly when a step raced, or a branch or PR action is stale, and nothing failed. error outranks it.

Engine

  • StepFailure::Stale with From<patchula_update::Error> (Raced → Stale, anything else → Repo) at every step that maps an update error, the inventory read included. Publish and auto-merge share one failure_status.
  • Both write tails lift a stale branch or PR action to the repository after the error and protected checks. Only complete repositories record their schedule turn, so a stale run keeps the window for its rerun.

Server

  • BatchOutcome::report requeues on Status::Stale; patchula_update::needs_requeue is deleted. The log reads repository changed during the run; requeued. The cap from fix(server): consecutive requeues are bounded #274 still bounds a race that persists.
  • /api/v1 status (and a PR's action status) can be stale, documented, with no path bump.

CLI and Action

  • patchula run (and run --remote) exits 5 when no repository errored and at least one is stale. An error still exits 1. This includes the base-moved race, which exited 0.
  • The summary prints a warning-painted stale: <reason> per repository. The Action already fails the step on any non-zero exit (guide/github-actions.md says so for 5), so a stale run is visible and the next scheduled run retries it.

Tests

  • One engine test per raced site (seven: publish lease, write inventory, obsolete-PR refresh, closure lease, cleanup lease, a foreign commit on the published head, bounded retries). Each asserts stale with the race's text, no error action and no schedule turn, then a rerun that completes. Five of these races had no test before.
  • a_stale_run_keeps_the_schedule_window_for_its_rerun: a raced run inside a single-time window records nothing, and the rerun a few seconds later still creates the branch.
  • Precedence: a stale action plus an error action is error.
  • Report round-trip and validation; server stale → requeue and stale + error → failed; CLI exit 5 then 0, and an output snapshot.
  • Flipped: the needs_requeue assertions, the two published-head cases (error → stale), the server's stale-base test, and the report test that rejected a stale PR action.

Docs: reference/report.md (v7), guide/server.mdx, guide/github-actions.md, internals/engine.md, reference/cli.md and the help snapshot.

Behaviour change: when the default branch, an obsolete pull request or a published pull request's head changes under the run, the repository's report status is stale instead of error (or complete, for the base race), and a raced PR action is stale. patchula run exits 5 for it. The server reruns it a minute later without counting a failure, and treats the fourth such run in a row as a failure. A stale run no longer takes the repository's schedule turn.

View guided diff Turn on auto-fix

Follow-up (not in this PR): the Action workflow's dry run runs the latest release against this checkout's PatchulaConfig.pkl, so it fails whenever main has removed a config field since that release (v0.8.1 still requires submodules). It only runs when action.yml or tests/action/** change, and clears at the next release.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula f97f44e Commit Preview URL

Branch Preview URL
Nov 12 2026, 01:51 AM

…equeues

A run that loses a race with the repository is no longer a failure. When
the default branch, an obsolete pull request or a published pull
request's head changes under the run, the repository's report status is
`stale` (new; report schemaVersion 7, actions 3) instead of `error`, and
a raced pull request action is `stale` instead of `error`. A repository
whose branches went stale at publish is `stale` too, where it was
`complete`. `patchula run` exits 5 for it — so does the base race that
previously exited 0 — and the Action fails the step so the next
scheduled run retries it. The server runs it again a minute later
without counting a failure, and after three such runs in a row treats
the next as a failure. A stale run no longer takes the repository's
schedule turn. The repository API's `status` can be `stale`.
@sweepies
sweepies force-pushed the feat/stale-repositories branch from fed20a3 to c46edd1 Compare November 12, 2026 01:39
@sweepies
sweepies merged commit aa4d32a into main Nov 12, 2026
13 checks passed
@sweepies
sweepies deleted the feat/stale-repositories branch November 12, 2026 01:59
@sweepies-ops sweepies-ops Bot mentioned this pull request Nov 12, 2026
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.

1 participant