Skip to content

Run the backlog merge canary

The backlog merge ladder takes a delivered item from review to a merged pull request: the audit passes and writes the green marker (backlog.awaiting_human_merge), a person drags the card to Done, and the merge gate merges on the forge (backlog.completed) or reports that it could not (backlog.merge_unavailable). The stage canary runs this ladder every night on a fixture repository, so a defect shows up there and not on production work.

The stage-backlog-canary workflow (.forgejo/workflows/stage-backlog-canary.yml) has its recurring trigger paused by the owner (2026-10-14). Manual dispatch of scripts/ci/backlog_merge_canary.py nightly logs in to stage as the canary member and does the following:

  1. Drives the ladder. For every card in In review that shows the green marker, it drags the card to Done once. The fixture repository’s main branch requires one approval, so the forge refuses the merge and the gate records backlog.merge_unavailable. The script then approves the pull request as the fixture reviewer and drags the card again, and the merge completes (backlog.completed). A first drag that merges immediately is reported as protection_missing and fails the run.
  2. Asserts the markers. It reads the canary workspace’s audit trail and fails unless the last 24 hours hold at least one backlog.awaiting_human_merge, one backlog.merge_unavailable and one backlog.completed row for the canary project. Review rounds (backlog.return_to_sender, backlog.review_failed, backlog.awaiting_reverify, backlog.reverify_recorded) are counted in the summary but not required, because a fixture cannot force a failed first review.
  3. Files the next fixture issue. Unless a [canary] issue is still open, it opens one on the fixture repository and imports it into the backlog, so the next night has a delivered item to drive.

A failed run is the alert. The bw-infra Grafana rule on the same markers alerts independently when the canary shows no green marker and no completed merge for 24 hours.

Do not switch the backlog loop on for a production project until the canary has been green for 7 consecutive days. To check, dispatch the workflow on main with check set to release-gate. It exits successfully only when each of the last seven 24-hour windows holds all three markers, and the job summary lists each window with the markers it lacked.

The canary needs this setup once. These are operator steps on the forge and on stage:

  • Fixture repository on the forge, with branch protection on main that requires one approval, and an approval allowlist that contains only the fixture reviewer account. The Forgejo credential of the SupaCloud project must belong to another account, so the merge gate cannot approve its own pull request.
  • Canary workspace on stage that holds only the canary project, with the audit_log_workspace feature. The canary project uses the fixture repository, has the backlog automation on with the pr_only merge policy and an explicit project autonomy level of 50, and has no required CI status checks.
  • Canary member: a password account without two-factor authentication. It is an admin of the canary workspace, because the audit log is admin-only.
  • Repository variables: BACKLOG_CANARY_SUPACLOUD_URL, BACKLOG_CANARY_WORKSPACE_ID, BACKLOG_CANARY_PROJECT_ID, BACKLOG_CANARY_FORGEJO_REPO (owner/name).
  • Repository secrets: BACKLOG_CANARY_MEMBER_EMAIL, BACKLOG_CANARY_MEMBER_PASSWORD, BACKLOG_CANARY_REVIEWER_TOKEN (a token of the fixture reviewer with repository write access).
Terminal window
python3 -S -m unittest scripts/ci/backlog_merge_canary_test.py

The tests fake the transport, so they need no stage access.