@ibgib/core-gib 0.1.19 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/other/ibgib-helper.d.mts +13 -0
- package/dist/common/other/ibgib-helper.d.mts.map +1 -1
- package/dist/common/other/ibgib-helper.mjs +44 -0
- package/dist/common/other/ibgib-helper.mjs.map +1 -1
- 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/graft-info/graft-info-types.d.mts.map +1 -0
- 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 +37 -0
- package/dist/sync/strategies/conflict-optimistic.d.mts.map +1 -0
- package/dist/sync/strategies/conflict-optimistic.mjs +112 -0
- package/dist/sync/strategies/conflict-optimistic.mjs.map +1 -0
- package/dist/sync/sync-conflict.respec.d.mts +8 -0
- package/dist/sync/sync-conflict.respec.d.mts.map +1 -0
- package/dist/sync/sync-conflict.respec.mjs +277 -0
- package/dist/sync/sync-conflict.respec.mjs.map +1 -0
- package/dist/sync/sync-constants.d.mts +1 -3
- package/dist/sync/sync-constants.d.mts.map +1 -1
- package/dist/sync/sync-constants.mjs +0 -2
- package/dist/sync/sync-constants.mjs.map +1 -1
- package/dist/sync/sync-innerspace-constants.respec.mjs +2 -2
- package/dist/sync/sync-innerspace-constants.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs +0 -1
- package/dist/sync/sync-innerspace-deep-updates.respec.mjs.map +1 -1
- package/dist/sync/sync-innerspace.respec.mjs +1 -1
- package/dist/sync/sync-innerspace.respec.mjs.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts +5 -2
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.d.mts.map +1 -1
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs +70 -7
- package/dist/sync/sync-peer/sync-peer-innerspace-v1.mjs.map +1 -1
- package/dist/sync/sync-saga-coordinator.d.mts +45 -27
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +811 -253
- package/dist/sync/sync-saga-coordinator.mjs.map +1 -1
- package/dist/sync/sync-saga-message/sync-saga-message-helpers.d.mts +11 -0
- 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 +25 -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 +24 -12
- package/dist/sync/sync-saga-message/sync-saga-message-types.d.mts.map +1 -1
- package/dist/sync/sync-types.d.mts +31 -4
- package/dist/sync/sync-types.d.mts.map +1 -1
- package/dist/sync/sync-types.mjs.map +1 -1
- package/ibgib-foundations.md +147 -0
- package/package.json +1 -1
- package/roadmap.md +59 -0
- package/src/common/other/ibgib-helper.mts +52 -0
- package/src/keystone/README.md +13 -155
- package/src/keystone/docs/architecture.md +55 -0
- package/src/sync/README.md +37 -42
- package/src/sync/docs/architecture.md +69 -0
- package/src/sync/docs/verification.md +43 -0
- 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 +149 -0
- package/src/sync/sync-conflict.respec.mts +330 -0
- package/src/sync/sync-constants.mts +1 -4
- package/src/sync/sync-innerspace-constants.respec.mts +1 -1
- package/src/sync/sync-innerspace-deep-updates.respec.mts +0 -1
- package/src/sync/sync-innerspace.respec.mts +1 -1
- package/src/sync/sync-peer/sync-peer-innerspace-v1.mts +85 -12
- package/src/sync/sync-saga-coordinator.mts +905 -268
- package/src/sync/sync-saga-message/sync-saga-message-helpers.mts +43 -0
- package/src/sync/sync-saga-message/sync-saga-message-types.mts +23 -11
- package/src/sync/sync-types.mts +33 -4
- package/test_output.log +0 -0
- package/tmp.md +44 -426
|
@@ -20,6 +20,8 @@ export async function getSyncSagaMessageIb({
|
|
|
20
20
|
data.stage
|
|
21
21
|
].join(' ');
|
|
22
22
|
|
|
23
|
+
// console.log(`${lc} constructed ib: ${ib}`); // temporary debug
|
|
24
|
+
|
|
23
25
|
return ib;
|
|
24
26
|
} catch (error) {
|
|
25
27
|
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
@@ -57,3 +59,44 @@ export async function parseSyncSagaMessageIb({
|
|
|
57
59
|
throw error;
|
|
58
60
|
}
|
|
59
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Helper to retrieve the Message Stone associated with a Saga Frame.
|
|
65
|
+
*
|
|
66
|
+
* Saga Frames link to their Message Stone via the `sync-msg` relationship.
|
|
67
|
+
*/
|
|
68
|
+
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
69
|
+
import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
|
|
70
|
+
import { getRel8dIbGibs } from "../../common/other/ibgib-helper.mjs";
|
|
71
|
+
import { SYNC_MSG_REL8N_NAME } from "../sync-constants.mjs";
|
|
72
|
+
|
|
73
|
+
export async function getSyncSagaMessageFromFrame({
|
|
74
|
+
frameIbGib,
|
|
75
|
+
space,
|
|
76
|
+
}: {
|
|
77
|
+
frameIbGib: IbGib_V1,
|
|
78
|
+
space: IbGibSpaceAny,
|
|
79
|
+
}): Promise<IbGib_V1<SyncSagaMessageData_V1>> {
|
|
80
|
+
const lc = `[${getSyncSagaMessageFromFrame.name}]`;
|
|
81
|
+
try {
|
|
82
|
+
const rel8d = await getRel8dIbGibs({
|
|
83
|
+
ibGib: frameIbGib,
|
|
84
|
+
rel8nNames: [SYNC_MSG_REL8N_NAME],
|
|
85
|
+
space
|
|
86
|
+
});
|
|
87
|
+
const msgs = rel8d[SYNC_MSG_REL8N_NAME];
|
|
88
|
+
|
|
89
|
+
if (!msgs || msgs.length === 0) {
|
|
90
|
+
throw new Error(`(UNEXPECTED) No sync message stone found found for frame: ${frameIbGib.ib} (E: 8a4b2c1d3e5f6a9b7c8d9e0f1a2b3c4d)`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (msgs.length > 1) {
|
|
94
|
+
throw new Error(`(UNEXPECTED) Multiple sync message stones found (${msgs.length}) for frame: ${frameIbGib.ib}. logic not currently equipped to handle multiple messages per frame. (E: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d)`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return msgs[0] as IbGib_V1<SyncSagaMessageData_V1>;
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -47,25 +47,37 @@ export interface SyncSagaMessageAckData_V1 extends SyncSagaMessageData_V1 {
|
|
|
47
47
|
* Used by Sender to calculate differential payloads.
|
|
48
48
|
*/
|
|
49
49
|
knowledgeVector?: { [groupKey: string]: string[] };
|
|
50
|
+
/**
|
|
51
|
+
* List of identified conflicts.
|
|
52
|
+
*
|
|
53
|
+
* If present, the Sender should use the `timelineAddrs` (Receiver's history)
|
|
54
|
+
* to compute the LCA and delta requirements for merging.
|
|
55
|
+
*/
|
|
56
|
+
conflicts?: {
|
|
57
|
+
tjpAddr: string;
|
|
58
|
+
localAddr: string;
|
|
59
|
+
remoteAddr: string;
|
|
60
|
+
/**
|
|
61
|
+
* Full history of the timeline from the Receiver's perspective.
|
|
62
|
+
* Used by Sender to find LCA.
|
|
63
|
+
*/
|
|
64
|
+
timelineAddrs: string[];
|
|
65
|
+
reason: string;
|
|
66
|
+
terminal: boolean;
|
|
67
|
+
}[];
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
export interface SyncSagaMessageDeltaData_V1 extends SyncSagaMessageData_V1, SyncDeltaData {
|
|
53
71
|
stage: typeof SyncStage.delta;
|
|
54
72
|
requests?: string[];
|
|
73
|
+
/**
|
|
74
|
+
* Flag indicating the sender has no further requests or payloads
|
|
75
|
+
* and is ready to commit the transaction.
|
|
76
|
+
*/
|
|
77
|
+
proposeCommit?: boolean;
|
|
55
78
|
}
|
|
56
79
|
|
|
57
80
|
export interface SyncSagaMessageCommitData_V1 extends SyncSagaMessageData_V1, SyncCommitData {
|
|
58
81
|
stage: typeof SyncStage.commit;
|
|
59
82
|
}
|
|
60
83
|
|
|
61
|
-
export interface SyncSagaMessageConflictData_V1 extends SyncSagaMessageData_V1 {
|
|
62
|
-
stage: typeof SyncStage.conflict;
|
|
63
|
-
conflictStrategy: SyncConflictStrategy;
|
|
64
|
-
isTerminal: boolean; // default true for V1
|
|
65
|
-
conflicts: {
|
|
66
|
-
tjp: string;
|
|
67
|
-
localAddr?: string;
|
|
68
|
-
remoteAddr?: string;
|
|
69
|
-
reason?: string;
|
|
70
|
-
}[];
|
|
71
|
-
}
|
package/src/sync/sync-types.mts
CHANGED
|
@@ -4,6 +4,7 @@ import { KeystoneIbGib_V1, KeystoneProof } from "../keystone/keystone-types.mjs"
|
|
|
4
4
|
import { SYNC_ATOM, SyncStage } from "./sync-constants.mjs";
|
|
5
5
|
import { IbGibSpaceAny } from "../witness/space/space-base-v1.mjs";
|
|
6
6
|
import { MetaspaceService } from "../witness/space/metaspace/metaspace-types.mjs";
|
|
7
|
+
import { SyncPeerWitness } from "./sync-peer/sync-peer-types.mjs";
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
// #region SyncMode
|
|
@@ -45,6 +46,10 @@ export function isValidSyncConflictStrategy(strategy: string): strategy is SyncC
|
|
|
45
46
|
// #endregion SyncConflictStrategy
|
|
46
47
|
|
|
47
48
|
export interface SyncOptions {
|
|
49
|
+
/**
|
|
50
|
+
* The peer we are syncing with.
|
|
51
|
+
*/
|
|
52
|
+
peer: SyncPeerWitness;
|
|
48
53
|
/**
|
|
49
54
|
* The ibgibs we wish to sync.
|
|
50
55
|
*
|
|
@@ -54,11 +59,15 @@ export interface SyncOptions {
|
|
|
54
59
|
/**
|
|
55
60
|
* The space containing the data we want to send.
|
|
56
61
|
*/
|
|
57
|
-
source
|
|
62
|
+
source?: IbGibSpaceAny;
|
|
63
|
+
/**
|
|
64
|
+
* Alias for {@link source}. Used in some contexts.
|
|
65
|
+
*/
|
|
66
|
+
localSpace?: IbGibSpaceAny;
|
|
58
67
|
/**
|
|
59
68
|
* The space receiving the data.
|
|
60
69
|
*/
|
|
61
|
-
dest
|
|
70
|
+
dest?: IbGibSpaceAny;
|
|
62
71
|
/**
|
|
63
72
|
* The metaspace context (for registering sync sagas locally).
|
|
64
73
|
*/
|
|
@@ -66,16 +75,22 @@ export interface SyncOptions {
|
|
|
66
75
|
/**
|
|
67
76
|
* The identity authorizing this sync.
|
|
68
77
|
*/
|
|
69
|
-
identity
|
|
78
|
+
identity?: KeystoneIbGib_V1;
|
|
70
79
|
/**
|
|
71
80
|
* The secret for the identity (to sign the commit).
|
|
72
81
|
*/
|
|
73
|
-
identitySecret
|
|
82
|
+
identitySecret?: string;
|
|
74
83
|
/**
|
|
75
84
|
* How to handle conflicts when both Source and Dest have diverged on the same timeline.
|
|
76
85
|
* @default 'abort'
|
|
77
86
|
*/
|
|
78
87
|
conflictStrategy?: SyncConflictStrategy;
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use `identity` instead if you have a specific identity.
|
|
90
|
+
* If true, creates an ephemeral session identity.
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
useSessionIdentity?: boolean;
|
|
79
94
|
}
|
|
80
95
|
|
|
81
96
|
// ===========================================================================
|
|
@@ -168,6 +183,20 @@ export interface SyncData_V1 extends IbGibData_V1 {
|
|
|
168
183
|
*/
|
|
169
184
|
uuid: string;
|
|
170
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Optional verification metadata (e.g. success count).
|
|
188
|
+
*/
|
|
189
|
+
successCount?: number;
|
|
190
|
+
/**
|
|
191
|
+
* If failed, the reasons why.
|
|
192
|
+
*/
|
|
193
|
+
errors?: string[];
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Strategy used for resolving conflicts in this saga.
|
|
197
|
+
*/
|
|
198
|
+
conflictStrategy?: SyncConflictStrategy;
|
|
199
|
+
|
|
171
200
|
/**
|
|
172
201
|
* Optional absolute timestamp (Unix ms) after which this frame should be considered void.
|
|
173
202
|
* Useful for:
|
package/test_output.log
ADDED
|
Binary file
|