@ibgib/core-gib 0.1.20 → 0.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sync/graft-info/graft-info-constants.d.mts +5 -0
- package/dist/sync/graft-info/graft-info-constants.d.mts.map +1 -0
- package/dist/sync/graft-info/graft-info-constants.mjs +5 -0
- package/dist/sync/graft-info/graft-info-constants.mjs.map +1 -0
- package/dist/sync/graft-info/graft-info-helpers.d.mts +49 -0
- package/dist/sync/graft-info/graft-info-helpers.d.mts.map +1 -0
- package/dist/sync/graft-info/graft-info-helpers.mjs +236 -0
- package/dist/sync/graft-info/graft-info-helpers.mjs.map +1 -0
- package/dist/sync/graft-info/graft-info-helpers.respec.d.mts +2 -0
- package/dist/sync/graft-info/graft-info-helpers.respec.d.mts.map +1 -0
- package/dist/sync/graft-info/graft-info-helpers.respec.mjs +70 -0
- package/dist/sync/graft-info/graft-info-helpers.respec.mjs.map +1 -0
- package/dist/sync/graft-info/graft-info-types.d.mts +31 -0
- package/dist/sync/{merge-info/merge-info-types.d.mts.map → graft-info/graft-info-types.d.mts.map} +1 -1
- package/dist/sync/graft-info/graft-info-types.mjs +2 -0
- package/dist/sync/graft-info/graft-info-types.mjs.map +1 -0
- package/dist/sync/strategies/conflict-optimistic.d.mts +1 -1
- package/dist/sync/strategies/conflict-optimistic.d.mts.map +1 -1
- package/dist/sync/strategies/conflict-optimistic.mjs +10 -60
- package/dist/sync/strategies/conflict-optimistic.mjs.map +1 -1
- package/dist/sync/sync-conflict.respec.mjs +155 -34
- package/dist/sync/sync-conflict.respec.mjs.map +1 -1
- package/dist/sync/sync-constants.d.mts +9 -11
- package/dist/sync/sync-constants.d.mts.map +1 -1
- package/dist/sync/sync-constants.mjs +3 -5
- package/dist/sync/sync-constants.mjs.map +1 -1
- package/dist/sync/sync-helpers.d.mts +2 -0
- package/dist/sync/sync-helpers.d.mts.map +1 -1
- package/dist/sync/sync-helpers.mjs +11 -9
- package/dist/sync/sync-helpers.mjs.map +1 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs +5 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs +5 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs +8 -4
- package/dist/sync/sync-innerspace-dest-ahead.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs +5 -1
- package/dist/sync/sync-innerspace-multiple-timelines.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-partial-update.respec.mjs +5 -1
- package/dist/sync/sync-innerspace-partial-update.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +5 -1
- package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-constants.d.mts +2 -0
- package/dist/sync/sync-peer/sync-peer-constants.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-constants.mjs +2 -0
- package/dist/sync/sync-peer/sync-peer-constants.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-helpers.d.mts +2 -0
- package/dist/sync/sync-peer/sync-peer-helpers.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-helpers.mjs +2 -0
- package/dist/sync/sync-peer/sync-peer-helpers.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts +8 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs +8 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.d.mts +18 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.mjs +54 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts +80 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mjs +5 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts +43 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.d.mts.map +1 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs +229 -0
- package/dist/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs.map +1 -0
- package/dist/sync/sync-peer/sync-peer-types.d.mts +12 -0
- package/dist/sync/sync-peer/sync-peer-types.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.d.mts +15 -7
- package/dist/sync/sync-peer/sync-peer-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-v1.mjs +105 -24
- package/dist/sync/sync-peer/sync-peer-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-helpers.d.mts +5 -8
- 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 +34 -18
- 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 +26 -22
- package/dist/sync/sync-saga-context/sync-saga-context-types.d.mts.map +1 -1
- package/dist/sync/sync-saga-context/sync-saga-context-types.mjs +1 -9
- package/dist/sync/sync-saga-context/sync-saga-context-types.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +48 -51
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +720 -420
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs +1 -0
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts +1 -12
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +15 -3
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/witness/light-witness-base-v1.d.mts.map +1 -1
- package/dist/witness/light-witness-base-v1.mjs +2 -0
- package/dist/witness/light-witness-base-v1.mjs.map +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.mjs +1 -1
- package/dist/witness/space/inner-space/inner-space-v1.mjs.map +1 -1
- package/ibgib-foundations.md +20 -2
- package/package.json +1 -1
- package/src/sync/README.md +31 -22
- package/src/sync/graft-info/graft-info-constants.mts +4 -0
- package/src/sync/graft-info/graft-info-helpers.mts +308 -0
- package/src/sync/graft-info/graft-info-helpers.respec.mts +83 -0
- package/src/sync/graft-info/graft-info-types.mts +33 -0
- package/src/sync/strategies/conflict-optimistic.mts +11 -70
- package/src/sync/sync-conflict.respec.mts +177 -37
- package/src/sync/sync-constants.mts +5 -9
- package/src/sync/sync-helpers.mts +11 -7
- package/src/sync/sync-innerspace-constants.respec.mts +5 -1
- package/src/sync/sync-innerspace-deep-updates.respec.mts +5 -1
- package/src/sync/sync-innerspace-dest-ahead.respec.mts +7 -3
- package/src/sync/sync-innerspace-multiple-timelines.respec.mts +5 -1
- package/src/sync/sync-innerspace-partial-update.respec.mts +8 -2
- package/src/sync/sync-innerspace.respec.mts +5 -1
- package/src/sync/sync-peer/sync-peer-constants.mts +0 -0
- package/src/sync/sync-peer/sync-peer-helpers.mts +0 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-constants.mts +8 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-helpers.mts +72 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-types.mts +87 -0
- package/src/sync/sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mts +242 -0
- package/src/sync/sync-peer/sync-peer-types.mts +13 -1
- package/src/sync/sync-peer/sync-peer-v1.mts +93 -27
- package/src/sync/sync-saga-context/sync-saga-context-helpers.mts +47 -29
- package/src/sync/sync-saga-context/sync-saga-context-types.mts +29 -30
- package/src/sync/sync-saga-coordinator.mts +782 -441
- package/src/sync/sync-saga-message/sync-saga-message-helpers.mts +2 -0
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +0 -11
- package/src/sync/sync-types.mts +17 -3
- package/src/witness/light-witness-base-v1.mts +2 -1
- package/src/witness/space/inner-space/inner-space-v1.mts +1 -1
- package/test_output.log +489 -0
- package/tmp.md +61 -2
- package/dist/sync/merge-info/merge-info-constants.d.mts +0 -2
- package/dist/sync/merge-info/merge-info-constants.d.mts.map +0 -1
- package/dist/sync/merge-info/merge-info-constants.mjs +0 -2
- package/dist/sync/merge-info/merge-info-constants.mjs.map +0 -1
- package/dist/sync/merge-info/merge-info-helpers.d.mts +0 -51
- package/dist/sync/merge-info/merge-info-helpers.d.mts.map +0 -1
- package/dist/sync/merge-info/merge-info-helpers.mjs +0 -92
- package/dist/sync/merge-info/merge-info-helpers.mjs.map +0 -1
- package/dist/sync/merge-info/merge-info-helpers.respec.d.mts +0 -2
- package/dist/sync/merge-info/merge-info-helpers.respec.d.mts.map +0 -1
- package/dist/sync/merge-info/merge-info-helpers.respec.mjs +0 -32
- package/dist/sync/merge-info/merge-info-helpers.respec.mjs.map +0 -1
- package/dist/sync/merge-info/merge-info-types.d.mts +0 -26
- package/dist/sync/merge-info/merge-info-types.mjs +0 -2
- package/dist/sync/merge-info/merge-info-types.mjs.map +0 -1
- package/dist/sync/sync-local-spaces.respec.d.mts +0 -2
- package/dist/sync/sync-local-spaces.respec.d.mts.map +0 -1
- package/dist/sync/sync-local-spaces.respec.mjs +0 -159
- package/dist/sync/sync-local-spaces.respec.mjs.map +0 -1
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts +0 -39
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts.map +0 -1
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs +0 -131
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs.map +0 -1
- package/dist/sync/sync-saga-coordinator.respec.d.mts +0 -2
- package/dist/sync/sync-saga-coordinator.respec.d.mts.map +0 -1
- package/dist/sync/sync-saga-coordinator.respec.mjs +0 -40
- package/dist/sync/sync-saga-coordinator.respec.mjs.map +0 -1
- package/src/sync/merge-info/merge-info-constants.mts +0 -1
- package/src/sync/merge-info/merge-info-helpers.mts +0 -134
- package/src/sync/merge-info/merge-info-helpers.respec.mts +0 -41
- package/src/sync/merge-info/merge-info-types.mts +0 -28
- package/src/sync/sync-local-spaces.respec.mts +0 -200
- package/src/sync/sync-peer/sync-peer-innerspace-v1.mts +0 -167
- package/src/sync/sync-saga-coordinator.respec.mts +0 -52
|
@@ -19,11 +19,14 @@ import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-inner
|
|
|
19
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
20
20
|
import { createTimelineRootHelper, getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
21
21
|
import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
22
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
22
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
23
23
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
24
|
-
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
|
+
import { getTjpAddr, toDto } from '../common/other/ibgib-helper.mjs';
|
|
25
25
|
import { SyncConflictStrategy, SyncSagaInfo } from './sync-types.mjs';
|
|
26
|
-
import { IbGibData_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
26
|
+
import { IbGibData_V1, IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
27
|
+
import { fnObs } from '../common/pubsub/observer/observer-helper.mjs';
|
|
28
|
+
import { getDependencyGraph } from '../common/other/graph-helper.mjs';
|
|
29
|
+
import { ErrorIbGib_V1 } from '../common/error/error-types.mjs';
|
|
27
30
|
|
|
28
31
|
interface TestData extends IbGibData_V1 {
|
|
29
32
|
text?: string;
|
|
@@ -71,28 +74,43 @@ await respecfully(sir, `Sync Conflict Resolution`, async () => {
|
|
|
71
74
|
|
|
72
75
|
// 2. Seed Common History (V0 -> V1)
|
|
73
76
|
console.log(`${lc} Creating Common History...`);
|
|
74
|
-
const
|
|
77
|
+
const testRoot = await createTimelineRootHelper<TestData>({
|
|
75
78
|
ib: 'timeline_root',
|
|
76
|
-
data: { type: '
|
|
79
|
+
data: { type: 'testRoot', text: 'v0' },
|
|
77
80
|
space: sourceSpace,
|
|
78
81
|
});
|
|
79
|
-
// Sync root to dest immediately so they start synced
|
|
80
|
-
await metaspace.put({ ibGib: root, space: destSpace });
|
|
81
|
-
await metaspace.registerNewIbGib({ ibGib: root, space: destSpace });
|
|
82
|
-
|
|
83
|
-
|
|
84
82
|
// Create V1 (Common)
|
|
85
|
-
const
|
|
86
|
-
timeline:
|
|
87
|
-
mut8Opts: {
|
|
83
|
+
const v1_Common = await mut8Timeline<TestData>({
|
|
84
|
+
timeline: testRoot,
|
|
85
|
+
mut8Opts: {
|
|
86
|
+
mut8Ib: testRoot.ib + '_common',
|
|
87
|
+
dataToAddOrPatch: { text: 'v1_common' }
|
|
88
|
+
},
|
|
88
89
|
metaspace,
|
|
89
90
|
space: sourceSpace,
|
|
90
91
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const tjpAddr =
|
|
93
|
+
getTjpAddr({ ibGib: testRoot, defaultIfNone: 'incomingAddr' }) ??
|
|
94
|
+
getIbGibAddr({ ibGib: testRoot });
|
|
95
|
+
console.log(`${lc} [TEST DEBUG] tjpAddr: ${tjpAddr}`)
|
|
96
|
+
// Sync testRoot to dest immediately so they start synced
|
|
97
|
+
// must get the entire dependency graph for testRoot
|
|
98
|
+
const depGraph_testRootAndV1Common = await getDependencyGraph({
|
|
99
|
+
ibGibAddrs: [tjpAddr],
|
|
100
|
+
space: sourceSpace,
|
|
101
|
+
live: true,
|
|
102
|
+
}) ?? {};
|
|
103
|
+
console.log(`${lc} depGraph_testRootAndV1Common: ${pretty(depGraph_testRootAndV1Common)}`)
|
|
104
|
+
if (Object.keys(depGraph_testRootAndV1Common).length === 0) {
|
|
105
|
+
throw new Error(`(UNEXPECTED) depGraph_testRootAndV1Common empty? (E: 39b4d855ffa65476084b4123786da826)`);
|
|
106
|
+
}
|
|
107
|
+
// put the entire graph into the destspace, but...
|
|
108
|
+
await metaspace.put({ ibGibs: Object.values(depGraph_testRootAndV1Common), space: destSpace });
|
|
109
|
+
// ...only register the main ibgibs
|
|
110
|
+
await metaspace.registerNewIbGib({ ibGib: testRoot, space: destSpace });
|
|
111
|
+
await metaspace.registerNewIbGib({ ibGib: v1_Common, space: destSpace });
|
|
94
112
|
|
|
95
|
-
const resGetDest = await getFromSpace({ space: destSpace, addr: getIbGibAddr({ ibGib:
|
|
113
|
+
const resGetDest = await getFromSpace({ space: destSpace, addr: getIbGibAddr({ ibGib: v1_Common }) });
|
|
96
114
|
if (!resGetDest.success || !resGetDest.ibGibs || resGetDest.ibGibs.length === 0) {
|
|
97
115
|
throw new Error(`Failed to retrieve v1_Dest from destSpace. (E: a1b2c3d4e5f6g7h8i9j0)`);
|
|
98
116
|
}
|
|
@@ -104,8 +122,11 @@ await respecfully(sir, `Sync Conflict Resolution`, async () => {
|
|
|
104
122
|
|
|
105
123
|
// Source: V1 -> V2a (Edit Field A)
|
|
106
124
|
const v2a = await mut8Timeline<TestData>({
|
|
107
|
-
timeline:
|
|
108
|
-
mut8Opts: {
|
|
125
|
+
timeline: v1_Common,
|
|
126
|
+
mut8Opts: {
|
|
127
|
+
mut8Ib: testRoot.ib + '_v2a',
|
|
128
|
+
dataToAddOrPatch: { fieldA: 'source_edit' }
|
|
129
|
+
},
|
|
109
130
|
metaspace,
|
|
110
131
|
space: sourceSpace,
|
|
111
132
|
});
|
|
@@ -113,15 +134,15 @@ await respecfully(sir, `Sync Conflict Resolution`, async () => {
|
|
|
113
134
|
// Dest: V1 -> V2b (Edit Field B)
|
|
114
135
|
const v2b = await mut8Timeline<TestData>({
|
|
115
136
|
timeline: v1_Dest,
|
|
116
|
-
mut8Opts: {
|
|
137
|
+
mut8Opts: {
|
|
138
|
+
mut8Ib: testRoot.ib + '_v2b',
|
|
139
|
+
dataToAddOrPatch: { fieldB: 'dest_edit' }
|
|
140
|
+
},
|
|
117
141
|
metaspace,
|
|
118
142
|
space: destSpace,
|
|
119
143
|
});
|
|
120
144
|
|
|
121
145
|
// Verify Divergence
|
|
122
|
-
const tjpAddr = root.rel8ns!.tjp![0]; // wait, root IS tjp, so no tjp rel8n...
|
|
123
|
-
// Actually root frame has isTjp: true.
|
|
124
|
-
// v1 has tjp: [v0_gib].
|
|
125
146
|
console.log(`${lc} Divergence created.`);
|
|
126
147
|
|
|
127
148
|
|
|
@@ -131,27 +152,47 @@ await respecfully(sir, `Sync Conflict Resolution`, async () => {
|
|
|
131
152
|
const senderCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
132
153
|
const receiverCoordinator = new SyncSagaCoordinator(mockKeystone);
|
|
133
154
|
|
|
155
|
+
|
|
156
|
+
|
|
134
157
|
const peer = new SyncPeerInnerspace_V1({
|
|
135
158
|
senderSpace: sourceSpace,
|
|
159
|
+
// No senderTempSpace - sync() creates its own internally
|
|
136
160
|
receiverSpace: destSpace,
|
|
137
161
|
receiverCoordinator,
|
|
138
162
|
receiverMetaspace: metaspace,
|
|
163
|
+
receiverTempSpace: 0 as any, // placeholder this is wrong
|
|
164
|
+
senderTempSpace: 0 as any, // placeholder this is wrong
|
|
165
|
+
}, {
|
|
166
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
139
167
|
});
|
|
168
|
+
await peer.initialized;
|
|
169
|
+
await peer.initialize();
|
|
140
170
|
|
|
141
171
|
// Verify Receiver has correct KV (Pre-Sync Check)
|
|
142
172
|
// This ensures the conflict precondition exists.
|
|
143
173
|
await ifWe(sir, 'verify receiver KV pre-sync', async () => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
174
|
+
try {
|
|
175
|
+
const destKV = await receiverCoordinator.getKnowledgeVector({
|
|
176
|
+
space: destSpace,
|
|
177
|
+
metaspace,
|
|
178
|
+
domainIbGibs: [v1_Dest]
|
|
179
|
+
});
|
|
180
|
+
const v1TjpAddr = getTjpAddr({ ibGib: v1_Dest, defaultIfNone: 'incomingAddr' }) ?? getIbGibAddr({ ibGib: v1_Dest });
|
|
181
|
+
console.log(`[TEST DEBUG] v1_Dest: ${JSON.stringify(v1_Dest)}`);
|
|
182
|
+
console.log(`[TEST DEBUG] v1TjpAddr: ${v1TjpAddr}`);
|
|
183
|
+
console.log(`[TEST DEBUG] destKV: ${JSON.stringify(destKV)}`);
|
|
184
|
+
console.log(`[TEST DEBUG] v1_Dest.rel8ns.tjp: ${v1_Dest.rel8ns?.tjp?.join(', ')}`);
|
|
185
|
+
|
|
186
|
+
// Actually v1 has tjp rel8n.
|
|
187
|
+
const destTip = destKV[v1TjpAddr];
|
|
188
|
+
iReckon(sir, !!destTip).asTo(`Dest KV has timeline tip for ${v1TjpAddr}`).isGonnaBeTruthy();
|
|
189
|
+
if (!destTip) {
|
|
190
|
+
throw new Error(`Test Setup Fail: Dest Space does not have index for timeline ${v1TjpAddr}. Seeding failed. (E: c194a80b4e4877b77826c37a1753b826)`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
195
|
+
iReckon(sir, true).asTo('getKnowledgeVector errored out').isGonnaBeFalse();
|
|
155
196
|
}
|
|
156
197
|
});
|
|
157
198
|
|
|
@@ -171,7 +212,32 @@ await respecfully(sir, `Sync Conflict Resolution`, async () => {
|
|
|
171
212
|
// explicit useSessionIdentity: true is default
|
|
172
213
|
});
|
|
173
214
|
|
|
215
|
+
const sublc = `${lc}[updates$]`;
|
|
216
|
+
/**
|
|
217
|
+
* I have added this so you can see how to subscribe to an ibgib
|
|
218
|
+
* observable using {@link fnObs}.
|
|
219
|
+
*/
|
|
220
|
+
const subscription = await resSync.updates$.subscribe(fnObs({
|
|
221
|
+
next: async (ctxIbGib) => {
|
|
222
|
+
// console.log(`${sublc} next fired. ${JSON.stringify(ctxIbGib)}`);
|
|
223
|
+
console.log(`${sublc} next fired. (I: 72db8820f058312f5cb2a92b8f9bde26)`);
|
|
224
|
+
},
|
|
225
|
+
error: async (e: ErrorIbGib_V1) => {
|
|
226
|
+
if (e.data) {
|
|
227
|
+
console.error(`${sublc} error fired. error: ${JSON.stringify(e.data)} (E: 01cc08ba05ad99682831174fd7c31a26)`);
|
|
228
|
+
} else {
|
|
229
|
+
console.dir(e);
|
|
230
|
+
console.error(`${sublc} error fired. error: ${extractErrorMsg(e)} (E: 73d3d61464e8e4ce4cd6efd8b9675826)`);
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
complete: async () => {
|
|
234
|
+
console.log(`${sublc} complete fired`);
|
|
235
|
+
},
|
|
236
|
+
}));
|
|
237
|
+
|
|
238
|
+
console.log(`${lc} awaiting resSync.done`)
|
|
174
239
|
await resSync.done;
|
|
240
|
+
|
|
175
241
|
console.log(`${lc} Sync Complete.`);
|
|
176
242
|
} catch (e) {
|
|
177
243
|
console.error(`${lc} Sync Failed with Error:`, e);
|
|
@@ -185,9 +251,83 @@ await respecfully(sir, `Sync Conflict Resolution`, async () => {
|
|
|
185
251
|
const resSourceTip = await getFromSpace({ space: sourceSpace, addr: getIbGibAddr({ ibGib: v2a }) });
|
|
186
252
|
|
|
187
253
|
await ifWe(sir, `verify merge happened`, async () => {
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
|
|
254
|
+
// Retrieve updated KV from Source (or check what happened to v2a)
|
|
255
|
+
// Ideally, we just check the source space for the timeline tip
|
|
256
|
+
// The timeline tip for testRoot/v0 should now be NEW.
|
|
257
|
+
|
|
258
|
+
try {
|
|
259
|
+
// Get the KV for the Source Space
|
|
260
|
+
const sourceKV = await senderCoordinator.getKnowledgeVector({
|
|
261
|
+
space: sourceSpace,
|
|
262
|
+
metaspace,
|
|
263
|
+
domainIbGibs: [testRoot] // We want to know the tip of this timeline
|
|
264
|
+
});
|
|
265
|
+
const tjpAddr =
|
|
266
|
+
getTjpAddr({ ibGib: testRoot, defaultIfNone: 'incomingAddr' }) ??
|
|
267
|
+
getIbGibAddr({ ibGib: testRoot });
|
|
268
|
+
|
|
269
|
+
if (logalot) { console.log(`${lc} getKnowledgeVector returned. sourceKV: ${pretty(sourceKV)} (I: e8780cda37c8b2a46eeb85786874e926)`); }
|
|
270
|
+
|
|
271
|
+
const sourceTipAddr = sourceKV[tjpAddr];
|
|
272
|
+
if (!sourceTipAddr) {
|
|
273
|
+
throw new Error(`Source Space missing timeline tip for ${tjpAddr} (E: ec95980b9c980c5c5870812e15e43826)`);
|
|
274
|
+
}
|
|
275
|
+
console.log(`${lc} [TEST DEBUG] sourceTipAddr: ${sourceTipAddr}`);
|
|
276
|
+
console.log(`${lc} [TEST DEBUG] v2a: ${getIbGibAddr({ ibGib: v2a })}`);
|
|
277
|
+
console.log(`${lc} [TEST DEBUG] v2b: ${getIbGibAddr({ ibGib: v2b })}`);
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
iReckon(sir, sourceTipAddr).asTo(`Source Tip (${sourceTipAddr}) should NOT be v2a`).not.isGonnaBe(getIbGibAddr({ ibGib: v2a }));
|
|
281
|
+
iReckon(sir, sourceTipAddr).asTo(`Source Tip (${sourceTipAddr}) should NOT be v2b`).not.isGonnaBe(getIbGibAddr({ ibGib: v2b }));
|
|
282
|
+
|
|
283
|
+
// Fetch the new tip
|
|
284
|
+
const resTip = await getFromSpace({ space: sourceSpace, addr: sourceTipAddr });
|
|
285
|
+
const newTip = resTip.ibGibs![0] as IbGib_V1<TestData>;
|
|
286
|
+
console.log(`${lc} [TEST DEBUG] newTip: ${JSON.stringify(newTip)}`);
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
// Check Data: Should have BOTH edits
|
|
290
|
+
iReckon(sir, newTip.data!.fieldA).asTo('New Tip Data Field A').isGonnaBe('source_edit');
|
|
291
|
+
iReckon(sir, newTip.data!.fieldB).asTo('New Tip Data Field B').isGonnaBe('dest_edit');
|
|
292
|
+
|
|
293
|
+
// Check Graft Structure
|
|
294
|
+
// Look for 'graftinfo' rel8n
|
|
295
|
+
const graftInfoRel = newTip.rel8ns?.graftinfo;
|
|
296
|
+
iReckon(sir, graftInfoRel).asTo('New Tip should have graftinfo rel8n').isGonnaBeTruthy();
|
|
297
|
+
if (graftInfoRel) {
|
|
298
|
+
iReckon(sir, graftInfoRel!.length).asTo('Only 1 graftinfo').isGonnaBe(1);
|
|
299
|
+
|
|
300
|
+
// Fetch Graft Info Stone
|
|
301
|
+
const resGraft = await getFromSpace({ space: sourceSpace, addr: graftInfoRel![0] });
|
|
302
|
+
const graftInfo = resGraft.ibGibs![0];
|
|
303
|
+
console.log(`${lc} [TEST DEBUG] graftInfo: ${JSON.stringify(graftInfo)}`);
|
|
304
|
+
|
|
305
|
+
// Check Graft Relations (graftbase, graftorphan)
|
|
306
|
+
const baseRel = graftInfo.rel8ns?.graftbase;
|
|
307
|
+
const orphanRel = graftInfo.rel8ns?.graftorphan;
|
|
308
|
+
|
|
309
|
+
iReckon(sir, baseRel).asTo('Graft Base exists').isGonnaBeTruthy();
|
|
310
|
+
iReckon(sir, orphanRel).asTo('Graft Orphan exists').isGonnaBeTruthy();
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
// Verify Base/Orphan identity (one should be v2a, one v2b)
|
|
314
|
+
const addrV2a = getIbGibAddr({ ibGib: v2a });
|
|
315
|
+
const addrV2b = getIbGibAddr({ ibGib: v2b });
|
|
316
|
+
|
|
317
|
+
const bases = baseRel || [];
|
|
318
|
+
const orphans = orphanRel || [];
|
|
319
|
+
|
|
320
|
+
const isV2aInvolved = bases.includes(addrV2a) || orphans.includes(addrV2a);
|
|
321
|
+
const isV2bInvolved = bases.includes(addrV2b) || orphans.includes(addrV2b);
|
|
322
|
+
|
|
323
|
+
iReckon(sir, isV2aInvolved).asTo('V2a is involved in graft').isGonnaBeTrue();
|
|
324
|
+
iReckon(sir, isV2bInvolved).asTo('V2b is involved in graft').isGonnaBeTrue();
|
|
325
|
+
}
|
|
326
|
+
} catch (error) {
|
|
327
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
328
|
+
iReckon(sir, true).asTo('getKnowledgeVector errored out').isGonnaBeFalse();
|
|
329
|
+
}
|
|
330
|
+
|
|
191
331
|
});
|
|
192
332
|
});
|
|
193
333
|
|
|
@@ -1,27 +1,24 @@
|
|
|
1
1
|
export const SYNC_ATOM = "sync";
|
|
2
2
|
|
|
3
3
|
export const SYNC_MSG_REL8N_NAME = "sync-msg";
|
|
4
|
-
export const SYNC_SAGA_PAYLOAD_ADDRS_REL8N_NAME = "@payloadAddrs";
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
|
-
*
|
|
5
|
+
* payload addrs should be domain-only, i.e., we are not including the sync
|
|
6
|
+
* saga ibgib, or its message stone, or identity keystones.
|
|
8
7
|
*/
|
|
9
|
-
export const
|
|
8
|
+
export const SYNC_SAGA_PAYLOAD_ADDRS_DOMAIN = "@payloadAddrsDomain";
|
|
10
9
|
|
|
11
10
|
export const SYNC_STAGE_INIT = "init";
|
|
12
11
|
export const SYNC_STAGE_ACK = "ack";
|
|
13
12
|
export const SYNC_STAGE_REQUEST = "request";
|
|
14
13
|
export const SYNC_STAGE_DELTA = "delta";
|
|
15
14
|
export const SYNC_STAGE_COMMIT = "commit";
|
|
16
|
-
export const SYNC_STAGE_CONFLICT = "conflict";
|
|
17
15
|
|
|
18
16
|
export type SyncStage =
|
|
19
17
|
| typeof SYNC_STAGE_INIT
|
|
20
18
|
| typeof SYNC_STAGE_ACK
|
|
21
19
|
| typeof SYNC_STAGE_REQUEST
|
|
22
20
|
| typeof SYNC_STAGE_DELTA
|
|
23
|
-
| typeof SYNC_STAGE_COMMIT
|
|
24
|
-
| typeof SYNC_STAGE_CONFLICT;
|
|
21
|
+
| typeof SYNC_STAGE_COMMIT;
|
|
25
22
|
|
|
26
23
|
export const SyncStage = {
|
|
27
24
|
init: SYNC_STAGE_INIT,
|
|
@@ -29,5 +26,4 @@ export const SyncStage = {
|
|
|
29
26
|
request: SYNC_STAGE_REQUEST,
|
|
30
27
|
delta: SYNC_STAGE_DELTA,
|
|
31
28
|
commit: SYNC_STAGE_COMMIT,
|
|
32
|
-
|
|
33
|
-
} as const;
|
|
29
|
+
} satisfies { [key: string]: SyncStage };
|
|
@@ -7,6 +7,7 @@ import { SYNC_ATOM, SYNC_MSG_REL8N_NAME } from "./sync-constants.mjs";
|
|
|
7
7
|
import { SyncData_V1, SyncIb_V1, SyncIbGib_V1 } from "./sync-types.mjs";
|
|
8
8
|
import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs";
|
|
9
9
|
import { getFromSpace } from "../witness/space/space-helper.mjs";
|
|
10
|
+
import { IbGibSpaceResultData, IbGibSpaceResultIbGib, IbGibSpaceResultRel8ns } from "../witness/space/space-types.mjs";
|
|
10
11
|
|
|
11
12
|
const logalot = GLOBAL_LOG_A_LOT;
|
|
12
13
|
|
|
@@ -161,6 +162,8 @@ export async function isPastFrame({
|
|
|
161
162
|
/**
|
|
162
163
|
* Gets a shallow dependency graph for a Sync Saga Frame.
|
|
163
164
|
*
|
|
165
|
+
* DOES NOT GET THE ENTIRE DEPENDENCY FRAME (INCLUDING PAST).
|
|
166
|
+
*
|
|
164
167
|
* Unlike standard `getDependencyGraph`, this does NOT traverse `ancestor` (history) or `past`.
|
|
165
168
|
* It only retrieves the *content* of the current frame:
|
|
166
169
|
* 1. The Frame itself.
|
|
@@ -181,13 +184,14 @@ export async function getSyncSagaDependencyGraph({
|
|
|
181
184
|
|
|
182
185
|
// Helper to fetch and push
|
|
183
186
|
const fetchAndPush = async (addrs: string[]) => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
187
|
+
const res = await getFromSpace({ space, addrs });
|
|
188
|
+
if (res.success && res.ibGibs?.length === addrs.length) {
|
|
189
|
+
res.ibGibs!.forEach(x => result.push(x));
|
|
190
|
+
} else {
|
|
191
|
+
const resIbGib =
|
|
192
|
+
res.rawResultIbGib as IbGibSpaceResultIbGib<IbGib_V1, IbGibSpaceResultData, IbGibSpaceResultRel8ns>
|
|
193
|
+
if (!resIbGib.data) { throw new Error(`(UNEXPECTED) res.rawResultIbGib.data falsy? (E: c26c681d2f831fc537ba6f48fee36d26)`); }
|
|
194
|
+
throw new Error(`(UNEXPECTED) couldn't find addrs? addrsNotFound: ${resIbGib.data.addrsNotFound}? (E: 43b7b5a6ad982715c8f3eed69bfa0d26)`);
|
|
191
195
|
}
|
|
192
196
|
};
|
|
193
197
|
|
|
@@ -16,10 +16,10 @@ import { Factory_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs';
|
|
|
16
16
|
import { SyncSagaCoordinator } from './sync-saga-coordinator.mjs';
|
|
17
17
|
import { putInSpace, getFromSpace } from '../witness/space/space-helper.mjs';
|
|
18
18
|
import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-innerspace/metaspace-innerspace.mjs';
|
|
19
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
20
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
21
20
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
22
21
|
import { getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
22
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
23
23
|
|
|
24
24
|
const lc = `[sync-innerspace-constants.respec]`;
|
|
25
25
|
|
|
@@ -74,6 +74,10 @@ await respecfully(sir, `Sync Constants (No TJP)`, async () => {
|
|
|
74
74
|
receiverSpace: destSpace,
|
|
75
75
|
receiverCoordinator: receiverCoordinator,
|
|
76
76
|
receiverMetaspace: metaspace,
|
|
77
|
+
receiverTempSpace: 0 as any, // placeholder this is wrong
|
|
78
|
+
senderTempSpace: 0 as any, // placeholder this is wrong
|
|
79
|
+
}, {
|
|
80
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
77
81
|
});
|
|
78
82
|
|
|
79
83
|
// 4. Sync C1 (First Pass)
|
|
@@ -19,9 +19,9 @@ import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-inner
|
|
|
19
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
20
20
|
import { createTimelineRootHelper, getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
21
21
|
import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
22
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
23
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
24
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
25
|
|
|
26
26
|
const logalot = true;
|
|
27
27
|
const lc = `[sync-innerspace-deep-updates.respec]`;
|
|
@@ -105,6 +105,10 @@ await respecfully(sir, `Sync InnerSpaces (Deep Updates)`, async () => {
|
|
|
105
105
|
receiverSpace: destSpace,
|
|
106
106
|
receiverCoordinator: receiverCoordinator,
|
|
107
107
|
receiverMetaspace: metaspace,
|
|
108
|
+
receiverTempSpace: 0 as any,
|
|
109
|
+
senderTempSpace: 0 as any,
|
|
110
|
+
}, {
|
|
111
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
108
112
|
});
|
|
109
113
|
|
|
110
114
|
// 4. Run Sync
|
|
@@ -19,9 +19,9 @@ import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-inner
|
|
|
19
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
20
20
|
import { createTimelineRootHelper, getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
21
21
|
import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
22
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
23
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
24
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
25
|
|
|
26
26
|
const logalot = true;
|
|
27
27
|
const lc = `[sync-innerspace-dest-ahead.respec]`;
|
|
@@ -98,7 +98,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
|
|
|
98
98
|
});
|
|
99
99
|
const addrV2 = getIbGibAddr({ ibGib: v2 });
|
|
100
100
|
|
|
101
|
-
await
|
|
101
|
+
await ifWeMight(sir, 'verify setup', async () => {
|
|
102
102
|
// Ensure V2 is ONLY in Dest (it is, per `space: destSpace`)
|
|
103
103
|
// Ensure Source does NOT have V2
|
|
104
104
|
const checkV2InSource = await getFromSpace({ space: sourceSpace, addr: addrV2 });
|
|
@@ -115,6 +115,10 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
|
|
|
115
115
|
receiverSpace: destSpace,
|
|
116
116
|
receiverCoordinator: receiverCoordinator,
|
|
117
117
|
receiverMetaspace: metaspace,
|
|
118
|
+
receiverTempSpace: 0 as any,// this is wrong just getting to build
|
|
119
|
+
senderTempSpace: 0 as any, // this is wrong just getting to build
|
|
120
|
+
}, {
|
|
121
|
+
classname: SyncPeerInnerspace_V1.name
|
|
118
122
|
});
|
|
119
123
|
|
|
120
124
|
// 4. Run Sync (Source Pushes V1)
|
|
@@ -132,7 +136,7 @@ await respecfully(sir, `Sync InnerSpaces (Dest Ahead)`, async () => {
|
|
|
132
136
|
// 5. Verify Dest (Should still have V2 as latest)
|
|
133
137
|
console.log(`${lc} Verifying Destination...`);
|
|
134
138
|
|
|
135
|
-
await
|
|
139
|
+
await ifWeMight(sir, `verify dest stays ahead`, async () => {
|
|
136
140
|
// Verify Tip (V2)
|
|
137
141
|
const getV2 = await getFromSpace({ space: destSpace, addr: addrV2 });
|
|
138
142
|
iReckon(sir, getV2.success).asTo('V2 still present in Dest').isGonnaBeTrue();
|
|
@@ -19,9 +19,9 @@ import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-inner
|
|
|
19
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
20
20
|
import { createTimelineRootHelper, getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
21
21
|
import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
22
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
23
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
24
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
25
|
|
|
26
26
|
const logalot = true;
|
|
27
27
|
const lc = `[sync-innerspace-multiple-timelines.respec]`;
|
|
@@ -109,6 +109,10 @@ await respecfully(sir, `Sync InnerSpaces (Multiple Timelines)`, async () => {
|
|
|
109
109
|
receiverSpace: destSpace,
|
|
110
110
|
receiverCoordinator: receiverCoordinator,
|
|
111
111
|
receiverMetaspace: metaspace,
|
|
112
|
+
receiverTempSpace: 0 as any,
|
|
113
|
+
senderTempSpace: 0 as any,
|
|
114
|
+
}, {
|
|
115
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
112
116
|
});
|
|
113
117
|
|
|
114
118
|
// 4. Run Sync (Push Both)
|
|
@@ -19,9 +19,9 @@ import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-inner
|
|
|
19
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
20
20
|
import { createTimelineRootHelper, getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
21
21
|
import { mut8Timeline } from '../timeline/timeline-api.mjs';
|
|
22
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
23
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
24
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
24
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
25
25
|
|
|
26
26
|
const logalot = true;
|
|
27
27
|
const lc = `[sync-innerspace-partial-update.respec]`;
|
|
@@ -117,7 +117,13 @@ await respecfully(sir, `Sync InnerSpaces (Partial Update)`, async () => {
|
|
|
117
117
|
receiverSpace: destSpace,
|
|
118
118
|
receiverCoordinator: receiverCoordinator,
|
|
119
119
|
receiverMetaspace: metaspace,
|
|
120
|
-
|
|
120
|
+
receiverTempSpace: 0 as any,
|
|
121
|
+
senderTempSpace: 0 as any,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
125
|
+
}
|
|
126
|
+
);
|
|
121
127
|
|
|
122
128
|
// 4. Run Sync (Source Pushes V2)
|
|
123
129
|
console.log(`${lc} Running Sync...`);
|
|
@@ -19,10 +19,10 @@ import { Metaspace_Innerspace } from '../witness/space/metaspace/metaspace-inner
|
|
|
19
19
|
import { InnerSpace_V1 } from '../witness/space/inner-space/inner-space-v1.mjs';
|
|
20
20
|
import { createTimelineRootHelper, getTestKeystoneServiceHelper } from '../agent-helpers.mjs';
|
|
21
21
|
import { mut8Timeline, } from '../timeline/timeline-api.mjs';
|
|
22
|
-
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace-v1.mjs';
|
|
23
22
|
import { DEFAULT_INNER_SPACE_DATA_V1 } from '../witness/space/inner-space/inner-space-types.mjs';
|
|
24
23
|
import { toDto } from '../common/other/ibgib-helper.mjs';
|
|
25
24
|
import { fnObs } from '../common/pubsub/observer/observer-helper.mjs';
|
|
25
|
+
import { SyncPeerInnerspace_V1 } from './sync-peer/sync-peer-innerspace/sync-peer-innerspace-v1.mjs';
|
|
26
26
|
|
|
27
27
|
const logalot = true;
|
|
28
28
|
const lc = `[sync-innerspace.respec]`;
|
|
@@ -108,6 +108,10 @@ await respecfully(sir, `Sync InnerSpaces`, async () => {
|
|
|
108
108
|
receiverSpace: destSpace, // "Server"
|
|
109
109
|
receiverCoordinator: receiverCoordinator,
|
|
110
110
|
receiverMetaspace: metaspace,
|
|
111
|
+
senderTempSpace: 0 as any,
|
|
112
|
+
receiverTempSpace: 0 as any,
|
|
113
|
+
}, {
|
|
114
|
+
classname: SyncPeerInnerspace_V1.name,
|
|
111
115
|
});
|
|
112
116
|
|
|
113
117
|
// 4. Run Sync
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sync peer innerspace helpers
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
6
|
+
import { Ib } from '@ibgib/ts-gib/dist/types.mjs';
|
|
7
|
+
|
|
8
|
+
import { SYNC_PEER_INNERSPACE_ATOM } from './sync-peer-innerspace-constants.mjs';
|
|
9
|
+
import { SyncPeerInnerspaceIb_V1, SyncPeerInnerspaceData_V1 } from './sync-peer-innerspace-types.mjs';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Constructs the standard 'ib' string for a Sync Peer Innerspace stone.
|
|
13
|
+
*/
|
|
14
|
+
export async function getSyncPeerInnerspaceIb({
|
|
15
|
+
data,
|
|
16
|
+
}: {
|
|
17
|
+
data: SyncPeerInnerspaceData_V1,
|
|
18
|
+
}): Promise<Ib> {
|
|
19
|
+
const lc = `[${getSyncPeerInnerspaceIb.name}]`;
|
|
20
|
+
try {
|
|
21
|
+
if (!data) { throw new Error(`data required (E: 7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d)`); }
|
|
22
|
+
|
|
23
|
+
if (!data.classname) { throw new Error(`invalid data. data.classname required. (E: 3aad38bfe23866c2d8c1ca66b03d9126)`); }
|
|
24
|
+
|
|
25
|
+
// sync_peer_innerspace
|
|
26
|
+
const ib = [
|
|
27
|
+
SYNC_PEER_INNERSPACE_ATOM,
|
|
28
|
+
data.classname,
|
|
29
|
+
].join(' ');
|
|
30
|
+
|
|
31
|
+
return ib;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Parses a standard Sync Peer Innerspace 'ib' string.
|
|
40
|
+
*/
|
|
41
|
+
export async function parseSyncPeerInnerspaceIb({
|
|
42
|
+
ib,
|
|
43
|
+
}: {
|
|
44
|
+
ib: Ib,
|
|
45
|
+
}): Promise<SyncPeerInnerspaceIb_V1> {
|
|
46
|
+
const lc = `[${parseSyncPeerInnerspaceIb.name}]`;
|
|
47
|
+
try {
|
|
48
|
+
if (ib !== SYNC_PEER_INNERSPACE_ATOM) {
|
|
49
|
+
throw new Error(`Atom mismatch. Expected ${SYNC_PEER_INNERSPACE_ATOM}. Got ${ib}. (E: 8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e)`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const pieces = ib.split(' ');
|
|
53
|
+
|
|
54
|
+
if (pieces.length !== 2) {
|
|
55
|
+
throw new Error(`invalid ib. expected 2 pieces: atom and classname (E: f9c0c8067368444bac69f5777eeaa826)`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const [
|
|
59
|
+
atom,
|
|
60
|
+
classname
|
|
61
|
+
] = pieces;
|
|
62
|
+
|
|
63
|
+
if (atom !== SYNC_PEER_INNERSPACE_ATOM) {
|
|
64
|
+
throw new Error(`invalid ib. atom (${atom}) is expected to be ${SYNC_PEER_INNERSPACE_ATOM} (E: fda078ef3a0853629eb22e48a01a8826)`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { atom, classname };
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|