@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,340 +0,0 @@
1
- import {
2
- validateWorld
3
- } from "./chunk-7P3S7MAY.js";
4
- import {
5
- simulateWorld
6
- } from "./chunk-FYS2CBUW.js";
7
-
8
- // src/engine/improve-engine.ts
9
- function improveWorld(world) {
10
- const suggestions = [];
11
- const report = validateWorld(world);
12
- addValidationSuggestions(report.findings, suggestions);
13
- analyzeRuleBalance(world, suggestions);
14
- analyzeStateCoverage(world, suggestions);
15
- analyzeGateCoverage(world, suggestions);
16
- analyzeAssumptions(world, suggestions);
17
- analyzeSimulationDynamics(world, suggestions);
18
- analyzeCompleteness(world, suggestions);
19
- const seen = /* @__PURE__ */ new Set();
20
- const unique = suggestions.filter((s) => {
21
- if (seen.has(s.id)) return false;
22
- seen.add(s.id);
23
- return true;
24
- });
25
- const priorityOrder = {
26
- critical: 0,
27
- high: 1,
28
- medium: 2,
29
- low: 3
30
- };
31
- unique.sort((a, b) => priorityOrder[a.priority] - priorityOrder[b.priority]);
32
- const score = computeHealthScore(world, unique);
33
- return {
34
- worldId: world.world.world_id,
35
- worldName: world.world.name,
36
- score,
37
- suggestions: unique,
38
- stats: {
39
- critical: unique.filter((s) => s.priority === "critical").length,
40
- high: unique.filter((s) => s.priority === "high").length,
41
- medium: unique.filter((s) => s.priority === "medium").length,
42
- low: unique.filter((s) => s.priority === "low").length
43
- }
44
- };
45
- }
46
- function addValidationSuggestions(findings, suggestions) {
47
- for (const f of findings) {
48
- if (f.severity === "info") continue;
49
- const priority = f.severity === "error" ? "critical" : "high";
50
- const category = f.severity === "error" ? "fix" : "structure";
51
- suggestions.push({
52
- id: `validate-${f.id}`,
53
- priority,
54
- category,
55
- title: f.message,
56
- description: f.message,
57
- action: f.suggestion ?? `Review ${f.affectedBlocks.join(", ")}`,
58
- affectedFiles: f.affectedBlocks
59
- });
60
- }
61
- }
62
- function analyzeRuleBalance(world, suggestions) {
63
- if (!world.rules || world.rules.length === 0) return;
64
- const structural = world.rules.filter((r) => r.severity === "structural");
65
- const degradation = world.rules.filter((r) => r.severity === "degradation");
66
- const advantage = world.rules.filter((r) => r.severity === "advantage");
67
- if (structural.length === 0) {
68
- suggestions.push({
69
- id: "no-structural-rules",
70
- priority: "high",
71
- category: "balance",
72
- title: "No structural rules",
73
- description: "All rules are degradation or advantage. Structural rules define the core mechanics that hold the world together.",
74
- action: "Add at least one structural-severity rule that enforces a fundamental world constraint.",
75
- affectedFiles: ["rules/"]
76
- });
77
- }
78
- if (advantage.length === 0 && world.rules.length >= 3) {
79
- suggestions.push({
80
- id: "no-advantage-rules",
81
- priority: "medium",
82
- category: "balance",
83
- title: "No advantage rules",
84
- description: "All rules are negative (structural or degradation). Adding advantage rules creates positive feedback loops.",
85
- action: 'Add a rule with severity "advantage" that rewards desirable state.',
86
- affectedFiles: ["rules/"]
87
- });
88
- }
89
- if (degradation.length === 0 && world.rules.length >= 3) {
90
- suggestions.push({
91
- id: "no-degradation-rules",
92
- priority: "medium",
93
- category: "balance",
94
- title: "No degradation rules",
95
- description: "No rules model gradual decline. Degradation rules create realistic tension.",
96
- action: 'Add a rule with severity "degradation" that models gradual state decline.',
97
- affectedFiles: ["rules/"]
98
- });
99
- }
100
- const missingTranslation = world.rules.filter(
101
- (r) => !r.causal_translation?.trigger_text && !r.causal_translation?.effect_text
102
- );
103
- if (missingTranslation.length > 0 && missingTranslation.length <= 5) {
104
- suggestions.push({
105
- id: "missing-causal-translations",
106
- priority: "low",
107
- category: "completeness",
108
- title: `${missingTranslation.length} rule(s) missing causal translations`,
109
- description: "Causal translations provide human-readable narratives for rules. They improve explain output.",
110
- action: `Add causal_translation to: ${missingTranslation.map((r) => r.id).join(", ")}`,
111
- affectedFiles: ["rules/"]
112
- });
113
- }
114
- }
115
- function analyzeStateCoverage(world, suggestions) {
116
- if (!world.stateSchema?.variables || !world.rules) return;
117
- const variables = Object.keys(world.stateSchema.variables);
118
- const ruleTargets = /* @__PURE__ */ new Set();
119
- const ruleTriggers = /* @__PURE__ */ new Set();
120
- for (const rule of world.rules) {
121
- for (const t of rule.triggers) {
122
- if (t.source === "state") ruleTriggers.add(t.field);
123
- }
124
- for (const e of rule.effects ?? []) {
125
- ruleTargets.add(e.target);
126
- }
127
- for (const ce of rule.effects_conditional ?? []) {
128
- for (const e of ce.effects) {
129
- ruleTargets.add(e.target);
130
- }
131
- }
132
- }
133
- const writeOnly = variables.filter((v) => ruleTargets.has(v) && !ruleTriggers.has(v));
134
- if (writeOnly.length > 0) {
135
- suggestions.push({
136
- id: "write-only-variables",
137
- priority: "medium",
138
- category: "structure",
139
- title: `${writeOnly.length} write-only variable(s)`,
140
- description: `These variables are modified by rules but never trigger any rule: ${writeOnly.join(", ")}. They may be dead-end state.`,
141
- action: "Add rules that trigger on these variables to create feedback loops.",
142
- affectedFiles: ["rules/", "state-schema.json"]
143
- });
144
- }
145
- const readOnly = variables.filter((v) => ruleTriggers.has(v) && !ruleTargets.has(v));
146
- if (readOnly.length > 0 && readOnly.length <= 3) {
147
- suggestions.push({
148
- id: "read-only-variables",
149
- priority: "low",
150
- category: "structure",
151
- title: `${readOnly.length} input-only variable(s)`,
152
- description: `These variables trigger rules but are never modified: ${readOnly.join(", ")}. They act as fixed inputs.`,
153
- action: "This is fine for configuration inputs. If they should evolve, add rules that target them.",
154
- affectedFiles: ["state-schema.json"]
155
- });
156
- }
157
- }
158
- function analyzeGateCoverage(world, suggestions) {
159
- const gates = world.gates?.viability_classification ?? [];
160
- if (gates.length === 0) return;
161
- const statuses = new Set(gates.map((g) => g.status));
162
- const standard = ["THRIVING", "STABLE", "COMPRESSED", "CRITICAL", "MODEL_COLLAPSES"];
163
- const missing = standard.filter((s) => !statuses.has(s));
164
- if (missing.length > 0 && missing.length <= 2) {
165
- suggestions.push({
166
- id: "incomplete-viability-gates",
167
- priority: "medium",
168
- category: "structure",
169
- title: `Missing viability level(s): ${missing.join(", ")}`,
170
- description: "A complete viability ladder gives finer-grained status classification.",
171
- action: `Add gates for: ${missing.join(", ")}`,
172
- affectedFiles: ["gates.json"]
173
- });
174
- }
175
- }
176
- function analyzeAssumptions(world, suggestions) {
177
- const profiles = Object.keys(world.assumptions?.profiles ?? {});
178
- if (profiles.length === 1) {
179
- suggestions.push({
180
- id: "single-assumption-profile",
181
- priority: "medium",
182
- category: "completeness",
183
- title: "Only one assumption profile",
184
- description: "A single profile means no scenario comparison. Add an alternative profile to enable what-if analysis.",
185
- action: "Add a second profile with different parameter values to assumptions.json.",
186
- affectedFiles: ["assumptions.json"]
187
- });
188
- }
189
- }
190
- function analyzeSimulationDynamics(world, suggestions) {
191
- if (!world.rules || world.rules.length === 0) return;
192
- if (!world.stateSchema?.variables || Object.keys(world.stateSchema.variables).length === 0) return;
193
- try {
194
- const result = simulateWorld(world, { steps: 1 });
195
- const step = result.steps[0];
196
- if (step && step.rulesFired === 0) {
197
- suggestions.push({
198
- id: "no-rules-fire-default",
199
- priority: "high",
200
- category: "balance",
201
- title: "No rules fire with default state",
202
- description: "With all variables at their defaults, zero rules trigger. The world is inert until state changes.",
203
- action: "Adjust rule thresholds or state defaults so at least some rules fire in the baseline scenario.",
204
- affectedFiles: ["rules/", "state-schema.json"]
205
- });
206
- }
207
- if (result.collapsed && result.collapseStep === 1) {
208
- suggestions.push({
209
- id: "immediate-collapse",
210
- priority: "critical",
211
- category: "balance",
212
- title: "World collapses on first step",
213
- description: `Rule "${result.collapseRule}" triggers collapse immediately with default state. The world cannot sustain itself.`,
214
- action: "Adjust collapse thresholds or state defaults to prevent immediate collapse.",
215
- affectedFiles: ["rules/", "state-schema.json"]
216
- });
217
- }
218
- if (!result.collapsed) {
219
- const multiStep = simulateWorld(world, { steps: 5 });
220
- if (multiStep.collapsed) {
221
- suggestions.push({
222
- id: "eventual-collapse",
223
- priority: "high",
224
- category: "balance",
225
- title: `World collapses by step ${multiStep.collapseStep}`,
226
- description: `Starting from defaults, the world collapses after ${multiStep.collapseStep} steps. Consider adding stabilizing advantage rules.`,
227
- action: "Add advantage rules or adjust degradation rates to allow sustainable states.",
228
- affectedFiles: ["rules/"]
229
- });
230
- }
231
- }
232
- } catch {
233
- }
234
- }
235
- function analyzeCompleteness(world, suggestions) {
236
- if (!world.guards) {
237
- suggestions.push({
238
- id: "add-guards",
239
- priority: "low",
240
- category: "completeness",
241
- title: "No guards defined",
242
- description: "Guards enable runtime enforcement in Action Space. Without them, the world has no runtime protection.",
243
- action: "Add guards.json with structural guards backing each invariant.",
244
- affectedFiles: ["guards.json"]
245
- });
246
- }
247
- if (!world.roles) {
248
- suggestions.push({
249
- id: "add-roles",
250
- priority: "low",
251
- category: "completeness",
252
- title: "No roles defined",
253
- description: "Roles enable multi-agent governance with different permission levels.",
254
- action: "Add roles.json with at least an observer and steward role.",
255
- affectedFiles: ["roles.json"]
256
- });
257
- }
258
- if (!world.kernel) {
259
- suggestions.push({
260
- id: "add-kernel",
261
- priority: "low",
262
- category: "completeness",
263
- title: "No kernel configuration",
264
- description: "A kernel config provides Thinking Space governance with forbidden patterns and response vocabulary.",
265
- action: "Add kernel.json with input/output boundaries.",
266
- affectedFiles: ["kernel.json"]
267
- });
268
- }
269
- const outcomes = world.outcomes?.computed_outcomes ?? [];
270
- if (outcomes.length > 0 && !outcomes.some((o) => o.primary)) {
271
- suggestions.push({
272
- id: "no-primary-outcome",
273
- priority: "medium",
274
- category: "structure",
275
- title: "No primary outcome defined",
276
- description: "Marking one outcome as primary helps tools identify the main metric to display.",
277
- action: "Set primary: true on the most important computed outcome.",
278
- affectedFiles: ["outcomes.json"]
279
- });
280
- }
281
- }
282
- function computeHealthScore(world, suggestions) {
283
- let score = 100;
284
- for (const s of suggestions) {
285
- switch (s.priority) {
286
- case "critical":
287
- score -= 15;
288
- break;
289
- case "high":
290
- score -= 5;
291
- break;
292
- case "medium":
293
- score -= 2;
294
- break;
295
- case "low":
296
- score -= 1;
297
- break;
298
- }
299
- }
300
- return Math.max(0, Math.min(100, score));
301
- }
302
- function renderImproveText(report) {
303
- const lines = [];
304
- lines.push(`IMPROVE: ${report.worldName}`);
305
- lines.push(`Health Score: ${report.score}/100`);
306
- lines.push("");
307
- if (report.suggestions.length === 0) {
308
- lines.push("No suggestions \u2014 this world is in great shape.");
309
- return lines.join("\n");
310
- }
311
- const groups = [
312
- ["CRITICAL (must fix)", "critical", "x"],
313
- ["HIGH PRIORITY", "high", "!"],
314
- ["SUGGESTIONS", "medium", "-"],
315
- ["NICE TO HAVE", "low", "."]
316
- ];
317
- for (const [header, priority, icon] of groups) {
318
- const items = report.suggestions.filter((s) => s.priority === priority);
319
- if (items.length === 0) continue;
320
- lines.push(header);
321
- for (const s of items) {
322
- lines.push(` ${icon} ${s.title}`);
323
- lines.push(` Action: ${s.action}`);
324
- }
325
- lines.push("");
326
- }
327
- const { stats } = report;
328
- const parts = [];
329
- if (stats.critical > 0) parts.push(`${stats.critical} critical`);
330
- if (stats.high > 0) parts.push(`${stats.high} high`);
331
- if (stats.medium > 0) parts.push(`${stats.medium} medium`);
332
- if (stats.low > 0) parts.push(`${stats.low} low`);
333
- lines.push(`Total: ${report.suggestions.length} suggestions (${parts.join(", ")})`);
334
- return lines.join("\n");
335
- }
336
-
337
- export {
338
- improveWorld,
339
- renderImproveText
340
- };
@@ -1,43 +0,0 @@
1
- // src/cli/cli-utils.ts
2
- async function resolveWorldPath(input) {
3
- const { stat } = await import("fs/promises");
4
- try {
5
- const info = await stat(input);
6
- if (info.isDirectory()) return input;
7
- } catch {
8
- }
9
- const neuroversePath = `.neuroverse/worlds/${input}`;
10
- try {
11
- const info = await stat(neuroversePath);
12
- if (info.isDirectory()) return neuroversePath;
13
- } catch {
14
- }
15
- throw new Error(
16
- `World not found: "${input}"
17
- Tried:
18
- ${input}
19
- ${neuroversePath}
20
-
21
- Build a world first: neuroverse build <input.md>`
22
- );
23
- }
24
- async function readStdin() {
25
- const chunks = [];
26
- for await (const chunk of process.stdin) {
27
- chunks.push(chunk);
28
- }
29
- return Buffer.concat(chunks).toString("utf-8");
30
- }
31
- function parseCliValue(raw) {
32
- if (raw === "true") return true;
33
- if (raw === "false") return false;
34
- const num = Number(raw);
35
- if (!isNaN(num) && raw.trim() !== "") return num;
36
- return raw;
37
- }
38
-
39
- export {
40
- resolveWorldPath,
41
- readStdin,
42
- parseCliValue
43
- };