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:
- load groupevery version of this session
- wait for quiet30s idle, capped at 10 min
- extractone completion per window
- screendeterministic checks
- resolveone call per candidate, no lock held
- writere-validated, one transaction
Modes
| Mode | When it runs | Use for |
|---|---|---|
batched (default) | Once the session has been quiet for 30 seconds | Real conversations |
instant | Immediately | Tests and demos |
none | Never | Documents 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:
| Reason | Example |
|---|---|
unresolved-pronoun | "She never picks up the phone." Who is she? A memory is shown without its conversation. |
secret | Anything the redactor catches: API keys, tokens, passwords. |
low-confidence | Below 0.5. Small talk and guesses. |
already-expired | An expiry in the past. |
duplicate-in-batch | The same fact twice in one run. |
malformed, empty, too-long | Output 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.