@neuroverseos/nv-sim 0.1.2 → 0.1.5
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 +562 -68
- package/dist/adapters/mirofish.js +461 -0
- package/dist/adapters/scienceclaw.js +750 -0
- package/dist/assets/index-B64NuIXu.css +1 -0
- package/dist/assets/index-DbzSnYxr.js +532 -0
- package/dist/assets/mirotir-logo-DUexumBH.svg +185 -0
- package/dist/assets/reportEngine-DKWTrP6-.js +1 -0
- package/dist/components/ConstraintsPanel.js +11 -0
- package/dist/components/StakeholderBuilder.js +32 -0
- package/dist/components/ui/badge.js +24 -0
- package/dist/components/ui/button.js +70 -0
- package/dist/components/ui/card.js +57 -0
- package/dist/components/ui/input.js +44 -0
- package/dist/components/ui/label.js +45 -0
- package/dist/components/ui/select.js +70 -0
- package/dist/engine/aiProvider.js +681 -0
- package/dist/engine/auditTrace.js +352 -0
- package/dist/engine/behavioralAnalysis.js +605 -0
- package/dist/engine/cli.js +1408 -299
- package/dist/engine/dynamicsGovernance.js +588 -0
- package/dist/engine/fullGovernedLoop.js +367 -0
- package/dist/engine/governance.js +8 -3
- package/dist/engine/governedSimulation.js +114 -17
- package/dist/engine/index.js +56 -1
- package/dist/engine/liveAdapter.js +342 -0
- package/dist/engine/liveVisualizer.js +4284 -0
- package/dist/engine/metrics/science.metrics.js +335 -0
- package/dist/engine/narrativeInjection.js +360 -0
- package/dist/engine/policyEnforcement.js +1611 -0
- package/dist/engine/policyEngine.js +799 -0
- package/dist/engine/primeRadiant.js +540 -0
- package/dist/engine/reasoningEngine.js +57 -3
- package/dist/engine/reportEngine.js +97 -0
- package/dist/engine/scenarioCapsule.js +56 -0
- package/dist/engine/scenarioComparison.js +463 -0
- package/dist/engine/scenarioLibrary.js +248 -0
- package/dist/engine/swarmSimulation.js +54 -1
- package/dist/engine/worldComparison.js +358 -0
- package/dist/engine/worldStorage.js +232 -0
- package/dist/favicon.ico +0 -0
- package/dist/index.html +23 -0
- package/dist/lib/reasoningEngine.js +290 -0
- package/dist/lib/simulationAdapter.js +686 -0
- package/dist/lib/swarmParser.js +291 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/utils.js +8 -0
- package/dist/placeholder.svg +1 -0
- package/dist/robots.txt +14 -0
- package/dist/runtime/govern.js +473 -0
- package/dist/runtime/index.js +75 -0
- package/dist/runtime/types.js +11 -0
- package/package.json +17 -12
- package/variants/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -1,130 +1,624 @@
|
|
|
1
|
-
# NV-SIM
|
|
1
|
+
# NV-SIM
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Change the rules. See why the system changed.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npx @neuroverseos/nv-sim visualize
|
|
7
|
+
```
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## The Problem With Agentic Simulation Today
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
You build a multi-agent system. You run it. You get metrics — loss curves, reward signals, completion rates. Something goes wrong, or something goes right, and you ask the only question that matters:
|
|
12
|
+
|
|
13
|
+
*Why did the agents do that?*
|
|
14
|
+
|
|
15
|
+
Nobody can tell you. The metrics say *what* happened. The logs say *when* it happened. But nothing tells you *why agents changed their behavior* — which rule caused it, which agents shifted first, what strategy they abandoned, and what they replaced it with.
|
|
16
|
+
|
|
17
|
+
So you rerun. You tweak. You guess. You stare at dashboards full of numbers that describe the system but never explain it.
|
|
18
|
+
|
|
19
|
+
That's the gap.
|
|
20
|
+
|
|
21
|
+
## What NV-SIM Gives You That Nothing Else Does
|
|
22
|
+
|
|
23
|
+
NV-SIM doesn't predict outcomes. It shows you **why agents behaved the way they did** — and what happens when you change the rules.
|
|
24
|
+
|
|
25
|
+
You change one constraint — block panic selling, cap leverage at 3x, close a shipping lane — and the system shows you:
|
|
26
|
+
|
|
27
|
+
- **Before → After proof**: "80% of agents shifted from panic selling to coordinated holding"
|
|
28
|
+
- **Emergent patterns**: "Panic suppression appeared — not programmed, not predicted"
|
|
29
|
+
- **Causal chains**: "Agents became more cautious after early aggressive attempts failed"
|
|
30
|
+
- **Quantified outcomes**: "Volatility dropped 21%, cascade avoided"
|
|
10
31
|
|
|
11
|
-
```
|
|
12
|
-
|
|
32
|
+
```
|
|
33
|
+
Rule changed
|
|
34
|
+
→ Agents shifted strategy
|
|
35
|
+
→ New patterns emerged
|
|
36
|
+
→ System outcome changed
|
|
37
|
+
→ You know exactly why
|
|
13
38
|
```
|
|
14
39
|
|
|
15
|
-
|
|
40
|
+
This is behavioral evidence, not metrics. You don't get a number — you get a story you can trace, verify, and share.
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
It changes the structure of the system itself.
|
|
42
|
+
### For researchers
|
|
19
43
|
|
|
20
|
-
|
|
44
|
+
You get **controlled behavioral experiments** on complex systems. Same agents, different rules, measured side by side. The output isn't a chart — it's proof of what changed and why.
|
|
45
|
+
|
|
46
|
+
### For developers
|
|
47
|
+
|
|
48
|
+
You get **runtime governance** for any agent system. One HTTP call between "agent decides" and "agent acts." Your agents become observable, auditable, and controllable — without rewriting your framework.
|
|
49
|
+
|
|
50
|
+
### For both
|
|
51
|
+
|
|
52
|
+
You get something that didn't exist before: **rule-to-behavior causation**. Not correlation. Not post-hoc analysis. Direct, traceable proof that changing rule X caused agents to shift from behavior A to behavior B.
|
|
53
|
+
|
|
54
|
+
## The Demo Moment
|
|
55
|
+
|
|
56
|
+
**Before:**
|
|
57
|
+
```
|
|
58
|
+
panic_sell → panic_sell → panic_sell
|
|
59
|
+
pressure: 0.94
|
|
60
|
+
system: unstable
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Rule added:** no panic selling
|
|
64
|
+
|
|
65
|
+
**After:**
|
|
66
|
+
```
|
|
67
|
+
Market stabilized as agents shifted toward safer positions
|
|
68
|
+
|
|
69
|
+
panic_sell → hold
|
|
70
|
+
panic_sell → hold
|
|
71
|
+
panic_sell → hold
|
|
72
|
+
|
|
73
|
+
80% of agents shifted from aggressive to conservative strategies
|
|
74
|
+
Uncertainty dropped 34% as agents moved from exploration to caution
|
|
75
|
+
|
|
76
|
+
WHY: Agents became more cautious after early attempts failed
|
|
77
|
+
|
|
78
|
+
Pattern: coordinated_holding
|
|
79
|
+
Pattern: panic_suppression
|
|
80
|
+
|
|
81
|
+
pressure: 0.54
|
|
82
|
+
cascade: avoided
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
You didn't predict this. You caused it — by changing one rule — and the system told you exactly why.
|
|
86
|
+
|
|
87
|
+
## What This Actually Is
|
|
88
|
+
|
|
89
|
+
Most simulation tools answer: *"What will happen?"*
|
|
90
|
+
|
|
91
|
+
NV-SIM answers: *"What changes when I change the rules — and why?"*
|
|
92
|
+
|
|
93
|
+
You're not forecasting. You're running controlled behavioral experiments. Every simulation produces:
|
|
94
|
+
|
|
95
|
+
| What You Get | What It Proves |
|
|
96
|
+
|---|---|
|
|
97
|
+
| **Outcome statement** | System state + dominant agent behavior in one sentence |
|
|
98
|
+
| **Behavioral shifts** | Before → after for every agent group, with percentages |
|
|
99
|
+
| **Causal explanation** | Why agents changed — in their experience, not system jargon |
|
|
100
|
+
| **Confidence rating** | How strong the evidence is, how much risk remains |
|
|
101
|
+
| **Full audit trail** | Every decision, every rule, every adaptation — append-only |
|
|
102
|
+
|
|
103
|
+
The output is designed to be specific, narrative, and shareable. Not "40% adjusted actions" — but "40% shifted from aggressive to conservative strategies after early attempts failed."
|
|
104
|
+
|
|
105
|
+
## Design the Rules Once. Run Them Anywhere.
|
|
106
|
+
|
|
107
|
+
NV-SIM is a runtime, not just a simulator. It runs in two modes:
|
|
108
|
+
|
|
109
|
+
- **Simulate** — explore how agents behave under different rules
|
|
110
|
+
- **Act** — govern real agents, real workflows, real decisions in production
|
|
111
|
+
|
|
112
|
+
The interface is the same. The difference is where the agents come from.
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Simulate → internal swarm engine (built-in agents, instant results)
|
|
116
|
+
Act → your system (any framework, any language, one HTTP call)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The same world file can simulate a crisis, govern a live system, and produce comparable outcomes across both. This means the experiments you run in simulation directly translate to the rules you deploy in production.
|
|
120
|
+
|
|
121
|
+
## Behavioral Analysis — The Proof Layer
|
|
122
|
+
|
|
123
|
+
Blocking actions is easy. The hard part is proving what changed and why. NV-SIM doesn't just count actions — it tracks how agents actually reorganized.
|
|
124
|
+
|
|
125
|
+
Every simulation produces behavioral evidence:
|
|
21
126
|
|
|
22
|
-
|
|
127
|
+
- **Action classification** — each agent action categorized as aggressive, defensive, cautious, cooperative, opportunistic, or neutral
|
|
128
|
+
- **Agent trajectories** — each agent's behavior traced across rounds, showing when and how they shifted
|
|
129
|
+
- **Behavioral shifts** — the exact moment agents changed strategy, with before → after
|
|
130
|
+
- **Cross-run comparison** — same agents under different rules, measured side by side
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
BEHAVIORAL ANALYSIS
|
|
134
|
+
|
|
135
|
+
Action Distribution:
|
|
136
|
+
aggressive: 12% (was 67%)
|
|
137
|
+
cooperative: 41% (was 8%)
|
|
138
|
+
cautious: 31% (was 11%)
|
|
139
|
+
defensive: 16% (was 14%)
|
|
140
|
+
|
|
141
|
+
Shifts Detected:
|
|
142
|
+
→ 80% shifted from aggressive to cooperative after round 3
|
|
143
|
+
→ Panic selling replaced by coordinated holding
|
|
144
|
+
→ New pattern: quality_competition (not present in baseline)
|
|
145
|
+
|
|
146
|
+
Trajectory: agent_hedge_fund_1
|
|
147
|
+
Round 1: aggressive → Round 2: aggressive → Round 3: [shifted] → Round 4: cautious → Round 5: cooperative
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The behavioral shift is the insight. You changed a rule, and the system tells you exactly who changed, when they changed, and what they changed to.
|
|
151
|
+
|
|
152
|
+
## Audit Trail — Full Evidence Chain
|
|
153
|
+
|
|
154
|
+
Every decision is recorded in an append-only audit log. Every rule, every agent action, every adaptation — persistent and queryable.
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
AUDIT TRAIL (session: 2026-03-18T14:22:00)
|
|
158
|
+
|
|
159
|
+
agent_hedge_fund_1 → attempted panic_sell → blocked
|
|
160
|
+
rule: no_panic_selling (invariant)
|
|
161
|
+
evidence: action matches blocked pattern during high volatility
|
|
162
|
+
|
|
163
|
+
agent_hedge_fund_1 → shifted to hold
|
|
164
|
+
adapted: true (shifted from aggressive to defensive)
|
|
165
|
+
|
|
166
|
+
BEHAVIORAL SHIFT: agent_hedge_fund_1
|
|
167
|
+
before: aggressive | after: cautious
|
|
168
|
+
trigger: early aggressive attempts failed at round 3
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Stored as JSONL — one JSON object per line, human-readable, pipeable through `jq`. No cloud, no deletion. Complete evidence chain.
|
|
172
|
+
|
|
173
|
+
## Worlds — Where the Power Lives
|
|
174
|
+
|
|
175
|
+
The `world` you pass controls everything. Change the world, change the outcome.
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
verdict = evaluate(actor="agent_1", action="panic_sell", world="trading")
|
|
179
|
+
^^^^^^^^
|
|
180
|
+
this controls everything
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Built-in Worlds
|
|
184
|
+
|
|
185
|
+
| World | Domain | What You Can Change |
|
|
186
|
+
|-------|--------|---------------------|
|
|
187
|
+
| `trading` | Financial markets | Leverage ratio, liquidity index, volatility, circuit breakers |
|
|
188
|
+
| `strait_of_hormuz` | Geopolitical energy | Oil supply disruption, military escalation, diplomatic channels |
|
|
189
|
+
| `gas_price_spike` | Economic energy | Gas price, consumer sentiment, EV demand, grid capacity |
|
|
190
|
+
| `ai_regulation_crisis` | Tech regulation | AI regulation impact on markets and sector alignment |
|
|
191
|
+
|
|
192
|
+
### Same Agents, Different Rules
|
|
23
193
|
|
|
24
194
|
```bash
|
|
25
|
-
npx @neuroverseos/nv-sim
|
|
195
|
+
npx @neuroverseos/nv-sim worlds trading strait_of_hormuz
|
|
26
196
|
```
|
|
27
197
|
|
|
28
|
-
|
|
198
|
+
Same agents. Different rules. Different outcomes. That's the experiment.
|
|
199
|
+
|
|
200
|
+
## Narrative Shocks
|
|
201
|
+
|
|
202
|
+
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.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npx @neuroverseos/nv-sim compare --inject tanker_explosion@3,sanctions@5
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The `@` syntax sets when the event hits. Events have severity, propagation speed, and directional impact.
|
|
209
|
+
|
|
210
|
+
## Named Scenarios
|
|
211
|
+
|
|
212
|
+
Pre-built crisis sequences — a world + ordered narrative events:
|
|
29
213
|
|
|
30
214
|
```bash
|
|
31
|
-
npx @neuroverseos/nv-sim
|
|
215
|
+
npx @neuroverseos/nv-sim scenario taiwan_crisis
|
|
216
|
+
npx @neuroverseos/nv-sim scenario bank_run --compare
|
|
217
|
+
npx @neuroverseos/nv-sim scenarios # list all
|
|
32
218
|
```
|
|
33
219
|
|
|
34
|
-
|
|
220
|
+
| Scenario | Events | What It Tests |
|
|
221
|
+
|----------|--------|---------------|
|
|
222
|
+
| `taiwan_crisis` | 4 | Military escalation + sanctions + shipping disruption |
|
|
223
|
+
| `hormuz_blockade` | 3 | Tanker attack escalates to full shipping disruption |
|
|
224
|
+
| `bank_run` | 4 | Bank insolvency triggers contagion cascade |
|
|
225
|
+
| `flash_cascade` | 3 | Algorithmic failure chain reaction |
|
|
226
|
+
| `oil_shock` | 4 | Tanker attack + sanctions compound crisis |
|
|
227
|
+
| `energy_transition_shock` | 3 | Grid failure during rapid transition |
|
|
228
|
+
| `election_shock` | 4 | Political shock cascades into markets |
|
|
229
|
+
| `ai_crackdown` | 3 | Overnight AI regulation triggers panic |
|
|
230
|
+
| `perfect_storm` | 6 | Geopolitical + financial + energy convergence |
|
|
231
|
+
| `black_swan` | 5 | Extreme low-probability events in succession |
|
|
232
|
+
|
|
233
|
+
The `--compare` flag runs the same scenario across multiple worlds — which rule environment is more resilient?
|
|
234
|
+
|
|
235
|
+
## Interactive Control Platform
|
|
35
236
|
|
|
36
237
|
```bash
|
|
37
238
|
npx @neuroverseos/nv-sim visualize
|
|
38
239
|
```
|
|
39
240
|
|
|
40
|
-
|
|
241
|
+
This opens a control surface where you can:
|
|
242
|
+
|
|
243
|
+
- Switch between rule environments
|
|
244
|
+
- Adjust state variables with auto-generated controls
|
|
245
|
+
- Inject narrative events at specific rounds
|
|
246
|
+
- Load crisis scenarios with one click
|
|
247
|
+
- Watch the **Outcome Panel** — not a log of what happened, but a story of what the system became and why
|
|
248
|
+
- Save any experiment as a reusable variant
|
|
249
|
+
|
|
250
|
+
### The Outcome Panel
|
|
251
|
+
|
|
252
|
+
When rules reshape behavior, you don't get a dashboard of metrics. You get this:
|
|
253
|
+
|
|
254
|
+
```
|
|
255
|
+
◆ OUTCOME
|
|
256
|
+
|
|
257
|
+
Market stabilized as agents shifted toward safer positions
|
|
258
|
+
|
|
259
|
+
Confidence: Strong | Evidence: Solid | Risk: Low
|
|
260
|
+
|
|
261
|
+
┌─ What Agents Did ────────────────┐
|
|
262
|
+
│ 80% shifted from aggressive to │
|
|
263
|
+
│ conservative strategies │
|
|
264
|
+
│ 12% reduced position size after │
|
|
265
|
+
│ initial attempts failed │
|
|
266
|
+
│ 8% maintained original strategy │
|
|
267
|
+
└──────────────────────────────────┘
|
|
268
|
+
|
|
269
|
+
┌─ Why This Happened ──────────────┐
|
|
270
|
+
│ Early aggressive attempts failed,│
|
|
271
|
+
│ forcing agents to rethink. │
|
|
272
|
+
│ Uncertainty dropped as agents │
|
|
273
|
+
│ stopped experimenting. │
|
|
274
|
+
└──────────────────────────────────┘
|
|
275
|
+
|
|
276
|
+
┌─ What Emerged ───────────────────┐
|
|
277
|
+
│ Coordinated Holding │
|
|
278
|
+
│ Panic Suppression │
|
|
279
|
+
└──────────────────────────────────┘
|
|
280
|
+
|
|
281
|
+
┌─ System Outcome ─────────────────┐
|
|
282
|
+
│ Volatility 47% → 26% │
|
|
283
|
+
│ Stability 58% → 79% │
|
|
284
|
+
│ Cascade Avoided │
|
|
285
|
+
└──────────────────────────────────┘
|
|
286
|
+
|
|
287
|
+
▶ View audit trail
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Every line is specific. Every line is shareable. No system jargon.
|
|
291
|
+
|
|
292
|
+
### World Variants
|
|
41
293
|
|
|
42
|
-
|
|
294
|
+
Save any experiment as a named variant:
|
|
43
295
|
|
|
44
|
-
|
|
296
|
+
```
|
|
297
|
+
Adjust rules → Inject events → Run → See what changed → Save as variant
|
|
298
|
+
```
|
|
45
299
|
|
|
46
|
-
|
|
47
|
-
But they cannot enforce rules.
|
|
300
|
+
Variants capture the base world, state overrides, narrative events, and results. Store them in git. Share them. Replay them. This turns experiments into assets.
|
|
48
301
|
|
|
49
|
-
|
|
302
|
+
## Governance Runtime — Plug Into Your Own System
|
|
50
303
|
|
|
51
|
-
|
|
52
|
-
|
|
304
|
+
```bash
|
|
305
|
+
npx @neuroverseos/nv-sim serve
|
|
306
|
+
```
|
|
53
307
|
|
|
54
|
-
|
|
308
|
+
This starts a local server. Any simulator, agent framework, or application can POST actions and get decisions back.
|
|
55
309
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
310
|
+
```
|
|
311
|
+
Endpoint: http://localhost:3456/api/evaluate
|
|
312
|
+
Method: POST
|
|
313
|
+
Contract: { actor, action, payload?, state?, world? }
|
|
314
|
+
Response: { decision: ALLOW|BLOCK|MODIFY, reason, evidence }
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Your agents call localhost. The world file decides what's allowed. No cloud. No cost.
|
|
318
|
+
|
|
319
|
+
Additional endpoints:
|
|
63
320
|
|
|
64
|
-
|
|
321
|
+
| Endpoint | What It Does |
|
|
322
|
+
|----------|-------------|
|
|
323
|
+
| `POST /api/evaluate` | Submit an action for evaluation |
|
|
324
|
+
| `GET /api/session` | Current session stats |
|
|
325
|
+
| `GET /api/session/report` | Full session report |
|
|
326
|
+
| `POST /api/session/reset` | Reset session state |
|
|
327
|
+
| `POST /api/session/save` | Save session as experiment |
|
|
328
|
+
| `GET /api/events` | SSE stream of live events |
|
|
65
329
|
|
|
66
|
-
|
|
67
|
-
|--------|----------|
|
|
68
|
-
| `trading` | Flash crash — algorithmic cascade (default) |
|
|
69
|
-
| `strait_of_hormuz` | Geopolitical energy crisis |
|
|
70
|
-
| `gas_price_spike` | Economic energy shock |
|
|
71
|
-
| `ai_regulation_crisis` | AI regulation impact |
|
|
330
|
+
### Works With Anything
|
|
72
331
|
|
|
73
|
-
|
|
332
|
+
If your system has actions, you can govern them. One API call.
|
|
74
333
|
|
|
75
334
|
```
|
|
76
|
-
|
|
335
|
+
Agent decides → POST /api/evaluate → verdict → agent adapts
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
The entire integration:
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
Before: action = agent.decide()
|
|
342
|
+
After: action = govern(agent.decide())
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
No SDK required. No framework required. Just an HTTP call.
|
|
346
|
+
|
|
347
|
+
**curl** (zero dependencies):
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
curl -X POST http://localhost:3456/api/evaluate \
|
|
351
|
+
-H "Content-Type: application/json" \
|
|
352
|
+
-d '{"actor":"agent_1","action":"panic_sell","world":"trading"}'
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**Python:**
|
|
356
|
+
|
|
357
|
+
```python
|
|
358
|
+
import requests
|
|
359
|
+
|
|
360
|
+
verdict = requests.post("http://localhost:3456/api/evaluate", json={
|
|
361
|
+
"actor": "agent_1",
|
|
362
|
+
"action": "panic_sell",
|
|
363
|
+
"world": "trading"
|
|
364
|
+
}).json()
|
|
365
|
+
|
|
366
|
+
if verdict["decision"] == "BLOCK":
|
|
367
|
+
action = "hold"
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**JavaScript:**
|
|
371
|
+
|
|
372
|
+
```js
|
|
373
|
+
const verdict = await fetch("http://localhost:3456/api/evaluate", {
|
|
374
|
+
method: "POST",
|
|
375
|
+
headers: { "Content-Type": "application/json" },
|
|
376
|
+
body: JSON.stringify({ actor: "agent_1", action: "panic_sell", world: "trading" })
|
|
377
|
+
}).then(r => r.json());
|
|
378
|
+
|
|
379
|
+
if (verdict.decision === "BLOCK") action = "hold";
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
**Any agent loop:**
|
|
383
|
+
|
|
384
|
+
```python
|
|
385
|
+
for agent in agents:
|
|
386
|
+
action = agent.decide()
|
|
77
387
|
|
|
78
|
-
|
|
79
|
-
Stability: 80%
|
|
80
|
-
Volatility: 56%
|
|
81
|
-
Coalition risks: 2
|
|
388
|
+
verdict = evaluate(actor=agent.id, action=action, world="trading")
|
|
82
389
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
390
|
+
if verdict["decision"] == "BLOCK":
|
|
391
|
+
action = "hold"
|
|
392
|
+
elif verdict["decision"] == "MODIFY":
|
|
393
|
+
action = verdict["modified_action"]
|
|
87
394
|
|
|
88
|
-
|
|
89
|
-
Stability: +9 percentage points
|
|
90
|
-
Volatility: -25%
|
|
91
|
-
Coalition risks: 2 eliminated
|
|
395
|
+
environment.apply(agent, action)
|
|
92
396
|
```
|
|
93
397
|
|
|
94
|
-
|
|
398
|
+
If your system can make an HTTP request, it can be governed.
|
|
95
399
|
|
|
96
|
-
|
|
400
|
+
Most systems generate behavior. This one shapes it.
|
|
401
|
+
|
|
402
|
+
See [INTEGRATION.md](./INTEGRATION.md) for the full API contract, framework guides, and decision types.
|
|
403
|
+
|
|
404
|
+
## Policy Enforcement — The Experiment Loop
|
|
405
|
+
|
|
406
|
+
Write rules in plain English. Run the same scenario. See what changes. Adjust and repeat.
|
|
407
|
+
|
|
408
|
+
### Step 1: See it work (zero config)
|
|
97
409
|
|
|
98
410
|
```bash
|
|
99
|
-
npx
|
|
411
|
+
npx nv-sim enforce
|
|
100
412
|
```
|
|
101
413
|
|
|
102
|
-
Runs
|
|
414
|
+
Runs three iterations automatically: no rules → light rules → full rules. You see divergence immediately.
|
|
415
|
+
|
|
416
|
+
### Step 2: Write your own rules
|
|
417
|
+
|
|
418
|
+
Create a text file. That's it.
|
|
103
419
|
|
|
104
420
|
```
|
|
105
|
-
|
|
106
|
-
Scenarios tested: 500
|
|
421
|
+
# my-rules.txt
|
|
107
422
|
|
|
108
|
-
|
|
109
|
-
|
|
423
|
+
Block panic selling during high volatility
|
|
424
|
+
Limit leverage to 5x
|
|
425
|
+
Maintain minimum liquidity floor
|
|
426
|
+
Slow down algorithmic trading when contagion spreads
|
|
427
|
+
```
|
|
110
428
|
|
|
111
|
-
|
|
112
|
-
Market Panic Circuit Breaker (247 times)
|
|
429
|
+
### Step 3: Run it
|
|
113
430
|
|
|
114
|
-
|
|
431
|
+
```bash
|
|
432
|
+
npx nv-sim enforce trading my-rules.txt
|
|
115
433
|
```
|
|
116
434
|
|
|
435
|
+
The engine parses your plain English into rules, runs the scenario, and shows what changed — with before → after behavioral proof.
|
|
436
|
+
|
|
437
|
+
### Step 4: Change a rule. Run again.
|
|
438
|
+
|
|
439
|
+
Remove "Limit leverage to 5x". Run again. Did stability drop? That rule was load-bearing.
|
|
440
|
+
|
|
441
|
+
Add "Require transparency for all large trades". Run again. Did agents shift strategy?
|
|
442
|
+
|
|
443
|
+
The report tracks every change:
|
|
444
|
+
|
|
445
|
+
```
|
|
446
|
+
RULE CHANGES
|
|
447
|
+
Run 2:
|
|
448
|
+
+ Block panic selling during high volatility
|
|
449
|
+
+ Slow down algorithmic trading when contagion spreads
|
|
450
|
+
- Limit leverage to 5x
|
|
451
|
+
|
|
452
|
+
DIVERGENCE ANALYSIS
|
|
453
|
+
Stability trend: 79% → 98%
|
|
454
|
+
Effectiveness trend: 11% → 32%
|
|
455
|
+
|
|
456
|
+
KEY INSIGHT
|
|
457
|
+
Removing the leverage cap caused agents to take larger positions — but the
|
|
458
|
+
panic selling block forced them to hold through volatility instead of exiting.
|
|
459
|
+
Net effect: more risk-taking, but more stability.
|
|
460
|
+
|
|
461
|
+
TRY THIS EXPERIMENT
|
|
462
|
+
Remove "Block panic selling during high volatility" from your rules file, then run again.
|
|
463
|
+
If stability drops, that rule was load-bearing. If nothing changes, it was noise.
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Step 5: Compare two rule sets side by side
|
|
467
|
+
|
|
468
|
+
```bash
|
|
469
|
+
npx nv-sim enforce trading light-rules.txt strict-rules.txt
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### Rule patterns
|
|
473
|
+
|
|
474
|
+
The engine understands these patterns in plain English:
|
|
475
|
+
|
|
476
|
+
| Pattern | What it does | Example |
|
|
477
|
+
|---------|-------------|---------|
|
|
478
|
+
| `Block X` | Hard suppression of matching actions | `Block panic selling` |
|
|
479
|
+
| `Limit X` / `Cap X` | Caps extreme positions | `Limit leverage to 5x` |
|
|
480
|
+
| `Slow X` / `Dampen X` | Reduces large movements | `Slow down algorithmic trading` |
|
|
481
|
+
| `Maintain X` / `Floor X` | Enforces minimum thresholds | `Maintain minimum liquidity` |
|
|
482
|
+
| `Rebalance X` | Pulls extremes toward equilibrium | `Rebalance correlated positions` |
|
|
483
|
+
| `Require X` | Enforceable structural constraint | `Require transparency for large trades` |
|
|
484
|
+
| `Monitor X` | Generates a circuit breaker gate | `Monitor contagion spread` |
|
|
485
|
+
|
|
486
|
+
### Other scenarios
|
|
487
|
+
|
|
488
|
+
```bash
|
|
489
|
+
npx nv-sim enforce strait_of_hormuz my-rules.txt # Same rules, different scenario
|
|
490
|
+
npx nv-sim enforce ai_regulation_crisis # Default progressive run
|
|
491
|
+
npx nv-sim enforce trading --output=report.json # Save as JSON
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### Advanced: JSON world files
|
|
495
|
+
|
|
496
|
+
For full control over gates, state variables, and thesis, use JSON world files. See `examples/worlds/` for templates. Enforce accepts both `.txt` and `.json` — mix and match.
|
|
497
|
+
|
|
498
|
+
## AI Providers — Bring Your Own Model
|
|
499
|
+
|
|
500
|
+
AI is optional. AI is governed. AI is pluggable.
|
|
501
|
+
|
|
502
|
+
NV-SIM works without any AI — the deterministic engine runs on math, not tokens. But when you bring your own model, AI becomes a governed actor inside the system — subject to the same rules as every other agent.
|
|
503
|
+
|
|
504
|
+
### How AI fits in
|
|
505
|
+
|
|
506
|
+
AI plays two governed roles:
|
|
507
|
+
|
|
508
|
+
| Role | What It Does | Constraints |
|
|
509
|
+
|------|-------------|-------------|
|
|
510
|
+
| `ai_translator` | Converts unstructured input into normalized events | Must output valid schema, no invention of events, must include confidence |
|
|
511
|
+
| `ai_analyst` | Generates reports from simulation traces | Must reference trace data, must include blocked actions, no unverifiable claims |
|
|
512
|
+
|
|
513
|
+
Both roles go through `/api/evaluate` like any other actor. The AI doesn't control the system — the system controls the AI.
|
|
514
|
+
|
|
515
|
+
### Supported providers
|
|
516
|
+
|
|
517
|
+
NV-SIM auto-detects the best available provider from your environment:
|
|
518
|
+
|
|
519
|
+
| Provider | Env Var | What It Connects To |
|
|
520
|
+
|----------|---------|---------------------|
|
|
521
|
+
| Anthropic (Claude) | `ANTHROPIC_API_KEY` | Claude Sonnet, Opus, Haiku |
|
|
522
|
+
| OpenAI | `OPENAI_API_KEY` | GPT-4, GPT-4o, o1 |
|
|
523
|
+
| Groq | `GROQ_API_KEY` | Llama 3 70B |
|
|
524
|
+
| Together | `TOGETHER_API_KEY` | Llama, Mixtral |
|
|
525
|
+
| Mistral | `MISTRAL_API_KEY` | Mistral Large |
|
|
526
|
+
| Deepseek | `DEEPSEEK_API_KEY` | Deepseek Chat |
|
|
527
|
+
| Fireworks | `FIREWORKS_API_KEY` | Llama, custom models |
|
|
528
|
+
| Ollama | `OLLAMA_BASE_URL` | Any local model |
|
|
529
|
+
| Local LLM | `LOCAL_LLM_URL` | LM Studio, vLLM, llama.cpp |
|
|
530
|
+
| (none) | — | Deterministic fallback (no AI, no cost) |
|
|
531
|
+
|
|
532
|
+
Set the env var and run. No configuration files. No provider lock-in.
|
|
533
|
+
|
|
534
|
+
Any endpoint that speaks the OpenAI chat completions format (`POST /v1/chat/completions`) works out of the box.
|
|
535
|
+
|
|
536
|
+
## Quick Start
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
# See it
|
|
540
|
+
npx @neuroverseos/nv-sim visualize
|
|
541
|
+
|
|
542
|
+
# Compare governed vs ungoverned
|
|
543
|
+
npx @neuroverseos/nv-sim compare
|
|
544
|
+
|
|
545
|
+
# Run a crisis
|
|
546
|
+
npx @neuroverseos/nv-sim scenario taiwan_crisis
|
|
547
|
+
|
|
548
|
+
# Same crisis, different worlds — which rules hold?
|
|
549
|
+
npx @neuroverseos/nv-sim scenario bank_run --compare
|
|
550
|
+
|
|
551
|
+
# Inject shocks
|
|
552
|
+
npx @neuroverseos/nv-sim compare --inject tanker_explosion@3,sanctions@5
|
|
553
|
+
|
|
554
|
+
# Stress test (500 randomized runs)
|
|
555
|
+
npx @neuroverseos/nv-sim chaos --runs 500
|
|
556
|
+
|
|
557
|
+
# Run local governance runtime for your own simulator
|
|
558
|
+
npx @neuroverseos/nv-sim serve
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
## Commands
|
|
562
|
+
|
|
563
|
+
| Command | What It Does |
|
|
564
|
+
|---------|-------------|
|
|
565
|
+
| `nv-sim enforce [preset]` | Policy enforcement lab — iterative rule testing |
|
|
566
|
+
| `nv-sim visualize` | Interactive control platform |
|
|
567
|
+
| `nv-sim compare [preset]` | Baseline vs governed simulation |
|
|
568
|
+
| `nv-sim compare --inject event@round,...` | With narrative shocks |
|
|
569
|
+
| `nv-sim scenario <id>` | Run a named stress scenario |
|
|
570
|
+
| `nv-sim scenario <id> --compare` | Cross-world scenario comparison |
|
|
571
|
+
| `nv-sim scenarios` | List all available scenarios |
|
|
572
|
+
| `nv-sim worlds <a> <b>` | Compare two rule environments |
|
|
573
|
+
| `nv-sim chaos [preset] --runs N` | Stress test across randomized scenarios |
|
|
574
|
+
| `nv-sim serve --port N` | Local governance runtime for any simulator |
|
|
575
|
+
| `nv-sim run <simulator>` | Connect external simulator to governance |
|
|
576
|
+
| `nv-sim analyze <file>` | Analyze simulation from file or stdin |
|
|
577
|
+
| `nv-sim presets` | List available world presets |
|
|
578
|
+
|
|
579
|
+
## How It Works
|
|
580
|
+
|
|
581
|
+
```
|
|
582
|
+
event → narrative propagation → belief shift → agent action → governance → behavioral analysis → outcome
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
Five forces shape every simulation:
|
|
586
|
+
|
|
587
|
+
1. **Agent behavior** — traders, voters, regulators, media — each with different risk profiles and strategies
|
|
588
|
+
2. **World rules** — leverage caps, circuit breakers, chokepoints — the constraints that shape what agents can do
|
|
589
|
+
3. **Narrative events** — information shocks that propagate through the system at different speeds
|
|
590
|
+
4. **Perception propagation** — different agents react differently to the same event based on their role and exposure
|
|
591
|
+
5. **Behavioral analysis** — tracks how agents reorganize, producing the before → after evidence that proves rules actually changed the system
|
|
592
|
+
|
|
593
|
+
This lets you ask compound questions:
|
|
594
|
+
|
|
595
|
+
> What happens if a tanker explodes while Hormuz is closed and leverage is capped at 3x?
|
|
596
|
+
|
|
597
|
+
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.
|
|
598
|
+
|
|
117
599
|
## Architecture
|
|
118
600
|
|
|
119
601
|
```
|
|
120
602
|
@neuroverseos/governance ← deterministic rule engine
|
|
121
603
|
↓
|
|
122
|
-
nv-sim
|
|
604
|
+
nv-sim engine ← world rules + narrative injection + swarm simulation
|
|
123
605
|
↓
|
|
124
|
-
|
|
606
|
+
behavioral analysis ← before→after shift detection, trajectory tracking, cross-run comparison
|
|
607
|
+
↓
|
|
608
|
+
audit trail ← append-only evidence chain (JSONL)
|
|
609
|
+
↓
|
|
610
|
+
nv-sim CLI ← scenarios, comparison, chaos testing, governance runtime
|
|
611
|
+
↓
|
|
612
|
+
control platform ← interactive browser UI + outcome panels
|
|
613
|
+
↓
|
|
614
|
+
AI providers (optional) ← BYOM: Anthropic, OpenAI, Groq, local LLMs, or none
|
|
615
|
+
↓
|
|
616
|
+
world variants ← saved experiments as shareable assets
|
|
125
617
|
```
|
|
126
618
|
|
|
127
|
-
NV-SIM uses [`@neuroverseos/governance`](https://www.npmjs.com/package/@neuroverseos/governance) for deterministic guard evaluation
|
|
619
|
+
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.
|
|
620
|
+
|
|
621
|
+
AI is optional. When present, it's governed — subject to the same rules as any other actor in the system.
|
|
128
622
|
|
|
129
623
|
## License
|
|
130
624
|
|
|
@@ -132,6 +626,6 @@ Apache 2.0
|
|
|
132
626
|
|
|
133
627
|
---
|
|
134
628
|
|
|
135
|
-
|
|
629
|
+
Change the rules. See why the system changed.
|
|
136
630
|
|
|
137
631
|
[@neuroverseos](https://github.com/NeuroverseOS)
|