ReceiptDB by Counterfoil Labs
Self-hosted on your PostgreSQL · Community, free and source-available

Every AI answer, with a receipt.

The receipt says which documents the answer used and who was allowed to see them, for every chunk, vector and answer, kept in your own PostgreSQL. Withdraw a source, restrict access, or erase a person, and every copy follows.

For platform, data and compliance teams running RAG and agents.

pip install "receiptdb[live]==1.0.0rc1" See it retract a source

PostgreSQL 16 or 17 with pgvectorNothing hosted by usAny model, and search without one

$ receipt ingest ./handbook --trust verified --license internal
./handbook: 38 added, 0 changed, 0 unchanged; 412 new chunks
$ receipt ask "What does the travel policy say about economy upgrades?"
Upgrades to premium economy are allowed on flights over six hours when the fare difference is under 30% of the economy fare. Business class needs a director's approval.
Sources:
file:///home/dana/handbook/travel-policy.md (passage 7c1e2d3a41b0)
Grounding (lexical@1): every sentence is supported by the sources
Answer receipt: 5d9b0a95ffe5 (receipt explain 5d9b0a95ffe5)
$ receipt explain 5d9b0a95ffe5
answer 5d9b0a95ff (cli:ask:claude-opus-5-5@a1) trust=verified license=internal [ai] "Upgrades to premium economy are allowed on flights over six…"
└─ chunk 7c1e2d3a41 (ingest:paragraphs@1) trust=verified license=internal "## Flights Economy is the default for all flights. Upgrad…"
└─ source a50f25c7f0 (source) trust=verified license=internal "file:///home/dana/handbook/travel-policy.md"
# Nothing is trusted by assumption: each file is labelled unknown-provenance until you vouch for its origin with one logged receipt relabel, done here.

See it work

Withdraw a source. Every copy follows.

ReceiptDB links every chunk, vector and answer to what it was derived from, so a withdrawal reaches every copy, and labels such as a source's readers flow down to everything built from it.

The Globex MSA is amended. One call handles everything built from it, in a single transaction, and names the people whose answers it invalidates. Preview it, then run it →

$ receipt impact contracts://globex/msa-2025
impact (nothing changed yet)
chunk 41 retract
embedding 41 remove from index
answer 17 flag · 6 askers
source 1 retract
summary 1 retract

A preview first: nothing has changed yet.

The graph as text: the source msa-2025 has one part, p.11 v3, cut into three chunks, §14.2, §14.3 and §15.1. Each chunk has an embedding, and a summary is built from §14.3 and §15.1. Answer 5d9b0a, asked by dana@acme.com, used §14.2 and §14.3; answer a81f0c, asked by priya@acme.com, used the summary and §15.1. Every record inherits the source's readers, group:legal.

source msa-2025 active

Readers
group:legal, its own
Derived from
nothing: it is a source
Built from it
8 records, 2 answers

Hover, tap or tab to a record to trace its lineage. Labels flow down: everything below the source inherits group:legal.

Runs on the PostgreSQL you already have

  • PostgreSQL 16 · 17
  • pgvector
  • Amazon RDS
  • Google Cloud SQL
  • Azure Database
  • Docker
  • Kubernetes

How it works

One lineage graph under your RAG pipeline.

Every record is identified by its content and linked to what it was derived from and the versioned transform that produced it. Labels flow down that graph and fail closed: a derived record is never more trusted, or less restricted, than its riskiest input.

Source you label it

Ingest

A file, a page, a row. Re-running ingest is safe: unchanged sources are no-ops, a changed one supersedes its old version.

trust=verifiedlicense=internalreaders=group:hrsubjects=person:…
Chunks · embeddings inherited

Derive

Chunks, vectors, summaries and agent memories, each with a receipt naming its inputs and the transform, such as ingest:paragraphs@1.

trust=verifiedlicense=internalreaders=group:hr
Query policies enforced

Search and ask

Vector, keyword or hybrid. Who is asking, which licence, how much trust, where the content may be sent: all applied inside the query, so a withheld passage is never ranked.

--as user:dana@acme.com--min-trust medium--commercial
Answer a record too

Receipt

The answer records every passage the model was shown, the model, who asked, and whether each sentence is supported. It inherits the strictest labels of its sources.

readers=group:hr[ai]grounding: supported

Because the graph is kept, the operations that matter later reach every copy: retract a source, erase a person, revoke a group, swap the embedding model. Each applies in a single transaction, and a retraction or an erasure can be previewed first. Trace a graph and run a retract above ↑

Install

Three steps to your first receipt.

About ten minutes. You need Python 3.12 or later and Docker. The Docker line matches ReceiptDB's default connection string, so there is nothing to configure.

1

Install the package

python3 -m venv .venv && . .venv/bin/activatepip install "receiptdb[live,server,client,pdf,office]==1.0.0rc1"receipt --version

live adds the local embedding model and the Anthropic SDK; pdf and office add PDF, Word and PowerPoint. For the Python library alone, pip install receiptdb==1.0.0rc1 is enough.

2

Start PostgreSQL

docker run -d --name receiptdb-postgres --shm-size=1g -p 127.0.0.1:54329:5432 -e POSTGRES_USER=receipt -e POSTGRES_PASSWORD=receipt -e POSTGRES_DB=receipt pgvector/pgvector:pg17

Your own database works too: set RECEIPTDB_DSN. Any PostgreSQL 16 or 17 with the pgvector extension, managed or self-run.

3

Ingest, then ask

receipt ingest ./my-docs --trust verified --license internal# ask answers with Claude by default; RECEIPTDB_MODEL=ollama:… needs no key; search needs noneexport ANTHROPIC_API_KEY=…receipt ask "What does our travel policy say about upgrades?"

ask prints the answer, the sources it used and the answer's receipt. receipt explain <id> shows the full lineage, as in the terminal at the top of the page.

Supported files: Word, PowerPoint, PDF (the text layer), Markdown, text, reStructuredText, CSV, JSON, HTML, XML and YAML. For services in other languages, or a shared deployment, deploy/quickstart runs the HTTP API with its database under Docker Compose. The full getting-started guide →

What the receipt guarantees

Every guarantee reaches every copy.

One document becomes chunks, vectors, memories, summaries and answers. Because ReceiptDB records where each one came from, access, withdrawal, erasure and audit reach all of them.

Access that follows the data

Every derived record inherits access from every input, so a summary or an answer is never readable by someone who couldn't read its sources. Revoke a group's access to a source and it's revoked on everything built from it.

receipt ingest … --readers group:legal

Withdraw a source everywhere

One call retracts a source and everything built from it, in a single transaction, and names the people whose answers it invalidates. ReceiptDB blocks new derivations from retracted data and refuses to re-ingest a retracted source.

receipt impact <uri> · receipt retract <uri> --reason …

Erasure you can verify

Tag sources with the people they're about. Erase a person across chunks, vectors, memories and answers; only unreadable fingerprints stay. A certificate lists what went, and a separate command checks the database against it.

receipt erase --subject person:… · receipt verify-erasure

Versioned re-ingestion

Re-index on every run. A changed source, or with page-level versioning just the changed page, supersedes its previous version and everything derived from it, answers already given included. Only text that changed is re-embedded.

receipt ingest ./docs --prune · receipt follow-up

Grounding on every answer

By default, each answer the API or the CLI records says in its receipt whether its claims are supported by the passages it cites: a score, the unsupported sentences, and the checker, offline word overlap or a model of your choice. Export one receipt per answer as JSON Lines. Check any receipt later: one command re-hashes it against the database, down to every source.

receipt audit --since 2026-01-01

Suspect content, quarantined

Scanners hold flagged sources and everything derived from them out of retrieval until someone reviews them. Built-in heuristics, built-in personal-data detection or Microsoft Presidio, Meta's Prompt Guard 2 run locally, Lakera Guard, or your own classifier over HTTP.

RECEIPTDB_SCAN=pii,heuristics,prompt-guard

Why not a vector database

A metadata filter guards one chunk. Lineage guards everything built from it.

A filter is attached to the chunk it guards; nothing carries it to what was built from that chunk. ReceiptDB stores the vectors too, and serves search with your policies enforced.

WhenWith a metadata filterWith ReceiptDB
A legal-only contract is summarisedThe summary is readable by anyone the filter missesThe summary is readable only by those who may read every source
A document is withdrawnIts chunks and answers keep serving until someone rebuilds the indexOne call retracts everything built from it and lists the answers it affected
A person asks to be erasedSomeone hunts for every copy by handErased from every chunk, vector, memory and answer, with a certificate
"Which sources did this answer use?"Nothing records itEvery answer has a receipt

Compliance

The evidence your auditors ask for, built from the records.

Requests from OneTrust or Transcend are answered with an erasure certificate, and stay open while a legal hold keeps records. In Enterprise, report templates for the EU AI Act and FINRA are built from the same receipts. Your privacy team starts ahead, with a DPIA template that sets out what ReceiptDB stores and where its data flows, and article-by-article mappings for GDPR and the EU AI Act, each naming the tests that show it; ask for them.

EU AI Act · Art. 12

Record-keeping for AI systems

Each answer is stored with its inputs, model, asker and time, and period reports are built from those records.

GDPR · Art. 17

Right to erasure

Erase a person from every chunk, vector, memory and answer derived from their data, with a certificate of what was removed.

FINRA · Regulatory Notice 24-09

Supervising AI output

An audit export per answer: what it said, who asked, and every source it relied on.

EU AI Act record-keeping report (Art. 12)

System: Credit-operations assistant (sample) · Provider/deployer: Acme Bank (fictional)
Period: 2026-01-01T00:00:00+00:00 to 2026-04-01T00:00:00+00:00 · Generated: 2026-10-12T20:21:36.182127+00:00

1. Outputs recorded

  • 7 answers were recorded with full provenance (inputs, sources, model, asker, time).
  • 4 of them are no longer valid, because a source was retracted, superseded or erased since.
  • 1 relied on low-trust content, 0 on non-commercial or restricted content, and 1 involved personal data.

2. Input data: in the full sample, not this excerpt

3. Outputs invalidated in the period

Outputs whose inputs were later retracted, superseded, erased or quarantined.

WhenAsked byQuestionStatusReason
2026-03-02T09:05:00a.dubois@bank.exampleWhat's the current personal loan rate?quarantinedquarantine: rates changed on 1 March: out of date
2026-03-04T08:30:00l.fischer@bank.exampleWhat's the maximum debt-to-income for a personal loan?supersededthe March 2026 lending policy
2026-03-04T08:30:00s.romano@bank.exampleCan we go above 40% DTI for a strong applicant?supersededthe March 2026 lending policy
2026-03-18T17:45:00erasedGDPR Art. 17 request #418

The last row is an answer built on a loan applicant's data, erased under their GDPR request: its question and asker went with it, and the record that an answer existed stays.

An excerpt of a sample report ReceiptDB Enterprise wrote for a fictional bank's credit-operations assistant over a quarter: unedited, its event log verified. Read the full EU AI Act sample →   FINRA →

ReceiptDB gives you the evidence; how you use it determines compliance.

Use it from

A small change to the app you already have.

ReceiptDB is a vector store to LangChain and LlamaIndex, a memory store to LangGraph, a tool server to any MCP client, and an HTTP API with Python and TypeScript clients for everything else.

LangChain

Four changed lines move a RAG app from the in-memory store. Loaders already set metadata["source"], which ties each chunk to its source.

-from langchain_core.vectorstores import InMemoryVectorStore+from receiptdb.integrations.langchain import ReceiptVectorStore -store = InMemoryVectorStore(embeddings)+store = ReceiptVectorStore(embeddings, source_labels=source_labels())      answer = next(b.text for b in response.content if b.type == "text")+    store.record_answer(question, answer, docs, transform=f"agent:{response.model}@p1", asked_by=user)     return answer

MCP: Claude, Cursor, any agent

The API serves an MCP server at /mcp. The agent's identity is fixed by the operator, never chosen by the model, and destructive tools are off by default.

# Claude Codeclaude mcp add --transport http receiptdb http://127.0.0.1:8321/mcp --header "Authorization: Bearer <your key>" # Cursor: .cursor/mcp.json{"mcpServers": {"receiptdb": {"url": "http://127.0.0.1:8321/mcp", "headers": {"Authorization": "Bearer <your key>"}}}} # tools: search · explain · record_answer · impact_of_retracting

HTTP API

One command starts the API with its database. The reference is served at /docs; ReceiptClient (Python) and @receiptdb/client (TypeScript) wrap it.

cd deploy/quickstart./setup.sh            # writes .env with a random API keydocker compose up -d --waitcurl -s http://127.0.0.1:8321/health # Pythonfrom receiptdb.client import ReceiptClientdb = ReceiptClient("http://127.0.0.1:8321", api_key=KEY)db.search(vector, model="my-model@1",   # your embedder's vector for the question          policy={"principals": ["user:dana@acme.com"]})

LlamaIndex plugs in through a StorageContext in six lines; LangGraph's ReceiptStore replaces InMemoryStore in two. Haystack and Semantic Kernel stores ship too. Every integration, with the diff →

Architecture

In your process or your cluster. Never in ours.

A library in your process, or a stateless API, in front of the PostgreSQL you already back up, monitor and secure. Nothing leaves your network unless you point it at a hosted model, and content labelled for local use never goes to one.

Your machine, or your cloud
Your AI applications and agentsLangChain, LlamaIndex, LangGraph, Haystack, Semantic Kernel, MCP clients, or the HTTP, Python and TypeScript APIs
Your contentFolders of Word, PowerPoint, PDF, Markdown and more, ingested with the labels you give them; or a collection imported from Pinecone, Weaviate, Qdrant, Chroma, Elasticsearch or OpenSearch
Your modelsAnthropic, any OpenAI-compatible endpoint, Ollama, AWS Bedrock; or no model at all, for search alone
ReceiptDB
The receipt CLI and Python library, or the stateless APIDocker Compose from deploy/quickstart, or Kubernetes with the Helm chart; scale by adding replicas
Lineage, labels and policyEvery search access-checked inside the query; retraction and erasure in one transaction, with a dry run first
Your PostgreSQL 16 or 17 with pgvectorSelf-managed, Amazon RDS, Cloud SQL or Azure Database; records, vectors and the lineage graph in ordinary tables, under your backups
Content scanningBuilt-in heuristics and personal-data detection; Meta's Prompt Guard 2 run locally, Lakera Guard, Microsoft Presidio, or your own classifier over HTTP
Your observabilityLangfuse and Arize Phoenix for answer spans; OpenTelemetry traces and Prometheus metrics from the API
Your privacy requestsOneTrust and Transcend erasure requests answered with a certificate; signed webhooks on every lifecycle change

Single sign-on, the connectors that sync permissions from Google Drive, SharePoint, Slack, Confluence and cloud buckets, crypto-shredding with keys in your KMS and the tamper-evident audit log are Enterprise; they sit on the same database.

Run by your platform team. Works behind PgBouncer, serves again within about a second of the database coming back after a failover, and applies every lifecycle operation whole or not at all, with rate limits and zero-downtime key rotation.

Performance

Search at index speed, with every access check.

Every figure includes the access check, and how much a caller may read barely moves it.

3.3ms

median search on real embeddings, with trust and licence policies enforced

99%

recall at one million chunks, policies enforced

13,000/s

searches per second through the API on one 32-vCPU server, each one access-checked

How we measured

3.3 ms: the median search over 18,891 SQuAD passages with real bge-small embeddings (384 dimensions), k = 10 through the HNSW index, trust and licence filters on every search, on tuned PostgreSQL on its own 8-vCPU server with the search on another.

99%: recall@10 on a synthetic million-chunk corpus, trust and licence filters on every search, on tuned PostgreSQL on its own 32-vCPU server with the search on another, with the 16-bit vectors stored today and the HNSW settings ReceiptDB picks at that size (m = 24, ef_construction = 256, ef_search = 400).

About 13,000/s: tuned PostgreSQL on its own 32-vCPU server, the API on a second 32-vCPU server and the load generator on a third, with the server's default worker pinning and search settings: 100,000 chunks, k = 10 through the HNSW index, trust and licence filters on every search, 8 concurrent clients per process. The medians: 13,605 searches/s with the Community edition alone and 13,233 with Enterprise installed (32 processes each).

On a million-chunk corpus on two 8-vCPU servers, a caller who can read half of it and one who can read a hundredth of a percent both search in 4 to 40 ms. Lineage and labels add 1 to 9 ms per search.

Works with

Fits the stack you already run.

Database

  • PostgreSQL 16 · 17
  • pgvector
  • Amazon RDS
  • Google Cloud SQL
  • Azure Database for PostgreSQL

Models

  • Anthropic
  • OpenAI-compatible endpoints
  • Ollama and local models
  • AWS Bedrock
  • Search with no model at all

Frameworks and agents

  • LangChain
  • LlamaIndex
  • LangGraph
  • Haystack
  • Semantic Kernel
  • Model Context Protocol

Import from

  • Pinecone
  • Weaviate
  • Qdrant
  • Chroma
  • Elasticsearch
  • OpenSearch
  • plain pgvector

Content scanning

  • Llama Prompt Guard 2
  • Lakera Guard
  • Microsoft Presidio
  • Your own, over HTTP

Observability

  • Langfuse
  • Arize Phoenix
  • OpenTelemetry
  • Prometheus metrics

Privacy requests

  • OneTrust
  • Transcend
  • Signed webhooks

Deployment

  • Docker Compose
  • Kubernetes
  • Helm

Editions

Start with the core. Add what your auditors ask for.

ReceiptDB Community

For teams building RAG and agents

  • Receipts, label inheritance and cascading retraction
  • Permission-aware vector and hybrid search, with policies enforced
  • Erasure across every derived record, legal holds and quarantine
  • Personal-data detection, grounding checks and data-egress labels
  • Answer audit export, re-answering and signed webhooks
  • Any model; LangChain, LlamaIndex, LangGraph, Haystack, Semantic Kernel and MCP; importers from Pinecone, Weaviate, Qdrant, Chroma, Elasticsearch and OpenSearch
  • Functional Source License: use, modify and redistribute it for any purpose but a Competing Use; each release becomes Apache-2.0 two years after it ships
Install it
For regulated teams

ReceiptDB Enterprise

For regulated and multi-team deployments

  • SSO (OIDC) and SCIM identity sync from Okta or Entra ID, with groups from SpiceDB or OpenFGA if you run one
  • Connectors that sync content and permissions from Google Drive, SharePoint, Slack, Confluence, and S3, Google Cloud Storage or Azure Blob buckets; a revoked share in Drive or SharePoint applies about a minute after the source reports it, with an optional live check at the source
  • Crypto-shredding of text and vectors, with keys in AWS KMS, Google Cloud KMS or Azure Key Vault and a separate key store for backups
  • Signed erasure certificates and a tamper-evident audit log with anchors
  • EU AI Act and FINRA report templates, provenance explorer
  • Multi-tenancy: a directory, webhooks and audit export per tenant, tenants you can disable or remove, scoped API keys, usage metering and quotas
  • A licence that never holds data hostage: after expiry, a grace period, then only new Enterprise value stops
Request a demo

FAQ

Questions people ask first.

Does it replace our vector database?

It can. ReceiptDB stores vectors in PostgreSQL with pgvector and serves search itself, with your policies enforced. It plugs into LangChain and LlamaIndex as a vector store, so adopting it is a small code change rather than a migration project. One command imports a collection from Pinecone, Weaviate, Qdrant, Chroma, Elasticsearch, OpenSearch or plain pgvector, labelled as unknown provenance until you say otherwise.

Do we need to run a new database?

No. ReceiptDB runs on PostgreSQL 16 or 17 with the pgvector extension, self-managed or managed. The lineage graph and the event log are ordinary tables, so your existing backups, monitoring and access controls apply.

Which models can we use?

Any. Answers and grounding checks run on Anthropic, any OpenAI-compatible endpoint including local models, or AWS Bedrock. Search works with no model key at all. Content labelled for local use never goes to a hosted model.

What is the licence?

The Community edition is under the Functional Source License (FSL-1.1-ALv2). Use, modify and redistribute it for any purpose but a Competing Use: offering it to others in a commercial product or service that substitutes for it or does substantially the same. Each release becomes Apache-2.0 two years after it ships. Enterprise is a separate commercial licence from Counterfoil Labs.

What does Community not include?

Single sign-on and SCIM, the connectors that sync content and permissions from Google Drive, SharePoint, Slack, Confluence and cloud buckets, crypto-shredding, signed certificates and the anchored audit log, the explorer and multi-tenancy. Those are Enterprise. Everything the receipt itself does, retraction, permission-aware search and erasure included, is in Community.