Skip to content

refactor(repos): replace the onboard settings rows with OpenTofu #7497

Backlog

Description

@dan-petty

Problem

devops repos onboard has its own desired-state engine for repository settings. It reads the live settings and compares them with github/repository.yaml. Then it writes each difference through REST.

The code (lines at commit d0bc3dffa):

  • src/devops_cli/github/onboard/ has 3,388 lines and 85 tests.
  • model.py:153-201 makes the diff.
  • settings_rows.py:280-311 sends the repository PATCH.
  • settings_rows.py:373-549 writes the security settings and the environments.
  • settings_rows.py:576-625 writes the environment secret.
  • settings_rows.py:626-786 creates and updates the ruleset, and merges the required checks.
  • service_rows.py:151-170 writes the labels. service_rows.py:271-327 writes the webhook.
  • routes.py:31-491 holds the routes. run.py:170-252 sets the row order.
  • In dan-petty/github-workflows, templates/repository/github/repository.yaml.jinja:1-119 holds raw REST bodies. templates/github-repository.schema.json is a hand-written schema of 391 lines.

The engine broke often in the last 30 days:

A plan engine removes these bug classes by design:

The owner closed #7489 as not planned on 2026-11-27. The close comment gives the reason: the owner rejects more custom code where an open tool solves the problem. The comment names this replacement as the item to plan instead.

Change

Replace the settings rows of onboard with the OpenTofu provider integrations/github.

These settings move to provider resources:

  • github_repository: the repository settings and the security settings.
  • github_repository_ruleset: the main ruleset and its required checks.
  • github_repository_environment: the environments.
  • github_issue_labels: the labels.
  • github_repository_webhook: the webhook.
  • github_workflow_repository_permissions: the workflow permissions.

These parts stay, for these reasons:

Delete:

  • The diff of model.py.
  • The rows that the provider covers: repository, security, environments, ruleset, labels and webhook. Also their routes in routes.py and their tests.
  • The REST bodies of repository.yaml.jinja and github-repository.schema.json in dan-petty/github-workflows. The variable types of the module validate the input.

ADR 0035 chose the onboard engine and rejected OpenTofu for two reasons: the stacks did not exist, and the provider cannot hold code_quality. ADR 0035 also says that the project "keeps its own apply code, which OpenTofu would give". A person must amend or supersede ADR 0035 before the work starts. The new record restores decisions 1, 4 and 7 of ADR 0026.

Related items:

Existing tool considered

  • integrations/terraform-provider-github (MIT, v6.13.0) with OpenTofu. It covers each setting above. It does not cover code_quality, immutable releases, code scanning default setup, or the values of environment secrets.
  • github-community/safe-settings (ISC, 3.0.0). It needs a hosted App, and ADR 0026 rejected it.
  • repository-settings/app (ISC, v5.0.16). It needs a hosted App too.

Done when

  • A person amends or supersedes ADR 0035.
  • The onboard rows that the provider covers, the diff in model.py, the REST bodies and the hand-written schema are deleted.
  • Only the calls for code_quality, immutable releases and default setup stay. Each call names its upstream issue or PR.
  • After the import, tofu plan of devops-cli shows 0 to add, change or destroy.
  • A plan that removes a required check from the ruleset input shows an update of github_repository_ruleset (the case of fix(repos): onboard cannot remove a required check #7489).
  • The drift job of feat(k8s): find GitHub settings drift every night with a read-only App #5328 runs tofu plan -detailed-exitcode and reports drift.

Source

Source: https://github.com/dan-petty/devops-cli/blob/d0bc3dffa781951f7b49935ba545cad82b2ecfaf/src/devops_cli/github/onboard/settings_rows.py

Proposed design

Problem statement

The onboard command keeps its own desired-state engine for repository settings, and that engine broke often and cannot remove a required check. The owner rejects more custom code where an open tool solves the problem, so the repository, security, environment, ruleset, label and webhook rows move to the OpenTofu provider integrations/terraform-provider-github. This issue delivers the devops-cli side: it deletes the covered rows, routes, diff and tests, keeps one small call for each provider gap, keeps the Vault-backed environment secret path, and adds the ADR that supersedes ADR 0035 and records the new scope. The OpenTofu root stacks and shared module remain #5325.

Acceptance criteria

Requirement: Covered settings rows are deleted

The onboard command SHALL delete the repository, security, environment, ruleset, label and webhook rows.

Scenario: The covered row names are absent

  • WHEN a test reads ROW_NAMES in src/devops_cli/github/onboard/run.py and imports the onboard modules
  • THEN ROW_NAMES holds no entry for rows 2, 3, 5, 8, 10 or 12, and the modules hold no repository_row, security_row, environment_row, labels_row, ruleset_row or webhook_row function.

Requirement: Kept rows stay

The onboard command SHALL keep the preflight, create, code quality, release secret, app check, template pull request, ready, Service, cluster, RAG and OpenSpec rows.

Scenario: The kept row names are present

  • WHEN a test reads ROW_NAMES
  • THEN it still holds rows 0, 1, 4, 6, 7, 9, 11, 13, 14, 15 and 16.

Requirement: Covered routes are deleted

The onboard command SHALL delete the routes of the covered settings rows.

Scenario: The covered routes are absent

  • WHEN a test reads ROUTES in src/devops_cli/github/onboard/routes.py
  • THEN it holds no route key repository, vulnerability-alerts-on, vulnerability-alerts-off, private-reporting-on, private-reporting-off, workflow-permissions, environment, branch-policy, variable-create, variable-update, label, ruleset-create, hook-create or hook-update.

Requirement: Settings diff is deleted

The onboard command SHALL delete the settings diff code from model.py.

Scenario: The diff functions are absent

  • WHEN a test imports devops_cli.github.onboard.model
  • THEN the module has no differences, held_differences or _list_matches callable.

Requirement: code_quality rule call stays

The onboard command SHALL keep one API call that adds the code_quality rule to the main ruleset.

Scenario: The kept ruleset call sends code_quality

  • WHEN a test runs the kept ruleset call with a baseline that holds a code_quality rule and a live ruleset that lacks it
  • THEN the GitHub API fake records a PUT /repos/{repo}/rulesets/{ruleset} body whose rules contains a rule of type code_quality.

Requirement: Immutable releases call stays

The onboard command SHALL keep one API call for immutable releases.

Scenario: The kept immutable releases call sends the setting

  • WHEN a test runs the kept immutable releases call with immutable releases enabled
  • THEN the GitHub API fake records PUT /repos/{repo}/immutable-releases.

Requirement: Code scanning default setup call stays

The onboard command SHALL keep one API call for code scanning default setup.

Scenario: The kept code scanning call sends the setting

  • WHEN a test runs the kept code scanning default setup call
  • THEN the GitHub API fake records PATCH /repos/{repo}/code-scanning/default-setup with a body that sets state to configured.

Requirement: Environment secret value stays out of state

The onboard command SHALL set the environment secret value through the existing sync_repository_secrets(..., environment=...) path, with the Vault source, and SHALL keep the value out of the state, the process arguments and the output.

Scenario: The environment secret update seals the value

  • WHEN a test runs the environment secret update with a Vault value
  • THEN the process fake records gh api -X PUT /repos/{repo}/environments/{environment}/secrets/{secret} --input -, and the value appears in no argument, state file or output.

Requirement: Each kept call names its upstream item

The onboard command MUST name the upstream issue or PR in each kept small API call.

Scenario: The kept calls name their upstream items

  • WHEN a test reads the constants or comments of the kept calls
  • THEN the calls name integrations/terraform-provider-github#3664, integrations/terraform-provider-github#2746 and integrations/terraform-provider-github#3315.

Requirement: Route ownership test lists only kept routes

The route-ownership test SHALL list only the onboard routes that stay.

Scenario: The route-ownership test passes

  • WHEN uv run devops ci test tests/github/onboard/test_onboard_routes.py runs
  • THEN it exits 0 and ROUTES holds no deleted route.

Requirement: New ADR supersedes ADR 0035

The change SHALL add a new accepted ADR that supersedes ADR 0035 and records the OpenTofu ownership of decisions 1, 4 and 7 of ADR 0026, with labels and the webhook in the provider and the main ruleset in the provider except the code_quality rule.

Scenario: The ADR records are consistent

  • WHEN uv run devops ci test tests/invariants/test_adr_records.py runs and a test reads the records
  • THEN the command exits 0, the new record has status: accepted and supersedes: ["0035"], ADR 0035 has status: superseded and a superseded-by key that names the new record, and the new record names the provider resources for the labels and the webhook and the small code_quality call.

Requirement: Pending a person after the merge

A person MUST merge the pull request that holds the new ADR and the deletion before the OpenTofu stacks replace the onboard rows.

Scenario: The ADR is superseded

  • WHEN the pull request passes its checks and a person merges it
  • THEN ADR 0035 records superseded and the new ADR records the OpenTofu ownership of decisions 1, 4 and 7 with the new scope.

Existing Tool Considered

No alternatives check has run. The open tool that covers the need is integrations/terraform-provider-github (MIT, v6.13.0, active) with OpenTofu. It covers repository and security settings, environments, the main ruleset, labels, the webhook and workflow permissions. It lacks the code_quality ruleset rule (integrations/terraform-provider-github#3664), immutable releases (#2746), code scanning default setup (#3315) and a state-free way to set environment secret values; the change keeps one small API call for each of the first three and the existing devops gh secret sync --env path for the last. safe-settings 3.0.0 and repository-settings/app 5.0.16 need a hosted App, and ADR 0026 rejected safe-settings.

Key questions

  • Which tool should manage the repository settings?: Use the OpenTofu provider integrations/terraform-provider-github (MIT, v6.13.0) after a new ADR supersedes ADR 0035. ADR 0026 chose OpenTofu, and the provider covers the settings. ADR 0035 is in force and rejects OpenTofu, so the new ADR is the record that restores the OpenTofu ownership. (best practice) [sources: docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:27, docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:63, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:27, https://github.com/integrations/terraform-provider-github]
    • Chosen: OpenTofu with integrations/terraform-provider-github. ADR 0026 chose it, and the provider covers the settings.
    • Rejected: Keep the onboard engine. The owner rejects more custom code, and ADR 0035 is the record to supersede.
    • Rejected: safe-settings. It needs a hosted App, and ADR 0026 rejected it.
    • Rejected: repository-settings/app. It needs a hosted App.
  • Which settings does the provider cover, and which gaps need a small API call?: The provider covers the repository and security settings, the environments, the main ruleset, the labels, the webhook and the workflow permissions. It lacks the code_quality ruleset rule, immutable releases, code scanning default setup and a state-free environment secret value. The change keeps one small API call for each of the first three and the existing sync_repository_secrets(..., environment=...) path for the last. [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:14, docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:20, src/devops_cli/github/onboard/settings_rows.py:281, src/devops_cli/github/onboard/settings_rows.py:374, src/devops_cli/github/onboard/settings_rows.py:780, src/devops_cli/github/onboard/service_rows.py:151, src/devops_cli/github/onboard/service_rows.py:271, src/devops_cli/github/onboard/routes.py:159, https://github.com/integrations/terraform-provider-github]
  • How should the small API calls be kept?: Keep one small API call for each gap, and route each through RouteWriter so the route table still guards the write. Each call names its upstream item: integrations/terraform-provider-github#3664 for the code_quality rule, #2746 for immutable releases and #3315 for code scanning default setup. The environment secret value stays with the existing devops gh secret sync --env path. (best practice) [sources: docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:14, src/devops_cli/github/onboard/settings_rows.py:626, src/devops_cli/github/onboard/routes.py:98]
    • Chosen: Keep one small API call for each gap. The provider does not cover the gap, and the call keeps the setting managed without a second full engine.
    • Rejected: Wait for the provider to cover the gap. The upstream items are open and would block the replacement.
    • Rejected: Build a custom provider. This adds the custom code that the owner rejects.
  • How should the environment secret value be set?: Keep the existing sync_repository_secrets(..., environment=...) path with the Vault source. It reads the environment public key, seals the value with libsodium and sends the sealed body on stdin through gh api -X PUT ... --input -, so the value reaches neither the state nor the process arguments nor the output. Do not use gh secret set: the project rejected it in feat(gh): seal a secret into an environment with secret sync #6781 because it puts the value in the process arguments or in its own stdin form and bypasses the run_gh rate limiter and the dry-run plan. (best practice) [sources: openspec/changes/archive/2026-11-22-6781-secret-sync-environment/proposal.md:31, src/devops_cli/github/secrets.py:194, src/devops_cli/github/secrets.py:235, src/devops_cli/github/onboard/settings_rows.py:577]
  • Where do the OpenTofu root stacks and the shared module live?: The root stacks live in dan-petty/homelab under tf/github/; the shared module lives in dan-petty/infra as tf/modules/github-repository. [sources: docs/adr/0032-infrastructure-templates-live-in-four-homes.md:69, docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:27]
  • Who runs tofu apply?: Only a person runs tofu apply. Agents write the stacks and run tofu plan with the read-only devops-settings-reader App. (best practice) [sources: AGENTS.md:21, docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:35]
    • Chosen: Only a person applies. AGENTS.md says only a person changes repository settings, and ADR 0026 gives the apply to the owner.
    • Rejected: An agent applies. AGENTS.md forbids an agent to change repository settings.
  • Which part of the replacement does this issue deliver?: This issue delivers the devops-cli deletion: rows 2, 3, 5, 8, 10 and 12, their routes and tests, the diff in model.py, the small calls for the provider gaps, and the new ADR. The OpenTofu root stacks and the shared module are feat(tf): declare and import devops-cli in tf/github/dan-petty #5325's stack form and live in dan-petty/homelab and dan-petty/infra; the template and schema change in dan-petty/github-workflows is also feat(tf): declare and import devops-cli in tf/github/dan-petty #5325. One PR in devops-cli cannot deliver those, so this issue depends on feat(tf): declare and import devops-cli in tf/github/dan-petty #5325. (best practice) [sources: docs/adr/0032-infrastructure-templates-live-in-four-homes.md:69, docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:27, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:80, src/devops_cli/github/onboard/routes.py:98]
    • Chosen: Deliver the devops-cli deletion and the new ADR. The deletion, the small calls and the ADR are all in devops-cli, so one PR can deliver them.
    • Rejected: Deliver the stacks and the module in this issue. The root stacks live in dan-petty/homelab and the shared module in dan-petty/infra, so one PR in devops-cli cannot deliver them.
    • Rejected: Deliver the template and schema change here. Those files live in dan-petty/github-workflows, so one PR in devops-cli cannot deliver them.
  • How should the project change ADR 0035?: Supersede ADR 0035 with a new accepted record. An accepted record's body does not change, so the new record names supersedes: ["0035"], ADR 0035 gets status: superseded and superseded-by, and the new record records the new scope. (best practice) [sources: docs/adr/README.md:28, docs/adr/README.md:42, docs/adr/0035-the-onboard-command-owns-the-repository-settings.md:63]
    • Chosen: Supersede ADR 0035 with a new record. The ADR rules forbid a body edit of an accepted record, and a supersession links both records.
    • Rejected: Amend ADR 0035 in place. tests/invariants/test_adr_records.py fails the body hash when an accepted record's body changes.
    • Rejected: Leave ADR 0035 in force. It rejects OpenTofu for the repository settings.
  • Which ADR 0026 decisions does the new record restore?: It restores the OpenTofu ownership of decisions 1, 4 and 7, and it records the scope changes: labels and the webhook move to the provider, and the main ruleset moves to the provider except the code_quality rule. Decisions 4 and 7 as written keep labels, webhooks and the ruleset out of code, so the new record amends them. (best practice) [sources: docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:39, docs/adr/0026-github-settings-are-opentofu-code-the-owner-applies.md:49, src/devops_cli/github/onboard/service_rows.py:151, src/devops_cli/github/onboard/service_rows.py:271, src/devops_cli/github/onboard/settings_rows.py:780]
    • Chosen: Restore the OpenTofu ownership with the new scope. The issue moves labels and the webhook to provider resources and the ruleset to the provider except the code_quality rule.
    • Rejected: Restore decisions 4 and 7 as written. Decision 4 keeps labels and webhooks out of the state, and decision 7 keeps the ruleset unmanaged; both contradict the provider resources.
    • Rejected: Keep the onboard engine. The owner rejects more custom code where an open tool solves the problem.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#5325

Activity

  1. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor
    • Priority: The settings engine produced 15 issues and 5 fix PRs in 30 days, an increased error rate the owner directed to fix by replacement.
  2. added
    type/refactor
    source/agent
    status/new
    effort/high
    value/high
    scope/repos
    priority/p1-high
    on Nov 28, 2026
  3. 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.

  4. added
    owner/agent
    status/in-progress
    and removed
    status/new
    on Nov 28, 2026
  5. dan-petty commented on Nov 28, 2026

    @dan-petty
    OwnerAuthor

    Facts for the replacement, from the review of PR #7481 (2026-11-28). They were filed as #7494, which I close as not planned because it patched the onboard rows that this item replaces:

    • Row 10 merges only the rules of a live ruleset. The top-level keys conditions, bypass_actors and enforcement come from the baseline, so a wider live scope, fewer bypass actors or a stricter enforcement is written over with no warning.
    • A live required check entry loses its integration_id when the baseline names the same check without one. The next run shows no difference, because the compare accepts the extra live key.

    With github_repository_ruleset of integrations/github, these keys are in the declared resource, and tofu plan shows a difference in each of them as drift, so the replacement needs no merge code for them. A check for the replacement: a plan of a repository whose live ruleset has a wider conditions.ref_name.include or an integration_id on a check shows the difference and writes nothing.

  6. added 3 commits that reference this issue on Nov 28, 2026
  7. added 3 commits that reference this issue on Nov 28, 2026
  8. dan-petty commented on Nov 30, 2026

    @dan-petty
    OwnerAuthor

    A defect of the settings rows. The replacement must not copy it.

    src/devops_cli/github/onboard/settings_rows.py reads a failed request with status 403 as a limit of the plan, or as a setting that cannot be read (probe_rulesets, _enabled, _settings_endpoint and the environment row). A rate limit also has status 403.

    Offline probe: a primary rate limit (GitHubRateLimitError) on the ruleset read of a private repository sets plan_limited and gives no failure reason. The probe ran probe_rulesets only. The other three places have the same condition in the source.

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/highowner/agentpriority/p1-highscope/repossource/agentstatus/in-progresstype/refactorvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions