feat: optimize export-audit workflow (~94% weekly cost reduction)#4205
feat: optimize export-audit workflow (~94% weekly cost reduction)#4205Copilot wants to merge 3 commits into
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR optimizes the export-audit agentic workflow to substantially reduce weekly LLM usage/cost by running less frequently, limiting turns, shrinking prompt/context, and consolidating pre-agent analysis into a single script.
Changes:
- Switch
export-audittrigger frompushto a weeklyscheduleand reducemax-turnsfrom 12 → 6 with an explicit hard stop. - Replace multiple pre-agent context-building steps with a single
scripts/ci/export-audit-analysis.shscript that writes the context file directly. - Update workflow lock/tests and adjust analysis output caps (
head -80 → -30, etc.) to reduce context size.
Show a summary per file
| File | Description |
|---|---|
scripts/ci/export-audit-workflow.test.ts |
Updates assertions for weekly schedule, reduced turns, condensed prompt, and consolidated analysis step/script. |
scripts/ci/export-audit-analysis.sh |
New consolidated analysis script that generates the markdown context (with reduced output caps). |
.github/workflows/export-audit.md |
Changes trigger to weekly schedule, reduces turns, and condenses prompt/instructions. |
.github/workflows/export-audit.lock.yml |
Regenerated lock workflow reflecting the new schedule/turn cap and consolidated step (but currently contains a schedule indentation bug and weaker pinning). |
.github/workflows/red-team-benchmark.lock.yml |
Updates checkout/install/build behavior (appears to be lock regeneration/postprocess fallout). |
.github/aw/actions-lock.json |
Removes some gh-aw-actions/* pins; currently missing replacements for versions referenced by updated lock workflow. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (1)
.github/aw/actions-lock.json:92
.github/aw/actions-lock.jsonremoved the entries forgithub/gh-aw-actions/setup@v0.76.1/setup-cli@v0.76.1but does not add replacements for the versions referenced by the updated lock workflow (e.g.github/gh-aw-actions/setup@v0.77.5). This makes it impossible to resolve a commit SHA forgithub/gh-aw-actions/setupduring compilation, which is why the lock manifest now contains"sha":"v0.77.5"instead of a real SHA.
"docker/setup-buildx-action@v4.1.0": {
"repo": "docker/setup-buildx-action",
"version": "v4.1.0",
"sha": "d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5"
},
"github/gh-aw/actions/setup-cli@v0.76.1": {
"repo": "github/gh-aw/actions/setup-cli",
"version": "v0.76.1",
"sha": "58d1bedbb7200f59c2d224151339e38fd8687d05"
},
"github/gh-aw/actions/setup@v0.76.1": {
"repo": "github/gh-aw/actions/setup",
"version": "v0.76.1",
"sha": "58d1bedbb7200f59c2d224151339e38fd8687d05"
},
- Files reviewed: 6/6 changed files
- Comments generated: 3
| **Issue format:** Title `[Export Audit] <description>`. Body: File, Symbol, Evidence grep, Dead code risk. Max 5 issues. Score ≥ 3: unused public API = 3, circular dep = 4, naming = 2, bad test import = 2, security-critical module = +2. | ||
|
|
||
| ## Pre-computed Data | ||
| If TS_ERRORS is non-empty, report errors and exit without filing. |
| # gh-aw-metadata: {"schema_version":"v4","frontmatter_hash":"fc0ba3460e14981caf77be5f2c57f005f99f462f759265999a6389f3b05c9634","body_hash":"6a75b85eb558fa803878c5b3b33c70aa203a0a54aa35ee280f41da71bf687202","compiler_version":"v0.77.5","strict":true,"agent_id":"claude"} | ||
| # gh-aw-manifest: {"version":1,"secrets":["ANTHROPIC_API_KEY","GH_AW_GITHUB_MCP_SERVER_TOKEN","GH_AW_GITHUB_TOKEN","GITHUB_TOKEN"],"actions":[{"repo":"actions/checkout","sha":"de0fac2e4500dabe0009e67214ff5f5447ce83dd","version":"v6.0.2"},{"repo":"actions/download-artifact","sha":"3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c","version":"v8.0.1"},{"repo":"actions/github-script","sha":"3a2844b7e9c422d3c10d287c895573f7108da1b3","version":"v9.0.0"},{"repo":"actions/setup-node","sha":"48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e","version":"v6.4.0"},{"repo":"actions/upload-artifact","sha":"043fb46d1a93c77aae656e7c1c64a875d1fc6a0a","version":"v7.0.1"},{"repo":"github/gh-aw-actions/setup","sha":"v0.77.5","version":"v0.77.5"}],"containers":[{"image":"ghcr.io/github/gh-aw-firewall/agent:0.25.58"},{"image":"ghcr.io/github/gh-aw-firewall/api-proxy:0.25.58"},{"image":"ghcr.io/github/gh-aw-firewall/squid:0.25.58"},{"image":"ghcr.io/github/gh-aw-mcpg:v0.3.22"},{"image":"ghcr.io/github/github-mcp-server:v1.1.0"},{"image":"node:lts-alpine","digest":"sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f","pinned_image":"node:lts-alpine@sha256:d1b3b4da11eefd5941e7f0b9cf17783fc99d9c6fc34884a665f40a06dbdfc94f"}]} |
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| schedule: | ||
| - cron: "0 9 * * 1" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
Addressed in b6b197d. Details per review thread: Comment 1 — Comment 2 — SHA/digest pinning ✅ Partially fixed
Comment 3 — |
Smoke Test: Claude Engine
Result: PASS
|
🔬 Smoke Test Results
Overall: PASS PR by
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR author: Overall: PASS (file test inconclusive due to unexpanded template vars)
|
|
Merged PRs reviewed:
Checks:
Overall status: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
Smoke Test Results (Gemini)
Overall status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
The
export-auditworkflow was the #1 cost driver in the fleet at ~$4.30/week ($0.86/run × 5 runs/week), with 9.6 LLM turns/run and a verbose 1,561-token prompt. Addresses all five recommendations from the token optimization report.Changes
Trigger:
push→ weeklyschedulemainmax-turns: 12 → 6Prompt: ~1,561 tokens → ~400 tokens
headlimits reduced in analysis scripthead -80→head -30head -40→head -15head -20→head -109 pre-agent steps consolidated into 1
scripts/ci/export-audit-analysis.shcontaining all analysis logic$GITHUB_OUTPUTmultiline heredoc chain; writes context file directlyExpected impact
Lock file recompiled via
gh aw compile+postprocess-smoke-workflows.ts. Tests updated to assert the new configuration.