Skip to content

[copilot] Add flaky-test investigation skill - #13783

Closed
simonrozsival wants to merge 1 commit into
mainfrom
dev/simonrozsival/flaky-tests-skill-2026-11-25
Closed

simonrozsival wants to merge 1 commit into
mainfrom
dev/simonrozsival/flaky-tests-skill-2026-11-25

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

The session review found about 12 recurring flaky-test investigation and remediation pitfalls, plus evidence from CI-triage sessions: agents sometimes reran before preserving logs, treated a passing retry as proof the failure was resolved, conflated test/product/infrastructure failures, or weakened assertions and increased timeouts without showing the test's regression value. These habits erase the evidence needed to distinguish a flaky test from a real product bug and can make CI appear healthier without restoring reliable coverage.

The new on-demand flaky-tests skill gives agents a compact workflow: search existing issues and fixes, confirm against a current build, save evidence before retrying, retry only the failed job, classify and count attempts accurately, preserve the behavior the test protects, and use the repository's existing per-test ignore convention when disabling is justified. It explicitly treats incomplete evidence as unknown and asks before creating or commenting on issues.

This complements rather than duplicates #13728: that PR addresses avoiding flaky tests while authoring and reviewing new tests; this skill handles triage and remediation after an intermittent failure occurs. It loads only for those tasks, avoiding more always-on guidance.

Validation: git diff --cached --check passed. No build or tests were run because this change adds agent documentation only.

Session review found recurring evidence loss, retry misclassification, and fixes that weakened the test oracle. Add on-demand guidance for diagnosis, classification, retries, and justified test disabling.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival changed the title [docs] Add flaky-test investigation skill [copilot] Add flaky-test investigation skill Nov 25, 2026
simonrozsival added a commit that referenced this pull request Nov 26, 2026
Move the always-loaded test-reliability list behind a one-line pointer
to testing-rules.md, and add the flaky-tests skill from #13783.

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

Copy link
Copy Markdown
Member Author

Folded into #13728, which now covers both preventing and investigating flaky tests.

simonrozsival added a commit that referenced this pull request Nov 26, 2026
Context: #13430
Context: #13780

A review found missing `external/android-api-docs` initialization in 22 local agent sessions. Fresh worktree builds fail late when `Mono.Android.xml` cannot be produced, even though the Unix and Windows build guides say preparation updates submodules. The `Prepare` target did not actually run that step.

Run `git submodule update --init -- external/android-api-docs` from the repository root before the bootstrap builds. Both `make prepare` and solution preparation on Windows use this target. Git checks out the pinned submodule revision rather than following its upstream branch; when already at that revision, no checkout is needed. Initialization or checkout errors stop preparation instead of surfacing much later. Update the build guides to name the submodule explicitly.

### Relationship to other changes

#13780 already merged agent-facing manual initialization guidance. This change addresses the build itself and contains no `.github/` edits, so it does not overlap the open `[copilot]` PRs (#13766, #13778, #13782, #13783, #13784, #13785).

#13430 replaces preparation entry points but retains the `Prepare` target and does not initialize this submodule. Its `Prepare.proj` hunk was checked to apply on top of this change. It also rewrites both guide paragraphs edited here; if this merges first, keep #13430's replacement guide wording when resolving those documentation conflicts.
simonrozsival added a commit that referenced this pull request Nov 27, 2026
Context: #13783 (folded into this PR)

CI investigations have exposed recurring sources of test flakiness: timing-based assertions, uncontrolled global state, output and log reuse, shared test directories, and environmental dependencies. Agents both introduce these patterns when writing tests and spend a lot of effort investigating existing flakes inefficiently, so this PR covers both sides in one place.

### Prevention

The code-review skill's `testing-rules.md` gains a flake-prevention checklist, so reviewers flag these patterns before they reach CI. It also calls out crosstalk from process-wide runtime state (JNI global references, GC and finalizer activity, thread-pool state) and recommends asserting behavior of test-owned objects rather than exact global counter deltas.

The always-loaded `copilot-instructions.md` gets only a one-sentence summary pointing to that checklist and to the new skill, rather than a full list, to keep the file that is loaded in every session short.

### Investigation

A new `flaky-tests` skill covers investigating, fixing, disabling, and counting flaky tests. It is based on a review of local agent sessions, where flaky-test work repeatedly went wrong in the same ways:

  * Starting from stale inventories instead of confirming the test still fails, or duplicating an existing issue or fix.
  * Rerunning or cleaning up before saving logs, which destroyed the evidence.
  * Counting only final job results, so failures that passed on retry were missed, and labeling unrecognized failures as flaky without evidence.
  * "Fixing" flakes by loosening assertions, inflating timeouts, or changing the code path under test.
  * Using inconsistent `[Ignore]` formats, or filing issues without asking.

The skill's description routes per-PR CI failure classification to `ci-status`, so the two skills don't compete.
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.

1 participant