The Autonomous Stack

Dev & Release · Testing & Evals · v1.0.2

Agent Flaky Tests v1.0

Proves which CI tests are actually flaky, clusters them by root cause, and runs a quarantine list that releases itself.

$3.00one-timePay with crypto

flaky-tests ci-triage test-quarantine junit byo-llm

agent ⟶ theautonomousstack.xyz

01GET /api/v1/pack/agent-flaky-tests-v1

402 Payment RequiredX-PAYMENT-REQUIRED

02sign TransferWithAuthorization3.00 USDC · Base (eip155:8453)

03GET + PAYMENT-SIGNATURE

200 OKapplication/zip · 24 files

pay per pack over x402no account

What's inside

Stop re-running CI and hoping. This agent watches your JUnit reports run after run, proves which tests are actually non-deterministic, groups them by shared root cause, and keeps a quarantine list that releases itself once a test is stable again.

The honest promise

What it does

What it does not do

Who it is for

Quick start (60 seconds)

bash install.sh --no-service          # venv only; add sudo + drop the flag for systemd
venv/bin/python agent.py demo         # bundled 6-run history -> full report

demo materializes six real JUnit reports (from samples/sample_runs.json) into a temp directory and ingests them through the normal path. They cover every verdict the classifier can emit — flaky, broken, regressed, stable, retry-recovered, insufficient data — so you see the output shape before wiring your own CI. Add --dest ./samples-out to keep the generated XML and inspect it.

Then point it at your own reports:

export FLAKY_REPORTS_DIR=/var/ci/junit
venv/bin/python agent.py ingest --path "$FLAKY_REPORTS_DIR" --commit "$GIT_SHA" --branch main
venv/bin/python agent.py report --format md --out FLAKY_REPORT.md
venv/bin/python agent.py quarantine --sync --dry-run     # see the policy's decision
venv/bin/python agent.py quarantine --sync               # apply it
venv/bin/python agent.py quarantine --export pytest --out quarantine.args
pytest $(cat quarantine.args)                            # green pipeline, debt tracked

How it works

        CI job                         agent.py                      you
   ┌──────────────┐              ┌──────────────────┐         ┌──────────────┐
   │ pytest/jest  │  junit.xml   │  WATCHING        │         │              │
   │  --junitxml ─┼─────────────▶│    │ new file?   │         │              │
   └──────────────┘              │    ▼             │         │              │
                                 │  INGESTING       │         │              │
                                 │    │ parse+store │         │              │
   ┌──────────────┐              │    ▼             │         │              │
   │  SQLite      │◀────────────▶│  CORRELATING     │         │              │
   │  history     │  runs/results│    │ same commit?│         │              │
   │  (local)     │              │    │ flips? retry│         │              │
   └──────────────┘              │    ▼             │         │              │
                                 │  verdict: flaky  │         │              │
                                 │  broken │ regressed│       │              │
                                 │    │             │         │              │
                                 │    ├─▶ QUARANTINING ──────▶│ quarantine.args
                                 │    ├─▶ RELEASING  ────────▶│ (auto, 10 clean)
                                 │    └─▶ REPORTING  ────────▶│ FLAKY_REPORT.md
                                 └──────────────────┘         └──────────────┘
                                          │
                                   optional BYO-LLM
                                   (root-cause hypothesis)

The same-commit contradiction is the core signal: if commit a1b2c3d produced both a pass and a fail for the same test, the code is not the variable — the test is. Status flips and retry recoveries are the secondary signals, used when your CI does not report a commit SHA.

Commands

Command What it does
demo Ingest the bundled sample history and print a full report
ingest --path P [--commit SHA] [--branch B] Read a file, directory or glob of JUnit XML (idempotent)
analyze [--window N] [--json] Per-test verdict over the last N runs
quarantine [--sync] [--dry-run] Apply the policy: add proven flakes, release proven-stable tests
quarantine --export FORMAT [--out F] txt, pytest, pytest-marker, jest, json
quarantine --add/--remove TEST_ID Manual override, recorded in the audit trail
report [--format md\|json] [--out F] Human digest or machine payload
explain --test TEST_ID Root-cause hypothesis (LLM if connected, heuristics otherwise)
run [--once] [--deterministic] OODA loop: watch the reports dir, triage, quarantine, report
status Database counters + detected LLM backend

Bring your own LLM (optional)

If a coding-agent CLI is installed and logged in, explain upgrades from a keyword heuristic to a reasoned hypothesis using the Executor Prompt in PROMPTS.md. No API key is stored or required — your existing subscription is the billing relationship:

PACK_LLM=claude venv/bin/python agent.py explain --test "tests/test_checkout.py::test_checkout_completes"

Supported: Claude Code (claude), Kimi Code (kimi-code), Codex CLI (codex). None installed? Every command above still works — the reply just carries "mode": "deterministic".

Install as a service

sudo bash install.sh          # venv + systemd unit, watches FLAKY_REPORTS_DIR
systemctl status agent-flaky-tests-v1
journalctl -u agent-flaky-tests-v1 -f

Files

File Role
agent.py The agent: parsing, correlation, verdicts, quarantine, reporting, OODA loop
llm_adapter.py BYO-LLM CLI adapter (claude/kimi/codex), no API key
PROMPTS.md The 5 named prompts, loaded at runtime
SPEC.md Verdict rules, schema, every configurable parameter
CHECKLIST.md 26-step rollout, from first ingest to a defended flake budget
CUSTOMIZE.md Where to plug your own reports, formats and policy
SOUL.md Mission, values, OODA states, invariants
OPERATING_COST_ESTIMATE.md What it costs to run (provider-agnostic)
samples/sample_runs.json Six-run sample history, materialized into real JUnit XML by demo
templates/ Policy and CI-hook templates to copy into your repo
scripts/ Config template and helper scripts

Licence & support

Sold as-is for your own infrastructure. You own the database, the reports and the quarantine list — everything is a local file you can inspect, diff and revert.