How it works
Indexing, search, the index files, credentials and limits, in detail.
View source on GitHubiglo.memory docs 2 of 2
On this page
This is the detailed reference behind the README. The reasons for these choices are in design decisions. Retrieval internals and provider limits are in the retrieval design and provider contracts.
Command contract
Run commands from anywhere inside the target Git worktree. A missing Git
executable does not prevent worktree discovery. Every command writes one JSON
object to stdout. Prompts and progress use stderr. Errors are JSON objects of
the form {"error":{"code","message"}}, plus stage and reason for provider
failures, and exit with status 1. Error messages never include arbitrary
exception text, provider bodies, source text or keys.
init creates .agent/memory.json (only if it is absent) and the
.agent/knowledge, .agent/decisions, .agent/inbox and .agent/memory-index
directories. It preserves existing configuration and Markdown. It does not call
OpenRouter or build an index.
Sources
Only .agent/knowledge/**/*.md and .agent/decisions/**/*.md are indexed.
.agent/inbox (unverified notes), the index itself and entries named .git,
node_modules, dist, build, .env or .env.* are excluded. Source symlinks
are rejected. Unreadable files and invalid UTF-8 fail preparation with
SOURCE_INVALID. Markdown is never modified.
Every file uses the same Markdown heading, paragraph and code-block processing. Line endings are normalized for indexing. Complete blocks are grouped toward a soft target of 500 Qwen body tokens, so results stay focused. Embedding inputs carry the project name, source path and heading ancestry as context. There is no local file length rejection or truncation. An oversized block is split at source boundaries without dropping text. Provider input limits still apply: if a provider rejects an input, preparation fails and the prior snapshot remains available.
Prepare
prepare scans the sources, builds the keyword (BM25) statistics and embeds
missing or changed passages through OpenRouter. With the default Qwen model a
request holds at most 32 inputs and 32,768 input tokens. Unchanged valid vectors
are reused, so an unchanged rerun embeds nothing.
The published snapshot lives at .agent/memory-index/snapshot.json, with one
binary float32 vector file per embedding in .agent/memory-index/vectors/.
Vectors and receipts are written first; replacing the snapshot is the single
publication step. A failed preparation does not publish partial results and
leaves the previous snapshot searchable. Compatible, valid vectors left over
from a failed preparation (“orphans”) can be reused by the next run.
Embedding requests retry temporary network failures, HTTP 429 and 5xx. They
honor Retry-After and are bounded to four attempts and a two-minute budget per
request. Permanent errors do not retry.
Output: project, preparedAt, documents, chunks, reusedVectors and
embeddedVectors.
Search
search reads prepared data only. It does not read Markdown, check freshness,
refresh or repair the index. Results describe the content as it was prepared
and can be stale. Search keeps working after source files are removed or made
unreadable.
For a non-empty snapshot, search:
- embeds the original question and scores it against the prepared vectors and BM25 statistics;
- asks a query-expansion model for up to two keyword variants, two rephrasings and one short hypothetical passage, and searches with those too;
- fuses all lists with reciprocal-rank fusion (constant 60, original lists weighted twice) into at most 40 candidates;
- sends the original question and those complete candidate passages to the
voyageai/rerank-2.5reranker, and keeps up to eight passages above a fixed score cutoff.
Any provider failure, invalid provider output or timeout is an error. There is no partial result and no keyword-only fallback. One 30-second deadline covers lock wait, loading, all provider calls and output. Each provider attempt is limited to ten seconds and the remaining time; transient failures get at most one retry. An empty snapshot returns no results without a key or network.
Each result has score (the ordinal rank 1, 0.5, 0.333333…, not a
probability), passageId, source, heading, startLine, endLine, a
snippet of at most 400 Unicode code points and a snippetSpan. The snippet is
the window of the passage that best matches the question’s terms; … marks
text cut before or after it. snippetSpan gives the snippet’s code-point
offsets in the source and its start and end line and column. The response also
carries query, preparedAt, responseVersion, scoreKind and
retrievalRevision.
Status and gc
status reports the project, preparedAt, document, chunk and vector counts,
missingVectors, the snapshot schemaVersion, the keyword (lexicalProfile)
and embedding (profile) identities. It does not read sources or call
OpenRouter. Corrupt data that is present is an error.
gc removes recognized index files that the current snapshot does not
reference. It requires valid metadata and all referenced vectors before deleting
anything. It decides from the published snapshot, not from current Markdown.
Freshness, worktrees and locking
Run prepare after edits, or when a new worktree needs a fresh snapshot. A
valid committed snapshot can also be searched as-is. Each worktree has its own
index; sibling worktrees are not combined. If you commit the index, budget for
its size: with the default model, each passage’s vector takes about 16 KiB.
Preparation, snapshot loading, status and gc take an exclusive OS lock on
the worktree directory and wait up to five seconds for it before failing with
INDEX_BUSY. prepare holds the lock while it embeds, so a long preparation
can make a concurrent search fail with INDEX_BUSY. Search releases the lock
after loading, before its provider calls. A stopped process releases its lock
through the OS.
Configuration
init writes:
{
"project": "your-repository",
"embedding": { "model": "qwen/qwen3-embedding-8b" }
}
project defaults to the worktree directory name. Only the OpenRouter embedding
model is configurable; the endpoint and source roots are fixed. The default Qwen
profile has 4096 dimensions. Explicitly configured OpenAI embedding models keep
their known token-counting profile; other models use one-input requests and a
conservative size policy (see provider contracts).
Changing the model, the project name or the chunking rules makes the existing
snapshot incompatible (INDEX_INCOMPATIBLE) until prepare runs again.
Rotating the key does not require re-embedding.
The file also accepts an optional retrieval.model, but only its default
voyageai/rerank-2.5 works; leave it unset (see
roadmap item U12).
Credentials
Run iglo.memory init in a terminal. If no key is available, it asks for an
OpenRouter key with input hidden and saves it to
~/.config/iglo.memory/credentials.json. Create a key at
https://openrouter.ai/settings/keys.
This is one plaintext file shared by your repositories and worktrees. The
directory is 0700 and the file 0600, private to your OS user. The key is never
copied into the repository. Cancellation or a failed save preserves the previous
key. init does not test the key against OpenRouter.
OPENROUTER_API_KEY overrides the saved key without changing it.
iglo.memory init --reset-credentials replaces the saved key interactively. It
checks the existing ~/.config/iglo.memory folder and file before prompting,
so it does not repair them: if they have unsafe permissions
(CREDENTIALS_INVALID), run
chmod 700 ~/.config/iglo.memory && chmod 600 ~/.config/iglo.memory/credentials.json,
or delete a damaged file and run init again. The tool trusts other processes
running as your OS user; it is not a secret vault. Keep your home and
credentials directory outside Git repositories.
prepare and search never prompt. They need a key only when making a provider
request, so an empty prepared snapshot can be searched without a key or network.
Moving a key saved by iglo.mem
The CLI was renamed from iglo.mem. When
~/.config/iglo.memory/credentials.json is absent, the key saved at
~/.config/iglo.mem/credentials.json is still read, with the same ownership,
permission, link and repository checks. It is never written or copied. The new
file wins when both exist, and init names the file in use. To move the key,
run iglo.memory init --reset-credentials, then delete the old file. To move it
by hand, keep the new directory 0700 (a plain mkdir is usually 0755 and
fails):
install -d -m 700 ~/.config/iglo.memory
mv ~/.config/iglo.mem/credentials.json ~/.config/iglo.memory/
chmod 600 ~/.config/iglo.memory/credentials.json
What providers receive
OpenRouter and the provider serving each model receive:
| Command | Model | Data |
|---|---|---|
prepare |
embedding model (qwen/qwen3-embedding-8b) |
new or changed passages, each with project name, path and headings |
search |
embedding model | the question, plus the generated rephrasings and hypothetical passage |
search |
expansion model (openai/gpt-5.6-luna) |
the question |
search |
reranker (voyageai/rerank-2.5) |
the question and up to 40 complete candidate passages with their context |
Do not put secrets in the indexed Markdown. init, status and gc make no
network requests.
Keeping the index fresh
The tool does not install schedules, hooks, watchers or background services. For cron, configure your own working directory and use the saved key:
0 * * * * cd /absolute/path/to/worktree && /absolute/path/to/iglo.memory prepare