feat: ingest BookOrbit annotations as chapter entries #47

Closed
opened 2026-11-08 19:52:09 +00:00 by david · 1 comment
Owner

BookOrbit (books.notsosm.art, v3.6.0) holds 234 annotations across 511 books. None of it is visible to knox, so recall about books I have actually read is empty.

Source

The export endpoint is the contract to use; the Postgres schema is not.

  • POST /api/v1/auth/login with {username, password} → accessToken (15 min TTL, login throttled to 3/min)
  • GET /api/v1/annotations/export?format=json → the whole hub, no pagination cap (server-side findHubAll)
  • Row shape: id, bookId, bookTitle, chapterTitle, text, note, color, style, origin, page, cfi, xpointer, highlightedAt, createdAt

Design (agreed)

  • New ingester internal/ingest/bookorbit.go, SourceID: "bookorbit".
  • Credentials from ~/.config/knox/bookorbit.env (0600), loaded like karakeep.env.
  • One observation per book+chapter, not per highlight: dense, readable, and enough for recall. Rows without a chapter bucket at book level.
  • Render Markdown: blockquote + Note: + <sub>origin, date</sub>, mirroring BookOrbit's own export.
  • Fingerprint sha256("bookorbit:<bookId>:<chapter>"), with an ordinal when a book repeats a chapter title.
  • ContentHash over the rendered body: a new highlight updates the entry and appends a log version instead of duplicating it.
  • CreatedAt = latest highlight in the chapter; Project = author; provenance carries book_id, chapter, annotation_ids.
  • 30-minute ticker inside the LocalSourcesEnabled() path (the server node runs KNOX_LOCAL_SOURCES=none and must stay a pure replica).

Verification

  • httptest covering login + export, grouping, fingerprint stability, content-hash change when a highlight is added, and 401 surfacing as an error.
  • Live run: entry count equals distinct book+chapter pairs, not 234.
  • knox_count shows the bookorbit source and a known highlight is findable via knox_search.

Out of scope

Auto-thread per book (blocked behind #42's non-deterministic threader).

BookOrbit (books.notsosm.art, v3.6.0) holds **234 annotations across 511 books**. None of it is visible to knox, so recall about books I have actually read is empty. ## Source The export endpoint is the contract to use; the Postgres schema is not. - `POST /api/v1/auth/login` with `{username, password}` → `accessToken` (15 min TTL, login throttled to 3/min) - `GET /api/v1/annotations/export?format=json` → the whole hub, no pagination cap (server-side `findHubAll`) - Row shape: `id, bookId, bookTitle, chapterTitle, text, note, color, style, origin, page, cfi, xpointer, highlightedAt, createdAt` ## Design (agreed) - New ingester `internal/ingest/bookorbit.go`, `SourceID: "bookorbit"`. - Credentials from `~/.config/knox/bookorbit.env` (0600), loaded like `karakeep.env`. - **One observation per book+chapter**, not per highlight: dense, readable, and enough for recall. Rows without a chapter bucket at book level. - Render Markdown: blockquote + `Note:` + `<sub>origin, date</sub>`, mirroring BookOrbit's own export. - Fingerprint `sha256("bookorbit:<bookId>:<chapter>")`, with an ordinal when a book repeats a chapter title. - `ContentHash` over the rendered body: a new highlight updates the entry and appends a log version instead of duplicating it. - `CreatedAt` = latest highlight in the chapter; `Project` = author; provenance carries `book_id`, `chapter`, `annotation_ids`. - 30-minute ticker inside the `LocalSourcesEnabled()` path (the server node runs `KNOX_LOCAL_SOURCES=none` and must stay a pure replica). ## Verification - `httptest` covering login + export, grouping, fingerprint stability, content-hash change when a highlight is added, and 401 surfacing as an error. - Live run: entry count equals distinct book+chapter pairs, not 234. - `knox_count` shows the `bookorbit` source and a known highlight is findable via `knox_search`. ## Out of scope Auto-thread per book (blocked behind #42's non-deterministic threader).
david closed this issue 2026-11-08 19:55:57 +00:00
Author
Owner

Live verification done after the credentials landed.

  • First sweep: 18 chapter entries, 18 new — matching the 7 books / 18 chapter buckets in the source.
  • Second sweep: 0 new, and (after #51) no new observation rows — 36 → 36. Before #51 it appended 18 duplicates per sweep because of the byte/character dedupe bug.
  • Content sizes 125 B – 10.5 KB, average 3.2 KB: chapter granularity is not producing an unreadable blob.
  • Search works end to end: knox_count "Repeat Room" reports 2 bookorbit hits, and knox_search returns the chapter titles.

Watcher restarted on the new binary; the 30-minute tick now runs with the fix.

Live verification done after the credentials landed. - First sweep: **18 chapter entries, 18 new** — matching the 7 books / 18 chapter buckets in the source. - Second sweep: 0 new, and (after #51) **no new observation rows** — 36 → 36. Before #51 it appended 18 duplicates per sweep because of the byte/character dedupe bug. - Content sizes 125 B – 10.5 KB, average 3.2 KB: chapter granularity is not producing an unreadable blob. - Search works end to end: `knox_count "Repeat Room"` reports 2 `bookorbit` hits, and `knox_search` returns the chapter titles. Watcher restarted on the new binary; the 30-minute tick now runs with the fix.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#47