Skip to content

Prioritize and batch AI Scan fixes without duplicating open PRs - #79559

Merged
pelikhan merged 1 commit into
mainfrom
pelikhan/code-scanning-fixes
Nov 20, 2026
Merged

pelikhan merged 1 commit into
mainfrom
pelikhan/code-scanning-fixes

Conversation

@pelikhan

Copy link
Copy Markdown
Collaborator

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

  • Run every four hours and select up to five related alerts by scanner, rule, and parent directory, with AI Scan first and severity-based ordering within each priority tier.
  • Inspect all open PRs, including drafts and human-authored PRs. Exclude alerts referenced in PR titles or bodies, affected files changed or renamed by a PR, and clusters already being remediated.
  • Fail closed when PR file coverage is unavailable or potentially truncated. File-overlap exclusion is deliberately conservative and can defer unrelated work in the same file.
  • Track accepted PR requests as pending rather than resolved, preserve bounded stall recovery and patch-size safeguards, and keep unrelated clusters eligible while PRs are open.
  • Update workflow instructions, evals, regression coverage, and the generated lock file.

Validation

  • make recompile
  • make agent-report-progress
  • node --test scripts/code-scanning-fixer-selection.test.cjs (19 passing tests)
  • node --test --test-name-pattern='Fixer' scripts/workflow-tool-contracts.test.cjs
  • bash -n .github/scripts/code-scanning-fixer-context.sh
  • python3 scripts/check-instruction-prefixes.py .github/workflows/code-scanning-fixer.md

No live workflows were dispatched.

@pelikhan
pelikhan marked this pull request as ready for review November 20, 2026 17:57
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 17:57
@pelikhan
pelikhan merged commit 9f91840 into main Nov 20, 2026
72 of 73 checks passed
@pelikhan
pelikhan deleted the pelikhan/code-scanning-fixes branch November 20, 2026 17:57
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

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.

Generated by PR Specification Reviewer for #79559 · copilot · gpt56 · ~1 AIC · ⌖ ~1 AIC · ⊞ 1.7K · ◷

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

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.

Generated by Ponytail Reviewer for #79559 · codex · routed: gpt61 medium · ~6 AIC · ⌖ ~1 AIC · ⊞ 185 · ◷

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

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.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt56 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

🧪 Test quality analysis by Test Quality Sentinel · copilot · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ⊞ 7.2K · ◷

@github-actions

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer is reviewing this pull request using Matt Pocock's engineering skills...

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.

🟡 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
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)

Comment on lines +48 to +51
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")
Comment on lines +60 to +64
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"
Comment on lines +73 to +74
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.
Comment on lines +194 to 195
- 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.
Comment on lines +203 to +204
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]}`.
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.

2 participants