super-productivity/docs/sync-and-op-log
Johannes Millan 9f0adbb95c docs: fix outdated file paths and types in diagrams
- Fix FileBasedSyncData type: remove non-existent lastSeq, add clientId
- Fix file paths: op-log/processing → op-log/apply
- Fix file paths: features/time-tracking → features/archive
- Fix file path: super-sync not supersync
- Fix vector-clock path: now in op-log/sync/
- Remove non-existent state-capture.meta-reducer.ts reference
- Remove pfapi-migration.service.ts (no longer exists)

docs: remove outdated .bak file references from diagrams

The backup file (sync-data.json.bak) is no longer created during
upload. It's only deleted as cleanup from legacy implementations.

docs: add sync comparison and simple sync flow diagrams

- Add 07-supersync-vs-file-based.md comparing the two sync approaches
- Add 08-sync-flow-explained.md with step-by-step sync explanation
- Remove consolidated unified-oplog-sync-diagrams.md
- Update diagrams README with new entries

docs(sync): reorganize diagrams into subfolder and update for unified architecture

- Create docs/sync-and-op-log/diagrams/ with topic-based diagram files
- Remove outdated PFAPI Legacy Bridge references from diagrams
- Update archive diagrams to use generic "Archive Database" naming
- Fix file paths from sync/providers/ to sync-providers/
- Update quick-reference Area 12 to show unified file-based sync
- Update README to reference new diagram locations

docs: update architecture docs to reflect PFAPI elimination

- Delete obsolete PFAPI documentation:
  - docs/sync-and-op-log/pfapi-sync-persistence-architecture.md
  - docs/sync-and-op-log/pfapi-sync-overview.md
  - docs/plans/pfapi-elimination-status.md

- Update sync-and-op-log/README.md:
  - Describe unified operation log architecture
  - Document file-based sync (Part B) and server sync (Part C)
  - Update file structure to reflect sync-providers location

- Update operation-log-architecture.md:
  - Rewrite Part B from "Legacy Sync Bridge" to "File-Based Sync"
  - Remove all PFAPI code examples and references
  - Update IndexedDB structure diagram (single SUP_OPS database)
  - Update architecture overview to show current provider structure
  - Add notes about PFAPI elimination (January 2026)

- Mark completed implementation plans:
  - replace-pfapi-with-oplog-plan.md - marked as COMPLETED
  - file-based-oplog-sync-implementation-plan.md - marked as COMPLETED

Also includes fix for file-based sync gap detection to handle
snapshot replacement (when "Use Local" is chosen in conflict resolution).
2026-01-08 11:10:29 +01:00
..
background-info test(sync): add tests for bulk dispatch edge cases 2025-12-27 11:31:51 +01:00
diagrams docs: fix outdated file paths and types in diagrams 2026-01-08 11:10:29 +01:00
long-term-plans docs: fix outdated file paths and types in diagrams 2026-01-08 11:10:29 +01:00
operation-log-architecture-diagrams.md test(time-tracking): add comprehensive tests and documentation 2025-12-28 13:16:07 +01:00
operation-log-architecture.md docs: fix outdated file paths and types in diagrams 2026-01-08 11:10:29 +01:00
operation-payload-optimization-discussion.md test(sync): add tests for bulk dispatch edge cases 2025-12-27 11:31:51 +01:00
operation-rules.md test(sync): add tests for bulk dispatch edge cases 2025-12-27 11:31:51 +01:00
quick-reference.md docs: fix outdated file paths and types in diagrams 2026-01-08 11:10:29 +01:00
README.md docs: fix outdated file paths and types in diagrams 2026-01-08 11:10:29 +01:00
supersync-encryption-architecture.md refactor: reorganize operation-log files into src/app/op-log/ 2025-12-27 17:52:11 +01:00
vector-clocks.md chore: clean up leftover pfapi references after refactor 2026-01-07 21:10:38 +01:00

Operation Log Documentation

Last Updated: January 2026

This directory contains the architectural documentation for Super Productivity's Operation Log system - an event-sourced persistence and synchronization layer that handles ALL sync providers (SuperSync, WebDAV, Dropbox, LocalFile).

Quick Start

If you want to... Read this
Understand the overall architecture operation-log-architecture.md
See visual diagrams diagrams/ (split by topic)
Learn the design rules operation-rules.md
Understand file-based sync diagrams/04-file-based-sync.md
Understand SuperSync encryption supersync-encryption-architecture.md

Documentation Overview

Core Documentation

Document Description Status
operation-log-architecture.md Comprehensive architecture reference covering Parts A-F: Local Persistence, File-Based Sync, Server Sync, Validation & Repair, Smart Archive Handling, and Atomic State Consistency Active
diagrams/ Mermaid diagrams split by topic (local persistence, server sync, file-based sync, etc.) Active
operation-rules.md Design rules and guidelines for the operation log store and operations Active

Sync Architecture

Document Description Status
diagrams/04-file-based-sync.md File-based sync with single sync-data.json (WebDAV/Dropbox/LocalFile) Implemented
diagrams/02-server-sync.md SuperSync server sync architecture Implemented
supersync-encryption-architecture.md End-to-end encryption for SuperSync (AES-256-GCM + Argon2id) Implemented

Historical / Completed Plans

Document Description Status
replace-pfapi-with-oplog-plan.md Plan to unify sync by replacing PFAPI with operation log Completed (Jan 2026)
e2e-encryption-plan.md Original E2EE design (see supersync-encryption for impl) Implemented (Dec 2025)

Architecture at a Glance

The Operation Log system is the single sync system for all providers:

                         User Action
                              │
                              ▼
                         NgRx Store
                   (Runtime Source of Truth)
                              │
          ┌───────────────────┼───────────────────┐
          ▼                   │                   ▼
    OpLogEffects              │             Other Effects
          │                   │
          ├──► SUP_OPS ◄──────┘
          │    (Local Persistence - IndexedDB)
          │
          └──► Sync Providers
               ├── SuperSync (operation-based, real-time)
               ├── WebDAV (file-based, single-file snapshot)
               ├── Dropbox (file-based, single-file snapshot)
               └── LocalFile (file-based, single-file snapshot)

Sync Provider Types

Provider Type Providers How It Works
Server-based SuperSync Individual operations uploaded/downloaded via HTTP API
File-based WebDAV, Dropbox, LocalFile Single sync-data.json file with state snapshot + recent ops

The Core Parts

Part Purpose Description
A. Local Persistence Fast writes, crash recovery Operations stored in IndexedDB (SUP_OPS), with snapshots for fast hydration
B. File-Based Sync WebDAV/Dropbox/LocalFile Single-file sync with state snapshot and embedded operations buffer
C. Server Sync Operation-based sync Upload/download individual operations via SuperSync server
D. Validation & Repair Data integrity Checkpoint validation with automatic repair and REPAIR operations

Additional architectural patterns:

Pattern Purpose
E. Smart Archive Handling Deterministic archive operations synced via instructions, not data
F. Atomic State Consistency Meta-reducers ensure multi-entity changes are atomic

Key Concepts

Event Sourcing

The Operation Log treats the database as a timeline of events rather than mutable state:

  • Source of Truth: The log is truth; current state is derived by replaying the log
  • Immutability: Operations are never modified, only appended
  • Snapshots: Periodic snapshots speed up hydration (replay from snapshot + tail ops)

Vector Clocks

Vector clocks track causality for conflict detection:

  • Each client has its own counter in the vector clock
  • Comparison reveals: EQUAL, LESS_THAN, GREATER_THAN, or CONCURRENT
  • CONCURRENT indicates a true conflict requiring resolution

LOCAL_ACTIONS Token

Effects that perform side effects (snacks, external APIs, UI) must use LOCAL_ACTIONS instead of Actions:

private _actions$ = inject(LOCAL_ACTIONS); // Excludes remote operations

This prevents duplicate side effects when syncing operations from other clients.

Key Files

Sync Providers

src/app/op-log/sync-providers/
├── super-sync/                     # SuperSync server provider
├── file-based/                     # File-based providers
│   ├── file-based-sync-adapter.service.ts  # Unified adapter for file providers
│   ├── file-based-sync.types.ts    # FileBasedSyncData types
│   ├── webdav/                     # WebDAV provider
│   ├── dropbox/                    # Dropbox provider
│   └── local-file/                 # Local file sync provider
├── provider-manager.service.ts     # Provider activation/management
├── wrapped-provider.service.ts     # Provider wrapper with encryption
└── credential-store.service.ts     # OAuth/credential storage

Core Operation Log

src/app/op-log/
├── core/                           # Core types and operations
├── persistence/                    # IndexedDB storage
├── sync/                           # Sync orchestration
└── validation/                     # Data validation and repair
Location Content
vector-clocks.md Vector clock implementation details
packages/super-sync-server/ SuperSync server implementation
background-info/ Research and best practices documents

Implementation Status

Component Status
Local Persistence (Part A) Complete
File-Based Sync (Part B) Complete (WebDAV, Dropbox, LocalFile)
Server Sync (Part C) Complete (SuperSync)
Validation & Repair (Part D) Complete
End-to-End Encryption Complete (AES-256-GCM + Argon2id)
PFAPI Elimination Complete (Jan 2026)
Cross-version Sync (A.7.11) Documented (not yet implemented)
Schema Migrations Infrastructure ready (no migrations defined yet)

See operation-log-architecture.md#implementation-status for detailed status.