Repository navigation
Description
Problem Description
Row 10 (Ruleset) of devops repos onboard merges only the rules of the live ruleset into the baseline ruleset (#7326, PR #7481). Two other parts of the live ruleset are still written over with no warning line:
- The top-level keys
conditions,bypass_actorsandenforcementcome from the baseline ruleset only. A live ruleset with a widerconditions.ref_name.include, fewerbypass_actorsor a stricterenforcementloses that setting at the next write. Rule 5 ofAGENTS.mdlets only the owner lower a security setting. - A live required check entry loses its
integration_idwhen the baseline names the same check without one._union_checksinsrc/devops_cli/github/onboard/ruleset_merge.pyand_with_required_checksinsrc/devops_cli/github/onboard/settings_rows.pykeep the baseline entry first. After the write, any app can report the check. The next run shows no difference, becausedifferencesaccepts the extra live key, so no output names the loss. This behavior was there before fix(repos): Keep live rules and stricter thresholds #7481.
Reproduction Steps
- Baseline ruleset
main:bypass_actors: [{actor_id: 5, actor_type: Integration, bypass_mode: always}],conditions.ref_name.include: ["~DEFAULT_BRANCH"], check entry{"context": "CodeQL"}. - Live ruleset
main:bypass_actors: [],conditions.ref_name.include: ["~DEFAULT_BRANCH", "refs/heads/release/*"], check entry{"context": "CodeQL", "integration_id": 57789}, and one other difference that makes row 10 write. - Run the calls of
ruleset_row:_kept_live_ruleset,merge_live_ruleset,_with_required_checks,held_differences.
Expected vs Actual Behavior
Expected: row 10 keeps each stricter top-level setting and each live integration_id, and writes one ! warning line for each setting that it keeps, as it does for each rule since #7326.
Actual: the PUT body removes refs/heads/release/* from the scope, adds the bypass actor, and sends {"context": "CodeQL"} with no integration_id. The row writes no warning line.
Environment Diagnostics
Found in the review of PR #7481 on 2026-11-28, with a scratch script on the branch fix/7326-onboard-lowers-a-stricter-ruleset. The live main ruleset of this repository has no integration_id on its checks today.
Logs, Traces, or Terminal Output
None.
Source
Source: #7481
Proposed design
Problem statement
Row 10 of devops repos onboard writes the baseline ruleset over the live ruleset. It keeps live rules only. It loses a wider conditions.ref_name.include, fewer bypass_actors, a stricter enforcement and a live check integration_id. It writes no warning line for these losses. The fix must merge these settings, keep the stricter value, and write one warning line for each kept setting.
Acceptance criteria
Requirement: Top-level include merge
Row 10 SHALL keep each live conditions.ref_name.include pattern that the baseline lacks and SHALL write one warning line for each kept pattern.
Scenario: Wider live branch scope
- WHEN The baseline ruleset has conditions.ref_name.include [~DEFAULT_BRANCH] and the live ruleset has [~DEFAULT_BRANCH, refs/heads/release/*].
- THEN merge_live_ruleset returns both include patterns and one warning line that contains keeps, conditions.ref_name.include and refs/heads/release/*.
Requirement: Bypass actor merge
Row 10 SHALL keep a live bypass_actors list when it grants fewer bypasses than the baseline list and SHALL write one warning line for that setting.
Scenario: Live has no bypass actor
- WHEN The baseline ruleset has one bypass actor and the live ruleset has an empty bypass_actors list.
- THEN merge_live_ruleset returns an empty bypass_actors list and one warning line that contains keeps and bypass_actors.
Requirement: Enforcement merge
Row 10 SHALL keep the live enforcement value when it is stricter than the baseline value and SHALL write one warning line for that setting.
Scenario: Live enforcement is active
- WHEN The baseline ruleset has enforcement evaluate and the live ruleset has enforcement active.
- THEN merge_live_ruleset returns enforcement active and one warning line that contains keeps and enforcement.
Requirement: Weaker live enforcement is raised
Row 10 SHALL write the baseline enforcement value when the live value is weaker and SHALL write no warning line for that value.
Scenario: Live enforcement is evaluate
- WHEN The baseline ruleset has enforcement active and the live ruleset has enforcement evaluate.
- THEN merge_live_ruleset returns enforcement active and no warning line contains enforcement.
Requirement: Check integration id is kept
Row 10 SHALL keep a live required check integration_id when the baseline entry of the same context has no integration_id.
Scenario: Live CodeQL check names an app
- WHEN The baseline check entry is context CodeQL with no integration_id and the live check entry is context CodeQL with integration_id 57789.
- THEN _union_checks returns a CodeQL entry with integration_id 57789.
Requirement: Check integration id warning
Row 10 SHALL write one warning line for each live required check integration_id that it keeps.
Scenario: Warning for kept check app
- WHEN The baseline check entry is context CodeQL with no integration_id and the live check entry is context CodeQL with integration_id 57789.
- THEN the change lines that ruleset_row builds contain one line that contains keeps, CodeQL and 57789.
Requirement: Baseline check app is kept
Row 10 SHALL keep a baseline required check integration_id when the live entry of the same context has no integration_id.
Scenario: Baseline CodeQL check names an app
- WHEN The baseline check entry is context CodeQL with integration_id 123 and the live check entry is context CodeQL with no integration_id.
- THEN _union_checks returns a CodeQL entry with integration_id 123.
Existing Tool Considered
No alternatives check has run. No open, maintained tool covers the merge policy. The GitHub REST ruleset API only reads and writes a ruleset. gidgethub covers the HTTP session, not the merge policy (ADR 0006). Extend the existing merge code: about 10,000 tokens and 2 hours to build, keep and fix.
Key questions
- How should row 10 merge the top-level ruleset settings conditions, bypass_actors and enforcement?: Use a per-key merge. For conditions.ref_name.include, keep the union of baseline and live patterns. For conditions.ref_name.exclude, keep the intersection. For bypass_actors, keep the intersection by actor identity. For enforcement, keep the higher rank active > evaluate > disabled. Write one warning line for each live value that this merge keeps. (best practice) [sources: src/devops_cli/github/onboard/ruleset_merge.py, AGENTS.md]
- Rejected: Keep the baseline top-level keys. This is the current defect: it lowers a stricter live setting.
- Rejected: Keep the live top-level keys. A weaker live setting would lower the baseline and break rule 5 of AGENTS.md.
- Chosen: Per-key stricter merge. It keeps each stricter value and writes a warning, as the rule merge does.
- How should row 10 merge a required check entry that has the same context on both sides?: Start from the baseline entry. Add each live key that the baseline entry lacks. Keep the live integration_id when the baseline entry has none. Write one warning line for that kept integration_id. Keep the baseline integration_id when the live entry has none. (best practice) [sources: src/devops_cli/github/onboard/ruleset_merge.py:110, src/devops_cli/github/onboard/settings_rows.py:732]
- Rejected: Keep the baseline entry first. This is the current defect: the live integration_id is dropped.
- Rejected: Keep the live entry first. A live entry with no integration_id would drop the baseline app.
- Chosen: Merge keys by context with baseline first. It keeps both sides and adds the live integration_id only when the baseline has none.
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 28, 2026
The tool silently lowers enforcement, adds bypass actors, and removes integration_id, which weakens security on every write.devops-cli-service commentedon Nov 28, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
dan-petty commentedon Nov 28, 2026
Closed as not planned: this item patches the ruleset rows of
devops repos onboard, and #7497 replaces those rows with OpenTofu (owner direction of 2026-11-27: replace the custom settings code, do not extend it). Its two facts are on #7497 as points that the replacement must cover: #7497 (comment)