Offline Sync & Multi-Device Conflict Rules
What works offline
Field and extension officers can keep working with no signal: form entries, harvest and inventory updates, task changes, farm operations, service requests and plot details are queued on the device. A banner shows how many items are waiting.
The queue is stored per device. Photos taken offline are uploaded when the connection returns, and each item is retried up to three times before it is marked abandoned for review.
What happens when two devices edit the same record
Nothing is silently overwritten. When a queued edit reaches the server, it is merged field by field against the current server record using fixed rules:
1. Append-only fields are unioned. Visits, vaccination and health records, weight logs, management history, training schedules, rotation plans, input demand and machinery requests keep every entry from every device. Nothing is dropped and the list stays in date order.
2. Monotonic counters only move forward. Usage hours and similar counters take the higher value, so a late sync cannot wind the number back.
3. Mutable fields are last-write-wins with provenance. If the server record has not moved since the device snapshot, the offline edit is applied. If another device wrote in the meantime, the newer server value is kept for that field and the local attempt is recorded as a conflict with the device, the timestamp and both values.
4. Identity fields are never taken from a device. Record id, workspace, creator and created date are always the server's.
Because the rules compare timestamps and union lists rather than replaying edits in arrival order, two devices flushing in either order produce the same merged record.
Seeing the conflicts
When a merge keeps the server value for any field, the officer sees a warning naming the record and how many fields were changed elsewhere. The conflict is also written to the device's conflict log, with the record, field, both values, the timestamps and the device that made the local edit, so a supervisor can review what happened rather than guessing.
Running at scale (thousands of members)
- Give each officer their own device identity — it is generated automatically per browser and travels with every queued item.
- Prefer separate records over shared ones: a visit log per officer merges by union; a single shared note field merges last-write-wins.
- Sync daily. Long-offline devices accumulate edits that are more likely to collide with other officers' work.
- Never clear the queue to make the banner go away: abandoned items are kept precisely so nothing is lost.
- After a big sync, check the conflict log before closing the day.
What is not merged
Deletions are not resurrected: if a record was deleted on the server, the queued edit cannot recreate it, and the item stays in the queue as failed for review. Membership payment proofs and portal uploads are online-only actions, because they need the private file upload.