Flakes cluster by cause — async/wait races alone account for roughly 45% of them — and each cause leaves a recognizable signature in the failure evidence. AI drafts the classification from logs and stack traces in minutes; targeted reruns then confirm or refute it, so fixes target causes instead of symptoms.
Tier: Core · Workflow area: Triage, flakes & defect intelligence
This playbook takes a set of intermittently failing tests, classifies each by failure signature with an assistant, verifies the classification with a designed rerun experiment, and routes each class to its standard fix — with retries-as-medication explicitly banned.
Assemble evidence per suspect — multiple failures, not one. A single failure is an anecdote; three failing runs plus one passing run per test is a dataset. Pull the JUnit XML and logs for each.
Ask for classification against the standard taxonomy. Constrain the model to the categories and demand evidence quotes:
Here are 4 runs (3 fail, 1 pass) of "order-history pagination" — JUnit XML,
stack traces, and test source attached.
Classify the flake into exactly one primary category:
ASYNC/WAIT (races, missing waits, animation timing)
DATA (shared state, leftover records, order-dependent data)
ENVIRONMENT (ports, containers, clock, resources, third-party deps)
ORDER (passes alone, fails after specific tests)
CONCURRENCY (parallel workers colliding)
For your classification: quote the exact log/trace lines that support it,
state confidence (high/med/low), name the most likely alternative, and
propose ONE rerun experiment that would distinguish the two.
Sample output worth expecting:
CLASSIFICATION: DATA (confidence: medium)
EVIDENCE: fail runs show "expected 10 rows, found 12" with ids 4491, 4492
not present in seed set; pass run shows exactly seeded ids.
ALTERNATIVE: ORDER — extra rows may be written by a test earlier in the shard.
EXPERIMENT: run this test alone 10x on a fresh DB (expect: 10/10 pass),
then run after checkout.spec 10x (fail rate returning = ORDER/DATA-pollution).
Run the discriminating experiment — this is the actual QA. The model proposed it; you execute it:
npx playwright test order-history --repeat-each=10 --workers=1 # isolation baseline
npx playwright test checkout order-history --repeat-each=10 # pollution probe
Record the numbers. A classification without a confirming rerun is a plausible story, and plausible stories are how flakes survive for years.
Apply the standard fix for the confirmed class. Route by diagnosis, not by creativity:
expect(...).toPass, web-first assertions); await the response, not the spinner.The assistant can draft the patch; review it like any AI test edit — the review-clinic rubric applies.
Prove the fix statistically, then release from quarantine. The exit bar is numeric:
npx playwright test order-history --repeat-each=25 --workers=4
# 25/25 green, parallel, shuffled -> release from quarantine
Log the diagnosis. Test, class, evidence, experiment result, fix, proof run — one row per flake. This log is what turns next quarter's flake wave into pattern-matching instead of re-derivation, and it is the input the clustering playbook uses to spot systemic causes.
The model reads logs faster than you; it does not get to skip the experiment. Classification is a hypothesis, the discriminating rerun is the test of it, and only the confirmed class earns a fix. Retry-until-green is not on the fix list — it is the disease wearing a lab coat.
pytest-repeat, -p no:randomly vs shuffled) and watch for order flakes hidden by fixed execution order.CI logs routinely leak internal hostnames, tokens in URLs, and customer identifiers in test data — scrub before pasting into any external assistant (the PII-masking playbook's pipeline applies to logs, not just datasets). On client engagements, run classification through approved tools or a local model (flake-signature classification works acceptably on strong local models since the taxonomy constrains the answer), and keep the flake log itself in the client's tracker if their audit rules require it.
Track "time from first flake to confirmed class" as your triage KPI. When it drops from days to under an hour, you have converted flake triage from archaeology into a checklist — and that is precisely the judgment-plus-automation shape that the rest of this track keeps rewarding.