@neuroverseos/governance 0.2.3 → 0.3.1

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 (118) hide show
  1. package/package.json +4 -2
  2. package/policies/content-moderation-rules.txt +8 -0
  3. package/policies/marketing-rules.txt +8 -0
  4. package/policies/science-research-rules.txt +11 -0
  5. package/policies/social-media-rules.txt +7 -0
  6. package/policies/strict-rules.txt +8 -0
  7. package/policies/trading-rules.txt +8 -0
  8. package/simulate.html +1899 -0
  9. package/dist/adapters/autoresearch.cjs +0 -196
  10. package/dist/adapters/autoresearch.d.cts +0 -103
  11. package/dist/adapters/autoresearch.d.ts +0 -103
  12. package/dist/adapters/autoresearch.js +0 -7
  13. package/dist/adapters/deep-agents.cjs +0 -1472
  14. package/dist/adapters/deep-agents.d.cts +0 -181
  15. package/dist/adapters/deep-agents.d.ts +0 -181
  16. package/dist/adapters/deep-agents.js +0 -17
  17. package/dist/adapters/express.cjs +0 -1196
  18. package/dist/adapters/express.d.cts +0 -66
  19. package/dist/adapters/express.d.ts +0 -66
  20. package/dist/adapters/express.js +0 -12
  21. package/dist/adapters/index.cjs +0 -2038
  22. package/dist/adapters/index.d.cts +0 -8
  23. package/dist/adapters/index.d.ts +0 -8
  24. package/dist/adapters/index.js +0 -68
  25. package/dist/adapters/langchain.cjs +0 -1259
  26. package/dist/adapters/langchain.d.cts +0 -89
  27. package/dist/adapters/langchain.d.ts +0 -89
  28. package/dist/adapters/langchain.js +0 -17
  29. package/dist/adapters/openai.cjs +0 -1289
  30. package/dist/adapters/openai.d.cts +0 -99
  31. package/dist/adapters/openai.d.ts +0 -99
  32. package/dist/adapters/openai.js +0 -17
  33. package/dist/adapters/openclaw.cjs +0 -1281
  34. package/dist/adapters/openclaw.d.cts +0 -99
  35. package/dist/adapters/openclaw.d.ts +0 -99
  36. package/dist/adapters/openclaw.js +0 -17
  37. package/dist/bootstrap-GXVDZNF7.js +0 -114
  38. package/dist/build-X5MZY4IA.js +0 -339
  39. package/dist/chunk-4L6OPKMQ.js +0 -100
  40. package/dist/chunk-4NGDRRQH.js +0 -10
  41. package/dist/chunk-5U2MQO5P.js +0 -57
  42. package/dist/chunk-6BB55YJI.js +0 -113
  43. package/dist/chunk-6CZSKEY5.js +0 -164
  44. package/dist/chunk-7P3S7MAY.js +0 -1090
  45. package/dist/chunk-A5W4GNQO.js +0 -130
  46. package/dist/chunk-AF2VX4AL.js +0 -363
  47. package/dist/chunk-AKW5YVCE.js +0 -96
  48. package/dist/chunk-BMOXICAB.js +0 -340
  49. package/dist/chunk-BQZMOEML.js +0 -43
  50. package/dist/chunk-D2UCV5AK.js +0 -326
  51. package/dist/chunk-EVDJUSZ2.js +0 -91
  52. package/dist/chunk-FYS2CBUW.js +0 -304
  53. package/dist/chunk-I3RRAYK2.js +0 -11
  54. package/dist/chunk-IZSO75NZ.js +0 -792
  55. package/dist/chunk-JCKSW2PZ.js +0 -304
  56. package/dist/chunk-JZPQGIKR.js +0 -79
  57. package/dist/chunk-KTFTTLTP.js +0 -246
  58. package/dist/chunk-MH7BT4VH.js +0 -15
  59. package/dist/chunk-ORJ3NOE6.js +0 -622
  60. package/dist/chunk-OT6PXH54.js +0 -61
  61. package/dist/chunk-Q6O7ZLO2.js +0 -62
  62. package/dist/chunk-QLPTHTVB.js +0 -253
  63. package/dist/chunk-REXY4LUL.js +0 -226
  64. package/dist/chunk-T5EUJQE5.js +0 -172
  65. package/dist/chunk-TTBKTF3P.js +0 -608
  66. package/dist/chunk-XPDMYECO.js +0 -642
  67. package/dist/chunk-YZFATT7X.js +0 -9
  68. package/dist/chunk-ZIVQNSZU.js +0 -119
  69. package/dist/chunk-ZJTDUCC2.js +0 -194
  70. package/dist/cli/neuroverse.cjs +0 -12564
  71. package/dist/cli/neuroverse.d.cts +0 -1
  72. package/dist/cli/neuroverse.d.ts +0 -1
  73. package/dist/cli/neuroverse.js +0 -208
  74. package/dist/cli/plan.cjs +0 -1686
  75. package/dist/cli/plan.d.cts +0 -20
  76. package/dist/cli/plan.d.ts +0 -20
  77. package/dist/cli/plan.js +0 -353
  78. package/dist/cli/run.cjs +0 -1945
  79. package/dist/cli/run.d.cts +0 -20
  80. package/dist/cli/run.d.ts +0 -20
  81. package/dist/cli/run.js +0 -143
  82. package/dist/configure-ai-TK67ZWZL.js +0 -132
  83. package/dist/decision-flow-LETV5NWY.js +0 -61
  84. package/dist/derive-7365SUFU.js +0 -152
  85. package/dist/doctor-QYISMKEL.js +0 -173
  86. package/dist/equity-penalties-63FGB3I2.js +0 -244
  87. package/dist/explain-A2EWI2OL.js +0 -51
  88. package/dist/guard-3BWL3IGH.js +0 -92
  89. package/dist/guard-contract-C9_zKbzd.d.cts +0 -821
  90. package/dist/guard-contract-C9_zKbzd.d.ts +0 -821
  91. package/dist/guard-engine-QFMIBWJY.js +0 -10
  92. package/dist/impact-UB6DXKSX.js +0 -59
  93. package/dist/improve-XZA57GER.js +0 -66
  94. package/dist/index.cjs +0 -6821
  95. package/dist/index.d.cts +0 -1829
  96. package/dist/index.d.ts +0 -1829
  97. package/dist/index.js +0 -430
  98. package/dist/infer-world-7GVZWFX4.js +0 -543
  99. package/dist/init-PKPIYHYE.js +0 -144
  100. package/dist/init-world-VWMQZQC7.js +0 -223
  101. package/dist/mcp-server-XWQZXNW7.js +0 -13
  102. package/dist/model-adapter-BB7G4MFI.js +0 -11
  103. package/dist/playground-ADWZORNV.js +0 -550
  104. package/dist/redteam-JRQ7FD2F.js +0 -357
  105. package/dist/session-MMYX5YCF.js +0 -15
  106. package/dist/shared--Q8wPBVN.d.ts +0 -60
  107. package/dist/shared-HpAG90PX.d.cts +0 -60
  108. package/dist/shared-U2QFV7JH.js +0 -16
  109. package/dist/simulate-GMIFFXYV.js +0 -83
  110. package/dist/test-JBBZ65X4.js +0 -217
  111. package/dist/trace-3MYWIDEF.js +0 -166
  112. package/dist/validate-LLBWVPGV.js +0 -81
  113. package/dist/validate-engine-UIABSIHD.js +0 -7
  114. package/dist/world-BFJCIQSH.js +0 -378
  115. package/dist/world-loader-HMPTOEA2.js +0 -9
  116. package/dist/worlds/autoresearch.nv-world.md +0 -230
  117. package/dist/worlds/coding-agent.nv-world.md +0 -211
  118. package/dist/worlds/derivation-world.nv-world.md +0 -278
@@ -1,304 +0,0 @@
1
- // src/engine/simulate-engine.ts
2
- function simulateWorld(world, options = {}) {
3
- const steps = Math.max(1, Math.min(options.steps ?? 1, 50));
4
- const profileName = options.profile ?? world.world.default_assumption_profile;
5
- const state = buildInitialState(world.stateSchema, options.stateOverrides);
6
- const assumptions = resolveAssumptions(world.assumptions, profileName);
7
- const initialState = { ...state };
8
- const simulationSteps = [];
9
- let collapsed = false;
10
- let collapseStep;
11
- let collapseRule;
12
- const sortedRules = [...world.rules].sort((a, b) => a.order - b.order);
13
- for (let stepNum = 1; stepNum <= steps; stepNum++) {
14
- if (collapsed) break;
15
- const stepResult = evaluateStep(
16
- stepNum,
17
- sortedRules,
18
- state,
19
- assumptions,
20
- world
21
- );
22
- simulationSteps.push(stepResult);
23
- if (stepResult.collapsed) {
24
- collapsed = true;
25
- collapseStep = stepNum;
26
- collapseRule = stepResult.rulesEvaluated.find((r) => r.collapsed)?.ruleId;
27
- }
28
- }
29
- const finalViability = classifyViability(state, world);
30
- return {
31
- worldId: world.world.world_id,
32
- worldName: world.world.name,
33
- profile: profileName,
34
- initialState,
35
- steps: simulationSteps,
36
- finalState: { ...state },
37
- finalViability,
38
- collapsed,
39
- collapseStep,
40
- collapseRule
41
- };
42
- }
43
- function evaluateStep(stepNum, rules, state, assumptions, world) {
44
- const evaluations = [];
45
- let rulesFired = 0;
46
- let collapsed = false;
47
- const firedRuleIds = /* @__PURE__ */ new Set();
48
- for (const rule of rules) {
49
- if (collapsed) {
50
- evaluations.push({
51
- ruleId: rule.id,
52
- label: rule.label,
53
- triggered: false,
54
- excluded: true,
55
- effects: [],
56
- collapsed: false
57
- });
58
- continue;
59
- }
60
- const excluded = rule.exclusive_with ? firedRuleIds.has(rule.exclusive_with) : false;
61
- if (excluded) {
62
- evaluations.push({
63
- ruleId: rule.id,
64
- label: rule.label,
65
- triggered: false,
66
- excluded: true,
67
- effects: [],
68
- collapsed: false
69
- });
70
- continue;
71
- }
72
- const triggered = evaluateTriggers(rule.triggers, state, assumptions);
73
- if (!triggered) {
74
- evaluations.push({
75
- ruleId: rule.id,
76
- label: rule.label,
77
- triggered: false,
78
- excluded: false,
79
- effects: [],
80
- collapsed: false
81
- });
82
- continue;
83
- }
84
- firedRuleIds.add(rule.id);
85
- rulesFired++;
86
- const appliedEffects = [];
87
- for (const effect of rule.effects ?? []) {
88
- const applied = applyEffect(effect, state);
89
- if (applied) appliedEffects.push(applied);
90
- }
91
- for (const ce of rule.effects_conditional ?? []) {
92
- const conditionMet = evaluateSingleTrigger(ce.condition, state, assumptions);
93
- const andMet = ce.and ? evaluateSingleTrigger(ce.and, state, assumptions) : true;
94
- const orMet = ce.or ? evaluateSingleTrigger(ce.or, state, assumptions) : false;
95
- const anyMet = ce.condition_any ? ce.condition_any.some((c) => evaluateSingleTrigger(c, state, assumptions)) : false;
96
- const shouldApply = conditionMet && andMet || ce.or && orMet || ce.condition_any && anyMet;
97
- if (shouldApply) {
98
- for (const effect of ce.effects) {
99
- const applied = applyEffect(effect, state);
100
- if (applied) appliedEffects.push(applied);
101
- }
102
- }
103
- }
104
- let ruleCollapsed = false;
105
- if (rule.collapse_check) {
106
- const fieldVal = typeof state[rule.collapse_check.field] === "number" ? state[rule.collapse_check.field] : 0;
107
- if (evaluateOperator(fieldVal, rule.collapse_check.operator, rule.collapse_check.value)) {
108
- ruleCollapsed = true;
109
- collapsed = true;
110
- }
111
- }
112
- if (!ruleCollapsed && rule.secondary_check) {
113
- const fieldVal = typeof state[rule.secondary_check.field] === "number" ? state[rule.secondary_check.field] : 0;
114
- if (evaluateOperator(fieldVal, rule.secondary_check.operator, rule.secondary_check.value)) {
115
- ruleCollapsed = true;
116
- collapsed = true;
117
- }
118
- }
119
- evaluations.push({
120
- ruleId: rule.id,
121
- label: rule.label,
122
- triggered: true,
123
- excluded: false,
124
- effects: appliedEffects,
125
- collapsed: ruleCollapsed,
126
- collapseField: ruleCollapsed ? rule.collapse_check?.field ?? rule.secondary_check?.field : void 0
127
- });
128
- }
129
- const viability = classifyViability(state, world);
130
- return {
131
- step: stepNum,
132
- rulesEvaluated: evaluations,
133
- rulesFired,
134
- stateAfter: { ...state },
135
- viability,
136
- collapsed
137
- };
138
- }
139
- function evaluateTriggers(triggers, state, assumptions) {
140
- if (!triggers || triggers.length === 0) return true;
141
- return triggers.every((t) => evaluateSingleTrigger(t, state, assumptions));
142
- }
143
- function evaluateSingleTrigger(trigger, state, assumptions) {
144
- const source = trigger.source === "assumption" ? assumptions : state;
145
- const fieldValue = source[trigger.field];
146
- if (fieldValue === void 0) return false;
147
- return evaluateOperator(fieldValue, trigger.operator, trigger.value);
148
- }
149
- function evaluateOperator(fieldValue, operator, conditionValue) {
150
- switch (operator) {
151
- case "==":
152
- return fieldValue === conditionValue;
153
- case "!=":
154
- return fieldValue !== conditionValue;
155
- case ">":
156
- return typeof fieldValue === "number" && typeof conditionValue === "number" && fieldValue > conditionValue;
157
- case "<":
158
- return typeof fieldValue === "number" && typeof conditionValue === "number" && fieldValue < conditionValue;
159
- case ">=":
160
- return typeof fieldValue === "number" && typeof conditionValue === "number" && fieldValue >= conditionValue;
161
- case "<=":
162
- return typeof fieldValue === "number" && typeof conditionValue === "number" && fieldValue <= conditionValue;
163
- case "in":
164
- return Array.isArray(conditionValue) && conditionValue.includes(String(fieldValue));
165
- default:
166
- return false;
167
- }
168
- }
169
- function applyEffect(effect, state) {
170
- const before = state[effect.target];
171
- let after;
172
- switch (effect.operation) {
173
- case "multiply":
174
- case "multiply_dynamic": {
175
- const current = typeof before === "number" ? before : 0;
176
- const factor = typeof effect.value === "number" ? effect.value : 1;
177
- after = current * factor;
178
- break;
179
- }
180
- case "add":
181
- case "add_dynamic": {
182
- const current = typeof before === "number" ? before : 0;
183
- const addend = typeof effect.value === "number" ? effect.value : 0;
184
- after = current + addend;
185
- break;
186
- }
187
- case "subtract":
188
- case "subtract_dynamic": {
189
- const current = typeof before === "number" ? before : 0;
190
- const subtrahend = typeof effect.value === "number" ? effect.value : 0;
191
- after = current - subtrahend;
192
- break;
193
- }
194
- case "set":
195
- case "set_dynamic":
196
- after = effect.value;
197
- break;
198
- case "set_boolean":
199
- after = !!effect.value;
200
- break;
201
- default:
202
- return null;
203
- }
204
- state[effect.target] = after;
205
- return {
206
- target: effect.target,
207
- operation: effect.operation,
208
- value: effect.value,
209
- before: before ?? 0,
210
- after
211
- };
212
- }
213
- function buildInitialState(schema, overrides) {
214
- const state = {};
215
- for (const [name, variable] of Object.entries(schema.variables ?? {})) {
216
- state[name] = variable.default;
217
- }
218
- if (overrides) {
219
- for (const [key, value] of Object.entries(overrides)) {
220
- state[key] = value;
221
- }
222
- }
223
- return state;
224
- }
225
- function resolveAssumptions(config, profileName) {
226
- const profile = config.profiles?.[profileName];
227
- return profile?.parameters ?? {};
228
- }
229
- function classifyViability(state, world) {
230
- const gates = world.gates?.viability_classification ?? [];
231
- for (const gate of gates) {
232
- const fieldValue = state[gate.field];
233
- if (typeof fieldValue !== "number") continue;
234
- if (evaluateOperator(fieldValue, gate.operator, gate.value)) {
235
- return gate.status;
236
- }
237
- }
238
- return "MODEL_COLLAPSES";
239
- }
240
- function renderSimulateText(result) {
241
- const lines = [];
242
- lines.push(`SIMULATION: ${result.worldName}`);
243
- lines.push(`Profile: ${result.profile}`);
244
- lines.push(`Steps: ${result.steps.length}`);
245
- lines.push("");
246
- lines.push("INITIAL STATE");
247
- for (const [key, value] of Object.entries(result.initialState)) {
248
- lines.push(` ${key}: ${value}`);
249
- }
250
- lines.push("");
251
- for (const step of result.steps) {
252
- lines.push(`STEP ${step.step}`);
253
- const fired = step.rulesEvaluated.filter((r) => r.triggered);
254
- const skipped = step.rulesEvaluated.filter((r) => !r.triggered && !r.excluded);
255
- const excluded = step.rulesEvaluated.filter((r) => r.excluded);
256
- if (fired.length === 0) {
257
- lines.push(" No rules fired (state unchanged)");
258
- } else {
259
- for (const rule of fired) {
260
- lines.push(` FIRED: ${rule.label}`);
261
- for (const effect of rule.effects) {
262
- const beforeStr = formatValue(effect.before);
263
- const afterStr = formatValue(effect.after);
264
- lines.push(` ${effect.target}: ${beforeStr} -> ${afterStr}`);
265
- }
266
- if (rule.collapsed) {
267
- lines.push(` COLLAPSE on ${rule.collapseField}`);
268
- }
269
- }
270
- }
271
- if (excluded.length > 0) {
272
- lines.push(` Excluded: ${excluded.map((r) => r.label).join(", ")}`);
273
- }
274
- lines.push(` Viability: ${step.viability}`);
275
- if (step.collapsed) {
276
- lines.push(" ** MODEL COLLAPSED **");
277
- }
278
- lines.push("");
279
- }
280
- lines.push("FINAL STATE");
281
- for (const [key, value] of Object.entries(result.finalState)) {
282
- const initial = result.initialState[key];
283
- const changed = initial !== value;
284
- const marker = changed ? " (changed)" : "";
285
- lines.push(` ${key}: ${formatValue(value)}${marker}`);
286
- }
287
- lines.push("");
288
- lines.push(`VIABILITY: ${result.finalViability}`);
289
- if (result.collapsed) {
290
- lines.push(`COLLAPSED at step ${result.collapseStep} (rule: ${result.collapseRule})`);
291
- }
292
- return lines.join("\n");
293
- }
294
- function formatValue(v) {
295
- if (typeof v === "number") {
296
- return Number.isInteger(v) ? String(v) : v.toFixed(2);
297
- }
298
- return String(v);
299
- }
300
-
301
- export {
302
- simulateWorld,
303
- renderSimulateText
304
- };
@@ -1,11 +0,0 @@
1
- // src/contracts/validate-contract.ts
2
- var VALIDATE_EXIT_CODES = {
3
- PASS: 0,
4
- FAIL: 1,
5
- WARN: 2,
6
- ERROR: 3
7
- };
8
-
9
- export {
10
- VALIDATE_EXIT_CODES
11
- };