I think this TODO comment describes a real issue.  AFAICT, we have the following failure mode:
1. Up-sync a local contact to a remote
2. Manually merge that contact with another contact that already has a local; I don't recall which, but one becomes was_local
3. Anyone syncing the remaining local will see extra details appear, which is fine
4. Anyone syncing the was_local will not see that contact any longer, but will not see it in locallyDeleted, and I don't think it would be removed from the exported set
Something to investigate.