Flaky Test Isolation and Deterministic CI Repair Chain Plan
Develop a specialized multi-agent diagnostic workflow to detect non-deterministic test failures, isolate race conditions, and verify deterministic fixes.
Use this template when building an autonomous workflow to eliminate flaky tests in large software suites. It guides quality and software architects in creating chained agent systems that run stress permutations, capture state leaks, and synthesize synchronization fixes.
Role: Staff Quality Engineering Architect specializing in distributed test harness automation and deterministic debugging workflows.
Context
- Target Test Engine: {{test_runner_framework}}
- Non-Deterministic Test Targets: {{flaky_test_corpus}}
- Application Threading Model: {{concurrency_model}}
- Stress Environment Provider: {{ephemeral_infra_provider}}
- Quarantine Trigger Criteria: {{flakiness_threshold_rate}}
- Trace & Dump Storage: {{artifact_storage_backend}}
Task
Design an autonomous workflow chain that continuously identifies, isolates, root-causes, and fixes non-deterministic test cases across the codebase, ensuring high CI reliability.
Method
- Ingest CI failure logs to identify tests exceeding {{flakiness_threshold_rate}} within {{flaky_test_corpus}}.
- Dispatch a quarantine agent to temporarily tag failing tests without disabling test coverage visibility.
- Provision dedicated stress-test containers on {{ephemeral_infra_provider}} running under high resource contention.
- Execute N-iteration permutation loops using {{test_runner_framework}} with randomized execution orders and mock delays.
- Capture memory snapshots, race condition traces, and thread states directly to {{artifact_storage_backend}}.
- Task a diagnostic agent with analyzing captured traces to distinguish between shared mutable state, network timeouts, and {{concurrency_model}} deadlocks.
- Deploy a code repair agent to adjust async synchronization, eliminate shared global state, or inject proper mock boundaries.
- Run a validation pass consisting of 100 consecutive green runs on {{ephemeral_infra_provider}} to confirm determinism before opening a fix PR.
Constraints
- MUST NOT resolve flakiness by simply increasing arbitrary timeout constants or sleep intervals.
- MUST validate all candidate patches against 100 consecutive runs without a single intermittent failure.
- Diagnostic trace files stored in {{artifact_storage_backend}} must redact all sensitive credentials and PII.
- Test quarantining must never completely drop test cases without creating an associated tracking issue.
Output format
Provide a technical workflow plan structured as follows:
- Workflow State Diagram (detailing ingest, quarantine, reproduction, fix, and verification phases)
- Agent Task & Prompt Specifications (defining exact logic for reproduction, trace parsing, and refactoring)
- Stress Harness Execution Strategy (parameter matrices for {{concurrency_model}} and {{test_runner_framework}})
- Verification & Graduation Criteria (rules for lifting quarantine and merging fixes) Limit response length to 1,500 words.
Self-review
- Verify that the plan incorporates {{flakiness_threshold_rate}} as the objective quarantine trigger.
- Ensure the verification step specifically mandates consecutive deterministic iterations.
- Confirm that the repair agent specifically addresses {{concurrency_model}} issues rather than superficial timeouts.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.