Memnest
Run it

Ingestion and extraction

How raw conversations become atomic facts, and what gets rejected.

add() returns as soon as the text is indexed, so your app never waits on a model. A job then turns the document into facts:

  1. load groupevery version of this session
  2. wait for quiet30s idle, capped at 10 min
  3. extractone completion per window
  4. screendeterministic checks
  5. resolveone call per candidate, no lock held
  6. writere-validated, one transaction

Modes

ModeWhen it runsUse for
batched (default)Once the session has been quiet for 30 secondsReal conversations
instantImmediatelyTests and demos
noneNeverDocuments you only want searchable as text

Why batched is the default. A single chat message rarely holds a durable fact; a session does. Extracting per message produces fragments like "He moved there in March" that depend on context the memory will never be shown with. Documents sharing a customId form one session, extracted once over the newest version. If the session keeps growing, only the new part is extracted, with the processed tail passed along so references still resolve.

What gets rejected

The prompt asks for self-contained, one-topic, non-trivial, secret-free candidates. Deterministic checks then enforce that regardless of what the model returns:

ReasonExample
unresolved-pronoun"She never picks up the phone." Who is she? A memory is shown without its conversation.
secretAnything the redactor catches: API keys, tokens, passwords.
low-confidenceBelow 0.5. Small talk and guesses.
already-expiredAn expiry in the past.
duplicate-in-batchThe same fact twice in one run.
malformed, empty, too-longOutput that does not fit the schema.

Every rejection is recorded, redacted, on the run. Nothing is silently dropped.

Reading a run

memnest ingest session.json --container user:123 --custom-id session-1   # .json turns, .md or .txt
memnest worker                     # or: memnest jobs run — process what is due, then exit
memnest runs --container user:123

A run lists every decision with how it was reached: no-neighbors and exact cost no model call, model is a resolution call, fallback means the model's answer was invalid twice and the fact was written as new, and conflict means the target was forgotten or superseded between planning and writing, so the fact was written as new instead. The live preview shows a real run.

Jobs

One queue implementation runs over pluggable storage: in memory, the SQLite memnest_jobs table, or Postgres. It handles attempts, exponential backoff, leases (a crashed worker's job is taken over) and deferral that does not spend attempts.

memnest jobs --container user:123 --status failed
memnest jobs retry <jobId> --container user:123

A failed extraction never loses the document: its chunks stay searchable, and the job can be requeued. Supply your own queue (BullMQ, say) through the JobQueue port.

Contextual chunks

Chunks are embedded when the document is added. When the extraction job runs, one extra completion writes a one-sentence summary of the newest version, and the chunks are re-embedded with that summary in front, so a chunk that says "we moved it last week" still retrieves for "Acme database migration". This is best-effort: if it fails, the reason is recorded and extraction continues.