Skip to content

[aw] Replace 3 always-noop nightly-fix-finder categories - #11739

Merged
simonrozsival merged 3 commits into
mainfrom
jonathanpeppers-symmetrical-doodle
Jun 26, 2026
Merged

[aw] Replace 3 always-noop nightly-fix-finder categories#11739
simonrozsival merged 3 commits into
mainfrom
jonathanpeppers-symmetrical-doodle

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Why

Issue #11506 tracks every no-op run from the nightly fix-finder. Three of its scripts have only produced no-ops since they were introduced, because their detectors are dominated by false positives that can never clear the confidence/safety gate:

  • 02-obsolete-api-usage (4 no-ops) -- only finds intentional #pragma CS0618 back-compat suppressions
  • 03-performance-antipatterns (3 no-ops) -- "string concat in loop" matches += event-handler subscriptions and integer accumulators
  • 07-error-handling (3 no-ops) -- "swallowed exception" matches catches that already log, rethrow, FailFast, or RaisePendingException

Keeping them in rotation wastes ~30% of nightly runs.

Approach

Delete the three losing scripts and replace each with a category tied to an explicit rule in the repo's AGENTS.md, where the detector signal is structurally cleaner and the fix is mechanical and low-risk (so it can clear safety >= 6):

  • 02-null-forgiving-operator -- postfix ! usages (foo!., foo![, foo!;, foo!,, foo!)). Repo rule: NEVER use ! in C# code. Documents the standard refactor patterns (explicit null check + throw, extract-after-Assert, declare [SetUp] field as nullable).
  • 03-region-directives -- #region / #endregion in shipped code. Repo rule: Do NOT use #region. Pure deletion fix; safety = 10.
  • 07-asynctask-log-property -- direct Log.LogMessage / Log.LogError / etc. calls inside classes deriving from AsyncTask. Repo rule: Log is [Obsolete] on AsyncTask because calling it from a background thread can hang Visual Studio. The fix is a mechanical swap to the thread-safe LogMessage / LogCodedError / LogCodedWarning / LogDebugMessage helpers.

The workflow_dispatch dropdown in nightly-fix-finder.md is updated to match, and the lock file has been regenerated with gh aw compile.

Verification

Ran each new script locally against src/:

  • 02-null-forgiving-operator returns 20 real postfix-! hits across Mono.Android and Xamarin.Android.Build.Tasks
  • 03-region-directives returns 20 real #region hits (top offender: AdbSyncClient.cs with 18 regions)
  • 07-asynctask-log-property correctly enumerates 17 AsyncTask-derived task files and surfaces real Log.Log* violations in MavenDownload.cs, LinkNativeRuntime.cs, GetMicrosoftNuGetPackagesMap.cs

Each script prints its GUIDANCE heredoc first (what to look for, how to fix, what NOT to flag) so the agent has full context without re-reading the workflow.

Checklist

  • Useful description of why the change is necessary
  • Links to issues -- context in [aw] No-Op Runs #11506
  • Unit tests -- N/A (workflow scripts, not shipped code)

Per issue #11506, three nightly-fix-finder scripts have only ever
produced no-ops because their detectors are dominated by false
positives:

  - 02-obsolete-api-usage  (4 no-ops): only finds intentional
    [Obsolete] back-compat #pragma suppressions
  - 03-performance-antipatterns  (3 no-ops): "string concat in loop"
    matches += event handler subscriptions and integer accumulators
  - 07-error-handling  (3 no-ops): "swallowed exception" matches
    catches that already log, rethrow, FailFast, or RaisePendingException

Replace them with three categories tied to explicit repo rules,
where the detector signal is structurally cleaner and the fix is
mechanical and low-risk (clears safety >= 6):

  - 02-null-forgiving-operator: postfix ! usages (foo!., foo![,
    foo!;, foo!,, foo!)). Repo rule: NEVER use ! in C# code.
  - 03-region-directives: #region / #endregion. Repo rule: Do NOT
    use #region or #endregion. Pure delete.
  - 07-asynctask-log-property: direct Log.Log* calls inside classes
    deriving from AsyncTask. Repo rule: Log is [Obsolete] on
    AsyncTask -- calling it from a background thread can hang VS.
    Swap to the thread-safe LogMessage / LogCodedError / LogCodedWarning
    / LogDebugMessage helpers.

Updated workflow_dispatch dropdown and recompiled lock file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 25, 2026 18:46
@jonathanpeppers
jonathanpeppers temporarily deployed to copilot-pr-reviewer June 25, 2026 18:46 — with GitHub Actions Inactive
@jonathanpeppers
jonathanpeppers temporarily deployed to copilot-pr-reviewer June 25, 2026 18:47 — with GitHub Actions Inactive

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.

Pull request overview

This PR updates the nightly “fix-finder” agentic workflow to reduce no-op runs by removing three historically unproductive scan categories and replacing them with three mechanically-fixable categories aligned to explicit repo rules (null-forgiving operator !, #region directives, and AsyncTask Log property misuse).

Changes:

  • Removed the 02-obsolete-api-usage, 03-performance-antipatterns, and 07-error-handling nightly scripts.
  • Added 02-null-forgiving-operator, 03-region-directives, and 07-asynctask-log-property scripts with embedded GUIDANCE + sampling output.
  • Updated the workflow workflow_dispatch dropdown options and regenerated the compiled lock file.

Reviewed changes

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

Show a summary per file
File Description
.github/workflows/nightly-fix-finder/02-obsolete-api-usage.sh Deleted obsolete-api scan category script.
.github/workflows/nightly-fix-finder/02-null-forgiving-operator.sh New scan category for postfix null-forgiving operator usage.
.github/workflows/nightly-fix-finder/03-performance-antipatterns.sh Deleted performance-antipattern scan category script.
.github/workflows/nightly-fix-finder/03-region-directives.sh New scan category for #region / #endregion usage in src/.
.github/workflows/nightly-fix-finder/07-error-handling.sh Deleted error-handling scan category script.
.github/workflows/nightly-fix-finder/07-asynctask-log-property.sh New scan category for AsyncTask-derived tasks using Log.Log* directly.
.github/workflows/nightly-fix-finder.md Updated workflow_dispatch script options to match new categories.
.github/workflows/nightly-fix-finder.lock.yml Regenerated compiled workflow lock file reflecting updated options/hashes.

Comment thread .github/workflows/nightly-fix-finder/02-null-forgiving-operator.sh
Comment thread .github/workflows/nightly-fix-finder/07-asynctask-log-property.sh
@jonathanpeppers
jonathanpeppers temporarily deployed to copilot-pr-reviewer June 25, 2026 18:52 — with GitHub Actions Inactive
- 02-null-forgiving-operator: drop the redundant `grep -vP '!='` post-filter.
  The regex already excludes `!=` at the character level (the class after
  `!` does not include `=`), so the line-level filter only created false
  negatives when a line happened to also contain `!=` elsewhere. Document
  this in the GUIDANCE.

- 07-asynctask-log-property: fix the contradictory `Log.LogErrorFromException`
  replacement example. The previous suggestion `LogCodedError ("XAxxxx",
  e.Message)` contradicted the rule below the table that error strings
  must come from `Properties.Resources`. Replace all table cells with the
  correct shape and explicitly call out that no inline English strings
  are acceptable -- prefer `noop` if a new `XA####` resource entry is
  needed.

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

Copy link
Copy Markdown
Member Author

/review

@jonathanpeppers
jonathanpeppers temporarily deployed to copilot-pr-reviewer June 25, 2026 18:54 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

@github-actions github-actions Bot 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.

🤖 Code Review — ⚠️ One recommended fix + one suggestion (non-blocking)

Cleanly-scoped workflow change that retires three always-noop fix-finder detectors and replaces them with three higher-precision ones tied to explicit AGENTS.md rules. The .md dropdown, the regenerated .lock.yml, and the script filenames are all consistent — and I confirmed no references to the old category names remain anywhere in the tree.

Findings (both inline)

  • ⚠️ 07-asynctask-log-property.sh:22 — the LogErrorFromException replacement row points at a bare helper that isn't part of AsyncTask's thread-safe API and would likely not compile.
  • 💡 07-asynctask-log-property.sh:45 — the : AsyncTask detector only matches direct derivation, missing transitive subclasses (e.g. Aapt2Compile/Aapt2Link).

Verified / positive callouts

  • Lock regeneration is correct and minimal: only frontmatter_hash + the three dropdown option lines changed; body_hash is correctly unchanged (the workflow body selects scripts dynamically via find/$INPUT_SCRIPT, so no script names are hardcoded).
  • 02 null-forgiving regex is genuinely high-precision: [A-Za-z0-9_)\]]!(\.|\[|;|,|\)) — a postfix ! in those positions is syntactically always null-forgiving (prefix ! is excluded by the leading char class, and != is excluded because = isn't in the follow set). Residual false positives are only inside strings/comments, which the "What NOT to flag" section already calls out.
  • 07 grep alternation is ordered safely: the trailing \b prevents LogError from shadowing LogErrorFromException.
  • | shuf | head -20 || echo "None found" matches the unchanged sibling scripts (00, 04, 08); I empirically confirmed it does not spuriously emit "None found" under the harness's bash -o pipefail at normal scale (shuf's output fits the pipe buffer, so it exits 0).

CI

At review time the Azure DevOps dotnet-android builds (Linux/Mac/Windows) and the agent check are still in progress (not failing); license/cla passed. This is a workflow-script-only change, so product builds are unaffected — please confirm CI is green before merge.

Neither finding is merge-blocking, so submitting as a COMMENT review rather than requesting changes. Nice, well-documented cleanup. 👍

Generated by Android PR Reviewer for issue #11739 · 819.4 AIC · ⌖ 48.3 AIC · ⊞ 37.9K
Comment /review to run again

Comment thread .github/workflows/nightly-fix-finder/07-asynctask-log-property.sh Outdated
Comment thread .github/workflows/nightly-fix-finder/07-asynctask-log-property.sh
07-asynctask-log-property:

- Fix the LogErrorFromException replacement cell. `LogErrorFromException`
  is NOT a thread-safe helper on AsyncTask -- it only exists on the
  `Log` (TaskLoggingHelper) property, so a bare `LogErrorFromException`
  call would not compile (CS0103). Verified every existing call site
  in src/ uses `Log.LogErrorFromException(...)`. Replace the bare-call
  suggestion with "fold the exception detail into the LogCodedError
  call, or `throw;` to propagate".

- Document that the AsyncTask-derivation regex matches DIRECT derivation
  only. Subclasses that reach AsyncTask through an intermediate base
  (e.g. `Aapt2Compile : Aapt2 : AsyncTask`) will not appear in the
  enumerated list. That is acceptable for a one-fix-per-night sampler,
  but the agent must still verify transitive derivation when reading
  the candidate file.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival merged commit 4d873b2 into main Jun 26, 2026
46 checks passed
@simonrozsival
simonrozsival deleted the jonathanpeppers-symmetrical-doodle branch June 26, 2026 09:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-review This PR is ready to review/merge, I think any CI failures are just flaky (ignorable).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants