Repository navigation
fix(github): align the repo baseline ruleset with steward-default-branch - #1045
Conversation
Rename the baseline default-branch ruleset from Default to steward-default-branch, the one repo-steward manages, so remediation updates it in place instead of creating a competing ruleset. Mirror repo-steward's policy/baseline.toml [protection]: deletion, non_fast_forward, required_linear_history and required_signatures, with forks keeping only deletion and non_fast_forward, and the owner bypass (RepositoryRole 5, always). PR-only (steward-pull-request) and release-tag protection (steward-release-tags) stay with repo-steward, so pull_request is no longer managed here; like status checks and Copilot review, it is carried over untouched. Closes #1044 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
🟡 Changes recommended
Case-insensitive rule validation accepts uppercase values that are sent unchanged to GitHub, whose case-sensitive rule-type enum rejects them and causes creation or remediation to fail.
1 open issue
What changed in this PR
Aligns DotfilesHelpers’ default-branch protection with repo-steward, addressing #1044 by updating steward-default-branch rather than creating a competing ruleset.
Changes:
- Replaces legacy ruleset options with
RulesandForkRules, applying reduced protection to forks. - Preserves unmanaged rules, including
pull_request, while leaving PR-only and tag protection to repo-steward. - Updates documentation and tests for ruleset identity, drift detection, payloads, and fork remediation.
| File | Description |
|---|---|
tests/powershell/Profile.Tests.ps1 |
Adds the desired-rule helper to module checks. |
tests/powershell/OnePasswordCredential.Tests.ps1 |
Aligns ruleset fixtures with the new baseline. |
tests/powershell/GitHubRuleset.Tests.ps1 |
Tests managed rules, fork payloads, validation, and preservation. |
tests/powershell/GitHubRepoConfig.Tests.ps1 |
Updates baseline, drift, identity, and fork-remediation tests. |
tests/powershell/GitHubCredentialPlacement.Tests.ps1 |
Aligns credential-placement fixtures with the baseline. |
tests/powershell/GitHubApi.Tests.ps1 |
Updates API fixtures to use steward rules. |
home/dot_config/powershell/modules/DotfilesHelpers/Public/GitHubRuleset.ps1 |
Selects and validates desired rules while preserving unmanaged rules. |
home/dot_config/powershell/modules/DotfilesHelpers/Public/GitHubRepoConfig.ps1 |
Aligns baseline settings, drift detection, and fork-aware remediation. |
docs/github-repo-config.md |
Documents steward ownership, fork behavior, and replacement overrides. |
Review effort: Balanced
Rule-type validation is case-insensitive, but GitHub's rule-type enum is not. Return the canonical lower-case names so an override such as 'DELETION' no longer reaches the API as-is. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Summary
The
DotfilesHelpersbaseline managed a default-branch ruleset namedDefault, but every repo now uses repo-steward'ssteward-default-branch. RunningSet-GitHubRepoConfig -Category Rulesetwould have created a second, competing ruleset with different rules. This aligns the baseline with repo-steward'spolicy/baseline.toml[protection]:Default→steward-default-branch, so the existing ruleset is updated in place.deletion,non_fast_forward,required_linear_history,required_signatures. These are modelled asRulesandForkRuleslists that mirrorrequired_rulesandfork_rulesin the TOML. Unsupported types are rejected.deletionandnon_fast_forward, because GitHub's "Sync fork" pushes upstream commits that are neither signed nor linear. On a fork, linear history and signatures are reported as drift and removed when remediating.always).Behaviour change:
pull_requestis no longer managed hererepo-steward keeps PR-only in a separate
steward-pull-requestruleset, so a repo can be exempted from that rule alone. The livesteward-default-branchrulesets have nopull_requestrule. Managing one here would make the two tools fight, so the baseline dropsRequirePullRequest,RequiredApprovingReviewsandAllowedMergeMethods. Apull_requestrule found on the ruleset is now preserved like any other unmanaged rule, and is neither judged nor rewritten. Release-tag protection (steward-release-tags) is likewise documented as repo-steward's, rather than recognised here.Breaking for
-Baselineoverrides:RulesetkeysRequirePullRequest,RequiredApprovingReviews,BlockDeletion,BlockForcePushandAllowedMergeMethodsare gone; useRules/ForkRulesinstead. The docs and examples are updated.Docs
docs/github-repo-config.mdnow states that repo-steward is the reference and the two must stay in sync, explains the fork subset, and says PR-only and tag protection belong to repo-steward.Relationship to #1043
This branches from
mainand is independent of #1043; the two touch different parts of the same files. A trial merge of both branches is conflict-free, and the full Pester suite passes on the merged result (994 passed).Validation (local, on the owner's Windows machine)
SetPOST), preservingpull_requestverbatim, rejecting unsupported rule types, sending canonical lower-case rule types, and the rename.Read-only audit:
Get-GitHubRepoConfig -All -Check RulesetNone of the 27 has a competing branch ruleset;
ai-toolkitandnote-iqhave onlysteward-release-tags(tag), andentra-docs-prhas onlypush-protection(push). NoDefaultruleset remains on any repo. 10 of the 27 are forks, so they would get the fork rule set.Dry run:
... | Set-GitHubRepoConfig -Category Ruleset -WhatIfNothing was written. Excerpt (27 lines, one per repo):
Whether to create those 27 rulesets from here or let repo-steward do it is the owner's call; this PR only stops the two tools from diverging.
Closes #1044
Summary by CodeRabbit