← ALL POSTS
December 3, 2026 · 7 min read

Offline-First Sync: Record Conflicts, Don't Resolve Them

Offline-first sync for field data isn't a merge problem: use append-only events, keep three clocks, and treat every conflict as evidence.

engineeringarchitecture

Every guide to offline-first sync tells you how to resolve conflicts. For field data, I think that's the wrong goal — and the problem isn't going away.

Malaysia's internet coverage stood at 99.73% of populated areas at the end of May, and the government is aiming for 100% by 2027. The word doing the work in that sentence is "populated".

Field data isn't captured where people live. It's captured where they work — between rows of oil palm, on a slope, at the far end of an estate road. In July the Communications Minister said that terrain and extensive oil palm and pineapple plantations were weakening the signal in part of Johor that already had a tower. The next phase of the national rollout, due to start towards the end of this quarter, will help. It won't put a bar of signal on every field.

So any app that collects data in the field has to work offline and sync later. Most of what you'll read treats the conflicts that follow as a merge problem: pick a winner, converge, move on. For data that someone will later audit, I'd design it differently. Here is how, and why.

Why offline-first sync is different for field data

Most sync advice descends from collaborative software. The local-first essay from Ink & Switch, published in 2019, made the case for apps that keep working without a server, and it shaped a generation of sync engines. Its home ground is documents: notes, drawings, task boards. Two people edit, the software merges, and everyone ends up looking at the same thing.

Field data has a different job. A record of what was applied to a plot, or where a sample was taken, isn't a shared document. It's a claim about the physical world, made by a specific person, on a specific device, at a specific time. Later, someone whose job is to be sceptical will ask how you know.

I described that audit in MRV, Explained for Engineers: a credible pipeline has no silent overwrites. Sync is the first place a silent overwrite can happen.

Last write wins is a quiet delete

The strategy you'll meet first is last write wins. Two devices changed the same record, so keep the one with the newer timestamp and discard the other.

It has two problems.

"Last" is decided by a clock you don't control. Android's own documentation says the wall clock can be set by the user or the phone network, so it can jump backwards or forwards. This is old news in distributed systems. Kyle Kingsbury's The trouble with timestamps made the same point about databases that order writes by wall-clock time, running on servers with far better clocks than a phone that has spent a week in a truck.

The loser disappears. Even with perfect clocks, last write wins answers the question "which value do we keep?" by deleting the other answer. Nobody is told. No error is raised. The data looks clean.

For a to-do list, that's fine. For a record an auditor may challenge, the system has just destroyed the most interesting fact it had: two people disagreed about what happened.

The insight: a conflict is evidence, not an error

Here's the part I don't see in most sync guides. Convergence and truth are different properties.

A sync engine that converges guarantees every device ends up with the same state. It says nothing about whether that state is what actually happened in the field. Merge algorithms are very good at the first and silent on the second.

When two field officers record different values for the same plot on the same day, that isn't a bug in your sync layer. It's a finding. Maybe one of them was at the wrong plot. Maybe the plot boundary is wrong. Maybe one entry was typed from memory that evening. Each of those is something a project needs to know.

So the goal changes. Don't resolve conflicts in the sync layer. Record them, and make resolution a visible decision by a named person.

This isn't exotic. CouchDB has worked roughly this way for years: when replicas diverge it picks a deterministic winner so every node shows the same thing, but it keeps the conflicting revisions and leaves the merge to the application. The difference I'm arguing for is one of attitude. Treat the kept revisions as the product, not as a cleanup task.

How I'd design offline-first sync for field data

At HiTerra we build software for farmers and agricultural carbon projects, and I've written before that our data capture is offline-first on the write path, not the whole app. What follows is the design reasoning I'd apply to that write path — principles, not a tour of our codebase.

Sync facts, not rows. The device doesn't upload "the current state of plot 14". It uploads events: this person observed this value, here, at this time. Events are append-only. An edit is a new event that points at the one it corrects. Nothing is updated in place, so there is nothing to overwrite.

Give every event an identity on the device. A client-generated UUID means the event has the same ID before and after it reaches the server. The current UUID standard, RFC 9562, notes that database auto-increment schemes don't work well in distributed applications. One caution: time-ordered UUIDs embed the device's clock. Use them as identifiers, never as proof of order.

Make every upload idempotent. Field connections die mid-request. The device can't tell whether the server received the batch, so it will send it again. If the server treats the event ID as an idempotency key — the same idea Stripe documents for payment retries — a retry is harmless. Without that, a weak signal produces duplicate records.

Keep three clocks, and trust them differently.

FieldSet byWhat it's good for
device_timeThe phone's wall clockWhat the user believes the time was. Evidence, not ordering.
device_seqA counter per device, incremented per eventOrder within one device, and spotting gaps — if 41 and 43 arrive, 42 is missing.
received_atThe serverThe only clock you control. Proves when the claim reached you.

The gap between device_time and received_at is itself useful. An event that says it happened this morning but arrives three weeks later isn't wrong — it's flagged. If you need causal ordering across devices, hybrid logical clocks are the standard tool. I'd add them only when a real requirement asks for it.

Derive state on the server, and make conflict a state. Current values are a projection over the event log. When two events from different devices make incompatible claims about the same thing, the projection doesn't pick one. It marks the record as disputed and shows both.

Resolution is another event. A reviewer chooses a value, or records a third. That decision is appended with their identity and a reason. The original claims stay. Change the rule later and you can replay the log and get a different, equally defensible answer.

None of this needs special infrastructure. It's an outbox table on the device, an events table in the relational database you already run, and discipline.

Where this breaks

Four honest limits.

It moves work to people. A dispute queue nobody reviews is just last write wins with extra steps. Auto-resolve what is genuinely low-stakes, and keep humans for the fields an auditor would ask about. Where that line sits is a domain decision, and I don't think there's a general answer.

It's the wrong tool for live collaboration. If two people are editing the same text at once, you want automatic merging. Use a CRDT library. This design is for claims, not documents.

Some rules can't be enforced offline. Uniqueness, quotas, anything that needs global knowledge. A device can only check what it has seen. Those violations surface at sync time, as disputes.

Old app versions live for a long time. A phone that was offline for a month uploads events in last month's shape. The server has to accept every event version it has ever shipped. And a device lost before its first sync takes its data with it. No protocol fixes that.

The takeaway

Offline-first sync for field data isn't about getting every device to agree. It's about never losing a claim, and being able to show who said what, when, and who decided between them.

One specific next step: take two phones, put both in flight mode, and change the same record on each. Reconnect them in the opposite order to the one you edited in. Then look at your database. If you can see both values, who entered each, and which one the system chose and why — you're in good shape. If one of them is simply gone, that's the gap to close first.

I'll go deeper on the server side of this — projections, replay, and recomputing results when a method changes — in a later post. If you'd like that in your inbox, the newsletter is just below.

Get new posts by email

Occasional essays on building, climate, and engineering. No spam — unsubscribe anytime.

RELATED
COMMENTS