anvil starts the suite runs Forgejo doesn't, and keeps a pass ledger (MQ-12 step 3b) #64

Open
nelson wants to merge 2 commits from mq-12-start into main
Owner

Stage 3 step 3b of https://openproject.home.romaine.life/wp/MQ-12: anvil starts the suite runs Forgejo doesn't start, and keeps a pass ledger. Inert today: every suite's ci.yml on main still has a pull_request trigger, so nothing here starts a run or posts a status until a suite loses it (pipeline-templates' flip, or a repository's CI_SUITES_REF=anvil-trial).

Added

  • anvil.go: for each suite whose suites/<s>/ci.yml, at the branch Forgejo loads for the repository (its CI_SUITES_REF actions variable, read from the API, else main; read from the pipeline-templates clone), has no pull_request key under on:, a new head gets Suite <s> / scope (pull_request) pending "deciding", decide runs with --passes, and the run is started through patch 0015's POST /repos/{o}/{r}/pulls/{n}/suite-runs with suites_sha, the head, decide's true jobs and the plan {"suites_sha","base","outputs"}. Then reused checks are posted skipped "Identical inputs; passed on " (and a reused package check's covered check-build jobs), unchanged ones skipped "inputs unchanged by this change", the run's anvil / release build / anvil / image build attestations (CI_BUILD_V1 / CI_IMAGE_V1, run = Forgejo's run ID), and scope success "anvil, ci-suites : ran N, reused M, unchanged K". 409 drops the head; other 4xx fail the scope with Forgejo's message; 5xx leaves it pending and retries on the repository's next delivery. Each write wakes the queue in-process.
  • A trial branch (CI_SUITES_REF other than main) decides from a worktree of the suites clone at the branch tip, with the pinned package's installed dependencies (its lock must match), and starts runs with that tip as suites_sha.
  • Ledger in store.go (migration 2): runs (each suite handled on a head, its run and the checks each job runs), passes (by fingerprint, recorded from successful jobs of runs anvil started), pins; passes of any suites commit but the current and previous pin are dropped at startup.
  • Restart: runs anvil started that hadn't ended are read from the jobs API; open pull requests on anvil-run suites with no finished row for their head are decided and started.
  • Metrics merge_queue_suite_runs_total{result} and merge_queue_passes_total{suite}; README section "Starting suite runs".
  • Tests against the fake Forgejo (suite-runs route, CI_SUITES_REF): a native suite is untouched; a dispatch-only suite gets scope pending then success and a run with exactly the decided jobs and plan; a recorded pass is reused on the next head; 409/4xx/5xx and decide failure; restart reconcile; a trial; attestations.

After review

  • A retry kept for an old head is dropped once an event names the pull request's newer head; decisions waiting are keyed by head.
  • The queue lands no head of a repository anvil runs a suite of until anvil's Suite <s> / scope (pull_request) status for each is on it ("waiting for CI to start"), whatever else the head has.
  • A run's row keeps the decision it was started from; its statuses and attestations are posted from that alone, and a different decision for the same head starts a new run.
  • reopened starts again a suite whose run the close cancelled (or that failed or was dropped); a run that ended on its own stands.
  • Decide not finishing (fetch, timeout, ledger, trial worktree) leaves the scope pending and is retried on the repository's next delivery, reopen or restart; only decide's refusal fails it. A 422 "suites_sha not on the branch" after a trial branch is pushed over decides again at the new tip.
  • The suites clone is fetched first when older than the event; a suite no longer anvil's (CI_SUITES_REF removed) gets "no longer run by anvil" on a scope it left pending.
  • Row writes are serialized, so a run's end recorded during posting stays. A retry after a 5xx takes up a run merge-queue already started on the head instead of starting another.
  • A database newer than the build turns shadow mode and anvil's runs off with a warn line; the queue runs. README "Rolling back": builds before this one stop on a newer database, so rolling back to them means moving anvil.db aside first.

Changed

  • decide.go runs from a source (the package, or a trial tip), passes the ledger as --passes only for heads anvil starts runs of, and checks decide's suitesSHA against that source.
  • shadow.go shares the started-run test with anvil; the payload's job carries html_url; PR.Base.SHA is read.
  • Adds gopkg.in/yaml.v3 to read a suite's on:.

Left alone: shadow mode's comparison, the queue, groups, landings, prepared landings, batches; no Forgejo, OpenBao or infra-bootstrap change.

Local: go vet, go test -p 4 ./... and pull-request check pass; -race runs only in CI (no C compiler on nelsonpc).

🤖 Generated with Claude Code

Stage 3 step 3b of https://openproject.home.romaine.life/wp/MQ-12: anvil starts the suite runs Forgejo doesn't start, and keeps a pass ledger. Inert today: every suite's ci.yml on main still has a `pull_request` trigger, so nothing here starts a run or posts a status until a suite loses it (pipeline-templates' flip, or a repository's `CI_SUITES_REF=anvil-trial`). **Added** - `anvil.go`: for each suite whose `suites/<s>/ci.yml`, at the branch Forgejo loads for the repository (its `CI_SUITES_REF` actions variable, read from the API, else main; read from the pipeline-templates clone), has no `pull_request` key under `on:`, a new head gets `Suite <s> / scope (pull_request)` pending "deciding", decide runs with `--passes`, and the run is started through patch 0015's `POST /repos/{o}/{r}/pulls/{n}/suite-runs` with `suites_sha`, the head, decide's true `jobs` and the plan `{"suites_sha","base","outputs"}`. Then reused checks are posted skipped "Identical inputs; passed on <sha12>" (and a reused package check's covered `check-build` jobs), unchanged ones skipped "inputs unchanged by this change", the run's `anvil / release build` / `anvil / image build` attestations (`CI_BUILD_V1` / `CI_IMAGE_V1`, run = Forgejo's run ID), and scope success "anvil, ci-suites <ver>: ran N, reused M, unchanged K". 409 drops the head; other 4xx fail the scope with Forgejo's message; 5xx leaves it pending and retries on the repository's next delivery. Each write wakes the queue in-process. - A trial branch (`CI_SUITES_REF` other than main) decides from a worktree of the suites clone at the branch tip, with the pinned package's installed dependencies (its lock must match), and starts runs with that tip as `suites_sha`. - Ledger in `store.go` (migration 2): `runs` (each suite handled on a head, its run and the checks each job runs), `passes` (by fingerprint, recorded from successful jobs of runs anvil started), `pins`; passes of any suites commit but the current and previous pin are dropped at startup. - Restart: runs anvil started that hadn't ended are read from the jobs API; open pull requests on anvil-run suites with no finished row for their head are decided and started. - Metrics `merge_queue_suite_runs_total{result}` and `merge_queue_passes_total{suite}`; README section "Starting suite runs". - Tests against the fake Forgejo (suite-runs route, `CI_SUITES_REF`): a native suite is untouched; a dispatch-only suite gets scope pending then success and a run with exactly the decided jobs and plan; a recorded pass is reused on the next head; 409/4xx/5xx and decide failure; restart reconcile; a trial; attestations. **After review** - A retry kept for an old head is dropped once an event names the pull request's newer head; decisions waiting are keyed by head. - The queue lands no head of a repository anvil runs a suite of until anvil's `Suite <s> / scope (pull_request)` status for each is on it ("waiting for CI to start"), whatever else the head has. - A run's row keeps the decision it was started from; its statuses and attestations are posted from that alone, and a different decision for the same head starts a new run. - `reopened` starts again a suite whose run the close cancelled (or that failed or was dropped); a run that ended on its own stands. - Decide not finishing (fetch, timeout, ledger, trial worktree) leaves the scope pending and is retried on the repository's next delivery, reopen or restart; only decide's refusal fails it. A 422 "suites_sha not on the branch" after a trial branch is pushed over decides again at the new tip. - The suites clone is fetched first when older than the event; a suite no longer anvil's (CI_SUITES_REF removed) gets "no longer run by anvil" on a scope it left pending. - Row writes are serialized, so a run's end recorded during posting stays. A retry after a 5xx takes up a run merge-queue already started on the head instead of starting another. - A database newer than the build turns shadow mode and anvil's runs off with a warn line; the queue runs. README "Rolling back": builds before this one stop on a newer database, so rolling back to them means moving `anvil.db` aside first. **Changed** - `decide.go` runs from a source (the package, or a trial tip), passes the ledger as `--passes` only for heads anvil starts runs of, and checks decide's `suitesSHA` against that source. - `shadow.go` shares the started-run test with anvil; the payload's job carries `html_url`; `PR.Base.SHA` is read. - Adds `gopkg.in/yaml.v3` to read a suite's `on:`. **Left alone**: shadow mode's comparison, the queue, groups, landings, prepared landings, batches; no Forgejo, OpenBao or infra-bootstrap change. Local: `go vet`, `go test -p 4 ./...` and `pull-request check` pass; `-race` runs only in CI (no C compiler on nelsonpc). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
anvil starts the suite runs Forgejo doesn't, and keeps a pass ledger (MQ-12 step 3b)
All checks were successful
Suite cluster-service / scope (push) Has been skipped
Suite cluster-service / check-manifests (push) Has been skipped
Suite cluster-service / check-image (push) Has been skipped
Suite cluster-service / check-smoke (push) Has been skipped
Suite cluster-service / publish (push) Has been skipped
Suite cluster-service / reused-checks (push) Has been skipped
Suite default / scope (pull_request) Successful in 4s
Suite go / scope (pull_request) Successful in 4s
Suite cluster-service / scope (pull_request) Successful in 5s
Suite go / check-test-windows (pull_request) Has been skipped
Suite go / check-services (pull_request) Has been skipped
Suite cluster-service / check-smoke (pull_request) Has been skipped
Suite cluster-service / publish (pull_request) Has been skipped
Suite go / reused-checks (pull_request) Successful in 3s
Suite default / check-fetches (pull_request) Has been skipped
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite default / check-rules (pull_request) Successful in 4s
Suite default / check-logs (pull_request) Successful in 5s
Suite go / check-format (pull_request) Successful in 6s
Suite default / reused-checks (pull_request) Successful in 4s
Suite cluster-service / check-image (pull_request) Successful in 35s
Suite cluster-service / reused-checks (pull_request) Successful in 4s
Suite go / check-test-linux (pull_request) Successful in 1m16s
17c0b9ffa7
A suite whose ci.yml, at the pipeline-templates branch Forgejo loads for the
repository (CI_SUITES_REF, else main), has no pull_request trigger is started
by anvil through Forgejo's suite-runs route with decide's jobs and plan; its
reused and unchanged checks, build attestations and scope are posted as
statuses. Passes are recorded from the jobs of runs anvil started and given to
decide as --passes. Inert today: every suite still has the trigger.
anvil: review fixes (MQ-12 step 3b)
All checks were successful
Suite go / check-format (pull_request) Successful in 6s
Suite cluster-service / check-image (pull_request) Successful in 35s
Suite cluster-service / reused-checks (pull_request) Successful in 3s
Suite go / reused-checks (pull_request) Successful in 3s
Suite cluster-service / scope (push) Has been skipped
Suite cluster-service / check-manifests (push) Has been skipped
Suite cluster-service / check-image (push) Has been skipped
Suite cluster-service / check-smoke (push) Has been skipped
Suite cluster-service / publish (push) Has been skipped
Suite cluster-service / reused-checks (push) Has been skipped
Suite go / scope (pull_request) Successful in 4s
Suite cluster-service / scope (pull_request) Successful in 5s
Suite default / check-fetches (pull_request) Has been skipped
Suite go / check-test-windows (pull_request) Has been skipped
Suite default / scope (pull_request) Successful in 4s
Suite cluster-service / check-smoke (pull_request) Has been skipped
Suite cluster-service / publish (pull_request) Has been skipped
Suite cluster-service / check-manifests (pull_request) Has been skipped
Suite go / check-services (pull_request) Has been skipped
Suite default / check-logs (pull_request) Successful in 4s
Suite default / check-rules (pull_request) Successful in 5s
Suite default / reused-checks (pull_request) Successful in 4s
Suite go / check-test-linux (pull_request) Successful in 1m22s
ae8854e91f
A retry of an old head is dropped instead of replacing the new head's request;
the queue lands no head before anvil's scope status for each suite it runs; a
run's statuses come only from the decision it was started from; a reopened
pull request starts its cancelled runs again; transient decide failures are
retried, and a trial branch pushed over is decided again at its tip; the
suites clone is fetched when older than the event, and a suite no longer
anvil's releases its pending scope; an ended run stays ended; a start whose
answer was lost is taken up, not started twice; a newer database turns shadow
mode off instead of stopping the service.
All checks were successful
Suite go / check-format (pull_request) Successful in 6s
Required
Details
Suite cluster-service / check-image (pull_request) Successful in 35s
Required
Details
Suite cluster-service / reused-checks (pull_request) Successful in 3s
Required
Details
Suite go / reused-checks (pull_request) Successful in 3s
Required
Details
Suite cluster-service / scope (push) Has been skipped
Suite cluster-service / check-manifests (push) Has been skipped
Suite cluster-service / check-image (push) Has been skipped
Suite cluster-service / check-smoke (push) Has been skipped
Suite cluster-service / publish (push) Has been skipped
Suite cluster-service / reused-checks (push) Has been skipped
Suite go / scope (pull_request) Successful in 4s
Required
Details
Suite cluster-service / scope (pull_request) Successful in 5s
Required
Details
Suite default / check-fetches (pull_request) Has been skipped
Required
Details
Suite go / check-test-windows (pull_request) Has been skipped
Required
Details
Suite default / scope (pull_request) Successful in 4s
Required
Details
Suite cluster-service / check-smoke (pull_request) Has been skipped
Required
Details
Suite cluster-service / publish (pull_request) Has been skipped
Required
Details
Suite cluster-service / check-manifests (pull_request) Has been skipped
Required
Details
Suite go / check-services (pull_request) Has been skipped
Required
Details
Suite default / check-logs (pull_request) Successful in 4s
Required
Details
Suite default / check-rules (pull_request) Successful in 5s
Required
Details
Suite default / reused-checks (pull_request) Successful in 4s
Required
Details
Suite go / check-test-linux (pull_request) Successful in 1m22s
Required
Details
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'mq-12-start:mq-12-start'
git switch 'mq-12-start'
Sign in to join this conversation.
No reviewers
No labels
queue
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
romaine-life/merge-queue!64
No description provided.