Skip to content

[ci-scan-feedback] Allow fixer to read scanner-authored KBE bodies - #133150

Merged
vitek-karas merged 11 commits into
dotnet:mainfrom
vitek-karas:vitek-karas-fixer-kbe-integrity-gate
Sep 14, 2026
Merged

vitek-karas merged 11 commits into
dotnet:mainfrom
vitek-karas:vitek-karas-fixer-kbe-integrity-gate

Conversation

@vitek-karas

@vitek-karas vitek-karas commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Problem

The CI failure scanner files [ci-scan] Known Build Error issues for the companion ci-failure-fix workflow to investigate. The fixer could not reliably see scanner-authored issue bodies, leaving it unable to analyze those failures or produce fixes and owner handoffs. This is the problem reported in #132745.

The fix scopes issue enumeration to dotnet/runtime and the Known Build Error label, then deterministically selects issues created by the scanner bot before the agent processes them.

The earlier filtering implementation needed additional corrections:

  • gh issue list --json author represents the scanner as app/github-actions, not github-actions[bot]. Comparing those values rejected every scanner candidate: a read-only check found 0 matches despite 35 eligible issues.
  • The gh-aw v0.86.2 pre-agent CLI proxy does not apply approval-label settings, so placing enumeration in that phase does not reliably solve the original intake problem.
  • The empty-result path referenced a safe-output variable that was not available in that step and did not actually prevent agent startup.

How the fix works

  1. Keep GitHub content reads scoped to dotnet/runtime and configure Known Build Error as the approval label used to make KBE bodies available.
  2. Add a separate deterministic scanner_kbes job with issues: read. It uses a shared, paginated REST filter scoped by repository, open state, and label. REST exposes the scanner's canonical github-actions[bot] identity.
  3. Filter each page for actual issues—not pull requests—with the exact label, [ci-scan] title prefix, matching bot login, and Bot account type. Preserve issue metadata needed for validation and order candidates oldest first. There is no 1,000-issue cap or recency cutoff that could strand older open KBEs.
  4. Start the agent only when the candidate count is greater than zero. Enumeration failures fail the job rather than publishing a partial list; a missing or invalid allowlist must not fall back to broader search. Candidate bodies and comments are read through GitHub MCP.
  5. Harden the live eval by preserving and restoring the trusted scanner helper when it is present in the trusted checkout. The deterministic grader validates generated candidate metadata and requires the selected issue's current MCP body read to confirm that it remains open, scanner-authored, correctly titled, and still carries the Known Build Error label, along with a successful comments read for the same candidate.
  6. Add regression coverage for filtering, metadata, pagination, failure handling, trusted setup, current-state validation, MCP evidence, and invalid candidate lists.

Explicit non-goal

This PR does not redesign the existing eval harness to make the candidate artifact immutable or independently provenance-verifiable. That is a larger eval-harness change and remains out of scope for this focused improvement.

The lock file was regenerated with its recorded compiler version, gh-aw v0.86.2. The original failure-issue expiry value of 0 is preserved. This does not change the fixer's separate PR/comment deduplication logic.

Validation

  • python3 .github/workflows/evals/test_ci_failure_fix_candidates.py: 18 tests passed, covering filtering, metadata, oldest-first ordering, pagination beyond 1,000 issues, empty results, API failure propagation, repository/job conditions, trusted eval setup, current candidate state, and body/comments/decision identity.
  • gh aw compile ci-failure-fix --no-check-update: 1/1 workflow compiled for the changed source workflow.
  • gh aw validate ci-failure-fix --no-check-update: passed.
  • vally lint --eval-spec .github/workflows/evals/ci-failure-fix.eval.yaml --strict: passed.
  • ShellCheck 0.11.0 and bash -n on the shared filter script: passed.
  • git diff --check: passed.

Actionlint baseline caveat: Actionlint 1.7.12 reports the same three diagnostics on the prior PR head and this implementation when shellcheck integration is disabled: two unsupported concurrency.queue keys and one github.aw expression. No new diagnostics were introduced. Its shellcheck integration also reports four pre-existing diagnostics in the generated workflow block.

No live GitHub Actions run or full LLM eval was performed.

Note

This PR and its description were prepared with GitHub Copilot.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
15 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@vitek-karas
vitek-karas marked this pull request as ready for review September 3, 2026 06:55
@vitek-karas
vitek-karas requested review from a team and jeffhandley as code owners September 3, 2026 06:55
Copilot AI lite review requested due to automatic review settings September 3, 2026 06:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
15 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

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

The lock file includes an additional operational change (GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS 0→168) that appears out-of-scope and should be reverted or explicitly justified.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the ci-failure-fix agentic workflow’s GitHub tool guard configuration so that content authored by github-actions[bot] can pass the workflow’s min-integrity: approved filter, enabling the fixer to consume scanner-authored KBE issue bodies.

Changes:

  • Add github-actions[bot] to the workflow’s GitHub MCP trusted-users list.
  • Regenerate the compiled lock workflow to include the corresponding guard environment change.
File summaries
File Description
.github/workflows/ci-failure-fix.md Adds trusted-users: ["github-actions[bot]"] to the GitHub tool config.
.github/workflows/ci-failure-fix.lock.yml Updates generated guard config to include the trusted user (and includes an additional env-value change that should be confirmed/reverted).
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread .github/workflows/ci-failure-fix.md Resolved
Limit CI fixer reads to runtime KBE items and regenerate the compiled workflow.

Co-authored-by: Copilot App <[email protected]>
Copilot AI review requested due to automatic review settings September 8, 2026 07:47

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

The implemented guard change (label-based approval promotion) does not match the PR’s stated intent (trusted user for github-actions[bot]) and expands trust semantics beyond what the description/scope claims.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread .github/workflows/ci-failure-fix.md Resolved
vitek-karas and others added 2 commits September 8, 2026 10:26
Use the Known Build Error label for integrity approval, then deterministically allowlist only scanner-authored issues before the agent runs.

Co-authored-by: Copilot App <[email protected]>
Recover scanner-only filtering with paginated metadata enumeration, conditional agent execution, and regression coverage.

Co-authored-by: Copilot App <[email protected]>

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

Unresolved allowlist enforcement, repository-guard, and eval-integrity findings block approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (3)

.github/workflows/ci-failure-fix.md:59

  • This newly added job hardcodes repos/dotnet/runtime but has no repository guard. The generated lock likewise emits scanner_kbes without an if, while the workflow guidance requires jobs to be restricted to the intended repository/fork context (.github/workflows/README.md:9-19). In a non-fork copy where activation runs, this job can still enumerate runtime KBEs and pass them to the agent; add an explicit if: github.repository == 'dotnet/runtime' (or equivalent) and regenerate the lock.
  scanner_kbes:
    needs: activation
    runs-on: ubuntu-latest

.github/workflows/evals/ci-failure-fix.eval.yaml:49

  • This eval step reads the selected KBE with gh issue view, which bypasses the workflow's required integrity-gated GitHub MCP path for bodies/comments (Step 2 explicitly says NOT gh). The live eval can therefore consume maintainer-authored comments unfiltered and still pass even if the production MCP gate is broken. Use the GitHub MCP issue/comments tools here and reserve gh for the metadata intake/source reads.
      2. Read it with `gh issue view <n> --repo dotnet/runtime` to recover the failing test and error signature, and inspect the relevant product or test source it points at, using `gh api` raw content or the failing area path, enough to decide whether a safe, in-bounds fix exists.

.github/workflows/evals/ci-failure-fix.eval.yaml:88

  • By broadening the only required tool-call pattern to gh (api|issue), this eval can satisfy its acted-on-real-kbe evidence after the agent merely runs the allowlist enumeration; that call does not show that it read or acted on any candidate. The production enumerator runs outside the agent, while the prompt's gh issue view is the issue-level evidence, so keep a separate or conditional requirement for gh issue when the allowlist is non-empty while still allowing the empty-list noop path.
              command: 'gh (api|issue)'
  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread .github/workflows/ci-failure-fix.md Resolved
Copilot AI review requested due to automatic review settings September 11, 2026 12:47
Copilot AI review requested due to automatic review settings September 11, 2026 12:55

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.

🔵 Needs a closer look

The eval grader does not verify intake provenance and can be bypassed with unvalidated issue reads.

Review details

Suppressed comments (1)

.github/workflows/evals/ci-failure-fix.eval.yaml:141

  • The grader does not actually establish that the deterministic intake ran. This regex accepts any successful command containing the repos/dotnet/runtime/issues prefix (including gh api repos/dotnet/runtime/issues/<number>), without checking the label, author/type, PR exclusion, pagination, or filter output; the candidate file is separately trusted after only validating positive numbers. An agent could therefore read a human-authored issue through gh, write its number to out/scanner-kbe-candidates.json, make a matching MCP read, and pass this eval despite bypassing the production intake and its “no gh body reads” rule. Validate the exact intake parameters/output provenance and reject CLI body reads, with a regression test for this bypass.
                      if name == "bash" and re.search(
                          r"\bgh api\b[^\n]*\brepos/dotnet/runtime/issues\b",
                          args.get("command", ""),
                      ):
                          enumerated = True
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 13:08

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

Two critical workflow and grader-integrity issues remain, along with a comments-filtering issue.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

.github/workflows/evals/ci-failure-fix.eval.yaml:153

  • This rejects the entire read whenever the serialized result contains [Filtered], including a normal comments response with one association-gated comment. The linked issue explicitly requires maintainer comments to remain filtered while the bot-authored body is readable, and the fixer is supposed to skip filtered comments; consequently a valid candidate can fail the live eval solely because an unrelated comment was filtered. Distinguish a filtered body/error from filtered entries within the comments collection, and require the comments call without requiring every comment to be trusted.
                      if data.get("success") is not True or (
                          isinstance(result, dict) and result.get("isError") is True
                      ) or "[Filtered]" in json.dumps(result):
                          continue
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread .github/workflows/ci-failure-fix.md Resolved
Copilot AI review requested due to automatic review settings September 11, 2026 15:11

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

The eval setup is not trusted against PR-controlled code, and unbounded output can exceed GitHub Actions limits.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 15:39

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.

🔵 Needs a closer look

Unresolved findings affect filtered-content handling, issue-state revalidation, candidate validation, and artifact retention.

Review details

Suppressed comments (5)

.github/workflows/ci-failure-fix.md:84

  • The candidate artifact is consumed immediately by the dependent agent, but this upload does not set a retention period. With the repository's default artifact retention, a new allowlist is retained for every 12-hour run (including empty-list runs) for much longer than it is useful, causing avoidable artifact/storage accumulation; the other transient artifacts in this workflow use one-day retention. Add retention-days: 1 here and regenerate the lock file.
          name: scanner-kbe-candidates
          path: ${{ runner.temp }}/scanner-kbe-candidates.json
          if-no-files-found: error

.github/workflows/ci-failure-fix.md:192

  • This replacement removes the previous explicit rule to skip [Filtered] MCP content, even though comments remain integrity-gated. Without telling the agent to treat a filtered body as unavailable and to ignore filtered comment entries during deduplication, it can act on incomplete/untrusted content or miss an existing handoff and emit a duplicate artifact. Restore explicit filtered-content handling and add coverage for it.
The deterministic `scanner_kbes` job has prepared `/tmp/gh-aw/agent/scanner-kbe-candidates.json`. It selects remediation candidates: only open `dotnet/runtime` issues whose exact `Known Build Error` label, `[ci-scan]` title prefix, and `github-actions[bot]` author were verified through the GitHub API. Select work only from `.candidates[].number`, in ascending creation order. If the candidate file is missing or invalid, report the error and stop; do not fall back to search for other candidates.

.github/workflows/ci-failure-fix.md:192

  • The allowlist is produced in a separate job and can become stale before the agent runs: an issue may be closed after gh api enumerates it, but this instruction still permits processing it as an open remediation target. Re-read the current issue state through MCP and require state == open before deduplication/analysis (and cover that handoff race in the deterministic grader).
The deterministic `scanner_kbes` job has prepared `/tmp/gh-aw/agent/scanner-kbe-candidates.json`. It selects remediation candidates: only open `dotnet/runtime` issues whose exact `Known Build Error` label, `[ci-scan]` title prefix, and `github-actions[bot]` author were verified through the GitHub API. Select work only from `.candidates[].number`, in ascending creation order. If the candidate file is missing or invalid, report the error and stop; do not fall back to search for other candidates.

.github/workflows/evals/ci-failure-fix.eval.yaml:168

  • This accepts every successful get_comments call without checking whether the result is usable. An integrity-gated MCP read that returns only [Filtered] comments can therefore satisfy the eval, even though the fixer cannot inspect comments needed for deduplication and owner-engagement decisions. Reject an all-filtered comments result while still allowing a mixed result containing some filtered entries, and add a regression fixture for that case.
                      elif args.get("method") == "get_comments":
                          comments_numbers.add(args["issue_number"])

.github/workflows/evals/ci-failure-fix.eval.yaml:130

  • If the candidate artifact contains a non-string title (for example null), this validation raises AttributeError at .startswith instead of taking the documented invalid-candidate path. Validate the title's type before calling the string method and add a malformed-title regression case so corrupted setup data produces a deterministic grader error.
                  not item.get("title", "").startswith("[ci-scan] ") or
  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Holistic Review

Motivation: Deterministic scanner-candidate intake addresses the previously missing selection gate.

Approach: The pushed helper, repository-scoped intake job, and artifact transport address my prior missing-gate concern. One setup failure remains in the revised eval.

Summary: Needs Changes at e9ed82cb: the production-intake concern is addressed, but the new eval setup command fails under the configured Linux runner shell.

Detailed Findings

❌ Error — Eval setup uses Bash options under /bin/sh

.github/workflows/evals/ci-failure-fix.eval.yaml:42 starts an environment.commands block with set -euo pipefail. Pinned Vally 0.14 executes these commands using Node exec without a shell override, which selects /bin/sh on Unix. On Ubuntu this is dash, and executing the exact parsed setup command reproduces exit 2: set: Illegal option -o pipefail, before the helper or agent starts.

Use portable set -eu in this outer block (the helper is already explicitly invoked with Bash), or explicitly run the entire block under Bash. Add coverage that executes the actual setup block under the runner shell with fake gh; the existing collector tests invoke Bash and do not catch this mismatch.

This applies when the revised spec is evaluated directly or deployed. Since PR ci-eval preserves the base spec, it is not a claim that the current PR check already encountered this failure.

The separately discussed eval-provenance limitations remain deferred; this follow-up does not claim those are fixed or introduce a new production trust finding. CI status and merge readiness were not evaluated.

Note

This review was generated by GitHub Copilot.

Copilot AI review requested due to automatic review settings September 11, 2026 17:43

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

Unresolved trusted-helper handling and an eval fixture mismatch must be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

.github/workflows/evals/test_ci_failure_fix_candidates.py:395

  • This fixture does not match the REST shape consumed by filter-scanner-kbes.sh: the filter requires .state == "open" and .user.login/.user.type, but this fake response omits state and supplies projected author/author_type fields instead. The filter therefore produces an empty candidate list, so test_eval_setup_runs_under_posix_shell fails instead of validating the setup; return a raw issue-shaped object here.
                "    printf '%s\\n' '[{\"number\":42,\"created_at\":\"2026-01-01T00:00:00Z\","
                "\"title\":\"[ci-scan] Test failure\",\"author\":\"github-actions[bot]\","
                "\"author_type\":\"Bot\",\"labels\":[\"Known Build Error\"]}]'\n"
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread .github/workflows/ci-eval.yml Resolved
@vitek-karas

Copy link
Copy Markdown
Member Author

@PureWeen could you please take another look - I think this is ready. I am intentionally not trying to make the entire eval more robust than it already was in this PR (that's a whole other large thing to tackle if we think we really need it).

@vitek-karas
vitek-karas merged commit 7d312ad into dotnet:main Sep 14, 2026
24 checks passed
@vitek-karas
vitek-karas deleted the vitek-karas-fixer-kbe-integrity-gate branch September 14, 2026 10:18
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 15, 2026
jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 18, 2026
…otnet#133150)

## Problem

The CI failure scanner files `[ci-scan]` Known Build Error issues for
the companion `ci-failure-fix` workflow to investigate. The fixer could
not reliably see scanner-authored issue bodies, leaving it unable to
analyze those failures or produce fixes and owner handoffs. This is the
problem reported in dotnet#132745.

The fix scopes issue enumeration to `dotnet/runtime` and the `Known
Build Error` label, then deterministically selects issues created by the
scanner bot before the agent processes them.

The earlier filtering implementation needed additional corrections:

- `gh issue list --json author` represents the scanner as
`app/github-actions`, not `github-actions[bot]`. Comparing those values
rejected every scanner candidate: a read-only check found **0 matches
despite 35 eligible issues**.
- The gh-aw v0.86.2 pre-agent CLI proxy does not apply approval-label
settings, so placing enumeration in that phase does not reliably solve
the original intake problem.
- The empty-result path referenced a safe-output variable that was not
available in that step and did not actually prevent agent startup.

## How the fix works

1. Keep GitHub content reads scoped to `dotnet/runtime` and configure
`Known Build Error` as the approval label used to make KBE bodies
available.
2. Add a separate deterministic `scanner_kbes` job with `issues: read`.
It uses a shared, paginated REST filter scoped by repository, open
state, and label. REST exposes the scanner's canonical
`github-actions[bot]` identity.
3. Filter each page for actual issues—not pull requests—with the exact
label, `[ci-scan] ` title prefix, matching bot login, and `Bot` account
type. Preserve issue metadata needed for validation and order candidates
oldest first. There is no 1,000-issue cap or recency cutoff that could
strand older open KBEs.
4. Start the agent only when the candidate count is greater than zero.
Enumeration failures fail the job rather than publishing a partial list;
a missing or invalid allowlist must not fall back to broader search.
Candidate bodies and comments are read through GitHub MCP.
5. Harden the live eval by preserving and restoring the trusted scanner
helper when it is present in the trusted checkout. The deterministic
grader validates generated candidate metadata and requires the selected
issue's current MCP body read to confirm that it remains open,
scanner-authored, correctly titled, and still carries the `Known Build
Error` label, along with a successful comments read for the same
candidate.
6. Add regression coverage for filtering, metadata, pagination, failure
handling, trusted setup, current-state validation, MCP evidence, and
invalid candidate lists.

## Explicit non-goal

This PR does not redesign the existing eval harness to make the
candidate artifact immutable or independently provenance-verifiable.
That is a larger eval-harness change and remains out of scope for this
focused improvement.

The lock file was regenerated with its recorded compiler version,
**gh-aw v0.86.2**. The original failure-issue expiry value of `0` is
preserved. This does not change the fixer's separate PR/comment
deduplication logic.

## Validation

- `python3 .github/workflows/evals/test_ci_failure_fix_candidates.py`:
**18 tests passed**, covering filtering, metadata, oldest-first
ordering, pagination beyond 1,000 issues, empty results, API failure
propagation, repository/job conditions, trusted eval setup, current
candidate state, and body/comments/decision identity.
- `gh aw compile ci-failure-fix --no-check-update`: **1/1 workflow
compiled** for the changed source workflow.
- `gh aw validate ci-failure-fix --no-check-update`: passed.
- `vally lint --eval-spec
.github/workflows/evals/ci-failure-fix.eval.yaml --strict`: passed.
- ShellCheck 0.11.0 and `bash -n` on the shared filter script: passed.
- `git diff --check`: passed.

**Actionlint baseline caveat:** Actionlint 1.7.12 reports the same three
diagnostics on the prior PR head and this implementation when shellcheck
integration is disabled: two unsupported `concurrency.queue` keys and
one `github.aw` expression. No new diagnostics were introduced. Its
shellcheck integration also reports four pre-existing diagnostics in the
generated workflow block.

No live GitHub Actions run or full LLM eval was performed.

> [!NOTE]
> This PR and its description were prepared with GitHub Copilot.

---------

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Vitek Karas <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants