Route centralized command dispatches to the triggering PR branch and harden PR checkout runtime#37187
Route centralized command dispatches to the triggering PR branch and harden PR checkout runtime#37187Copilot wants to merge 16 commits into
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
/scout do a security review on this change |
|
🔭 Recon complete! Scout has charted the territory. Map ready! 🗺️ |
🔍 Scout Research ReportTriggered by Executive SummaryThis PR resolves a well-known GitHub Actions limitation: Research surfaced two correctness gotchas and one security consideration worth confirming the PR handles. They are summarized below the fold. Click to expand detailed findingsResearch Findings1. The root cause is confirmed and intentional GitHub behaviorThe const pr = await github.rest.pulls.get({ owner, repo, pull_number: context.payload.issue.number });
// dispatch ref: pr.data.head.ref2.
|
|
@copilot the compiler already includes a step to checkout the pull-request branch. For issue_comment workflows, it needs to update the expression to support workflow_dispatch with a specific branch provided in the context. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Updated in f4c8810. The compiler now includes workflow_dispatch + aw_context(issue_comment + pull_request item_type) in the PR checkout step condition, and I added a unit test to cover the generated expression. |
|
🧠 Matt Pocock Skills Reviewer failed during the skills-based review. |
|
❌ Test Quality Sentinel failed during test quality analysis. |
|
|
|
❌ Design Decision Gate 🏗️ failed during design decision gate check. |
There was a problem hiding this comment.
Pull request overview
This PR fixes centralized agentic_commands workflow dispatch so decentralized slash/label workflows run against the triggering PR’s head branch (instead of the router’s ref), including issue/label events that originate from PR-backed issues.
Changes:
- Updated JS router ref resolution to prefer PR head refs (env
GITHUB_HEAD_REF, PR payload head ref, then PR lookup viapulls.getfor issue-backed PR events) and normalized refs consistently. - Updated workflow compiler logic to treat dispatched
workflow_dispatchruns withaw_contextindicatingissue_commenton apull_requestas eligible for “Checkout PR branch”. - Updated central router workflow permission emission to include
pull-requests: writewhen issue/issue_comment routes may require PR head resolution, plus added/extended unit tests.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/pr.go | Extends PR checkout step condition to include dispatched issue_comment PR contexts via aw_context. |
| pkg/workflow/pr_test.go | Adds coverage asserting the new workflow_dispatch + aw_context PR-checkout condition is emitted. |
| pkg/workflow/central_slash_command_workflow.go | Refactors PR permission decision into needsPullRequestsPermission, expanding to issue/issue_comment-backed PR cases. |
| pkg/workflow/central_slash_command_workflow_test.go | Adds coverage ensuring issue_comment centralized routes emit pull-requests: write. |
| actions/setup/js/route_slash_command.cjs | Makes dispatch ref resolution branch-aware (PR-first ordering + issue-backed PR lookup) and normalizes refs. |
| actions/setup/js/route_slash_command.test.cjs | Adds assertions that issue-comment and label events on PR-backed issues dispatch to the PR head branch. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 0
|
@copilot review all comments and fix the failing test/build-wasm jobs before re-evaluating.
|
|
@copilot merge main and recompile |
…er-agentic-commands-runtime Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot review all comments and address unresolved review feedback. Please refresh the branch and summarize any remaining blockers.
|
|
``
|
|
@copilot also handle pull request review comment |
|
@copilot this checkout PR step must assert in the runtime that the repository is not forked and the actor has at least write access. |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot refresh the branch from main, then rerun checks.
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Implemented in 8ee1261. The checkout step now enforces runtime safety before any PR branch checkout:
I also added focused tests for both failure paths in |
| id: checkout-pr | ||
| if: | | ||
| github.event.pull_request || github.event.issue.pull_request | ||
| github.event.pull_request || github.event.issue.pull_request || github.event_name == 'workflow_dispatch' && fromJSON(github.event.inputs.aw_context || '{}').event_type == 'issue_comment' && fromJSON(github.event.inputs.aw_context || '{}').item_type == 'pull_request' |
There was a problem hiding this comment.
@copilot you don't need to filter on the issue_comment event type. It just matters that the context is a pull request.
There was a problem hiding this comment.
Updated in 2fdc2b6: the workflow_dispatch checkout condition now only checks aw_context.item_type == 'pull_request' (no event_type filter).
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…er-agentic-commands-runtime Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Centralized
agentic_commandsdispatch was triggering decentralized slash/label workflows on router context refs instead of the event’s branch context. This change makes dispatch branch-aware, including issue-comment and label events that originate from a PR thread.Runtime: branch-aware dispatch ref resolution
route_slash_command.cjsnow resolves dispatch refs in PR-first order:GITHUB_HEAD_REFpayload.pull_request.head.refpulls.get(forissues/issue_commenton PRs)refs/*inputs are handled consistently.Runtime: issue-backed PR handling
Compiler: router permission alignment
central_slash_command_workflow.gonow emitspull-requests: writewhen merged events include issue/issue_comment paths that may require PR head resolution.needsPullRequestsPermission) for readability and maintenance.Compiler: workflow_dispatch PR-checkout condition alignment
pr.gonow treats relayedworkflow_dispatchruns as PR-checkout eligible whenaw_context.item_type == 'pull_request'(without filtering onaw_context.event_type).Runtime: PR checkout safety guardrails
checkout_pr_branch.cjsnow asserts trusted runtime context before checking out PR code:write,maintain, oradminaccessCoverage updates
workflow_dispatch+aw_context.item_type == 'pull_request'behavior.pr-sous-chef: requested branch update in workflow run 27063217612.
> Generated by 👨🍳 PR Sous Chef · 30.7 AIC · ⌖ 4.72 AIC · ◷