Back to Super Productivity

Operation Log Documentation

docs/sync-and-op-log/README.md

18.4.410.3 KB
Original Source

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 architectureoperation-log-architecture.md
See visual diagramsdiagrams/ (split by topic)
Learn the design rulesoperation-rules.md
Understand file-based syncdiagrams/04-file-based-sync.md
Understand SuperSync encryptionsupersync-encryption-architecture.md

Documentation Overview

Core Documentation

DocumentDescriptionStatus
operation-log-architecture.mdComprehensive architecture reference covering Parts A-F: Local Persistence, File-Based Sync, Server Sync, Validation & Repair, Smart Archive Handling, and Atomic State ConsistencyActive
diagrams/Mermaid diagrams split by topic (local persistence, server sync, file-based sync, etc.)Active
operation-rules.mdDesign rules and guidelines for the operation log store and operationsActive

Sync Architecture

DocumentDescriptionStatus
diagrams/04-file-based-sync.mdFile-based sync with single sync-data.json (WebDAV/Dropbox/LocalFile)Implemented
diagrams/02-server-sync.mdSuperSync server sync architectureImplemented
supersync-encryption-architecture.mdEnd-to-end encryption for SuperSync (AES-256-GCM + Argon2id)Implemented

Historical / Completed Plans

DocumentDescriptionStatus
replace-pfapi-with-oplog-plan.mdPlan to unify sync by replacing PFAPI with operation logCompleted (Jan 2026)
e2e-encryption-plan.mdOriginal 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 TypeProvidersHow It Works
Server-basedSuperSyncIndividual operations uploaded/downloaded via HTTP API
File-basedWebDAV, Dropbox, LocalFileSingle sync-data.json file with state snapshot + recent ops

The Core Parts

PartPurposeDescription
A. Local PersistenceFast writes, crash recoveryOperations stored in IndexedDB (SUP_OPS), with snapshots for fast hydration
B. File-Based SyncWebDAV/Dropbox/LocalFileSingle-file sync with state snapshot and embedded operations buffer
C. Server SyncOperation-based syncUpload/download individual operations via SuperSync server
D. Validation & RepairData integrityCheckpoint validation with automatic repair and REPAIR operations

Additional architectural patterns:

PatternPurpose
E. Smart Archive HandlingDeterministic archive operations synced via instructions, not data
F. Atomic State ConsistencyMeta-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:

typescript
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
LocationContent
vector-clocks.mdVector clock implementation details
packages/super-sync-server/SuperSync server implementation
background-info/Research and best practices documents

Implementation Status

ComponentStatus
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 EncryptionComplete (AES-256-GCM + Argon2id)
PFAPI EliminationComplete (Jan 2026)
Cross-version Sync (A.7.11)Documented (not yet implemented)
Schema MigrationsInfrastructure ready (no migrations defined yet)

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