Aemon/ documentation source ↗
On this page

#Schema and SQL Access

The schema is not embedded in the binary: it lives in numbered files under migrations/, applied in order by a pragma user_version runner. Adding a column means adding migrations/0002_*.sql, never editing shipped SQL.

-- migrations/0001_init.sql
docs(id, name unique, library, version, release, kind, source, ingested_at)
pages(id, doc_id, path, title, kind)
entries(id, doc_id, page_id, title, kind, path, ord, body, summary)
entries_fts  -- FTS5 external content over entries(body, title, kind), porter unicode61
rerank_cache, expand_cache, enrich_state, prune_state

kind is page for body chunks and symbol:<Builtin|Function|Guide|Parameter|Variable| Word|...> for searchIndex rows. title is the heading the chunk sits under, so results read like Getting Started, not like a filename.

docs carries the provenance fields (library, version, release, source) plus license and attribution, which aemon sources reads back out.

#Querying directly

-- top matches with highlighted snippets
select d.name, e.title, snippet(entries_fts, 0, '[', ']', '…', 20)
  from entries_fts join entries e on e.id = entries_fts.rowid
  join docs d on d.id = e.doc_id
 where entries_fts match 'borrow checker' limit 5;

-- every chunk of one page, in document order
select ord, title, body from entries where path = 'std/borrowck.html' order by ord;

-- the symbol index only
select title, path from entries where kind like 'symbol:%' and title = 'sort_by';

Search ranks with bm25(entries_fts, 1.0, 5.0, 1.0) — body weight 1, title weight 5 — and retries with OR when the strict AND query returns nothing. Full syntax is FTS5's; entries_fts is an external-content table, so insert/delete go through entries.

Read-only access is safe while a query is running: aemon serve opens workers read-only, and sqlite3 "file:$HOME/.local/share/aemon/aemon.db?mode=ro" works too. Corpus mutations go through the CLI, which owns migrations.

#Maintenance

aemon compact --dedupe --vacuum    # junk/dup clean-up + FTS rebuild
aemon audit                        # corpus shape
aemon stats --json                 # per-corpus counts and freshness

compact --vacuum rewrites the file and needs free disk equal to the database size.