The shadow sync system has had multiple critical bugs due to complex state management:
Create a formal TLA+ specification that defines:
NONE: No shadow exists for this source eventCREATED: Shadow created but not yet recorded in storeSYNCED: Shadow exists and store record matches current inputsSTALE: Shadow exists but inputs changed (needs update)ORPHANED: Store record exists but source event no longer existsDELETED: Shadow removed from calendarNONE -> CREATED: First sync creates shadow
CREATED -> SYNCED: Store record saved successfully
SYNCED -> SYNCED: Inputs unchanged (skip)
SYNCED -> STALE: Source event inputs changed
STALE -> SYNCED: Shadow updated with new inputs
SYNCED -> ORPHANED: Source event deleted/removed
ORPHANED -> DELETED: Orphan cleanup runs
DELETED -> NONE: Cleanup complete
ShadowState enum matching TLA+ states{ruleID}-{sourceEventID}@{timestamp}{sourceEventID} (no timestamp)BlockItOut/Services/ShadowSnapshotStore.swiftBlockItOut/SyncEngine/SyncService.swiftBlockItOut/Services/ShadowNoteManager.swiftThis must be addressed comprehensively to prevent continued regression bugs in the sync system.