Skip to content

Require scoped base branches for merge-pull-request - #77371

Merged
pelikhan merged 8 commits into
mainfrom
pelikhan/merge-rai-validation
Nov 13, 2026
Merged

pelikhan merged 8 commits into
mainfrom
pelikhan/merge-rai-validation

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Refusing default and protected branches does not by itself establish an explicit human-owned boundary for autonomous merges. Require repository owners to declare the non-consequential integration destinations that merge-pull-request may update.

Changes

  • Add mandatory, non-empty, static allowed-base-branches configuration. Reject wildcard/separator-only entries such as "*", "**", "*/*", and "**/**", GitHub Actions expressions, and unsupported glob operators; only * and ** are supported.
  • Match the live PR base branch during evaluation and require unchanged destination state through final snapshot revalidation, including staged and cross-repository operations. Agent tool-call arguments cannot override the policy.
  • Keep allowed-branches as an independent source filter and preserve default/protected-branch refusals, caution vetoes, protected-file checks, review gates, configured CI requirements, and head-SHA binding.
  • Expose nested merge-policy editor completions and add generated/published-data regression coverage.
  • Update schema, compiler/runtime configuration, regression fixtures, reference/specification documentation, and the breaking-change changeset.

ADR: ADR-77371: Require scoped base branches for merge-pull-request

Migration and limitations

Existing workflows must add a scoped destination list and recompile. Null/default-only merge configuration and omitted or empty destination lists are no longer accepted; destination policy is never inferred from source filters.

safe-outputs:
  merge-pull-request:
    allowed-base-branches: ["agent-work/*"]

This is an owner declaration of suitable integration scope, not automated proof of harmless downstream effects or per-merge human approval. Owners remain responsible for assessing downstream automation and protecting policy definitions from agent edits. The existing mutable-policy race remains: GitHub atomically enforces only the evaluated head SHA.

The existing specification-review detection caution remains intact and requires independent human review. Completing the proposed ADR or passing local checks does not clear it or imply maintainer approval.

Validation

  • All 273 focused merge runtime tests passed, including missing/wildcard policies, unsupported syntax, source/base distinctions, destination matching, retargeting to both allowed and disallowed bases, staged/cross-repository rejection, and protected/default-branch vetoes.
  • Two editor generator tests passed, including generated/published merge-data parity.
  • Targeted parser/compiler, safe-output, merge, and specification tests passed, including rejection of compact/embedded expressions before an executable lock file is emitted.
  • make agent-report-progress passed: build, JavaScript type checking/lint, change-scoped Go lint/custom analyzers, impacted tests, schema freshness, and workflow drift. Custom analyzer diagnostics were confined to unchanged files.
  • All 366 repository workflows compiled successfully with no lock-file drift.
  • Updated from main using make merge-main. No PR merge or manual workflow dispatch was performed.

pelikhan and others added 2 commits November 12, 2026 22:23
Add mandatory owner-declared destination allowlists, enforce them during merge evaluation and revalidation, and reject unrestricted wildcard policies. Preserve source filtering and all existing merge safeguards, with regression coverage and migration documentation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the merge destination policy change scoped by restoring the pre-existing generated maintenance workflow after the workflow-drift check.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review November 13, 2026 06:36
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 06:36
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #77371

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output. Detected threat types: malicious patch.

Review the workflow run logs for details.

Generated by PR Specification Reviewer for #77371

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What this change does: It requires an owner-defined list of destination branches for automated merges. The handler checks that policy alongside the existing merge gates.

Should fix: The final destination match duplicates the earlier match and the existing snapshot comparison. See the inline comment.

Verdict: Ship.
Lean: -3 lines possible.

Generated by ✂️ Ponytail Reviewer for #77371 · codex · routed: gpt61 medium · ~7 AIC · ⌖ ~1 AIC · ⊞ 182
Comment /ponytail to run again

Comment thread actions/setup/js/merge_pull_request.cjs Resolved

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review completed. I found one actionable documentation/editor regression: the autocomplete entry is marked expandable without nested properties, so the required merge destination configuration cannot be discovered or completed. No tests were run per review constraints; the specialist pass was unavailable because its diff access was denied.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (144 new lines in business-logic directories) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/77371-require-scoped-base-branches-for-merge-pull-request.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff. Rationale that the PR does not state is marked [TODO: verify].

  2. Complete the missing sections — add context the AI could not infer, refine the decision rationale, and confirm the listed alternatives are ones you actually considered.

  3. Commit the finalized ADR to docs/adr/ on your branch

  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-77371: Require Scoped Base Branches for merge-pull-request (link unavailable: invalid HTTPS URL)

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say I'll deal with this later. Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 0042-use-postgresql.md for PR #42).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 8.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

agentic threat detected
Threat detection flagged this output in warn mode. Manual review is REQUIRED before any follow-up automation.

Details

Potential security threats were detected in the agent output. Detected threat types: malicious patch.

Review the workflow run logs for details.

Reviewed PR head 9150ef36ef0805bfbcf198952dba368d9d8ff399 against the Safe Outputs MCP Gateway Specification, §7.3 merge_pull_request requirements and MPR-001–MPR-005. The implementation, schema, runtime revalidation, and focused regression evidence align with the intentional allowed-base-branches change; protected/default branch refusals and existing gates remain preserved.

Synchronized docs/src/content/docs/specs/safe-outputs-specification.md to Version 1.30.0 (2026-11-13), clarified the mandatory destination-policy wording, and added the corresponding changelog entry. The specification-only commit is queued for publication to the same-repository PR branch.

Coverage limit: this was a static contract review; tests were not run.

Generated by PR Specification Reviewer for #77371 · copilot · gpt50 · ~6 AIC · ⌖ ~3 AIC · ⊞ 1.6K
Comment /review-specs to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /diagnosing-bugs, /tdd and /codebase-design to the destination-policy changes. Requesting changes on one correctness gap in the new wildcard guard.

📋 Key Themes & Highlights

Key Themes

  • Incomplete wildcard rejection (blocking): The guard is implemented three times (JS at merge_pull_request.cjs:610, Go at merge_pull_request.go:147, schema at main_workflow_schema.json:10906). Each one rejects only runs of *, so **/*, */*, */** and **/** pass all three. I confirmed with globPatternToRegex and the Go validator. These patterns match nearly every nested branch, which defeats the stated “scoped destination” boundary.
  • Regression coverage: The new tests cover * and ** but not slash-only variants. Add them so the fix is pinned.
  • Triplicated rule: The same check lives in three places. Keep the rule identical across them, or the layers will drift again.

Positive Highlights

  • ✅ The base-branch check runs at evaluation and again at final revalidation, so retargeting is caught.
  • ✅ allowed-base-branches is kept independent of allowed-branches, and the test for a destination match not bypassing the source filter is useful.
  • ✅ Protected and default-branch vetoes are preserved, with tests for each.

@copilot please address the inline comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~5 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again

Comment thread actions/setup/js/merge_pull_request.cjs Resolved
Comment thread pkg/workflow/merge_pull_request.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical validation gaps allow unencoded expressions to inject handler settings and overly broad or unsupported glob patterns to authorize unintended destination branches.

2 open issues
What changed in this PR

This PR adds an explicit destination boundary to gh-aw’s merge-pull-request safe output, requiring owners to declare which integration branches autonomous merges may update.

Changes:

  • Require non-empty allowed-base-branches configuration across the schema, compiler, and runtime types.
  • Check the live destination during evaluation and final revalidation while preserving existing merge gates.
  • Update regression coverage, examples, migration guidance, and the breaking-change changeset.
File Description
pkg/​workflow/​safe_outputs_validation_merge_pull_request_test.go Tests destination-policy validation and serialization.
pkg/​workflow/​safe_outputs_specification_merge_pull_request_test.go Checks that the specification documents the requirement.
pkg/​workflow/​safe_outputs_permissions_test.go Adds destination scope to permission-test fixtures.
pkg/​workflow/​safe_outputs_import_test.go Updates imported merge configurations.
pkg/​workflow/​safe_outputs_handler_registry_pull_requests.go Passes destination patterns to the runtime handler.
pkg/​workflow/​safe_outputs_allowed_labels_validation_test.go Updates the label-validation fixture.
pkg/​workflow/​merge_pull_request.go Parses and validates required destination patterns.
pkg/​workflow/​merge_pull_request_experimental_warning_test.go Updates the experimental-warning fixture.
pkg/​workflow/​compiler_safe_outputs_config_protection_test.go Updates the protected-file configuration fixture.
pkg/​workflow/​compiler_safe_outputs_config_pr_policy_test.go Verifies destination-policy serialization.
pkg/​parser/​schemas/​main_workflow_schema.json Requires destination patterns and removes null configuration.
pkg/​parser/​schema_test.go Updates protected-file schema fixtures.
pkg/​parser/​schema_safe_outputs_target_test.go Updates target-selection schema fixtures.
pkg/​parser/​schema_merge_pull_request_test.go Tests required lists and invalid destination configurations.
pkg/​cli/​workflows/​test-copilot-merge-pull-request.md Adds destination scope to the example workflow.
docs/​src/​content/​docs/​specs/​safe-outputs-specification.md Specifies destination matching and owner responsibilities.
docs/​src/​content/​docs/​reference/​safe-outputs-pull-requests.md Explains matching, migration, and policy limitations.
docs/​src/​content/​docs/​reference/​frontmatter-full.md Updates the full configuration reference.
docs/​public/​editor/​autocomplete-data.json Marks merge configuration as object-only.
actions/​setup/​js/​types/​safe-outputs-config.d.ts Declares the required workflow configuration field.
actions/​setup/​js/​types/​handler-factory.d.ts Declares the runtime destination-policy field.
actions/​setup/​js/​safe_output_manifest.cjs Recognizes the destination-rejection failure code.
actions/​setup/​js/​merge_pull_request.test.cjs Covers destination matching, retargeting, and existing vetoes.
actions/​setup/​js/​merge_pull_request.cjs Enforces destination policy before merging or previewing.
.github/​aw/​safe-outputs-management.md Updates agent-facing configuration guidance.
.changeset/​merge-required-base-branches.md Records the breaking requirement and migration.

Review effort: Max (dynamic)

Comment thread pkg/workflow/merge_pull_request.go Resolved
Comment thread pkg/workflow/merge_pull_request.go Resolved
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/merge_pull_request.cjs:968): address unresolved feedback - Review comment
  3. Review (docs/public/editor/autocomplete-data.json:3055): address unresolved feedback - Review comment
  4. Review (actions/setup/js/merge_pull_request.cjs:610): address unresolved feedback - Review comment
  5. Review (pkg/workflow/merge_pull_request.go:147): address unresolved feedback - Review comment
  6. Review (pkg/parser/schemas/main_workflow_schema.json:10906): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "45d8f8ec97ae6c285d9956a19dd3d5decbd6036e",
  "kind": "requested",
  "schema_version": "1",
  "state": "d2cf3a0ec068e11daa52c0d967d8fd2e0b995d8e8d7d4d367ad45b1c1916a4ed",
  "work": [
    "07b8fc9647941234c1e1a4e0336f5c13da6d030b3b1ab749b8e0c2791a9cf6ec",
    "37a406e7390a81793f6fbe91ab3e4fdfeafebe6e3735b91a53954a3bc099a4b7",
    "4d46aa1c6618044c692ae6442ff14c0093d5ca7560d77fdf4f34f6db35db1c03",
    "55101ecd244f4501f2d77cba60a652414fecf8fa1823609bdedba8831a5691bc",
    "ac37977c2c96860772840b62892f8e82c29f2bfe15fd2725377f73b75fd188de"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

Copilot AI and others added 3 commits November 13, 2026 07:32
…lidation

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
pelikhan and others added 2 commits November 13, 2026 04:42
Reject expressions and unsupported glob syntax consistently across schema, compiler and runtime; preserve scoped wildcard checks and snapshot-based retargeting protection. Add compiler, runtime and editor-data regressions, synchronize policy guidance, and complete the proposed ADR without claiming human review clearance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to Test Quality Sentinel: no code change is requested by this status notice. This batch was checked directly with focused regression tests and repository validation rather than treating the earlier no-op report as verification.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to Matt Pocock Skills Reviewer: accepted the actionable inline findings. Wildcard/separator-only destination patterns are rejected consistently across the schema, compiler and runtime, with regression cases for the reported forms.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to PR Code Quality Reviewer: accepted the inline autocomplete finding. Nested merge settings are discoverable in generated editor data, with a generator regression test covering the mandatory destination configuration.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to Ponytail Reviewer: accepted the inline simplification. The redundant final match is removed while snapshot-based retargeting protection and its regression coverage remain.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to Design Decision Gate: completed the generated ADR's rationale, alternatives and consequences and linked it in the PR description. This documents the decision without claiming an unavailable human RAI approval.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to PR Specification Reviewer: the existing detection artifact reports malicious_patch=true but supplies no reasons or warnings, so I cannot establish or clear the flagged concern from that evidence. The caution remains intact and requires independent human review; this batch does not approve or merge the PR.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to ADR Required: accepted the documentation request and completed ADR-77371, including context, decision, alternatives and consequences. The PR description now links it; the document does not substitute for independent human review.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

In response to PR Sous Chef: accepted the branch synchronization and code-feedback requests, ran make merge-main, and addressed the listed review findings. No PR merge or manual workflow dispatch was performed.

@pelikhan
pelikhan merged commit 35b0791 into main Nov 13, 2026
167 of 168 checks passed
@pelikhan
pelikhan deleted the pelikhan/merge-rai-validation branch November 13, 2026 13:10
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants