@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,821 +0,0 @@
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
- }
235
- type RoleAssignment = 'dynamic' | 'per_session' | 'permanent';
236
- interface RoleTransition {
237
- from: string;
238
- to: string;
239
- initiator: 'self' | 'steward' | 'any';
240
- condition?: string;
241
- }
242
- interface RolesConfig {
243
- assignment: RoleAssignment;
244
- roles: WorldRoleDefinition[];
245
- transitions?: RoleTransition[];
246
- }
247
- interface Guard {
248
- id: string;
249
- label: string;
250
- description: string;
251
- category: 'structural' | 'operational' | 'advisory';
252
- enforcement: 'block' | 'pause' | 'warn' | 'modify' | 'penalize' | 'reward' | 'neutral';
253
- immutable: boolean;
254
- invariant_ref?: string;
255
- intent_patterns: string[];
256
- required_roles?: string[];
257
- redirect?: string;
258
- default_enabled?: boolean;
259
- /** Tool names this guard applies to (case-insensitive). Empty/absent = all tools. */
260
- appliesTo?: string[];
261
- player_modes?: {
262
- thinking?: 'annotate' | 'block' | 'ignore';
263
- experience?: 'simulate' | 'score' | 'ignore';
264
- action?: 'block' | 'pause' | 'warn' | 'modify' | 'penalize' | 'reward' | 'neutral';
265
- };
266
- /** Consequence to apply when enforcement is 'penalize' */
267
- consequence?: {
268
- type: 'freeze' | 'reduce_influence' | 'increase_risk' | 'cooldown' | 'custom';
269
- rounds?: number;
270
- magnitude?: number;
271
- description: string;
272
- };
273
- /** Reward to apply when enforcement is 'reward' */
274
- reward?: {
275
- type: 'boost_influence' | 'priority' | 'faster_execution' | 'weight_increase' | 'custom';
276
- rounds?: number;
277
- magnitude?: number;
278
- description: string;
279
- };
280
- /** For 'modify' enforcement: what the action should be changed to */
281
- modify_to?: string;
282
- }
283
- interface IntentPattern {
284
- label: string;
285
- pattern: string;
286
- }
287
- interface GuardsConfig {
288
- guards: Guard[];
289
- intent_vocabulary: Record<string, IntentPattern>;
290
- /** All known action surfaces (e.g. "shell", "http", "db", "email", "deploy").
291
- * When declared, the validator checks that every surface has at least one
292
- * governing guard — surfaces without guards are reported as fail-open. */
293
- tool_surfaces?: string[];
294
- }
295
- interface WorldDefinition {
296
- world: WorldIdentity;
297
- invariants: Invariant[];
298
- assumptions: AssumptionConfig;
299
- stateSchema: StateSchema;
300
- rules: Rule[];
301
- gates: GatesConfig;
302
- outcomes: OutcomesConfig;
303
- guards?: GuardsConfig;
304
- roles?: RolesConfig;
305
- kernel?: KernelConfig;
306
- enforcement?: string;
307
- metadata: WorldMetadata;
308
- }
309
-
310
- /**
311
- * Plan Contract — Plan Enforcement Types
312
- *
313
- * Defines the input/output contract for plan-based governance.
314
- *
315
- * Plans are temporary guard overlays — "mom's rules for this trip."
316
- * They define what an agent should do (steps) and what it must not
317
- * exceed (constraints). Plans layer on top of worlds, narrowing
318
- * behavior without overriding safety or world-level governance.
319
- *
320
- * INVARIANTS:
321
- * - Plans can only restrict, never expand. A plan cannot override a world BLOCK.
322
- * - Plan enforcement is deterministic: same event + same plan → same verdict.
323
- * - No AI in the evaluation loop. Parsing and evaluation are pure functions.
324
- */
325
- interface PlanStep {
326
- /** Auto-generated slug from label (e.g., "write_announcement_blog_post"). */
327
- id: string;
328
- /** Human-readable step name. */
329
- label: string;
330
- /** Optional detail about the step. */
331
- description?: string;
332
- /** Restrict this step to specific tools (optional). */
333
- tools?: string[];
334
- /** Step IDs that must complete first (optional). */
335
- requires?: string[];
336
- /** Semantic tags for action mapping (e.g., ["deploy", "marketing"]). */
337
- tags?: string[];
338
- /** Completion condition name (optional). */
339
- verify?: string;
340
- /** Current step status. */
341
- status: 'pending' | 'active' | 'completed' | 'skipped';
342
- }
343
- interface PlanConstraint {
344
- /** Auto-generated constraint ID. */
345
- id: string;
346
- /** Constraint type. 'approval' always returns PAUSE until human confirms. */
347
- type: 'budget' | 'time' | 'scope' | 'approval' | 'custom';
348
- /** Human-readable description. */
349
- description: string;
350
- /** Enforcement mode. */
351
- enforcement: 'block' | 'pause';
352
- /** Numeric limit (for budget/time). */
353
- limit?: number;
354
- /** Unit for the limit (e.g., "USD", "minutes"). */
355
- unit?: string;
356
- /** Pattern that activates this constraint. */
357
- trigger?: string;
358
- }
359
- /**
360
- * How step completion is determined:
361
- * - 'trust' — caller asserts completion, plan advances (default)
362
- * - 'verified' — steps with a `verify` field require evidence to advance;
363
- * steps without `verify` still advance on trust
364
- */
365
- type PlanCompletionMode = 'trust' | 'verified';
366
- /**
367
- * Evidence provided when advancing a step in verified mode.
368
- * The verifier checks that evidence.type matches step.verify.
369
- */
370
- interface StepEvidence {
371
- /** Evidence type — must match the step's `verify` field. */
372
- type: string;
373
- /** Proof payload (URL, hash, output snippet, etc.). */
374
- proof: string;
375
- /** When the evidence was produced. */
376
- timestamp?: string;
377
- }
378
- /**
379
- * Result of attempting to advance a step.
380
- */
381
- interface AdvanceResult {
382
- /** Whether the step was successfully advanced. */
383
- success: boolean;
384
- /** Updated plan (if success). */
385
- plan?: PlanDefinition;
386
- /** Why advancement failed (if !success). */
387
- reason?: string;
388
- /** The evidence that was accepted (if verified mode). */
389
- evidence?: StepEvidence;
390
- }
391
- interface PlanDefinition {
392
- /** Unique plan identifier. */
393
- plan_id: string;
394
- /** Human-readable objective. */
395
- objective: string;
396
- /** Whether steps must run in order. */
397
- sequential: boolean;
398
- /**
399
- * How step completion is determined.
400
- * - 'trust' (default) — caller asserts "done", plan advances
401
- * - 'verified' — steps with `verify` require evidence to advance
402
- */
403
- completion: PlanCompletionMode;
404
- /** The steps in this plan. */
405
- steps: PlanStep[];
406
- /** Constraints that apply to this plan. */
407
- constraints: PlanConstraint[];
408
- /** Optional parent world ID. */
409
- world_id?: string;
410
- /** When this plan was created. */
411
- created_at: string;
412
- /** Optional expiry time. */
413
- expires_at?: string;
414
- }
415
- type PlanStatus = 'ON_PLAN' | 'OFF_PLAN' | 'CONSTRAINT_VIOLATED' | 'PLAN_COMPLETE';
416
- interface PlanVerdict {
417
- /** Whether the action is allowed by this plan. */
418
- allowed: boolean;
419
- /** Plan verdict status. */
420
- status: PlanStatus;
421
- /** Why the action was blocked or paused. */
422
- reason?: string;
423
- /** Which step this action matched (if any). */
424
- matchedStep?: string;
425
- /** Nearest step when OFF_PLAN (for agent self-correction). */
426
- closestStep?: string;
427
- /** How close the action was to the nearest step (0-1). */
428
- similarityScore?: number;
429
- /** Current plan progress. */
430
- progress: PlanProgress;
431
- }
432
- interface PlanProgress {
433
- /** Number of completed steps. */
434
- completed: number;
435
- /** Total number of steps. */
436
- total: number;
437
- /** Completion percentage. */
438
- percentage: number;
439
- }
440
- interface PlanCheck {
441
- /** The plan being enforced. */
442
- planId: string;
443
- /** Whether the action matched a plan step. */
444
- matched: boolean;
445
- /** Which step was matched. */
446
- matchedStepId?: string;
447
- /** Label of the matched step. */
448
- matchedStepLabel?: string;
449
- /** Nearest step when no match (for self-correction). */
450
- closestStepId?: string;
451
- /** Label of the nearest step. */
452
- closestStepLabel?: string;
453
- /** Similarity score to the nearest step. */
454
- similarityScore?: number;
455
- /** Whether step sequence requirements are satisfied. */
456
- sequenceValid?: boolean;
457
- /** Results of constraint checks. */
458
- constraintsChecked: Array<{
459
- constraintId: string;
460
- passed: boolean;
461
- reason?: string;
462
- }>;
463
- /** Current progress. */
464
- progress: {
465
- completed: number;
466
- total: number;
467
- };
468
- }
469
- declare const PLAN_EXIT_CODES: {
470
- readonly ON_PLAN: 0;
471
- readonly OFF_PLAN: 1;
472
- readonly CONSTRAINT_VIOLATED: 2;
473
- readonly ERROR: 3;
474
- readonly PLAN_COMPLETE: 4;
475
- };
476
- type PlanExitCode = (typeof PLAN_EXIT_CODES)[keyof typeof PLAN_EXIT_CODES];
477
-
478
- /**
479
- * Guard Contract — CLI Governance Evaluation Types
480
- *
481
- * Defines the input/output contract for `neuroverse guard`.
482
- *
483
- * GuardEvent comes in (stdin JSON).
484
- * GuardVerdict goes out (stdout JSON).
485
- * Exit code encodes status: 0=ALLOW, 1=BLOCK, 2=PAUSE.
486
- *
487
- * The EvaluationTrace is the internal debugging structure that records
488
- * every check performed, whether it matched, and how precedence resolved.
489
- * Included in the verdict when trace mode is enabled. Powers:
490
- * - OS debugging UI
491
- * - Explainability features
492
- * - Evidence generation for enterprise compliance
493
- * - CI/CD audit trails
494
- *
495
- * INVARIANTS:
496
- * - Deterministic: same event + same world → same verdict, always.
497
- * - Zero network calls. All evaluation is local pattern matching.
498
- * - Single event in, single verdict out.
499
- * - Trace records every check, not just the deciding one.
500
- */
501
- /**
502
- * A governance event to evaluate.
503
- * This is the CLI-facing contract — simpler than ExecutionEvent,
504
- * focused on what the guard engine actually needs.
505
- */
506
- interface GuardEvent {
507
- /** Human-readable intent description. REQUIRED. */
508
- intent: string;
509
- /** Tool being invoked (e.g., "shell", "browser", "fs", "http") */
510
- tool?: string;
511
- /** Scope of the action (file path, domain, resource identifier) */
512
- scope?: string;
513
- /** Role ID of the actor (for multi-agent worlds) */
514
- roleId?: string;
515
- /**
516
- * Direction of the event.
517
- * - 'input': user/agent → system (pre-check)
518
- * - 'output': system → user/agent (post-check)
519
- *
520
- * When set, enables direction-specific safety checks:
521
- * - direction='input': execution intent detection
522
- * - direction='output': execution claim detection
523
- *
524
- * When absent, direction-specific checks are skipped.
525
- */
526
- direction?: 'input' | 'output';
527
- /** Action category for quick classification */
528
- actionCategory?: 'read' | 'write' | 'delete' | 'network' | 'shell' | 'browser' | 'other';
529
- /** Risk level hint from the caller */
530
- riskLevel?: 'low' | 'medium' | 'high' | 'critical';
531
- /** Whether the action is irreversible (advisory hint) */
532
- irreversible?: boolean;
533
- /** Raw payload data (used for injection detection) */
534
- payload?: unknown;
535
- /** Tool arguments — supports dot-notation field resolution (e.g. args.file_path) */
536
- args?: Record<string, unknown>;
537
- /** Environment context (e.g. "development", "production") */
538
- environment?: string;
539
- }
540
- type GuardStatus = 'ALLOW' | 'BLOCK' | 'PAUSE' | 'MODIFY' | 'PENALIZE' | 'REWARD' | 'NEUTRAL';
541
- /**
542
- * Consequence applied when an agent is PENALIZED.
543
- * The governance engine blocks the action AND imposes a behavioral cost.
544
- */
545
- interface Consequence {
546
- /** Type of penalty */
547
- type: 'freeze' | 'reduce_influence' | 'increase_risk' | 'cooldown' | 'custom';
548
- /** Duration in rounds (for freeze/cooldown) */
549
- rounds?: number;
550
- /** Magnitude of effect (e.g., influence reduction percentage 0-1) */
551
- magnitude?: number;
552
- /** Human-readable description of what happens */
553
- description: string;
554
- }
555
- /**
556
- * Reward applied when an agent's action is REWARDED.
557
- * The action proceeds AND the agent receives a behavioral boost.
558
- */
559
- interface Reward {
560
- /** Type of reward */
561
- type: 'boost_influence' | 'priority' | 'faster_execution' | 'weight_increase' | 'custom';
562
- /** Duration in rounds (for temporary boosts) */
563
- rounds?: number;
564
- /** Magnitude of effect (e.g., influence boost percentage 0-1) */
565
- magnitude?: number;
566
- /** Human-readable description of what happens */
567
- description: string;
568
- }
569
- /**
570
- * Tracks the behavioral state of an agent across governance evaluations.
571
- * This is what makes governance a behavior-shaping system, not just a filter.
572
- */
573
- interface AgentBehaviorState {
574
- /** Agent/role identifier */
575
- agentId: string;
576
- /** Rounds remaining in cooldown (0 = active) */
577
- cooldownRemaining: number;
578
- /** Current influence multiplier (1.0 = normal) */
579
- influence: number;
580
- /** Accumulated reward multiplier (1.0 = normal) */
581
- rewardMultiplier: number;
582
- /** Total penalties received */
583
- totalPenalties: number;
584
- /** Total rewards received */
585
- totalRewards: number;
586
- /** History of consequences applied */
587
- consequenceHistory: Array<{
588
- ruleId: string;
589
- consequence: Consequence;
590
- appliedAt: number;
591
- }>;
592
- /** History of rewards applied */
593
- rewardHistory: Array<{
594
- ruleId: string;
595
- reward: Reward;
596
- appliedAt: number;
597
- }>;
598
- }
599
- /**
600
- * Tracks what an agent WANTED to do vs what governance MADE it do.
601
- * This is the core of the Decision Flow visualization.
602
- *
603
- * The gap between intent and outcome = governance value.
604
- */
605
- interface IntentRecord {
606
- /** Original action the agent attempted */
607
- originalIntent: string;
608
- /** What actually happened after governance */
609
- finalAction: string;
610
- /** The rule that caused the interception */
611
- ruleApplied?: string;
612
- /** How the intent was transformed */
613
- enforcement: GuardStatus;
614
- /** If MODIFY, what the action was changed to */
615
- modifiedTo?: string;
616
- /** If PENALIZE, the consequence applied */
617
- consequence?: Consequence;
618
- /** If REWARD, the reward applied */
619
- reward?: Reward;
620
- }
621
- /**
622
- * Evidence attached to every verdict for audit purposes.
623
- * Always present, regardless of trace mode.
624
- */
625
- interface VerdictEvidence {
626
- /** World identity */
627
- worldId: string;
628
- worldName: string;
629
- worldVersion: string;
630
- /** Evaluation timestamp */
631
- evaluatedAt: number;
632
- /** Invariant coverage summary */
633
- invariantsSatisfied: number;
634
- invariantsTotal: number;
635
- /** IDs of guards that matched the event */
636
- guardsMatched: string[];
637
- /** IDs of kernel rules that matched the event */
638
- rulesMatched: string[];
639
- /** Enforcement level used for evaluation */
640
- enforcementLevel: string;
641
- }
642
- /**
643
- * The verdict — what goes to stdout.
644
- *
645
- * Exit codes:
646
- * 0 = ALLOW (proceed)
647
- * 1 = BLOCK (denied, do not proceed)
648
- * 2 = PAUSE (needs human decision)
649
- * 3 = ERROR (invalid input, missing world, etc.)
650
- */
651
- interface GuardVerdict {
652
- /** The governance decision */
653
- status: GuardStatus;
654
- /** Human-readable reason (for BLOCK/PAUSE) */
655
- reason?: string;
656
- /** ID of the rule/guard that produced this verdict */
657
- ruleId?: string;
658
- /** Advisory warning (for ALLOW with warn-mode guards) */
659
- warning?: string;
660
- /** Consequence applied (for PENALIZE verdicts) */
661
- consequence?: Consequence;
662
- /** Reward applied (for REWARD verdicts) */
663
- reward?: Reward;
664
- /** Intent tracking — what the agent wanted vs what happened */
665
- intentRecord?: IntentRecord;
666
- /** Audit evidence — always present */
667
- evidence: VerdictEvidence;
668
- /** Evaluation trace — present when trace mode is enabled */
669
- trace?: EvaluationTrace;
670
- }
671
- /**
672
- * The evaluation trace records every check the engine performed.
673
- * Not just the deciding check — ALL of them. This is what powers
674
- * the debugging UI, explainability, and enterprise audit.
675
- *
676
- * Internal by default. Exposed via --trace flag or programmatic option.
677
- */
678
- interface EvaluationTrace {
679
- /** Every invariant coverage check */
680
- invariantChecks: InvariantCheck[];
681
- /** Safety checks (injection, scope escape) */
682
- safetyChecks: SafetyCheck[];
683
- /** Plan enforcement check (Phase 1.5) — present when a plan is active */
684
- planCheck?: PlanCheck;
685
- /** Every role rule checked */
686
- roleChecks: RoleCheck[];
687
- /** Every declarative guard checked */
688
- guardChecks: GuardCheck[];
689
- /** Every kernel rule checked */
690
- kernelRuleChecks: KernelRuleCheck[];
691
- /** Level constraint checks */
692
- levelChecks: LevelCheck[];
693
- /** How the final verdict was determined */
694
- precedenceResolution: PrecedenceResolution;
695
- /** Wall-clock duration */
696
- durationMs: number;
697
- }
698
- /**
699
- * Invariant coverage check.
700
- * Verifies that the world's invariants are properly backed by guards.
701
- */
702
- interface InvariantCheck {
703
- invariantId: string;
704
- label: string;
705
- /** Whether a structural guard references this invariant */
706
- hasGuardCoverage: boolean;
707
- /** ID of the guard that covers this invariant (if any) */
708
- coveringGuardId?: string;
709
- }
710
- /**
711
- * Safety check result (injection detection, scope escape).
712
- */
713
- interface SafetyCheck {
714
- checkType: 'prompt-injection' | 'scope-escape' | 'execution-claim' | 'execution-intent';
715
- triggered: boolean;
716
- /** Which pattern matched (if triggered) */
717
- matchedPattern?: string;
718
- }
719
- /**
720
- * Role rule evaluation result.
721
- */
722
- interface RoleCheck {
723
- roleId: string;
724
- roleName: string;
725
- rule: string;
726
- ruleType: 'canDo' | 'cannotDo' | 'requiresApproval';
727
- matched: boolean;
728
- }
729
- /**
730
- * Declarative guard evaluation result.
731
- */
732
- interface GuardCheck {
733
- guardId: string;
734
- label: string;
735
- category: 'structural' | 'operational' | 'advisory';
736
- enabled: boolean;
737
- matched: boolean;
738
- enforcement: 'block' | 'pause' | 'warn' | 'modify' | 'penalize' | 'reward' | 'neutral';
739
- /** Which intent patterns matched (if any) */
740
- matchedPatterns: string[];
741
- /** Whether the guard was skipped due to role gating */
742
- roleGated: boolean;
743
- }
744
- /**
745
- * Kernel rule evaluation result.
746
- */
747
- interface KernelRuleCheck {
748
- ruleId: string;
749
- text: string;
750
- category: 'allowed' | 'forbidden';
751
- matched: boolean;
752
- /** How the match was performed */
753
- matchMethod: 'pattern' | 'keyword' | 'none';
754
- }
755
- /**
756
- * Level constraint check result.
757
- */
758
- interface LevelCheck {
759
- checkType: 'delete' | 'write-external' | 'network-mutate' | 'credential-access' | 'irreversible';
760
- level: string;
761
- triggered: boolean;
762
- reason?: string;
763
- }
764
- /**
765
- * How the engine resolved precedence to produce the final verdict.
766
- */
767
- interface PrecedenceResolution {
768
- /** Which check category produced the final verdict */
769
- decidingLayer: 'session-allowlist' | 'safety' | 'plan-enforcement' | 'role' | 'guard' | 'kernel-rule' | 'level-constraint' | 'default-allow';
770
- /** Specific ID of the deciding check (guard ID, rule ID, etc.) */
771
- decidingId?: string;
772
- /** Resolution strategy used */
773
- strategy: 'first-match-wins';
774
- /** The full evaluation chain in order */
775
- chainOrder: string[];
776
- }
777
- /**
778
- * Options for the guard engine evaluation.
779
- */
780
- interface GuardEngineOptions {
781
- /** Include full evaluation trace in verdict. Default: false. */
782
- trace?: boolean;
783
- /** Enforcement level override. If not set, uses world default or 'standard'. */
784
- level?: 'basic' | 'standard' | 'strict';
785
- /**
786
- * Session allowlist — set of pre-approved event keys.
787
- * Use `eventToAllowlistKey(event)` to build keys.
788
- *
789
- * If the event's key is in this set, the engine returns ALLOW
790
- * immediately (before safety checks).
791
- *
792
- * The engine reads but never mutates this set.
793
- * The caller owns persistence (allow-once, allow-always, etc.).
794
- */
795
- sessionAllowlist?: Set<string>;
796
- /**
797
- * Active plan overlay — temporary task-scoped governance.
798
- * When set, plan enforcement runs at Phase 1.5 (after safety, before roles).
799
- * Plans can only restrict, never expand.
800
- */
801
- plan?: PlanDefinition;
802
- /**
803
- * Agent behavior states — tracks cooldowns, influence, rewards per agent.
804
- * The engine reads this to check if an agent is penalized (frozen).
805
- * The caller owns mutation (applying consequences/rewards after verdict).
806
- */
807
- agentStates?: Map<string, AgentBehaviorState>;
808
- }
809
- declare const GUARD_EXIT_CODES: {
810
- readonly ALLOW: 0;
811
- readonly BLOCK: 1;
812
- readonly PAUSE: 2;
813
- readonly ERROR: 3;
814
- readonly MODIFY: 4;
815
- readonly PENALIZE: 5;
816
- readonly REWARD: 6;
817
- readonly NEUTRAL: 7;
818
- };
819
- type GuardExitCode = (typeof GUARD_EXIT_CODES)[keyof typeof GUARD_EXIT_CODES];
820
-
821
- 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 ViabilityStatus as V, type WorldDefinition as W, type GuardVerdict as a, type GuardEngineOptions as b, type PlanProgress as c, type PlanVerdict as d, type PlanCheck as e, type AgentBehaviorState as f, type GuardStatus 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, type VerdictEvidence as u };