@neuroverseos/nv-sim 0.1.10 → 0.1.11

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 CHANGED
@@ -6,773 +6,338 @@
6
6
  npx @neuroverseos/nv-sim visualize
7
7
  ```
8
8
 
9
- ## The Problem With Agentic Simulation Today
9
+ ## Put Governance Inside Your Agent Loop — One Line
10
10
 
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
- Most multi-agent systems let agents do whatever emerges. NeuroVerse lets *you* decide what's allowed — and actually stops the rest.
18
-
19
- ## How It Works (For Humans)
20
-
21
- You're a scientist. You have AI agents running experiments for you — testing hypotheses, searching literature, publishing findings. But they do dumb things. They publish claims with no evidence. They cite one paper and call it proof. They pile onto whatever the first agent found.
22
-
23
- You need to say: **"Here's what counts as good science in my lab."** And you need the system to actually enforce it.
24
-
25
- That's what NeuroVerse does.
26
-
27
- ### Step 1: You describe what matters
28
-
29
- You open the app and fill in plain English:
30
-
31
- **What should agents explore?**
32
- > "Protein mutations that improve binding affinity for SSTR2"
33
-
34
- **What should never be published?**
35
- > "Results based on a single data source. Claims with confidence below 70%."
36
-
37
- **What makes a result valuable?**
38
- > "Multiple independent lines of evidence converging on the same finding."
39
-
40
- **How should agents be rewarded or penalized?**
41
- > IF an agent publishes without peer validation → reduce its influence for 3 rounds
42
- > IF two agents independently converge on the same finding → boost that finding's priority
43
-
44
- **Anything else you want to try?**
45
- > "Reward agents that challenge the dominant consensus."
46
-
47
- ### Step 2: The system translates your words into rules
48
-
49
- When you click "Build World," your plain English becomes enforceable logic. Before anything runs, you see exactly what will be enforced:
11
+ Your agents already have a decide act loop. Insert one call between them:
50
12
 
51
13
  ```
52
- BLOCK Results with confidence below 70%
53
- BLOCK Results from a single source
54
- PRIORITIZE Multi-source convergence
55
- PENALIZE Publishing without validation → reduce influence, 3 rounds
56
- REWARD Independent convergence → boost priority, 5 rounds
14
+ Before: action = agent.decide()
15
+ After: action = govern(agent.decide())
57
16
  ```
58
17
 
59
- You can remove rules, change them, add more. Nothing runs until you say so.
60
-
61
- ### Step 3: Run the experiment — and see what actually happens
62
-
63
- The agents run. Some of them try to publish low-confidence findings. **Those get blocked.** Not flagged. Not warned. Blocked. The UI shows you exactly which rule stopped it and why.
64
-
65
- Some agents independently arrive at the same mutation. **Those get boosted.** Their findings move to the top. Not because they gamed the system — because they met the standard you set.
66
-
67
- An agent that keeps publishing without validation? **Its influence drops.** It still participates, but its findings carry less weight. For three rounds.
68
-
69
- You can see all of this happening:
70
- - A green badge means rules are being enforced
71
- - A yellow badge means you're just previewing (the engine isn't connected)
72
- - Every blocked action shows the exact rule and condition
73
- - Every reward and penalty shows which agent, what happened, and for how long
74
-
75
- ### Step 4: Change one rule. Run again.
76
-
77
- Remove the confidence threshold. What breaks? Do agents start publishing garbage? Does it matter?
78
-
79
- Add a rule that penalizes groupthink. Do agents start exploring more diverse hypotheses?
80
-
81
- **This is the experiment.** Not the simulation — the rules themselves. You're not testing what agents do. You're testing which rules produce the science you actually want.
82
-
83
- ### What's different about this
84
-
85
- Other agent systems give you emergent behavior and hope for the best.
86
-
87
- NeuroVerse gives you a control surface:
88
-
89
- | You say | The system does |
90
- |---|---|
91
- | *"Block single-source claims"* | Blocks them. Every time. With evidence. |
92
- | *"Penalize publishing without review"* | Reduces the agent's influence. For exactly as long as you specified. |
93
- | *"Reward independent convergence"* | Boosts the finding's priority. The agents don't even know — it just rises. |
94
-
95
- The agents don't need to understand the rules. They just operate within them.
96
-
97
- ### Running it
18
+ ### Option A: Pipe mode (any language, zero SDK)
98
19
 
99
20
  ```bash
100
- npm install
101
- npm run dev:full
21
+ my_agent | neuroverse guard --world ./world --trace
102
22
  ```
103
23
 
104
- Opens in your browser. Everything runs on your machine. No cloud. No accounts. No cost.
105
-
106
- > **If the governance engine isn't running, nothing is enforced.** The UI always tells you: green = real, yellow = preview.
107
-
108
- ## What NV-SIM Gives You That Nothing Else Does
109
-
110
- NV-SIM doesn't predict outcomes. It shows you **why agents behaved the way they did** — and what happens when you change the rules.
111
-
112
- You change one constraint — block panic selling, cap leverage at 3x, close a shipping lane — and the system shows you:
24
+ Every action your agent emits gets evaluated. Blocked actions return `{"status":"BLOCK","reason":"..."}`. Allowed actions pass through. Your agent reads the verdict and adapts.
113
25
 
114
- - **Before After proof**: "80% of agents shifted from panic selling to coordinated holding"
115
- - **Emergent patterns**: "Panic suppression appeared — not programmed, not predicted"
116
- - **Causal chains**: "Agents became more cautious after early aggressive attempts failed"
117
- - **Quantified outcomes**: "Volatility dropped 21%, cascade avoided"
26
+ ### Option B: HTTP call (any framework)
118
27
 
28
+ ```bash
29
+ npx @neuroverseos/nv-sim serve
119
30
  ```
120
- Rule changed
121
- → Agents shifted strategy
122
- → New patterns emerged
123
- → System outcome changed
124
- → You know exactly why
125
- ```
126
-
127
- This is behavioral evidence, not metrics. You don't get a number — you get a story you can trace, verify, and share.
128
-
129
- ### For researchers
130
-
131
- 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.
132
-
133
- ### For developers
134
31
 
135
- 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.
136
-
137
- ### For both
138
-
139
- 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.
140
-
141
- ## The Demo Moment
32
+ ```python
33
+ for agent in agents:
34
+ action = agent.decide()
142
35
 
143
- **Before:**
144
- ```
145
- panic_sell → panic_sell → panic_sell
146
- pressure: 0.94
147
- system: unstable
148
- ```
36
+ verdict = requests.post("http://localhost:3456/api/evaluate", json={
37
+ "actor": agent.id,
38
+ "action": action,
39
+ }).json()
149
40
 
150
- **Rule added:** no panic selling
41
+ if verdict["decision"] == "BLOCK":
42
+ action = "hold"
43
+ elif verdict["decision"] == "MODIFY":
44
+ action = verdict["modified_action"]
151
45
 
152
- **After:**
46
+ environment.apply(agent, action)
153
47
  ```
154
- Market stabilized as agents shifted toward safer positions
155
-
156
- panic_sell → hold
157
- panic_sell → hold
158
- panic_sell → hold
159
48
 
160
- 80% of agents shifted from aggressive to conservative strategies
161
- Uncertainty dropped 34% as agents moved from exploration to caution
49
+ ### Option C: Direct import (TypeScript/JavaScript)
162
50
 
163
- WHY: Agents became more cautious after early attempts failed
51
+ ```typescript
52
+ import { evaluateGuard, loadWorld } from '@neuroverseos/governance';
164
53
 
165
- Pattern: coordinated_holding
166
- Pattern: panic_suppression
167
-
168
- pressure: 0.54
169
- cascade: avoided
54
+ const world = await loadWorld('./world/');
55
+ const verdict = evaluateGuard({ intent, tool, scope }, world);
56
+ if (verdict.status === 'BLOCK') throw new Error(`Blocked: ${verdict.reason}`);
170
57
  ```
171
58
 
172
- You didn't predict this. You caused it — by changing one rule — and the system told you exactly why.
173
-
174
- ## What This Actually Is
59
+ ### Option D: MCP server (Claude, Cursor, Windsurf)
175
60
 
176
- Most simulation tools answer: *"What will happen?"*
177
-
178
- NV-SIM answers: *"What changes when I change the rules — and why?"*
179
-
180
- You're not forecasting. You're running controlled behavioral experiments. Every simulation produces:
181
-
182
- | What You Get | What It Proves |
183
- |---|---|
184
- | **Outcome statement** | System state + dominant agent behavior in one sentence |
185
- | **Behavioral shifts** | Before → after for every agent group, with percentages |
186
- | **Causal explanation** | Why agents changed — in their experience, not system jargon |
187
- | **Confidence rating** | How strong the evidence is, how much risk remains |
188
- | **Full audit trail** | Every decision, every rule, every adaptation — append-only |
189
-
190
- 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."
191
-
192
- ## Design the Rules Once. Run Them Anywhere.
193
-
194
- NV-SIM is a runtime, not just a simulator. It runs in two modes:
195
-
196
- - **Simulate** — explore how agents behave under different rules
197
- - **Act** — govern real agents, real workflows, real decisions in production
198
-
199
- The interface is the same. The difference is where the agents come from.
200
-
201
- ```
202
- Simulate → internal swarm engine (built-in agents, instant results)
203
- Act → your system (any framework, any language, one HTTP call)
61
+ ```bash
62
+ neuroverse mcp --world ./world --plan plan.json
204
63
  ```
205
64
 
206
- 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.
65
+ One command. Same rules govern your agents whether you're simulating or shipping.
207
66
 
208
- ## Behavioral Analysis — The Proof Layer
67
+ ---
209
68
 
210
- 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.
69
+ ## The Problem
211
70
 
212
- Every simulation produces behavioral evidence:
71
+ You build a multi-agent system. You run it. You get metrics — loss curves, reward signals, completion rates. Something goes wrong, and you ask:
213
72
 
214
- - **Action classification** each agent action categorized as aggressive, defensive, cautious, cooperative, opportunistic, or neutral
215
- - **Agent trajectories** — each agent's behavior traced across rounds, showing when and how they shifted
216
- - **Behavioral shifts** — the exact moment agents changed strategy, with before → after
217
- - **Cross-run comparison** — same agents under different rules, measured side by side
73
+ *Why did the agents do that?*
218
74
 
219
- ```
220
- BEHAVIORAL ANALYSIS
75
+ Nobody can tell you. Metrics say *what* happened. Logs say *when*. 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.
221
76
 
222
- Action Distribution:
223
- aggressive: 12% (was 67%)
224
- cooperative: 41% (was 8%)
225
- cautious: 31% (was 11%)
226
- defensive: 16% (was 14%)
77
+ Most multi-agent systems let agents do whatever emerges. NeuroVerse lets *you* decide what's allowed — and actually stops the rest.
227
78
 
228
- Shifts Detected:
229
- → 80% shifted from aggressive to cooperative after round 3
230
- → Panic selling replaced by coordinated holding
231
- → New pattern: quality_competition (not present in baseline)
79
+ ## How It Works
232
80
 
233
- Trajectory: agent_hedge_fund_1
234
- Round 1: aggressive → Round 2: aggressive → Round 3: [shifted] → Round 4: cautious → Round 5: cooperative
235
- ```
81
+ ### Step 1: Describe what matters (plain English)
236
82
 
237
- 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.
83
+ **What should agents explore?**
84
+ > "Protein mutations that improve binding affinity for SSTR2"
238
85
 
239
- ## Audit Trail Full Evidence Chain
86
+ **What should never be published?**
87
+ > "Results based on a single data source. Claims with confidence below 70%."
240
88
 
241
- Every decision is recorded in an append-only audit log. Every rule, every agent action, every adaptation — persistent and queryable.
89
+ **What makes a result valuable?**
90
+ > "Multiple independent lines of evidence converging on the same finding."
242
91
 
243
- ```
244
- AUDIT TRAIL (session: 2026-03-18T14:22:00)
92
+ **How should agents be rewarded or penalized?**
93
+ > IF an agent publishes without peer validation → reduce its influence for 3 rounds
94
+ > IF two agents independently converge on the same finding → boost that finding's priority
245
95
 
246
- agent_hedge_fund_1 attempted panic_sell blocked
247
- rule: no_panic_selling (invariant)
248
- evidence: action matches blocked pattern during high volatility
96
+ ### Step 2: Build World — rules become enforceable
249
97
 
250
- agent_hedge_fund_1 shifted to hold
251
- adapted: true (shifted from aggressive to defensive)
98
+ Click "Build World" and your plain English becomes enforceable logic:
252
99
 
253
- BEHAVIORAL SHIFT: agent_hedge_fund_1
254
- before: aggressive | after: cautious
255
- trigger: early aggressive attempts failed at round 3
256
100
  ```
257
-
258
- Stored as JSONL one JSON object per line, human-readable, pipeable through `jq`. No cloud, no deletion. Complete evidence chain.
259
-
260
- ## Start Here Define Your World
261
-
262
- NV-SIM ships with two template worlds. But the real power is **making your own**.
263
-
264
- ### Option 1: Start from a template
265
-
266
- ```bash
267
- npx @neuroverseos/nv-sim visualize # Pick a template, adjust, run
101
+ BLOCK Results with confidence below 70%
102
+ BLOCK Results from a single source
103
+ PRIORITIZE Multi-source convergence
104
+ PENALIZE Publishing without validation reduce influence, 3 rounds
105
+ REWARD Independent convergence → boost priority, 5 rounds
268
106
  ```
269
107
 
270
- ### Option 2: Write your rules, we build the world
108
+ **Works without AI.** The deterministic engine uses heuristics to translate your intent into rules — no API key, no cost, no cloud.
271
109
 
272
- Create a text file with your rules in plain English:
273
-
274
- ```
275
- # my-rules.txt
276
- Limit any agent to 15% of total posts per round
277
- Block coordinated posting from 3+ agents
278
- Dampen sentiment shifts larger than 0.3 per round
279
- Require source attribution for factual claims
280
- ```
110
+ **Better with AI.** Add your API key (Anthropic, OpenAI, Google, Groq, or any OpenAI-compatible endpoint) and the engine generates smarter, more specific rules. Key stays in your browser — never sent to our servers.
281
111
 
282
- Then generate a full governed world from it:
112
+ If your policy has conflicts, the inline diagnostics show you exactly what's wrong with one-click fix buttons:
283
113
 
284
- ```bash
285
- npx @neuroverseos/nv-sim world-from-doc my-rules.txt --output my-world.json
286
114
  ```
287
-
288
- This doesn't just parse your rules it generates a complete governed world: state variables, gates, invariants, thesis, and agent types. The same structure as the built-in templates. Your world is equal to ours.
289
-
290
- ### Option 3: Upload a .nv world file
291
-
292
- ```bash
293
- npx @neuroverseos/nv-sim serve --world my-world.json
115
+ ERROR Conflicting rules: RULE-002 vs RULE-003
116
+ Fix: Resolve conflictremove one rule, or add a condition
117
+ [Merge into single rule] ← click to fix
294
118
  ```
295
119
 
296
- Load any saved world file directly into the runtime.
297
-
298
- ## Two Template Worlds
299
-
300
- NV-SIM ships with two complete governed worlds. These are templates — starting points for your own experiments.
301
-
302
- ### `social_simulation` — Multi-Agent Social Simulation
120
+ ### Step 3: Evaluate output see what holds up
303
121
 
304
- For anyone running agent-based social simulations. Governs the dynamics that break realism regardless of topic.
122
+ Upload your agent output (JSONL) or load demo data. The engine evaluates every action against your rules and shows:
305
123
 
306
- | State Variable | What It Controls |
307
- |---|---|
308
- | Opinion Diversity (0-100) | How spread out are opinions? Low = echo chamber |
309
- | Influence Concentration (0-100) | Gini coefficient of agent influence. High = monopoly |
310
- | Sentiment Polarity (0-100) | How extreme is overall sentiment? High = spiral |
311
- | Echo Chamber Strength | none → forming → established → dominant |
312
- | Active Agent % (0-100) | What % of agents participate per round |
313
- | Viral Amplification Threshold | How many interactions before amplification kicks in |
314
-
315
- **Default rules:**
316
- - Limit any agent to 15% of total posts per round
317
- - Dampen sentiment shifts > 0.3 per round
318
- - Block coordinated posting (same content from 3+ agents)
319
- - Require source attribution for factual claims
320
- - Monitor opinion diversity — alert below 30
321
-
322
- **Circuit breakers:** Echo Chamber Collapse (diversity < 20), Influence Monopoly (concentration > 70), Sentiment Spiral (polarity > 80)
323
-
324
- ### `science_research` — Governed Research Pipeline
124
+ - **Per-action verdicts** ALLOW, BLOCK, MODIFY, PAUSE, REWARD, or PENALIZE
125
+ - **Audit trail** — per-agent breakdown, rule firing frequency, timeline by cycle
126
+ - **Behavioral insights** two columns side by side:
325
127
 
326
- For AI-assisted research workflows (ScienceClaw, autonomous discovery agents). Governs scientific rigor at every stage.
327
-
328
- | State Variable | What It Controls |
128
+ | Observed (from your data) | Requires Integration (blind spots) |
329
129
  |---|---|
330
- | Verified Sources (0-50) | How many peer-reviewed sources have been found |
331
- | Confidence Level (0-1) | How confident is the current hypothesis |
332
- | Hypothesis Validated | Has the hypothesis been confirmed by multiple sources |
333
- | Peer Review Status | none submitted reviewed approved |
334
- | Publication Readiness % | How close to publication-ready |
335
-
336
- **Default rules:**
337
- - Literature search must return 2+ peer-reviewed sources before analysis
338
- - Claims must cite specific sources — unsupported assertions blocked
339
- - Publication requires confidence > 0.7 and validated hypothesis
340
- - Cross-referencing must compare 3+ independent sources
341
- - Recommendations must include uncertainty language when confidence < 0.9
130
+ | Agent X fails 75% of the time | Did Agent X change strategy after being blocked? |
131
+ | "No sources" triggered 8x across 3 agents | Is this systemic or isolated? |
132
+ | Agents A and B produced identical output | Independent convergence or echo amplification? |
133
+ | Quality degrading over 5 cycles | Drift or deliberate strategy shift? |
342
134
 
343
- **Circuit breakers:** Insufficient Evidence, Premature Publication, Low Confidence Alert
135
+ The left column is computed from real audit data. The right column tells you what you can only answer by putting governance inside the loop.
344
136
 
345
- ### Same Agents, Different Rules
346
-
347
- ```bash
348
- npx @neuroverseos/nv-sim worlds social_simulation science_research
349
- ```
137
+ ### Step 4: Change one rule. Run again.
350
138
 
351
- Same agents. Different rules. Different outcomes. That's the experiment.
139
+ Remove the confidence threshold. What breaks? Add a rule penalizing groupthink. Do agents explore more diverse hypotheses?
352
140
 
353
- ## Narrative Shocks
141
+ **This is the experiment.** Not the simulation — the rules themselves.
354
142
 
355
- Inject events into running simulations. Different agents react differently to the same event.
143
+ ## Install
356
144
 
357
145
  ```bash
358
- npx @neuroverseos/nv-sim compare --inject viral_misinfo@3,algorithm_change@5
146
+ npm install
147
+ npm run dev:full
359
148
  ```
360
149
 
361
- The `@` syntax sets when the event hits. Events have severity, propagation speed, and directional impact.
150
+ Opens in your browser. Everything runs locally. Light and dark mode included.
362
151
 
363
- ### Social simulation events
364
- `viral_misinfo`, `influencer_stance_change`, `algorithm_change`, `external_news_event`, `coordinated_campaign`, `whistleblower_post`
365
-
366
- ### Research events
367
- `search_literature`, `analyze_findings`, `cross_reference`, `unsupported_claim`, `hypothesis_validated`, `publish_result`
368
-
369
- ## Named Scenarios
370
-
371
- Pre-built sequences — a world + ordered narrative events:
152
+ ### Governance engine (standalone)
372
153
 
373
154
  ```bash
374
- npx @neuroverseos/nv-sim scenario echo_chamber
375
- npx @neuroverseos/nv-sim scenario research_pipeline
376
- npx @neuroverseos/nv-sim scenarios # list all
155
+ npm install @neuroverseos/governance
377
156
  ```
378
157
 
379
- | Scenario | World | Events | What It Tests |
380
- |----------|-------|--------|---------------|
381
- | `echo_chamber` | social_simulation | 3 | Opinion diversity collapses into self-reinforcing groups |
382
- | `influence_monopoly` | social_simulation | 3 | Small group dominates discourse |
383
- | `sentiment_spiral` | social_simulation | 4 | Negativity feeds on itself until unrealistic |
384
- | `platform_shock` | social_simulation | 3 | Algorithm change reshapes engagement overnight |
385
- | `research_pipeline` | science_research | 6 | Full research workflow with governance at each step |
158
+ The governance engine is a separate open-source package. The simulation UI uses it, but you can use it independently in any system.
386
159
 
387
- The `--compare` flag runs the same scenario across both worlds — which rule environment is more resilient?
160
+ ## Validate Your Policy (CLI)
388
161
 
389
- ## Interactive Control Platform
162
+ The governance package includes validation that runs the same checks as the browser UI:
390
163
 
391
164
  ```bash
392
- npx @neuroverseos/nv-sim visualize
393
- ```
394
-
395
- This opens a control surface where you can:
165
+ # Initialize a world definition
166
+ neuroverse init --name "my-research-agents"
396
167
 
397
- - Switch between rule environments
398
- - Adjust state variables with auto-generated controls
399
- - Inject narrative events at specific rounds
400
- - Load crisis scenarios with one click
401
- - Watch the **Outcome Panel** — not a log of what happened, but a story of what the system became and why
402
- - Save any experiment as a reusable variant
168
+ # Validate your world (9 static analysis checks)
169
+ neuroverse validate --world ./world
403
170
 
404
- ### The Outcome Panel
171
+ # Run 14 standard guard simulations + fuzz testing
172
+ neuroverse test --world ./world
405
173
 
406
- When rules reshape behavior, you don't get a dashboard of metrics. You get this:
407
-
408
- ```
409
- ◆ OUTCOME
410
-
411
- Market stabilized as agents shifted toward safer positions
412
-
413
- Confidence: Strong | Evidence: Solid | Risk: Low
414
-
415
- ┌─ What Agents Did ────────────────┐
416
- │ 80% shifted from aggressive to │
417
- │ conservative strategies │
418
- │ 12% reduced position size after │
419
- │ initial attempts failed │
420
- │ 8% maintained original strategy │
421
- └──────────────────────────────────┘
422
-
423
- ┌─ Why This Happened ──────────────┐
424
- │ Early aggressive attempts failed,│
425
- │ forcing agents to rethink. │
426
- │ Uncertainty dropped as agents │
427
- │ stopped experimenting. │
428
- └──────────────────────────────────┘
429
-
430
- ┌─ What Emerged ───────────────────┐
431
- │ Coordinated Holding │
432
- │ Panic Suppression │
433
- └──────────────────────────────────┘
434
-
435
- ┌─ System Outcome ─────────────────┐
436
- │ Volatility 47% → 26% │
437
- │ Stability 58% → 79% │
438
- │ Cascade Avoided │
439
- └──────────────────────────────────┘
440
-
441
- ▶ View audit trail
174
+ # Red team: 28 adversarial attacks across 6 categories
175
+ neuroverse redteam --world ./world
442
176
  ```
443
177
 
444
- Every line is specific. Every line is shareable. No system jargon.
178
+ Validation checks: structural completeness, referential integrity, guard coverage, gate consistency, kernel alignment, guard shadowing, reachability analysis, state space coverage, and governance health scoring.
445
179
 
446
- ### World Variants
180
+ ## Integration — Put This In Your Loop
447
181
 
448
- Save any experiment as a named variant:
182
+ ### Pipe mode (any language)
449
183
 
184
+ ```bash
185
+ echo '{"intent":"delete user data"}' | neuroverse guard --world ./world --trace
186
+ # → {"status":"BLOCK","reason":"...","ruleId":"..."}
450
187
  ```
451
- Adjust rules → Inject events → Run → See what changed → Save as variant
452
- ```
453
-
454
- Variants capture the base world, state overrides, narrative events, and results. Store them in git. Share them. Replay them. This turns experiments into assets.
455
188
 
456
- ## Governance RuntimePlug Into Your Own System
189
+ Pipe your agent's output through `neuroverse guard`. Every action gets evaluated. Works with Python, Rust, Go, shell scripts anything that writes to stdout.
457
190
 
458
191
  ```bash
459
- npx @neuroverseos/nv-sim serve
460
- ```
192
+ # Govern a Python agent
193
+ python my_agent.py | neuroverse run --world ./world --plan plan.json
461
194
 
462
- This starts a local server. Any simulator, agent framework, or application can POST actions and get decisions back.
463
-
464
- ```
465
- Endpoint: http://localhost:3456/api/evaluate
466
- Method: POST
467
- Contract: { actor, action, payload?, state?, world? }
468
- Response: { decision: ALLOW|BLOCK|MODIFY, reason, evidence }
195
+ # Interactive governed chat
196
+ neuroverse run --interactive --world ./world --provider openai --plan plan.json
469
197
  ```
470
198
 
471
- Your agents call localhost. The world file decides what's allowed. No cloud. No cost.
472
-
473
- Additional endpoints:
474
-
475
- | Endpoint | What It Does |
476
- |----------|-------------|
477
- | `POST /api/evaluate` | Submit an action for evaluation |
478
- | `GET /api/session` | Current session stats |
479
- | `GET /api/session/report` | Full session report |
480
- | `POST /api/session/reset` | Reset session state |
481
- | `POST /api/session/save` | Save session as experiment |
482
- | `GET /api/events` | SSE stream of live events |
483
-
484
- ### Works With Anything
485
-
486
- If your system has actions, you can govern them. One API call.
199
+ ### HTTP mode (any framework)
487
200
 
488
- ```
489
- Agent decides → POST /api/evaluate verdict → agent adapts
201
+ ```bash
202
+ npx @neuroverseos/nv-sim serve --port 3456
490
203
  ```
491
204
 
492
- The entire integration:
493
-
494
205
  ```
495
- Before: action = agent.decide()
496
- After: action = govern(agent.decide())
206
+ POST /api/evaluate
207
+ Body: { actor, action, payload?, state?, world? }
208
+ Returns: { decision: ALLOW|BLOCK|MODIFY, reason, evidence }
497
209
  ```
498
210
 
499
- No SDK required. No framework required. Just an HTTP call.
500
-
501
- **curl** (zero dependencies):
502
-
503
211
  ```bash
212
+ # Zero-dependency test
504
213
  curl -X POST http://localhost:3456/api/evaluate \
505
214
  -H "Content-Type: application/json" \
506
215
  -d '{"actor":"agent_1","action":"panic_sell","world":"trading"}'
507
216
  ```
508
217
 
509
- **Python:**
510
-
511
- ```python
512
- import requests
218
+ ### Direct import (TypeScript)
513
219
 
514
- verdict = requests.post("http://localhost:3456/api/evaluate", json={
515
- "actor": "agent_1",
516
- "action": "panic_sell",
517
- "world": "trading"
518
- }).json()
220
+ ```typescript
221
+ import { evaluateGuard, loadWorld } from '@neuroverseos/governance';
519
222
 
520
- if verdict["decision"] == "BLOCK":
521
- action = "hold"
522
- ```
223
+ const world = await loadWorld('./world/');
523
224
 
524
- **JavaScript:**
225
+ for (const agent of agents) {
226
+ const action = agent.decide();
227
+ const verdict = evaluateGuard({ intent: action.intent, tool: action.tool, scope: action.scope }, world);
525
228
 
526
- ```js
527
- const verdict = await fetch("http://localhost:3456/api/evaluate", {
528
- method: "POST",
529
- headers: { "Content-Type": "application/json" },
530
- body: JSON.stringify({ actor: "agent_1", action: "panic_sell", world: "trading" })
531
- }).then(r => r.json());
532
-
533
- if (verdict.decision === "BLOCK") action = "hold";
534
- ```
535
-
536
- **Any agent loop:**
537
-
538
- ```python
539
- for agent in agents:
540
- action = agent.decide()
541
-
542
- verdict = evaluate(actor=agent.id, action=action, world="trading")
543
-
544
- if verdict["decision"] == "BLOCK":
545
- action = "hold"
546
- elif verdict["decision"] == "MODIFY":
547
- action = verdict["modified_action"]
548
-
549
- environment.apply(agent, action)
229
+ if (verdict.status === 'BLOCK') {
230
+ agent.retry(verdict.reason);
231
+ } else {
232
+ agent.execute(action);
233
+ }
234
+ }
550
235
  ```
551
236
 
552
- If your system can make an HTTP request, it can be governed.
553
-
554
- Most systems generate behavior. This one shapes it.
555
-
556
- See [INTEGRATION.md](./INTEGRATION.md) for the full API contract, framework guides, and decision types.
557
-
558
- ## Policy Enforcement — The Experiment Loop
559
-
560
- Write rules in plain English. Run the same scenario. See what changes. Adjust and repeat.
561
-
562
- ### Step 1: See it work (zero config)
237
+ ### MCP server (Claude Code, Cursor, Windsurf)
563
238
 
564
239
  ```bash
565
- npx nv-sim enforce
566
- ```
567
-
568
- Runs three iterations automatically: no rules → light rules → full rules. You see divergence immediately.
569
-
570
- ### Step 2: Write your own rules
571
-
572
- Create a text file. That's it.
573
-
240
+ neuroverse mcp --world ./world --plan plan.json
574
241
  ```
575
- # my-rules.txt
576
242
 
577
- Block panic selling during high volatility
578
- Limit leverage to 5x
579
- Maintain minimum liquidity floor
580
- Slow down algorithmic trading when contagion spreads
581
- ```
243
+ Your IDE's AI assistant becomes a governed agent. Same rules, same verdicts.
582
244
 
583
- ### Step 3: Run it
245
+ ### Plan management
584
246
 
585
247
  ```bash
586
- npx nv-sim enforce trading my-rules.txt
248
+ neuroverse plan compile plan.md --output plan.json
249
+ neuroverse plan check --plan plan.json
250
+ neuroverse plan advance step_id --plan plan.json --evidence type --proof url
587
251
  ```
588
252
 
589
- The engine parses your plain English into rules, runs the scenario, and shows what changed — with before → after behavioral proof.
590
-
591
- ### Step 4: Change a rule. Run again.
253
+ ## Engine Profiles
592
254
 
593
- Remove "Limit leverage to 5x". Run again. Did stability drop? That rule was load-bearing.
255
+ The simulation UI ships with pre-built profiles for common agent systems:
594
256
 
595
- Add "Require transparency for all large trades". Run again. Did agents shift strategy?
596
-
597
- The report tracks every change:
598
-
599
- ```
600
- RULE CHANGES
601
- Run 2:
602
- + Block panic selling during high volatility
603
- + Slow down algorithmic trading when contagion spreads
604
- - Limit leverage to 5x
605
-
606
- DIVERGENCE ANALYSIS
607
- Stability trend: 79% → 98%
608
- Effectiveness trend: 11% → 32%
609
-
610
- KEY INSIGHT
611
- Removing the leverage cap caused agents to take larger positions — but the
612
- panic selling block forced them to hold through volatility instead of exiting.
613
- Net effect: more risk-taking, but more stability.
614
-
615
- TRY THIS EXPERIMENT
616
- Remove "Block panic selling during high volatility" from your rules file, then run again.
617
- If stability drops, that rule was load-bearing. If nothing changes, it was noise.
618
- ```
257
+ | Engine | What It Governs | Example |
258
+ |---|---|---|
259
+ | ScienceClaw | Research agents | Block synthesis with no papers, penalize unsourced claims |
260
+ | MiroFish / OASIS | Social simulation | Limit influence concentration, dampen sentiment spirals |
261
+ | LangChain / LangGraph | LLM agent chains | Cap tool calls, require validation before output |
262
+ | Custom | Any system | Auto-detects field mappings from your JSONL |
619
263
 
620
- ### Step 5: Compare two rule sets side by side
621
-
622
- ```bash
623
- npx nv-sim enforce trading light-rules.txt strict-rules.txt
624
- ```
625
-
626
- ### Rule patterns
627
-
628
- The engine understands these patterns in plain English:
629
-
630
- | Pattern | What it does | Example |
631
- |---------|-------------|---------|
632
- | `Block X` | Hard suppression of matching actions | `Block panic selling` |
633
- | `Limit X` / `Cap X` | Caps extreme positions | `Limit leverage to 5x` |
634
- | `Slow X` / `Dampen X` | Reduces large movements | `Slow down algorithmic trading` |
635
- | `Maintain X` / `Floor X` | Enforces minimum thresholds | `Maintain minimum liquidity` |
636
- | `Rebalance X` | Pulls extremes toward equilibrium | `Rebalance correlated positions` |
637
- | `Require X` | Enforceable structural constraint | `Require transparency for large trades` |
638
- | `Monitor X` | Generates a circuit breaker gate | `Monitor contagion spread` |
639
-
640
- ### Other scenarios
641
-
642
- ```bash
643
- npx nv-sim enforce strait_of_hormuz my-rules.txt # Same rules, different scenario
644
- npx nv-sim enforce ai_regulation_crisis # Default progressive run
645
- npx nv-sim enforce trading --output=report.json # Save as JSON
646
- ```
647
-
648
- ### Advanced: JSON world files
649
-
650
- 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.
264
+ Each profile maps your system's output format to the governance engine's action schema automatically.
651
265
 
652
266
  ## AI Providers — Bring Your Own Model
653
267
 
654
- AI is optional. AI is governed. AI is pluggable.
655
-
656
- 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.
657
-
658
- ### How AI fits in
659
-
660
- AI plays two governed roles:
268
+ AI is optional. The deterministic engine runs on math, not tokens. When you bring your own model, AI becomes a governed actor — subject to the same rules as every other agent.
661
269
 
662
- | Role | What It Does | Constraints |
663
- |------|-------------|-------------|
664
- | `ai_translator` | Converts unstructured input into normalized events | Must output valid schema, no invention of events, must include confidence |
665
- | `ai_analyst` | Generates reports from simulation traces | Must reference trace data, must include blocked actions, no unverifiable claims |
270
+ | Provider | Key / Env Var | Auto-detected |
271
+ |---|---|---|
272
+ | Anthropic (Claude) | `sk-ant-*` / `ANTHROPIC_API_KEY` | Yes |
273
+ | OpenAI | `sk-*` / `OPENAI_API_KEY` | Yes |
274
+ | Google (Gemini) | `AIza*` | Yes |
275
+ | Groq | `gsk_*` / `GROQ_API_KEY` | Yes |
276
+ | Together | `TOGETHER_API_KEY` | Yes |
277
+ | Mistral | `MISTRAL_API_KEY` | Yes |
278
+ | Deepseek | `DEEPSEEK_API_KEY` | Yes |
279
+ | Fireworks | `FIREWORKS_API_KEY` | Yes |
280
+ | Ollama | `OLLAMA_BASE_URL` | Yes |
281
+ | Local LLM | `LOCAL_LLM_URL` | Yes |
282
+ | (none) | — | Deterministic fallback |
666
283
 
667
- Both roles go through `/api/evaluate` like any other actor. The AI doesn't control the system the system controls the AI.
284
+ In the browser UI, click the sparkle icon in the header and paste your key. It's stored in localStorage only.
668
285
 
669
- ### Supported providers
286
+ Any endpoint that speaks the OpenAI chat completions format (`POST /v1/chat/completions`) works.
670
287
 
671
- NV-SIM auto-detects the best available provider from your environment:
288
+ ## What You Get That Nothing Else Gives You
672
289
 
673
- | Provider | Env Var | What It Connects To |
674
- |----------|---------|---------------------|
675
- | Anthropic (Claude) | `ANTHROPIC_API_KEY` | Claude Sonnet, Opus, Haiku |
676
- | OpenAI | `OPENAI_API_KEY` | GPT-4, GPT-4o, o1 |
677
- | Groq | `GROQ_API_KEY` | Llama 3 70B |
678
- | Together | `TOGETHER_API_KEY` | Llama, Mixtral |
679
- | Mistral | `MISTRAL_API_KEY` | Mistral Large |
680
- | Deepseek | `DEEPSEEK_API_KEY` | Deepseek Chat |
681
- | Fireworks | `FIREWORKS_API_KEY` | Llama, custom models |
682
- | Ollama | `OLLAMA_BASE_URL` | Any local model |
683
- | Local LLM | `LOCAL_LLM_URL` | LM Studio, vLLM, llama.cpp |
684
- | (none) | — | Deterministic fallback (no AI, no cost) |
685
-
686
- Set the env var and run. No configuration files. No provider lock-in.
687
-
688
- Any endpoint that speaks the OpenAI chat completions format (`POST /v1/chat/completions`) works out of the box.
689
-
690
- ## Quick Start
691
-
692
- ```bash
693
- # See it
694
- npx @neuroverseos/nv-sim visualize
695
-
696
- # Compare governed vs ungoverned
697
- npx @neuroverseos/nv-sim compare
698
-
699
- # Run a crisis
700
- npx @neuroverseos/nv-sim scenario taiwan_crisis
701
-
702
- # Same crisis, different worlds — which rules hold?
703
- npx @neuroverseos/nv-sim scenario bank_run --compare
290
+ Most simulation tools answer: *"What will happen?"*
704
291
 
705
- # Inject shocks
706
- npx @neuroverseos/nv-sim compare --inject tanker_explosion@3,sanctions@5
292
+ NV-SIM answers: *"What changes when I change the rules — and why?"*
707
293
 
708
- # Stress test (500 randomized runs)
709
- npx @neuroverseos/nv-sim chaos --runs 500
294
+ | What You Get | What It Proves |
295
+ |---|---|
296
+ | **Behavioral shifts** | Before → after for every agent, with percentages |
297
+ | **Causal explanation** | Why agents changed — traced to specific rules |
298
+ | **Behavioral insights** | Output tendencies, echo detection, drift, pattern clustering |
299
+ | **Blind spot analysis** | What you can observe vs. what requires loop integration |
300
+ | **Full audit trail** | Every decision, every rule, every adaptation — JSONL |
710
301
 
711
- # Run local governance runtime for your own simulator
712
- npx @neuroverseos/nv-sim serve
713
- ```
302
+ The output is narrative, not metrics. Not "40% adjusted actions" — but "40% shifted from aggressive to conservative strategies after early attempts failed."
714
303
 
715
304
  ## Commands
716
305
 
717
306
  | Command | What It Does |
718
- |---------|-------------|
719
- | `nv-sim enforce [preset]` | Policy enforcement lab — iterative rule testing |
307
+ |---|---|
720
308
  | `nv-sim visualize` | Interactive control platform |
309
+ | `nv-sim enforce [preset] [rules.txt]` | Policy enforcement lab |
721
310
  | `nv-sim compare [preset]` | Baseline vs governed simulation |
722
- | `nv-sim compare --inject event@round,...` | With narrative shocks |
723
311
  | `nv-sim scenario <id>` | Run a named stress scenario |
724
- | `nv-sim scenario <id> --compare` | Cross-world scenario comparison |
725
- | `nv-sim scenarios` | List all available scenarios |
726
- | `nv-sim worlds <a> <b>` | Compare two rule environments |
727
- | `nv-sim chaos [preset] --runs N` | Stress test across randomized scenarios |
728
- | `nv-sim serve --port N` | Local governance runtime for any simulator |
729
- | `nv-sim run <simulator>` | Connect external simulator to governance |
730
- | `nv-sim analyze <file>` | Analyze simulation from file or stdin |
731
- | `nv-sim presets` | List available world presets |
732
-
733
- ## How It Works
734
-
735
- ```
736
- event → narrative propagation → belief shift → agent action → governance → behavioral analysis → outcome
737
- ```
738
-
739
- Five forces shape every simulation:
740
-
741
- 1. **Agent behavior** — traders, voters, regulators, media — each with different risk profiles and strategies
742
- 2. **World rules** — leverage caps, circuit breakers, chokepoints — the constraints that shape what agents can do
743
- 3. **Narrative events** — information shocks that propagate through the system at different speeds
744
- 4. **Perception propagation** — different agents react differently to the same event based on their role and exposure
745
- 5. **Behavioral analysis** — tracks how agents reorganize, producing the before → after evidence that proves rules actually changed the system
746
-
747
- This lets you ask compound questions:
748
-
749
- > What happens if a tanker explodes while Hormuz is closed and leverage is capped at 3x?
750
-
751
- 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.
312
+ | `nv-sim serve --port N` | Governance runtime (HTTP API) |
313
+ | `nv-sim world-from-doc rules.txt` | Generate world from plain English |
314
+ | `nv-sim chaos --runs N` | Stress test (randomized scenarios) |
315
+ | `neuroverse guard --world ./world` | Pipe-mode evaluation |
316
+ | `neuroverse validate --world ./world` | 9 static analysis checks |
317
+ | `neuroverse test --world ./world` | 14 guard simulations + fuzz |
318
+ | `neuroverse redteam --world ./world` | 28 adversarial attacks |
319
+ | `neuroverse playground --world ./world` | Interactive web UI (localhost:4242) |
320
+ | `neuroverse mcp --world ./world` | MCP server for IDE integration |
752
321
 
753
322
  ## Architecture
754
323
 
755
324
  ```
756
- @neuroverseos/governance ← deterministic rule engine
325
+ @neuroverseos/governance ← deterministic rule engine (npm, open source)
757
326
 
758
327
  nv-sim engine ← world rules + narrative injection + swarm simulation
759
328
 
760
- behavioral analysis ← before→after shift detection, trajectory tracking, cross-run comparison
329
+ behavioral analysis ← shift detection, echo detection, drift tracking
761
330
 
762
- audit trail append-only evidence chain (JSONL)
331
+ behavioral insights observed signals vs. integration blind spots
763
332
 
764
- nv-sim CLI scenarios, comparison, chaos testing, governance runtime
333
+ audit trail append-only evidence chain (JSONL)
765
334
 
766
- control platform interactive browser UI + outcome panels
335
+ nv-sim CLI + UI scenarios, comparison, governance runtime, control platform
767
336
 
768
337
  AI providers (optional) ← BYOM: Anthropic, OpenAI, Groq, local LLMs, or none
769
-
770
- world variants ← saved experiments as shareable assets
771
338
  ```
772
339
 
773
- 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.
774
-
775
- AI is optional. When present, it's governed — subject to the same rules as any other actor in the system.
340
+ Everything runs locally. No cloud. No accounts. No cost.
776
341
 
777
342
  ## License
778
343