# `library@1`: the books you read, are reading and want to read

Version **1.0.0** · published 2026-11-30 · MIT · boards: reading-log · [changelog](../CHANGELOG.md)

One row of `items` is one **edition** of a book; `work_id` groups the editions of one work. One row of `reads` is one
shelf entry or one read of an item: to read, reading, read, did not finish, paused. Goodreads and StoryGraph exports fill
it today (lane 1, files the person downloads); a hand-written library CSV and progress logged with `dashremix log` too.
Reading Log reads it.

## Conventions
- **Item ids.** The ISBN-13 when the source gives a usable one (an ISBN-10 is converted to its 978 ISBN-13); otherwise
  `t-` + the first 12 hex of sha1(normalised title | normalised main author). `work_id` is `w-` + the same hash, for every
  edition. Normalised: case-folded; accents removed from Latin letters and ø ł ß æ œ đ ð þ spelled o l ss ae oe d d th;
  letters and digits of every script kept (日本語, кириллица, ελληνικά, العربية); a series suffix in brackets (`(Tidewater, #2)`) and an
  edition phrase after a colon (`: A Novel`) dropped, `&` read as `and`, leading `the`/`a`/`an` dropped, punctuation and
  repeated spaces removed. The subtitle is kept, so `Series: First` and `Series: Second` are two works. A title that
  normalises to nothing is never matched by title: its id and work use the source's own key. Both fit the
  shape `dashremix log` accepts, so the item id is the handle for logging progress.
- **ISBNs** are kept only with a valid check digit. A spreadsheet-mangled ISBN (`9.78E+12`, a lost leading zero) is
  repaired only when the check digit proves the repair, otherwise dropped and counted in `data_issues`; the book is then
  matched by title and author. Goodreads writes ISBNs as `="0123456789"` so spreadsheets keep them as text: the wrapper is
  removed.
- **One source per book.** Each item's reads come from one source. When a book is in two exports (matched by ISBN-13,
  then by normalised title + main author when the ISBNs do not contradict, or by the person's own `same_book` decision),
  one source wins the whole book by the board's source order and the other rows are recorded in `source_matches` with
  `kept = 0`. Fields are never merged across sources. Same title and author with **different** ISBNs are two editions:
  both are kept and marked `possible_duplicate` until the person decides (and never
  counted as a reread of each other); so are two rows that share only the title before the colon and the author. If both
  exports give such a pair the same finish date, it is one read recorded twice (`same_read`): one source wins, as for a match.
- **Reads and dates.** A `read` row's `finished` is the day the source says it was finished; NULL means "read, date
  unknown" (counted as read, in no year). Earlier reads a source only counts (Goodreads gives one date and a Read Count)
  are never invented as rows: the count is kept in `source_read_count` on the newest row. `reread_n` counts reads of the
  work from 0 in finished order. A `to_read` row has `date_added` and no read dates; the TBR is the to_read rows.
- **Ratings** are 0.5 to 5 (quarters allowed, as StoryGraph gives them). NULL is not rated: a source's 0 means not rated
  and is stored as NULL, so averages and distributions are right.
- **Units.** Pages are whole pages of that edition. They describe the edition, not the read, so a book whose source has
  no page count takes it from another export's row for the **same ISBN-13**, or from the person's own setting, and
  `pages_source` says which; audiobook length `audio_s` is in seconds; dates `YYYY-MM-DD`; instants
  ISO 8601 UTC with `Z`.
- **Progress** (optional `entries`, the DashRemix write path, same columns as tracker@1): `tracker_id` is the item id,
  `value` the page reached. Append-only; the latest entry counts.
- **Provenance:** `source`, `source_ref`, `imported_at` on items and reads; `imported_at` is left out of `meta.data_hash`.
  Review text is never stored, only `review_words`.
- meta required keys: `schema`, `schema_version`, `as_of`, `data_hash`; recommended (`warn`): `source_built_at`.

## Sources that fill it
| Source | Lane | Fills |
|---|---|---|
| Goodreads library export (`goodreads_library_export.csv`; My Books, Import and export, Export Library; desktop web) | 1 | items (Book Id kept as `source_matches.source_key`; ISBN, ISBN13 with the `="…"` wrapper removed; Number of Pages, Binding, Year Published, Original Publication Year, Publisher), item_authors (Author, Additional Authors), reads (Exclusive Shelf, Date Added, Date Read, My Rating with 0 = unrated, Read Count, Owned Copies, review word count), tags (Bookshelves). **No start dates** in this export. |
| StoryGraph export (Manage Account, Export StoryGraph Library) | 1 | items (ISBN/UID when it is an ISBN, Format), item_authors (Authors, Contributors), reads (Read Status, Date Added, Dates Read with start and end, Last Date Read, Read Count, Star Rating in quarters, Owned?), tags (Tags, Moods). Column names partly UNVERIFIED (see the board's importer) |
| A library CSV (`title,author,isbn13,isbn10,status,date_added,started,finished,rating,pages,format,audio_minutes,shelves,genres`) | 1 | everything above, written by the person or their assistant |
| `dashremix log <board> <item_id> <page>` | 1 | entries |

## Compatibility
- A board that declares `library@1 >=1.0` keeps working on any later 1.x database.
- Remixes that add only metrics, pages and `x_<owner>_` tables survive every minor.
- Breaking changes go to `library@2` with a migration and `metrics-codemod.py` (see `../../README.md`, Semver).
- Planned minors: series (name and number) as columns, reading sessions with minutes, a Hardcover and Libby source.

## Fields

<!-- fields:begin (generated from schema.sql by spec/build.py; edit the DDL comments) -->

### `meta` (required table)

Key/value facts about this database. Required: schema, schema_version, as_of, data_hash. Recommended (checked at warn): source_built_at (ISO 8601 UTC instant the importer wrote it). Boards may add their own keys (dataset, person_name ...).

| Field | Type | Required | Meaning |
|---|---|---|---|
| `key` | TEXT | no |  |
| `value` | TEXT | no |  |

### `items` (required table)

One edition of a book.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `item_id` | TEXT | **yes** | the ISBN-13 (ISBN-10s are converted), else t- + the first 12 hex of sha1(normalised title\|normalised first author), e.g. 9780000000002 or t-3f9a0c2e7b1d |
| `work_id` | TEXT | **yes** | w- + the first 12 hex of sha1(normalised title\|normalised first author): the same for every edition of one work |
| `title` | TEXT | **yes** | the title as the source gives it, series suffix included: The Salt Archive (Tidewater, #2) |
| `authors` | TEXT | no | display list, main author first, comma separated (item_authors has one row each) |
| `isbn13` | TEXT | no | 13 digits with a valid check digit; NULL when the source has none or it was unreadable |
| `isbn10` | TEXT | no | 10 characters (digits, last may be X) with a valid check digit, as the source gave it |
| `pages` | INTEGER | no | page count of this edition (> 0); NULL when unknown |
| `pages_source` | TEXT | no | where pages came from when not this row's source: another export's row for the same ISBN-13 (goodreads-csv ...) or the person's own setting (reading-yaml); NULL = this row's source |
| `format` | TEXT (vocab `formats`) | no | print \| ebook \| audio \| unknown (vocab formats), from the source's binding or format |
| `binding` | TEXT | no | the source's own word: Paperback, Kindle Edition, Audible Audio, hardcover, digital |
| `audio_s` | INTEGER | no | audiobook length in seconds (> 0); NULL when unknown or not audio |
| `year_published` | INTEGER | no | year this edition was published |
| `original_year` | INTEGER | no | year the work was first published |
| `publisher` | TEXT | no | publisher of this edition |
| `source` | TEXT (vocab `sources`) | **yes** | connector that wrote the row: goodreads-csv \| storygraph-csv \| library-csv (vocab sources) |
| `source_ref` | TEXT | no | where in the source: data/files/goodreads_library_export.csv:12 |
| `imported_at` | TEXT (instant) | no | ISO 8601 UTC instant of the import (left out of meta.data_hash) |

### `item_authors`

The people on an item, in the source's order.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `item_id` | TEXT | **yes** | the item |
| `ord` | INTEGER | **yes** | 1 = main author |
| `author` | TEXT | **yes** | the name as the source writes it: Odile Marchetti |
| `role` | TEXT (vocab `author_roles`) | no | author \| translator \| narrator \| editor \| illustrator \| other (vocab author_roles); NULL = author |

### `reads` (required table)

One shelf entry or one read. A to_read row has no dates but date_added; a reading row has started (when known); a read row has finished when the source gives the date (NULL = read, date unknown: counted as read, in no year); dnf and paused rows keep the dates they have. Sources that give only the last read date and a count (Goodreads) write one dated row and keep the count in source_read_count: earlier, undated reads are never invented as rows.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `read_id` | TEXT | **yes** | first 16 hex of sha1(source\|item_id\|n) |
| `item_id` | TEXT | **yes** | the item read |
| `status` | TEXT (vocab `read_statuses`) | **yes** | to_read \| reading \| read \| dnf \| paused (vocab read_statuses) |
| `date_added` | TEXT (date) | no | the day it went on the person's shelves (YYYY-MM-DD) |
| `started` | TEXT (date) | no | the day this read started (YYYY-MM-DD); NULL when the source does not say |
| `finished` | TEXT (date) | no | the day this read ended (read: finished; dnf: stopped) (YYYY-MM-DD) |
| `rating` | REAL | no | the person's rating, 0.5 to 5 (quarters allowed); NULL = not rated (a source's 0 means not rated) |
| `reread_n` | INTEGER | no | 0 = first read of the work, 1 = first reread ...; NULL on to_read rows |
| `source_read_count` | INTEGER | no | the read count the source reports for the item (on its newest row); may exceed the dated read rows |
| `review_words` | INTEGER | no | words in the person's review (the text itself is never stored) |
| `owned` | INTEGER | no | 1 when the source says the person owns a copy |
| `source` | TEXT (vocab `sources`) | **yes** | goodreads-csv \| storygraph-csv \| library-csv (vocab sources) |
| `source_ref` | TEXT | no | file:line of the row it came from |
| `imported_at` | TEXT (instant) | no | ISO 8601 UTC instant of the import (left out of meta.data_hash) |

### `tags`

Shelves, genres, tags and moods on an item.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `item_id` | TEXT | **yes** | the item |
| `kind` | TEXT (vocab `tag_kinds`) | **yes** | shelf \| genre \| tag \| mood (vocab tag_kinds): genre when the person's shelf or tag names a genre |
| `tag` | TEXT | **yes** | lower case as the person wrote it (book-club, adventurous); a genre uses the board's genre name (sci-fi -> science-fiction) |
| `source` | TEXT | no | the connector that wrote it |

### `entries`

Optional: reading progress the person logs (the DashRemix write path: dashremix log, the assistant from chat). Same columns as tracker@1 entries; tracker_id is the item_id, value is the page reached. Append-only: a correction is another entry, and the latest entry counts.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `entry_id` | TEXT | **yes** | the writer's id (16 hex, minted once per log and kept on retry) |
| `tracker_id` | TEXT | **yes** | the item_id of the book |
| `date` | TEXT (date) | **yes** | the person's local date of the reading (YYYY-MM-DD) |
| `value` | REAL | **yes** | the page reached (>= 0) |
| `note` | TEXT | no | one line the person wrote with it |
| `source` | TEXT (vocab `entry_sources`) | no | app \| chat \| cli \| csv \| import (as tracker@1 entries) |
| `created_at` | TEXT (instant) | no | ISO 8601 UTC instant it was logged, with milliseconds |
| `source_ref` | TEXT | no | data/entries/2026-11/cli.jsonl:3 |
| `imported_at` | TEXT (instant) | no | ISO 8601 UTC instant of the import (left out of meta.data_hash) |

### `goals`

Optional: the person's reading goals, one row per year.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `year` | INTEGER | **yes** | calendar year, e.g. 2026 |
| `books` | INTEGER | no | books to finish that year (> 0) |
| `pages` | INTEGER | no | pages to finish that year (> 0) |
| `source_ref` | TEXT | no | where the person set it: data/reading.yaml:goals |

### `source_matches`

Books found in more than one source, and what was done: every source row of such a book has a row here. One source wins each book (kept = 1); the other rows are dropped (kept = 0) and counted. Two editions that only look alike (same title and author, different ISBNs or subtitles) are both kept and marked possible_duplicate until the person decides; when both exports give them the same finish date they are one read in two exports (same_read): one source wins, as for a match.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `match_id` | TEXT | **yes** | first 16 hex of sha1(source\|source_ref) |
| `item_id` | TEXT | **yes** | the item the row belongs to (for a dropped row: the kept item it matched) |
| `source` | TEXT (vocab `sources`) | **yes** | the row's source (vocab sources) |
| `source_ref` | TEXT | **yes** | file:line of the row |
| `source_key` | TEXT | no | the row's own id or ISBN in that source (Goodreads Book Id, StoryGraph ISBN/UID) |
| `method` | TEXT (vocab `match_methods`) | **yes** | isbn \| title_author \| confirmed \| same_read \| possible_duplicate (vocab match_methods) |
| `kept` | INTEGER | **yes** | 1 = this row's source is the book's source; 0 = dropped as a duplicate |
| `other_item_id` | TEXT | no | possible_duplicate: the other edition's item_id |
| `note` | TEXT | no | what was decided, in words |

### `data_issues`

What the importer could not read or decided: rows skipped, ISBNs it could not use, books in two sources.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `issue_id` | TEXT | **yes** | stable id |
| `severity` | TEXT (vocab `severities`) | **yes** | info \| warn \| error (vocab severities) |
| `kind` | TEXT | **yes** | rows_skipped \| isbn_unreadable \| isbn_repaired \| in_two_sources \| possible_duplicate \| undated_reads \| ... |
| `title` | TEXT | **yes** | one line |
| `detail` | TEXT | **yes** | what and where (file:line), never the person's review text |
| `source_ref` | TEXT | no | file, or file:line |
| `handling` | TEXT | **yes** | what the importer did about it |

### `annotations`

Notes on metrics and pages (platform table, as finance@2). Numbers only through {{metric:...}} placeholders.

| Field | Type | Required | Meaning |
|---|---|---|---|
| `annotation_id` | TEXT | **yes** | stable id |
| `target` | TEXT | **yes** | metric id or page id |
| `kind` | TEXT | **yes** | note \| caveat \| flag \| decision \| open_item |
| `body` | TEXT | **yes** | the note text |
| `author` | TEXT | no | person or assistant |
| `source_ref` | TEXT | no | where it came from |
| `created_at` | TEXT | no | ISO 8601 instant |
| `data_hash` | TEXT | no | hash of the cited metric values when written (stale when they change) |
| `status` | TEXT | no | active \| stale \| retired |

### `metric_registry`

| Field | Type | Required | Meaning |
|---|---|---|---|
| `metric_id` | TEXT | **yes** | e.g. reading.goal_pace |
| `version` | INTEGER | no | the metric's own version |
| `unit` | TEXT | no | rows \| pct \| count \| days ... |
| `params` | TEXT | no | comma list of parameters it honours |
| `description` | TEXT | no | the @desc line |
| `sql` | TEXT | no | expanded SQL |
| `test` | TEXT | no | the @test line (check that covers it) |

<!-- fields:end -->

## Vocabularies
- `formats.csv`: print, ebook, audio, unknown, with the source words that map to each (`items.format`).
- `read_statuses.csv`: to_read, reading, read, dnf, paused and the Goodreads and StoryGraph shelf names (`reads.status`).
- `sources.csv`: goodreads-csv, storygraph-csv, library-csv.
- `tag_kinds.csv`: shelf, genre, tag, mood. `author_roles.csv`: author, translator, narrator, editor, illustrator, other.
- `match_methods.csv`: isbn, title_author, same_read, confirmed, possible_duplicate (`source_matches.method`).
- `entry_sources.csv`, `severities.csv`: as tracker@1.
