@ibgib/core-gib 0.1.25 → 0.1.26
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.
- package/dist/common/other/ibgib-helper.d.mts +1 -1
- package/dist/common/other/ibgib-helper.d.mts.map +1 -1
- package/dist/common/other/ibgib-helper.mjs.map +1 -1
- package/dist/sync/sync-constants.d.mts +1 -0
- package/dist/sync/sync-constants.d.mts.map +1 -1
- package/dist/sync/sync-constants.mjs +1 -0
- package/dist/sync/sync-constants.mjs.map +1 -1
- package/dist/sync/sync-helpers.d.mts +5 -0
- package/dist/sync/sync-helpers.d.mts.map +1 -1
- package/dist/sync/sync-helpers.mjs +37 -1
- package/dist/sync/sync-helpers.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +0 -2
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +148 -62
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +13 -29
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +17 -57
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +15 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs +60 -4
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +49 -3
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +180 -101
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-types.d.mts +1 -3
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/package.json +1 -1
- package/src/common/other/ibgib-helper.mts +1 -1
- package/src/sync/sync-constants.mts +1 -0
- package/src/sync/sync-helpers.mts +41 -1
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +147 -47
- package/src/sync/sync-peer/sync-peer-v1.mts +31 -74
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +55 -7
- package/src/sync/sync-saga-coordinator.mts +232 -110
- package/src/sync/sync-types.mts +2 -2
|
@@ -95,7 +95,7 @@ export class SyncSagaCoordinator {
|
|
|
95
95
|
* @param opts.domainIbGibs - The root ibgibs defining the scope of the sync.
|
|
96
96
|
* @param opts.useSessionIdentity - (Optional) Whether to create an ephemeral session identity. Default: true.
|
|
97
97
|
*/
|
|
98
|
-
async sync({
|
|
98
|
+
public async sync({
|
|
99
99
|
peer,
|
|
100
100
|
domainIbGibs,
|
|
101
101
|
conflictStrategy = SyncConflictStrategy.abort,
|
|
@@ -191,6 +191,91 @@ export class SyncSagaCoordinator {
|
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
+
/**
|
|
195
|
+
* This is what the receiving side of the sync calls to drive the FSM to the
|
|
196
|
+
* next stage.
|
|
197
|
+
*
|
|
198
|
+
* So whereas the sender executes a saga loop and drives the entire process,
|
|
199
|
+
* this is a reactive one-off that drives just the single step that the
|
|
200
|
+
* receiver does in that saga.
|
|
201
|
+
*
|
|
202
|
+
* @returns next context result if another round, else if commit returns
|
|
203
|
+
* null
|
|
204
|
+
*/
|
|
205
|
+
public async receiverContinueSync({
|
|
206
|
+
sagaContext,
|
|
207
|
+
mySpace,
|
|
208
|
+
myTempSpace,
|
|
209
|
+
identity,
|
|
210
|
+
identitySecret,
|
|
211
|
+
metaspace,
|
|
212
|
+
}: {
|
|
213
|
+
sagaContext: SyncSagaContextIbGib_V1,
|
|
214
|
+
/**
|
|
215
|
+
* Local space relative to the execution context's POV
|
|
216
|
+
*/
|
|
217
|
+
mySpace: IbGibSpaceAny,
|
|
218
|
+
/**
|
|
219
|
+
* Local temp space relative to the execution context's POV
|
|
220
|
+
*/
|
|
221
|
+
myTempSpace: IbGibSpaceAny,
|
|
222
|
+
identity?: KeystoneIbGib_V1,
|
|
223
|
+
identitySecret?: string,
|
|
224
|
+
metaspace: MetaspaceService,
|
|
225
|
+
}): Promise<SyncSagaContextIbGib_V1 | null> {
|
|
226
|
+
const lc = `${this.lc}[${this.receiverContinueSync.name}]`;
|
|
227
|
+
try {
|
|
228
|
+
if (logalot) { console.log(`${lc} starting... (I: f64e08bf77d1425378601f380384ec26)`); }
|
|
229
|
+
|
|
230
|
+
const contextResult = await this.handleResponseSagaContext({
|
|
231
|
+
sagaContext,
|
|
232
|
+
mySpace,
|
|
233
|
+
myTempSpace,
|
|
234
|
+
identity,
|
|
235
|
+
identitySecret,
|
|
236
|
+
metaspace,
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
if (!contextResult) {
|
|
240
|
+
if (logalot) { console.log(`${lc} Handler returned null (Saga End). (I: 43da8bb6c846b1fe7766332643be0e26)`); }
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// #region error conditions throw
|
|
245
|
+
if (contextResult.errorMsg) {
|
|
246
|
+
throw new Error(`Couldn't handle response saga context. errorMsg: ${contextResult.errorMsg} (E: 7b41a183cf3cb58a5859c803800cf826)`);
|
|
247
|
+
} else if (!contextResult.nextFrameInfo) {
|
|
248
|
+
throw new Error(`(UNEXPECTED) contextResult.nextFrameInfo falsy? (E: 5740542f5eb8ccb41dfec188d87c1e26)`);
|
|
249
|
+
} else if (contextResult.nextFrameInfo?.responseWasNull) {
|
|
250
|
+
throw new Error(`(UNEXPECTED) contextResult.nextFrameInfo.responseWasNull? logic flow should not have gotten here. (E: ae06748d8c0c5e70c92322c8fb0cb426)`);
|
|
251
|
+
}
|
|
252
|
+
// #endregion error conditions throw
|
|
253
|
+
|
|
254
|
+
// create the return context
|
|
255
|
+
const { frame, payloadIbGibsDomain } = contextResult.nextFrameInfo;
|
|
256
|
+
|
|
257
|
+
const responseCtx = await createSyncSagaContext({
|
|
258
|
+
sagaFrame: frame,
|
|
259
|
+
localSpace: mySpace,
|
|
260
|
+
payloadIbGibsDomain,
|
|
261
|
+
// todo: we need to thoroughly go through the identity per each step after getting basic merging
|
|
262
|
+
sessionKeystones: identity ? [identity] : undefined, // ??
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const immediateValidationErrors = await validateContextAndSagaFrame({
|
|
266
|
+
context: responseCtx,
|
|
267
|
+
});
|
|
268
|
+
if (immediateValidationErrors.length > 0) { throw new Error(`(UNEXPECTED) just created sync saga context () and there were immediateValidationErrors? immediateValidationErrors: ${immediateValidationErrors} (E: c120e8e0aa98673d685267a8a36e5826)`); }
|
|
269
|
+
|
|
270
|
+
return responseCtx;
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
273
|
+
throw error;
|
|
274
|
+
} finally {
|
|
275
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
194
279
|
protected async getSessionIdentity({
|
|
195
280
|
sagaId,
|
|
196
281
|
metaspace,
|
|
@@ -253,6 +338,12 @@ export class SyncSagaCoordinator {
|
|
|
253
338
|
metaspace
|
|
254
339
|
}: {
|
|
255
340
|
initFrame: SyncIbGib_V1,
|
|
341
|
+
/**
|
|
342
|
+
* This is the initial dependency graph of all domain ibgibs passed in
|
|
343
|
+
* to the original {@link sync} call.
|
|
344
|
+
*
|
|
345
|
+
* if we're executing on the sender, this will be populated
|
|
346
|
+
*/
|
|
256
347
|
initDomainGraph: FlatIbGibGraph,
|
|
257
348
|
peer: SyncPeerWitness,
|
|
258
349
|
sessionIdentity?: KeystoneIbGib_V1,
|
|
@@ -362,8 +453,11 @@ export class SyncSagaCoordinator {
|
|
|
362
453
|
if (!responseCtx.data) { throw new Error(`(UNEXPECTED) responseCtx.data falsy? (E: a969992bae53ab18a827ec58aec15826)`); }
|
|
363
454
|
updates$.next(responseCtx); // spins off for saga UI updating
|
|
364
455
|
|
|
365
|
-
// validate context
|
|
366
|
-
|
|
456
|
+
// immediately validate context/saga frame (but not payloads because
|
|
457
|
+
// we may not have those yet)
|
|
458
|
+
const contextAndSagaFrameValidationErrors =
|
|
459
|
+
await validateContextAndSagaFrame({ context: responseCtx });
|
|
460
|
+
if (contextAndSagaFrameValidationErrors.length > 0) { throw new Error(`contextAndSagaFrameValidationErrors: ${contextAndSagaFrameValidationErrors} (E: 6eebe8e7fa437c00a8cde3ada3c66826)`); }
|
|
367
461
|
|
|
368
462
|
// Extract expected domain addresses from response context
|
|
369
463
|
const responsePayloadAddrsDomain = responseCtx.data[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN] as string[] || [];
|
|
@@ -399,6 +493,7 @@ export class SyncSagaCoordinator {
|
|
|
399
493
|
// finished/errored out.
|
|
400
494
|
const contextResult = await this.handleResponseSagaContext({
|
|
401
495
|
sagaContext: responseCtx,
|
|
496
|
+
initDomainGraph,
|
|
402
497
|
mySpace: localSpace,
|
|
403
498
|
myTempSpace: tempSpace,
|
|
404
499
|
metaspace,
|
|
@@ -708,6 +803,7 @@ export class SyncSagaCoordinator {
|
|
|
708
803
|
|
|
709
804
|
/**
|
|
710
805
|
* This is the heart of the "ping pong" transaction, where we send a context
|
|
806
|
+
*
|
|
711
807
|
* and receive a context. IOW, this drives the FSM of the sync saga ibgib as
|
|
712
808
|
* a whole.
|
|
713
809
|
*
|
|
@@ -728,6 +824,7 @@ export class SyncSagaCoordinator {
|
|
|
728
824
|
*/
|
|
729
825
|
public async handleResponseSagaContext({
|
|
730
826
|
sagaContext,
|
|
827
|
+
initDomainGraph,
|
|
731
828
|
mySpace,
|
|
732
829
|
myTempSpace,
|
|
733
830
|
identity,
|
|
@@ -735,6 +832,13 @@ export class SyncSagaCoordinator {
|
|
|
735
832
|
metaspace,
|
|
736
833
|
}: {
|
|
737
834
|
sagaContext: SyncSagaContextIbGib_V1,
|
|
835
|
+
/**
|
|
836
|
+
* This is the initial dependency graph of all domain ibgibs passed in
|
|
837
|
+
* to the original {@link sync} call.
|
|
838
|
+
*
|
|
839
|
+
* if we're executing on the sender, this will be populated
|
|
840
|
+
*/
|
|
841
|
+
initDomainGraph?: FlatIbGibGraph,
|
|
738
842
|
/**
|
|
739
843
|
* Local space relative to the execution context's POV
|
|
740
844
|
*/
|
|
@@ -746,7 +850,7 @@ export class SyncSagaCoordinator {
|
|
|
746
850
|
identity?: KeystoneIbGib_V1,
|
|
747
851
|
identitySecret?: string,
|
|
748
852
|
metaspace: MetaspaceService,
|
|
749
|
-
}): Promise<HandleSagaResponseContextResult
|
|
853
|
+
}): Promise<HandleSagaResponseContextResult> {
|
|
750
854
|
const lc = `${this.lc}[${this.handleResponseSagaContext.name}]`;
|
|
751
855
|
try {
|
|
752
856
|
if (logalot) { console.log(`${lc} starting... (I: 5deec8a1f7a6d263c88cd458ad990826)`); }
|
|
@@ -780,7 +884,16 @@ export class SyncSagaCoordinator {
|
|
|
780
884
|
break;
|
|
781
885
|
|
|
782
886
|
case SyncStage.ack:
|
|
783
|
-
|
|
887
|
+
if (!initDomainGraph) { throw new Error(`(UNEXPECTED) initDomainGraph falsy on the sender? (E: a3d758ad954829aba88663188eafc826)`); }
|
|
888
|
+
nextFrameInfo = await this.handleAckFrame({
|
|
889
|
+
sagaIbGib,
|
|
890
|
+
srcGraph,
|
|
891
|
+
initDomainGraph,
|
|
892
|
+
metaspace,
|
|
893
|
+
destSpace: mySpace,
|
|
894
|
+
tempSpace: myTempSpace,
|
|
895
|
+
identity,
|
|
896
|
+
});
|
|
784
897
|
break;
|
|
785
898
|
|
|
786
899
|
case SyncStage.delta:
|
|
@@ -1090,8 +1203,6 @@ export class SyncSagaCoordinator {
|
|
|
1090
1203
|
* we want to push ibgibs to the remote/sender if we have push
|
|
1091
1204
|
* offers. an ack frame's payloads, if any, are those push offers
|
|
1092
1205
|
*/
|
|
1093
|
-
// let payloadIbGibsDomain: IbGib_V1[] | undefined = await getPushOffers
|
|
1094
|
-
|
|
1095
1206
|
let payloadIbGibsDomain: IbGib_V1[] | undefined;
|
|
1096
1207
|
if (pushOfferInfos.length > 0) {
|
|
1097
1208
|
const searchSecondSpaceAddrs: IbGibAddr[] = [];
|
|
@@ -1143,12 +1254,10 @@ export class SyncSagaCoordinator {
|
|
|
1143
1254
|
// we have now populated payloadIbGibsDomain
|
|
1144
1255
|
}
|
|
1145
1256
|
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
// payloadIbGibsDomain,
|
|
1151
|
-
// };
|
|
1257
|
+
return {
|
|
1258
|
+
frame: ackFrame,
|
|
1259
|
+
payloadIbGibsDomain,
|
|
1260
|
+
};
|
|
1152
1261
|
|
|
1153
1262
|
} catch (error) {
|
|
1154
1263
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
@@ -1173,6 +1282,7 @@ export class SyncSagaCoordinator {
|
|
|
1173
1282
|
protected async handleAckFrame({
|
|
1174
1283
|
sagaIbGib,
|
|
1175
1284
|
srcGraph,
|
|
1285
|
+
initDomainGraph,
|
|
1176
1286
|
destSpace,
|
|
1177
1287
|
tempSpace,
|
|
1178
1288
|
metaspace,
|
|
@@ -1180,6 +1290,13 @@ export class SyncSagaCoordinator {
|
|
|
1180
1290
|
}: {
|
|
1181
1291
|
sagaIbGib: SyncIbGib_V1,
|
|
1182
1292
|
srcGraph: { [addr: string]: IbGib_V1 },
|
|
1293
|
+
/**
|
|
1294
|
+
* This is the initial dependency graph of all domain ibgibs passed in
|
|
1295
|
+
* to the original {@link sync} call.
|
|
1296
|
+
*
|
|
1297
|
+
* if we're executing on the sender, this will be populated
|
|
1298
|
+
*/
|
|
1299
|
+
initDomainGraph: FlatIbGibGraph,
|
|
1183
1300
|
destSpace: IbGibSpaceAny,
|
|
1184
1301
|
tempSpace: IbGibSpaceAny,
|
|
1185
1302
|
metaspace: MetaspaceService,
|
|
@@ -1215,11 +1332,12 @@ export class SyncSagaCoordinator {
|
|
|
1215
1332
|
throw new Error(`${lc} Peer reported terminal conflicts. (E: 23a0096ee05a2ccfa89334e8f156b426)`);
|
|
1216
1333
|
}
|
|
1217
1334
|
|
|
1218
|
-
|
|
1335
|
+
// at this point, if we have conflicts, they are non-terminal
|
|
1336
|
+
|
|
1219
1337
|
const mergeDeltaReqs: string[] = []; // Additional requests for merging
|
|
1220
1338
|
|
|
1221
|
-
if (
|
|
1222
|
-
console.log(`${lc} [CONFLICT DEBUG] Processing ${
|
|
1339
|
+
if (conflicts.length > 0) {
|
|
1340
|
+
console.log(`${lc} [CONFLICT DEBUG] Processing ${conflicts.length} non-terminal conflicts`);
|
|
1223
1341
|
// We need to resolve these.
|
|
1224
1342
|
// Strategy:
|
|
1225
1343
|
// 1. Analyze Divergence (Sender vs Receiver)
|
|
@@ -1252,102 +1370,106 @@ export class SyncSagaCoordinator {
|
|
|
1252
1370
|
|
|
1253
1371
|
// Let's analyze and pull immediately.
|
|
1254
1372
|
|
|
1255
|
-
for (const conflict of
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
//
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
//
|
|
1264
|
-
// We
|
|
1265
|
-
//
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
// We need
|
|
1269
|
-
//
|
|
1270
|
-
const
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
//
|
|
1275
|
-
//
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1373
|
+
for (const conflict of conflicts) {
|
|
1374
|
+
// todo: integrate conflict strategies into this point...this whole block needs to be redone, but I want to check the fast-forward/backward simpler case tests first
|
|
1375
|
+
|
|
1376
|
+
throw new Error(`conflicts not (re)implemented yet (E: 3b7d0819f83842a6de3ae988819bc826)`);
|
|
1377
|
+
|
|
1378
|
+
// const { timelineAddrs, localAddr: receiverTip, remoteAddr: senderTip } = conflict;
|
|
1379
|
+
|
|
1380
|
+
// // Sender History
|
|
1381
|
+
// // We need our own history for this timeline.
|
|
1382
|
+
// // We know the 'senderTip' (remoteAddr in Ack).
|
|
1383
|
+
// // Sender should verify it has this tip.
|
|
1384
|
+
|
|
1385
|
+
// // Compute Diffs
|
|
1386
|
+
// // We need to find `receiverOnly` addrs.
|
|
1387
|
+
// // Receiver sent us `timelineAddrs` (Full History).
|
|
1388
|
+
// const receiverHistorySet = new Set(timelineAddrs);
|
|
1389
|
+
|
|
1390
|
+
// // We need our execution context's history for this senderTip.
|
|
1391
|
+
// // We can fetch valid 'past' from space.
|
|
1392
|
+
// const resSenderTip = await getFromSpace({ space: destSpace, addr: senderTip });
|
|
1393
|
+
// const senderTipIbGib = resSenderTip.ibGibs?.[0];
|
|
1394
|
+
// if (!senderTipIbGib) { throw new Error(`${lc} Sender missing its own tip? ${senderTip} (E: 832f3804645878869ee3c13714366726)`); }
|
|
1395
|
+
|
|
1396
|
+
// // Basic Diff: Find what Receiver has that we don't.
|
|
1397
|
+
// // Actually, we need to traverse OUR past to find commonality.
|
|
1398
|
+
// const senderHistory = [senderTip, ...(senderTipIbGib.rel8ns?.past || [])];
|
|
1399
|
+
|
|
1400
|
+
// const receiverOnlyAddrs = timelineAddrs.filter(addr => !senderHistory.includes(addr));
|
|
1401
|
+
|
|
1402
|
+
// if (receiverOnlyAddrs.length > 0) {
|
|
1403
|
+
// console.log(`${lc} [CONFLICT DEBUG] Found ${receiverOnlyAddrs.length} receiver-only frames - need to pull for merge`);
|
|
1404
|
+
// console.log(`${lc} [CONFLICT DEBUG] Receiver-only addrs:`, receiverOnlyAddrs);
|
|
1405
|
+
// // PULL these frames from Peer into Local Space
|
|
1406
|
+
// // (Validation: We trust peer for now / verification happens on put)
|
|
1407
|
+
// for (const addr of receiverOnlyAddrs) {
|
|
1408
|
+
// console.error(`${lc} [CONFLICT DEBUG] NOT IMPLEMENTED (E: e6bf1a9d2758c469bb2f97514062d826)`);
|
|
1409
|
+
// }
|
|
1410
|
+
|
|
1411
|
+
// // Compute DELTA dependencies for each receiver-only frame
|
|
1412
|
+
// // Find LCA to determine what dependencies we already have
|
|
1413
|
+
// const lcaAddr = timelineAddrs.find(addr => senderHistory.includes(addr));
|
|
1414
|
+
// console.log(`${lc} [CONFLICT DEBUG] LCA: ${lcaAddr || 'NONE'}`);
|
|
1415
|
+
|
|
1416
|
+
// const skipAddrsSet = new Set<string>();
|
|
1417
|
+
// if (lcaAddr) {
|
|
1418
|
+
// try {
|
|
1419
|
+
// const lcaRes = await getFromSpace({ addr: lcaAddr, space: destSpace });
|
|
1420
|
+
// const lcaIbGib = lcaRes.ibGibs?.[0];
|
|
1421
|
+
// if (lcaIbGib) {
|
|
1422
|
+
// const lcaDeps = await getDependencyGraph({ ibGib: lcaIbGib, space: destSpace });
|
|
1423
|
+
// if (lcaDeps) Object.keys(lcaDeps).forEach(a => skipAddrsSet.add(a));
|
|
1424
|
+
// console.log(`${lc} [CONFLICT DEBUG] LCA deps to skip: ${skipAddrsSet.size}`);
|
|
1425
|
+
// }
|
|
1426
|
+
// } catch (e) {
|
|
1427
|
+
// console.warn(`${lc} Error getting LCA deps: ${extractErrorMsg(e)}`);
|
|
1428
|
+
// }
|
|
1429
|
+
// }
|
|
1430
|
+
|
|
1431
|
+
|
|
1432
|
+
// // For each receiver-only frame, get its DELTA dependency graph (minus LCA deps)
|
|
1433
|
+
// for (const addr of receiverOnlyAddrs) {
|
|
1434
|
+
// // Add the frame itself first
|
|
1435
|
+
// if (!mergeDeltaReqs.includes(addr)) {
|
|
1436
|
+
// mergeDeltaReqs.push(addr);
|
|
1437
|
+
// }
|
|
1438
|
+
|
|
1439
|
+
// // Get the frame's delta dependencies (skip LCA's deps)
|
|
1440
|
+
// try {
|
|
1441
|
+
// const frameRes = await getFromSpace({ addr, space: destSpace });
|
|
1442
|
+
// const frameIbGib = frameRes.ibGibs?.[0];
|
|
1443
|
+
|
|
1444
|
+
// if (frameIbGib) {
|
|
1445
|
+
// // Get dependency graph, skipping all LCA dependencies
|
|
1446
|
+
// const frameDeltaDeps = await getDependencyGraph({
|
|
1447
|
+
// ibGib: frameIbGib,
|
|
1448
|
+
// space: destSpace,
|
|
1449
|
+
// skipAddrs: Array.from(skipAddrsSet), // Skip entire LCA dep graph
|
|
1450
|
+
// });
|
|
1451
|
+
|
|
1452
|
+
// if (frameDeltaDeps) {
|
|
1453
|
+
// // Add all delta dependencies (Object.keys gives us the addresses)
|
|
1454
|
+
// Object.keys(frameDeltaDeps).forEach(depAddr => {
|
|
1455
|
+
// if (!mergeDeltaReqs.includes(depAddr) && !skipAddrsSet.has(depAddr)) {
|
|
1456
|
+
// mergeDeltaReqs.push(depAddr);
|
|
1457
|
+
// }
|
|
1458
|
+
// });
|
|
1459
|
+
// }
|
|
1460
|
+
// }
|
|
1461
|
+
// } catch (depError) {
|
|
1462
|
+
// console.warn(`${lc} [CONFLICT DEBUG] Error getting delta deps for ${addr}: ${extractErrorMsg(depError)}`);
|
|
1463
|
+
// }
|
|
1464
|
+
// }
|
|
1465
|
+
|
|
1466
|
+
// console.log(`${lc} [CONFLICT DEBUG] Total merge requests (frames + delta deps): ${mergeDeltaReqs.length}`);
|
|
1467
|
+
// } else {
|
|
1468
|
+
// console.log(`${lc} [CONFLICT DEBUG] No receiver-only frames found for this conflict`);
|
|
1469
|
+
// }
|
|
1348
1470
|
}
|
|
1349
1471
|
|
|
1350
|
-
console.log(`${lc} [CONFLICT DEBUG] Finished processing ${
|
|
1472
|
+
console.log(`${lc} [CONFLICT DEBUG] Finished processing ${conflicts.length} conflicts. mergeDeltaReqs: ${mergeDeltaReqs.length}`);
|
|
1351
1473
|
} else {
|
|
1352
1474
|
console.log(`${lc} [CONFLICT DEBUG] No optimistic conflicts to process`);
|
|
1353
1475
|
}
|
package/src/sync/sync-types.mts
CHANGED
|
@@ -57,8 +57,8 @@ export function isValidSyncConflictStrategy(strategy: string): strategy is SyncC
|
|
|
57
57
|
export interface NextSagaFrameInfo_Frame {
|
|
58
58
|
frame: SyncIbGib_V1;
|
|
59
59
|
payloadIbGibsDomain?: IbGib_V1[];
|
|
60
|
-
conflictInfos?: SyncSagaConflictInfo;
|
|
61
|
-
responseWasNull
|
|
60
|
+
// conflictInfos?: SyncSagaConflictInfo;
|
|
61
|
+
responseWasNull?: undefined;
|
|
62
62
|
}
|
|
63
63
|
export interface NextSagaFrameInfo_Null {
|
|
64
64
|
frame: never;
|