Skip to content

[gh-aw] Add nightly-fix-finder agentic workflow#11352

Open
jonathanpeppers wants to merge 12 commits into
mainfrom
jonathanpeppers/nightly-fix-finder-workflow
Open

[gh-aw] Add nightly-fix-finder agentic workflow#11352
jonathanpeppers wants to merge 12 commits into
mainfrom
jonathanpeppers/nightly-fix-finder-workflow

Conversation

@jonathanpeppers
Copy link
Copy Markdown
Member

Summary

Adds a nightly agentic workflow (gh aw) that automatically scans the repo for code quality improvements, files issues, and assigns Copilot (Claude Opus 4.6) to fix them.

What it does

Each night, the workflow:

  1. Runs a pre-agent bash step to collect codebase metrics across 10 scan categories
  2. The AI agent picks one random category and investigates specific files
  3. Creates a focused GitHub issue describing the problem and fix
  4. Assigns copilot to the issue with claude-opus-4.6 model via assign-to-agent

Scan categories

Category What it looks for
Nullable gaps Files without #nullable enable
TODO/HACK comments Stale inline markers
Large methods Methods over 80 lines
Dead usings Unnecessary using directives
Magic numbers Unexplained numeric literals
Inconsistent naming Style violations
Missing XML docs Public APIs without docs
Exception handling Bare catch blocks
Code duplication Repeated patterns
Test coverage gaps Untested public methods

Key design decisions

  • Uses assign-to-agent safe-output with model: "claude-opus-4.6" to ensure Opus is used (not the default "Auto")
  • close-older-issues: true — each run replaces unfixed issues from previous runs
  • Issues expire after 7 days (expires: 7d)
  • Limited to 1 issue per run (max: 1)
  • strict: true with read-only permissions — the agent cannot modify code directly
  • 30-minute timeout

Files

  • .github/workflows/nightly-fix-finder.md — Workflow source (frontmatter + agent prompt)
  • .github/workflows/nightly-fix-finder.lock.yml — Compiled workflow (auto-generated by gh aw compile)

Adds a gh aw workflow that runs nightly to scan the codebase for
random improvement opportunities across 10 categories (TODO comments,
nullable gaps, large files, obsolete APIs, test coverage, etc.).

Each night it picks one category, finds a specific actionable issue,
files a GitHub issue, and assigns Copilot with Claude Opus 4.6 via
the assign-to-agent safe-output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 14, 2026 21:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new gh-aw nightly “fix finder” agentic workflow that scans src/ for a rotating set of code-quality signals, then creates (and optionally assigns) a focused GitHub issue for Copilot to address. It adds both the human-authored workflow source (.md) and the compiled lock workflow (.lock.yml) used by GitHub Actions.

Changes:

  • Adds a nightly scheduled agentic workflow prompt + pre-scan bash step to generate /tmp/gh-aw/agent/scan-results.md.
  • Configures safe outputs for create-issue + assign-to-agent (Opus 4.6) and a noop path.
  • Checks in the generated .lock.yml produced by gh aw compile.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
.github/workflows/nightly-fix-finder.md Defines the workflow frontmatter, bash scan step, and the agent prompt/instructions.
.github/workflows/nightly-fix-finder.lock.yml Auto-generated compiled workflow consumed by GitHub Actions runner.

Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md
Comment thread .github/workflows/nightly-fix-finder.md
jonathanpeppers and others added 2 commits May 14, 2026 16:11
Automatically runs the nightly-fix-finder workflow when PRs
modify either the .md source or .lock.yml compiled file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Use --exclude-dir=obj/bin instead of piping through grep -v
- Replace slow find -exec grep per-file with grep -rL batch
- Fix Category 8 regex: add grep -P for \s and \b support
- Fix Category 4: adjust description since same-line /// check
  is unreliable, let the agent verify docs on preceding lines
- Remove $(date) from prompt (not a shell context), reference
  the pre-computed scan results instead

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers and others added 2 commits May 14, 2026 16:25
The first run showed the agent called assign_to_agent with only
temporary_id but no issue_number, causing the assignment to be
silently skipped. Updated the prompt to explicitly instruct the
agent to pass issue_number referencing the create_issue temporary_id.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allows the agent to read all issues (including community-filed)
when checking for duplicates before filing a new issue.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The agent passed issue_number: "#aw_xdoc1" but the validator
requires just "aw_xdoc1" (no # prefix) for temporary IDs.

Also scope Category 4 (XML docs) to src/Mono.Android/ only —
internal build tasks/tools do not need XML documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The default GITHUB_TOKEN lacks permission to assign the Copilot
coding agent via GraphQL. Use ANDROID_TEAM_PAT which has the
required scopes (same pattern as dotnet/android-libraries#1389).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers and others added 2 commits May 14, 2026 16:57
These are plumbing/bridge types (InputStreamInvoker, JNIEnv, etc.)
that developers never interact with directly. Focus XML doc
suggestions on user-facing APIs like Android.App, Android.Widget.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

.github/workflows/nightly-fix-finder.md:76

  • Same pipefail issue for the nullable file count: grep -rL returns exit code 1 when it finds no files to print, which would fail the step under -e -o pipefail. Make this count command tolerant of “0 files” results so the workflow keeps running when the repo eventually fully opts into nullable.
        grep -rL '#nullable enable' --include="*.cs" --exclude-dir=obj --exclude-dir=bin src/ 2>/dev/null | shuf | head -20 || echo "None found"
        echo "### Total count"
        grep -rL '#nullable enable' --include="*.cs" --exclude-dir=obj --exclude-dir=bin src/ 2>/dev/null | wc -l

Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md Outdated
Comment thread .github/workflows/nightly-fix-finder.md Outdated
- Replace deterministic date-based category (day%10) with \%10
  so it doesn't pick the same category every run on the same day
- Add || true to grep|wc -l pipelines to avoid pipefail abort
- Fix grep -c || echo 0 double-output bug with || true + default

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jonathanpeppers
Copy link
Copy Markdown
Member Author

/review

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 14, 2026

Android PR Reviewer completed successfully!

The agent was ignoring the category index and always picking XML docs
(Category 4) because it saw data for all categories. Now the bash step
uses a case statement to only collect data for the randomly selected
category, forcing the agent to work with whatever it gets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

✅ LGTM — Clean PR with minor suggestions

Well-designed nightly agentic workflow. The bash scan step is properly hardened (previous review feedback addressed), the agent prompt is clear and well-structured, and the safety constraints (strict: true, read-only permissions, scoped bash tools, close-older-issues, expires: 7d) are solid.

Issue summary

Severity Count
💡 Suggestion 2

Positive callouts

  • Good constraint design: strict: true + read-only permissions + scoped bash tool allowlist keeps the agent's blast radius minimal
  • Issue lifecycle management: close-older-issues: true + expires: 7d prevents issue pile-up — at most 1 open issue at a time
  • Category-specific guidance: The prompt gives focused instructions per scan category, improving the quality of filed issues
  • Pipeline safety: All grep | wc -l pipelines properly guard against pipefail with || true

Generated by Android PR Reviewer for issue #11352 · ● 2.8M

Comment thread .github/workflows/nightly-fix-finder.md
Comment thread .github/workflows/nightly-fix-finder.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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