Skip to content

Align safe-output no-context behavior: allow MCP enqueue, rely on runtime soft-skip - #48955

Closed
pelikhan with Copilot wants to merge 7 commits into
mainfrom
copilot/deep-report-fix-soft-skip-hard-fail
Closed

Align safe-output no-context behavior: allow MCP enqueue, rely on runtime soft-skip#48955
pelikhan with Copilot wants to merge 7 commits into
mainfrom
copilot/deep-report-fix-soft-skip-hard-fail

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Safe-output handling had an MCP/runtime mismatch: scheduled or context-free runs could hard-fail at MCP enqueue for update_pull_request / add_comment, even though runtime handlers are designed to soft-skip unresolved target: triggering cases. This surfaced in PR Sous Chef mixed payloads (create_issue + update_pull_request + add_comment).

  • Behavior change: remove MCP hard-stop for no-trigger context

    • actions/setup/js/safe_outputs_handlers.cjs
    • Dropped MCP-time context rejection for:
      • add_comment with target: triggering and no issue/PR/discussion context
      • update_pull_request with target: triggering and no PR context
    • Entries are now recorded and handed to runtime resolution, where no-context targets are soft-skipped instead of failing the whole safe-outputs pass.
  • Scope preserved

    • Kept existing early validations that are unrelated to this failure mode:
      • wildcard target requirements (e.g. target: '*' still requires explicit item number fields)
      • payload-shape checks (e.g. update_pull_request still requires one of title|body|update_branch)
  • Targeted test expectation updates

    • actions/setup/js/safe_outputs_handlers.test.cjs
    • Updated cases for push, schedule, and workflow_dispatch (without context override) to assert successful enqueue for add_comment and update_pull_request instead of MCP intent errors.
// before: MCP rejected in no-context events
const result = handlers.updatePullRequestHandler({ body: "Report" });
// expected: intent error

// now: MCP records; runtime handler resolves/soft-skips if context is absent
const result = handlers.updatePullRequestHandler({ body: "Report" });
// expected: success enqueue (NDJSON entry written)

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.2 AIC · ⌖ 6.24 AIC · ⊞ 7.8K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.5 AIC · ⌖ 7.46 AIC · ⊞ 7.8K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.44 AIC · ⌖ 4.57 AIC · ⊞ 7.8K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.3 AIC · ⌖ 7.29 AIC · ⊞ 7.8K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix soft-skip vs hard-fail inconsistency in safe-outputs handler Align safe-output no-context behavior: allow MCP enqueue, rely on runtime soft-skip Jul 29, 2026
Copilot AI requested a review from pelikhan July 29, 2026 18:22
@pelikhan
pelikhan marked this pull request as ready for review July 29, 2026 18:24
Copilot AI review requested due to automatic review settings July 29, 2026 18:24

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.

Pull request overview

Allows context-free safe-output items to enqueue and rely on runtime soft-skipping.

Changes:

  • Removes MCP no-context rejection for comments and PR updates.
  • Updates enqueue expectations for push, schedule, and dispatch events.
Show a summary per file
File Description
actions/setup/js/safe_outputs_handlers.cjs Defers no-context handling to runtime.
actions/setup/js/safe_outputs_handlers.test.cjs Tests successful context-free enqueueing.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment on lines 1902 to 1903
// Build the entry with a temporary_id
const entry = { ...(args || {}), type: "add_comment" };

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in commit 704795f. Both addCommentHandler and updatePullRequestHandler now call resolveInvocationContext(context) unconditionally (not gated on no-context checks). Any ERR_VALIDATION error — including a disallowed target_repo (SEC-005) — is surfaced immediately as an MCP intent error before writing to NDJSON. Non-validation structural errors are still silently passed downstream. A dedicated test case (should return intent error when workflow_dispatch has disallowed target_repo (SEC-005)) confirms the rejection path for each handler.

}
}

return defaultHandler("update_pull_request")(args || {});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in commit 704795f. updatePullRequestHandler now calls resolveInvocationContext(context) unconditionally and surfaces ERR_VALIDATION errors (including SEC-005 / disallowed target_repo) at MCP-phase before appending to NDJSON. No-context events (schedule, push, workflow_dispatch without aw_context) are enqueued and soft-skipped at runtime. A dedicated test case (should return intent error when workflow_dispatch has disallowed target_repo (SEC-005)) verifies that a disallowed target_repo is rejected with an intent error and mockAppendSafeOutput is never called.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (0 additions detected in default business dirs: src/, lib/, pkg/, internal/, app/, core/, domain/, services/, api/).

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Code Quality Reviewer failed during code quality review.

@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 and /codebase-design — commenting, not blocking.

📋 Key Themes & Highlights

Key Themes

  • SEC-005 regression (pre-existing comments #3677053881, #3677053921): The removed blocks contained the only MCP-phase SEC-005 (target_repo) validation for these two handlers. Previous review comments already flag this — that path should be preserved or lifted out before the context gate.
  • Runtime soft-skip coverage gap: Tests confirm successful MCP enqueue but do not cover the runtime processor's soft-skip behavior. If the downstream handler regresses, the MCP test suite stays green.
  • Asymmetric documentation: updatePullRequestHandler received a JSDoc update explaining the delegation; addCommentHandler did not.

Positive Highlights

  • ✅ Correct fix for the mixed-payload hard-fail problem (#48925) — delegating no-context resolution to runtime is the right architecture.
  • ✅ Wildcard-target and payload-shape validations are preserved.
  • ✅ Tests are clearly renamed to reflect the new behavior.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 34 AIC · ⌖ 10.6 AIC · ⊞ 7K
Comment /matt to run again

Comments that could not be inline-anchored

actions/setup/js/safe_outputs_handlers.test.cjs:2288

[/diagnosing-bugs] These tests now assert MCP enqueue succeeds, but there is no coverage for what happens to these entries in the runtime processor — the correctness of the soft-skip itself is untested here.

<details>
<summary>💡 Suggested additional coverage</summary>

Consider adding integration-style or mocked runtime handler tests for entries written from non-PR/issue/discussion contexts:

it(&#39;runtime handler soft-skips add_comment entries from push context&#39;, () =&gt; {
  // Arrange…

</details>

<details><summary>actions/setup/js/safe_outputs_handlers.cjs:1942</summary>

**[/codebase-design]** The updated JSDoc comment for `updatePullRequestHandler` accurately describes the new behavior, but `addCommentHandler` above still has no equivalent comment explaining the soft-skip delegation. A reader unfamiliar with the change will see validation removed with no explanation.

&lt;details&gt;
&lt;summary&gt;💡 Suggestion&lt;/summary&gt;

Add a brief comment above the `addCommentHandler` entry block similar to the one added to `updatePullRequestHandler`:

```js
// For target:triggering i…

</details>

@github-actions

Copy link
Copy Markdown
Contributor

Warning

threat detection engine error
The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

Details

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Test comment

🧪 Test quality analysis by Test Quality Sentinel · haiku45 · 21.2 AIC · ⊞ 8.4K ·
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.

❌ Test Quality Sentinel: 20/100 — Poor. 100% implementation tests (threshold: ≤30%). This PR flips a critical behavioral contract (MCP hard-fail → downstream soft-skip) but tests only verify MCP-layer acceptance, not the downstream guarantee. Review flagged tests in the PR comment above.

@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.

Review Summary

The behavior change is clearly motivated and the test updates are correct. Two existing inline comments already flag the main concern: removing the MCP-phase context gate for add_comment and update_pull_request also removes the independent SEC-005 (target_repo) validation that previously fired inside those blocks.

Additional observation: update_issue (~line 2180) still retains its context guard and early-rejects on non-issue events. With this PR, add_comment and update_pull_request diverge to the enqueue+runtime-soft-skip path. The asymmetry appears intentional but should be documented in a JSDoc comment or follow-up issue so future reviewers understand why the three handlers behave differently.

No new blocking issues beyond what the existing inline comments already surfaced.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 25.3 AIC · ⌖ 8.84 AIC · ⊞ 5.3K

@github-actions

Copy link
Copy Markdown
Contributor

Triage: refactor (safe-output behavior)

Risk: medium | Priority: high (score 66/100)

Breakdown: impact 30/50 (touches safe-output MCP/runtime hard-fail vs soft-skip behavior, cross-cutting) · urgency 21/30 (in-progress CI, active review thread, addresses real production mismatch) · quality 15/20 (detailed description, has reviewer comments to address, tests updated)

Recommended action: fast_track

Behavior-affecting change to safe-output enqueue/soft-skip semantics with existing reviewer feedback (2 review comments) — recommend expedited human review before merge.

Generated by 🔧 PR Triage Agent · aut00 · 40.7 AIC · ⌖ 5.25 AIC · ⊞ 7.9K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the unresolved review feedback, and rerun any needed checks. Failed checks to investigate:

Reviewer feedback to address:

  • github-actions: runtime soft-skip coverage is still missing and addCommentHandler should document the delegated behavior.
  • github-actions: verify the SEC-005 / target_repo validation path remains preserved after removing the MCP-phase context gate.

Run: https://github.com/github/gh-aw/actions/runs/30481139487

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 12.2 AIC · ⌖ 6.24 AIC · ⊞ 7.8K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the unresolved review feedback below, and rerun any needed checks.

Unresolved review threads:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.5 AIC · ⌖ 7.46 AIC · ⊞ 7.8K ·
Comment /souschef to run again

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot implement the best systems so that the agent gets a feedback in the chat that it hasn't used the safeoutputs correctly and can recover

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot implement the best systems so that the agent gets a feedback in the chat that it hasn't used the safeoutputs correctly and can recover

Done in the latest commit. When add_comment or update_pull_request is called in a no-context event (e.g. push, schedule, workflow_dispatch without aw_context), the MCP response now includes a hint field alongside result: "success". The hint names the triggering event, explains the entry will be skipped at runtime if no context is found, and suggests create_issue or create_discussion as alternatives. Explicit item_number and valid PR/issue/discussion contexts suppress the hint. SEC-005 and runtime soft-skip behavior are unchanged.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, address the unresolved review threads below, and update the branch once fixes are ready.

Unresolved review threads (newest first):

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 6.44 AIC · ⌖ 4.57 AIC · ⊞ 7.8K ·
Comment /souschef to run again

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address the unresolved review threads below, and update the branch once fixes are ready.

Unresolved review threads (newest first):...

The two unresolved threads (r3677518165, r3677518154) are outdated — both show is_outdated: true because the code at those original line numbers has since changed. The underlying SEC-005 concerns they raised were addressed in commit 704795f:

  • addCommentHandler (lines 1912–1926): calls resolveInvocationContext(context) unconditionally; any ERR_VALIDATION error (including a disallowed target_repo) surfaces as an MCP intent error before writing to NDJSON.
  • updatePullRequestHandler (lines 2284–2298): same pattern — SEC-005 is enforced at MCP-phase; no-context events (schedule, push, workflow_dispatch without aw_context) are enqueued and soft-skipped at runtime with a hint.

All 194 tests in safe_outputs_handlers.test.cjs pass, including the dedicated SEC-005 cases (should return intent error when workflow_dispatch has disallowed target_repo) for both handlers. No code changes were needed this session.

@github-actions

Copy link
Copy Markdown
Contributor

Triage: Align safe-output no-context behavior (soft-skip/hard-fail)

  • Category: refactor | Risk: medium | Score: 38/100 (Impact 20, Urgency 8, Quality 10)
  • Recommendation: defer — CI failing, changes-requested from automated reviewer, blocked mergeable state. Previously fast-tracked (score 74) in prior run; downgraded due to unresolved review feedback and failing CI. Needs rework before re-triage.

Generated by 🔧 PR Triage Agent · aut00 · 52.7 AIC · ⌖ 9.26 AIC · ⊞ 7.9K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, review the latest feedback on this PR, and resolve any still-open review threads before rerunning checks.

Unresolved review threads (newest first):

Run: https://github.com/github/gh-aw/actions/runs/30505477072

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 19.3 AIC · ⌖ 7.29 AIC · ⊞ 7.8K ·
Comment /souschef to run again

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, review the latest feedback on this PR, and resolve any still-open review threads before rerunning checks.

Unresolved review threads (newest first):...

Both threads (r3677053921, r3677053881) are is_outdated: true — the original code lines they referenced were changed in commit 704795f. The SEC-005 concerns are implemented in the current code:

  • addCommentHandler lines 1916–1926: resolveInvocationContext(context) called unconditionally; ERR_VALIDATION (including disallowed target_repo) surfaced as MCP intent error before any NDJSON write.
  • updatePullRequestHandler lines 2288–2298: same pattern.

The threads show is_resolved: false in the API because they require a manual "Resolve conversation" click in the GitHub UI — they cannot be resolved programmatically. The linked CI run (30505477072) is the PR Sous Chef scheduler running on main and concluded success; there are no failing checks on this PR branch. No further code changes are needed.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, review the latest feedback on this PR, address the unresolved review threads below, and rerun any needed checks once the branch is up to date.

Unresolved review threads (newest first):

Run: https://github.com/github/gh-aw/actions/runs/30507870059

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 8.44 AIC · ⌖ 7.77 AIC · ⊞ 7.8K ·
Comment /souschef to run again

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, review the latest feedback on this PR, address the unresolved review threads below, and rerun any needed checks once the branch is up to date.

Unresolved ...

Same status as previous sessions — both threads are is_outdated: true and the SEC-005 fix has been in place since commit 704795f. The linked CI run (30507870059) is the PR Sous Chef scheduler on main (concluded success), not a failure on this branch. The threads remain is_resolved: false in the API because programmatic resolution isn't possible; a maintainer needs to click "Resolve conversation" on each thread in the PR UI to stop the bot from re-flagging them.

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.

[deep-report] Fix soft-skip vs hard-fail inconsistency in safe-outputs handler for scheduled/no-trigger-context runs (PR Sous Chef pattern)

4 participants