Highlights that vanish when a reader switches devices. Bookmarks that point at the wrong paragraph. Last-read position that jumps backward every time a book reopens. These are not edge cases — they are the default outcome when annotation systems are built without understanding how EPUB actually anchors text.
EPUB CFI & Annotation Sync is a production handbook for engineers building reading apps, annotation platforms, and ebook stores. It covers the EPUB Canonical Fragment Identifier from the ground up: what it is, how it resolves, why it breaks, and how to build systems that survive real-world reflow, DOM mutation, and multi-device sync.
Inside:
The full CFI grammar — steps, assertions, offsets, indirection, and ranges
Generation and resolution algorithms with working code
Stability analysis: what actually invalidates a CFI (and what doesn't)
Highlights, bookmarks, and last-read position as production data models
Cross-device sync using G-Set CRDTs and LWW-Registers
Offline-first architecture with outbox queues and backoff
Conflict resolution policies that match user expectations
Storage, indexing, and query patterns that scale to 100M annotations
Testing strategies: round-trip, property-based, and chaos
A full case study of a production annotation service
Written for engineers who already ship software and need the real tradeoffs, not a tutorial. Every chapter ends with a production checklist. Every claim is grounded in the EPUB 3.3 specification or explicitly flagged where the spec is silent.
If your reader loses annotations, this book is why — and how to fix it.