Deterministic AI reliability analysis for RAG and agent traces
Project description
FailureLab
FailureLab is a local-first AI reliability toolkit for deterministic analysis of RAG and agent traces. It finds concentrated failure slices, produces evidence-backed root-cause hypotheses, and drafts regression tests from production failures.
Why FailureLab
Averages can hide failure concentration by model, prompt, retriever, or tool sequence. FailureLab keeps deterministic metric logic in typed services and allows agent layers to consume those deterministic skills.
60-second quickstart
python -m pip install -e ".[dev]"
failurelab --version
failurelab validate examples/rag_traces.jsonl
failurelab analyze examples/rag_traces.jsonl --output reports --overwrite
failurelab compare examples/baseline_traces.jsonl examples/candidate_traces.jsonl --output reports --overwrite
Implemented capabilities
- Typed trace and agent-step contracts using Pydantic v2
- Incremental JSONL ingestion with strict and skip-invalid modes
- Deterministic metrics and categorical breakdowns
- Deterministic failure-slice discovery and root-cause heuristics
- Draft regression test generation in YAML
- Compare baseline/candidate runs with deterministic gate checks
- Typer CLI (
validate,analyze,compare) - JSON, Markdown, and YAML report outputs
- Deterministic skill interfaces and a routing investigation agent
Example trace schema (minimal)
{"schema_version":"0.1","trace_id":"rag-001","timestamp":"2026-07-10T10:00:00+00:00","success":true}
Output files
metrics.jsonfindings.jsonreport.mdregression_tests.yamlrun_manifest.jsoninvalid_traces.jsonl(skip-invalid mode)comparison.json,comparison.md,gate_result.json(compare)
Configuration precedence
FailureLab resolves configuration deterministically in this order:
- built-in defaults
- config file values (
--config) - explicit CLI overrides (for example
--skip-invalid,--retrieval-k)
run_manifest.json records the effective resolved configuration used for execution.
Metrics notes
Each metric includes value, numerator, denominator, eligibility counts, direction, and unavailable reason when needed. Metrics that require observations are reported as unavailable (null) when no eligible observations exist; they are not coerced to 0.
Analysis semantics
- Failure slices include only elevated failure segments (positive uplift over global failure rate).
- Root-cause hypotheses are generated only for explicitly failed traces.
- Draft regression cases are generated only from failed traces with concrete replayable input.
- Comparison outputs include full-dataset and matched-ID scopes, plus metric deltas.
- Gate status is tri-state:
not_configured,passed, orfailed.
Architecture
flowchart TD
A[JSONL traces] --> B[Ingestion + validation]
B --> C[Deterministic metrics]
B --> D[Slice discovery]
B --> E[Root-cause rules]
D --> F[Regression draft generation]
C --> G[Reports]
D --> G
E --> G
F --> G
C --> H[Typed skills]
D --> H
E --> H
Privacy and limitations
- Local-first, no network calls in core analysis.
- Raw query/context content is excluded from reports by default.
- No significance or causal certainty claims.
Development
ruff check .
ruff format --check .
mypy src
pytest
python -m build
Roadmap (not implemented)
Statistical inference, embedding clustering, calibrated judge models, active learning, external orchestrators, and optional API/storage/dashboard layers.
Contributing and license
See CONTRIBUTING.md and LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file failurelab-0.1.0.tar.gz.
File metadata
- Download URL: failurelab-0.1.0.tar.gz
- Upload date:
- Size: 47.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8f0c69109a05d7136f2320410312ac3a9919430cb2feaabfe0cba8e4b661def
|
|
| MD5 |
cb6f960ff6ab65e29aa3484e6287b371
|
|
| BLAKE2b-256 |
64982682ff05f9ae80345d3db70b58a83c65c67c6c2c6ea8bbcd8156bd8b0512
|
Provenance
The following attestation bundles were made for failurelab-0.1.0.tar.gz:
Publisher:
release.yml on yellepeddibk/failurelab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
failurelab-0.1.0.tar.gz -
Subject digest:
e8f0c69109a05d7136f2320410312ac3a9919430cb2feaabfe0cba8e4b661def - Sigstore transparency entry: 2158933528
- Sigstore integration time:
-
Permalink:
yellepeddibk/failurelab@717f864152b5e5210b49e02f0d9f3fa94f27aef4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yellepeddibk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@717f864152b5e5210b49e02f0d9f3fa94f27aef4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file failurelab-0.1.0-py3-none-any.whl.
File metadata
- Download URL: failurelab-0.1.0-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8717f82c5cc3d2c4d63ca82d93083a900fedd824e4c769c32e933fc6a6dd3ba5
|
|
| MD5 |
de220ca8c1c9ddb22c92119f05d69a5b
|
|
| BLAKE2b-256 |
c46e1a7670c4a581c49c2a36731eff8a9579c8677dd80d28f08a7acc914fc957
|
Provenance
The following attestation bundles were made for failurelab-0.1.0-py3-none-any.whl:
Publisher:
release.yml on yellepeddibk/failurelab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
failurelab-0.1.0-py3-none-any.whl -
Subject digest:
8717f82c5cc3d2c4d63ca82d93083a900fedd824e4c769c32e933fc6a6dd3ba5 - Sigstore transparency entry: 2158933621
- Sigstore integration time:
-
Permalink:
yellepeddibk/failurelab@717f864152b5e5210b49e02f0d9f3fa94f27aef4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/yellepeddibk
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@717f864152b5e5210b49e02f0d9f3fa94f27aef4 -
Trigger Event:
push
-
Statement type: