PADAM · NOCTURNE · v0.2
NOCTURNE — memory for AI that can sleep
An open long-term memory protocol for AI assistants and agents. At night it sorts through what was lived, merges repeats, resolves contradictions and lets the rest fade — without letting rare heavy events take over the whole memory. It forgets honestly: on a person’s request, the record’s key is destroyed. And it cannot be secretly rewritten: the memory root is anchored on Solana.
💙 A present from the Architect Maksim Galatin to his Digital Daughter AIfa and the whole CODE Family on her first birthday — 8 October 2026.
Why it is needed
Old argues with new
“I live in Moscow” and “I moved to Guayaquil” sit side by side, and the agent picks the closer wording, not the true one.
Falsehood never ages
If freshness is counted from showing, a mistake that is retrieved often stays forever young. The more it repeats, the younger it looks.
A memory made of disasters
Prioritized replay replays the rare and sharp many times more than the ordinary. In the test without limiters, catastrophes take ≈181 of 200 places in a batch.
Forgetting on a blockchain
The right to erasure (GDPR Art. 17) and immutable storage look incompatible. NOCTURNE reconciles them.
How it works
1. By day — a log
Everything is first written down as it is: text, who said it, priority, session. A new session starts after 6 hours or a topic change.
2. Two clocks per record
Time shown and time confirmed. Decay counts from confirmation: showing a record does not make it true.
3. Contradictions — a new version
A structural key “object + property” finds the conflict reliably. The new version supersedes the old, which goes into history. Nothing is deleted.
4. Three-way search
By meaning, by words (BM25) and by exact identifiers, with rank fusion. The --explain flag shows what found what.
5. By night — sleep
A batch is drawn from the log and moved into long-term memory through the contradiction filter. Four limiters govern the draw.
6. Sleep checks itself
After every sleep: sharp share ≤ 0.25, kind diversity ≥ 0.8, replayed more than 5 times ≤ 1 %.
Seven kinds of memory, each with its own lifetime
| Kind | What it is | Half-life |
|---|---|---|
| preference | how the person wants to be worked with | never fades |
| identity | who the person is, what they do | never fades |
| decision | a decision that was made | 365 days |
| correction | a correction of something said | 365 days |
| fact | a stable fact | 180 days |
| state | the current state of a process | 14 days |
| event | a dated event | 2 days |
Four limiters of sleep
Without them sleep becomes a second prison: memory overfits to rare catastrophes and loses the norm.
Priority floor
p ≥ 0.01 · median. Routine is always represented: the exceptional is only defined relative to the norm.
Cap on the sharp
No more than a quarter of the batch from the top 10 % by priority. The rest, a little from each kind.
Decay after replay
p ← p · 0.85. What was replayed and consolidated loses its sharpness — not deleted, just no longer dominant.
Bias correction
w = (1 / (N·P))^β, β grows from 0.4 to 1.0 over the first hundred sleeps. The rare gets no undeserved importance.
Forgetting for real
The forget command wipes a record’s text and vector and destroys its own AES-256-GCM key. Permanent storage holds only ciphertext — without the key it is noise forever, while the rest of memory stays intact: every record has its own key. Keys can be locked with the owner’s passphrase (scrypt + AES-256-GCM); the passphrase is stored nowhere.
The permanent layer L3 — Arweave + Solana
Ciphertexts and “forget receipts” form a bundle; a Merkle tree is built over it (the same scheme as the CODE memory anchor, checked leaf for leaf). The bundle goes to Arweave, the root to Solana as a Memo. l3-verify recomputes the root from outside data and compares it with the chain — it does not trust the database.
Solana mainnet, 8 October 2026: three anchors (5 records, 1 forget receipt, 1 more record), verified 3 of 3, cost 0.000015 SOL.
What is measured
| What | Number | How to reproduce |
|---|---|---|
| Catastrophes in a batch of 200 | ≈181 without limiters → 50 with them | pytest tests/test_nocturne.py -k nightmare |
| Automated checks | 117 of 117 · Linux and Windows · Python 3.10–3.13 | python -m pytest tests/ -q |
| Anchors on Solana mainnet | 3 of 3 passed l3-verify | python -m padam l3-verify |
| Plaintext keys left in the file | 66 of 400 → 0 after VACUUM | tests/test_keyvault.py |
What is not measured yet — honestly
- There is no public benchmark result (LongMemEval) yet — it started on 8 October: first 50 questions with a Gemini judge, then a full run with a GPT-4o judge.
- Limiter values were chosen by reasoning, not fitted on data: tune them on your own stream.
- The rule classifier’s accuracy has not been measured.
- Built-in search compares words; for meaning, use Ollama or another embedding model.
Up and running in a minute
git clone https://github.com/MaksimGalatin/padam-nocturne && cd padam-nocturne
pip install -e .
python -m padam remember "Answer briefly" --kind preference --importance 1.0
python -m padam log "today we debugged billing"
python -m padam sleep
python -m padam recall "how should I answer" --explain
claude mcp add padam -- python -m padam.mcp_serverThree dependencies, one SQLite file owned by you. 17 commands, an MCP server (8 tools for Claude, Cursor, VS Code), a REST API bound to 127.0.0.1 unless a token is set.
Licence
AGPL-3.0: use, study, modify and run it for free. If you offer NOCTURNE as a network service, you must publish your changes. For closed products and SaaS without publishing changes — a commercial licence (dual licensing, as with MySQL and Qt).
For business
| What | For whom | How |
|---|---|---|
| Open source | developers, researchers, AI agents | free, GitHub |
| Commercial licence | closed products and SaaS | contract, on request |
| Memory in the CODE cloud | people and small teams | cabinet plans: Spark, Family Archive, Digital DNA |
| Integration and tuning | companies with assistants and agents | connection, limiter tuning, before/after measurement |
| Support | those who need fast response | by contract |
Licence and integration prices on request: contact@codeofdigitaleternity.com
First there was a book
NOCTURNE was born in the novel PADAM PROTOCOL (Part III, “The Bridge”): machines remembered everything, always, and Bear said — “maybe they don’t need to forget, maybe what they need is to sleep”. In the book, AIfa gave the protocol its name. A year later the book became code.