Books (v0.1.0): formats, positions, library, import, export #1

Closed
mnovak wants to merge 0 commits from feature/books into main
Owner

Day 1 (v0.1.0) of Liber's public core: liber-format and liber-library.

What

  • liber-format: EPUB 2/3, FB2 (+ .fb2.zip), TXT (Windows-1250 detection), DRM-free MOBI 6 / AZW3 into one Document; own zip reader/writer with hard caps; whitelist sanitizer; CFI points + text-quote anchors (Exact / Approximate / Lost); DRM detection (ADEPT, LCP, FairPlay, non-font encryption.xml, MOBI encryption, KFX, Topaz) refused with one sentence; text fingerprint and ISBN.
  • liber-library: the library as a fold of events in total HLC order (books, possession, loans, reads/re-reads, shelves, ratings, review/notes with both-versions-on-conflict, positions furthest + jump-back, highlights with tombstones, sessions, goals, identity merge by ISBN/fingerprint); stats; Goodreads/StoryGraph CSV import with report; liber-export v1 (JSON, CSV with formula escaping, Markdown highlights, zip with book files).

Tests (59 functions, all green; proptest adds 256 + 200 + 150 generated cases)

  • hostile.rs 14 (mandatory 1): zip slip ×5 names, symlink, ratio bomb (~1000:1), sub-ratio bomb stopped at max_xml, total cap, entry count, XXE / billion laughs / harmless DTD, scripts + handlers + forms + remote URLs, truncated ×4 + flipped byte, malformed OPF, 100k-deep nesting (XML and tag soup), DRM ×8, hostile MOBI ×5
  • positions.rs 9 (mandatory 2, core half): CFI round trip at every offset, re-import exact, across elements, changed edition → approximate at the same words, moved chapter, reworded → lost, ambiguous → lost
  • import.rs 7 (mandatory 3), export.rs 4 (mandatory 4), sync.rs 5 (mandatory 5, core half), stats.rs 1, formats.rs 8, fuzz.rs 1, purity.rs 2, corpus.rs 1, unit 6 + doc 1
  • node scripts/deps.mjs --check: 100 crates, 0 outside the allowed set. cargo clippy --all-targets: 0 warnings.

Self-review (critical)

  • Publisher CSS is dropped entirely. Safe, but centring/small caps are lost; a CSS subset is future work (FORMATS.md §7).
  • HUFF/CDIC is implemented from calibre's algorithm but only exercised by refusal tests, not a real HUFF book. First real-world MOBI from Mark will tell.
  • MOBI/KF8 links (filepos, kindle:pos) are not mapped; text stays, links don't. TOC from headings only.
  • "Network-blocked run" for the core is structural: no fs/net/clock APIs in sources and no network crate in Cargo.lock (purity.rs). The app's tests do the real blocked run.
  • Positions, font/theme half lives in the app (vitest over the same xhtml); here the tree simply has no render inputs.
  • Licence interpretations inherited from Pictor (ISC, Unicode-3.0, BSL/CC0, plus csv's Unlicense-OR-MIT) still await Mark's confirmation; nothing here needs them except Unicode-3.0 (unicode-ident, unicode-normalization).
  • fixtures-fetch/manifest.json is empty: every mandatory fixture is generated in code; no external corpus was pinned yet.
  • The roadmap calls this repo LiberPublic; it is Liber-public on Gitea (code wins, CLAUDE.md says so).
Day 1 (v0.1.0) of Liber's public core: `liber-format` and `liber-library`. ## What - **liber-format**: EPUB 2/3, FB2 (+ .fb2.zip), TXT (Windows-1250 detection), DRM-free MOBI 6 / AZW3 into one `Document`; own zip reader/writer with hard caps; whitelist sanitizer; CFI points + text-quote anchors (`Exact` / `Approximate` / `Lost`); DRM detection (ADEPT, LCP, FairPlay, non-font encryption.xml, MOBI encryption, KFX, Topaz) refused with one sentence; text fingerprint and ISBN. - **liber-library**: the library as a fold of events in total HLC order (books, possession, loans, reads/re-reads, shelves, ratings, review/notes with both-versions-on-conflict, positions furthest + jump-back, highlights with tombstones, sessions, goals, identity merge by ISBN/fingerprint); stats; Goodreads/StoryGraph CSV import with report; `liber-export` v1 (JSON, CSV with formula escaping, Markdown highlights, zip with book files). ## Tests (59 functions, all green; proptest adds 256 + 200 + 150 generated cases) - hostile.rs 14 (mandatory 1): zip slip ×5 names, symlink, ratio bomb (~1000:1), sub-ratio bomb stopped at max_xml, total cap, entry count, XXE / billion laughs / harmless DTD, scripts + handlers + forms + remote URLs, truncated ×4 + flipped byte, malformed OPF, 100k-deep nesting (XML and tag soup), DRM ×8, hostile MOBI ×5 - positions.rs 9 (mandatory 2, core half): CFI round trip at every offset, re-import exact, across elements, changed edition → approximate at the same words, moved chapter, reworded → lost, ambiguous → lost - import.rs 7 (mandatory 3), export.rs 4 (mandatory 4), sync.rs 5 (mandatory 5, core half), stats.rs 1, formats.rs 8, fuzz.rs 1, purity.rs 2, corpus.rs 1, unit 6 + doc 1 - `node scripts/deps.mjs --check`: 100 crates, 0 outside the allowed set. `cargo clippy --all-targets`: 0 warnings. ## Self-review (critical) - **Publisher CSS is dropped entirely.** Safe, but centring/small caps are lost; a CSS subset is future work (FORMATS.md §7). - **HUFF/CDIC** is implemented from calibre's algorithm but only exercised by refusal tests, not a real HUFF book. First real-world MOBI from Mark will tell. - **MOBI/KF8 links** (`filepos`, `kindle:pos`) are not mapped; text stays, links don't. TOC from headings only. - **"Network-blocked run"** for the core is structural: no fs/net/clock APIs in sources and no network crate in Cargo.lock (purity.rs). The app's tests do the real blocked run. - **Positions, font/theme half** lives in the app (vitest over the same xhtml); here the tree simply has no render inputs. - **Licence interpretations** inherited from Pictor (ISC, Unicode-3.0, BSL/CC0, plus `csv`'s Unlicense-OR-MIT) still await Mark's confirmation; nothing here needs them except Unicode-3.0 (`unicode-ident`, `unicode-normalization`). - `fixtures-fetch/manifest.json` is empty: every mandatory fixture is generated in code; no external corpus was pinned yet. - The roadmap calls this repo `LiberPublic`; it is `Liber-public` on Gitea (code wins, CLAUDE.md says so).
mnovak added 2 commits 2026-11-17 01:36:50 +01:00
Author
Owner

Merged with --no-ff as b9462af (main), tagged v0.1.0. Gitea does not detect merges pushed to main here (manual-merge detection is off), so this PR is closed by hand.

Merged with --no-ff as b9462af (main), tagged v0.1.0. Gitea does not detect merges pushed to main here (manual-merge detection is off), so this PR is closed by hand.
mnovak closed this pull request 2026-11-17 01:37:29 +01:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/Liber-public#1