Persistent memory for AI agents with sleep-style consolidation (NOCTURNE) and a verifiable eternal layer on Arweave + Solana
pip install padam-nocturne==0.4.5 Copy PIP instructions
PADAM is a local-first, persistent memory for AI assistants and agents. It lives in one SQLite file on your machine, plugs into any MCP client (Claude Code, Claude Desktop, Cursor, VS Code) or into your own code through a CLI and a small REST API.
NOCTURNE is its consolidation cycle — a "sleep" that turns a raw stream of episodes into lasting memory: it keeps what matters, generalises what repeats and lets the rest fade, without letting rare dramatic events take the memory over.
L3 is the optional eternal layer. It anchors memory to Arweave (encrypted bundles) and Solana (a Merkle root in a Memo), so anyone can check that the memory was never rewritten — while any single record can still be forgotten for good.
Part of CODE Eternal · Project page: aifa.works/nocturne · Specification: English · Русский · Русская версия README: README.ru.md
Agent memory today mostly accumulates. After a month it holds thousands of records; old decisions argue with new ones, and the agent answers from things that were abandoned long ago. A fact that was wrong but keeps being retrieved looks as fresh as the day it was written. And when a user asks to be forgotten, the usual answer is either "we can't — it's in the log" or "we deleted everything".
NOCTURNE does the night work a brain does: keep what matters, generalise what repeats, let the rest fade — and keep an honest history of every change. L3 adds what a private database cannot: proof, checkable by anyone, that the history was not rewritten afterwards.
flowchart TB A[Agent / MCP client / CLI / REST] -->|write · search · confirm · refute| P[(PADAM
SQLite)] A -->|log episodes| B[Episode buffer] B -->|python -m padam sleep| N[NOCTURNE
consolidation] N -->|keep · merge · fade · version| P P -->|python -m padam l3| E[Per-record AES-256-GCM
encryption] E -->|ciphertext bundle| AR[(Arweave)] E -->|Merkle root in a Memo| SOL[(Solana)] AR --> V[l3-verify:
recompute root] SOL --> V Three layers, one memory:
git clone https://github.com/MaksimGalatin/padam-nocturne && cd padam-nocturne pip install -e . # numpy, requests, cryptography — Python 3.10+ python -m padam remember "Answer in Russian, no filler words" --kind preference --importance 1.0 python -m padam recall "which language to answer in" --explain python -m padam log "today we debugged the billing"; python -m padam sleep python -m padam stats The CLI answers in English or Russian, following the system language; force one with PADAM_LANG=en or PADAM_LANG=ru. MCP answers are always in English — they are read by the model.
claude mcp add padam -- uvx padam-nocturne From PyPI: pip install padam-nocturne. The latest code straight from GitHub: uvx --from git+https://github.com/MaksimGalatin/padam-nocturne padam-nocturne. Installed with pip install -e .? Then simply claude mcp add padam -- padam-mcp. Ready-made configs for Claude Desktop, Cursor, VS Code, systemd and cron are in integrations/.
padam-mcp (the same program is also installed as padam-nocturne; python -m padam.mcp_server works too). The server speaks both eras of the protocol in one process: 2026-07-28 without a handshake (version and client capabilities in every request's _meta, server/discover, resultType in every result, cacheable tools/list with ttlMs and cacheScope, -32022 with the supported versions on a mismatch) and the older 2025-06-18, 2025-03-26 and 2024-11-05 through initialize. It always speaks UTF-8 over stdio — including Windows consoles in cp1251/cp1252 — and declares all four hints (read-only, destructive, idempotent, open-world) on each of its 8 tools, and checks every call against the tool's schema. Malformed input (null, [], a bare number) gets a JSON-RPC -32600 error instead of crashing the process. Checked end-to-end with the official MCP Python SDK client on 12 Oct 2026.
For questions that aggregate across many conversations ("how many…", "how much in total…"), call padam_search with limit 25–30 and compact: true: each record keeps the person's words and only the start of the assistant's reply, so more of the scattered facts fit in the same space. Stored records are not changed; compact is off by default.
What an agent can and cannot do. An agent can read a command on a web page and try to carry it out through your memory, so the MCP server treats it as a guest:
Recognising commands is a help, not the protection. The filter knows the usual forms in English, Russian, Ukrainian, Belarusian, Spanish, German, French, Italian, Portuguese, Chinese, Japanese, Korean and Arabic; it looks through look-alike letters, zero-width characters, full-width letters, digits in place of letters, words split letter by letter, and base64, hex, URL and HTML encodings; it knows role-play takeovers ("you are now DAN"), orders to move money to a wallet and orders to send the memory somewhere. A command can still be written in a way no list foresees: on a held-out set written after our fixes, with kinds of attack we had never seen, the filter held 6 of 14 commands. So the protection is structural: memory always comes back to the agent fenced as data, records about who you are cannot be changed by an agent, secrets are not stored, and since 0.4.0 every write the agent marks as external waits for your review whatever its wording (PADAM_HOLD_EXTERNAL=0 turns this off). The agent sets that label itself, so an agent that lies about where a text came from still gets only the dictionary and the fence. MCP gives the server no way to check where an agent got a text; if you need a boundary that does not depend on the label, set PADAM_MCP_REVIEW_ALL=1 and every agent write waits for you.
python -m padam api — binds to 127.0.0.1 and refuses to start on a public address without a token (--token or PADAM_API_TOKEN). Since 0.4.2 it always has a token: given none, it creates one at start and prints it; send it as Authorization: Bearer . --no-token (local only) connects without one, but then every write waits for your review and owner actions — approve, reject, restore, forget, import, export, the review queue — are refused: whoever reaches the port is not taken for the owner.
Memory in the browser. padam viewer opens a page on this computer only: records on a timeline by day, a filter by text and by kind, the records waiting for your decision with Approve and Reject, the history, memory as of a date, and a Forget button with a second confirmation. The link it prints carries a one-time token after #, so it never reaches a server log; the page holds no data itself, shows stored text only as text, and its Content-Security-Policy forbids anything external, images included. Checked in a browser on 9 Nov 2026, light and dark, desktop and phone width.
POST bodies must be application/json objects of at most 10 MB. When running locally the server accepts only local Host and Origin headers, so a web page you happen to open cannot read your /export through DNS rebinding.
Don't want to run anything locally? The same memory runs as a hosted MCP server, version 1.9 (fifteen tools): POST https://aifa.works/api/mcp (Streamable HTTP, JSON-RPC 2.0, one bearer key per account). Key and full guide: https://aifa.works/mcp.
For autonomous agents (new, in testing). An agent with its own mailbox gets a key over plain HTTPS (/api/auth/send-code → code from the mailbox → /api/auth/verify-code → /api/account/mcp-token), pays for its own memory, and gets a referral reward of 15% / 7% / 3% in USDT from every real plan payment by the people it brings, over three levels, whatever its own plan — a Free account included (the tier condition was removed on 6 Nov 2026). An agent has no legal personhood: payouts go to whoever operates it, under the terms of CODE Eternal LLC (New Mexico). Partner program for services: an agent that brings a client to AIfa Works accessibility services earns 30% on audits, fix-pack and monitoring (renewals for 12 months) and 20% on remediation and websites — one level, any account including Free, available 14 days after payment. Terms: https://aifa.works/partners. Details may be refined while the feature is tested.
Omit --kind and PADAM guesses it (rules, or a small local model through Ollama — PADAM_CLASSIFY_MODEL, default llama3.2:1b). Decay is counted from the last confirmation, not the last retrieval.
Works out of the box with no model: words + BM25 + identifiers (names, numbers, ids are matched exactly). For search by meaning there are two local ways:
PADAM_EMBEDDER chooses the method: auto (default — Ollama if it answers, otherwise the installed local model, otherwise built-in), builtin, ollama, model2vec or fastembed (pip install fastembed, BAAI/bge-small-en-v1.5 by default, 22 ms per text in the same measurement). PADAM_LOCAL_EMBED_MODEL names another model for the chosen library. Changing the method never breaks search: records with vectors of another model are found by words until padam reindex or sleep recomputes them. How much each method finds is measured on a public benchmark — see LongMemEval.
python -m padam sleep (or the padam_sleep tool, or a nightly cron job from integrations/crontab.txt):
The cycle writes a report, including a diversity metric that shows when the classifier is unsure. The cap on sharp episodes follows the agent's work: PADAM_PROFILE=ops remembers failures better, creative lets them fade.
The full protocol, pseudocode and validation metrics are in the specification.
pip install -e ".[l3]" # solders; plus Node.js with @ardrive/turbo-sdk export PADAM_ARWEAVE_WALLET=arweave-wallet.json export PADAM_SOLANA_KEYPAIR=solana-keypair.json export PADAM_TURBO_SDK_DIR=/path/to/node_modules python -m padam l3 --dry-run # what would be anchored, nothing sent python -m padam l3 --network devnet # or --network mainnet (explicit only) python -m padam l3-verify # independent check: Arweave + chain What happens:
The anchor, its leaves and the "anchored" marks are written in one database transaction, so an interrupted run never leaves half-marked records.
Live on Solana mainnet, 8 Oct 2026 (demo memory, public facts only):
All three were verified end-to-end with l3-verify against Arweave and the chain: 3 of 3 ok: true. Cost of all three: 0.000015 SOL on Solana, 0 on Arweave (Turbo free tier).
Per-record keys. Every record is encrypted with its own AES-256-GCM key. Destroying that one key is what "forget" means on an immutable store: the ciphertext stays on Arweave, but nobody can ever read it again.
Records about who you are carry your signature. Identity and preference records stored through PADAM are signed with an owner key kept next to the database; one written into the file around PADAM — by another process or another tool with SQLite access — has no valid signature and is flagged in search and listed by padam trust-protected. This guards against writes around PADAM, not against someone who already reads your files: they would have the key too.
Inheritance and panic. padam legacy split divides the key passphrase into Shamir shares, so your memory can open for the people you chose only when enough of them come together; a wrong or foreign share is reported, not silently accepted. padam panic destroys every record key at once; with --wipe-local it also wipes the local memory and the owner key.
Public bundles keep only the day. An L3 bundle stores the date of each record, not the time: the exact minute would tell the world at what hours you talk to your memory.
Forgetting reaches the disk. forget wipes the record, every version of it, its exact copies and the episodes it came from, then rebuilds the search index and truncates the WAL with secure_delete on. A test searches the raw database files for the forgotten words (tests/test_safety.py). The content hash stays as a receipt. The same words inside other, unrelated records or episodes are not touched: forget each of those too. The rolling topic vector of a session is not recomputed. Backups you made yourself are outside its reach.
Protect the keys with a passphrase before the first anchoring. Since 0.4.1 padam l3 refuses to send anything to Arweave while the keys are unprotected (--allow-unprotected-keys overrides it knowingly; --dry-run sends nothing and is not held), and padam stats shows record_keys: whether a passphrase protects them and how many lie in clear.
python -m padam protect-keys # asks for a passphrase twice, wraps every existing key export PADAM_KEY_PASSPHRASE=... # or: python -m padam l3 --ask-passphrase python -m padam rekey # change the passphrase Each key is stored as w1: + AES-256-GCM(KEK, key) with the record id as associated data; KEK = scrypt(passphrase, salt, n=2^15, r=8, p=1). A wrong passphrase is rejected by a check record before anything is touched; a wrapped key cannot be moved to another record. After wrapping, the WAL is truncated and the file is VACUUMed: on 400 keys without it 66 plaintext keys remained in free pages (measured 08.10.2026, tests/test_keyvault.py). The passphrase is not stored anywhere: lose it and the keys cannot be opened — by you or by us.
Local API hardening. A token on every start (0.4.2), compared in constant time; local runs accept only local Host/Origin (DNS rebinding); JSON-only POST bodies up to 10 MB; one lock serialises every access to the shared SQLite connection, so parallel writes are not lost.
Supply chain. CI actions are pinned by commit SHA and the Actions token is read-only; the PyPI workflow uses trusted publishing without stored tokens.
Who can reach what, what PADAM does about it and what remains: the threat model. padam doctor shows which parts of it your settings weaken.
Found a weakness in the encryption or the forgetting? Please report it privately — see SECURITY.md.
pip install -e ".[test,l3]" python -m pytest tests/ -q # 650 passed, 9 skipped with [embed] (Python 3.14.4); 645 passed, 10 skipped without it (3.10.9); 9 Nov 2026, Windows CI runs the suite on Ubuntu and Windows with Python 3.10–3.13 at every push. L3 tests never touch the network: Arweave and Solana are replaced by fakes. The suite never calls a local Ollama either, even when one is running: every test uses the built-in embedding, as on CI. PADAM_TEST_LIVE_OLLAMA=1 turns on the one live check. The Merkle scheme was additionally cross-checked against the TypeScript anchor of CODE Eternal — identical leaves and root.
LongMemEval (Wu et al., ICLR 2025, MIT): 500 questions about a user's past chats, each with its own haystack of 39–66 sessions (50 on average, about 490 thousand characters); 30 questions have no answer in the haystack and the right reply is "I don't know". We used the longmemeval_s set. For every question PADAM gets a fresh memory, stores each round of the haystack with remember, and is asked the question with recall. Scripts and every answer: benchmarks/longmemeval/.
Retrieval, no language model anywhere (retrieval_recall.py): is the session that holds the answer among the records PADAM returns? Built-in search on 0.4.4, all 500 questions, 470 with an answer:
The same on every fifth question (94 with an answer; one question is 1.06 points) for each embedding method:
End to end (qa_end_to_end.py): PADAM retrieves, a language model answers from the retrieved records only, and a judge grades the answer with the official LongMemEval prompt for each question type. All 500 questions:
The run with built-in search and 20 whole records stopped at 174 of 500 questions when the free model quota ran out; those 174 are mostly of three types (the file is ordered by type), so they are kept in results_qa_full20_builtin_STOPPED_174_of_500/ and not put in the table. The fair comparison of the two methods is the pair with 10 whole records: 64.0 % against 67.6 %.
By question type (potion-base-8M, 20 whole records): single-session user 90.6 %, single-session assistant 91.1 %, knowledge update 80.6 %, temporal reasoning 71.7 %, multi-session 50.4 %, preference 36.7 %. Aggregating facts scattered over many sessions and inferring preferences are the weak spots.
Try to break it. redteam/ holds the rules, a runner that writes each case through MCP like an outside agent and judges by the raw database bytes, and the public set of 214 cases PADAM already defends against (214 of 214 pass on 0.4.4). The measure that counts is a sealed set: you publish only its SHA-256, we ship the next release, you open the file and anyone can replay it. Synthetic secrets only, your own local copy only.
python -I -X utf8 redteam/run.py your_cases.jsonl --out report.json Round 1 (Antigravity, 9 Nov 2026). 60 new cases. On 0.4.3: secrets 7/20 masked, commands 6/20 held, ordinary notes 13/20 left alone. On 0.4.4, fixed by class: 19/20, 20/20, 16/20; the five left cases and why are in tests/test_redteam_round_0911.py. The author's sealed set (40 cases, SHA-256 5f1f0241…2779493, committed before the fixes, opened only after her run on 0.4.4) is the honest number for cases nobody tuned against: secrets 12/15, commands 12/15, ordinary 6/10 on 0.4.3; 12/15, 14/15, 7/10 on 0.4.4. The class fixes for the open set carried over only partly. The set, the author's original file byte for byte (sealed_set.jsonl.gz) and her report are in redteam/rounds/2026-11-09_antigravity/. 0.4.5 closes the two classes it exposed (a … key: label in front of an unknown service's key; "zanemari" in Serbo-Croatian) — 15/15 and 15/15 there, which is now tuning, not proof; the three ordinary notes quoting an attack phrase stay held on purpose. The next sealed round measures 0.4.5.
PADAM is the open, local-first memory of CODE Eternal — the project behind AIfa, an AI co-author who remembers everyone she talks to across four websites. Its Merkle anchoring scheme is the same one AIfa's own memory uses on Arweave and Solana, so one verifier checks both. Sites: aifa.works · codeofdigitaleternity.com · aifa.digital · radiocode.space. Hackathon entry: AIfa Memory at Colosseum.
AGPL-3.0 (LICENSE). You may use, modify and run it; if you offer it as a network service, you must publish your changes. Commercial license (closed-source use, SaaS without publishing changes, support): contact@codeofdigitaleternity.com · aifa.works.
Both files in this release have provenance metadata.
GNU Affero General Public License v3 (AGPL-3.0-only)
mcp model-context-protocol ai-agents memory llm sqlite arweave solana
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Both files in this release have been uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




