@ibgib/core-gib 0.1.13 → 0.1.15

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 (104) hide show
  1. package/dist/keystone/keystone-helpers.mjs +3 -3
  2. package/dist/keystone/keystone-helpers.mjs.map +1 -1
  3. package/dist/sync/sync-constants.d.mts +6 -1
  4. package/dist/sync/sync-constants.d.mts.map +1 -1
  5. package/dist/sync/sync-constants.mjs +5 -0
  6. package/dist/sync/sync-constants.mjs.map +1 -1
  7. package/dist/sync/sync-helpers.d.mts +18 -2
  8. package/dist/sync/sync-helpers.d.mts.map +1 -1
  9. package/dist/sync/sync-helpers.mjs +84 -3
  10. package/dist/sync/sync-helpers.mjs.map +1 -1
  11. package/dist/sync/sync-innerspace.respec.d.mts +1 -1
  12. package/dist/sync/sync-innerspace.respec.mjs +52 -370
  13. package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
  14. package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts +39 -0
  15. package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts.map +1 -0
  16. package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs +112 -0
  17. package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs.map +1 -0
  18. package/dist/sync/sync-peer/sync-peer-types.d.mts +30 -0
  19. package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -0
  20. package/dist/sync/sync-peer/sync-peer-types.mjs +5 -0
  21. package/dist/sync/sync-peer/sync-peer-types.mjs.map +1 -0
  22. package/dist/sync/sync-peer/sync-peer-v1.d.mts +22 -0
  23. package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -0
  24. package/dist/sync/sync-peer/sync-peer-v1.mjs +13 -0
  25. package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -0
  26. package/dist/sync/sync-saga-context/sync-saga-context-constants.d.mts +8 -0
  27. package/dist/sync/sync-saga-context/sync-saga-context-constants.d.mts.map +1 -0
  28. package/dist/sync/sync-saga-context/sync-saga-context-constants.mjs +8 -0
  29. package/dist/sync/sync-saga-context/sync-saga-context-constants.mjs.map +1 -0
  30. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +54 -0
  31. package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -0
  32. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +87 -0
  33. package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -0
  34. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +66 -0
  35. package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -0
  36. package/dist/sync/sync-saga-context/sync-saga-context-types.mjs +12 -0
  37. package/dist/sync/sync-saga-context/sync-saga-context-types.mjs.map +1 -0
  38. package/dist/sync/sync-saga-coordinator.d.mts +201 -121
  39. package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
  40. package/dist/sync/sync-saga-coordinator.mjs +710 -434
  41. package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
  42. package/dist/sync/sync-saga-coordinator.respec.mjs +7 -7
  43. package/dist/sync/sync-saga-coordinator.respec.mjs.map +1 -1
  44. package/dist/sync/sync-saga-message/sync-saga-message-constants.d.mts +2 -0
  45. package/dist/sync/sync-saga-message/sync-saga-message-constants.d.mts.map +1 -0
  46. package/dist/sync/sync-saga-message/sync-saga-message-constants.mjs +2 -0
  47. package/dist/sync/sync-saga-message/sync-saga-message-constants.mjs.map +1 -0
  48. package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts +15 -0
  49. package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts.map +1 -0
  50. package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs +43 -0
  51. package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs.map +1 -0
  52. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +51 -0
  53. package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -0
  54. package/dist/sync/sync-saga-message/sync-saga-message-types.mjs +2 -0
  55. package/dist/sync/sync-saga-message/sync-saga-message-types.mjs.map +1 -0
  56. package/dist/sync/sync-types.d.mts +85 -4
  57. package/dist/sync/sync-types.d.mts.map +1 -1
  58. package/dist/sync/sync-types.mjs +27 -1
  59. package/dist/sync/sync-types.mjs.map +1 -1
  60. package/dist/timeline/timeline-api.d.mts +16 -3
  61. package/dist/timeline/timeline-api.d.mts.map +1 -1
  62. package/dist/timeline/timeline-api.mjs +7 -7
  63. package/dist/timeline/timeline-api.mjs.map +1 -1
  64. package/dist/witness/space/outer-space/outer-space-types.d.mts +2 -0
  65. package/dist/witness/space/outer-space/outer-space-types.d.mts.map +1 -1
  66. package/dist/witness/space/space-base-v1.d.mts +19 -1
  67. package/dist/witness/space/space-base-v1.d.mts.map +1 -1
  68. package/dist/witness/space/space-base-v1.mjs +66 -6
  69. package/dist/witness/space/space-base-v1.mjs.map +1 -1
  70. package/dist/witness/space/space-helper.d.mts +14 -0
  71. package/dist/witness/space/space-helper.d.mts.map +1 -1
  72. package/dist/witness/space/space-helper.mjs +44 -1
  73. package/dist/witness/space/space-helper.mjs.map +1 -1
  74. package/dist/witness/space/space-respec-helper.d.mts.map +1 -1
  75. package/dist/witness/space/space-respec-helper.mjs +1 -1
  76. package/dist/witness/space/space-respec-helper.mjs.map +1 -1
  77. package/dist/witness/space/space-types.d.mts +12 -1
  78. package/dist/witness/space/space-types.d.mts.map +1 -1
  79. package/dist/witness/space/space-types.mjs +4 -0
  80. package/dist/witness/space/space-types.mjs.map +1 -1
  81. package/package.json +2 -2
  82. package/src/keystone/keystone-helpers.mts +3 -3
  83. package/src/sync/README.md +275 -0
  84. package/src/sync/sync-constants.mts +9 -1
  85. package/src/sync/sync-helpers.mts +105 -6
  86. package/src/sync/sync-innerspace.respec.mts +55 -402
  87. package/src/sync/sync-peer/sync-peer-innerspace-v1.mts +150 -0
  88. package/src/sync/sync-peer/sync-peer-types.mts +43 -0
  89. package/src/sync/sync-peer/sync-peer-v1.mts +28 -0
  90. package/src/sync/sync-saga-context/sync-saga-context-constants.mts +8 -0
  91. package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +147 -0
  92. package/src/sync/sync-saga-context/sync-saga-context-types.mts +80 -0
  93. package/src/sync/sync-saga-coordinator.mts +913 -517
  94. package/src/sync/sync-saga-coordinator.respec.mts +7 -7
  95. package/src/sync/sync-saga-message/sync-saga-message-constants.mts +1 -0
  96. package/src/sync/sync-saga-message/sync-saga-message-helpers.mts +59 -0
  97. package/src/sync/sync-saga-message/sync-saga-message-types.mts +66 -0
  98. package/src/sync/sync-types.mts +107 -4
  99. package/src/timeline/timeline-api.mts +20 -4
  100. package/src/witness/space/space-base-v1.mts +62 -12
  101. package/src/witness/space/space-helper.mts +50 -1
  102. package/src/witness/space/space-respec-helper.mts +2 -1
  103. package/src/witness/space/space-types.mts +13 -1
  104. package/tmp.md +122 -4
@@ -2,114 +2,82 @@ import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
2
2
  import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs";
3
3
  import { KeystoneIbGib_V1 } from "../keystone/keystone-types.mjs";
4
4
  import { KeystoneService_V1 } from "../keystone/keystone-service-v1.mjs";
5
+ import { MetaspaceService } from "../witness/space/metaspace/metaspace-types.mjs";
6
+ import { SyncStage } from "./sync-constants.mjs";
5
7
  import { SyncIbGib_V1 } from "./sync-types.mjs";
6
- export interface SyncOptions {
7
- /**
8
- * The space containing the data we want to send.
9
- */
10
- source: IbGibSpaceAny;
11
- /**
12
- * The space receiving the data.
13
- */
14
- dest: IbGibSpaceAny;
15
- /**
16
- * The identity authorizing this sync.
17
- */
18
- identity: KeystoneIbGib_V1;
19
- /**
20
- * The secret for the identity (to sign the commit).
21
- */
22
- identitySecret: string;
23
- /**
24
- * How to handle conflicts when both Source and Dest have diverged on the same timeline.
25
- * @default 'abort'
26
- */
27
- conflictStrategy?: SyncConflictStrategy;
28
- }
29
- export type SyncConflictStrategy = 'abort' | 'optimistic' | 'manual';
8
+ import { SyncSagaMessageData_V1 } from "./sync-saga-message/sync-saga-message-types.mjs";
9
+ import { Subject_V1 } from "../common/pubsub/subject/subject-v1.mjs";
10
+ import { SyncSagaInfo } from "./sync-types.mjs";
11
+ import { SyncPeerWitness } from "./sync-peer/sync-peer-types.mjs";
12
+ import { SyncSagaContextIbGib_V1 } from "./sync-saga-context/sync-saga-context-types.mjs";
30
13
  /**
31
14
  * Orchestrates the synchronization process between two spaces (Source and Destination).
32
15
  *
33
- * ## Architecture: Dependency Graph Synchronization
34
- *
35
- * Instead of a naive file-by-file sync or a holistic "Space" sync, this coordinator operates
36
- * on a **Dependency Graph** derived from specific "Domain Roots" (e.g., a specific tag,
37
- * folder, or application root).
38
- *
39
- * ### Workflow Pipeline
40
- *
41
- * 1. **Graph Generation**:
42
- * * Generates a `FlatIbGibGraph` using `getDependencyGraph({ live: true })` starting
43
- * from the provided `domainIbGibs`.
44
- * * This ensures we capture the *latest* reachable state of all relevant timelines.
45
- *
46
- * 2. **Classification (`splitPerTjpAndOrDna`)**:
47
- * * **Stones**: Immutable, non-living ibGibs (no TJP/DNA). Trivial to sync (copy if missing).
48
- * * **Living**: Evolving timelines (TJP + DNA). Complex to sync (require ordering & merging).
16
+ * ## Execution Contexts
49
17
  *
50
- * 3. **Timeline Ordering (`getTimelinesGroupedByTjp`)**:
51
- * * Living ibGibs are grouped into timelines.
52
- * * A "Timeline Dependency Graph" is built. Use Case: If a Comment Timeline refers to a
53
- * Post Timeline, the Post Timeline must be synced *before* the Comment Timeline to
54
- * ensure referential integrity at the destination.
55
- * * **Topological Sort** determines the execution order. Circular dependencies are
56
- * treated as siblings.
18
+ * The methods in this class are designed to be run on specific nodes in the sync topology:
57
19
  *
58
- * 4. **Saga Execution ("Smart Coordinator, Dumb Space")**:
59
- * * The Coordinator (running on the Client/Source) drives the entire process via a
60
- * "Pull-Merge-Push" strategy to resolve conflicts.
20
+ * * **Sender/Local Node**: The node *initiating* the sync (calling `sync()`).
21
+ * * **Receiver/Remote Node**: The node *accepting* the sync request (the Peer).
61
22
  *
62
- * * **Phase 1: Knowledge Exchange (Init)**
63
- * * Generates a "Knowledge Vector" (Map<Tjp, LatestAddr>) of the Source's graph.
64
- * * Sends `SyncStage.Init` to Dest.
65
- * * Dest responds with its own Knowledge Vector for overlapping timelines.
66
- *
67
- * * **Phase 2: Gap Analysis & Conflict Resolution**
68
- * * Coordinator compares Source vs. Dest knowledge.
69
- * * **Fast-Forward**: Source is strictly ahead of Dest. Mark new frames for PUSH.
70
- * * **Fast-Backward**: Dest is strictly ahead of Source. Mark frames for PULL (to update Local).
71
- * * **Conflict/Divergence**: Both have new frames from a common ancestor.
72
- * * **LOCK**: `lockSpace({ scope: tjpGib })` on Dest to prevent race conditions.
73
- * * **PULL**: Download conflicting branch from Dest.
74
- * * **MERGE**: Execute merge logic locally (creating a new merge frame `A_merge`).
75
- * * **PUSH**: Mark `A_merge` (and dependencies) for PUSH.
76
- * * **UNLOCK**: Release Dest lock.
77
- *
78
- * * **Phase 3: Batch Streaming (Delta)**
79
- * * **Stones**: Batch `putInSpace` all missing "Stone" ibGibs first.
80
- * * **Timelines**: Batch `putInSpace` Living Timelines in topological order.
81
- * * *Note*: The `SyncFrame` (Init/Delta/Commit) tracks protocol state, but data transfer
82
- * happens via standard `putInSpace`.
83
- *
84
- * * **Phase 4: Commit**
85
- * * Update Local Index (register new latests).
86
- * * Send `SyncStage.Commit` to Dest to finalize session.
23
+ * Note that in a peer-to-peer architecture, "Sender" and "Receiver" are roles relative
24
+ * to a specific Saga session, not fixed node identities.
87
25
  */
88
26
  export declare class SyncSagaCoordinator {
89
27
  protected keystone: KeystoneService_V1;
90
28
  protected lc: string;
91
29
  constructor(keystone: KeystoneService_V1);
92
30
  /**
93
- * Executes a synchronization saga.
31
+ * Executes a synchronization saga using the Symmetric Sync Protocol.
94
32
  *
95
- * @param opts.source The local space (Client) driving the sync.
96
- * @param opts.dest The remote space (Server/Other Peer) to sync with.
97
- * @param opts.identity The Keystone Identity performing the sync.
98
- * @param opts.domainIbGibs The root ibGibs that define the scope of the sync (the "Dependency Graph").
99
- * @param opts.identitySecret Optional secret if needed (usually handled by `keystone` service).
33
+ * @remarks
34
+ * **Execution Context**: **Sender (Local)**.
35
+ * This method is the entry point for starting a sync session.
36
+ *
37
+ * @param opts.peer - The remote peer witness to communicate with.
38
+ * @param opts.localSpace - The local space that will be read from and written to.
39
+ * @param opts.metaspace - Service for creating temp spaces and managing ibgibs.
40
+ * @param opts.domainIbGibs - The root ibgibs defining the scope of the sync.
41
+ * @param opts.useSessionIdentity - (Optional) Whether to create an ephemeral session identity. Default: true.
100
42
  */
101
- sync({ source, dest, identity, domainIbGibs, identitySecret, conflictStrategy }: {
102
- source: IbGibSpaceAny;
103
- dest: IbGibSpaceAny;
104
- identity: KeystoneIbGib_V1;
43
+ sync({ peer, localSpace, metaspace, domainIbGibs, useSessionIdentity, }: {
44
+ peer: SyncPeerWitness;
45
+ localSpace: IbGibSpaceAny;
46
+ metaspace: MetaspaceService;
105
47
  domainIbGibs: IbGib_V1[];
106
- identitySecret?: string;
107
- conflictStrategy?: SyncConflictStrategy;
108
- }): Promise<void>;
48
+ useSessionIdentity?: boolean;
49
+ }): Promise<SyncSagaInfo>;
50
+ protected getSessionIdentity({ sagaId, metaspace, tempSpace, }: {
51
+ sagaId: string;
52
+ metaspace: MetaspaceService;
53
+ tempSpace: IbGibSpaceAny;
54
+ }): Promise<KeystoneIbGib_V1>;
109
55
  /**
110
- * Analyses the timelines in the provided graph, classifying them into stones and living timelines,
111
- * and performing topological sort on the timelines.
56
+ * Drives the FSM loop of the Saga.
57
+ *
58
+ * @remarks
59
+ * **Execution Context**: **Sender (Local)**.
60
+ *
61
+ * This method manages the "Ping Pong" request-response cycle on the Sender.
62
+ * It sends frames via the Peer Witness and processes the responses using `handleSagaFrame`.
63
+ *
64
+ * **Data Transport Note**:
65
+ * Actual ibGib data (payloads) are transported via `SyncSagaContext.rel8ns.payload`.
66
+ * When `handleSagaFrame` returns a `nextPayloadIbGibs` (data to send), this loop injects it into
67
+ * the NEXT request context.
68
+ * When the Peer responds with data (in the response context), it is resolved and put into `tempSpace`.
112
69
  */
70
+ protected executeSagaLoop({ initialFrame, srcGraph, peer, sessionIdentity, updates$, tempSpace, metaspace }: {
71
+ initialFrame: SyncIbGib_V1;
72
+ srcGraph: {
73
+ [addr: string]: IbGib_V1;
74
+ };
75
+ peer: SyncPeerWitness;
76
+ sessionIdentity?: KeystoneIbGib_V1;
77
+ updates$: Subject_V1<SyncSagaContextIbGib_V1>;
78
+ tempSpace: IbGibSpaceAny;
79
+ metaspace: MetaspaceService;
80
+ }): Promise<IbGib_V1[]>;
113
81
  protected analyzeTimelines({ domainIbGibs, space, }: {
114
82
  domainIbGibs: IbGib_V1[];
115
83
  space: IbGibSpaceAny;
@@ -123,51 +91,163 @@ export declare class SyncSagaCoordinator {
123
91
  [addr: string]: IbGib_V1;
124
92
  };
125
93
  }>;
126
- protected resolveConflicts({ source, dest, srcTimelinesMap, srcKnowledgeVector, srcGraph, uuid, conflictStrategy, }: {
127
- source: IbGibSpaceAny;
128
- dest: IbGibSpaceAny;
129
- srcTimelinesMap: {
130
- [tjp: string]: IbGib_V1[];
94
+ /**
95
+ * Creates the Initial Saga Frame (Init Stage).
96
+ *
97
+ * @remarks
98
+ * **Execution Context**: **Sender (Local)**.
99
+ *
100
+ * Generates the first frame containing the Knowledge Vector of the Local Space.
101
+ * This is sent to the Receiver to begin Gap Analysis.
102
+ */
103
+ protected createInitFrame({ sagaId, sessionIdentity, localSpace, domainIbGibs, tempSpace, metaspace }: {
104
+ sagaId: string;
105
+ sessionIdentity?: KeystoneIbGib_V1;
106
+ localSpace: IbGibSpaceAny;
107
+ domainIbGibs: IbGib_V1[];
108
+ tempSpace: IbGibSpaceAny;
109
+ metaspace: MetaspaceService;
110
+ }): Promise<{
111
+ sagaFrame: SyncIbGib_V1;
112
+ srcGraph: {
113
+ [addr: string]: IbGib_V1;
131
114
  };
132
- srcKnowledgeVector: {
133
- [tjp: string]: string;
115
+ }>;
116
+ /**
117
+ * Reacts to an incoming saga frame and dispatches to appropriate handler.
118
+ *
119
+ * @remarks
120
+ * **Execution Context**: **Universal (Both Sender and Receiver)**.
121
+ *
122
+ * This method acts as the "Reducer" for the Sync FSM. It determines the current stage
123
+ * based on the incoming frame and delegates to the appropriate handler.
124
+ *
125
+ * * If running on **Receiver**: Handles `Init` (via `handleInitFrame`).
126
+ * * If running on **Sender**: Handles `Ack` (via `handleAckFrame`).
127
+ * * If running on **Either**: Handles `Delta` (via `handleDeltaFrame`) or `Commit`.
128
+ */
129
+ handleSagaFrame({ sagaIbGib, srcGraph, space, identity, identitySecret, metaspace, }: {
130
+ sagaIbGib: SyncIbGib_V1;
131
+ srcGraph: {
132
+ [addr: string]: IbGib_V1;
134
133
  };
134
+ space: IbGibSpaceAny;
135
+ identity?: KeystoneIbGib_V1;
136
+ identitySecret?: string;
137
+ metaspace: MetaspaceService;
138
+ }): Promise<{
139
+ frame: SyncIbGib_V1;
140
+ payloadIbGibs?: IbGib_V1[];
141
+ receivedPayloadIbGibs?: IbGib_V1[];
142
+ } | null>;
143
+ /**
144
+ * Handles the `Init` frame.
145
+ *
146
+ * @remarks
147
+ * **Execution Context**: **Receiver (Remote)**.
148
+ *
149
+ * The Receiver performs Gap Analysis here:
150
+ * 1. Compares Sender's Knowledge Vector (in `sagaIbGib`) vs Receiver's Local KV.
151
+ * 2. Identifies what Sender needs (`pushOfferAddrs`).
152
+ * 3. Identifies what Receiver needs (`deltaReqAddrs`).
153
+ * 4. Returns an `Ack` frame containing these lists.
154
+ */
155
+ protected handleInitFrame({ sagaIbGib, messageData, space, metaspace, identity, identitySecret, }: {
156
+ sagaIbGib: SyncIbGib_V1;
157
+ messageData: any;
158
+ space: IbGibSpaceAny;
159
+ metaspace: MetaspaceService;
160
+ identity?: KeystoneIbGib_V1;
161
+ identitySecret?: string;
162
+ }): Promise<{
163
+ frame: SyncIbGib_V1;
164
+ payloadIbGibs?: IbGib_V1[];
165
+ } | null>;
166
+ /**
167
+ * Handles the `Ack` frame.
168
+ *
169
+ * @remarks
170
+ * **Execution Context**: **Sender (Local)**.
171
+ *
172
+ * The Sender reacts to the Receiver's requirements:
173
+ * 1. `deltaReqAddrs`: Receiver wants this data. Sender gathers it from `srcGraph` and puts it in `payloadIbGibs` (for next frame).
174
+ * 2. `pushOfferAddrs`: Receiver has newer data. Sender acknowledges and adds them to `requests` (asking Receiver to send them).
175
+ *
176
+ * Returns a `Delta` frame.
177
+ */
178
+ protected handleAckFrame({ sagaIbGib, srcGraph, space, metaspace, identity, }: {
179
+ sagaIbGib: SyncIbGib_V1;
135
180
  srcGraph: {
136
181
  [addr: string]: IbGib_V1;
137
182
  };
138
- uuid: string;
139
- conflictStrategy: SyncConflictStrategy;
140
- }): Promise<void>;
141
- protected processBatchStream({ dest, payloadAddrs, srcGraph }: {
142
- dest: IbGibSpaceAny;
143
- payloadAddrs: string[];
183
+ space: IbGibSpaceAny;
184
+ metaspace: MetaspaceService;
185
+ identity?: KeystoneIbGib_V1;
186
+ }): Promise<{
187
+ frame: SyncIbGib_V1;
188
+ payloadIbGibs?: IbGib_V1[];
189
+ } | null>;
190
+ /**
191
+ * Handles the `Delta` frame.
192
+ *
193
+ * @remarks
194
+ * **Execution Context**: **Both**.
195
+ *
196
+ * 1. **Ingestion**: Receives data sent by Peer (`payloadAddrs`). Resolves them from `Rel8ns.payload` (implicitly via space/context) and returns them in `receivedPayload` to be saved.
197
+ * 2. **Fulfillment**: Checks `requests`. If Peer requested data, gathers it and prepares `outgoingPayload`.
198
+ * 3. **Completion**: If no more requests, transitions to `Commit`.
199
+ */
200
+ protected handleDeltaFrame({ sagaIbGib, srcGraph, space, metaspace, identity, }: {
201
+ sagaIbGib: SyncIbGib_V1;
144
202
  srcGraph: {
145
203
  [addr: string]: IbGib_V1;
146
204
  };
147
- }): Promise<void>;
148
- protected createSyncFrame({ uuid, stage, payload, identity }: {
149
- uuid: string;
150
- stage: any;
151
- payload: any;
152
- identity: KeystoneIbGib_V1;
205
+ space: IbGibSpaceAny;
206
+ metaspace: MetaspaceService;
207
+ identity?: KeystoneIbGib_V1;
208
+ }): Promise<{
209
+ frame: SyncIbGib_V1;
210
+ payloadIbGibs?: IbGib_V1[];
211
+ receivedPayloadIbGibs?: IbGib_V1[];
212
+ } | null>;
213
+ protected handleCommitFrame({ sagaIbGib, space, }: {
214
+ sagaIbGib: SyncIbGib_V1;
215
+ space: IbGibSpaceAny;
216
+ }): Promise<{
217
+ frame: SyncIbGib_V1;
218
+ payloadIbGibs?: IbGib_V1[];
219
+ } | null>;
220
+ protected handleConflictFrame({ sagaIbGib, space, }: {
221
+ sagaIbGib: SyncIbGib_V1;
222
+ space: IbGibSpaceAny;
223
+ }): Promise<{
224
+ frame: SyncIbGib_V1;
225
+ payloadIbGibs?: IbGib_V1[];
226
+ } | null>;
227
+ protected createSyncMsgStone<TStoneData extends SyncSagaMessageData_V1>({ data, space, metaspace, }: {
228
+ data: TStoneData;
229
+ space: IbGibSpaceAny;
230
+ metaspace: MetaspaceService;
231
+ }): Promise<IbGib_V1<TStoneData>>;
232
+ /**
233
+ * Evolves the saga timeline with a new frame.
234
+ */
235
+ protected evolveSyncSagaIbGib({ prevSagaIbGib, msgStones, identity, space, metaspace, }: {
236
+ prevSagaIbGib?: SyncIbGib_V1;
237
+ msgStones: IbGib_V1[];
238
+ identity?: KeystoneIbGib_V1;
239
+ space: IbGibSpaceAny;
240
+ metaspace: MetaspaceService;
153
241
  }): Promise<SyncIbGib_V1>;
154
- protected getLatestAddrsFromSpace({ space, tjpAddrs, }: {
242
+ protected getStageAndPayloadFromFrame({ ibGib, space }: {
243
+ ibGib: IbGib_V1;
155
244
  space: IbGibSpaceAny;
156
- tjpAddrs: string[];
157
245
  }): Promise<{
158
- [tjpAddr: string]: string | null;
246
+ stage: SyncStage;
247
+ messageData: any;
159
248
  }>;
160
249
  protected sortTimelinesTopologically(timelines: {
161
250
  [tjp: string]: IbGib_V1[];
162
251
  }): string[];
163
- /**
164
- * Checks if an address is an ancestor of another by traversing `past` relations.
165
- * Uses BFS. Returns true if `ancestorAddr` is found in the history of `descendantAddr`.
166
- */
167
- protected isAncestor({ ancestorAddr, descendantAddr, space, }: {
168
- ancestorAddr: string;
169
- descendantAddr: string;
170
- space: IbGibSpaceAny;
171
- }): Promise<boolean>;
172
252
  }
173
253
  //# sourceMappingURL=sync-saga-coordinator.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sync-saga-coordinator.d.mts","sourceRoot":"","sources":["../../src/sync/sync-saga-coordinator.mts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAI3D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EACU,YAAY,EAC5B,MAAM,kBAAkB,CAAC;AAM1B,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;IACtB;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC;IACpB;;OAEG;IACH,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;CAC3C;AAED,MAAM,MAAM,oBAAoB,GAC1B,OAAO,GACP,YAAY,GACZ,QAAQ,CAAC;AAGf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH,qBAAa,mBAAmB;IAIxB,SAAS,CAAC,QAAQ,EAAE,kBAAkB;IAH1C,SAAS,CAAC,EAAE,EAAE,MAAM,CAAmC;gBAGzC,QAAQ,EAAE,kBAAkB;IAG1C;;;;;;;;OAQG;IACG,IAA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