Skip to content

feat: enforce protected files for merge-pull-request - #76771

Merged
pelikhan merged 4 commits into
mainfrom
pelikhan/merge-pr-rai-analysis
Nov 11, 2026
Merged

pelikhan merged 4 commits into
mainfrom
pelikhan/merge-pr-rai-analysis

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Why

merge-pull-request previously relied on protected-file caution notices rather than inspecting actual changes. A PR without those notices could merge protected files into an otherwise eligible feature branch.

Approach

  • Block protected-file changes by default using the same protected set, engine-specific files, matching, and exclusions as create-pull-request, including repository-wide exceptions and the default CHANGELOG.md exception.
  • Inspect the complete live PR file list, including deleted paths and both sides of renames, and repeat the check before merging or producing a staged preview. Missing, malformed, duplicate, or incomplete evidence fails closed; PRs exceeding GitHub's 3000-file listing limit are blocked.
  • Support protected-files: allowed as an explicit workflow-owned opt-out and object-form scoped exclusions. Creation-specific request-review and fallback-to-issue policies are intentionally unsupported. Existing caution, branch, and review gates remain enforced; required-approvers remains optional.
  • Serialize dynamic protected-file policies as raw toJSON(...) values in both handler-manager and MCP configurations, preventing quoted or multiline input from overwriting sibling merge gates.
  • Preserve exclusions from overridden imports, report protected-file counts rather than raw paths, and provide operator guidance in summaries and the debugging playbook.

Migration

This changes existing behavior and carries a major changeset. Workflows that intentionally merge protected files must configure scoped protected-files.exclude exceptions or explicitly set protected-files: allowed, then recompile; otherwise keep the default and merge those PRs manually. The opt-out does not bypass caution notices or other gates.

ADR: ADR-76771: Enforce Protected-File Checks for merge-pull-request

Validation

  • Focused parser/compiler checks passed for the initial implementation. Follow-up Go tests cover imported exclusions, the rooted changeset exception, and dynamic-policy serialization for both configuration paths, including quoted/multiline input.
  • First follow-up JavaScript merge, summary, audit, and handler-manager suites: 586 passed, 3 skipped. Latest merge runtime suite: 230 passed.
  • Latest build, standard Go lint, JavaScript lint, type checking, and impacted tests passed. The full make agent-report-progress gate remains blocked by the same 12 pre-existing custom-linter diagnostics in unchanged portions of pkg/workflow/imports.go.
  • Separately ran workflow drift validation: all 365 workflows compiled with no lock-file drift.

Limitations

GitHub atomically enforces only the evaluated head SHA. File inspection and other mutable policy reads do not eliminate the race window between final revalidation and the merge API call. No live merge or workflow dispatch was performed. The ADR records implemented user direction without claiming unrecorded maintainer sign-off.

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

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

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 Ponytail Reviewer · routed: gpt61 medium · ~7 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 181 · ◷

Generated by Ponytail Reviewer for #76771

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #76771

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 11, 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 11, 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 11, 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

Comment thread actions/setup/js/merge_pull_request.cjs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

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

Evidence: 121 added lines in business-logic directories (pkg/), above the 100-line threshold. The implementation label is not set, and the PR body links no ADR.

📄 Draft ADR committed: docs/adr/76771-enforce-protected-files-for-merge-pull-request.md — review and complete it before merging. Items marked [TODO: verify] need human confirmation.

🔒 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

  2. Complete the missing sections — add context the AI couldn't infer, refine the decision rationale, and list real alternatives you 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-76771: Enforce Protected-File Checks 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/. This ADR is numbered by the full five-digit PR number, matching existing entries such as 27523-....

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ⊞ 8.5K · ◷
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.

Reviewed PR head 960ea62 against safe-outputs specification 1.29.22 and related protected-file contracts. The implementation and tests substantively align: default-blocked complete changed-file inspection, rename old/new paths, fail-closed malformed/incomplete/count limits, and final revalidation. Synchronized docs/src/content/docs/specs/safe-outputs-specification.md to version 1.29.23 with metadata and changelog updates; the specification-only commit was queued to the same-repository PR branch. No blocking conformance findings identified.

Generated by PR Specification Reviewer for #76771 · copilot · gpt50 · ~8 AIC · ⌖ ~2 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.

Reviewed the changed lines and relevant implementation paths. I found no actionable correctness, security, performance, or maintainability issues requiring a blocking comment. This was a static review; tests were not run.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~8 AIC · ⌖ ~1 AIC · ⊞ 1.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.

Skills-Based Review 🧠

Applied /tdd, /diagnosing-bugs, and /grill-with-docs. Requesting changes for one confirmed correctness bug. The fail-closed design is sound.

📋 Key Themes and Highlights

Blocking

  • Import exclusions dropped for merge-pull-request (inline on safe_outputs_handler_registry_pull_requests.go). MergeSafeOutputs only re-applies accumulated protected-files.exclude for create and push types. A temporary repro confirmed it: the create-pull-request control kept its exclusion, and merge-pull-request returned an empty list.

Non-blocking

  • Changeset bump and migration (inline on .changeset/merge-protected-files.md). This is default-on, so it should state the migration path and confirm minor vs major.
  • Test mock ordering (inline on merge_pull_request.test.cjs). Sequenced listFiles mocks can shift silently. Assert the pagination call count.
  • Debug playbook gap. .github/aw/debug-playbook.md (around line 203) lists merge failure codes but omits protected_files_modified, so operators get no remedy for this new block.
  • Summary advice gap. safe_output_summary.cjs (line 395) gives tailored advice only for manual_review_caution. Consider the same for protected_files_modified.

Positive Highlights

  • ✅ Fail-closed on malformed, partial, or over-3000 file evidence, and on unknown policy values.
  • ✅ Checks both rename sides and re-evaluates the file list at final revalidation.
  • ✅ Reuses the create-pull-request protected set, so the two stay consistent.

@copilot please address the review comments above.

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

Comment thread .changeset/merge-protected-files.md 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

Dynamic protected-file expressions lack JSON-safe serialization, risking configuration corruption or merge-gate overrides, and merge handlers silently discard imported exclusions.

2 open issues
What changed in this PR

Adds live protected-file enforcement to gh-aw’s merge-pull-request safe output, supplementing caution notices while preserving existing merge gates.

Changes:

  • Checks complete PR file lists, including deletions and rename paths, and repeats protection checks before merging or staged previews.
  • Adds shared protection rules, scoped exclusions, and a trusted allowed opt-out through schema and compiler configuration.
  • Expands tests, audit codes, tool descriptions, documentation, and release notes.
File Description
pkg/​workflow/​safe_outputs_validation_merge_pull_request_test.go Tests policy parsing and handler defaults.
pkg/​workflow/​safe_outputs_handler_registry_pull_requests.go Emits merge file-protection configuration.
pkg/​workflow/​merge_pull_request.go Parses and validates protection policies.
pkg/​workflow/​js/​safe_outputs_tools.json Updates the embedded merge tool description.
pkg/​workflow/​compiler_safe_outputs_config_protection_test.go Tests compiled exclusions and shared protection rules.
pkg/​parser/​schemas/​main_workflow_schema.json Defines supported policies and exclusions.
pkg/​parser/​schema_test.go Extends exclusion validation to merges.
pkg/​parser/​schema_merge_pull_request_test.go Tests accepted and rejected policy forms.
docs/​src/​content/​docs/​specs/​safe-outputs-specification.md Specifies file-inspection and revalidation requirements.
docs/​src/​content/​docs/​reference/​safe-outputs-pull-requests.md Documents defaults, exceptions, and limitations.
actions/​setup/​js/​safe_outputs_tools.json Updates the runtime merge tool description.
actions/​setup/​js/​safe_output_manifest.cjs Registers the protected-file failure code.
actions/​setup/​js/​merge_pull_request.test.cjs Covers protected paths, evidence validation, and rechecks.
actions/​setup/​js/​merge_pull_request.cjs Implements live file inspection and final revalidation.
.changeset/​merge-protected-files.md Adds a minor-release changeset.

Review effort: Max (auto)

Comment thread pkg/workflow/merge_pull_request.go Resolved
Preserve imported exclusions, minimize protected-file diagnostics, strengthen revalidation tests, document breaking migration, and complete the ADR.

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

Copy link
Copy Markdown
Collaborator Author

Regarding the Ponytail Reviewer completion notice: no code change is requested by this notification. I treated reported_no_action as informational rather than validation evidence and ran focused checks for the follow-up fixes.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the specification review: the normative protected-file rules were already present, but the reported version synchronization was not on the branch. Updated the specification metadata and history to 1.29.23 without changing those rules.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the ADR draft notification: reviewed and completed the generated ADR's context, decision, alternatives, and consequences. The record distinguishes implemented user direction from maintainer sign-off that has not been recorded.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the skills-based review: addressed import exclusions, migration/versioning, and endpoint-specific pagination assertions. Added protected_files_modified guidance in both the debug playbook and summaries, preserving manual review and existing caution vetoes.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the code-quality review: no code change is requested by this completion notice. The follow-up fixes have focused regression coverage; the final gate separately reports existing custom-linter violations in unchanged portions of imports.go.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the Test Quality Sentinel notice: reported_no_action is not proof of test coverage. Added explicit pagination and path-minimization assertions and ran the focused Go import regressions plus JavaScript merge, summary, audit, and handler-manager suites.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Accepted the ADR gate feedback. Completed ADR-76771, removed unsupported historical and validation claims, and linked it in the PR body without claiming unrecorded maintainer approval.

Use raw toJSON expressions for merge policies and cover quoted input in both generated configuration paths. Add the rooted imported-exclusion regression.

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

Copy link
Copy Markdown
Collaborator Author

Regarding the Ponytail completion notice: this was already acknowledged in the previous batch and requests no further code change. reported_no_action remains informational, not evidence that the implementation passes validation.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the specification completion notice: the prior fix already synchronized the protected-file specification metadata and history to 1.29.23. No additional specification change is requested here.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the ADR draft notification: the draft was completed in ebd399a387d and linked from the PR body. That record remains in place without claiming unrecorded maintainer sign-off.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the skills-review completion notice: the import, migration, pagination-assertion, and diagnostic-guidance fixes from the previous batch remain in place. No additional change follows from this repeated completion notice.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the code-quality completion notice: no further implementation change is requested. Static review and focused execution results remain separate evidence.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

Regarding the Test Quality Sentinel notice: no new change is requested by this repeated notification. The serialization and import cases are evaluated with focused tests rather than inferred from reported_no_action.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The ADR gate request is already addressed: ADR-76771 has completed context, decision, alternatives, and consequences and is linked in the PR body. No new ADR revision is needed for this repeated request.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

No further change is requested by this earlier acknowledgment. Its distinction between a no-action notification and actual validation evidence remains applicable.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

This earlier response is already reflected in the branch: specification version 1.29.23 and its history entry remain present. No additional version bump is needed for acknowledging the same review.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The completed ADR described in this earlier response remains unchanged. It continues to distinguish the implemented decision from unrecorded maintainer approval.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The fixes listed in this earlier response remain in place, including the major migration notice and protected-file operator guidance. This acknowledgment introduces no new implementation request.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

No additional change is requested by this earlier response. The existing custom-linter findings in unchanged portions of imports.go remain disclosed rather than being presented as a passing full gate.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The pagination and path-minimization regressions described in this earlier response remain part of the branch. This batch adds focused validation for the new serialization feedback instead of treating review notifications as test evidence.

@pelikhan

Copy link
Copy Markdown
Collaborator Author

The ADR completion and PR link described in this earlier response are already present. No further edit or claim of maintainer sign-off is warranted by this acknowledgment.

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.3

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants