memwal.remember(...), your data goes through several steps before it’s stored. Here’s what happens.
Storing a memory
Embedding
The relayer generates a vector embedding from your plaintext content. This embedding is a numerical representation of the meaning of your memory — it’s what makes semantic search possible during recall.Encryption
The plaintext content is encrypted using SEAL (Sui’s encryption framework). The encrypted payload can only be decrypted by the owner or their authorized delegates.Blob upload
The encrypted payload is uploaded to Walrus as a blob. Metadata including the namespace is attached so the blob can be discovered later during restore. Walrus stores it durably across a decentralized network — there’s no single point of failure.Vector indexing
The vector embedding (1536-dimensional, generated bytext-embedding-3-small), along with the blob ID, owner address, and namespace, is stored in the vector_entries table in PostgreSQL with pgvector. An HNSW index on the embedding column enables fast approximate nearest neighbor search during recall.Recalling a memory
- Your query is converted into a vector embedding
- The database is searched for the closest matching vectors using pgvector’s cosine distance operator (
<=>), scoped to your memory space (owner + namespace) - Matching encrypted blobs are downloaded from Walrus concurrently
- Each blob is decrypted via SEAL using the delegate key
- Plaintext results are returned to your app, sorted by distance (most relevant first)
If a blob has expired on Walrus (returns 404), the relayer automatically deletes the stale vector entry from the database. This reactive cleanup keeps your recall results clean without manual intervention.
Restoring a memory space
If the local database is lost or incomplete, the restore flow rebuilds it from Walrus — the permanent source of truth.- The relayer queries on-chain Walrus blob objects owned by the user, filtered by namespace metadata
- It compares against the local database to find which blobs are already indexed
- Only missing blobs are downloaded, decrypted, re-embedded, and re-indexed
- The restore supports a configurable
limit(default: 50) to control how many blobs are processed per call
Two layers, one system
| Layer | Stores | Purpose |
|---|---|---|
| Walrus | Encrypted blobs | Durable, decentralized source of truth |
| PostgreSQL + pgvector | Vector embeddings + metadata | Fast semantic search for recall |