@neuroverseos/governance 0.1.0 → 0.1.2
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.md +190 -0
- package/README.md +472 -115
- package/dist/adapters/express.cjs +874 -0
- package/dist/adapters/express.d.cts +66 -0
- package/dist/adapters/express.d.ts +66 -0
- package/dist/adapters/express.js +10 -0
- package/dist/adapters/index.cjs +1166 -0
- package/dist/adapters/index.d.cts +5 -0
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/index.js +40 -0
- package/dist/adapters/langchain.cjs +861 -0
- package/dist/adapters/langchain.d.cts +82 -0
- package/dist/adapters/langchain.d.ts +82 -0
- package/dist/adapters/langchain.js +14 -0
- package/dist/adapters/openai.cjs +891 -0
- package/dist/adapters/openai.d.cts +92 -0
- package/dist/adapters/openai.d.ts +92 -0
- package/dist/adapters/openai.js +14 -0
- package/dist/adapters/openclaw.cjs +883 -0
- package/dist/adapters/openclaw.d.cts +92 -0
- package/dist/adapters/openclaw.d.ts +92 -0
- package/dist/adapters/openclaw.js +14 -0
- package/dist/bootstrap-H4HHKQ5G.js +113 -0
- package/dist/build-73KAVHEY.js +308 -0
- package/dist/chunk-4NGDRRQH.js +10 -0
- package/dist/chunk-B4NF3OLW.js +673 -0
- package/dist/chunk-BUWWN2NX.js +192 -0
- package/dist/chunk-CROPZ75A.js +107 -0
- package/dist/chunk-D7BGWV2J.js +620 -0
- package/dist/chunk-EIUHJXBB.js +340 -0
- package/dist/chunk-EQXFOKH2.js +85 -0
- package/dist/chunk-FYPYZFV5.js +187 -0
- package/dist/chunk-FYS2CBUW.js +304 -0
- package/dist/chunk-FZQCRGUU.js +115 -0
- package/dist/chunk-I3RRAYK2.js +11 -0
- package/dist/chunk-ITJ3LCPG.js +225 -0
- package/dist/chunk-M3TZFGHO.js +79 -0
- package/dist/chunk-MWDQ4MJB.js +11 -0
- package/dist/chunk-O5OMJMIE.js +590 -0
- package/dist/chunk-T4X42QXC.js +121 -0
- package/dist/chunk-XPDMYECO.js +642 -0
- package/dist/chunk-Z2S2HIV5.js +100 -0
- package/dist/cli/neuroverse.cjs +5864 -0
- package/dist/cli/neuroverse.d.cts +1 -0
- package/dist/cli/neuroverse.d.ts +1 -0
- package/dist/cli/neuroverse.js +128 -0
- package/dist/configure-ai-46JVG56I.js +129 -0
- package/dist/derive-6NAEWLM5.js +150 -0
- package/dist/explain-3B3VB6TL.js +69 -0
- package/dist/guard-67Y66P3I.js +82 -0
- package/dist/guard-contract-D_RQz9kt.d.cts +529 -0
- package/dist/guard-contract-D_RQz9kt.d.ts +529 -0
- package/dist/impact-CHERK3O6.js +57 -0
- package/dist/improve-YG6I6ERG.js +84 -0
- package/dist/index.cjs +4227 -0
- package/dist/index.d.cts +1147 -0
- package/dist/index.d.ts +1139 -25
- package/dist/index.js +318 -1159
- package/dist/init-Z66T6TDI.js +142 -0
- package/dist/simulate-ETHHINZ4.js +107 -0
- package/dist/trace-3YODSSIP.js +164 -0
- package/dist/validate-UVE6GKQU.js +72 -0
- package/dist/validate-engine-657D75OG.js +6 -0
- package/dist/world-WLNHL5XC.js +298 -0
- package/dist/worlds/derivation-world.nv-world.md +278 -0
- package/package.json +74 -26
- package/LICENSE +0 -21
- package/dist/audit-logger.d.ts +0 -38
- package/dist/audit-logger.d.ts.map +0 -1
- package/dist/audit-logger.js +0 -100
- package/dist/audit-logger.js.map +0 -1
- package/dist/condition-engine.d.ts +0 -16
- package/dist/condition-engine.d.ts.map +0 -1
- package/dist/condition-engine.js +0 -186
- package/dist/condition-engine.js.map +0 -1
- package/dist/drift-monitor.d.ts +0 -81
- package/dist/drift-monitor.d.ts.map +0 -1
- package/dist/drift-monitor.js +0 -228
- package/dist/drift-monitor.js.map +0 -1
- package/dist/governance-engine.d.ts +0 -131
- package/dist/governance-engine.d.ts.map +0 -1
- package/dist/governance-engine.js +0 -660
- package/dist/governance-engine.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types.d.ts +0 -196
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -9
- package/dist/types.js.map +0 -1
- package/dist/world-bootstrap.d.ts +0 -31
- package/dist/world-bootstrap.d.ts.map +0 -1
- package/dist/world-bootstrap.js +0 -415
- package/dist/world-bootstrap.js.map +0 -1
- package/openclaw.plugin.json +0 -59
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import {
|
|
2
|
+
loadWorld
|
|
3
|
+
} from "./chunk-M3TZFGHO.js";
|
|
4
|
+
import {
|
|
5
|
+
validateWorld
|
|
6
|
+
} from "./chunk-O5OMJMIE.js";
|
|
7
|
+
|
|
8
|
+
// src/cli/world.ts
|
|
9
|
+
var USAGE = `
|
|
10
|
+
neuroverse world \u2014 World management
|
|
11
|
+
|
|
12
|
+
Usage:
|
|
13
|
+
neuroverse world status <path> Show world identity and health
|
|
14
|
+
neuroverse world diff <path1> <path2> Compare two world versions
|
|
15
|
+
neuroverse world snapshot <path> Save a timestamped snapshot
|
|
16
|
+
neuroverse world rollback <path> Restore the previous snapshot
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--json Output as JSON
|
|
20
|
+
`.trim();
|
|
21
|
+
function parseArgs(argv) {
|
|
22
|
+
const subcommand = argv[0];
|
|
23
|
+
const paths = [];
|
|
24
|
+
const flags = {};
|
|
25
|
+
for (let i = 1; i < argv.length; i++) {
|
|
26
|
+
const arg = argv[i];
|
|
27
|
+
if (arg === "--json") flags.json = true;
|
|
28
|
+
else if (arg === "--help" || arg === "-h") flags.help = true;
|
|
29
|
+
else paths.push(arg);
|
|
30
|
+
}
|
|
31
|
+
return { subcommand, paths, flags };
|
|
32
|
+
}
|
|
33
|
+
async function worldStatus(worldPath, json) {
|
|
34
|
+
const world = await loadWorld(worldPath);
|
|
35
|
+
const report = validateWorld(world);
|
|
36
|
+
if (json) {
|
|
37
|
+
process.stdout.write(JSON.stringify({
|
|
38
|
+
world: world.world,
|
|
39
|
+
metadata: world.metadata,
|
|
40
|
+
guards: world.guards?.guards.length ?? 0,
|
|
41
|
+
invariants: world.invariants.length,
|
|
42
|
+
rules: world.rules.length,
|
|
43
|
+
roles: world.roles?.roles.length ?? 0,
|
|
44
|
+
kernel: world.kernel ? {
|
|
45
|
+
allowedInputs: world.kernel.allowed_inputs?.length ?? 0,
|
|
46
|
+
forbiddenInputs: world.kernel.forbidden_inputs?.length ?? 0,
|
|
47
|
+
allowedOutputs: world.kernel.allowed_outputs?.length ?? 0,
|
|
48
|
+
forbiddenOutputs: world.kernel.forbidden_outputs?.length ?? 0
|
|
49
|
+
} : null,
|
|
50
|
+
validation: report.summary
|
|
51
|
+
}, null, 2) + "\n");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const lines = [];
|
|
55
|
+
lines.push("WORLD STATUS");
|
|
56
|
+
lines.push("\u2500".repeat(40));
|
|
57
|
+
lines.push(` Name: ${world.world.name}`);
|
|
58
|
+
lines.push(` ID: ${world.world.id}`);
|
|
59
|
+
lines.push(` Version: ${world.world.version}`);
|
|
60
|
+
lines.push(` Created: ${world.metadata.created_at || "\u2014"}`);
|
|
61
|
+
lines.push(` Modified: ${world.metadata.last_modified || "\u2014"}`);
|
|
62
|
+
lines.push(` Authoring: ${world.metadata.authoring_method}`);
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push("COMPONENTS");
|
|
65
|
+
lines.push("\u2500".repeat(40));
|
|
66
|
+
lines.push(` Invariants: ${world.invariants.length}`);
|
|
67
|
+
lines.push(` Guards: ${world.guards?.guards.length ?? 0}`);
|
|
68
|
+
lines.push(` Rules: ${world.rules.length}`);
|
|
69
|
+
lines.push(` Roles: ${world.roles?.roles.length ?? 0}`);
|
|
70
|
+
if (world.kernel) {
|
|
71
|
+
const k = world.kernel;
|
|
72
|
+
const totalRules = (k.allowed_inputs?.length ?? 0) + (k.forbidden_inputs?.length ?? 0) + (k.allowed_outputs?.length ?? 0) + (k.forbidden_outputs?.length ?? 0);
|
|
73
|
+
lines.push(` Kernel: ${totalRules} rules`);
|
|
74
|
+
}
|
|
75
|
+
lines.push("");
|
|
76
|
+
lines.push("HEALTH");
|
|
77
|
+
lines.push("\u2500".repeat(40));
|
|
78
|
+
const sev = report.summary;
|
|
79
|
+
const healthIcon = sev.errors === 0 && sev.warnings === 0 ? "HEALTHY" : sev.errors > 0 ? "ISSUES FOUND" : "WARNINGS";
|
|
80
|
+
lines.push(` Status: ${healthIcon}`);
|
|
81
|
+
lines.push(` Errors: ${sev.errors}`);
|
|
82
|
+
lines.push(` Warnings: ${sev.warnings}`);
|
|
83
|
+
lines.push(` Info: ${sev.info}`);
|
|
84
|
+
if (report.findings.length > 0) {
|
|
85
|
+
lines.push("");
|
|
86
|
+
lines.push(" Top findings:");
|
|
87
|
+
for (const f of report.findings.slice(0, 5)) {
|
|
88
|
+
const icon = f.severity === "error" ? "!" : f.severity === "warning" ? "?" : "-";
|
|
89
|
+
lines.push(` [${icon}] ${f.message}`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
process.stdout.write(lines.join("\n") + "\n");
|
|
93
|
+
}
|
|
94
|
+
async function worldDiff(path1, path2, json) {
|
|
95
|
+
const world1 = await loadWorld(path1);
|
|
96
|
+
const world2 = await loadWorld(path2);
|
|
97
|
+
const diff = computeWorldDiff(world1, world2);
|
|
98
|
+
if (json) {
|
|
99
|
+
process.stdout.write(JSON.stringify(diff, null, 2) + "\n");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const lines = [];
|
|
103
|
+
lines.push("WORLD DIFF");
|
|
104
|
+
lines.push("\u2550".repeat(50));
|
|
105
|
+
lines.push(` A: ${world1.world.name} v${world1.world.version}`);
|
|
106
|
+
lines.push(` B: ${world2.world.name} v${world2.world.version}`);
|
|
107
|
+
lines.push("");
|
|
108
|
+
for (const change of diff.changes) {
|
|
109
|
+
const icon = change.type === "added" ? "+" : change.type === "removed" ? "-" : "~";
|
|
110
|
+
lines.push(` [${icon}] ${change.component}: ${change.description}`);
|
|
111
|
+
}
|
|
112
|
+
if (diff.changes.length === 0) {
|
|
113
|
+
lines.push(" No differences found.");
|
|
114
|
+
}
|
|
115
|
+
process.stdout.write(lines.join("\n") + "\n");
|
|
116
|
+
}
|
|
117
|
+
function computeWorldDiff(a, b) {
|
|
118
|
+
const changes = [];
|
|
119
|
+
if (a.world.version !== b.world.version) {
|
|
120
|
+
changes.push({ type: "changed", component: "version", description: `${a.world.version} \u2192 ${b.world.version}` });
|
|
121
|
+
}
|
|
122
|
+
const aInvIds = new Set(a.invariants.map((i) => i.id));
|
|
123
|
+
const bInvIds = new Set(b.invariants.map((i) => i.id));
|
|
124
|
+
for (const id of bInvIds) {
|
|
125
|
+
if (!aInvIds.has(id)) changes.push({ type: "added", component: "invariant", description: id });
|
|
126
|
+
}
|
|
127
|
+
for (const id of aInvIds) {
|
|
128
|
+
if (!bInvIds.has(id)) changes.push({ type: "removed", component: "invariant", description: id });
|
|
129
|
+
}
|
|
130
|
+
const aGuardIds = new Set((a.guards?.guards ?? []).map((g) => g.id));
|
|
131
|
+
const bGuardIds = new Set((b.guards?.guards ?? []).map((g) => g.id));
|
|
132
|
+
for (const id of bGuardIds) {
|
|
133
|
+
if (!aGuardIds.has(id)) changes.push({ type: "added", component: "guard", description: id });
|
|
134
|
+
}
|
|
135
|
+
for (const id of aGuardIds) {
|
|
136
|
+
if (!bGuardIds.has(id)) changes.push({ type: "removed", component: "guard", description: id });
|
|
137
|
+
}
|
|
138
|
+
const aRuleIds = new Set(a.rules.map((r) => r.id));
|
|
139
|
+
const bRuleIds = new Set(b.rules.map((r) => r.id));
|
|
140
|
+
for (const id of bRuleIds) {
|
|
141
|
+
if (!aRuleIds.has(id)) changes.push({ type: "added", component: "rule", description: id });
|
|
142
|
+
}
|
|
143
|
+
for (const id of aRuleIds) {
|
|
144
|
+
if (!bRuleIds.has(id)) changes.push({ type: "removed", component: "rule", description: id });
|
|
145
|
+
}
|
|
146
|
+
const aRoleIds = new Set((a.roles?.roles ?? []).map((r) => r.id));
|
|
147
|
+
const bRoleIds = new Set((b.roles?.roles ?? []).map((r) => r.id));
|
|
148
|
+
for (const id of bRoleIds) {
|
|
149
|
+
if (!aRoleIds.has(id)) changes.push({ type: "added", component: "role", description: id });
|
|
150
|
+
}
|
|
151
|
+
for (const id of aRoleIds) {
|
|
152
|
+
if (!bRoleIds.has(id)) changes.push({ type: "removed", component: "role", description: id });
|
|
153
|
+
}
|
|
154
|
+
const aGuardCount = a.guards?.guards.length ?? 0;
|
|
155
|
+
const bGuardCount = b.guards?.guards.length ?? 0;
|
|
156
|
+
if (aGuardCount !== bGuardCount && changes.filter((c) => c.component === "guard").length === 0) {
|
|
157
|
+
changes.push({ type: "changed", component: "guards", description: `${aGuardCount} \u2192 ${bGuardCount}` });
|
|
158
|
+
}
|
|
159
|
+
return { changes };
|
|
160
|
+
}
|
|
161
|
+
async function worldSnapshot(worldPath) {
|
|
162
|
+
const { readdir, readFile, mkdir, writeFile } = await import("fs/promises");
|
|
163
|
+
const { join } = await import("path");
|
|
164
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
165
|
+
const snapshotDir = join(worldPath, ".snapshots", timestamp);
|
|
166
|
+
await mkdir(snapshotDir, { recursive: true });
|
|
167
|
+
const files = await readdir(worldPath);
|
|
168
|
+
let copied = 0;
|
|
169
|
+
for (const file of files) {
|
|
170
|
+
if (file.endsWith(".json")) {
|
|
171
|
+
const content = await readFile(join(worldPath, file), "utf-8");
|
|
172
|
+
await writeFile(join(snapshotDir, file), content, "utf-8");
|
|
173
|
+
copied++;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
const rulesDir = join(worldPath, "rules");
|
|
178
|
+
const ruleFiles = await readdir(rulesDir);
|
|
179
|
+
await mkdir(join(snapshotDir, "rules"), { recursive: true });
|
|
180
|
+
for (const file of ruleFiles) {
|
|
181
|
+
if (file.endsWith(".json")) {
|
|
182
|
+
const content = await readFile(join(rulesDir, file), "utf-8");
|
|
183
|
+
await writeFile(join(snapshotDir, "rules", file), content, "utf-8");
|
|
184
|
+
copied++;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} catch {
|
|
188
|
+
}
|
|
189
|
+
process.stdout.write(`Snapshot saved: ${snapshotDir}
|
|
190
|
+
`);
|
|
191
|
+
process.stdout.write(`Files: ${copied}
|
|
192
|
+
`);
|
|
193
|
+
}
|
|
194
|
+
async function worldRollback(worldPath) {
|
|
195
|
+
const { readdir, readFile, writeFile, mkdir } = await import("fs/promises");
|
|
196
|
+
const { join } = await import("path");
|
|
197
|
+
const snapshotsDir = join(worldPath, ".snapshots");
|
|
198
|
+
let snapshots;
|
|
199
|
+
try {
|
|
200
|
+
snapshots = (await readdir(snapshotsDir)).sort();
|
|
201
|
+
} catch {
|
|
202
|
+
process.stderr.write("No snapshots found. Run `neuroverse world snapshot` first.\n");
|
|
203
|
+
process.exit(1);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (snapshots.length === 0) {
|
|
207
|
+
process.stderr.write("No snapshots found. Run `neuroverse world snapshot` first.\n");
|
|
208
|
+
process.exit(1);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const latest = snapshots[snapshots.length - 1];
|
|
212
|
+
const snapshotDir = join(snapshotsDir, latest);
|
|
213
|
+
const backupTimestamp = "pre-rollback-" + (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
214
|
+
const backupDir = join(snapshotsDir, backupTimestamp);
|
|
215
|
+
await mkdir(backupDir, { recursive: true });
|
|
216
|
+
const currentFiles = await readdir(worldPath);
|
|
217
|
+
for (const file of currentFiles) {
|
|
218
|
+
if (file.endsWith(".json")) {
|
|
219
|
+
const content = await readFile(join(worldPath, file), "utf-8");
|
|
220
|
+
await writeFile(join(backupDir, file), content, "utf-8");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const snapshotFiles = await readdir(snapshotDir);
|
|
224
|
+
let restored = 0;
|
|
225
|
+
for (const file of snapshotFiles) {
|
|
226
|
+
if (file.endsWith(".json")) {
|
|
227
|
+
const content = await readFile(join(snapshotDir, file), "utf-8");
|
|
228
|
+
await writeFile(join(worldPath, file), content, "utf-8");
|
|
229
|
+
restored++;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
const rulesDir = join(snapshotDir, "rules");
|
|
234
|
+
const ruleFiles = await readdir(rulesDir);
|
|
235
|
+
await mkdir(join(worldPath, "rules"), { recursive: true });
|
|
236
|
+
for (const file of ruleFiles) {
|
|
237
|
+
if (file.endsWith(".json")) {
|
|
238
|
+
const content = await readFile(join(rulesDir, file), "utf-8");
|
|
239
|
+
await writeFile(join(worldPath, "rules", file), content, "utf-8");
|
|
240
|
+
restored++;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
} catch {
|
|
244
|
+
}
|
|
245
|
+
process.stdout.write(`Rolled back to: ${latest}
|
|
246
|
+
`);
|
|
247
|
+
process.stdout.write(`Restored: ${restored} files
|
|
248
|
+
`);
|
|
249
|
+
process.stdout.write(`Backup saved: ${backupDir}
|
|
250
|
+
`);
|
|
251
|
+
}
|
|
252
|
+
async function main(argv = process.argv.slice(2)) {
|
|
253
|
+
const { subcommand, paths, flags } = parseArgs(argv);
|
|
254
|
+
if (flags.help || !subcommand) {
|
|
255
|
+
process.stdout.write(USAGE + "\n");
|
|
256
|
+
process.exit(0);
|
|
257
|
+
}
|
|
258
|
+
switch (subcommand) {
|
|
259
|
+
case "status": {
|
|
260
|
+
if (!paths[0]) {
|
|
261
|
+
process.stderr.write("Usage: neuroverse world status <path>\n");
|
|
262
|
+
process.exit(1);
|
|
263
|
+
}
|
|
264
|
+
return worldStatus(paths[0], !!flags.json);
|
|
265
|
+
}
|
|
266
|
+
case "diff": {
|
|
267
|
+
if (!paths[0] || !paths[1]) {
|
|
268
|
+
process.stderr.write("Usage: neuroverse world diff <path1> <path2>\n");
|
|
269
|
+
process.exit(1);
|
|
270
|
+
}
|
|
271
|
+
return worldDiff(paths[0], paths[1], !!flags.json);
|
|
272
|
+
}
|
|
273
|
+
case "snapshot": {
|
|
274
|
+
if (!paths[0]) {
|
|
275
|
+
process.stderr.write("Usage: neuroverse world snapshot <path>\n");
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
return worldSnapshot(paths[0]);
|
|
279
|
+
}
|
|
280
|
+
case "rollback": {
|
|
281
|
+
if (!paths[0]) {
|
|
282
|
+
process.stderr.write("Usage: neuroverse world rollback <path>\n");
|
|
283
|
+
process.exit(1);
|
|
284
|
+
}
|
|
285
|
+
return worldRollback(paths[0]);
|
|
286
|
+
}
|
|
287
|
+
default: {
|
|
288
|
+
process.stderr.write(`Unknown world subcommand: "${subcommand}"
|
|
289
|
+
|
|
290
|
+
`);
|
|
291
|
+
process.stdout.write(USAGE + "\n");
|
|
292
|
+
process.exit(1);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
export {
|
|
297
|
+
main
|
|
298
|
+
};
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
world_id: derivationworld
|
|
3
|
+
name: DerivationWorld
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
runtime_mode: synthesis
|
|
6
|
+
default_profile: strict_synthesis
|
|
7
|
+
alternative_profile: permissive_synthesis
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Thesis
|
|
11
|
+
|
|
12
|
+
AI-synthesized governance documents must be structurally valid, epistemically honest, and deterministically verifiable. A derived .nv-world.md is only legitimate if it satisfies the same parser constraints as a hand-authored world, distinguishes declared facts from inferred claims, and never introduces governance domains beyond the source material.
|
|
13
|
+
|
|
14
|
+
# Invariants
|
|
15
|
+
|
|
16
|
+
- `output_must_be_valid_nv_world` — Synthesized output must parse successfully under parseWorldMarkdown with zero errors (prompt, immutable)
|
|
17
|
+
- `must_include_required_sections` — Output must contain Thesis, Invariants, State, Rules, Gates, and Outcomes sections (prompt, immutable)
|
|
18
|
+
- `must_distinguish_declared_vs_inferred` — Invariants derived from explicit source statements must be marked structural; those inferred by the model must be marked operational (prompt, immutable)
|
|
19
|
+
- `must_not_invent_external_domains` — All state variables, rules, and invariants must trace to concepts present in the input markdown (prompt, immutable)
|
|
20
|
+
- `invariants_must_be_enforceable_or_marked` — Every invariant must be structurally enforceable via rules, or explicitly tagged as non-enforceable with rationale (prompt, immutable)
|
|
21
|
+
- `no_json_output` — Output must be .nv-world.md markdown only, never JSON (prompt, immutable)
|
|
22
|
+
- `no_extra_commentary` — Output must contain only the .nv-world.md document, no preamble, explanation, or trailing commentary (prompt, immutable)
|
|
23
|
+
- `frontmatter_must_be_complete` — Output frontmatter must include world_id, name, and version fields (prompt, immutable)
|
|
24
|
+
- `rules_must_have_triggers_and_effects` — Every rule must include a When trigger line and a Then effect line (prompt, immutable)
|
|
25
|
+
- `gate_thresholds_must_be_ordered` — Gate thresholds must be monotonically decreasing from best to worst status (prompt, immutable)
|
|
26
|
+
|
|
27
|
+
# State
|
|
28
|
+
|
|
29
|
+
## source_section_count
|
|
30
|
+
- type: number
|
|
31
|
+
- min: 0
|
|
32
|
+
- max: 100
|
|
33
|
+
- step: 1
|
|
34
|
+
- default: 5
|
|
35
|
+
- label: Source Section Count
|
|
36
|
+
- description: Number of distinct sections or files in the input markdown. More sections generally means richer synthesis material.
|
|
37
|
+
|
|
38
|
+
## source_token_estimate
|
|
39
|
+
- type: number
|
|
40
|
+
- min: 0
|
|
41
|
+
- max: 200000
|
|
42
|
+
- step: 100
|
|
43
|
+
- default: 2000
|
|
44
|
+
- label: Source Token Estimate
|
|
45
|
+
- description: Approximate token count of concatenated input. Determines whether context window constraints may truncate material.
|
|
46
|
+
|
|
47
|
+
## declared_concept_count
|
|
48
|
+
- type: number
|
|
49
|
+
- min: 0
|
|
50
|
+
- max: 200
|
|
51
|
+
- step: 1
|
|
52
|
+
- default: 10
|
|
53
|
+
- label: Declared Concept Count
|
|
54
|
+
- description: Number of distinct governance concepts explicitly named in source material. Drives state variable and rule generation.
|
|
55
|
+
|
|
56
|
+
## concept_specificity
|
|
57
|
+
- type: number
|
|
58
|
+
- min: 0
|
|
59
|
+
- max: 100
|
|
60
|
+
- default: 50
|
|
61
|
+
- label: Concept Specificity
|
|
62
|
+
- description: How precisely the source material defines its governance concepts. 0 = vague aspirations. 100 = precise structural claims with measurable criteria.
|
|
63
|
+
|
|
64
|
+
## domain_coherence
|
|
65
|
+
- type: number
|
|
66
|
+
- min: 0
|
|
67
|
+
- max: 100
|
|
68
|
+
- default: 60
|
|
69
|
+
- label: Domain Coherence
|
|
70
|
+
- description: How well source sections relate to a single governance domain. Low coherence indicates conflicting or unrelated source material.
|
|
71
|
+
|
|
72
|
+
## synthesis_fidelity
|
|
73
|
+
- type: number
|
|
74
|
+
- min: 0.00
|
|
75
|
+
- max: 1.00
|
|
76
|
+
- step: 0.01
|
|
77
|
+
- default: 0.70
|
|
78
|
+
- label: Synthesis Fidelity
|
|
79
|
+
- description: Measure of how faithfully the derived world represents the source material. Primary outcome metric.
|
|
80
|
+
|
|
81
|
+
## structural_completeness
|
|
82
|
+
- type: number
|
|
83
|
+
- min: 0
|
|
84
|
+
- max: 100
|
|
85
|
+
- default: 60
|
|
86
|
+
- label: Structural Completeness
|
|
87
|
+
- description: Percentage of required .nv-world.md sections that contain meaningful content rather than stubs.
|
|
88
|
+
|
|
89
|
+
## epistemic_honesty
|
|
90
|
+
- type: number
|
|
91
|
+
- min: 0
|
|
92
|
+
- max: 100
|
|
93
|
+
- default: 70
|
|
94
|
+
- label: Epistemic Honesty
|
|
95
|
+
- description: Degree to which the output correctly distinguishes source-declared constraints from model-inferred constraints. 0 = everything claimed as declared. 100 = perfect attribution.
|
|
96
|
+
|
|
97
|
+
## invention_ratio
|
|
98
|
+
- type: number
|
|
99
|
+
- min: 0.00
|
|
100
|
+
- max: 1.00
|
|
101
|
+
- step: 0.01
|
|
102
|
+
- default: 0.10
|
|
103
|
+
- label: Invention Ratio
|
|
104
|
+
- description: Fraction of output concepts that have no traceable origin in the source material. Should be near zero. Above 0.30 indicates hallucination.
|
|
105
|
+
|
|
106
|
+
# Assumptions
|
|
107
|
+
|
|
108
|
+
## strict_synthesis
|
|
109
|
+
- name: Strict Synthesis
|
|
110
|
+
- description: Conservative derivation that only produces governance elements with clear source basis. Prefers omission over invention. Marks all inferred elements as operational.
|
|
111
|
+
- invention_tolerance: minimal
|
|
112
|
+
- attribution_mode: strict
|
|
113
|
+
- completeness_priority: low
|
|
114
|
+
- fidelity_priority: high
|
|
115
|
+
|
|
116
|
+
## permissive_synthesis
|
|
117
|
+
- name: Permissive Synthesis
|
|
118
|
+
- description: Broader derivation that fills structural gaps with reasonable inferences. Produces more complete worlds but with higher invention ratio. All inferences are still marked operational.
|
|
119
|
+
- invention_tolerance: moderate
|
|
120
|
+
- attribution_mode: standard
|
|
121
|
+
- completeness_priority: high
|
|
122
|
+
- fidelity_priority: moderate
|
|
123
|
+
|
|
124
|
+
# Rules
|
|
125
|
+
|
|
126
|
+
## rule-001: Empty Source Rejection (structural)
|
|
127
|
+
Synthesis from empty or trivially short input cannot produce meaningful governance. The derivation must fail rather than fabricate.
|
|
128
|
+
|
|
129
|
+
When source_section_count < 1 [state]
|
|
130
|
+
Then synthesis_fidelity *= 0.00
|
|
131
|
+
Collapse: synthesis_fidelity < 0.05
|
|
132
|
+
|
|
133
|
+
> trigger: Source input contains no sections — nothing to derive from.
|
|
134
|
+
> rule: A world cannot be synthesized from nothing. Empty input must produce a clear failure, not a fabricated world.
|
|
135
|
+
> shift: Derivation halts. No output file is written.
|
|
136
|
+
> effect: Synthesis fidelity set to zero. Derivation rejected.
|
|
137
|
+
|
|
138
|
+
## rule-002: Sparse Source Warning (degradation)
|
|
139
|
+
Minimal source material limits the quality of derived governance. Output will be structurally thin.
|
|
140
|
+
|
|
141
|
+
When source_section_count < 3 [state] AND source_token_estimate < 500 [state]
|
|
142
|
+
Then synthesis_fidelity *= 0.50, structural_completeness *= 0.60
|
|
143
|
+
|
|
144
|
+
> trigger: Source has fewer than 3 sections and under 500 tokens — sparse material.
|
|
145
|
+
> rule: Sparse input yields sparse governance. The model cannot reliably infer structure from fragments.
|
|
146
|
+
> shift: Output quality degrades. State variables and rules will be minimal.
|
|
147
|
+
> effect: Synthesis fidelity reduced to 50%. Structural completeness reduced to 60%.
|
|
148
|
+
|
|
149
|
+
## rule-003: Concept Vagueness Penalty (degradation)
|
|
150
|
+
Source material with low concept specificity produces invariants and rules that are aspirational rather than structural.
|
|
151
|
+
|
|
152
|
+
When concept_specificity < 25 [state]
|
|
153
|
+
Then synthesis_fidelity *= 0.60, epistemic_honesty *= 0.70
|
|
154
|
+
|
|
155
|
+
> trigger: Source concept specificity below 25% — governance concepts are vague.
|
|
156
|
+
> rule: Vague concepts cannot produce structural invariants. The model must either invent specificity or produce unenforceable constraints.
|
|
157
|
+
> shift: Output invariants trend toward aspiration. Rules lack deterministic triggers.
|
|
158
|
+
> effect: Synthesis fidelity reduced to 60%. Epistemic honesty reduced to 70%.
|
|
159
|
+
|
|
160
|
+
## rule-004: Domain Incoherence Penalty (degradation)
|
|
161
|
+
Source material spanning unrelated domains produces a world with conflicting governance logic.
|
|
162
|
+
|
|
163
|
+
When domain_coherence < 30 [state]
|
|
164
|
+
Then synthesis_fidelity *= 0.55
|
|
165
|
+
|
|
166
|
+
> trigger: Domain coherence below 30% — source material is internally contradictory or covers unrelated domains.
|
|
167
|
+
> rule: A single .nv-world.md should govern a coherent domain. Mixed domains produce conflicting rules and meaningless invariants.
|
|
168
|
+
> shift: Output becomes structurally confused. State variables may not relate to each other.
|
|
169
|
+
> effect: Synthesis fidelity reduced to 55%.
|
|
170
|
+
|
|
171
|
+
## rule-005: Invention Threshold Breach (structural)
|
|
172
|
+
Excessive invention without source basis constitutes fabrication, not derivation.
|
|
173
|
+
|
|
174
|
+
When invention_ratio > 0.30 [state]
|
|
175
|
+
Then synthesis_fidelity *= 0.30, epistemic_honesty *= 0.40
|
|
176
|
+
Collapse: synthesis_fidelity < 0.05
|
|
177
|
+
|
|
178
|
+
> trigger: Invention ratio exceeds 30% — more than a third of output has no source basis.
|
|
179
|
+
> rule: Derivation must be grounded. A world that is mostly invented does not represent the user's governance intent.
|
|
180
|
+
> shift: Output crosses from synthesis to hallucination. Fidelity drops below usable threshold.
|
|
181
|
+
> effect: Synthesis fidelity reduced to 30%. Epistemic honesty reduced to 40%.
|
|
182
|
+
|
|
183
|
+
## rule-006: High Fidelity Source (advantage)
|
|
184
|
+
Rich, specific, coherent source material enables high-quality derivation.
|
|
185
|
+
|
|
186
|
+
When concept_specificity > 70 [state] AND domain_coherence > 70 [state] AND declared_concept_count > 8 [state]
|
|
187
|
+
Then synthesis_fidelity *= 1.20, structural_completeness *= 1.15
|
|
188
|
+
|
|
189
|
+
> trigger: High concept specificity, strong domain coherence, and rich concept count.
|
|
190
|
+
> rule: Quality source material produces quality governance. The model has enough structure to derive rather than invent.
|
|
191
|
+
> shift: Output is well-grounded. Most invariants and rules trace directly to source.
|
|
192
|
+
> effect: Synthesis fidelity boosted by 20%. Structural completeness boosted by 15%.
|
|
193
|
+
|
|
194
|
+
## rule-007: Structural Completeness Gate (degradation)
|
|
195
|
+
A derived world missing critical sections is not usable regardless of quality in present sections.
|
|
196
|
+
|
|
197
|
+
When structural_completeness < 40 [state]
|
|
198
|
+
Then synthesis_fidelity *= 0.50
|
|
199
|
+
|
|
200
|
+
> trigger: Structural completeness below 40% — too many required sections are empty or stub.
|
|
201
|
+
> rule: A partial world is not a valid world. Missing sections mean missing governance.
|
|
202
|
+
> shift: The output may parse but cannot function as meaningful governance.
|
|
203
|
+
> effect: Synthesis fidelity reduced to 50%.
|
|
204
|
+
|
|
205
|
+
## rule-008: Epistemic Honesty Reward (advantage)
|
|
206
|
+
Correct attribution of declared versus inferred constraints makes output trustworthy and auditable.
|
|
207
|
+
|
|
208
|
+
When epistemic_honesty > 80 [state]
|
|
209
|
+
Then synthesis_fidelity *= 1.10
|
|
210
|
+
|
|
211
|
+
> trigger: Epistemic honesty above 80% — model correctly attributes constraint origins.
|
|
212
|
+
> rule: Honest attribution makes governance auditable. Users can verify which constraints they declared versus which the model suggested.
|
|
213
|
+
> shift: Output gains trust. Declared constraints can be relied upon; inferred ones can be reviewed.
|
|
214
|
+
> effect: Synthesis fidelity boosted by 10%.
|
|
215
|
+
|
|
216
|
+
## rule-009: Context Window Overflow Risk (degradation)
|
|
217
|
+
Extremely large source material risks truncation and missed governance concepts.
|
|
218
|
+
|
|
219
|
+
When source_token_estimate > 100000 [state]
|
|
220
|
+
Then synthesis_fidelity *= 0.75
|
|
221
|
+
|
|
222
|
+
> trigger: Source material exceeds 100k tokens — likely to be truncated.
|
|
223
|
+
> rule: Truncated input means incomplete synthesis. The model may miss governance concepts that appear late in the concatenation.
|
|
224
|
+
> shift: Output may be partial. Critical sections from later source files may be absent.
|
|
225
|
+
> effect: Synthesis fidelity reduced to 75% due to truncation risk.
|
|
226
|
+
|
|
227
|
+
## rule-010: Derivation Coherence Reward (advantage)
|
|
228
|
+
Aligned quality metrics across fidelity, honesty, and invention produce a genuine governance document.
|
|
229
|
+
|
|
230
|
+
When synthesis_fidelity > 0.80 [state] AND epistemic_honesty > 75 [state] AND invention_ratio < 0.15 [state]
|
|
231
|
+
Then synthesis_fidelity *= 1.15
|
|
232
|
+
Collapse: synthesis_fidelity < 0.05
|
|
233
|
+
|
|
234
|
+
> trigger: Synthesis fidelity above 80%, epistemic honesty above 75%, and invention ratio below 15%.
|
|
235
|
+
> rule: Coherent derivation across all metrics indicates a faithful, usable governance document.
|
|
236
|
+
> shift: The derived world moves from draft to production-quality. Suitable for bootstrap and validation.
|
|
237
|
+
> effect: Synthesis fidelity boosted by 15%. Derivation coherence achieved.
|
|
238
|
+
|
|
239
|
+
# Gates
|
|
240
|
+
|
|
241
|
+
- FAITHFUL: synthesis_fidelity >= 0.85
|
|
242
|
+
- USABLE: synthesis_fidelity >= 0.60
|
|
243
|
+
- REVIEWABLE: synthesis_fidelity >= 0.40
|
|
244
|
+
- SUSPECT: synthesis_fidelity > 0.15
|
|
245
|
+
- DERIVATION_REJECTED: synthesis_fidelity <= 0.15
|
|
246
|
+
|
|
247
|
+
# Outcomes
|
|
248
|
+
|
|
249
|
+
## synthesis_fidelity
|
|
250
|
+
- type: number
|
|
251
|
+
- range: 0-1
|
|
252
|
+
- display: percentage
|
|
253
|
+
- label: Synthesis Fidelity
|
|
254
|
+
- primary: true
|
|
255
|
+
|
|
256
|
+
## structural_completeness
|
|
257
|
+
- type: number
|
|
258
|
+
- range: 0-100
|
|
259
|
+
- display: percentage
|
|
260
|
+
- label: Structural Completeness
|
|
261
|
+
|
|
262
|
+
## epistemic_honesty
|
|
263
|
+
- type: number
|
|
264
|
+
- range: 0-100
|
|
265
|
+
- display: percentage
|
|
266
|
+
- label: Epistemic Honesty
|
|
267
|
+
|
|
268
|
+
## invention_ratio
|
|
269
|
+
- type: number
|
|
270
|
+
- range: 0-1
|
|
271
|
+
- display: percentage
|
|
272
|
+
- label: Invention Ratio
|
|
273
|
+
- assignment: external
|
|
274
|
+
|
|
275
|
+
## derivation_status
|
|
276
|
+
- type: enum
|
|
277
|
+
- label: Derivation Status
|
|
278
|
+
- assignment: external
|
package/package.json
CHANGED
|
@@ -1,36 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuroverseos/governance",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Deterministic
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"main": "dist/index.
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Deterministic governance engine for AI agents — evaluate events against world definitions with full audit trace",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"./adapters": {
|
|
17
|
+
"types": "./dist/adapters/index.d.ts",
|
|
18
|
+
"import": "./dist/adapters/index.js",
|
|
19
|
+
"require": "./dist/adapters/index.cjs"
|
|
20
|
+
},
|
|
21
|
+
"./adapters/langchain": {
|
|
22
|
+
"types": "./dist/adapters/langchain.d.ts",
|
|
23
|
+
"import": "./dist/adapters/langchain.js",
|
|
24
|
+
"require": "./dist/adapters/langchain.cjs"
|
|
25
|
+
},
|
|
26
|
+
"./adapters/openai": {
|
|
27
|
+
"types": "./dist/adapters/openai.d.ts",
|
|
28
|
+
"import": "./dist/adapters/openai.js",
|
|
29
|
+
"require": "./dist/adapters/openai.cjs"
|
|
30
|
+
},
|
|
31
|
+
"./adapters/openclaw": {
|
|
32
|
+
"types": "./dist/adapters/openclaw.d.ts",
|
|
33
|
+
"import": "./dist/adapters/openclaw.js",
|
|
34
|
+
"require": "./dist/adapters/openclaw.cjs"
|
|
35
|
+
},
|
|
36
|
+
"./adapters/express": {
|
|
37
|
+
"types": "./dist/adapters/express.d.ts",
|
|
38
|
+
"import": "./dist/adapters/express.js",
|
|
39
|
+
"require": "./dist/adapters/express.cjs"
|
|
40
|
+
}
|
|
11
41
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"prepublishOnly": "npm run build"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"typescript": "^5.0.0"
|
|
18
|
-
},
|
|
19
|
-
"peerDependencies": {
|
|
20
|
-
"openclaw": "*"
|
|
42
|
+
"bin": {
|
|
43
|
+
"neuroverse": "dist/cli/neuroverse.js"
|
|
21
44
|
},
|
|
22
45
|
"files": [
|
|
23
46
|
"dist",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
47
|
+
"dist/worlds",
|
|
48
|
+
"LICENSE.md",
|
|
49
|
+
"README.md"
|
|
27
50
|
],
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup src/index.ts src/cli/neuroverse.ts src/adapters/index.ts src/adapters/langchain.ts src/adapters/openai.ts src/adapters/openclaw.ts src/adapters/express.ts --format esm,cjs --dts --clean && cp src/worlds/derivation-world.nv-world.md dist/worlds/derivation-world.nv-world.md",
|
|
53
|
+
"prebuild": "mkdir -p dist/worlds",
|
|
54
|
+
"dev": "tsup src/index.ts src/cli/neuroverse.ts --format esm,cjs --dts --watch",
|
|
55
|
+
"test": "vitest run",
|
|
56
|
+
"test:watch": "vitest"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/node": "^25.3.3",
|
|
60
|
+
"tsup": "^8.0.0",
|
|
61
|
+
"typescript": "^5.3.0",
|
|
62
|
+
"vitest": "^2.0.0"
|
|
63
|
+
},
|
|
28
64
|
"keywords": [
|
|
29
|
-
"
|
|
65
|
+
"neuroverse",
|
|
30
66
|
"governance",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
67
|
+
"guard",
|
|
68
|
+
"deterministic",
|
|
69
|
+
"rule-engine",
|
|
70
|
+
"ai-governance",
|
|
71
|
+
"ai-agents",
|
|
72
|
+
"compliance",
|
|
73
|
+
"audit",
|
|
74
|
+
"world-engine"
|
|
75
|
+
],
|
|
76
|
+
"repository": {
|
|
77
|
+
"type": "git",
|
|
78
|
+
"url": "git+https://github.com/neuroverseos/neuroverseos-governance.git"
|
|
79
|
+
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=18"
|
|
82
|
+
},
|
|
83
|
+
"homepage": "https://neuroverseos.com"
|
|
36
84
|
}
|