theprogrammablemind_4wp 7.5.8-beta.0 → 7.5.8-beta.2

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -110,6 +110,9 @@ class ErrorReason extends Error {
110
110
  const setupArgs = (args, config, logs, hierarchy) => {
111
111
  config.setArgs(args)
112
112
  args.calls = new InitCalls(config.name)
113
+ if (global.theprogrammablemind && global.theprogrammablemind.loadForTesting) {
114
+ args.calls = new InitCalls(Object.keys(global.theprogrammablemind.loadForTesting)[0])
115
+ }
113
116
  args.km = (name) => config.getConfig(name)
114
117
  args.error = (context) => {
115
118
  throw new ErrorReason(context)
@@ -149,7 +152,10 @@ const setupArgs = (args, config, logs, hierarchy) => {
149
152
  args.g = (c) => config.getGenerators(logs).apply(args, c)
150
153
  args.gp = (c) => config.getGenerators(logs).apply(args, { ...c, paraphrase: true, isResponse: false, response: false})
151
154
  args.gr = (c) => config.getGenerators(logs).apply(args, { ...c, paraphrase: false, isResponse: true })
152
- args.e = (c) => config.getEvaluator(args.s, logs, c)
155
+ if (!logs) {
156
+ debugger
157
+ }
158
+ args.e = (c) => config.getEvaluator(args.s, args.calls, logs, c)
153
159
  args.log = (message) => logs.push(message)
154
160
  // config.getAddedArgs(args)
155
161
  args.gs = gs(args.g)
@@ -359,6 +365,9 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
359
365
 
360
366
  const objects = config.get('objects')
361
367
  const args = { objects, isResponse: true, response: json, isTest, getObjects: getObjects(objects) }
368
+ if (!json.logs) {
369
+ json.logs = []
370
+ }
362
371
  setupArgs(args, config, json.logs, hierarchy)
363
372
  const toDo = [...contexts]
364
373
  args.insert = (context) => toDo.unshift(context)
@@ -654,7 +663,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
654
663
  return response
655
664
  } catch(error) {
656
665
  error.query = query
657
- throw error
666
+ errorHandler(error)
658
667
  }
659
668
  }
660
669
 
@@ -688,11 +697,13 @@ const getConfigForTest = (config, testConfig) => {
688
697
  return configForTest
689
698
  }
690
699
 
691
- const runTest = async (config, expected, { verbose, afterTest, testConfig, debug }) => {
700
+ const runTest = async (config, expected, { args, verbose, afterTest, testConfig, debug }) => {
692
701
  const test = expected.query
693
702
  // initialize in between test so state is not preserved since the test was adding without state
694
703
  config.rebuild()
695
- config.addAssociationsFromTests(config.tests)
704
+ if (!args.dontAddAssociations) {
705
+ config.addAssociationsFromTests(config.tests)
706
+ }
696
707
  // config.addAssocationsFromTests(
697
708
  const errorHandler = (error) => {
698
709
  if (error.metadata) {
@@ -1344,7 +1355,11 @@ const knowledgeModule = async ({
1344
1355
  if (config.needsRebuild(template.template, template.instance)) {
1345
1356
  throw `This module "${config.name}" cannot be used because the instance file needs rebuilding. Run on the command line with no arguements or the -rt argument to rebuild.`
1346
1357
  }
1347
- config.load(template.template, template.instance)
1358
+ try {
1359
+ config.load(template.template, template.instance)
1360
+ } catch( e ) {
1361
+ errorHandler(e)
1362
+ }
1348
1363
  }
1349
1364
  }
1350
1365
  if (isProcess) {
@@ -1353,6 +1368,13 @@ const knowledgeModule = async ({
1353
1368
  description: 'Entodicton knowledge module'
1354
1369
  })
1355
1370
 
1371
+ const helpDebugAssociation = 'In order to get a debug break when a specific association is created set the DEBUG_ASSOCIATION environment variable to the JSON of the association to break on. For example DEBUG_ASSOCIATION=\'["the#0", "mammel#0"]\' })'
1372
+ const helpDebugHierarchy = 'In order to get a debug break when a specific hierarchy is created set the DEBUG_HIERARCHY environment variable to the JSON of the child-parent pair to break on. For example DEBUG_HIERARCHY=\'["cat#1", "mammel#1"]\' })'
1373
+ const helpDebugPriority = 'In order to get a debug break when a specific set of priorities is created set set DEBUG_PRIORITY environment variable to the JSON of the priorities that you want to break on. For example DEBUG_PRIORITY=\'["verb#0", "article#0"]\' })'
1374
+ const helpDebugBridge = 'In order to get a debug break when a specific bridge is created set the DEBUG_BRIDGE environment variable to id/level to break on. For example DEBUG_BRIDGE=\'id#level\' })'
1375
+ const helpDebugOperator = 'In order to get a debug break when a specific hierarcy is created set the DEBUG_OPERATOR environment variable to debug any config loaded. For example DEBUG_OPERATOR=\'([operator] ([arg]))\' })'
1376
+
1377
+
1356
1378
  parser.add_argument('-tmn', '--testModuleName', { help: 'When running tests instead of using the current modules tests use the specified modules tests' })
1357
1379
  parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
1358
1380
  parser.add_argument('-tv', '--testVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. Create tests by running with the --query or --loop with the --save flag' })
@@ -1379,30 +1401,34 @@ const knowledgeModule = async ({
1379
1401
  parser.add_argument('-dic', '--debugIncludeConvolutions', { action: 'store_true', help: 'When running with the --debugIncludeConvolutions flag the logs will include convolutions which are somewhat annoying verbose. Default is false' })
1380
1402
  parser.add_argument('-dl', '--debugLoops', { action: 'store_true', help: 'When running with the --debugLoops flag the logs calls to semantics and generators will be immediately written to the console '})
1381
1403
  parser.add_argument('-d', '--debug', { action: 'store_true', help: 'When running with the --debug flag this set the debug flag in the config' })
1382
- parser.add_argument('-da', '--debugAssociation', { help: 'When running with the --debugAssociation flag the debugging will break when the specified association is added to the config' })
1383
- parser.add_argument('-dh', '--debugHierarchy', { help: 'When running with the --debugHierarchy flag the debugging will break when the specified child-parent pair is added to the config for the main config. Set DEBUG_HIERARCHY to debug any config loaded. For example DEBUG_HIERARCHY=\'["cat", "mammel"]\'' })
1384
- parser.add_argument('-db', '--debugBridge', { help: 'When running with the --debugBridge flag the debugging will break when the specified bridge is added to the config for the main config. Set DEBUG_BRIDGE to debug any config loaded. For example DEBUG_BRIDGE=\'id/level\'' })
1385
- parser.add_argument('-do', '--debugOperator', { help: 'When running with the --debugOperator flag the debugging will break when the specified operator is added to the config for the main config. Set DEBUG_OPERATOR to debug any config loaded. For example DEBUG_OPERATOR=\'([operator] ([arg]))\'' })
1404
+ parser.add_argument('-da', '--debugAssociation', { help: helpDebugAssociation })
1405
+ parser.add_argument('-dh', '--debugHierarchy', { help: helpDebugHierarchy })
1406
+ parser.add_argument('-dp', '--debugPriority', { help: helpDebugPriority })
1407
+ parser.add_argument('-db', '--debugBridge', { help: helpDebugBridge })
1408
+ parser.add_argument('-do', '--debugOperator', { help: helpDebugOperator })
1386
1409
 
1387
1410
  const args = parser.parse_args()
1388
1411
  args.count = args.count || 1
1389
1412
 
1390
1413
  if (args.debugAssociation) {
1391
- global.entodictonDebugAssociation = JSON.parse(args.debugAssociation)
1414
+ console.log(helpDebugAssociation)
1415
+ runtime.process.exit(-1)
1392
1416
  }
1393
1417
  if (args.debugHierarchy) {
1394
- global.entodictonDebugHierarchy = JSON.parse(args.debugHierarchy)
1418
+ console.log(helpDebugHierarchy)
1419
+ runtime.process.exit(-1)
1420
+ }
1421
+ if (args.debugPriority) {
1422
+ console.log(helpDebugPriority)
1423
+ runtime.process.exit(-1)
1395
1424
  }
1396
1425
  if (args.debugBridge) {
1397
- // id/level
1398
- global.entodictonDebugBridge = args.debugBridge.split('/')
1399
- if (global.entodictonDebugBridge.length !== 2) {
1400
- console.log('Expected DEBUG_BRIDGE to be of the form "id/level"');
1401
- }
1426
+ console.log(helpDebugBridge)
1427
+ runtime.process.exit(-1)
1402
1428
  }
1403
1429
  if (args.debugOperator) {
1404
- // id/level
1405
- global.entodictonDebugOperator = args.debugOperator
1430
+ console.log(helpDebugOperator)
1431
+ runtime.process.exit(-1)
1406
1432
  }
1407
1433
 
1408
1434
  if (args.clean) {
@@ -1471,87 +1497,94 @@ const knowledgeModule = async ({
1471
1497
  }
1472
1498
  */
1473
1499
 
1474
- if (args.print) {
1475
- if (args.print.includes('t')) {
1476
- console.log("Test queries")
1477
- let counter = 0
1478
- for (const test of config.tests) {
1479
- console.log(`${counter} - ${test.query}`)
1480
- counter += 1
1481
- }
1482
- }
1483
- if (args.print.includes('c')) {
1484
- const { data } = setupProcessB({ config })
1485
- console.log("Config as sent to server")
1486
- console.log(JSON.stringify(data, null, 2));
1500
+ let configPrinted = false
1501
+ const printConfig = () => {
1502
+ if (configPrinted) {
1503
+ return
1487
1504
  }
1505
+ configPrinted = true
1506
+ if (args.print) {
1507
+ if (args.print.includes('t')) {
1508
+ console.log("Test queries")
1509
+ let counter = 0
1510
+ for (const test of config.tests) {
1511
+ console.log(`${counter} - ${test.query}`)
1512
+ counter += 1
1513
+ }
1514
+ }
1515
+ if (args.print.includes('c')) {
1516
+ const { data } = setupProcessB({ config })
1517
+ console.log("Config as sent to server")
1518
+ console.log(JSON.stringify(data, null, 2));
1519
+ }
1488
1520
 
1489
- if (args.print.includes('l')) {
1490
- console.log('Module load ordering')
1491
- for (const km of config.configs) {
1492
- console.log(` ${km.name}`)
1521
+ if (args.print.includes('l')) {
1522
+ console.log('Module load ordering')
1523
+ for (const km of config.configs) {
1524
+ console.log(` ${km.name}`)
1525
+ }
1493
1526
  }
1494
- }
1495
- if (args.print.includes('w')) {
1496
- for (const word in config.config.words) {
1497
- console.log(word.concat(' ', ...config.config.words[word].map((def) => JSON.stringify(def))))
1527
+ if (args.print.includes('w')) {
1528
+ for (const word in config.config.words) {
1529
+ console.log(word.concat(' ', ...config.config.words[word].map((def) => JSON.stringify(def))))
1530
+ }
1498
1531
  }
1499
- }
1500
- if (args.print.includes('b')) {
1501
- for (const bridge of config.config.bridges) {
1502
- console.log(JSON.stringify(bridge))
1532
+ if (args.print.includes('b')) {
1533
+ for (const bridge of config.config.bridges) {
1534
+ console.log(JSON.stringify(bridge))
1535
+ }
1503
1536
  }
1504
- }
1505
- if (args.print.includes('o')) {
1506
- for (const operator of config.config.operators) {
1507
- console.log(JSON.stringify(operator))
1537
+ if (args.print.includes('o')) {
1538
+ for (const operator of config.config.operators) {
1539
+ console.log(JSON.stringify(operator))
1540
+ }
1508
1541
  }
1509
- }
1510
- if (args.print.includes('j')) {
1511
- const { data } = setupProcessB( { config } )
1512
- console.log(JSON.stringify(data, null, 2))
1513
- }
1514
- if (args.print.includes('a')) {
1515
- console.log('associations ================')
1516
- const properties = ['negative', 'positive']
1517
- for (let property of properties) {
1518
- console.log(` ${property} ===============`)
1519
- for (let association of config.config.associations[property]) {
1520
- console.log(` ${JSON.stringify(association)}`)
1542
+ if (args.print.includes('j')) {
1543
+ const { data } = setupProcessB( { config } )
1544
+ console.log(JSON.stringify(data, null, 2))
1545
+ }
1546
+ if (args.print.includes('a')) {
1547
+ console.log('associations ================')
1548
+ const properties = ['negative', 'positive']
1549
+ for (let property of properties) {
1550
+ console.log(` ${property} ===============`)
1551
+ for (let association of config.config.associations[property]) {
1552
+ console.log(` ${JSON.stringify(association)}`)
1553
+ }
1521
1554
  }
1522
1555
  }
1523
- }
1524
- if (args.print.includes('d')) {
1525
- console.log(JSON.stringify(config.config.objects, null, 2))
1526
- }
1527
- if (args.print.includes('p')) {
1528
- for (let priority of config.config.priorities) {
1529
- console.log(JSON.stringify(priority))
1556
+ if (args.print.includes('d')) {
1557
+ console.log(JSON.stringify(config.config.objects, null, 2))
1530
1558
  }
1531
- }
1532
- if (args.print.includes('h')) {
1533
- for (let edge of config.config.hierarchy) {
1534
- console.log(JSON.stringify(edge))
1559
+ if (args.print.includes('p')) {
1560
+ for (let priority of config.config.priorities) {
1561
+ console.log(JSON.stringify(priority))
1562
+ }
1535
1563
  }
1536
- }
1537
- if (args.print.includes('g')) {
1538
- const easyToRead = _.cloneDeep(config.config.generators)
1539
- for (const semantic of easyToRead) {
1540
- semantic.match = semantic.match.toString()
1541
- semantic.apply = semantic.apply.toString()
1542
- if (semantic.applyWrapped) {
1543
- semantic.applyWrapped = semantic.applyWrapped.toString()
1564
+ if (args.print.includes('h')) {
1565
+ for (let edge of config.config.hierarchy) {
1566
+ console.log(JSON.stringify(edge))
1544
1567
  }
1545
1568
  }
1546
- console.dir(easyToRead)
1547
- }
1548
- if (args.print.includes('s')) {
1549
- const easyToRead = _.cloneDeep(config.config.semantics)
1550
- for (const semantic of easyToRead) {
1551
- semantic.match = semantic.match.toString()
1552
- semantic.apply = semantic.apply.toString()
1569
+ if (args.print.includes('g')) {
1570
+ const easyToRead = _.cloneDeep(config.config.generators)
1571
+ for (const semantic of easyToRead) {
1572
+ semantic.match = semantic.match.toString()
1573
+ semantic.apply = semantic.apply.toString()
1574
+ if (semantic.applyWrapped) {
1575
+ semantic.applyWrapped = semantic.applyWrapped.toString()
1576
+ }
1577
+ }
1578
+ console.dir(easyToRead)
1579
+ }
1580
+ if (args.print.includes('s')) {
1581
+ const easyToRead = _.cloneDeep(config.config.semantics)
1582
+ for (const semantic of easyToRead) {
1583
+ semantic.match = semantic.match.toString()
1584
+ semantic.apply = semantic.apply.toString()
1585
+ }
1586
+ console.dir(easyToRead)
1553
1587
  }
1554
- console.dir(easyToRead)
1555
1588
  }
1556
1589
  }
1557
1590
 
@@ -1586,12 +1619,7 @@ const knowledgeModule = async ({
1586
1619
  test = useTestConfig.name
1587
1620
 
1588
1621
  }
1589
- runTests(config, test, { debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1590
- if (results.length > 0 && args.vimdiff) {
1591
- for (const result of results) {
1592
- vimdiff(result.actual, result.expected)
1593
- }
1594
- }
1622
+ runTests(config, test, { args, debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1595
1623
  let newError = false
1596
1624
  if (results.length > 0) {
1597
1625
  let headerShown = false
@@ -1650,6 +1678,12 @@ const knowledgeModule = async ({
1650
1678
  headerShown = true
1651
1679
  }
1652
1680
  }
1681
+ } else {
1682
+ if (results.length > 0 && args.vimdiff) {
1683
+ for (const result of results) {
1684
+ vimdiff(result.actual, result.expected)
1685
+ }
1686
+ }
1653
1687
  }
1654
1688
  if (!headerShown) {
1655
1689
  if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
@@ -1711,11 +1745,12 @@ const knowledgeModule = async ({
1711
1745
  }
1712
1746
  config.beforeQuery({ query: args.query, isModule: false, objects })
1713
1747
  try {
1714
- processResults(_process(config, args.query, { commandLineArgs: args, dontAddAssociations: args.dontAddAssociations, writeTests: args.save || args.saveDeveloper, saveDeveloper: args.saveDeveloper, testConfig, testsFN: test }))
1748
+ await processResults(_process(config, args.query, { commandLineArgs: args, dontAddAssociations: args.dontAddAssociations, writeTests: args.save || args.saveDeveloper, saveDeveloper: args.saveDeveloper, testConfig, testsFN: test }))
1715
1749
  } catch( error ) {
1716
1750
  console.log('Error', error);
1717
1751
  }
1718
1752
  }
1753
+ printConfig()
1719
1754
  } else {
1720
1755
  config.addAssociationsFromTests(config.tests);
1721
1756
  //for (let query in config.tests) {
@@ -1723,6 +1758,7 @@ const knowledgeModule = async ({
1723
1758
  //}
1724
1759
  module()
1725
1760
  }
1761
+
1726
1762
  }
1727
1763
 
1728
1764
  /*
package/package.json CHANGED
@@ -63,6 +63,6 @@
63
63
  "json-stable-stringify": "^1.0.1",
64
64
  "node-fetch": "^2.6.1"
65
65
  },
66
- "version": "7.5.8-beta.0",
66
+ "version": "7.5.8-beta.2",
67
67
  "license": "ISC"
68
68
  }
package/src/config.js CHANGED
@@ -5,6 +5,7 @@ const { Generators } = require('./generators')
5
5
  const client = require('../client')
6
6
  const DigraphInternal = require('./digraph_internal')
7
7
  const helpers = require('./helpers')
8
+ const { ecatch } = require('./helpers')
8
9
  const runtime = require('../runtime')
9
10
  const _ = require('lodash')
10
11
 
@@ -22,97 +23,102 @@ const indent = (string, indent) => {
22
23
  }
23
24
 
24
25
  const handleBridgeProps = (config, bridge) => {
25
- if (!bridge.bridge) {
26
- bridge.bridge = "{ ...next(operator) }"
27
- }
28
- if (!bridge.level) {
29
- bridge.level = 0
30
- }
31
- if (bridge.children) {
32
- for (let child of bridge.children) {
33
- config.addHierarchy(child, bridge.id)
34
- }
35
- }
36
- if (bridge.parents) {
37
- for (let parent of bridge.parents) {
38
- config.addHierarchy(bridge.id, parent)
39
- }
40
- }
41
- if (bridge.isA) {
42
- for (let parent of bridge.isA) {
43
- config.addHierarchy(bridge.id, parent)
44
- }
45
- }
46
- if (bridge.before) {
47
- for (let after of bridge.before) {
48
- if (typeof after == 'string') {
49
- after = [after, 0]
26
+ ecatch(`While processing the bridge for ${bridge.id}#${bridge.level}`,
27
+ () => {
28
+ if (!bridge.bridge) {
29
+ bridge.bridge = "{ ...next(operator) }"
50
30
  }
51
- config.addPriorities([after, [bridge.id, bridge.level]])
52
- }
53
- }
54
- if (bridge.words) {
55
- for (let def of bridge.words) {
56
- if (typeof def == 'string') {
57
- config.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
58
- } else {
59
- const word = def.word
60
- def = { initial: JSON.stringify(def), id: bridge.id, word: undefined }
61
- config.addWordInternal(word, def)
31
+ if (!bridge.level) {
32
+ bridge.level = 0
33
+ }
34
+ if (bridge.children) {
35
+ for (let child of bridge.children) {
36
+ config.addHierarchy(child, bridge.id)
37
+ }
38
+ }
39
+ if (bridge.parents) {
40
+ for (let parent of bridge.parents) {
41
+ config.addHierarchy(bridge.id, parent)
42
+ }
43
+ }
44
+ if (bridge.isA) {
45
+ for (let parent of bridge.isA) {
46
+ config.addHierarchy(bridge.id, parent)
47
+ }
48
+ }
49
+ if (bridge.before) {
50
+ for (let after of bridge.before) {
51
+ if (typeof after == 'string') {
52
+ after = [after, 0]
53
+ }
54
+ config.addPriorities([after, [bridge.id, bridge.level]])
55
+ }
56
+ }
57
+ if (bridge.words) {
58
+ for (let def of bridge.words) {
59
+ if (typeof def == 'string') {
60
+ config.addWordInternal(def, {"id": bridge.id, "initial": `{ value: "${def}"}` })
61
+ } else {
62
+ const word = def.word
63
+ def = { initial: JSON.stringify(def), id: bridge.id, word: undefined }
64
+ config.addWordInternal(word, def)
65
+ }
66
+ }
67
+ }
68
+ if (bridge.generator) {
69
+ config.config.generators.unshift(bridge.generator)
70
+ }
71
+ if (bridge.generators) {
72
+ const generators = [...bridge.generators]
73
+ generators.reverse()
74
+ for (let generator of generators) {
75
+ config.config.generators.unshift(generator)
76
+ }
77
+ }
78
+ if (bridge.generatorpr) {
79
+ bridge.generatorp = bridge.generatorpr
80
+ bridge.generatorr = bridge.generatorpr
81
+ }
82
+ if (bridge.generatorp) {
83
+ config.config.generators.unshift({
84
+ where: bridge.generatorp.where || bridge.where || client.where(4),
85
+ // match: ({context}) => bridge.id == context.marker && context.paraphrase,
86
+ match: ({context}) => bridge.id == context.marker && context.level == bridge.level + 1 && context.paraphrase,
87
+ apply: (args) => bridge.generatorp(args),
88
+ applyWrapped: bridge.generatorp,
89
+ property: 'generatorp',
90
+ })
91
+ }
92
+ if (bridge.generatorr) {
93
+ config.config.generators.unshift({
94
+ // TODO merge response and isResponse
95
+ where: bridge.generatorr.where || bridge.where || client.where(3),
96
+ match: ({context}) => bridge.id == context.marker && !context.paraphrase && (context.response || context.isResponse),
97
+ apply: (args) => bridge.generatorr(args),
98
+ applyWrapped: bridge.generatorr,
99
+ property: 'generatorr',
100
+ })
101
+ }
102
+ if (bridge.evaluator) {
103
+ config.config.semantics.unshift({
104
+ where: bridge.evaluator.where || bridge.where || client.where(3),
105
+ match: ({context}) => bridge.id == context.marker && context.evaluate,
106
+ apply: (args) => bridge.evaluator(args),
107
+ applyWrapped: bridge.evaluator,
108
+ property: 'evaluator',
109
+ })
110
+ }
111
+ if (bridge.semantic) {
112
+ config.config.semantics.unshift({
113
+ where: bridge.semantic.where || bridge.where || client.where(3),
114
+ match: ({context}) => bridge.id == context.marker,
115
+ apply: (args) => bridge.semantic(args),
116
+ applyWrapped: bridge.semantic,
117
+ property: 'semantic',
118
+ })
62
119
  }
63
120
  }
64
- }
65
- if (bridge.generator) {
66
- config.config.generators.unshift(bridge.generator)
67
- }
68
- if (bridge.generators) {
69
- const generators = [...bridge.generators]
70
- generators.reverse()
71
- for (let generator of generators) {
72
- config.config.generators.unshift(generator)
73
- }
74
- }
75
- if (bridge.generatorpr) {
76
- bridge.generatorp = bridge.generatorpr
77
- bridge.generatorr = bridge.generatorpr
78
- }
79
- if (bridge.generatorp) {
80
- config.config.generators.unshift({
81
- where: bridge.generatorp.where || bridge.where || client.where(4),
82
- match: ({context}) => bridge.id == context.marker && context.paraphrase,
83
- apply: (args) => bridge.generatorp(args),
84
- applyWrapped: bridge.generatorp,
85
- property: 'generatorp',
86
- })
87
- }
88
- if (bridge.generatorr) {
89
- config.config.generators.unshift({
90
- // TODO merge response and isResponse
91
- where: bridge.generatorr.where || bridge.where || client.where(3),
92
- match: ({context}) => bridge.id == context.marker && !context.paraphrase && (context.response || context.isResponse),
93
- apply: (args) => bridge.generatorr(args),
94
- applyWrapped: bridge.generatorr,
95
- property: 'generatorr',
96
- })
97
- }
98
- if (bridge.evaluator) {
99
- config.config.semantics.unshift({
100
- where: bridge.evaluator.where || bridge.where || client.where(3),
101
- match: ({context}) => bridge.id == context.marker && context.evaluate,
102
- apply: (args) => bridge.evaluator(args),
103
- applyWrapped: bridge.evaluator,
104
- property: 'evaluator',
105
- })
106
- }
107
- if (bridge.semantic) {
108
- config.config.semantics.unshift({
109
- where: bridge.semantic.where || bridge.where || client.where(3),
110
- match: ({context}) => bridge.id == context.marker,
111
- apply: (args) => bridge.semantic(args),
112
- applyWrapped: bridge.semantic,
113
- property: 'semantic',
114
- })
115
- }
121
+ )
116
122
  }
117
123
 
118
124
  const handleCalculatedProps = (baseConfig, moreConfig) => {
@@ -137,6 +143,14 @@ if (runtime.process.env.DEBUG_HIERARCHY) {
137
143
  global.entodictonDebugHierarchy = JSON.parse(runtime.process.env.DEBUG_HIERARCHY)
138
144
  }
139
145
 
146
+ if (runtime.process.env.DEBUG_PRIORITY) {
147
+ global.entodictonDebugPriority = JSON.parse(runtime.process.env.DEBUG_PRIORITY)
148
+ }
149
+
150
+ if (runtime.process.env.DEBUG_ASSOCIATION) {
151
+ global.entodictonDebugAssociation = JSON.parse(runtime.process.env.DEBUG_ASSOCIATION)
152
+ }
153
+
140
154
  if (runtime.process.env.DEBUG_BRIDGE) {
141
155
  // id/level
142
156
  global.entodictonDebugBridge = runtime.process.env.DEBUG_BRIDGE.split('/')
@@ -614,8 +628,9 @@ class Config {
614
628
  return instance
615
629
  }
616
630
  */
617
- getEvaluator (s, log, context) {
631
+ getEvaluator (s, calls, log, context) {
618
632
  const instance = s({ ...context, evaluate: true })
633
+ calls.touch(instance)
619
634
  if (!instance.evalue && !instance.verbatim && !instance.value) {
620
635
  this.warningNotEvaluated(log, context);
621
636
  }
@@ -777,10 +792,15 @@ class Config {
777
792
  if (!this.config.priorities) {
778
793
  this.config.priorities = []
779
794
  }
795
+ if (global.entodictonDebugPriority) {
796
+ if (helpers.safeEquals(entodictonDebugPriority, priorities)) {
797
+ debugger; // debug hierarchy hit
798
+ }
799
+ }
780
800
  this.config.priorities.push(priorities)
781
801
  this._delta.json.priorities.push({ action: 'add', priorities })
782
802
  }
783
-
803
+
784
804
  addHierarchy (child, parent) {
785
805
  if (child && parent || !child || Array.isArray(child) || (typeof child == 'string' && !parent)) {
786
806
  this.addHierarchyChildParent(child, parent)
@@ -799,7 +819,7 @@ class Config {
799
819
  throw `addHierarchy expected parent property to be a string. got ${JSON.stringify(parent)}`
800
820
  }
801
821
  if (global.entodictonDebugHierarchy) {
802
- if ((helpers.safeEquals.entodictonDebugHierarchy, [child, parent])) {
822
+ if (helpers.safeEquals(entodictonDebugHierarchy, [child, parent])) {
803
823
  debugger; // debug hierarchy hit
804
824
  }
805
825
  }
@@ -846,7 +866,7 @@ class Config {
846
866
  }
847
867
  const bridges = this.config.bridges
848
868
  const def = Object.assign({}, bridge, { uuid: this._uuid })
849
-
869
+
850
870
  if (global.entodictonDebugBridge) {
851
871
  if (global.entodictonDebugBridge[0] == bridge.id && global.entodictonDebugBridge[1] == bridge.level) {
852
872
  debugger; // debug hierarchy hit
package/src/helpers.js CHANGED
@@ -309,7 +309,16 @@ const functionsToStrings = (config) => {
309
309
  return config
310
310
  }
311
311
 
312
+ const ecatch = (where, call) => {
313
+ try {
314
+ return call()
315
+ } catch( e ) {
316
+ throw new Error(`${where} ${e}`)
317
+ }
318
+ }
319
+
312
320
  module.exports = {
321
+ ecatch,
313
322
  functionsToStrings,
314
323
  updateQueries,
315
324
  mapInPlace,