Indexes and trail search: indexes only nominate, answers come from files
Questions take the cheapest route first, and federated search is used only when the trail breaks. Every index can be deleted and rebuilt; SQLite is used only on the side.
The previous two posts covered how files are written and what the AI reads first when a session opens. This one is about finding: when a question comes in, where the AI looks and in what order; how an index helps when the trail breaks; and where SQLite is actually used in this system.
Conclusion first
- Trail first: take the cheapest route first: opening summary → project register → progress log → files. Use global search only when the trail breaks.
- Indexes only nominate: search gives candidate locations that “may be here”; the answer always comes from opening the file.
- One entry point, results listed separately: one query searches all ten sources, but results are listed by source rather than forced into a single overall ranking.
- A test set: a fixed 30-question test; 12 correct the first time, 23 now. Scores are not tuned to fit the test.
- SQLite is used only on the side: it holds no source of truth, so deleting it loses no records.
1. The order of trail search

- Already in view: the opening summary has already named this project, so look there directly.
- Follow the register: one register row → latest progress log → the file the log names. Three steps get there, with no search needed.
- Check the lookup table: if the question is about how to do something rather than a fact, check the routing table or skill dictionary and read the manual it points to.
- Trail breaks: run one federated search, get candidate locations, then open the files and read the answer.
- Last resort: full-text search, or go back through the saved raw conversation files.
Most questions end in the first two steps. This is why the first two posts spent so much effort on “one matter, one home” and “the register holds only pointers”: when the trail is clear, there is little need to search.
2. Federated search
Step four uses a single “federated search” entry point: the same question is sent at once to ten existing sources, each ranking its own results.
| Source | Contents |
|---|---|
| Memory | long-term memory cards for each folder |
| Lessons | 216 lesson cards |
| Manuals | operating manuals and rules |
| Projects | project register and progress logs |
| Places | what each folder is for |
| Conversation summaries | 1,323 summary cards generated from the raw conversation files |
| Outputs | slides, web pages and documents I have made |
| Candidates | the candidate shelf of the asset library |
| Card index, relation graph | ranked by the two other tools themselves |
A few deliberate choices:
- Only the Python standard library: no separate database or vector store, and no network access. Ranking uses the common BM25 keyword scoring, with titles weighted higher than body text.
- Results are listed by source. The ten sources hold very different content, and mixing their scores into one overall ranking would actually mislead; listing them separately lets the AI judge which block is most relevant.
- Only locations. Each candidate comes with its file location; the AI has to open the file and read it, and may not answer straight from the search results.
3. Test set
To find out whether retrieval actually works, I wrote a fixed test set: 34 questions of the form “I remember handling this before, but forgot where,” 30 of which can be graded automatically.
- First run: 12 correct out of 29.
- Later I kept adding the sources I had missed and fixing problems in the retrieval itself: 23 correct out of 30, which is the current baseline.
- Rule: do not tune scores to fit the test. Score changes may only come from real improvement, never from tweaks aimed at specific questions.
The 7 misses are mostly down to wording: a question in Chinese while the note is in English, or one thing with two names. This is exactly where keyword search falls short and semantic search should help.
There is also a warning mechanism: if a question is answered correctly but was found in only one source and only in the last two places, it is marked “narrow hit.” Questions like this tend to slip after the next change.
4. Every index can be rebuilt

| Index | Computed from | Current status |
|---|---|---|
| Card index | the small card at the top of each file | 959 cards from 17 sources, stored as JSON |
| Relation graph | references and links between files (about 12,800 nodes, 35,800 edges) | Stale; queries are refused |
| Master directory files | the lesson card directory, the master memory directory, and so on | Generated automatically, never edited by hand |
| Vector index | conversation summary cards | Updates paused (see the next section) |
There are only two rules: when an index conflicts with a file, the file wins; a stale index must say it is stale and may not answer with old data.
5. Where SQLite is actually used
The title says “even a little SQLite.” In practice, it looks like this:
- Vector index for conversation summaries: an open-source conversation memory tool built on SQLite with a vector extension. The embedding model runs locally and automatically picks a larger or smaller model depending on available memory. The index was last built on July 19, 2026; after that I decided to pause updates until it is hooked into federated search.
- Full-text index for research data: another project uses SQLite’s built-in full-text search (FTS5 with trigram tokenization, so mixed Chinese and English queries work), kept separate from this memory system.
- A read-only audit tool: it reads databases left behind by other programs and never writes to them.
In other words, SQLite never holds the source of truth here. Its appeal is that it is a single file, needs no server, and can be deleted and rebuilt, so if you were building a small system from scratch, SQLite’s full-text index would actually be a good first index. I only hold off on making it the main tool because the files already have routing.
Limits of this layer
- Search only matches literal text: mixing Chinese and English and synonyms are the biggest gap, and that is mostly why 7 of the 30 questions were missed.
- The relation graph and the vector index are both stale. The system says “stale,” but for now those two paths amount to nothing.
- Results are listed by source, so the AI has to judge which block is most relevant; when there are many candidates, the AI has more to read.
Next: Slide version: walk through this whole memory system at once
Sources
- episodic-memory (conversation memory tool, MIT license) (Open-source tool for the vector index)
- SQLite FTS5 Extension (Built-in SQLite full-text search, with trigram tokenization)
← Previous:Routing layer: what AI reads at the start, and what it reads only when it hits something
Next:Slide version: the whole AI memory system at a glance →
Email subscriptions will open later. For now, you can follow new articles and work with RSS.