Skip to main content

Context infrastructure for AI applications

Project description

Fabra

Fabra records what your AI saw — so you can replay and debug it.

Fabra creates a replayable Context Record for every AI call: what data was used,
where it came from, what got dropped, and why.

PyPI version License Python Version


The Problem

ML Engineers: Feast needs Kubernetes and Spark. You have a 4-person team and a deadline.

AI Engineers: Legal asked what data your AI used for a decision last Tuesday. You had no answer.

Both problems have the same root cause: you don't own your data pipeline.


30 Seconds to Proof

pip install fabra-ai && fabra demo

That's it. Server starts, makes a test request, shows you the result. No Docker. No config files. No API keys.

What you'll see
  Fabra Demo Server

  Testing feature retrieval...
  curl localhost:8000/features/user_engagement?entity_id=user_123

  Response:
  {
    "value": 87.5,
    "freshness_ms": 0,
    "served_from": "online"
  }

  Press Ctrl+C to stop, or visit http://localhost:8000/docs

Two Entry Points, One Infrastructure

For ML Engineers

"I need features in production, not a platform team."

from fabra import FeatureStore, entity, feature
from datetime import timedelta

store = FeatureStore()

@entity(store)
class User:
    user_id: str

@feature(entity=User, refresh=timedelta(hours=1))
def purchase_count(user_id: str) -> int:
    return db.query(
        "SELECT COUNT(*) FROM purchases WHERE user_id = ?",
        user_id
    )
fabra serve features.py
curl localhost:8000/features/purchase_count?entity_id=u123
# {"value": 47, "freshness_ms": 0, "served_from": "online"}

Python decorators. Not YAML.

For AI Engineers

"Compliance asked what the AI knew. I need an answer."

from fabra import FeatureStore
from fabra.context import context, ContextItem

store = FeatureStore()

@context(store, max_tokens=4000, freshness_sla="5m")
async def build_prompt(user_id: str, query: str):
    tier = await store.get_feature("user_tier", user_id)
    docs = await search_docs(query)
    return [
        ContextItem(content=f"User tier: {tier}", priority=1),
        ContextItem(content=docs, priority=2),
    ]

ctx = await build_prompt("user_123", "question")
print(ctx.id)       # ctx_018f3a2b-... (stable Context Record ID)
print(ctx.lineage)  # exact data used, full provenance

Full audit trail. Not a black box.


Core Concept: Context Record

A Context Record is an immutable snapshot of everything an AI knew at a specific moment in time:

  • Structured features with freshness timestamps
  • Retrieved documents with content hashes
  • Token budget decisions (what was included vs dropped)
  • Full lineage metadata (sources, versions, latencies)
  • Cryptographic integrity (tamper-evident hashes)

Every Context Record has a stable ID (ctx_...) and can be replayed, diffed, or audited at any time:

# Replay any historical context
fabra context show ctx_018f3a2b-7def-7abc-8901-234567890abc

# Verify cryptographic integrity
fabra context verify ctx_018f3a2b-7def-7abc-8901-234567890abc

# Compare what changed between two decisions
fabra context diff ctx_abc123 ctx_def456

Why It Works

1. You Own Your Data

LangChain queries your vector DB. Fabra is your vector DB. We ingest, index, track freshness, and serve. When someone asks "what did the AI know?", we have the answer because we never lost sight of the data.

# Replay any historical context
fabra context show ctx_018f3a2b-7def-7abc-8901-234567890abc

# Compare what changed between two decisions
fabra context diff ctx_abc123 ctx_def456

2. Same Code Everywhere

Development uses DuckDB (zero setup). Production uses Postgres + Redis (just add env vars). Your feature definitions don't change.

# Development (right now, on your laptop)
fabra serve features.py

# Production (same code, different backends)
FABRA_ENV=production \
FABRA_POSTGRES_URL=postgresql://... \
FABRA_REDIS_URL=redis://... \
fabra serve features.py

3. Point-in-Time Correctness

Training ML models? We use ASOF JOIN to ensure your training data reflects exactly what the model would have seen at prediction time. No data leakage. No training-serving skew.

4. Token Budgets That Work

No more prompt length errors in production. Set a budget, assign priorities, and low-priority items get dropped automatically.

@context(store, max_tokens=4000)
async def build_prompt(user_id: str, query: str):
    return [
        ContextItem(content=system_prompt, priority=0, required=True),
        ContextItem(content=user_history, priority=1),  # dropped first if over budget
        ContextItem(content=docs, priority=2),
    ]

What's Real

This isn't a framework that wraps other tools. This is infrastructure:

Capability What It Does
Feature Store @feature decorators, online/offline stores, point-in-time joins
Context Store @context decorators, token budgeting, lineage tracking
Vector Search Built-in pgvector, automatic chunking, freshness tracking
Context Replay fabra context show <id> returns exact historical state
Context Diff fabra context diff <id1> <id2> shows what changed
Freshness SLAs freshness_sla="5m" fails if data is stale
Diagnostics fabra doctor validates your setup

CLI

fabra serve features.py      # Start the server
fabra demo                   # Interactive demo (no setup)
fabra doctor                 # Diagnose configuration issues
fabra context show <id>      # Replay historical context
fabra context diff <a> <b>   # Compare two contexts
fabra context list           # List recent contexts
fabra context export <id>    # Export for audit
fabra deploy fly|railway     # Generate deployment config
fabra ui features.py         # Launch the dashboard (requires Node.js)

Note: fabra ui requires Node.js. Run npm install in src/fabra/ui-next/ if dependencies aren't installed.


How Fabra Fits in Your Stack

Fabra is not a replacement for:

Tool Purpose Relationship to Fabra
Airflow / Dagster Batch workflow orchestration Use for pipelines that feed Fabra
MLflow / W&B Model training & experiment tracking Use for training; Fabra handles inference-time context
LangChain / LlamaIndex LLM orchestration & chains Use for orchestration; Fabra provides the data layer

Fabra replaces or complements:

Tool Fabra Advantage
Feast Simpler setup, built-in context assembly
Custom feature serving Production-ready out of the box
Ad-hoc RAG pipelines Lineage, freshness SLAs, token budgets

See full comparison guide for detailed breakdowns vs Feast, Tecton, LangChain, and Pinecone.


Honest Comparison

vs Feast

Feast Fabra
Setup Kubernetes + Spark pip install
Config YAML files Python decorators
Local dev Docker required Works immediately
Context/RAG Not supported Built-in

Choose Feast if: You have a platform team and existing K8s infrastructure.

vs LangChain

LangChain Fabra
Architecture Orchestration framework Storage + serving infrastructure
Data ownership Queries external stores Owns the write path
Audit trail None Full lineage + replay
Token management DIY Built-in budgets

Choose LangChain if: You need agent chains and don't need compliance.

Note: You can use Fabra + LangChain together — Fabra for storage/serving, LangChain for orchestration.


Production Checklist

  • Observability: Prometheus metrics at /metrics, structured logging
  • Reliability: Circuit breakers, fallback chains, health checks
  • Security: Self-hosted, your data stays in your infrastructure
  • Deployment: One-command deploy to Fly.io, Railway, Cloud Run, Render

Quick Start (Detailed)

Feature Store

pip install fabra-ai
fabra serve examples/demo_features.py

Test it:

curl localhost:8000/features/user_engagement?entity_id=user_123

Response:

{"value": 87.5, "freshness_ms": 0, "served_from": "online"}

Context Store

pip install fabra-ai
fabra serve examples/demo_context.py

Test it:

curl -X POST localhost:8000/v1/context/chat_context \
  -H "Content-Type: application/json" \
  -d '{"user_id":"user_123","query":"how do features work?"}'

Response:

{
  "id": "ctx_018f3a2b-...",
  "content": "You are a helpful AI assistant...",
  "meta": {
    "freshness_status": "guaranteed",
    "token_usage": 150
  },
  "lineage": {
    "features_used": ["user_tier", "user_engagement_score"],
    "retrievers_used": ["demo_docs"]
  }
}

Replay it later:

fabra context show ctx_018f3a2b-...

What Fabra Does Not Do

  • Agent orchestration - Use LangChain
  • Workflow scheduling - Use Airflow/Dagster
  • High-QPS streaming inference - Use Tecton
  • No-code builders - This is Python infrastructure

Fabra focuses on one thing: making inference context provable.


Try in Browser · Quickstart · Docs


Fabra · Apache 2.0 · 2025

Once context is a ledger, everything else follows.

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

fabra_ai-2.1.0.tar.gz (814.4 kB view details)

Uploaded Source

Built Distribution

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

fabra_ai-2.1.0-py3-none-any.whl (202.1 kB view details)

Uploaded Python 3

File details

Details for the file fabra_ai-2.1.0.tar.gz.

File metadata

  • Download URL: fabra_ai-2.1.0.tar.gz
  • Upload date:
  • Size: 814.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fabra_ai-2.1.0.tar.gz
Algorithm Hash digest
SHA256 7c6d0f4de2e83a1b15c8f1c8d46329389e9f4e3e8097785ca8227aecfe13ec74
MD5 adc5c5bbdeb3cd3618350a87e1a36a5f
BLAKE2b-256 023b5c18e9118de5b603c25b7411f1336c4d26ef8bd0f8d4a61742cce2c918c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fabra_ai-2.1.0.tar.gz:

Publisher: release.yml on davidahmann/fabra

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

File details

Details for the file fabra_ai-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: fabra_ai-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 202.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fabra_ai-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d8bd5515e81e6a3ad691540710ccf7c87538dea6bbbe01dac4fc897df1a129e
MD5 f7011f354a728785310d1a7bf96f1540
BLAKE2b-256 1dfc90f584a2ab674c4d0842fdfd1b266f57de44effb8f313e1fd2b2647136ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for fabra_ai-2.1.0-py3-none-any.whl:

Publisher: release.yml on davidahmann/fabra

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