1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//! Data Synchronization Abstraction Layer
//!
//! This module provides a unified interface for CRDT-based data synchronization,
//! enabling Peat Protocol to work with multiple sync engines without changing
//! business logic.
//!
//! ## Architecture
//!
//! The abstraction consists of four core traits:
//!
//! 1. **`DocumentStore`** - CRUD operations, queries, and live observers
//! 2. **`PeerDiscovery`** - Finding and connecting to other nodes
//! 3. **`SyncEngine`** - Controlling synchronization behavior
//! 4. **`DataSyncBackend`** - Lifecycle management and trait composition
//!
//! ## Supported Backends
//!
//! - **Automerge + Iroh** - Open-source CRDT with QUIC-based P2P transport
//!
//! ## Usage Example
//!
//! ```rust,ignore
//! use peat_protocol::sync::{DataSyncBackend, BackendConfig};
//! use peat_protocol::storage::AutomergeBackend;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Create backend
//! let backend = AutomergeBackend::new();
//!
//! // Initialize with config
//! let config = BackendConfig {
//! app_id: "my-app".to_string(),
//! persistence_dir: "/tmp/data".into(),
//! // ...
//! };
//! backend.initialize(config).await?;
//!
//! // Start peer discovery and sync
//! backend.peer_discovery().start().await?;
//! backend.sync_engine().start_sync().await?;
//!
//! // Use document store
//! let doc_store = backend.document_store();
//! let doc = Document::new(fields);
//! doc_store.upsert("collection", doc).await?;
//!
//! // Cleanup
//! backend.shutdown().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Testing
//!
//! The abstraction enables testing without real backends:
//!
//! ```rust,ignore
//! use peat_protocol::sync::mock::MockBackend;
//!
//! # async fn test_example() {
//! let backend = MockBackend::new();
//! // Test Peat protocol logic with mock backend
//! # }
//! ```
//!
//! ## Design Rationale
//!
//! See ADR-005 for full context on why this abstraction exists:
//! - Eliminate vendor lock-in with proprietary sync engines
//! - Enable open-source alternatives for DoD/NATO deployments
//! - Support multiple sync strategies (Ditto, Automerge, custom)
//! - Simplify testing (mocks, no real Ditto instances needed)
// Backend implementations
// Automerge CRDT backend (E8 evaluation)
// In-flight origin map for IrohDocumentStore observer-pipeline origin
// threading (ADR-059 ยง"Origin propagation through async observer pipelines").
pub
// BLE translation layer (ADR-041, #557). The translator implements
// `peat_mesh::transport::Translator` (ADR-059 Slice 1.b.2) so it plugs
// directly into `TransportManager`'s fan-out โ the older `BleGateway`
// wrapper that composed translator+Node has been deleted (Slice 1.b.2.2);
// callers compose the two themselves at their own integration boundary.
// Re-export core types and traits for convenience
pub use *;
pub use *;