@neuroverseos/governance 0.1.6 → 0.2.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.
Files changed (82) hide show
  1. package/README.md +279 -423
  2. package/dist/adapters/express.cjs +242 -2
  3. package/dist/adapters/express.d.cts +1 -1
  4. package/dist/adapters/express.d.ts +1 -1
  5. package/dist/adapters/express.js +5 -3
  6. package/dist/adapters/index.cjs +337 -5
  7. package/dist/adapters/index.d.cts +1 -1
  8. package/dist/adapters/index.d.ts +1 -1
  9. package/dist/adapters/index.js +8 -6
  10. package/dist/adapters/langchain.cjs +297 -3
  11. package/dist/adapters/langchain.d.cts +8 -1
  12. package/dist/adapters/langchain.d.ts +8 -1
  13. package/dist/adapters/langchain.js +5 -3
  14. package/dist/adapters/openai.cjs +297 -3
  15. package/dist/adapters/openai.d.cts +8 -1
  16. package/dist/adapters/openai.d.ts +8 -1
  17. package/dist/adapters/openai.js +5 -3
  18. package/dist/adapters/openclaw.cjs +297 -3
  19. package/dist/adapters/openclaw.d.cts +8 -1
  20. package/dist/adapters/openclaw.d.ts +8 -1
  21. package/dist/adapters/openclaw.js +5 -3
  22. package/dist/{bootstrap-H4HHKQ5G.js → bootstrap-GXVDZNF7.js} +2 -1
  23. package/dist/{build-73KAVHEY.js → build-P42YFKQV.js} +34 -3
  24. package/dist/{chunk-Z2S2HIV5.js → chunk-2NICNKOM.js} +2 -2
  25. package/dist/{chunk-B4NF3OLW.js → chunk-4JRYGIO7.js} +56 -2
  26. package/dist/chunk-4QXB6PEO.js +232 -0
  27. package/dist/chunk-6CZSKEY5.js +164 -0
  28. package/dist/{chunk-O5OMJMIE.js → chunk-7P3S7MAY.js} +502 -2
  29. package/dist/chunk-A5W4GNQO.js +130 -0
  30. package/dist/chunk-AKW5YVCE.js +96 -0
  31. package/dist/chunk-DPVS43ZT.js +608 -0
  32. package/dist/{chunk-EIUHJXBB.js → chunk-GR6DGCZ2.js} +1 -1
  33. package/dist/chunk-KEST3MWO.js +324 -0
  34. package/dist/{chunk-D7BGWV2J.js → chunk-NF5POFCI.js} +5 -3
  35. package/dist/{chunk-FZQCRGUU.js → chunk-OHAC6HJE.js} +27 -3
  36. package/dist/chunk-OT6PXH54.js +61 -0
  37. package/dist/{chunk-ITJ3LCPG.js → chunk-PDOZHZWL.js} +1 -1
  38. package/dist/{chunk-T4X42QXC.js → chunk-Q6O7ZLO2.js} +0 -59
  39. package/dist/{chunk-FYPYZFV5.js → chunk-QPASI2BR.js} +1 -1
  40. package/dist/{chunk-EQXFOKH2.js → chunk-RWXVAH6P.js} +27 -3
  41. package/dist/{chunk-CROPZ75A.js → chunk-SKU3GAPD.js} +27 -3
  42. package/dist/chunk-YZFATT7X.js +9 -0
  43. package/dist/cli/neuroverse.cjs +5343 -732
  44. package/dist/cli/neuroverse.js +69 -13
  45. package/dist/cli/plan.cjs +1599 -0
  46. package/dist/cli/plan.d.cts +20 -0
  47. package/dist/cli/plan.d.ts +20 -0
  48. package/dist/cli/plan.js +361 -0
  49. package/dist/cli/run.cjs +1746 -0
  50. package/dist/cli/run.d.cts +20 -0
  51. package/dist/cli/run.d.ts +20 -0
  52. package/dist/cli/run.js +143 -0
  53. package/dist/{configure-ai-46JVG56I.js → configure-ai-TK67ZWZL.js} +5 -2
  54. package/dist/{derive-6NAEWLM5.js → derive-TLIV4OOU.js} +6 -4
  55. package/dist/doctor-QV6HELS5.js +170 -0
  56. package/dist/{explain-3B3VB6TL.js → explain-IDCRWMPX.js} +2 -1
  57. package/dist/{guard-67Y66P3I.js → guard-GFLQZY6U.js} +20 -6
  58. package/dist/{guard-contract-D_RQz9kt.d.ts → guard-contract-Cm91Kp4j.d.cts} +182 -2
  59. package/dist/{guard-contract-D_RQz9kt.d.cts → guard-contract-Cm91Kp4j.d.ts} +182 -2
  60. package/dist/guard-engine-JLTUARGU.js +10 -0
  61. package/dist/{impact-CHERK3O6.js → impact-XPECYRLH.js} +5 -3
  62. package/dist/{improve-YG6I6ERG.js → improve-GPUBKTEA.js} +4 -3
  63. package/dist/index.cjs +2135 -89
  64. package/dist/index.d.cts +481 -12
  65. package/dist/index.d.ts +481 -12
  66. package/dist/index.js +70 -20
  67. package/dist/{init-Z66T6TDI.js → init-PKPIYHYE.js} +2 -0
  68. package/dist/mcp-server-LZVJHBT5.js +13 -0
  69. package/dist/model-adapter-BB7G4MFI.js +11 -0
  70. package/dist/playground-FGOMASHN.js +550 -0
  71. package/dist/redteam-SK7AMIG3.js +357 -0
  72. package/dist/session-VISISNWJ.js +14 -0
  73. package/dist/{simulate-ETHHINZ4.js → simulate-VDOYQFRO.js} +2 -1
  74. package/dist/test-75AVHC3R.js +217 -0
  75. package/dist/{trace-3YODSSIP.js → trace-JVF67VR3.js} +4 -2
  76. package/dist/{validate-UVE6GKQU.js → validate-LLBWVPGV.js} +15 -6
  77. package/dist/validate-engine-UIABSIHD.js +7 -0
  78. package/dist/{world-WLNHL5XC.js → world-LAXO6DOX.js} +87 -7
  79. package/dist/world-loader-HMPTOEA2.js +9 -0
  80. package/package.json +19 -5
  81. package/dist/validate-engine-657D75OG.js +0 -6
  82. /package/dist/{chunk-M3TZFGHO.js → chunk-JZPQGIKR.js} +0 -0
@@ -271,6 +271,10 @@ interface IntentPattern {
271
271
  interface GuardsConfig {
272
272
  guards: Guard[];
273
273
  intent_vocabulary: Record<string, IntentPattern>;
274
+ /** All known action surfaces (e.g. "shell", "http", "db", "email", "deploy").
275
+ * When declared, the validator checks that every surface has at least one
276
+ * governing guard — surfaces without guards are reported as fail-open. */
277
+ tool_surfaces?: string[];
274
278
  }
275
279
  interface WorldDefinition {
276
280
  world: WorldIdentity;
@@ -287,6 +291,174 @@ interface WorldDefinition {
287
291
  metadata: WorldMetadata;
288
292
  }
289
293
 
294
+ /**
295
+ * Plan Contract — Plan Enforcement Types
296
+ *
297
+ * Defines the input/output contract for plan-based governance.
298
+ *
299
+ * Plans are temporary guard overlays — "mom's rules for this trip."
300
+ * They define what an agent should do (steps) and what it must not
301
+ * exceed (constraints). Plans layer on top of worlds, narrowing
302
+ * behavior without overriding safety or world-level governance.
303
+ *
304
+ * INVARIANTS:
305
+ * - Plans can only restrict, never expand. A plan cannot override a world BLOCK.
306
+ * - Plan enforcement is deterministic: same event + same plan → same verdict.
307
+ * - No AI in the evaluation loop. Parsing and evaluation are pure functions.
308
+ */
309
+ interface PlanStep {
310
+ /** Auto-generated slug from label (e.g., "write_announcement_blog_post"). */
311
+ id: string;
312
+ /** Human-readable step name. */
313
+ label: string;
314
+ /** Optional detail about the step. */
315
+ description?: string;
316
+ /** Restrict this step to specific tools (optional). */
317
+ tools?: string[];
318
+ /** Step IDs that must complete first (optional). */
319
+ requires?: string[];
320
+ /** Semantic tags for action mapping (e.g., ["deploy", "marketing"]). */
321
+ tags?: string[];
322
+ /** Completion condition name (optional). */
323
+ verify?: string;
324
+ /** Current step status. */
325
+ status: 'pending' | 'active' | 'completed' | 'skipped';
326
+ }
327
+ interface PlanConstraint {
328
+ /** Auto-generated constraint ID. */
329
+ id: string;
330
+ /** Constraint type. 'approval' always returns PAUSE until human confirms. */
331
+ type: 'budget' | 'time' | 'scope' | 'approval' | 'custom';
332
+ /** Human-readable description. */
333
+ description: string;
334
+ /** Enforcement mode. */
335
+ enforcement: 'block' | 'pause';
336
+ /** Numeric limit (for budget/time). */
337
+ limit?: number;
338
+ /** Unit for the limit (e.g., "USD", "minutes"). */
339
+ unit?: string;
340
+ /** Pattern that activates this constraint. */
341
+ trigger?: string;
342
+ }
343
+ /**
344
+ * How step completion is determined:
345
+ * - 'trust' — caller asserts completion, plan advances (default)
346
+ * - 'verified' — steps with a `verify` field require evidence to advance;
347
+ * steps without `verify` still advance on trust
348
+ */
349
+ type PlanCompletionMode = 'trust' | 'verified';
350
+ /**
351
+ * Evidence provided when advancing a step in verified mode.
352
+ * The verifier checks that evidence.type matches step.verify.
353
+ */
354
+ interface StepEvidence {
355
+ /** Evidence type — must match the step's `verify` field. */
356
+ type: string;
357
+ /** Proof payload (URL, hash, output snippet, etc.). */
358
+ proof: string;
359
+ /** When the evidence was produced. */
360
+ timestamp?: string;
361
+ }
362
+ /**
363
+ * Result of attempting to advance a step.
364
+ */
365
+ interface AdvanceResult {
366
+ /** Whether the step was successfully advanced. */
367
+ success: boolean;
368
+ /** Updated plan (if success). */
369
+ plan?: PlanDefinition;
370
+ /** Why advancement failed (if !success). */
371
+ reason?: string;
372
+ /** The evidence that was accepted (if verified mode). */
373
+ evidence?: StepEvidence;
374
+ }
375
+ interface PlanDefinition {
376
+ /** Unique plan identifier. */
377
+ plan_id: string;
378
+ /** Human-readable objective. */
379
+ objective: string;
380
+ /** Whether steps must run in order. */
381
+ sequential: boolean;
382
+ /**
383
+ * How step completion is determined.
384
+ * - 'trust' (default) — caller asserts "done", plan advances
385
+ * - 'verified' — steps with `verify` require evidence to advance
386
+ */
387
+ completion: PlanCompletionMode;
388
+ /** The steps in this plan. */
389
+ steps: PlanStep[];
390
+ /** Constraints that apply to this plan. */
391
+ constraints: PlanConstraint[];
392
+ /** Optional parent world ID. */
393
+ world_id?: string;
394
+ /** When this plan was created. */
395
+ created_at: string;
396
+ /** Optional expiry time. */
397
+ expires_at?: string;
398
+ }
399
+ type PlanStatus = 'ON_PLAN' | 'OFF_PLAN' | 'CONSTRAINT_VIOLATED' | 'PLAN_COMPLETE';
400
+ interface PlanVerdict {
401
+ /** Whether the action is allowed by this plan. */
402
+ allowed: boolean;
403
+ /** Plan verdict status. */
404
+ status: PlanStatus;
405
+ /** Why the action was blocked or paused. */
406
+ reason?: string;
407
+ /** Which step this action matched (if any). */
408
+ matchedStep?: string;
409
+ /** Nearest step when OFF_PLAN (for agent self-correction). */
410
+ closestStep?: string;
411
+ /** How close the action was to the nearest step (0-1). */
412
+ similarityScore?: number;
413
+ /** Current plan progress. */
414
+ progress: PlanProgress;
415
+ }
416
+ interface PlanProgress {
417
+ /** Number of completed steps. */
418
+ completed: number;
419
+ /** Total number of steps. */
420
+ total: number;
421
+ /** Completion percentage. */
422
+ percentage: number;
423
+ }
424
+ interface PlanCheck {
425
+ /** The plan being enforced. */
426
+ planId: string;
427
+ /** Whether the action matched a plan step. */
428
+ matched: boolean;
429
+ /** Which step was matched. */
430
+ matchedStepId?: string;
431
+ /** Label of the matched step. */
432
+ matchedStepLabel?: string;
433
+ /** Nearest step when no match (for self-correction). */
434
+ closestStepId?: string;
435
+ /** Label of the nearest step. */
436
+ closestStepLabel?: string;
437
+ /** Similarity score to the nearest step. */
438
+ similarityScore?: number;
439
+ /** Whether step sequence requirements are satisfied. */
440
+ sequenceValid?: boolean;
441
+ /** Results of constraint checks. */
442
+ constraintsChecked: Array<{
443
+ constraintId: string;
444
+ passed: boolean;
445
+ reason?: string;
446
+ }>;
447
+ /** Current progress. */
448
+ progress: {
449
+ completed: number;
450
+ total: number;
451
+ };
452
+ }
453
+ declare const PLAN_EXIT_CODES: {
454
+ readonly ON_PLAN: 0;
455
+ readonly OFF_PLAN: 1;
456
+ readonly CONSTRAINT_VIOLATED: 2;
457
+ readonly ERROR: 3;
458
+ readonly PLAN_COMPLETE: 4;
459
+ };
460
+ type PlanExitCode = (typeof PLAN_EXIT_CODES)[keyof typeof PLAN_EXIT_CODES];
461
+
290
462
  /**
291
463
  * Guard Contract — CLI Governance Evaluation Types
292
464
  *
@@ -406,6 +578,8 @@ interface EvaluationTrace {
406
578
  invariantChecks: InvariantCheck[];
407
579
  /** Safety checks (injection, scope escape) */
408
580
  safetyChecks: SafetyCheck[];
581
+ /** Plan enforcement check (Phase 1.5) — present when a plan is active */
582
+ planCheck?: PlanCheck;
409
583
  /** Every role rule checked */
410
584
  roleChecks: RoleCheck[];
411
585
  /** Every declarative guard checked */
@@ -490,7 +664,7 @@ interface LevelCheck {
490
664
  */
491
665
  interface PrecedenceResolution {
492
666
  /** Which check category produced the final verdict */
493
- decidingLayer: 'session-allowlist' | 'safety' | 'role' | 'guard' | 'kernel-rule' | 'level-constraint' | 'default-allow';
667
+ decidingLayer: 'session-allowlist' | 'safety' | 'plan-enforcement' | 'role' | 'guard' | 'kernel-rule' | 'level-constraint' | 'default-allow';
494
668
  /** Specific ID of the deciding check (guard ID, rule ID, etc.) */
495
669
  decidingId?: string;
496
670
  /** Resolution strategy used */
@@ -517,6 +691,12 @@ interface GuardEngineOptions {
517
691
  * The caller owns persistence (allow-once, allow-always, etc.).
518
692
  */
519
693
  sessionAllowlist?: Set<string>;
694
+ /**
695
+ * Active plan overlay — temporary task-scoped governance.
696
+ * When set, plan enforcement runs at Phase 1.5 (after safety, before roles).
697
+ * Plans can only restrict, never expand.
698
+ */
699
+ plan?: PlanDefinition;
520
700
  }
521
701
  declare const GUARD_EXIT_CODES: {
522
702
  readonly ALLOW: 0;
@@ -526,4 +706,4 @@ declare const GUARD_EXIT_CODES: {
526
706
  };
527
707
  type GuardExitCode = (typeof GUARD_EXIT_CODES)[keyof typeof GUARD_EXIT_CODES];
528
708
 
529
- export { type EvaluationTrace as E, type GuardVerdict as G, type InvariantCheck as I, type KernelRuleCheck as K, type LevelCheck as L, type PrecedenceResolution as P, type RoleCheck as R, type SafetyCheck as S, type ViabilityStatus as V, type WorldDefinition as W, type GuardEvent as a, type GuardEngineOptions as b, GUARD_EXIT_CODES as c, type GuardCheck as d, type GuardExitCode as e, type GuardStatus as f, type VerdictEvidence as g };
709
+ export { type AdvanceResult as A, type EvaluationTrace as E, type GuardVerdict as G, type InvariantCheck as I, type KernelRuleCheck as K, type LevelCheck as L, type PlanDefinition as P, type RoleCheck as R, type StepEvidence as S, type ViabilityStatus as V, type WorldDefinition as W, type GuardEvent as a, type PlanProgress as b, type GuardEngineOptions as c, type PlanVerdict as d, type PlanCheck as e, GUARD_EXIT_CODES as f, type GuardCheck as g, type GuardExitCode as h, type GuardStatus as i, PLAN_EXIT_CODES as j, type PlanCompletionMode as k, type PlanConstraint as l, type PlanExitCode as m, type PlanStatus as n, type PlanStep as o, type PrecedenceResolution as p, type SafetyCheck as q, type VerdictEvidence as r };
@@ -0,0 +1,10 @@
1
+ import {
2
+ evaluateGuard,
3
+ eventToAllowlistKey
4
+ } from "./chunk-4JRYGIO7.js";
5
+ import "./chunk-4QXB6PEO.js";
6
+ import "./chunk-YZFATT7X.js";
7
+ export {
8
+ evaluateGuard,
9
+ eventToAllowlistKey
10
+ };
@@ -1,11 +1,13 @@
1
1
  import {
2
2
  generateImpactReport,
3
3
  renderImpactReport
4
- } from "./chunk-ITJ3LCPG.js";
4
+ } from "./chunk-PDOZHZWL.js";
5
5
  import {
6
6
  readAuditLog
7
- } from "./chunk-FYPYZFV5.js";
8
- import "./chunk-B4NF3OLW.js";
7
+ } from "./chunk-QPASI2BR.js";
8
+ import "./chunk-4JRYGIO7.js";
9
+ import "./chunk-4QXB6PEO.js";
10
+ import "./chunk-YZFATT7X.js";
9
11
 
10
12
  // src/cli/impact.ts
11
13
  var USAGE = `
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  improveWorld,
3
3
  renderImproveText
4
- } from "./chunk-EIUHJXBB.js";
4
+ } from "./chunk-GR6DGCZ2.js";
5
5
  import "./chunk-FYS2CBUW.js";
6
+ import "./chunk-7P3S7MAY.js";
6
7
  import {
7
8
  loadWorld
8
- } from "./chunk-M3TZFGHO.js";
9
- import "./chunk-O5OMJMIE.js";
9
+ } from "./chunk-JZPQGIKR.js";
10
+ import "./chunk-YZFATT7X.js";
10
11
 
11
12
  // src/cli/improve.ts
12
13
  function parseArgs(argv) {