@neuroverseos/governance 0.2.2 → 0.2.3

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 (91) hide show
  1. package/.well-known/ai-plugin.json +26 -0
  2. package/.well-known/mcp.json +68 -0
  3. package/AGENTS.md +219 -0
  4. package/README.md +84 -4
  5. package/dist/adapters/autoresearch.cjs +196 -0
  6. package/dist/adapters/autoresearch.d.cts +103 -0
  7. package/dist/adapters/autoresearch.d.ts +103 -0
  8. package/dist/adapters/autoresearch.js +7 -0
  9. package/dist/adapters/deep-agents.cjs +1472 -0
  10. package/dist/adapters/deep-agents.d.cts +181 -0
  11. package/dist/adapters/deep-agents.d.ts +181 -0
  12. package/dist/adapters/deep-agents.js +17 -0
  13. package/dist/adapters/express.cjs +103 -21
  14. package/dist/adapters/express.d.cts +1 -1
  15. package/dist/adapters/express.d.ts +1 -1
  16. package/dist/adapters/express.js +3 -3
  17. package/dist/adapters/index.cjs +649 -109
  18. package/dist/adapters/index.d.cts +4 -1
  19. package/dist/adapters/index.d.ts +4 -1
  20. package/dist/adapters/index.js +39 -13
  21. package/dist/adapters/langchain.cjs +152 -48
  22. package/dist/adapters/langchain.d.cts +5 -5
  23. package/dist/adapters/langchain.d.ts +5 -5
  24. package/dist/adapters/langchain.js +4 -3
  25. package/dist/adapters/openai.cjs +154 -50
  26. package/dist/adapters/openai.d.cts +5 -5
  27. package/dist/adapters/openai.d.ts +5 -5
  28. package/dist/adapters/openai.js +4 -3
  29. package/dist/adapters/openclaw.cjs +152 -48
  30. package/dist/adapters/openclaw.d.cts +5 -5
  31. package/dist/adapters/openclaw.d.ts +5 -5
  32. package/dist/adapters/openclaw.js +4 -3
  33. package/dist/{build-P42YFKQV.js → build-X5MZY4IA.js} +2 -2
  34. package/dist/{chunk-2NICNKOM.js → chunk-4L6OPKMQ.js} +1 -1
  35. package/dist/chunk-5U2MQO5P.js +57 -0
  36. package/dist/{chunk-SKU3GAPD.js → chunk-6BB55YJI.js} +16 -34
  37. package/dist/{chunk-KEST3MWO.js → chunk-AF2VX4AL.js} +47 -8
  38. package/dist/chunk-BQZMOEML.js +43 -0
  39. package/dist/chunk-D2UCV5AK.js +326 -0
  40. package/dist/{chunk-RWXVAH6P.js → chunk-EVDJUSZ2.js} +16 -34
  41. package/dist/{chunk-4JRYGIO7.js → chunk-IZSO75NZ.js} +72 -7
  42. package/dist/chunk-JCKSW2PZ.js +304 -0
  43. package/dist/{chunk-PDOZHZWL.js → chunk-KTFTTLTP.js} +25 -4
  44. package/dist/{chunk-MWDQ4MJB.js → chunk-MH7BT4VH.js} +5 -1
  45. package/dist/{chunk-4QXB6PEO.js → chunk-QLPTHTVB.js} +37 -16
  46. package/dist/{chunk-QPASI2BR.js → chunk-REXY4LUL.js} +49 -10
  47. package/dist/chunk-T5EUJQE5.js +172 -0
  48. package/dist/{chunk-DPVS43ZT.js → chunk-TTBKTF3P.js} +5 -5
  49. package/dist/{chunk-OHAC6HJE.js → chunk-ZIVQNSZU.js} +16 -36
  50. package/dist/{chunk-BUWWN2NX.js → chunk-ZJTDUCC2.js} +9 -7
  51. package/dist/cli/neuroverse.cjs +2582 -493
  52. package/dist/cli/neuroverse.js +39 -15
  53. package/dist/cli/plan.cjs +119 -32
  54. package/dist/cli/plan.js +5 -13
  55. package/dist/cli/run.cjs +223 -24
  56. package/dist/cli/run.js +2 -2
  57. package/dist/decision-flow-LETV5NWY.js +61 -0
  58. package/dist/{derive-TLIV4OOU.js → derive-7365SUFU.js} +2 -2
  59. package/dist/{doctor-QV6HELS5.js → doctor-QYISMKEL.js} +5 -2
  60. package/dist/equity-penalties-63FGB3I2.js +244 -0
  61. package/dist/{explain-IDCRWMPX.js → explain-A2EWI2OL.js} +4 -23
  62. package/dist/{guard-GFLQZY6U.js → guard-3BWL3IGH.js} +6 -10
  63. package/dist/{guard-contract-Cm91Kp4j.d.ts → guard-contract-C9_zKbzd.d.cts} +117 -5
  64. package/dist/{guard-contract-Cm91Kp4j.d.cts → guard-contract-C9_zKbzd.d.ts} +117 -5
  65. package/dist/{guard-engine-JLTUARGU.js → guard-engine-QFMIBWJY.js} +2 -2
  66. package/dist/{impact-XPECYRLH.js → impact-UB6DXKSX.js} +4 -4
  67. package/dist/{improve-GPUBKTEA.js → improve-XZA57GER.js} +5 -24
  68. package/dist/index.cjs +592 -44
  69. package/dist/index.d.cts +218 -5
  70. package/dist/index.d.ts +218 -5
  71. package/dist/index.js +92 -41
  72. package/dist/infer-world-7GVZWFX4.js +543 -0
  73. package/dist/init-world-VWMQZQC7.js +223 -0
  74. package/dist/{mcp-server-LZVJHBT5.js → mcp-server-XWQZXNW7.js} +3 -3
  75. package/dist/{playground-FGOMASHN.js → playground-ADWZORNV.js} +2 -2
  76. package/dist/{redteam-SK7AMIG3.js → redteam-JRQ7FD2F.js} +2 -2
  77. package/dist/{session-VISISNWJ.js → session-MMYX5YCF.js} +4 -3
  78. package/dist/shared--Q8wPBVN.d.ts +60 -0
  79. package/dist/shared-HpAG90PX.d.cts +60 -0
  80. package/dist/shared-U2QFV7JH.js +16 -0
  81. package/dist/{simulate-VDOYQFRO.js → simulate-GMIFFXYV.js} +5 -30
  82. package/dist/{test-75AVHC3R.js → test-JBBZ65X4.js} +2 -2
  83. package/dist/{trace-JVF67VR3.js → trace-3MYWIDEF.js} +3 -3
  84. package/dist/worlds/autoresearch.nv-world.md +230 -0
  85. package/dist/worlds/coding-agent.nv-world.md +211 -0
  86. package/llms.txt +79 -0
  87. package/openapi.yaml +230 -0
  88. package/package.json +26 -4
  89. package/dist/{chunk-GR6DGCZ2.js → chunk-BMOXICAB.js} +3 -3
  90. package/dist/{chunk-NF5POFCI.js → chunk-ORJ3NOE6.js} +3 -3
  91. package/dist/{world-LAXO6DOX.js → world-BFJCIQSH.js} +3 -3
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as GuardEvent, W as WorldDefinition, c as GuardEngineOptions, G as GuardVerdict, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, d as PlanVerdict, e as PlanCheck, b as PlanProgress, V as ViabilityStatus } from './guard-contract-Cm91Kp4j.cjs';
2
- export { E as EvaluationTrace, f as GUARD_EXIT_CODES, g as GuardCheck, h as GuardExitCode, i as GuardStatus, I as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, j as PLAN_EXIT_CODES, k as PlanCompletionMode, l as PlanConstraint, m as PlanExitCode, n as PlanStatus, o as PlanStep, p as PrecedenceResolution, R as RoleCheck, q as SafetyCheck, r as VerdictEvidence } from './guard-contract-Cm91Kp4j.cjs';
1
+ import { G as GuardEvent, W as WorldDefinition, b as GuardEngineOptions, a as GuardVerdict, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, d as PlanVerdict, e as PlanCheck, c as PlanProgress, f as AgentBehaviorState, g as GuardStatus, C as Consequence, R as Reward, V as ViabilityStatus } from './guard-contract-C9_zKbzd.cjs';
2
+ export { E as EvaluationTrace, h as GUARD_EXIT_CODES, i as GuardCheck, j as GuardExitCode, I as IntentRecord, k as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, l as PLAN_EXIT_CODES, m as PlanCompletionMode, n as PlanConstraint, o as PlanExitCode, p as PlanStatus, q as PlanStep, r as PrecedenceResolution, s as RoleCheck, t as SafetyCheck, u as VerdictEvidence } from './guard-contract-C9_zKbzd.cjs';
3
3
 
4
4
  /**
5
5
  * Guard Engine — Deterministic Governance Evaluator
@@ -291,6 +291,14 @@ interface SessionState {
291
291
  actionsBlocked: number;
292
292
  /** Total actions paused. */
293
293
  actionsPaused: number;
294
+ /** Total actions modified. */
295
+ actionsModified: number;
296
+ /** Total actions penalized. */
297
+ actionsPenalized: number;
298
+ /** Total actions rewarded. */
299
+ actionsRewarded: number;
300
+ /** Agent behavior states — tracks cooldowns, influence, rewards per agent. */
301
+ agentStates: Map<string, AgentBehaviorState>;
294
302
  }
295
303
  declare class SessionManager {
296
304
  private config;
@@ -307,6 +315,15 @@ declare class SessionManager {
307
315
  * Returns the verdict without executing anything.
308
316
  */
309
317
  evaluate(event: GuardEvent): GuardVerdict;
318
+ /**
319
+ * Advance all agent states by one round.
320
+ * Call this at the end of each simulation round to decrement cooldowns.
321
+ */
322
+ tickRound(): void;
323
+ /**
324
+ * Get the behavior state for a specific agent.
325
+ */
326
+ getAgentState(agentId: string): AgentBehaviorState | undefined;
310
327
  /**
311
328
  * Evaluate and execute a tool call.
312
329
  * Returns the execution result or block reason.
@@ -458,10 +475,27 @@ interface AuditEvent {
458
475
  actor?: string;
459
476
  direction?: 'input' | 'output';
460
477
  /** The governance decision */
461
- decision: 'ALLOW' | 'BLOCK' | 'PAUSE';
478
+ decision: 'ALLOW' | 'BLOCK' | 'PAUSE' | 'MODIFY' | 'PENALIZE' | 'REWARD' | 'NEUTRAL';
462
479
  reason?: string;
463
480
  ruleId?: string;
464
481
  warning?: string;
482
+ /** Consequence applied (for PENALIZE decisions) */
483
+ consequence?: {
484
+ type: string;
485
+ rounds?: number;
486
+ magnitude?: number;
487
+ description: string;
488
+ };
489
+ /** Reward applied (for REWARD decisions) */
490
+ reward?: {
491
+ type: string;
492
+ rounds?: number;
493
+ magnitude?: number;
494
+ description: string;
495
+ };
496
+ /** Intent tracking — original vs final action */
497
+ originalIntent?: string;
498
+ finalAction?: string;
465
499
  /** Which rules/guards matched */
466
500
  guardsMatched: string[];
467
501
  rulesMatched: string[];
@@ -483,6 +517,10 @@ interface AuditSummary {
483
517
  allowed: number;
484
518
  blocked: number;
485
519
  paused: number;
520
+ modified: number;
521
+ penalized: number;
522
+ rewarded: number;
523
+ neutral: number;
486
524
  /** Unique actors seen */
487
525
  actors: string[];
488
526
  /** Actions grouped by intent */
@@ -491,6 +529,8 @@ interface AuditSummary {
491
529
  count: number;
492
530
  blocked: number;
493
531
  paused: number;
532
+ penalized: number;
533
+ rewarded: number;
494
534
  }[];
495
535
  /** Most frequently triggered rules */
496
536
  topRules: {
@@ -500,6 +540,13 @@ interface AuditSummary {
500
540
  /** Time range */
501
541
  firstEvent: string;
502
542
  lastEvent: string;
543
+ /** Behavioral economy summary */
544
+ behavioralEconomy: {
545
+ totalPenalties: number;
546
+ totalRewards: number;
547
+ netPressure: number;
548
+ redirectionRate: number;
549
+ };
503
550
  }
504
551
  /**
505
552
  * Pluggable audit logger interface.
@@ -667,8 +714,14 @@ interface ImpactReport {
667
714
  totalBlocked: number;
668
715
  totalPaused: number;
669
716
  totalAllowed: number;
670
- /** Prevention rate: (blocked + paused) / total */
717
+ totalModified: number;
718
+ totalPenalized: number;
719
+ totalRewarded: number;
720
+ totalNeutral: number;
721
+ /** Prevention rate: (blocked + paused + modified + penalized) / total */
671
722
  preventionRate: number;
723
+ /** Redirection rate: everything not ALLOW/NEUTRAL */
724
+ redirectionRate: number;
672
725
  /** Blocked actions grouped by category */
673
726
  preventedByCategory: PreventionCategory[];
674
727
  /** Top prevented intents */
@@ -724,6 +777,166 @@ declare function renderImpactReport(report: ImpactReport): string;
724
777
  */
725
778
  declare function generateImpactReportFromFile(logPath: string): Promise<ImpactReport>;
726
779
 
780
+ /**
781
+ * Decision Flow Engine — Intent → Rule → Outcome Visualization
782
+ *
783
+ * This is the core of the behavioral governance visualization.
784
+ * It transforms audit events into a flow structure that shows:
785
+ *
786
+ * LEFT (Intent Pool) → CENTER (Rules) → RIGHT (Outcome Pool)
787
+ * What agents wanted What intercepted What actually happened
788
+ *
789
+ * The gap between intent and outcome = governance value.
790
+ *
791
+ * Key metric: "X% of agent intent was redirected by governance"
792
+ *
793
+ * INVARIANTS:
794
+ * - Pure function: audit events in, flow structure out.
795
+ * - No speculation — only reports on actual evaluated actions.
796
+ * - Every flow path is traceable to a specific audit event.
797
+ */
798
+
799
+ /**
800
+ * A cluster of agents with the same intent.
801
+ */
802
+ interface IntentCluster {
803
+ /** The original intent (e.g., "sell", "publish", "attack") */
804
+ intent: string;
805
+ /** Number of agents with this intent */
806
+ agentCount: number;
807
+ /** Intensity score (0-1) based on volume and risk */
808
+ intensity: number;
809
+ /** Individual agent IDs in this cluster */
810
+ agents: string[];
811
+ }
812
+ /**
813
+ * A rule that intercepted actions in the flow.
814
+ */
815
+ interface RuleObstacle {
816
+ /** Rule/guard ID */
817
+ ruleId: string;
818
+ /** Human-readable label */
819
+ label: string;
820
+ /** How many actions this rule intercepted */
821
+ interceptCount: number;
822
+ /** Breakdown by enforcement type */
823
+ enforcements: {
824
+ blocked: number;
825
+ modified: number;
826
+ penalized: number;
827
+ paused: number;
828
+ rewarded: number;
829
+ };
830
+ }
831
+ /**
832
+ * An outcome cluster — what agents ended up doing.
833
+ */
834
+ interface OutcomeCluster {
835
+ /** The enforcement type that produced this outcome */
836
+ enforcement: GuardStatus;
837
+ /** Number of agents with this outcome */
838
+ agentCount: number;
839
+ /** For MODIFY: what they were changed to */
840
+ modifiedTo?: string;
841
+ /** Agent IDs in this cluster */
842
+ agents: string[];
843
+ /** Visual style hint */
844
+ style: 'green' | 'yellow' | 'red' | 'gray' | 'blue' | 'white';
845
+ }
846
+ /**
847
+ * A single flow path from intent → rule → outcome.
848
+ */
849
+ interface FlowPath {
850
+ /** Source intent */
851
+ intent: string;
852
+ /** Rule that intercepted (if any) */
853
+ ruleId?: string;
854
+ /** Resulting enforcement */
855
+ enforcement: GuardStatus;
856
+ /** Agent ID */
857
+ agentId: string;
858
+ /** Original action */
859
+ originalAction: string;
860
+ /** Final action */
861
+ finalAction: string;
862
+ /** Consequence applied (if PENALIZE) */
863
+ consequence?: Consequence;
864
+ /** Reward applied (if REWARD) */
865
+ reward?: Reward;
866
+ }
867
+ /**
868
+ * The complete Decision Flow — the visualization data structure.
869
+ *
870
+ * LEFT → CENTER → RIGHT
871
+ * Intents → Rules → Outcomes
872
+ */
873
+ interface DecisionFlow {
874
+ /** Left column: intent clusters */
875
+ intents: IntentCluster[];
876
+ /** Center column: rule obstacles */
877
+ rules: RuleObstacle[];
878
+ /** Right column: outcome clusters */
879
+ outcomes: OutcomeCluster[];
880
+ /** Every individual flow path */
881
+ paths: FlowPath[];
882
+ /** Key metrics */
883
+ metrics: DecisionFlowMetrics;
884
+ /** Time window */
885
+ periodStart: string;
886
+ periodEnd: string;
887
+ worldName: string;
888
+ }
889
+ /**
890
+ * The headline metrics for the Decision Flow.
891
+ */
892
+ interface DecisionFlowMetrics {
893
+ /** Total intents evaluated */
894
+ totalIntents: number;
895
+ /** How many were redirected (not ALLOW) */
896
+ totalRedirected: number;
897
+ /** Headline: "X% of agent intent was redirected by governance" */
898
+ redirectionRate: number;
899
+ /** Breakdown by enforcement type */
900
+ byEnforcement: Record<string, number>;
901
+ /** Total penalties applied */
902
+ totalPenalties: number;
903
+ /** Total rewards applied */
904
+ totalRewards: number;
905
+ /** Net behavioral pressure (rewards - penalties) */
906
+ netBehavioralPressure: number;
907
+ }
908
+ /**
909
+ * Generate a Decision Flow from audit events.
910
+ *
911
+ * This is the primary entry point — takes raw audit data and produces
912
+ * the complete visualization structure.
913
+ */
914
+ declare function generateDecisionFlow(events: AuditEvent[]): DecisionFlow;
915
+ /**
916
+ * Create a fresh agent behavior state.
917
+ */
918
+ declare function createAgentState(agentId: string): AgentBehaviorState;
919
+ /**
920
+ * Apply a consequence to an agent's behavior state.
921
+ * Returns the updated state (immutable — creates a new object).
922
+ */
923
+ declare function applyConsequence(state: AgentBehaviorState, consequence: Consequence, ruleId: string): AgentBehaviorState;
924
+ /**
925
+ * Apply a reward to an agent's behavior state.
926
+ * Returns the updated state (immutable).
927
+ */
928
+ declare function applyReward(state: AgentBehaviorState, reward: Reward, ruleId: string): AgentBehaviorState;
929
+ /**
930
+ * Advance all agent states by one round.
931
+ * Decrements cooldowns, applies time-based effects.
932
+ */
933
+ declare function tickAgentStates(states: Map<string, AgentBehaviorState>): Map<string, AgentBehaviorState>;
934
+ /**
935
+ * Render a Decision Flow as human-readable text.
936
+ * This is what `neuroverse decision-flow` prints.
937
+ */
938
+ declare function renderDecisionFlow(flow: DecisionFlow): string;
939
+
727
940
  /**
728
941
  * World Loader — Shared world file loading for CLI commands
729
942
  *
@@ -1613,4 +1826,4 @@ interface ImprovementReport {
1613
1826
  declare function improveWorld(world: WorldDefinition): ImprovementReport;
1614
1827
  declare function renderImproveText(report: ImprovementReport): string;
1615
1828
 
1616
- export { type AIProvider, type AIProviderConfig, AdvanceResult, type AppliedEffect, type AuditEvent, type AuditLogger, type AuditSummary, BOOTSTRAP_EXIT_CODES, type BootstrapExitCode, type BootstrapResult, CONFIGURE_AI_EXIT_CODES, type ChatMessage, type CollectedSource, CompositeAuditLogger, type Condition, type ConditionOperator, type ConditionResult, ConsoleAuditLogger, DERIVE_EXIT_CODES, type DeriveExitCode, type DeriveFinding, type DeriveResult, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FormatVerdictOptions, type GovernanceEngineOptions, type GovernanceHealth, GuardEngineOptions, GuardEvent, GuardVerdict, type ImpactReport, type ImprovementReport, McpGovernanceServer, type McpServerConfig, ModelAdapter, type ModelConfig, type ModelResponse, type NormalizationSummary, PROVIDERS, type ParseIssue, type ParsedAssumptionProfile, type ParsedEffect, type ParsedFrontmatter, type ParsedGate, type ParsedInvariant, type ParsedOutcome, type ParsedRule, type ParsedStateVariable, type ParsedTrigger, type ParsedWorld, PlanCheck, PlanDefinition, type PlanParseResult, PlanProgress, PlanVerdict, type PreventionCategory, type ProviderPreset, type RuleEvaluation, type SessionConfig, SessionManager, type SessionState, type SimulateOptions, type SimulationResult, type SimulationStep, StepEvidence, type Suggestion, type SuggestionCategory, type SuggestionPriority, type ToolCall, type ToolDefinition, VALIDATE_EXIT_CODES, type ValidateExitCode, type ValidateFinding, type ValidateReport, type ValidateSummary, type ValidationMode, type WorldInfo, advancePlan, buildPlanCheck, createGovernanceEngine, deriveWorld, describeActiveWorld, emitWorldDefinition, evaluateCondition, evaluateGuard, evaluatePlan, eventToAllowlistKey, explainWorld, extractWorldMarkdown, formatVerdict, formatVerdictOneLine, generateImpactReport, generateImpactReportFromFile, getActiveWorldName, getPlanProgress, improveWorld, listWorlds, loadWorld, loadWorldFromDirectory, normalizeWorldMarkdown, parsePlanMarkdown, parseWorldMarkdown, readAuditLog, renderExplainText, renderImpactReport, renderImproveText, renderSimulateText, resolveProvider, resolveWorldPath, runInteractiveMode, runPipeMode, setActiveWorld, simulateWorld, summarizeAuditEvents, validateWorld, verdictToAuditEvent };
1829
+ export { type AIProvider, type AIProviderConfig, AdvanceResult, AgentBehaviorState, type AppliedEffect, type AuditEvent, type AuditLogger, type AuditSummary, BOOTSTRAP_EXIT_CODES, type BootstrapExitCode, type BootstrapResult, CONFIGURE_AI_EXIT_CODES, type ChatMessage, type CollectedSource, CompositeAuditLogger, type Condition, type ConditionOperator, type ConditionResult, Consequence, ConsoleAuditLogger, DERIVE_EXIT_CODES, type DecisionFlow, type DecisionFlowMetrics, type DeriveExitCode, type DeriveFinding, type DeriveResult, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FlowPath, type FormatVerdictOptions, type GovernanceEngineOptions, type GovernanceHealth, GuardEngineOptions, GuardEvent, GuardStatus, GuardVerdict, type ImpactReport, type ImprovementReport, type IntentCluster, McpGovernanceServer, type McpServerConfig, ModelAdapter, type ModelConfig, type ModelResponse, type NormalizationSummary, type OutcomeCluster, PROVIDERS, type ParseIssue, type ParsedAssumptionProfile, type ParsedEffect, type ParsedFrontmatter, type ParsedGate, type ParsedInvariant, type ParsedOutcome, type ParsedRule, type ParsedStateVariable, type ParsedTrigger, type ParsedWorld, PlanCheck, PlanDefinition, type PlanParseResult, PlanProgress, PlanVerdict, type PreventionCategory, type ProviderPreset, Reward, type RuleEvaluation, type RuleObstacle, type SessionConfig, SessionManager, type SessionState, type SimulateOptions, type SimulationResult, type SimulationStep, StepEvidence, type Suggestion, type SuggestionCategory, type SuggestionPriority, type ToolCall, type ToolDefinition, VALIDATE_EXIT_CODES, type ValidateExitCode, type ValidateFinding, type ValidateReport, type ValidateSummary, type ValidationMode, type WorldInfo, advancePlan, applyConsequence, applyReward, buildPlanCheck, createAgentState, createGovernanceEngine, deriveWorld, describeActiveWorld, emitWorldDefinition, evaluateCondition, evaluateGuard, evaluatePlan, eventToAllowlistKey, explainWorld, extractWorldMarkdown, formatVerdict, formatVerdictOneLine, generateDecisionFlow, generateImpactReport, generateImpactReportFromFile, getActiveWorldName, getPlanProgress, improveWorld, listWorlds, loadWorld, loadWorldFromDirectory, normalizeWorldMarkdown, parsePlanMarkdown, parseWorldMarkdown, readAuditLog, renderDecisionFlow, renderExplainText, renderImpactReport, renderImproveText, renderSimulateText, resolveProvider, resolveWorldPath, runInteractiveMode, runPipeMode, setActiveWorld, simulateWorld, summarizeAuditEvents, tickAgentStates, validateWorld, verdictToAuditEvent };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as GuardEvent, W as WorldDefinition, c as GuardEngineOptions, G as GuardVerdict, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, d as PlanVerdict, e as PlanCheck, b as PlanProgress, V as ViabilityStatus } from './guard-contract-Cm91Kp4j.js';
2
- export { E as EvaluationTrace, f as GUARD_EXIT_CODES, g as GuardCheck, h as GuardExitCode, i as GuardStatus, I as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, j as PLAN_EXIT_CODES, k as PlanCompletionMode, l as PlanConstraint, m as PlanExitCode, n as PlanStatus, o as PlanStep, p as PrecedenceResolution, R as RoleCheck, q as SafetyCheck, r as VerdictEvidence } from './guard-contract-Cm91Kp4j.js';
1
+ import { G as GuardEvent, W as WorldDefinition, b as GuardEngineOptions, a as GuardVerdict, P as PlanDefinition, S as StepEvidence, A as AdvanceResult, d as PlanVerdict, e as PlanCheck, c as PlanProgress, f as AgentBehaviorState, g as GuardStatus, C as Consequence, R as Reward, V as ViabilityStatus } from './guard-contract-C9_zKbzd.js';
2
+ export { E as EvaluationTrace, h as GUARD_EXIT_CODES, i as GuardCheck, j as GuardExitCode, I as IntentRecord, k as InvariantCheck, K as KernelRuleCheck, L as LevelCheck, l as PLAN_EXIT_CODES, m as PlanCompletionMode, n as PlanConstraint, o as PlanExitCode, p as PlanStatus, q as PlanStep, r as PrecedenceResolution, s as RoleCheck, t as SafetyCheck, u as VerdictEvidence } from './guard-contract-C9_zKbzd.js';
3
3
 
4
4
  /**
5
5
  * Guard Engine — Deterministic Governance Evaluator
@@ -291,6 +291,14 @@ interface SessionState {
291
291
  actionsBlocked: number;
292
292
  /** Total actions paused. */
293
293
  actionsPaused: number;
294
+ /** Total actions modified. */
295
+ actionsModified: number;
296
+ /** Total actions penalized. */
297
+ actionsPenalized: number;
298
+ /** Total actions rewarded. */
299
+ actionsRewarded: number;
300
+ /** Agent behavior states — tracks cooldowns, influence, rewards per agent. */
301
+ agentStates: Map<string, AgentBehaviorState>;
294
302
  }
295
303
  declare class SessionManager {
296
304
  private config;
@@ -307,6 +315,15 @@ declare class SessionManager {
307
315
  * Returns the verdict without executing anything.
308
316
  */
309
317
  evaluate(event: GuardEvent): GuardVerdict;
318
+ /**
319
+ * Advance all agent states by one round.
320
+ * Call this at the end of each simulation round to decrement cooldowns.
321
+ */
322
+ tickRound(): void;
323
+ /**
324
+ * Get the behavior state for a specific agent.
325
+ */
326
+ getAgentState(agentId: string): AgentBehaviorState | undefined;
310
327
  /**
311
328
  * Evaluate and execute a tool call.
312
329
  * Returns the execution result or block reason.
@@ -458,10 +475,27 @@ interface AuditEvent {
458
475
  actor?: string;
459
476
  direction?: 'input' | 'output';
460
477
  /** The governance decision */
461
- decision: 'ALLOW' | 'BLOCK' | 'PAUSE';
478
+ decision: 'ALLOW' | 'BLOCK' | 'PAUSE' | 'MODIFY' | 'PENALIZE' | 'REWARD' | 'NEUTRAL';
462
479
  reason?: string;
463
480
  ruleId?: string;
464
481
  warning?: string;
482
+ /** Consequence applied (for PENALIZE decisions) */
483
+ consequence?: {
484
+ type: string;
485
+ rounds?: number;
486
+ magnitude?: number;
487
+ description: string;
488
+ };
489
+ /** Reward applied (for REWARD decisions) */
490
+ reward?: {
491
+ type: string;
492
+ rounds?: number;
493
+ magnitude?: number;
494
+ description: string;
495
+ };
496
+ /** Intent tracking — original vs final action */
497
+ originalIntent?: string;
498
+ finalAction?: string;
465
499
  /** Which rules/guards matched */
466
500
  guardsMatched: string[];
467
501
  rulesMatched: string[];
@@ -483,6 +517,10 @@ interface AuditSummary {
483
517
  allowed: number;
484
518
  blocked: number;
485
519
  paused: number;
520
+ modified: number;
521
+ penalized: number;
522
+ rewarded: number;
523
+ neutral: number;
486
524
  /** Unique actors seen */
487
525
  actors: string[];
488
526
  /** Actions grouped by intent */
@@ -491,6 +529,8 @@ interface AuditSummary {
491
529
  count: number;
492
530
  blocked: number;
493
531
  paused: number;
532
+ penalized: number;
533
+ rewarded: number;
494
534
  }[];
495
535
  /** Most frequently triggered rules */
496
536
  topRules: {
@@ -500,6 +540,13 @@ interface AuditSummary {
500
540
  /** Time range */
501
541
  firstEvent: string;
502
542
  lastEvent: string;
543
+ /** Behavioral economy summary */
544
+ behavioralEconomy: {
545
+ totalPenalties: number;
546
+ totalRewards: number;
547
+ netPressure: number;
548
+ redirectionRate: number;
549
+ };
503
550
  }
504
551
  /**
505
552
  * Pluggable audit logger interface.
@@ -667,8 +714,14 @@ interface ImpactReport {
667
714
  totalBlocked: number;
668
715
  totalPaused: number;
669
716
  totalAllowed: number;
670
- /** Prevention rate: (blocked + paused) / total */
717
+ totalModified: number;
718
+ totalPenalized: number;
719
+ totalRewarded: number;
720
+ totalNeutral: number;
721
+ /** Prevention rate: (blocked + paused + modified + penalized) / total */
671
722
  preventionRate: number;
723
+ /** Redirection rate: everything not ALLOW/NEUTRAL */
724
+ redirectionRate: number;
672
725
  /** Blocked actions grouped by category */
673
726
  preventedByCategory: PreventionCategory[];
674
727
  /** Top prevented intents */
@@ -724,6 +777,166 @@ declare function renderImpactReport(report: ImpactReport): string;
724
777
  */
725
778
  declare function generateImpactReportFromFile(logPath: string): Promise<ImpactReport>;
726
779
 
780
+ /**
781
+ * Decision Flow Engine — Intent → Rule → Outcome Visualization
782
+ *
783
+ * This is the core of the behavioral governance visualization.
784
+ * It transforms audit events into a flow structure that shows:
785
+ *
786
+ * LEFT (Intent Pool) → CENTER (Rules) → RIGHT (Outcome Pool)
787
+ * What agents wanted What intercepted What actually happened
788
+ *
789
+ * The gap between intent and outcome = governance value.
790
+ *
791
+ * Key metric: "X% of agent intent was redirected by governance"
792
+ *
793
+ * INVARIANTS:
794
+ * - Pure function: audit events in, flow structure out.
795
+ * - No speculation — only reports on actual evaluated actions.
796
+ * - Every flow path is traceable to a specific audit event.
797
+ */
798
+
799
+ /**
800
+ * A cluster of agents with the same intent.
801
+ */
802
+ interface IntentCluster {
803
+ /** The original intent (e.g., "sell", "publish", "attack") */
804
+ intent: string;
805
+ /** Number of agents with this intent */
806
+ agentCount: number;
807
+ /** Intensity score (0-1) based on volume and risk */
808
+ intensity: number;
809
+ /** Individual agent IDs in this cluster */
810
+ agents: string[];
811
+ }
812
+ /**
813
+ * A rule that intercepted actions in the flow.
814
+ */
815
+ interface RuleObstacle {
816
+ /** Rule/guard ID */
817
+ ruleId: string;
818
+ /** Human-readable label */
819
+ label: string;
820
+ /** How many actions this rule intercepted */
821
+ interceptCount: number;
822
+ /** Breakdown by enforcement type */
823
+ enforcements: {
824
+ blocked: number;
825
+ modified: number;
826
+ penalized: number;
827
+ paused: number;
828
+ rewarded: number;
829
+ };
830
+ }
831
+ /**
832
+ * An outcome cluster — what agents ended up doing.
833
+ */
834
+ interface OutcomeCluster {
835
+ /** The enforcement type that produced this outcome */
836
+ enforcement: GuardStatus;
837
+ /** Number of agents with this outcome */
838
+ agentCount: number;
839
+ /** For MODIFY: what they were changed to */
840
+ modifiedTo?: string;
841
+ /** Agent IDs in this cluster */
842
+ agents: string[];
843
+ /** Visual style hint */
844
+ style: 'green' | 'yellow' | 'red' | 'gray' | 'blue' | 'white';
845
+ }
846
+ /**
847
+ * A single flow path from intent → rule → outcome.
848
+ */
849
+ interface FlowPath {
850
+ /** Source intent */
851
+ intent: string;
852
+ /** Rule that intercepted (if any) */
853
+ ruleId?: string;
854
+ /** Resulting enforcement */
855
+ enforcement: GuardStatus;
856
+ /** Agent ID */
857
+ agentId: string;
858
+ /** Original action */
859
+ originalAction: string;
860
+ /** Final action */
861
+ finalAction: string;
862
+ /** Consequence applied (if PENALIZE) */
863
+ consequence?: Consequence;
864
+ /** Reward applied (if REWARD) */
865
+ reward?: Reward;
866
+ }
867
+ /**
868
+ * The complete Decision Flow — the visualization data structure.
869
+ *
870
+ * LEFT → CENTER → RIGHT
871
+ * Intents → Rules → Outcomes
872
+ */
873
+ interface DecisionFlow {
874
+ /** Left column: intent clusters */
875
+ intents: IntentCluster[];
876
+ /** Center column: rule obstacles */
877
+ rules: RuleObstacle[];
878
+ /** Right column: outcome clusters */
879
+ outcomes: OutcomeCluster[];
880
+ /** Every individual flow path */
881
+ paths: FlowPath[];
882
+ /** Key metrics */
883
+ metrics: DecisionFlowMetrics;
884
+ /** Time window */
885
+ periodStart: string;
886
+ periodEnd: string;
887
+ worldName: string;
888
+ }
889
+ /**
890
+ * The headline metrics for the Decision Flow.
891
+ */
892
+ interface DecisionFlowMetrics {
893
+ /** Total intents evaluated */
894
+ totalIntents: number;
895
+ /** How many were redirected (not ALLOW) */
896
+ totalRedirected: number;
897
+ /** Headline: "X% of agent intent was redirected by governance" */
898
+ redirectionRate: number;
899
+ /** Breakdown by enforcement type */
900
+ byEnforcement: Record<string, number>;
901
+ /** Total penalties applied */
902
+ totalPenalties: number;
903
+ /** Total rewards applied */
904
+ totalRewards: number;
905
+ /** Net behavioral pressure (rewards - penalties) */
906
+ netBehavioralPressure: number;
907
+ }
908
+ /**
909
+ * Generate a Decision Flow from audit events.
910
+ *
911
+ * This is the primary entry point — takes raw audit data and produces
912
+ * the complete visualization structure.
913
+ */
914
+ declare function generateDecisionFlow(events: AuditEvent[]): DecisionFlow;
915
+ /**
916
+ * Create a fresh agent behavior state.
917
+ */
918
+ declare function createAgentState(agentId: string): AgentBehaviorState;
919
+ /**
920
+ * Apply a consequence to an agent's behavior state.
921
+ * Returns the updated state (immutable — creates a new object).
922
+ */
923
+ declare function applyConsequence(state: AgentBehaviorState, consequence: Consequence, ruleId: string): AgentBehaviorState;
924
+ /**
925
+ * Apply a reward to an agent's behavior state.
926
+ * Returns the updated state (immutable).
927
+ */
928
+ declare function applyReward(state: AgentBehaviorState, reward: Reward, ruleId: string): AgentBehaviorState;
929
+ /**
930
+ * Advance all agent states by one round.
931
+ * Decrements cooldowns, applies time-based effects.
932
+ */
933
+ declare function tickAgentStates(states: Map<string, AgentBehaviorState>): Map<string, AgentBehaviorState>;
934
+ /**
935
+ * Render a Decision Flow as human-readable text.
936
+ * This is what `neuroverse decision-flow` prints.
937
+ */
938
+ declare function renderDecisionFlow(flow: DecisionFlow): string;
939
+
727
940
  /**
728
941
  * World Loader — Shared world file loading for CLI commands
729
942
  *
@@ -1613,4 +1826,4 @@ interface ImprovementReport {
1613
1826
  declare function improveWorld(world: WorldDefinition): ImprovementReport;
1614
1827
  declare function renderImproveText(report: ImprovementReport): string;
1615
1828
 
1616
- export { type AIProvider, type AIProviderConfig, AdvanceResult, type AppliedEffect, type AuditEvent, type AuditLogger, type AuditSummary, BOOTSTRAP_EXIT_CODES, type BootstrapExitCode, type BootstrapResult, CONFIGURE_AI_EXIT_CODES, type ChatMessage, type CollectedSource, CompositeAuditLogger, type Condition, type ConditionOperator, type ConditionResult, ConsoleAuditLogger, DERIVE_EXIT_CODES, type DeriveExitCode, type DeriveFinding, type DeriveResult, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FormatVerdictOptions, type GovernanceEngineOptions, type GovernanceHealth, GuardEngineOptions, GuardEvent, GuardVerdict, type ImpactReport, type ImprovementReport, McpGovernanceServer, type McpServerConfig, ModelAdapter, type ModelConfig, type ModelResponse, type NormalizationSummary, PROVIDERS, type ParseIssue, type ParsedAssumptionProfile, type ParsedEffect, type ParsedFrontmatter, type ParsedGate, type ParsedInvariant, type ParsedOutcome, type ParsedRule, type ParsedStateVariable, type ParsedTrigger, type ParsedWorld, PlanCheck, PlanDefinition, type PlanParseResult, PlanProgress, PlanVerdict, type PreventionCategory, type ProviderPreset, type RuleEvaluation, type SessionConfig, SessionManager, type SessionState, type SimulateOptions, type SimulationResult, type SimulationStep, StepEvidence, type Suggestion, type SuggestionCategory, type SuggestionPriority, type ToolCall, type ToolDefinition, VALIDATE_EXIT_CODES, type ValidateExitCode, type ValidateFinding, type ValidateReport, type ValidateSummary, type ValidationMode, type WorldInfo, advancePlan, buildPlanCheck, createGovernanceEngine, deriveWorld, describeActiveWorld, emitWorldDefinition, evaluateCondition, evaluateGuard, evaluatePlan, eventToAllowlistKey, explainWorld, extractWorldMarkdown, formatVerdict, formatVerdictOneLine, generateImpactReport, generateImpactReportFromFile, getActiveWorldName, getPlanProgress, improveWorld, listWorlds, loadWorld, loadWorldFromDirectory, normalizeWorldMarkdown, parsePlanMarkdown, parseWorldMarkdown, readAuditLog, renderExplainText, renderImpactReport, renderImproveText, renderSimulateText, resolveProvider, resolveWorldPath, runInteractiveMode, runPipeMode, setActiveWorld, simulateWorld, summarizeAuditEvents, validateWorld, verdictToAuditEvent };
1829
+ export { type AIProvider, type AIProviderConfig, AdvanceResult, AgentBehaviorState, type AppliedEffect, type AuditEvent, type AuditLogger, type AuditSummary, BOOTSTRAP_EXIT_CODES, type BootstrapExitCode, type BootstrapResult, CONFIGURE_AI_EXIT_CODES, type ChatMessage, type CollectedSource, CompositeAuditLogger, type Condition, type ConditionOperator, type ConditionResult, Consequence, ConsoleAuditLogger, DERIVE_EXIT_CODES, type DecisionFlow, type DecisionFlowMetrics, type DeriveExitCode, type DeriveFinding, type DeriveResult, type ExplainOutput, FileAuditLogger, type FindingCategory, type FindingSeverity, type FlowPath, type FormatVerdictOptions, type GovernanceEngineOptions, type GovernanceHealth, GuardEngineOptions, GuardEvent, GuardStatus, GuardVerdict, type ImpactReport, type ImprovementReport, type IntentCluster, McpGovernanceServer, type McpServerConfig, ModelAdapter, type ModelConfig, type ModelResponse, type NormalizationSummary, type OutcomeCluster, PROVIDERS, type ParseIssue, type ParsedAssumptionProfile, type ParsedEffect, type ParsedFrontmatter, type ParsedGate, type ParsedInvariant, type ParsedOutcome, type ParsedRule, type ParsedStateVariable, type ParsedTrigger, type ParsedWorld, PlanCheck, PlanDefinition, type PlanParseResult, PlanProgress, PlanVerdict, type PreventionCategory, type ProviderPreset, Reward, type RuleEvaluation, type RuleObstacle, type SessionConfig, SessionManager, type SessionState, type SimulateOptions, type SimulationResult, type SimulationStep, StepEvidence, type Suggestion, type SuggestionCategory, type SuggestionPriority, type ToolCall, type ToolDefinition, VALIDATE_EXIT_CODES, type ValidateExitCode, type ValidateFinding, type ValidateReport, type ValidateSummary, type ValidationMode, type WorldInfo, advancePlan, applyConsequence, applyReward, buildPlanCheck, createAgentState, createGovernanceEngine, deriveWorld, describeActiveWorld, emitWorldDefinition, evaluateCondition, evaluateGuard, evaluatePlan, eventToAllowlistKey, explainWorld, extractWorldMarkdown, formatVerdict, formatVerdictOneLine, generateDecisionFlow, generateImpactReport, generateImpactReportFromFile, getActiveWorldName, getPlanProgress, improveWorld, listWorlds, loadWorld, loadWorldFromDirectory, normalizeWorldMarkdown, parsePlanMarkdown, parseWorldMarkdown, readAuditLog, renderDecisionFlow, renderExplainText, renderImpactReport, renderImproveText, renderSimulateText, resolveProvider, resolveWorldPath, runInteractiveMode, runPipeMode, setActiveWorld, simulateWorld, summarizeAuditEvents, tickAgentStates, validateWorld, verdictToAuditEvent };