@ibgib/core-gib 0.1.60 → 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 +3 -0
- 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-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.d.mts +1 -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 +13 -4
- 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-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +165 -145
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-withid.pingpong.respec.mjs +8 -8
- 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.md +54 -21
- 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-websocket/sync-peer-websocket-receiver/sync-peer-websocket-receiver-v1.mts +12 -4
- package/src/sync/sync-peer/sync-peer-websocket/sync-peer-websocket-receiver/sync-websocket-peer-helpers.mts +5 -3
- package/src/sync/sync-saga-coordinator.mts +159 -143
- package/src/sync/sync-withid.pingpong.respec.mts +8 -8
- 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/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
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sync-conflict-basic-divergence.withid.respec
|
|
3
|
+
*
|
|
4
|
+
* Verifies Basic Divergence Conflict Resolution (optimistic merge / grafting) with Identity.
|
|
5
|
+
*/
|
|
6
|
+
import { respecfully, iReckon, ifWe } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
7
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
8
|
+
import { clone, delay } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
9
|
+
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
10
|
+
import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
|
|
11
|
+
import { SyncSagaCoordinator } from './sync-saga-coordinator.mjs';
|
|
12
|
+
import { getFromSpace } from '../witness/space/space-helper.mjs';
|
|
13
|
+
import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs';
|
|
14
|
+
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
15
|
+
import { createTimelineRootTestHelper } from '../test-helpers.mjs';
|
|
16
|
+
import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
17
|
+
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
18
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
19
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
20
|
+
import { getDependencyGraph, graphsAreEquivalent } from '../common/other/graph-helper.mjs';
|
|
21
|
+
import { KeystoneService_V1 } from '../keystone/keystone-service-v1.mjs';
|
|
22
|
+
import { KEYSTONE_VERB_SYNC, POOL_ID_SYNC, } from '../keystone/keystone-constants.mjs';
|
|
23
|
+
import { createStandardPoolConfig } from '../keystone/keystone-config-builder.mjs';
|
|
24
|
+
import { KeystoneReplenishStrategy } from '../keystone/keystone-types.mjs';
|
|
25
|
+
import { SyncConflictStrategy } from './sync-constants.mjs';
|
|
26
|
+
import { GRAFT_BASE_REL8N_NAME, GRAFT_ORPHAN_REL8N_NAME, GRAFT_INFO_REL8N_NAME } from './graft-info/graft-info-constants.mjs';
|
|
27
|
+
import { getTjpAddr } from '../common/other/ibgib-helper.mjs';
|
|
28
|
+
const logalot = GLOBAL_LOG_A_LOT || true;
|
|
29
|
+
const lc = `[sync-conflict-basic-divergence.withid.respec]`;
|
|
30
|
+
const SENDER_SECRET = 'test-sender-secret-conflict-basic-divergence-withid';
|
|
31
|
+
const SENDER_IDENTITY_SYNC_POOL_CONFIG = createStandardPoolConfig({
|
|
32
|
+
id: POOL_ID_SYNC,
|
|
33
|
+
salt: 'senderidentitysyncsaltconflictbasicdivergencewithid',
|
|
34
|
+
verbs: [KEYSTONE_VERB_SYNC],
|
|
35
|
+
size: 200,
|
|
36
|
+
sequential: 1,
|
|
37
|
+
random: 1,
|
|
38
|
+
targetBinding: 2,
|
|
39
|
+
replenishStrategy: KeystoneReplenishStrategy.topUp,
|
|
40
|
+
});
|
|
41
|
+
await respecfully(sir, `Sync Conflict Basic Divergence with Identity`, async () => {
|
|
42
|
+
for (let i = 0; i <= 1; i++) {
|
|
43
|
+
const srcMakesFirstDivergentEdit = i === 0;
|
|
44
|
+
await respecfully(sir, `srcMakesFirstDivergentEdit: ${srcMakesFirstDivergentEdit}`, async () => {
|
|
45
|
+
// 1. Setup Spaces
|
|
46
|
+
const metaspace = new Metaspace_Innerspace(undefined);
|
|
47
|
+
await metaspace.initialize({
|
|
48
|
+
getFnAlert: () => async ({ title, msg }) => { console.log(`[Alert] ${title}: ${msg}`); },
|
|
49
|
+
getFnPrompt: () => async ({ title, msg }) => { console.log(`[Prompt] ${title}: ${msg}`); return ''; },
|
|
50
|
+
getFnPromptPassword: () => async (title, msg) => { console.log(`[PromptPwd] ${title}: ${msg}`); return null; },
|
|
51
|
+
});
|
|
52
|
+
while (!metaspace.initialized) {
|
|
53
|
+
await delay(10);
|
|
54
|
+
}
|
|
55
|
+
const defaultLocalUserSpace = await metaspace.getLocalUserSpace({ lock: false });
|
|
56
|
+
await defaultLocalUserSpace.initialized;
|
|
57
|
+
const sourceSpace = new InnerSpace_V1({
|
|
58
|
+
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
59
|
+
name: 'source',
|
|
60
|
+
uuid: 'source_uuid',
|
|
61
|
+
description: 'source test space',
|
|
62
|
+
});
|
|
63
|
+
await sourceSpace.initialized;
|
|
64
|
+
const destSpace = new InnerSpace_V1({
|
|
65
|
+
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
66
|
+
name: 'dest',
|
|
67
|
+
uuid: 'dest_uuid',
|
|
68
|
+
description: 'dest test space',
|
|
69
|
+
});
|
|
70
|
+
await destSpace.initialized;
|
|
71
|
+
// 2. Setup Identities
|
|
72
|
+
const keystoneSvc = new KeystoneService_V1();
|
|
73
|
+
const r1_senderIdentity_v0_source = await keystoneSvc.genesis({
|
|
74
|
+
masterSecret: SENDER_SECRET,
|
|
75
|
+
configs: [SENDER_IDENTITY_SYNC_POOL_CONFIG],
|
|
76
|
+
metaspace,
|
|
77
|
+
space: sourceSpace,
|
|
78
|
+
});
|
|
79
|
+
// Register identity in both spaces
|
|
80
|
+
await metaspace.put({ ibGib: r1_senderIdentity_v0_source, space: destSpace });
|
|
81
|
+
await metaspace.registerNewIbGib({ ibGib: r1_senderIdentity_v0_source, space: destSpace });
|
|
82
|
+
// 3. Seed Common History (V0 -> V1)
|
|
83
|
+
const testRoot = await createTimelineRootTestHelper({
|
|
84
|
+
ib: 'timeline_root_conflict_withid',
|
|
85
|
+
data: { type: 'testRoot', text: 'v0' },
|
|
86
|
+
space: sourceSpace,
|
|
87
|
+
});
|
|
88
|
+
const tjpAddr = getTjpAddr({ ibGib: testRoot, defaultIfNone: 'incomingAddr' }) ?? getIbGibAddr({ ibGib: testRoot });
|
|
89
|
+
// Create V1 (Common)
|
|
90
|
+
const v1_Common_onSource = await mut8Timeline({
|
|
91
|
+
timeline: testRoot,
|
|
92
|
+
mut8Opts: {
|
|
93
|
+
mut8Ib: testRoot.ib + '_common',
|
|
94
|
+
dataToAddOrPatch: { text: 'v1_common' }
|
|
95
|
+
},
|
|
96
|
+
metaspace,
|
|
97
|
+
space: sourceSpace,
|
|
98
|
+
});
|
|
99
|
+
// Sync testRoot and V1 to Dest immediately
|
|
100
|
+
const depGraphCommon = await getDependencyGraph({
|
|
101
|
+
ibGibAddrs: [tjpAddr],
|
|
102
|
+
space: sourceSpace,
|
|
103
|
+
live: true,
|
|
104
|
+
}) ?? {};
|
|
105
|
+
await metaspace.put({ ibGibs: Object.values(depGraphCommon), space: destSpace });
|
|
106
|
+
await metaspace.registerNewIbGib({ ibGib: testRoot, space: destSpace });
|
|
107
|
+
const resGetDest = await getFromSpace({ space: destSpace, addr: getIbGibAddr({ ibGib: v1_Common_onSource }) });
|
|
108
|
+
if (!resGetDest.success || !resGetDest.ibGibs || resGetDest.ibGibs.length === 0) {
|
|
109
|
+
throw new Error("Failed to copy V1 to Dest");
|
|
110
|
+
}
|
|
111
|
+
const v1_Common_onDest = resGetDest.ibGibs[0];
|
|
112
|
+
await metaspace.registerNewIbGib({ ibGib: v1_Common_onDest, space: destSpace });
|
|
113
|
+
// 4. Create Divergence (V2a vs V2b)
|
|
114
|
+
let v2a;
|
|
115
|
+
let v2b;
|
|
116
|
+
let baseAddr;
|
|
117
|
+
let orphanAddr;
|
|
118
|
+
if (srcMakesFirstDivergentEdit) {
|
|
119
|
+
// Source: V1 -> V2a (Edit Field A)
|
|
120
|
+
v2a = await mut8Timeline({
|
|
121
|
+
timeline: v1_Common_onSource,
|
|
122
|
+
mut8Opts: {
|
|
123
|
+
mut8Ib: testRoot.ib + '_v2a',
|
|
124
|
+
dataToAddOrPatch: { fieldA: 'source_edit' }
|
|
125
|
+
},
|
|
126
|
+
metaspace,
|
|
127
|
+
space: sourceSpace,
|
|
128
|
+
});
|
|
129
|
+
baseAddr = getIbGibAddr({ ibGib: v2a });
|
|
130
|
+
await delay(16);
|
|
131
|
+
// Dest: V1 -> V2b (Edit Field B)
|
|
132
|
+
v2b = await mut8Timeline({
|
|
133
|
+
timeline: v1_Common_onDest,
|
|
134
|
+
mut8Opts: {
|
|
135
|
+
mut8Ib: testRoot.ib + '_v2b',
|
|
136
|
+
dataToAddOrPatch: { fieldB: 'dest_edit' }
|
|
137
|
+
},
|
|
138
|
+
metaspace,
|
|
139
|
+
space: destSpace,
|
|
140
|
+
});
|
|
141
|
+
orphanAddr = getIbGibAddr({ ibGib: v2b });
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
// Dest: V1 -> V2b (Edit Field B)
|
|
145
|
+
v2b = await mut8Timeline({
|
|
146
|
+
timeline: v1_Common_onDest,
|
|
147
|
+
mut8Opts: {
|
|
148
|
+
mut8Ib: testRoot.ib + '_v2b',
|
|
149
|
+
dataToAddOrPatch: { fieldB: 'dest_edit' }
|
|
150
|
+
},
|
|
151
|
+
metaspace,
|
|
152
|
+
space: destSpace,
|
|
153
|
+
});
|
|
154
|
+
baseAddr = getIbGibAddr({ ibGib: v2b });
|
|
155
|
+
await delay(16);
|
|
156
|
+
// Source: V1 -> V2a (Edit Field A)
|
|
157
|
+
v2a = await mut8Timeline({
|
|
158
|
+
timeline: v1_Common_onSource,
|
|
159
|
+
mut8Opts: {
|
|
160
|
+
mut8Ib: testRoot.ib + '_v2a',
|
|
161
|
+
dataToAddOrPatch: { fieldA: 'source_edit' }
|
|
162
|
+
},
|
|
163
|
+
metaspace,
|
|
164
|
+
space: sourceSpace,
|
|
165
|
+
});
|
|
166
|
+
orphanAddr = getIbGibAddr({ ibGib: v2a });
|
|
167
|
+
}
|
|
168
|
+
// 5. Setup Coordinators
|
|
169
|
+
const senderCoordinator = new SyncSagaCoordinator();
|
|
170
|
+
const receiverCoordinator = new SyncSagaCoordinator();
|
|
171
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
172
|
+
await peer.initialized;
|
|
173
|
+
await peer.initializeOpts({
|
|
174
|
+
localMetaspace: metaspace,
|
|
175
|
+
localSpace: sourceSpace,
|
|
176
|
+
receiverSpace: destSpace,
|
|
177
|
+
receiverCoordinator,
|
|
178
|
+
receiverMetaspace: metaspace,
|
|
179
|
+
});
|
|
180
|
+
// 6. Run Sync with Identity
|
|
181
|
+
console.log(`${lc} Running Sync...`);
|
|
182
|
+
const resSync = await senderCoordinator.sync({
|
|
183
|
+
peer,
|
|
184
|
+
localSpace: sourceSpace,
|
|
185
|
+
metaspace,
|
|
186
|
+
domainIbGibs: [v2a],
|
|
187
|
+
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
188
|
+
senderIdentity: r1_senderIdentity_v0_source,
|
|
189
|
+
fnSenderSecret: async () => SENDER_SECRET,
|
|
190
|
+
});
|
|
191
|
+
await resSync.done;
|
|
192
|
+
// #region r1 verify post
|
|
193
|
+
await respecfully(sir, `r1 verify post`, async () => {
|
|
194
|
+
await ifWe(sir, `verify graft/merge tip contains both edits and graft relations`, async () => {
|
|
195
|
+
const sourceKV = await senderCoordinator.getKnowledgeMap({
|
|
196
|
+
space: sourceSpace,
|
|
197
|
+
metaspace,
|
|
198
|
+
domainIbGibs: [testRoot]
|
|
199
|
+
});
|
|
200
|
+
const sourceTipAddr = sourceKV[tjpAddr];
|
|
201
|
+
iReckon(sir, sourceTipAddr).asTo('Source tip exists').isGonnaBeTruthy();
|
|
202
|
+
if (sourceTipAddr) {
|
|
203
|
+
iReckon(sir, sourceTipAddr).asTo('Tip should not be v2a').not.isGonnaBe(getIbGibAddr({ ibGib: v2a }));
|
|
204
|
+
iReckon(sir, sourceTipAddr).asTo('Tip should not be v2b').not.isGonnaBe(getIbGibAddr({ ibGib: v2b }));
|
|
205
|
+
const resTip = await getFromSpace({ space: sourceSpace, addr: sourceTipAddr });
|
|
206
|
+
const newTip = resTip.ibGibs[0];
|
|
207
|
+
iReckon(sir, newTip.data.fieldA).asTo('Merged fieldA').isGonnaBe('source_edit');
|
|
208
|
+
iReckon(sir, newTip.data.fieldB).asTo('Merged fieldB').isGonnaBe('dest_edit');
|
|
209
|
+
const graftInfoRel = newTip.rel8ns?.[GRAFT_INFO_REL8N_NAME];
|
|
210
|
+
iReckon(sir, graftInfoRel).asTo('New Tip has graftinfo rel8n').isGonnaBeTruthy();
|
|
211
|
+
if (graftInfoRel?.[0]) {
|
|
212
|
+
const resGraft = await getFromSpace({ space: sourceSpace, addr: graftInfoRel[0] });
|
|
213
|
+
const graftInfo = resGraft.ibGibs[0];
|
|
214
|
+
const baseRel = graftInfo.rel8ns?.[GRAFT_BASE_REL8N_NAME];
|
|
215
|
+
const orphanRel = graftInfo.rel8ns?.[GRAFT_ORPHAN_REL8N_NAME];
|
|
216
|
+
iReckon(sir, baseRel?.[0]).asTo('Base matches').isGonnaBe(baseAddr);
|
|
217
|
+
iReckon(sir, orphanRel?.[0]).asTo('Orphan matches').isGonnaBe(orphanAddr);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
await ifWe(sir, 'sessionIdentity evolved the expected number of times', async () => {
|
|
222
|
+
const latestS = peer.currentSessionIdentity;
|
|
223
|
+
iReckon(sir, latestS).asTo('latest session identity exists').isGonnaBeTruthy();
|
|
224
|
+
if (latestS) {
|
|
225
|
+
console.log("ACTUAL SESSION IDENTITY N:", latestS.data?.n);
|
|
226
|
+
iReckon(sir, latestS.data?.n).asTo('session identity data.n').isGonnaBe(3); // conflict resolution adds one
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
await ifWe(sir, 'sender durable space has I (evolved frame)', async () => {
|
|
230
|
+
const latestSenderIdentityAddr = await metaspace.getLatestAddr({
|
|
231
|
+
addr: getIbGibAddr({ ibGib: r1_senderIdentity_v0_source }),
|
|
232
|
+
space: sourceSpace,
|
|
233
|
+
});
|
|
234
|
+
iReckon(sir, latestSenderIdentityAddr).asTo('latestSenderIdentityAddr exists').isGonnaBeTruthy();
|
|
235
|
+
if (latestSenderIdentityAddr) {
|
|
236
|
+
const resGetSourceI = await getFromSpace({ space: sourceSpace, addr: latestSenderIdentityAddr });
|
|
237
|
+
iReckon(sir, resGetSourceI.success && resGetSourceI.ibGibs?.length === 1).asTo('evolved I exists in sourceSpace').isGonnaBeTrue();
|
|
238
|
+
if (resGetSourceI.success && resGetSourceI.ibGibs?.[0]) {
|
|
239
|
+
const evolvedI = resGetSourceI.ibGibs[0];
|
|
240
|
+
iReckon(sir, evolvedI.data?.n).asTo('evolved I data.n').isGonnaBe(1);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
await ifWe(sir, 'receiver durable space has I (evolved frame)', async () => {
|
|
245
|
+
const latestSenderIdentityAddr = await metaspace.getLatestAddr({
|
|
246
|
+
addr: getIbGibAddr({ ibGib: r1_senderIdentity_v0_source }),
|
|
247
|
+
space: sourceSpace,
|
|
248
|
+
});
|
|
249
|
+
iReckon(sir, latestSenderIdentityAddr).asTo('latestSenderIdentityAddr exists').isGonnaBeTruthy();
|
|
250
|
+
if (latestSenderIdentityAddr) {
|
|
251
|
+
const resGetDestI = await getFromSpace({ space: destSpace, addr: latestSenderIdentityAddr });
|
|
252
|
+
iReckon(sir, resGetDestI.success && resGetDestI.ibGibs?.length === 1).asTo('evolved I exists in destSpace').isGonnaBeTrue();
|
|
253
|
+
if (resGetDestI.success && resGetDestI.ibGibs?.[0]) {
|
|
254
|
+
const evolvedI = resGetDestI.ibGibs[0];
|
|
255
|
+
iReckon(sir, evolvedI.data?.n).asTo('evolved I data.n').isGonnaBe(1);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
await ifWe(sir, 'session keystone dependency graphs are equivalent on source and dest', async () => {
|
|
260
|
+
const latestS = peer.currentSessionIdentity;
|
|
261
|
+
iReckon(sir, latestS).asTo('latestS exists').isGonnaBeTruthy();
|
|
262
|
+
if (latestS) {
|
|
263
|
+
const depGraphSource = await getDependencyGraph({ ibGib: latestS, space: sourceSpace });
|
|
264
|
+
const depGraphDest = await getDependencyGraph({ ibGib: latestS, space: destSpace });
|
|
265
|
+
const equal = graphsAreEquivalent({ graphA: depGraphSource, graphB: depGraphDest });
|
|
266
|
+
iReckon(sir, equal).asTo('session graphs are equivalent').isGonnaBeTrue();
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
// #endregion r1 verify post
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
//# sourceMappingURL=sync-conflict-basic-divergence.withid.respec.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-conflict-basic-divergence.withid.respec.mjs","sourceRoot":"","sources":["../../src/sync/sync-conflict-basic-divergence.withid.respec.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,WAAW,EAAmB,OAAO,EAAE,IAAI,EAC9C,MAAM,kDAAkD,CAAC;AAC1D,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAA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OAAO,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,eAAe,EAAE,CAAC;oBAC/D,IAAI,OAAO,EAAE,CAAC;wBACV,MAAM,cAAc,GAAG,MAAM,kBAAkB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;wBACxF,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;wBACpF,MAAM,KAAK,GAAG,mBAAmB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;wBACpF,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,aAAa,EAAE,CAAC;oBAC9E,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;YACH,4BAA4B;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sync-conflict-basic-multitimelines.withid.respec
|
|
3
|
+
*
|
|
4
|
+
* Verifies Divergence Conflict Resolution (optimistic merge / grafting) with Identity
|
|
5
|
+
* when multiple related timelines are involved.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=sync-conflict-basic-multitimelines.withid.respec.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-conflict-basic-multitimelines.withid.respec.d.mts","sourceRoot":"","sources":["../../src/sync/sync-conflict-basic-multitimelines.withid.respec.mts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sync-conflict-basic-multitimelines.withid.respec
|
|
3
|
+
*
|
|
4
|
+
* Verifies Divergence Conflict Resolution (optimistic merge / grafting) with Identity
|
|
5
|
+
* when multiple related timelines are involved.
|
|
6
|
+
*/
|
|
7
|
+
import { respecfully, iReckon, ifWe } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
8
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
9
|
+
import { clone, delay } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
10
|
+
import { getIbGibAddr } from '@ibgib/ts-gib/dist/helper.mjs';
|
|
11
|
+
import { GLOBAL_LOG_A_LOT } from '../core-constants.mjs';
|
|
12
|
+
import { SyncSagaCoordinator } from './sync-saga-coordinator.mjs';
|
|
13
|
+
import { getFromSpace } from '../witness/space/space-helper.mjs';
|
|
14
|
+
import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs';
|
|
15
|
+
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
16
|
+
import { createTimelineRootTestHelper } from '../test-helpers.mjs';
|
|
17
|
+
import { appendToTimeline, mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
18
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
19
|
+
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
20
|
+
import { getIbGibsFromCache_fallbackToSpaces, getTjpAddr } from '../common/other/ibgib-helper.mjs';
|
|
21
|
+
import { getDependencyGraph, graphsAreEquivalent } from '../common/other/graph-helper.mjs';
|
|
22
|
+
import { SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs';
|
|
23
|
+
import { SyncConflictStrategy } from './sync-constants.mjs';
|
|
24
|
+
import { GRAFT_BASE_REL8N_NAME, GRAFT_ORPHAN_REL8N_NAME, GRAFT_INFO_REL8N_NAME } from './graft-info/graft-info-constants.mjs';
|
|
25
|
+
import { KeystoneService_V1 } from '../keystone/keystone-service-v1.mjs';
|
|
26
|
+
import { KEYSTONE_VERB_SYNC, POOL_ID_SYNC, } from '../keystone/keystone-constants.mjs';
|
|
27
|
+
import { createStandardPoolConfig } from '../keystone/keystone-config-builder.mjs';
|
|
28
|
+
import { KeystoneReplenishStrategy } from '../keystone/keystone-types.mjs';
|
|
29
|
+
const logalot = GLOBAL_LOG_A_LOT || false;
|
|
30
|
+
const lc = `[sync-conflict-basic-multitimelines.withid.respec]`;
|
|
31
|
+
const SENDER_SECRET = 'test-sender-secret-conflict-basic-multitimelines-withid';
|
|
32
|
+
const SENDER_IDENTITY_SYNC_POOL_CONFIG = createStandardPoolConfig({
|
|
33
|
+
id: POOL_ID_SYNC,
|
|
34
|
+
salt: 'senderidentitysyncsaltconflictbasicmultitimelineswithid',
|
|
35
|
+
verbs: [KEYSTONE_VERB_SYNC],
|
|
36
|
+
size: 200,
|
|
37
|
+
sequential: 1,
|
|
38
|
+
random: 1,
|
|
39
|
+
targetBinding: 2,
|
|
40
|
+
replenishStrategy: KeystoneReplenishStrategy.topUp,
|
|
41
|
+
});
|
|
42
|
+
const TEST_REL8N_NAME = 'testrel8n';
|
|
43
|
+
await respecfully(sir, `Sync Conflict Basic Multitimelines with Identity`, async () => {
|
|
44
|
+
for (let i = 0; i <= 1; i++) {
|
|
45
|
+
const srcMakesFirstDivergentEdit = i === 0;
|
|
46
|
+
await respecfully(sir, `srcMakesFirstDivergentEdit: ${srcMakesFirstDivergentEdit}`, async () => {
|
|
47
|
+
// 1. Setup Spaces
|
|
48
|
+
const metaspace = new Metaspace_Innerspace(undefined);
|
|
49
|
+
await metaspace.initialize({
|
|
50
|
+
getFnAlert: () => async ({ title, msg }) => { console.log(`[Alert] ${title}: ${msg}`); },
|
|
51
|
+
getFnPrompt: () => async ({ title, msg }) => { console.log(`[Prompt] ${title}: ${msg}`); return ''; },
|
|
52
|
+
getFnPromptPassword: () => async (title, msg) => { console.log(`[PromptPwd] ${title}: ${msg}`); return null; },
|
|
53
|
+
});
|
|
54
|
+
while (!metaspace.initialized) {
|
|
55
|
+
await delay(10);
|
|
56
|
+
}
|
|
57
|
+
const defaultLocalUserSpace = await metaspace.getLocalUserSpace({ lock: false });
|
|
58
|
+
await defaultLocalUserSpace.initialized;
|
|
59
|
+
const sourceSpace = new InnerSpace_V1({
|
|
60
|
+
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
61
|
+
name: 'source',
|
|
62
|
+
uuid: 'source_uuid',
|
|
63
|
+
description: 'source test space',
|
|
64
|
+
});
|
|
65
|
+
await sourceSpace.initialized;
|
|
66
|
+
const destSpace = new InnerSpace_V1({
|
|
67
|
+
...DEFAULT_INNER_SPACE_DATA_V1,
|
|
68
|
+
name: 'dest',
|
|
69
|
+
uuid: 'dest_uuid',
|
|
70
|
+
description: 'dest test space',
|
|
71
|
+
});
|
|
72
|
+
await destSpace.initialized;
|
|
73
|
+
// 2. Setup Identities
|
|
74
|
+
const keystoneSvc = new KeystoneService_V1();
|
|
75
|
+
const r1_senderIdentity_v0_source = await keystoneSvc.genesis({
|
|
76
|
+
masterSecret: SENDER_SECRET,
|
|
77
|
+
configs: [SENDER_IDENTITY_SYNC_POOL_CONFIG],
|
|
78
|
+
metaspace,
|
|
79
|
+
space: sourceSpace,
|
|
80
|
+
});
|
|
81
|
+
// Register identity in both spaces
|
|
82
|
+
await metaspace.put({ ibGib: r1_senderIdentity_v0_source, space: destSpace });
|
|
83
|
+
await metaspace.registerNewIbGib({ ibGib: r1_senderIdentity_v0_source, space: destSpace });
|
|
84
|
+
// 3. Seed Common History (V0 -> V1)
|
|
85
|
+
const alpha_v0 = await createTimelineRootTestHelper({
|
|
86
|
+
ib: 'alpha_multitimelines_withid',
|
|
87
|
+
data: { type: 'alpha', },
|
|
88
|
+
space: sourceSpace,
|
|
89
|
+
});
|
|
90
|
+
const tjpAddr = getTjpAddr({ ibGib: alpha_v0, defaultIfNone: 'incomingAddr' }) ?? getIbGibAddr({ ibGib: alpha_v0 });
|
|
91
|
+
// Create v1 (common)
|
|
92
|
+
const alpha_v1_common_onSource = await mut8Timeline({
|
|
93
|
+
timeline: alpha_v0,
|
|
94
|
+
mut8Opts: {
|
|
95
|
+
mut8Ib: alpha_v0.ib + '_common',
|
|
96
|
+
dataToAddOrPatch: { commonField: 'common yo' }
|
|
97
|
+
},
|
|
98
|
+
metaspace,
|
|
99
|
+
space: sourceSpace,
|
|
100
|
+
});
|
|
101
|
+
// Sync alpha to dest immediately
|
|
102
|
+
const depGraph_alpha_v1Andcommon = await getDependencyGraph({
|
|
103
|
+
ibGibAddrs: [tjpAddr],
|
|
104
|
+
space: sourceSpace,
|
|
105
|
+
live: true,
|
|
106
|
+
}) ?? {};
|
|
107
|
+
await metaspace.put({ ibGibs: Object.values(depGraph_alpha_v1Andcommon), space: destSpace });
|
|
108
|
+
await metaspace.registerNewIbGib({ ibGib: alpha_v0, space: destSpace });
|
|
109
|
+
const resGetDest = await getFromSpace({ space: destSpace, addr: getIbGibAddr({ ibGib: alpha_v1_common_onSource }) });
|
|
110
|
+
if (!resGetDest.success || !resGetDest.ibGibs || resGetDest.ibGibs.length === 0) {
|
|
111
|
+
throw new Error("Failed to copy V1 to Dest");
|
|
112
|
+
}
|
|
113
|
+
const alpha_v1_common_onDest = resGetDest.ibGibs[0];
|
|
114
|
+
await metaspace.registerNewIbGib({ ibGib: alpha_v1_common_onDest, space: destSpace });
|
|
115
|
+
// 4. Create Divergences (V2a vs V2b)
|
|
116
|
+
let alpha_v3_source_rel8beta;
|
|
117
|
+
let alpha_v2_dest;
|
|
118
|
+
let baseAddr;
|
|
119
|
+
let orphanAddr;
|
|
120
|
+
let beta_v0_source;
|
|
121
|
+
let betaAddr_v0;
|
|
122
|
+
// Beta is created on source
|
|
123
|
+
beta_v0_source = await createTimelineRootTestHelper({
|
|
124
|
+
ib: 'beta_multitimelines_withid',
|
|
125
|
+
data: {
|
|
126
|
+
fieldA: 'beta field A created on source',
|
|
127
|
+
},
|
|
128
|
+
space: sourceSpace,
|
|
129
|
+
});
|
|
130
|
+
betaAddr_v0 = getIbGibAddr({ ibGib: beta_v0_source });
|
|
131
|
+
if (srcMakesFirstDivergentEdit) {
|
|
132
|
+
// Source: V1 -> V2a (Edit Field A + Rel8 Beta)
|
|
133
|
+
const alpha_v2_source_sansBeta = await mut8Timeline({
|
|
134
|
+
timeline: alpha_v1_common_onSource,
|
|
135
|
+
mut8Opts: {
|
|
136
|
+
mut8Ib: alpha_v0.ib + '_v2source',
|
|
137
|
+
dataToAddOrPatch: { fieldA: 'source_edit' }
|
|
138
|
+
},
|
|
139
|
+
metaspace,
|
|
140
|
+
space: sourceSpace,
|
|
141
|
+
});
|
|
142
|
+
alpha_v3_source_rel8beta = await appendToTimeline({
|
|
143
|
+
timeline: alpha_v2_source_sansBeta,
|
|
144
|
+
metaspace,
|
|
145
|
+
space: sourceSpace,
|
|
146
|
+
rel8nInfos: [
|
|
147
|
+
{ rel8nName: TEST_REL8N_NAME, ibGibs: [beta_v0_source] }
|
|
148
|
+
],
|
|
149
|
+
});
|
|
150
|
+
baseAddr = getIbGibAddr({ ibGib: alpha_v3_source_rel8beta });
|
|
151
|
+
await delay(16);
|
|
152
|
+
// Dest: V1 -> V2b (Edit Field B)
|
|
153
|
+
alpha_v2_dest = await mut8Timeline({
|
|
154
|
+
timeline: alpha_v1_common_onDest,
|
|
155
|
+
mut8Opts: {
|
|
156
|
+
mut8Ib: alpha_v0.ib + '_v2dest',
|
|
157
|
+
dataToAddOrPatch: { fieldB: 'dest_edit' }
|
|
158
|
+
},
|
|
159
|
+
metaspace,
|
|
160
|
+
space: destSpace,
|
|
161
|
+
});
|
|
162
|
+
orphanAddr = getIbGibAddr({ ibGib: alpha_v2_dest });
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
// Dest: V1 -> V2b (Edit Field B)
|
|
166
|
+
alpha_v2_dest = await mut8Timeline({
|
|
167
|
+
timeline: alpha_v1_common_onDest,
|
|
168
|
+
mut8Opts: {
|
|
169
|
+
mut8Ib: alpha_v0.ib + '_v2dest',
|
|
170
|
+
dataToAddOrPatch: { fieldB: 'dest_edit' }
|
|
171
|
+
},
|
|
172
|
+
metaspace,
|
|
173
|
+
space: destSpace,
|
|
174
|
+
});
|
|
175
|
+
baseAddr = getIbGibAddr({ ibGib: alpha_v2_dest });
|
|
176
|
+
await delay(16);
|
|
177
|
+
// Source: V1 -> V2a (Edit Field A + Rel8 Beta)
|
|
178
|
+
const alpha_v2_source_sansBeta = await mut8Timeline({
|
|
179
|
+
timeline: alpha_v1_common_onSource,
|
|
180
|
+
mut8Opts: {
|
|
181
|
+
mut8Ib: alpha_v0.ib + '_v2source',
|
|
182
|
+
dataToAddOrPatch: { fieldA: 'source_edit' }
|
|
183
|
+
},
|
|
184
|
+
metaspace,
|
|
185
|
+
space: sourceSpace,
|
|
186
|
+
});
|
|
187
|
+
alpha_v3_source_rel8beta = await appendToTimeline({
|
|
188
|
+
timeline: alpha_v2_source_sansBeta,
|
|
189
|
+
metaspace,
|
|
190
|
+
space: sourceSpace,
|
|
191
|
+
rel8nInfos: [
|
|
192
|
+
{ rel8nName: TEST_REL8N_NAME, ibGibs: [beta_v0_source] }
|
|
193
|
+
],
|
|
194
|
+
});
|
|
195
|
+
orphanAddr = getIbGibAddr({ ibGib: alpha_v3_source_rel8beta });
|
|
196
|
+
}
|
|
197
|
+
// 5. Setup Coordinators
|
|
198
|
+
const senderCoordinator = new SyncSagaCoordinator();
|
|
199
|
+
const receiverCoordinator = new SyncSagaCoordinator();
|
|
200
|
+
const peer = new SyncPeerInnerspace_V1(clone(SYNC_PEER_INNERSPACE_DEFAULT_DATA_V1));
|
|
201
|
+
await peer.initialized;
|
|
202
|
+
await peer.initializeOpts({
|
|
203
|
+
localMetaspace: metaspace,
|
|
204
|
+
localSpace: sourceSpace,
|
|
205
|
+
receiverSpace: destSpace,
|
|
206
|
+
receiverCoordinator,
|
|
207
|
+
receiverMetaspace: metaspace,
|
|
208
|
+
});
|
|
209
|
+
// 6. Run Sync with Identity
|
|
210
|
+
console.log(`${lc} Running Sync...`);
|
|
211
|
+
const resSync = await senderCoordinator.sync({
|
|
212
|
+
peer,
|
|
213
|
+
localSpace: sourceSpace,
|
|
214
|
+
metaspace,
|
|
215
|
+
domainIbGibs: [alpha_v3_source_rel8beta],
|
|
216
|
+
conflictStrategy: SyncConflictStrategy.optimisticWithLCS,
|
|
217
|
+
senderIdentity: r1_senderIdentity_v0_source,
|
|
218
|
+
fnSenderSecret: async () => SENDER_SECRET,
|
|
219
|
+
});
|
|
220
|
+
await resSync.done;
|
|
221
|
+
console.log(`${lc} Sync finished.`);
|
|
222
|
+
// 7. Verify merge & related timelines
|
|
223
|
+
await respecfully(sir, `verify merge and related timelines`, async () => {
|
|
224
|
+
await ifWe(sir, `verify graft/merge tip contains both edits and graft relations`, async () => {
|
|
225
|
+
const sourceKV = await senderCoordinator.getKnowledgeMap({
|
|
226
|
+
space: sourceSpace,
|
|
227
|
+
metaspace,
|
|
228
|
+
domainIbGibs: [alpha_v0]
|
|
229
|
+
});
|
|
230
|
+
const sourceTipAddr = sourceKV[tjpAddr];
|
|
231
|
+
iReckon(sir, sourceTipAddr).asTo('Source tip exists').isGonnaBeTruthy();
|
|
232
|
+
if (sourceTipAddr) {
|
|
233
|
+
iReckon(sir, sourceTipAddr).asTo('Tip should not be baseAddr').not.isGonnaBe(baseAddr);
|
|
234
|
+
iReckon(sir, sourceTipAddr).asTo('Tip should not be orphanAddr').not.isGonnaBe(orphanAddr);
|
|
235
|
+
const resTip = await getFromSpace({ space: sourceSpace, addr: sourceTipAddr });
|
|
236
|
+
const newTip = resTip.ibGibs[0];
|
|
237
|
+
iReckon(sir, newTip.data.fieldA).asTo('Merged fieldA').isGonnaBe('source_edit');
|
|
238
|
+
iReckon(sir, newTip.data.fieldB).asTo('Merged fieldB').isGonnaBe('dest_edit');
|
|
239
|
+
const graftInfoRel = newTip.rel8ns?.[GRAFT_INFO_REL8N_NAME];
|
|
240
|
+
iReckon(sir, graftInfoRel).asTo('New Tip has graftinfo rel8n').isGonnaBeTruthy();
|
|
241
|
+
if (graftInfoRel?.[0]) {
|
|
242
|
+
const resGraft = await getFromSpace({ space: sourceSpace, addr: graftInfoRel[0] });
|
|
243
|
+
const graftInfo = resGraft.ibGibs[0];
|
|
244
|
+
const baseRel = graftInfo.rel8ns?.[GRAFT_BASE_REL8N_NAME];
|
|
245
|
+
const orphanRel = graftInfo.rel8ns?.[GRAFT_ORPHAN_REL8N_NAME];
|
|
246
|
+
iReckon(sir, baseRel).asTo('Graft Base exists').isGonnaBeTruthy();
|
|
247
|
+
iReckon(sir, orphanRel).asTo('Graft Orphan exists').isGonnaBeTruthy();
|
|
248
|
+
iReckon(sir, baseRel.at(-1)).asTo('base rel8ns final addr will be baseAddr').isGonnaBe(baseAddr);
|
|
249
|
+
iReckon(sir, orphanRel.at(-1)).asTo('orphan rel8ns final addr will be orphanAddr').isGonnaBe(orphanAddr);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
await ifWe(sir, 'related timeline beta is synced to destSpace and graphs match', async () => {
|
|
254
|
+
const [beta_dest] = await getIbGibsFromCache_fallbackToSpaces({
|
|
255
|
+
addrs: [betaAddr_v0],
|
|
256
|
+
space: destSpace,
|
|
257
|
+
});
|
|
258
|
+
iReckon(sir, beta_dest).asTo('beta exists in dest').isGonnaBeTruthy();
|
|
259
|
+
if (beta_dest) {
|
|
260
|
+
const depGraph_beta_source = await getDependencyGraph({ ibGib: beta_v0_source, space: sourceSpace });
|
|
261
|
+
const depGraph_beta_dest = await getDependencyGraph({ ibGib: beta_dest, space: destSpace });
|
|
262
|
+
const betaDepsAreEqual = graphsAreEquivalent({
|
|
263
|
+
graphA: depGraph_beta_source,
|
|
264
|
+
graphB: depGraph_beta_dest,
|
|
265
|
+
slowButThorough: true,
|
|
266
|
+
});
|
|
267
|
+
iReckon(sir, betaDepsAreEqual).asTo('beta dependencies are fully synced').isGonnaBeTrue();
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
await ifWe(sir, 'sessionIdentity evolved the expected number of times', async () => {
|
|
271
|
+
const latestS = peer.currentSessionIdentity;
|
|
272
|
+
iReckon(sir, latestS).asTo('latest session identity exists').isGonnaBeTruthy();
|
|
273
|
+
if (latestS) {
|
|
274
|
+
console.log("ACTUAL SESSION IDENTITY N:", latestS.data?.n);
|
|
275
|
+
iReckon(sir, latestS.data?.n).asTo('session identity data.n').isGonnaBe(3);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
await ifWe(sir, 'sender durable space has I (evolved frame)', async () => {
|
|
279
|
+
const latestSenderIdentityAddr = await metaspace.getLatestAddr({
|
|
280
|
+
addr: getIbGibAddr({ ibGib: r1_senderIdentity_v0_source }),
|
|
281
|
+
space: sourceSpace,
|
|
282
|
+
});
|
|
283
|
+
iReckon(sir, latestSenderIdentityAddr).asTo('latestSenderIdentityAddr exists').isGonnaBeTruthy();
|
|
284
|
+
if (latestSenderIdentityAddr) {
|
|
285
|
+
const resGetSourceI = await getFromSpace({ space: sourceSpace, addr: latestSenderIdentityAddr });
|
|
286
|
+
iReckon(sir, resGetSourceI.success && resGetSourceI.ibGibs?.length === 1).asTo('evolved I exists in sourceSpace').isGonnaBeTrue();
|
|
287
|
+
if (resGetSourceI.success && resGetSourceI.ibGibs?.[0]) {
|
|
288
|
+
const evolvedI = resGetSourceI.ibGibs[0];
|
|
289
|
+
iReckon(sir, evolvedI.data?.n).asTo('evolved I data.n').isGonnaBe(1);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
await ifWe(sir, 'receiver durable space has I (evolved frame)', async () => {
|
|
294
|
+
const latestSenderIdentityAddr = await metaspace.getLatestAddr({
|
|
295
|
+
addr: getIbGibAddr({ ibGib: r1_senderIdentity_v0_source }),
|
|
296
|
+
space: sourceSpace,
|
|
297
|
+
});
|
|
298
|
+
iReckon(sir, latestSenderIdentityAddr).asTo('latestSenderIdentityAddr exists').isGonnaBeTruthy();
|
|
299
|
+
if (latestSenderIdentityAddr) {
|
|
300
|
+
const resGetDestI = await getFromSpace({ space: destSpace, addr: latestSenderIdentityAddr });
|
|
301
|
+
iReckon(sir, resGetDestI.success && resGetDestI.ibGibs?.length === 1).asTo('evolved I exists in destSpace').isGonnaBeTrue();
|
|
302
|
+
if (resGetDestI.success && resGetDestI.ibGibs?.[0]) {
|
|
303
|
+
const evolvedI = resGetDestI.ibGibs[0];
|
|
304
|
+
iReckon(sir, evolvedI.data?.n).asTo('evolved I data.n').isGonnaBe(1);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
await ifWe(sir, 'session keystone dependency graphs are equivalent on source and dest', async () => {
|
|
309
|
+
const latestS = peer.currentSessionIdentity;
|
|
310
|
+
iReckon(sir, latestS).asTo('latestS exists').isGonnaBeTruthy();
|
|
311
|
+
if (latestS) {
|
|
312
|
+
const depGraphSource = await getDependencyGraph({ ibGib: latestS, space: sourceSpace });
|
|
313
|
+
const depGraphDest = await getDependencyGraph({ ibGib: latestS, space: destSpace });
|
|
314
|
+
const equal = graphsAreEquivalent({ graphA: depGraphSource, graphB: depGraphDest });
|
|
315
|
+
iReckon(sir, equal).asTo('session graphs are equivalent').isGonnaBeTrue();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
//# sourceMappingURL=sync-conflict-basic-multitimelines.withid.respec.mjs.map
|