Engineering

11 min read

Notes on a small sync engine

What I learned building Quire: logical clocks, why deletes are the hard part, and the test that pulls the network cable every night.

I set out to build a note app and ended up building a sync engine. These are my notes from the two years in between, mostly things I got wrong.

Start with the log

Every edit is an operation with an id and a place in a logical order. The document is what you get when you replay the log. Once I believed that, half of my bugs disappeared.

Deletes are the hard part

Adding text is easy to merge. Removing it is not, because a device that was offline may edit text another device has already removed. Quire keeps a marker where the text was and cleans up only when every device has seen it.

The cable test

A script starts two clients, makes random edits and cuts the network at random moments for eight hours. If the two documents differ in the morning, I have work to do. In two years it has found eleven real bugs.

Written by

Iri Halvorsen, software engineer in Bergen

mail iri

Found a bug in my thinking? Tell me.

$ subscribe --notes

New notes by email, when there are any. About one a month.

Iri Halvorsen

Software engineer

Bergen, Norway

Open to work from January 2027

Colophon

Set in Geist and Geist Mono

Built in Framer

No tracking, no cookie banner

buildlog_

© 2026 Iri Halvorsen. All demo work is fictional.

exit 0

Create a free website with Framer, the website builder loved by startups, designers and agencies.