Architect a simple app that includes networking and local storage.
Implement the synchronization core as a pure function. Each local and network record has id, version, value, and deleted; local records may also have pending: true. The network input is a complete snapshot, so a non-pending local record absent from it should be removed. Return the records to persist locally and the local records that must be uploaded.
Use the higher version. If versions tie, prefer a pending local record. Preserve pending on records selected for upload. Return records and uploads sorted by id.
Function: sync_records(local_records, network_records)
Return: {"records": [...], "upload": [...]}.
def sync_records(local_records, network_records):