@indra.ai/deva 1.64.53 → 1.64.55

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/_data/tests.json CHANGED
@@ -60,8 +60,20 @@
60
60
  {
61
61
  "file": "08-error.test.js",
62
62
  "title": "Error",
63
- "describe": "err() rejects or hands off to onError without calling context(), talks one stamped error packet, and context() and contexts() read each Deva's own vars.context, falling back safely when it is missing.",
63
+ "describe": "err() rejects or hands off to onError without calling context(), talks one stamped error packet, and context() and contexts() read each Deva's own vars.context, falling back safely when it is missing. A local method that rejects or throws rejects question() with one error packet, a child ask error is logged by both Devas, and an unknown feature is rejected.",
64
64
  "count": 10
65
+ },
66
+ {
67
+ "file": "09-ready-hash.test.js",
68
+ "title": "Ready Hash",
69
+ "describe": "The ready hash is stable across Devas with identical functions, a func or method source change before ready changes the hash, and a listener added after ready with listen() does not change the stored ready hash.",
70
+ "count": 3
71
+ },
72
+ {
73
+ "file": "10-vocabulary.test.js",
74
+ "title": "Vocabulary",
75
+ "describe": "Two Devas in one process each keep their own agent zones, actions, states, intents, beliefs and messages, and neither mutates the shared base config.",
76
+ "count": 1
65
77
  }
66
78
  ],
67
79
  "edgecases": [
@@ -88,7 +100,19 @@
88
100
  "describe": "A missing section resolved help not found but kept going, threw, logged an error, and the finally block logged valid and good on both not-found paths.",
89
101
  "suite": "07-help.test.js",
90
102
  "fixed": "1.64.25"
91
- }
92
- ]
103
+ },
104
+ {
105
+ "title": "Ready hash covers _binding source strings",
106
+ "describe": "The ready hash is taken from the _binding source strings for func, methods, utils and listeners. It stays the same for identical functions, changes when a func or method source changes before ready, and a listener added after ready with listen() is left out of the stored hash.",
107
+ "suite": "09-ready-hash.test.js",
108
+ "fixed": "1.64.46"
109
+ },
110
+ {
111
+ "title": "Vocabulary isolation",
112
+ "describe": "Each Deva shallow-copies config zones, actions, states, intents, beliefs and messages so custom agent entries stay on that Deva and the shared base config is not mutated.",
113
+ "suite": "10-vocabulary.test.js",
114
+ "fixed": "1.64.52"
115
+ }
116
+ ]
93
117
  }
94
118
  }
package/index.js CHANGED
@@ -2102,7 +2102,6 @@ class Deva {
2102
2102
  const license = this._info.VLA ? this._info.VLA.uid : false;
2103
2103
  const client = this.client(); // get the client
2104
2104
  const agent = this.agent(); // get the agent
2105
- const {profile} = agent;
2106
2105
  const machine = this.machine(); // get the machine hash
2107
2106
 
2108
2107
  const core_hash = this._core.sha256; // get the core sha256 hash
@@ -2157,7 +2156,7 @@ class Deva {
2157
2156
  const max = Math.ceil(time + (time * Math.PI)); // generate max time form Math.PI multiplier.
2158
2157
  const begin_random = Math.floor(Math.random() * (max - min) + min); // generate random number between min and max.
2159
2158
  const {end_min, end_max} = this._uid; // set end min and max in to constant
2160
- const end_random = Math.ceil(Math.random() * (end_max - end_min) + end_min); // generate the 5 digit end salt on the number for added randomness.
2159
+ const end_random = Math.ceil(Math.random() * (end_max - end_min) + end_min); // generate end salt on the number for added randomness.
2161
2160
 
2162
2161
  const uid = `${begin_random}${end_random}`; // set uid to local constant
2163
2162
  data.uid = uid; // set base data object.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "31711622713594414221",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.64.53",
4
+ "version": "1.64.55",
5
5
  "description": "Deva Core a Vedic-inspired Event Based Context Aware Feature, Zone, Action, and State Machine integrated Artificial Intelligence Framework",
6
6
  "main": "index.js",
7
7
  "license": "VLA:31711622713594414221 LICENSE.md",
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // Deva Core Test Suite: step 9, the _binding ready hash
3
+ // Copyright ©2000-2026 Quinn Michaels; All rights reserved.
4
+ // Owner Signature Required For Lawful Use.
5
+ // Distributed under VLA:31711622713594414221 LICENSE.md
6
+
7
+ import test from 'node:test';
8
+ import assert from 'node:assert/strict';
9
+ import {build, client, agent} from './_deva.js';
10
+
11
+ const fresh = () => structuredClone(client);
12
+ const vars = () => structuredClone(agent.vars);
13
+
14
+ // identical source on every call, so two Devas hash the same _binding strings
15
+ const same = () => ({
16
+ config: {hash: {}},
17
+ vars: vars(),
18
+ func: { ping() { return 'pong'; } },
19
+ methods: { greet() { return 'hi'; } },
20
+ utils: { clip(s) { return s.trim(); } },
21
+ listeners: { 'suite:ready'(packet) { return packet; } },
22
+ });
23
+
24
+ const readyHash = deva => deva.config.hash[deva.agent().key];
25
+
26
+ test('the ready hash is stable across two Devas with identical functions', async () => {
27
+ const a = build(same());
28
+ const b = build(same());
29
+ await a.init(fresh());
30
+ await b.init(fresh());
31
+ assert.deepEqual(readyHash(a), readyHash(b));
32
+ for (const item of ['func', 'methods', 'utils', 'listeners']) {
33
+ assert.equal(typeof readyHash(a)[item], 'string', item);
34
+ }
35
+ await a.stop();
36
+ await b.stop();
37
+ });
38
+
39
+ test('changing a func or method source before ready changes the hash', async () => {
40
+ const a = build(same());
41
+ const b = build({
42
+ ...same(),
43
+ func: { ping() { return 'pong-changed'; } },
44
+ methods: { greet() { return 'hi-changed'; } },
45
+ });
46
+ await a.init(fresh());
47
+ await b.init(fresh());
48
+ assert.notEqual(readyHash(a).func, readyHash(b).func, 'func source change');
49
+ assert.notEqual(readyHash(a).methods, readyHash(b).methods, 'method source change');
50
+ assert.equal(readyHash(a).utils, readyHash(b).utils, 'unchanged utils stay the same');
51
+ assert.equal(readyHash(a).listeners, readyHash(b).listeners, 'unchanged listeners stay the same');
52
+ await a.stop();
53
+ await b.stop();
54
+ });
55
+
56
+ test('a listener added after ready with listen() does not change the stored ready hash', async () => {
57
+ const deva = build(same());
58
+ await deva.init(fresh());
59
+ const before = structuredClone(readyHash(deva));
60
+ deva.listen('suite:after', () => {});
61
+ assert.deepEqual(readyHash(deva), before, 'stored ready hash is unchanged');
62
+ assert.equal('suite:after' in deva.listeners, true, 'listen() still registers the listener');
63
+ assert.equal('suite:after' in (deva._binding.get('listeners') || {}), false, 'the new listener is not folded into _binding');
64
+ await deva.stop();
65
+ });
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ // Deva Core Test Suite: step 10, vocabulary isolation
3
+ // Copyright ©2000-2026 Quinn Michaels; All rights reserved.
4
+ // Owner Signature Required For Lawful Use.
5
+ // Distributed under VLA:31711622713594414221 LICENSE.md
6
+
7
+ import test from 'node:test';
8
+ import assert from 'node:assert/strict';
9
+ import {build, client, agent} from './_deva.js';
10
+ import coreConfig from '../../_data/index.js';
11
+
12
+ const fresh = () => structuredClone(client);
13
+ const vars = () => structuredClone(agent.vars);
14
+
15
+ // the six config zones the constructor shallow-copies for each Deva
16
+ const KINDS = ['zones', 'actions', 'states', 'intents', 'beliefs', 'messages'];
17
+
18
+ function withVocab(key, label) {
19
+ const extra = {};
20
+ for (const kind of KINDS) {
21
+ const singular = kind === 'messages' ? 'message' : kind.slice(0, -1);
22
+ extra[kind] = {[`${key}_${singular}`]: `${label} ${singular}`};
23
+ }
24
+ return build({
25
+ config: {hash: {}},
26
+ vars: vars(),
27
+ agent: {
28
+ ...agent,
29
+ id: key,
30
+ key,
31
+ profile: {...agent.profile, name: label},
32
+ ...extra,
33
+ },
34
+ });
35
+ }
36
+
37
+ test('two Devas keep their own agent vocabulary and leave the shared base alone', async () => {
38
+ const before = Object.fromEntries(KINDS.map(kind => [kind, Object.keys(coreConfig[kind]).sort()]));
39
+ const a = withVocab('alpha', 'Alpha');
40
+ const b = withVocab('beta', 'Beta');
41
+ await a.init(fresh());
42
+ await b.init(fresh());
43
+
44
+ for (const kind of KINDS) {
45
+ const singular = kind === 'messages' ? 'message' : kind.slice(0, -1);
46
+ const aKey = `alpha_${singular}`;
47
+ const bKey = `beta_${singular}`;
48
+ const aMap = a[`_${kind}`];
49
+ const bMap = b[`_${kind}`];
50
+ assert.equal(aMap[aKey], `Alpha ${singular}`, `${kind}: alpha keeps its own`);
51
+ assert.equal(bMap[bKey], `Beta ${singular}`, `${kind}: beta keeps its own`);
52
+ assert.equal(aMap[bKey], undefined, `${kind}: alpha does not see beta`);
53
+ assert.equal(bMap[aKey], undefined, `${kind}: beta does not see alpha`);
54
+ assert.equal(coreConfig[kind][aKey], undefined, `${kind}: shared base has no alpha entry`);
55
+ assert.equal(coreConfig[kind][bKey], undefined, `${kind}: shared base has no beta entry`);
56
+ assert.deepEqual(Object.keys(coreConfig[kind]).sort(), before[kind], `${kind}: shared base keys are unchanged`);
57
+ }
58
+
59
+ await a.stop();
60
+ await b.stop();
61
+ });