super-productivity/docs/sync-and-op-log/long-term-plans/replace-pfapi-with-oplog-plan.md
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

2.7 KiB

Plan: Replace PFAPI with Operation Log Sync for All Providers

STATUS: COMPLETED (January 2026)

This plan has been fully implemented. The entire src/app/pfapi/ directory has been deleted. All sync providers now use the unified operation log system via FileBasedSyncAdapter.

Current Implementation:

  • Sync providers: src/app/op-log/sync-providers/
  • File-based adapter: src/app/op-log/sync-providers/file-based/file-based-sync-adapter.service.ts
  • Server migration: src/app/op-log/sync/server-migration.service.ts

Original Goal

Simplify the codebase by removing PFAPI's model-by-model sync and using operation logs exclusively for all sync providers (WebDAV, Dropbox, LocalFile). Migration required for existing users; old PFAPI files kept as backup.

What Was Implemented

Phase 1: Enable Operation Log Sync (All Providers) - DONE

All providers now use operation log sync:

  • WebDAV: src/app/op-log/sync-providers/file-based/webdav/
  • Dropbox: src/app/op-log/sync-providers/file-based/dropbox/
  • LocalFile: src/app/op-log/sync-providers/file-based/local-file/
  • SuperSync: src/app/op-log/sync-providers/super-sync/

Phase 2: Migration Logic - DONE

Migration from legacy PFAPI format is handled by ServerMigrationService:

  • Checks for existing PFAPI metadata file on remote
  • Downloads full state and creates SYNC_IMPORT operation
  • Uploads initial snapshot via operation log

Phase 3: PFAPI Code Removal - DONE

The entire src/app/pfapi/ directory has been deleted (~83 files, 2.0 MB).

What was kept (moved to op-log):

  • Provider implementations (WebDAV, Dropbox, LocalFile)
  • Encryption/compression utilities
  • Auth flows

Phase 4: Testing & Cleanup - DONE

  • Multi-device sync scenarios tested via E2E tests
  • Migration testing completed
  • Large operation log handling verified
  • All tests pass

Final Architecture

src/app/op-log/
├── sync-providers/
│   ├── super-sync/                 # Server-based sync
│   ├── file-based/                 # File-based providers
│   │   ├── file-based-sync-adapter.service.ts
│   │   ├── webdav/
│   │   ├── dropbox/
│   │   └── local-file/
│   ├── provider-manager.service.ts
│   └── wrapped-provider.service.ts
├── sync/
│   ├── operation-log-sync.service.ts
│   └── server-migration.service.ts
└── ...

Key Decisions Made

  • Single-file sync format (sync-data.json) with state snapshot + recent ops
  • Content-based optimistic locking via syncVersion counter
  • Piggybacking mechanism for concurrent sync handling
  • Server migration service handles legacy PFAPI data migration