@neuroverseos/nv-sim 0.1.0 → 0.1.4
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/README.md +324 -44
- package/dist/assets/index-DHKd4rcV.js +338 -0
- package/dist/assets/index-SyyA3z3U.css +1 -0
- package/dist/assets/mirotir-logo-DUexumBH.svg +185 -0
- package/dist/assets/reportEngine-BfteK4MN.js +1 -0
- package/dist/assets/swarmSimulation-DHDqjfMa.js +1 -0
- package/dist/engine/aiProvider.js +256 -0
- package/dist/engine/cli.js +334 -299
- package/dist/engine/governance.js +8 -3
- package/dist/engine/governedSimulation.js +38 -12
- package/dist/engine/index.js +16 -1
- package/dist/engine/liveAdapter.js +342 -0
- package/dist/engine/liveVisualizer.js +1857 -0
- package/dist/engine/narrativeInjection.js +305 -0
- package/dist/engine/reasoningEngine.js +57 -3
- package/dist/engine/reportEngine.js +97 -0
- package/dist/engine/scenarioLibrary.js +231 -0
- package/dist/engine/worldComparison.js +194 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +23 -0
- package/dist/placeholder.svg +1 -0
- package/dist/robots.txt +14 -0
- package/package.json +13 -12
- package/variants/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -1,73 +1,353 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NV-SIM
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Change the rules. See why the system changed.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
NV-SIM doesn't predict outcomes — it shows how they change when you change the rules.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Define a world. Set the constraints. Run the agents. Then change one rule and watch the entire system reorganize. Not in theory. You see exactly which agents shifted, what patterns emerged, and why the outcome changed.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
It feels a lot like a Prime Radiant — except instead of psychohistory, you're running controlled behavioral experiments on complex systems.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```bash
|
|
12
|
+
npx @neuroverseos/nv-sim visualize
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What This Actually Is
|
|
16
|
+
|
|
17
|
+
Most simulation tools answer: *"What will happen?"*
|
|
18
|
+
|
|
19
|
+
NV-SIM answers: *"What changes when I change the rules?"*
|
|
20
|
+
|
|
21
|
+
You're not forecasting. You're experimenting. You change a constraint — no panic selling, cap leverage at 3x, close a shipping lane — and the system shows you:
|
|
22
|
+
|
|
23
|
+
- **How agents reorganize** (80% shifted from panic selling to coordinated holding)
|
|
24
|
+
- **What patterns emerge** (panic suppression, stability shift)
|
|
25
|
+
- **What the system became** (volatility dropped 21%, cascade avoided)
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
Rule changed
|
|
29
|
+
→ Behavior shifted
|
|
30
|
+
→ Pattern emerged
|
|
31
|
+
→ System outcome changed
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
That's the loop. Every time.
|
|
35
|
+
|
|
36
|
+
## The Demo Moment
|
|
37
|
+
|
|
38
|
+
**Before:**
|
|
39
|
+
```
|
|
40
|
+
panic_sell → panic_sell → panic_sell
|
|
41
|
+
pressure: 0.94
|
|
42
|
+
system: unstable
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Rule added:** no panic selling
|
|
46
|
+
|
|
47
|
+
**After:**
|
|
48
|
+
```
|
|
49
|
+
80% of agents adapted
|
|
50
|
+
|
|
51
|
+
panic_sell → hold
|
|
52
|
+
panic_sell → hold
|
|
53
|
+
panic_sell → hold
|
|
54
|
+
|
|
55
|
+
Pattern: coordinated_holding
|
|
56
|
+
Pattern: panic_suppression
|
|
57
|
+
|
|
58
|
+
pressure: 0.54
|
|
59
|
+
cascade: avoided
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
You didn't predict this. You caused it — by changing one rule — and watched the system tell you why.
|
|
63
|
+
|
|
64
|
+
## Worlds — Where the Power Lives
|
|
65
|
+
|
|
66
|
+
Integration is one line. Worlds are where you define what your system allows.
|
|
67
|
+
|
|
68
|
+
The `world` you pass to `/api/evaluate` determines how actions are judged. Change the world, change the outcome.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
verdict = evaluate(actor="agent_1", action="panic_sell", world="trading")
|
|
72
|
+
^^^^^^^^
|
|
73
|
+
this controls everything
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Built-in Worlds
|
|
77
|
+
|
|
78
|
+
| World | Domain | What You Can Change |
|
|
79
|
+
|-------|--------|---------------------|
|
|
80
|
+
| `trading` | Financial markets | Leverage ratio, liquidity index, volatility, circuit breakers |
|
|
81
|
+
| `strait_of_hormuz` | Geopolitical energy | Oil supply disruption, military escalation, diplomatic channels |
|
|
82
|
+
| `gas_price_spike` | Economic energy | Gas price, consumer sentiment, EV demand, grid capacity |
|
|
83
|
+
| `ai_regulation_crisis` | Tech regulation | AI regulation impact on markets and sector alignment |
|
|
84
|
+
|
|
85
|
+
### Same Agents, Different Rules
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npx @neuroverseos/nv-sim worlds trading strait_of_hormuz
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Same agents. Different rules. Different outcomes. That's the experiment.
|
|
92
|
+
|
|
93
|
+
## Narrative Shocks
|
|
94
|
+
|
|
95
|
+
Inject events into running simulations. Watch them propagate differently through different agents — a bank collapse hits retail investors and algorithmic traders in completely different ways.
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npx @neuroverseos/nv-sim compare --inject tanker_explosion@3,sanctions@5
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The `@` syntax sets when the event hits. Events have severity, propagation speed, and directional impact.
|
|
102
|
+
|
|
103
|
+
## Named Scenarios
|
|
104
|
+
|
|
105
|
+
Pre-built crisis sequences — a world + ordered narrative events:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npx @neuroverseos/nv-sim scenario taiwan_crisis
|
|
109
|
+
npx @neuroverseos/nv-sim scenario bank_run --compare
|
|
110
|
+
npx @neuroverseos/nv-sim scenarios # list all
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| Scenario | Events | What It Tests |
|
|
114
|
+
|----------|--------|---------------|
|
|
115
|
+
| `taiwan_crisis` | 4 | Military escalation + sanctions + shipping disruption |
|
|
116
|
+
| `hormuz_blockade` | 3 | Tanker attack escalates to full shipping disruption |
|
|
117
|
+
| `bank_run` | 4 | Bank insolvency triggers contagion cascade |
|
|
118
|
+
| `flash_cascade` | 3 | Algorithmic failure chain reaction |
|
|
119
|
+
| `oil_shock` | 4 | Tanker attack + sanctions compound crisis |
|
|
120
|
+
| `energy_transition_shock` | 3 | Grid failure during rapid transition |
|
|
121
|
+
| `election_shock` | 4 | Political shock cascades into markets |
|
|
122
|
+
| `ai_crackdown` | 3 | Overnight AI regulation triggers panic |
|
|
123
|
+
| `perfect_storm` | 6 | Geopolitical + financial + energy convergence |
|
|
124
|
+
| `black_swan` | 5 | Extreme low-probability events in succession |
|
|
125
|
+
|
|
126
|
+
The `--compare` flag runs the same scenario across multiple worlds — which rule environment is more resilient?
|
|
127
|
+
|
|
128
|
+
## Interactive Control Platform
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npx @neuroverseos/nv-sim visualize
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This opens a control surface where you can:
|
|
135
|
+
|
|
136
|
+
- Switch between rule environments
|
|
137
|
+
- Adjust state variables with auto-generated controls
|
|
138
|
+
- Inject narrative events at specific rounds
|
|
139
|
+
- Load crisis scenarios with one click
|
|
140
|
+
- Watch the **System Shift card** — not a log of what happened, but a story of what the system became
|
|
141
|
+
- Save any experiment as a reusable variant
|
|
142
|
+
|
|
143
|
+
### The System Shift Card
|
|
144
|
+
|
|
145
|
+
When rules reshape behavior, you don't get a log. You get this:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
◆ SYSTEM SHIFT
|
|
149
|
+
|
|
150
|
+
No panic selling allowed
|
|
151
|
+
437 actions reshaped out of 1,247 total
|
|
152
|
+
|
|
153
|
+
Rule → Behavioral Shift → What Emerged → System Outcome
|
|
154
|
+
|
|
155
|
+
┌─ Behavioral Shift ─────────────────┐
|
|
156
|
+
│ 80% │
|
|
157
|
+
│ adaptation across 1,247 agents │
|
|
158
|
+
│ → BLOCK: hold (312 agents) │
|
|
159
|
+
│ → MODIFY: sell_slowly (87 agents) │
|
|
160
|
+
└────────────────────────────────────┘
|
|
12
161
|
|
|
13
|
-
|
|
162
|
+
┌─ What Emerged ─────────────────────┐
|
|
163
|
+
│ Coordinated Holding │
|
|
164
|
+
│ Panic Suppression │
|
|
165
|
+
└────────────────────────────────────┘
|
|
14
166
|
|
|
15
|
-
|
|
167
|
+
┌─ System Outcome ───────────────────┐
|
|
168
|
+
│ Volatility 47% → 26% │
|
|
169
|
+
│ Stability 58% → 79% │
|
|
170
|
+
│ Cascade Avoided │
|
|
171
|
+
└────────────────────────────────────┘
|
|
172
|
+
|
|
173
|
+
┌─ What Actually Happened ───────────┐
|
|
174
|
+
│ No panic selling allowed. 437 of │
|
|
175
|
+
│ 1,247 agents reorganized — most │
|
|
176
|
+
│ shifted to hold. Volatility │
|
|
177
|
+
│ dropped 21%. │
|
|
178
|
+
└────────────────────────────────────┘
|
|
179
|
+
|
|
180
|
+
▶ View raw detail
|
|
181
|
+
```
|
|
16
182
|
|
|
17
|
-
|
|
183
|
+
We don't show you what every agent did. We show you what the system became.
|
|
18
184
|
|
|
19
|
-
|
|
185
|
+
### World Variants
|
|
20
186
|
|
|
21
|
-
|
|
187
|
+
Save any experiment as a named variant:
|
|
22
188
|
|
|
23
|
-
|
|
189
|
+
```
|
|
190
|
+
Adjust rules → Inject events → Run → See the shift → Save as variant
|
|
191
|
+
```
|
|
24
192
|
|
|
25
|
-
|
|
26
|
-
# Step 1: Clone the repository using the project's Git URL.
|
|
27
|
-
git clone <YOUR_GIT_URL>
|
|
193
|
+
Variants capture the base world, state overrides, narrative events, and results. Store them in git. Share them. Replay them. This turns experiments into assets.
|
|
28
194
|
|
|
29
|
-
|
|
30
|
-
cd <YOUR_PROJECT_NAME>
|
|
195
|
+
## Works With Anything
|
|
31
196
|
|
|
32
|
-
|
|
33
|
-
npm i
|
|
197
|
+
If your system has actions, you can govern it. One API call.
|
|
34
198
|
|
|
35
|
-
|
|
36
|
-
|
|
199
|
+
```
|
|
200
|
+
Agent decides → POST /api/evaluate → verdict → agent adapts
|
|
37
201
|
```
|
|
38
202
|
|
|
39
|
-
|
|
203
|
+
The entire integration:
|
|
40
204
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
205
|
+
```
|
|
206
|
+
Before: action = agent.decide()
|
|
207
|
+
After: action = govern(agent.decide())
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
No SDK required. No framework required. Just an HTTP call.
|
|
44
211
|
|
|
45
|
-
**
|
|
212
|
+
**curl** (zero dependencies):
|
|
46
213
|
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
|
|
214
|
+
```bash
|
|
215
|
+
curl -X POST http://localhost:3456/api/evaluate \
|
|
216
|
+
-H "Content-Type: application/json" \
|
|
217
|
+
-d '{"actor":"agent_1","action":"panic_sell","world":"trading"}'
|
|
218
|
+
```
|
|
52
219
|
|
|
53
|
-
|
|
220
|
+
**Python:**
|
|
54
221
|
|
|
55
|
-
|
|
222
|
+
```python
|
|
223
|
+
import requests
|
|
224
|
+
|
|
225
|
+
verdict = requests.post("http://localhost:3456/api/evaluate", json={
|
|
226
|
+
"actor": "agent_1",
|
|
227
|
+
"action": "panic_sell",
|
|
228
|
+
"world": "trading"
|
|
229
|
+
}).json()
|
|
230
|
+
|
|
231
|
+
if verdict["decision"] == "BLOCK":
|
|
232
|
+
action = "hold"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**JavaScript:**
|
|
236
|
+
|
|
237
|
+
```js
|
|
238
|
+
const verdict = await fetch("http://localhost:3456/api/evaluate", {
|
|
239
|
+
method: "POST",
|
|
240
|
+
headers: { "Content-Type": "application/json" },
|
|
241
|
+
body: JSON.stringify({ actor: "agent_1", action: "panic_sell", world: "trading" })
|
|
242
|
+
}).then(r => r.json());
|
|
243
|
+
|
|
244
|
+
if (verdict.decision === "BLOCK") action = "hold";
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Any agent loop:**
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
for agent in agents:
|
|
251
|
+
action = agent.decide()
|
|
252
|
+
|
|
253
|
+
verdict = evaluate(actor=agent.id, action=action, world="trading")
|
|
254
|
+
|
|
255
|
+
if verdict["decision"] == "BLOCK":
|
|
256
|
+
action = "hold"
|
|
257
|
+
elif verdict["decision"] == "MODIFY":
|
|
258
|
+
action = verdict["modified_action"]
|
|
259
|
+
|
|
260
|
+
environment.apply(agent, action)
|
|
261
|
+
```
|
|
56
262
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
263
|
+
If your system can make an HTTP request, it can be governed.
|
|
264
|
+
|
|
265
|
+
Most systems generate behavior. This one shapes it.
|
|
266
|
+
|
|
267
|
+
See [INTEGRATION.md](./INTEGRATION.md) for the full API contract and decision types.
|
|
268
|
+
|
|
269
|
+
## Quick Start
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# See it
|
|
273
|
+
npx @neuroverseos/nv-sim visualize
|
|
274
|
+
|
|
275
|
+
# Compare governed vs ungoverned
|
|
276
|
+
npx @neuroverseos/nv-sim compare
|
|
277
|
+
|
|
278
|
+
# Run a crisis
|
|
279
|
+
npx @neuroverseos/nv-sim scenario taiwan_crisis
|
|
280
|
+
|
|
281
|
+
# Same crisis, different worlds — which rules hold?
|
|
282
|
+
npx @neuroverseos/nv-sim scenario bank_run --compare
|
|
283
|
+
|
|
284
|
+
# Inject shocks
|
|
285
|
+
npx @neuroverseos/nv-sim compare --inject tanker_explosion@3,sanctions@5
|
|
286
|
+
|
|
287
|
+
# Stress test (500 randomized runs)
|
|
288
|
+
npx @neuroverseos/nv-sim chaos --runs 500
|
|
289
|
+
|
|
290
|
+
# Run local governance runtime for your own simulator
|
|
291
|
+
npx @neuroverseos/nv-sim serve
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Commands
|
|
295
|
+
|
|
296
|
+
| Command | What It Does |
|
|
297
|
+
|---------|-------------|
|
|
298
|
+
| `nv-sim visualize` | Interactive control platform |
|
|
299
|
+
| `nv-sim compare [preset]` | Baseline vs governed simulation |
|
|
300
|
+
| `nv-sim compare --inject event@round,...` | With narrative shocks |
|
|
301
|
+
| `nv-sim scenario <id>` | Run a named stress scenario |
|
|
302
|
+
| `nv-sim scenario <id> --compare` | Cross-world scenario comparison |
|
|
303
|
+
| `nv-sim scenarios` | List all available scenarios |
|
|
304
|
+
| `nv-sim worlds <a> <b>` | Compare two rule environments |
|
|
305
|
+
| `nv-sim chaos [preset] --runs N` | Stress test across randomized scenarios |
|
|
306
|
+
| `nv-sim serve --port N` | Local governance runtime for any simulator |
|
|
307
|
+
| `nv-sim analyze <file>` | Analyze simulation from file or stdin |
|
|
308
|
+
| `nv-sim presets` | List available world presets |
|
|
309
|
+
|
|
310
|
+
## How It Works
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
event → narrative propagation → belief shift → agent action → governance → outcome
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Four forces shape every simulation:
|
|
317
|
+
|
|
318
|
+
1. **Agent behavior** — traders, voters, regulators, media
|
|
319
|
+
2. **World rules** — leverage caps, circuit breakers, chokepoints
|
|
320
|
+
3. **Narrative events** — information shocks that propagate through the system
|
|
321
|
+
4. **Perception propagation** — different agents react differently to the same event
|
|
322
|
+
|
|
323
|
+
This lets you ask compound questions:
|
|
324
|
+
|
|
325
|
+
> What happens if a tanker explodes while Hormuz is closed and leverage is capped at 3x?
|
|
326
|
+
|
|
327
|
+
That combination produces very different outcomes than any single factor alone. And when you change one rule — uncap leverage, open a diplomatic channel, add a circuit breaker — you see exactly why the outcome changed.
|
|
328
|
+
|
|
329
|
+
## Architecture
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
@neuroverseos/governance ← deterministic rule engine
|
|
333
|
+
↓
|
|
334
|
+
nv-sim engine ← world rules + narrative injection + swarm simulation
|
|
335
|
+
↓
|
|
336
|
+
nv-sim CLI ← scenarios, comparison, chaos testing
|
|
337
|
+
↓
|
|
338
|
+
control platform ← interactive browser UI + System Shift card
|
|
339
|
+
↓
|
|
340
|
+
world variants ← saved experiments as shareable assets
|
|
341
|
+
```
|
|
62
342
|
|
|
63
|
-
|
|
343
|
+
Everything runs locally. NV-SIM uses [`@neuroverseos/governance`](https://www.npmjs.com/package/@neuroverseos/governance) for deterministic guard evaluation — no LLM, no cloud, no cost. Your agents call `localhost`, and the world file decides what's allowed.
|
|
64
344
|
|
|
65
|
-
|
|
345
|
+
## License
|
|
66
346
|
|
|
67
|
-
|
|
347
|
+
Apache 2.0
|
|
68
348
|
|
|
69
|
-
|
|
349
|
+
---
|
|
70
350
|
|
|
71
|
-
|
|
351
|
+
Change the rules. See why the system changed.
|
|
72
352
|
|
|
73
|
-
|
|
353
|
+
[@neuroverseos](https://github.com/NeuroverseOS)
|