Business · Product · Technology · AI

Preserve local follow-list edits when an older sync response completes

A Movo-X account-preference synchronization case covering first-sync migration, dirty lists, failed saves, mutation counters and the difference between a returned response and current local state.

Work directly with Omer Muneer Qazi · Reviewed 29 November 2026

The scenario: a local tap happens while a save is still completing

A person adds a clinic to a followed list and the app begins saving it. Before that save returns, the person adds another clinic. If the first response blindly replaces the current local list and clears its dirty flag, the second choice can disappear even though the interface already accepted the tap.

The inspected Movo-X follow-list implementation tracks local mutations alongside saved slugs and synchronization flags. This case follows its first-sync migration and later reconciliation rules through portable tests using a fake service and an in-memory store. It concerns account preferences, not clinical record synchronization or authority to access a clinic.

Separate a local list from a synchronized account baseline

The model keeps the clinic slugs, a dirty indicator and a flag recording whether synchronization has succeeded. Adding a valid slug updates its position, normalizes the list and marks it dirty. Removing a slug also records a local change rather than waiting for the server before updating the device copy.

The normalization rule keeps accepted slugs, removes duplicates in first-position order and applies a bounded list size. That is a representation policy for this feature. The selected reset fixture checks the limit alongside clearing flags. It does not establish real UserDefaults durability, account isolation across every app path or correctness of server-side preference storage.

Treat first-sync migration differently from an ordinary pull

An older install can already have a device-only list even though it has never synchronized with the account service. In the clean first-sync branch, the implementation reads the server list and appends the existing local entries before normalizing and saving a changed merge.

The selected migration fixture begins with overlapping local and server entries and checks their resulting order without duplication. This preserves selected historical device choices during that transition. It is a specific migration rule, not a general conflict-free merge algorithm. A dirty local list follows the write branch instead, so the branch conditions are part of the migration contract.

Use the server copy when no local edit is pending

After successful initialization, a clean list is refreshed from the service. The selected fixture changes the fake server list between passes and verifies that the device adopts the new list without sending an unnecessary write.

That behaviour allows another device’s saved choice to appear on this device when there is no pending local intent. It does not mean the client subscribes to instantaneous remote updates. The timing of synchronization remains a caller concern, and the fake-service example does not establish notifications, live delivery or the behaviour of several real devices changing the list simultaneously.

Leave a failed write dirty for the next pass

When local edits are pending, synchronization sends the selected local list. If the fake service fails, the test checks that the local choice remains available and dirty. A later successful pass sends it again and can clear the flag once the response is eligible to be adopted.

This is an explicit retryable state rather than evidence of a successful remote save. The fixture also checks a later removal reaching the fake server. Because the store is in memory, the result is not described as actual process-restart recovery or protection against every interrupted persistence write. Those durability questions require the production store and lifecycle tests.

Compare the local mutation counter before adopting a response

The sync method captures a mutation counter at its start. After the service call completes, it adopts the returned list and clears the dirty flag only if that counter still matches. A local change increments the counter, so an older save response does not acknowledge the newer edit in the selected race fixture.

The test injects a local addition during the fake service’s write call, then checks that both local choices remain and the list stays dirty. A following pass pushes the newer list. This proves that selected interleaving, not general linearizability or a full multithreaded stress result. The counter and store operations need to be assessed according to their actual execution context.

Do not confuse the returned response with the newest local view

The method returns the service response even when a newer local mutation prevents adoption. Source inspection therefore distinguishes the response representing that service operation from the list currently held on the device. A caller should not infer that successful completion always makes those two views identical.

The feature also sends a whole list in its dirty-write path. The selected mutation guard protects a local edit from this client’s older response; it does not prove automatic merging of simultaneous edits from two different devices. If that behaviour is required, it needs a separately defined server conflict or merge contract and corresponding tests.

A concrete local-sync acceptance package

Retain cases for migration from a clean device-only list, a later server pull, an offline dirty save, a change during a write and reset of local state. Check visible entries, write payloads and bookkeeping flags independently so a successful request cannot hide an unacknowledged local edit.

For a CTO, the result is a small synchronization protocol with understandable ownership: clean state can follow the server, dirty state represents local intent, and an older response cannot acknowledge a later mutation in the tested path. Real persistence, sign-out lifecycle, concurrent-device resolution and backend permissions remain separate acceptance work.

Compare the reviewed boundaries

Which state wins in a follow-list sync pass

On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.

Starting conditionInspected decisionSeparate acceptance
Clean and never synchronizedMerge server list with device-only entriesExact migration branch and lifecycle
Clean and previously synchronizedAdopt selected server responseRefresh timing across devices
Dirty local listWrite local intent; keep dirty on failureReal persistence and server permission
New local mutation during service callDo not adopt older response or clear dirtyOther interleavings and multi-device conflicts

Illustrative control flow

Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.

started = local_mutation_counter
response = migrate_pull_or_push_according_to_local_flags()
if local_mutation_counter == started:
    adopt_response_and_clear_dirty()
else:
    retain_newer_local_intent_for_next_sync()
return response

# Returned service state and current local state can differ.

About this engineering series

Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.

Explore the Movo-X engineering series → · Related implementation experience →

Discuss a similar engineering problem

Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.

Discuss your project on WhatsApp ↗
WhatsApp Omer about this project ↗