Skip to content

Add opt-out for automatic audit baseline downloads - #63012

Merged
pelikhan merged 4 commits into
mainfrom
copilot/gh-aw-audit-single-run-fix
Sep 23, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/gh-aw-audit-single-run-fix

Conversation

Copilot AI commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Single-run audits automatically fetched a previous run and downloaded its artifacts for comparison, adding unnecessary network and runtime cost when callers only needed the requested run.

  • CLI

    • Add --no-baseline for single-run audits.
    • Preserve automatic baseline comparison by default.
  • Audit rendering

    • Skip baseline discovery and artifact downloads for fresh and cached audit paths.
    • Preserve the existing JSON comparison shape with baseline_found: false.
gh aw audit <run-id> --repo <owner>/<repo> --json --no-baseline

Requested branch refresh from PR Sous Chef run https://github.com/github/gh-aw/actions/runs/35916643961

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 22.2 AIC · ⌖ 8.74 AIC · ⊞ 9.6K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix single-run audit to avoid downloading baseline artifacts Add opt-out for automatic audit baseline downloads Sep 23, 2026
@pelikhan
pelikhan marked this pull request as ready for review September 23, 2026 19:56
Copilot AI balanced review requested due to automatic review settings September 23, 2026 19:56

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.

Copilot review overview

🟡 Changes recommended

Full audit caches ignore the requested mode and can also preserve an opt-out result for later default audits.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds a --no-baseline option to avoid automatic baseline discovery and downloads during single-run audits.

Changes:

  • Propagates the opt-out through CLI and audit configuration.
  • Skips comparison generation for fresh and logs-cached reports.
  • Adds flag and rendering tests.
File Description
pkg/​cli/​audit.go Adds baseline opt-out state.
pkg/​cli/​audit_run_pipeline.go Propagates the option through execution.
pkg/​cli/​audit_run_pipeline_test.go Tests configuration propagation.
pkg/​cli/​audit_render_output.go Conditionally skips baseline generation.
pkg/​cli/​audit_render_output_test.go Tests fresh and logs-cache behavior.
pkg/​cli/​audit_command.go Registers and forwards the CLI flag.
pkg/​cli/​audit_command_test.go Tests flag registration and parsing.

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

Comment thread pkg/cli/audit_render_output.go Outdated
Comment on lines +60 to +62
func buildRenderedAuditComparison(ctx context.Context, processedRun ProcessedRun, createdItems []CreatedItemReport, runOutputDir string, opts AuditOptions) *AuditComparisonData {
if opts.NoBaseline {
return &AuditComparisonData{BaselineFound: false}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in af29bc1. renderAuditReport now drops the comparison from a full cache hit when --no-baseline is set, and an opt-out result is no longer persisted as a full cache entry, so a later default audit still computes the baseline comparison. Both invocation orders are covered by TestRenderAuditReportDropsCachedComparisonWithNoBaseline and TestRenderAuditReportDoesNotCacheNoBaselineResult.

@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Warning

Firewall blocked 5 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • o205451.ingest.us.sentry.io
  • proxy.golang.org
  • storage.googleapis.com
  • sum.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"
    - "o205451.ingest.us.sentry.io"
    - "proxy.golang.org"
    - "storage.googleapis.com"
    - "sum.golang.org"

See Network Configuration for more information.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

Copy link
Copy Markdown
Contributor

🔎 PR Code Quality Reviewer is reviewing code quality for this pull request...

@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

No ADR enforcement needed: PR does not have the 'implementation' label and has <=100 new lines of code in business logic directories.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Sep 23, 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

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • o205451.ingest.us.sentry.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "o205451.ingest.us.sentry.io"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Ponytail Reviewer for #63012

@github-actions github-actions Bot 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.

Applied Impeccable harden and audit modes (bug-fix change adding a new CLI opt-out flag with edge-state handling).

Findings

🟠 HIGH--no-baseline is not cache-safe: a pre-existing full audit cache (written by a prior run without the flag) is served as-is by renderAuditReport, bypassing buildRenderedAuditComparison entirely, so the flag silently has no effect. See inline comment on pkg/cli/audit_render_output.go.

No other blocking issues found in the diff (flag wiring, config threading, and the logs-cache/fresh-build paths look correct and are covered by the new tests).

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • o205451.ingest.us.sentry.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "o205451.ingest.us.sentry.io"

See Network Configuration for more information.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · copilot · sonnet50 · 57 AIC · ⌖ 13.2 AIC · ⊞ 8.1K

Comments that could not be inline-anchored

pkg/cli/audit_render_output.go:25

--no-baseline doesn't take effect when a full audit cache already exists on disk. renderAuditReport checks loadCachedAuditData(runOutputDir, processedRun.Run, auditCacheSourceFull) first and, on a cache hit, returns the cached AuditData (including its Comparison) directly — buildRenderedAuditComparison/opts.NoBaseline is never consulted in that path (see pkg/cli/audit_render_output.go lines 23-31).

Repro: run gh aw audit &lt;run&gt; once (populates the full cache with a real co…

@github-actions github-actions Bot 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 and /tdd — requesting changes on a confirmed cache-safety bug.

📋 Key Themes & Highlights

Key Themes

  • Cache-safety bug (confirmed by reproduction): renderAuditReport short-circuits on a pre-existing full audit cache before buildRenderedAuditComparison ever runs, so --no-baseline is silently ignored when a cache entry already exists (and the reverse: a BaselineFound:false result cached under --no-baseline persists after removing the flag). I wrote and ran a local reproduction confirming both directions. This duplicates and confirms an existing unresolved review comment from Copilot on the same line.
  • Test coverage gap: the two new tests exercise buildRenderedAuditData/buildRenderedAuditDataFromCache directly, which never touches the buggy cache short-circuit in renderAuditReport. A regression test through the real entry point is needed to catch this.

Positive Highlights

  • ✅ Clean, minimal flag threading through AuditOptionsauditRunConfig → CLI, consistent with existing patterns.
  • buildRenderedAuditComparison is a good extraction that removes duplication between the two build paths.
  • ✅ Flag registration test coverage for --no-baseline is present and correct.

@copilot please address the review comments above.

Warning

Firewall blocked 5 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • o205451.ingest.us.sentry.io
  • proxy.golang.org
  • storage.googleapis.com
  • sum.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"
    - "o205451.ingest.us.sentry.io"
    - "proxy.golang.org"
    - "storage.googleapis.com"
    - "sum.golang.org"

See Network Configuration for more information.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 95 AIC · ⌖ 14.7 AIC · ⊞ 10.1K
Comment /matt to run again

Comments that could not be inline-anchored

pkg/cli/audit_render_output.go:23

[/diagnosing-bugs] --no-baseline is not cache-safe: loadCachedAuditData never checks opts.NoBaseline, so a stale full-audit cache written without the flag is replayed verbatim when --no-baseline is passed later (and vice versa — a BaselineFound:false cache from a --no-baseline run sticks even after the flag is removed). I reproduced this locally by seeding a full cache with BaselineFound:true and then calling renderAuditReport with NoBaseline:true; the stale true value…

pkg/cli/audit_render_output_test.go:92

[/tdd] Both new tests call buildRenderedAuditData/buildRenderedAuditDataFromCache directly, bypassing renderAuditReport's loadCachedAuditData(..., auditCacheSourceFull) short-circuit — so the cache-bypass bug flagged in the sibling comment on audit_render_output.go has no failing test to catch it. A regression test should call renderAuditReport twice (with a pre-seeded full-cache file, and with NoBaseline toggled between calls) to assert the flag is honored even when a cache e…

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please move this PR forward.

Outstanding review feedback remains unresolved and the compact candidate set still shows failed checks:

Please address the open review finding, inspect the failed runs, refresh the branch if needed, and run the pr-finisher skill before handing back for maintainer review.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 22.2 AIC · ⌖ 8.74 AIC · ⊞ 9.6K ·
Comment /souschef to run again

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

Copilot AI commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please move this PR forward.

Outstanding review feedback remains unresolved and the compact candidate set still shows failed checks:...

Addressed in af29bc1:

  • Review finding (--no-baseline cache safety): renderAuditReport now drops the comparison from a full cache hit when --no-baseline is set, and opt-out results are never written as a full cache entry, so a later default audit still computes the baseline comparison. Both invocation orders have tests.
  • Failed checks: neither is caused by this branch. Unit tests (N-R) failed on the coverage upload step (Coverage upload failed (HTTP 403): Resource not accessible by integration); the Go tests themselves passed. The conclusion job failure is from the agentic workflow run, which reported No failed non-builtin jobs found.
  • Branch freshness: branch merges cleanly with main (no conflicts), so no refresh was needed.

Local validation (make agent-report-progress, including formatting, linting, and impacted unit tests) passes.

@pelikhan
pelikhan merged commit 4b60626 into main Sep 23, 2026
2 of 3 checks passed
@pelikhan
pelikhan deleted the copilot/gh-aw-audit-single-run-fix branch September 23, 2026 21:16
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.

gh aw audit: single-run mode unconditionally downloads a second 'baseline' run's full artifacts

4 participants