Skip to content

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

Done

Description

@ekbritecore

Analysis

Since v0.93.1, guardCustomJobDetection (pkg/workflow/compiler_custom_job_detection.go, #70997 / ADR-70997) wraps every custom job downstream of agent in a guard that can't be overridden:

needs.detection.result == 'success' && needs.detection.outputs.detection_success == 'true' && (<authored if>)

The only exemption is turning detection off. ADR-70997 names the cost under Negative: "Authors can no longer run post-agent custom jobs on detection failure … for example to send failure notifications."

That case is ours. Two workflows are dispatched from a chat request (a Slack mention). A custom jobs: entry reports the outcome back to the requester: it replaces a 👀 reaction with ✅/⚠️/❌ and posts one fixed-text line. Its constraints:

  • It never reads agent output: no download-artifact, no needs.agent.outputs.*, no GH_AW_AGENT_OUTPUT.
  • It reads only needs.<job>.result.
  • It reads the created PR/issue number and URL from needs.safe_outputs.outputs.*. Those are compiler-gated, so they're empty when detection fails.
  • A lock-invariant test pins this shape.

On v0.93.0 it runs with if: always() && … and reports "❌ blocked by a safety check" when detection fails or warns. On v0.93.1+ it's skipped exactly then. The requester is left with a 👀 that never resolves, and that's the case where they most need to hear back.

Reproduce: compile a workflow that has detection enabled and this custom job:

jobs:
  status:
    needs: [agent, detection, safe_outputs]
    if: always()
    runs-on: ubuntu-latest
    steps:
      - run: echo "${{ needs.agent.result }} ${{ needs.detection.result }}"

The lock's jobs.status.if comes out as needs.detection.result == 'success' && needs.detection.outputs.detection_success == 'true' && (always()).

Implementation Plan

Add an explicit opt-in for status-only custom jobs. The compiler verifies the job can't carry agent-derived data, and only then exempts it from the outer guard. Everything else stays under CTR-005.

  1. Schema: add a gh-aw key on custom jobs, e.g. jobs.<id>.detection-gate: status-only (name up to you). Strip it from the emitted Actions job.
  2. Contract check in guardCustomJobDetection: a job with the opt-in must pass all of these, or compilation fails with a jobs.<id> diagnostic naming the offending reference:
    • no actions/download-artifact step;
    • no expression reference to needs.agent.outputs.* or needs.detection.outputs.*, or to the outputs of any custom job or non-detection-gated job;
    • no GH_AW_AGENT_OUTPUT or safe-output file paths in env/run;
    • needs.<any>.result is allowed, and so are outputs of compiler-owned jobs that are themselves gated on detection (safe_outputs).
  3. For a job that passes: keep the authored if and still add detection to needs (so ordering after detection holds), but skip the outer guard. Don't apply the exemption to jobs that other custom jobs depend on (or apply the same contract to them transitively).
  4. Lint: teach custom-job-detection (pkg/workflow/lint/custom_job_detection.go) about the key. An opted-in job with always() gets no "bypasses detection" diagnostic, and the contract violations above are reported.
  5. Tests in compiler_custom_job_detection_test.go and lint/custom_job_detection_test.go:
    • an opted-in job reading only needs.*.result and needs.safe_outputs.outputs.* keeps if: always();
    • an opted-in job referencing needs.agent.outputs.x or using download-artifact fails to compile;
    • a job without the key is guarded exactly as today.
  6. Update ADR-70997 (record the exemption under Decision) and CTR-005 with the new mapping, plus steps-jobs.md. Run make agent-finish.

Acceptance Criteria

  • With detection enabled, a custom job marked status-only that reads no agent-derived data compiles with its authored if (e.g. always()) and runs after a failed, skipped or warn-mode detection.
  • The same job referencing agent or detection outputs, or downloading artifacts, is a compile error.
  • Unmarked custom jobs are guarded exactly as in v0.93.2.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions