Repository navigation
Add opt-in trigger reaction removal on completion - #77561
Conversation
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: 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.
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: 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.
|
There was a problem hiding this comment.
Reviewed the changed lines in the pre-fetched diff. I found no actionable correctness, regression, performance, or maintainability issues. The delegated first-pass reviewer was unavailable because its file-read tool call was denied; this review is based on independent static analysis. Tests were not run per the static-review instructions.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (>100 new lines under 📄 Draft ADR committed:
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. ❓ Why ADRs MatterADRs 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 ReferenceAn ADR must contain these four sections to be considered complete:
ADRs are stored in
|
There was a problem hiding this comment.
Reviewed head 2b6d9becb38a5172a064fd5d7823b3fe4479d295. Applicable contract: specs/security-architecture-spec.md v1.1.10, OI-03 (write operations declared via safe-outputs), OI-06 (validated output), OI-11 (validated isolated writes), and SG-04 (least privilege). The opt-in cleanup is intentionally implemented as a direct actions/github-script write in the conclusion job and grants resource write permissions; see inline comment on reaction_cleanup.go:48. This is a normative contract gap, not an editorial synchronization. No specification files were changed. Coverage was limited to the captured diff, local implementation, and applicable security contract; tests were not run per static-review policy.
Generated by PR Specification Reviewer for #77561 · copilot · gpt50 · ~4 AIC · ⌖ ~2 AIC · ⊞ 1.6K
Comment /review-specs to run again
| " - name: Remove trigger reaction on completion\n", | ||
| " id: remove-trigger-reaction\n", | ||
| " if: always() && needs.activation.outputs.reaction_id != ''\n", | ||
| fmt.Sprintf(" uses: %s\n", getCachedActionPin("actions/github-script", data)), |
There was a problem hiding this comment.
Blocking contract gap: this adds a direct GitHub API write in the conclusion job via actions/github-script. Security Architecture Specification OI-03 requires write operations to be declared in safe-outputs, and OI-06/OI-11 require safe-output validation before execution. The new cleanup path is neither a safe output nor validated agent output, while still granting issues: write, pull-requests: write, or discussions: write. Please either route cleanup through an approved/contracted write path or obtain and document a normative exception (including its validation and permission-isolation guarantees); do not weaken the security contract only to bless this implementation.
There was a problem hiding this comment.
I did not change the direct conclusion write path: OI-03/OI-06/OI-11 require a declared, validated, isolated safe-output path, and the current trigger setting does not establish that contract. I also cannot self-approve a normative exception. This remains a blocker pending an approved implementation path or security-architecture decision.
Comment MemoryPeek at saved memory (review-history)History |
Comment MemoryPeek at saved memory (spec-review-history)History |
There was a problem hiding this comment.
🟡 Changes recommended
Reaction cleanup can receive empty job-output credentials, omit required discussion permissions for built-in-token expressions, and fail unnecessarily when the triggering discussion or comment has been deleted.
3 open issues
What changed in this PR
Adds opt-in trigger-reaction cleanup to gh-aw, addressing #77508 by removing reactions when conclusion runs while preserving existing behavior by default.
Changes:
- Adds
on.reaction.remove-on-completeconfiguration and documentation. - Connects activation’s reaction ID and credentials to conclusion cleanup, independently of status comments and disabled in dry-run mode.
- Adds REST and GraphQL removal handling with compiler and runtime tests.
| File | Description |
|---|---|
pkg/workflow/workflow_data.go |
Stores the cleanup option. |
pkg/workflow/trigger_parser.go |
Parses and validates the option. |
pkg/workflow/reaction_cleanup.go |
Generates cleanup steps, permissions, and conditions. |
pkg/workflow/reaction_cleanup_test.go |
Tests configuration, credentials, permissions, and dry-run behavior. |
pkg/workflow/notify_comment.go |
Integrates cleanup into conclusion. |
pkg/workflow/notify_comment_conclusion_helpers.go |
Adjusts conclusion conditions and isolates safe-output App permissions. |
pkg/workflow/compiler_development.go |
Disables cleanup in dry-run mode. |
pkg/workflow/compiler_activation_steps.go |
Exposes the recorded reaction ID. |
pkg/parser/schemas/main_workflow_schema.json |
Defines the new boolean option. |
docs/src/content/docs/reference/triggers.md |
Documents cleanup behavior and authentication. |
actions/setup/js/add_reaction.test.cjs |
Tests removal targets, errors, and retries. |
actions/setup/js/add_reaction.cjs |
Implements REST and GraphQL reaction removal. |
Review effort: Balanced (dynamic)
| function handleReactionError(error, removing = false) { | ||
| const operation = removing ? "remove" : "add"; | ||
| const status = error && typeof error === "object" && "status" in error ? error.status : undefined; | ||
| if (removing && status === 404) { |
| } | ||
|
|
||
| func addReactionCleanupJobPermissions(data *WorkflowData, permissions *Permissions) { | ||
| if reactionCleanupEnabled(data) && activationTokenMayUseGitHubToken(data) { |
| steps = append(steps, c.buildGitHubAppTokenMintStepForJob( | ||
| "conclusion", data.ActivationGitHubApp, permissions, "", | ||
| "", | ||
| "Generate GitHub App token for reaction cleanup", "activation-app-token", |
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design, /diagnosing-bugs and /grill-with-docs. Requesting changes on one ordering issue and one error-handling risk.
📋 Key Themes and Highlights
Key Themes
- Step ordering: the cleanup step runs before the noop, missing-tool, and report steps, which have no
always(). A cleanup failure would skip them. - Error severity: removal failures other than 404, 429, rate-limit, or locked errors call
setFailed, so best-effort cleanup can fail the conclusion job. - Docs wording: "exact reaction ID" does not match the discussion path, which removes by content.
Positive Highlights
- ✅ Dry-run suppression is handled in both
reactionCleanupEnabledanddryRunConclusionData. - ✅ Cleanup does not widen the safe-output App token, and the permission tests cover this.
- ✅ The duplicate
addReactionCleanupJobPermissionscall is intentional: the work-queue branch resets permissions. - ✅
go test ./pkg/workflowpasses for the reaction and conclusion tests.
Limits
- The JS tests in
add_reaction.test.cjswere not run because vitest could not be installed through the package proxy. - Not verified: whether a missing
SafeOutputsskips cleanup when reactions are configured.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K
Comment /matt to run again
| // failed-jobs reporting, the optional status-comment update, and the steering-issue step. | ||
| func (c *Compiler) buildConclusionJobSteps(data *WorkflowData, mainJobName string, safeOutputJobNames []string) ([]string, error) { | ||
| steps := c.buildConclusionSetupSteps(data) | ||
| steps = append(steps, c.buildReactionCleanupSteps(data)...) |
There was a problem hiding this comment.
[/codebase-design] The cleanup step is inserted before the noop, missing-tool, detection-runs and report steps. Those steps have no always(), so if cleanup calls setFailed, they are skipped and the run loses its reporting.
💡 Suggested change
Append c.buildReactionCleanupSteps(data) after all reporting steps, including the work-queue early return. Cleanup keeps its own always() guard, so it still runs after earlier failures.
@copilot please address this.
There was a problem hiding this comment.
Cleanup now runs after all conclusion reporting steps, including the work-queue path. Commit: efbee82.
| return; | ||
| } | ||
| core.setFailed(`${ERR_API}: Failed to add reaction: ${errorMessage}`); | ||
| core.setFailed(`${ERR_API}: Failed to ${operation} reaction: ${errorMessage}`); |
There was a problem hiding this comment.
[/diagnosing-bugs] When removing is true, a non-rate-limit error (for example a 403) calls setFailed, which turns the whole conclusion job red after the agent has finished. Cleanup is best-effort, so removal failures should be logged with core.warning instead. Add a test that a removal 403 does not fail the job.
@copilot please address this.
There was a problem hiding this comment.
Removal API failures now emit a warning instead of failing conclusion; the 403 behavior is covered by a test. Commit: efbee82.
| removing | ||
| ? ` | ||
| mutation($subjectId: ID!, $content: ReactionContent!) { | ||
| removeReaction(input: { subjectId: $subjectId, content: $content }) { |
There was a problem hiding this comment.
[/grill-with-docs] The PR describes removal as targeting the exact reaction ID, but the discussion path calls removeReaction with subjectId and content. That removes the reaction of that content type made by the authenticated actor, not a specific reaction. Align the wording in triggers.md and the PR description with this.
@copilot please address this.
There was a problem hiding this comment.
The trigger reference now distinguishes REST cleanup by reaction ID from GraphQL cleanup by the authenticated user's reaction content. I can't edit the PR description with the available write tools, so its wording still needs to be aligned.
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "b7edff6dcd9afee1c914f3e7fa6f24a6137f9724",
"kind": "requested",
"schema_version": "1",
"state": "a5765cec4e5cee6123b66861aeeecb64085cd17daee3e3e1da718eaeafc874ed",
"work": [
"431ddb31d28749f4cefa64a85c1ffd823e68e91f24ccc4e62202a7d84cb38241",
"8de02ce43a3c3f513f293e29ecacf32b32484493de07205dd4c3ad0f81d65c05",
"98b48dea7785699c0bc33b71da9d3c94a89fdd82ca0b156794560b830de6587c",
"98ef16870a577429e87ceadeb41072f3be5be6d1adb7e7e4028dc2c7ce6ff165"
],
"workflow": "pr-sous-chef"
}
|
…g-removing-reaction Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts on this branch. |
…g-removing-reaction # Conflicts: # pkg/workflow/notify_comment_test.go Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Resolved and merged |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "9fc9716c85d53e1f518eb3ec00cee64077bb5feb",
"kind": "requested",
"schema_version": "1",
"state": "ca7aeb2442a95994192e15aaf55c5985bbb21689056e427b4ea3d1744e1a2854",
"work": [
"8acb61a077717e3a460018aacdfde96fd489f77606cd36169e2328d9079b75bb"
],
"workflow": "pr-sous-chef"
}
|
…g-removing-reaction Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Merged the latest
The merge is
No further reply.
Understood.
CodeQL review remains to be completed.
Final validation is complete. |
|
🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:
Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering. Structured data{
"completed_task": 0,
"head": "801e2f915b6fa0813c846f723129f23ccc0fbdce",
"kind": "requested",
"schema_version": "1",
"state": "dc67763225ac1bb705f2ef75f5d0eb950b104f60c6a436d2bbca7835e001b2cf",
"work": [
"60f9c6f75a23e45038bdc0a714895e50930dc28c799e65ed0e0a6ca6d5b913c3"
],
"workflow": "pr-sous-chef"
}
|
…g-removing-reaction Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts on this branch. |
…g-removing-reaction # Conflicts: # scripts/test-wasm-golden.mjs Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Which workflows should enable reaction removal?
Merged |
|
🎉 This pull request is included in a new release. Release: |

Trigger reactions currently remain indefinitely, making completed workflows appear active—even with status comments disabled.
on.reaction.remove-on-complete, defaulting tofalseto preserve existing behavior.