Skip to content

chore(github): required CI checks bind merges into release and main, and ADR 0004 records the verification policy #842

Closed

Description

@dan-petty

Problem Statement

GitHub will merge a pull request into release/* or main with failing or missing CI:

  • The main ruleset (21466414) has required_status_checks: [].
  • The release ruleset (23059172) has no status-check rule at all. Both rulesets carry CodeQL code_scanning, code_quality, and a code_coverage rule that nothing feeds.
  • Classic branch protection returns 404 for both branches.

Merge safety therefore rests on agents running devops pr check-readiness, which passes when a head SHA has no check runs and no statuses: _failing_check_runs returns two empty lists and _check_run_blockers reports nothing (src/devops_cli/commands/pr.py:1343-1405).

That state is common:

Two more problems:

All of the last 100 merged PRs were green at merge, so this does not change disciplined work. It makes the rule binding before the unattended roadmap service (#741, #752, #981) arrives.

Proposed Solution

The owner's sequence D3 (2026-10-01) stands, with one correction accepted on 2026-10-02 (Q2): step 2 is a code change that must merge and be verified live before step 4 can be turned on, so it is its own item, #984. This item is steps 3, 4 and 5.

  1. fix(ci): only collaborators can trigger pr updates with /update or /sync comments #754 lands, restricting who can trigger update-prs.yml.
  2. feat(ci): devops pr update --dispatch-ci starts ci.yml on each branch it updates, and only update-prs.yml may hold actions: write #984 (v0.2.27, after fix(ci): only collaborators can trigger pr updates with /update or /sync comments #754 and refactor(ci): github ci runs the gate through devops ci from one check table #843): devops pr update --dispatch-ci dispatches ci.yml on each head it updates, and update-prs.yml gains actions: write.
  3. Pending a person: one bot-updated PR is confirmed to get fresh Static Analysis and Tests & Coverage runs on its new head; with feat(ci): devops pr update --dispatch-ci starts ci.yml on each branch it updates, and only update-prs.yml may hold actions: write #984 in place those are workflow_dispatch runs on the head branch.
  4. Pending a person (owner settings): require Static Analysis and Tests & Coverage (GitHub Actions source, strict) on both rulesets. On the release ruleset, set do_not_enforce_on_create. Today devops release pr creates the branch locally and pushes a version-bump commit that has no check runs (src/devops_cli/commands/release.py:1177-1178, :812-829, git push -u origin <branch> at :823; :1577 pushes tags only). fix(release): one fail-closed release path: cut branch from the remote release tip, uv.lock bump, draft flag, required label and milestone #982 (v0.2.26, before this item) changes that command to push chore/cut-vX.Y.Z only, so by the time this step runs no devops command pushes to release/*; the branch is created by hand (or by feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740, undelivered, no milestone), and do_not_enforce_on_create is what keeps that creation push unblocked. If the owner prefers not to set it, the proof is the next release/* branch created by hand with the rule in place. Remove the inert code_coverage rule from both rulesets.
  5. This item's pull request:

Owner decisions (2026-10-01), kept on record because they replace any matching proposed answer:

Owner decision (2026-10-02, Q2): #842 keeps steps 3-5; #984 holds step 2 and sits between #754 and #842 in v0.2.27.

Scope

In this item: the step 5 pull request, with steps 3 and 4 recorded as Pending a person: bullets with their exact commands in the task file. One pull request.

Not in this item: the dispatch code (step 2), which is #984; it depends on #754 and #843 and lands before this item. The parts of the original body that described step 2 (the PROJECT_TOKEN option, "ci.yml gains that trigger") are superseded by the owner's dispatch decision and by ci.yml:16, which already has workflow_dispatch.

Constraints:

Key Questions

All answered.

Acceptance Criteria

  • rg -n 'branch-protection.yml' --glob '!CHANGELOG.md' --glob '!docs/ROADMAP.md' --glob '!docs/agent/tasks/task-114-*' matches only the command's default path (src/devops_cli/commands/gh.py:1646,1699, src/devops_cli/github/branch_protection.py:80), the generated docs/commands/gh.md and docs/CLI_REFERENCE.md, and tests/test_github_branch_protection.py:68. CHANGELOG.md and docs/ROADMAP.md are never edited in an item pull request, and task-114 is a historical record (Status: Done).
  • uv run devops gh branch-protection --help says the command manages classic branch protection and does not cover rulesets; a CliRunner test in tests/test_github_branch_protection.py (which already invokes the gh app at :349) asserts the help text contains classic and rulesets. No test covers this help text today.
  • uv run devops gh branch-protection audit --repo dan-petty/devops-cli with no --policy-file reports Branch protection policy file not found (branch_protection.py:82-87) rather than a traceback; test_load_branch_protection_policies_missing_file (tests/test_github_branch_protection.py:82-85) still passes.
  • docs/adr/0004-ci-is-the-authoritative-gate.md exists, has the sections of ADR 0001-0003 (statement, ## Considered Options, ## Consequences), names both required checks, strict mode, the devops pr update --dispatch-ci route with actions: write held only by the update-prs.yml job and guarded by feat(ci): devops pr update --dispatch-ci starts ci.yml on each branch it updates, and only update-prs.yml may hold actions: write #984's allowlist invariant, D6 (Copilot review on pull requests into main only; rg -n 'main' docs/adr/0004-ci-is-the-authoritative-gate.md shows the sentence), and the rejected options feat(github): pr readiness requires an issue-linked, completed task file #704, chore(ci): per-check input scoping — investigated, not building #405 and feat(cli): devops ci test selects tests from a coverage index built on demand by devops ci coverage --build-index #406. uv run devops docs check passes (it is the docs row of uv run devops ci, src/devops_cli/commands/ci.py:442-448).
  • CONTEXT.md has Gate, Check and Required check entries with Avoid lines: rg -n -A2 '^\*\*(Gate|Check|Required check)\*\*:' CONTEXT.md prints three entries, each followed by an _Avoid_: line. No test reads CONTEXT.md today (rg -l CONTEXT.md tests/ prints nothing), and this item adds none.
  • changelog.d/842.md exists and uv run devops pr check-readiness passes on the pull request with no CHANGELOG.md or docs/ROADMAP.md change.
  • docs/agent/tasks/task-842-required-ci-checks.md passes tests/test_agent_task_files.py (issue link, no pull request field, no unchecked box).
  • git diff main...HEAD --stat -- .github/workflows/ci.yml tests/test_architectural_invariants.py prints nothing; those files belong to feat(ci): devops pr update --dispatch-ci starts ci.yml on each branch it updates, and only update-prs.yml may hold actions: write #984.
  • uv run devops ci passes offline.
  • Pending a person (after feat(ci): devops pr update --dispatch-ci starts ci.yml on each branch it updates, and only update-prs.yml may hold actions: write #984 merges): a bot update after a release-branch merge produces fresh Static Analysis and Tests & Coverage runs on the PR head. Commands: gh pr view <n> --json headRefOid --jq .headRefOid, then gh api repos/dan-petty/devops-cli/commits/<sha>/check-runs --jq '.check_runs[].name'; both names appear. gh run list --workflow ci.yml --event workflow_dispatch --branch <head> --limit 3 shows the dispatched run on the head branch. Output pasted into the task file.
  • Pending a person: gh api repos/dan-petty/devops-cli/rulesets/21466414 and gh api repos/dan-petty/devops-cli/rulesets/23059172 each show a required_status_checks rule listing both contexts with strict_required_status_checks_policy: true, and no code_coverage rule; the release ruleset shows do_not_enforce_on_create: true, or the next bullet proves creation works. Output pasted into the task file.
  • Pending a person: a throwaway PR with a failing test shows gh pr view <n> --json mergeStateStatus --jq .mergeStateStatus as BLOCKED.
  • Pending a person (only when do_not_enforce_on_create is not set): the next release/* branch is created by hand (git push -u origin release/vX.Y.Z from the main tip) with the rule in place, and gh api repos/dan-petty/devops-cli/branches/release/vX.Y.Z --jq .name prints it. devops release pr is not the proof: after fix(release): one fail-closed release path: cut branch from the remote release tip, uv.lock bump, draft flag, required label and milestone #982 it pushes chore/cut-vX.Y.Z, not release/*.

Out of Scope

Dependencies

Order: #843 (v0.2.26) -> #754 -> #984 -> #842.

Finding from the v0.2.25 release PR (2026-10-03): Copilot re-reviews the whole release diff on every push

Problem (added). D6 keeps automatic Copilot review on pull requests into main only, for the token budget. The main ruleset's copilot_code_review rule has review_on_push: true (read through the rulesets API on 2026-10-03). A release PR into main receives a push each time an item PR merges into the release branch, so Copilot reviewed the whole release diff again on each push and opened new threads each pass: three passes on #1089, each adding threads on code the previous pass had already covered. Every pass spends the token budget D6 protects and adds threads that block merge (required_review_thread_resolution: true).

Acceptance criteria (added).

  • The main ruleset's Copilot rule sets review_on_push: false, so Copilot reviews a release PR once when it is opened or marked ready, and a person (or devops pr ready) requests a re-review on purpose. ADR 0004 records this beside D6.
  • The ruleset change is a person's step (rulesets are owner settings, as in this item's sequence); the PR records the before and after copilot_code_review parameters read with gh api repos/{owner}/{repo}/rulesets/<id>.
  • If devops pr ready requests the Copilot review, a test with a fake client shows it requests exactly one review per call and none on later pushes.

Key question (added). Keep review on push and dismiss stale threads instead? (proposed) No. Re-reviewing the full diff is the cost D6 avoids; one review at ready time, plus deliberate re-requests, keeps the gate and the budget.

Readiness check (2026-10-04)

Re-checked at b61e5a0 (release/v0.2.26). #843, #741 and #982 are merged. #754 and #984 are open and earlier in v0.2.27, as order D3 requires. One owner decision is open (last section).

Corrected locations (under src/devops_cli/ unless stated):

  • commands/pr.py: _failing_check_runs is at :1346, _check_run_blockers at :1376.
  • .github/workflows/ci.yml: Tests & Coverage is at :46 (was :72); Static Analysis is still at :26.
  • The default policy path is at commands/gh.py:1560 and :1613 (were :1646 and :1699). github/branch_protection.py:80, its missing-file error :82-87 and the classic API calls :139 and :384 are unchanged. At HEAD, the first criterion's rg matches exactly these, plus the generated docs/commands/gh.md and docs/CLI_REFERENCE.md and tests/test_github_branch_protection.py:68.
  • The branch-protection help strings are at lang/en/help.py:864-872 (were :811-815).
  • Release push path after fix(release): one fail-closed release path: cut branch from the remote release tip, uv.lock bump, draft flag, required label and milestone #982:
    • devops release pr runs cut_release (commands/release.py:1328) and force-pushes only chore/cut-vX.Y.Z (:1072).
    • Tags are pushed at :1854.
    • The citations release.py:1177-1178, :812-829, :823 and :1577 are gone.

Stale premise: a devops command does create release/*. #740 is closed (v0.2.25), not "undelivered, no milestone". When a release starts, devops roadmap reprioritize creates release/vX.Y.Z at the default branch's head. It does this through POST repos/{repo}/git/refs (roadmap/reprioritize.py:1612-1619, roadmap/github_store.py:1092-1101), as the machine account. Step 4's answer stands: do_not_enforce_on_create keeps that creation unblocked, and it now protects an unattended job rather than a hand push.

  • Step 4's fallback proof, needed only when do_not_enforce_on_create is not set, is the next release/* branch that devops roadmap reprioritize creates with the rule in place. Read it back with gh api repos/dan-petty/devops-cli/branches/release/vX.Y.Z --jq .name.

A test reads CONTEXT.md now. tests/test_roadmap_lifecycle_properties.py:1131-1141 collects terms from lines matching ^\*\*Term\*\*:$, so "No test reads CONTEXT.md today" is stale.

  • The Gate, Check and Required check entries use exactly that form: the term alone on its line, ending in :, then the definition, then _Avoid_:. The existing test keeps passing, and this item still adds no test.

devops pr ready requests no Copilot review at HEAD. rg 'requested_reviewers|copilot-pull-request-reviewer|--add-reviewer' src/devops_cli finds nothing. The criterion "If devops pr ready requests the Copilot review..." therefore has nothing to test, and no code change follows from the 2026-10-03 finding: re-reviews are a person's request.

Open owner decision. The 2026-10-03 key question ("Keep review on push and dismiss stale threads instead?") is marked "(proposed)" and has no recorded owner answer. It changes what the reviewed gate covers: with review_on_push: false, item PRs merged into the release branch after the release PR opens get no automatic Copilot pass. Recommended: accept review_on_push: false, for the token budget D6 protects. ADR 0004's sentence on this and the step-4 ruleset change wait on the answer.

Owner decision (2026-10-04)

The owner accepted the recommendation in the readiness check above; the 2026-10-03 key question is answered "No".

  • The main ruleset's Copilot rule sets review_on_push: false. Copilot reviews a release PR once, when it is opened or marked ready, and each re-review is requested on purpose by a person.
  • Accepted trade-off: item PRs merged into the release branch after the release PR opens get no automatic Copilot pass.
  • ADR 0004 records this decision and the trade-off beside D6. The step-4 ruleset change no longer waits on an answer.

Amended criterion. The conditional criterion "If devops pr ready requests the Copilot review, a test with a fake client shows ..." is replaced by:

  • devops pr ready requests no Copilot review, and this item adds no code that requests one; re-reviews are a person's request. At merge, rg 'requested_reviewers|copilot-pull-request-reviewer|--add-reviewer' src/devops_cli finds nothing.

Activity

  1. added
    type/infra
    scope/github
    priority/p1-high
    on Oct 1, 2026
  2. added this to the v0.2.27 milestone on Oct 1, 2026
  3. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Placement (2026-10-01): v0.2.27. Value High, Effort Medium. Not Ready yet.

    Checked against release/v0.2.24 at d38251e. What stops it being Ready:

    • Not deliverable by one PR. The owner sequence D3 needs a code change (step 2: update-prs dispatches ci.yml), then live verification (step 3), then owner ruleset settings (step 4), then the cleanup/ADR PR (step 5). Split step 2 into its own item, or fold it into fix(ci): only collaborators can trigger pr updates with /update or /sync comments #754.
    • Dispatch details unanswered: devops pr update uses the async update-branch API (pr.py:1595-1660), so how does the dispatch wait for or target the new head? update-prs.yml would need actions: write, which no workflow has today. Should the dispatch live in the workflow or in devops pr update?
    • Stale: 'ci.yml gains that trigger', but ci.yml:16 already has workflow_dispatch. The inert code_coverage rule is also on the main ruleset, not only release.
    • The 'changed-line coverage item' is not named (likely feat(ci): changed-line coverage on pull requests (diff-cover) #850, backlog).
  4. dan-petty commented on Oct 3, 2026

    @dan-petty
    OwnerAuthor

    The machine-account token now lives in Secret devops-cli (namespace devops, key GH_TOKEN), created by #741 from the keyring.

  5. dan-petty-bot commented on Oct 6, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1251, merged into release/v0.2.27 as 20525df.

    Description

    This pull request delivers #842, establishing authoritative required CI checks for merges into release/* and main branches and formally documenting the verification policy in ADR 0004.

    • Deletes .github/branch-protection.yml which declared an inert ci context.
    • Updates help strings in devops gh branch-protection CLI commands to clarify management of classic branch protection policies and that it does not cover repository rulesets.
    • Adds CliRunner tests in tests/test_github_branch_protection.py verifying that help text mentions classic and rulesets, and that auditing with a missing policy file cleanly reports an error without a traceback.
    • Adds docs/adr/0004-ci-is-the-authoritative-gate.md in ADR 0001–0003 format documenting the CI verification policy, required checks (Static Analysis and Tests & Coverage), strict mode, dispatch route via devops pr update --dispatch-ci, machine-account token boundary, and owner decisions (D6 Copilot review and rejected options feat(github): pr readiness requires an issue-linked, completed task file #704, chore(ci): per-check input scoping — investigated, not building #405, feat(cli): devops ci test selects tests from a coverage index built on demand by devops ci coverage --build-index #406).
    • Adds glossary definitions for Gate, Check, and Required check with Avoid: lines to CONTEXT.md.
    • Regenerates documentation via devops docs generate and verifies via devops docs check.
    • Adds changelog fragment changelog.d/842.md and task record docs/agent/tasks/task-842-required-ci-checks.md.

    Closes #842

    11 file(s) changed.

    How it was verified

    Check runs at c79063c:

    • Prune PR DevContainer Images: pass
    • Analyze (python): pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-842-required-ci-checks.md:

    • rg -n 'branch-protection.yml' --glob '!CHANGELOG.md' --glob '!docs/ROADMAP.md' --glob '!docs/agent/tasks/task-114-*' matches only allowed code defaults and reference documentation.
    • devops gh branch-protection --help specifies that the command manages classic branch protection policies and does not cover rulesets; tested via CliRunner in tests/test_github_branch_protection.py.
    • devops gh branch-protection audit --repo dan-petty/devops-cli reports Branch protection policy file not found with no traceback when policy file is absent; tested via CliRunner in tests/test_github_branch_protection.py.
    • docs/adr/0004-ci-is-the-authoritative-gate.md exists in ADR 0001–0003 format recording the required checks, strict mode, dispatch route, token boundary, D6 Copilot review policy, and rejected options.
    • CONTEXT.md contains Gate, Check, and Required check entries with _Avoid_: lines conforming to lifecycle property invariants.
    • Documentation regenerated and verified via devops docs check.
    • Changelog fragment changelog.d/842.md created.
    • Task file docs/agent/tasks/task-842-required-ci-checks.md passes tests/test_agent_task_files.py.
    • git diff origin/release/v0.2.27...HEAD --stat -- .github/workflows/ci.yml tests/test_architectural_invariants.py makes no edits to CI workflow or architectural invariants.
    • All unit, CLI, and invariant tests pass offline via uv run devops ci.
    • Pending a person (after feat(ci): devops pr update --dispatch-ci starts ci.yml on each branch it updates, and only update-prs.yml may hold actions: write #984 merges): A bot update after a release-branch merge produces fresh Static Analysis and Tests & Coverage runs on the PR head.
      • gh pr view <n> --json headRefOid --jq .headRefOid
      • gh api repos/dan-petty/devops-cli/commits/<sha>/check-runs --jq '.check_runs[].name'
      • gh run list --workflow ci.yml --event workflow_dispatch --branch <head> --limit 3
    • Pending a person (owner settings): Rulesets 21466414 and 23059172 each show required_status_checks with Static Analysis and Tests & Coverage in strict mode, without code_coverage, and with do_not_enforce_on_create: true on release.
      • gh api repos/dan-petty/devops-cli/rulesets/21466414
      • gh api repos/dan-petty/devops-cli/rulesets/23059172
    • Pending a person: A throwaway PR with a failing test shows gh pr view <n> --json mergeStateStatus --jq .mergeStateStatus as BLOCKED.
    • Pending a person: The main ruleset's Copilot rule sets review_on_push: false.
      • gh api repos/dan-petty/devops-cli/rulesets/21466414
  6. added a commit that references this issue on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/githubtype/infra

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions