Skip to content

Add opt-in agent-success gate for safe-output publication - #77559

Merged
pelikhan merged 5 commits into
mainfrom
copilot/fix-safe-outputs-block-publication
Nov 14, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/fix-safe-outputs-block-publication

Conversation

@pelikhan

@pelikhan pelikhan commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

A failed agent job can still publish staged safe outputs, so failing a deterministic check does not block publication.

  • Publication gate: Add safe-outputs.require-agent-success: true to require agent success before detection, built-in handlers, custom safe jobs, and asset publication run.
  • Compatibility: Default remains false, preserving publication after agent failure. Conclusion and failure-reporting jobs remain unchanged.
  • Imports: An explicit main-workflow value takes precedence; otherwise, any imported true enables the gate.
safe-outputs:
  require-agent-success: true
  add-comment:

Checks must fail the agent job; continue-on-error: true does not block publication.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@pelikhan pelikhan changed the title [WIP] Fix agent job to prevent safe_outputs execution on failure Add opt-in agent-success gate for safe-output publication Nov 13, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 13, 2026 22:32
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 22:32
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

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.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~6 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.5K · ◷

@github-actions

github-actions Bot commented Nov 13, 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 · copilot · routed: haiku55 xhigh · ~8 AIC · ⌖ ~2 AIC · ⊞ 6.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

Generated by PR Specification Reviewer for #77559 · copilot · gpt56 · ~6 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 13, 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 by Ponytail Reviewer for #77559 · codex · routed: gpt61 medium · ~4 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 182 · ◷

@github-actions

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

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.2K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate: ADR Required

This PR adds 199 lines in business-logic directories (pkg/), above the 100-line threshold, and no ADR was found. I committed a draft ADR to the branch: docs/adr/77559-opt-in-agent-success-gate-for-safe-output-publication.md.

Inferred decision: add an opt-in safe-outputs.require-agent-success flag (default false). When true, it requires needs.agent.result == 'success' for detection, safe_outputs, custom safe jobs and asset upload. The conclusion job is unchanged.

Next step: review the draft, fill in the [TODO: verify] items (deciders, alternatives, consequences), and change the status from Draft to Accepted before merging.

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · pi · routed: sonnet55 high · ~14 AIC · ⌖ ~2 AIC · ⊞ 8.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.

Reviewed head 57d92237d49b9c55ef4e27a82371a20406c79509 against docs/src/content/docs/specs/safe-outputs-specification.md v1.29.25 and the changed implementation/tests.

Blocking finding: the new require-agent-success behavior is not enforced for the upload_assets publication job. pkg/workflow/publish_assets.go omits requireSafeOutputsAgentSuccess, so assets may publish after an agent failure despite the documented contract. An inline comment is attached to the changed documentation line.

The formal safe-outputs specification has no current section for this new option. The intentional behavior is eligible for synchronization (default false, import precedence, detection/handlers/custom jobs/assets gated, conclusion/failure reporting unchanged), but I did not apply a spec update while the implementation is incomplete. No tests were run per static-review constraints.

Generated by PR Specification Reviewer for #77559 · copilot · gpt50 · ~6 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review-specs to run again


### Require Agent Success (`require-agent-success`)

`safe-outputs.require-agent-success` is a boolean that defaults to `false`. When `true`, detection, built-in safe-output handlers, custom safe jobs, and asset publication require `needs.agent.result == 'success'`. Downstream uploads and workflow calls are also skipped when safe-output processing is skipped.

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.

The documented gate is not applied to asset publication. pkg/workflow/publish_assets.go builds the upload_assets job condition with BuildSafeOutputType("upload_asset") but never calls requireSafeOutputsAgentSuccess, so require-agent-success: true still allows asset publication after the agent fails. Please apply the same gate before the conditional-detection wrapping and add coverage for the upload-assets job. This is required by the behavior described here and by the PR’s stated publication contract.

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.

Asset publication already receives the gate through buildSafeOutputJob. The compiled-condition coverage includes upload_assets across detection modes; verified in 82d2954.

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

Found one blocking correctness issue: the new success gate is not applied to push_repo_memory and potentially other downstream writers, allowing failed-agent output to be published despite require-agent-success: true. Please gate all agent-derived publication jobs consistently and add coverage.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~6 AIC · ⌖ ~1 AIC · ⊞ 1.5K
Comment /review to run again

BuildStringLiteral("skipped"),
),
)
agentNotSkipped = requireSafeOutputsAgentSuccess(agentNotSkipped, data.SafeOutputs)

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.

This gate does not cover all agent-derived publication jobs. In particular, push_repo_memory is still built by buildPushRepoMemoryJobCondition with only the existing agent.result != skipped check, so with require-agent-success: true a failed agent can still push staged repo-memory changes. That contradicts the documented publication gate and leaves the main safety issue exploitable on workflows using repo memory. Apply the same helper to every downstream writer (at least push_repo_memory, and audit the other memory/coverage publishers) and add a compiled-condition test.

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.

Fixed in 82d2954. Repo-memory now requires agent success when enabled; cache and drive memory already require it, and ledger and coverage depend on safe-output processing.

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (spec-review-history)
{"id":"ldg-9796c653-f1ba-4c3f-bc29-0d716a731526","parents":[],"payload":{"id":"ldg-2fdc5ee8-e5ee-4b14-b49b-afcc5add3d37","operation":"append","value":{"finding_count":1,"head_sha":"57d92237d49b9c55ef4e27a82371a20406c79509","outcome":"regression"}},"sha":"sha256:620a2fbbf5d744270a299f4cf3e2de324d9e9a6e44103b7a35d8528b26b50264","timestamp":"2026-11-13T22:47:31.230Z","type":"ledger_append","version":1}
History

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (review-history)
{"id":"ldg-1c43447b-d9f2-4133-b749-95bd68a70f11","parents":[],"payload":{"id":"ldg-548665d6-2a08-4695-acb2-513f4785b697","operation":"append","value":{"finding_count":1,"head_sha":"57d92237d49b9c55ef4e27a82371a20406c79509","outcome":"findings"}},"sha":"sha256:12b45cba4a4fceb13d4e9358fc9a8aaf775e6e760dd331e0972b78cac35edf75","timestamp":"2026-11-13T22:48:13.665Z","type":"ledger_append","version":1}
History

@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, /tdd, and /grill-with-docs. Requesting changes because the new gate does not cover every publication path.

📋 Key Themes and Highlights

Key Themes

  • Publication bypass (blocking): push_repo_memory still runs after an agent failure. Its condition (repo_memory.go ~L1029-1043) never consults require-agent-success, and buildDetectionPassedCondition() treats a skipped detection as a pass. Confirmed by compiling a workflow with require-agent-success: true, threat-detection: true, and repo-memory.
  • Test gap: TestSafeOutputsRequireAgentSuccess covers the main job and detection gating, but nothing asserts the gate on the repo memory push job.
  • Docs scope: the "Require Agent Success" section says the gate applies to all publication, which is not true until the push job is gated.

Positive Highlights

  • ✅ The gate is applied consistently through a single requireSafeOutputsAgentSuccess helper at the four safe-output call sites (main job, detection, custom safe jobs, and the shared job builder used by upload_assets).
  • ✅ Default false keeps existing behavior, and the import merge rule (explicit main value wins) is covered by tests.
  • ✅ Failure reporting is unaffected: handle_agent_failure runs with always() and reads engine error outputs from the agent job, not from detection.
  • ✅ The call_workflow job gates on needs.safe_outputs.outputs.call_workflow_name, so it is skipped when safe_outputs is skipped.
🔧 Checked and Verified
  • go test ./pkg/parser/ -run 'RequireAgentSuccess|MainWorkflowSchema' passes.
  • go test ./pkg/workflow/ -run RequireAgentSuccess passes.
  • gofmt -l pkg/parser pkg/workflow is clean.
  • Uncertainty: the review did not run the full compile golden suite, so any lock-file diffs outside these tests were not checked.

@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

)
}

func requireSafeOutputsAgentSuccess(condition ConditionNode, safeOutputs *SafeOutputsConfig) ConditionNode {

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.

[/diagnosing-bugs] The root cause is only partly fixed: push_repo_memory still runs after an agent failure. buildPushRepoMemoryJobCondition (pkg/workflow/repo_memory.go L1029-1043) never reads data.SafeOutputs, and buildDetectionPassedCondition() accepts a skipped detection. This gate skips detection on agent failure, so the repo memory push proceeds. Confirmed in the compiled YAML: the push_repo_memory if: checks (needs.detection.result == 'success' || needs.detection.result == 'skipped') and needs.agent.result != 'skipped', with no agent-success term.

💡 Suggested fix

Pass data.SafeOutputs into buildPushRepoMemoryJobCondition and wrap its condition with requireSafeOutputsAgentSuccess when threatDetectionEnabled is true. Repo memory is a publication path, and update_cache_memory already requires agent success (cache_memory.go ~L564), so this matches existing behavior.

@copilot please address this.

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.

Fixed in 82d2954, including when threat detection is disabled or conditional.

"github.com/stretchr/testify/require"
)

func TestSafeOutputsRequireAgentSuccess(t *testing.T) {

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.

[/tdd] This table covers the main job and detection gating, but no assertion checks the gate on push_repo_memory. Add a case with repo-memory enabled and require-agent-success: true, then assert that the push job if: contains needs.agent.result == 'success'. That test would have caught the gap above.

@copilot please address this.

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.

Added compiled-condition coverage for repo-memory, agent outcomes, and detection outcomes in 82d2954.

add-comment:
```

A failing agent step, including a deterministic `post-steps` check, blocks publication without needing to delete staged output files. The check must fail the agent job; a step with `continue-on-error: true` does not block publication. This setting does not provide a new gate hook or change the restrictions on accessing safe-output files from `post-steps`.

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.

[/grill-with-docs] This statement is not accurate yet. A failing agent blocks publication, but the repo memory push still runs until the gap above is closed. Once that is fixed, the wording holds for the gated outputs.

@copilot please address this.

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.

Repo-memory publication is now gated and explicitly documented in 82d2954.

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

When agent success is required, a failed agent can skip threat detection while staged repo-memory is still pushed, bypassing the existing threat check.

1 open issue
What changed in this PR

Adds an opt-in agent-success requirement to gh-aw’s safe-output pipeline so a failed deterministic check can block staged output publication while preserving existing behavior by default.

Changes:

  • Adds safe-outputs.require-agent-success, including schema validation and import precedence.
  • Applies the requirement to detection, built-in handlers, custom safe jobs, and asset publication.
  • Documents the option and adds compilation, import, and schema coverage.
File Description
pkg/​workflow/​threat_detection_job.go Applies the success requirement to detection.
pkg/​workflow/​safe_outputs_jobs.go Gates generated safe-output jobs.
pkg/​workflow/​safe_outputs_import_test.go Tests imported values and main-workflow precedence.
pkg/​workflow/​safe_outputs_config_types.go Adds the configuration field.
pkg/​workflow/​safe_outputs_config_global.go Parses the boolean option.
pkg/​workflow/​safe_jobs.go Gates custom safe jobs.
pkg/​workflow/​imports.go Merges imported requirements with explicit overrides.
pkg/​workflow/​expression_builder.go Adds a shared agent-success condition helper.
pkg/​workflow/​compiler_safe_outputs_job.go Gates consolidated safe-output processing.
pkg/​workflow/​compiler_safe_outputs_job_test.go Tests publication conditions across job outcomes.
pkg/​parser/​schemas/​main_workflow_schema.json Defines the option and its default.
pkg/​parser/​schema_safe_outputs_target_test.go Tests accepted values and metadata classification.
pkg/​parser/​schema_compiler.go Classifies the option as configuration metadata.
docs/​src/​content/​docs/​reference/​safe-outputs.md Explains behavior, limitations, and import precedence.

Review effort: Max (dynamic)

BuildStringLiteral("skipped"),
)
jobConditionNode := BuildAnd(alwaysFunc, agentNotSkipped)
jobConditionNode = requireSafeOutputsAgentSuccess(jobConditionNode, data.SafeOutputs)
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (docs/src/content/docs/reference/safe-outputs.md:1850): address unresolved feedback - Review comment
  3. Review (pkg/workflow/compiler_safe_outputs_job.go:1014): address unresolved feedback - Review comment
  4. Review (pkg/workflow/expression_builder.go:387): address unresolved feedback - Review comment
  5. Review (pkg/workflow/compiler_safe_outputs_job_test.go:21): address unresolved feedback - Review comment
  6. Review (docs/src/content/docs/reference/safe-outputs.md:1858): address unresolved feedback - Review comment

Keeping the changes focused; human review and CI get the final taste test. No merging or CI triggering.

Structured data
{
  "completed_task": 0,
  "head": "c66587c2fae53aee57e9930723b380dfbb58b83a",
  "kind": "requested",
  "schema_version": "1",
  "state": "acb47bb1758b2fa6be58a91e6a08e99adc554e323a2116eed9817c9247dc409b",
  "work": [
    "02cf70ea0dee2776c753ccd073bc795829c27c6967dacf2bfba181d1f227a438",
    "12b0e7ba6b6dde22286c7eb05b3f47889259c57dac6aaa5d08781177e78754eb",
    "19a0b0b4e19dc8c4eaa8c96ed25ca7230c0c3c4328bfb0a4e75164963ff025cb",
    "70691bf2484c21b8066e43fa87342721eca0380ef30afe2b787793dc9c3e6992",
    "d011f4c72f4f3e031f700f44ede364d2d8476cab2ba0f76ea6e8f647838efd65"
  ],
  "workflow": "pr-sous-chef"
}

Generated by 👨🍳 PR Sous Chef · pi · routed: haiku55 xhigh · ~4 AIC · ⌖ ~2 AIC · ⊞ 6.9K · ◷
Comment /souschef to run again

gh-aw-bot and others added 2 commits November 13, 2026 23:26
…uts-block-publication

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 AI commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@copilot

🍳 A little prep to help this PR along! Copilot assignment requested for the following outstanding work:...

Merged main in e410e18 and addressed the linked feedback in 82d2954. Targeted tests passed; the final gate reports existing custom-linter findings, and CodeQL timed out.

Copilot AI requested a review from gh-aw-bot November 13, 2026 23:42
@pelikhan
pelikhan merged commit a89b3f7 into main Nov 14, 2026
114 checks passed
@pelikhan
pelikhan deleted the copilot/fix-safe-outputs-block-publication branch November 14, 2026 02:54
pelikhan added a commit that referenced this pull request Nov 14, 2026
#77559 and #77560 crossed; the require-agent-success check referenced
topRawSafeOutputs inside mergeSafeOutputConfig where it was undefined,
breaking the Go/WASM build used by the docs workflow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
pelikhan added a commit that referenced this pull request Nov 14, 2026
…77643)

#77559 and #77560 merged with a semantic conflict: the parameter
topRawSafeOutputs was renamed to explicitSafeOutputs, leaving an
undefined reference that broke every Go build. Keep import values
OR-combined, with only the main workflow able to override them.

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

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.3.0

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.

safe_outputs and detection still run when the agent job fails; no supported way for a gate to block publication

4 participants