Conversation
…lattened agent artifact Previously detectFirewallAuditArtifacts only looked in: - sandbox/firewall/audit/ (post-flattening) - firewall-audit*/ directories (legacy separate artifact) It did not check inside the non-flattened unified agent artifact directory (agent/, agent-artifacts/, or *-agent/ for workflow_call), so the files would not be found when audit is run on a directory populated via `gh run download` without going through flattenUnifiedArtifact. Adds lookup for: - agent/sandbox/firewall/audit/ (new structure, v4+ prefix stripping) - agent/tmp/gh-aw/sandbox/firewall/audit/ (old structure, full path preserved) - agent-artifacts/... (legacy artifact name) - <hash>-agent/... (workflow_call prefixed names) Also adds 4 new test cases for these additional lookup paths. Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2303d4dd-1c37-4812-aa7c-d740e1a19b96 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/2303d4dd-1c37-4812-aa7c-d740e1a19b96 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Extends detectFirewallAuditArtifacts so gh aw audit can locate firewall audit artifacts inside a non-flattened unified agent artifact directory (e.g., after gh run download but before flattenUnifiedArtifact runs).
Changes:
- Refactors
detectFirewallAuditArtifactsto check additional agent artifact layouts (agent/sandbox/...andagent/tmp/gh-aw/...) before falling back to legacyfirewall-audit*. - Reuses
findArtifactDirto supportagent,agent-artifacts, and workflow_call-prefixed*-agentdirectories. - Adds new subtests covering the non-flattened artifact directory structures and naming variants.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/firewall_policy.go | Adds new lookup steps for non-flattened unified agent artifact layouts; refactors repeated stat logic into checkDir. |
| pkg/cli/firewall_policy_test.go | Adds subtests validating detection across new/old agent artifact layouts and naming variants. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
| // New artifact structure (actions/upload-artifact v4+, /tmp/gh-aw/ prefix stripped): | ||
| // agent/sandbox/firewall/audit/ | ||
| if !checkDir(filepath.Join(agentDir, "sandbox", "firewall", "audit"), "agent/sandbox/firewall/audit") { | ||
| // Old artifact structure (/tmp/gh-aw/ prefix preserved inside the artifact): | ||
| // agent/tmp/gh-aw/sandbox/firewall/audit/ | ||
| checkDir(filepath.Join(agentDir, "tmp", "gh-aw", "sandbox", "firewall", "audit"), "agent/tmp/gh-aw/sandbox/firewall/audit") | ||
| } | ||
| if manifestPath != "" && auditJSONLPath != "" { | ||
| return | ||
| } |
| // New artifact structure (actions/upload-artifact v4+, /tmp/gh-aw/ prefix stripped): | ||
| // agent/sandbox/firewall/audit/ | ||
| if !checkDir(filepath.Join(agentDir, "sandbox", "firewall", "audit"), "agent/sandbox/firewall/audit") { | ||
| // Old artifact structure (/tmp/gh-aw/ prefix preserved inside the artifact): | ||
| // agent/tmp/gh-aw/sandbox/firewall/audit/ | ||
| checkDir(filepath.Join(agentDir, "tmp", "gh-aw", "sandbox", "firewall", "audit"), "agent/tmp/gh-aw/sandbox/firewall/audit") |
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification Details
Flagged Tests — Requires ReviewNone. All new tests are clean. Language SupportTests analyzed:
📋 Detailed Analysis NotesAll 4 new sub-tests are added to the existing
Each test:
Verdict
References: §25181134281
|
There was a problem hiding this comment.
✅ Test Quality Sentinel: 100/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). All 4 new sub-tests verify observable outputs of detectFirewallAuditArtifacts across distinct real-world artifact directory structures.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Commit pushed:
|
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (122 new lines in AI has analyzed the PR diff and generated a draft ADR to help you get started: 📄 Draft ADR: The draft captures the key architectural decision: a fixed four-step search order in What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. Why ADRs Matter
ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
References: §25181134127
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal! The multi-path artifact discovery refactor looks solid. The checkDir closure eliminates the duplicated stat+assign pattern cleanly, and the 4-step search order is well-documented. See inline comments for two minor suggestions.
💥 [THE END] — Illustrated by Smoke Claude · ● 261.7K
| // checkDir probes dir for policy-manifest.json and audit.jsonl, populating the | ||
| // return variables for any files not yet found. Returns true when both are found. | ||
| checkDir := func(dir, label string) bool { | ||
| if manifestPath == "" { |
There was a problem hiding this comment.
The checkDir closure is a clean approach that reduces duplication nicely. One suggestion: consider logging the resolved agentDir path once (before probing steps 2 & 3) so debugging is easier when the audit files aren't found — the label strings are hardcoded as agent/... but the actual dir may be agent-artifacts or abc123-agent.
| // files land at agent/sandbox/firewall/audit/ inside the downloaded artifact dir. | ||
| dir := t.TempDir() | ||
| auditDir := filepath.Join(dir, "agent", "sandbox", "firewall", "audit") | ||
| require.NoError(t, os.MkdirAll(auditDir, 0755)) |
There was a problem hiding this comment.
Good table-driven test coverage for the new artifact layouts. Consider adding a test case where both the primary path AND one of the non-flattened paths exist simultaneously — verifying that the primary path takes priority (step 1 wins) would give extra confidence in the search order contract.
|
@copilot review all comments |
…ir logs - Guard against findArtifactDir returning a file path: check os.Stat IsDir() before probing for audit files inside the agent artifact directory - Derive log labels from filepath.Base(agentDir) so debug output reflects the actual on-disk name (agent-artifacts, abc123-agent, etc.) instead of the hardcoded "agent/..." string - Add test: file named "agent" does not panic or falsely match Agent-Logs-Url: https://github.com/github/gh-aw/sessions/5534ec16-9018-4e51-8a41-c13438eecaf6 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Both reviewer comments addressed in 7c6b5c6:
A new subtest ( |
Comment MemoryNote This comment is managed by comment memory.It stores persistent context for this thread in the code block at the top of this comment. |
Summary
detectFirewallAuditArtifactspreviously only searched two locations:sandbox/firewall/audit/— the post-flattening path afterflattenUnifiedArtifactrunsfirewall-audit*/directories — legacy separatefirewall-audit-logsartifactIt did not look inside the non-flattened unified agent artifact directory, so
policy-manifest.jsonandaudit.jsonlwould not be found whengh aw auditis run on a directory populated viagh run downloadwithout going throughflattenUnifiedArtifact(e.g. a user manually downloads artifacts and pointsgh aw auditat that directory, or a cached run skips the download step).Changes
pkg/cli/firewall_policy.go— RefactoreddetectFirewallAuditArtifactsto add two new lookup steps between the primary path and the legacy fallback:agent/sandbox/firewall/audit/—actions/upload-artifact v4+strips the/tmp/gh-aw/common prefix, so files land directly atsandbox/firewall/audit/inside the artifact directoryagent/tmp/gh-aw/sandbox/firewall/audit/— older artifact uploads preserved the full/tmp/gh-aw/path inside the artifactUses
findArtifactDirto resolve the agent directory, handling:agent(current name)agent-artifacts(legacy name)<hash>-agent(workflow_call prefix)Also extracted the per-directory stat+assign logic into a
checkDirclosure to eliminate the repetitive double-check pattern.pkg/cli/firewall_policy_test.go— Adds 4 new sub-tests toTestDetectFirewallAuditArtifacts:tmp/gh-awprefix (not yet flattened)agent-artifactslegacy artifact name (not yet flattened)✨ PR Review Safe Output Test - Run 25181816514