feat(github): rerun and rerequest endpoints for in-place reruns

Merged
BN
11d ago
+1138-20

Current scope: the GitHub REST rerun/cancel shims and rerequest handling, intentionally stacked on PR A (Bnjoroge/rerun-in-place).

Problem

GitHub tooling and webhook rerequests need GitHub-compatible rerun and cancel endpoints while retaining GitHub-shaped error responses and in-place attempt semantics.

Design summary

Adds the /repos/{owner}/{repo}/actions/runs/{id}/rerun, failed-jobs, job-rerun, and cancel shims with dispatch authorization, GitHub-compatible status/error envelopes, check-run and check-suite rerequested handling, and focused dispatch/broker coverage. This PR is intentionally stacked on PR A (Bnjoroge/rerun-in-place) and should merge after it.

Intentionally in the other PR

PR A contains the control-plane rerun engine, attempt-history schema copies, native API and CLI, archiver hold, latest-attempt views, and the shared engine tests.

Verification

  • cargo fmt --all --check — clean.
  • cargo clippy --locked -p preloop-runner-server -p preloop-cli --all-targets -- -D warnings — clean.
  • cargo test --locked -p preloop-runner-server --lib with scratch PostgreSQL — 979 passed, 0 failed, 3 ignored.
  • cargo test --locked -p preloop-runner-server --features test-support --test broker — 60 passed, 0 failed, 0 ignored.

This PR remains open and is intentionally stacked on PR A until A merges.


Devin Review


Summary by cubic

Adds GitHub-compatible rerun and cancel endpoints (/repos/{owner}/{repo}/actions/runs/{id}/rerun, rerun-failed-jobs, actions/jobs/{job_id}/rerun, cancel) so GitHub tooling and gh run rerun work against in-place attempt semantics. Also handles check_suite.rerequested webhooks by re-running the suite's run in place instead of minting a new run. Reruns and rerequests now record the triggering actor (API caller or webhook sender).

  • Endpoints accept both preloop UUIDs and the synthetic numeric ids emitted by list_actions_runs.
  • Responses use GitHub-shaped error envelopes (message + documentation_url) while keeping the legacy error key for existing clients.
  • enable_debugger in the rerun body overrides the stored submission's debugger setting for the new attempt; enable_debug_logging is accepted but ignored. Wrong-typed values return 422.
  • Archived runs: partial rerun modes return 409, full rerun resubmits the recorded submission as a new run.
  • Execution protection applies to check_suite rerequests the same way it applies to check-run rerequests.
  • Intentionally stacked on Bnjoroge/rerun-in-place; merge after that PR lands.

Summary by CodeRabbit

  • New Features

    • Added GitHub-compatible endpoints to rerun all jobs, rerun failed jobs, rerun a specific job, and cancel a workflow run.
    • Added support for check-suite rerequests to rerun eligible workflows.
    • Rerun requests can optionally enable debugger support.
    • Workflow endpoint errors now use a GitHub-compatible response format.
  • Bug Fixes

    • Check-run rerequests now rerun the requested job while retaining its existing run and check-run mapping.