GitHub connector: add effective branch rules and policy-guarded merge

Open 💬 0 comments Opened Aug 5, 2026 by nikoisthebest

Summary

The GitHub connector exposes useful PR, status, workflow, review, thread, auto-merge, and expected-head merge operations, but it does not expose the effective branch policy that governs a merge. A client therefore cannot safely distinguish “no requirements configured” from “requirements unknown or not queried,” and an admin-authenticated direct merge may bypass policy.

Please add a server-side, fail-closed guarded merge surface so deterministic automation can merge without treating model text or caller booleans as policy evidence.

Requested operations

github_get_effective_branch_rules

Inputs:

  • repository_full_name
  • branch

Behavior:

  • Read all active rules applying to the branch, including parent/repository rulesets and legacy branch protection.
  • Complete pagination before returning success.
  • Normalize required checks, required reviews, code-owner and last-push requirements, conversation resolution, merge-queue state, bypass applicability, and unknown rule types.
  • Return bounded query_complete, observation timestamps, and a deterministic snapshot digest.
  • Fail closed on partial, unknown, or contradictory policy.

github_policy_guarded_merge

Inputs:

  • repository_full_name
  • pr_number
  • expected_head_sha
  • expected_base_sha
  • expected_merge_tree_sha
  • merge_method
  • policy_snapshot_digest

Behavior:

  1. Refresh PR identity, effective branch rules, required checks, reviews, review threads, mergeability, base/head SHAs, and prospective merge tree in one bounded server-side operation.
  2. Reject incomplete, unknown, stale, pending, skipped, conflicting, or changed state.
  3. Never use admin/force bypass; bypass must be fixed to false rather than caller-controlled.
  4. Enforce expected head and compare expected base and merge tree before delivery.
  5. Perform at most one merge attempt.
  6. Return a typed outcome suitable for read-only reconciliation after an unknown delivery result.
  7. Verify the resulting default-branch tree after success.

An exact-head auto-merge operation would also help, but it should expose expectedHeadOid and retain the same policy refresh and no-bypass requirements.

Acceptance criteria

  • Empty check/review collections pass only when effective policy proves their required counts are zero.
  • Unknown rule types fail closed.
  • Head/base/tree/policy drift is rejected.
  • Admin-authenticated callers cannot silently bypass rules.
  • Responses are structured, bounded, and contain no credentials or unrelated repository content.
  • The final merge result is verified against the exact expected tree.

View original on GitHub ↗