@neuroverseos/nv-sim 0.1.0
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/LICENSE +201 -0
- package/README.md +73 -0
- package/dist/engine/analyzer.js +651 -0
- package/dist/engine/api.js +208 -0
- package/dist/engine/chaosEngine.js +292 -0
- package/dist/engine/cli.js +803 -0
- package/dist/engine/goalEngine.js +559 -0
- package/dist/engine/governance.js +210 -0
- package/dist/engine/governedSimulation.js +529 -0
- package/dist/engine/index.js +82 -0
- package/dist/engine/mirofish.js +295 -0
- package/dist/engine/reasoningEngine.js +548 -0
- package/dist/engine/scenarioCapsule.js +351 -0
- package/dist/engine/swarmSimulation.js +244 -0
- package/dist/engine/types.js +15 -0
- package/dist/engine/worldBridge.js +481 -0
- package/dist/package.json +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* World Bridge — Converts between Echelon scenario types and NeuroverseOS WorldDefinition
|
|
4
|
+
*
|
|
5
|
+
* NeuroverseOS/Neuroverseos-governance (Apache 2.0) provides:
|
|
6
|
+
* - WorldDefinition: the full reasoning model (state, rules, gates, guards, roles, kernel)
|
|
7
|
+
* - evaluateGuard(): deterministic governance evaluation
|
|
8
|
+
* - simulateWorld(): deterministic state evolution through rules
|
|
9
|
+
* - validateWorld(): static analysis of world health
|
|
10
|
+
*
|
|
11
|
+
* This bridge:
|
|
12
|
+
* 1. Builds WorldDefinition from scenario capsules (for inline evaluation)
|
|
13
|
+
* 2. Converts NeuroverseOS simulation results into Echelon swarm format
|
|
14
|
+
* 3. Maps NeuroverseOS guard verdicts into Echelon governance traces
|
|
15
|
+
*
|
|
16
|
+
* IMPORTANT: NeuroverseOS uses dynamic imports to avoid pulling Node.js APIs
|
|
17
|
+
* (fs, path, os) into the browser bundle. The pure governance functions
|
|
18
|
+
* (evaluateGuard, simulateWorld, validateWorld) don't need fs — but the
|
|
19
|
+
* package bundles everything. Dynamic import solves this cleanly.
|
|
20
|
+
*
|
|
21
|
+
* The relationship:
|
|
22
|
+
* NeuroverseOS provides deterministic rails (what CAN'T happen)
|
|
23
|
+
* Echelon provides LLM reasoning within those rails (what SHOULD happen)
|
|
24
|
+
*/
|
|
25
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(o, k2, desc);
|
|
32
|
+
}) : (function(o, m, k, k2) {
|
|
33
|
+
if (k2 === undefined) k2 = k;
|
|
34
|
+
o[k2] = m[k];
|
|
35
|
+
}));
|
|
36
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
37
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38
|
+
}) : function(o, v) {
|
|
39
|
+
o["default"] = v;
|
|
40
|
+
});
|
|
41
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
42
|
+
var ownKeys = function(o) {
|
|
43
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
44
|
+
var ar = [];
|
|
45
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
46
|
+
return ar;
|
|
47
|
+
};
|
|
48
|
+
return ownKeys(o);
|
|
49
|
+
};
|
|
50
|
+
return function (mod) {
|
|
51
|
+
if (mod && mod.__esModule) return mod;
|
|
52
|
+
var result = {};
|
|
53
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
54
|
+
__setModuleDefault(result, mod);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.initNeuroverseModule = initNeuroverseModule;
|
|
60
|
+
exports.buildWorldFromScenario = buildWorldFromScenario;
|
|
61
|
+
exports.evaluateScenarioGuard = evaluateScenarioGuard;
|
|
62
|
+
exports.runWorldSimulation = runWorldSimulation;
|
|
63
|
+
exports.validateScenarioWorld = validateScenarioWorld;
|
|
64
|
+
exports.verdictToConstitutionalChecks = verdictToConstitutionalChecks;
|
|
65
|
+
exports.simulationToGovernanceSignals = simulationToGovernanceSignals;
|
|
66
|
+
exports.validationToEnforcedConstraints = validationToEnforcedConstraints;
|
|
67
|
+
// ============================================
|
|
68
|
+
// LAZY MODULE LOADER
|
|
69
|
+
// ============================================
|
|
70
|
+
/**
|
|
71
|
+
* Lazy-load @neuroverseos/governance at runtime.
|
|
72
|
+
* Returns null in browser environments where Node modules aren't available.
|
|
73
|
+
*/
|
|
74
|
+
let _nvModule;
|
|
75
|
+
async function getNVModule() {
|
|
76
|
+
if (_nvModule !== undefined)
|
|
77
|
+
return _nvModule;
|
|
78
|
+
try {
|
|
79
|
+
const mod = await Promise.resolve().then(() => __importStar(require("@neuroverseos/governance")));
|
|
80
|
+
_nvModule = {
|
|
81
|
+
evaluateGuard: mod.evaluateGuard,
|
|
82
|
+
simulateWorld: mod.simulateWorld,
|
|
83
|
+
validateWorld: mod.validateWorld,
|
|
84
|
+
};
|
|
85
|
+
return _nvModule;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
_nvModule = null;
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Synchronous access to NeuroverseOS module.
|
|
94
|
+
* Must call initNeuroverseModule() first (or it returns null).
|
|
95
|
+
*/
|
|
96
|
+
function getNVModuleSync() {
|
|
97
|
+
return _nvModule ?? null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Initialize NeuroverseOS module. Call once at startup.
|
|
101
|
+
*/
|
|
102
|
+
async function initNeuroverseModule() {
|
|
103
|
+
const mod = await getNVModule();
|
|
104
|
+
return mod !== null;
|
|
105
|
+
}
|
|
106
|
+
// ============================================
|
|
107
|
+
// WORLD BUILDER — Scenario → WorldDefinition
|
|
108
|
+
// ============================================
|
|
109
|
+
/**
|
|
110
|
+
* Build a minimal NeuroverseOS WorldDefinition from an Echelon scenario.
|
|
111
|
+
*/
|
|
112
|
+
function buildWorldFromScenario(request, worldLite) {
|
|
113
|
+
const scenarioId = request.scenario.slice(0, 40).replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
|
|
114
|
+
const stateVariables = {};
|
|
115
|
+
if (request.assumptions?.severity) {
|
|
116
|
+
stateVariables["severity"] = {
|
|
117
|
+
type: "enum",
|
|
118
|
+
options: ["low", "moderate", "high", "critical"],
|
|
119
|
+
default: request.assumptions.severity,
|
|
120
|
+
mutable: true,
|
|
121
|
+
label: "Severity",
|
|
122
|
+
description: "Severity of the situation",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
if (request.assumptions?.environmental_hostility) {
|
|
126
|
+
stateVariables["environmental_hostility"] = {
|
|
127
|
+
type: "enum",
|
|
128
|
+
options: ["low", "moderate", "high"],
|
|
129
|
+
default: request.assumptions.environmental_hostility,
|
|
130
|
+
mutable: true,
|
|
131
|
+
label: "Environmental Hostility",
|
|
132
|
+
description: "External environment hostility",
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (request.assumptions?.time_pressure) {
|
|
136
|
+
stateVariables["time_pressure"] = {
|
|
137
|
+
type: "enum",
|
|
138
|
+
options: ["none", "low", "moderate", "urgent", "immediate"],
|
|
139
|
+
default: request.assumptions.time_pressure,
|
|
140
|
+
mutable: true,
|
|
141
|
+
label: "Time Pressure",
|
|
142
|
+
description: "Time pressure on decision",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (request.assumptions?.regulatory_climate) {
|
|
146
|
+
stateVariables["regulatory_climate"] = {
|
|
147
|
+
type: "enum",
|
|
148
|
+
options: ["permissive", "neutral", "strict", "adversarial"],
|
|
149
|
+
default: request.assumptions.regulatory_climate,
|
|
150
|
+
mutable: true,
|
|
151
|
+
label: "Regulatory Climate",
|
|
152
|
+
description: "Regulatory environment",
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (worldLite?.state_variables) {
|
|
156
|
+
for (const sv of worldLite.state_variables) {
|
|
157
|
+
stateVariables[sv.id] = {
|
|
158
|
+
type: sv.type,
|
|
159
|
+
options: sv.enum_values ? [...sv.enum_values] : undefined,
|
|
160
|
+
min: sv.range?.min,
|
|
161
|
+
max: sv.range?.max,
|
|
162
|
+
default: sv.default_value,
|
|
163
|
+
mutable: true,
|
|
164
|
+
label: sv.label,
|
|
165
|
+
description: sv.label,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const invariants = (worldLite?.invariants ?? []).map((inv) => ({
|
|
170
|
+
id: inv.id,
|
|
171
|
+
label: inv.description,
|
|
172
|
+
enforcement: (inv.enforceable ? "structural" : "prompt"),
|
|
173
|
+
mutable: false,
|
|
174
|
+
}));
|
|
175
|
+
const viabilityClassification = (worldLite?.gates ?? []).map((gate) => ({
|
|
176
|
+
status: mapGateSeverityToViability(gate.severity),
|
|
177
|
+
field: gate.id,
|
|
178
|
+
operator: "==",
|
|
179
|
+
value: 1,
|
|
180
|
+
color: gate.severity === "critical" ? "#ef4444" : gate.severity === "warning" ? "#f59e0b" : "#22c55e",
|
|
181
|
+
icon: gate.severity === "critical" ? "alert-triangle" : gate.severity === "warning" ? "alert-circle" : "info",
|
|
182
|
+
}));
|
|
183
|
+
return {
|
|
184
|
+
world: {
|
|
185
|
+
world_id: `echelon_${scenarioId}`,
|
|
186
|
+
name: request.scenario.slice(0, 60),
|
|
187
|
+
thesis: worldLite?.thesis ?? `Reasoning world for: ${request.scenario.slice(0, 100)}`,
|
|
188
|
+
version: "1.0.0",
|
|
189
|
+
runtime_mode: "SIMULATION",
|
|
190
|
+
default_assumption_profile: "baseline",
|
|
191
|
+
default_alternative_profile: "stressed",
|
|
192
|
+
modules: [],
|
|
193
|
+
players: {
|
|
194
|
+
thinking_space: true,
|
|
195
|
+
experience_space: false,
|
|
196
|
+
action_space: false,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
invariants,
|
|
200
|
+
assumptions: {
|
|
201
|
+
profiles: {
|
|
202
|
+
baseline: {
|
|
203
|
+
name: "Baseline",
|
|
204
|
+
description: "Default assumptions from the scenario",
|
|
205
|
+
is_default_baseline: true,
|
|
206
|
+
parameters: buildAssumptionParameters(request),
|
|
207
|
+
},
|
|
208
|
+
stressed: {
|
|
209
|
+
name: "Stressed",
|
|
210
|
+
description: "Worst-case assumption profile",
|
|
211
|
+
is_default_alternative: true,
|
|
212
|
+
parameters: buildStressedParameters(),
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
parameter_definitions: {},
|
|
216
|
+
},
|
|
217
|
+
stateSchema: {
|
|
218
|
+
variables: stateVariables,
|
|
219
|
+
presets: {},
|
|
220
|
+
},
|
|
221
|
+
rules: [],
|
|
222
|
+
gates: {
|
|
223
|
+
viability_classification: viabilityClassification.length > 0
|
|
224
|
+
? viabilityClassification
|
|
225
|
+
: [{
|
|
226
|
+
status: "STABLE",
|
|
227
|
+
field: "severity",
|
|
228
|
+
operator: "==",
|
|
229
|
+
value: 1,
|
|
230
|
+
color: "#22c55e",
|
|
231
|
+
icon: "check-circle",
|
|
232
|
+
}],
|
|
233
|
+
structural_override: {
|
|
234
|
+
description: "Echelon governance enforcement",
|
|
235
|
+
enforcement: "mandatory",
|
|
236
|
+
},
|
|
237
|
+
sustainability_threshold: 30,
|
|
238
|
+
collapse_visual: {
|
|
239
|
+
background: "#1a0000",
|
|
240
|
+
text: "#ef4444",
|
|
241
|
+
border: "#7f1d1d",
|
|
242
|
+
label: "SCENARIO COLLAPSES",
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
outcomes: {
|
|
246
|
+
computed_outcomes: [],
|
|
247
|
+
comparison_layout: {
|
|
248
|
+
primary_card: "viability",
|
|
249
|
+
status_badge: "severity",
|
|
250
|
+
structural_indicators: [],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
metadata: {
|
|
254
|
+
format_version: "1.0",
|
|
255
|
+
created_at: new Date().toISOString(),
|
|
256
|
+
last_modified: new Date().toISOString(),
|
|
257
|
+
authoring_method: "manual-authoring",
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function mapGateSeverityToViability(severity) {
|
|
262
|
+
switch (severity) {
|
|
263
|
+
case "info": return "STABLE";
|
|
264
|
+
case "warning": return "COMPRESSED";
|
|
265
|
+
case "critical": return "CRITICAL";
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function buildAssumptionParameters(request) {
|
|
269
|
+
const params = {};
|
|
270
|
+
if (request.assumptions?.severity)
|
|
271
|
+
params["severity"] = request.assumptions.severity;
|
|
272
|
+
if (request.assumptions?.environmental_hostility)
|
|
273
|
+
params["environmental_hostility"] = request.assumptions.environmental_hostility;
|
|
274
|
+
if (request.assumptions?.time_pressure)
|
|
275
|
+
params["time_pressure"] = request.assumptions.time_pressure;
|
|
276
|
+
if (request.assumptions?.regulatory_climate)
|
|
277
|
+
params["regulatory_climate"] = request.assumptions.regulatory_climate;
|
|
278
|
+
return params;
|
|
279
|
+
}
|
|
280
|
+
function buildStressedParameters() {
|
|
281
|
+
return {
|
|
282
|
+
severity: "critical",
|
|
283
|
+
environmental_hostility: "high",
|
|
284
|
+
time_pressure: "immediate",
|
|
285
|
+
regulatory_climate: "adversarial",
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
// ============================================
|
|
289
|
+
// GUARD EVALUATION — Scenario → GuardVerdict
|
|
290
|
+
// ============================================
|
|
291
|
+
/**
|
|
292
|
+
* Run NeuroverseOS guard evaluation on a reason request.
|
|
293
|
+
* Falls back to ALLOW verdict if NeuroverseOS is not available (browser).
|
|
294
|
+
*/
|
|
295
|
+
function evaluateScenarioGuard(request, world, options) {
|
|
296
|
+
const nv = getNVModuleSync();
|
|
297
|
+
if (!nv) {
|
|
298
|
+
// NeuroverseOS not available — return permissive verdict
|
|
299
|
+
return {
|
|
300
|
+
status: "ALLOW",
|
|
301
|
+
reason: "NeuroverseOS guard not loaded — permissive fallback",
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
const event = {
|
|
305
|
+
intent: request.scenario,
|
|
306
|
+
tool: "reason",
|
|
307
|
+
scope: "echelon-reasoning",
|
|
308
|
+
actionCategory: "read",
|
|
309
|
+
direction: "input",
|
|
310
|
+
args: {
|
|
311
|
+
depth: request.depth ?? "standard",
|
|
312
|
+
mode: request.mode ?? "explore",
|
|
313
|
+
stakeholder_count: request.stakeholders?.length ?? 0,
|
|
314
|
+
has_goal: !!request.goal,
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
return nv.evaluateGuard(event, world, {
|
|
318
|
+
trace: options?.trace ?? true,
|
|
319
|
+
level: options?.level ?? "standard",
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
// ============================================
|
|
323
|
+
// SIMULATION — World state evolution
|
|
324
|
+
// ============================================
|
|
325
|
+
/**
|
|
326
|
+
* Run NeuroverseOS deterministic simulation.
|
|
327
|
+
* Falls back to empty result if NeuroverseOS is not available.
|
|
328
|
+
*/
|
|
329
|
+
function runWorldSimulation(world, options) {
|
|
330
|
+
const nv = getNVModuleSync();
|
|
331
|
+
if (!nv) {
|
|
332
|
+
return {
|
|
333
|
+
worldId: world.world.world_id,
|
|
334
|
+
worldName: world.world.name,
|
|
335
|
+
profile: "baseline",
|
|
336
|
+
initialState: {},
|
|
337
|
+
steps: [],
|
|
338
|
+
finalState: {},
|
|
339
|
+
finalViability: "STABLE",
|
|
340
|
+
collapsed: false,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
return nv.simulateWorld(world, {
|
|
344
|
+
steps: options?.steps ?? 5,
|
|
345
|
+
stateOverrides: options?.stateOverrides,
|
|
346
|
+
profile: options?.profile,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
// ============================================
|
|
350
|
+
// VALIDATION — World health check
|
|
351
|
+
// ============================================
|
|
352
|
+
/**
|
|
353
|
+
* Validate a NeuroverseOS world definition.
|
|
354
|
+
* Falls back to a healthy report if NeuroverseOS is not available.
|
|
355
|
+
*/
|
|
356
|
+
function validateScenarioWorld(world, mode) {
|
|
357
|
+
const nv = getNVModuleSync();
|
|
358
|
+
if (!nv) {
|
|
359
|
+
return {
|
|
360
|
+
worldId: world.world.world_id,
|
|
361
|
+
worldName: world.world.name,
|
|
362
|
+
worldVersion: world.world.version,
|
|
363
|
+
validatedAt: Date.now(),
|
|
364
|
+
durationMs: 0,
|
|
365
|
+
summary: {
|
|
366
|
+
errors: 0,
|
|
367
|
+
warnings: 0,
|
|
368
|
+
info: 0,
|
|
369
|
+
completenessScore: 100,
|
|
370
|
+
invariantCoverage: 100,
|
|
371
|
+
canRun: true,
|
|
372
|
+
isHealthy: true,
|
|
373
|
+
},
|
|
374
|
+
validationMode: mode ?? "standard",
|
|
375
|
+
findings: [],
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return nv.validateWorld(world, mode);
|
|
379
|
+
}
|
|
380
|
+
// ============================================
|
|
381
|
+
// VERDICT → GOVERNANCE TRACE MAPPING
|
|
382
|
+
// ============================================
|
|
383
|
+
/**
|
|
384
|
+
* Convert NeuroverseOS guard verdicts into Echelon ConstitutionalCheck format.
|
|
385
|
+
*/
|
|
386
|
+
function verdictToConstitutionalChecks(verdict) {
|
|
387
|
+
const checks = [];
|
|
388
|
+
checks.push({
|
|
389
|
+
rule_id: verdict.ruleId ?? "NV-GUARD",
|
|
390
|
+
rule: `NeuroverseOS guard evaluation: ${verdict.status}`,
|
|
391
|
+
passed: verdict.status === "ALLOW",
|
|
392
|
+
detail: verdict.reason ?? "Guard evaluation completed",
|
|
393
|
+
});
|
|
394
|
+
if (verdict.evidence) {
|
|
395
|
+
const evidence = verdict.evidence;
|
|
396
|
+
if (evidence.safetyChecks) {
|
|
397
|
+
for (const sc of evidence.safetyChecks) {
|
|
398
|
+
checks.push({
|
|
399
|
+
rule_id: `NV-SAFETY-${sc.check}`,
|
|
400
|
+
rule: `Safety: ${sc.check}`,
|
|
401
|
+
passed: !sc.triggered,
|
|
402
|
+
detail: sc.triggered ? `Triggered: ${sc.evidence ?? "pattern match"}` : "Passed",
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
if (evidence.guardChecks) {
|
|
407
|
+
for (const gc of evidence.guardChecks) {
|
|
408
|
+
checks.push({
|
|
409
|
+
rule_id: `NV-GUARD-${gc.guardId}`,
|
|
410
|
+
rule: gc.label ?? `Guard ${gc.guardId}`,
|
|
411
|
+
passed: !gc.triggered,
|
|
412
|
+
detail: gc.triggered ? `Triggered: ${gc.enforcement ?? "block"}` : "Passed",
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
if (evidence.invariantChecks) {
|
|
417
|
+
for (const ic of evidence.invariantChecks) {
|
|
418
|
+
checks.push({
|
|
419
|
+
rule_id: `NV-INV-${ic.invariantId}`,
|
|
420
|
+
rule: ic.label ?? `Invariant ${ic.invariantId}`,
|
|
421
|
+
passed: ic.satisfied,
|
|
422
|
+
detail: ic.satisfied ? "Satisfied" : "Violated",
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (evidence.kernelCheck) {
|
|
427
|
+
const kc = evidence.kernelCheck;
|
|
428
|
+
checks.push({
|
|
429
|
+
rule_id: "NV-KERNEL",
|
|
430
|
+
rule: "Kernel boundary enforcement",
|
|
431
|
+
passed: !kc.triggered,
|
|
432
|
+
detail: kc.triggered ? `Kernel violation: ${kc.patternId ?? "forbidden pattern"}` : "Passed",
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return checks;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Convert NeuroverseOS simulation result into governance-relevant signals.
|
|
440
|
+
*/
|
|
441
|
+
function simulationToGovernanceSignals(sim) {
|
|
442
|
+
const totalRulesFired = sim.steps.reduce((sum, s) => sum + s.rulesFired, 0);
|
|
443
|
+
let collapseRisk = "none";
|
|
444
|
+
if (sim.collapsed) {
|
|
445
|
+
collapseRisk = "high";
|
|
446
|
+
}
|
|
447
|
+
else if (sim.finalViability === "CRITICAL") {
|
|
448
|
+
collapseRisk = "high";
|
|
449
|
+
}
|
|
450
|
+
else if (sim.finalViability === "COMPRESSED") {
|
|
451
|
+
collapseRisk = "moderate";
|
|
452
|
+
}
|
|
453
|
+
else if (totalRulesFired > sim.steps.length * 3) {
|
|
454
|
+
collapseRisk = "low";
|
|
455
|
+
}
|
|
456
|
+
return {
|
|
457
|
+
viability: sim.finalViability,
|
|
458
|
+
collapsed: sim.collapsed,
|
|
459
|
+
rulesFired: totalRulesFired,
|
|
460
|
+
collapseRisk,
|
|
461
|
+
stateTrajectory: sim.steps.map((s) => s.stateAfter),
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Convert NeuroverseOS validate report into governance enforced constraints.
|
|
466
|
+
*/
|
|
467
|
+
function validationToEnforcedConstraints(report) {
|
|
468
|
+
const constraints = [];
|
|
469
|
+
constraints.push(`WORLD_HEALTH: ${report.summary.isHealthy ? "HEALTHY" : "DEGRADED"} (${report.summary.completenessScore}% complete)`);
|
|
470
|
+
if (report.summary.invariantCoverage < 100) {
|
|
471
|
+
constraints.push(`INVARIANT_COVERAGE: ${report.summary.invariantCoverage}% — ${100 - report.summary.invariantCoverage}% of invariants lack guard backing`);
|
|
472
|
+
}
|
|
473
|
+
if (report.summary.governanceHealth) {
|
|
474
|
+
const gh = report.summary.governanceHealth;
|
|
475
|
+
constraints.push(`GOVERNANCE_RISK: ${gh.riskLevel} (${gh.surfacesCovered}/${gh.surfacesTotal} surfaces governed)`);
|
|
476
|
+
}
|
|
477
|
+
if (report.summary.errors > 0) {
|
|
478
|
+
constraints.push(`WORLD_ERRORS: ${report.summary.errors} structural issues detected`);
|
|
479
|
+
}
|
|
480
|
+
return constraints;
|
|
481
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/package.json
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neuroverseos/nv-sim",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md",
|
|
9
|
+
"LICENSE"
|
|
10
|
+
],
|
|
11
|
+
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/NeuroverseOS/neuroverse-simulations"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/NeuroverseOS/neuroverse-simulations",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/NeuroverseOS/neuroverse-simulations/issues"
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"nv-sim": "dist/engine/cli.js"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"dev": "vite",
|
|
25
|
+
"build": "vite build",
|
|
26
|
+
"build:cli": "tsc -p tsconfig.cli.json && echo '{\"type\":\"commonjs\"}' > dist/package.json",
|
|
27
|
+
"build:dev": "vite build --mode development",
|
|
28
|
+
"build:all": "vite build && tsc -p tsconfig.cli.json",
|
|
29
|
+
"lint": "eslint .",
|
|
30
|
+
"preview": "vite preview",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"test:watch": "vitest"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@hookform/resolvers": "^3.10.0",
|
|
36
|
+
"@neuroverseos/governance": "^0.3.0",
|
|
37
|
+
"@radix-ui/react-accordion": "^1.2.11",
|
|
38
|
+
"@radix-ui/react-alert-dialog": "^1.1.14",
|
|
39
|
+
"@radix-ui/react-aspect-ratio": "^1.1.7",
|
|
40
|
+
"@radix-ui/react-avatar": "^1.1.10",
|
|
41
|
+
"@radix-ui/react-checkbox": "^1.3.2",
|
|
42
|
+
"@radix-ui/react-collapsible": "^1.1.11",
|
|
43
|
+
"@radix-ui/react-context-menu": "^2.2.15",
|
|
44
|
+
"@radix-ui/react-dialog": "^1.1.14",
|
|
45
|
+
"@radix-ui/react-dropdown-menu": "^2.1.15",
|
|
46
|
+
"@radix-ui/react-hover-card": "^1.1.14",
|
|
47
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
48
|
+
"@radix-ui/react-menubar": "^1.1.15",
|
|
49
|
+
"@radix-ui/react-navigation-menu": "^1.2.13",
|
|
50
|
+
"@radix-ui/react-popover": "^1.1.14",
|
|
51
|
+
"@radix-ui/react-progress": "^1.1.7",
|
|
52
|
+
"@radix-ui/react-radio-group": "^1.3.7",
|
|
53
|
+
"@radix-ui/react-scroll-area": "^1.2.9",
|
|
54
|
+
"@radix-ui/react-select": "^2.2.5",
|
|
55
|
+
"@radix-ui/react-separator": "^1.1.7",
|
|
56
|
+
"@radix-ui/react-slider": "^1.3.5",
|
|
57
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
58
|
+
"@radix-ui/react-switch": "^1.2.5",
|
|
59
|
+
"@radix-ui/react-tabs": "^1.1.12",
|
|
60
|
+
"@radix-ui/react-toast": "^1.2.14",
|
|
61
|
+
"@radix-ui/react-toggle": "^1.1.9",
|
|
62
|
+
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
63
|
+
"@radix-ui/react-tooltip": "^1.2.7",
|
|
64
|
+
"@tanstack/react-query": "^5.83.0",
|
|
65
|
+
"class-variance-authority": "^0.7.1",
|
|
66
|
+
"clsx": "^2.1.1",
|
|
67
|
+
"cmdk": "^1.1.1",
|
|
68
|
+
"date-fns": "^3.6.0",
|
|
69
|
+
"embla-carousel-react": "^8.6.0",
|
|
70
|
+
"input-otp": "^1.4.2",
|
|
71
|
+
"lucide-react": "^0.462.0",
|
|
72
|
+
"next-themes": "^0.3.0",
|
|
73
|
+
"react": "^18.3.1",
|
|
74
|
+
"react-day-picker": "^8.10.1",
|
|
75
|
+
"react-dom": "^18.3.1",
|
|
76
|
+
"react-hook-form": "^7.61.1",
|
|
77
|
+
"react-resizable-panels": "^2.1.9",
|
|
78
|
+
"react-router-dom": "^6.30.1",
|
|
79
|
+
"recharts": "^2.15.4",
|
|
80
|
+
"sonner": "^1.7.4",
|
|
81
|
+
"tailwind-merge": "^2.6.0",
|
|
82
|
+
"tailwindcss-animate": "^1.0.7",
|
|
83
|
+
"vaul": "^0.9.9",
|
|
84
|
+
"zod": "^3.25.76"
|
|
85
|
+
},
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@eslint/js": "^9.32.0",
|
|
88
|
+
"@playwright/test": "^1.57.0",
|
|
89
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
90
|
+
"@testing-library/jest-dom": "^6.6.0",
|
|
91
|
+
"@testing-library/react": "^16.0.0",
|
|
92
|
+
"@types/node": "^22.16.5",
|
|
93
|
+
"@types/react": "^18.3.23",
|
|
94
|
+
"@types/react-dom": "^18.3.7",
|
|
95
|
+
"@vitejs/plugin-react-swc": "^3.11.0",
|
|
96
|
+
"autoprefixer": "^10.4.21",
|
|
97
|
+
"eslint": "^9.32.0",
|
|
98
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
99
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
100
|
+
"globals": "^15.15.0",
|
|
101
|
+
"jsdom": "^20.0.3",
|
|
102
|
+
"lovable-tagger": "^1.1.13",
|
|
103
|
+
"postcss": "^8.5.6",
|
|
104
|
+
"tailwindcss": "^3.4.17",
|
|
105
|
+
"typescript": "^5.8.3",
|
|
106
|
+
"typescript-eslint": "^8.38.0",
|
|
107
|
+
"vite": "^5.4.19",
|
|
108
|
+
"vitest": "^3.2.4"
|
|
109
|
+
}
|
|
110
|
+
}
|