@affectively/aeon 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +342 -342
  3. package/dist/compression/index.cjs.map +1 -1
  4. package/dist/compression/index.js.map +1 -1
  5. package/dist/core/index.d.cts +213 -208
  6. package/dist/core/index.d.ts +213 -208
  7. package/dist/crypto/index.cjs.map +1 -1
  8. package/dist/crypto/index.d.cts +441 -402
  9. package/dist/crypto/index.d.ts +441 -402
  10. package/dist/crypto/index.js.map +1 -1
  11. package/dist/distributed/index.cjs +8 -2
  12. package/dist/distributed/index.cjs.map +1 -1
  13. package/dist/distributed/index.d.cts +1005 -890
  14. package/dist/distributed/index.d.ts +1005 -890
  15. package/dist/distributed/index.js +8 -2
  16. package/dist/distributed/index.js.map +1 -1
  17. package/dist/index.cjs +58 -733
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +50 -5
  20. package/dist/index.d.ts +50 -5
  21. package/dist/index.js +55 -732
  22. package/dist/index.js.map +1 -1
  23. package/dist/offline/index.cjs.map +1 -1
  24. package/dist/offline/index.d.cts +148 -142
  25. package/dist/offline/index.d.ts +148 -142
  26. package/dist/offline/index.js.map +1 -1
  27. package/dist/optimization/index.cjs.map +1 -1
  28. package/dist/optimization/index.js.map +1 -1
  29. package/dist/persistence/index.cjs.map +1 -1
  30. package/dist/persistence/index.d.cts +57 -57
  31. package/dist/persistence/index.d.ts +57 -57
  32. package/dist/persistence/index.js.map +1 -1
  33. package/dist/presence/index.cjs.map +1 -1
  34. package/dist/presence/index.js.map +1 -1
  35. package/dist/{types-CMxO7QF0.d.cts → types-B7CxsoLh.d.cts} +30 -30
  36. package/dist/{types-CMxO7QF0.d.ts → types-B7CxsoLh.d.ts} +30 -30
  37. package/dist/utils/index.cjs.map +1 -1
  38. package/dist/utils/index.d.cts +35 -35
  39. package/dist/utils/index.d.ts +35 -35
  40. package/dist/utils/index.js.map +1 -1
  41. package/dist/versioning/index.cjs +18 -8
  42. package/dist/versioning/index.cjs.map +1 -1
  43. package/dist/versioning/index.d.cts +1 -1
  44. package/dist/versioning/index.d.ts +1 -1
  45. package/dist/versioning/index.js +18 -8
  46. package/dist/versioning/index.js.map +1 -1
  47. package/package.json +196 -192
package/README.md CHANGED
@@ -1,342 +1,342 @@
1
- # Aeon
2
-
3
- > Distributed synchronization, schema versioning, and conflict resolution for real-time collaborative applications.
4
-
5
- [![npm version](https://badge.fury.io/js/@affectively%2Faeon.svg)](https://www.npmjs.com/package/@affectively/aeon)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.6+-blue.svg)](https://www.typescriptlang.org/)
8
-
9
- ## Philosophy
10
-
11
- In Gnosticism, **Aeons** are not just time periods; they are divine beings or powers that emanate from the "One" (the Pleroma). They function as links or "levels" between the pure divine source and the material world, often existing in pairs (syzygies) to maintain balance.
12
-
13
- In the Affectively framework, if "halos" are the users, then **Aeons are the collaborative structures** - the channels that allow users to communicate with the higher-level logic of the platform. They bridge the gap between individual user state and the distributed system, maintaining harmony across the network.
14
-
15
- ## Overview
16
-
17
- **Aeon** is a comprehensive TypeScript library for building distributed, collaborative applications. It provides the primitives needed for:
18
-
19
- - **Distributed Synchronization** - Coordinate sync sessions across multiple nodes
20
- - **Schema Versioning** - Manage schema evolution with migrations and rollbacks
21
- - **Data Replication** - Configure consistency levels and replication policies
22
- - **Conflict Resolution** - Multiple strategies for resolving divergent state
23
- - **Real-time Presence** - Track node health and status in real-time
24
-
25
- Roadmap vision: see [ROADMAP.md](./ROADMAP.md).
26
-
27
- ## Installation
28
-
29
- ```bash
30
- npm install @affectively/aeon
31
- # or
32
- yarn add @affectively/aeon
33
- # or
34
- pnpm add @affectively/aeon
35
- # or
36
- bun add @affectively/aeon
37
- ```
38
-
39
- ## Quick Start
40
-
41
- ### Distributed Synchronization
42
-
43
- ```typescript
44
- import { SyncCoordinator } from '@affectively/aeon';
45
-
46
- // Create a sync coordinator
47
- const coordinator = new SyncCoordinator();
48
-
49
- // Register nodes
50
- coordinator.registerNode({
51
- id: 'node-1',
52
- address: 'localhost',
53
- port: 3000,
54
- status: 'online',
55
- lastHeartbeat: new Date().toISOString(),
56
- version: '1.0.0',
57
- capabilities: ['sync', 'replicate'],
58
- });
59
-
60
- // Create a sync session
61
- const session = coordinator.createSyncSession('node-1', ['node-2', 'node-3']);
62
-
63
- // Listen for sync events
64
- coordinator.on('sync-completed', (session) => {
65
- console.log(`Session ${session.id} completed:`, session.itemsSynced, 'items synced');
66
- });
67
-
68
- // Start heartbeat monitoring
69
- coordinator.startHeartbeatMonitoring(5000);
70
- ```
71
-
72
- ### Schema Versioning & Migrations
73
-
74
- ```typescript
75
- import { SchemaVersionManager, MigrationEngine, MigrationTracker } from '@affectively/aeon';
76
-
77
- // Initialize version manager
78
- const versionManager = new SchemaVersionManager();
79
-
80
- // Register schema versions
81
- versionManager.registerVersion({
82
- major: 1,
83
- minor: 0,
84
- patch: 0,
85
- timestamp: new Date().toISOString(),
86
- description: 'Initial schema',
87
- breaking: false,
88
- });
89
-
90
- versionManager.registerVersion({
91
- major: 2,
92
- minor: 0,
93
- patch: 0,
94
- timestamp: new Date().toISOString(),
95
- description: 'Added user status field',
96
- breaking: true,
97
- });
98
-
99
- // Create migration engine
100
- const migrationEngine = new MigrationEngine();
101
-
102
- // Register a migration
103
- migrationEngine.registerMigration({
104
- id: 'add-status-field',
105
- version: '2.0.0',
106
- name: 'Add user status field',
107
- up: (data) => ({ ...data, status: 'active' }),
108
- down: (data) => {
109
- const { status, ...rest } = data;
110
- return rest;
111
- },
112
- timestamp: new Date().toISOString(),
113
- description: 'Adds status field to all user records',
114
- });
115
-
116
- // Execute migration
117
- const result = await migrationEngine.executeMigration('add-status-field', userData);
118
- console.log(`Migration completed: ${result.itemsAffected} items affected`);
119
- ```
120
-
121
- ### Data Replication
122
-
123
- ```typescript
124
- import { ReplicationManager } from '@affectively/aeon';
125
-
126
- const replicationManager = new ReplicationManager();
127
-
128
- // Create a replication policy
129
- const policy = replicationManager.createPolicy(
130
- 'user-data-policy',
131
- 3, // replication factor
132
- 'read-after-write', // consistency level
133
- 1000, // sync interval (ms)
134
- 10000 // max replication lag (ms)
135
- );
136
-
137
- // Register replicas
138
- replicationManager.registerReplica({
139
- id: 'replica-1',
140
- nodeId: 'node-1',
141
- status: 'primary',
142
- lastSyncTime: new Date().toISOString(),
143
- lagBytes: 0,
144
- lagMillis: 0,
145
- });
146
-
147
- // Check replication health
148
- const health = replicationManager.checkReplicationHealth(policy.id);
149
- console.log('Replication healthy:', health.healthy);
150
- ```
151
-
152
- ### Conflict Resolution
153
-
154
- ```typescript
155
- import { StateReconciler } from '@affectively/aeon';
156
-
157
- const reconciler = new StateReconciler();
158
-
159
- // Record state versions from different nodes
160
- reconciler.recordStateVersion('user:123', '1.0', '2024-01-01T00:00:00Z', 'node-1', 'hash-a', { name: 'Alice' });
161
- reconciler.recordStateVersion('user:123', '1.0', '2024-01-01T00:00:01Z', 'node-2', 'hash-b', { name: 'Bob' });
162
-
163
- // Detect conflicts
164
- if (reconciler.detectConflicts('user:123')) {
165
- // Reconcile using last-write-wins strategy
166
- const versions = reconciler.getStateVersions('user:123');
167
- const result = reconciler.reconcileLastWriteWins(versions);
168
-
169
- console.log('Resolved state:', result.mergedState);
170
- console.log('Conflicts resolved:', result.conflictsResolved);
171
- }
172
- ```
173
-
174
- ## Modules
175
-
176
- ### Core (`@affectively/aeon/core`)
177
-
178
- Shared types and utilities used across all modules.
179
-
180
- ```typescript
181
- import type { Operation, VectorClock, PresenceInfo } from '@affectively/aeon/core';
182
- ```
183
-
184
- ### Persistence (`@affectively/aeon/persistence`)
185
-
186
- Optional persistence boundaries and adapters for durable Aeon state.
187
-
188
- - `StorageAdapter` - runtime-agnostic adapter contract
189
- - `InMemoryStorageAdapter` - reference adapter for tests/dev
190
- - `DashStorageAdapter` - local-first adapter with optional debounced sync batching for D1/R2-backed resilience
191
-
192
- ### Offline (`@affectively/aeon/offline`)
193
-
194
- Offline-first operation management.
195
-
196
- - `OfflineOperationQueue` - Priority-based offline operation queue with retry logic
197
-
198
- ### Compression (`@affectively/aeon/compression`)
199
-
200
- Data compression and delta sync optimization.
201
-
202
- - `CompressionEngine` - Native compression using CompressionStream API
203
- - `DeltaSyncOptimizer` - Field-level change detection (70-90% payload reduction)
204
-
205
- ### Optimization (`@affectively/aeon/optimization`)
206
-
207
- Network and performance optimization.
208
-
209
- - `PrefetchingEngine` - Predictive pre-compression based on operation patterns
210
- - `BatchTimingOptimizer` - Intelligent batch scheduling based on network conditions
211
- - `AdaptiveCompressionOptimizer` - Auto-adjusting compression level (1-9)
212
-
213
- ### Presence (`@affectively/aeon/presence`)
214
-
215
- Real-time agent presence tracking.
216
-
217
- - `AgentPresenceManager` - Track agent status, cursors, and activity
218
-
219
- ### Versioning (`@affectively/aeon/versioning`)
220
-
221
- Schema versioning and migration system.
222
-
223
- - `SchemaVersionManager` - Version tracking and compatibility
224
- - `MigrationEngine` - Migration execution and rollback
225
- - `DataTransformer` - Data transformation during migrations
226
- - `MigrationTracker` - Migration history and audit trails
227
-
228
- ### Distributed (`@affectively/aeon/distributed`)
229
-
230
- Distributed synchronization primitives.
231
-
232
- - `SyncCoordinator` - Sync session management
233
- - `ReplicationManager` - Replica management and policies
234
- - `SyncProtocol` - Protocol messages and handshaking
235
- - `StateReconciler` - Conflict detection and resolution
236
-
237
- ### Utils (`@affectively/aeon/utils`)
238
-
239
- Shared utilities including pluggable logging.
240
-
241
- ```typescript
242
- import { setLogger, disableLogging } from '@affectively/aeon/utils';
243
-
244
- // Use custom logger
245
- setLogger({
246
- debug: (...args) => myLogger.debug(...args),
247
- info: (...args) => myLogger.info(...args),
248
- warn: (...args) => myLogger.warn(...args),
249
- error: (...args) => myLogger.error(...args),
250
- });
251
-
252
- // Or disable logging entirely
253
- disableLogging();
254
- ```
255
-
256
- ## API Reference
257
-
258
- ### SyncCoordinator
259
-
260
- | Method | Description |
261
- |--------|-------------|
262
- | `registerNode(node)` | Register a node in the cluster |
263
- | `deregisterNode(nodeId)` | Remove a node from the cluster |
264
- | `createSyncSession(initiatorId, participantIds)` | Create a new sync session |
265
- | `updateSyncSession(sessionId, updates)` | Update sync session status |
266
- | `recordConflict(sessionId, nodeId, data)` | Record a conflict |
267
- | `getStatistics()` | Get sync statistics |
268
- | `startHeartbeatMonitoring(interval)` | Start health monitoring |
269
-
270
- ### SchemaVersionManager
271
-
272
- | Method | Description |
273
- |--------|-------------|
274
- | `registerVersion(version)` | Register a schema version |
275
- | `getCurrentVersion()` | Get current active version |
276
- | `setCurrentVersion(version)` | Set the current version |
277
- | `canMigrate(from, to)` | Check if migration path exists |
278
- | `getMigrationPath(from, to)` | Get migration steps |
279
- | `compareVersions(v1, v2)` | Compare two versions |
280
-
281
- ### MigrationEngine
282
-
283
- | Method | Description |
284
- |--------|-------------|
285
- | `registerMigration(migration)` | Register a migration |
286
- | `executeMigration(id, data)` | Execute a migration |
287
- | `rollbackMigration(id, data)` | Rollback a migration |
288
- | `getState()` | Get current migration state |
289
- | `getPendingMigrations()` | Get pending migrations |
290
- | `getStatistics()` | Get migration statistics |
291
-
292
- ### ReplicationManager
293
-
294
- | Method | Description |
295
- |--------|-------------|
296
- | `registerReplica(replica)` | Register a replica |
297
- | `removeReplica(replicaId)` | Remove a replica |
298
- | `createPolicy(...)` | Create replication policy |
299
- | `updateReplicaStatus(...)` | Update replica status |
300
- | `checkReplicationHealth(policyId)` | Check replication health |
301
- | `getStatistics()` | Get replication statistics |
302
-
303
- ### StateReconciler
304
-
305
- | Method | Description |
306
- |--------|-------------|
307
- | `recordStateVersion(...)` | Record a state version |
308
- | `detectConflicts(key)` | Detect state conflicts |
309
- | `compareStates(s1, s2)` | Generate state diff |
310
- | `reconcileLastWriteWins(versions)` | LWW reconciliation |
311
- | `reconcileVectorClock(versions)` | Vector clock reconciliation |
312
- | `reconcileMajorityVote(versions)` | Majority vote reconciliation |
313
-
314
- ## Comparison with Similar Libraries
315
-
316
- | Feature | Aeon | Yjs | Automerge |
317
- |---------|------|-----|-----------|
318
- | Schema Versioning | ✅ | ❌ | ❌ |
319
- | Migrations | ✅ | ❌ | ❌ |
320
- | Replication Policies | ✅ | ❌ | ❌ |
321
- | Multiple Merge Strategies | ✅ | ⚠️ | ⚠️ |
322
- | TypeScript-first | ✅ | ⚠️ | ⚠️ |
323
- | Zero Dependencies* | ✅ | ❌ | ❌ |
324
-
325
- *Only `eventemitter3` for event handling
326
-
327
- ## Requirements
328
-
329
- - Node.js >= 18.0.0
330
- - TypeScript >= 5.0.0 (for types)
331
-
332
- ## Contributing
333
-
334
- Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
335
-
336
- ## License
337
-
338
- MIT - see [LICENSE](LICENSE) for details.
339
-
340
- ## Credits
341
-
342
- Built with care by [Affectively AI](https://github.com/affectively-ai).
1
+ # Aeon
2
+
3
+ > Distributed synchronization, schema versioning, and conflict resolution for real-time collaborative applications.
4
+
5
+ [![npm version](https://badge.fury.io/js/@affectively%2Faeon.svg)](https://www.npmjs.com/package/@affectively/aeon)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.6+-blue.svg)](https://www.typescriptlang.org/)
8
+
9
+ ## Philosophy
10
+
11
+ In Gnosticism, **Aeons** are not just time periods; they are divine beings or powers that emanate from the "One" (the Pleroma). They function as links or "levels" between the pure divine source and the material world, often existing in pairs (syzygies) to maintain balance.
12
+
13
+ In the Affectively framework, if "halos" are the users, then **Aeons are the collaborative structures** - the channels that allow users to communicate with the higher-level logic of the platform. They bridge the gap between individual user state and the distributed system, maintaining harmony across the network.
14
+
15
+ ## Overview
16
+
17
+ **Aeon** is a comprehensive TypeScript library for building distributed, collaborative applications. It provides the primitives needed for:
18
+
19
+ - **Distributed Synchronization** - Coordinate sync sessions across multiple nodes
20
+ - **Schema Versioning** - Manage schema evolution with migrations and rollbacks
21
+ - **Data Replication** - Configure consistency levels and replication policies
22
+ - **Conflict Resolution** - Multiple strategies for resolving divergent state
23
+ - **Real-time Presence** - Track node health and status in real-time
24
+
25
+ Roadmap vision: see [ROADMAP.md](./ROADMAP.md).
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ npm install @affectively/aeon
31
+ # or
32
+ yarn add @affectively/aeon
33
+ # or
34
+ pnpm add @affectively/aeon
35
+ # or
36
+ bun add @affectively/aeon
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ### Distributed Synchronization
42
+
43
+ ```typescript
44
+ import { SyncCoordinator } from '@affectively/aeon';
45
+
46
+ // Create a sync coordinator
47
+ const coordinator = new SyncCoordinator();
48
+
49
+ // Register nodes
50
+ coordinator.registerNode({
51
+ id: 'node-1',
52
+ address: 'localhost',
53
+ port: 3000,
54
+ status: 'online',
55
+ lastHeartbeat: new Date().toISOString(),
56
+ version: '1.0.0',
57
+ capabilities: ['sync', 'replicate'],
58
+ });
59
+
60
+ // Create a sync session
61
+ const session = coordinator.createSyncSession('node-1', ['node-2', 'node-3']);
62
+
63
+ // Listen for sync events
64
+ coordinator.on('sync-completed', (session) => {
65
+ console.log(`Session ${session.id} completed:`, session.itemsSynced, 'items synced');
66
+ });
67
+
68
+ // Start heartbeat monitoring
69
+ coordinator.startHeartbeatMonitoring(5000);
70
+ ```
71
+
72
+ ### Schema Versioning & Migrations
73
+
74
+ ```typescript
75
+ import { SchemaVersionManager, MigrationEngine, MigrationTracker } from '@affectively/aeon';
76
+
77
+ // Initialize version manager
78
+ const versionManager = new SchemaVersionManager();
79
+
80
+ // Register schema versions
81
+ versionManager.registerVersion({
82
+ major: 1,
83
+ minor: 0,
84
+ patch: 0,
85
+ timestamp: new Date().toISOString(),
86
+ description: 'Initial schema',
87
+ breaking: false,
88
+ });
89
+
90
+ versionManager.registerVersion({
91
+ major: 2,
92
+ minor: 0,
93
+ patch: 0,
94
+ timestamp: new Date().toISOString(),
95
+ description: 'Added user status field',
96
+ breaking: true,
97
+ });
98
+
99
+ // Create migration engine
100
+ const migrationEngine = new MigrationEngine();
101
+
102
+ // Register a migration
103
+ migrationEngine.registerMigration({
104
+ id: 'add-status-field',
105
+ version: '2.0.0',
106
+ name: 'Add user status field',
107
+ up: (data) => ({ ...data, status: 'active' }),
108
+ down: (data) => {
109
+ const { status, ...rest } = data;
110
+ return rest;
111
+ },
112
+ timestamp: new Date().toISOString(),
113
+ description: 'Adds status field to all user records',
114
+ });
115
+
116
+ // Execute migration
117
+ const result = await migrationEngine.executeMigration('add-status-field', userData);
118
+ console.log(`Migration completed: ${result.itemsAffected} items affected`);
119
+ ```
120
+
121
+ ### Data Replication
122
+
123
+ ```typescript
124
+ import { ReplicationManager } from '@affectively/aeon';
125
+
126
+ const replicationManager = new ReplicationManager();
127
+
128
+ // Create a replication policy
129
+ const policy = replicationManager.createPolicy(
130
+ 'user-data-policy',
131
+ 3, // replication factor
132
+ 'read-after-write', // consistency level
133
+ 1000, // sync interval (ms)
134
+ 10000 // max replication lag (ms)
135
+ );
136
+
137
+ // Register replicas
138
+ replicationManager.registerReplica({
139
+ id: 'replica-1',
140
+ nodeId: 'node-1',
141
+ status: 'primary',
142
+ lastSyncTime: new Date().toISOString(),
143
+ lagBytes: 0,
144
+ lagMillis: 0,
145
+ });
146
+
147
+ // Check replication health
148
+ const health = replicationManager.checkReplicationHealth(policy.id);
149
+ console.log('Replication healthy:', health.healthy);
150
+ ```
151
+
152
+ ### Conflict Resolution
153
+
154
+ ```typescript
155
+ import { StateReconciler } from '@affectively/aeon';
156
+
157
+ const reconciler = new StateReconciler();
158
+
159
+ // Record state versions from different nodes
160
+ reconciler.recordStateVersion('user:123', '1.0', '2024-01-01T00:00:00Z', 'node-1', 'hash-a', { name: 'Alice' });
161
+ reconciler.recordStateVersion('user:123', '1.0', '2024-01-01T00:00:01Z', 'node-2', 'hash-b', { name: 'Bob' });
162
+
163
+ // Detect conflicts
164
+ if (reconciler.detectConflicts('user:123')) {
165
+ // Reconcile using last-write-wins strategy
166
+ const versions = reconciler.getStateVersions('user:123');
167
+ const result = reconciler.reconcileLastWriteWins(versions);
168
+
169
+ console.log('Resolved state:', result.mergedState);
170
+ console.log('Conflicts resolved:', result.conflictsResolved);
171
+ }
172
+ ```
173
+
174
+ ## Modules
175
+
176
+ ### Core (`@affectively/aeon/core`)
177
+
178
+ Shared types and utilities used across all modules.
179
+
180
+ ```typescript
181
+ import type { Operation, VectorClock, PresenceInfo } from '@affectively/aeon/core';
182
+ ```
183
+
184
+ ### Persistence (`@affectively/aeon/persistence`)
185
+
186
+ Optional persistence boundaries and adapters for durable Aeon state.
187
+
188
+ - `StorageAdapter` - runtime-agnostic adapter contract
189
+ - `InMemoryStorageAdapter` - reference adapter for tests/dev
190
+ - `DashStorageAdapter` - local-first adapter with optional debounced sync batching for D1/R2-backed resilience
191
+
192
+ ### Offline (`@affectively/aeon/offline`)
193
+
194
+ Offline-first operation management.
195
+
196
+ - `OfflineOperationQueue` - Priority-based offline operation queue with retry logic
197
+
198
+ ### Compression (`@affectively/aeon/compression`)
199
+
200
+ Data compression and delta sync optimization.
201
+
202
+ - `CompressionEngine` - Native compression using CompressionStream API
203
+ - `DeltaSyncOptimizer` - Field-level change detection (70-90% payload reduction)
204
+
205
+ ### Optimization (`@affectively/aeon/optimization`)
206
+
207
+ Network and performance optimization.
208
+
209
+ - `PrefetchingEngine` - Predictive pre-compression based on operation patterns
210
+ - `BatchTimingOptimizer` - Intelligent batch scheduling based on network conditions
211
+ - `AdaptiveCompressionOptimizer` - Auto-adjusting compression level (1-9)
212
+
213
+ ### Presence (`@affectively/aeon/presence`)
214
+
215
+ Real-time agent presence tracking.
216
+
217
+ - `AgentPresenceManager` - Track agent status, cursors, and activity
218
+
219
+ ### Versioning (`@affectively/aeon/versioning`)
220
+
221
+ Schema versioning and migration system.
222
+
223
+ - `SchemaVersionManager` - Version tracking and compatibility
224
+ - `MigrationEngine` - Migration execution and rollback
225
+ - `DataTransformer` - Data transformation during migrations
226
+ - `MigrationTracker` - Migration history and audit trails
227
+
228
+ ### Distributed (`@affectively/aeon/distributed`)
229
+
230
+ Distributed synchronization primitives.
231
+
232
+ - `SyncCoordinator` - Sync session management
233
+ - `ReplicationManager` - Replica management and policies
234
+ - `SyncProtocol` - Protocol messages and handshaking
235
+ - `StateReconciler` - Conflict detection and resolution
236
+
237
+ ### Utils (`@affectively/aeon/utils`)
238
+
239
+ Shared utilities including pluggable logging.
240
+
241
+ ```typescript
242
+ import { setLogger, disableLogging } from '@affectively/aeon/utils';
243
+
244
+ // Use custom logger
245
+ setLogger({
246
+ debug: (...args) => myLogger.debug(...args),
247
+ info: (...args) => myLogger.info(...args),
248
+ warn: (...args) => myLogger.warn(...args),
249
+ error: (...args) => myLogger.error(...args),
250
+ });
251
+
252
+ // Or disable logging entirely
253
+ disableLogging();
254
+ ```
255
+
256
+ ## API Reference
257
+
258
+ ### SyncCoordinator
259
+
260
+ | Method | Description |
261
+ |--------|-------------|
262
+ | `registerNode(node)` | Register a node in the cluster |
263
+ | `deregisterNode(nodeId)` | Remove a node from the cluster |
264
+ | `createSyncSession(initiatorId, participantIds)` | Create a new sync session |
265
+ | `updateSyncSession(sessionId, updates)` | Update sync session status |
266
+ | `recordConflict(sessionId, nodeId, data)` | Record a conflict |
267
+ | `getStatistics()` | Get sync statistics |
268
+ | `startHeartbeatMonitoring(interval)` | Start health monitoring |
269
+
270
+ ### SchemaVersionManager
271
+
272
+ | Method | Description |
273
+ |--------|-------------|
274
+ | `registerVersion(version)` | Register a schema version |
275
+ | `getCurrentVersion()` | Get current active version |
276
+ | `setCurrentVersion(version)` | Set the current version |
277
+ | `canMigrate(from, to)` | Check if migration path exists |
278
+ | `getMigrationPath(from, to)` | Get migration steps |
279
+ | `compareVersions(v1, v2)` | Compare two versions |
280
+
281
+ ### MigrationEngine
282
+
283
+ | Method | Description |
284
+ |--------|-------------|
285
+ | `registerMigration(migration)` | Register a migration |
286
+ | `executeMigration(id, data)` | Execute a migration |
287
+ | `rollbackMigration(id, data)` | Rollback a migration |
288
+ | `getState()` | Get current migration state |
289
+ | `getPendingMigrations()` | Get pending migrations |
290
+ | `getStatistics()` | Get migration statistics |
291
+
292
+ ### ReplicationManager
293
+
294
+ | Method | Description |
295
+ |--------|-------------|
296
+ | `registerReplica(replica)` | Register a replica |
297
+ | `removeReplica(replicaId)` | Remove a replica |
298
+ | `createPolicy(...)` | Create replication policy |
299
+ | `updateReplicaStatus(...)` | Update replica status |
300
+ | `checkReplicationHealth(policyId)` | Check replication health |
301
+ | `getStatistics()` | Get replication statistics |
302
+
303
+ ### StateReconciler
304
+
305
+ | Method | Description |
306
+ |--------|-------------|
307
+ | `recordStateVersion(...)` | Record a state version |
308
+ | `detectConflicts(key)` | Detect state conflicts |
309
+ | `compareStates(s1, s2)` | Generate state diff |
310
+ | `reconcileLastWriteWins(versions)` | LWW reconciliation |
311
+ | `reconcileVectorClock(versions)` | Vector clock reconciliation |
312
+ | `reconcileMajorityVote(versions)` | Majority vote reconciliation |
313
+
314
+ ## Comparison with Similar Libraries
315
+
316
+ | Feature | Aeon | Yjs | Automerge |
317
+ |---------|------|-----|-----------|
318
+ | Schema Versioning | ✅ | ❌ | ❌ |
319
+ | Migrations | ✅ | ❌ | ❌ |
320
+ | Replication Policies | ✅ | ❌ | ❌ |
321
+ | Multiple Merge Strategies | ✅ | ⚠️ | ⚠️ |
322
+ | TypeScript-first | ✅ | ⚠️ | ⚠️ |
323
+ | Zero Dependencies* | ✅ | ❌ | ❌ |
324
+
325
+ *Only `eventemitter3` for event handling
326
+
327
+ ## Requirements
328
+
329
+ - Node.js >= 18.0.0
330
+ - TypeScript >= 5.0.0 (for types)
331
+
332
+ ## Contributing
333
+
334
+ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
335
+
336
+ ## License
337
+
338
+ MIT - see [LICENSE](LICENSE) for details.
339
+
340
+ ## Credits
341
+
342
+ Built with care by [Affectively AI](https://github.com/affectively-ai).