Route centralized command dispatches to the triggering PR branch#37187
Route centralized command dispatches to the triggering PR branch#37187Copilot wants to merge 7 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 |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@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.
|
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_contextindicates anissue_commentevent on apull_requestitem.Coverage updates
workflow_dispatch+aw_contextissue-comment PR context.