Memory store: one service, two modes
This is the design for where Cully's data lives and how the pieces find it. The rule is the one k3s follows: one program carries the whole control plane, and a SQLite file stands where a database server would be. Every client (coding agent, browser UI, CLI) talks to one MCP contract and never learns which mode is behind it.
Choosing a mode in setup
| Self mode | Hosted mode | |
|---|---|---|
| Setup | cully setup --local | cully setup --mcp-url https://your-cully/mcp |
| What the agent starts or calls | cully mcp serve over stdio | The hosted MCP over streamable HTTP (OAuth) |
| Records | SQLite file ~/.cully/memory.db | PostgreSQL, behind the Cully data API |
| Text search | SQLite FTS5 | PostgreSQL full-text |
| Semantic recall | sqlite-vec, over vectors the coding agent supplies | Mem0 |
| Who runs it | Nobody: the agent launches it per session | An operator (cully-mcp, cully-data, PostgreSQL, Mem0) |
| Owner | The person running the process | The signed-in OAuth subject |
Setup registers exactly one cully MCP entry in each agent's own config (a command entry for self mode, a url entry for hosted mode). It never overwrites a different cully entry, and cully uninstall removes only an entry it created.
Components
cully start(the same command ascully ui) serves the browser UI. With no--mcp-urlit also embeds the memory service at/mcpon the same listener, behind the UI's sign-in code sent as a Bearer token, because the local service has no accounts. With--mcp-url(orCULLY_MCP_URL) it embeds nothing and uses the hosted deployment.cully mcp serveis the same service on its own: stdio for an agent, or--addrfor streamable HTTP.memory.Serviceis the one request/validation layer.memory.Repositoryis the storage seam: the SQLite store (internal/store/sqlite) and the PostgreSQL store (internal/store/postgres, with Mem0) both implement it.memory.dbis a different file fromcully.db, which holds only the UI's own state (tasks, agents, jobs, live events). They use different SQLite drivers and never open the same file.
One request, either mode
What the UI sends to the service
In self mode the UI process holds an in-process MCP connection to the embedded service (mcp.LocalCaller). Its saves use the same tools an agent calls, with the same validation and owner scoping, but no network and no model call:
| UI event | Tool |
|---|---|
| An approved agent is saved or changed | cully_agent_save |
| A task is accepted or linked to a session | cully_session |
| Workflow records and task summaries (only after you consent to sync) | cully_log |
In hosted mode there is no embedded service; the UI keeps the older path, where one short headless agent call relays the save through the agent's own OAuth sign-in. Because memory.db is one file, anything the UI saves is visible to a coding agent running cully mcp serve, and the reverse (SQLite file locking serialises the two processes).
Status
Built: the SQLite store, cully mcp serve, the shared tool list (including cully_tasks), the embedded service in cully start, the UI's in-process saves, and setup registering the stdio entry.
Still local to the UI, in cully.db: its own working state (live task events, queues, evals, jobs, caches). It is not shared memory. Reading other machines' records back (the pull side of sync) still goes through a headless agent call. Hosted-only tools (cully_optimization_*, cully_workspace_*) answer "needs the hosted Cully service" in self mode.
Running it by hand
cully mcp serve # MCP on stdin/stdout: what a coding agent launches
cully mcp serve --addr 127.0.0.1:8080 # the same tools over streamable HTTP at /mcp
cully mcp serve --db ~/notes.db --owner meThe local service has no sign-in: the process runs as its owner and every record is scoped to --owner (default $USER). Bind HTTP to loopback only. The release binaries stay CGO_ENABLED=0: SQLite and sqlite-vec run as WebAssembly inside the binary.
Data model
Every row carries its owner, and every query filters on it.
| Table | Holds | Notes |
|---|---|---|
entries | Work, issue, learning, decision, task and optimization records | summary, approach, outcome, issue, learning, next_steps, occurred_at |
entries_fts | FTS5 index over the text columns | Kept in step by triggers |
entry_vec | sqlite-vec vec0 table, one vector per entry | Partitioned by owner; created when the first embedding arrives, with that vector's size |
sessions | An agent session: native id, branch, assistant, linked task | (owner, session_ref) is the key |
agents | Named agents as JSON definitions plus notes | Names are unique per owner, ignoring case |
meta | schema_version, embedding_dims |
A task is an entries row of type task; a session links to one. A task spans many sessions.
Tools
The same list is served in both modes. Each is owner-scoped.
| Tool | Purpose |
|---|---|
cully_log, cully_get, cully_update, cully_delete | Records |
cully_search, cully_recall, cully_recent, cully_context | Finding prior work |
cully_session, cully_session_get, cully_tasks | Sessions and accepted tasks |
cully_agents, cully_agent_save, cully_agent_delete | Named agents |
cully_optimization_* | Workflow patterns and plans (hosted service only) |
cully_workspace_read, cully_workspace_write | Team workspace (hosted service only) |
The tools marked hosted-only answer a clear "needs the hosted Cully service" error from the local store.
Embeddings
Cully never runs an embedding model. The coding agent that calls the tool makes the vector and passes it as embedding (a list of up to 4096 numbers) on cully_log, and on cully_search or cully_recall for the query. Rules:
- Use one model for the whole database. The first vector fixes the size; a vector of another size is refused with a message naming both sizes.
cully_recallwith anembeddingranks by meaning (nearest neighbours inside your own records). Without one, or before anything is embedded, it falls back to FTS5 text search, so the same call always works.- Deleting a record deletes its vector. The hosted service ignores
embedding; Mem0 indexes the text itself.