Skip to content

Allow validated status-only jobs after detection - #71623

Merged
pelikhan merged 5 commits into
mainfrom
copilot/adr-70997-custom-jobs-status-only
Oct 24, 2026
Merged

pelikhan merged 5 commits into
mainfrom
copilot/adr-70997-custom-jobs-status-only

Conversation

Copilot AI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Post-agent custom jobs were blocked whenever detection failed or reported warn-mode findings, leaving status notifications unresolved. Add a constrained opt-out for jobs that report job results without consuming agent-derived data.

  • Opt-in: detection-gate: status-only preserves the authored if and ensures detection is in needs.
  • Contract: Reject artifact downloads, opaque reusable workflows, non-detection-gated output reads, agent/safe-output file access, and custom-job dependents. Allow job results and outputs from detection-gated compiler jobs such as safe_outputs.
  • Lint and docs: Report contract violations and update the schema, ADR-70997, CTR-005, and job/linter documentation.
jobs:
  status:
    needs: [agent, detection, safe_outputs]
    detection-gate: status-only
    if: always()
    runs-on: ubuntu-latest
    steps:
      - run: echo "${{ needs.agent.result }} ${{ needs.detection.result }} ${{ needs.safe_outputs.outputs.created_issue_number }}"

Copilot AI changed the title [WIP] Allow status-only jobs to run after failed detection Allow validated status-only jobs after detection Oct 24, 2026
Copilot AI requested a review from pelikhan October 24, 2026 11:42
return ok && (strings.EqualFold(value.Value, "success") || strings.EqualFold(value.Value, "skipped"))
}

func statusOnlyExpressionPath(node actionlint.ExprNode) ([]string, bool) {
if path == "jobs."+validator.jobID && uses != "" {
validator.addViolation(childPath, "status-only jobs cannot call an opaque reusable workflow")
}
if strings.Contains(strings.ToLower(uses), "actions/download-artifact") {
@github-actions

This comment has been minimized.

@pelikhan
pelikhan marked this pull request as ready for review October 24, 2026 14:48
Copilot AI max review requested due to automatic review settings October 24, 2026 14:48
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot rename "detection-gate: status-only" to "continue-on-detection-error: true"

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

Status-only validation still permits prohibited agent-data access, and compiler/linter integration has unresolved correctness gaps.

7 open issues
What changed in this PR

Adds a detection-gate: status-only opt-in to gh-aw custom jobs so status notifications can run after failed or warn-mode detection while ordinary jobs retain their detection guards.

Changes:

  • Preserves opted-in jobs’ authored conditions and ensures detection ordering.
  • Adds shared compiler/linter contract validation and schema support.
  • Adds regression tests and updates security specifications and documentation.
File Description
specs/​compiler-threat-detection-spec.md Defines the status-only exception under CTR-005.
specs/​compiler-threat-detection-changelog.md Records the exception and validation mapping.
pkg/​workflow/​lint/​custom_job_detection.go Adds status-only contract diagnostics and exemption handling.
pkg/​workflow/​lint/​custom_job_detection_test.go Covers permitted reads, prohibited operations, and leaf requirements.
pkg/​workflow/​compiler_custom_job_detection.go Validates opted-in jobs before omitting the detection guard.
pkg/​workflow/​compiler_custom_job_detection_test.go Adds compilation and contract-validation cases.
pkg/​workflow/​compiler_custom_job_detection_expression_test.go Updates calls to the guard helper.
pkg/​workflow/​aw/​status_only_job.go Introduces shared expression and job-contract validation.
pkg/​parser/​schemas/​main_workflow_schema.json Accepts the compiler-only status-only opt-in.
docs/​src/​content/​docs/​reference/​workflow-linters.md Documents lint behavior and contract restrictions.
docs/​src/​content/​docs/​reference/​steps-jobs.md Explains status-only notifications with an example.
docs/​adr/​70997-enforce-detection-gates-for-custom-workflow-jobs.md Records the exception to mandatory detection gating.

Review effort: Max

Comment on lines +100 to +102
if strings.Contains(strings.ToLower(uses), "actions/download-artifact") {
validator.addViolation(childPath, "status-only jobs cannot use actions/download-artifact")
}
Comment on lines +128 to +137
matches := statusOnlyExpressionPattern.FindAllString(value, -1)
for _, match := range matches {
validator.inspectExpression(match, path)
}
if strings.Contains(value, "${{") && len(matches) == 0 {
validator.addViolation(path, "status-only job contains an expression that cannot be inspected safely")
}
if inIf && !strings.Contains(value, "${{") && strings.Contains(strings.ToLower(value), "needs") {
validator.inspectExpression(value, path)
}
Comment on lines +155 to +158
parts, ok := statusOnlyExpressionPath(child)
jobID, outputsReference := statusOnlyOutputJobID(parts)
if !ok || !outputsReference {
return
Comment on lines 175 to +177
if input.Document != nil {
if sourceFields, ok := authored[id].(map[string]any); ok {
fields["uses"] = sourceFields["uses"]
fields["runs-on"] = sourceFields["runs-on"]
maps.Copy(fields, sourceFields)
Comment on lines +163 to +164
require.Contains(t, content, "if: always()")
require.NotContains(t, content, "if: needs.detection.result == 'success'")
func customJobDetectionStatusOnlyDiagnostics(id string, fields map[string]any, jobs map[string]any, graph aw.JobDependencyGraph, allowedOutputJobs map[string]struct{}) []Diagnostic {
var diagnostics []Diagnostic
for _, dependent := range sliceutil.SortedKeys(jobs) {
if dependent != id && !constants.IsCompilerOwnedJobName(dependent) && graph.DependsOn(dependent, id) {
break
}
}
for _, violation := range aw.ValidateStatusOnlyJob(id, fields, allowedOutputJobs) {
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

@copilot rename "detection-gate: status-only" to "continue-on-detection-error: true"

Renamed the option to continue-on-detection-error: true in commit 36c3120.

// HasSuccessfulDetectionCondition reports whether a job's condition requires
// detection success on every branch, allowing skipped detection for conditional gates.
func HasSuccessfulDetectionCondition(condition string) bool {
if strings.TrimSpace(condition) == "" {
}
}

func (validator *statusOnlyJobValidator) inspectMapKey(value map[string]any, path, key, childPath string, inEnv bool) {
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot return to "detection-gate: status-only" naming + update compiler threat specification and TLA+ specs

Copilot AI commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Ran pr-finisher. Commit 7cb1256 is pushed; local formatting, lint, impacted tests, and secret scanning passed, and CodeQL reported no Python alerts (Go analysis skipped due database size). The PR is open, but current checks remain in progress and mergeability is unstable, so it is not merge-ready. The new TLC model could not be executed because the downloaded jar failed its pinned SHA-256 check. Review threads outside the latest explicit request remain untouched.

@copilot return to "detection-gate: status-only" naming + update compiler threat specification and TLA+ specs

Restored detection-gate: status-only across the compiler, schema, and docs, and updated CTR-005 with bounded StatusOnlyJob.tla coverage in commit 7cb1256. Formatting, lint, and impacted tests pass. TLC was not run because the downloaded jar failed the repository-pinned SHA-256 check.

if path == "jobs."+validator.jobID && uses != "" {
validator.addViolation(childPath, "status-only jobs cannot call an opaque reusable workflow")
}
if strings.Contains(strings.ToLower(uses), "actions/download-artifact") {
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for implementing detection-gate status-only! One item: please confirm unit tests cover the key validator scenarios in pkg/workflow/aw/status_only_job.go (rejecting artifact downloads, opaque reusable workflows, allowed detection-gated outputs).

Generated by ✅ Contribution Check · copilot · auto · ~34 AIC · ⌖ ~1 AIC · ⊞ 9.3K · ◷

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot address the following outstanding work in one pass:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (pkg/workflow/aw/status_only_job.go:226): Sensitive information disclosure risk: the status-only contract validator can miss indirect references to job outputs via expression re-shaping (e.g., wrapping needs in function calls like fromJSON(toJSON(needs)) and then dereferencing .agent.outputs.*). statusOnlyExpressionPath only recognizes Variable/ObjectDeref/IndexAccess nodes and returns false for other node kinds, so output reads can evade ValidateStatusOnlyJob, letting a detection-gate: status-only job (which is allowed to run with if: always() ... - Allow validated status-only jobs after detection #71623 (comment)
  3. Review (pkg/workflow/aw/status_only_job.go:100): Excessive agency risk: status-only jobs are permitted to run after failed/warn-mode detection, but the contract check only blocks actions/download-artifact by matching the uses string. A status-only job can still fetch agent artifacts through other actions, gh run download, or GitHub API calls inside run steps, undermining the intent of the opt-out and re-enabling post-detection agent-data consumption without the clean-detection gate. - Allow validated status-only jobs after detection #71623 (comment)
  4. Review (pkg/workflow/aw/status_only_job.go:102): A status-only job with actions: read, GH_TOKEN: ${{ github.token }}, and run: gh run download "$GITHUB_RUN_ID" --repo "$GITHUB_REPOSITORY" --name agent passes this validator but can download the agent artifact after detection fails. Blocking only actions/download-artifact does not enforce the promised no-artifact contract for scripts or other actions. Restrict the exemption's execution capabilities or use a constrained notification mechanism that cannot retrieve agent artifacts. - Allow validated status-only jobs after detection #71623 (comment)
  5. Review (pkg/workflow/aw/status_only_job.go:137): A bare step condition such as always() && contains('${{ true }}', 'true') && needs.agent.outputs.output != '' is checked only as ${{ true }}, allowing the prohibited output read after failed detection. The same delimiter regex also truncates valid expressions containing quoted }}, rejecting result-only notifications. Parse each if as a complete expression and use quote-aware scanning for other interpolated fields. - Allow validated status-only jobs after detection #71623 (comment)
  6. Review (pkg/workflow/aw/status_only_job.go:158): ${{ toJSON(needs.agent) }} and ${{ toJSON(needs) }} pass validation but include prohibited agent outputs, exposing them to a status-only job even after detection fails. Computed fields such as needs.agent[format('out{0}', 'puts')].value and wildcard reads such as toJSON(needs.*.outputs) also escape this check. Validate complete needs access chains, allowing only proven result reads or approved compiler-job outputs and rejecting aggregate or unresolved accesses that can contain other outputs. - Allow validated status-only jobs after detection #71623 (comment)
  7. Review (pkg/workflow/lint/custom_job_detection.go:177): With an Actions AST and companion AW document, this validates the companion's steps, env, and uses rather than the executable job's fields. A harmless status-only source can therefore exempt a lock job containing an artifact download or agent-output read from the detection guard diagnostic. Take the opt-in from the companion, validate the effective Actions execution fields, and add a regression where the source and lock steps differ. - Allow validated status-only jobs after detection #71623 (comment)
  8. Review (pkg/workflow/compiler_custom_job_detection_test.go:164): These whole-workflow assertions still pass if the status-only exemption disappears: other jobs or steps contain if: always(), while the injected detection guard is emitted with a quoted ${{ ... }} wrapper that the negative assertion never matches. Assert the compiled status job's condition and detection dependency instead. Also run custom-job-detection with the generated Actions graph and companion source to exercise the CLI linting path. - Allow validated status-only jobs after detection #71623 (comment)
  9. Review (pkg/workflow/lint/custom_job_detection.go:87): The leaf check exempts authored custom jobs named push_repo_memory, update_cache_memory, and other maintenance names, so it misses a custom dependent that the compiler rejects. custom_job_ownership_test.go treats these as custom jobs in source-backed analysis. Exclude only built-in customization targets here, matching the compiler's classification. - Allow validated status-only jobs after detection #71623 (comment)
  10. Review (pkg/workflow/lint/custom_job_detection.go:95): Gateway-dispatch compilation injects reads of needs.gateway_provenance.outputs.verified and needs.gateway_admission.outputs.verified into the status job's condition. The linter validates that compiled condition against an allowlist that excludes both jobs, so an otherwise valid status-only notification fails compilation with built-in linting enabled. Distinguish compiler-injected security guards from authored output reads and add a gateway-dispatch regression with linting enabled. - Allow validated status-only jobs after detection #71623 (comment)
  11. Review (pkg/workflow/aw/status_only_job.go:36): Sensitive information disclosure risk: Status-only job output allowlisting is based on HasSuccessfulDetectionCondition(), which returns true for empty conditions and treats success()/skipped as sufficient; compiler and linter then allow reading needs..outputs from any compiler-owned job downstream of detection that matches this lax predicate, even if it is not guarded by the clean-detection check (needs.detection.outputs.detection_success == 'true'). This can let a status-only custom job consume agent-derived data via compiler-owned job outputs on warn-mode detection. - Allow validated status-only jobs after detection #71623 (comment)
  12. Review (pkg/workflow/aw/status_only_job.go:94): Sensitive information disclosure risk: The status-only contract blocks artifacts only when a step uses actions/download-artifact, but does not detect artifact retrieval via run scripts (e.g., gh/api/curl against Actions artifacts). A status-only job that runs after failed or warn-mode detection could still fetch and exfiltrate agent artifacts through these alternate paths, bypassing the intended no-artifact-download contract. - Allow validated status-only jobs after detection #71623 (comment)
  13. Review (pkg/workflow/aw/status_only_job.go:100):

    Sensitive information disclosure risk: the status-only contract blocks only a literal match on actions/download-artifact (and does not cover other artifact download mechanisms such as third-party download-artifact actions or CLI-based downloads), so a job opted into detection-gate: status-only can still fetch agent-produced artifacts and exfiltrate agent-derived data even when detection fails or reports warn-mode findings.

    - Allow validated status-only jobs after detection #71623 (comment)

Push the necessary fixes, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved. Use the pr-finisher skill and stop when only human review or CI remains; do not trigger CI.

Sous-chef head: 7cb1256
Sous-chef state: 113b68d2f69946d940994eafe370cb99052cbb9ad464e18bc69590552bc30146

Generated by 👨‍🍳 PR Sous Chef · pi · haiku45 · ~13 AIC · ⌖ ~7 AIC · ⊞ 1.1K · ◷
Comment /souschef to run again

@pelikhan
pelikhan merged commit 61a6d37 into main Oct 24, 2026
38 of 39 checks passed
@pelikhan
pelikhan deleted the copilot/adr-70997-custom-jobs-status-only branch October 24, 2026 18:34
Copilot stopped work on behalf of gh-aw-bot due to an error October 24, 2026 18:35
Copilot AI requested a review from gh-aw-bot October 24, 2026 18:35
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.93.4

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.

Custom jobs: let status-only jobs (no agent output) run after failed or warn-mode detection (opt-out for ADR-70997 gate)

5 participants