Skip to content

refactor(gh): remove the classic devops gh branch-protection group #5329

Open

Description

@dan-petty

Update 2026-11-26 (infra move): The ruleset has a new owner (ADR 0035).

devops repos onboard (row 10) manages the main ruleset of each repository, not OpenTofu stacks. The baseline is in dan-petty/infra. The removal of devops gh branch-protection is still open.


Problem or Motivation

The group manages classic protection only. Its default file .github/branch-protection.yml is missing, so the audit exits 1. No repo uses classic protection.

Order 14 of the plan in #5311. The owner approved the plan on 2026-11-13.

Proposed Solution & Architectural Design

Delete branch_protection.py, its 25 tests, the dry-run rows, the docs and the CLI reference rows. Add no shim.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

gh ruleset view and check through the pass-through, plus row 10 of devops repos onboard, which manages the main ruleset (ADR 0035).

Cost: Build: about 200k tokens, 0.5 day. Upkeep goes down by about 500 lines and 25 tests.

Acceptance Criteria

  • No reference to 'branch-protection' stays in src, the docs or the specs.
  • The CI checks pass.

Dependencies

#5323; owner decision 16 in #5311. Part of #5311.

Source: #5311

Alternatives check of 2026-11-26: not-applicable.
Class: refactor, no model call.
Tool: none found.

Proposed design

Problem statement

The devops gh group keeps a classic branch-protection command that manages classic protection only. No managed repository holds its file .github/branch-protection.yml, so its audit exits 1. The command is also a second writer of the protection that the onboard ruleset row owns (ADR 0035). The change removes the group, its module, its 25 tests, its dry-run rows, its documentation and its CLI reference rows. It adds no shim.

Acceptance criteria

Requirement: Remove the branch-protection command group

The devops gh command group SHALL NOT expose a branch-protection command and SHALL add no compatibility shim.

Scenario: Help output omits the branch-protection command

  • WHEN A test runs uv run devops gh --help.
  • THEN The command exits 0 and its output holds no branch-protection entry.

Requirement: Delete the branch-protection module and its tests

The repository MUST NOT hold a source or test file whose name contains branch_protection.

Scenario: No file name in src or tests contains branch_protection

  • WHEN A test walks the src and tests trees for file names that contain branch_protection.
  • THEN The walk finds no path.

Requirement: Remove the source references

The src tree SHALL NOT hold the strings branch-protection or branch_protection.

Scenario: Source search returns no match

  • WHEN A test searches the src tree for branch-protection and branch_protection.
  • THEN The search finds no match.

Requirement: Remove the documentation and spec references

The docs tree and the openspec/specs tree SHALL NOT hold the string branch-protection.

Scenario: Documentation and spec search returns no match

  • WHEN A test searches the docs tree and the openspec/specs tree for branch-protection.
  • THEN The search finds no match.

Requirement: Keep the generated documentation current

The generated documentation MUST agree with the command tree after the removal.

Scenario: The documentation check passes

  • WHEN A check runs uv run devops ci docs.
  • THEN The command exits 0 and reports no out-of-date document.

Requirement: Required checks pass

The pull request MUST pass the required Static Analysis and Tests & Coverage checks.

Scenario: Required checks pass on the pull request

  • WHEN The pull request runs the required checks.
  • THEN Static Analysis and Tests & Coverage complete with conclusion success.

Existing Tool Considered

The alternatives check block of 2026-11-26 in the issue body records not-applicable and Tool: none found, because the class is refactor. No open, maintained tool covers the need: the change deletes code and builds no replacement. The devops gh pass-through already reaches gh ruleset view and gh ruleset check (ADR 0037). devops repos onboard row 10 owns the main ruleset (ADR 0035). The issue body gives the written cost: build about 200k tokens and 0.5 day. Upkeep falls by about 500 lines and 25 tests.

Key questions

  • Should the classic branch-protection group be removed outright or kept behind a compatibility shim?: Remove the group outright and add no shim. (best practice) [sources: src/devops_cli/commands/gh.py, src/devops_cli/github/branch_protection.py, AGENTS.md]
    • Chosen: Remove the group outright. No managed repository holds .github/branch-protection.yml, so the group writes nothing and its audit exits 1.
    • Rejected: Keep a compatibility shim. The shim keeps dead code alive. AGENTS.md rule 2 forbids compensating code.
    • Rejected: Keep the classic audit. Its default file .github/branch-protection.yml is missing, so the audit exits 1.
  • What replaces the removed classic branch-protection audit?: Use gh ruleset view and gh ruleset check through the devops gh pass-through. devops repos onboard row 10 owns the main ruleset (ADR 0035). (best practice) [sources: docs/repos/onboard.md, docs/CLI_REFERENCE.md]
    • Chosen: Ruleset view and check through the pass-through. ADR 0035 gives the ruleset to onboard row 10, and the pass-through already reaches gh (ADR 0037).
    • Rejected: Build a new classic audit. No repository holds the classic file, so a new audit has no input.
    • Rejected: Keep the classic audit. The default file is missing, so the audit exits 1.
  • Which modules must lose their use of branch_protection?: src/devops_cli/commands/gh.py, src/devops_cli/config/constants.py and src/devops_cli/github/merge_readiness.py call or name the module. The change removes each use with the module. [sources: src/devops_cli/commands/gh.py, src/devops_cli/config/constants.py, src/devops_cli/github/merge_readiness.py]
  • How does the change keep the documentation and the generated CLI reference correct?: Remove each reference in docs/ in the same pull request. Then regenerate the CLI reference and verify it with uv run devops ci docs. (best practice) [sources: AGENTS.md, docs/CLI_REFERENCE.md, docs/commands/gh.md]
    • Chosen: Fix the documents and regenerate the reference in the same pull request. AGENTS.md rule 8 requires a document that the change makes wrong to be fixed in the same pull request.
    • Rejected: Leave the documents to a later item. The documentation and spec search criterion would then fail.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#5323

Activity

  1. added
    source/agent
    on Nov 13, 2026
  2. added
    type/refactor
    scope/gh
    status/new
    value/medium
    effort/low
    on Nov 13, 2026
  3. dan-petty commented on Nov 13, 2026

    @dan-petty
    OwnerAuthor
  4. added
    priority/p2-medium
    on Nov 13, 2026
  5. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: refactor. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-16. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at ba041d8 while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

  7. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  8. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor

    Audit evidence: custom code against open tools, 2026-11-28, devops-cli at d0bc3dffa. The audit lists this deletion in rank 26 (dead or duplicate code).

    • src/devops_cli/github/branch_protection.py (502 lines, 25 tests) and commands/gh.py:1845-1975.
    • It reads .github/branch-protection.yml. No repository holds that file (git ls-files finds 0).
    • It is a second writer of the protection that the onboard ruleset row owns (ADR 0035). refactor(repos): replace the onboard settings rows with OpenTofu #7497 now asks to move that ruleset to the OpenTofu resource github_repository_ruleset. This deletion stays valid in both cases.

    #7505 deletes the other dead security modules of rank 26, and leaves this file to this item.

  9. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

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

    effort/lowpriority/p2-mediumscope/ghsource/agentstatus/newtype/refactorvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions