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