@nicia-ai/typegraph 0.32.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 +51 -0
- package/dist/backend/postgres/index.cjs +36 -19
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +14 -9
- package/dist/backend/postgres/pglite.cjs +18 -13
- package/dist/backend/postgres/pglite.cjs.map +1 -1
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +14 -9
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +34 -17
- package/dist/backend/sqlite/index.d.cts +7 -7
- package/dist/backend/sqlite/index.d.ts +7 -7
- package/dist/backend/sqlite/index.js +13 -8
- package/dist/backend/sqlite/libsql.cjs +19 -14
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +12 -5
- package/dist/backend/sqlite/libsql.d.ts +12 -5
- package/dist/backend/sqlite/libsql.js +15 -10
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +19 -14
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +14 -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-2MRAX3UE.js +105 -0
- package/dist/chunk-2MRAX3UE.js.map +1 -0
- package/dist/{chunk-2LAT5BIK.cjs → chunk-3BRVBQQD.cjs} +2328 -3131
- package/dist/chunk-3BRVBQQD.cjs.map +1 -0
- package/dist/chunk-3E7SNSIA.cjs +55 -0
- package/dist/chunk-3E7SNSIA.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-IJORSAC3.js → chunk-4DIBPQNJ.js} +6 -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-LAZGHOZW.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-MXE2U3EX.js → chunk-BVTWD66D.js} +4 -115
- package/dist/chunk-BVTWD66D.js.map +1 -0
- package/dist/{chunk-W4ZX2GCP.js → chunk-CHXTTSC6.js} +5 -39
- package/dist/chunk-CHXTTSC6.js.map +1 -0
- package/dist/{chunk-XQFAJVYW.js → chunk-CYX2JTDG.js} +124 -5
- package/dist/chunk-CYX2JTDG.js.map +1 -0
- 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-2BVHPOIG.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-SB65GJNY.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-NDM5PXEH.js → chunk-LANHCOXB.js} +44 -11
- 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-RHZWOJVA.cjs +109 -0
- package/dist/chunk-RHZWOJVA.cjs.map +1 -0
- package/dist/{chunk-6RMLO5O4.cjs → chunk-RRKQAKD6.cjs} +13 -11
- package/dist/chunk-RRKQAKD6.cjs.map +1 -0
- package/dist/{chunk-TUA3MEJJ.js → chunk-RY2VIWAM.js} +612 -564
- 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-HFBRAOF7.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-EEYV6UOE.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-YL4F3CMD.cjs → chunk-TOTPVGOG.cjs} +105 -72
- package/dist/chunk-TOTPVGOG.cjs.map +1 -0
- package/dist/{chunk-3HQDMOBK.cjs → chunk-UJLOZYKT.cjs} +680 -636
- package/dist/chunk-UJLOZYKT.cjs.map +1 -0
- package/dist/chunk-UNNPKQUG.cjs +1390 -0
- 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-V3QNTB7Z.js +1351 -0
- 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-YQGLVWB2.cjs → chunk-WL2SG7ZV.cjs} +6 -122
- package/dist/chunk-WL2SG7ZV.cjs.map +1 -0
- package/dist/{chunk-WNORITK6.js → chunk-WLRIWYHQ.js} +2041 -2834
- package/dist/chunk-WLRIWYHQ.js.map +1 -0
- package/dist/{chunk-JKRKIEVA.cjs → chunk-WVC2Q2FD.cjs} +128 -6
- package/dist/chunk-WVC2Q2FD.cjs.map +1 -0
- package/dist/chunk-XLUNB2TZ.js +53 -0
- package/dist/chunk-XLUNB2TZ.js.map +1 -0
- 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-CAMMC3E4.cjs → chunk-ZP5WHI4C.cjs} +109 -81
- 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-7WW3WL6E.js → chunk-ZV5N4DBG.js} +49 -21
- 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-C8e8zDAE.d.ts → ddl-BrmPg61z.d.ts} +3 -3
- package/dist/{ddl-CwyG4HoQ.d.cts → ddl-j1-sH6lE.d.cts} +3 -3
- package/dist/{extension-types-D1k0inWU.d.cts → extension-types-YGFJPrzK.d.cts} +1 -1
- package/dist/{extension-types-D1k0inWU.d.ts → extension-types-YGFJPrzK.d.ts} +1 -1
- package/dist/graph-extension/index.cjs +18 -17
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +3 -2
- package/dist/graph-merge/index.cjs +295 -146
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +6 -6
- package/dist/graph-merge/index.d.ts +6 -6
- package/dist/graph-merge/index.js +173 -24
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-BEK0VtNB.d.ts → index-DGX6D9j1.d.ts} +2 -2
- package/dist/{index-C8sSTErx.d.cts → index-SEvUHDA6.d.cts} +2 -2
- package/dist/index.cjs +206 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -55
- package/dist/index.d.ts +25 -55
- package/dist/index.js +32 -22
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +28 -25
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +10 -7
- package/dist/interchange/index.cjs +25 -16
- package/dist/interchange/index.d.cts +5 -5
- package/dist/interchange/index.d.ts +5 -5
- package/dist/interchange/index.js +12 -3
- package/dist/{manager-8htmuGr-.d.ts → manager-BZUeN_BU.d.ts} +2 -2
- package/dist/{manager-aVgxbGt-.d.cts → manager-ms9cKdc6.d.cts} +2 -2
- package/dist/{materialize-indexes-CAGhqPHQ.d.ts → materialize-indexes-CAkIYFV-.d.ts} +1 -1
- package/dist/{materialize-indexes-DEYkU-wr.d.cts → materialize-indexes-D20xNluI.d.cts} +1 -1
- package/dist/{postgres-Dhom7iiX.d.ts → postgres-BhpxGMC5.d.cts} +2651 -596
- package/dist/{postgres-jgXmD45C.d.cts → postgres-CWHLwNl1.d.ts} +2651 -596
- package/dist/profiler/index.cjs +5 -4
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +3 -2
- package/dist/profiler/index.js.map +1 -1
- 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 +37 -32
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +14 -9
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-DcQ_BCUW.d.cts → sqlite-CGu5SLsw.d.ts} +2726 -455
- package/dist/{sqlite-BfLsCEqO.d.ts → sqlite-XrDxNaa7.d.cts} +2726 -455
- package/dist/{store-view-pBOUrQte.d.ts → store-view-BlgnhEYf.d.ts} +467 -131
- package/dist/{store-view-lTcb_cnp.d.cts → store-view-D09po4H6.d.cts} +467 -131
- package/dist/{types-DGDiXAYc.d.ts → types-B1TbZJYS.d.ts} +2 -2
- package/dist/{types-Dk8r09KY.d.ts → types-D1Sqeyxy.d.ts} +161 -26
- package/dist/{types-5RQwzWXx.d.cts → types-DiE1AO7p.d.cts} +2 -2
- package/dist/{types-Dvmn-eal.d.cts → types-DkNnF-7K.d.cts} +161 -26
- package/dist/{where-Cx_glEEB.d.cts → where-DKjuofPr.d.cts} +2 -2
- package/dist/{where-CHZFELX0.d.ts → where-DrUIIWHb.d.ts} +2 -2
- package/package.json +8 -2
- package/dist/chunk-2BVHPOIG.js.map +0 -1
- package/dist/chunk-2LAT5BIK.cjs.map +0 -1
- package/dist/chunk-2YMGNYXY.js +0 -40
- package/dist/chunk-2YMGNYXY.js.map +0 -1
- package/dist/chunk-3HQDMOBK.cjs.map +0 -1
- package/dist/chunk-454I6GDF.js.map +0 -1
- package/dist/chunk-6G35I3VW.cjs +0 -40
- package/dist/chunk-6G35I3VW.cjs.map +0 -1
- package/dist/chunk-6RMLO5O4.cjs.map +0 -1
- package/dist/chunk-6ZR4QC3O.cjs +0 -12
- package/dist/chunk-73KASJGO.cjs.map +0 -1
- package/dist/chunk-7WW3WL6E.js.map +0 -1
- package/dist/chunk-C4C4Q7A6.js.map +0 -1
- package/dist/chunk-CAMMC3E4.cjs.map +0 -1
- package/dist/chunk-CEF2QOTO.js.map +0 -1
- package/dist/chunk-CFNT3ITG.cjs.map +0 -1
- package/dist/chunk-EEYV6UOE.cjs.map +0 -1
- package/dist/chunk-FDN43KXV.cjs.map +0 -1
- package/dist/chunk-HFBRAOF7.js.map +0 -1
- package/dist/chunk-IJORSAC3.js.map +0 -1
- package/dist/chunk-JKRKIEVA.cjs.map +0 -1
- package/dist/chunk-KTIEB7VH.cjs.map +0 -1
- package/dist/chunk-LAZGHOZW.cjs.map +0 -1
- package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
- package/dist/chunk-M6OC455F.js +0 -65
- package/dist/chunk-M6OC455F.js.map +0 -1
- package/dist/chunk-MXE2U3EX.js.map +0 -1
- package/dist/chunk-NDM5PXEH.js.map +0 -1
- package/dist/chunk-PRMKPFN5.js.map +0 -1
- package/dist/chunk-RP7YITHX.cjs +0 -70
- package/dist/chunk-RP7YITHX.cjs.map +0 -1
- package/dist/chunk-SAJSMR2B.js +0 -35
- package/dist/chunk-SAJSMR2B.js.map +0 -1
- package/dist/chunk-SB65GJNY.cjs.map +0 -1
- package/dist/chunk-TUA3MEJJ.js.map +0 -1
- package/dist/chunk-W4ZX2GCP.js.map +0 -1
- package/dist/chunk-WNORITK6.js.map +0 -1
- package/dist/chunk-XKNAK27R.js.map +0 -1
- package/dist/chunk-XQFAJVYW.js.map +0 -1
- package/dist/chunk-YCV72E6L.js.map +0 -1
- package/dist/chunk-YL4F3CMD.cjs.map +0 -1
- package/dist/chunk-YQGLVWB2.cjs.map +0 -1
- package/dist/chunk-YW7GHMF4.cjs.map +0 -1
- package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
|
@@ -1,29 +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');
|
|
25
|
+
require('../chunk-3E7SNSIA.cjs');
|
|
26
|
+
require('../chunk-DI74SMXS.cjs');
|
|
17
27
|
var chunkJIEJCTDS_cjs = require('../chunk-JIEJCTDS.cjs');
|
|
18
28
|
require('../chunk-FLRCVI2G.cjs');
|
|
19
29
|
var zod = require('zod');
|
|
20
30
|
|
|
21
31
|
// src/graph-merge/canonical-props.ts
|
|
22
32
|
function canonicalizeProps(props) {
|
|
23
|
-
return JSON.stringify(props,
|
|
33
|
+
return JSON.stringify(props, chunkACSVZPK7_cjs.sortedReplacer);
|
|
24
34
|
}
|
|
25
35
|
function canonicalValueKey(value) {
|
|
26
|
-
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
|
+
]);
|
|
27
47
|
}
|
|
28
48
|
function parseRowProps(props) {
|
|
29
49
|
let parsed;
|
|
@@ -48,9 +68,6 @@ function mergeKey(kind, id) {
|
|
|
48
68
|
}
|
|
49
69
|
return `${kind}${SEPARATOR}${id}`;
|
|
50
70
|
}
|
|
51
|
-
function compareStrings(left, right) {
|
|
52
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
53
|
-
}
|
|
54
71
|
function mergeKeyOf(node) {
|
|
55
72
|
return mergeKey(node.kind, node.id);
|
|
56
73
|
}
|
|
@@ -224,15 +241,16 @@ function diffEdgeKind(kind, baseRows, forkRows) {
|
|
|
224
241
|
return { new: created, modified, deleted };
|
|
225
242
|
}
|
|
226
243
|
function byId(left, right) {
|
|
227
|
-
return compareStrings(left.id, right.id);
|
|
244
|
+
return chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id);
|
|
228
245
|
}
|
|
229
|
-
async function diffAgainstBase(baseStore, forkStore) {
|
|
246
|
+
async function diffAgainstBase(baseStore, forkStore, captureForkState = true) {
|
|
230
247
|
const graph = baseStore.graph;
|
|
231
|
-
const nodeKinds =
|
|
232
|
-
const edgeKinds =
|
|
248
|
+
const nodeKinds = chunkT6SPUYLX_cjs.getNodeKinds(graph);
|
|
249
|
+
const edgeKinds = chunkT6SPUYLX_cjs.getEdgeKinds(graph);
|
|
233
250
|
const newNodes = [];
|
|
234
251
|
const modifiedNodes = [];
|
|
235
252
|
const deletedNodes = [];
|
|
253
|
+
const forkNodeVersions = /* @__PURE__ */ new Map();
|
|
236
254
|
for (const kind of nodeKinds) {
|
|
237
255
|
const baseRows = await enumerateAllNodes(
|
|
238
256
|
baseStore.backend,
|
|
@@ -244,6 +262,11 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
244
262
|
forkStore.graphId,
|
|
245
263
|
kind
|
|
246
264
|
);
|
|
265
|
+
if (captureForkState) {
|
|
266
|
+
for (const row of forkRows) {
|
|
267
|
+
forkNodeVersions.set(mergeKey(kind, row.id), row.version);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
247
270
|
const delta = diffNodeKind(kind, baseRows, forkRows);
|
|
248
271
|
for (const entry of delta.new) {
|
|
249
272
|
newNodes.push(entry);
|
|
@@ -258,6 +281,7 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
258
281
|
const newEdges = [];
|
|
259
282
|
const modifiedEdges = [];
|
|
260
283
|
const deletedEdges = [];
|
|
284
|
+
const forkEdgeSignatures = /* @__PURE__ */ new Map();
|
|
261
285
|
for (const kind of edgeKinds) {
|
|
262
286
|
const baseRows = await enumerateAllEdges(
|
|
263
287
|
baseStore.backend,
|
|
@@ -269,6 +293,21 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
269
293
|
forkStore.graphId,
|
|
270
294
|
kind
|
|
271
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
|
+
}
|
|
272
311
|
const delta = diffEdgeKind(kind, baseRows, forkRows);
|
|
273
312
|
for (const entry of delta.new) {
|
|
274
313
|
newEdges.push(entry);
|
|
@@ -290,7 +329,9 @@ async function diffAgainstBase(baseStore, forkStore) {
|
|
|
290
329
|
new: newEdges.sort((left, right) => byId(left, right)),
|
|
291
330
|
modified: modifiedEdges.sort((left, right) => byId(left, right)),
|
|
292
331
|
deleted: deletedEdges.sort((left, right) => byId(left, right))
|
|
293
|
-
}
|
|
332
|
+
},
|
|
333
|
+
forkNodeVersions,
|
|
334
|
+
forkEdgeSignatures
|
|
294
335
|
};
|
|
295
336
|
}
|
|
296
337
|
|
|
@@ -311,16 +352,16 @@ async function readActiveSchemaVersion(backend, graphId) {
|
|
|
311
352
|
}
|
|
312
353
|
async function computeSchemaComponent(store) {
|
|
313
354
|
const version = await readActiveSchemaVersion(store.backend, store.graphId);
|
|
314
|
-
return
|
|
355
|
+
return chunk6HVOHZHS_cjs.computeSchemaHash(chunk6HVOHZHS_cjs.serializeSchema(store.graph, version));
|
|
315
356
|
}
|
|
316
357
|
function byDigestEntry(left, right) {
|
|
317
|
-
const byKind = compareStrings(left.kind, right.kind);
|
|
318
|
-
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;
|
|
319
360
|
}
|
|
320
361
|
var CONTENT_FINGERPRINT_BYTES = 16;
|
|
321
362
|
async function computeContentComponent(backend, graphId, graph) {
|
|
322
|
-
const nodeKinds =
|
|
323
|
-
const edgeKinds =
|
|
363
|
+
const nodeKinds = chunkT6SPUYLX_cjs.getNodeKinds(graph);
|
|
364
|
+
const edgeKinds = chunkT6SPUYLX_cjs.getEdgeKinds(graph);
|
|
324
365
|
const nodeDigest = [];
|
|
325
366
|
for (const kind of nodeKinds) {
|
|
326
367
|
const rows = await enumerateAllNodes(backend, graphId, kind);
|
|
@@ -355,7 +396,7 @@ async function computeContentComponent(backend, graphId, graph) {
|
|
|
355
396
|
}
|
|
356
397
|
}
|
|
357
398
|
}
|
|
358
|
-
return
|
|
399
|
+
return chunkZY4GXIVN_cjs.sha256Hex(
|
|
359
400
|
canonicalizeProps({
|
|
360
401
|
nodes: nodeDigest.sort((left, right) => byDigestEntry(left, right)),
|
|
361
402
|
edges: edgeDigest.sort((left, right) => byDigestEntry(left, right))
|
|
@@ -446,17 +487,17 @@ var CLONE_IMPORT_BATCH_SIZE = 1e3;
|
|
|
446
487
|
function cloneWorkingCopyStrategy(makeBackend) {
|
|
447
488
|
return {
|
|
448
489
|
create: async (baseStore) => {
|
|
449
|
-
const data = await
|
|
490
|
+
const data = await chunkKNHYNQQ3_cjs.exportGraph(baseStore, {
|
|
450
491
|
includeMeta: true,
|
|
451
492
|
includeDeleted: false
|
|
452
493
|
});
|
|
453
494
|
const backend = await makeBackend();
|
|
454
495
|
try {
|
|
455
|
-
const [freshStore] = await
|
|
496
|
+
const [freshStore] = await chunk3BRVBQQD_cjs.createStoreWithSchema(
|
|
456
497
|
baseStore.graph,
|
|
457
498
|
backend
|
|
458
499
|
);
|
|
459
|
-
const result = await
|
|
500
|
+
const result = await chunkKNHYNQQ3_cjs.importGraph(freshStore, data, {
|
|
460
501
|
onConflict: "error",
|
|
461
502
|
onUnknownProperty: "error",
|
|
462
503
|
validateReferences: true,
|
|
@@ -484,12 +525,12 @@ function cloneWorkingCopyStrategy(makeBackend) {
|
|
|
484
525
|
async function branch(baseStore, makeBackend, options, strategy) {
|
|
485
526
|
try {
|
|
486
527
|
const base = await computeBaseVersion(baseStore);
|
|
487
|
-
const id = options?.id ?? asBranchId(
|
|
528
|
+
const id = options?.id ?? asBranchId(chunk5IQIX7LU_cjs.generateId());
|
|
488
529
|
const workingCopyStrategy = strategy ?? cloneWorkingCopyStrategy(makeBackend);
|
|
489
530
|
const store = await workingCopyStrategy.create(baseStore);
|
|
490
|
-
return
|
|
531
|
+
return chunkHK5SATYM_cjs.ok({ id, base, store });
|
|
491
532
|
} catch (error) {
|
|
492
|
-
return
|
|
533
|
+
return chunkHK5SATYM_cjs.err(
|
|
493
534
|
new BranchError("Failed to create working-copy branch of base store", {
|
|
494
535
|
cause: error
|
|
495
536
|
})
|
|
@@ -513,7 +554,7 @@ function constraintSignature(node, constraint) {
|
|
|
513
554
|
return void 0;
|
|
514
555
|
}
|
|
515
556
|
}
|
|
516
|
-
return `${constraint.name}${KEY_PART_SEPARATOR}${
|
|
557
|
+
return `${constraint.name}${KEY_PART_SEPARATOR}${chunk5IQIX7LU_cjs.computeUniqueKey(
|
|
517
558
|
props,
|
|
518
559
|
constraint.fields,
|
|
519
560
|
constraint.collation
|
|
@@ -550,12 +591,12 @@ function blockNodes(newNodes, resolveConfig, uniqueConstraints = []) {
|
|
|
550
591
|
}
|
|
551
592
|
}
|
|
552
593
|
const sortedKeys = [...buckets.keys()].sort(
|
|
553
|
-
(left, right) => compareStrings(left, right)
|
|
594
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
554
595
|
);
|
|
555
596
|
const ordered = /* @__PURE__ */ new Map();
|
|
556
597
|
for (const key of sortedKeys) {
|
|
557
598
|
const members = [...buckets.get(key)].sort(
|
|
558
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
599
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
559
600
|
);
|
|
560
601
|
ordered.set(key, members);
|
|
561
602
|
}
|
|
@@ -572,7 +613,7 @@ function buildBranchRank(branchOrder, allBranchIds) {
|
|
|
572
613
|
next += 1;
|
|
573
614
|
}
|
|
574
615
|
}
|
|
575
|
-
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));
|
|
576
617
|
for (const branchId of remaining) {
|
|
577
618
|
if (!rank.has(branchId)) {
|
|
578
619
|
rank.set(branchId, next);
|
|
@@ -644,8 +685,8 @@ function collectConflictingValues(property, contributions) {
|
|
|
644
685
|
values.push({ branchId, value });
|
|
645
686
|
}
|
|
646
687
|
return [...values].sort((left, right) => {
|
|
647
|
-
const byBranch = compareStrings(left.branchId, right.branchId);
|
|
648
|
-
return byBranch === 0 ? compareStrings(
|
|
688
|
+
const byBranch = chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId);
|
|
689
|
+
return byBranch === 0 ? chunkZ5HBYM7U_cjs.compareStrings(
|
|
649
690
|
canonicalValueKey(left.value),
|
|
650
691
|
canonicalValueKey(right.value)
|
|
651
692
|
) : byBranch;
|
|
@@ -772,7 +813,7 @@ function unionProperties(canonicalMember, members, context, baseContext, branchR
|
|
|
772
813
|
const props = {};
|
|
773
814
|
const conflicts = [];
|
|
774
815
|
for (const property of [...propertyNames].sort(
|
|
775
|
-
(left, right) => compareStrings(left, right)
|
|
816
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
776
817
|
)) {
|
|
777
818
|
const values = collectConflictingValues(property, members);
|
|
778
819
|
if (values.length === 0) {
|
|
@@ -837,14 +878,14 @@ function canonicalizeCluster(cluster, members, policy, branchRank, weights, cano
|
|
|
837
878
|
);
|
|
838
879
|
const memberIds = [
|
|
839
880
|
...new Set(cluster.members.map((member) => idOf(member)))
|
|
840
|
-
].sort((left, right) => compareStrings(left, right));
|
|
881
|
+
].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
841
882
|
const branchOrigins = [
|
|
842
883
|
...new Set(
|
|
843
884
|
members.map((member) => member.branchId).filter(
|
|
844
885
|
(branchId) => branchId !== BASE_PROVENANCE_BRANCH && branchId !== preferredBranchId
|
|
845
886
|
)
|
|
846
887
|
)
|
|
847
|
-
].sort((left, right) => compareStrings(left, right));
|
|
888
|
+
].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
848
889
|
const resolution = {
|
|
849
890
|
canonicalId,
|
|
850
891
|
memberIds,
|
|
@@ -904,7 +945,7 @@ var UnionFind = class {
|
|
|
904
945
|
var SUB_CLASS_OF_META_EDGE = "subClassOf";
|
|
905
946
|
var EQUIVALENT_TO_META_EDGE = "equivalentTo";
|
|
906
947
|
function buildSubClassClosure(ontology) {
|
|
907
|
-
const unionFind = new UnionFind(compareStrings);
|
|
948
|
+
const unionFind = new UnionFind(chunkZ5HBYM7U_cjs.compareStrings);
|
|
908
949
|
for (const relation of ontology) {
|
|
909
950
|
unionFind.add(relation.from);
|
|
910
951
|
unionFind.add(relation.to);
|
|
@@ -935,7 +976,7 @@ function buildSubClassClosure(ontology) {
|
|
|
935
976
|
relations.push([child, parent]);
|
|
936
977
|
}
|
|
937
978
|
return {
|
|
938
|
-
closure:
|
|
979
|
+
closure: chunkHK5SATYM_cjs.computeTransitiveClosure(relations),
|
|
939
980
|
canonicalOf
|
|
940
981
|
};
|
|
941
982
|
}
|
|
@@ -948,7 +989,7 @@ function isReachable2(closure, from, to) {
|
|
|
948
989
|
if (fromRep === toRep) {
|
|
949
990
|
return from !== to;
|
|
950
991
|
}
|
|
951
|
-
return
|
|
992
|
+
return chunkHK5SATYM_cjs.isReachable(closure.closure, fromRep, toRep);
|
|
952
993
|
}
|
|
953
994
|
|
|
954
995
|
// src/graph-merge/similarity.ts
|
|
@@ -1131,37 +1172,37 @@ function scorePrepared(left, right, strategy, ctx) {
|
|
|
1131
1172
|
switch (strategy.kind) {
|
|
1132
1173
|
case "custom": {
|
|
1133
1174
|
const raw = strategy.score(left.node, right.node);
|
|
1134
|
-
return
|
|
1175
|
+
return chunkHK5SATYM_cjs.ok(clampScore(raw));
|
|
1135
1176
|
}
|
|
1136
1177
|
case "fulltext": {
|
|
1137
1178
|
if (left.text.length === 0 || right.text.length === 0) {
|
|
1138
|
-
return
|
|
1179
|
+
return chunkHK5SATYM_cjs.ok(NO_EVIDENCE_SCORE);
|
|
1139
1180
|
}
|
|
1140
|
-
return
|
|
1181
|
+
return chunkHK5SATYM_cjs.ok(clampScore(diceFromMultisets(left.grams, right.grams)));
|
|
1141
1182
|
}
|
|
1142
1183
|
case "vector": {
|
|
1143
1184
|
if (ctx.embeddings === void 0) {
|
|
1144
|
-
return
|
|
1185
|
+
return chunkHK5SATYM_cjs.err(embedderUnavailable("vector", ctx));
|
|
1145
1186
|
}
|
|
1146
1187
|
if (left.text.length === 0 || right.text.length === 0) {
|
|
1147
|
-
return
|
|
1188
|
+
return chunkHK5SATYM_cjs.ok(NO_EVIDENCE_SCORE);
|
|
1148
1189
|
}
|
|
1149
1190
|
const cosine = cosineFromLookup(ctx.embeddings, left.text, right.text);
|
|
1150
|
-
return
|
|
1191
|
+
return chunkHK5SATYM_cjs.ok(clampScore(cosine));
|
|
1151
1192
|
}
|
|
1152
1193
|
case "hybrid": {
|
|
1153
1194
|
if (ctx.embeddings === void 0) {
|
|
1154
|
-
return
|
|
1195
|
+
return chunkHK5SATYM_cjs.err(embedderUnavailable("hybrid", ctx));
|
|
1155
1196
|
}
|
|
1156
1197
|
if (left.text.length === 0 || right.text.length === 0) {
|
|
1157
|
-
return
|
|
1198
|
+
return chunkHK5SATYM_cjs.ok(NO_EVIDENCE_SCORE);
|
|
1158
1199
|
}
|
|
1159
1200
|
const vectorScore = clampScore(
|
|
1160
1201
|
cosineFromLookup(ctx.embeddings, left.text, right.text)
|
|
1161
1202
|
);
|
|
1162
1203
|
const fulltextScore = diceFromMultisets(left.grams, right.grams);
|
|
1163
1204
|
const weights = normalizeHybridWeights(strategy.weights);
|
|
1164
|
-
return
|
|
1205
|
+
return chunkHK5SATYM_cjs.ok(
|
|
1165
1206
|
clampScore(
|
|
1166
1207
|
weights.vector * vectorScore + weights.fulltext * fulltextScore
|
|
1167
1208
|
)
|
|
@@ -1219,7 +1260,7 @@ function scoreCandidates(input, resolveConfig, ctx, ceilingPolicy, maxComparison
|
|
|
1219
1260
|
}
|
|
1220
1261
|
if (maxComparisonsPerKind !== void 0 && fuzzy.length > maxComparisonsPerKind) {
|
|
1221
1262
|
if (ceilingPolicy === "error") {
|
|
1222
|
-
return
|
|
1263
|
+
return chunkHK5SATYM_cjs.err(
|
|
1223
1264
|
new MergeError(
|
|
1224
1265
|
`Comparison ceiling exceeded: ${fuzzy.length} candidate pairs > maxComparisonsPerKind ${maxComparisonsPerKind}.`,
|
|
1225
1266
|
{
|
|
@@ -1232,7 +1273,7 @@ function scoreCandidates(input, resolveConfig, ctx, ceilingPolicy, maxComparison
|
|
|
1232
1273
|
)
|
|
1233
1274
|
);
|
|
1234
1275
|
}
|
|
1235
|
-
return
|
|
1276
|
+
return chunkHK5SATYM_cjs.ok({
|
|
1236
1277
|
edges: [...forced].sort(
|
|
1237
1278
|
(left, right) => compareCandidateEdges(left, right)
|
|
1238
1279
|
),
|
|
@@ -1250,14 +1291,14 @@ function scoreCandidates(input, resolveConfig, ctx, ceilingPolicy, maxComparison
|
|
|
1250
1291
|
const edges = [...forced];
|
|
1251
1292
|
for (const { left, right, a, b } of fuzzy) {
|
|
1252
1293
|
const scored = scorer(a, left, b, right);
|
|
1253
|
-
if (
|
|
1254
|
-
return
|
|
1294
|
+
if (chunkHK5SATYM_cjs.isErr(scored)) {
|
|
1295
|
+
return chunkHK5SATYM_cjs.err(scored.error);
|
|
1255
1296
|
}
|
|
1256
1297
|
if (scored.data >= threshold) {
|
|
1257
1298
|
edges.push({ a, b, score: scored.data });
|
|
1258
1299
|
}
|
|
1259
1300
|
}
|
|
1260
|
-
return
|
|
1301
|
+
return chunkHK5SATYM_cjs.ok({
|
|
1261
1302
|
edges: edges.sort((left, right) => compareCandidateEdges(left, right)),
|
|
1262
1303
|
warnings: []
|
|
1263
1304
|
});
|
|
@@ -1467,7 +1508,7 @@ function pickHighestPriorityBranch(branchIds, branchRank) {
|
|
|
1467
1508
|
let chosenRank = branchRank.get(chosen) ?? Number.MAX_SAFE_INTEGER;
|
|
1468
1509
|
for (const candidate of branchIds.slice(1)) {
|
|
1469
1510
|
const candidateRank = branchRank.get(candidate) ?? Number.MAX_SAFE_INTEGER;
|
|
1470
|
-
if (candidateRank < chosenRank || candidateRank === chosenRank && compareStrings(candidate, chosen) < 0) {
|
|
1511
|
+
if (candidateRank < chosenRank || candidateRank === chosenRank && chunkZ5HBYM7U_cjs.compareStrings(candidate, chosen) < 0) {
|
|
1471
1512
|
chosen = candidate;
|
|
1472
1513
|
chosenRank = candidateRank;
|
|
1473
1514
|
}
|
|
@@ -1560,20 +1601,20 @@ function resolveDeleteModifyOver(modified, deleted, modifiedEntity, deletedEntit
|
|
|
1560
1601
|
}
|
|
1561
1602
|
return {
|
|
1562
1603
|
survivingModifications: [...survivingModifications].sort((left, right) => {
|
|
1563
|
-
const byId2 = compareStrings(
|
|
1604
|
+
const byId2 = chunkZ5HBYM7U_cjs.compareStrings(
|
|
1564
1605
|
modifiedEntity(left).id,
|
|
1565
1606
|
modifiedEntity(right).id
|
|
1566
1607
|
);
|
|
1567
|
-
return byId2 === 0 ? compareStrings(left.branchId, right.branchId) : byId2;
|
|
1608
|
+
return byId2 === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.branchId, right.branchId) : byId2;
|
|
1568
1609
|
}),
|
|
1569
1610
|
deletions: [...deletions].sort(
|
|
1570
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
1611
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
1571
1612
|
),
|
|
1572
1613
|
conflicts: [...conflicts].sort(
|
|
1573
|
-
(left, right) => compareStrings(left.entityId, right.entityId)
|
|
1614
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.entityId, right.entityId)
|
|
1574
1615
|
),
|
|
1575
1616
|
dropped: [...dropped].sort(
|
|
1576
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
1617
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
1577
1618
|
)
|
|
1578
1619
|
};
|
|
1579
1620
|
}
|
|
@@ -1617,11 +1658,11 @@ function reconcileOver(survivingModifications, entityOf, rebuild, policy, branch
|
|
|
1617
1658
|
}
|
|
1618
1659
|
return {
|
|
1619
1660
|
survivingModifications: [...out].sort((left, right) => {
|
|
1620
|
-
const byId2 = compareStrings(entityOf(left).id, entityOf(right).id);
|
|
1621
|
-
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;
|
|
1622
1663
|
}),
|
|
1623
1664
|
conflicts: conflicts.sort(
|
|
1624
|
-
(left, right) => compareStrings(
|
|
1665
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(
|
|
1625
1666
|
`${left.entityId}|${left.property}`,
|
|
1626
1667
|
`${right.entityId}|${right.property}`
|
|
1627
1668
|
)
|
|
@@ -1655,7 +1696,7 @@ function threeWayMergeProps(entityId, kind, baseProps, contributions, context, b
|
|
|
1655
1696
|
propertyNames.add(name);
|
|
1656
1697
|
}
|
|
1657
1698
|
}
|
|
1658
|
-
for (const property of [...propertyNames].sort(compareStrings)) {
|
|
1699
|
+
for (const property of [...propertyNames].sort(chunkZ5HBYM7U_cjs.compareStrings)) {
|
|
1659
1700
|
const baseHas = property in baseProps;
|
|
1660
1701
|
const baseKey = baseHas ? canonicalValueKey(baseProps[property]) : void 0;
|
|
1661
1702
|
const changed = contributions.filter((contribution) => {
|
|
@@ -1792,7 +1833,7 @@ function unionEdgeProps(survivorId, kind, survivor, edges, context, branchRank,
|
|
|
1792
1833
|
const conflicts = [];
|
|
1793
1834
|
const contributions = edges.map((edge) => edge.staged);
|
|
1794
1835
|
for (const property of [...propertyNames].sort(
|
|
1795
|
-
(left, right) => compareStrings(left, right)
|
|
1836
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
1796
1837
|
)) {
|
|
1797
1838
|
const values = collectConflictingValues(property, contributions);
|
|
1798
1839
|
if (values.length === 0) {
|
|
@@ -1861,7 +1902,7 @@ function repointEdges(stagedEdges, canonicalOf, deletedNodeIds, policy, branchRa
|
|
|
1861
1902
|
const merged = [];
|
|
1862
1903
|
const conflicts = [];
|
|
1863
1904
|
const sortedGroups = [...dedupeKeyByGroup.keys()].sort(
|
|
1864
|
-
(left, right) => compareStrings(left, right)
|
|
1905
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
1865
1906
|
);
|
|
1866
1907
|
for (const group of sortedGroups) {
|
|
1867
1908
|
const dedupeKeys = [...dedupeKeyByGroup.get(group)];
|
|
@@ -1873,7 +1914,7 @@ function repointEdges(stagedEdges, canonicalOf, deletedNodeIds, policy, branchRa
|
|
|
1873
1914
|
}
|
|
1874
1915
|
const survivor = pickSurvivor(groupEdges, preferredBranchId);
|
|
1875
1916
|
const survivorId = survivor.staged.id;
|
|
1876
|
-
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));
|
|
1877
1918
|
const fromId = idOf(survivor.fromKey);
|
|
1878
1919
|
const fromKind = kindOf(survivor.fromKey);
|
|
1879
1920
|
const toId = idOf(survivor.toKey);
|
|
@@ -1922,12 +1963,12 @@ function repointEdges(stagedEdges, canonicalOf, deletedNodeIds, policy, branchRa
|
|
|
1922
1963
|
mergeKey(edge.toKind, edge.toId),
|
|
1923
1964
|
edge.props
|
|
1924
1965
|
)
|
|
1925
|
-
})).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);
|
|
1926
1967
|
return {
|
|
1927
1968
|
edges: sortedEdges,
|
|
1928
|
-
dropped: dropped.sort((left, right) => compareStrings(left.id, right.id)),
|
|
1969
|
+
dropped: dropped.sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)),
|
|
1929
1970
|
conflicts: conflicts.sort(
|
|
1930
|
-
(left, right) => compareStrings(
|
|
1971
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(
|
|
1931
1972
|
`${left.entityId}|${left.property}`,
|
|
1932
1973
|
`${right.entityId}|${right.property}`
|
|
1933
1974
|
)
|
|
@@ -2056,7 +2097,7 @@ function normalizeMergeOptions(options = {}) {
|
|
|
2056
2097
|
...provenanceWeights === void 0 ? {} : { provenanceWeights }
|
|
2057
2098
|
};
|
|
2058
2099
|
}
|
|
2059
|
-
var Provenance =
|
|
2100
|
+
var Provenance = chunk6HVOHZHS_cjs.defineNode("Provenance", {
|
|
2060
2101
|
schema: zod.z.object({
|
|
2061
2102
|
targetGraphId: zod.z.string(),
|
|
2062
2103
|
role: zod.z.enum(["node", "edge"]),
|
|
@@ -2070,14 +2111,14 @@ function provenanceGraphId(targetGraphId) {
|
|
|
2070
2111
|
return `${targetGraphId}::merge-provenance`;
|
|
2071
2112
|
}
|
|
2072
2113
|
function buildProvenanceGraph(targetGraphId) {
|
|
2073
|
-
return
|
|
2114
|
+
return chunkT6SPUYLX_cjs.defineGraph({
|
|
2074
2115
|
id: provenanceGraphId(targetGraphId),
|
|
2075
2116
|
nodes: { Provenance: { type: Provenance } },
|
|
2076
2117
|
edges: {}
|
|
2077
2118
|
});
|
|
2078
2119
|
}
|
|
2079
2120
|
async function openProvenanceStore(backend, targetGraphId) {
|
|
2080
|
-
const [store] = await
|
|
2121
|
+
const [store] = await chunk3BRVBQQD_cjs.createStoreWithSchema(
|
|
2081
2122
|
buildProvenanceGraph(targetGraphId),
|
|
2082
2123
|
backend
|
|
2083
2124
|
);
|
|
@@ -2097,7 +2138,7 @@ async function provenanceNodeId(targetGraphId, record) {
|
|
|
2097
2138
|
record.branchId,
|
|
2098
2139
|
record.sourceId
|
|
2099
2140
|
].join(ID_SEPARATOR);
|
|
2100
|
-
const digest = await
|
|
2141
|
+
const digest = await chunkZY4GXIVN_cjs.sha256Hex(tuple, ID_DIGEST_BYTES);
|
|
2101
2142
|
return `prov_${digest}`;
|
|
2102
2143
|
}
|
|
2103
2144
|
async function persistProvenanceRecords(store, targetGraphId, records) {
|
|
@@ -2124,7 +2165,7 @@ async function readProvenance(store, query = {}) {
|
|
|
2124
2165
|
const all = await store.nodes.Provenance.find();
|
|
2125
2166
|
return all.filter(
|
|
2126
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)
|
|
2127
|
-
).sort((left, right) => compareStrings(left.id, right.id));
|
|
2168
|
+
).sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id));
|
|
2128
2169
|
}
|
|
2129
2170
|
|
|
2130
2171
|
// src/graph-merge/sources.ts
|
|
@@ -2134,10 +2175,10 @@ function orderEndpoints(left, right) {
|
|
|
2134
2175
|
return compareMergeKeys(leftKey, rightKey) <= 0 ? { a: leftKey, b: rightKey, left, right } : { a: rightKey, b: leftKey, left: right, right: left };
|
|
2135
2176
|
}
|
|
2136
2177
|
function sortMembersById(members) {
|
|
2137
|
-
return [...members].sort((left, right) => compareStrings(left.id, right.id));
|
|
2178
|
+
return [...members].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id));
|
|
2138
2179
|
}
|
|
2139
2180
|
function sortedBucketKeys(blocks) {
|
|
2140
|
-
return [...blocks.keys()].sort((left, right) => compareStrings(left, right));
|
|
2181
|
+
return [...blocks.keys()].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
2141
2182
|
}
|
|
2142
2183
|
var NODE_SYSTEM_FIELDS = /* @__PURE__ */ new Set(["id", "kind", "meta"]);
|
|
2143
2184
|
function nodeProps(node) {
|
|
@@ -2165,7 +2206,7 @@ function windowedPairs(members, config) {
|
|
|
2165
2206
|
key: fieldText(node, config.sortFields)
|
|
2166
2207
|
}));
|
|
2167
2208
|
keyed.sort(
|
|
2168
|
-
(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)
|
|
2169
2210
|
);
|
|
2170
2211
|
const pairs = [];
|
|
2171
2212
|
for (let index = 0; index < keyed.length; index += 1) {
|
|
@@ -2223,7 +2264,7 @@ function ontologyRetypeEdges(stagedIdentities, isRetypeCompatible) {
|
|
|
2223
2264
|
}
|
|
2224
2265
|
}
|
|
2225
2266
|
const edges = [];
|
|
2226
|
-
for (const id of [...identitiesById.keys()].sort(compareStrings)) {
|
|
2267
|
+
for (const id of [...identitiesById.keys()].sort(chunkZ5HBYM7U_cjs.compareStrings)) {
|
|
2227
2268
|
const identities = [...new Set(identitiesById.get(id))].sort(
|
|
2228
2269
|
compareMergeKeys
|
|
2229
2270
|
);
|
|
@@ -2315,7 +2356,7 @@ var baseUniqueSource = {
|
|
|
2315
2356
|
const forcedEdges = [];
|
|
2316
2357
|
const baseMembers = /* @__PURE__ */ new Map();
|
|
2317
2358
|
const constraints = [...uniqueConstraints].sort(
|
|
2318
|
-
(left, right) => compareStrings(left.name, right.name)
|
|
2359
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.name, right.name)
|
|
2319
2360
|
);
|
|
2320
2361
|
const items = nodes.map((node) => ({ props: nodeProps(node) }));
|
|
2321
2362
|
const matchesByConstraint = await Promise.all(
|
|
@@ -2358,7 +2399,7 @@ var baseUniqueSource = {
|
|
|
2358
2399
|
pairs: [],
|
|
2359
2400
|
forcedEdges,
|
|
2360
2401
|
baseMembers: [...baseMembers.values()].sort(
|
|
2361
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
2402
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
2362
2403
|
)
|
|
2363
2404
|
};
|
|
2364
2405
|
}
|
|
@@ -2415,7 +2456,7 @@ var baseKeySource = {
|
|
|
2415
2456
|
pairs,
|
|
2416
2457
|
forcedEdges: [],
|
|
2417
2458
|
baseMembers: [...baseMembers.values()].sort(
|
|
2418
|
-
(left, right) => compareStrings(left.id, right.id)
|
|
2459
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id)
|
|
2419
2460
|
)
|
|
2420
2461
|
};
|
|
2421
2462
|
}
|
|
@@ -2427,16 +2468,16 @@ var CANDIDATE_SOURCES = [
|
|
|
2427
2468
|
|
|
2428
2469
|
// src/graph-merge/staging.ts
|
|
2429
2470
|
function compareByIdThenBranch(left, right) {
|
|
2430
|
-
const byId2 = compareStrings(left.id, right.id);
|
|
2431
|
-
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;
|
|
2432
2473
|
}
|
|
2433
2474
|
function compareByKindIdBranch(left, right) {
|
|
2434
|
-
const byKind = compareStrings(left.kind, right.kind);
|
|
2475
|
+
const byKind = chunkZ5HBYM7U_cjs.compareStrings(left.kind, right.kind);
|
|
2435
2476
|
if (byKind !== 0) {
|
|
2436
2477
|
return byKind;
|
|
2437
2478
|
}
|
|
2438
|
-
const byId2 = compareStrings(left.id, right.id);
|
|
2439
|
-
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;
|
|
2440
2481
|
}
|
|
2441
2482
|
function groupByKind(items) {
|
|
2442
2483
|
const buckets = /* @__PURE__ */ new Map();
|
|
@@ -2450,7 +2491,7 @@ function groupByKind(items) {
|
|
|
2450
2491
|
}
|
|
2451
2492
|
const ordered = /* @__PURE__ */ new Map();
|
|
2452
2493
|
for (const kind of [...buckets.keys()].sort(
|
|
2453
|
-
(left, right) => compareStrings(left, right)
|
|
2494
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2454
2495
|
)) {
|
|
2455
2496
|
ordered.set(
|
|
2456
2497
|
kind,
|
|
@@ -2461,16 +2502,26 @@ function groupByKind(items) {
|
|
|
2461
2502
|
}
|
|
2462
2503
|
return ordered;
|
|
2463
2504
|
}
|
|
2464
|
-
async function stageBranches(baseStore, branches) {
|
|
2505
|
+
async function stageBranches(baseStore, branches, captureTargetStateFor) {
|
|
2465
2506
|
const newNodes = [];
|
|
2466
2507
|
const modifiedNodes = [];
|
|
2467
2508
|
const deletedNodes = [];
|
|
2468
2509
|
const newEdges = [];
|
|
2469
2510
|
const modifiedEdges = [];
|
|
2470
2511
|
const deletedEdges = [];
|
|
2512
|
+
let targetNodeVersions = /* @__PURE__ */ new Map();
|
|
2513
|
+
let targetEdgeSignatures = /* @__PURE__ */ new Map();
|
|
2471
2514
|
for (const branch2 of branches) {
|
|
2472
|
-
const diff = await diffAgainstBase(baseStore, branch2.store);
|
|
2473
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
|
+
}
|
|
2474
2525
|
for (const node of diff.nodes.new) {
|
|
2475
2526
|
newNodes.push({ branchId, node, kind: node.kind, id: node.id });
|
|
2476
2527
|
}
|
|
@@ -2504,7 +2555,9 @@ async function stageBranches(baseStore, branches) {
|
|
|
2504
2555
|
),
|
|
2505
2556
|
deletedEdges: [...deletedEdges].sort(
|
|
2506
2557
|
(left, right) => compareByKindIdBranch(left, right)
|
|
2507
|
-
)
|
|
2558
|
+
),
|
|
2559
|
+
targetNodeVersions,
|
|
2560
|
+
targetEdgeSignatures
|
|
2508
2561
|
};
|
|
2509
2562
|
}
|
|
2510
2563
|
|
|
@@ -2553,7 +2606,7 @@ async function withTxConflictRetry(commit) {
|
|
|
2553
2606
|
// src/graph-merge/type-reconcile.ts
|
|
2554
2607
|
var INCOMPATIBLE_TYPES_FLAG_REASON = "type-reconcile:incompatible-kinds";
|
|
2555
2608
|
function distinctKinds(kinds) {
|
|
2556
|
-
return [...new Set(kinds)].sort((left, right) => compareStrings(left, right));
|
|
2609
|
+
return [...new Set(kinds)].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right));
|
|
2557
2610
|
}
|
|
2558
2611
|
function areEquivalent(closure, left, right) {
|
|
2559
2612
|
return left !== right && isReachable2(closure, left, right) && isReachable2(closure, right, left);
|
|
@@ -2571,7 +2624,7 @@ function mostSpecificCommonKind(closure, kinds) {
|
|
|
2571
2624
|
if (qualifiers.length === 0) {
|
|
2572
2625
|
return void 0;
|
|
2573
2626
|
}
|
|
2574
|
-
return [...qualifiers].sort((left, right) => compareStrings(left, right))[0];
|
|
2627
|
+
return [...qualifiers].sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right))[0];
|
|
2575
2628
|
}
|
|
2576
2629
|
function reconcileTypes(clusters, closure, mode) {
|
|
2577
2630
|
if (mode === "off") {
|
|
@@ -2608,10 +2661,10 @@ function reconcileTypes(clusters, closure, mode) {
|
|
|
2608
2661
|
}
|
|
2609
2662
|
return {
|
|
2610
2663
|
reconciliations: reconciliations.sort(
|
|
2611
|
-
(left, right) => compareStrings(left.entityId, right.entityId)
|
|
2664
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.entityId, right.entityId)
|
|
2612
2665
|
),
|
|
2613
2666
|
retypeMap,
|
|
2614
|
-
dropped: dropped.sort((left, right) => compareStrings(left.id, right.id))
|
|
2667
|
+
dropped: dropped.sort((left, right) => chunkZ5HBYM7U_cjs.compareStrings(left.id, right.id))
|
|
2615
2668
|
};
|
|
2616
2669
|
}
|
|
2617
2670
|
|
|
@@ -2630,8 +2683,8 @@ function newNodesByKind(staging) {
|
|
|
2630
2683
|
ordered.set(
|
|
2631
2684
|
kind,
|
|
2632
2685
|
[...items].sort((left, right) => {
|
|
2633
|
-
const byId2 = compareStrings(left.node.id, right.node.id);
|
|
2634
|
-
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;
|
|
2635
2688
|
})
|
|
2636
2689
|
);
|
|
2637
2690
|
}
|
|
@@ -2663,7 +2716,7 @@ async function precomputeEmbeddings(byKind, resolve, embedder) {
|
|
|
2663
2716
|
return lookup;
|
|
2664
2717
|
}
|
|
2665
2718
|
const orderedTexts = [...texts].sort(
|
|
2666
|
-
(left, right) => compareStrings(left, right)
|
|
2719
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2667
2720
|
);
|
|
2668
2721
|
const vectors = await embedder(orderedTexts);
|
|
2669
2722
|
if (vectors.length !== orderedTexts.length) {
|
|
@@ -2699,7 +2752,7 @@ async function embedMissingPairTexts(base, pairs, strategy, embedder) {
|
|
|
2699
2752
|
return existing;
|
|
2700
2753
|
}
|
|
2701
2754
|
const orderedTexts = [...missing].sort(
|
|
2702
|
-
(left, right) => compareStrings(left, right)
|
|
2755
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2703
2756
|
);
|
|
2704
2757
|
const vectors = await embedder(orderedTexts);
|
|
2705
2758
|
if (vectors.length !== orderedTexts.length) {
|
|
@@ -2729,7 +2782,7 @@ async function generateAllCandidates(target, staging, options, introspectionKind
|
|
|
2729
2782
|
async ([kind, items]) => {
|
|
2730
2783
|
const resolveConfig = options.resolve[kind];
|
|
2731
2784
|
if (resolveConfig === void 0) {
|
|
2732
|
-
return
|
|
2785
|
+
return chunkHK5SATYM_cjs.ok({ edges: [], warnings: [], baseMembers: [] });
|
|
2733
2786
|
}
|
|
2734
2787
|
const nodes = items.map((staged) => asNode(staged));
|
|
2735
2788
|
const uniqueConstraints = uniqueConstraintsFor(
|
|
@@ -2772,10 +2825,10 @@ async function generateAllCandidates(target, staging, options, introspectionKind
|
|
|
2772
2825
|
options.onComparisonCeiling,
|
|
2773
2826
|
options.maxComparisonsPerKind
|
|
2774
2827
|
);
|
|
2775
|
-
if (
|
|
2776
|
-
return
|
|
2828
|
+
if (chunkHK5SATYM_cjs.isErr(scored)) {
|
|
2829
|
+
return chunkHK5SATYM_cjs.err(scored.error);
|
|
2777
2830
|
}
|
|
2778
|
-
return
|
|
2831
|
+
return chunkHK5SATYM_cjs.ok({
|
|
2779
2832
|
edges: scored.data.edges,
|
|
2780
2833
|
warnings: scored.data.warnings.map(
|
|
2781
2834
|
(warning) => `[${kind}] ${warning.message}`
|
|
@@ -2786,14 +2839,14 @@ async function generateAllCandidates(target, staging, options, introspectionKind
|
|
|
2786
2839
|
)
|
|
2787
2840
|
);
|
|
2788
2841
|
for (const result of perKind) {
|
|
2789
|
-
if (
|
|
2790
|
-
return
|
|
2842
|
+
if (chunkHK5SATYM_cjs.isErr(result)) {
|
|
2843
|
+
return chunkHK5SATYM_cjs.err(result.error);
|
|
2791
2844
|
}
|
|
2792
2845
|
allEdges.push(...result.data.edges);
|
|
2793
2846
|
warnings.push(...result.data.warnings);
|
|
2794
2847
|
baseMembers.push(...result.data.baseMembers);
|
|
2795
2848
|
}
|
|
2796
|
-
return
|
|
2849
|
+
return chunkHK5SATYM_cjs.ok({
|
|
2797
2850
|
// The ONE shared `(a, b)` edge comparator (id-first `(kind, id)` order), so this
|
|
2798
2851
|
// stage emits edges in exactly the order clustering consumes them.
|
|
2799
2852
|
edges: allEdges.sort((left, right) => compareCandidateEdges(left, right)),
|
|
@@ -2896,9 +2949,9 @@ function buildProvenanceIndex(records) {
|
|
|
2896
2949
|
for (const [branchId, sets] of byBranch) {
|
|
2897
2950
|
frozen.set(branchId, {
|
|
2898
2951
|
nodeIds: [...sets.nodeIds].sort(
|
|
2899
|
-
(left, right) => compareStrings(left, right)
|
|
2952
|
+
(left, right) => chunkZ5HBYM7U_cjs.compareStrings(left, right)
|
|
2900
2953
|
),
|
|
2901
|
-
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)
|
|
2902
2955
|
});
|
|
2903
2956
|
}
|
|
2904
2957
|
return {
|
|
@@ -3113,7 +3166,7 @@ function planMerge(staging, candidateEdges, candidateWarnings, baseMembers, opti
|
|
|
3113
3166
|
...repoint2.dropped,
|
|
3114
3167
|
...reconciliation.dropped
|
|
3115
3168
|
].sort(
|
|
3116
|
-
(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}`)
|
|
3117
3170
|
);
|
|
3118
3171
|
return {
|
|
3119
3172
|
canonicalEntities,
|
|
@@ -3146,7 +3199,7 @@ function planMerge(staging, candidateEdges, candidateWarnings, baseMembers, opti
|
|
|
3146
3199
|
mergeKey(left.kind, left.entityId),
|
|
3147
3200
|
mergeKey(right.kind, right.entityId)
|
|
3148
3201
|
);
|
|
3149
|
-
return byEntity === 0 ? compareStrings(left.property, right.property) : byEntity;
|
|
3202
|
+
return byEntity === 0 ? chunkZ5HBYM7U_cjs.compareStrings(left.property, right.property) : byEntity;
|
|
3150
3203
|
}
|
|
3151
3204
|
),
|
|
3152
3205
|
deleteModifyConflicts: [
|
|
@@ -3334,7 +3387,7 @@ async function validateBaseVersions(target, branches) {
|
|
|
3334
3387
|
const targetVersion = await computeBaseVersion(target);
|
|
3335
3388
|
for (const branch2 of branches) {
|
|
3336
3389
|
if (branch2.base !== targetVersion) {
|
|
3337
|
-
return
|
|
3390
|
+
return chunkHK5SATYM_cjs.err(
|
|
3338
3391
|
new BaseVersionMismatchError(
|
|
3339
3392
|
`Branch "${branch2.id}" forked from base@V "${branch2.base}", which does not match the merge target's current base@V "${targetVersion}".`,
|
|
3340
3393
|
{
|
|
@@ -3348,20 +3401,20 @@ async function validateBaseVersions(target, branches) {
|
|
|
3348
3401
|
);
|
|
3349
3402
|
}
|
|
3350
3403
|
}
|
|
3351
|
-
return
|
|
3404
|
+
return chunkHK5SATYM_cjs.ok(targetVersion);
|
|
3352
3405
|
}
|
|
3353
3406
|
function tryNormalize(optionsInput) {
|
|
3354
3407
|
try {
|
|
3355
|
-
return
|
|
3408
|
+
return chunkHK5SATYM_cjs.ok(normalizeMergeOptions(optionsInput));
|
|
3356
3409
|
} catch (error) {
|
|
3357
|
-
return
|
|
3410
|
+
return chunkHK5SATYM_cjs.err(new MergeError("Invalid merge options.", { cause: error }));
|
|
3358
3411
|
}
|
|
3359
3412
|
}
|
|
3360
3413
|
async function resolveMerge(store, target, branches, options, useBaseSources, incremental, expectedBaseVersion) {
|
|
3361
3414
|
let targetBranchSeen = false;
|
|
3362
3415
|
for (const branch2 of branches) {
|
|
3363
3416
|
if (branch2.id === BASE_PROVENANCE_BRANCH) {
|
|
3364
|
-
return
|
|
3417
|
+
return chunkHK5SATYM_cjs.err(
|
|
3365
3418
|
new MergeError(
|
|
3366
3419
|
`Branch id "${BASE_PROVENANCE_BRANCH}" is reserved for committed-base provenance and cannot be used as a branch id.`,
|
|
3367
3420
|
{ details: { branchId: branch2.id } }
|
|
@@ -3370,7 +3423,7 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3370
3423
|
}
|
|
3371
3424
|
if (branch2.id === COMMITTED_TARGET_BRANCH) {
|
|
3372
3425
|
if (incremental?.targetBranchId !== COMMITTED_TARGET_BRANCH || targetBranchSeen) {
|
|
3373
|
-
return
|
|
3426
|
+
return chunkHK5SATYM_cjs.err(
|
|
3374
3427
|
new MergeError(
|
|
3375
3428
|
`Branch id "${COMMITTED_TARGET_BRANCH}" is reserved for the committed incremental target and cannot be used as a branch id.`,
|
|
3376
3429
|
{ details: { branchId: branch2.id } }
|
|
@@ -3381,8 +3434,8 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3381
3434
|
}
|
|
3382
3435
|
}
|
|
3383
3436
|
try {
|
|
3384
|
-
const staging = await stageBranches(store, branches);
|
|
3385
3437
|
const preferredBranchId = incremental?.targetBranchId;
|
|
3438
|
+
const staging = await stageBranches(store, branches, preferredBranchId);
|
|
3386
3439
|
const branchIds = branches.map((branch2) => branch2.id);
|
|
3387
3440
|
const branchOrder = preferredBranchId === void 0 ? options.branchOrder ?? [] : [
|
|
3388
3441
|
preferredBranchId,
|
|
@@ -3415,8 +3468,8 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3415
3468
|
useBaseSources,
|
|
3416
3469
|
options.embedder
|
|
3417
3470
|
);
|
|
3418
|
-
if (
|
|
3419
|
-
return
|
|
3471
|
+
if (chunkHK5SATYM_cjs.isErr(candidates)) {
|
|
3472
|
+
return chunkHK5SATYM_cjs.err(candidates.error);
|
|
3420
3473
|
}
|
|
3421
3474
|
const plan = planMerge(
|
|
3422
3475
|
staging,
|
|
@@ -3436,7 +3489,9 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3436
3489
|
// anything NEW the in-tx re-probe surfaces is a window write.
|
|
3437
3490
|
plannedBaseMatchKeys: new Set(
|
|
3438
3491
|
candidates.data.baseMembers.map((member) => mergeKeyOf(member))
|
|
3439
|
-
)
|
|
3492
|
+
),
|
|
3493
|
+
targetNodeVersions: staging.targetNodeVersions,
|
|
3494
|
+
targetEdgeSignatures: staging.targetEdgeSignatures
|
|
3440
3495
|
});
|
|
3441
3496
|
const provenance = options.provenance ? buildProvenanceIndex(plan.provenanceRecords) : { byBranch: () => ({ nodeIds: [], edgeIds: [] }) };
|
|
3442
3497
|
const warnings = [...plan.warnings];
|
|
@@ -3474,12 +3529,12 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3474
3529
|
warnings,
|
|
3475
3530
|
...provenancePersisted === void 0 ? {} : { provenancePersisted }
|
|
3476
3531
|
};
|
|
3477
|
-
return
|
|
3532
|
+
return chunkHK5SATYM_cjs.ok(report);
|
|
3478
3533
|
} catch (error) {
|
|
3479
3534
|
if (error instanceof MergeError) {
|
|
3480
|
-
return
|
|
3535
|
+
return chunkHK5SATYM_cjs.err(error);
|
|
3481
3536
|
}
|
|
3482
|
-
return
|
|
3537
|
+
return chunkHK5SATYM_cjs.err(
|
|
3483
3538
|
new MergeError(
|
|
3484
3539
|
`Merge failed while staging or committing: ${describeCause(error)}`,
|
|
3485
3540
|
{ cause: error }
|
|
@@ -3489,14 +3544,14 @@ async function resolveMerge(store, target, branches, options, useBaseSources, in
|
|
|
3489
3544
|
}
|
|
3490
3545
|
async function merge(store, branches, optionsInput = {}) {
|
|
3491
3546
|
const normalized = tryNormalize(optionsInput);
|
|
3492
|
-
if (
|
|
3493
|
-
return
|
|
3547
|
+
if (chunkHK5SATYM_cjs.isErr(normalized)) {
|
|
3548
|
+
return chunkHK5SATYM_cjs.err(normalized.error);
|
|
3494
3549
|
}
|
|
3495
3550
|
const options = normalized.data;
|
|
3496
3551
|
const target = options.target ?? store;
|
|
3497
3552
|
const precondition = await validateBaseVersions(target, branches);
|
|
3498
|
-
if (
|
|
3499
|
-
return
|
|
3553
|
+
if (chunkHK5SATYM_cjs.isErr(precondition)) {
|
|
3554
|
+
return chunkHK5SATYM_cjs.err(precondition.error);
|
|
3500
3555
|
}
|
|
3501
3556
|
return resolveMerge(
|
|
3502
3557
|
store,
|
|
@@ -3512,7 +3567,7 @@ async function validateForkPointVersions(forkPoint, branches) {
|
|
|
3512
3567
|
const forkVersion = await computeBaseVersion(forkPoint);
|
|
3513
3568
|
for (const branch2 of branches) {
|
|
3514
3569
|
if (branch2.base !== forkVersion) {
|
|
3515
|
-
return
|
|
3570
|
+
return chunkHK5SATYM_cjs.err(
|
|
3516
3571
|
new BaseVersionMismatchError(
|
|
3517
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.`,
|
|
3518
3573
|
{
|
|
@@ -3526,7 +3581,7 @@ async function validateForkPointVersions(forkPoint, branches) {
|
|
|
3526
3581
|
);
|
|
3527
3582
|
}
|
|
3528
3583
|
}
|
|
3529
|
-
return
|
|
3584
|
+
return chunkHK5SATYM_cjs.ok(forkVersion);
|
|
3530
3585
|
}
|
|
3531
3586
|
function nodeSchemaFor(target, kind) {
|
|
3532
3587
|
const registry = target.graph.nodes;
|
|
@@ -3737,7 +3792,7 @@ async function validateIncrementalEdgeWrites(target, edgesApi, plan) {
|
|
|
3737
3792
|
}
|
|
3738
3793
|
}
|
|
3739
3794
|
}
|
|
3740
|
-
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));
|
|
3741
3796
|
if (notFound.length > 0) {
|
|
3742
3797
|
const crossKindById = /* @__PURE__ */ new Map();
|
|
3743
3798
|
for (const kind of Object.keys(target.graph.edges)) {
|
|
@@ -3866,6 +3921,99 @@ async function assertBaseResolutionStable(lookupStore, guard) {
|
|
|
3866
3921
|
}
|
|
3867
3922
|
);
|
|
3868
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
|
+
}
|
|
3869
4017
|
async function commitIncrementalPlan(target, plan, guard) {
|
|
3870
4018
|
if (!target.backend.capabilities.transactions) {
|
|
3871
4019
|
throw new MergeError(
|
|
@@ -3878,6 +4026,7 @@ async function commitIncrementalPlan(target, plan, guard) {
|
|
|
3878
4026
|
const nodesApi = tx.nodes;
|
|
3879
4027
|
const edgesApi = tx.edges;
|
|
3880
4028
|
await assertBaseResolutionStable(tx, guard);
|
|
4029
|
+
await assertInheritedTargetUnchanged(nodesApi, edgesApi, guard, plan);
|
|
3881
4030
|
await validateIncrementalNodeWrites(target, nodesApi, plan);
|
|
3882
4031
|
await validateIncrementalEdgeWrites(target, edgesApi, plan);
|
|
3883
4032
|
return applyMergePlan(plan, nodesApi, edgesApi);
|
|
@@ -3887,12 +4036,12 @@ async function commitIncrementalPlan(target, plan, guard) {
|
|
|
3887
4036
|
async function mergeIncremental(args) {
|
|
3888
4037
|
const { forkPoint, target, branches } = args;
|
|
3889
4038
|
const normalized = tryNormalize(args.options ?? {});
|
|
3890
|
-
if (
|
|
3891
|
-
return
|
|
4039
|
+
if (chunkHK5SATYM_cjs.isErr(normalized)) {
|
|
4040
|
+
return chunkHK5SATYM_cjs.err(normalized.error);
|
|
3892
4041
|
}
|
|
3893
4042
|
const options = normalized.data;
|
|
3894
4043
|
if (options.onBasePropertyConflict !== "flag") {
|
|
3895
|
-
return
|
|
4044
|
+
return chunkHK5SATYM_cjs.err(
|
|
3896
4045
|
new MergeError(
|
|
3897
4046
|
'mergeIncremental() requires onBasePropertyConflict: "flag" (keep-base); a non-keep-base policy could overwrite a newer committed base value with a stale branch value.',
|
|
3898
4047
|
{ details: {} }
|
|
@@ -3900,8 +4049,8 @@ async function mergeIncremental(args) {
|
|
|
3900
4049
|
);
|
|
3901
4050
|
}
|
|
3902
4051
|
const forkPrecondition = await validateForkPointVersions(forkPoint, branches);
|
|
3903
|
-
if (
|
|
3904
|
-
return
|
|
4052
|
+
if (chunkHK5SATYM_cjs.isErr(forkPrecondition)) {
|
|
4053
|
+
return chunkHK5SATYM_cjs.err(forkPrecondition.error);
|
|
3905
4054
|
}
|
|
3906
4055
|
const forkVersion = forkPrecondition.data;
|
|
3907
4056
|
const [forkSchema, targetSchema] = await Promise.all([
|
|
@@ -3909,7 +4058,7 @@ async function mergeIncremental(args) {
|
|
|
3909
4058
|
computeSchemaComponent(target)
|
|
3910
4059
|
]);
|
|
3911
4060
|
if (forkSchema !== targetSchema) {
|
|
3912
|
-
return
|
|
4061
|
+
return chunkHK5SATYM_cjs.err(
|
|
3913
4062
|
new MergeError(
|
|
3914
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).",
|
|
3915
4064
|
{ details: {} }
|
|
@@ -3933,15 +4082,15 @@ async function mergeIncremental(args) {
|
|
|
3933
4082
|
|
|
3934
4083
|
Object.defineProperty(exports, "isErr", {
|
|
3935
4084
|
enumerable: true,
|
|
3936
|
-
get: function () { return
|
|
4085
|
+
get: function () { return chunkHK5SATYM_cjs.isErr; }
|
|
3937
4086
|
});
|
|
3938
4087
|
Object.defineProperty(exports, "isOk", {
|
|
3939
4088
|
enumerable: true,
|
|
3940
|
-
get: function () { return
|
|
4089
|
+
get: function () { return chunkHK5SATYM_cjs.isOk; }
|
|
3941
4090
|
});
|
|
3942
4091
|
Object.defineProperty(exports, "unwrap", {
|
|
3943
4092
|
enumerable: true,
|
|
3944
|
-
get: function () { return
|
|
4093
|
+
get: function () { return chunkHK5SATYM_cjs.unwrap; }
|
|
3945
4094
|
});
|
|
3946
4095
|
exports.BaseVersionMismatchError = BaseVersionMismatchError;
|
|
3947
4096
|
exports.BranchError = BranchError;
|