feat: ingest BookOrbit highlights as chapter entries (#47)
build / image (push) Successful in 40s
build / test (push) Successful in 3m42s

The index had no trace of anything I have read: BookOrbit holds 234
annotations across 511 books and none of it reached knox, so recall about books
was empty.

Entries are chapters, not highlights. A book produces a handful of dense,
readable entries instead of hundreds of fragments, which is what a reader
actually asks for ("what did I highlight in this chapter").

Uses the annotations export endpoint rather than the Postgres schema: it is the
contract BookOrbit maintains, and it already carries book, chapter, note, style
and origin. Login is one POST per sweep (the endpoint is throttled at 3/min).

Fingerprint is (book, chapter); the content hash is the rendered body, so a new
highlight updates the entry and appends a log version rather than creating a
second copy of the chapter. The watcher deliberately has no mtime-style skip:
a highlight edited in place keeps the same latest timestamp, and skipping on
that would hide the edit.

Wired as 'knox bookorbit', into the full 'knox ingest' sweep, and a 30-minute
ticker inside LocalSourcesEnabled (the server node replicates only).
This commit is contained in:
2026-11-08 11:55:41 -08:00
parent 499cd2be5d
commit fc9454832f
7 changed files with 647 additions and 9 deletions
+18 -2
View File
@@ -1,8 +1,9 @@
# knox
Knowledge index and long-term memory for agents: it ingests opencode sessions,
logs, git/Gitea activity, browser history, Obsidian notes and Karakeep
bookmarks into a SQLite index with FTS5 search, and exposes it over MCP.
logs, git/Gitea activity, browser history, Obsidian notes, Karakeep bookmarks
and BookOrbit reading highlights into a SQLite index with FTS5 search, and
exposes it over MCP.
Materialized state is derived from an append-only observation log, so nodes
converge by exchanging that log and reconciling — no consensus, no shared
@@ -39,6 +40,21 @@ DNS name: a self-signed certificate and a shared bearer token are enough.
Ports: `8931` gossip/REST, `8932` metrics, `8930` MCP HTTP.
### Reading sources
Both are pull-only and read their configuration from the environment (the
systemd unit loads them from `~/.config/knox/*.env`):
| Source | Variables | What becomes an entry |
|---|---|---|
| Karakeep | `KARAKEEP_URL`, `KARAKEEP_API_KEY` | one entry per bookmark, with its crawled page text |
| BookOrbit | `BOOKORBIT_URL`, `BOOKORBIT_USERNAME`, `BOOKORBIT_PASSWORD` | one entry per book chapter, with its highlights and notes |
BookOrbit entries fingerprint by book and chapter and hash their rendered body,
so a new highlight updates the chapter and appends a log version instead of
creating a second entry. `knox bookorbit` forces a sweep; the watcher runs one
every 30 minutes on nodes with local sources enabled.
Seeding a new replica: start it empty and pull, rather than copying `index.db` —
a copied database carries the origin's `node_id`, which breaks ownership and
echo suppression.