@indra.ai/deva 1.64.8 → 1.64.10
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 +76 -0
- package/_includes/header.html +1 -0
- package/index.js +7 -3
- package/package.json +1 -1
- package/test.md +22 -0
- package/tests/suite/06-shutdown.test.js +23 -2
package/_data/tests.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "41985016213321096966",
|
|
3
|
+
"title": "Deva Core Tests",
|
|
4
|
+
"copyright": "Copyright ©2000-2026 Quinn Michaels; All rights reserved.",
|
|
5
|
+
"VLA": "31711622713594414221",
|
|
6
|
+
"DATA": {
|
|
7
|
+
"runner": "node:test",
|
|
8
|
+
"assert": "node:assert/strict",
|
|
9
|
+
"node": "24",
|
|
10
|
+
"command": "npm test",
|
|
11
|
+
"suites": [
|
|
12
|
+
{
|
|
13
|
+
"file": "00-build.test.js",
|
|
14
|
+
"title": "Build",
|
|
15
|
+
"describe": "build() makes a Deva that reaches ready.",
|
|
16
|
+
"count": 1
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"file": "01-init.test.js",
|
|
20
|
+
"title": "Init",
|
|
21
|
+
"describe": "init() resolves with the ready data, waits for onReady, and a failing step or onError reject stops the chain.",
|
|
22
|
+
"count": 5
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"file": "02-getters.test.js",
|
|
26
|
+
"title": "Feature Getters",
|
|
27
|
+
"describe": "Each feature getter returns exactly its own _key data as a copy, carries the client and its concerns, and answers offline after stop().",
|
|
28
|
+
"count": 31
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"file": "03-hash.test.js",
|
|
32
|
+
"title": "Hash",
|
|
33
|
+
"describe": "The md5, sha256 and sha512 tiers match node:crypto, every hashing site carries all three, the uid fingerprint holds, and one changed field breaks every tier.",
|
|
34
|
+
"count": 6
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"file": "04-license.test.js",
|
|
38
|
+
"title": "License",
|
|
39
|
+
"describe": "A matching VLA activates the Deva with stamped hashes; a changed, missing or absent VLA answers its message and stays inactive.",
|
|
40
|
+
"count": 6
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"file": "05-messaging.test.js",
|
|
44
|
+
"title": "Messaging",
|
|
45
|
+
"describe": "question() runs local /commands and #ask calls to child Devas, child errors reach the asker right away, and missing or silent targets answer not found or timeout.",
|
|
46
|
+
"count": 12
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"file": "06-shutdown.test.js",
|
|
50
|
+
"title": "Shutdown",
|
|
51
|
+
"describe": "stop() stops child Devas first, runs the full chain in order to onShutdown, clears features, answers pending asks offline and leaves nothing on the event bus.",
|
|
52
|
+
"count": 8
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
"edgecases": [
|
|
56
|
+
{
|
|
57
|
+
"title": "Child errors reach the asker",
|
|
58
|
+
"describe": "A failing or throwing child Deva method now rejects the asker right away instead of waiting for the ask timeout.",
|
|
59
|
+
"suite": "05-messaging.test.js",
|
|
60
|
+
"fixed": "1.64.7"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"title": "Pending asks at shutdown",
|
|
64
|
+
"describe": "A question still waiting on an answer when the Deva stops now resolves offline instead of hanging.",
|
|
65
|
+
"suite": "06-shutdown.test.js",
|
|
66
|
+
"fixed": "1.64.8"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"title": "Parent stop reaches its children",
|
|
70
|
+
"describe": "A parent's stop() now stops each child Deva through its full chain before the parent closes.",
|
|
71
|
+
"suite": "06-shutdown.test.js",
|
|
72
|
+
"fixed": "1.64.9"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
package/_includes/header.html
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<a class="page-link" href="/vibe/">Vibe</a>
|
|
16
16
|
<a class="page-link" href="/core/">Core</a>
|
|
17
17
|
<a class="page-link" href="/docs/">Docs</a>
|
|
18
|
+
<a class="page-link" href="/tests/">Tests</a>
|
|
18
19
|
<a class="page-link" href="/about/">About</a>
|
|
19
20
|
</nav></div>
|
|
20
21
|
</header>
|
package/index.js
CHANGED
|
@@ -1280,12 +1280,16 @@ class Deva {
|
|
|
1280
1280
|
Recursion Framework.
|
|
1281
1281
|
***************/
|
|
1282
1282
|
stop() {
|
|
1283
|
-
if (!this._active) return this._messages.offline; // check for active status
|
|
1283
|
+
if (!this._active) return Promise.resolve(this._messages.offline); // check for active status
|
|
1284
1284
|
const key = 'stop'; // set the stop key
|
|
1285
1285
|
const id = this.uid(); // generate the stop uid
|
|
1286
1286
|
let data;
|
|
1287
|
-
return new Promise((resolve, reject) => {
|
|
1287
|
+
return new Promise(async (resolve, reject) => {
|
|
1288
1288
|
try {
|
|
1289
|
+
// stop the child Devas first so none are left running when the parent closes. ready() loads them last.
|
|
1290
|
+
this.state('loop', `${key}:devas:${id.uid}`);
|
|
1291
|
+
for (const deva in this.devas) await this.devas[deva].stop();
|
|
1292
|
+
|
|
1289
1293
|
this.state('set', `${key}:agent:${id.uid}`); // state stop agent
|
|
1290
1294
|
const agentData = this.agent();
|
|
1291
1295
|
const agent = agentData.sha256; // get the current agent
|
|
@@ -1303,7 +1307,7 @@ class Deva {
|
|
|
1303
1307
|
client, // set the client
|
|
1304
1308
|
stop: Date.now(), // set the created date
|
|
1305
1309
|
}
|
|
1306
|
-
|
|
1310
|
+
|
|
1307
1311
|
this.action('return', `${key}:invoke:${data.id.uid}`);
|
|
1308
1312
|
this.state('valid', `${key}:invoke:${data.id.uid}`);
|
|
1309
1313
|
this.intent('good', `${key}:invoke:${data.id.uid}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "31711622713594414221",
|
|
3
3
|
"name": "@indra.ai/deva",
|
|
4
|
-
"version": "1.64.
|
|
4
|
+
"version": "1.64.10",
|
|
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",
|
package/test.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Tests
|
|
4
|
+
permalink: /tests/
|
|
5
|
+
description: How the Deva Core is tested, what each test suite proves, and the edge cases the suite found and fixed.
|
|
6
|
+
image: /assets/banner.png
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
{{ page.description }}
|
|
10
|
+
|
|
11
|
+
{% assign tests = site.data.tests.DATA %}
|
|
12
|
+
{% assign total = 0 %}
|
|
13
|
+
{% for suite in tests.suites %}{% assign total = total | plus: suite.count %}{% endfor %}
|
|
14
|
+
|
|
15
|
+
The Deva Core test suite has {{ tests.suites | size }} suites and {{ total }} tests. It uses Node's built-in `{{ tests.runner }}` runner with `{{ tests.assert }}`, so it adds no dependencies.
|
|
16
|
+
|
|
17
|
+
## How to run it
|
|
18
|
+
|
|
19
|
+
Run the tests on Node.js {{ tests.node }} or later:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
{{ tests.command }}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import test from 'node:test';
|
|
8
8
|
import assert from 'node:assert/strict';
|
|
9
|
-
import {build, client} from './_deva.js';
|
|
9
|
+
import {build, client, agent} from './_deva.js';
|
|
10
10
|
|
|
11
11
|
const TIERS = ['md5', 'sha256', 'sha512'];
|
|
12
12
|
const CHAIN = ['stop', 'close', 'leave', 'exit', 'shutdown'];
|
|
@@ -14,7 +14,9 @@ const fresh = () => structuredClone(client);
|
|
|
14
14
|
|
|
15
15
|
test('stop() answers offline before init()', async () => {
|
|
16
16
|
const deva = build();
|
|
17
|
-
|
|
17
|
+
const stopped = deva.stop();
|
|
18
|
+
assert.ok(stopped instanceof Promise, 'offline stop still returns a Promise');
|
|
19
|
+
assert.equal(await stopped, deva._messages.offline);
|
|
18
20
|
});
|
|
19
21
|
|
|
20
22
|
test('stop() runs the full chain and resolves the stamped stop data', async () => {
|
|
@@ -99,4 +101,23 @@ test('a pending ask at shutdown answers offline and leaves nothing behind', asyn
|
|
|
99
101
|
assert.equal(deva._pending.size, 0);
|
|
100
102
|
bus.removeListener('silent:ask', silent);
|
|
101
103
|
assert.deepEqual(bus.eventNames(), []);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('stop() stops the child Devas first and leaves nothing on the bus', async () => {
|
|
107
|
+
const order = [];
|
|
108
|
+
const helper = build({
|
|
109
|
+
agent: {...agent, id: 'helper', key: 'helper', profile: {...agent.profile, name: 'Helper'}},
|
|
110
|
+
onShutdown(data, resolve) { order.push('helper:shutdown'); return resolve(data); },
|
|
111
|
+
});
|
|
112
|
+
const deva = build({devas: {helper}});
|
|
113
|
+
await deva.init(fresh());
|
|
114
|
+
assert.ok(helper._active, 'the child is running after init');
|
|
115
|
+
const bus = deva.events;
|
|
116
|
+
const heard = packet => order.push(`${packet.value}:stop`);
|
|
117
|
+
bus.on(deva._events.stop, heard);
|
|
118
|
+
await deva.stop();
|
|
119
|
+
bus.removeListener(deva._events.stop, heard);
|
|
120
|
+
assert.equal(helper._active, false, 'the child is offline');
|
|
121
|
+
assert.deepEqual(order, ['helper:stop', 'helper:shutdown', 'test:stop'], 'the child finishes before the parent starts');
|
|
122
|
+
assert.deepEqual(bus.eventNames(), [], 'nothing left on the bus');
|
|
102
123
|
});
|