docs/sync-and-op-log/background-info/synthesized-delta-vs-oplog.md
Synthesized From: Gemini 2.5 Flash, GPT-5, Claude Opus 4.5
Date: December 2, 2025
Branches Compared: feat/delta-sync vs feat/operation-logs
Both approaches have substantial implementations.
| Branch | Key Files | Lines | Status |
|---|---|---|---|
feat/delta-sync | super-sync.ts, diff-utils.ts, super-sync-api.ts | ~1,600 | Full implementation: shadow state (IDB), diffing, watermarks, granular encryption |
feat/operation-logs | operation-log-store.service.ts, operation-log-sync.service.ts, etc. | ~600+ | Core logic implemented: op store, sync service, effects, hydrator |
| Model | Delta Sync Source | Notes |
|---|---|---|
| Gemini | Earlier state of feat/delta-sync | Analyzed before branch was updated with full implementation |
| GPT-5 | Design docs + code | Analyzed architectural design |
| Opus | feat/delta-sync (940-line implementation) | Full code analysis of implemented delta sync |
Update: Gemini's finding that delta sync was "vaporware" is now outdated. The feat/delta-sync branch has been updated and now contains the full 940-line SuperSyncProvider implementation with IDB shadow state, diff engine, and watermark tracking. Both approaches can now be compared on equal footing as implemented code.
This document compares two synchronization architectures for Super Productivity, both of which are now substantially implemented:
| Approach | Branch | Core Principle | Implementation |
|---|---|---|---|
| Delta Sync | feat/delta-sync | Compare state snapshots, transmit differences | Implemented (~1,600 lines) |
| Operation Log | feat/operation-logs | Record actions, transmit and replay operations | Partially implemented (~600+ lines) |
All three models recommend Operation Log based on architectural analysis:
| Model | Rationale |
|---|---|
| Gemini | Delta sync has fundamental shadow state consistency issues |
| GPT-5 | Delta sync design has inherent LWW data-loss risk |
| Opus | Code analysis reveals non-atomic state updates and vector clock governance gaps |
Client Storage (super-sync.ts):
├── App data (IndexedDB)
├── Shadow state (super-sync-shadow IDB)
│ ├── shadow_state: last synced state per model
│ └── watermarks: revision cursors per model
└── Memory cache (lastSyncedState Map)
Sync Flow:
1. Load shadow state from IDB (or memory cache)
2. Compute diff via createDiff() in diff-utils.ts
3. Upload changes to /api/sync/changes
4. Server shallow-merges (LWW)
5. Update shadow + watermark in IDB
Code-Verified Concerns (from Opus analysis of super-sync.ts):
Client Storage (actual):
├── SUP_OPS IndexedDB
│ ├── ops: append-only operation log
│ └── state_cache: periodic snapshots
└── NgRx Store (derived from ops)
Sync Flow:
1. Local action → append to ops log
2. Upload pending ops to remote
3. Download remote ops
4. Detect conflicts via vector clock comparison
5. Apply non-conflicting ops; surface conflicts to user
Code-Verified Characteristics:
This is the most significant differentiator and is architecture-dependent, not implementation-dependent.
| Aspect | Delta Sync (Design) | Operation Log (Implemented) |
|---|---|---|
| Detection | Whole-file vector clock | Per-entity vector clock |
| Merge | Shallow LWW ({...old, ...new}) | Semantic (independent ops both apply) |
| User choice | All-or-nothing | Per-entity granular |
| Data loss risk | High (silent overwrites) | Low (conflicts surfaced) |
Example:
Device A: Renames task to "Meeting"
Device B: Marks task complete
Delta Sync (LWW): One change lost
Operation Log: Both changes applied (independent operations)
Winner: Operation Log (unanimous, strong confidence)
| Aspect | Delta Sync (Design) | Operation Log (Implemented) |
|---|---|---|
| Data models | 2 (app state + shadow) | 1 (operation log) |
| Adding features | Update shadow handling + diff rules | Add action to whitelist |
| Debugging | Compare shadow vs actual vs server | Inspect operation sequence |
| Source of truth | Ambiguous (shadow can drift) | Clear (operation log) |
Winner: Operation Log (unanimous)
| Metric | Delta Sync | Operation Log | Basis |
|---|---|---|---|
| Diff cost | O(N) per sync | O(1) append | Code-verified (diff-utils.ts iterates all entities) |
| Startup | Fast (load state) | Snapshot + replay tail | Code-verified |
| Bandwidth | Smaller patches | Larger payloads | Code-verified (delta sends only changed fields) |
| Large datasets | UI freeze risk at 10k+ entities | Scales with change rate | Needs measurement |
Winner: Tie — Delta sync wins on bandwidth; operation log wins on CPU. Needs benchmarking with real datasets.
| Metric | Delta Sync (Implemented) | Operation Log (Implemented) |
|---|---|---|
| Steady-state | ~2X (shadow state in IDB) | ~1.2X (with compaction) |
| Basis | Code-verified (super-sync-shadow IDB) | Code-verified (compaction service exists) |
Winner: Operation Log (if compaction works correctly)
feat/delta-sync now has full implementation (~1,600 lines). Remaining work to stabilize:
| Component | Effort | Notes |
|---|---|---|
| Atomic shadow/watermark updates | 1-2 weeks | Currently separate IDB transactions |
| Web worker for diff | 1 week | Prevent UI freeze on large datasets |
| Server delta API hardening | 1-2 weeks | Pagination, error handling |
| Conflict UI improvements | 1 week | Auto-merge feedback |
| Testing/hardening | 2-4 weeks | Edge cases, concurrent clients, crash recovery |
Total: 6-10 weeks (high risk due to multi-state consistency issues identified in code analysis)
feat/operation-logs has core logic (~600+ lines); remaining work:
| Component | Effort | Notes |
|---|---|---|
| Conflict resolution UI | 1-2 weeks | Currently stub |
| Dependency resolver retry | 0.5-1 week | Handle missing parents |
| Smart resolution suggestions | 1 week | LWW fallback for simple conflicts |
| Genesis migration | 1 week | Convert existing data to first op |
| Effect guards | 0.5-1 week | Prevent side effects during replay |
| Testing/hardening | 1-2 weeks | Compaction, large logs, concurrent tabs |
Total: 4-6 weeks (medium risk, primarily compaction correctness)
Before committing to either approach, measure:
createDiff() with 1k, 10k, 50k entities| Risk | Likelihood | Impact | Notes |
|---|---|---|---|
| Shadow/watermark desync | High | High | Non-atomic IDB transactions in super-sync.ts |
| LWW data loss | High | High | Fundamental to architecture |
| O(N) UI freeze | Medium | Medium | Can be mitigated with web workers |
| Vector clock governance | Medium | Medium | Empty clocks = false conflicts |
| Risk | Likelihood | Impact | Notes |
|---|---|---|---|
| Compaction data loss | Low | High | Mitigate with conservative retention |
| Replay non-determinism | Medium | Medium | Requires reducer purity |
| Log growth unbounded | Medium | Low | Compaction service exists |
Assessment: Operation log has fewer high-likelihood, high-impact risks.
Complete the Operation Log implementation (feat/operation-logs).
| Aspect | Delta Sync | Operation Log |
|---|---|---|
| Implementation status | Implemented (~1,600 lines) | Partially implemented (~600+ lines) |
| Conflict handling | LWW (lossy) | Per-entity (preserves intent) |
| Effort to production | 6-10 weeks | 4-6 weeks |
| Risk level | High (multi-state consistency) | Medium (compaction correctness) |
| Recommendation | Viable but risky | Recommended |
Both approaches are now substantially implemented. The recommendation for operation log is based on code-verified architectural concerns in the delta sync implementation:
Bottom line: Operation log provides a more robust architecture for Super Productivity's multi-device use case. If delta sync is chosen, significant stabilization work is needed to address the identified issues.