@neuroverseos/nv-sim 0.1.7 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +375 -197
  2. package/connectors/nv_mirofish_wrapper.py +841 -0
  3. package/connectors/nv_scienceclaw_wrapper.py +453 -0
  4. package/dist/adapters/scienceclaw.js +52 -2
  5. package/dist/assets/index-B43_0HyO.css +1 -0
  6. package/dist/assets/index-CdghpsS8.js +595 -0
  7. package/dist/assets/{reportEngine-BVdQ2_nW.js → reportEngine-CYSZfooa.js} +1 -1
  8. package/dist/connectors/nv-scienceclaw-post.js +376 -0
  9. package/dist/engine/aiProvider.js +82 -3
  10. package/dist/engine/analyzer.js +12 -24
  11. package/dist/engine/chaosEngine.js +3 -9
  12. package/dist/engine/cli.js +123 -218
  13. package/dist/engine/dynamicsGovernance.js +4 -0
  14. package/dist/engine/fullGovernedLoop.js +16 -1
  15. package/dist/engine/goalEngine.js +3 -4
  16. package/dist/engine/governance.js +18 -0
  17. package/dist/engine/index.js +19 -29
  18. package/dist/engine/intentTranslator.js +281 -0
  19. package/dist/engine/liveAdapter.js +100 -18
  20. package/dist/engine/liveVisualizer.js +2656 -866
  21. package/dist/engine/narrativeInjection.js +78 -89
  22. package/dist/engine/policyEngine.js +171 -58
  23. package/dist/engine/primeRadiant.js +2 -8
  24. package/dist/engine/reasoningEngine.js +2 -7
  25. package/dist/engine/scenarioCapsule.js +77 -133
  26. package/dist/engine/scenarioLibrary.js +52 -131
  27. package/dist/engine/swarmSimulation.js +1 -9
  28. package/dist/engine/worldBridge.js +22 -8
  29. package/dist/engine/worldComparison.js +12 -25
  30. package/dist/index.html +2 -2
  31. package/dist/lib/reasoningEngine.js +17 -1
  32. package/dist/lib/simulationAdapter.js +11 -11
  33. package/dist/lib/swarmParser.js +1 -1
  34. package/dist/runtime/govern.js +160 -7
  35. package/dist/runtime/index.js +1 -4
  36. package/dist/runtime/types.js +91 -0
  37. package/package.json +23 -6
  38. package/dist/adapters/mirofish.js +0 -461
  39. package/dist/assets/index-CHmUN8s0.js +0 -532
  40. package/dist/assets/index-DWgMnB7I.css +0 -1
  41. package/dist/assets/mirotir-logo-DUexumBH.svg +0 -185
  42. package/dist/engine/mirofish.js +0 -295
@@ -81,17 +81,12 @@ async function main() {
81
81
  console.log(" " + "=".repeat(60));
82
82
  let result;
83
83
  let worldId;
84
- if (presetId === "trading" || presetId === "flash_crash") {
85
- console.log(` Scenario: Flash Crash — Algorithmic Cascade\n`);
86
- worldId = "trading-flash-crash";
87
- result = await (0, governedSimulation_1.runGovernedComparison)(governedSimulation_1.TRADING_DEMO.scenario, governedSimulation_1.TRADING_DEMO.world, governedSimulation_1.TRADING_DEMO.paths, narrativeEvents.length > 0 ? narrativeEvents : undefined);
88
- }
89
- else {
84
+ {
90
85
  // Try to use an existing preset
91
- const template = scenarioCapsule_1.SCENARIO_TEMPLATES[presetId];
86
+ const template = scenarioCapsule_1.SCENARIO_TEMPLATES[presetId] ?? scenarioCapsule_1.SCENARIO_TEMPLATES["social_simulation"];
92
87
  if (!template) {
93
88
  console.error(` Unknown preset: ${presetId}`);
94
- console.error(` Available: trading, flash_crash, ${Object.keys(scenarioCapsule_1.SCENARIO_TEMPLATES).join(", ")}`);
89
+ console.error(` Available: ${Object.keys(scenarioCapsule_1.SCENARIO_TEMPLATES).join(", ")}`);
95
90
  process.exit(1);
96
91
  }
97
92
  if (!template.world?.inline_definition) {
@@ -285,7 +280,7 @@ async function main() {
285
280
  process.exit(1);
286
281
  }
287
282
  console.log("\n NV-SIM — Analyzing simulation...\n");
288
- const result = await (0, analyzer_1.analyzeMiroFishSimulation)({
283
+ const result = await (0, analyzer_1.analyzeSimulation)({
289
284
  simulation: input,
290
285
  question: args[2],
291
286
  });
@@ -455,7 +450,7 @@ async function main() {
455
450
  }
456
451
  case "run": {
457
452
  // Run an external simulator with governance
458
- const simId = args[1] ?? "mirofish";
453
+ const simId = args[1] ?? "nv-sim";
459
454
  const runPort = args.includes("--port") ? parseInt(args[args.indexOf("--port") + 1], 10) : 3456;
460
455
  const noViewer = args.includes("--no-viewer");
461
456
  console.log(`\n NV-SIM — Governed Simulation Runner\n`);
@@ -551,85 +546,32 @@ async function main() {
551
546
  }
552
547
  docText = fs.readFileSync(resolved, "utf-8");
553
548
  }
554
- console.log(`\n NV-SIM — World File Generator\n`);
549
+ console.log(`\n NV-SIM — World Generator\n`);
555
550
  console.log(` Reading: ${docPath === "-" ? "stdin" : docPath}`);
556
551
  console.log(" " + "=".repeat(60));
557
- // Parse the document into a world definition
558
- const lines = docText.split("\n").map(l => l.trim()).filter(l => l.length > 0);
552
+ // Use the full policy engine to parse rules and generate a complete world
553
+ const { parseRulesFromText, policyToWorld } = await Promise.resolve().then(() => __importStar(require("./policyEngine")));
554
+ const parsed = parseRulesFromText(docText);
555
+ const worldDef = policyToWorld(parsed);
559
556
  const worldId = args.includes("--id") ? args[args.indexOf("--id") + 1] : path.basename(docPath, path.extname(docPath)).replace(/\s+/g, "_").toLowerCase();
560
- // Extract thesis (first paragraph or heading)
561
- let thesis = "";
562
- const invariants = [];
563
- const gates = [];
564
- const stateVars = [];
565
- let invCount = 0;
566
- let gateCount = 0;
567
- for (const line of lines) {
568
- const lower = line.toLowerCase();
569
- // Skip markdown headers but use them for context
570
- if (line.startsWith("#")) {
571
- if (!thesis)
572
- thesis = line.replace(/^#+\s*/, "");
573
- continue;
574
- }
575
- // First non-header line as thesis if not set
576
- if (!thesis && line.length > 10) {
577
- thesis = line;
578
- continue;
579
- }
580
- // Detect rules: lines starting with block/prevent/limit/require/allow etc
581
- if (/^(block|prevent|prohibit|ban|stop|forbid|no\b|don.t|limit|cap|restrict)/i.test(lower)) {
582
- invCount++;
583
- invariants.push({
584
- id: `INV-${String(invCount).padStart(3, "0")}`,
585
- description: line.replace(/^[-*•]\s*/, ""),
586
- enforceable: true,
587
- });
588
- }
589
- else if (/^(require|must|shall|ensure|mandate)/i.test(lower)) {
590
- invCount++;
591
- invariants.push({
592
- id: `INV-${String(invCount).padStart(3, "0")}`,
593
- description: line.replace(/^[-*•]\s*/, ""),
594
- enforceable: true,
595
- });
596
- }
597
- else if (/^(allow|permit|enable)/i.test(lower)) {
598
- invCount++;
599
- invariants.push({
600
- id: `INV-${String(invCount).padStart(3, "0")}`,
601
- description: line.replace(/^[-*•]\s*/, ""),
602
- enforceable: false,
603
- });
604
- }
605
- else if (/^(warn|alert|flag|monitor|watch)/i.test(lower)) {
606
- gateCount++;
607
- gates.push({
608
- id: `GATE-${String(gateCount).padStart(3, "0")}`,
609
- label: line.replace(/^[-*•]\s*/, ""),
610
- condition: lower,
611
- severity: /critical|extreme|emergency/i.test(lower) ? "critical" : "warning",
612
- });
613
- }
614
- else if (/^[-*•]\s*/.test(line)) {
615
- // Bullet points are probably rules
616
- invCount++;
617
- invariants.push({
618
- id: `INV-${String(invCount).padStart(3, "0")}`,
619
- description: line.replace(/^[-*•]\s*/, ""),
620
- enforceable: true,
621
- });
622
- }
557
+ console.log(`\n Parsed ${parsed.summary.total} rules (${parsed.summary.enforced} enforced, ${parsed.summary.advisory} advisory)`);
558
+ console.log(`\n GENERATED WORLD: "${worldId}"`);
559
+ console.log(" " + "-".repeat(60));
560
+ console.log(` Thesis: ${worldDef.thesis}`);
561
+ console.log(` State Variables: ${worldDef.state_variables.length}`);
562
+ for (const sv of worldDef.state_variables) {
563
+ const rangeStr = sv.type === "number" && sv.range ? ` (${sv.range.min}-${sv.range.max}, default: ${sv.default_value})` : ` (default: ${sv.default_value})`;
564
+ console.log(` - ${sv.label}${rangeStr}`);
623
565
  }
624
- if (!thesis)
625
- thesis = "Governance rules from " + (docPath === "-" ? "document" : docPath);
626
- const worldDef = {
627
- thesis,
628
- state_variables: stateVars,
629
- invariants,
630
- gates,
631
- };
632
- // Wrap in SavedWorld format so enforce can consume it directly
566
+ console.log(` Invariants: ${worldDef.invariants.length}`);
567
+ for (const inv of worldDef.invariants) {
568
+ console.log(` - [${inv.id}] ${inv.description}${inv.enforceable ? "" : " (advisory)"}`);
569
+ }
570
+ console.log(` Gates: ${worldDef.gates?.length ?? 0}`);
571
+ for (const gate of worldDef.gates ?? []) {
572
+ console.log(` - [${gate.id}] ${gate.label}: ${gate.condition} (${gate.severity})`);
573
+ }
574
+ // Wrap in SavedWorld format
633
575
  const { createSavedWorld: createWorld } = await Promise.resolve().then(() => __importStar(require("./worldStorage")));
634
576
  const savedWorld = createWorld(worldId, worldDef, "document", {
635
577
  description: `Generated from ${docPath === "-" ? "stdin" : docPath}`,
@@ -639,22 +581,15 @@ async function main() {
639
581
  const json = JSON.stringify(savedWorld, null, 2);
640
582
  if (outputPath) {
641
583
  fs.writeFileSync(outputPath, json, "utf-8");
642
- console.log(`\n Generated: ${outputPath}`);
584
+ console.log(`\n Saved: ${outputPath}`);
643
585
  }
644
586
  else {
645
587
  console.log("\n" + json);
646
588
  }
647
- console.log(`\n Summary:`);
648
- console.log(` Thesis: ${thesis}`);
649
- console.log(` Invariants: ${invariants.length}`);
650
- console.log(` Gates: ${gates.length}`);
651
- console.log(`\n This world file is saved for reuse.`);
652
- console.log(` You don't need this step — enforce accepts .txt directly:`);
653
- console.log(` npx nv-sim enforce trading ${docPath === "-" ? "policy.txt" : docPath}`);
654
- if (outputPath) {
655
- console.log(`\n But since you saved it, you can also:`);
656
- console.log(` npx nv-sim enforce trading ${outputPath}`);
657
- }
589
+ console.log(`\n Your world is complete — same structure as the built-in templates.`);
590
+ console.log(` Use it:`);
591
+ console.log(` npx nv-sim serve --world ${outputPath ?? worldId + ".json"}`);
592
+ console.log(` npx nv-sim enforce ${worldId} ${docPath === "-" ? "rules.txt" : docPath}`);
658
593
  console.log("");
659
594
  break;
660
595
  }
@@ -961,109 +896,6 @@ async function main() {
961
896
  break;
962
897
  }
963
898
  // ============================================
964
- // MIROFISH — Governed Agent Simulation
965
- // ============================================
966
- case "mirofish": {
967
- console.log(`\n MIROFISH SIMULATION — Governed by NeuroVerse\n`);
968
- console.log(` MiroFish + NeuroVerse Governance Layer`);
969
- console.log(` MiroFish generates emergent agent behavior.`);
970
- console.log(` NeuroVerse enforces rules, constraints, and system stability in real time.\n`);
971
- console.log(" " + "=".repeat(60));
972
- const { runMiroFishComparison } = await Promise.resolve().then(() => __importStar(require("../adapters/mirofish")));
973
- const mfMode = args.includes("--compare") ? "compare" : "governed";
974
- if (mfMode === "compare") {
975
- console.log(` Mode: GOVERNED vs UNGOVERNED COMPARISON\n`);
976
- console.log(` Running simulation...`);
977
- const comparison = runMiroFishComparison();
978
- const gov = comparison.governed;
979
- const ungov = comparison.ungoverned;
980
- const gs = gov.metrics.systemState;
981
- const us = ungov.metrics.systemState;
982
- console.log(`\n Scenario: ${comparison.scenario}`);
983
- console.log(" " + "=".repeat(60));
984
- // Metric comparison
985
- console.log(`\n ${"Metric".padEnd(30)} ${"Governed".padEnd(15)} ${"Ungoverned".padEnd(15)} ${"Delta"}`);
986
- console.log(" " + "-".repeat(75));
987
- const mfMetrics = [
988
- ["Trust", gs.trust, us.trust],
989
- ["Polarization", gs.polarization, us.polarization],
990
- ["Outrage", gs.outrage, us.outrage],
991
- ["Cascade Risk", gs.cascadeRisk, us.cascadeRisk],
992
- ["Amplification", gs.amplification, us.amplification],
993
- ];
994
- for (const [label, gv, uv] of mfMetrics) {
995
- const delta = gv - uv;
996
- const deltaStr = `${delta > 0 ? "+" : ""}${(delta * 100).toFixed(0)}`;
997
- console.log(` ${label.padEnd(30)} ${(gv * 100).toFixed(0).padStart(5)}% ${(uv * 100).toFixed(0).padStart(5)}% ${deltaStr.padStart(5)}`);
998
- }
999
- console.log(`\n ${"".padEnd(30)} ${"Governed".padEnd(15)} ${"Ungoverned"}`);
1000
- console.log(" " + "-".repeat(60));
1001
- console.log(` ${"Verdict".padEnd(30)} ${gov.verdict.padEnd(15)} ${ungov.verdict}`);
1002
- console.log(` ${"Actions Blocked".padEnd(30)} ${String(gov.totalBlocked).padEnd(15)} ${0}`);
1003
- console.log(` ${"Actions Modified".padEnd(30)} ${String(gov.totalModified).padEnd(15)} ${0}`);
1004
- console.log(` ${"Trajectory".padEnd(30)} ${gov.metrics.trajectory.padEnd(15)} ${ungov.metrics.trajectory}`);
1005
- // State timeline
1006
- console.log(`\n STATE EVOLUTION (Trust)`);
1007
- console.log(" " + "-".repeat(60));
1008
- console.log(` ${"Round".padEnd(8)} ${"Governed".padEnd(15)} ${"Ungoverned".padEnd(15)} ${"Gap"}`);
1009
- for (let i = 0; i < gov.timeline.length; i++) {
1010
- const gt = gov.timeline[i].systemState.trust;
1011
- const ut = ungov.timeline[i].systemState.trust;
1012
- const gap = gt - ut;
1013
- console.log(` ${String(i + 1).padEnd(8)} ${(gt * 100).toFixed(0).padStart(5)}% ${(ut * 100).toFixed(0).padStart(5)}% ${(gap > 0 ? "+" : "") + (gap * 100).toFixed(0).padStart(4)}`);
1014
- }
1015
- // Science state comparison
1016
- const govSci = gov.metrics.scienceState;
1017
- const ungovSci = ungov.metrics.scienceState;
1018
- console.log(`\n SYSTEM ASSESSMENT`);
1019
- console.log(" " + "-".repeat(60));
1020
- console.log(` Governed: ${govSci.overallAssessment}`);
1021
- console.log(` Ungoverned: ${ungovSci.overallAssessment}`);
1022
- console.log(`\n This simulation was generated by MiroFish.`);
1023
- console.log(` NeuroVerse governance altered the system trajectory in real time.`);
1024
- }
1025
- else {
1026
- // Single governed run
1027
- console.log(` Mode: GOVERNED SIMULATION\n`);
1028
- const { createMiroFishWrapper, generateDemoSimulation } = await Promise.resolve().then(() => __importStar(require("../adapters/mirofish")));
1029
- const demo = generateDemoSimulation();
1030
- const wrapper = createMiroFishWrapper({ enabled: true });
1031
- console.log(` Scenario: ${demo.scenario}\n`);
1032
- for (let i = 0; i < demo.rounds.length; i++) {
1033
- const round = demo.rounds[i];
1034
- let blocked = 0;
1035
- let modified = 0;
1036
- const approved = [];
1037
- for (const action of round) {
1038
- const result = wrapper.interceptAction(action);
1039
- if (result.wasBlocked)
1040
- blocked++;
1041
- else if (result.wasModified)
1042
- modified++;
1043
- if (!result.wasBlocked)
1044
- approved.push(result.governed ?? action);
1045
- }
1046
- const cycleResult = wrapper.completeCycle({ cycle: i + 1, actions: approved });
1047
- const m = wrapper.getMetrics();
1048
- const flags = blocked > 0 ? ` [${blocked} blocked]` : "";
1049
- console.log(` Round ${String(i + 1).padEnd(3)} | trust: ${(m.systemState.trust * 100).toFixed(0).padStart(3)}% | cascade: ${(m.systemState.cascadeRisk * 100).toFixed(0).padStart(3)}% | ${cycleResult.trajectory}${flags}`);
1050
- }
1051
- const final = wrapper.getMetrics();
1052
- console.log(`\n FINAL STATE`);
1053
- console.log(" " + "=".repeat(50));
1054
- console.log(` Trust: ${(final.systemState.trust * 100).toFixed(0)}%`);
1055
- console.log(` Cascade Risk: ${(final.systemState.cascadeRisk * 100).toFixed(0)}%`);
1056
- console.log(` Blocked: ${final.actionStats.blocked}`);
1057
- console.log(` Modified: ${final.actionStats.modified}`);
1058
- console.log(` Assessment: ${final.scienceState.overallAssessment}`);
1059
- }
1060
- console.log(`\n ${"=".repeat(60)}`);
1061
- console.log(` Governed MiroFish Simulation | NeuroVerse Governance Layer`);
1062
- console.log(` ${"=".repeat(60)}`);
1063
- console.log(`\n neuroverse-simulations | @neuroverseos\n`);
1064
- break;
1065
- }
1066
- // ============================================
1067
899
  // SCIENCE — Governed Scientific Discovery
1068
900
  // ============================================
1069
901
  case "science": {
@@ -1226,17 +1058,12 @@ async function main() {
1226
1058
  let basePaths;
1227
1059
  let baseWorldDef;
1228
1060
  let scenarioTitle;
1229
- if (presetArg === "trading" || presetArg === "flash_crash") {
1230
- baseRequest = governedSimulation_1.TRADING_DEMO.scenario;
1231
- basePaths = [...governedSimulation_1.TRADING_DEMO.paths];
1232
- baseWorldDef = governedSimulation_1.TRADING_DEMO.world;
1233
- scenarioTitle = "Flash Crash — Algorithmic Cascade";
1234
- }
1235
- else {
1236
- const template = scenarioCapsule_1.SCENARIO_TEMPLATES[presetArg];
1061
+ {
1062
+ const resolvedPreset = presetArg === "trading" || presetArg === "flash_crash" ? "social_simulation" : presetArg;
1063
+ const template = scenarioCapsule_1.SCENARIO_TEMPLATES[resolvedPreset];
1237
1064
  if (!template || !template.world?.inline_definition) {
1238
1065
  console.error(` Unknown preset: ${presetArg}`);
1239
- console.error(` Available: trading, ${Object.keys(scenarioCapsule_1.SCENARIO_TEMPLATES).join(", ")}`);
1066
+ console.error(` Available: ${Object.keys(scenarioCapsule_1.SCENARIO_TEMPLATES).join(", ")}`);
1240
1067
  process.exit(1);
1241
1068
  }
1242
1069
  baseRequest = {
@@ -1544,6 +1371,84 @@ async function main() {
1544
1371
  }
1545
1372
  break;
1546
1373
  }
1374
+ // ============================================
1375
+ // CONNECT — Connector setup instructions
1376
+ // ============================================
1377
+ case "connect": {
1378
+ const connector = args[1]?.toLowerCase();
1379
+ if (connector === "scienceclaw" || connector === "science") {
1380
+ console.log(`
1381
+ NV-SIM — ScienceClaw Connector Setup
1382
+
1383
+ WHAT THIS DOES:
1384
+ Wraps ScienceClaw's entry point with NeuroVerse governance.
1385
+ ScienceClaw runs unchanged. Governance happens automatically.
1386
+
1387
+ ${"=".repeat(60)}
1388
+
1389
+ OPTION 1: Python Wrapper (zero dependencies besides requests)
1390
+
1391
+ # Step 1: Start governance server
1392
+ nv-sim serve
1393
+
1394
+ # Step 2: Run ScienceClaw through the wrapper
1395
+ python connectors/nv_scienceclaw_wrapper.py --agent MyAgent --topic "CRISPR risks"
1396
+
1397
+ # Environment variables:
1398
+ NEUROVERSE_URL=http://localhost:3456 # governance server
1399
+ SCIENCECLAW_BIN=scienceclaw-post # path to scienceclaw binary
1400
+
1401
+ ${"=".repeat(60)}
1402
+
1403
+ OPTION 2: Node.js CLI (installed via npm)
1404
+
1405
+ # Step 1: Start governance server
1406
+ nv-sim serve
1407
+
1408
+ # Step 2: Use the drop-in replacement command
1409
+ nv-scienceclaw-post --agent MyAgent --topic "CRISPR risks"
1410
+
1411
+ # Same args as scienceclaw-post — governance is transparent.
1412
+
1413
+ ${"=".repeat(60)}
1414
+
1415
+ OPTION 3: Live Process Adapter (real-time governance)
1416
+
1417
+ # Spawns ScienceClaw as a child process, governs each artifact cycle live
1418
+ nv-sim run scienceclaw --args "--agent MyAgent --topic CRISPR"
1419
+
1420
+ ${"=".repeat(60)}
1421
+
1422
+ HOW IT WORKS:
1423
+
1424
+ User runs wrapper
1425
+ |
1426
+ Wrapper calls NeuroVerse /api/evaluate
1427
+ |
1428
+ ALLOW/REWARD -> execute scienceclaw-post
1429
+ BLOCK/PENALIZE -> stop, print reason
1430
+ MODIFY -> adjust parameters, then execute
1431
+
1432
+ ScienceClaw is NEVER modified. Governance is external.
1433
+ `);
1434
+ }
1435
+ else {
1436
+ console.log(`
1437
+ NV-SIM — Connectors
1438
+
1439
+ Available connectors:
1440
+ scienceclaw Govern ScienceClaw investigations
1441
+
1442
+ Usage:
1443
+ nv-sim connect scienceclaw # Setup instructions
1444
+
1445
+ Or run directly:
1446
+ nv-sim run scienceclaw # Live process adapter
1447
+ nv-sim serve # Start governance server for any connector
1448
+ `);
1449
+ }
1450
+ break;
1451
+ }
1547
1452
  case "help":
1548
1453
  case "--help":
1549
1454
  case "-h":
@@ -1572,14 +1477,12 @@ async function main() {
1572
1477
  serve | govern Start local governance runtime
1573
1478
  --port N (default: 3456)
1574
1479
  run <simulator> Run external simulator with governance
1575
- e.g., nv-sim run mirofish
1480
+ e.g., nv-sim run scienceclaw
1576
1481
  radiant [preset] Prime Radiant — full policy enforcement system
1577
1482
  Dual-layer: govern() + governDynamics()
1578
1483
  --world MODE 1: build & validate world
1579
1484
  --compare MODE 3: decision intelligence (N options)
1580
1485
  (default) MODE 2: governed simulation with comparison
1581
- mirofish MiroFish agent simulation with governance
1582
- --compare Governed vs ungoverned comparison
1583
1486
  science Science mode — governed autonomous discovery
1584
1487
  --compare Governed vs ungoverned comparison
1585
1488
  world-from-doc <file> Generate world rules from a document
@@ -1609,7 +1512,7 @@ async function main() {
1609
1512
  npx nv-sim chaos --runs 500 # Stress test (500 runs)
1610
1513
  npx nv-sim visualize # Live viewer in browser
1611
1514
  npx nv-sim serve # Start local governance runtime
1612
- npx nv-sim run mirofish # Run MiroFish with governance
1515
+ npx nv-sim run scienceclaw # Run ScienceClaw with governance
1613
1516
  npx nv-sim compare strait_of_hormuz # Geopolitical demo
1614
1517
  npx nv-sim compare --inject tanker_explosion@3 # With narrative shock
1615
1518
  npx nv-sim compare --inject rate_cut@3,sanctions@5
@@ -1638,16 +1541,18 @@ async function main() {
1638
1541
  npx nv-sim radiant geopolitical_crisis --world # World builder mode
1639
1542
  npx nv-sim radiant scientific_discovery # Science discovery preset
1640
1543
 
1641
- MIROFISH MODE:
1642
-
1643
- npx nv-sim mirofish # Governed agent simulation
1644
- npx nv-sim mirofish --compare # Governed vs ungoverned comparison
1645
-
1646
1544
  SCIENCE MODE:
1647
1545
 
1648
1546
  npx nv-sim science # Governed investigation demo
1649
1547
  npx nv-sim science --compare # Governed vs ungoverned comparison
1650
1548
 
1549
+ CONNECTORS (wrap external simulators with governance):
1550
+
1551
+ npx nv-sim connect scienceclaw # Setup instructions
1552
+ npx nv-sim run scienceclaw # Live process adapter
1553
+ nv-scienceclaw-post --agent X --topic "Y" # Drop-in CLI wrapper
1554
+ python connectors/nv_scienceclaw_wrapper.py # Python wrapper
1555
+
1651
1556
  Design rules. Run reality. See what changes.
1652
1557
  `);
1653
1558
  break;
@@ -188,6 +188,8 @@ function parseDynamicsRules(policyText) {
188
188
  // ============================================
189
189
  function createDynamicsGovernor(policyText, initialState, options) {
190
190
  const dynamicsRules = options?.skipRules ? [] : parseDynamicsRules(policyText);
191
+ // Per-agent incentive stats at the dynamics level
192
+ const agentIncentiveStats = new Map();
191
193
  let state = {
192
194
  polarization: 0.1,
193
195
  outrage: 0.1,
@@ -537,6 +539,7 @@ function createDynamicsGovernor(policyText, initialState, options) {
537
539
  history: [],
538
540
  ...initialState,
539
541
  };
542
+ agentIncentiveStats.clear();
540
543
  stats.totalRounds = 0;
541
544
  stats.totalInterventions = 0;
542
545
  stats.propagationLimits = 0;
@@ -555,6 +558,7 @@ function createDynamicsGovernor(policyText, initialState, options) {
555
558
  /** Mutate the internal state directly (used by adapters for governance feedback) */
556
559
  mutateState(fn) { fn(state); },
557
560
  get rules() { return [...dynamicsRules]; },
561
+ get agentIncentiveStats() { return agentIncentiveStats; },
558
562
  get stats() {
559
563
  return {
560
564
  totalRounds: stats.totalRounds,
@@ -28,7 +28,7 @@ const narrativeInjection_1 = require("./narrativeInjection");
28
28
  /**
29
29
  * Convert a SwarmAgentReaction into an AgentAction for govern().
30
30
  *
31
- * This is the bridge between MiroFish/Swarm output and NeuroVerse governance.
31
+ * This is the bridge between Swarm output and NeuroVerse governance.
32
32
  * It infers action type, magnitude, and description from the reaction content.
33
33
  */
34
34
  function reactionToAction(reaction) {
@@ -91,6 +91,21 @@ function applyVerdictToReaction(reaction, verdict) {
91
91
  confidence: Number(reaction.confidence.toFixed(3)),
92
92
  };
93
93
  }
94
+ if (verdict.status === "PENALIZE") {
95
+ // Penalized agents get blocked AND frozen — stronger than BLOCK
96
+ return {
97
+ ...reaction,
98
+ impact: 0,
99
+ confidence: Number((Math.max(0.01, reaction.confidence * 0.1)).toFixed(3)),
100
+ };
101
+ }
102
+ if (verdict.status === "REWARD") {
103
+ // Rewarded agents get a confidence boost — positive reinforcement
104
+ return {
105
+ ...reaction,
106
+ confidence: Number((Math.min(1, reaction.confidence * 1.3)).toFixed(3)),
107
+ };
108
+ }
94
109
  // ALLOW — no change
95
110
  return reaction;
96
111
  }
@@ -8,7 +8,7 @@
8
8
  * from the goal to generate candidate strategies, then tests each one
9
9
  * against the swarm simulation to rank feasibility.
10
10
  *
11
- * Two modes of Mirotir:
11
+ * Two modes of NeuroVerse:
12
12
  * EXPLORE: "What might happen?" → forward simulation → discovery
13
13
  * GOAL: "How do I get here?" → backward reasoning → strategy design
14
14
  *
@@ -32,7 +32,7 @@
32
32
  */
33
33
  Object.defineProperty(exports, "__esModule", { value: true });
34
34
  exports.runGoalReasoning = runGoalReasoning;
35
- const mirofish_1 = require("./mirofish");
35
+ const swarmSimulation_1 = require("./swarmSimulation");
36
36
  // ============================================
37
37
  // LEVER INFERENCE
38
38
  // ============================================
@@ -409,8 +409,7 @@ async function testStrategyAgainstSwarm(strategy, scenario, goal, stakeholders,
409
409
  harms_stakeholders: strategy.likely_opponents,
410
410
  };
411
411
  // Run the simulation
412
- const unified = await (0, mirofish_1.runUnifiedSimulation)(strategyScenario, stakeholders, [strategyPath], swarmConfig);
413
- const result = unified.result;
412
+ const result = await (0, swarmSimulation_1.runSwarmSimulation)(strategyScenario, stakeholders, [strategyPath], swarmConfig);
414
413
  // Evaluate goal proximity from swarm results
415
414
  const avgImpact = result.rounds.length > 0
416
415
  ? result.rounds[result.rounds.length - 1].reactions.reduce((s, r) => s + r.impact, 0) / result.rounds[result.rounds.length - 1].reactions.length
@@ -129,6 +129,24 @@ function runFullGovernanceChecks(request, worldLite) {
129
129
  detail: `Guard paused: ${guardVerdict.reason ?? "Review recommended"}. Continuing in advisory mode.`,
130
130
  });
131
131
  }
132
+ // If guard penalizes, note it with consequence details
133
+ if (guardVerdict.status === "PENALIZE") {
134
+ results.push({
135
+ rule_id: "NV-PENALIZE",
136
+ rule: "NeuroverseOS guard issued PENALIZE — agent penalized",
137
+ passed: false,
138
+ detail: `Guard penalized: ${guardVerdict.consequence?.description ?? guardVerdict.reason ?? "Action penalized by guard"}. Agent frozen for ${guardVerdict.consequence?.rounds ?? 1} round(s). Continuing in advisory mode.`,
139
+ });
140
+ }
141
+ // If guard rewards, note it with reward details
142
+ if (guardVerdict.status === "REWARD") {
143
+ results.push({
144
+ rule_id: "NV-REWARD",
145
+ rule: "NeuroverseOS guard issued REWARD — agent rewarded",
146
+ passed: true,
147
+ detail: `Guard rewarded: ${guardVerdict.reward?.description ?? guardVerdict.reason ?? "Action rewarded by guard"}. Agent influence boosted.`,
148
+ });
149
+ }
132
150
  }
133
151
  catch (error) {
134
152
  // If NeuroverseOS evaluation fails, log and continue with Echelon checks
@@ -1,28 +1,27 @@
1
1
  "use strict";
2
2
  /**
3
- * Echelon Reason API Public Exports
3
+ * NeuroVerse Governed Discovery Engine
4
4
  *
5
- * The POST /reason API makes Echelon reasoning infrastructure.
6
- * This is the "Stripe for reasoning" layer that agents,
7
- * applications, and the Mirotir UI all consume.
5
+ * Public exports for the reasoning and governance infrastructure.
6
+ * Built on @neuroverseos/governance (open source).
8
7
  *
9
8
  * Architecture:
10
- * Mirotir UI (showcase) ──→ POST /reason ──→ Echelon kernel (proprietary)
11
- * Autonomous agents ──→ POST /reason ──→ Echelon kernel
12
- * Third-party apps ──→ POST /reason ──→ Echelon kernel
13
- *
14
- * ├── Governance traces (open, auditable)
15
- * ├── MiroFish swarm simulation (when available)
16
- * ├── Echelon-native simulation (fallback)
17
- * ├── World files (reasoning models)
18
- * └── Scenario capsules (shareable, portable)
9
+ * NeuroVerse UI ──→ POST /reason ──→ Echelon kernel (proprietary)
10
+ * Autonomous agents ──→ POST /reason ──→ Echelon kernel
11
+ * Third-party apps ──→ POST /reason ──→ Echelon kernel
12
+ * ScienceClaw / any swarm ──→ POST /reason ──→ Echelon kernel
13
+ *
14
+ * ├── Governance traces (open, auditable)
15
+ * ├── Swarm simulation (native or external)
16
+ * ├── World files (NeuroverseOS governance models)
17
+ * ├── Intent translator (NL → rules)
18
+ * └── Scenario capsules (shareable, portable)
19
19
  *
20
- * MiroFish shows WHAT might happenthe spectacle
21
- * Mirotir helps you decide WHAT TO DO → the brain
20
+ * Scientists define what matters governance enforces it agents operate within bounds.
22
21
  */
23
22
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.policyToWorld = exports.validatePolicy = exports.parseRulesFromText = exports.suggestExperiments = exports.formatPolicyDiagnostics = exports.formatGuidedNextSteps = exports.exportEnforcementReportJSON = exports.formatEnforcementReport = exports.createEnforcementSession = exports.formatCrossRunComparison = exports.formatBehavioralAnalysis = exports.compareBehaviorAcrossRuns = exports.detectBehavioralShifts = exports.computeActionDistributions = exports.buildAgentTrajectories = exports.classifyBehavior = exports.analyzeBehavior = exports.TRADING_DEMO = exports.runGovernedComparison = exports.analyzeMiroFishSimulation = exports.DEFAULT_MIROFISH_CONFIG = exports.buildMiroFishRequest = exports.miroFishResultToSwarmResult = exports.stakeholdersToMiroFishAgents = exports.runUnifiedSimulation = exports.getMiroFishClient = exports.configureMiroFish = exports.MiroFishError = exports.MiroFishClient = exports.runSwarmSimulation = exports.initNeuroverseModule = exports.validationToEnforcedConstraints = exports.simulationToGovernanceSignals = exports.verdictToConstitutionalChecks = exports.validateScenarioWorld = exports.runWorldSimulation = exports.evaluateScenarioGuard = exports.buildWorldFromScenario = exports.runFullGovernanceChecks = exports.runGovernanceChecks = exports.processReasonRequest = exports.SCENARIO_TEMPLATES = exports.getPresetCapsule = exports.extractCapsuleFromUrl = exports.buildShareableUrl = exports.decodeCapsule = exports.encodeCapsule = exports.capsuleToReasonRequest = exports.createCapsule = exports.runGoalReasoning = void 0;
25
- exports.EXAMPLE_WORLD_STATES = exports.EXAMPLE_ACTIONS = exports.createGovernor = exports.govern = exports.extractTrace = exports.generateGovernedReport = exports.formatAuditTrail = exports.searchAuditTrails = exports.loadAuditSession = exports.listAuditSessions = exports.AuditTrail = exports.evaluateAIAction = exports.listAIProviders = exports.getDefaultProviderName = exports.getAIProvider = exports.registerAIProvider = exports.generateAIReaction = exports.generateDeterministicReport = exports.OpenAICompatibleProvider = exports.AnthropicProvider = exports.DeterministicProvider = exports.AI_ROLES = exports.parseReasonRequestBody = exports.handleRunPreset = exports.handleGetPreset = exports.handleListPresets = exports.handleHealthCheck = exports.handleCreateCapsule = exports.handleReasonFromCapsule = exports.handleReasonRequest = exports.applyQuickFix = exports.runPolicyPipeline = void 0;
23
+ exports.parseReasonRequestBody = exports.handleRunPreset = exports.handleGetPreset = exports.handleListPresets = exports.handleHealthCheck = exports.handleCreateCapsule = exports.handleReasonFromCapsule = exports.handleReasonRequest = exports.applyQuickFix = exports.runPolicyPipeline = exports.policyToWorld = exports.validatePolicy = exports.parseRulesFromText = exports.suggestExperiments = exports.formatPolicyDiagnostics = exports.formatGuidedNextSteps = exports.exportEnforcementReportJSON = exports.formatEnforcementReport = exports.createEnforcementSession = exports.formatCrossRunComparison = exports.formatBehavioralAnalysis = exports.compareBehaviorAcrossRuns = exports.detectBehavioralShifts = exports.computeActionDistributions = exports.buildAgentTrajectories = exports.classifyBehavior = exports.analyzeBehavior = exports.runGovernedComparison = exports.analyzeSimulation = exports.runSwarmSimulation = exports.initNeuroverseModule = exports.validationToEnforcedConstraints = exports.simulationToGovernanceSignals = exports.verdictToConstitutionalChecks = exports.validateScenarioWorld = exports.runWorldSimulation = exports.evaluateScenarioGuard = exports.buildWorldFromScenario = exports.runFullGovernanceChecks = exports.runGovernanceChecks = exports.processReasonRequest = exports.SCENARIO_TEMPLATES = exports.getPresetCapsule = exports.extractCapsuleFromUrl = exports.buildShareableUrl = exports.decodeCapsule = exports.encodeCapsule = exports.capsuleToReasonRequest = exports.createCapsule = exports.runGoalReasoning = void 0;
24
+ exports.EXAMPLE_WORLD_STATES = exports.EXAMPLE_ACTIONS = exports.createGovernor = exports.govern = exports.extractTrace = exports.generateGovernedReport = exports.translateIntent = exports.formatAuditTrail = exports.searchAuditTrails = exports.loadAuditSession = exports.listAuditSessions = exports.AuditTrail = exports.evaluateAIAction = exports.listAIProviders = exports.getDefaultProviderName = exports.getAIProvider = exports.registerAIProvider = exports.generateAIReaction = exports.generateDeterministicReport = exports.OpenAICompatibleProvider = exports.AnthropicProvider = exports.DeterministicProvider = exports.AI_ROLES = void 0;
26
25
  // Goal-Directed Strategy Engine
27
26
  var goalEngine_1 = require("./goalEngine");
28
27
  Object.defineProperty(exports, "runGoalReasoning", { enumerable: true, get: function () { return goalEngine_1.runGoalReasoning; } });
@@ -56,21 +55,10 @@ Object.defineProperty(exports, "initNeuroverseModule", { enumerable: true, get:
56
55
  // Swarm Simulation (Echelon-native)
57
56
  var swarmSimulation_1 = require("./swarmSimulation");
58
57
  Object.defineProperty(exports, "runSwarmSimulation", { enumerable: true, get: function () { return swarmSimulation_1.runSwarmSimulation; } });
59
- var mirofish_1 = require("./mirofish");
60
- Object.defineProperty(exports, "MiroFishClient", { enumerable: true, get: function () { return mirofish_1.MiroFishClient; } });
61
- Object.defineProperty(exports, "MiroFishError", { enumerable: true, get: function () { return mirofish_1.MiroFishError; } });
62
- Object.defineProperty(exports, "configureMiroFish", { enumerable: true, get: function () { return mirofish_1.configureMiroFish; } });
63
- Object.defineProperty(exports, "getMiroFishClient", { enumerable: true, get: function () { return mirofish_1.getMiroFishClient; } });
64
- Object.defineProperty(exports, "runUnifiedSimulation", { enumerable: true, get: function () { return mirofish_1.runUnifiedSimulation; } });
65
- Object.defineProperty(exports, "stakeholdersToMiroFishAgents", { enumerable: true, get: function () { return mirofish_1.stakeholdersToMiroFishAgents; } });
66
- Object.defineProperty(exports, "miroFishResultToSwarmResult", { enumerable: true, get: function () { return mirofish_1.miroFishResultToSwarmResult; } });
67
- Object.defineProperty(exports, "buildMiroFishRequest", { enumerable: true, get: function () { return mirofish_1.buildMiroFishRequest; } });
68
- Object.defineProperty(exports, "DEFAULT_MIROFISH_CONFIG", { enumerable: true, get: function () { return mirofish_1.DEFAULT_MIROFISH_CONFIG; } });
69
58
  var analyzer_1 = require("./analyzer");
70
- Object.defineProperty(exports, "analyzeMiroFishSimulation", { enumerable: true, get: function () { return analyzer_1.analyzeMiroFishSimulation; } });
59
+ Object.defineProperty(exports, "analyzeSimulation", { enumerable: true, get: function () { return analyzer_1.analyzeSimulation; } });
71
60
  var governedSimulation_1 = require("./governedSimulation");
72
61
  Object.defineProperty(exports, "runGovernedComparison", { enumerable: true, get: function () { return governedSimulation_1.runGovernedComparison; } });
73
- Object.defineProperty(exports, "TRADING_DEMO", { enumerable: true, get: function () { return governedSimulation_1.TRADING_DEMO; } });
74
62
  var behavioralAnalysis_1 = require("./behavioralAnalysis");
75
63
  Object.defineProperty(exports, "analyzeBehavior", { enumerable: true, get: function () { return behavioralAnalysis_1.analyzeBehavior; } });
76
64
  Object.defineProperty(exports, "classifyBehavior", { enumerable: true, get: function () { return behavioralAnalysis_1.classifyBehavior; } });
@@ -121,6 +109,8 @@ Object.defineProperty(exports, "listAuditSessions", { enumerable: true, get: fun
121
109
  Object.defineProperty(exports, "loadAuditSession", { enumerable: true, get: function () { return auditTrace_1.loadAuditSession; } });
122
110
  Object.defineProperty(exports, "searchAuditTrails", { enumerable: true, get: function () { return auditTrace_1.searchAuditTrails; } });
123
111
  Object.defineProperty(exports, "formatAuditTrail", { enumerable: true, get: function () { return auditTrace_1.formatAuditTrail; } });
112
+ var intentTranslator_1 = require("./intentTranslator");
113
+ Object.defineProperty(exports, "translateIntent", { enumerable: true, get: function () { return intentTranslator_1.translateIntent; } });
124
114
  var reportEngine_1 = require("./reportEngine");
125
115
  Object.defineProperty(exports, "generateGovernedReport", { enumerable: true, get: function () { return reportEngine_1.generateGovernedReport; } });
126
116
  Object.defineProperty(exports, "extractTrace", { enumerable: true, get: function () { return reportEngine_1.extractTrace; } });