ContextBOM (CBOM) — a bill of materials for every prompt. Record where every piece of your AI model's context came from.
Project description
contextbom
A bill of materials for every prompt. Know exactly what went into your AI model — every source, every transformation, every redaction — as a signed, auditable manifest.
pip install contextbom
import contextbom as cbom
from openai import OpenAI
ctx = cbom.Context()
# Stamp provenance as you gather context
docs = ctx.add(retriever.search(query), source="qdrant://kb/policies", sensitivity="internal")
history = ctx.add(memory.recall(user_id), source="mem0://user/123", sensitivity="pii")
ticket = ctx.add(fetch_ticket(id), source="https://jira.co/T-42", transform=cbom.redact_pii)
# Call any model — the manifest is generated automatically
response = ctx.complete(OpenAI(), model="gpt-5", messages=build_prompt(docs, history, ticket))
print(ctx.manifest.to_json()) # full lineage of everything the model saw
Output — a CBOM manifest for that call:
{
"cbom_version": "0.1",
"call_id": "0198f3a2-...",
"model": "gpt-5",
"segments": [
{
"source": "qdrant://kb/policies",
"hash": "sha256:9f2c...",
"sensitivity": "internal",
"transforms": [],
"tokens": 812
},
{
"source": "https://jira.co/T-42",
"hash": "sha256:41ab...",
"sensitivity": "internal",
"transforms": [{"type": "redact_pii", "removed": 3}],
"tokens": 240
}
],
"signature": "..."
}
Why
- Audit & compliance — EU AI Act Article 12 requires logging what high-risk AI systems processed. A CBOM manifest is that record.
- Security — see exactly which tool output entered the prompt when investigating an injection or leak. Prove secrets never left the boundary.
- Debugging — "why did the model say that?" starts with "what did the model see?"
- Trust — signed manifests make AI decisions explainable to auditors, customers, and courts.
What it is / isn't
| ✅ An open spec (JSON) + SDKs that stamp provenance onto context at assembly time | ❌ A gateway or proxy you must deploy |
| ✅ Works with any model, any framework | ❌ Another agent framework |
| ✅ Complements CycloneDX ML-BOM / SPDX (static artifacts) with runtime lineage | ❌ A replacement for SBOM standards |
| ✅ Exports over OpenTelemetry | ❌ A hosted service |
Features
cbom.Context— wrap context assembly; automatic manifest generation- Transforms — built-in, recordable
redact_pii,strip_secrets,summarize,truncate cbom view— CLI (installed with the package) that renders any prompt color-coded by source and sensitivity- Signing — optional Sigstore-style attestation of manifests
- Exporters — OTel, JSONL audit log, webhook
- Integrations — LangChain, LlamaIndex, MCP middleware (roadmap)
Spec
The manifest format is defined in SPEC.md. v0.1 is deliberately small: segments, sources, hashes, transforms, sensitivity labels, signatures. Extensions are namespaced.
Contributing
The spec is developed in the open — issues and RFCs welcome. Good first contributions: SDK ports (TypeScript, Go), framework integrations, transform plugins.
Apache-2.0.
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 contextbom-0.1.0.tar.gz.
File metadata
- Download URL: contextbom-0.1.0.tar.gz
- Upload date:
- Size: 130.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7d07d9fa9e9ab98ddc18641f7f975f17996e2b179e8a194aee2bb93e56c1e85
|
|
| MD5 |
4a690f8afcaa79593fab9d634200f526
|
|
| BLAKE2b-256 |
171ef252e5aebf4939c3491b4f492f81a980337928d334f494b7fcfcff1d5bef
|
File details
Details for the file contextbom-0.1.0-py3-none-any.whl.
File metadata
- Download URL: contextbom-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dea6a9835c32cb98617988e0922f541e5813c9e04662f2b8c98258ec8a432f1
|
|
| MD5 |
a218ff233d5af77f96dd826e8bf1ac9d
|
|
| BLAKE2b-256 |
30e12407d38ed7331f662916238c3383f02a9b7b2d6b6205050af3ef1a7eaf88
|