@neuroverseos/governance 0.4.0 → 0.4.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 (105) hide show
  1. package/dist/adapters/autoresearch.d.cts +2 -1
  2. package/dist/adapters/autoresearch.d.ts +2 -1
  3. package/dist/adapters/autoresearch.js +2 -2
  4. package/dist/adapters/deep-agents.d.cts +3 -2
  5. package/dist/adapters/deep-agents.d.ts +3 -2
  6. package/dist/adapters/deep-agents.js +2 -2
  7. package/dist/adapters/express.d.cts +2 -1
  8. package/dist/adapters/express.d.ts +2 -1
  9. package/dist/adapters/express.js +2 -2
  10. package/dist/adapters/index.cjs +66 -1
  11. package/dist/adapters/index.d.cts +4 -278
  12. package/dist/adapters/index.d.ts +4 -278
  13. package/dist/adapters/index.js +33 -33
  14. package/dist/adapters/langchain.d.cts +3 -2
  15. package/dist/adapters/langchain.d.ts +3 -2
  16. package/dist/adapters/langchain.js +2 -2
  17. package/dist/adapters/mentraos.cjs +2181 -0
  18. package/dist/adapters/mentraos.d.cts +319 -0
  19. package/dist/adapters/mentraos.d.ts +319 -0
  20. package/dist/{mentraos-YFS7FMJH.js → adapters/mentraos.js} +6 -6
  21. package/dist/adapters/openai.d.cts +3 -2
  22. package/dist/adapters/openai.d.ts +3 -2
  23. package/dist/adapters/openai.js +2 -2
  24. package/dist/adapters/openclaw.d.cts +3 -2
  25. package/dist/adapters/openclaw.d.ts +3 -2
  26. package/dist/adapters/openclaw.js +2 -2
  27. package/dist/{add-LYHDZ5RL.js → add-XSANI3FK.js} +1 -1
  28. package/dist/bootstrap-contract-DcV6t-8M.d.cts +216 -0
  29. package/dist/bootstrap-contract-DcV6t-8M.d.ts +216 -0
  30. package/dist/{build-THUEYMVT.js → build-EGBGZFIJ.js} +5 -5
  31. package/dist/{chunk-MFKHTE5R.js → chunk-3AYKQHYI.js} +1 -1
  32. package/dist/chunk-3S5AD4AB.js +421 -0
  33. package/dist/{chunk-V4FZHJQX.js → chunk-A7SHG75T.js} +1 -1
  34. package/dist/{chunk-JKGPSFGH.js → chunk-AV7XJJWK.js} +1 -1
  35. package/dist/{chunk-Y6WXAPKY.js → chunk-DA5MHFRR.js} +1 -1
  36. package/dist/{chunk-7D7PZLB7.js → chunk-FS2UUJJO.js} +3 -3
  37. package/dist/{chunk-TD5GKIHP.js → chunk-FVOGUCB6.js} +1 -1
  38. package/dist/{chunk-APU4OZIP.js → chunk-GTPV2XGO.js} +67 -2
  39. package/dist/{chunk-BXLTEUS4.js → chunk-I4RTIMLX.js} +2 -2
  40. package/dist/{chunk-5JUZ4HL7.js → chunk-J2IZBHXJ.js} +3 -3
  41. package/dist/{chunk-YNYCQECH.js → chunk-QMVQ6KPL.js} +1 -1
  42. package/dist/{chunk-25XHSTPT.js → chunk-RDA7ISWC.js} +1 -1
  43. package/dist/{chunk-DWHUZUEY.js → chunk-YJ34R5NB.js} +1 -1
  44. package/dist/{chunk-UTH7OXTM.js → chunk-ZEIT2QLM.js} +3 -3
  45. package/dist/cli/neuroverse.cjs +580 -28
  46. package/dist/cli/neuroverse.js +21 -21
  47. package/dist/cli/plan.js +2 -2
  48. package/dist/cli/run.js +2 -2
  49. package/dist/{demo-66MMJTEH.js → demo-6OQYWRR6.js} +3 -3
  50. package/dist/{derive-5LOMN7GO.js → derive-7Y7YWVLU.js} +4 -4
  51. package/dist/{doctor-WIO4FLA3.js → doctor-NHXI7OQW.js} +3 -2
  52. package/dist/engine/bootstrap-emitter.cjs +241 -0
  53. package/dist/engine/bootstrap-emitter.d.cts +27 -0
  54. package/dist/engine/bootstrap-emitter.d.ts +27 -0
  55. package/dist/{bootstrap-emitter-GIMOJFOC.js → engine/bootstrap-emitter.js} +2 -2
  56. package/dist/engine/bootstrap-parser.cjs +560 -0
  57. package/dist/engine/bootstrap-parser.d.cts +96 -0
  58. package/dist/engine/bootstrap-parser.d.ts +96 -0
  59. package/dist/{bootstrap-parser-LBLGVEMU.js → engine/bootstrap-parser.js} +2 -2
  60. package/dist/engine/guard-engine.cjs +1116 -0
  61. package/dist/engine/guard-engine.d.cts +60 -0
  62. package/dist/engine/guard-engine.d.ts +60 -0
  63. package/dist/{guard-engine-N7TUIUU7.js → engine/guard-engine.js} +3 -3
  64. package/dist/engine/simulate-engine.cjs +390 -0
  65. package/dist/engine/simulate-engine.d.cts +105 -0
  66. package/dist/engine/simulate-engine.d.ts +105 -0
  67. package/dist/engine/simulate-engine.js +9 -0
  68. package/dist/{equity-penalties-WWC7UDQD.js → equity-penalties-NVBAB5WL.js} +2 -2
  69. package/dist/{explain-MUSGDT67.js → explain-HDFN4ION.js} +1 -1
  70. package/dist/github-TIKTWOGU.js +27 -0
  71. package/dist/{guard-W3BMQPBJ.js → guard-6KSCWT2W.js} +2 -2
  72. package/dist/{guard-contract-CLBbTGK_.d.cts → guard-contract-C991HDZp.d.cts} +2 -369
  73. package/dist/{guard-contract-CLBbTGK_.d.ts → guard-contract-hHjTTjtR.d.ts} +2 -369
  74. package/dist/{improve-PJDAWW4Q.js → improve-2PWGGO5B.js} +3 -3
  75. package/dist/index.cjs +452 -0
  76. package/dist/index.d.cts +231 -492
  77. package/dist/index.d.ts +231 -492
  78. package/dist/index.js +76 -55
  79. package/dist/{lens-IP6GIZ2Q.js → lens-MHMUDCMQ.js} +92 -25
  80. package/dist/{mcp-server-OG3PPVD2.js → mcp-server-TNIWZ7B5.js} +2 -2
  81. package/dist/{playground-4BK2XQ47.js → playground-3FLDGBET.js} +2 -2
  82. package/dist/{redteam-BRZALBPP.js → redteam-HV6LMKEH.js} +2 -2
  83. package/dist/{session-SGRUT2UH.js → session-XZP2754M.js} +2 -2
  84. package/dist/{shared-BGzmYP5g.d.cts → shared-DGnn1jiS.d.cts} +1 -1
  85. package/dist/{shared-CwGpPheR.d.ts → shared-U405h52W.d.ts} +1 -1
  86. package/dist/{simulate-FGXKIH7V.js → simulate-VT437EEL.js} +2 -2
  87. package/dist/spatial/index.cjs +682 -0
  88. package/dist/spatial/index.d.cts +517 -0
  89. package/dist/spatial/index.d.ts +517 -0
  90. package/dist/spatial/index.js +633 -0
  91. package/dist/{test-PT44BSYG.js → test-4WTX6RKQ.js} +2 -2
  92. package/dist/types.cjs +18 -0
  93. package/dist/types.d.cts +370 -0
  94. package/dist/types.d.ts +370 -0
  95. package/dist/types.js +0 -0
  96. package/dist/{validate-Q5O5TGLT.js → validate-M52DX22Y.js} +1 -1
  97. package/dist/{world-V52ZMH26.js → world-O4HTQPDP.js} +1 -1
  98. package/dist/{world-loader-C4D3VPP3.js → world-loader-YTYFOP7D.js} +1 -1
  99. package/dist/worlds/mentraos-spatial.nv-world.md +68 -0
  100. package/package.json +46 -3
  101. package/dist/{behavioral-SPWPGYXL.js → behavioral-SLW7ALEK.js} +3 -3
  102. package/dist/{bootstrap-IP5QMC3Q.js → bootstrap-2OW5ZLBL.js} +3 -3
  103. package/dist/{chunk-7QIAF377.js → chunk-CYDMUJVZ.js} +0 -0
  104. package/dist/{chunk-QZ666FCV.js → chunk-FHXXD2TI.js} +6 -6
  105. package/dist/{configure-ai-5MP5DWTT.js → configure-ai-LL3VAPQW.js} +3 -3
@@ -0,0 +1,105 @@
1
+ import { GovernanceEvent, ViabilityStatus, WorldDefinition } from '../types.js';
2
+
3
+ /**
4
+ * Simulate Engine — Deterministic State Evolution (Reference Simulator)
5
+ *
6
+ * Pure function: (world, options) → SimulationResult
7
+ *
8
+ * This is NeuroVerse's REFERENCE SIMULATOR — one way to model how a world
9
+ * evolves over time. It is NOT the governance engine.
10
+ *
11
+ * simulateWorld() ≠ evaluateGuard()
12
+ *
13
+ * evaluateGuard() — Runtime enforcement. Decides if an action is allowed.
14
+ * Includes safety layer, role checks, plan enforcement,
15
+ * kernel rules, level constraints. Use for governance.
16
+ *
17
+ * simulateWorld() — State evolution modeling. Evaluates rule triggers,
18
+ * applies effects, tracks viability over N steps.
19
+ * Use for scenario planning and what-if analysis.
20
+ *
21
+ * World files (.nv-world.md) are portable — they define rules, roles, and
22
+ * constraints that can be consumed by any simulator or governance engine.
23
+ * This simulator is a reference implementation, not the only interpreter.
24
+ *
25
+ * Supports:
26
+ * - Single-step evaluation (default)
27
+ * - Multi-step iteration (--steps N)
28
+ * - State overrides (start from non-default values)
29
+ * - Assumption profile selection
30
+ * - Collapse detection (early termination)
31
+ *
32
+ * INVARIANTS:
33
+ * - Deterministic: same world + same options → same result.
34
+ * - Zero network calls. Zero LLM calls. Zero async.
35
+ * - Every rule evaluation is recorded in the trace.
36
+ * - World definition is REQUIRED — no world, no simulation.
37
+ */
38
+
39
+ interface SimulateOptions {
40
+ /** Number of simulation steps (default: 1) */
41
+ steps?: number;
42
+ /** State variable overrides (start values) */
43
+ stateOverrides?: Record<string, string | number | boolean>;
44
+ /** Assumption profile to use (default: world default) */
45
+ profile?: string;
46
+ /**
47
+ * Governance events to inject into the simulation.
48
+ * Events are applied before state-driven rules each step.
49
+ * This is the bridge: Guard → Events → Simulate → State Evolution.
50
+ *
51
+ * Events are distributed across steps (round-robin) or all applied to step 1
52
+ * if there are fewer steps than events.
53
+ */
54
+ events?: GovernanceEvent[];
55
+ }
56
+ interface SimulationResult {
57
+ worldId: string;
58
+ worldName: string;
59
+ profile: string;
60
+ initialState: Record<string, string | number | boolean>;
61
+ steps: SimulationStep[];
62
+ finalState: Record<string, string | number | boolean>;
63
+ finalViability: ViabilityStatus;
64
+ collapsed: boolean;
65
+ collapseStep?: number;
66
+ collapseRule?: string;
67
+ /** Total events consumed during simulation */
68
+ eventsConsumed: number;
69
+ }
70
+ interface SimulationStep {
71
+ step: number;
72
+ /** Events applied during this step (before rules) */
73
+ eventsApplied: EventApplication[];
74
+ rulesEvaluated: RuleEvaluation[];
75
+ rulesFired: number;
76
+ stateAfter: Record<string, string | number | boolean>;
77
+ viability: ViabilityStatus;
78
+ collapsed: boolean;
79
+ }
80
+ /** Record of an event applied during simulation */
81
+ interface EventApplication {
82
+ eventType: string;
83
+ rulesTriggered: string[];
84
+ effects: AppliedEffect[];
85
+ }
86
+ interface RuleEvaluation {
87
+ ruleId: string;
88
+ label: string;
89
+ triggered: boolean;
90
+ excluded: boolean;
91
+ effects: AppliedEffect[];
92
+ collapsed: boolean;
93
+ collapseField?: string;
94
+ }
95
+ interface AppliedEffect {
96
+ target: string;
97
+ operation: string;
98
+ value: number | boolean | string;
99
+ before: string | number | boolean;
100
+ after: string | number | boolean;
101
+ }
102
+ declare function simulateWorld(world: WorldDefinition, options?: SimulateOptions): SimulationResult;
103
+ declare function renderSimulateText(result: SimulationResult): string;
104
+
105
+ export { type AppliedEffect, type EventApplication, type RuleEvaluation, type SimulateOptions, type SimulationResult, type SimulationStep, renderSimulateText, simulateWorld };
@@ -0,0 +1,9 @@
1
+ import {
2
+ renderSimulateText,
3
+ simulateWorld
4
+ } from "../chunk-CYDMUJVZ.js";
5
+ import "../chunk-QWGCMQQD.js";
6
+ export {
7
+ renderSimulateText,
8
+ simulateWorld
9
+ };
@@ -12,10 +12,10 @@ import {
12
12
  import {
13
13
  evaluateGuard
14
14
  } from "./chunk-ZAF6JH23.js";
15
- import "./chunk-QLPTHTVB.js";
16
15
  import {
17
16
  loadWorld
18
- } from "./chunk-BXLTEUS4.js";
17
+ } from "./chunk-I4RTIMLX.js";
18
+ import "./chunk-QLPTHTVB.js";
19
19
  import "./chunk-QWGCMQQD.js";
20
20
 
21
21
  // src/cli/equity-penalties.ts
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-ZJTDUCC2.js";
8
8
  import {
9
9
  loadWorld
10
- } from "./chunk-BXLTEUS4.js";
10
+ } from "./chunk-I4RTIMLX.js";
11
11
  import "./chunk-QWGCMQQD.js";
12
12
 
13
13
  // src/cli/explain.ts
@@ -0,0 +1,27 @@
1
+ import {
2
+ GitHubGovernanceBlockedError,
3
+ GitHubGovernor,
4
+ GitHubWebhookHandler,
5
+ createGitHubGovernor,
6
+ createGitHubGovernorFromWorld,
7
+ createGitHubWebhookHandler,
8
+ createGitHubWebhookHandlerFromWorld,
9
+ formatForActions,
10
+ formatPRComment
11
+ } from "./chunk-3S5AD4AB.js";
12
+ import "./chunk-5U2MQO5P.js";
13
+ import "./chunk-ZAF6JH23.js";
14
+ import "./chunk-I4RTIMLX.js";
15
+ import "./chunk-QLPTHTVB.js";
16
+ import "./chunk-QWGCMQQD.js";
17
+ export {
18
+ GitHubGovernanceBlockedError,
19
+ GitHubGovernor,
20
+ GitHubWebhookHandler,
21
+ createGitHubGovernor,
22
+ createGitHubGovernorFromWorld,
23
+ createGitHubWebhookHandler,
24
+ createGitHubWebhookHandlerFromWorld,
25
+ formatForActions,
26
+ formatPRComment
27
+ };
@@ -13,10 +13,10 @@ import {
13
13
  import {
14
14
  evaluateGuard
15
15
  } from "./chunk-ZAF6JH23.js";
16
- import "./chunk-QLPTHTVB.js";
17
16
  import {
18
17
  loadWorld
19
- } from "./chunk-BXLTEUS4.js";
18
+ } from "./chunk-I4RTIMLX.js";
19
+ import "./chunk-QLPTHTVB.js";
20
20
  import "./chunk-QWGCMQQD.js";
21
21
 
22
22
  // src/cli/guard.ts
@@ -1,371 +1,4 @@
1
- /**
2
- * World Engine Types — Subset for Governance Engine
3
- *
4
- * These types map to the .nv-world.zip file format.
5
- * This file contains only the types referenced by the governance
6
- * engine (guard, validate, bootstrap). The full type system lives
7
- * in the main NeuroVerse OS repo.
8
- */
9
- interface ModelIdentity {
10
- modelName: string;
11
- acronymExpansion?: string;
12
- nameType: 'acronym' | 'metaphor';
13
- purpose: string;
14
- domain?: string;
15
- }
16
- interface WorldIdentity {
17
- world_id: string;
18
- name: string;
19
- thesis: string;
20
- version: string;
21
- runtime_mode: 'SIMULATION' | 'NARRATIVE' | 'COMPLIANCE' | 'CUSTOM';
22
- default_assumption_profile: string;
23
- default_alternative_profile: string;
24
- modules: string[];
25
- players: {
26
- thinking_space: boolean;
27
- experience_space: boolean;
28
- action_space: boolean;
29
- };
30
- modelIdentity?: ModelIdentity;
31
- }
32
- interface Invariant {
33
- id: string;
34
- label: string;
35
- enforcement: 'structural' | 'prompt';
36
- mutable: false;
37
- }
38
- interface AssumptionProfile {
39
- name: string;
40
- description: string;
41
- is_default_baseline?: boolean;
42
- is_default_alternative?: boolean;
43
- parameters: Record<string, string>;
44
- }
45
- interface ParameterDefinition {
46
- type: 'enum' | 'number' | 'boolean';
47
- options?: string[];
48
- min?: number;
49
- max?: number;
50
- label: string;
51
- description: string;
52
- }
53
- interface AssumptionConfig {
54
- profiles: Record<string, AssumptionProfile>;
55
- parameter_definitions: Record<string, ParameterDefinition>;
56
- }
57
- interface StateVariable {
58
- type: 'enum' | 'number' | 'boolean';
59
- options?: string[];
60
- min?: number;
61
- max?: number;
62
- step?: number;
63
- default: string | number | boolean;
64
- mutable: boolean;
65
- label: string;
66
- description: string;
67
- display_as?: 'percentage' | 'integer' | 'decimal';
68
- }
69
- interface StatePreset {
70
- description: string;
71
- values: Record<string, string | number | boolean>;
72
- }
73
- interface StateSchema {
74
- variables: Record<string, StateVariable>;
75
- presets: Record<string, StatePreset>;
76
- }
77
- type TriggerOperator = '==' | '!=' | '>' | '<' | '>=' | '<=' | 'in';
78
- type EffectOperation = 'multiply' | 'add' | 'subtract' | 'set' | 'set_boolean' | 'multiply_dynamic' | 'add_dynamic' | 'subtract_dynamic' | 'set_dynamic';
79
- type RuleSeverity = 'structural' | 'degradation' | 'advantage';
80
- interface Trigger {
81
- field: string;
82
- operator: TriggerOperator;
83
- value: string | number | boolean | string[];
84
- source: 'state' | 'assumption';
85
- }
86
- interface Effect {
87
- target: string;
88
- operation: EffectOperation;
89
- value: number | boolean | string;
90
- value_formula?: string;
91
- }
92
- interface CollapseCheck {
93
- field: string;
94
- operator: TriggerOperator;
95
- value: number;
96
- result: 'MODEL_COLLAPSES';
97
- }
98
- interface ConditionalEffect {
99
- condition: Trigger;
100
- and?: Trigger;
101
- or?: Trigger;
102
- condition_any?: Trigger[];
103
- effects: Effect[];
104
- }
105
- interface CausalTranslation {
106
- trigger_text: string;
107
- rule_text: string;
108
- shift_text: string;
109
- effect_text: string;
110
- }
111
- interface RuleRedirect {
112
- suggested_action: string;
113
- reason: string;
114
- fallback_state_changes?: Record<string, string | number | boolean>;
115
- }
116
- interface Rule {
117
- id: string;
118
- severity: RuleSeverity;
119
- label: string;
120
- description: string;
121
- order: number;
122
- triggers: Trigger[];
123
- effects?: Effect[];
124
- effects_conditional?: ConditionalEffect[];
125
- collapse_check?: CollapseCheck;
126
- secondary_check?: CollapseCheck;
127
- exclusive_with?: string;
128
- causal_translation: CausalTranslation;
129
- redirect?: RuleRedirect;
130
- }
131
- type ViabilityStatus = 'THRIVING' | 'STABLE' | 'COMPRESSED' | 'CRITICAL' | 'MODEL_COLLAPSES';
132
- interface ViabilityGate {
133
- status: ViabilityStatus;
134
- field: string;
135
- operator: TriggerOperator;
136
- value: number;
137
- color: string;
138
- icon: string;
139
- }
140
- interface CollapseVisual {
141
- background: string;
142
- text: string;
143
- border: string;
144
- label: string;
145
- }
146
- interface GatesConfig {
147
- viability_classification: ViabilityGate[];
148
- structural_override: {
149
- description: string;
150
- enforcement: 'mandatory';
151
- };
152
- sustainability_threshold: number;
153
- collapse_visual: CollapseVisual;
154
- }
155
- interface ComputedOutcome {
156
- id: string;
157
- type: 'number' | 'boolean' | 'enum';
158
- range?: [number, number];
159
- options?: string[];
160
- default?: number | boolean | string;
161
- display_as?: 'percentage' | 'integer' | 'decimal';
162
- label: string;
163
- primary?: boolean;
164
- initial_value?: string;
165
- derived_from?: string;
166
- assignment?: 'rule' | 'external';
167
- show_in_comparison: boolean;
168
- structural_indicator?: boolean;
169
- }
170
- interface ComparisonLayout {
171
- primary_card: string;
172
- status_badge: string;
173
- structural_indicators: string[];
174
- }
175
- interface OutcomesConfig {
176
- computed_outcomes: ComputedOutcome[];
177
- comparison_layout: ComparisonLayout;
178
- }
179
- interface WorldMetadata {
180
- format_version: string;
181
- created_at: string;
182
- last_modified: string;
183
- authoring_method: 'manual-authoring' | 'configurator-ai' | 'migration';
184
- integrity_hash?: string;
185
- }
186
- interface KernelConfig {
187
- artifact_type: string;
188
- kernel_id: string;
189
- version: string;
190
- domain: string;
191
- enforcement_level: 'standard' | 'strict' | 'permissive';
192
- input_boundaries: {
193
- forbidden_patterns: Array<{
194
- id: string;
195
- pattern: string;
196
- reason: string;
197
- action: 'BLOCK' | 'WARN';
198
- }>;
199
- };
200
- output_boundaries: {
201
- forbidden_patterns: Array<{
202
- id: string;
203
- pattern: string;
204
- reason: string;
205
- action: 'BLOCK' | 'WARN';
206
- }>;
207
- };
208
- response_vocabulary: Record<string, string>;
209
- metadata: {
210
- compiled_by: string;
211
- compiled_at: string;
212
- source_hash: string;
213
- compiler_version: string;
214
- };
215
- }
216
- type RoleArchetype = 'observer' | 'operator' | 'strategist' | 'guardian' | 'steward' | 'executor';
217
- type RoleAuthority = 'none' | 'execute_within_limits' | 'reprioritize_within_bounds' | 'block_violations' | 'escalate_audit_freeze' | 'execute_declared_actions';
218
- type RolePosture = 'analyze' | 'task_oriented' | 'long_term_coherence' | 'constraint_aware' | 'system_integrity' | 'efficient';
219
- interface WorldRoleDefinition {
220
- id: string;
221
- archetype: RoleArchetype;
222
- authority: RoleAuthority;
223
- posture: RolePosture;
224
- name: string;
225
- description: string;
226
- icon?: string;
227
- roleMandate: string;
228
- voiceStyle?: string;
229
- canDo: string[];
230
- cannotDo: string[];
231
- requiresApproval?: boolean;
232
- trackedOutcomes?: string[];
233
- ownedRules?: string[];
234
- /** Default lens for this role (references a lens id from the world's lenses config) */
235
- defaultLens?: string;
236
- }
237
- type RoleAssignment = 'dynamic' | 'per_session' | 'permanent';
238
- interface RoleTransition {
239
- from: string;
240
- to: string;
241
- initiator: 'self' | 'steward' | 'any';
242
- condition?: string;
243
- }
244
- interface RolesConfig {
245
- assignment: RoleAssignment;
246
- roles: WorldRoleDefinition[];
247
- transitions?: RoleTransition[];
248
- }
249
- interface Guard {
250
- id: string;
251
- label: string;
252
- description: string;
253
- category: 'structural' | 'operational' | 'advisory';
254
- enforcement: 'block' | 'pause' | 'warn' | 'modify' | 'penalize' | 'reward' | 'neutral';
255
- immutable: boolean;
256
- invariant_ref?: string;
257
- intent_patterns: string[];
258
- required_roles?: string[];
259
- redirect?: string;
260
- default_enabled?: boolean;
261
- /** Tool names this guard applies to (case-insensitive). Empty/absent = all tools. */
262
- appliesTo?: string[];
263
- player_modes?: {
264
- thinking?: 'annotate' | 'block' | 'ignore';
265
- experience?: 'simulate' | 'score' | 'ignore';
266
- action?: 'block' | 'pause' | 'warn' | 'modify' | 'penalize' | 'reward' | 'neutral';
267
- };
268
- /** Consequence to apply when enforcement is 'penalize' */
269
- consequence?: {
270
- type: 'freeze' | 'reduce_influence' | 'increase_risk' | 'cooldown' | 'custom';
271
- rounds?: number;
272
- magnitude?: number;
273
- description: string;
274
- };
275
- /** Reward to apply when enforcement is 'reward' */
276
- reward?: {
277
- type: 'boost_influence' | 'priority' | 'faster_execution' | 'weight_increase' | 'custom';
278
- rounds?: number;
279
- magnitude?: number;
280
- description: string;
281
- };
282
- /** For 'modify' enforcement: what the action should be changed to */
283
- modify_to?: string;
284
- }
285
- interface IntentPattern {
286
- label: string;
287
- pattern: string;
288
- }
289
- interface GuardsConfig {
290
- guards: Guard[];
291
- intent_vocabulary: Record<string, IntentPattern>;
292
- /** All known action surfaces (e.g. "shell", "http", "db", "email", "deploy").
293
- * When declared, the validator checks that every surface has at least one
294
- * governing guard — surfaces without guards are reported as fail-open. */
295
- tool_surfaces?: string[];
296
- }
297
- /**
298
- * A governance event — the bridge between Guard and Simulate.
299
- *
300
- * Guard produces events (what happened).
301
- * Simulate consumes events (what changes because of it).
302
- *
303
- * Events are NOT stored — they flow through the system.
304
- * Guard evaluation log IS the event stream.
305
- */
306
- interface GovernanceEvent {
307
- /** Semantic event type: "complaint", "refund", "action_blocked", etc. */
308
- type: string;
309
- /** Who caused this event */
310
- actor?: 'customer' | 'agent' | 'system';
311
- /** Where the event originated */
312
- source: 'guard' | 'manual' | 'system';
313
- /** Unix timestamp (ms) */
314
- timestamp: number;
315
- /** Guard status that produced this event (when source=guard) */
316
- guardStatus?: 'ALLOW' | 'BLOCK' | 'PAUSE' | 'MODIFY' | 'PENALIZE' | 'REWARD' | 'NEUTRAL';
317
- /** Optional metadata */
318
- metadata?: Record<string, unknown>;
319
- }
320
- interface LensDirectiveConfig {
321
- id: string;
322
- scope: 'response_framing' | 'language_style' | 'content_filtering' | 'value_emphasis' | 'behavior_shaping';
323
- instruction: string;
324
- }
325
- interface LensConfig {
326
- id: string;
327
- name: string;
328
- tagline: string;
329
- description: string;
330
- tags: string[];
331
- tone: {
332
- formality: 'casual' | 'neutral' | 'formal' | 'professional';
333
- verbosity: 'terse' | 'concise' | 'balanced' | 'detailed';
334
- emotion: 'warm' | 'neutral' | 'reserved' | 'clinical';
335
- confidence: 'humble' | 'balanced' | 'authoritative' | 'assertive';
336
- };
337
- directives: LensDirectiveConfig[];
338
- defaultForRoles: string[];
339
- priority: number;
340
- stackable: boolean;
341
- }
342
- interface LensesConfig {
343
- lenses: LensConfig[];
344
- /**
345
- * Lens policy:
346
- * - 'locked': lenses are assigned by role, user cannot change without pin
347
- * - 'role_default': lenses start as role default, user can override
348
- * - 'user_choice': no default, user picks freely
349
- */
350
- policy?: 'locked' | 'role_default' | 'user_choice';
351
- /** Pin required to change lenses when policy is 'locked' */
352
- lockPin?: string;
353
- }
354
- interface WorldDefinition {
355
- world: WorldIdentity;
356
- invariants: Invariant[];
357
- assumptions: AssumptionConfig;
358
- stateSchema: StateSchema;
359
- rules: Rule[];
360
- gates: GatesConfig;
361
- outcomes: OutcomesConfig;
362
- guards?: GuardsConfig;
363
- roles?: RolesConfig;
364
- kernel?: KernelConfig;
365
- lenses?: LensesConfig;
366
- enforcement?: string;
367
- metadata: WorldMetadata;
368
- }
1
+ import { GovernanceEvent } from './types.cjs';
369
2
 
370
3
  /**
371
4
  * Plan Contract — Plan Enforcement Types
@@ -924,4 +557,4 @@ declare const GUARD_EXIT_CODES: {
924
557
  };
925
558
  type GuardExitCode = (typeof GUARD_EXIT_CODES)[keyof typeof GUARD_EXIT_CODES];
926
559
 
927
- export { type AdvanceResult as A, type Consequence as C, type EvaluationTrace as E, type GuardEvent as G, type Invariant as I, type KernelRuleCheck as K, type LevelCheck as L, type PlanDefinition as P, type Reward as R, type StepEvidence as S, type ViabilityStatus as V, type WorldDefinition as W, type GuardVerdict as a, type GuardEngineOptions as b, type PlanProgress as c, type GuardStatus as d, type GovernanceEvent as e, type PlanVerdict as f, type PlanCheck as g, type AgentBehaviorState as h, type Guard as i, type Rule as j, GUARD_EXIT_CODES as k, type GuardCheck as l, type GuardExitCode as m, type IntentRecord as n, type InvariantCheck as o, PLAN_EXIT_CODES as p, type PlanCompletionMode as q, type PlanConstraint as r, type PlanExitCode as s, type PlanStatus as t, type PlanStep as u, type PrecedenceResolution as v, type RoleCheck as w, type SafetyCheck as x, type VerdictEvidence as y };
560
+ export { type AdvanceResult as A, type Consequence as C, type EvaluationTrace as E, type GuardEvent as G, type IntentRecord as I, type KernelRuleCheck as K, type LevelCheck as L, type PlanDefinition as P, type Reward as R, type StepEvidence as S, type VerdictEvidence as V, type GuardVerdict as a, type GuardEngineOptions as b, type PlanProgress as c, type GuardStatus as d, type PlanVerdict as e, type PlanCheck as f, type AgentBehaviorState as g, GUARD_EXIT_CODES as h, type GuardCheck as i, type GuardExitCode as j, type InvariantCheck as k, PLAN_EXIT_CODES as l, type PlanCompletionMode as m, type PlanConstraint as n, type PlanExitCode as o, type PlanStatus as p, type PlanStep as q, type PrecedenceResolution as r, type RoleCheck as s, type SafetyCheck as t };