@ibgib/core-gib 0.1.20 → 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/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 +152 -33
- package/dist/sync/sync-conflict.respec.mjs.map +1 -1
- 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-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 +25 -18
- package/dist/sync/sync-saga-coordinator.d.mts.map +1 -1
- package/dist/sync/sync-saga-coordinator.mjs +508 -316
- 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/ibgib-foundations.md +20 -2
- package/package.json +1 -1
- 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 +171 -35
- package/src/sync/sync-constants.mts +1 -4
- package/src/sync/sync-peer/sync-peer-innerspace-v1.mts +85 -12
- package/src/sync/sync-saga-coordinator.mts +569 -338
- 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/test_output.log +0 -0
- package/tmp.md +43 -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/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
|
@@ -81,14 +81,3 @@ export interface SyncSagaMessageCommitData_V1 extends SyncSagaMessageData_V1, Sy
|
|
|
81
81
|
stage: typeof SyncStage.commit;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
export interface SyncSagaMessageConflictData_V1 extends SyncSagaMessageData_V1 {
|
|
85
|
-
stage: typeof SyncStage.conflict;
|
|
86
|
-
conflictStrategy: SyncConflictStrategy;
|
|
87
|
-
isTerminal: boolean; // default true for V1
|
|
88
|
-
conflicts: {
|
|
89
|
-
tjp: string;
|
|
90
|
-
localAddr?: string;
|
|
91
|
-
remoteAddr?: string;
|
|
92
|
-
reason?: string;
|
|
93
|
-
}[];
|
|
94
|
-
}
|
package/test_output.log
ADDED
|
Binary file
|
package/tmp.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
PS C:\Users\billm\antigravity\ibgib\libs\core-gib> npm run test:agent 2>&1 | Select-String "TEST DEBUG"
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] mapWithTjp_YesDna: {"A02A08897FBD25BE9146890CD9F47A6E12C7915E4136BBC6978962538C895AA3.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":{"
|
|
4
|
+
ib":"timeline_root","gib":"A02A08897FBD25BE9146890CD9F47A6E12C7915E4136BBC6978962538C895AA3.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67","data":{"n":2,"timestamp":"Sat, 10 Jan 2026
|
|
5
|
+
18:29:11 GMT","timestampMs":612,"uuid":"5ca69ef03475155a24a4378693eda096500043615dc51f3845fae15a9b730168","type":"testRoot","text":"v1_common"},"rel8ns":{"ancestor":["timeline_root^gib"],"dna":["fork^DFA028E3
|
|
6
|
+
3A42BCE51E9B031837A475B34B189B93349BCDF4F90077E1F031808C","mut8^F1178ECC62C184C913CA5C527C8743A0C1D0734F8E613FA8F8608E3F2445C2C6","mut8^1ED375AD0643E799DEC91A1D16CC3F103BFB34817C06D9B63FAE9EE6C0079212"],"past
|
|
7
|
+
":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67","timeline_root^B1383DDDBA8A29FA1984C0CB318C0603EC40D875DE100104CB14113EC2C299A1.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E
|
|
8
|
+
2CA606F1496F564A5C67"],"tjp":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"]}}} (I: 287e22897148298e185712c8d50cfb26)
|
|
9
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] mapWithTjp_NoDna: {} (I: 1bdc62656294aed0f9df334647dc7326)
|
|
10
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] timelineMap: {"timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":[
|
|
11
|
+
{
|
|
12
|
+
"ib":"timeline_root","gib":"A02A08897FBD25BE9146890CD9F47A6E12C7915E4136BBC6978962538C895AA3.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67",
|
|
13
|
+
"data":{"n":2,"timestamp":"Sat, 10 Jan 2026 18:29:11 GMT","timestampMs":612,"uuid":"5ca69ef03475155a24a437 8693eda096500043615dc51f3845fae15a9b730168","type":"testRoot","text":"v1_common"},
|
|
14
|
+
"rel8ns":{
|
|
15
|
+
"ancestor":["timeline_root^gib"],
|
|
16
|
+
"dna":["fork^DFA028E33A42BCE51E9B031837A475B34B189B93349BCDF4F90077E1F031808C","mut 8^F1178ECC62C184C913CA5C527C8743A0C1D0734F8E613FA8F8608E3F2445C2C6","mut8^1ED375AD0643E799DEC91A1D16CC3F103BFB34817C06D9B63FAE9EE6C0079212"],
|
|
17
|
+
"past":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E 2CA606F1496F564A5C67","timeline_root^B1383DDDBA8A29FA1984C0CB318C0603EC40D875DE100104CB14113EC2C299A1.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"],
|
|
18
|
+
"tjp":["timeline_root^1BF1DB4C60514EFAC 6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
]} (I: 2cc04898e5f85179fb1ac7f827abc426)
|
|
22
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] res.data.latestAddrsMap: {"timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":null} (I: a8e128bdf80898ac2e6d8021a5bff726)
|
|
23
|
+
[TEST DEBUG] v1_Dest:
|
|
24
|
+
{"ib":"timeline_root","gib":"A02A08897FBD25BE9146890CD9F47A6E12C7915E4136BBC6978962538C895AA3.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67","data":{"n":2,"timestamp":"Sat, 10 Jan 2026
|
|
25
|
+
18:29:11 GMT","timestampMs":612,"uuid":"5ca69ef03475155a24a4378693eda096500043615dc51f3845fae15a9b730168","type":"testRoot","text":"v1_common"},"rel8ns":{"ancestor":["timeline_root^gib"],"dna":["fork^DFA028E3
|
|
26
|
+
3A42BCE51E9B031837A475B34B189B93349BCDF4F90077E1F031808C","mut8^F1178ECC62C184C913CA5C527C8743A0C1D0734F8E613FA8F8608E3F2445C2C6","mut8^1ED375AD0643E799DEC91A1D16CC3F103BFB34817C06D9B63FAE9EE6C0079212"],"past
|
|
27
|
+
":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67","timeline_root^B1383DDDBA8A29FA1984C0CB318C0603EC40D875DE100104CB14113EC2C299A1.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E
|
|
28
|
+
2CA606F1496F564A5C67"],"tjp":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"]}}
|
|
29
|
+
[TEST DEBUG] v1TjpAddr: timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67
|
|
30
|
+
[TEST DEBUG] destKV: {"timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":null}
|
|
31
|
+
[TEST DEBUG] v1_Dest.rel8ns.tjp: timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67
|
|
32
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] mapWithTjp_YesDna: {"B1383DDDBA8A29FA1984C0CB318C0603EC40D875DE100104CB14113EC2C299A1.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":{"
|
|
33
|
+
ib":"timeline_root","gib":"B1383DDDBA8A29FA1984C0CB318C0603EC40D875DE100104CB14113EC2C299A1.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67","data":{"n":1,"timestamp":"Sat, 10 Jan 2026
|
|
34
|
+
18:29:11 GMT","timestampMs":573,"uuid":"5ca69ef03475155a24a4378693eda096500043615dc51f3845fae15a9b730168","type":"testRoot","text":"v0"},"rel8ns":{"ancestor":["timeline_root^gib"],"dna":["fork^DFA028E33A42BCE
|
|
35
|
+
51E9B031837A475B34B189B93349BCDF4F90077E1F031808C","mut8^F1178ECC62C184C913CA5C527C8743A0C1D0734F8E613FA8F8608E3F2445C2C6"],"past":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5
|
|
36
|
+
C67"],"tjp":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"]}}} (I: 287e22897148298e185712c8d50cfb26)
|
|
37
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] mapWithTjp_NoDna: {} (I: 1bdc62656294aed0f9df334647dc7326)
|
|
38
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] timelineMap: {"timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":[{"ib":"timeline_root","gib":"B1383DDDBA8A29FA1984C0CB318C0
|
|
39
|
+
603EC40D875DE100104CB14113EC2C299A1.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67","data":{"n":1,"timestamp":"Sat, 10 Jan 2026 18:29:11 GMT","timestampMs":573,"uuid":"5ca69ef03475155a24a437
|
|
40
|
+
8693eda096500043615dc51f3845fae15a9b730168","type":"testRoot","text":"v0"},"rel8ns":{"ancestor":["timeline_root^gib"],"dna":["fork^DFA028E33A42BCE51E9B031837A475B34B189B93349BCDF4F90077E1F031808C","mut8^F1178
|
|
41
|
+
ECC62C184C913CA5C527C8743A0C1D0734F8E613FA8F8608E3F2445C2C6"],"past":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"],"tjp":["timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2F
|
|
42
|
+
FBC2E8BE3E2CA606F1496F564A5C67"]}}]} (I: 2cc04898e5f85179fb1ac7f827abc426)
|
|
43
|
+
[SyncSagaCoordinator][getKnowledgeVector][TEST DEBUG] res.data.latestAddrsMap: {"timeline_root^1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67":"timeline_root^585D6DC8B1653A2989DD24EAF62022AA
|
|
44
|
+
6A1A7CCB98DF5CE5F34A023DB5F9D92F.1BF1DB4C60514EFAC6A74DD268247D3B2FFBC2E8BE3E2CA606F1496F564A5C67"} (I: a8e128bdf80898ac2e6d8021a5bff726)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-constants.d.mts","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-constants.mts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-constants.mjs","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-constants.mts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
2
|
-
import { MetaspaceService } from "../../witness/space/metaspace/metaspace-types.mjs";
|
|
3
|
-
import { MergeInfoData_V1, MergeInfoIbGib_V1, MergeInfoIb_V1 } from "./merge-info-types.mjs";
|
|
4
|
-
import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
|
|
5
|
-
/**
|
|
6
|
-
* Validates and constructs the `ib` object for a Merge Info ibGib.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getMergeInfoIb({ data }: {
|
|
9
|
-
data: MergeInfoData_V1;
|
|
10
|
-
}): Promise<string>;
|
|
11
|
-
/**
|
|
12
|
-
* Parses a standard Merge Info 'ib' string.
|
|
13
|
-
*/
|
|
14
|
-
export declare function parseMergeInfoIb({ ib }: {
|
|
15
|
-
ib: string;
|
|
16
|
-
}): Promise<MergeInfoIb_V1>;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new MergeInfo ibGib.
|
|
19
|
-
*/
|
|
20
|
-
export declare function createMergeInfo({ algo, ancestors, details, }: {
|
|
21
|
-
algo: string;
|
|
22
|
-
ancestors: IbGib_V1[];
|
|
23
|
-
details?: string;
|
|
24
|
-
}): Promise<MergeInfoIbGib_V1>;
|
|
25
|
-
/**
|
|
26
|
-
* Naive text merge.
|
|
27
|
-
* Strategies:
|
|
28
|
-
* 1. Concat (A + B)
|
|
29
|
-
* 2. structured diff (not impl)
|
|
30
|
-
*/
|
|
31
|
-
export declare function mergeText({ textA, textB, }: {
|
|
32
|
-
textA: string;
|
|
33
|
-
textB: string;
|
|
34
|
-
}): Promise<string>;
|
|
35
|
-
/**
|
|
36
|
-
* Combines two divergent timelines by applying missing DNA from one branch to another.
|
|
37
|
-
*
|
|
38
|
-
* Logic:
|
|
39
|
-
* 1. Identify missing DNA (transforms) in `targetTip` that exist in `sourceTip` (relative to LCA).
|
|
40
|
-
* 2. Replay those transforms onto `targetTip`.
|
|
41
|
-
* 3. Create a MergeInfo stone describing this operation.
|
|
42
|
-
* 4. Relate the new tip to the MergeInfo.
|
|
43
|
-
*/
|
|
44
|
-
export declare function combineDivergentTimelines({ targetTip, sourceTip, lca, space, metaspace, }: {
|
|
45
|
-
targetTip: IbGib_V1;
|
|
46
|
-
sourceTip: IbGib_V1;
|
|
47
|
-
lca: IbGib_V1;
|
|
48
|
-
space: IbGibSpaceAny;
|
|
49
|
-
metaspace: MetaspaceService;
|
|
50
|
-
}): Promise<IbGib_V1>;
|
|
51
|
-
//# sourceMappingURL=merge-info-helpers.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-helpers.d.mts","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-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QAAQ,CAAC,CAGpB"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
2
|
-
import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
3
|
-
import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
4
|
-
import { MERGE_INFO_ATOM } from "./merge-info-constants.mjs";
|
|
5
|
-
const lc = `[merge-info-helpers]`;
|
|
6
|
-
/**
|
|
7
|
-
* Validates and constructs the `ib` object for a Merge Info ibGib.
|
|
8
|
-
*/
|
|
9
|
-
export async function getMergeInfoIb({ data }) {
|
|
10
|
-
if (!data.algo) {
|
|
11
|
-
throw new Error(`(UNEXPECTED) data.algo required for MergeInfoIb (E: 8a9b0c1d2e3f4g5h)`);
|
|
12
|
-
}
|
|
13
|
-
// merge_info algo
|
|
14
|
-
return [MERGE_INFO_ATOM, data.algo].join(' ');
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Parses a standard Merge Info 'ib' string.
|
|
18
|
-
*/
|
|
19
|
-
export async function parseMergeInfoIb({ ib }) {
|
|
20
|
-
try {
|
|
21
|
-
const parts = ib.split(' ');
|
|
22
|
-
if (parts[0] !== MERGE_INFO_ATOM) {
|
|
23
|
-
throw new Error(`Atom mismatch. Expected ${MERGE_INFO_ATOM} (E: 8f03c92a95144b618821915632599266)`);
|
|
24
|
-
}
|
|
25
|
-
if (parts.length < 2) {
|
|
26
|
-
throw new Error(`Invalid merge info ib. Expected at least 2 parts. (E: 9c2b4c8a6d34469f8263544710183355)`);
|
|
27
|
-
}
|
|
28
|
-
const algo = parts.slice(1).join(' '); // allow spaces in algo? usually single word but safe to join.
|
|
29
|
-
return {
|
|
30
|
-
atom: MERGE_INFO_ATOM,
|
|
31
|
-
algo,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
36
|
-
throw error;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Creates a new MergeInfo ibGib.
|
|
41
|
-
*/
|
|
42
|
-
export async function createMergeInfo({ algo, ancestors, details, }) {
|
|
43
|
-
const data = {
|
|
44
|
-
algo,
|
|
45
|
-
details,
|
|
46
|
-
};
|
|
47
|
-
const ib = await getMergeInfoIb({ data });
|
|
48
|
-
const rel8ns = {};
|
|
49
|
-
if (ancestors && ancestors.length > 0) {
|
|
50
|
-
rel8ns.ancestors = ancestors.map(a => getIbGibAddr({ ibGib: a }));
|
|
51
|
-
}
|
|
52
|
-
const res = await Factory_V1.stone({
|
|
53
|
-
ib,
|
|
54
|
-
data,
|
|
55
|
-
rel8ns,
|
|
56
|
-
parentPrimitiveIb: MERGE_INFO_ATOM,
|
|
57
|
-
uuid: true, // Should be unique per merge event? Yes.
|
|
58
|
-
});
|
|
59
|
-
// Unwrapping if necessary, though recent checking suggests Factory returns ibGib directly.
|
|
60
|
-
// Wait, recent check in SyncSagaCoordinator showed Factory_V1.stone returns the ibGib directly.
|
|
61
|
-
// But check the implementation plan/previous learnings.
|
|
62
|
-
// Confirmed: Factory_V1.stone returns the ibGib directly.
|
|
63
|
-
return res;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Naive text merge.
|
|
67
|
-
* Strategies:
|
|
68
|
-
* 1. Concat (A + B)
|
|
69
|
-
* 2. structured diff (not impl)
|
|
70
|
-
*/
|
|
71
|
-
export async function mergeText({ textA, textB, }) {
|
|
72
|
-
// Very naive: Just concat with a marker for now.
|
|
73
|
-
// User wants "best effort at being non-destructive".
|
|
74
|
-
if (textA === textB) {
|
|
75
|
-
return textA;
|
|
76
|
-
}
|
|
77
|
-
return `${textA}\n\n>>> MERGE SEPARATOR <<<\n\n${textB}`;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Combines two divergent timelines by applying missing DNA from one branch to another.
|
|
81
|
-
*
|
|
82
|
-
* Logic:
|
|
83
|
-
* 1. Identify missing DNA (transforms) in `targetTip` that exist in `sourceTip` (relative to LCA).
|
|
84
|
-
* 2. Replay those transforms onto `targetTip`.
|
|
85
|
-
* 3. Create a MergeInfo stone describing this operation.
|
|
86
|
-
* 4. Relate the new tip to the MergeInfo.
|
|
87
|
-
*/
|
|
88
|
-
export async function combineDivergentTimelines({ targetTip, sourceTip, lca, space, metaspace, }) {
|
|
89
|
-
// stub implementation
|
|
90
|
-
return targetTip;
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=merge-info-helpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-helpers.mjs","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-helpers.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAI7D,MAAM,EAAE,GAAG,sBAAsB,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACjC,IAAI,EAGP;IACG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAAC,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAAC,CAAC;IAE7G,kBAAkB;IAClB,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,EACnC,EAAE,EAGL;IACG,IAAI,CAAC;QACD,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,KAAK,CAAC,CAAC,CAAC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IAC3F,gGAAgG;IAChG,wDAAwD;IACxD,0DAA0D;IAC1D,OAAO,GAAwB,CAAC;AACpC,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC5B,KAAK,EACL,KAAK,GAIR;IACG,iDAAiD;IACjD,qDAAqD;IACrD,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAAC,OAAO,KAAK,CAAC;IAAC,CAAC;IACtC,OAAO,GAAG,KAAK,kCAAkC,KAAK,EAAE,CAAC;AAC7D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,EAC5C,SAAS,EACT,SAAS,EACT,GAAG,EACH,KAAK,EACL,SAAS,GAOZ;IACG,sBAAsB;IACtB,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-helpers.respec.d.mts","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-helpers.respec.mts"],"names":[],"mappings":""}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module merge-info-helpers.respec
|
|
3
|
-
*/
|
|
4
|
-
import { iReckon, respecfully, ifWeMight } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
5
|
-
import { mergeText } from './merge-info-helpers.mjs';
|
|
6
|
-
const maam = `[${import.meta.url}]`;
|
|
7
|
-
const sir = maam;
|
|
8
|
-
await respecfully(sir, 'Merge Info Helpers', async () => {
|
|
9
|
-
await respecfully(sir, 'mergeText', async () => {
|
|
10
|
-
await ifWeMight(sir, 'mergeText should concat different strings', async () => {
|
|
11
|
-
const textA = "Hello";
|
|
12
|
-
const textB = "World";
|
|
13
|
-
const res = await mergeText({ textA, textB });
|
|
14
|
-
iReckon(sir, res).asTo('result').isGonnaBeTruthy();
|
|
15
|
-
iReckon(sir, res.includes(textA)).asTo('includes A').isGonnaBeTruthy();
|
|
16
|
-
iReckon(sir, res.includes(textB)).asTo('includes B').isGonnaBeTruthy();
|
|
17
|
-
iReckon(sir, res.includes('MERGE SEPARATOR')).asTo('includes separator').isGonnaBeTruthy();
|
|
18
|
-
});
|
|
19
|
-
await ifWeMight(sir, 'mergeText should return same string if identical', async () => {
|
|
20
|
-
const textA = "Hello";
|
|
21
|
-
const res = await mergeText({ textA, textB: textA });
|
|
22
|
-
iReckon(sir, res).asTo('result').isGonnaBe(textA);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
await respecfully(sir, 'combineDivergentTimelines', async () => {
|
|
26
|
-
await ifWeMight(sir, 'combineDivergentTimelines should work (Stub)', async () => {
|
|
27
|
-
// Validation of stub for now, just to ensure scaffolding works.
|
|
28
|
-
iReckon(sir, true).asTo('stub executed').isGonnaBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
//# sourceMappingURL=merge-info-helpers.respec.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-helpers.respec.mjs","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-helpers.respec.mts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAQ,SAAS,EAAE,MAAM,kDAAkD,CAAC;AACzG,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;AACpC,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,MAAM,WAAW,CAAC,GAAG,EAAE,oBAAoB,EAAE,KAAK,IAAI,EAAE;IAEpD,MAAM,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE;QAE3C,MAAM,SAAS,CAAC,GAAG,EAAE,2CAA2C,EAAE,KAAK,IAAI,EAAE;YACzE,MAAM,KAAK,GAAG,OAAO,CAAC;YACtB,MAAM,KAAK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AAC,CAAC,CAAC;IAEP,CAAC,CAAC,CAAC;AAEP,CAAC,CAAC,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
2
|
-
import { MERGE_INFO_ATOM } from "./merge-info-constants.mjs";
|
|
3
|
-
export interface MergeInfoIb_V1 {
|
|
4
|
-
atom: typeof MERGE_INFO_ATOM;
|
|
5
|
-
algo: string;
|
|
6
|
-
}
|
|
7
|
-
export interface MergeInfoData_V1 extends IbGibData_V1 {
|
|
8
|
-
/**
|
|
9
|
-
* The algorithm or strategy used to perform the merge.
|
|
10
|
-
*/
|
|
11
|
-
algo: string;
|
|
12
|
-
/**
|
|
13
|
-
* Optional details about the merge, e.g. validation results or specifics about conflicts resolved.
|
|
14
|
-
*/
|
|
15
|
-
details?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface MergeInfoRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
18
|
-
/**
|
|
19
|
-
* The ibGibs that were merged together.
|
|
20
|
-
* For a timeline merge, these are the tips of the divergent branches.
|
|
21
|
-
*/
|
|
22
|
-
ancestors?: string[];
|
|
23
|
-
}
|
|
24
|
-
export interface MergeInfoIbGib_V1 extends IbGib_V1<MergeInfoData_V1, MergeInfoRel8ns_V1> {
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=merge-info-types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-info-types.mjs","sourceRoot":"","sources":["../../../src/sync/merge-info/merge-info-types.mts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const MERGE_INFO_ATOM = 'merge_info';
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
2
|
-
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
3
|
-
import { getIbGibAddr } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
4
|
-
import { extractErrorMsg } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
5
|
-
|
|
6
|
-
import { MetaspaceService } from "../../witness/space/metaspace/metaspace-types.mjs";
|
|
7
|
-
import { MERGE_INFO_ATOM } from "./merge-info-constants.mjs";
|
|
8
|
-
import { MergeInfoData_V1, MergeInfoIbGib_V1, MergeInfoIb_V1 } from "./merge-info-types.mjs";
|
|
9
|
-
import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
|
|
10
|
-
|
|
11
|
-
const lc = `[merge-info-helpers]`;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Validates and constructs the `ib` object for a Merge Info ibGib.
|
|
15
|
-
*/
|
|
16
|
-
export async function getMergeInfoIb({
|
|
17
|
-
data
|
|
18
|
-
}: {
|
|
19
|
-
data: MergeInfoData_V1
|
|
20
|
-
}): Promise<string> {
|
|
21
|
-
if (!data.algo) { throw new Error(`(UNEXPECTED) data.algo required for MergeInfoIb (E: 8a9b0c1d2e3f4g5h)`); }
|
|
22
|
-
|
|
23
|
-
// merge_info algo
|
|
24
|
-
return [MERGE_INFO_ATOM, data.algo].join(' ');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Parses a standard Merge Info 'ib' string.
|
|
29
|
-
*/
|
|
30
|
-
export async function parseMergeInfoIb({
|
|
31
|
-
ib
|
|
32
|
-
}: {
|
|
33
|
-
ib: string
|
|
34
|
-
}): Promise<MergeInfoIb_V1> {
|
|
35
|
-
try {
|
|
36
|
-
const parts = ib.split(' ');
|
|
37
|
-
if (parts[0] !== MERGE_INFO_ATOM) { throw new Error(`Atom mismatch. Expected ${MERGE_INFO_ATOM} (E: 8f03c92a95144b618821915632599266)`); }
|
|
38
|
-
if (parts.length < 2) { throw new Error(`Invalid merge info ib. Expected at least 2 parts. (E: 9c2b4c8a6d34469f8263544710183355)`); }
|
|
39
|
-
|
|
40
|
-
const algo = parts.slice(1).join(' '); // allow spaces in algo? usually single word but safe to join.
|
|
41
|
-
|
|
42
|
-
return {
|
|
43
|
-
atom: MERGE_INFO_ATOM,
|
|
44
|
-
algo,
|
|
45
|
-
};
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Creates a new MergeInfo ibGib.
|
|
54
|
-
*/
|
|
55
|
-
export async function createMergeInfo({
|
|
56
|
-
algo,
|
|
57
|
-
ancestors,
|
|
58
|
-
details,
|
|
59
|
-
}: {
|
|
60
|
-
algo: string,
|
|
61
|
-
ancestors: IbGib_V1[],
|
|
62
|
-
details?: string,
|
|
63
|
-
}): Promise<MergeInfoIbGib_V1> {
|
|
64
|
-
const data: MergeInfoData_V1 = {
|
|
65
|
-
algo,
|
|
66
|
-
details,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const ib = await getMergeInfoIb({ data });
|
|
70
|
-
|
|
71
|
-
const rel8ns: any = {};
|
|
72
|
-
if (ancestors && ancestors.length > 0) {
|
|
73
|
-
rel8ns.ancestors = ancestors.map(a => getIbGibAddr({ ibGib: a }));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const res = await Factory_V1.stone({
|
|
77
|
-
ib,
|
|
78
|
-
data,
|
|
79
|
-
rel8ns,
|
|
80
|
-
parentPrimitiveIb: MERGE_INFO_ATOM,
|
|
81
|
-
uuid: true, // Should be unique per merge event? Yes.
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
// Unwrapping if necessary, though recent checking suggests Factory returns ibGib directly.
|
|
85
|
-
// Wait, recent check in SyncSagaCoordinator showed Factory_V1.stone returns the ibGib directly.
|
|
86
|
-
// But check the implementation plan/previous learnings.
|
|
87
|
-
// Confirmed: Factory_V1.stone returns the ibGib directly.
|
|
88
|
-
return res as MergeInfoIbGib_V1;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Naive text merge.
|
|
93
|
-
* Strategies:
|
|
94
|
-
* 1. Concat (A + B)
|
|
95
|
-
* 2. structured diff (not impl)
|
|
96
|
-
*/
|
|
97
|
-
export async function mergeText({
|
|
98
|
-
textA,
|
|
99
|
-
textB,
|
|
100
|
-
}: {
|
|
101
|
-
textA: string,
|
|
102
|
-
textB: string,
|
|
103
|
-
}): Promise<string> {
|
|
104
|
-
// Very naive: Just concat with a marker for now.
|
|
105
|
-
// User wants "best effort at being non-destructive".
|
|
106
|
-
if (textA === textB) { return textA; }
|
|
107
|
-
return `${textA}\n\n>>> MERGE SEPARATOR <<<\n\n${textB}`;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Combines two divergent timelines by applying missing DNA from one branch to another.
|
|
112
|
-
*
|
|
113
|
-
* Logic:
|
|
114
|
-
* 1. Identify missing DNA (transforms) in `targetTip` that exist in `sourceTip` (relative to LCA).
|
|
115
|
-
* 2. Replay those transforms onto `targetTip`.
|
|
116
|
-
* 3. Create a MergeInfo stone describing this operation.
|
|
117
|
-
* 4. Relate the new tip to the MergeInfo.
|
|
118
|
-
*/
|
|
119
|
-
export async function combineDivergentTimelines({
|
|
120
|
-
targetTip,
|
|
121
|
-
sourceTip,
|
|
122
|
-
lca,
|
|
123
|
-
space,
|
|
124
|
-
metaspace,
|
|
125
|
-
}: {
|
|
126
|
-
targetTip: IbGib_V1,
|
|
127
|
-
sourceTip: IbGib_V1,
|
|
128
|
-
lca: IbGib_V1,
|
|
129
|
-
space: IbGibSpaceAny,
|
|
130
|
-
metaspace: MetaspaceService,
|
|
131
|
-
}): Promise<IbGib_V1> {
|
|
132
|
-
// stub implementation
|
|
133
|
-
return targetTip;
|
|
134
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module merge-info-helpers.respec
|
|
3
|
-
*/
|
|
4
|
-
import { iReckon, respecfully, ifWe, ifWeMight } from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
5
|
-
import { mergeText } from './merge-info-helpers.mjs';
|
|
6
|
-
|
|
7
|
-
const maam = `[${import.meta.url}]`;
|
|
8
|
-
const sir = maam;
|
|
9
|
-
|
|
10
|
-
await respecfully(sir, 'Merge Info Helpers', async () => {
|
|
11
|
-
|
|
12
|
-
await respecfully(sir, 'mergeText', async () => {
|
|
13
|
-
|
|
14
|
-
await ifWeMight(sir, 'mergeText should concat different strings', async () => {
|
|
15
|
-
const textA = "Hello";
|
|
16
|
-
const textB = "World";
|
|
17
|
-
const res = await mergeText({ textA, textB });
|
|
18
|
-
iReckon(sir, res).asTo('result').isGonnaBeTruthy();
|
|
19
|
-
iReckon(sir, res.includes(textA)).asTo('includes A').isGonnaBeTruthy();
|
|
20
|
-
iReckon(sir, res.includes(textB)).asTo('includes B').isGonnaBeTruthy();
|
|
21
|
-
iReckon(sir, res.includes('MERGE SEPARATOR')).asTo('includes separator').isGonnaBeTruthy();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
await ifWeMight(sir, 'mergeText should return same string if identical', async () => {
|
|
25
|
-
const textA = "Hello";
|
|
26
|
-
const res = await mergeText({ textA, textB: textA });
|
|
27
|
-
iReckon(sir, res).asTo('result').isGonnaBe(textA);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
await respecfully(sir, 'combineDivergentTimelines', async () => {
|
|
33
|
-
|
|
34
|
-
await ifWeMight(sir, 'combineDivergentTimelines should work (Stub)', async () => {
|
|
35
|
-
// Validation of stub for now, just to ensure scaffolding works.
|
|
36
|
-
iReckon(sir, true).asTo('stub executed').isGonnaBeTruthy();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IbGib_V1, IbGibData_V1, IbGibRel8ns_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
2
|
-
import { MERGE_INFO_ATOM } from "./merge-info-constants.mjs";
|
|
3
|
-
|
|
4
|
-
export interface MergeInfoIb_V1 {
|
|
5
|
-
atom: typeof MERGE_INFO_ATOM;
|
|
6
|
-
algo: string; // e.g. "optimistic", "text", "manual"
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface MergeInfoData_V1 extends IbGibData_V1 {
|
|
10
|
-
/**
|
|
11
|
-
* The algorithm or strategy used to perform the merge.
|
|
12
|
-
*/
|
|
13
|
-
algo: string;
|
|
14
|
-
/**
|
|
15
|
-
* Optional details about the merge, e.g. validation results or specifics about conflicts resolved.
|
|
16
|
-
*/
|
|
17
|
-
details?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface MergeInfoRel8ns_V1 extends IbGibRel8ns_V1 {
|
|
21
|
-
/**
|
|
22
|
-
* The ibGibs that were merged together.
|
|
23
|
-
* For a timeline merge, these are the tips of the divergent branches.
|
|
24
|
-
*/
|
|
25
|
-
ancestors?: string[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface MergeInfoIbGib_V1 extends IbGib_V1<MergeInfoData_V1, MergeInfoRel8ns_V1> { }
|