Repository navigation
Description
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 ✅/
- It never reads agent output: no
download-artifact, noneeds.agent.outputs.*, noGH_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.
- 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. - Contract check in
guardCustomJobDetection: a job with the opt-in must pass all of these, or compilation fails with ajobs.<id>diagnostic naming the offending reference:- no
actions/download-artifactstep; - no expression reference to
needs.agent.outputs.*orneeds.detection.outputs.*, or to the outputs of any custom job or non-detection-gated job; - no
GH_AW_AGENT_OUTPUTor safe-output file paths inenv/run; needs.<any>.resultis allowed, and so are outputs of compiler-owned jobs that are themselves gated on detection (safe_outputs).
- no
- For a job that passes: keep the authored
ifand still adddetectiontoneeds(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). - Lint: teach
custom-job-detection(pkg/workflow/lint/custom_job_detection.go) about the key. An opted-in job withalways()gets no "bypasses detection" diagnostic, and the contract violations above are reported. - Tests in
compiler_custom_job_detection_test.goandlint/custom_job_detection_test.go:- an opted-in job reading only
needs.*.resultandneeds.safe_outputs.outputs.*keepsif: always(); - an opted-in job referencing
needs.agent.outputs.xor usingdownload-artifactfails to compile; - a job without the key is guarded exactly as today.
- an opted-in job reading only
- Update ADR-70997 (record the exemption under Decision) and CTR-005 with the new mapping, plus
steps-jobs.md. Runmake 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.
Activity