1. Executive Summary
Alexandria is an agent memory server written in Rust: one process over an embedded SurrealDB store, serving seventeen MCP tools over HTTP or stdio, with a signed-in web UI and client companions for Claude Code, pi and Hermes. An agent stores a fact into a named partition of its owner's workspace, and retrieval is cosine kNN over local embeddings. No model is called on the write or read path.
Notable: the partition is enforced in one place. A single
WHERE conjunct is built from the caller's resolved
partitions and spliced into the kNN statement itself
(crates/alexandria-storage/src/repos/scope.rs:100-106,
crates/alexandria-storage/src/repos/scoped_memory.rs:319-327).
Every semantic change commits a journal row with full before and after
snapshots in its own transaction. Rewrites a configured model proposes
wait for the owner's browser session.
Weak: what the agent itself stores, edits or deletes is never reviewed. Any token of an account can read every project of that account. The journal keeps a deleted memory's text with no path to erase it. The heat model is recorded on every read and ranks nothing.
Four marks are present and three are withheld (section 9).
Licence. LICENSE is the AGPL-3.0 text
followed by a Linking Exception for SurrealDB, which lets a
combined work with SurrealDB, licensed under the Business Source
License 1.1, be distributed under terms of your choice
provided the BSL is honoured for SurrealDB
(LICENSE:663-680). Every build embeds that engine
(Cargo.toml:46), so the program that runs is not wholly
under the copyleft the README presents as closing the network-service
loophole (README.md:672-675). No copyright holder is named
anywhere in the tree; the exception is granted by the copyright
holders of Alexandria, unnamed. No rider against analysis was found
in LICENSE, README.md, AGENTS.md,
CLAUDE.md or docs/. There is no
SECURITY.md.
2. Mental Model
A memory is a fact: a string the agent chose to keep, with tags, an
embedding and a confidence the writer sets. It belongs to one account's
workspace and to exactly one partition — Personal, one project, or
Unassigned
(crates/alexandria-storage/src/schema/v009_accounts_scopes.surql:403-412).
It is believed from the moment it is stored. There is no candidate
state, no validity interval and no supersession status on the row.
It stops being retrievable in two ways. deleted hides
it, and is what delete_memory and a duplicate collapse set.
quarantined_at hides it from every live read while the
owner can inspect it, and its only production writer is an approved
refinement that judged the fact noise
(crates/alexandria-storage/src/repos/refinement_repo/application.rs:550-556).
An edit keeps the fact's identity, rewrites its text, and stores the old
text as a hidden copy linked by derived_from.
Change that does not come from the agent waits. A configured model's proposal to rewrite, consolidate, split, supersede or quarantine is a pending row, and so is the agent's own proposal to move a fact between partitions. The owner decides both in the web UI.
Diagram source
%% caption: agent writes are admitted, targeted and journaled in one transaction and are live at once; reads splice one partition predicate into the kNN; model rewrites and scope moves wait for the owner
flowchart TD
AG["Agent MCP call<br/>bearer or stdio"] --> TGT{"write target<br/>named?"}
TGT -- "hosted, none" --> REF["refused before<br/>embedding"]
TGT -- "yes" --> TX["one transaction:<br/>fact, cluster, journal"]
TX --> PART["live fact in Personal<br/>or one project"]
TX --> JR["semantic_operation<br/>pre and postimages"]
AG --> SEL["read selection:<br/>auto, project, assigned"]
SEL --> KNN["kNN with partition<br/>conjunct and LIVE"]
PART --> KNN
KNN --> RANK["exact cosine<br/>and floor"]
RANK --> CTX["agent context"]
WK["refinement model<br/>if configured"] --> PEND["proposal pending"]
AG --> PROP["propose_memory_scope"]
PROP --> PEND
PEND --> OWN{"owner browser<br/>session decides"}
OWN -- "approve" --> TX
OWN -- "dismiss" --> DIS["dismissed"]
PEND --> SEC["second model, if<br/>owner opted in"]
SEC --> TX3. Architecture
Five crates. alexandria-storage owns the SurrealDB
connection, the seventeen migrations, the repositories and the access
layer that turns a credential into an owner and a read selection into
partitions. alexandria-engine holds the clock-free
algorithms: clustering, heat, recall, import chunking, dreaming rules
and refinement validation. alexandria-pipeline wraps the
embedding providers, MiniLM through Candle by default and Granite
through Burn as an opt-in. alexandria-mcp joins engine to
storage: the tool handlers, the journaled apply service, the refinement
worker and the web UI. alexandria is the binary, its
configuration, the dreaming scheduler and the maintenance commands.
Deployment and ergonomics
One binary. With transport = "http" it serves
/mcp behind bearer tokens and /debug behind
account sessions, runs the dreaming scheduler, and, if refinement is
configured, the refinement worker
(crates/alexandria/src/main.rs:555-560,
crates/alexandria/src/dreaming.rs:1-9). Over stdio it
serves one trusted local owner with no scheduler. SurrealKV is
single-writer, so dream, bench-retrieval and
the in-place re-embedding need the server stopped
(README.md:90-92). A first account is created by the
bootstrap-owner command, since enrollment is by invitation
only (crates/alexandria/src/main.rs:43-53). The first run
downloads the MiniLM weights from Hugging Face; a Containerfile ships an
Alpine image.
4. Essential Implementation Paths
- Admit.
admit_write_targetrefuses a hosted write that names no target before anything is authorized or embedded; a trusted local caller defaults to Personal (crates/alexandria-mcp/src/server.rs:1809-1843,crates/alexandria-mcp/src/scope_service.rs:305-340). - Store.
store_journaledchooses a cluster, then commits the fact, heat, provenance, cluster membership, centroid, session link and journal row as one change set (crates/alexandria-mcp/src/server.rs:2568-2696,crates/alexandria-mcp/src/mutation.rs:1-37). - Retrieve.
retrieve_coreembeds the query, asksScopedMemoryRepo::nearestforlimitplus slack, re-ranks by exact cosine and drops rows under the floor (crates/alexandria-mcp/src/server.rs:3448-3546). - Predicate.
ScopeFilter::conjunctand theLIVEconstant are the one spelling of which rows a read may see (crates/alexandria-storage/src/repos/scope.rs:93-118,crates/alexandria-storage/src/repos/scoped_memory.rs:33). - Update and delete. Both build a plan with an
expected revision and commit it through the apply service
(
crates/alexandria-mcp/src/server.rs:2891-2983,:2207-2230). - Journal.
CREATE_OPERATION_SQLandFINISH_OPERATION_SQL, and the snapshot writer beside them (crates/alexandria-storage/src/repos/mutation_repo.rs:3198-3206,:3359). - Review.
approve,dismiss,deferandreverton refinement proposals, anddecideon scope proposals, all take aBrowserSession(crates/alexandria-mcp/src/debug/refinement.rs:570-604,crates/alexandria-mcp/src/debug/collections.rs:700-705).
5. Memory Data Model
fact carries content,
confidence (default 0.5), embedding,
tags, created_at, metadata and
deleted
(crates/alexandria-storage/src/schema/v001_initial.surql:11-18),
plus quarantined_at (v008_dreaming.surql:22)
and the ownership columns account, workspace,
scope, project and
semantic_revision
(v009_accounts_scopes.surql:403-412). The ownership columns
are optional so that pre-v009 rows load; an unowned row matches no
scoped reader, and the ownership migration assigns such rows to
Unassigned
(crates/alexandria-storage/src/ownership_migration/snapshot.rs:150-157).
Around the fact: raw documents linked by
extracted_from, heat_state with heat,
stability and access counts, cluster with a centroid and
three revision guards, memory_edge between facts, sessions,
reminders, accounts, one workspace per account, projects and their
aliases, and credentials of kind browser, agent, invite or recovery
(v009_accounts_scopes.surql:62-196).
The journal is two tables. semantic_operation holds the
workspace, the acting account, the presenting credential, one of twelve
kinds, an operation key unique per workspace, a request fingerprint,
expected and actual effects, the affected partitions and ids, pre- and
postimage references with digests, and revert links
(v009_accounts_scopes.surql:261-298).
semantic_snapshot holds a fact's full text, tags,
confidence, partition, visibility, embedding and relations, or the
equivalent for an edge, cluster or reminder (:300-393).
6. Retrieval Mechanics
retrieve_memories resolves a selection —
auto is Personal plus a named project,
assigned is Personal plus every owned project, never
Unassigned
(crates/alexandria-mcp/src/scope_service.rs:362-406,
crates/alexandria-storage/src/access.rs:729-757). The kNN
statement is
SELECT * FROM fact WHERE {LIVE} AND {conjunct} AND embedding <|k,…|> $q,
indexed through HNSW when boot defined the index and exact otherwise
(crates/alexandria-storage/src/repos/scoped_memory.rs:319-327).
The result is re-ranked by cosine alone
(crates/alexandria-engine/src/search.rs:21-36) and cut at
retrieve_min_similarity. A session_id narrows
the candidates to that session's rows inside the same partitions.
recall ranks the caller's clusters by centroid, returns
representatives and a handle, and a second call ranks the members of one
cluster (crates/alexandria-mcp/src/server.rs:1853-1950).
Both reads record an access on the returned rows and warm their graph
neighbours' heat. Heat ranks nothing, which the README states
(README.md:8), and neither does confidence:
retrieve_core never reads it (recorded search below).
7. Write Mechanics
The agent decides what to store, through tool descriptions that ask
it to store proactively
(crates/alexandria-mcp/src/server.rs:363-365). None of the
client integrations writes on its own; the Claude extraction hook is a
no-op that warns
(contrib/claude/hooks/alexandria-extract.sh:2-12), and the
Hermes provider carries an extraction module that only its tests
call.
A store is synchronous. The text is embedded on the request path, a
cluster is chosen against cluster_join_threshold, and the
change set commits in one transaction with up to three preparations when
a centroid moved underneath
(crates/alexandria-mcp/src/mutation.rs:30-37). The fact is
retrievable as soon as the call returns. An update re-embeds when the
text changed and revectors the fact's cluster in the same commit
(crates/alexandria-mcp/src/server.rs:2966-2975).
Operational cost
One local embedding per store and per query; no model call. In HTTP
mode the dreaming scheduler runs five jobs on separate cadences, each
capped in rows per pass and rotated fairly across partitions. Cluster
split and merge refuse owned data and run only over legacy rows
(README.md:102). Collapse soft-deletes byte-identical
duplicates and appraisal lowers a cold, never-retrieved fact's
confidence to 0.2; both journal their changes
(crates/alexandria/src/dreaming.rs:768, :857,
crates/alexandria-engine/src/dreaming/appraise.rs:24).
Nothing rewrites the whole store.
8. Agent Integration
Seventeen tools: store, retrieve, recall, update, import and delete;
three session tools; four reminder tools; and
resolve_project, list_projects,
list_unassigned_memories and
propose_memory_scope
(crates/alexandria-mcp/src/server.rs:352-876). The server's
initialize instructions tell the agent when to read and
write (:878-894). Over HTTP each call carries an agent
bearer token; the credential table separates agent tokens from browser
sessions, so one cannot be presented as the other
(crates/alexandria-mcp/src/auth/service.rs:100-124).
Reminders are prospective memory: due-ness is evaluated when a client
calls check_reminders, and read paths carry a due summary.
The pi companion recalls before each prompt; the Claude Code hook
recalls from Personal unless a project id is configured.
9. Reliability, Safety, and Trust
One predicate, inside the scan
ScopeFilter is built from the resolved partitions,
selects nothing when none resolved, and names a project by id so
scope = 'project' cannot read a sibling project
(crates/alexandria-storage/src/repos/scope.rs:53-118). It
sits inside the kNN statement, not after it, so a caller with few rows
is not starved by another account's closer vectors. The schema states
why the boundary is code: an embedded root session ignores SurrealDB
PERMISSIONS
(v009_accounts_scopes.surql:36-40).
What waits and what does not
The gate covers changes the agent did not write. A refinement
proposal binds the consent and approval mode it was made under; approval
applies exactly the displayed revision, and the routes take a browser
session
(crates/alexandria-mcp/src/debug/refinement.rs:640-679).
The agent's own store_memory, update_memory
and delete_memory take effect at once, so memory content an
agent writes is never reviewed. delete_memory refuses an
Unassigned row, which only the owner's page may delete
(crates/alexandria-mcp/src/server.rs:2194-2201).
When the operator allows automatic approval and the owner selects
secondary_llm, a second model call may approve the exact
candidate, except contradictions
(crates/alexandria-mcp/src/refinement/worker.rs:801-830,
crates/alexandria-engine/src/refinement/policy.rs:313-317).
The alexandria refinement approval secondary-llm command
sets that preference from a shell on the host.
Reach inside an account
One workspace per account, and every agent token of the account may
name any of its projects or ask for assigned.
list_unassigned_memories hands Unassigned text to the
agent, though no recall reaches it. An administrator can issue a
recovery link for another account and sign in as that owner, and
admin_recovery_log records the issuance
(README.md:250-252).
Nothing is erased
Deletion sets a flag, and each journal row keeps the deleted text in its preimage. No statement in the tree deletes a fact, a snapshot or a journal row.
Marks
scope_enforced— present. Account from the credential, partitions from the request, one conjunct inside the kNN; the limit is that partitions divide one owner's data, and every token of the owner reaches all of them.audit_log— present.semantic_operationwith snapshots, written in the change's own transaction by every semantic writer and never deleted; append-only by code rather than by the database.human_review— present. Model-proposed rewrites and agent-proposed scope moves wait for the owner's browser session, which the agent's token cannot open and no tool approves. It does not cover the agent's own writes.negative_eval— present. Populated kNN cases require another account's, an unselected project's, and hidden rows to stay out, with closer vectors.trust_state— withheld. Visibility is live, deleted or quarantined, and quarantine marks noise rather than doubt; no state says a stored fact is unverified, andconfidenceis a float no read consults.bitemporal— withheld.created_atand the journal'scommitted_atare record times; nothing holds when a fact was true.tombstone— withheld. A deleted fact's text stored again is a new live row; collapse matches live duplicates only.
10. Tests, Evals, and Benchmarks
The tree carries 1,453 Rust test attributes, 24 of them
#[ignore]; the suites cited below run against an in-memory
embedded SurrealDB. CI runs formatting, clippy, the workspace under two
feature sets, CPU-only tests, the companions' suites, two Python
scorers, cargo deny and a container smoke test
(.github/workflows/ci.yml). I ran none of them.
The negative cases are in
crates/alexandria-storage/tests/scoped_retrieval_test.rs.
Each seeds excluded rows nearer the query than the eligible ones and
asserts the exact id list under both scans: a Personal-only read omits
the owner's project rows (:390-427), a
Personal-plus-project read omits the other project
(:433-480), deleted and quarantined rows stay out
(:572-607), and another account's rows never appear
(:610-643). Plan tests check that the index is used under
the predicate. None of these can pass on an empty result.
The journal is tested through the MCP surface: a store writes one
operation, an update journals content, vector and lineage with a hidden
snapshot, a delete journals one visibility effect with one pre- and one
postimage, and one owner's journal is never another's
(crates/alexandria-mcp/tests/journaled_writers_test.rs:550-626,
:875-949, :1145-1199). Refinement authority
tests pin that a pending proposal changes nothing until approved
(crates/alexandria-mcp/tests/refinement_authority_test.rs:207-216).
bench-retrieval and the Granite pilot publish score
distributions in docs/minilm-test-data.md and
docs/granite-test-data.md; the refinement scorer runs nine
owner-reviewed cases against three stand-in proposals. No paper
describes Alexandria; docs/security-findings.md reviews
someone else's paper as threat background.
Cases to want first: the negative kNN cases through the
retrieve_memories tool with two tokens of one account, and
a deleted fact's text stored again.
11. For Your Own Build
Steal
- Build the scope predicate once and put it inside the vector
query. A filter applied after
kreturns fewer rows by an amount someone else controls. - Refuse an untargeted write before embedding it. The refusal costs nothing and leaves nothing to clean up.
- Journal the change in its own transaction, with full snapshots. Expected and actual effects side by side make a partial write visible.
- Bind approval to a revision. A stale proposal is refused, not applied over a fact that moved.
Avoid
- Do not let a field nobody reads look like a ranking
input. Appraisal demotes
confidence, and retrieval never reads it. - Do not keep deleted text in the audit trail with no erase path where users will ask for deletion.
- Do not leave public unscoped methods beside the scoped ones. The interim arms have only test callers at this pin, and nothing stops the next caller.
Fit
Fits a person or a small group running one self-hosted server for several coding agents, who wants a defensible partition boundary, a history of every change, and model-driven cleanup they approve. The Rust is careful and heavily tested, and the storage engine's licence and single-writer lock come with it.
Walk away if agents must not write unreviewed memory, if tokens must be limited to one project, if deletion must erase, or if lexical recall matters.
12. Open Questions
- Whether
confidenceis meant to reach ranking, given that appraisal lowers it. - Whether a per-token project restriction is planned for hosted accounts.
- Whether the MCP instructions, which say nothing applies a scope proposal, are meant to describe the owner's classification page that does.
Appendix: File Index
- Schema:
crates/alexandria-storage/src/schema/v001_initial.surql,v008_dreaming.surql,v009_accounts_scopes.surql,v011_refinement.surql - Scope and access:
crates/alexandria-storage/src/repos/scope.rs,crates/alexandria-storage/src/repos/scoped_memory.rs,crates/alexandria-storage/src/access.rs,crates/alexandria-mcp/src/scope_service.rs - Tools and retrieval:
crates/alexandria-mcp/src/server.rs,crates/alexandria-engine/src/search.rs - Journal:
crates/alexandria-storage/src/repos/mutation_repo.rs,crates/alexandria-storage/src/repos/mutation_repo/quality.rs,crates/alexandria-mcp/src/mutation.rs - Review:
crates/alexandria-mcp/src/debug/refinement.rs,crates/alexandria-mcp/src/debug/collections.rs,crates/alexandria-mcp/src/refinement/worker.rs,crates/alexandria-engine/src/refinement/,crates/alexandria-storage/src/repos/refinement_repo/application.rs - Auth:
crates/alexandria-mcp/src/auth/service.rs,crates/alexandria-mcp/src/debug/web.rs,crates/alexandria-mcp/src/debug/guard.rs - Background:
crates/alexandria/src/dreaming.rs,crates/alexandria-engine/src/dreaming/ - Tests:
crates/alexandria-storage/tests/scoped_retrieval_test.rs,crates/alexandria-mcp/tests/journaled_writers_test.rs,crates/alexandria-mcp/tests/refinement_authority_test.rs
Recorded searches
Run from the repository root at the pinned commit with
/usr/bin/git grep. .gitmodules is absent.
- No validity time.
git grep -n -i -E 'valid_from|valid_to|valid_at|as_of|bitemporal' -- 'crates/*.rs' 'crates/*.surql'returns one test name containingvalid_token(crates/alexandria-mcp/src/debug/guard.rs:717). - No lexical arm.
git grep -n -i -E 'bm25|fulltext|full_text|search::score|SEARCH ANALYZER' -- 'crates/*.rs' 'crates/*.surql'returns nothing. - No value-keyed tombstone.
git grep -n -i -E 'tombstone|blocklist|denylist|rejected_value' -- 'crates/*.rs' 'crates/*.surql'returns one doc comment,crates/alexandria-storage/src/repos/scoped_memory.rs:368. - No schema guard on the journal.
git grep -n -E 'PERMISSIONS|DEFINE EVENT' -- 'crates/*.surql'returns only the comment atv009_accounts_scopes.surql:36-37; the same pattern overcrates/*.rshits test fixtures and doc comments only. - The journal is updated in two places and deleted in
none.
git grep -n -E '(UPDATE|DELETE|UPSERT)[^;]{0,40}semantic_(operation|snapshot)' -- 'crates/*.rs'returnsmutation_repo.rs:3203;git grep -n 'SET reverted_by' -- 'crates/*.rs'returnsmutation_repo/quality.rs:652. - Confidence ranks nothing.
sed -n 3448,3694p crates/alexandria-mcp/src/server.rs | grep -c -w confidencereturns 0, where the same range holdssimilaritytwice;git grep -n -w confidence -- crates/alexandria-engine/src/recall crates/alexandria-engine/src/search.rsreturns nothing, and the same overcrates/alexandria-engine/src/dreaming/appraise.rsreturns 7 lines. - No approve verb for the agent.
git grep -n -c -E '#\[tool\(' -- crates/alexandria-mcp/srcreturns 17, all inserver.rs;git grep -n -i -E 'async fn (approve|decide|apply|promote|resolve_proposal)' -- crates/alexandria-mcp/src/server.rsreturns nothing. - Hermes extraction has no product caller.
git grep -n -E 'run_extraction' -- contrib/hermesreturns the definition atcontrib/hermes/alexandria/extraction.py:135and test files only. - No paper.
CITATION.cffis absent;git grep -n -i -E 'arxiv|doi\.org|bibtex' -- . ':!*.lock' ':!*package-lock.json' ':!crates/alexandria-mcp/assets'returns nothing.
History
2026-12-03 — 074b8fa0….
First reading, from the 2026-12-03 triage shortlist, at the head of
main reached on 2026-12-03; the shortlist had assessed
8af3bdf1ce82, which the depth-1 clone does not hold.
Screened: one auto-run surface (a committed
.githooks/pre-commit, inert unless
core.hooksPath points there); no build-time execution
point; nothing inside the cooldown; one floating surface
(contrib/pi/extensions/alexandria/package.json, four caret
ranges with a lockfile beside it); AGENTS.md and
CLAUDE.md read as data. Nothing was installed, built or
run, and none of the 1,453 Rust tests was run. Four marks (section 9).