-
Notifications
You must be signed in to change notification settings - Fork 0
AI RCA Architecture
Automated root-cause analysis turns a raw failure into "here's the likely cause and what to do". The design principle: cheap classification first, LLM only when it adds value, always off the write-path, always budget-gated.
Running an LLM on every failing log.
That is slow, expensive, non-deterministic, and mostly redundant — the same failure recurs thousands of times. Flakemetry spends LLM tokens only on genuinely new failure signatures.
failure
→ normalize stack/error
strip line numbers, hex addresses, timestamps, absolute paths, UUIDs
→ normalized_hash + embedding (pgvector)
→ nearest-neighbor match
if within threshold → attach to existing cluster (occurrence_count++)
else → new cluster
Normalization collapses superficially-different failures ("the same bug") into one cluster. This is fast, deterministic, and free.
If the failure maps to an existing cluster:
- Label instantly: "known issue #N" / "known flake".
- Reuse the cluster's cached RCA — zero LLM cost.
- The PR bot de-noises the build: "this failure is a known flake, tracked in #N."
Two identical failures cost one LLM call, not two.
Only new clusters reach the model. The prompt is assembled from high-signal context:
context = normalized error + stack template
+ failing git diff summary (files changed in this run)
+ trace summary (from OTel spans: which step/network call failed)
+ top-K similar past failures (retrieval over clustered history) [M3]
Output is structured (validated against a zod schema before persistence):
{
"likely_cause": "…",
"confidence": 0.0,
"suggested_action": "…",
"similar_past": [{ "signature_id": "…", "resolution": "…" }]
}The result is cached on cluster_id, so the whole cluster benefits from one analysis.
- Per-project daily token budget; when exceeded, RCA is queued/skipped, never blocking.
-
token_costrecorded on everyrca_reportfor observability and (later) usage metering. - RCA runs entirely asynchronously — it never delays the ingestion
202or run processing.
LLMProvider decouples the pipeline from any vendor:
| Provider | Use case |
|---|---|
| Claude (default) | Hosted, highest-quality structured RCA |
| Ollama (local) | Self-host / privacy mode — no data leaves the network |
Swapping is config-only. Self-hosters with strict data policies run fully local.
Before any text is stored or sent to an LLM, a scrubbing pass removes secrets and PII (tokens, emails, connection strings, keys) from error messages and stack traces. Self-host + Ollama gives a fully air-gapped path for regulated environments.
- Dashboard thumbs-up/down on each RCA feeds a labelled eval set.
- Prompt templates are versioned; changes are measured against the eval set before rollout.
- Retrieval quality (are the "similar past" failures actually similar?) is tracked.
- M1 — basic RCA: normalization + fast path + single-shot structured LLM analysis, budget-gated.
- M3 — clustering at scale, retrieval-augmented RCA with historical context and calibrated confidence, known-issue linking, eval harness.
Related: Data Model (error_signature, rca_report) · Architecture (async processing) · Ingestion and Scaling.
Flakemetry Wiki
Product
Engineering
- Architecture
- Data Model
- Test Identity Engine
- Flaky Scoring
- AI RCA Architecture
- OTel Test Conventions
- Ingestion and Scaling
- Branching and Git Workflow
Reference