Repository navigation
Prioritize and batch AI Scan fixes without duplicating open PRs - #79559
Conversation
Co-authored-by: Copilot App <[email protected]>
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review. PR Code Quality ReviewerOutcome: The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills... |
There was a problem hiding this comment.
🟡 Changes recommended
Untrusted fork PR content is exposed to the agent and allowed to suppress remediation, creating critical prompt-injection and alert-suppression risks.
7 open issues
Untrusted fork PRs can suppress remediation · New Raw untrusted PR content is exposed to the agent · New Timed-out batches immediately retry remaining in-progress alerts · New Retryable detail failures can starve the remaining backlog · New Batch size limit suppresses individually publishable fixes · New PR coverage is not revalidated before publication · New Successful PR creation leaves checkpoints stuck in progress · New
What changed in this PR
Updates gh-aw’s Code Scanning Fixer to process the security backlog faster while avoiding remediation already covered by open pull requests.
Changes:
- Runs every four hours and selects up to five related alerts, prioritizing AI Scan findings.
- Checks all open PRs, including drafts and renamed files, and blocks remediation when coverage is incomplete.
- Updates batch checkpoints, pending-publication tracking, workflow evaluations, regression tests, and the generated workflow.
| File | Description |
|---|---|
scripts/code-scanning-fixer-selection.test.cjs |
Adds coverage for prioritization, batching, PR exclusions, pagination, and fetch failures. |
.github/workflows/code-scanning-fixer.md |
Defines the new schedule, batch-remediation instructions, cache outcomes, and evaluations. |
.github/workflows/code-scanning-fixer.lock.yml |
Regenerates the Actions workflow to reflect the source changes. |
.github/scripts/code-scanning-fixer-select.jq |
Implements deterministic ranking, clustering, eligibility, and duplicate checks. |
.github/scripts/code-scanning-fixer-context.sh |
Collects cached state, alerts, open PRs, and changed-file coverage for selection. |
Review effort: Max (adaptive)
| while IFS= read -r PR_NUMBER; do | ||
| if ! gh api --paginate "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files?per_page=100" | jq -se ' | ||
| add // [] | ||
| | if length >= 3000 then error("GitHub pull request file listing may be truncated at 3000 files") |
| jq -c --argjson number "$PR_NUMBER" --slurpfile files "$PULL_FILES" ' | ||
| .[] | select(.number == $number) | . + {files: $files[0]} | ||
| ' "$PULLS_FILE" >> "$PULL_RECORDS" | ||
| done < <(jq -r '.[].number' "$PULLS_FILE") | ||
| jq -s '.' "$PULL_RECORDS" > "$PULLS_FILE" |
| and (($record.outcome // "") != "in_progress" | ||
| or (stale($now; $record) and ($alert.number | tostring) != $stalled)) |
| - Use the `edit` tool to modify the affected file(s) | ||
| - Validate that your fix addresses the root cause | ||
| - Consider edge cases and potential side effects | ||
| - Do not broaden the patch to unrelated alerts or refactors. If a candidate is stale, a false positive, or cannot be safely fixed, leave it out of the PR and append a non-fixed `details_unavailable` outcome for that candidate, explaining the limitation. Continue with the remaining confirmed candidates; use `noop` if none remain. |
| - If the patch exceeds that limit, do not invoke `safeoutputs create-pull-request`. Append an oversized-patch JSON record for every included alert to `/tmp/gh-aw/cache-memory/fixed-alerts.jsonl` using its alert number, fingerprint, measured patch size, limit, and current timestamp. | ||
| - Discard all local edits for that attempt, invoke `safeoutputs noop` through bash stating that the alert was skipped because its patch exceeds 4,096 KB, and exit successfully. |
| - After the patch passes this size preflight, append `{"alert_number": [alert-number], "fingerprint": [candidate fingerprint], "outcome": "in_progress", "started_at": "[original started_at]", "last_successful_step": "patch_preflight_passed"}` to `/tmp/gh-aw/cache-memory/fixed-alerts.jsonl` before invoking `safeoutputs create-pull-request`. | ||
|
|
||
| After making code changes, invoke `safeoutputs create-pull-request` through bash. Follow the PR title and body format in the skill below. | ||
| Invoke `safeoutputs create-pull-request` once through bash, with a run-local `temporary_id`. Follow the PR body format below; summarize the shared correction in the title. Include the exact plain-text line `Code scanning cluster: CLUSTER_KEY`, replacing `CLUSTER_KEY` with the selection's verbatim `cluster_key`, and link every included alert as `https://github.com/${{ github.repository }}/security/code-scanning/NUMBER`. Keep this marker visible: HTML comments are stripped. The marker prevents a new PR for the same cluster while this PR is open. |
| After the tool accepts the PR intent, append one record per included alert to `/tmp/gh-aw/cache-memory/fixed-alerts.jsonl`: | ||
| - Use `{"alert_number": [alert-number], "fingerprint": [candidate fingerprint], "cluster_key": [selection cluster_key], "outcome": "pr_pending", "recorded_at": "[current-timestamp]", "pr_temporary_id": [temporary-id]}`. |


Why
The code scanning fixer handled one alert every six hours and stopped whenever any fixer PR was open. Prioritize AI Scan findings and reduce the backlog faster without duplicating remediation already underway.
Changes
Validation
make recompilemake agent-report-progressnode --test scripts/code-scanning-fixer-selection.test.cjs(19 passing tests)node --test --test-name-pattern='Fixer' scripts/workflow-tool-contracts.test.cjsbash -n .github/scripts/code-scanning-fixer-context.shpython3 scripts/check-instruction-prefixes.py .github/workflows/code-scanning-fixer.mdNo live workflows were dispatched.