docs/long-term-plans/sync-core-simplification-roadmap.md
Status: Planned
Goal: Reduce cognitive load and architectural coupling in the sync stack without destabilizing behavior.
Primary focus: Client-side sync orchestration.
Why now: The sync implementation is feature-rich and well-tested, but many edge cases accumulated in the orchestration layer. The highest-value work is to simplify control flow and boundaries before doing broader protocol or server refactors.
SyncWrapperService remains the application/UI boundary.Purpose: Establish a stable baseline before behavior-preserving refactors.
Required deliverables: This phase should produce concrete artifacts, not just exploratory notes.
src/app/imex/sync/sync-wrapper.service.tssrc/app/op-log/sync/operation-log-sync.service.tssrc/app/op-log/sync/remote-ops-processing.service.tssrc/app/op-log/sync/conflict-resolution.service.tssrc/app/op-log/core/types/sync-results.types.tssrc/app/op-log/sync/operation-log-download.service.tssrc/app/op-log/sync/operation-log-upload.service.tssrc/app/op-log/sync/operation-log-sync.service.tssrc/app/imex/sync/sync-wrapper.service.tsPurpose: Reduce branching complexity and make control flow exhaustive and explicit.
Scope constraint: This phase applies to the incremental sync path only. Full-state result modeling should be finalized in Phase 2 when those flows are extracted.
src/app/op-log/core/types/sync-results.types.tssrc/app/op-log/sync/operation-log-download.service.tssrc/app/op-log/sync/operation-log-upload.service.tssrc/app/op-log/sync/operation-log-sync.service.tssrc/app/imex/sync/sync-wrapper.service.tscancelledserverMigrationHandledneedsFullStateUploadlocalWinOpsCreatedsnapshotVectorClockhasMorePiggybackswitch on kindDownloadTransportResultUploadTransportResultIncrementalSyncStepResultIncrementalSyncSessionResultPurpose: Remove SYNC_IMPORT and related special cases from the incremental op-sync path.
src/app/op-log/sync/operation-log-sync.service.tssrc/app/op-log/sync/operation-log-download.service.tssrc/app/op-log/sync/operation-log-upload.service.tssrc/app/op-log/sync/server-migration.service.tssrc/app/op-log/sync/sync-import-filter.service.tssrc/app/op-log/sync/full-state-sync.service.tssrc/app/op-log/sync/full-state-sync.types.tsSYNC_IMPORTBACKUP_IMPORTREPAIROperationLogSyncService no longer owns most full-state branchingPurpose: Reduce the size and policy density of the conflict-resolution layer.
Risk: Highest-risk phase in this roadmap. ConflictResolutionService is tightly coupled to the entity registry, vector-clock utilities, store selectors, and operation application flow. This phase may need its own sub-plan before implementation starts.
src/app/op-log/sync/conflict-resolution.service.tssrc/app/op-log/sync/remote-ops-processing.service.tssrc/app/op-log/sync/conflict-strategies/ConflictResolutionService is primarily a coordinatorPurpose: Reconsider provider contract simplification after the higher-value refactors are complete.
Status: Optional reconsideration phase, not a committed refactor. Only pursue this if Phases 1-3 show that the current provider contract is materially contributing to complexity.
src/app/op-log/sync-providers/provider.interface.tssrc/app/op-log/sync-providers/file-based/file-based-sync-adapter.service.tssrc/app/op-log/sync-providers/wrapped-provider.service.tsOperationSyncCapable should be split into smaller capabilities such as:
Useful, but lower priority than the client orchestration cleanup.
Useful later, but not the main bottleneck today.
If work starts immediately, begin with Phase 1.
Reason: