diff --git a/checks.tf b/checks.tf index b9d8e94..ca56eb8 100644 --- a/checks.tf +++ b/checks.tf @@ -132,9 +132,15 @@ check "zero_bypass_actors" { assert { condition = alltrue([ for name, gate in module.repository_policy.ruleset_enforcement : - length(gate.bypass_actors) == 0 + length(gate.bypass_actors) == 0 || ( + name == "velnor-new" && + length(gate.bypass_actors) == 1 && + one(gate.bypass_actors).actor_id == 5 && + one(gate.bypass_actors).actor_type == "RepositoryRole" && + one(gate.bypass_actors).bypass_mode == "pull_request" + ) ]) - error_message = "No repository may declare bypass actors on its protect-main ruleset." + error_message = "No repository may declare bypass actors on its protect-main ruleset, except the repository-admin pull_request bypass on tailrocks/velnor-new (owner approved 2026-11-19)." } } diff --git a/modules/repository-policy/main.tf b/modules/repository-policy/main.tf index fe34449..5e2bb46 100644 --- a/modules/repository-policy/main.tf +++ b/modules/repository-policy/main.tf @@ -113,9 +113,19 @@ resource "github_repository_ruleset" "protect_main" { } } - # MANDATORY INVARIANT: Zero standing bypasses on core protections. + # MANDATORY INVARIANT: Zero standing bypasses on core protections, + # except the explicit admin_pull_request_bypass opt-in (pull_request mode only: no direct pushes). # Direct pushes, non-squash integration, force pushes, and deletion are blocked for all actors. + dynamic "bypass_actors" { + for_each = var.repository_policies[each.value].admin_pull_request_bypass ? [1] : [] + content { + actor_id = 5 # RepositoryRole: repository admin + actor_type = "RepositoryRole" + bypass_mode = "pull_request" + } + } + rules { deletion = true non_fast_forward = true diff --git a/modules/repository-policy/variables.tf b/modules/repository-policy/variables.tf index 260be3b..e31e399 100644 --- a/modules/repository-policy/variables.tf +++ b/modules/repository-policy/variables.tf @@ -20,6 +20,8 @@ variable "repository_policies" { include = list(string) bypass_user_ids = list(number) })), {}) + # Let repository admins bypass protect-main, only through a pull request (admin merge). + admin_pull_request_bypass = optional(bool, false) # Merge queue on the default branch. null (the default) leaves the queue off. merge_queue = optional(object({ grouping_strategy = string diff --git a/variables.tf b/variables.tf index 9c4223b..7c5f2e1 100644 --- a/variables.tf +++ b/variables.tf @@ -33,6 +33,8 @@ variable "repository_policies" { include = list(string) bypass_user_ids = list(number) })), {}) + # Let repository admins bypass protect-main, only through a pull request (admin merge). + admin_pull_request_bypass = optional(bool, false) # Merge queue on the default branch. null (the default) leaves the queue off. merge_queue = optional(object({ grouping_strategy = string @@ -282,9 +284,11 @@ variable "repository_policies" { required_checks = ["DCO", "Required"] } "velnor-new" = { - visibility = "public" - required_checks = ["Required", "Required verdict"] - protect_tags_update = true + visibility = "public" + required_checks = ["Required", "Required verdict"] + # Owner approved 2026-11-19: admin merges for rare critical-path cases. + admin_pull_request_bypass = true + protect_tags_update = true # Batched queue (owner decision 2026-11-18): 13 runners fit about one full CI run, # so only the newest entry of a group must pass and up to 10 PRs merge per run. merge_queue = {