@neuroverseos/governance 0.5.1 → 0.6.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.
Files changed (69) hide show
  1. package/README.md +55 -0
  2. package/dist/adapters/autoresearch.js +2 -2
  3. package/dist/adapters/deep-agents.js +2 -2
  4. package/dist/adapters/express.js +2 -2
  5. package/dist/adapters/github.js +2 -2
  6. package/dist/adapters/index.js +8 -8
  7. package/dist/adapters/langchain.js +2 -2
  8. package/dist/adapters/mentraos.js +2 -2
  9. package/dist/adapters/openai.js +2 -2
  10. package/dist/adapters/openclaw.js +2 -2
  11. package/dist/{add-JP7TC2K3.js → add-XSANI3FK.js} +1 -1
  12. package/dist/{build-THUEYMVT.js → build-UTVDGHB3.js} +4 -4
  13. package/dist/{chunk-TZBERHFM.js → chunk-7FL3U7Z5.js} +1 -1
  14. package/dist/{chunk-FGOSKQDE.js → chunk-A2UZTLRV.js} +1 -1
  15. package/dist/{chunk-R23T5SZG.js → chunk-B3IIPTY3.js} +1 -1
  16. package/dist/chunk-EQR7BGFN.js +337 -0
  17. package/dist/{chunk-LAKUB76X.js → chunk-FDPPZLSQ.js} +1 -1
  18. package/dist/{chunk-UZBW44KD.js → chunk-FKQCPRKI.js} +1 -1
  19. package/dist/{chunk-XPMZB46F.js → chunk-FS2UUJJO.js} +3 -3
  20. package/dist/{chunk-6UPEUMJ2.js → chunk-HDNDL6D5.js} +1 -1
  21. package/dist/{chunk-7UU7V3AD.js → chunk-IOVXB6QN.js} +1 -1
  22. package/dist/{chunk-EK77AJAH.js → chunk-OTZU76DH.js} +1 -1
  23. package/dist/{chunk-5RAQ5DZW.js → chunk-T6GMRZWC.js} +1 -1
  24. package/dist/{chunk-RF2L5SYG.js → chunk-TIXVEPS2.js} +1 -1
  25. package/dist/{chunk-TL4DLMMW.js → chunk-TJ5L2UTE.js} +1 -1
  26. package/dist/chunk-UGTNKTHS.js +542 -0
  27. package/dist/cli/neuroverse.cjs +1987 -303
  28. package/dist/cli/neuroverse.js +27 -19
  29. package/dist/cli/plan.js +1 -1
  30. package/dist/cli/run.js +2 -2
  31. package/dist/cli/worldmodel.cjs +1624 -0
  32. package/dist/cli/worldmodel.d.cts +24 -0
  33. package/dist/cli/worldmodel.d.ts +24 -0
  34. package/dist/cli/worldmodel.js +742 -0
  35. package/dist/{demo-N5K4VXJW.js → demo-6W3YXLAX.js} +2 -2
  36. package/dist/{derive-5LOMN7GO.js → derive-42IJW7JI.js} +3 -3
  37. package/dist/engine/worldmodel-compiler.cjs +366 -0
  38. package/dist/engine/worldmodel-compiler.d.cts +46 -0
  39. package/dist/engine/worldmodel-compiler.d.ts +46 -0
  40. package/dist/engine/worldmodel-compiler.js +17 -0
  41. package/dist/engine/worldmodel-parser.cjs +566 -0
  42. package/dist/engine/worldmodel-parser.d.cts +22 -0
  43. package/dist/engine/worldmodel-parser.d.ts +22 -0
  44. package/dist/engine/worldmodel-parser.js +7 -0
  45. package/dist/{equity-penalties-PYCJ3Q4U.js → equity-penalties-CCO3GVHS.js} +1 -1
  46. package/dist/{explain-42TVC3QD.js → explain-HDFN4ION.js} +1 -1
  47. package/dist/{guard-TPYDFG6V.js → guard-IHJEKHL2.js} +1 -1
  48. package/dist/{improve-HLZGJ54Z.js → improve-LRORRYEX.js} +1 -1
  49. package/dist/index.js +48 -48
  50. package/dist/{lens-NFGZHD76.js → lens-TLDZQXBI.js} +61 -2
  51. package/dist/{mcp-server-5XXNG6VC.js → mcp-server-CKYBHXWK.js} +2 -2
  52. package/dist/{playground-2EU5CFIH.js → playground-3TTBN7XD.js} +1 -1
  53. package/dist/{redteam-VK6OVHAE.js → redteam-W644UMWN.js} +1 -1
  54. package/dist/{session-NGA4DUPL.js → session-FMAROEIE.js} +2 -2
  55. package/dist/{simulate-4YNOBMES.js → simulate-VT437EEL.js} +1 -1
  56. package/dist/{test-HDBPMQTG.js → test-XDB2DH3L.js} +1 -1
  57. package/dist/{validate-6MFQZ2EG.js → validate-M52DX22Y.js} +1 -1
  58. package/dist/{world-H5WVURKU.js → world-O4HTQPDP.js} +1 -1
  59. package/dist/{world-loader-J47PCPDZ.js → world-loader-YTYFOP7D.js} +1 -1
  60. package/dist/worldmodel-contract-BPGhiuW5.d.cts +221 -0
  61. package/dist/worldmodel-contract-BPGhiuW5.d.ts +221 -0
  62. package/dist/worlds/auki-vanguard.worldmodel.md +116 -0
  63. package/dist/worlds/behavioral-demo.nv-world.md +130 -0
  64. package/dist/worlds/neuroverse-governance.worldmodel.md +115 -0
  65. package/package.json +2 -2
  66. package/dist/{bootstrap-IP5QMC3Q.js → bootstrap-2OW5ZLBL.js} +3 -3
  67. package/dist/{chunk-QZ666FCV.js → chunk-735Z3HA4.js} +3 -3
  68. /package/dist/{chunk-EQUAWNXW.js → chunk-I4RTIMLX.js} +0 -0
  69. /package/dist/{doctor-Q5APJOTS.js → doctor-XEMLO6UA.js} +0 -0
package/README.md CHANGED
@@ -388,6 +388,61 @@ const overlay = compileLensOverlay([lens]); // System prompt string
388
388
  | `role_default` | Starts as role default. User can override. |
389
389
  | `user_choice` | No default. User picks freely. |
390
390
 
391
+ ### Behavioral Lenses
392
+
393
+ Lenses are not limited to tone and style. A **behavioral lens** interprets actions, flags patterns, and shapes how the system reads situations — not just how it speaks.
394
+
395
+ The built-in `behavioral-interpreter` lens is the first behavioral governance overlay:
396
+
397
+ ```typescript
398
+ import { BEHAVIORAL_INTERPRETER_LENS, compileLensOverlay } from '@neuroverseos/governance';
399
+
400
+ const overlay = compileLensOverlay([BEHAVIORAL_INTERPRETER_LENS]);
401
+ // → Directives that prioritize observed behavior over stated intent,
402
+ // flag ambiguity and ownership diffusion, and distinguish
403
+ // observed facts from inference and speculation.
404
+ ```
405
+
406
+ Behavioral lenses can also be declared in world files:
407
+
408
+ ```markdown
409
+ # Lenses
410
+ - policy: role_default
411
+
412
+ ## behavioral-interpreter
413
+ - tagline: Read patterns, not promises.
414
+ - formality: neutral
415
+ - verbosity: concise
416
+ - emotion: neutral
417
+ - confidence: balanced
418
+ - tags: behavior, signals, alignment, analysis
419
+ - default_for_roles: all
420
+ - priority: 65
421
+
422
+ > response_framing: Prioritize observed behavior over stated intent.
423
+ > behavior_shaping: Detect repeated ambiguity, delay, or ownership diffusion.
424
+ > value_emphasis: Name alignment or misalignment between words and actions.
425
+ > content_filtering: Distinguish observed behavior from inference and speculation.
426
+ ```
427
+
428
+ To extract and compile a behavioral lens from a world file:
429
+
430
+ ```typescript
431
+ import { loadBundledWorld } from '@neuroverseos/governance/loader/world-loader';
432
+ import { lensesFromWorld, compileLensOverlay } from '@neuroverseos/governance';
433
+
434
+ const world = await loadBundledWorld('behavioral-demo');
435
+ const lenses = lensesFromWorld(world);
436
+ const overlay = compileLensOverlay(lenses);
437
+ console.log(overlay.systemPromptAddition);
438
+ ```
439
+
440
+ Run the end-to-end demo:
441
+
442
+ ```bash
443
+ npx tsx examples/behavioral-lens-demo/demo.ts
444
+ ```
445
+
391
446
  ---
392
447
 
393
448
  ## Worlds: The Universal Container
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  AutoresearchGovernor,
3
3
  createAutoresearchGovernor
4
- } from "../chunk-TL4DLMMW.js";
5
- import "../chunk-EQUAWNXW.js";
4
+ } from "../chunk-TJ5L2UTE.js";
5
+ import "../chunk-I4RTIMLX.js";
6
6
  import "../chunk-ZAF6JH23.js";
7
7
  import "../chunk-QLPTHTVB.js";
8
8
  import "../chunk-QWGCMQQD.js";
@@ -3,9 +3,9 @@ import {
3
3
  GovernanceBlockedError,
4
4
  createDeepAgentsGuard,
5
5
  createDeepAgentsGuardFromWorld
6
- } from "../chunk-5RAQ5DZW.js";
6
+ } from "../chunk-T6GMRZWC.js";
7
7
  import "../chunk-5U2MQO5P.js";
8
- import "../chunk-EQUAWNXW.js";
8
+ import "../chunk-I4RTIMLX.js";
9
9
  import "../chunk-ZAF6JH23.js";
10
10
  import "../chunk-QLPTHTVB.js";
11
11
  import "../chunk-QWGCMQQD.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createGovernanceMiddleware,
3
3
  createGovernanceMiddlewareFromWorld
4
- } from "../chunk-6UPEUMJ2.js";
5
- import "../chunk-EQUAWNXW.js";
4
+ } from "../chunk-HDNDL6D5.js";
5
+ import "../chunk-I4RTIMLX.js";
6
6
  import "../chunk-ZAF6JH23.js";
7
7
  import "../chunk-QLPTHTVB.js";
8
8
  import "../chunk-QWGCMQQD.js";
@@ -8,9 +8,9 @@ import {
8
8
  createGitHubWebhookHandlerFromWorld,
9
9
  formatForActions,
10
10
  formatPRComment
11
- } from "../chunk-FGOSKQDE.js";
11
+ } from "../chunk-A2UZTLRV.js";
12
12
  import "../chunk-5U2MQO5P.js";
13
- import "../chunk-EQUAWNXW.js";
13
+ import "../chunk-I4RTIMLX.js";
14
14
  import "../chunk-ZAF6JH23.js";
15
15
  import "../chunk-QLPTHTVB.js";
16
16
  import "../chunk-QWGCMQQD.js";
@@ -4,19 +4,19 @@ import {
4
4
  createMentraGovernedExecutor,
5
5
  createMentraGovernedExecutorFromWorld,
6
6
  evaluateUserRules
7
- } from "../chunk-7UU7V3AD.js";
7
+ } from "../chunk-IOVXB6QN.js";
8
8
  import {
9
9
  GovernanceBlockedError as GovernanceBlockedError4,
10
10
  GovernedToolExecutor,
11
11
  createGovernedToolExecutor,
12
12
  createGovernedToolExecutorFromWorld
13
- } from "../chunk-R23T5SZG.js";
13
+ } from "../chunk-B3IIPTY3.js";
14
14
  import {
15
15
  GovernanceBlockedError as GovernanceBlockedError5,
16
16
  NeuroVersePlugin,
17
17
  createNeuroVersePlugin,
18
18
  createNeuroVersePluginFromWorld
19
- } from "../chunk-RF2L5SYG.js";
19
+ } from "../chunk-TIXVEPS2.js";
20
20
  import {
21
21
  MENTRA_INTENT_TAXONOMY,
22
22
  MENTRA_KNOWN_INTENTS,
@@ -33,23 +33,23 @@ import {
33
33
  } from "../chunk-GJ6LM4JZ.js";
34
34
  import {
35
35
  AutoresearchGovernor
36
- } from "../chunk-TL4DLMMW.js";
36
+ } from "../chunk-TJ5L2UTE.js";
37
37
  import {
38
38
  DeepAgentsGuard,
39
39
  GovernanceBlockedError as GovernanceBlockedError2,
40
40
  createDeepAgentsGuard,
41
41
  createDeepAgentsGuardFromWorld
42
- } from "../chunk-5RAQ5DZW.js";
42
+ } from "../chunk-T6GMRZWC.js";
43
43
  import {
44
44
  createGovernanceMiddleware,
45
45
  createGovernanceMiddlewareFromWorld
46
- } from "../chunk-6UPEUMJ2.js";
46
+ } from "../chunk-HDNDL6D5.js";
47
47
  import {
48
48
  GovernanceBlockedError as GovernanceBlockedError3,
49
49
  NeuroVerseCallbackHandler,
50
50
  createNeuroVerseCallbackHandler,
51
51
  createNeuroVerseCallbackHandlerFromWorld
52
- } from "../chunk-UZBW44KD.js";
52
+ } from "../chunk-FKQCPRKI.js";
53
53
  import {
54
54
  GovernanceBlockedError,
55
55
  buildEngineOptions,
@@ -57,7 +57,7 @@ import {
57
57
  extractScope,
58
58
  trackPlanProgress
59
59
  } from "../chunk-5U2MQO5P.js";
60
- import "../chunk-EQUAWNXW.js";
60
+ import "../chunk-I4RTIMLX.js";
61
61
  import "../chunk-ZAF6JH23.js";
62
62
  import "../chunk-QLPTHTVB.js";
63
63
  import "../chunk-QWGCMQQD.js";
@@ -3,9 +3,9 @@ import {
3
3
  NeuroVerseCallbackHandler,
4
4
  createNeuroVerseCallbackHandler,
5
5
  createNeuroVerseCallbackHandlerFromWorld
6
- } from "../chunk-UZBW44KD.js";
6
+ } from "../chunk-FKQCPRKI.js";
7
7
  import "../chunk-5U2MQO5P.js";
8
- import "../chunk-EQUAWNXW.js";
8
+ import "../chunk-I4RTIMLX.js";
9
9
  import "../chunk-ZAF6JH23.js";
10
10
  import "../chunk-QLPTHTVB.js";
11
11
  import "../chunk-QWGCMQQD.js";
@@ -4,7 +4,7 @@ import {
4
4
  createMentraGovernedExecutor,
5
5
  createMentraGovernedExecutorFromWorld,
6
6
  evaluateUserRules
7
- } from "../chunk-7UU7V3AD.js";
7
+ } from "../chunk-IOVXB6QN.js";
8
8
  import {
9
9
  MENTRA_INTENT_MAP,
10
10
  MENTRA_INTENT_TAXONOMY,
@@ -23,7 +23,7 @@ import {
23
23
  import {
24
24
  GovernanceBlockedError
25
25
  } from "../chunk-5U2MQO5P.js";
26
- import "../chunk-EQUAWNXW.js";
26
+ import "../chunk-I4RTIMLX.js";
27
27
  import "../chunk-ZAF6JH23.js";
28
28
  import "../chunk-QLPTHTVB.js";
29
29
  import "../chunk-QWGCMQQD.js";
@@ -3,9 +3,9 @@ import {
3
3
  GovernedToolExecutor,
4
4
  createGovernedToolExecutor,
5
5
  createGovernedToolExecutorFromWorld
6
- } from "../chunk-R23T5SZG.js";
6
+ } from "../chunk-B3IIPTY3.js";
7
7
  import "../chunk-5U2MQO5P.js";
8
- import "../chunk-EQUAWNXW.js";
8
+ import "../chunk-I4RTIMLX.js";
9
9
  import "../chunk-ZAF6JH23.js";
10
10
  import "../chunk-QLPTHTVB.js";
11
11
  import "../chunk-QWGCMQQD.js";
@@ -3,9 +3,9 @@ import {
3
3
  NeuroVersePlugin,
4
4
  createNeuroVersePlugin,
5
5
  createNeuroVersePluginFromWorld
6
- } from "../chunk-RF2L5SYG.js";
6
+ } from "../chunk-TIXVEPS2.js";
7
7
  import "../chunk-5U2MQO5P.js";
8
- import "../chunk-EQUAWNXW.js";
8
+ import "../chunk-I4RTIMLX.js";
9
9
  import "../chunk-ZAF6JH23.js";
10
10
  import "../chunk-QLPTHTVB.js";
11
11
  import "../chunk-QWGCMQQD.js";
@@ -4,7 +4,7 @@ import {
4
4
  addRule,
5
5
  classifyIntent,
6
6
  parseGuardDescription
7
- } from "./chunk-XPMZB46F.js";
7
+ } from "./chunk-FS2UUJJO.js";
8
8
  import "./chunk-7P3S7MAY.js";
9
9
  import {
10
10
  describeActiveWorld,
@@ -2,19 +2,19 @@ import {
2
2
  DeriveInputError,
3
3
  DeriveProviderError,
4
4
  deriveWorld
5
- } from "./chunk-QZ666FCV.js";
5
+ } from "./chunk-735Z3HA4.js";
6
6
  import {
7
7
  DERIVE_EXIT_CODES
8
8
  } from "./chunk-FMSTRBBS.js";
9
9
  import "./chunk-OT6PXH54.js";
10
10
  import "./chunk-INWQHLPS.js";
11
11
  import "./chunk-7P3S7MAY.js";
12
- import {
13
- parseWorldMarkdown
14
- } from "./chunk-3NZMMSOW.js";
15
12
  import {
16
13
  emitWorldDefinition
17
14
  } from "./chunk-YPCVY4GS.js";
15
+ import {
16
+ parseWorldMarkdown
17
+ } from "./chunk-3NZMMSOW.js";
18
18
  import "./chunk-QWGCMQQD.js";
19
19
 
20
20
  // src/cli/build.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  loadWorld
3
- } from "./chunk-EQUAWNXW.js";
3
+ } from "./chunk-I4RTIMLX.js";
4
4
  import {
5
5
  evaluateGuard
6
6
  } from "./chunk-ZAF6JH23.js";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-5U2MQO5P.js";
6
6
  import {
7
7
  loadWorld
8
- } from "./chunk-EQUAWNXW.js";
8
+ } from "./chunk-I4RTIMLX.js";
9
9
  import {
10
10
  evaluateGuard
11
11
  } from "./chunk-ZAF6JH23.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-5U2MQO5P.js";
8
8
  import {
9
9
  loadWorld
10
- } from "./chunk-EQUAWNXW.js";
10
+ } from "./chunk-I4RTIMLX.js";
11
11
  import {
12
12
  evaluateGuard
13
13
  } from "./chunk-ZAF6JH23.js";
@@ -0,0 +1,337 @@
1
+ // src/engine/worldmodel-compiler.ts
2
+ function toSnakeCase(text) {
3
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
4
+ }
5
+ function toKebabCase(text) {
6
+ return text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
7
+ }
8
+ function titleCase(text) {
9
+ return text.split(/[\s_-]+/).map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase()).join(" ");
10
+ }
11
+ function matchSignal(behaviorText, signals) {
12
+ const lowerText = behaviorText.toLowerCase();
13
+ for (const signal of signals) {
14
+ const signalWords = signal.toLowerCase().split("_");
15
+ if (signalWords.some((w) => w.length > 3 && lowerText.includes(w))) {
16
+ return signal;
17
+ }
18
+ }
19
+ return "alignment_score";
20
+ }
21
+ function emitWorldMarkdown(model) {
22
+ const lines = [];
23
+ const worldId = model.frontmatter.model_id;
24
+ const worldName = model.frontmatter.name;
25
+ const version = model.frontmatter.version;
26
+ lines.push("---");
27
+ lines.push(`world_id: ${worldId}`);
28
+ lines.push(`name: ${worldName}`);
29
+ lines.push(`version: ${version}`);
30
+ lines.push("runtime_mode: COMPLIANCE");
31
+ lines.push("default_profile: aligned");
32
+ lines.push("alternative_profile: drifting");
33
+ lines.push("---");
34
+ lines.push("");
35
+ lines.push("# Thesis");
36
+ lines.push("");
37
+ lines.push(model.geometry.mission);
38
+ if (model.geometry.centerIdentity) {
39
+ lines.push(
40
+ `When all domains are aligned, the system operates as: ${model.geometry.centerIdentity}.`
41
+ );
42
+ }
43
+ lines.push("");
44
+ lines.push("# Invariants");
45
+ lines.push("");
46
+ let invariantIdx = 0;
47
+ for (const domain of model.geometry.domains) {
48
+ for (const value of domain.values) {
49
+ invariantIdx++;
50
+ const invId = `${toSnakeCase(domain.name)}_value_${String(invariantIdx).padStart(2, "0")}`;
51
+ lines.push(
52
+ `- \`${invId}\` \u2014 ${value} [${domain.name}] (structural, immutable)`
53
+ );
54
+ }
55
+ }
56
+ lines.push("");
57
+ lines.push("# State");
58
+ lines.push("");
59
+ lines.push("## alignment_score");
60
+ lines.push("- type: number");
61
+ lines.push("- min: 0");
62
+ lines.push("- max: 100");
63
+ lines.push("- step: 5");
64
+ lines.push("- default: 70");
65
+ lines.push("- label: Alignment Score");
66
+ lines.push(
67
+ "- description: Composite behavioral alignment metric derived from all signals"
68
+ );
69
+ lines.push("");
70
+ for (const signal of model.evolution.signals) {
71
+ const signalId = toSnakeCase(signal);
72
+ const signalLabel = titleCase(signal);
73
+ lines.push(`## ${signalId}`);
74
+ lines.push("- type: number");
75
+ lines.push("- min: 0");
76
+ lines.push("- max: 100");
77
+ lines.push("- step: 5");
78
+ lines.push("- default: 70");
79
+ lines.push(`- label: ${signalLabel}`);
80
+ lines.push(`- description: Behavioral signal measuring ${signal.replace(/_/g, " ")}`);
81
+ lines.push("");
82
+ }
83
+ lines.push("# Assumptions");
84
+ lines.push("");
85
+ lines.push("## aligned");
86
+ lines.push("- name: Aligned");
87
+ lines.push("- description: All behavioral signals at healthy levels");
88
+ lines.push("- pressure_level: low");
89
+ lines.push("");
90
+ lines.push("## drifting");
91
+ lines.push("- name: Drifting");
92
+ lines.push("- description: Behavioral signals under pressure with drift risk");
93
+ lines.push("- pressure_level: high");
94
+ lines.push("");
95
+ lines.push("# Rules");
96
+ lines.push("");
97
+ let ruleIdx = 0;
98
+ for (const drift of model.evolution.driftBehaviors) {
99
+ ruleIdx++;
100
+ const ruleId = `rule-${String(ruleIdx).padStart(3, "0")}`;
101
+ const matchedSignal = matchSignal(drift, model.evolution.signals);
102
+ const signalId = toSnakeCase(matchedSignal);
103
+ lines.push(`## ${ruleId}: ${drift} (degradation)`);
104
+ lines.push(`Drift behavior detected: ${drift}`);
105
+ lines.push("");
106
+ lines.push(`When ${signalId} < 50 [state]`);
107
+ lines.push("Then alignment_score *= 0.80");
108
+ lines.push("");
109
+ lines.push(`> trigger: ${signalId} drops below threshold`);
110
+ lines.push(`> rule: Drift behavior weakens alignment`);
111
+ lines.push(`> shift: Behavioral alignment decreases`);
112
+ lines.push(`> effect: Alignment score reduced by 20%`);
113
+ lines.push("");
114
+ }
115
+ for (const aligned of model.evolution.alignedBehaviors) {
116
+ ruleIdx++;
117
+ const ruleId = `rule-${String(ruleIdx).padStart(3, "0")}`;
118
+ const matchedSignal = matchSignal(aligned, model.evolution.signals);
119
+ const signalId = toSnakeCase(matchedSignal);
120
+ lines.push(`## ${ruleId}: ${aligned} (advantage)`);
121
+ lines.push(`Aligned behavior reinforced: ${aligned}`);
122
+ lines.push("");
123
+ lines.push(`When ${signalId} >= 70 [state]`);
124
+ lines.push("Then alignment_score *= 1.10");
125
+ lines.push("");
126
+ lines.push(`> trigger: ${signalId} above healthy threshold`);
127
+ lines.push(`> rule: Aligned behavior strengthens system`);
128
+ lines.push(`> shift: Behavioral alignment increases`);
129
+ lines.push(`> effect: Alignment score boosted by 10%`);
130
+ lines.push("");
131
+ }
132
+ for (let i = 0; i < model.evolution.decisionPriorities.length; i++) {
133
+ ruleIdx++;
134
+ const priority = model.evolution.decisionPriorities[i];
135
+ const ruleId = `rule-${String(ruleIdx).padStart(3, "0")}`;
136
+ lines.push(
137
+ `## ${ruleId}: ${priority.preferred} over ${priority.over} (structural)`
138
+ );
139
+ lines.push(
140
+ `Priority: ${priority.preferred} takes precedence over ${priority.over} in tradeoff situations.`
141
+ );
142
+ lines.push("");
143
+ lines.push("When alignment_score < 40 [state]");
144
+ lines.push("Then alignment_score *= 0.70");
145
+ lines.push("Collapse: alignment_score < 10");
146
+ lines.push("");
147
+ lines.push(`> trigger: Alignment score critically low`);
148
+ lines.push(
149
+ `> rule: Priority violation \u2014 ${priority.preferred} must outweigh ${priority.over}`
150
+ );
151
+ lines.push(`> shift: System enters structural enforcement`);
152
+ lines.push(`> effect: Alignment sharply reduced; collapse if critical`);
153
+ lines.push("");
154
+ }
155
+ lines.push("# Gates");
156
+ lines.push("");
157
+ lines.push("- STRONG: alignment_score >= 85");
158
+ lines.push("- STABLE: alignment_score >= 65");
159
+ lines.push("- WATCHING: alignment_score >= 45");
160
+ lines.push("- FRAGILE: alignment_score > 30");
161
+ lines.push("- MISALIGNED: alignment_score <= 30");
162
+ lines.push("");
163
+ lines.push("# Outcomes");
164
+ lines.push("");
165
+ lines.push("## alignment_score");
166
+ lines.push("- type: number");
167
+ lines.push("- range: 0-100");
168
+ lines.push("- display: percentage");
169
+ lines.push("- label: Alignment Score");
170
+ lines.push("- primary: true");
171
+ lines.push("");
172
+ for (const signal of model.evolution.signals) {
173
+ const signalId = toSnakeCase(signal);
174
+ const signalLabel = titleCase(signal);
175
+ lines.push(`## ${signalId}`);
176
+ lines.push("- type: number");
177
+ lines.push("- range: 0-100");
178
+ lines.push("- display: percentage");
179
+ lines.push(`- label: ${signalLabel}`);
180
+ lines.push("");
181
+ }
182
+ const lensSuggestions = buildLensSuggestions(model);
183
+ if (lensSuggestions.length > 0) {
184
+ lines.push("# Lenses");
185
+ lines.push("- policy: role_default");
186
+ lines.push("");
187
+ for (const lens of lensSuggestions) {
188
+ lines.push(`## ${lens.id}`);
189
+ lines.push(`- tagline: ${lens.tagline}`);
190
+ lines.push(
191
+ `- description: Lens derived from ${lens.derived_from.domainA} and ${lens.derived_from.domainB} interaction, producing ${lens.derived_from.effect}.`
192
+ );
193
+ lines.push(`- formality: ${lens.tone.formality}`);
194
+ lines.push(`- verbosity: ${lens.tone.verbosity}`);
195
+ lines.push(`- emotion: ${lens.tone.emotion}`);
196
+ lines.push(`- confidence: ${lens.tone.confidence}`);
197
+ lines.push("- tags: behavioral, worldmodel, overlap");
198
+ lines.push("- default_for_roles: all");
199
+ lines.push("- priority: 50");
200
+ lines.push("- stackable: true");
201
+ lines.push("");
202
+ for (const directive of lens.directives) {
203
+ lines.push(`> ${directive.scope}: ${directive.instruction}`);
204
+ }
205
+ lines.push("");
206
+ }
207
+ }
208
+ return lines.join("\n");
209
+ }
210
+ function emitSignalSchema(model) {
211
+ const signals = model.evolution.signals.map((signal) => ({
212
+ id: toSnakeCase(signal),
213
+ name: titleCase(signal),
214
+ type: "number",
215
+ default: 70
216
+ }));
217
+ return {
218
+ model_id: model.frontmatter.model_id,
219
+ signals
220
+ };
221
+ }
222
+ function emitOverlapMap(model) {
223
+ const pairings = model.geometry.overlapEffects.map((o) => ({
224
+ domainA: o.domainA,
225
+ domainB: o.domainB,
226
+ effect: o.effect
227
+ }));
228
+ const matrix = {};
229
+ for (const overlap of model.geometry.overlapEffects) {
230
+ const keyA = toKebabCase(overlap.domainA);
231
+ const keyB = toKebabCase(overlap.domainB);
232
+ if (!matrix[keyA]) matrix[keyA] = {};
233
+ matrix[keyA][keyB] = overlap.effect;
234
+ }
235
+ return {
236
+ model_id: model.frontmatter.model_id,
237
+ pairings,
238
+ matrix
239
+ };
240
+ }
241
+ function emitContextsConfig(model) {
242
+ return {
243
+ model_id: model.frontmatter.model_id,
244
+ authority_layers: model.modifiers.authorityLayers,
245
+ spatial_contexts: model.modifiers.spatialContexts,
246
+ interpretation_rules: model.modifiers.interpretationRules
247
+ };
248
+ }
249
+ function deriveTone(domainA, domainB) {
250
+ const combined = `${domainA} ${domainB}`.toLowerCase();
251
+ let formality = "neutral";
252
+ if (/strateg|technic|analytic|research|engineer/.test(combined)) {
253
+ formality = "professional";
254
+ } else if (/narrat|story|communi|creative/.test(combined)) {
255
+ formality = "casual";
256
+ }
257
+ let verbosity = "balanced";
258
+ if (/foresight|scenario|plan|design/.test(combined)) {
259
+ verbosity = "detailed";
260
+ } else if (/prosper|negotiat|stakeholder/.test(combined)) {
261
+ verbosity = "concise";
262
+ }
263
+ let emotion = "neutral";
264
+ if (/empath|emoti|care|safe|trust/.test(combined)) {
265
+ emotion = "warm";
266
+ } else if (/analytic|system|data/.test(combined)) {
267
+ emotion = "clinical";
268
+ }
269
+ let confidence = "balanced";
270
+ if (/lead|command|decis|strateg/.test(combined)) {
271
+ confidence = "authoritative";
272
+ } else if (/explor|experiment|creat/.test(combined)) {
273
+ confidence = "exploratory";
274
+ }
275
+ return { formality, verbosity, emotion, confidence };
276
+ }
277
+ function buildLensSuggestions(model) {
278
+ const lenses = [];
279
+ const domainMap = new Map(model.geometry.domains.map((d) => [d.name.toLowerCase(), d]));
280
+ for (const overlap of model.geometry.overlapEffects) {
281
+ const lensId = toKebabCase(overlap.effect);
282
+ const tone = deriveTone(overlap.domainA, overlap.domainB);
283
+ const domainAData = domainMap.get(overlap.domainA.toLowerCase());
284
+ const domainBData = domainMap.get(overlap.domainB.toLowerCase());
285
+ const directives = [];
286
+ if (domainAData && domainAData.skills.length > 0) {
287
+ directives.push({
288
+ scope: "response_framing",
289
+ instruction: `Approach through the lens of ${domainAData.skills.join(", ").toLowerCase()}.`
290
+ });
291
+ }
292
+ if (domainBData && domainBData.values.length > 0) {
293
+ directives.push({
294
+ scope: "behavior_shaping",
295
+ instruction: `Maintain ${domainBData.values.join(", ").toLowerCase()} in all responses.`
296
+ });
297
+ }
298
+ directives.push({
299
+ scope: "value_emphasis",
300
+ instruction: `Emphasize ${overlap.effect.toLowerCase()} as the emergent state of aligned behavior.`
301
+ });
302
+ lenses.push({
303
+ id: lensId,
304
+ name: titleCase(overlap.effect),
305
+ tagline: `${overlap.effect} through ${overlap.domainA} and ${overlap.domainB}.`,
306
+ derived_from: {
307
+ domainA: overlap.domainA,
308
+ domainB: overlap.domainB,
309
+ effect: overlap.effect
310
+ },
311
+ tone,
312
+ directives
313
+ });
314
+ }
315
+ return lenses;
316
+ }
317
+ function emitLensSuggestions(model) {
318
+ return buildLensSuggestions(model);
319
+ }
320
+ function compileWorldModel(model) {
321
+ return {
322
+ worldMarkdown: emitWorldMarkdown(model),
323
+ signalSchema: emitSignalSchema(model),
324
+ overlapMap: emitOverlapMap(model),
325
+ contextsConfig: emitContextsConfig(model),
326
+ lensSuggestions: emitLensSuggestions(model)
327
+ };
328
+ }
329
+
330
+ export {
331
+ emitWorldMarkdown,
332
+ emitSignalSchema,
333
+ emitOverlapMap,
334
+ emitContextsConfig,
335
+ emitLensSuggestions,
336
+ compileWorldModel
337
+ };
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AKW5YVCE.js";
5
5
  import {
6
6
  loadWorld
7
- } from "./chunk-EQUAWNXW.js";
7
+ } from "./chunk-I4RTIMLX.js";
8
8
  import {
9
9
  evaluateGuard
10
10
  } from "./chunk-ZAF6JH23.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-5U2MQO5P.js";
7
7
  import {
8
8
  loadWorld
9
- } from "./chunk-EQUAWNXW.js";
9
+ } from "./chunk-I4RTIMLX.js";
10
10
  import {
11
11
  evaluateGuard
12
12
  } from "./chunk-ZAF6JH23.js";
@@ -35,7 +35,7 @@ async function addGuard(worldDir, input) {
35
35
  };
36
36
  config.guards.push(guard);
37
37
  await writeFile(guardsPath, JSON.stringify(config, null, 2) + "\n");
38
- const { loadWorldFromDirectory } = await import("./world-loader-J47PCPDZ.js");
38
+ const { loadWorldFromDirectory } = await import("./world-loader-YTYFOP7D.js");
39
39
  const world = await loadWorldFromDirectory(worldDir);
40
40
  const report = validateWorld(world);
41
41
  return {
@@ -83,7 +83,7 @@ async function addRule(worldDir, input) {
83
83
  };
84
84
  const rulePath = join(rulesDir, `rule-${ruleNum}.json`);
85
85
  await writeFile(rulePath, JSON.stringify(rule, null, 2) + "\n");
86
- const { loadWorldFromDirectory } = await import("./world-loader-J47PCPDZ.js");
86
+ const { loadWorldFromDirectory } = await import("./world-loader-YTYFOP7D.js");
87
87
  const world = await loadWorldFromDirectory(worldDir);
88
88
  const report = validateWorld(world);
89
89
  return {
@@ -118,7 +118,7 @@ async function addInvariant(worldDir, input) {
118
118
  };
119
119
  config.invariants.push(invariant);
120
120
  await writeFile(invariantsPath, JSON.stringify(config, null, 2) + "\n");
121
- const { loadWorldFromDirectory } = await import("./world-loader-J47PCPDZ.js");
121
+ const { loadWorldFromDirectory } = await import("./world-loader-YTYFOP7D.js");
122
122
  const world = await loadWorldFromDirectory(worldDir);
123
123
  const report = validateWorld(world);
124
124
  return {