@nicia-ai/typegraph 0.33.0 → 0.34.0
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/README.md +20 -0
- package/dist/backend/postgres/index.cjs +26 -22
- package/dist/backend/postgres/index.d.cts +5 -5
- package/dist/backend/postgres/index.d.ts +5 -5
- package/dist/backend/postgres/index.js +13 -9
- package/dist/backend/postgres/pglite.cjs +17 -13
- package/dist/backend/postgres/pglite.cjs.map +1 -1
- package/dist/backend/postgres/pglite.d.cts +2 -2
- package/dist/backend/postgres/pglite.d.ts +2 -2
- package/dist/backend/postgres/pglite.js +13 -9
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +24 -20
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +12 -8
- package/dist/backend/sqlite/libsql.cjs +18 -14
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +11 -4
- package/dist/backend/sqlite/libsql.d.ts +11 -4
- package/dist/backend/sqlite/libsql.js +14 -10
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +18 -14
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +2 -2
- package/dist/backend/sqlite/local.d.ts +2 -2
- package/dist/backend/sqlite/local.js +13 -9
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-2EBMPJBO.js +16 -0
- package/dist/chunk-2EBMPJBO.js.map +1 -0
- package/dist/{chunk-CFNT3ITG.cjs → chunk-2JXB3NYJ.cjs} +15 -35
- package/dist/chunk-2JXB3NYJ.cjs.map +1 -0
- package/dist/{chunk-GYVBEZAO.js → chunk-2MRAX3UE.js} +3 -18
- package/dist/chunk-2MRAX3UE.js.map +1 -0
- package/dist/{chunk-D3EWZ67S.cjs → chunk-3BRVBQQD.cjs} +999 -2675
- package/dist/chunk-3BRVBQQD.cjs.map +1 -0
- package/dist/{chunk-FDN43KXV.cjs → chunk-3Z6TW3CT.cjs} +20 -19
- package/dist/chunk-3Z6TW3CT.cjs.map +1 -0
- package/dist/{chunk-6NRFUHMS.js → chunk-4DIBPQNJ.js} +5 -4
- package/dist/chunk-4DIBPQNJ.js.map +1 -0
- package/dist/chunk-4S2FXGBJ.js +9 -0
- package/dist/chunk-4S2FXGBJ.js.map +1 -0
- package/dist/chunk-5IQIX7LU.cjs +2070 -0
- package/dist/chunk-5IQIX7LU.cjs.map +1 -0
- package/dist/{chunk-CWFPJ3RC.js → chunk-6GNSY7AV.js} +3 -3
- package/dist/{chunk-CWFPJ3RC.js.map → chunk-6GNSY7AV.js.map} +1 -1
- package/dist/{chunk-NG5N7R45.cjs → chunk-6HVOHZHS.cjs} +184 -117
- package/dist/chunk-6HVOHZHS.cjs.map +1 -0
- package/dist/chunk-6SCVW4AS.js +20 -0
- package/dist/chunk-6SCVW4AS.js.map +1 -0
- package/dist/chunk-A7SZZFAG.js +2010 -0
- package/dist/chunk-A7SZZFAG.js.map +1 -0
- package/dist/chunk-ACSVZPK7.cjs +21 -0
- package/dist/chunk-ACSVZPK7.cjs.map +1 -0
- package/dist/{chunk-IZ4PCL47.js → chunk-BVTWD66D.js} +4 -66
- package/dist/chunk-BVTWD66D.js.map +1 -0
- package/dist/{chunk-QBYTJSAY.js → chunk-CHXTTSC6.js} +5 -39
- package/dist/chunk-CHXTTSC6.js.map +1 -0
- package/dist/{chunk-DJYRRDHA.js → chunk-CYX2JTDG.js} +3 -3
- package/dist/{chunk-DJYRRDHA.js.map → chunk-CYX2JTDG.js.map} +1 -1
- package/dist/{chunk-PRMKPFN5.js → chunk-DEQFL35G.js} +4 -3
- package/dist/chunk-DEQFL35G.js.map +1 -0
- package/dist/chunk-DI74SMXS.cjs +29 -0
- package/dist/chunk-DI74SMXS.cjs.map +1 -0
- package/dist/{chunk-WWVV44DY.cjs → chunk-G6SOJEDI.cjs} +11 -11
- package/dist/{chunk-WWVV44DY.cjs.map → chunk-G6SOJEDI.cjs.map} +1 -1
- package/dist/{chunk-LM2IC4ZJ.cjs → chunk-GQANNXXT.cjs} +15 -14
- package/dist/chunk-GQANNXXT.cjs.map +1 -0
- package/dist/chunk-GZCNZ7QW.js +24 -0
- package/dist/chunk-GZCNZ7QW.js.map +1 -0
- package/dist/{chunk-KTIEB7VH.cjs → chunk-HK5SATYM.cjs} +35 -58
- package/dist/chunk-HK5SATYM.cjs.map +1 -0
- package/dist/chunk-HMFK4BXR.cjs +12 -0
- package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-HMFK4BXR.cjs.map} +1 -1
- package/dist/chunk-ITE4IXAK.js +25 -0
- package/dist/chunk-ITE4IXAK.js.map +1 -0
- package/dist/chunk-JJRCLAUN.cjs +155 -0
- package/dist/chunk-JJRCLAUN.cjs.map +1 -0
- package/dist/{chunk-ZFWNO3GE.cjs → chunk-JQGIPGVL.cjs} +66 -2
- package/dist/chunk-JQGIPGVL.cjs.map +1 -0
- package/dist/{chunk-XVUJY72M.js → chunk-K2TGS3EN.js} +105 -38
- package/dist/chunk-K2TGS3EN.js.map +1 -0
- package/dist/chunk-K34OPSJK.js +29 -0
- package/dist/chunk-K34OPSJK.js.map +1 -0
- package/dist/{chunk-YW7GHMF4.cjs → chunk-KGC4LY5T.cjs} +18 -17
- package/dist/chunk-KGC4LY5T.cjs.map +1 -0
- package/dist/{chunk-SST7XDY6.cjs → chunk-KNHYNQQ3.cjs} +111 -72
- package/dist/chunk-KNHYNQQ3.cjs.map +1 -0
- package/dist/{chunk-C4C4Q7A6.js → chunk-KUTNI6SI.js} +6 -21
- package/dist/chunk-KUTNI6SI.js.map +1 -0
- package/dist/{chunk-OS6KS3HV.js → chunk-LANHCOXB.js} +8 -7
- package/dist/chunk-LANHCOXB.js.map +1 -0
- package/dist/chunk-N6WTUSBV.cjs +23 -0
- package/dist/chunk-N6WTUSBV.cjs.map +1 -0
- package/dist/{chunk-73KASJGO.cjs → chunk-NAUA4PW5.cjs} +4 -28
- package/dist/chunk-NAUA4PW5.cjs.map +1 -0
- package/dist/chunk-QV245VMN.js +145 -0
- package/dist/chunk-QV245VMN.js.map +1 -0
- package/dist/{chunk-CEF2QOTO.js → chunk-RBV7YCQD.js} +4 -3
- package/dist/chunk-RBV7YCQD.js.map +1 -0
- package/dist/{chunk-OIE2UPVG.cjs → chunk-RHZWOJVA.cjs} +2 -19
- package/dist/chunk-RHZWOJVA.cjs.map +1 -0
- package/dist/{chunk-3IR2GEMJ.cjs → chunk-RRKQAKD6.cjs} +10 -9
- package/dist/chunk-RRKQAKD6.cjs.map +1 -0
- package/dist/{chunk-UPDMJEW6.js → chunk-RY2VIWAM.js} +11 -8
- package/dist/chunk-RY2VIWAM.js.map +1 -0
- package/dist/{chunk-PIHXFF73.js → chunk-SHLY4MCM.js} +3 -3
- package/dist/{chunk-PIHXFF73.js.map → chunk-SHLY4MCM.js.map} +1 -1
- package/dist/{chunk-SPT5JMME.js → chunk-T2DWPQNE.js} +103 -64
- package/dist/chunk-T2DWPQNE.js.map +1 -0
- package/dist/{chunk-WYTUF3QO.js → chunk-T46GR2VY.js} +3 -3
- package/dist/{chunk-WYTUF3QO.js.map → chunk-T46GR2VY.js.map} +1 -1
- package/dist/{chunk-MBLXCV2Y.cjs → chunk-T6SPUYLX.cjs} +5 -43
- package/dist/chunk-T6SPUYLX.cjs.map +1 -0
- package/dist/{chunk-3QRBXYT5.cjs → chunk-TGJE22RM.cjs} +6 -6
- package/dist/{chunk-3QRBXYT5.cjs.map → chunk-TGJE22RM.cjs.map} +1 -1
- package/dist/{chunk-BF3ZDEUE.cjs → chunk-TOTPVGOG.cjs} +70 -69
- package/dist/chunk-TOTPVGOG.cjs.map +1 -0
- package/dist/{chunk-KY5SDVA7.cjs → chunk-UJLOZYKT.cjs} +90 -87
- package/dist/chunk-UJLOZYKT.cjs.map +1 -0
- package/dist/{chunk-I4W7MKVG.cjs → chunk-UNNPKQUG.cjs} +19 -155
- package/dist/chunk-UNNPKQUG.cjs.map +1 -0
- package/dist/chunk-UR7W5YQK.js +18 -0
- package/dist/chunk-UR7W5YQK.js.map +1 -0
- package/dist/{chunk-PYD3UCDU.js → chunk-V3QNTB7Z.js} +19 -148
- package/dist/chunk-V3QNTB7Z.js.map +1 -0
- package/dist/{chunk-XKNAK27R.js → chunk-VCGO4V26.js} +4 -3
- package/dist/chunk-VCGO4V26.js.map +1 -0
- package/dist/{chunk-EF3Z645U.cjs → chunk-WL2SG7ZV.cjs} +6 -72
- package/dist/chunk-WL2SG7ZV.cjs.map +1 -0
- package/dist/{chunk-WLP6TKFB.js → chunk-WLRIWYHQ.js} +640 -2307
- package/dist/chunk-WLRIWYHQ.js.map +1 -0
- package/dist/{chunk-4RBAJVEC.cjs → chunk-WVC2Q2FD.cjs} +5 -5
- package/dist/{chunk-4RBAJVEC.cjs.map → chunk-WVC2Q2FD.cjs.map} +1 -1
- package/dist/chunk-XXVEULWX.js +39 -0
- package/dist/chunk-XXVEULWX.js.map +1 -0
- package/dist/chunk-YAZE7QZR.cjs +32 -0
- package/dist/chunk-YAZE7QZR.cjs.map +1 -0
- package/dist/chunk-YC6PWTHY.cjs +44 -0
- package/dist/chunk-YC6PWTHY.cjs.map +1 -0
- package/dist/chunk-Z5HBYM7U.cjs +11 -0
- package/dist/chunk-Z5HBYM7U.cjs.map +1 -0
- package/dist/{chunk-454I6GDF.js → chunk-Z5XBMDXU.js} +63 -3
- package/dist/chunk-Z5XBMDXU.js.map +1 -0
- package/dist/{chunk-3642VBVC.cjs → chunk-ZP5WHI4C.cjs} +106 -80
- package/dist/chunk-ZP5WHI4C.cjs.map +1 -0
- package/dist/{chunk-YCV72E6L.js → chunk-ZURTTSCM.js} +4 -25
- package/dist/chunk-ZURTTSCM.js.map +1 -0
- package/dist/{chunk-JHOBXD7O.js → chunk-ZV5N4DBG.js} +46 -20
- package/dist/chunk-ZV5N4DBG.js.map +1 -0
- package/dist/chunk-ZY4GXIVN.cjs +32 -0
- package/dist/chunk-ZY4GXIVN.cjs.map +1 -0
- package/dist/{ddl-CVnHJcar.d.ts → ddl-BrmPg61z.d.ts} +3 -3
- package/dist/{ddl-Dxt_fBHr.d.cts → ddl-j1-sH6lE.d.cts} +3 -3
- package/dist/graph-extension/index.cjs +18 -17
- package/dist/graph-extension/index.js +3 -2
- package/dist/graph-merge/index.cjs +294 -146
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +3 -3
- package/dist/graph-merge/index.d.ts +3 -3
- package/dist/graph-merge/index.js +172 -24
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +181 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +30 -22
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +27 -25
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +9 -7
- package/dist/interchange/index.cjs +25 -16
- package/dist/interchange/index.d.cts +3 -3
- package/dist/interchange/index.d.ts +3 -3
- package/dist/interchange/index.js +12 -3
- package/dist/{manager-C0_r0ALf.d.ts → manager-BZUeN_BU.d.ts} +1 -1
- package/dist/{manager-BYl_zyZR.d.cts → manager-ms9cKdc6.d.cts} +1 -1
- package/dist/{postgres-MzBPkYzq.d.ts → postgres-BhpxGMC5.d.cts} +1 -1
- package/dist/{postgres-_9psmVGm.d.cts → postgres-CWHLwNl1.d.ts} +1 -1
- package/dist/profiler/index.cjs +3 -3
- package/dist/profiler/index.d.cts +5 -5
- package/dist/profiler/index.d.ts +5 -5
- package/dist/profiler/index.js +2 -2
- package/dist/provenance/index.cjs +591 -0
- package/dist/provenance/index.cjs.map +1 -0
- package/dist/provenance/index.d.cts +73 -0
- package/dist/provenance/index.d.ts +73 -0
- package/dist/provenance/index.js +589 -0
- package/dist/provenance/index.js.map +1 -0
- package/dist/schema/index.cjs +36 -32
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +4 -4
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.js +13 -9
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-gm44dShb.d.ts → sqlite-CGu5SLsw.d.ts} +1 -1
- package/dist/{sqlite-BfksSb45.d.cts → sqlite-XrDxNaa7.d.cts} +1 -1
- package/dist/{store-view-FfE5_7eo.d.ts → store-view-BlgnhEYf.d.ts} +33 -5
- package/dist/{store-view-9jQ2rPum.d.cts → store-view-D09po4H6.d.cts} +33 -5
- package/dist/{types-CdWxK-nD.d.ts → types-B1TbZJYS.d.ts} +1 -1
- package/dist/{types-DGylBhWo.d.ts → types-D1Sqeyxy.d.ts} +7 -3
- package/dist/{types-B6mhrcLv.d.cts → types-DiE1AO7p.d.cts} +1 -1
- package/dist/{types-C_UnQOQp.d.cts → types-DkNnF-7K.d.cts} +7 -3
- package/dist/{where-Bpp2ul_z.d.cts → where-DKjuofPr.d.cts} +1 -1
- package/dist/{where-BsEXraKW.d.ts → where-DrUIIWHb.d.ts} +1 -1
- package/package.json +8 -2
- package/dist/chunk-2YMGNYXY.js +0 -40
- package/dist/chunk-2YMGNYXY.js.map +0 -1
- package/dist/chunk-3642VBVC.cjs.map +0 -1
- package/dist/chunk-3IR2GEMJ.cjs.map +0 -1
- package/dist/chunk-454I6GDF.js.map +0 -1
- package/dist/chunk-6NRFUHMS.js.map +0 -1
- package/dist/chunk-6ZR4QC3O.cjs +0 -12
- package/dist/chunk-73KASJGO.cjs.map +0 -1
- package/dist/chunk-BF3ZDEUE.cjs.map +0 -1
- package/dist/chunk-C4C4Q7A6.js.map +0 -1
- package/dist/chunk-CEF2QOTO.js.map +0 -1
- package/dist/chunk-CFNT3ITG.cjs.map +0 -1
- package/dist/chunk-D3EWZ67S.cjs.map +0 -1
- package/dist/chunk-EF3Z645U.cjs.map +0 -1
- package/dist/chunk-FDN43KXV.cjs.map +0 -1
- package/dist/chunk-GYVBEZAO.js.map +0 -1
- package/dist/chunk-I4W7MKVG.cjs.map +0 -1
- package/dist/chunk-IZ4PCL47.js.map +0 -1
- package/dist/chunk-JHOBXD7O.js.map +0 -1
- package/dist/chunk-KTIEB7VH.cjs.map +0 -1
- package/dist/chunk-KY5SDVA7.cjs.map +0 -1
- package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
- package/dist/chunk-MBLXCV2Y.cjs.map +0 -1
- package/dist/chunk-NG5N7R45.cjs.map +0 -1
- package/dist/chunk-OIE2UPVG.cjs.map +0 -1
- package/dist/chunk-OS6KS3HV.js.map +0 -1
- package/dist/chunk-PRMKPFN5.js.map +0 -1
- package/dist/chunk-PYD3UCDU.js.map +0 -1
- package/dist/chunk-QBYTJSAY.js.map +0 -1
- package/dist/chunk-SPT5JMME.js.map +0 -1
- package/dist/chunk-SST7XDY6.cjs.map +0 -1
- package/dist/chunk-UPDMJEW6.js.map +0 -1
- package/dist/chunk-WLP6TKFB.js.map +0 -1
- package/dist/chunk-XKNAK27R.js.map +0 -1
- package/dist/chunk-XVUJY72M.js.map +0 -1
- package/dist/chunk-YCV72E6L.js.map +0 -1
- package/dist/chunk-YW7GHMF4.cjs.map +0 -1
- package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
|
@@ -1,30 +1,49 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk3BRVBQQD_cjs = require('../chunk-3BRVBQQD.cjs');
|
|
4
4
|
require('../chunk-HTGDWIDE.cjs');
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
require('../chunk-
|
|
9
|
-
require('../chunk-
|
|
10
|
-
require('../chunk-
|
|
11
|
-
require('../chunk-
|
|
12
|
-
|
|
13
|
-
require('../chunk-
|
|
14
|
-
var
|
|
15
|
-
require('../chunk-
|
|
16
|
-
var
|
|
5
|
+
require('../chunk-JJRCLAUN.cjs');
|
|
6
|
+
var chunkKNHYNQQ3_cjs = require('../chunk-KNHYNQQ3.cjs');
|
|
7
|
+
require('../chunk-N6WTUSBV.cjs');
|
|
8
|
+
var chunk6HVOHZHS_cjs = require('../chunk-6HVOHZHS.cjs');
|
|
9
|
+
var chunkACSVZPK7_cjs = require('../chunk-ACSVZPK7.cjs');
|
|
10
|
+
var chunkT6SPUYLX_cjs = require('../chunk-T6SPUYLX.cjs');
|
|
11
|
+
require('../chunk-TGJE22RM.cjs');
|
|
12
|
+
require('../chunk-2JXB3NYJ.cjs');
|
|
13
|
+
require('../chunk-RRKQAKD6.cjs');
|
|
14
|
+
var chunkZY4GXIVN_cjs = require('../chunk-ZY4GXIVN.cjs');
|
|
15
|
+
require('../chunk-WL2SG7ZV.cjs');
|
|
16
|
+
var chunkHK5SATYM_cjs = require('../chunk-HK5SATYM.cjs');
|
|
17
|
+
var chunkZ5HBYM7U_cjs = require('../chunk-Z5HBYM7U.cjs');
|
|
18
|
+
var chunk5IQIX7LU_cjs = require('../chunk-5IQIX7LU.cjs');
|
|
19
|
+
require('../chunk-UNNPKQUG.cjs');
|
|
20
|
+
require('../chunk-YC6PWTHY.cjs');
|
|
21
|
+
require('../chunk-RHZWOJVA.cjs');
|
|
22
|
+
require('../chunk-YAZE7QZR.cjs');
|
|
23
|
+
require('../chunk-NAUA4PW5.cjs');
|
|
24
|
+
require('../chunk-JQGIPGVL.cjs');
|
|
17
25
|
require('../chunk-3E7SNSIA.cjs');
|
|
26
|
+
require('../chunk-DI74SMXS.cjs');
|
|
18
27
|
var chunkJIEJCTDS_cjs = require('../chunk-JIEJCTDS.cjs');
|
|
19
28
|
require('../chunk-FLRCVI2G.cjs');
|
|
20
29
|
var zod = require('zod');
|
|
21
30
|
|
|
22
31
|
// src/graph-merge/canonical-props.ts
|
|
23
32
|
function canonicalizeProps(props) {
|
|
24
|
-
return JSON.stringify(props,
|
|
33
|
+
return JSON.stringify(props, chunkACSVZPK7_cjs.sortedReplacer);
|
|
25
34
|
}
|
|
26
35
|
function canonicalValueKey(value) {
|
|
27
|
-
return JSON.stringify(value,
|
|
36
|
+
return JSON.stringify(value, chunkACSVZPK7_cjs.sortedReplacer);
|
|
37
|
+
}
|
|
38
|
+
function edgeStateSignature(edge) {
|
|
39
|
+
return JSON.stringify([
|
|
40
|
+
edge.fromKind,
|
|
41
|
+
edge.fromId,
|
|
42
|
+
edge.toKind,
|
|
43
|
+
edge.toId,
|
|
44
|
+
edge.live,
|
|
45
|
+
canonicalizeProps(edge.props)
|
|
46
|
+
]);
|
|
28
47
|
}
|
|
29
48
|
function parseRowProps(props) {
|
|
30
49
|
let parsed;
|
|
@@ -49,9 +68,6 @@ function mergeKey(kind, id) {
|
|
|
49
68
|
}
|
|
50
69
|
return `${kind}${SEPARATOR}${id}`;
|
|
51
70
|
}
|
|
52
|
-
function compareStrings(left, right) {
|
|
53
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
54
|
-
}
|
|
55
71
|
function mergeKeyOf(node) {
|
|
56
72
|
return mergeKey(node.kind, node.id);
|
|
57
73
|
}
|
|
@@ -225,15 +241,16 @@ function diffEdgeKind(kind, baseRows, forkRows) {
|
|
|
225
241
|
return { new: created, modified, deleted };
|
|
226
242
|
}
|
|
227
243
|
function byId(left, right) {
|
|
228
|
-
return compareStrings(left.id, right.id);
|
|
244
|
+
return chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id);
|
|
229
245
|
}
|
|
230
|
-
async function diffAgainstBase(baseStore, forkStore) {
|
|
246
|
+
async function diffAgainstBase(baseStore, forkStore, captureForkState = true) {
|
|
231
247
|
const graph = baseStore.graph;
|
|
232
|
-
const nodeKinds =
|
|
233
|
-
const edgeKinds =
|
|
248
|
+
const nodeKinds = chunkT6SPUYLX_cjs.getNodeKinds(graph);
|
|
249
|
+
const edgeKinds = chunkT6SPUYLX_cjs.getEdgeKinds(graph);
|
|
234
250
|
const newNodes = [];
|
|
235
251
|
const modifiedNodes = [];
|
|
236
252
|
const deletedNodes = [];
|
|
253
|
+
const forkNodeVersions = /* @__PURE__ */ new Map();
|
|
237
254
|
for (const kind of nodeKinds) {
|
|
238
255
|
const baseRows = await enumerateAllNodes(
|
|
239
256
|
baseStore.backend,
|
|
@@ -245,6 +262,11 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
245
262
|
forkStore.graphId,
|
|
246
263
|
kind
|
|
247
264
|
);
|
|
265
|
+
if (captureForkState) {
|
|
266
|
+
for (const row of forkRows) {
|
|
267
|
+
forkNodeVersions.set(mergeKey(kind, row.id), row.version);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
248
270
|
const delta = diffNodeKind(kind, baseRows, forkRows);
|
|
249
271
|
for (const entry of delta.new) {
|
|
250
272
|
newNodes.push(entry);
|
|
@@ -259,6 +281,7 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
259
281
|
const newEdges = [];
|
|
260
282
|
const modifiedEdges = [];
|
|
261
283
|
const deletedEdges = [];
|
|
284
|
+
const forkEdgeSignatures = /* @__PURE__ */ new Map();
|
|
262
285
|
for (const kind of edgeKinds) {
|
|
263
286
|
const baseRows = await enumerateAllEdges(
|
|
264
287
|
baseStore.backend,
|
|
@@ -270,6 +293,21 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
270
293
|
forkStore.graphId,
|
|
271
294
|
kind
|
|
272
295
|
);
|
|
296
|
+
if (captureForkState) {
|
|
297
|
+
for (const row of forkRows) {
|
|
298
|
+
forkEdgeSignatures.set(
|
|
299
|
+
mergeKey(kind, row.id),
|
|
300
|
+
edgeStateSignature({
|
|
301
|
+
fromKind: row.from_kind,
|
|
302
|
+
fromId: row.from_id,
|
|
303
|
+
toKind: row.to_kind,
|
|
304
|
+
toId: row.to_id,
|
|
305
|
+
live: isLive(row),
|
|
306
|
+
props: parseRowProps(row.props)
|
|
307
|
+
})
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
273
311
|
const delta = diffEdgeKind(kind, baseRows, forkRows);
|
|
274
312
|
for (const entry of delta.new) {
|
|
275
313
|
newEdges.push(entry);
|
|
@@ -291,7 +329,9 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
291
329
|
new: newEdges.sort((left, right) => byId(left, right)),
|
|
292
330
|
modified: modifiedEdges.sort((left, right) => byId(left, right)),
|
|
293
331
|
deleted: deletedEdges.sort((left, right) => byId(left, right))
|
|
294
|
-
}
|
|
332
|
+
},
|
|
333
|
+
forkNodeVersions,
|
|
334
|
+
forkEdgeSignatures
|
|
295
335
|
};
|
|
296
336
|
}
|
|
297
337
|
|
|
@@ -312,16 +352,16 @@ async function readActiveSchemaVersion(backend, graphId) {
|
|
|
312
352
|
}
|
|
313
353
|
async function computeSchemaComponent(store) {
|
|
314
354
|
const version = await readActiveSchemaVersion(store.backend, store.graphId);
|
|
315
|
-
return
|
|
355
|
+
return chunk6HVOHZHS_cjs.computeSchemaHash(chunk6HVOHZHS_cjs.serializeSchema(store.graph, version));
|
|
316
356
|
}
|
|
317
357
|
function byDigestEntry(left, right) {
|
|
318
|
-
const byKind = compareStrings(left.kind, right.kind);
|
|
319
|
-
return byKind === 0 ? compareStrings(left.id, right.id) : byKind;
|
|
358
|
+
const byKind = chunkZ5HBYM7U_cjs.compareStrings(left.kind, right.kind);
|
|
359
|
+
return byKind === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id) : byKind;
|
|
320
360
|
}
|
|
321
361
|
var CONTENT_FINGERPRINT_BYTES = 16;
|
|
322
362
|
async function computeContentComponent(backend, graphId, graph) {
|
|
323
|
-
const nodeKinds =
|
|
324
|
-
const edgeKinds =
|
|
363
|
+
const nodeKinds = chunkT6SPUYLX_cjs.getNodeKinds(graph);
|
|
364
|
+
const edgeKinds = chunkT6SPUYLX_cjs.getEdgeKinds(graph);
|
|
325
365
|
const nodeDigest = [];
|
|
326
366
|
for (const kind of nodeKinds) {
|
|
327
367
|
const rows = await enumerateAllNodes(backend, graphId, kind);
|
|
@@ -356,7 +396,7 @@ async function computeContentComponent(backend, graphId, graph) {
|
|
|
356
396
|
}
|
|
357
397
|
}
|
|
358
398
|
}
|
|
359
|
-
return
|
|
399
|
+
return chunkZY4GXIVN_cjs.sha256Hex(
|
|
360
400
|
canonicalizeProps({
|
|
361
401
|
nodes: nodeDigest.sort((left, right) => byDigestEntry(left, right)),
|
|
362
402
|
edges: edgeDigest.sort((left, right) => byDigestEntry(left, right))
|
|
@@ -447,17 +487,17 @@ var CLONE_IMPORT_BATCH_SIZE = 1e3;
|
|
|
447
487
|
function cloneWorkingCopyStrategy(makeBackend) {
|
|
448
488
|
return {
|
|
449
489
|
create: async (baseStore) => {
|
|
450
|
-
const data = await
|
|
490
|
+
const data = await chunkKNHYNQQ3_cjs.exportGraph(baseStore, {
|
|
451
491
|
includeMeta: true,
|
|
452
492
|
includeDeleted: false
|
|
453
493
|
});
|
|
454
494
|
const backend = await makeBackend();
|
|
455
495
|
try {
|
|
456
|
-
const [freshStore] = await
|
|
496
|
+
const [freshStore] = await chunk3BRVBQQD_cjs.createStoreWithSchema(
|
|
457
497
|
baseStore.graph,
|
|
458
498
|
backend
|
|
459
499
|
);
|
|
460
|
-
const result = await
|
|
500
|
+
const result = await chunkKNHYNQQ3_cjs.importGraph(freshStore, data, {
|
|
461
501
|
onConflict: "error",
|
|
462
502
|
onUnknownProperty: "error",
|
|
463
503
|
validateReferences: true,
|
|
@@ -485,12 +525,12 @@ function cloneWorkingCopyStrategy(makeBackend) {
|
|
|
485
525
|
async function branch(baseStore, makeBackend, options, strategy) {
|
|
486
526
|
try {
|
|
487
527
|
const base = await computeBaseVersion(baseStore);
|
|
488
|
-
const id = options?.id ?? asBranchId(
|
|
528
|
+
const id = options?.id ?? asBranchId(chunk5IQIX7LU_cjs.generateId());
|
|
489
529
|
const workingCopyStrategy = strategy ?? cloneWorkingCopyStrategy(makeBackend);
|
|
490
530
|
const store = await workingCopyStrategy.create(baseStore);
|
|
491
|
-
return
|
|
531
|
+
return chunkHK5SATYM_cjs.ok({ id, base, store });
|
|
492
532
|
} catch (error) {
|
|
493
|
-
return
|
|
533
|
+
return chunkHK5SATYM_cjs.err(
|
|
494
534
|
new BranchError("Failed to create working-copy branch of base store", {
|
|
495
535
|
cause: error
|
|
496
536
|
})
|
|
@@ -514,7 +554,7 @@ function constraintSignature(node, constraint) {
|
|
|
514
554
|
return void 0;
|
|
515
555
|
}
|
|
516
556
|
}
|
|
517
|
-
return `${constraint.name}${KEY_PART_SEPARATOR}${
|
|
557
|
+
return `${constraint.name}${KEY_PART_SEPARATOR}${chunk5IQIX7LU_cjs.computeUniqueKey(
|
|
518
558
|
props,
|
|
519
559
|
constraint.fields,
|
|
520
560
|
constraint.collation
|
|
@@ -551,12 +591,12 @@ function blockNodes(newNodes, resolveConfig, uniqueConstraints = []) {
|
|
|
551
591
|
}
|
|
552
592
|
}
|
|
553
593
|
const sortedKeys = [...buckets.keys()].sort(
|
|
554
|
-
(left, right) => compareStrings(left, right)
|
|
594
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
555
595
|
);
|
|
556
596
|
const ordered = /* @__PURE__ */ new Map();
|
|
557
597
|
for (const key of sortedKeys) {
|
|
558
598
|
const members = [...buckets.get(key)].sort(
|
|
559
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
599
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
560
600
|
);
|
|
561
601
|
ordered.set(key, members);
|
|
562
602
|
}
|
|
@@ -573,7 +613,7 @@ function buildBranchRank(branchOrder, allBranchIds) {
|
|
|
573
613
|
next += 1;
|
|
574
614
|
}
|
|
575
615
|
}
|
|
576
|
-
const remaining = allBranchIds.filter((branchId) => !rank.has(branchId)).sort((left, right) => compareStrings(left, right));
|
|
616
|
+
const remaining = allBranchIds.filter((branchId) => !rank.has(branchId)).sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
577
617
|
for (const branchId of remaining) {
|
|
578
618
|
if (!rank.has(branchId)) {
|
|
579
619
|
rank.set(branchId, next);
|
|
@@ -645,8 +685,8 @@ function collectConflictingValues(property, contributions) {
|
|
|
645
685
|
values.push({ branchId, value });
|
|
646
686
|
}
|
|
647
687
|
return [...values].sort((left, right) => {
|
|
648
|
-
const byBranch = compareStrings(left.branchId, right.branchId);
|
|
649
|
-
return byBranch === 0 ? compareStrings(
|
|
688
|
+
const byBranch = chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId);
|
|
689
|
+
return byBranch === 0 ? chunkZ5HBYM7U_cjs.compareStrings(
|
|
650
690
|
canonicalValueKey(left.value),
|
|
651
691
|
canonicalValueKey(right.value)
|
|
652
692
|
) : byBranch;
|
|
@@ -773,7 +813,7 @@ function unionProperties(canonicalMember, members, context, baseContext, branchR
|
|
|
773
813
|
const props = {};
|
|
774
814
|
const conflicts = [];
|
|
775
815
|
for (const property of [...propertyNames].sort(
|
|
776
|
-
(left, right) => compareStrings(left, right)
|
|
816
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
777
817
|
)) {
|
|
778
818
|
const values = collectConflictingValues(property, members);
|
|
779
819
|
if (values.length === 0) {
|
|
@@ -838,14 +878,14 @@ function canonicalizeCluster(cluster, members, policy, branchRank, weights, cano
|
|
|
838
878
|
);
|
|
839
879
|
const memberIds = [
|
|
840
880
|
...new Set(cluster.members.map((member) => idOf(member)))
|
|
841
|
-
].sort((left, right) => compareStrings(left, right));
|
|
881
|
+
].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
842
882
|
const branchOrigins = [
|
|
843
883
|
...new Set(
|
|
844
884
|
members.map((member) => member.branchId).filter(
|
|
845
885
|
(branchId) => branchId !== BASE_PROVENANCE_BRANCH && branchId !== preferredBranchId
|
|
846
886
|
)
|
|
847
887
|
)
|
|
848
|
-
].sort((left, right) => compareStrings(left, right));
|
|
888
|
+
].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
849
889
|
const resolution = {
|
|
850
890
|
canonicalId,
|
|
851
891
|
memberIds,
|
|
@@ -905,7 +945,7 @@ var UnionFind = class {
|
|
|
905
945
|
var SUB_CLASS_OF_META_EDGE = "subClassOf";
|
|
906
946
|
var EQUIVALENT_TO_META_EDGE = "equivalentTo";
|
|
907
947
|
function buildSubClassClosure(ontology) {
|
|
908
|
-
const unionFind = new UnionFind(compareStrings);
|
|
948
|
+
const unionFind = new UnionFind(chunkZ5HBYM7U_cjs.compareStrings);
|
|
909
949
|
for (const relation of ontology) {
|
|
910
950
|
unionFind.add(relation.from);
|
|
911
951
|
unionFind.add(relation.to);
|
|
@@ -936,7 +976,7 @@ function buildSubClassClosure(ontology) {
|
|
|
936
976
|
relations.push([child, parent]);
|
|
937
977
|
}
|
|
938
978
|
return {
|
|
939
|
-
closure:
|
|
979
|
+
closure: chunkHK5SATYM_cjs.computeTransitiveClosure(relations),
|
|
940
980
|
canonicalOf
|
|
941
981
|
};
|
|
942
982
|
}
|
|
@@ -949,7 +989,7 @@ function isReachable2(closure, from, to) {
|
|
|
949
989
|
if (fromRep === toRep) {
|
|
950
990
|
return from !== to;
|
|
951
991
|
}
|
|
952
|
-
return
|
|
992
|
+
return chunkHK5SATYM_cjs.isReachable(closure.closure, fromRep, toRep);
|
|
953
993
|
}
|
|
954
994
|
|
|
955
995
|
// src/graph-merge/similarity.ts
|
|
@@ -1132,37 +1172,37 @@ function scorePrepared(left, right, strategy, ctx) {
|
|
|
1132
1172
|
switch (strategy.kind) {
|
|
1133
1173
|
case "custom": {
|
|
1134
1174
|
const raw = strategy.score(left.node, right.node);
|
|
1135
|
-
return
|
|
1175
|
+
return chunkHK5SATYM_cjs.ok(clampScore(raw));
|
|
1136
1176
|
}
|
|
1137
1177
|
case "fulltext": {
|
|
1138
1178
|
if (left.text.length === 0 || right.text.length === 0) {
|
|
1139
|
-
return
|
|
1179
|
+
return chunkHK5SATYM_cjs.ok(NO_EVIDENCE_SCORE);
|
|
1140
1180
|
}
|
|
1141
|
-
return
|
|
1181
|
+
return chunkHK5SATYM_cjs.ok(clampScore(diceFromMultisets(left.grams, right.grams)));
|
|
1142
1182
|
}
|
|
1143
1183
|
case "vector": {
|
|
1144
1184
|
if (ctx.embeddings === void 0) {
|
|
1145
|
-
return
|
|
1185
|
+
return chunkHK5SATYM_cjs.err(embedderUnavailable("vector", ctx));
|
|
1146
1186
|
}
|
|
1147
1187
|
if (left.text.length === 0 || right.text.length === 0) {
|
|
1148
|
-
return
|
|
1188
|
+
return chunkHK5SATYM_cjs.ok(NO_EVIDENCE_SCORE);
|
|
1149
1189
|
}
|
|
1150
1190
|
const cosine = cosineFromLookup(ctx.embeddings, left.text, right.text);
|
|
1151
|
-
return
|
|
1191
|
+
return chunkHK5SATYM_cjs.ok(clampScore(cosine));
|
|
1152
1192
|
}
|
|
1153
1193
|
case "hybrid": {
|
|
1154
1194
|
if (ctx.embeddings === void 0) {
|
|
1155
|
-
return
|
|
1195
|
+
return chunkHK5SATYM_cjs.err(embedderUnavailable("hybrid", ctx));
|
|
1156
1196
|
}
|
|
1157
1197
|
if (left.text.length === 0 || right.text.length === 0) {
|
|
1158
|
-
return
|
|
1198
|
+
return chunkHK5SATYM_cjs.ok(NO_EVIDENCE_SCORE);
|
|
1159
1199
|
}
|
|
1160
1200
|
const vectorScore = clampScore(
|
|
1161
1201
|
cosineFromLookup(ctx.embeddings, left.text, right.text)
|
|
1162
1202
|
);
|
|
1163
1203
|
const fulltextScore = diceFromMultisets(left.grams, right.grams);
|
|
1164
1204
|
const weights = normalizeHybridWeights(strategy.weights);
|
|
1165
|
-
return
|
|
1205
|
+
return chunkHK5SATYM_cjs.ok(
|
|
1166
1206
|
clampScore(
|
|
1167
1207
|
weights.vector * vectorScore + weights.fulltext * fulltextScore
|
|
1168
1208
|
)
|
|
@@ -1220,7 +1260,7 @@ function scoreCandidates(input, resolveConfig, ctx, ceilingPolicy, maxComparison
|
|
|
1220
1260
|
}
|
|
1221
1261
|
if (maxComparisonsPerKind !== void 0 && fuzzy.length > maxComparisonsPerKind) {
|
|
1222
1262
|
if (ceilingPolicy === "error") {
|
|
1223
|
-
return
|
|
1263
|
+
return chunkHK5SATYM_cjs.err(
|
|
1224
1264
|
new MergeError(
|
|
1225
1265
|
`Comparison ceiling exceeded: ${fuzzy.length} candidate pairs > maxComparisonsPerKind ${maxComparisonsPerKind}.`,
|
|
1226
1266
|
{
|
|
@@ -1233,7 +1273,7 @@ function scoreCandidates(input, resolveConfig, ctx, ceilingPolicy, maxComparison
|
|
|
1233
1273
|
)
|
|
1234
1274
|
);
|
|
1235
1275
|
}
|
|
1236
|
-
return
|
|
1276
|
+
return chunkHK5SATYM_cjs.ok({
|
|
1237
1277
|
edges: [...forced].sort(
|
|
1238
1278
|
(left, right) => compareCandidateEdges(left, right)
|
|
1239
1279
|
),
|
|
@@ -1251,14 +1291,14 @@ function scoreCandidates(input, resolveConfig, ctx, ceilingPolicy, maxComparison
|
|
|
1251
1291
|
const edges = [...forced];
|
|
1252
1292
|
for (const { left, right, a, b } of fuzzy) {
|
|
1253
1293
|
const scored = scorer(a, left, b, right);
|
|
1254
|
-
if (
|
|
1255
|
-
return
|
|
1294
|
+
if (chunkHK5SATYM_cjs.isErr(scored)) {
|
|
1295
|
+
return chunkHK5SATYM_cjs.err(scored.error);
|
|
1256
1296
|
}
|
|
1257
1297
|
if (scored.data >= threshold) {
|
|
1258
1298
|
edges.push({ a, b, score: scored.data });
|
|
1259
1299
|
}
|
|
1260
1300
|
}
|
|
1261
|
-
return
|
|
1301
|
+
return chunkHK5SATYM_cjs.ok({
|
|
1262
1302
|
edges: edges.sort((left, right) => compareCandidateEdges(left, right)),
|
|
1263
1303
|
warnings: []
|
|
1264
1304
|
});
|
|
@@ -1468,7 +1508,7 @@ function pickHighestPriorityBranch(branchIds, branchRank) {
|
|
|
1468
1508
|
let chosenRank = branchRank.get(chosen) ?? Number.MAX_SAFE_INTEGER;
|
|
1469
1509
|
for (const candidate of branchIds.slice(1)) {
|
|
1470
1510
|
const candidateRank = branchRank.get(candidate) ?? Number.MAX_SAFE_INTEGER;
|
|
1471
|
-
if (candidateRank < chosenRank || candidateRank === chosenRank && compareStrings(candidate, chosen) < 0) {
|
|
1511
|
+
if (candidateRank < chosenRank || candidateRank === chosenRank && chunkZ5HBYM7U_cjs.compareStrings(candidate, chosen) < 0) {
|
|
1472
1512
|
chosen = candidate;
|
|
1473
1513
|
chosenRank = candidateRank;
|
|
1474
1514
|
}
|
|
@@ -1561,20 +1601,20 @@ function resolveDeleteModifyOver(modified, deleted, modifiedEntity, deletedEntit
|
|
|
1561
1601
|
}
|
|
1562
1602
|
return {
|
|
1563
1603
|
survivingModifications: [...survivingModifications].sort((left, right) => {
|
|
1564
|
-
const byId2 = compareStrings(
|
|
1604
|
+
const byId2 = chunkZ5HBYM7U_cjs.compareStrings(
|
|
1565
1605
|
modifiedEntity(left).id,
|
|
1566
1606
|
modifiedEntity(right).id
|
|
1567
1607
|
);
|
|
1568
|
-
return byId2 === 0 ? compareStrings(left.branchId, right.branchId) : byId2;
|
|
1608
|
+
return byId2 === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId) : byId2;
|
|
1569
1609
|
}),
|
|
1570
1610
|
deletions: [...deletions].sort(
|
|
1571
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
1611
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
1572
1612
|
),
|
|
1573
1613
|
conflicts: [...conflicts].sort(
|
|
1574
|
-
(left, right) => compareStrings(left.entityId, right.entityId)
|
|
1614
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.entityId, right.entityId)
|
|
1575
1615
|
),
|
|
1576
1616
|
dropped: [...dropped].sort(
|
|
1577
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
1617
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
1578
1618
|
)
|
|
1579
1619
|
};
|
|
1580
1620
|
}
|
|
@@ -1618,11 +1658,11 @@ function reconcileOver(survivingModifications, entityOf, rebuild, policy, branch
|
|
|
1618
1658
|
}
|
|
1619
1659
|
return {
|
|
1620
1660
|
survivingModifications: [...out].sort((left, right) => {
|
|
1621
|
-
const byId2 = compareStrings(entityOf(left).id, entityOf(right).id);
|
|
1622
|
-
return byId2 === 0 ? compareStrings(left.branchId, right.branchId) : byId2;
|
|
1661
|
+
const byId2 = chunkZ5HBYM7U_cjs.compareStrings(entityOf(left).id, entityOf(right).id);
|
|
1662
|
+
return byId2 === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId) : byId2;
|
|
1623
1663
|
}),
|
|
1624
1664
|
conflicts: conflicts.sort(
|
|
1625
|
-
(left, right) => compareStrings(
|
|
1665
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(
|
|
1626
1666
|
`${left.entityId}|${left.property}`,
|
|
1627
1667
|
`${right.entityId}|${right.property}`
|
|
1628
1668
|
)
|
|
@@ -1656,7 +1696,7 @@ function threeWayMergeProps(entityId, kind, baseProps, contributions, context, b
|
|
|
1656
1696
|
propertyNames.add(name);
|
|
1657
1697
|
}
|
|
1658
1698
|
}
|
|
1659
|
-
for (const property of [...propertyNames].sort(compareStrings)) {
|
|
1699
|
+
for (const property of [...propertyNames].sort(chunkZ5HBYM7U_cjs.compareStrings)) {
|
|
1660
1700
|
const baseHas = property in baseProps;
|
|
1661
1701
|
const baseKey = baseHas ? canonicalValueKey(baseProps[property]) : void 0;
|
|
1662
1702
|
const changed = contributions.filter((contribution) => {
|
|
@@ -1793,7 +1833,7 @@ function unionEdgeProps(survivorId, kind, survivor, edges, context, branchRank,
|
|
|
1793
1833
|
const conflicts = [];
|
|
1794
1834
|
const contributions = edges.map((edge) => edge.staged);
|
|
1795
1835
|
for (const property of [...propertyNames].sort(
|
|
1796
|
-
(left, right) => compareStrings(left, right)
|
|
1836
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
1797
1837
|
)) {
|
|
1798
1838
|
const values = collectConflictingValues(property, contributions);
|
|
1799
1839
|
if (values.length === 0) {
|
|
@@ -1862,7 +1902,7 @@ function repointEdges(stagedEdges, canonicalOf, deletedNodeIds, policy, branchRa
|
|
|
1862
1902
|
const merged = [];
|
|
1863
1903
|
const conflicts = [];
|
|
1864
1904
|
const sortedGroups = [...dedupeKeyByGroup.keys()].sort(
|
|
1865
|
-
(left, right) => compareStrings(left, right)
|
|
1905
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
1866
1906
|
);
|
|
1867
1907
|
for (const group of sortedGroups) {
|
|
1868
1908
|
const dedupeKeys = [...dedupeKeyByGroup.get(group)];
|
|
@@ -1874,7 +1914,7 @@ function repointEdges(stagedEdges, canonicalOf, deletedNodeIds, policy, branchRa
|
|
|
1874
1914
|
}
|
|
1875
1915
|
const survivor = pickSurvivor(groupEdges, preferredBranchId);
|
|
1876
1916
|
const survivorId = survivor.staged.id;
|
|
1877
|
-
const mergedIds = [...groupEdges].map((edge) => edge.staged.id).sort((left, right) => compareStrings(left, right));
|
|
1917
|
+
const mergedIds = [...groupEdges].map((edge) => edge.staged.id).sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
1878
1918
|
const fromId = idOf(survivor.fromKey);
|
|
1879
1919
|
const fromKind = kindOf(survivor.fromKey);
|
|
1880
1920
|
const toId = idOf(survivor.toKey);
|
|
@@ -1923,12 +1963,12 @@ function repointEdges(stagedEdges, canonicalOf, deletedNodeIds, policy, branchRa
|
|
|
1923
1963
|
mergeKey(edge.toKind, edge.toId),
|
|
1924
1964
|
edge.props
|
|
1925
1965
|
)
|
|
1926
|
-
})).sort((left, right) => compareStrings(left.sortKey, right.sortKey)).map(({ edge }) => edge);
|
|
1966
|
+
})).sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.sortKey, right.sortKey)).map(({ edge }) => edge);
|
|
1927
1967
|
return {
|
|
1928
1968
|
edges: sortedEdges,
|
|
1929
|
-
dropped: dropped.sort((left, right) => compareStrings(left.id, right.id)),
|
|
1969
|
+
dropped: dropped.sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)),
|
|
1930
1970
|
conflicts: conflicts.sort(
|
|
1931
|
-
(left, right) => compareStrings(
|
|
1971
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(
|
|
1932
1972
|
`${left.entityId}|${left.property}`,
|
|
1933
1973
|
`${right.entityId}|${right.property}`
|
|
1934
1974
|
)
|
|
@@ -2057,7 +2097,7 @@ function normalizeMergeOptions(options = {}) {
|
|
|
2057
2097
|
...provenanceWeights === void 0 ? {} : { provenanceWeights }
|
|
2058
2098
|
};
|
|
2059
2099
|
}
|
|
2060
|
-
var Provenance =
|
|
2100
|
+
var Provenance = chunk6HVOHZHS_cjs.defineNode("Provenance", {
|
|
2061
2101
|
schema: zod.z.object({
|
|
2062
2102
|
targetGraphId: zod.z.string(),
|
|
2063
2103
|
role: zod.z.enum(["node", "edge"]),
|
|
@@ -2071,14 +2111,14 @@ function provenanceGraphId(targetGraphId) {
|
|
|
2071
2111
|
return `${targetGraphId}::merge-provenance`;
|
|
2072
2112
|
}
|
|
2073
2113
|
function buildProvenanceGraph(targetGraphId) {
|
|
2074
|
-
return
|
|
2114
|
+
return chunkT6SPUYLX_cjs.defineGraph({
|
|
2075
2115
|
id: provenanceGraphId(targetGraphId),
|
|
2076
2116
|
nodes: { Provenance: { type: Provenance } },
|
|
2077
2117
|
edges: {}
|
|
2078
2118
|
});
|
|
2079
2119
|
}
|
|
2080
2120
|
async function openProvenanceStore(backend, targetGraphId) {
|
|
2081
|
-
const [store] = await
|
|
2121
|
+
const [store] = await chunk3BRVBQQD_cjs.createStoreWithSchema(
|
|
2082
2122
|
buildProvenanceGraph(targetGraphId),
|
|
2083
2123
|
backend
|
|
2084
2124
|
);
|
|
@@ -2098,7 +2138,7 @@ async function provenanceNodeId(targetGraphId, record) {
|
|
|
2098
2138
|
record.branchId,
|
|
2099
2139
|
record.sourceId
|
|
2100
2140
|
].join(ID_SEPARATOR);
|
|
2101
|
-
const digest = await
|
|
2141
|
+
const digest = await chunkZY4GXIVN_cjs.sha256Hex(tuple, ID_DIGEST_BYTES);
|
|
2102
2142
|
return `prov_${digest}`;
|
|
2103
2143
|
}
|
|
2104
2144
|
async function persistProvenanceRecords(store, targetGraphId, records) {
|
|
@@ -2125,7 +2165,7 @@ async function readProvenance(store, query = {}) {
|
|
|
2125
2165
|
const all = await store.nodes.Provenance.find();
|
|
2126
2166
|
return all.filter(
|
|
2127
2167
|
(node) => (query.branchId === void 0 || node.branchId === query.branchId) && (query.canonicalId === void 0 || node.canonicalId === query.canonicalId) && (query.role === void 0 || node.role === query.role)
|
|
2128
|
-
).sort((left, right) => compareStrings(left.id, right.id));
|
|
2168
|
+
).sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id));
|
|
2129
2169
|
}
|
|
2130
2170
|
|
|
2131
2171
|
// src/graph-merge/sources.ts
|
|
@@ -2135,10 +2175,10 @@ function orderEndpoints(left, right) {
|
|
|
2135
2175
|
return compareMergeKeys(leftKey, rightKey) <= 0 ? { a: leftKey, b: rightKey, left, right } : { a: rightKey, b: leftKey, left: right, right: left };
|
|
2136
2176
|
}
|
|
2137
2177
|
function sortMembersById(members) {
|
|
2138
|
-
return [...members].sort((left, right) => compareStrings(left.id, right.id));
|
|
2178
|
+
return [...members].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id));
|
|
2139
2179
|
}
|
|
2140
2180
|
function sortedBucketKeys(blocks) {
|
|
2141
|
-
return [...blocks.keys()].sort((left, right) => compareStrings(left, right));
|
|
2181
|
+
return [...blocks.keys()].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
2142
2182
|
}
|
|
2143
2183
|
var NODE_SYSTEM_FIELDS = /* @__PURE__ */ new Set(["id", "kind", "meta"]);
|
|
2144
2184
|
function nodeProps(node) {
|
|
@@ -2166,7 +2206,7 @@ function windowedPairs(members, config) {
|
|
|
2166
2206
|
key: fieldText(node, config.sortFields)
|
|
2167
2207
|
}));
|
|
2168
2208
|
keyed.sort(
|
|
2169
|
-
(left, right) => left.key === right.key ? compareStrings(left.node.id, right.node.id) : compareStrings(left.key, right.key)
|
|
2209
|
+
(left, right) => left.key === right.key ? chunkZ5HBYM7U_cjs.compareStrings(left.node.id, right.node.id) : chunkZ5HBYM7U_cjs.compareStrings(left.key, right.key)
|
|
2170
2210
|
);
|
|
2171
2211
|
const pairs = [];
|
|
2172
2212
|
for (let index = 0; index < keyed.length; index += 1) {
|
|
@@ -2224,7 +2264,7 @@ function ontologyRetypeEdges(stagedIdentities, isRetypeCompatible) {
|
|
|
2224
2264
|
}
|
|
2225
2265
|
}
|
|
2226
2266
|
const edges = [];
|
|
2227
|
-
for (const id of [...identitiesById.keys()].sort(compareStrings)) {
|
|
2267
|
+
for (const id of [...identitiesById.keys()].sort(chunkZ5HBYM7U_cjs.compareStrings)) {
|
|
2228
2268
|
const identities = [...new Set(identitiesById.get(id))].sort(
|
|
2229
2269
|
compareMergeKeys
|
|
2230
2270
|
);
|
|
@@ -2316,7 +2356,7 @@ var baseUniqueSource = {
|
|
|
2316
2356
|
const forcedEdges = [];
|
|
2317
2357
|
const baseMembers = /* @__PURE__ */ new Map();
|
|
2318
2358
|
const constraints = [...uniqueConstraints].sort(
|
|
2319
|
-
(left, right) => compareStrings(left.name, right.name)
|
|
2359
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.name, right.name)
|
|
2320
2360
|
);
|
|
2321
2361
|
const items = nodes.map((node) => ({ props: nodeProps(node) }));
|
|
2322
2362
|
const matchesByConstraint = await Promise.all(
|
|
@@ -2359,7 +2399,7 @@ var baseUniqueSource = {
|
|
|
2359
2399
|
pairs: [],
|
|
2360
2400
|
forcedEdges,
|
|
2361
2401
|
baseMembers: [...baseMembers.values()].sort(
|
|
2362
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
2402
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
2363
2403
|
)
|
|
2364
2404
|
};
|
|
2365
2405
|
}
|
|
@@ -2416,7 +2456,7 @@ var baseKeySource = {
|
|
|
2416
2456
|
pairs,
|
|
2417
2457
|
forcedEdges: [],
|
|
2418
2458
|
baseMembers: [...baseMembers.values()].sort(
|
|
2419
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
2459
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
2420
2460
|
)
|
|
2421
2461
|
};
|
|
2422
2462
|
}
|
|
@@ -2428,16 +2468,16 @@ var CANDIDATE_SOURCES = [
|
|
|
2428
2468
|
|
|
2429
2469
|
// src/graph-merge/staging.ts
|
|
2430
2470
|
function compareByIdThenBranch(left, right) {
|
|
2431
|
-
const byId2 = compareStrings(left.id, right.id);
|
|
2432
|
-
return byId2 === 0 ? compareStrings(left.branchId, right.branchId) : byId2;
|
|
2471
|
+
const byId2 = chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id);
|
|
2472
|
+
return byId2 === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId) : byId2;
|
|
2433
2473
|
}
|
|
2434
2474
|
function compareByKindIdBranch(left, right) {
|
|
2435
|
-
const byKind = compareStrings(left.kind, right.kind);
|
|
2475
|
+
const byKind = chunkZ5HBYM7U_cjs.compareStrings(left.kind, right.kind);
|
|
2436
2476
|
if (byKind !== 0) {
|
|
2437
2477
|
return byKind;
|
|
2438
2478
|
}
|
|
2439
|
-
const byId2 = compareStrings(left.id, right.id);
|
|
2440
|
-
return byId2 === 0 ? compareStrings(left.branchId, right.branchId) : byId2;
|
|
2479
|
+
const byId2 = chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id);
|
|
2480
|
+
return byId2 === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId) : byId2;
|
|
2441
2481
|
}
|
|
2442
2482
|
function groupByKind(items) {
|
|
2443
2483
|
const buckets = /* @__PURE__ */ new Map();
|
|
@@ -2451,7 +2491,7 @@ function groupByKind(items) {
|
|
|
2451
2491
|
}
|
|
2452
2492
|
const ordered = /* @__PURE__ */ new Map();
|
|
2453
2493
|
for (const kind of [...buckets.keys()].sort(
|
|
2454
|
-
(left, right) => compareStrings(left, right)
|
|
2494
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2455
2495
|
)) {
|
|
2456
2496
|
ordered.set(
|
|
2457
2497
|
kind,
|
|
@@ -2462,16 +2502,26 @@ function groupByKind(items) {
|
|
|
2462
2502
|
}
|
|
2463
2503
|
return ordered;
|
|
2464
2504
|
}
|
|
2465
|
-
async function stageBranches(baseStore, branches) {
|
|
2505
|
+
async function stageBranches(baseStore, branches, captureTargetStateFor) {
|
|
2466
2506
|
const newNodes = [];
|
|
2467
2507
|
const modifiedNodes = [];
|
|
2468
2508
|
const deletedNodes = [];
|
|
2469
2509
|
const newEdges = [];
|
|
2470
2510
|
const modifiedEdges = [];
|
|
2471
2511
|
const deletedEdges = [];
|
|
2512
|
+
let targetNodeVersions = /* @__PURE__ */ new Map();
|
|
2513
|
+
let targetEdgeSignatures = /* @__PURE__ */ new Map();
|
|
2472
2514
|
for (const branch2 of branches) {
|
|
2473
|
-
const diff = await diffAgainstBase(baseStore, branch2.store);
|
|
2474
2515
|
const branchId = branch2.id;
|
|
2516
|
+
const diff = await diffAgainstBase(
|
|
2517
|
+
baseStore,
|
|
2518
|
+
branch2.store,
|
|
2519
|
+
branchId === captureTargetStateFor
|
|
2520
|
+
);
|
|
2521
|
+
if (branchId === captureTargetStateFor) {
|
|
2522
|
+
targetNodeVersions = diff.forkNodeVersions;
|
|
2523
|
+
targetEdgeSignatures = diff.forkEdgeSignatures;
|
|
2524
|
+
}
|
|
2475
2525
|
for (const node of diff.nodes.new) {
|
|
2476
2526
|
newNodes.push({ branchId, node, kind: node.kind, id: node.id });
|
|
2477
2527
|
}
|
|
@@ -2505,7 +2555,9 @@ async function stageBranches(baseStore, branches) {
|
|
|
2505
2555
|
),
|
|
2506
2556
|
deletedEdges: [...deletedEdges].sort(
|
|
2507
2557
|
(left, right) => compareByKindIdBranch(left, right)
|
|
2508
|
-
)
|
|
2558
|
+
),
|
|
2559
|
+
targetNodeVersions,
|
|
2560
|
+
targetEdgeSignatures
|
|
2509
2561
|
};
|
|
2510
2562
|
}
|
|
2511
2563
|
|
|
@@ -2554,7 +2606,7 @@ async function withTxConflictRetry(commit) {
|
|
|
2554
2606
|
// src/graph-merge/type-reconcile.ts
|
|
2555
2607
|
var INCOMPATIBLE_TYPES_FLAG_REASON = "type-reconcile:incompatible-kinds";
|
|
2556
2608
|
function distinctKinds(kinds) {
|
|
2557
|
-
return [...new Set(kinds)].sort((left, right) => compareStrings(left, right));
|
|
2609
|
+
return [...new Set(kinds)].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
2558
2610
|
}
|
|
2559
2611
|
function areEquivalent(closure, left, right) {
|
|
2560
2612
|
return left !== right && isReachable2(closure, left, right) && isReachable2(closure, right, left);
|
|
@@ -2572,7 +2624,7 @@ function mostSpecificCommonKind(closure, kinds) {
|
|
|
2572
2624
|
if (qualifiers.length === 0) {
|
|
2573
2625
|
return void 0;
|
|
2574
2626
|
}
|
|
2575
|
-
return [...qualifiers].sort((left, right) => compareStrings(left, right))[0];
|
|
2627
|
+
return [...qualifiers].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right))[0];
|
|
2576
2628
|
}
|
|
2577
2629
|
function reconcileTypes(clusters, closure, mode) {
|
|
2578
2630
|
if (mode === "off") {
|
|
@@ -2609,10 +2661,10 @@ function reconcileTypes(clusters, closure, mode) {
|
|
|
2609
2661
|
}
|
|
2610
2662
|
return {
|
|
2611
2663
|
reconciliations: reconciliations.sort(
|
|
2612
|
-
(left, right) => compareStrings(left.entityId, right.entityId)
|
|
2664
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.entityId, right.entityId)
|
|
2613
2665
|
),
|
|
2614
2666
|
retypeMap,
|
|
2615
|
-
dropped: dropped.sort((left, right) => compareStrings(left.id, right.id))
|
|
2667
|
+
dropped: dropped.sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id))
|
|
2616
2668
|
};
|
|
2617
2669
|
}
|
|
2618
2670
|
|
|
@@ -2631,8 +2683,8 @@ function newNodesByKind(staging) {
|
|
|
2631
2683
|
ordered.set(
|
|
2632
2684
|
kind,
|
|
2633
2685
|
[...items].sort((left, right) => {
|
|
2634
|
-
const byId2 = compareStrings(left.node.id, right.node.id);
|
|
2635
|
-
return byId2 === 0 ? compareStrings(left.branchId, right.branchId) : byId2;
|
|
2686
|
+
const byId2 = chunkZ5HBYM7U_cjs.compareStrings(left.node.id, right.node.id);
|
|
2687
|
+
return byId2 === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId) : byId2;
|
|
2636
2688
|
})
|
|
2637
2689
|
);
|
|
2638
2690
|
}
|
|
@@ -2664,7 +2716,7 @@ async function precomputeEmbeddings(byKind, resolve, embedder) {
|
|
|
2664
2716
|
return lookup;
|
|
2665
2717
|
}
|
|
2666
2718
|
const orderedTexts = [...texts].sort(
|
|
2667
|
-
(left, right) => compareStrings(left, right)
|
|
2719
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2668
2720
|
);
|
|
2669
2721
|
const vectors = await embedder(orderedTexts);
|
|
2670
2722
|
if (vectors.length !== orderedTexts.length) {
|
|
@@ -2700,7 +2752,7 @@ async function embedMissingPairTexts(base, pairs, strategy, embedder) {
|
|
|
2700
2752
|
return existing;
|
|
2701
2753
|
}
|
|
2702
2754
|
const orderedTexts = [...missing].sort(
|
|
2703
|
-
(left, right) => compareStrings(left, right)
|
|
2755
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2704
2756
|
);
|
|
2705
2757
|
const vectors = await embedder(orderedTexts);
|
|
2706
2758
|
if (vectors.length !== orderedTexts.length) {
|
|
@@ -2730,7 +2782,7 @@ async function generateAllCandidates(target, staging, options, introspectionKind
|
|
|
2730
2782
|
async ([kind, items]) => {
|
|
2731
2783
|
const resolveConfig = options.resolve[kind];
|
|
2732
2784
|
if (resolveConfig === void 0) {
|
|
2733
|
-
return
|
|
2785
|
+
return chunkHK5SATYM_cjs.ok({ edges: [], warnings: [], baseMembers: [] });
|
|
2734
2786
|
}
|
|
2735
2787
|
const nodes = items.map((staged) => asNode(staged));
|
|
2736
2788
|
const uniqueConstraints = uniqueConstraintsFor(
|
|
@@ -2773,10 +2825,10 @@ async function generateAllCandidates(target, staging, options, introspectionKind
|
|
|
2773
2825
|
options.onComparisonCeiling,
|
|
2774
2826
|
options.maxComparisonsPerKind
|
|
2775
2827
|
);
|
|
2776
|
-
if (
|
|
2777
|
-
return
|
|
2828
|
+
if (chunkHK5SATYM_cjs.isErr(scored)) {
|
|
2829
|
+
return chunkHK5SATYM_cjs.err(scored.error);
|
|
2778
2830
|
}
|
|
2779
|
-
return
|
|
2831
|
+
return chunkHK5SATYM_cjs.ok({
|
|
2780
2832
|
edges: scored.data.edges,
|
|
2781
2833
|
warnings: scored.data.warnings.map(
|
|
2782
2834
|
(warning) => `[${kind}] ${warning.message}`
|
|
@@ -2787,14 +2839,14 @@ async function generateAllCandidates(target, staging, options, introspectionKind
|
|
|
2787
2839
|
)
|
|
2788
2840
|
);
|
|
2789
2841
|
for (const result of perKind) {
|
|
2790
|
-
if (
|
|
2791
|
-
return
|
|
2842
|
+
if (chunkHK5SATYM_cjs.isErr(result)) {
|
|
2843
|
+
return chunkHK5SATYM_cjs.err(result.error);
|
|
2792
2844
|
}
|
|
2793
2845
|
allEdges.push(...result.data.edges);
|
|
2794
2846
|
warnings.push(...result.data.warnings);
|
|
2795
2847
|
baseMembers.push(...result.data.baseMembers);
|
|
2796
2848
|
}
|
|
2797
|
-
return
|
|
2849
|
+
return chunkHK5SATYM_cjs.ok({
|
|
2798
2850
|
// The ONE shared `(a, b)` edge comparator (id-first `(kind, id)` order), so this
|
|
2799
2851
|
// stage emits edges in exactly the order clustering consumes them.
|
|
2800
2852
|
edges: allEdges.sort((left, right) => compareCandidateEdges(left, right)),
|
|
@@ -2897,9 +2949,9 @@ function buildProvenanceIndex(records) {
|
|
|
2897
2949
|
for (const [branchId, sets] of byBranch) {
|
|
2898
2950
|
frozen.set(branchId, {
|
|
2899
2951
|
nodeIds: [...sets.nodeIds].sort(
|
|
2900
|
-
(left, right) => compareStrings(left, right)
|
|
2952
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2901
2953
|
),
|
|
2902
|
-
edgeIds: [...sets.edgeIds].sort((left, right) => compareStrings(left, right)).map((id) => id)
|
|
2954
|
+
edgeIds: [...sets.edgeIds].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)).map((id) => id)
|
|
2903
2955
|
});
|
|
2904
2956
|
}
|
|
2905
2957
|
return {
|
|
@@ -3114,7 +3166,7 @@ function planMerge(staging, candidateEdges, candidateWarnings, baseMembers, opti
|
|
|
3114
3166
|
...repoint2.dropped,
|
|
3115
3167
|
...reconciliation.dropped
|
|
3116
3168
|
].sort(
|
|
3117
|
-
(left, right) => compareStrings(`${left.kind}|${left.id}`, `${right.kind}|${right.id}`)
|
|
3169
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(`${left.kind}|${left.id}`, `${right.kind}|${right.id}`)
|
|
3118
3170
|
);
|
|
3119
3171
|
return {
|
|
3120
3172
|
canonicalEntities,
|
|
@@ -3147,7 +3199,7 @@ function planMerge(staging, candidateEdges, candidateWarnings, baseMembers, opti
|
|
|
3147
3199
|
mergeKey(left.kind, left.entityId),
|
|
3148
3200
|
mergeKey(right.kind, right.entityId)
|
|
3149
3201
|
);
|
|
3150
|
-
return byEntity === 0 ? compareStrings(left.property, right.property) : byEntity;
|
|
3202
|
+
return byEntity === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.property, right.property) : byEntity;
|
|
3151
3203
|
}
|
|
3152
3204
|
),
|
|
3153
3205
|
deleteModifyConflicts: [
|
|
@@ -3335,7 +3387,7 @@ async function validateBaseVersions(target, branches) {
|
|
|
3335
3387
|
const targetVersion = await computeBaseVersion(target);
|
|
3336
3388
|
for (const branch2 of branches) {
|
|
3337
3389
|
if (branch2.base !== targetVersion) {
|
|
3338
|
-
return
|
|
3390
|
+
return chunkHK5SATYM_cjs.err(
|
|
3339
3391
|
new BaseVersionMismatchError(
|
|
3340
3392
|
`Branch "${branch2.id}" forked from base@V "${branch2.base}", which does not match the merge target's current base@V "${targetVersion}".`,
|
|
3341
3393
|
{
|
|
@@ -3349,20 +3401,20 @@ async function validateBaseVersions(target, branches) {
|
|
|
3349
3401
|
);
|
|
3350
3402
|
}
|
|
3351
3403
|
}
|
|
3352
|
-
return
|
|
3404
|
+
return chunkHK5SATYM_cjs.ok(targetVersion);
|
|
3353
3405
|
}
|
|
3354
3406
|
function tryNormalize(optionsInput) {
|
|
3355
3407
|
try {
|
|
3356
|
-
return
|
|
3408
|
+
return chunkHK5SATYM_cjs.ok(normalizeMergeOptions(optionsInput));
|
|
3357
3409
|
} catch (error) {
|
|
3358
|
-
return
|
|
3410
|
+
return chunkHK5SATYM_cjs.err(new MergeError("Invalid merge options.", { cause: error }));
|
|
3359
3411
|
}
|
|
3360
3412
|
}
|
|
3361
3413
|
async function resolveMerge(store, target, branches, options, useBaseSources, incremental, expectedBaseVersion) {
|
|
3362
3414
|
let targetBranchSeen = false;
|
|
3363
3415
|
for (const branch2 of branches) {
|
|
3364
3416
|
if (branch2.id === BASE_PROVENANCE_BRANCH) {
|
|
3365
|
-
return
|
|
3417
|
+
return chunkHK5SATYM_cjs.err(
|
|
3366
3418
|
new MergeError(
|
|
3367
3419
|
`Branch id "${BASE_PROVENANCE_BRANCH}" is reserved for committed-base provenance and cannot be used as a branch id.`,
|
|
3368
3420
|
{ details: { branchId: branch2.id } }
|
|
@@ -3371,7 +3423,7 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3371
3423
|
}
|
|
3372
3424
|
if (branch2.id === COMMITTED_TARGET_BRANCH) {
|
|
3373
3425
|
if (incremental?.targetBranchId !== COMMITTED_TARGET_BRANCH || targetBranchSeen) {
|
|
3374
|
-
return
|
|
3426
|
+
return chunkHK5SATYM_cjs.err(
|
|
3375
3427
|
new MergeError(
|
|
3376
3428
|
`Branch id "${COMMITTED_TARGET_BRANCH}" is reserved for the committed incremental target and cannot be used as a branch id.`,
|
|
3377
3429
|
{ details: { branchId: branch2.id } }
|
|
@@ -3382,8 +3434,8 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3382
3434
|
}
|
|
3383
3435
|
}
|
|
3384
3436
|
try {
|
|
3385
|
-
const staging = await stageBranches(store, branches);
|
|
3386
3437
|
const preferredBranchId = incremental?.targetBranchId;
|
|
3438
|
+
const staging = await stageBranches(store, branches, preferredBranchId);
|
|
3387
3439
|
const branchIds = branches.map((branch2) => branch2.id);
|
|
3388
3440
|
const branchOrder = preferredBranchId === void 0 ? options.branchOrder ?? [] : [
|
|
3389
3441
|
preferredBranchId,
|
|
@@ -3416,8 +3468,8 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3416
3468
|
useBaseSources,
|
|
3417
3469
|
options.embedder
|
|
3418
3470
|
);
|
|
3419
|
-
if (
|
|
3420
|
-
return
|
|
3471
|
+
if (chunkHK5SATYM_cjs.isErr(candidates)) {
|
|
3472
|
+
return chunkHK5SATYM_cjs.err(candidates.error);
|
|
3421
3473
|
}
|
|
3422
3474
|
const plan = planMerge(
|
|
3423
3475
|
staging,
|
|
@@ -3437,7 +3489,9 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3437
3489
|
// anything NEW the in-tx re-probe surfaces is a window write.
|
|
3438
3490
|
plannedBaseMatchKeys: new Set(
|
|
3439
3491
|
candidates.data.baseMembers.map((member) => mergeKeyOf(member))
|
|
3440
|
-
)
|
|
3492
|
+
),
|
|
3493
|
+
targetNodeVersions: staging.targetNodeVersions,
|
|
3494
|
+
targetEdgeSignatures: staging.targetEdgeSignatures
|
|
3441
3495
|
});
|
|
3442
3496
|
const provenance = options.provenance ? buildProvenanceIndex(plan.provenanceRecords) : { byBranch: () => ({ nodeIds: [], edgeIds: [] }) };
|
|
3443
3497
|
const warnings = [...plan.warnings];
|
|
@@ -3475,12 +3529,12 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3475
3529
|
warnings,
|
|
3476
3530
|
...provenancePersisted === void 0 ? {} : { provenancePersisted }
|
|
3477
3531
|
};
|
|
3478
|
-
return
|
|
3532
|
+
return chunkHK5SATYM_cjs.ok(report);
|
|
3479
3533
|
} catch (error) {
|
|
3480
3534
|
if (error instanceof MergeError) {
|
|
3481
|
-
return
|
|
3535
|
+
return chunkHK5SATYM_cjs.err(error);
|
|
3482
3536
|
}
|
|
3483
|
-
return
|
|
3537
|
+
return chunkHK5SATYM_cjs.err(
|
|
3484
3538
|
new MergeError(
|
|
3485
3539
|
`Merge failed while staging or committing: ${describeCause(error)}`,
|
|
3486
3540
|
{ cause: error }
|
|
@@ -3490,14 +3544,14 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3490
3544
|
}
|
|
3491
3545
|
async function merge(store, branches, optionsInput = {}) {
|
|
3492
3546
|
const normalized = tryNormalize(optionsInput);
|
|
3493
|
-
if (
|
|
3494
|
-
return
|
|
3547
|
+
if (chunkHK5SATYM_cjs.isErr(normalized)) {
|
|
3548
|
+
return chunkHK5SATYM_cjs.err(normalized.error);
|
|
3495
3549
|
}
|
|
3496
3550
|
const options = normalized.data;
|
|
3497
3551
|
const target = options.target ?? store;
|
|
3498
3552
|
const precondition = await validateBaseVersions(target, branches);
|
|
3499
|
-
if (
|
|
3500
|
-
return
|
|
3553
|
+
if (chunkHK5SATYM_cjs.isErr(precondition)) {
|
|
3554
|
+
return chunkHK5SATYM_cjs.err(precondition.error);
|
|
3501
3555
|
}
|
|
3502
3556
|
return resolveMerge(
|
|
3503
3557
|
store,
|
|
@@ -3513,7 +3567,7 @@ async function validateForkPointVersions(forkPoint, branches) {
|
|
|
3513
3567
|
const forkVersion = await computeBaseVersion(forkPoint);
|
|
3514
3568
|
for (const branch2 of branches) {
|
|
3515
3569
|
if (branch2.base !== forkVersion) {
|
|
3516
|
-
return
|
|
3570
|
+
return chunkHK5SATYM_cjs.err(
|
|
3517
3571
|
new BaseVersionMismatchError(
|
|
3518
3572
|
`Branch "${branch2.id}" forked from base@V "${branch2.base}", which does not match the fork-point's base@V "${forkVersion}". mergeIncremental() requires every branch to have forked from the supplied forkPoint.`,
|
|
3519
3573
|
{
|
|
@@ -3527,7 +3581,7 @@ async function validateForkPointVersions(forkPoint, branches) {
|
|
|
3527
3581
|
);
|
|
3528
3582
|
}
|
|
3529
3583
|
}
|
|
3530
|
-
return
|
|
3584
|
+
return chunkHK5SATYM_cjs.ok(forkVersion);
|
|
3531
3585
|
}
|
|
3532
3586
|
function nodeSchemaFor(target, kind) {
|
|
3533
3587
|
const registry = target.graph.nodes;
|
|
@@ -3738,7 +3792,7 @@ async function validateIncrementalEdgeWrites(target, edgesApi, plan) {
|
|
|
3738
3792
|
}
|
|
3739
3793
|
}
|
|
3740
3794
|
}
|
|
3741
|
-
const notFound = [...plannedKindById.keys()].filter((id) => !existingById.has(id)).sort((left, right) => compareStrings(left, right));
|
|
3795
|
+
const notFound = [...plannedKindById.keys()].filter((id) => !existingById.has(id)).sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
3742
3796
|
if (notFound.length > 0) {
|
|
3743
3797
|
const crossKindById = /* @__PURE__ */ new Map();
|
|
3744
3798
|
for (const kind of Object.keys(target.graph.edges)) {
|
|
@@ -3867,6 +3921,99 @@ async function assertBaseResolutionStable(lookupStore, guard) {
|
|
|
3867
3921
|
}
|
|
3868
3922
|
);
|
|
3869
3923
|
}
|
|
3924
|
+
function bucketInheritedRefsByKind(refs, identities) {
|
|
3925
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3926
|
+
const idsByKind = /* @__PURE__ */ new Map();
|
|
3927
|
+
for (const ref of refs) {
|
|
3928
|
+
const identity = mergeKey(ref.kind, ref.id);
|
|
3929
|
+
if (!identities.has(identity) || seen.has(identity)) {
|
|
3930
|
+
continue;
|
|
3931
|
+
}
|
|
3932
|
+
seen.add(identity);
|
|
3933
|
+
const bucket = idsByKind.get(ref.kind) ?? [];
|
|
3934
|
+
bucket.push(ref.id);
|
|
3935
|
+
idsByKind.set(ref.kind, bucket);
|
|
3936
|
+
}
|
|
3937
|
+
return idsByKind;
|
|
3938
|
+
}
|
|
3939
|
+
async function assertInheritedUnchanged(args) {
|
|
3940
|
+
if (args.expected.size === 0) {
|
|
3941
|
+
return;
|
|
3942
|
+
}
|
|
3943
|
+
const idsByKind = bucketInheritedRefsByKind(args.refs, args.expected);
|
|
3944
|
+
for (const [kind, ids] of idsByKind) {
|
|
3945
|
+
const rows = await args.fetchRows(kind, ids);
|
|
3946
|
+
for (const [index, id] of ids.entries()) {
|
|
3947
|
+
const expected = args.expected.get(mergeKey(kind, id));
|
|
3948
|
+
const current = args.deriveValue(rows[index]);
|
|
3949
|
+
if (current === expected) {
|
|
3950
|
+
continue;
|
|
3951
|
+
}
|
|
3952
|
+
throw args.buildError(id, kind, expected, current);
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
async function assertInheritedTargetUnchanged(nodesApi, edgesApi, guard, plan) {
|
|
3957
|
+
await Promise.all([
|
|
3958
|
+
assertInheritedNodesUnchanged(nodesApi, guard, plan),
|
|
3959
|
+
assertInheritedEdgesUnchanged(edgesApi, guard, plan)
|
|
3960
|
+
]);
|
|
3961
|
+
}
|
|
3962
|
+
async function assertInheritedNodesUnchanged(nodesApi, guard, plan) {
|
|
3963
|
+
const nodeRefs = plannedNodeWrites(plan).map(
|
|
3964
|
+
(write) => ({ kind: write.kind, id: write.id })
|
|
3965
|
+
);
|
|
3966
|
+
for (const [identity, kind] of plan.nodeDeletions) {
|
|
3967
|
+
nodeRefs.push({ kind, id: idOf(identity) });
|
|
3968
|
+
}
|
|
3969
|
+
await assertInheritedUnchanged({
|
|
3970
|
+
refs: nodeRefs,
|
|
3971
|
+
expected: guard.targetNodeVersions,
|
|
3972
|
+
fetchRows: (kind, ids) => nodeCollection(nodesApi, kind).getByIds(ids, INCLUDE_TOMBSTONES),
|
|
3973
|
+
deriveValue: (row) => row?.meta.version,
|
|
3974
|
+
buildError: (id, kind, expected, current) => new BaseVersionMismatchError(
|
|
3975
|
+
`mergeIncremental() observed committed node "${id}" (kind "${kind}") at version ${expected} while planning, but it changed before the commit transaction; the resolved plan no longer describes the live target and was not applied.`,
|
|
3976
|
+
{
|
|
3977
|
+
details: {
|
|
3978
|
+
id,
|
|
3979
|
+
kind,
|
|
3980
|
+
expectedVersion: expected,
|
|
3981
|
+
currentVersion: current
|
|
3982
|
+
},
|
|
3983
|
+
suggestion: "Re-run mergeIncremental(); the re-planned merge resolves the inherited modifications against the now-committed rows."
|
|
3984
|
+
}
|
|
3985
|
+
)
|
|
3986
|
+
});
|
|
3987
|
+
}
|
|
3988
|
+
async function assertInheritedEdgesUnchanged(edgesApi, guard, plan) {
|
|
3989
|
+
const edgeRefs = plan.mergedEdges.map((edge) => ({
|
|
3990
|
+
kind: edge.kind,
|
|
3991
|
+
id: edge.id
|
|
3992
|
+
}));
|
|
3993
|
+
for (const [identity, kind] of plan.edgeDeletions) {
|
|
3994
|
+
edgeRefs.push({ kind, id: idOf(identity) });
|
|
3995
|
+
}
|
|
3996
|
+
await assertInheritedUnchanged({
|
|
3997
|
+
refs: edgeRefs,
|
|
3998
|
+
expected: guard.targetEdgeSignatures,
|
|
3999
|
+
fetchRows: (kind, ids) => edgeCollection(edgesApi, kind).getByIds(ids, INCLUDE_TOMBSTONES),
|
|
4000
|
+
deriveValue: (row) => row === void 0 ? void 0 : edgeStateSignature({
|
|
4001
|
+
fromKind: row.fromKind,
|
|
4002
|
+
fromId: row.fromId,
|
|
4003
|
+
toKind: row.toKind,
|
|
4004
|
+
toId: row.toId,
|
|
4005
|
+
live: row.meta.deletedAt === void 0,
|
|
4006
|
+
props: edgeProps(row)
|
|
4007
|
+
}),
|
|
4008
|
+
buildError: (id, kind) => new BaseVersionMismatchError(
|
|
4009
|
+
`mergeIncremental() observed committed edge "${id}" (kind "${kind}") while planning, but its endpoints, liveness, or props changed before the commit transaction; the resolved plan no longer describes the live target and was not applied.`,
|
|
4010
|
+
{
|
|
4011
|
+
details: { id, kind },
|
|
4012
|
+
suggestion: "Re-run mergeIncremental(); the re-planned merge resolves the inherited modifications against the now-committed rows."
|
|
4013
|
+
}
|
|
4014
|
+
)
|
|
4015
|
+
});
|
|
4016
|
+
}
|
|
3870
4017
|
async function commitIncrementalPlan(target, plan, guard) {
|
|
3871
4018
|
if (!target.backend.capabilities.transactions) {
|
|
3872
4019
|
throw new MergeError(
|
|
@@ -3879,6 +4026,7 @@ async function commitIncrementalPlan(target, plan, guard) {
|
|
|
3879
4026
|
const nodesApi = tx.nodes;
|
|
3880
4027
|
const edgesApi = tx.edges;
|
|
3881
4028
|
await assertBaseResolutionStable(tx, guard);
|
|
4029
|
+
await assertInheritedTargetUnchanged(nodesApi, edgesApi, guard, plan);
|
|
3882
4030
|
await validateIncrementalNodeWrites(target, nodesApi, plan);
|
|
3883
4031
|
await validateIncrementalEdgeWrites(target, edgesApi, plan);
|
|
3884
4032
|
return applyMergePlan(plan, nodesApi, edgesApi);
|
|
@@ -3888,12 +4036,12 @@ async function commitIncrementalPlan(target, plan, guard) {
|
|
|
3888
4036
|
async function mergeIncremental(args) {
|
|
3889
4037
|
const { forkPoint, target, branches } = args;
|
|
3890
4038
|
const normalized = tryNormalize(args.options ?? {});
|
|
3891
|
-
if (
|
|
3892
|
-
return
|
|
4039
|
+
if (chunkHK5SATYM_cjs.isErr(normalized)) {
|
|
4040
|
+
return chunkHK5SATYM_cjs.err(normalized.error);
|
|
3893
4041
|
}
|
|
3894
4042
|
const options = normalized.data;
|
|
3895
4043
|
if (options.onBasePropertyConflict !== "flag") {
|
|
3896
|
-
return
|
|
4044
|
+
return chunkHK5SATYM_cjs.err(
|
|
3897
4045
|
new MergeError(
|
|
3898
4046
|
'mergeIncremental() requires onBasePropertyConflict: "flag" (keep-base); a non-keep-base policy could overwrite a newer committed base value with a stale branch value.',
|
|
3899
4047
|
{ details: {} }
|
|
@@ -3901,8 +4049,8 @@ async function mergeIncremental(args) {
|
|
|
3901
4049
|
);
|
|
3902
4050
|
}
|
|
3903
4051
|
const forkPrecondition = await validateForkPointVersions(forkPoint, branches);
|
|
3904
|
-
if (
|
|
3905
|
-
return
|
|
4052
|
+
if (chunkHK5SATYM_cjs.isErr(forkPrecondition)) {
|
|
4053
|
+
return chunkHK5SATYM_cjs.err(forkPrecondition.error);
|
|
3906
4054
|
}
|
|
3907
4055
|
const forkVersion = forkPrecondition.data;
|
|
3908
4056
|
const [forkSchema, targetSchema] = await Promise.all([
|
|
@@ -3910,7 +4058,7 @@ async function mergeIncremental(args) {
|
|
|
3910
4058
|
computeSchemaComponent(target)
|
|
3911
4059
|
]);
|
|
3912
4060
|
if (forkSchema !== targetSchema) {
|
|
3913
|
-
return
|
|
4061
|
+
return chunkHK5SATYM_cjs.err(
|
|
3914
4062
|
new MergeError(
|
|
3915
4063
|
"mergeIncremental() requires target and forkPoint to share a schema; schema drift is not supported (the target content may differ \u2014 only the schema must match).",
|
|
3916
4064
|
{ details: {} }
|
|
@@ -3934,15 +4082,15 @@ async function mergeIncremental(args) {
|
|
|
3934
4082
|
|
|
3935
4083
|
Object.defineProperty(exports, "isErr", {
|
|
3936
4084
|
enumerable: true,
|
|
3937
|
-
get: function () { return
|
|
4085
|
+
get: function () { return chunkHK5SATYM_cjs.isErr; }
|
|
3938
4086
|
});
|
|
3939
4087
|
Object.defineProperty(exports, "isOk", {
|
|
3940
4088
|
enumerable: true,
|
|
3941
|
-
get: function () { return
|
|
4089
|
+
get: function () { return chunkHK5SATYM_cjs.isOk; }
|
|
3942
4090
|
});
|
|
3943
4091
|
Object.defineProperty(exports, "unwrap", {
|
|
3944
4092
|
enumerable: true,
|
|
3945
|
-
get: function () { return
|
|
4093
|
+
get: function () { return chunkHK5SATYM_cjs.unwrap; }
|
|
3946
4094
|
});
|
|
3947
4095
|
exports.BaseVersionMismatchError = BaseVersionMismatchError;
|
|
3948
4096
|
exports.BranchError = BranchError;
|