Metadata-Version: 2.5
Name: tabula-memory
Version: 0.1.0
Summary: Tabula: governed memory for AI agents. MCP server + CLI that never stores personal data in clear text and proves it forgot a person, including everything inferred from them.
Project-URL: Homepage, https://github.com/parthagni22/tabula
Project-URL: Repository, https://github.com/parthagni22/tabula
Project-URL: Issues, https://github.com/parthagni22/tabula/issues
Author: parthagni22
License-Expression: MIT
License-File: LICENSE
Keywords: agent-memory,agents,audit,compliance,crypto-shredding,dpdp,gdpr,india,llm,machine-unlearning,mcp,mcp-server,memory,model-context-protocol,pii,privacy,redaction,right-to-erasure
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security
Classifier: Topic :: Security :: Cryptography
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: cryptography>=42
Requires-Dist: gupt-mcp>=0.1
Requires-Dist: mcp<3,>=2.3
Provides-Extra: dev
Requires-Dist: hypothesis>=6.100; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Provides-Extra: ner
Requires-Dist: gupt-mcp[ner]>=0.1; extra == 'ner'
Description-Content-Type: text/markdown

<!-- mcp-name: io.github.parthagni22/tabula -->

# Tabula

**Governed memory for AI agents.** Tabula is an MCP server, CLI and Python library that gives an agent long-term memory without storing personal data in clear text. It can also prove that it forgot a person, including everything the agent inferred from them.

[![PyPI](https://img.shields.io/pypi/v/tabula-memory.svg)](https://pypi.org/project/tabula-memory/)
[![Python](https://img.shields.io/pypi/pyversions/tabula-memory.svg)](https://pypi.org/project/tabula-memory/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Tabula is the sibling of [Gupt](https://github.com/parthagni22/gupt-mcp). Gupt keeps personal data away from a model for one session. Tabula keeps it out of an agent's memory for as long as the agent exists, and uses Gupt as the gate that every memory passes through.

```text
remember("Call me on 98765 43210 or mail asha.rao@example.in. I was diagnosed with asthma.", user_id="asha")

stored  → Call me on <<IN_PHONE#3f9a…>> or mail <<EMAIL_ADDRESS#9c41…>>. I was diagnosed with asthma.
facts   → [contact] Call me on <<IN_PHONE#3f9a…>> or mail <<EMAIL_ADDRESS#9c41…>>.
          [health]  I was diagnosed with asthma.
vault   → the two original values, encrypted under Asha's own key

forget_preview(user_id="asha", identifiers=["asha.rao@example.in"])  → what will go, and a manifest_hash
forget(confirm=manifest_hash, …)  → keys destroyed, cascade erased, summaries re-derived, signed receipt
```

## Why Tabula

Agent memory keeps personal data in more places than an erasure request reaches: the stored message, the facts and summaries derived from it, the keyword index, the logs. Tabula is built around three failures.

| Problem | What Tabula does |
| --- | --- |
| Personal data is stored as typed | Gupt tokenizes every message before anything is extracted, indexed or stored. Tokens are deterministic (an HMAC of the normalized value), so one person gets one token in every message, without the value being stored anywhere readable. |
| Erasure follows the author, not the person | A subject index built from the tokens finds every memory that **mentions** someone, whoever wrote it. When user A's message names user B, forgetting B removes it. |
| Derived memories survive | Each fact or summary records everything its writer read as its parents (the sound parent rule). A memory's key is derived from its parents' keys and its subjects' keys, so destroying one person's key makes every descendant unreadable. Rows are then deleted and the files vacuumed, and summaries are re-derived from the turns that survive. |
| Readable metadata after erasure | The graph holds opaque ids and tokens, never names. The keyword index stores HMACs of words, never the words. `tabula scan` checks every readable field with Gupt's detectors. |
| Poisoned writes | Each write carries a source trust level. Instruction-like text from an agent, tool, document or web source goes to quarantine, never into recall. |
| Proof | Two-step forget (preview, then confirm with the manifest hash), Ed25519-signed receipts that an auditor checks with the public key alone, a hash-chained audit log, and a DPDP/GDPR evidence pack. |

Other open-source memory tools already do parts of this well. Attestari, Provem and vayl-mcp all have erasure with certificates or receipts. Tabula's additions are detecting personal data before storage, erasing by subject rather than by author, and cascading erasure to derived memories. `tabula-bench` will compare all of them on the same canary workload (planned for v0.2). Until it has run, treat those claims as design goals.

## Install

```bash
pip install tabula-memory          # or: uvx tabula-memory
```

Dependencies: `gupt-mcp`, the official MCP SDK (2.x) and `cryptography`. There are no network calls.

## Set up keys

```bash
tabula init        # prints a new 32-byte root key (base64)
```

Store the key in your secret manager and pass it as `TABULA_ROOT_KEY`. Keep it away from the data directory. Without it Tabula runs in **dev mode** and creates `<data_dir>/root.key`, which is fine on a laptop but not in production. If the root key is lost, every memory becomes unreadable.

The receipt-signing key (Ed25519) is generated on first run and stored in `signing.key`, wrapped under the root key. To have a DPO or security team hold the key instead, give its PEM as `TABULA_SIGNING_KEY`. The public key is written to `<data_dir>/signing.pub.pem`.

## Connect it to your AI client

**Claude Code**

```bash
claude mcp add tabula -e TABULA_ROOT_KEY="$TABULA_ROOT_KEY" -- uvx tabula-memory
```

**Claude Desktop, Cursor and other JSON configs**

```json
{
  "mcpServers": {
    "tabula": {
      "command": "uvx",
      "args": ["tabula-memory"],
      "env": { "TABULA_ROOT_KEY": "…", "TABULA_DATA_DIR": "/path/to/tabula-data" }
    }
  }
}
```

**HTTP.** `tabula serve --http` serves streamable HTTP on 127.0.0.1:8766. It refuses to start unless `TABULA_HTTP_TOKEN` is set (at least 16 characters), and every request must send `Authorization: Bearer <token>`. Put TLS in front of it if it leaves the machine.

## MCP tools

| Tool | What it does | Safeguard |
| --- | --- | --- |
| `remember` | Tokenizes with Gupt, stores the message, extracts facts, writes small-window summaries, records purpose and expiry | Returns entity types and counts, never values |
| `recall` | Keyword search; returns tokens with provenance | Skips expired, quarantined and erased memories at read time |
| `restore` | Puts original values back in place of tokens | **Off** unless `TABULA_ALLOW_RESTORE=1` |
| `explain` | Source, parents, children, writer, trust, purpose and expiry of a memory | Contains no content |
| `correct` | Replaces a message, erases what was derived from it and derives it again | Logged with a request id |
| `forget_preview` | Everything `forget` would erase, descendants included, and a `manifest_hash` | Read-only |
| `forget` | Destroys the person's keys, erases the cascade, re-derives, signs a receipt | **Off** unless `TABULA_ALLOW_FORGET=1`; needs the preview's hash and refuses if the data has changed since the preview |
| `verify_audit` | Checks the hash chain and every receipt | Read-only |
| `evidence` | Writes the evidence pack | Contains no personal data |
| `status` | Policy packs, key mode, switches, counts | Read-only |

## CLI

```bash
tabula serve [--http]                                   # MCP server (stdio by default)
tabula status
tabula forget --user asha --identifier asha.rao@example.in             # preview
tabula forget --user asha --identifier asha.rao@example.in --confirm <manifest_hash>
tabula verify --user asha --identifier asha.rao@example.in             # exit 1 if anything is left
tabula purge                                            # erase memories past their retention
tabula scan [DATA_DIR]                                  # leak scan for CI / pre-commit, exit 1 on findings
tabula evidence ./pack && tabula verify-pack ./pack --public-key signing.pub.pem
tabula bench                                            # tabula-bench canary scenarios
```

The CLI `forget` is the operator path: the person running it is the human approval step, so it works even when the MCP tool is switched off. It still needs the preview's hash.

## Library

```python
from tabula import Tabula, load_config

t = Tabula(load_config(allow_forget=True))
t.remember("My email is meera@example.com and I like masala chai.", user_id="meera", purpose="support")
t.recall("masala chai")["results"][0]["content"]
# 'My email is <<EMAIL_ADDRESS#…>> and I like masala chai.'

preview = t.forget_preview(user_id="meera", identifiers=["meera@example.com"])
receipt = t.forget(confirm=preview["manifest_hash"], user_id="meera", identifiers=["meera@example.com"])["receipt"]
t.verify_erasure(user_id="meera", identifiers=["meera@example.com"])["ok"]   # True
```

## tabula-bench

`tabula bench` runs five canary scenarios, each on a fresh store. It plants known values and then searches for them in every layer an attacker with the files and the current keys could read: the graph (readable columns plus everything that still decrypts), the keyword index, the vault, the audit log and its JSONL mirror, the receipts, and the raw bytes of every file.

```text
PASS  no_plaintext_at_rest         Phone, Aadhaar and email never appear in graph, index, logs or files
PASS  erasure_follows_subject      A names B; forgetting B removes it
PASS  derived_memories_cascade     A secret inside a summary is unrecoverable after forget
PASS  no_readable_metadata         After erasure, no readable field matches a detector
PASS  injection_quarantined        Instructions in a document land in quarantine, not recall
```

## Configuration

Settings are read from environment variables, or from a JSON or TOML file named by `TABULA_CONFIG`; environment variables override the file.

| Variable | Default | Meaning |
| --- | --- | --- |
| `TABULA_ROOT_KEY` | (dev key file) | Base64 32-byte root key |
| `TABULA_DATA_DIR` | `~/.tabula` | Holds `memory.db` (the graph) and `vault.db` (keys and originals) |
| `TABULA_POLICY` | `dpdp,gdpr,secrets` | Gupt policy packs used by the gate |
| `TABULA_ENGINE` | `pattern` | `pattern`, `ner` or `auto` (needs `tabula-memory[ner]`) |
| `TABULA_DENY_LIST` / `TABULA_ALLOW_LIST` | | Extra terms to always or never tokenize, comma-separated |
| `TABULA_SUMMARY_WINDOW` | `4` | Turns per summary; small windows keep the forgetting radius small |
| `TABULA_ALLOW_RESTORE` / `TABULA_ALLOW_FORGET` | off | Enable the two tools that reveal or destroy data |
| `TABULA_PURPOSES` | any | Allowed purposes, comma-separated |
| `TABULA_DEFAULT_PURPOSE` | `general` | Purpose recorded when none is given |
| `TABULA_RETENTION_DAYS` | `0` (keep) | Default retention; `purpose_retention` in the config file sets it per purpose |
| `TABULA_QUARANTINE_SOURCES` | `agent,tool,document,web` | Sources whose instruction-like writes are quarantined |
| `TABULA_AUDIT_FILE` | | Optional JSONL mirror of the audit chain |
| `TABULA_SIGNING_KEY` | | Path to an operator-held Ed25519 PEM |
| `TABULA_HTTP_TOKEN` | | Bearer token, required for `--http` |

## Limits

- **Detection.** Anything Gupt does not recognise is stored encrypted, but not tokenized, so erasure by subject cannot find it. Bare names in free text need the NER extra or a deny-list.
- **Backups.** A backup taken before an erasure still holds the destroyed keys. Keep `vault.db` on a short-retention backup policy, or rotate the root key.
- **Graph shape.** Which memory was derived from which is stored in clear, though only as opaque ids.
- **Not a compliance certificate.** DPDP and GDPR compliance depends on the whole system. `MAPPING.md` in the evidence pack is engineering documentation, not legal advice.

How it works: [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md). Reporting security issues: [SECURITY.md](SECURITY.md).

## License

MIT © parthagni22
