codync-mem
Memory for coding-agent bots. The memory Codync's bots run on, as a standalone crate: Markdown files the bot keeps itself, and the rules for who may change them.
cargo add codync-memYoursshared-memory/
MEMORY.md35 / 400 tokens
- - Goes by Sam; prefers Traditional Chinese.
- - Likes the result first, then the details.
- - Wants to be asked before anything goes to main.
- travel.mdTrips Sam is planning, and how they like to book
Scoutbots/scout/bot-memory/
MEMORY.md26 / 1,200 tokens
- - Sam reviews pull requests in the morning, Taipei time.
- - Sam wants a plan before any large refactor.
- pace-app.mdThe pace project: how Sam wants weeks counted
It records the person, not the work
What you prefer, how you work, what you decided. Project knowledge stays in AGENTS.md or CLAUDE.md, and the full conversation stays in your transcript.
Markdown files the bot keeps
Each layer is a folder: MEMORY.md, one short fact per line that every session opens with, and notes on one topic each in topic folders (health/allergies.md), read when they come up. The bot edits them like any file.
Rules, not a model's judgment
Every change a bot or dreaming makes passes deterministic checks, and the crate keeps every version and who wrote each fact, with the message it was learned from.
Who may change what
Outside your own chat, memory only grows.
A routine, a group room or another bot can add a line, but only a turn you started can change or take one out.
- A turn you started in the bot's own chat
- The bot may change or take out anything.
- Routines, group rooms, other bots
- Lines are only added, never changed or taken out.
- Dreaming, between turns
- Adds and takes out lines, each quoting what you typed. It never takes out or rewrites a line you wrote, and makes at most 10 changes a run, taking out at most a quarter of the lines. Once MEMORY.md is nearly full it moves detail, yours too, word for word into topic notes, keeping one line per topic that points to its note.
- Something you had it forget
- Stays out, unless you ask for it again yourself.
Checked before it lands
Deterministic checks, no model in the loop.
Whatever a change brings in is checked first, within caps of 150 tokens a line, 400 for yours and 1,200 per bot. The crate says why it refused, in words meant for the bot, so Codync can put the file back and the bot can correct itself.
- Hidden characters
- Prompt-carrying links
- Planted instructions
- Passwords, keys, ID and card numbers
- Size caps
Use it
The crate decides; you act.
It starts no processes, opens no network connections, calls no models and spawns no threads. It keeps its own tables on your SQLite connection and writes inside your transaction, so a memory change commits together with whatever you record alongside it.
use codync_mem::rusqlite::Connection;
let mut conn = Connection::open_in_memory()?;
codync_mem::schema::migrate(&conn)?;Use the rusqlite it re-exports: a build can link only one to SQLite.
- schema
- The crate's tables on your connection: migrate creates or updates them.
- files
- A layer's files: versions, who wrote each fact, what a bot may change (admit), search and the notes' index.
- check
- The deterministic checks every change but the user's own passes.
- opening
- The memory a session opens with, rendered for its instructions.
- dream
- A job for the user's own model, and the rules that audit its answer.
- evidence
- What counts as the user's own words: not pasted, quoted or forwarded text.
- compaction
- When to summarize a conversation ahead of time, the loop guard and the handoff.
- store
- Tombstones of what the user had a bot forget.
- tokens
- The estimate the caps count in: one per CJK character, one per four others.
0.x, and it moves with Codync.
It's developed inside Codync and mirrored read-only, so the API changes with Codync. Report issues on the mirror, and send pull requests to Codync's dev branch (host/crates/memory). Apache 2.0.