Skip to main content

Deterministic AI reliability analysis for RAG and agent traces

Project description

FailureLab

CI Python License: MIT

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.json
  • findings.json
  • report.md
  • regression_tests.yaml
  • run_manifest.json
  • invalid_traces.jsonl (skip-invalid mode)
  • comparison.json, comparison.md, gate_result.json (compare)

Configuration precedence

FailureLab resolves configuration deterministically in this order:

  1. built-in defaults
  2. config file values (--config)
  3. 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, or failed.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

failurelab-0.1.0.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

failurelab-0.1.0-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

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

Hashes for failurelab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8f0c69109a05d7136f2320410312ac3a9919430cb2feaabfe0cba8e4b661def
MD5 cb6f960ff6ab65e29aa3484e6287b371
BLAKE2b-256 64982682ff05f9ae80345d3db70b58a83c65c67c6c2c6ea8bbcd8156bd8b0512

See more details on using hashes here.

Provenance

The following attestation bundles were made for failurelab-0.1.0.tar.gz:

Publisher: release.yml on yellepeddibk/failurelab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for failurelab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8717f82c5cc3d2c4d63ca82d93083a900fedd824e4c769c32e933fc6a6dd3ba5
MD5 de220ca8c1c9ddb22c92119f05d69a5b
BLAKE2b-256 c46e1a7670c4a581c49c2a36731eff8a9579c8677dd80d28f08a7acc914fc957

See more details on using hashes here.

Provenance

The following attestation bundles were made for failurelab-0.1.0-py3-none-any.whl:

Publisher: release.yml on yellepeddibk/failurelab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page