feat: ingest BookOrbit highlights as chapter entries #50

Merged
david merged 1 commits from feat/bookorbit-ingest into main 2026-11-08 19:55:57 +00:00
Owner

Closes #47.

BookOrbit holds 234 annotations across 511 books; none of it reached knox, so recall about books I have actually read was empty.

Source

The export endpoint, not the Postgres schema — it is the contract BookOrbit maintains, and it already carries everything knox needs.

  • POST /api/v1/auth/login {username,password} → accessToken (15 min, login throttled 3/min, so one login per sweep)
  • GET /api/v1/annotations/export?format=json → the whole hub, no pagination cap (findHubAll server-side)
  • Rows: bookId, bookTitle, chapterTitle, text, note, color, style, origin, highlightedAt

Shape

One observation per book+chapter, not per highlight. A reader asks "what did I highlight in this chapter"; 234 fragments would also crowd search results with near-duplicates from a single book. Rows with no chapter bucket at book level.

Rendering mirrors BookOrbit's own Markdown export: blockquote, Note:, and a <sub>style, color, origin, date</sub> footer.

Dedupe

  • Fingerprint sha256("bookorbit:<bookId>:<chapter>") — stable when the chapter gains highlights.
  • ContentHash over the rendered body — a new or edited highlight updates the chapter and appends a log version instead of duplicating it.
  • No mtime-style skip in the watcher: a highlight edited in place keeps the same latest timestamp, so skipping on that would hide the edit. The content hash is the change signal.

Wiring

  • knox bookorbit for a manual sweep
  • included in the full knox ingest run
  • 30-minute ticker inside LocalSourcesEnabled(), so dhg.lol (KNOX_LOCAL_SOURCES=none) stays a pure replica
  • credentials from ~/.config/knox/bookorbit.env (0600), the existing karakeep.env pattern

Verification

  • go test ./... and go vet green.
  • Unit tests: grouping (2 chapters + 1 book-level), stable fingerprint across identical sweeps, content hash changing when a highlight is added while the fingerprint stays put, login failure surfacing as an error rather than a silent zero, and unconfigured being a no-op.
  • Live contract probe against books.notsosm.art: the login payload shape is accepted (401 "Invalid credentials", not a 400 validation error) and the export endpoint returns 401 without a token.
  • Live ingestion is not verified yet — it needs the credentials file, tracked in #49. That is the remaining step, not a code gap.

Not in scope

Auto-thread per book — that would sit on #42's non-deterministic threader.

Closes #47. BookOrbit holds **234 annotations across 511 books**; none of it reached knox, so recall about books I have actually read was empty. ## Source The **export endpoint**, not the Postgres schema — it is the contract BookOrbit maintains, and it already carries everything knox needs. - `POST /api/v1/auth/login` `{username,password}` → `accessToken` (15 min, login throttled 3/min, so one login per sweep) - `GET /api/v1/annotations/export?format=json` → the whole hub, no pagination cap (`findHubAll` server-side) - Rows: `bookId, bookTitle, chapterTitle, text, note, color, style, origin, highlightedAt` ## Shape **One observation per book+chapter**, not per highlight. A reader asks "what did I highlight in this chapter"; 234 fragments would also crowd search results with near-duplicates from a single book. Rows with no chapter bucket at book level. Rendering mirrors BookOrbit's own Markdown export: blockquote, `Note:`, and a `<sub>style, color, origin, date</sub>` footer. ## Dedupe - Fingerprint `sha256("bookorbit:<bookId>:<chapter>")` — stable when the chapter gains highlights. - `ContentHash` over the **rendered body** — a new or edited highlight updates the chapter and appends a log version instead of duplicating it. - No mtime-style skip in the watcher: a highlight edited in place keeps the same latest timestamp, so skipping on that would hide the edit. The content hash is the change signal. ## Wiring - `knox bookorbit` for a manual sweep - included in the full `knox ingest` run - 30-minute ticker inside `LocalSourcesEnabled()`, so `dhg.lol` (`KNOX_LOCAL_SOURCES=none`) stays a pure replica - credentials from `~/.config/knox/bookorbit.env` (0600), the existing `karakeep.env` pattern ## Verification - `go test ./...` and `go vet` green. - Unit tests: grouping (2 chapters + 1 book-level), stable fingerprint across identical sweeps, content hash changing when a highlight is added while the fingerprint stays put, login failure surfacing as an error rather than a silent zero, and unconfigured being a no-op. - Live contract probe against books.notsosm.art: the login payload shape is accepted (401 "Invalid credentials", not a 400 validation error) and the export endpoint returns 401 without a token. - **Live ingestion is not verified yet** — it needs the credentials file, tracked in #49. That is the remaining step, not a code gap. ## Not in scope Auto-thread per book — that would sit on #42's non-deterministic threader.
david added 1 commit 2026-11-08 19:55:52 +00:00
feat: ingest BookOrbit highlights as chapter entries (#47)
build / image (push) Successful in 40s
build / test (push) Successful in 3m42s
fc9454832f
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).
david merged commit 83604d8f8a into main 2026-11-08 19:55:57 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#50