Causal Memory Layer — SDK for recording, auditing, and analyzing causal chains in systems
Project description
Causal Memory Layer (CML)
Why CML?
Logs show what happened. CML checks why it was allowed.
A workflow can pass every functional test and still be causally invalid: the action succeeded, but the approval, intent, or responsibility lineage is missing, ambiguous, or broken.
ordinary log: action completed -> OK
CML audit: parent_cause=approval-42 -> MISSING_PARENT
CML is an open-source causal audit layer for structured action traces, AI-agent workflows, high-trust automation, and reviewable safety infrastructure.
A system may be functionally correct while being causally invalid.
Star this repo if you care about auditable AI agents, deterministic oversight, causal traces, and open-source AI safety infrastructure.
30-second demo
Run the local API:
docker compose up --build
Then follow the Docker walkthrough:
docs/demo/DOCKER_CAUSAL_MEMORY_WALKTHROUGH.md
Expected example finding:
CML-AUDIT-R1-MISSING_PARENT
The action may look operationally valid, but CML asks whether its causal parent exists.
Use CML when you need to audit
- AI-agent tool calls and action chains.
- Human approval handoffs.
- Automation workflows with high-trust actions.
- Fintech or review-heavy decision paths.
- Structured traces where responsibility lineage matters.
- Research benchmarks for causal validity in agentic systems.
Agent-audit MCP integration
CML can also run as an experimental MCP tool server for AI-agent audit workflows.
pip install -e ".[mcp]"
cml-mcp
See docs/integrations/MCP_AGENT_AUDIT.md for local MCP client setup and available tools.
For a short coding-assistant setup path, see docs/integrations/CURSOR_MCP_QUICKSTART.md.
How CML differs
| System type | Usually answers | CML adds |
|---|---|---|
| Logs | What happened? | Was the action causally permitted? |
| Tracing | Where did execution go? | Did responsibility lineage survive the workflow? |
| Observability | What failed operationally? | What succeeded but had broken causal lineage? |
| Policy checks | Is this allowed now? | Why was this specific action allowed in this trace? |
| CML | Why was this action allowed? | Narrow audit primitive, not a full runtime safety stack. |
Fast validation
pip install -e ".[dev]"
pytest
python scripts/run_safety_eval.py
Dashboard:
https://safal207.github.io/Causal-Memory-Layer/
Review links
- Start here:
docs/START_HERE.md - Reviewer path:
docs/REVIEWER_PATH.md - Research map:
docs/research/CML_RESEARCH_MAP.md - Non-claims:
docs/NON_CLAIMS.md - Portfolio relationship:
docs/PORTFOLIO_RELATIONSHIP.md - Benchmark evidence:
docs/evidence/BENCHMARK_EVIDENCE_SNAPSHOT.md - External validation protocol:
docs/evidence/EXTERNAL_VALIDATION_PROTOCOL.md - Technical report outline:
docs/research/TECHNICAL_REPORT_OUTLINE.md - Funding / research evidence:
docs/GRANT_EVIDENCE.md - Docker walkthrough:
docs/demo/DOCKER_CAUSAL_MEMORY_WALKTHROUGH.md - MCP agent-audit integration:
docs/integrations/MCP_AGENT_AUDIT.md - Cursor MCP quickstart:
docs/integrations/CURSOR_MCP_QUICKSTART.md - Cause Band concept:
docs/research/CAUSE_BAND.md - Cause Band trajectory walkthrough:
docs/demo/CAUSE_BAND_TRAJECTORY_WALKTHROUGH.md - Agent intent drift example:
docs/demo/AGENT_INTENT_DRIFT_CAUSE_BAND_EXAMPLE.md - Dormant Causal Patterns:
docs/research/DORMANT_CAUSAL_PATTERNS.md - Temporal Causal Watchpoints:
docs/research/TEMPORAL_CAUSAL_WATCHPOINTS.md - Experimental Cause Band audit flag:
docs/experimental/CAUSE_BAND_AUDIT_FLAG.md - Quantum causal audit future direction:
docs/research/QUANTUM_CAUSAL_AUDIT_FUTURE_DIRECTION.md - Causal invalidity patterns:
docs/research/CAUSAL_INVALIDITY_PATTERNS.md - Audit findings glossary:
docs/audit/FINDINGS_GLOSSARY.md - LTP / CML bridge:
docs/LTP_CML_BRIDGE.md - Roadmap:
ROADMAP.md - Security:
SECURITY.md - License:
LICENSE
Current artifact
This repository already contains a working technical artifact, not only a concept.
Current components include:
- Python causal validation and audit engine;
- causal chain reconstruction utilities;
- CLI commands for lineage validation and chain inspection;
- API layer and store interface;
- example logs and audit outputs;
- tests for chain logic, audit rules, and CTAG behavior;
- API smoke tests for health, audit, and CTAG decode;
- deterministic safety-eval benchmark with fixtures and tracked results;
- documentation for vCML semantics and audit rules.
Key implementation entry points:
cml/audit.pycml/chain.pycli/main.pyapi/server.pytests/test_audit.pytests/test_api_smoke.py
Problem
Many systems record events, outputs, traces, and metrics, but do not validate the causal structure behind authorization and action.
That creates blind spots such as:
- actions that appear valid but have no grounded parent cause;
- ambiguous or malformed root authority;
- actions that succeed operationally while losing approval lineage;
- state transitions that cannot be tied back to intent, permission, and responsibility.
For agentic systems, this matters because output review alone can miss causally invalid action chains.
What CML does
CML checks whether a high-trust action or state transition was causally valid, not only whether it occurred.
It focuses on:
- validating causal links between actions and prior authorization;
- preserving responsibility lineage across multi-step workflows;
- checking intent and permission continuity across transitions;
- detecting suspicious or invalid lineage such as missing parents, malformed roots, or broken handoffs;
- validating causal coherence from structured logs and traces.
Evidence snapshot
- Deterministic benchmark fixtures with expected audit findings:
benchmarks/fixtures/ - Current tracked benchmark result:
6/6 matched - Benchmark runner:
python scripts/run_safety_eval.py - Tracked report:
benchmarks/RESULTS.md - Reviewer-friendly benchmark interpretation:
docs/evidence/BENCHMARK_EVIDENCE_SNAPSHOT.md - Larger-grant expansion path:
docs/evidence/BENCHMARK_EXPANSION_PLAN_50K_100K.md - External validation protocol:
docs/evidence/EXTERNAL_VALIDATION_PROTOCOL.md
External reproducibility evidence
External validation notes will be listed here as they are contributed.
Current external validation tasks:
Validation note template:
docs/evidence/external_validation/TEMPLATE_MCP_DEMO_RUNNER.md
This section is intentionally evidence-first: it should only list external notes after they are contributed. It does not claim production safety, compliance readiness, enforcement behavior, or stable Cause Band semantics.
Repository map
cml/: core Python implementationcli/: command-line toolingapi/: API and store layervcml/: vCML semantics, format, audit, and boundary docsexamples/: sample logs and reportsbenchmarks/: deterministic benchmark fixtures and resultstests/: regression coveragedocs/: supporting docs for review, research, and deployment
Scope
CML does not claim to solve all AI safety, security, or compliance problems.
It contributes one focused primitive:
causal-validity checking for structured action traces
See docs/NON_CLAIMS.md for the full scope boundary.
Research direction
The strongest research direction for CML is causal validity checking for agentic oversight.
A useful framing is:
How can we detect actions that appear valid at the surface level but are causally invalid because authorization, approval, or responsibility lineage is missing, ambiguous, or broken?
Bottom line
A system may be functionally correct while being causally invalid.
CML exists to make that distinction inspectable.
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 causal_memory_layer-0.4.0.tar.gz.
File metadata
- Download URL: causal_memory_layer-0.4.0.tar.gz
- Upload date:
- Size: 54.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7acea1a01c3a0c1369ccc2f01528805a6e417b43ac48038066758cd95b8db457
|
|
| MD5 |
d879e232d3f6e44ec7159454d0c760e3
|
|
| BLAKE2b-256 |
1b30e9c465beb5b121fcebedc59abbc9d6011973ebab10a9825d98734e4ba73d
|
Provenance
The following attestation bundles were made for causal_memory_layer-0.4.0.tar.gz:
Publisher:
publish-python-package.yml on safal207/Causal-Memory-Layer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
causal_memory_layer-0.4.0.tar.gz -
Subject digest:
7acea1a01c3a0c1369ccc2f01528805a6e417b43ac48038066758cd95b8db457 - Sigstore transparency entry: 1750519227
- Sigstore integration time:
-
Permalink:
safal207/Causal-Memory-Layer@7699cfc608c2e50086334d4005b3d3d049a37393 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/safal207
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-package.yml@7699cfc608c2e50086334d4005b3d3d049a37393 -
Trigger Event:
release
-
Statement type:
File details
Details for the file causal_memory_layer-0.4.0-py3-none-any.whl.
File metadata
- Download URL: causal_memory_layer-0.4.0-py3-none-any.whl
- Upload date:
- Size: 42.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60b1a5a5923531b95fb6a9b7bff83ad00ac120bf9e62222064188ebb0eb0dfea
|
|
| MD5 |
e4c7c1b517848fa5d7f17d7110fd62e5
|
|
| BLAKE2b-256 |
d447957caecd3c4e23c88d7c3f1e0e96a0458f774fd1dd32e80c96ce7c0a968a
|
Provenance
The following attestation bundles were made for causal_memory_layer-0.4.0-py3-none-any.whl:
Publisher:
publish-python-package.yml on safal207/Causal-Memory-Layer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
causal_memory_layer-0.4.0-py3-none-any.whl -
Subject digest:
60b1a5a5923531b95fb6a9b7bff83ad00ac120bf9e62222064188ebb0eb0dfea - Sigstore transparency entry: 1750519246
- Sigstore integration time:
-
Permalink:
safal207/Causal-Memory-Layer@7699cfc608c2e50086334d4005b3d3d049a37393 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/safal207
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-package.yml@7699cfc608c2e50086334d4005b3d3d049a37393 -
Trigger Event:
release
-
Statement type: