@ibgib/core-gib 0.1.59 → 0.1.61
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/CHANGELOG.md +12 -1
- package/dist/common/other/graph-helper.d.mts.map +1 -1
- package/dist/common/other/graph-helper.mjs +7 -6
- package/dist/common/other/graph-helper.mjs.map +1 -1
- package/dist/keystone/keystone-config-builder.d.mts +1 -2
- package/dist/keystone/keystone-config-builder.d.mts.map +1 -1
- package/dist/keystone/keystone-config-builder.mjs +4 -19
- package/dist/keystone/keystone-config-builder.mjs.map +1 -1
- package/dist/keystone/keystone-constants.d.mts +2 -0
- package/dist/keystone/keystone-constants.d.mts.map +1 -1
- package/dist/keystone/keystone-constants.mjs +2 -0
- package/dist/keystone/keystone-constants.mjs.map +1 -1
- package/dist/keystone/keystone-helpers.d.mts +5 -15
- package/dist/keystone/keystone-helpers.d.mts.map +1 -1
- package/dist/keystone/keystone-helpers.mjs +59 -73
- package/dist/keystone/keystone-helpers.mjs.map +1 -1
- package/dist/keystone/keystone-policy-types.d.mts +6 -4
- package/dist/keystone/keystone-policy-types.d.mts.map +1 -1
- package/dist/keystone/keystone-service-v1.d.mts.map +1 -1
- package/dist/keystone/keystone-service-v1.mjs +4 -8
- package/dist/keystone/keystone-service-v1.mjs.map +1 -1
- package/dist/keystone/keystone-service-v1.respec.mjs +182 -33
- package/dist/keystone/keystone-service-v1.respec.mjs.map +1 -1
- package/dist/keystone/keystone-types.d.mts +4 -11
- package/dist/keystone/keystone-types.d.mts.map +1 -1
- package/dist/keystone/policy/keystone-profile-builder.d.mts +25 -0
- package/dist/keystone/policy/keystone-profile-builder.d.mts.map +1 -0
- package/dist/keystone/policy/keystone-profile-builder.mjs +117 -0
- package/dist/keystone/policy/keystone-profile-builder.mjs.map +1 -0
- package/dist/keystone/policy/profiles/profile-high.json +84 -0
- package/dist/keystone/policy/profiles/profile-low.json +84 -0
- package/dist/keystone/policy/profiles/profile-medium.json +84 -0
- package/dist/keystone/policy/profiles/profile-session.json +84 -0
- package/dist/keystone/policy/profiles/profile-test.json +84 -0
- package/dist/keystone/policy/schemas/connect-pool.high.schema.json +23 -0
- package/dist/keystone/policy/schemas/connect-pool.low.schema.json +23 -0
- package/dist/keystone/policy/schemas/connect-pool.medium.schema.json +23 -0
- package/dist/keystone/policy/schemas/keystone.high.schema.json +26 -0
- package/dist/keystone/policy/schemas/keystone.low.schema.json +26 -0
- package/dist/keystone/policy/schemas/keystone.medium.schema.json +26 -0
- package/dist/keystone/policy/schemas/manage-pool.high.schema.json +23 -0
- package/dist/keystone/policy/schemas/manage-pool.low.schema.json +23 -0
- package/dist/keystone/policy/schemas/manage-pool.medium.schema.json +23 -0
- package/dist/keystone/policy/schemas/revoke-pool.high.schema.json +23 -0
- package/dist/keystone/policy/schemas/revoke-pool.low.schema.json +23 -0
- package/dist/keystone/policy/schemas/revoke-pool.medium.schema.json +23 -0
- package/dist/keystone/policy/schemas/sign-pool.high.schema.json +23 -0
- package/dist/keystone/policy/schemas/sign-pool.low.schema.json +23 -0
- package/dist/keystone/policy/schemas/sign-pool.medium.schema.json +23 -0
- package/dist/keystone/policy/schemas/sync-pool.high.schema.json +23 -0
- package/dist/keystone/policy/schemas/sync-pool.low.schema.json +23 -0
- package/dist/keystone/policy/schemas/sync-pool.medium.schema.json +23 -0
- package/dist/sync/sync-conflict-adv-multitimelines.withid.respec.d.mts +8 -0
- package/dist/sync/sync-conflict-adv-multitimelines.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-conflict-adv-multitimelines.withid.respec.mjs +582 -0
- package/dist/sync/sync-conflict-adv-multitimelines.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-conflict-basic-divergence.withid.respec.d.mts +7 -0
- package/dist/sync/sync-conflict-basic-divergence.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-conflict-basic-divergence.withid.respec.mjs +274 -0
- package/dist/sync/sync-conflict-basic-divergence.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-conflict-basic-multitimelines.withid.respec.d.mts +8 -0
- package/dist/sync/sync-conflict-basic-multitimelines.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-conflict-basic-multitimelines.withid.respec.mjs +322 -0
- package/dist/sync/sync-conflict-basic-multitimelines.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-conflict-text-merge.withid.respec.d.mts +7 -0
- package/dist/sync/sync-conflict-text-merge.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-conflict-text-merge.withid.respec.mjs +307 -0
- package/dist/sync/sync-conflict-text-merge.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-innerspace-constants.withid.respec.d.mts +8 -0
- package/dist/sync/sync-innerspace-constants.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-constants.withid.respec.mjs +233 -0
- package/dist/sync/sync-innerspace-constants.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-innerspace-deep-updates.withid.respec.d.mts +7 -0
- package/dist/sync/sync-innerspace-deep-updates.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-deep-updates.withid.respec.mjs +233 -0
- package/dist/sync/sync-innerspace-deep-updates.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-innerspace-dest-ahead.withid.respec.d.mts +7 -0
- package/dist/sync/sync-innerspace-dest-ahead.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-dest-ahead.withid.respec.mjs +225 -0
- package/dist/sync/sync-innerspace-dest-ahead.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-multiple-timelines.withid.respec.d.mts +7 -0
- package/dist/sync/sync-innerspace-multiple-timelines.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-multiple-timelines.withid.respec.mjs +235 -0
- package/dist/sync/sync-innerspace-multiple-timelines.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-innerspace-partial-update.withid.respec.d.mts +7 -0
- package/dist/sync/sync-innerspace-partial-update.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace-partial-update.withid.respec.mjs +211 -0
- package/dist/sync/sync-innerspace-partial-update.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-innerspace.withid.respec.d.mts +8 -0
- package/dist/sync/sync-innerspace.withid.respec.d.mts.map +1 -0
- package/dist/sync/sync-innerspace.withid.respec.mjs +260 -0
- package/dist/sync/sync-innerspace.withid.respec.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-types.d.mts +12 -1
- package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +7 -0
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +43 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.d.mts +2 -0
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mjs +28 -9
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-websocket-peer-helpers.d.mts +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-websocket-peer-helpers.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-websocket-peer-helpers.mjs +5 -3
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-websocket-peer-helpers.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.d.mts +16 -0
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.mjs +223 -79
- package/dist/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.mjs.map +1 -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 +41 -2
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts +4 -0
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +6 -0
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +213 -137
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-withid.pingpong.respec.mjs +70 -2
- package/dist/sync/sync-withid.pingpong.respec.mjs.map +1 -1
- package/dist/timeline/timeline-api.d.mts.map +1 -1
- package/dist/timeline/timeline-api.mjs +1 -14
- package/dist/timeline/timeline-api.mjs.map +1 -1
- package/dist/witness/space/reconciliation-space/reconciliation-space-base.d.mts.map +1 -1
- package/dist/witness/space/reconciliation-space/reconciliation-space-base.mjs +0 -40
- package/dist/witness/space/reconciliation-space/reconciliation-space-base.mjs.map +1 -1
- package/dist/witness/space/reconciliation-space/reconciliation-space-helper.d.mts.map +1 -1
- package/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs +6 -6
- package/dist/witness/space/reconciliation-space/reconciliation-space-helper.mjs.map +1 -1
- package/ibgib-foundations.md +2 -1
- package/package.json +1 -1
- package/src/common/other/graph-helper.mts +7 -6
- package/src/keystone/README.md +19 -15
- package/src/keystone/docs/CRYPTANALYSIS.md +185 -0
- package/src/keystone/docs/architecture.md +24 -1
- package/src/keystone/docs/profiles.md +124 -0
- package/src/keystone/keystone-config-builder.mts +3 -21
- package/src/keystone/keystone-constants.mts +2 -0
- package/src/keystone/keystone-helpers.mts +74 -77
- package/src/keystone/keystone-policy-types.mts +6 -4
- package/src/keystone/keystone-service-v1.mts +4 -9
- package/src/keystone/keystone-service-v1.respec.mts +214 -32
- package/src/keystone/keystone-types.mts +5 -9
- package/src/keystone/policy/IMPLEMENTATION.md +60 -0
- package/src/keystone/policy/README.md +94 -0
- package/src/keystone/policy/keystone-profile-builder.mts +131 -0
- package/src/keystone/policy/profiles/profile-high.json +84 -0
- package/src/keystone/policy/profiles/profile-low.json +84 -0
- package/src/keystone/policy/profiles/profile-medium.json +84 -0
- package/src/keystone/policy/profiles/profile-session.json +84 -0
- package/src/keystone/policy/profiles/profile-test.json +84 -0
- package/src/keystone/policy/schemas/connect-pool.high.schema.json +23 -0
- package/src/keystone/policy/schemas/connect-pool.low.schema.json +23 -0
- package/src/keystone/policy/schemas/connect-pool.medium.schema.json +23 -0
- package/src/keystone/policy/schemas/keystone.high.schema.json +26 -0
- package/src/keystone/policy/schemas/keystone.low.schema.json +26 -0
- package/src/keystone/policy/schemas/keystone.medium.schema.json +26 -0
- package/src/keystone/policy/schemas/manage-pool.high.schema.json +23 -0
- package/src/keystone/policy/schemas/manage-pool.low.schema.json +23 -0
- package/src/keystone/policy/schemas/manage-pool.medium.schema.json +23 -0
- package/src/keystone/policy/schemas/revoke-pool.high.schema.json +23 -0
- package/src/keystone/policy/schemas/revoke-pool.low.schema.json +23 -0
- package/src/keystone/policy/schemas/revoke-pool.medium.schema.json +23 -0
- package/src/keystone/policy/schemas/sign-pool.high.schema.json +23 -0
- package/src/keystone/policy/schemas/sign-pool.low.schema.json +23 -0
- package/src/keystone/policy/schemas/sign-pool.medium.schema.json +23 -0
- package/src/keystone/policy/schemas/sync-pool.high.schema.json +23 -0
- package/src/keystone/policy/schemas/sync-pool.low.schema.json +23 -0
- package/src/keystone/policy/schemas/sync-pool.medium.schema.json +23 -0
- package/src/sync/docs/security-3b.md +92 -0
- package/src/sync/docs/security.md +139 -38
- package/src/sync/sync-conflict-adv-multitimelines.withid.respec.mts +706 -0
- package/src/sync/sync-conflict-basic-divergence.withid.respec.mts +321 -0
- package/src/sync/sync-conflict-basic-multitimelines.withid.respec.mts +374 -0
- package/src/sync/sync-conflict-text-merge.withid.respec.mts +347 -0
- package/src/sync/sync-innerspace-constants.withid.respec.mts +264 -0
- package/src/sync/sync-innerspace-deep-updates.withid.respec.mts +272 -0
- package/src/sync/sync-innerspace-dest-ahead.withid.respec.mts +266 -0
- package/src/sync/sync-innerspace-multiple-timelines.respec.mts +0 -1
- package/src/sync/sync-innerspace-multiple-timelines.withid.respec.mts +273 -0
- package/src/sync/sync-innerspace-partial-update.withid.respec.mts +249 -0
- package/src/sync/sync-innerspace.withid.respec.mts +265 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +1 -1
- package/src/sync/sync-peer/sync-peer-types.mts +11 -1
- package/src/sync/sync-peer/sync-peer-v1.mts +47 -1
- package/src/sync/sync-peer/sync-peer-websocket/README.md +42 -0
- package/src/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mts +26 -9
- package/src/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-websocket-peer-helpers.mts +5 -3
- package/src/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-sender/sync-peer-websocket-sender-v1.mts +242 -78
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +46 -4
- package/src/sync/sync-saga-context/sync-saga-context-types.mts +5 -0
- package/src/sync/sync-saga-coordinator.mts +221 -137
- package/src/sync/sync-withid.pingpong.respec.mts +76 -3
- package/src/timeline/timeline-api.mts +1 -15
- package/src/timeline/timeline-api.respec.mts +3 -3
- package/src/witness/space/reconciliation-space/reconciliation-space-base.mts +0 -46
- package/src/witness/space/reconciliation-space/reconciliation-space-helper.mts +6 -5
- package/tsconfig.json +6 -1
- package/src/keystone/keystone-policy.schema.json +0 -51
- package/src/sync/docs/ping_pong_plan.md +0 -147
- package/src/witness/space/reconciliation-space/reconciliation-space-base.mts.OLD.md +0 -884
- package/src/witness/space/reconciliation-space/reconciliation-space-helper.mts.OLD.md +0 -125
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
HandleSagaResponseContextResult,
|
|
33
33
|
SyncSagaFrameDependencyGraph,
|
|
34
34
|
} from "./sync-types.mjs";
|
|
35
|
-
import { getSyncSagaFrameOrigin, getFullSyncSagaHistory, getSyncIb, getTempSpaceName, isPastFrame, putInSpace_dnasThenNonDnas, validateFullSyncSagaHistory, getAllOrphanedAddresses, getFinalConflictsInfo } from "./sync-helpers.mjs";
|
|
35
|
+
import { getSyncSagaFrameOrigin, getFullSyncSagaHistory, getSyncIb, getTempSpaceName, isPastFrame, putInSpace_dnasThenNonDnas, validateFullSyncSagaHistory, getAllOrphanedAddresses, getFinalConflictsInfo, getSyncSagaFrameDependencyGraph } from "./sync-helpers.mjs";
|
|
36
36
|
import { getDeltaDependencyGraph, getDependencyGraph, toFlatGraph } from "../common/other/graph-helper.mjs";
|
|
37
37
|
import {
|
|
38
38
|
SyncSagaMessageData_V1, SyncSagaMessageInitData_V1,
|
|
@@ -466,144 +466,158 @@ export class SyncSagaCoordinator {
|
|
|
466
466
|
}));
|
|
467
467
|
// #endregion set up peer observable for any domainPayloadsMap
|
|
468
468
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
469
|
+
try {
|
|
470
|
+
// ...create/compose the Request Context itself...
|
|
471
|
+
const requestCtx = await this.createSyncSagaContext({
|
|
472
|
+
sagaFrame: currentFrame,
|
|
473
|
+
/**
|
|
474
|
+
* init frame: empty
|
|
475
|
+
* ack frame: possible push offers
|
|
476
|
+
* delta frame: requested ibgibs or commit offer
|
|
477
|
+
* commit frame: empty
|
|
478
|
+
*/
|
|
479
|
+
payloadIbGibsDomain: nextDomainIbGibs,
|
|
480
|
+
localSpace,
|
|
481
|
+
metaspace,
|
|
482
|
+
sessionIdentityAddr: peer.currentSessionIdentityAddr,
|
|
483
|
+
peer,
|
|
484
|
+
});
|
|
484
485
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
486
|
+
// #region Log what we're sending
|
|
487
|
+
if (logalotControlDomain) {
|
|
488
|
+
const domainAddrs = nextDomainIbGibs.map(p => getIbGibAddr({ ibGib: p }));
|
|
489
|
+
console.log(`${lc}${lcControlDomain} SENDER TRANSMIT -> peer.witness (I: 5b0081803698770f0bf64992220b312)`);
|
|
490
|
+
console.log(`${lc}${lcControlDomain} Context: ${getIbGibAddr({ ibGib: requestCtx })}`);
|
|
491
|
+
console.log(`${lc}${lcControlDomain} Frame: ${getIbGibAddr({ ibGib: currentFrame })}`);
|
|
492
|
+
console.log(`${lc}${lcControlDomain} DOMAIN Payloads (${domainAddrs.length}): ${domainAddrs.join(', ') || '(none)'}`);
|
|
493
|
+
}
|
|
494
|
+
// #endregion Log what we're sending
|
|
495
|
+
|
|
496
|
+
// update our saga listeners...
|
|
497
|
+
// if (logalot) { console.log(`${lc} transmitting... requestCtx: ${pretty(requestCtx)} (I: 8cf20817c66899abdb1e76df50356826)`); }
|
|
498
|
+
updates$.next(requestCtx); // spins off for saga UI updates
|
|
499
|
+
|
|
500
|
+
// ...And send the context.
|
|
501
|
+
peer.setOptionalOpts({ localSpace, localTempSpace: tempSpace, });
|
|
502
|
+
const responseCtx = await peer.witness(requestCtx);
|
|
503
|
+
|
|
504
|
+
// the send returned, but a peer can return a falsy responseCtx, if
|
|
505
|
+
// we just sent a commit to them and they're done. If so, there will
|
|
506
|
+
// necessarily be no payload to wait to receive
|
|
507
|
+
if (!responseCtx) {
|
|
508
|
+
if (currentFrame) {
|
|
509
|
+
// Check for Commit (Peer silence expected)
|
|
510
|
+
const msg = await getSyncSagaMessageFromFrame({ frameIbGib: currentFrame, space: localSpace });
|
|
511
|
+
if (msg?.data?.stage === SyncStage.commit) {
|
|
512
|
+
if (logalot) { console.log(`${lc} Sender sent Commit. Peer returned no response. Saga Complete. (I: 26f9ee073858ca78b8284753368b5226)`); }
|
|
513
|
+
currentFrame = null;
|
|
514
|
+
break;
|
|
515
|
+
} else {
|
|
516
|
+
throw new Error(`(UNEXPECTED) responseCtx falsy and currentFrame truthy, but we're not in the commit stage? This may be expected ultimately, but atow I am not seeing this as being expected. (E: cc34498962bd370deeff351fac939f26)`);
|
|
517
|
+
}
|
|
514
518
|
} else {
|
|
515
|
-
throw new Error(`(UNEXPECTED)
|
|
519
|
+
throw new Error(`(UNEXPECTED) no response and currentFrame falsy? (E: 8d1085ea2f28cfc3f9c922649864a826)`);
|
|
516
520
|
}
|
|
517
|
-
} else {
|
|
518
|
-
throw new Error(`(UNEXPECTED) no response and currentFrame falsy? (E: 8d1085ea2f28cfc3f9c922649864a826)`);
|
|
519
521
|
}
|
|
520
|
-
}
|
|
521
522
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (!responseCtx.data) { throw new Error(`(UNEXPECTED) responseCtx.data falsy? (E: a969992bae53ab18a827ec58aec15826)`); }
|
|
528
|
-
updates$.next(responseCtx); // spins off for saga UI updating
|
|
529
|
-
|
|
530
|
-
// immediately validate context/saga frame (but not payloads because
|
|
531
|
-
// we may not have those yet)
|
|
532
|
-
const contextAndSagaFrameValidationErrors =
|
|
533
|
-
await validateContextAndSagaFrame({ context: responseCtx });
|
|
534
|
-
if (contextAndSagaFrameValidationErrors.length > 0) { throw new Error(`contextAndSagaFrameValidationErrors: ${contextAndSagaFrameValidationErrors} (E: 6eebe8e7fa437c00a8cde3ada3c66826)`); }
|
|
535
|
-
|
|
536
|
-
// Extract expected domain addresses from response context
|
|
537
|
-
const responsePayloadAddrsDomain = responseCtx.data[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN] as string[] || [];
|
|
538
|
-
|
|
539
|
-
// Poll for them if needed. see above jsdocs for domainPayloadsMap
|
|
540
|
-
if (responsePayloadAddrsDomain.length > 0) {
|
|
541
|
-
responseCtx.payloadIbGibsDomain = await this.pollForDomainPayloads({
|
|
542
|
-
expectedAddrs: responsePayloadAddrsDomain,
|
|
543
|
-
pollIntervalMs: 20, // relatively arbitrary right now
|
|
544
|
-
domainPayloadsMap,
|
|
545
|
-
tempSpace,
|
|
546
|
-
});
|
|
547
|
-
}
|
|
523
|
+
// at this point, we did indeed receive a response to analyze. BUT!
|
|
524
|
+
// we have only necessarily received the response context ibgib.
|
|
525
|
+
// if there were payloads expected to be transferred, they may not
|
|
526
|
+
// be done yet.
|
|
548
527
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
if (logalotControlDomain) {
|
|
552
|
-
const responseControlAddrs = responseCtx.data?.['@payloadAddrsControl'] as string[] || [];
|
|
553
|
-
console.log(`${lc}${lcControlDomain} SENDER RECEIVED <- peer.witness (I: 3dc76a9744d89a4fc3e2f076c2be4826)`);
|
|
554
|
-
console.log(`${lc}${lcControlDomain} Response Context: ${getIbGibAddr({ ibGib: responseCtx })}`);
|
|
555
|
-
console.log(`${lc}${lcControlDomain} Response Saga Frame: ${getIbGibAddr({ ibGib: responseCtx.sagaFrame })}`);
|
|
556
|
-
console.log(`${lc}${lcControlDomain} CONTROL Payloads (${responseControlAddrs.length}): ${responseControlAddrs.join(', ') || '(none)'}`);
|
|
557
|
-
console.log(`${lc}${lcControlDomain} DOMAIN Payloads (${responsePayloadAddrsDomain.length}): ${responsePayloadAddrsDomain.join(', ') || '(none)'}`);
|
|
558
|
-
}
|
|
559
|
-
// #endregion Log what we received back
|
|
528
|
+
if (!responseCtx.data) { throw new Error(`(UNEXPECTED) responseCtx.data falsy? (E: a969992bae53ab18a827ec58aec15826)`); }
|
|
529
|
+
updates$.next(responseCtx); // spins off for saga UI updating
|
|
560
530
|
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
531
|
+
// immediately validate context/saga frame (but not payloads because
|
|
532
|
+
// we may not have those yet)
|
|
533
|
+
const contextAndSagaFrameValidationErrors =
|
|
534
|
+
await validateContextAndSagaFrame({ context: responseCtx });
|
|
535
|
+
if (contextAndSagaFrameValidationErrors.length > 0) { throw new Error(`contextAndSagaFrameValidationErrors: ${contextAndSagaFrameValidationErrors} (E: 6eebe8e7fa437c00a8cde3ada3c66826)`); }
|
|
564
536
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
});
|
|
537
|
+
// Turn-by-turn continuation & identity checks
|
|
538
|
+
const returnContextErrors = await this.validateReturnContext({
|
|
539
|
+
requestCtx,
|
|
540
|
+
responseCtx,
|
|
541
|
+
localSpace,
|
|
542
|
+
});
|
|
543
|
+
if (returnContextErrors.length > 0) {
|
|
544
|
+
throw new Error(`validateReturnContext errors: ${returnContextErrors.join(', ')} (E: cb8a023b9d0728cceb09fa3da0bb8226)`);
|
|
545
|
+
}
|
|
575
546
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
console.error(`${lc} NAG ERROR (DOES NOT THROW): does this ever hit now? (E: e04d02efc2a8e72a88b79f1f0f95ca26)`);
|
|
579
|
-
break;
|
|
580
|
-
} else if (contextResult.nextFrameInfo?.sagaComplete) {
|
|
581
|
-
if (logalot) { console.log(`${lc} Handler returned null (Saga End). (I: 123bf9e7dca8886de72553a8d4f29e26)`); }
|
|
582
|
-
break;
|
|
583
|
-
}
|
|
547
|
+
// Extract expected domain addresses from response context
|
|
548
|
+
const responsePayloadAddrsDomain = responseCtx.data[SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN] as string[] || [];
|
|
584
549
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
550
|
+
// Poll for them if needed. see above jsdocs for domainPayloadsMap
|
|
551
|
+
if (responsePayloadAddrsDomain.length > 0) {
|
|
552
|
+
responseCtx.payloadIbGibsDomain = await this.pollForDomainPayloads({
|
|
553
|
+
expectedAddrs: responsePayloadAddrsDomain,
|
|
554
|
+
pollIntervalMs: 20, // relatively arbitrary right now
|
|
555
|
+
domainPayloadsMap,
|
|
556
|
+
tempSpace,
|
|
557
|
+
});
|
|
558
|
+
}
|
|
592
559
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
560
|
+
// #region Log what we received back
|
|
561
|
+
if (!responseCtx.sagaFrame) { throw new Error(`(UNEXPECTED) responseCtx.sagaFrame falsy? the Peer should have set this when it got the response back from the remote. (E: e650adadf9a2063ec6764a1e31d3d826)`); }
|
|
562
|
+
if (logalotControlDomain) {
|
|
563
|
+
const responseControlAddrs = responseCtx.data?.['@payloadAddrsControl'] as string[] || [];
|
|
564
|
+
console.log(`${lc}${lcControlDomain} SENDER RECEIVED <- peer.witness (I: 3dc76a9744d89a4fc3e2f076c2be4826)`);
|
|
565
|
+
console.log(`${lc}${lcControlDomain} Response Context: ${getIbGibAddr({ ibGib: responseCtx })}`);
|
|
566
|
+
console.log(`${lc}${lcControlDomain} Response Saga Frame: ${getIbGibAddr({ ibGib: responseCtx.sagaFrame })}`);
|
|
567
|
+
console.log(`${lc}${lcControlDomain} CONTROL Payloads (${responseControlAddrs.length}): ${responseControlAddrs.join(', ') || '(none)'}`);
|
|
568
|
+
console.log(`${lc}${lcControlDomain} DOMAIN Payloads (${responsePayloadAddrsDomain.length}): ${responsePayloadAddrsDomain.join(', ') || '(none)'}`);
|
|
569
|
+
}
|
|
570
|
+
// #endregion Log what we received back
|
|
571
|
+
|
|
572
|
+
// at this point, we have received the context AND **all** of the
|
|
573
|
+
// domain payloads (if applicable), so we are ready to do the next
|
|
574
|
+
// iteration in the saga loop
|
|
575
|
+
|
|
576
|
+
// this is the part that drives the FSM forward, i.e., when we
|
|
577
|
+
// evolve the sync saga ibgib itself to the next frame if we aren't
|
|
578
|
+
// finished/errored out.
|
|
579
|
+
const contextResult = await this.handleResponseSagaContext({
|
|
580
|
+
sagaContext: responseCtx,
|
|
581
|
+
initDomainGraph,
|
|
582
|
+
mySpace: localSpace,
|
|
583
|
+
myTempSpace: tempSpace,
|
|
584
|
+
metaspace,
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
if (!contextResult) {
|
|
588
|
+
// should this ever hit?
|
|
589
|
+
console.error(`${lc} NAG ERROR (DOES NOT THROW): does this ever hit now? (E: e04d02efc2a8e72a88b79f1f0f95ca26)`);
|
|
590
|
+
break;
|
|
591
|
+
} else if (contextResult.nextFrameInfo?.sagaComplete) {
|
|
592
|
+
if (logalot) { console.log(`${lc} Handler returned null (Saga End). (I: 123bf9e7dca8886de72553a8d4f29e26)`); }
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// #region error conditions throw
|
|
597
|
+
if (contextResult.errorMsg) {
|
|
598
|
+
throw new Error(`Couldn't handle response saga context. errorMsg: ${contextResult.errorMsg} (E: c948e81d513b2a0eb8b8afa878edc626)`);
|
|
599
|
+
} else if (!contextResult.nextFrameInfo) {
|
|
600
|
+
throw new Error(`(UNEXPECTED) contextResult.nextFrameInfo falsy? (E: c287a82e823e662a77923278e2418826)`);
|
|
601
|
+
}
|
|
602
|
+
// #endregion error conditions throw
|
|
603
|
+
|
|
604
|
+
// we have another frame to process and send out, with possibly
|
|
605
|
+
// payload domain ibgibs as well
|
|
606
|
+
const { frame, payloadIbGibsDomain, } = contextResult.nextFrameInfo;
|
|
607
|
+
currentFrame = frame;
|
|
608
|
+
nextDomainIbGibs = [...(payloadIbGibsDomain || [])];
|
|
609
|
+
|
|
610
|
+
// #region Log handler output for next iteration
|
|
611
|
+
if (logalotControlDomain) {
|
|
612
|
+
const handlerDomainAddrs = nextDomainIbGibs.map(p => getIbGibAddr({ ibGib: p }));
|
|
613
|
+
console.log(`${lc}${lcControlDomain} HANDLER RESULT -> next iteration (I: 6b0d88c4c28857ccd812381515bd7826)`);
|
|
614
|
+
console.log(`${lc}${lcControlDomain} Next Frame: ${getIbGibAddr({ ibGib: currentFrame })}`);
|
|
615
|
+
console.log(`${lc}${lcControlDomain} DOMAIN for next (${handlerDomainAddrs.length}): ${handlerDomainAddrs.join(', ') || '(none)'}`);
|
|
616
|
+
}
|
|
617
|
+
// #endregion Log handler output for next iteration
|
|
618
|
+
} finally {
|
|
619
|
+
await subscription.unsubscribe();
|
|
605
620
|
}
|
|
606
|
-
// #endregion Log handler output for next iteration
|
|
607
621
|
}
|
|
608
622
|
}
|
|
609
623
|
|
|
@@ -738,6 +752,16 @@ export class SyncSagaCoordinator {
|
|
|
738
752
|
|
|
739
753
|
// Attach actual ibgibs for transport
|
|
740
754
|
contextIbGib.sagaFrame = sagaFrame;
|
|
755
|
+
|
|
756
|
+
const { msgStones } = await getSyncSagaFrameDependencyGraph({
|
|
757
|
+
sagaIbGib: sagaFrame,
|
|
758
|
+
localSpace: localSpace,
|
|
759
|
+
});
|
|
760
|
+
if (msgStones.length !== 1) {
|
|
761
|
+
throw new Error(`(UNEXPECTED) msgStones.length !== 1 inside createSyncSagaContext? (E: a98165cf46ab4e82b7bd5e45a273b826)`);
|
|
762
|
+
}
|
|
763
|
+
contextIbGib.sagaFrameMsg = msgStones[0];
|
|
764
|
+
|
|
741
765
|
if (payloadIbGibsDomain && payloadIbGibsDomain.length > 0) {
|
|
742
766
|
contextIbGib.payloadIbGibsDomain = payloadIbGibsDomain;
|
|
743
767
|
}
|
|
@@ -942,6 +966,54 @@ export class SyncSagaCoordinator {
|
|
|
942
966
|
}
|
|
943
967
|
}
|
|
944
968
|
|
|
969
|
+
/**
|
|
970
|
+
* Validates that the return context received from a peer is a valid
|
|
971
|
+
* continuation of the outbound context and that the session identity
|
|
972
|
+
* is consistent.
|
|
973
|
+
*/
|
|
974
|
+
private async validateReturnContext({
|
|
975
|
+
requestCtx,
|
|
976
|
+
responseCtx,
|
|
977
|
+
localSpace,
|
|
978
|
+
}: {
|
|
979
|
+
requestCtx: SyncSagaContextIbGib_V1,
|
|
980
|
+
responseCtx: SyncSagaContextIbGib_V1,
|
|
981
|
+
localSpace: IbGibSpaceAny,
|
|
982
|
+
}): Promise<string[]> {
|
|
983
|
+
const lc = `${this.lc}[${this.validateReturnContext.name}]`;
|
|
984
|
+
const errors: string[] = [];
|
|
985
|
+
try {
|
|
986
|
+
// 1. Verify saga frame continuation
|
|
987
|
+
if (requestCtx.sagaFrame && responseCtx.sagaFrame) {
|
|
988
|
+
const requestFrameAddr = getIbGibAddr({ ibGib: requestCtx.sagaFrame });
|
|
989
|
+
const responseFrameAddr = getIbGibAddr({ ibGib: responseCtx.sagaFrame });
|
|
990
|
+
|
|
991
|
+
const isContinuation = await isPastFrame({
|
|
992
|
+
olderAddr: requestFrameAddr,
|
|
993
|
+
newerAddr: responseFrameAddr,
|
|
994
|
+
space: localSpace,
|
|
995
|
+
});
|
|
996
|
+
if (!isContinuation) {
|
|
997
|
+
errors.push(`Response saga frame (${responseFrameAddr}) is not a valid continuation of request saga frame (${requestFrameAddr}). (E: 2c85e8d97318ff24ac8a02bd3a068226)`);
|
|
998
|
+
}
|
|
999
|
+
} else {
|
|
1000
|
+
errors.push(`Missing sagaFrame on requestCtx or responseCtx. (E: b65c68ff891000ddca8d22384a088226)`);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// 2. Verify session identity has not changed
|
|
1004
|
+
const expectedSessionIdAddr = requestCtx.signedSessionIdentity ?
|
|
1005
|
+
getIbGibAddr({ ibGib: requestCtx.signedSessionIdentity }) :
|
|
1006
|
+
requestCtx.rel8ns?.sessionIdentity?.[0];
|
|
1007
|
+
const responseSessionIdAddr = responseCtx.rel8ns?.sessionIdentity?.[0];
|
|
1008
|
+
if (expectedSessionIdAddr !== responseSessionIdAddr) {
|
|
1009
|
+
errors.push(`Session identity mismatch. Expected ${expectedSessionIdAddr}, got ${responseSessionIdAddr}. (E: ab98716bca88d2243cc822187768226)`);
|
|
1010
|
+
}
|
|
1011
|
+
} catch (error) {
|
|
1012
|
+
errors.push(`Error during validateReturnContext: ${extractErrorMsg(error)} (E: da878e1239aa88ee27bdfca005c28226)`);
|
|
1013
|
+
}
|
|
1014
|
+
return errors;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
945
1017
|
/**
|
|
946
1018
|
* Helper to poll for streaming domain payloads and put them in the
|
|
947
1019
|
* local {@link tempSpace}.
|
|
@@ -965,7 +1037,8 @@ export class SyncSagaCoordinator {
|
|
|
965
1037
|
|
|
966
1038
|
let resultDomainPayloads: IbGib_V1[] = [];
|
|
967
1039
|
|
|
968
|
-
|
|
1040
|
+
const uniqueExpectedAddrs = [...new Set(expectedAddrs)];
|
|
1041
|
+
let pending = [...uniqueExpectedAddrs];
|
|
969
1042
|
const start = Date.now();
|
|
970
1043
|
/**
|
|
971
1044
|
* This needs
|
|
@@ -999,8 +1072,8 @@ export class SyncSagaCoordinator {
|
|
|
999
1072
|
if (pending.length > 0) { await delay(pollIntervalMs); }
|
|
1000
1073
|
}
|
|
1001
1074
|
|
|
1002
|
-
if (
|
|
1003
|
-
throw new Error(`(UNEXPECTED)
|
|
1075
|
+
if (uniqueExpectedAddrs.length !== resultDomainPayloads.length) {
|
|
1076
|
+
throw new Error(`(UNEXPECTED) uniqueExpectedAddrs.length !== resultDomainPayloads.length? at this point, we expect all of the payload ibgibs to have been received. (E: 03749a7478c4b8b28bfc86951887a826)`);
|
|
1004
1077
|
}
|
|
1005
1078
|
|
|
1006
1079
|
return resultDomainPayloads;
|
|
@@ -1594,12 +1667,10 @@ export class SyncSagaCoordinator {
|
|
|
1594
1667
|
*/
|
|
1595
1668
|
const outgoingPayloadIbGibsDomain_conflicts: IbGib_V1[] = [];
|
|
1596
1669
|
|
|
1670
|
+
const activeConflicts: SyncSagaConflictInfo[] = [];
|
|
1597
1671
|
if (conflicts.length > 0) {
|
|
1598
1672
|
if (logalot) { console.log(`${lc} [CONFLICT DEBUG] Processing ${conflicts.length} non-terminal conflicts`); }
|
|
1599
1673
|
|
|
1600
|
-
// we will need to resolve conflicts, so no commit yet
|
|
1601
|
-
proposeCommit = false;
|
|
1602
|
-
|
|
1603
1674
|
for (const conflict of conflicts) {
|
|
1604
1675
|
const {
|
|
1605
1676
|
receiverTipAddr,
|
|
@@ -1671,11 +1742,24 @@ export class SyncSagaCoordinator {
|
|
|
1671
1742
|
const deltaPayloadIbGib = deltaGraph[deltaPayloadAddr];
|
|
1672
1743
|
outgoingPayloadIbGibsDomain_conflicts.push(deltaPayloadIbGib);
|
|
1673
1744
|
});
|
|
1674
|
-
|
|
1675
|
-
|
|
1745
|
+
|
|
1746
|
+
const isFastForward = latestCommonFrameAddr === receiverTipAddr;
|
|
1747
|
+
if (isFastForward) {
|
|
1748
|
+
if (logalot) { console.log(`${lc} [CONFLICT DEBUG] TJP ${tjpAddr}: Fast-forward detected (receiver behind sender). Excluding from active conflicts and sending delta payload.`); }
|
|
1749
|
+
} else {
|
|
1750
|
+
if (conflict.accretivePayloadAddrs) { throw new Error(`(UNEXPECTED) conflict.accretivePayloadAddrs already truthy? This is expected to be falsy at this point in the sync. (E: 6b6b1846779867849cbde208f4374326)`); }
|
|
1751
|
+
conflict.accretivePayloadAddrs = accretivePayloadAddrs;
|
|
1752
|
+
activeConflicts.push(conflict);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
if (activeConflicts.length > 0) {
|
|
1757
|
+
proposeCommit = false;
|
|
1758
|
+
} else {
|
|
1759
|
+
proposeCommit = true;
|
|
1676
1760
|
}
|
|
1677
1761
|
|
|
1678
|
-
if (logalot) { console.log(`${lc} [CONFLICT DEBUG] Finished processing ${conflicts.length} conflicts. outgoingPayloadIbGibsDomain_conflicts.length (total outgoing payload ibgibs for ALL conflicts): ${outgoingPayloadIbGibsDomain_conflicts.length}`); }
|
|
1762
|
+
if (logalot) { console.log(`${lc} [CONFLICT DEBUG] Finished processing ${conflicts.length} conflicts. Active (divergent) conflicts: ${activeConflicts.length}. outgoingPayloadIbGibsDomain_conflicts.length (total outgoing payload ibgibs for ALL conflicts): ${outgoingPayloadIbGibsDomain_conflicts.length}`); }
|
|
1679
1763
|
} else {
|
|
1680
1764
|
if (logalot) { console.log(`${lc} [CONFLICT DEBUG] No optimistic conflicts to process`); }
|
|
1681
1765
|
}
|
|
@@ -1715,7 +1799,7 @@ export class SyncSagaCoordinator {
|
|
|
1715
1799
|
/**
|
|
1716
1800
|
* these are the modified conflicts with additional information.
|
|
1717
1801
|
*/
|
|
1718
|
-
conflicts,
|
|
1802
|
+
conflicts: activeConflicts,
|
|
1719
1803
|
/**
|
|
1720
1804
|
* we're sending these domain ibgibs as payload (they were
|
|
1721
1805
|
* requested by receiver and/or they are being sent as delta
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
respecfully, ifWeMight, iReckon,
|
|
12
|
+
respecfully, ifWeMight, iReckon, ifWe,
|
|
13
13
|
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
14
14
|
const maam = `[${import.meta.url}]`, sir = maam;
|
|
15
15
|
import { clone, delay, extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
@@ -34,7 +34,8 @@ import { IbGibAddr } from '@ibgib/ts-gib/dist/types.mjs';
|
|
|
34
34
|
import { getIdentity_throwIfUndefined } from '../keystone/keystone-helpers.mjs';
|
|
35
35
|
import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/factory.mjs';
|
|
36
36
|
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
37
|
-
import { getDependencyGraph } from '../common/other/graph-helper.mjs';
|
|
37
|
+
import { getDependencyGraph, graphsAreEquivalent } from '../common/other/graph-helper.mjs';
|
|
38
|
+
import { getFromSpace } from '../witness/space/space-helper.mjs';
|
|
38
39
|
|
|
39
40
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
40
41
|
const lc = sir;
|
|
@@ -153,9 +154,81 @@ await respecfully(sir, `Test Phase 3A: Ping Pong Sync with Identity`, async () =
|
|
|
153
154
|
syncError = error;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
await
|
|
157
|
+
await ifWe(sir, 'completes the entire sync saga successfully', async () => {
|
|
157
158
|
const errorMsg = syncError ? extractErrorMsg(syncError) : '';
|
|
158
159
|
iReckon(sir, syncError).asTo(`syncError: ${errorMsg}`).isGonnaBeFalsy();
|
|
159
160
|
});
|
|
160
161
|
|
|
162
|
+
await ifWe(sir, 'alpha dep graph matches on source and dest', async () => {
|
|
163
|
+
const resGetDest = await getFromSpace({ space: destSpace, addr: xStoneAddr });
|
|
164
|
+
iReckon(sir, resGetDest.success && resGetDest.ibGibs?.length === 1).asTo('xStone exists in destSpace').isGonnaBeTrue();
|
|
165
|
+
if (resGetDest.success && resGetDest.ibGibs?.[0]) {
|
|
166
|
+
const xStoneDest = resGetDest.ibGibs[0];
|
|
167
|
+
const depGraphSource = await getDependencyGraph({ ibGib: xStone, space: sourceSpace });
|
|
168
|
+
const depGraphDest = await getDependencyGraph({ ibGib: xStoneDest, space: destSpace });
|
|
169
|
+
const equal = graphsAreEquivalent({ graphA: depGraphSource, graphB: depGraphDest });
|
|
170
|
+
iReckon(sir, equal).asTo('graphs are equivalent').isGonnaBeTrue();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
await ifWe(sir, 'sessionIdentity evolved the expected number of times', async () => {
|
|
175
|
+
const latestS = peer.currentSessionIdentity;
|
|
176
|
+
iReckon(sir, latestS).asTo('latest session identity exists on peer').isGonnaBeTruthy();
|
|
177
|
+
if (latestS) {
|
|
178
|
+
iReckon(sir, latestS.data?.n).asTo('session identity data.n').isGonnaBe(2);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
await ifWe(sir, 'sender durable space has I (evolved frame)', async () => {
|
|
183
|
+
const latestSenderIdentityAddr = await metaspace.getLatestAddr({
|
|
184
|
+
addr: getIbGibAddr({ ibGib: senderIdentity }),
|
|
185
|
+
space: sourceSpace,
|
|
186
|
+
});
|
|
187
|
+
iReckon(sir, latestSenderIdentityAddr).asTo('latestSenderIdentityAddr exists').isGonnaBeTruthy();
|
|
188
|
+
if (latestSenderIdentityAddr) {
|
|
189
|
+
const resGetSourceI = await getFromSpace({ space: sourceSpace, addr: latestSenderIdentityAddr });
|
|
190
|
+
iReckon(sir, resGetSourceI.success && resGetSourceI.ibGibs?.length === 1).asTo('evolved I exists in sourceSpace').isGonnaBeTrue();
|
|
191
|
+
if (resGetSourceI.success && resGetSourceI.ibGibs?.[0]) {
|
|
192
|
+
const evolvedI = resGetSourceI.ibGibs[0];
|
|
193
|
+
iReckon(sir, evolvedI.data?.n).asTo('evolved I data.n').isGonnaBe(1);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
await ifWe(sir, 'receiver durable space has I (evolved frame)', async () => {
|
|
199
|
+
const latestSenderIdentityAddr = await metaspace.getLatestAddr({
|
|
200
|
+
addr: getIbGibAddr({ ibGib: senderIdentity }),
|
|
201
|
+
space: sourceSpace,
|
|
202
|
+
});
|
|
203
|
+
iReckon(sir, latestSenderIdentityAddr).asTo('latestSenderIdentityAddr exists').isGonnaBeTruthy();
|
|
204
|
+
if (latestSenderIdentityAddr) {
|
|
205
|
+
const resGetDestI = await getFromSpace({ space: destSpace, addr: latestSenderIdentityAddr });
|
|
206
|
+
iReckon(sir, resGetDestI.success && resGetDestI.ibGibs?.length === 1).asTo('evolved I exists in destSpace').isGonnaBeTrue();
|
|
207
|
+
if (resGetDestI.success && resGetDestI.ibGibs?.[0]) {
|
|
208
|
+
const evolvedI = resGetDestI.ibGibs[0];
|
|
209
|
+
iReckon(sir, evolvedI.data?.n).asTo('evolved I data.n').isGonnaBe(1);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
await ifWe(sir, 'sender durable space has full S dep graph', async () => {
|
|
215
|
+
const latestS = peer.currentSessionIdentity;
|
|
216
|
+
iReckon(sir, latestS).asTo('latestS exists').isGonnaBeTruthy();
|
|
217
|
+
if (latestS) {
|
|
218
|
+
const depGraphS = await getDependencyGraph({ ibGib: latestS, space: sourceSpace });
|
|
219
|
+
const addrs = Object.keys(depGraphS);
|
|
220
|
+
iReckon(sir, addrs.length > 2).asTo('number of nodes in S graph > 2').isGonnaBeTrue();
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
await ifWe(sir, 'receiver durable space has full S dep graph', async () => {
|
|
225
|
+
const latestS = peer.currentSessionIdentity;
|
|
226
|
+
iReckon(sir, latestS).asTo('latestS exists').isGonnaBeTruthy();
|
|
227
|
+
if (latestS) {
|
|
228
|
+
const depGraphS = await getDependencyGraph({ ibGib: latestS, space: destSpace });
|
|
229
|
+
const addrs = Object.keys(depGraphS);
|
|
230
|
+
iReckon(sir, addrs.length > 2).asTo('number of nodes in S graph in destSpace > 2').isGonnaBeTrue();
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
161
234
|
});
|
|
@@ -293,11 +293,7 @@ export async function appendToTimeline({
|
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
|
|
297
|
-
// should we await the publish or spin it off
|
|
298
|
-
// right now I have this spin off, inside the lock
|
|
299
|
-
// await metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space });
|
|
300
|
-
metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space }); // spin off
|
|
296
|
+
await metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space }); // already spins off
|
|
301
297
|
|
|
302
298
|
return newTimelineIbGib;
|
|
303
299
|
};
|
|
@@ -314,12 +310,6 @@ export async function appendToTimeline({
|
|
|
314
310
|
fn,
|
|
315
311
|
});
|
|
316
312
|
|
|
317
|
-
// should we publish within the lock or not within the lock?
|
|
318
|
-
// should we await the publish or spin it off
|
|
319
|
-
// right now I have this spin off, inside the lock
|
|
320
|
-
// await metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space });
|
|
321
|
-
// metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space }); // spin off
|
|
322
|
-
|
|
323
313
|
return newTimelineIbGib;
|
|
324
314
|
} catch (error) {
|
|
325
315
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
@@ -691,10 +681,6 @@ export async function mut8Timeline<TData extends IbGibData_V1 = any>({
|
|
|
691
681
|
});
|
|
692
682
|
}
|
|
693
683
|
|
|
694
|
-
// should we publish within the lock or not within the lock?
|
|
695
|
-
// should we await the publish or spin it off
|
|
696
|
-
// right now I have this spin off, inside the lock
|
|
697
|
-
// await metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space });
|
|
698
684
|
// we await the register call because this spins off the publish events (we are assuming implementation details here)
|
|
699
685
|
await metaspace.registerNewIbGib({ ibGib: newTimelineIbGib, space }); // already spins off
|
|
700
686
|
|
|
@@ -186,14 +186,14 @@ respecfully(sir, `[timeline-api]`, async () => {
|
|
|
186
186
|
* I'm getting output (warnings?) that the transform ibgib addr
|
|
187
187
|
* already exists. This stems from the fact that dna/transform
|
|
188
188
|
* ibgibs do not have timestamps or anything, they simply are
|
|
189
|
-
* memoized args to the transform functions. So we need something
|
|
189
|
+
* memoized args to the transform functions. So we need something
|
|
190
190
|
* unique _in the arg itself_, which in this case means in the
|
|
191
191
|
* `dataToAddOrPatch` field.
|
|
192
|
-
*
|
|
192
|
+
*
|
|
193
193
|
* Note, however, that it is expected for the original `fork`
|
|
194
194
|
* transform that created tInitial to be common and for it to
|
|
195
195
|
* already have this fork dna ibgib. But this shouldn't happen for
|
|
196
|
-
* each mut8 transform.
|
|
196
|
+
* each mut8 transform.
|
|
197
197
|
*/
|
|
198
198
|
const uniqueIdsForUniqueTransforms: string[] = [];
|
|
199
199
|
for (let i = 0; i < N; i++) {
|