theprogrammablemind_4wp 7.5.5-beta.0 → 7.5.5-beta.2

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -330,7 +330,7 @@ const setupContexts = (rawContexts) => {
330
330
  return contexts
331
331
  }
332
332
 
333
- const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url }) => {
333
+ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTest, query, data, retries, url, commandLineArgs }) => {
334
334
  // TODO fix this name to contextsPrime
335
335
  const contextsPrime = []
336
336
  const generatedPrime = []
@@ -344,6 +344,7 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
344
344
  const toDo = [...contexts]
345
345
  args.insert = (context) => toDo.unshift(context)
346
346
  let overlap, lastRange;
347
+ config.debugLoops = commandLineArgs && commandLineArgs.debugLoops
347
348
  while (toDo.length > 0) {
348
349
  const context = toDo.shift()
349
350
  /*
@@ -523,7 +524,7 @@ const processInstance = (config, instance) => {
523
524
  // config.addInternal(config.template.queries[i], { handleCalculatedProps: true } )
524
525
  config.addInternal(instance.template.queries[i], { handleCalculatedProps: true } )
525
526
  } else {
526
- processContextsB({ config, hierarchy, json: results/*, generators, semantics */ })
527
+ processContextsB({ config, hierarchy, json: results/*, generators, semantics */, commandLineArgs: {} })
527
528
  }
528
529
  }
529
530
  global.transitoryMode = transitoryMode
@@ -604,7 +605,7 @@ const _process = async (config, query, { initializer, commandLineArgs, credentia
604
605
  throw json
605
606
  } else {
606
607
  const { contextsPrime, generatedPrime, paraphrasesPrime, responsesPrime } =
607
- processContextsB({ isTest, config, hierarchy, json/*, generators, semantics */ })
608
+ processContextsB({ isTest, config, hierarchy, json, commandLineArgs /*, generators, semantics */ })
608
609
  response.associations = json.associations
609
610
  response.hierarchy = json.hierarchy
610
611
  response.load_cache_time += json.load_cache_time
@@ -935,6 +936,7 @@ const defaultErrorHandler = async (error) => {
935
936
  console.log(error.stack)
936
937
  }
937
938
 
939
+ let doErrorExit = false
938
940
  if (error.errors) {
939
941
  console.log('error: ')
940
942
  for (const e of error.errors) {
@@ -949,19 +951,25 @@ const defaultErrorHandler = async (error) => {
949
951
  } else {
950
952
  console.log('\n ', e)
951
953
  }
954
+ doErrorExit = true
952
955
  }
953
956
  }
954
957
  if (error.error) {
955
958
  console.log('error: ')
956
959
  for (const e of error.error) {
957
960
  console.log('\n ', e)
961
+ doErrorExit = true
958
962
  }
959
963
  }
960
964
 
961
965
  if (error.query) {
962
966
  console.log('query: ', error.query)
967
+ doErrorExit = true
963
968
  }
964
969
 
970
+ if (doErrorExit) {
971
+ runtime.process.exit(-1)
972
+ }
965
973
  // throw error
966
974
  }
967
975
 
@@ -1300,6 +1308,7 @@ const knowledgeModule = async ({
1300
1308
  parser.add_argument('-s', '--save', { action: 'store_true', help: 'When running with the --query flag this will save the current run to the test file. When running without the --query flag all tests will be run and resaved.' })
1301
1309
  parser.add_argument('-sd', '--saveDeveloper', { action: 'store_true', help: 'Same as -s but the query will not show up in the info command.' })
1302
1310
  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' })
1311
+ 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 '})
1303
1312
  parser.add_argument('-d', '--debug', { action: 'store_true', help: 'When running with the --debug flag this set the debug flag in the config' })
1304
1313
  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' })
1305
1314
  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"]\'' })
package/package.json CHANGED
@@ -62,6 +62,6 @@
62
62
  "json-stable-stringify": "^1.0.1",
63
63
  "node-fetch": "^2.6.1"
64
64
  },
65
- "version": "7.5.5-beta.0",
65
+ "version": "7.5.5-beta.2",
66
66
  "license": "ISC"
67
67
  }
package/src/config.js CHANGED
@@ -1220,6 +1220,9 @@ class Config {
1220
1220
  config.priorities = config.priorities || []
1221
1221
  }
1222
1222
 
1223
+ this.maxDepth = 50 // for generators and semantics
1224
+ this.debugLoops = false // for generators and semantics
1225
+
1223
1226
  this.allowDelta = false
1224
1227
  this.resetDelta()
1225
1228
 
@@ -1482,6 +1485,8 @@ class Config {
1482
1485
  this.valid()
1483
1486
  const cp = new Config()
1484
1487
  cp.logs = []
1488
+ cp.maxDepth = this.maxDepth
1489
+ cp.debugLoops = this.debugLoops
1485
1490
  cp.transitoryMode = this.transitoryMode
1486
1491
  cp.configs = this.configs.map((km) => km.copy2(Object.assign({}, options, { getCounter: (name) => cp.getCounter(name), callInitializers: false })))
1487
1492
  cp._uuid = cp.configs[0]._uuid
@@ -1883,12 +1888,6 @@ class Config {
1883
1888
  const addInternals = []
1884
1889
  const inits = []
1885
1890
  const initAfterApis = []
1886
- if (false && this.config.hierarchy.find( (pair) => JSON.stringify(pair) === JSON.stringify(["equipable2","property"]))) {
1887
- debugger // happened
1888
- }
1889
- if (false && this.name == 'countable') {
1890
- debugger // in rebuild
1891
- }
1892
1891
  const reverseIt = true
1893
1892
  const interleaved = true
1894
1893
  this.configs.forEach((km) => {
package/src/generators.js CHANGED
@@ -77,7 +77,13 @@ class Generator {
77
77
  if (!log) {
78
78
  throw 'generators.apply argument log is required'
79
79
  }
80
+ if (baseArgs.call && config && sbaseArgs.calls.stack.length > config.maxDepth) {
81
+ throw new Error(`Max depth of ${config.maxDepth} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
82
+ }
80
83
 
84
+ if (config && config.debugLoops) {
85
+ console.log("apply", this.toLabel())
86
+ }
81
87
  // this.getAPI(config)
82
88
  let n = (id) => id
83
89
  if (config && 'nsToString' in config) {
package/src/semantics.js CHANGED
@@ -79,6 +79,13 @@ class Semantic {
79
79
  apply (baseArgs, context, s, log, options = {}) {
80
80
  const { hierarchy, config, response } = baseArgs
81
81
  const objects = baseArgs.getObjects(this.uuid)
82
+ if (config && config.debugLoops) {
83
+ console.log("apply", this.toLabel())
84
+ }
85
+ if (baseArgs.calls && config && baseArgs.calls.stack.length > config.maxDepth) {
86
+ throw new Error(`Max depth of ${config.maxDepth} for calls has been exceeded. maxDepth can be set on the config object. To see the calls run with the --dl or set the debugLoops property on the config`)
87
+ }
88
+
82
89
  // const ask = baseArgs.getAsk(this.uuid)
83
90
  if (!log) {
84
91
  console.trace()
@@ -168,7 +175,6 @@ class Semantics {
168
175
  if (!(context instanceof Array || context instanceof Object)) {
169
176
  return context
170
177
  }
171
-
172
178
  const config = args.config
173
179
  let contextPrime = Object.assign({}, context)
174
180
  const s = (context, options) => this.apply(args, context, options)