Repository navigation
Description
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-201makes the diff.settings_rows.py:280-311sends the repository PATCH.settings_rows.py:373-549writes the security settings and the environments.settings_rows.py:576-625writes the environment secret.settings_rows.py:626-786creates and updates the ruleset, and merges the required checks.service_rows.py:151-170writes the labels.service_rows.py:271-327writes the webhook.routes.py:31-491holds the routes.run.py:170-252sets the row order.- In dan-petty/github-workflows,
templates/repository/github/repository.yaml.jinja:1-119holds raw REST bodies.templates/github-repository.schema.jsonis a hand-written schema of 391 lines.
The engine broke often in the last 30 days:
- Issues: fix(roadmap): onboard counts a hook with every event as wrong #6431, fix(roadmap): onboard counts a wildcard hook as missing events #6662, fix(repos): a missing merge setting is not drift #6875, fix(repos): onboard reads the release App client ID from GitHub #7305 (open), fix(repos): onboard writes no webhook from a default URL #7308, fix(repos): onboard reads the template answers from the repository #7309 (open), fix(repos): the template row removes a file of an old baseline #7310 (open), fix(repos): onboard requires a skipped check name #7318, fix(repos): onboard lowers a stricter ruleset #7326 (open), fix(repos): derive the template answers of an existing repository #7406 (open), fix(repos): a kept template file conflicts at copier update #7411 (open), fix(repos): onboard ignores the repo's own required checks #7423, fix(repos): onboard row 10 hides which ruleset key differs #7445 (open), fix(repos): onboard requires checks of a merged template pull request #7476, fix(repos): onboard cannot remove a required check #7489.
- Fix PRs: fix(repos): a field that GitHub leaves out is not drift #6878, fix(repos): Guard the webhook row against the default URL #7391, fix(repos): onboard requires the checks of github/repository.yaml #7446, fix(repos): Require only check runs that ended success #7470, fix(repos): onboard requires checks of a merged template pull request #7477.
A plan engine removes these bug classes by design:
- fix(repos): a missing merge setting is not drift #6875: a missing field was read as drift.
- fix(repos): onboard row 10 hides which ruleset key differs #7445: the report did not tell which key differs.
- fix(repos): onboard cannot remove a required check #7489: the engine cannot remove a required check.
- fix(repos): onboard requires a skipped check name #7318, fix(repos): onboard ignores the repo's own required checks #7423 and fix(repos): onboard requires checks of a merged template pull request #7476: the engine derived the required checks from the checks that reported.
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.
- Tool: integrations/terraform-provider-github (https://github.com/integrations/terraform-provider-github), MIT, v6.13.0 (2026-07-08). The repository is active.
- Engine: OpenTofu with the Kubernetes backend in namespace
tofu-state. This namespace now exists in dan-petty/homelab (k8s/namespaces.yaml, homelab change 379, archived 2026-11-27). - Layout, as ADR 0026 and feat(gh): manage GitHub organization and repository settings as code #5311 say: the root stacks go in dan-petty/homelab
tf/github/, and the shared module goes in dan-petty/infra. Import blocks withfor_eachstay in the code, so a plan can rebuild a lost state. - Agents write the stacks and run
tofu plan. Only a person runstofu apply.
These settings move to provider resources:
github_repository: the repository settings and the security settings.github_repository_ruleset: themainruleset 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:
- The
code_qualityrule of the ruleset. The provider cannot hold it until [FEAT]: Support the code_quality rule and require_extra_approval_for_unattributed_changes in rulesets integrations/terraform-provider-github#3664 ships. That issue was open on 2026-11-28. Keep one small API call for this rule only. - Immutable releases. v6.13.0 has no resource for them. Upstream issue fix(security): refuse the keys that make a child write a file #2746 is open, and the PRs fix(k8s): a direct embedding call must not reach the 48 GiB tier #3574 and test(k8s): measure volume move copy reliability live #3701 closed with no merge. Keep one small API call.
- Code scanning default setup. v6.13.0 has no resource for it. Upstream PR fix(pr): open a plan pull request with a Plans line #3315 is open. Keep one small API call.
- The values of environment secrets. A value in a resource goes into the state. Keep the Vault source, and set the value with
gh secret set. - The template PR, and the Service, cluster, RAG and OpenSpec rows. They are not repository settings.
Delete:
- The diff of
model.py. - The rows that the provider covers: repository, security, environments, ruleset, labels and webhook. Also their routes in
routes.pyand their tests. - The REST bodies of
repository.yaml.jinjaandgithub-repository.schema.jsonin 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:
- feat(gh): manage GitHub organization and repository settings as code #5311 tracks settings as code. Its update of 2026-11-26 gave the repository settings to onboard. This item reverses that update.
- feat(tf): declare and import devops-cli in tf/github/dan-petty #5325 changed on 2026-11-26 to add onboard rows. It goes back to its stack form.
- feat(k8s): find GitHub settings drift every night with a read-only App #5328 finds drift every night with a read-only App. It runs the plan of these stacks.
- refactor(gh): remove the classic devops gh branch-protection group #5329 deletes the classic
devops gh branch-protectiongroup. It stays valid. - The route-ownership test of feat(repos): onboard a repository with one command #6773 must list only the routes that stay.
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 planof 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-exitcodeand reports drift.
Source
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_NAMESinsrc/devops_cli/github/onboard/run.pyand imports theonboardmodules - THEN
ROW_NAMESholds no entry for rows 2, 3, 5, 8, 10 or 12, and the modules hold norepository_row,security_row,environment_row,labels_row,ruleset_roworwebhook_rowfunction.
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
ROUTESinsrc/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-createorhook-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_differencesor_list_matchescallable.
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_qualityrule and a live ruleset that lacks it - THEN the GitHub API fake records a
PUT /repos/{repo}/rulesets/{ruleset}body whoserulescontains a rule of typecode_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-setupwith a body that setsstatetoconfigured.
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#2746andintegrations/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.pyruns - THEN it exits 0 and
ROUTESholds 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.pyruns and a test reads the records - THEN the command exits 0, the new record has
status: acceptedandsupersedes: ["0035"], ADR 0035 hasstatus: supersededand asuperseded-bykey that names the new record, and the new record names the provider resources for the labels and the webhook and the smallcode_qualitycall.
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
supersededand 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
mainruleset, the labels, the webhook and the workflow permissions. It lacks thecode_qualityruleset 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 existingsync_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
RouteWriterso the route table still guards the write. Each call names its upstream item:integrations/terraform-provider-github#3664for thecode_qualityrule,#2746for immutable releases and#3315for code scanning default setup. The environment secret value stays with the existingdevops gh secret sync --envpath. (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 throughgh api -X PUT ... --input -, so the value reaches neither the state nor the process arguments nor the output. Do not usegh 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 therun_ghrate 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]- Chosen: Keep the existing sync path with the Vault source. It already seals the value and sends it on stdin through
gh api, and the project rejectedgh secret setin feat(gh): seal a secret into an environment with secret sync #6781. - Rejected: Use
gh secret set. The project rejected it in feat(gh): seal a secret into an environment with secret sync #6781: the value reaches the process arguments or its own stdin form, and it bypassesrun_ghand the dry-run plan. - Rejected: Use an OpenTofu environment secret resource. The value would go into the state.
- Chosen: Keep the existing sync path with the Vault source. It already seals the value and sends it on stdin through
- Where do the OpenTofu root stacks and the shared module live?: The root stacks live in
dan-petty/homelabundertf/github/; the shared module lives indan-petty/infraastf/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 runstofu apply. Agents write the stacks and runtofu planwith the read-onlydevops-settings-readerApp. (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 indan-petty/homelabanddan-petty/infra; the template and schema change indan-petty/github-workflowsis 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 getsstatus: supersededandsuperseded-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.pyfails 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
mainruleset moves to the provider except thecode_qualityrule. 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_qualityrule. - 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.
- 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
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 28, 2026
The settings engine produced 15 issues and 5 fix PRs in 30 days, an increased error rate the owner directed to fix by replacement.devops-cli-service commentedon Nov 28, 2026
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.
dan-petty commentedon Nov 28, 2026
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:
rulesof a live ruleset. The top-level keysconditions,bypass_actorsandenforcementcome from the baseline, so a wider live scope, fewer bypass actors or a stricter enforcement is written over with no warning.integration_idwhen 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_rulesetof integrations/github, these keys are in the declared resource, andtofu planshows 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 widerconditions.ref_name.includeor anintegration_idon a check shows the difference and writes nothing.docs(openspec): plan #7497 replace the onboard settings rows with Ope…
docs(openspec): plan #7497 replace the onboard settings rows with Ope…
docs(spec): plan #7497 replace the onboard settings rows with OpenTofu (
docs(spec): plan #7497 apply the GitHub settings in CI after the owne…
docs(spec): update #7497 OpenSpec plan to satisfy plan-check rules
docs(spec): plan #7497 apply settings in CI after the owner approves (#…
dan-petty commentedon Nov 30, 2026
A defect of the settings rows. The replacement must not copy it.
src/devops_cli/github/onboard/settings_rows.pyreads a failed request with status 403 as a limit of the plan, or as a setting that cannot be read (probe_rulesets,_enabled,_settings_endpointand 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 setsplan_limitedand gives no failure reason. The probe ranprobe_rulesetsonly. The other three places have the same condition in the source.