Skip to content

Restore detection step timeout and --rootless AWF install on the external threat-detect path - #54627

Merged
pelikhan merged 4 commits into
mainfrom
copilot/v0872-fix-detection-timeout-and-rootless
Aug 21, 2026
Merged

Restore detection step timeout and --rootless AWF install on the external threat-detect path#54627
pelikhan merged 4 commits into
mainfrom
copilot/v0872-fix-detection-timeout-and-rootless

Conversation

CopilotAI commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Moving the threat-detection job to the external threat-detect implementation dropped two properties of the detection job: the execution step lost its timeout-minutes (raising the effective ceiling from 20 to the GitHub default of 360, with no frontmatter lever to restore it), and the AWF install lost --rootless while the agent job kept it.

Changes

  • buildExternalDetectorExecutionStep now emits timeout-minutes: on the execution step, resolved from the same detection WorkflowData that produces GH_AW_TIMEOUT_MINUTES, so the two stay aligned. The env var is only honoured once the binary is running; a stall before that (image pull, AWF startup, headless server never becoming ready) was previously unbounded.
  • buildInstallAWFForExternalDetectorStep passed nil as the agent sandbox config, so generateAWFInstallationStep skipped --rootless even though the detection job invokes the rootless awf command. It now passes the detection job's own agent config, making install mode match invocation.
  • Unit tests for both, plus regenerated .lock.yml files and a patch changeset.

Resulting detection-job diff:

 - name: Install AWF binary
- run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.28.4+ run: bash "${RUNNER_TEMP}/gh-aw/actions/install_awf_binary.sh" v0.28.4 --rootless
...
- name: Execute threat detection with AWF
continue-on-error: true
+ timeout-minutes: 20

Note the detection job does not inherit sandbox.agent.runtime from the main workflow — it always resolves to the default docker (rootless) profile — so the install flag now tracks how AWF is actually invoked in that job rather than the agent job's runtime.


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 28.5 AIC · ⌖ 8.22 AIC · ⊞ 9.4K ·
Comment /souschef to run again

CopilotAIand others added 2 commits August 21, 2026 22:00
…etection
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
CopilotAI changed the title [WIP] Fix detection step timeout and AWF install for threat-detectRestore detection step timeout and --rootless AWF install on the external threat-detect pathAug 21, 2026
CopilotAI requested a review from pelikhanAugust 21, 2026 22:10
@pelikhan
pelikhan marked this pull request as ready for review August 21, 2026 22:19
CopilotAI balanced review requested due to automatic review settings August 21, 2026 22:19

CopilotAI 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

Restores the external threat-detection path’s 20-minute execution limit and rootless AWF installation.

Changes:

  • Emits timeout-minutes alongside GH_AW_TIMEOUT_MINUTES.
  • Installs AWF according to the detection job’s rootless profile.
  • Adds regression tests, regenerated locks, and a patch changeset.
Show a summary per file
FileDescription
pkg/workflow/threat_detection_external.goRestores timeout and rootless installation.
pkg/workflow/threat_detection_test.goAdds regression coverage; one comment needs correction.
.changeset/detection-step-timeout-and-rootless-awf-install.mdAdds release note; runtime wording needs correction.
.github/workflows/*.lock.yml (all changed lock files)Regenerates detection steps with rootless AWF and a 20-minute timeout.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

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

"gh-aw": patch
---

Restore two properties of the threat-detection job on the external `threat-detect` path. The detection execution step is again bounded by a step-level `timeout-minutes` (aligned with the `GH_AW_TIMEOUT_MINUTES` value it already exported), so a stall before the binary reaches its own timeout logic no longer runs up to the 360 minute GitHub default. The detection job's AWF binary install now passes `--rootless` in the same cases as the agent job, matching how `awf` is actually invoked in that job.
Comment on lines +3637 to +3638
// TestBuildInstallAWFForExternalDetectorStepUsesRootless verifies that the detection
// job installs the AWF binary in the same mode used to invoke it, matching the agent job.
@github-actions

github-actionsBot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actionsBot commented Aug 21, 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 (63 additions detected).

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actionsBot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. The pre-fetched diff for PR #54627 contains only regenerated .lock.yml workflow files (generated, out of scope per ponytail-review skill) and a .changeset markdown doc (not code). The actual Go source changes are not present in the capped diff, leaving no code surface to review for over-engineering.

Generated by Ponytail Reviewer for #54627

@github-actions

github-actionsBot commented Aug 21, 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

@github-actions

github-actionsBot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-08-21T00:00:00Z
review_event: COMMENT
top_themes:
- docs/test wording drift only
- no blocking correctness issues in changed lines
files_reviewed:
- .changeset/detection-step-timeout-and-rootless-awf-install.md
- pkg/workflow/threat_detection_external.go
- pkg/workflow/threat_detection_test.go
- .github/workflows/*.lock.yml
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 12.2 AIC · ⌖ 8.23 AIC · ⊞ 7K ·
Comment /review to run again

@github-actionsgithub-actionsBot 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.

Verdict

COMMENT — I don't see a blocking regression in the changed lines.

The only problems I found are wording drift that was already called out in prior review comments.
  • The implementation change in pkg/workflow/threat_detection_external.go looks internally consistent: the external detector now derives both timeout-minutes and the AWF install mode from the detection job's own synthetic workflow data.
  • generateAWFInstallationStep already suppresses --rootless for privileged profiles such as docker-sudo-iptables and cloud-hypervisor, so the new call site does not force rootless universally.
  • The lockfile churn matches the intended generated output.
  • Remaining issues are non-blocking wording inaccuracies in the new changeset/test comments, and those are already covered by existing Copilot review comments on this PR.

I skipped sub-agent input because grumpy-coder is not available in this environment.

🔎 Code quality review by PR Code Quality Reviewer · gpt54 · 12.2 AIC · ⌖ 8.23 AIC · ⊞ 7K
Comment /review to run again

@github-actionsgithub-actionsBot 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.

The changes are correct and consistent across all affected .lock.yml files. Both fixes (--rootless for AWF install and timeout-minutes: 20 on the detection step) are uniformly applied with no omissions or inconsistencies visible in the diff. No blocking issues found.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 20.1 AIC · ⌖ 8.94 AIC · ⊞ 6.2K

@github-actionsgithub-actionsBot mentioned this pull request Aug 21, 2026
github-actions[bot]
github-actionsBot previously requested changes Aug 21, 2026

@github-actionsgithub-actionsBot 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 — two minor issues in the new tests; overall the fix is correct and well-motivated.

📋 Key Themes & Highlights

Issues Found

  1. Hardcoded timeout value in test (threat_detection_test.go:3629) — the literal "20" should be derived from constants.DefaultAgenticWorkflowTimeout (or the env var neutralised with t.Setenv) so an enterprise GH_AW_DEFAULT_TIMEOUT_MINUTES override doesn't silently break the assertion.

  2. Misleading doc comment (threat_detection_test.go:3638) — "matching the agent job" re-introduces the same inaccuracy already flagged in the changeset: the detection job always uses its own independent default Docker/rootless profile, never inheriting sandbox.agent.runtime from the main workflow.

Positive Highlights

  • ✅ Root cause properly addressed: nilgetAgentConfig(detectionData) ensures install mode aligns with invocation mode.
  • timeout-minutes is sourced from resolveStepTimeoutValue(threatDetectionData), keeping it aligned with GH_AW_TIMEOUT_MINUTES automatically.
  • ✅ Both fixes have targeted unit tests and a clear changeset entry.
  • ✅ The comment in buildInstallAWFForExternalDetectorStep explains exactly why nil was wrong, which is excellent.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 65.3 AIC · ⌖ 9.95 AIC · ⊞ 7.6K
Comment /matt to run again

}
joined := strings.Join(steps, "")

if !strings.Contains(joined, " timeout-minutes: 20\n") {

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 assertion hardcodes "20" instead of deriving the value through the same resolution path as the production code. If GH_AW_DEFAULT_TIMEOUT_MINUTES is set in the test environment, resolveStepTimeoutValue returns a different value and this assertion silently fails — masking a real regression.

💡 Suggested fix

Isolate the env var or derive the expected value programmatically:

// Option 1 – neutralise the env overridet.Setenv(compilerenv.DefaultTimeoutMinutes, "")
// Option 2 – derive from the same constantfallback:=int(constants.DefaultAgenticWorkflowTimeout/time.Minute)
expected:=fmt.Sprintf(" timeout-minutes: %d\n", fallback)
if!strings.Contains(joined, expected) { ... }

@copilot please address this.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Addressed in bbb721c: the test now derives expectedTimeout via resolveStepTimeoutValue(data) and checks both timeout-minutes and GH_AW_TIMEOUT_MINUTES against that resolved value.

}

// TestBuildInstallAWFForExternalDetectorStepUsesRootless verifies that the detection
// job installs the AWF binary in the same mode used to invoke it, matching the agent job.

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 test comment says the rootless install matches "the agent job", but buildThreatDetectionWorkflowData explicitly creates a separate default Docker/rootless profile — it never inherits sandbox.agent.runtime from the main workflow. This wording is the same as the misleading phrase in the changeset and may re-introduce confusion when this test is read in isolation.

Consider: "verifies that the detection job installs AWF in rootless mode, matching how awf is invoked in the same job" — which is accurate and echoes the PR description.

@copilot please address this.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Addressed in bbb721c: the test comment now states that the install mode matches how awf is invoked in the detection job, rather than comparing it to the main agent job.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Branch refresh was requested. Please run the pr-finisher skill, verify the branch is still merge-ready after the refresh, and leave a concise maintainer handoff with exact validations rerun and any remaining human follow-up.

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

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 28.5 AIC · ⌖ 8.22 AIC · ⊞ 9.4K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

CopilotAI commented Aug 21, 2026

Copy link
Copy Markdown
ContributorAuthor

@copilot

Branch refresh was requested. Please run the pr-finisher skill, verify the branch is still merge-ready after the refresh, and leave a concise maintainer handoff with exact validations reru...

Ran the pr-finisher pass and pushed follow-up commit bbb721c. Local validation rerun: make fmt ✅, targeted go test ./pkg/workflow -run 'TestBuildExternalDetectorExecutionStepEmitsTimeoutMinutes|TestBuildInstallAWFForExternalDetectorStepUsesRootless' ✅, make test-unit ✅, make test ✅, make recompile ✅. make lint and make agent-report-progress are blocked by existing repository-wide golint-custom long-function findings outside this PR. CI on the new agent commit is stale/unverified until a maintainer re-triggers it.

CopilotAI requested a review from gh-aw-botAugust 21, 2026 23:11
@pelikhan
pelikhan merged commit e370182 into mainAug 21, 2026
2 checks passed
@pelikhan
pelikhan deleted the copilot/v0872-fix-detection-timeout-and-rootless branch August 21, 2026 23:18
Sign up for freeto 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.

v0.87.2 external threat-detect: detection step lost its timeout-minutes, and its AWF install lost --rootless

4 participants

@gh-aw-bot@pelikhan