@indra.ai/deva 1.64.0 → 1.64.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "31711622713594414221",
3
3
  "name": "@indra.ai/deva",
4
- "version": "1.64.0",
4
+ "version": "1.64.2",
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,77 @@
1
+ "use strict";
2
+ // Deva Core Test Suite: step 1, init and lifecycle
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} from './_deva.js';
10
+
11
+ const STAGES = ['start', 'enter', 'done', 'ready'];
12
+ const TIERS = ['md5', 'sha256', 'sha512'];
13
+
14
+ // fresh copy of the client so no test changes another's data
15
+ const fresh = (changes = {}) => ({...structuredClone(client), ...changes});
16
+ const wait = ms => new Promise(res => setTimeout(res, ms));
17
+ const status = (p, ms) => Promise.race([
18
+ p.then(() => 'resolved', () => 'rejected'),
19
+ wait(ms).then(() => 'pending'),
20
+ ]);
21
+
22
+ test('init() with no hooks resolves with the ready data', async () => {
23
+ const deva = build();
24
+ const data = await deva.init(fresh());
25
+ for (const k of STAGES) assert.equal(typeof data[k], 'number', `${k} timestamp`);
26
+ assert.ok(data.start <= data.enter && data.enter <= data.done && data.done <= data.ready, 'stages in order');
27
+ assert.equal(data.value, 'init');
28
+ assert.equal(typeof data.id.uid, 'string');
29
+ for (const t of TIERS) assert.equal(typeof data[t], 'string', `${t} hash`);
30
+ await deva.stop();
31
+ });
32
+
33
+ test('init() waits for onReady to resolve', async () => {
34
+ const order = [];
35
+ let release;
36
+ const deva = build({
37
+ onReady(data, resolve) {
38
+ order.push('onReady');
39
+ release = () => { order.push('hook-resolve'); resolve(data); };
40
+ },
41
+ });
42
+ deva.events.on('devacore:ready', () => order.push('ready-event'));
43
+ const p = deva.init(fresh()).then(data => { order.push('await'); return data; });
44
+
45
+ await wait(400);
46
+ assert.equal(await status(p, 50), 'pending', 'init still pending before the hook resolves');
47
+ assert.deepEqual(order, ['ready-event', 'onReady']);
48
+
49
+ release();
50
+ const data = await p;
51
+ assert.deepEqual(order, ['ready-event', 'onReady', 'hook-resolve', 'await']);
52
+ for (const k of STAGES) assert.equal(typeof data[k], 'number', `${k} timestamp`);
53
+ await deva.stop();
54
+ });
55
+
56
+ test('a failing feature step rejects init() and stops the chain', async () => {
57
+ const seen = [];
58
+ const deva = build({ onReady(data, resolve) { seen.push('onReady'); resolve(data); } });
59
+ for (const e of ['start', 'ready']) deva.events.on(`devacore:${e}`, () => seen.push(e));
60
+ deva.events.on('devacore:action', p => { if (p.value === 'feature') seen.push(p.text); });
61
+
62
+ await assert.rejects(deva.init(fresh({features: {}})));
63
+ await wait(200);
64
+ assert.ok(!seen.includes('start') && !seen.includes('ready') && !seen.includes('onReady'), 'no lifecycle after the failure');
65
+ assert.ok(seen.some(t => t.includes('Feature:license')), 'license step ran');
66
+ assert.ok(!seen.some(t => /Feature:(error|log|data|report|legal|security|support|services|systems):/.test(t)), 'no later feature steps');
67
+ });
68
+
69
+ test('onError that calls reject rejects init()', async () => {
70
+ const deva = build({ onError(err, packet, reject) { return reject && reject(err); } });
71
+ await assert.rejects(deva.init(fresh({features: {}})));
72
+ });
73
+
74
+ test('onError that never calls reject leaves init() pending (the hook owns the outcome)', async () => {
75
+ const deva = build({ onError() {} });
76
+ assert.equal(await status(deva.init(fresh({features: {}})), 500), 'pending');
77
+ });
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ // Deva Core Test Suite: step 2, feature getters
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} from './_deva.js';
10
+
11
+ const GETTERS = ['license', 'error', 'log', 'data', 'report', 'legal', 'security', 'support', 'services', 'systems'];
12
+
13
+ const deva = build();
14
+ test.before(async () => { await deva.init(structuredClone(client)); });
15
+
16
+ for (const key of GETTERS) {
17
+ test(`${key}() returns exactly its own _${key} data`, () => {
18
+ const got = deva[key]();
19
+ // the getter returns a JSON copy, so compare against the same form
20
+ assert.deepEqual(got, JSON.parse(JSON.stringify(deva[`_${key}`])));
21
+ });
22
+
23
+ test(`${key}() returns a copy, so changing it leaves _${key} alone`, () => {
24
+ const got = deva[key]();
25
+ assert.notEqual(got, deva[`_${key}`]);
26
+ got.client_id = 'changed';
27
+ assert.notEqual(deva[`_${key}`].client_id, 'changed');
28
+ });
29
+
30
+ test(`${key}() carries the client and its concerns`, () => {
31
+ const got = deva[key]();
32
+ assert.equal(got.client_id, client.id);
33
+ assert.equal(got.client_name, client.profile.name);
34
+ assert.deepEqual(got.concerns, client.features[key].concerns);
35
+ });
36
+ }
37
+
38
+ test('getters answer offline after stop()', async () => {
39
+ await deva.stop();
40
+ for (const key of GETTERS) assert.equal(deva[key](), deva._messages.offline, key);
41
+ });