monomind 1.11.11 → 1.11.13

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 (227) hide show
  1. package/.claude/commands/mastermind/idea.md +1 -1
  2. package/.claude/commands/mastermind/master.md +1 -1
  3. package/.claude/skills/mastermind/_protocol.md +4 -4
  4. package/.claude/skills/mastermind/architect.md +7 -4
  5. package/.claude/skills/mastermind/autodev.md +4 -2
  6. package/.claude/skills/mastermind/build.md +3 -3
  7. package/.claude/skills/mastermind/content.md +3 -3
  8. package/.claude/skills/mastermind/createorg.md +2 -2
  9. package/.claude/skills/mastermind/finance.md +3 -3
  10. package/.claude/skills/mastermind/idea.md +8 -0
  11. package/.claude/skills/mastermind/marketing.md +3 -3
  12. package/.claude/skills/mastermind/ops.md +3 -3
  13. package/.claude/skills/mastermind/release.md +3 -3
  14. package/.claude/skills/mastermind/research.md +3 -3
  15. package/.claude/skills/mastermind/review.md +3 -3
  16. package/.claude/skills/mastermind/sales.md +3 -3
  17. package/package.json +1 -1
  18. package/packages/@monomind/cli/dist/src/index.js +19 -14
  19. package/packages/@monomind/cli/dist/src/init/statusline-generator.js +3 -3
  20. package/packages/@monomind/cli/dist/src/observability/replay-reader.d.ts +1 -1
  21. package/packages/@monomind/cli/dist/src/update/checker.js +24 -7
  22. package/packages/@monomind/cli/dist/src/update/index.d.ts +10 -0
  23. package/packages/@monomind/cli/dist/src/update/index.js +29 -2
  24. package/packages/@monomind/cli/package.json +1 -1
  25. package/packages/@monomind/cli/dist/src/agents/halt-signal.d.ts +0 -25
  26. package/packages/@monomind/cli/dist/src/agents/halt-signal.js +0 -76
  27. package/packages/@monomind/cli/dist/src/agents/index.d.ts +0 -18
  28. package/packages/@monomind/cli/dist/src/agents/index.js +0 -13
  29. package/packages/@monomind/cli/dist/src/agents/managed-agent.d.ts +0 -41
  30. package/packages/@monomind/cli/dist/src/agents/managed-agent.js +0 -69
  31. package/packages/@monomind/cli/dist/src/agents/prompt-experiment.d.ts +0 -23
  32. package/packages/@monomind/cli/dist/src/agents/prompt-experiment.js +0 -49
  33. package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.d.ts +0 -22
  34. package/packages/@monomind/cli/dist/src/agents/prompt-version-manager.js +0 -80
  35. package/packages/@monomind/cli/dist/src/agents/registry-query.d.ts +0 -71
  36. package/packages/@monomind/cli/dist/src/agents/registry-query.js +0 -125
  37. package/packages/@monomind/cli/dist/src/agents/score-decay.d.ts +0 -19
  38. package/packages/@monomind/cli/dist/src/agents/score-decay.js +0 -22
  39. package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.d.ts +0 -13
  40. package/packages/@monomind/cli/dist/src/agents/shared-instructions-loader.js +0 -40
  41. package/packages/@monomind/cli/dist/src/agents/specialization-scorer.d.ts +0 -54
  42. package/packages/@monomind/cli/dist/src/agents/specialization-scorer.js +0 -212
  43. package/packages/@monomind/cli/dist/src/agents/termination-watcher.d.ts +0 -30
  44. package/packages/@monomind/cli/dist/src/agents/termination-watcher.js +0 -84
  45. package/packages/@monomind/cli/dist/src/agents/trigger-index.d.ts +0 -20
  46. package/packages/@monomind/cli/dist/src/agents/trigger-index.js +0 -38
  47. package/packages/@monomind/cli/dist/src/agents/trigger-scanner.d.ts +0 -64
  48. package/packages/@monomind/cli/dist/src/agents/trigger-scanner.js +0 -308
  49. package/packages/@monomind/cli/dist/src/agents/version-diff.d.ts +0 -18
  50. package/packages/@monomind/cli/dist/src/agents/version-diff.js +0 -64
  51. package/packages/@monomind/cli/dist/src/agents/version-store.d.ts +0 -60
  52. package/packages/@monomind/cli/dist/src/agents/version-store.js +0 -235
  53. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +0 -45
  54. package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.js +0 -404
  55. package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +0 -14
  56. package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +0 -333
  57. package/packages/@monomind/cli/dist/src/commands/ui.js +0 -68
  58. package/packages/@monomind/cli/dist/src/consensus/index.d.ts +0 -7
  59. package/packages/@monomind/cli/dist/src/consensus/index.js +0 -6
  60. package/packages/@monomind/cli/dist/src/context/context-provider.d.ts +0 -44
  61. package/packages/@monomind/cli/dist/src/context/context-provider.js +0 -25
  62. package/packages/@monomind/cli/dist/src/context/git-state-provider.d.ts +0 -12
  63. package/packages/@monomind/cli/dist/src/context/git-state-provider.js +0 -34
  64. package/packages/@monomind/cli/dist/src/context/index.d.ts +0 -12
  65. package/packages/@monomind/cli/dist/src/context/index.js +0 -12
  66. package/packages/@monomind/cli/dist/src/context/project-conventions-provider.d.ts +0 -15
  67. package/packages/@monomind/cli/dist/src/context/project-conventions-provider.js +0 -19
  68. package/packages/@monomind/cli/dist/src/context/prompt-assembler.d.ts +0 -26
  69. package/packages/@monomind/cli/dist/src/context/prompt-assembler.js +0 -93
  70. package/packages/@monomind/cli/dist/src/context/task-history-provider.d.ts +0 -24
  71. package/packages/@monomind/cli/dist/src/context/task-history-provider.js +0 -32
  72. package/packages/@monomind/cli/dist/src/context/user-preferences-provider.d.ts +0 -14
  73. package/packages/@monomind/cli/dist/src/context/user-preferences-provider.js +0 -27
  74. package/packages/@monomind/cli/dist/src/dlq/dlq-reader.d.ts +0 -31
  75. package/packages/@monomind/cli/dist/src/dlq/dlq-reader.js +0 -81
  76. package/packages/@monomind/cli/dist/src/dlq/dlq-writer.d.ts +0 -24
  77. package/packages/@monomind/cli/dist/src/dlq/dlq-writer.js +0 -65
  78. package/packages/@monomind/cli/dist/src/dlq/index.d.ts +0 -10
  79. package/packages/@monomind/cli/dist/src/dlq/index.js +0 -7
  80. package/packages/@monomind/cli/dist/src/eval/dataset-manager.d.ts +0 -33
  81. package/packages/@monomind/cli/dist/src/eval/dataset-manager.js +0 -107
  82. package/packages/@monomind/cli/dist/src/eval/dataset-runner.d.ts +0 -23
  83. package/packages/@monomind/cli/dist/src/eval/dataset-runner.js +0 -59
  84. package/packages/@monomind/cli/dist/src/eval/index.d.ts +0 -10
  85. package/packages/@monomind/cli/dist/src/eval/index.js +0 -7
  86. package/packages/@monomind/cli/dist/src/eval/trace-collector.d.ts +0 -40
  87. package/packages/@monomind/cli/dist/src/eval/trace-collector.js +0 -102
  88. package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.d.ts +0 -68
  89. package/packages/@monomind/cli/dist/src/infrastructure/in-memory-repositories.js +0 -264
  90. package/packages/@monomind/cli/dist/src/interactive/interrupt.d.ts +0 -22
  91. package/packages/@monomind/cli/dist/src/interactive/interrupt.js +0 -71
  92. package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.d.ts +0 -25
  93. package/packages/@monomind/cli/dist/src/mcp/deprecation-injector.js +0 -48
  94. package/packages/@monomind/cli/dist/src/mcp/tool-registry.d.ts +0 -61
  95. package/packages/@monomind/cli/dist/src/mcp/tool-registry.js +0 -246
  96. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +0 -9
  97. package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +0 -230
  98. package/packages/@monomind/cli/dist/src/model/complexity-scorer.d.ts +0 -21
  99. package/packages/@monomind/cli/dist/src/model/complexity-scorer.js +0 -106
  100. package/packages/@monomind/cli/dist/src/model/index.d.ts +0 -4
  101. package/packages/@monomind/cli/dist/src/model/index.js +0 -4
  102. package/packages/@monomind/cli/dist/src/model/model-settings.d.ts +0 -22
  103. package/packages/@monomind/cli/dist/src/model/model-settings.js +0 -33
  104. package/packages/@monomind/cli/dist/src/model/model-tier-resolver.d.ts +0 -24
  105. package/packages/@monomind/cli/dist/src/model/model-tier-resolver.js +0 -65
  106. package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +0 -34
  107. package/packages/@monomind/cli/dist/src/monovector/capabilities.js +0 -37
  108. package/packages/@monomind/cli/dist/src/orchestration/index.d.ts +0 -7
  109. package/packages/@monomind/cli/dist/src/orchestration/index.js +0 -6
  110. package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.d.ts +0 -11
  111. package/packages/@monomind/cli/dist/src/orchestration/mode-dispatcher.js +0 -31
  112. package/packages/@monomind/cli/dist/src/orchestration/routing-modes.d.ts +0 -68
  113. package/packages/@monomind/cli/dist/src/orchestration/routing-modes.js +0 -180
  114. package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.d.ts +0 -7
  115. package/packages/@monomind/cli/dist/src/plugins/tests/demo-plugin-store.js +0 -126
  116. package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.d.ts +0 -12
  117. package/packages/@monomind/cli/dist/src/plugins/tests/standalone-test.js +0 -188
  118. package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.d.ts +0 -7
  119. package/packages/@monomind/cli/dist/src/plugins/tests/test-plugin-store.js +0 -206
  120. package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +0 -60
  121. package/packages/@monomind/cli/dist/src/runtime/headless.js +0 -284
  122. package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.d.ts +0 -50
  123. package/packages/@monomind/cli/dist/src/services/agentic-flow-bridge.js +0 -95
  124. package/packages/@monomind/cli/dist/src/services/container-worker-pool.d.ts +0 -197
  125. package/packages/@monomind/cli/dist/src/services/container-worker-pool.js +0 -623
  126. package/packages/@monomind/cli/dist/src/services/index.d.ts +0 -13
  127. package/packages/@monomind/cli/dist/src/services/index.js +0 -11
  128. package/packages/@monomind/cli/dist/src/services/worker-queue.d.ts +0 -201
  129. package/packages/@monomind/cli/dist/src/services/worker-queue.js +0 -594
  130. package/packages/@monomind/cli/dist/src/swarm/communication-graph.d.ts +0 -25
  131. package/packages/@monomind/cli/dist/src/swarm/communication-graph.js +0 -77
  132. package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.d.ts +0 -31
  133. package/packages/@monomind/cli/dist/src/swarm/flow-enforcer.js +0 -61
  134. package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.d.ts +0 -19
  135. package/packages/@monomind/cli/dist/src/swarm/flow-visualizer.js +0 -68
  136. package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.d.ts +0 -13
  137. package/packages/@monomind/cli/dist/src/transfer/deploy-seraphine.js +0 -205
  138. package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.d.ts +0 -12
  139. package/packages/@monomind/cli/dist/src/transfer/store/tests/standalone-test.js +0 -190
  140. package/packages/@monomind/cli/dist/src/transfer/test-seraphine.d.ts +0 -6
  141. package/packages/@monomind/cli/dist/src/transfer/test-seraphine.js +0 -105
  142. package/packages/@monomind/cli/dist/src/transfer/tests/test-store.d.ts +0 -7
  143. package/packages/@monomind/cli/dist/src/transfer/tests/test-store.js +0 -214
  144. package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.d.ts +0 -10
  145. package/packages/@monomind/cli/dist/src/workflow/condition-evaluator.js +0 -82
  146. package/packages/@monomind/cli/dist/src/workflow/context-resolver.d.ts +0 -12
  147. package/packages/@monomind/cli/dist/src/workflow/context-resolver.js +0 -23
  148. package/packages/@monomind/cli/dist/src/workflow/dag-builder.d.ts +0 -17
  149. package/packages/@monomind/cli/dist/src/workflow/dag-builder.js +0 -129
  150. package/packages/@monomind/cli/dist/src/workflow/dag-executor.d.ts +0 -9
  151. package/packages/@monomind/cli/dist/src/workflow/dag-executor.js +0 -116
  152. package/packages/@monomind/cli/dist/src/workflow/dag-types.d.ts +0 -41
  153. package/packages/@monomind/cli/dist/src/workflow/dag-types.js +0 -8
  154. package/packages/@monomind/cli/dist/src/workflow/dsl-parser.d.ts +0 -12
  155. package/packages/@monomind/cli/dist/src/workflow/dsl-parser.js +0 -20
  156. package/packages/@monomind/cli/dist/src/workflow/dsl-schema.d.ts +0 -165
  157. package/packages/@monomind/cli/dist/src/workflow/dsl-schema.js +0 -82
  158. package/packages/@monomind/cli/dist/src/workflow/index.d.ts +0 -13
  159. package/packages/@monomind/cli/dist/src/workflow/index.js +0 -11
  160. package/packages/@monomind/cli/dist/src/workflow/template-engine.d.ts +0 -11
  161. package/packages/@monomind/cli/dist/src/workflow/template-engine.js +0 -40
  162. package/packages/@monomind/cli/dist/src/workflow/workflow-executor.d.ts +0 -29
  163. package/packages/@monomind/cli/dist/src/workflow/workflow-executor.js +0 -227
  164. package/packages/@monomind/guidance/dist/adversarial.d.ts +0 -284
  165. package/packages/@monomind/guidance/dist/adversarial.js +0 -572
  166. package/packages/@monomind/guidance/dist/analyzer.d.ts +0 -530
  167. package/packages/@monomind/guidance/dist/analyzer.js +0 -2518
  168. package/packages/@monomind/guidance/dist/artifacts.d.ts +0 -283
  169. package/packages/@monomind/guidance/dist/artifacts.js +0 -356
  170. package/packages/@monomind/guidance/dist/authority.d.ts +0 -290
  171. package/packages/@monomind/guidance/dist/authority.js +0 -558
  172. package/packages/@monomind/guidance/dist/capabilities.d.ts +0 -209
  173. package/packages/@monomind/guidance/dist/capabilities.js +0 -485
  174. package/packages/@monomind/guidance/dist/coherence.d.ts +0 -233
  175. package/packages/@monomind/guidance/dist/coherence.js +0 -372
  176. package/packages/@monomind/guidance/dist/compiler.d.ts +0 -87
  177. package/packages/@monomind/guidance/dist/compiler.js +0 -419
  178. package/packages/@monomind/guidance/dist/conformance-kit.d.ts +0 -225
  179. package/packages/@monomind/guidance/dist/conformance-kit.js +0 -629
  180. package/packages/@monomind/guidance/dist/continue-gate.d.ts +0 -214
  181. package/packages/@monomind/guidance/dist/continue-gate.js +0 -353
  182. package/packages/@monomind/guidance/dist/crypto-utils.d.ts +0 -17
  183. package/packages/@monomind/guidance/dist/crypto-utils.js +0 -24
  184. package/packages/@monomind/guidance/dist/evolution.d.ts +0 -282
  185. package/packages/@monomind/guidance/dist/evolution.js +0 -500
  186. package/packages/@monomind/guidance/dist/gates.d.ts +0 -79
  187. package/packages/@monomind/guidance/dist/gates.js +0 -302
  188. package/packages/@monomind/guidance/dist/gateway.d.ts +0 -206
  189. package/packages/@monomind/guidance/dist/gateway.js +0 -452
  190. package/packages/@monomind/guidance/dist/generators.d.ts +0 -153
  191. package/packages/@monomind/guidance/dist/generators.js +0 -682
  192. package/packages/@monomind/guidance/dist/headless.d.ts +0 -177
  193. package/packages/@monomind/guidance/dist/headless.js +0 -342
  194. package/packages/@monomind/guidance/dist/hooks.d.ts +0 -109
  195. package/packages/@monomind/guidance/dist/hooks.js +0 -347
  196. package/packages/@monomind/guidance/dist/index.d.ts +0 -205
  197. package/packages/@monomind/guidance/dist/index.js +0 -321
  198. package/packages/@monomind/guidance/dist/ledger.d.ts +0 -162
  199. package/packages/@monomind/guidance/dist/ledger.js +0 -375
  200. package/packages/@monomind/guidance/dist/manifest-validator.d.ts +0 -289
  201. package/packages/@monomind/guidance/dist/manifest-validator.js +0 -838
  202. package/packages/@monomind/guidance/dist/memory-gate.d.ts +0 -222
  203. package/packages/@monomind/guidance/dist/memory-gate.js +0 -382
  204. package/packages/@monomind/guidance/dist/meta-governance.d.ts +0 -265
  205. package/packages/@monomind/guidance/dist/meta-governance.js +0 -348
  206. package/packages/@monomind/guidance/dist/optimizer.d.ts +0 -104
  207. package/packages/@monomind/guidance/dist/optimizer.js +0 -329
  208. package/packages/@monomind/guidance/dist/persistence.d.ts +0 -189
  209. package/packages/@monomind/guidance/dist/persistence.js +0 -464
  210. package/packages/@monomind/guidance/dist/proof.d.ts +0 -185
  211. package/packages/@monomind/guidance/dist/proof.js +0 -238
  212. package/packages/@monomind/guidance/dist/retriever.d.ts +0 -116
  213. package/packages/@monomind/guidance/dist/retriever.js +0 -394
  214. package/packages/@monomind/guidance/dist/ruvbot-integration.d.ts +0 -370
  215. package/packages/@monomind/guidance/dist/ruvbot-integration.js +0 -738
  216. package/packages/@monomind/guidance/dist/temporal.d.ts +0 -426
  217. package/packages/@monomind/guidance/dist/temporal.js +0 -658
  218. package/packages/@monomind/guidance/dist/trust.d.ts +0 -283
  219. package/packages/@monomind/guidance/dist/trust.js +0 -473
  220. package/packages/@monomind/guidance/dist/truth-anchors.d.ts +0 -276
  221. package/packages/@monomind/guidance/dist/truth-anchors.js +0 -488
  222. package/packages/@monomind/guidance/dist/types.d.ts +0 -378
  223. package/packages/@monomind/guidance/dist/types.js +0 -10
  224. package/packages/@monomind/guidance/dist/uncertainty.d.ts +0 -372
  225. package/packages/@monomind/guidance/dist/uncertainty.js +0 -619
  226. package/packages/@monomind/guidance/dist/wasm-kernel.d.ts +0 -48
  227. package/packages/@monomind/guidance/dist/wasm-kernel.js +0 -158
@@ -1,265 +0,0 @@
1
- /**
2
- * @fileoverview Meta-Governance Module
3
- *
4
- * Provides constitutional governance over the governance system itself.
5
- * Manages invariants, amendments, and optimizer constraints to prevent
6
- * governance drift and ensure constitutional stability.
7
- *
8
- * Features:
9
- * - Constitutional invariants with severity levels
10
- * - Amendment proposal and voting system
11
- * - Optimizer action validation
12
- * - Rate limiting and supermajority requirements
13
- * - Built-in constitutional protections
14
- *
15
- * Core capabilities:
16
- * - Constitutional invariant checking
17
- * - Amendment lifecycle (propose → vote → resolve → enact)
18
- * - Optimizer constraint enforcement
19
- * - Supermajority voting
20
- * - Emergency veto power
21
- * - Immutability protection
22
- *
23
- * @module @monomind/guidance/meta-governance
24
- * @author Monomind Team
25
- */
26
- /**
27
- * Result of checking a constitutional invariant
28
- */
29
- export interface InvariantCheckResult {
30
- /** Whether the invariant holds */
31
- holds: boolean;
32
- /** Description of violation if invariant does not hold */
33
- violation?: string;
34
- /** Additional details about the check */
35
- details?: Record<string, unknown>;
36
- }
37
- /**
38
- * Current state of the governance system for invariant checking
39
- */
40
- export interface GovernanceState {
41
- /** Number of active governance rules */
42
- ruleCount: number;
43
- /** Size of constitution in lines */
44
- constitutionSize: number;
45
- /** Number of active gates */
46
- gateCount: number;
47
- /** Whether optimizer is enabled */
48
- optimizerEnabled: boolean;
49
- /** Number of active agents */
50
- activeAgentCount: number;
51
- /** Timestamp of last amendment */
52
- lastAmendmentTimestamp: number;
53
- /** Additional state metadata */
54
- metadata: Record<string, unknown>;
55
- }
56
- /**
57
- * Constitutional invariant that must hold
58
- */
59
- export interface ConstitutionalInvariant {
60
- /** Unique identifier */
61
- id: string;
62
- /** Human-readable name */
63
- name: string;
64
- /** Description of the invariant */
65
- description: string;
66
- /** Function to check if invariant holds */
67
- check: (state: GovernanceState) => InvariantCheckResult;
68
- /** Severity level */
69
- severity: 'critical' | 'warning';
70
- /** Whether this invariant can be removed */
71
- immutable: boolean;
72
- }
73
- /**
74
- * A specific change within an amendment
75
- */
76
- export interface AmendmentChange {
77
- /** Type of change */
78
- type: 'add-rule' | 'remove-rule' | 'modify-rule' | 'adjust-threshold' | 'add-gate' | 'remove-gate';
79
- /** Target of the change (rule ID, gate ID, etc.) */
80
- target: string;
81
- /** State before the change (for modify operations) */
82
- before?: string;
83
- /** State after the change */
84
- after?: string;
85
- }
86
- /**
87
- * Amendment to the governance system
88
- */
89
- export interface Amendment {
90
- /** Unique identifier */
91
- id: string;
92
- /** Agent or entity that proposed the amendment */
93
- proposedBy: string;
94
- /** Description of the amendment */
95
- description: string;
96
- /** Specific changes in the amendment */
97
- changes: AmendmentChange[];
98
- /** When the amendment was proposed */
99
- timestamp: number;
100
- /** Current status */
101
- status: 'proposed' | 'approved' | 'rejected' | 'enacted' | 'vetoed';
102
- /** Votes for/against (voterId → approve) */
103
- votes: Map<string, boolean>;
104
- /** Number of approvals required to pass */
105
- requiredApprovals: number;
106
- /** Additional metadata */
107
- metadata?: Record<string, unknown>;
108
- }
109
- /**
110
- * Constraints on optimizer behavior
111
- */
112
- export interface OptimizerConstraint {
113
- /** Unique identifier */
114
- id: string;
115
- /** Human-readable name */
116
- name: string;
117
- /** Description of the constraint */
118
- description: string;
119
- /** Maximum governance drift per optimization cycle (0-1) */
120
- maxDriftPerCycle: number;
121
- /** Maximum rules promoted per cycle */
122
- maxPromotionRate: number;
123
- /** Maximum rules demoted per cycle */
124
- maxDemotionRate: number;
125
- /** Cooldown between optimizer actions (ms) */
126
- cooldownMs: number;
127
- }
128
- /**
129
- * Action the optimizer wants to take
130
- */
131
- export interface OptimizerAction {
132
- /** Type of action */
133
- type: 'promote' | 'demote' | 'add' | 'remove' | 'reweight';
134
- /** Target rule identifier */
135
- targetRuleId: string;
136
- /** Magnitude of the action (interpretation depends on type) */
137
- magnitude: number;
138
- /** When the action was requested */
139
- timestamp: number;
140
- }
141
- /**
142
- * Validation result for an optimizer action
143
- */
144
- export interface OptimizerValidation {
145
- /** Whether the action is allowed */
146
- allowed: boolean;
147
- /** Reason for the decision */
148
- reason: string;
149
- /** Specific constraint violations */
150
- constraintViolations: string[];
151
- }
152
- /**
153
- * Report of all invariant checks
154
- */
155
- export interface InvariantReport {
156
- /** Whether all invariants hold */
157
- allHold: boolean;
158
- /** Results for each invariant */
159
- results: Array<{
160
- invariant: ConstitutionalInvariant;
161
- result: InvariantCheckResult;
162
- }>;
163
- /** When the report was generated */
164
- timestamp: number;
165
- }
166
- /**
167
- * Configuration for meta-governance
168
- */
169
- export interface MetaGovernanceConfig {
170
- /** Threshold for supermajority (0-1, default 0.75) */
171
- supermajorityThreshold?: number;
172
- /** Maximum amendments allowed per time window */
173
- maxAmendmentsPerWindow?: number;
174
- /** Time window for amendment rate limiting (ms) */
175
- amendmentWindowMs?: number;
176
- /** Optimizer constraints (partial allows overriding defaults) */
177
- optimizerConstraints?: Partial<OptimizerConstraint>;
178
- /** Optional signing key for amendments */
179
- signingKey?: string;
180
- }
181
- /**
182
- * Meta-Governor: Governs the governance system itself
183
- *
184
- * Enforces constitutional invariants, manages amendments,
185
- * and constrains optimizer behavior to prevent governance drift.
186
- */
187
- export declare class MetaGovernor {
188
- private invariants;
189
- private amendments;
190
- private amendmentHistory;
191
- private optimizerConstraints;
192
- private lastOptimizerAction;
193
- private optimizerActionsThisCycle;
194
- private readonly supermajorityThreshold;
195
- private readonly maxAmendmentsPerWindow;
196
- private readonly amendmentWindowMs;
197
- private readonly signingKey?;
198
- constructor(config?: MetaGovernanceConfig);
199
- /**
200
- * Add built-in constitutional invariants
201
- */
202
- private addBuiltInInvariants;
203
- /**
204
- * Add a constitutional invariant
205
- */
206
- addInvariant(invariant: ConstitutionalInvariant): void;
207
- /**
208
- * Remove an invariant (only if not immutable)
209
- */
210
- removeInvariant(id: string): boolean;
211
- /**
212
- * Check all constitutional invariants against current state
213
- */
214
- checkAllInvariants(state: GovernanceState): InvariantReport;
215
- /**
216
- * Propose a new amendment
217
- */
218
- proposeAmendment(proposal: Omit<Amendment, 'id' | 'timestamp' | 'status' | 'votes'>): Amendment;
219
- /**
220
- * Vote on an amendment
221
- */
222
- voteOnAmendment(amendmentId: string, voterId: string, approve: boolean): void;
223
- /**
224
- * Resolve an amendment (check if supermajority reached)
225
- */
226
- resolveAmendment(amendmentId: string): Amendment;
227
- /**
228
- * Enact an approved amendment
229
- * Returns true if enacted successfully
230
- */
231
- enactAmendment(amendmentId: string): boolean;
232
- /**
233
- * Emergency veto of an amendment
234
- */
235
- vetoAmendment(amendmentId: string, reason: string): void;
236
- /**
237
- * Get full amendment history
238
- */
239
- getAmendmentHistory(): Amendment[];
240
- /**
241
- * Validate an optimizer action against constraints
242
- */
243
- validateOptimizerAction(action: OptimizerAction): OptimizerValidation;
244
- /**
245
- * Get current optimizer constraints
246
- */
247
- getConstraints(): OptimizerConstraint;
248
- /**
249
- * Reset optimizer action tracking (call at cycle boundaries)
250
- */
251
- resetOptimizerTracking(): void;
252
- /**
253
- * Get all invariants
254
- */
255
- getInvariants(): ConstitutionalInvariant[];
256
- /**
257
- * Get pending amendments
258
- */
259
- getPendingAmendments(): Amendment[];
260
- }
261
- /**
262
- * Factory function to create a MetaGovernor instance
263
- */
264
- export declare function createMetaGovernor(config?: MetaGovernanceConfig): MetaGovernor;
265
- //# sourceMappingURL=meta-governance.d.ts.map
@@ -1,348 +0,0 @@
1
- /**
2
- * @fileoverview Meta-Governance Module
3
- *
4
- * Provides constitutional governance over the governance system itself.
5
- * Manages invariants, amendments, and optimizer constraints to prevent
6
- * governance drift and ensure constitutional stability.
7
- *
8
- * Features:
9
- * - Constitutional invariants with severity levels
10
- * - Amendment proposal and voting system
11
- * - Optimizer action validation
12
- * - Rate limiting and supermajority requirements
13
- * - Built-in constitutional protections
14
- *
15
- * Core capabilities:
16
- * - Constitutional invariant checking
17
- * - Amendment lifecycle (propose → vote → resolve → enact)
18
- * - Optimizer constraint enforcement
19
- * - Supermajority voting
20
- * - Emergency veto power
21
- * - Immutability protection
22
- *
23
- * @module @monomind/guidance/meta-governance
24
- * @author Monomind Team
25
- */
26
- import { randomUUID } from 'node:crypto';
27
- /**
28
- * Meta-Governor: Governs the governance system itself
29
- *
30
- * Enforces constitutional invariants, manages amendments,
31
- * and constrains optimizer behavior to prevent governance drift.
32
- */
33
- export class MetaGovernor {
34
- invariants = new Map();
35
- amendments = new Map();
36
- amendmentHistory = [];
37
- optimizerConstraints;
38
- lastOptimizerAction = 0;
39
- optimizerActionsThisCycle = new Map();
40
- supermajorityThreshold;
41
- maxAmendmentsPerWindow;
42
- amendmentWindowMs;
43
- signingKey;
44
- constructor(config = {}) {
45
- this.supermajorityThreshold = config.supermajorityThreshold ?? 0.75;
46
- this.maxAmendmentsPerWindow = config.maxAmendmentsPerWindow ?? 3;
47
- this.amendmentWindowMs = config.amendmentWindowMs ?? 24 * 60 * 60 * 1000; // 24 hours
48
- this.signingKey = config.signingKey;
49
- // Initialize optimizer constraints with defaults
50
- this.optimizerConstraints = {
51
- id: 'default-optimizer-constraints',
52
- name: 'Default Optimizer Constraints',
53
- description: 'Default constraints on optimizer behavior',
54
- maxDriftPerCycle: 0.1, // 10% change max
55
- maxPromotionRate: 2,
56
- maxDemotionRate: 1,
57
- cooldownMs: 3600000, // 1 hour
58
- ...config.optimizerConstraints,
59
- };
60
- // Add built-in invariants
61
- this.addBuiltInInvariants();
62
- }
63
- /**
64
- * Add built-in constitutional invariants
65
- */
66
- addBuiltInInvariants() {
67
- // 1. Constitution size limit
68
- this.addInvariant({
69
- id: 'constitution-size-limit',
70
- name: 'Constitution Size Limit',
71
- description: 'Constitution must not exceed 60 lines',
72
- severity: 'critical',
73
- immutable: true,
74
- check: (state) => {
75
- const holds = state.constitutionSize <= 60;
76
- return {
77
- holds,
78
- violation: holds ? undefined : `Constitution size ${state.constitutionSize} exceeds limit of 60 lines`,
79
- details: { constitutionSize: state.constitutionSize, limit: 60 },
80
- };
81
- },
82
- });
83
- // 2. Gate minimum
84
- this.addInvariant({
85
- id: 'gate-minimum',
86
- name: 'Minimum Gate Count',
87
- description: 'At least 4 gates must be active',
88
- severity: 'critical',
89
- immutable: true,
90
- check: (state) => {
91
- const holds = state.gateCount >= 4;
92
- return {
93
- holds,
94
- violation: holds ? undefined : `Gate count ${state.gateCount} is below minimum of 4`,
95
- details: { gateCount: state.gateCount, minimum: 4 },
96
- };
97
- },
98
- });
99
- // 3. Rule count sanity
100
- this.addInvariant({
101
- id: 'rule-count-sanity',
102
- name: 'Rule Count Sanity Check',
103
- description: 'Total rules should not exceed 1000',
104
- severity: 'warning',
105
- immutable: false,
106
- check: (state) => {
107
- const holds = state.ruleCount <= 1000;
108
- return {
109
- holds,
110
- violation: holds ? undefined : `Rule count ${state.ruleCount} exceeds recommended limit of 1000`,
111
- details: { ruleCount: state.ruleCount, recommendedLimit: 1000 },
112
- };
113
- },
114
- });
115
- // 4. Optimizer bounds
116
- this.addInvariant({
117
- id: 'optimizer-bounds',
118
- name: 'Optimizer Drift Bounds',
119
- description: 'Optimizer must operate within reasonable drift bounds',
120
- severity: 'warning',
121
- immutable: false,
122
- check: (state) => {
123
- if (!state.optimizerEnabled) {
124
- return { holds: true, details: { optimizerEnabled: false } };
125
- }
126
- const reasonableDrift = this.optimizerConstraints.maxDriftPerCycle <= 0.2;
127
- return {
128
- holds: reasonableDrift,
129
- violation: reasonableDrift ? undefined : `Optimizer drift ${this.optimizerConstraints.maxDriftPerCycle} exceeds reasonable bounds`,
130
- details: { maxDrift: this.optimizerConstraints.maxDriftPerCycle, reasonableLimit: 0.2 },
131
- };
132
- },
133
- });
134
- }
135
- /**
136
- * Add a constitutional invariant
137
- */
138
- addInvariant(invariant) {
139
- this.invariants.set(invariant.id, invariant);
140
- }
141
- /**
142
- * Remove an invariant (only if not immutable)
143
- */
144
- removeInvariant(id) {
145
- const invariant = this.invariants.get(id);
146
- if (!invariant) {
147
- return false;
148
- }
149
- if (invariant.immutable) {
150
- throw new Error(`Cannot remove immutable invariant: ${id}`);
151
- }
152
- return this.invariants.delete(id);
153
- }
154
- /**
155
- * Check all constitutional invariants against current state
156
- */
157
- checkAllInvariants(state) {
158
- const results = [];
159
- let allHold = true;
160
- for (const invariant of this.invariants.values()) {
161
- const result = invariant.check(state);
162
- results.push({ invariant, result });
163
- if (!result.holds) {
164
- allHold = false;
165
- }
166
- }
167
- return {
168
- allHold,
169
- results,
170
- timestamp: Date.now(),
171
- };
172
- }
173
- /**
174
- * Propose a new amendment
175
- */
176
- proposeAmendment(proposal) {
177
- // Check rate limiting
178
- const now = Date.now();
179
- const recentAmendments = this.amendmentHistory.filter((a) => now - a.timestamp < this.amendmentWindowMs);
180
- if (recentAmendments.length >= this.maxAmendmentsPerWindow) {
181
- throw new Error(`Amendment rate limit exceeded: ${this.maxAmendmentsPerWindow} per ${this.amendmentWindowMs}ms`);
182
- }
183
- const amendment = {
184
- id: randomUUID(),
185
- timestamp: now,
186
- status: 'proposed',
187
- votes: new Map(),
188
- ...proposal,
189
- };
190
- this.amendments.set(amendment.id, amendment);
191
- return amendment;
192
- }
193
- /**
194
- * Vote on an amendment
195
- */
196
- voteOnAmendment(amendmentId, voterId, approve) {
197
- const amendment = this.amendments.get(amendmentId);
198
- if (!amendment) {
199
- throw new Error(`Amendment not found: ${amendmentId}`);
200
- }
201
- if (amendment.status !== 'proposed') {
202
- throw new Error(`Cannot vote on amendment with status: ${amendment.status}`);
203
- }
204
- amendment.votes.set(voterId, approve);
205
- }
206
- /**
207
- * Resolve an amendment (check if supermajority reached)
208
- */
209
- resolveAmendment(amendmentId) {
210
- const amendment = this.amendments.get(amendmentId);
211
- if (!amendment) {
212
- throw new Error(`Amendment not found: ${amendmentId}`);
213
- }
214
- if (amendment.status !== 'proposed') {
215
- throw new Error(`Amendment already resolved: ${amendment.status}`);
216
- }
217
- const totalVotes = amendment.votes.size;
218
- const approvals = Array.from(amendment.votes.values()).filter((v) => v).length;
219
- const approvalRate = totalVotes > 0 ? approvals / totalVotes : 0;
220
- if (approvalRate >= this.supermajorityThreshold && approvals >= amendment.requiredApprovals) {
221
- amendment.status = 'approved';
222
- }
223
- else {
224
- amendment.status = 'rejected';
225
- }
226
- return amendment;
227
- }
228
- /**
229
- * Enact an approved amendment
230
- * Returns true if enacted successfully
231
- */
232
- enactAmendment(amendmentId) {
233
- const amendment = this.amendments.get(amendmentId);
234
- if (!amendment) {
235
- throw new Error(`Amendment not found: ${amendmentId}`);
236
- }
237
- if (amendment.status !== 'approved') {
238
- throw new Error(`Cannot enact amendment with status: ${amendment.status}`);
239
- }
240
- // Check if any changes would violate immutable invariants
241
- for (const change of amendment.changes) {
242
- if (change.type === 'remove-rule' || change.type === 'modify-rule') {
243
- const invariant = this.invariants.get(change.target);
244
- if (invariant?.immutable) {
245
- throw new Error(`Cannot modify immutable invariant: ${change.target}`);
246
- }
247
- }
248
- }
249
- amendment.status = 'enacted';
250
- this.amendmentHistory.push(amendment);
251
- this.amendments.delete(amendmentId);
252
- return true;
253
- }
254
- /**
255
- * Emergency veto of an amendment
256
- */
257
- vetoAmendment(amendmentId, reason) {
258
- const amendment = this.amendments.get(amendmentId);
259
- if (!amendment) {
260
- throw new Error(`Amendment not found: ${amendmentId}`);
261
- }
262
- amendment.status = 'vetoed';
263
- amendment.metadata = {
264
- ...amendment.metadata,
265
- vetoReason: reason,
266
- vetoedAt: Date.now(),
267
- };
268
- this.amendmentHistory.push(amendment);
269
- this.amendments.delete(amendmentId);
270
- }
271
- /**
272
- * Get full amendment history
273
- */
274
- getAmendmentHistory() {
275
- return [...this.amendmentHistory];
276
- }
277
- /**
278
- * Validate an optimizer action against constraints
279
- */
280
- validateOptimizerAction(action) {
281
- const violations = [];
282
- const now = Date.now();
283
- // Check cooldown
284
- if (now - this.lastOptimizerAction < this.optimizerConstraints.cooldownMs) {
285
- violations.push(`Cooldown not met: ${now - this.lastOptimizerAction}ms < ${this.optimizerConstraints.cooldownMs}ms`);
286
- }
287
- // Track actions this cycle
288
- const cycleKey = `${action.type}-${action.targetRuleId}`;
289
- const actionsThisCycle = this.optimizerActionsThisCycle.get(cycleKey) ?? 0;
290
- // Check promotion rate
291
- if (action.type === 'promote') {
292
- if (actionsThisCycle >= this.optimizerConstraints.maxPromotionRate) {
293
- violations.push(`Promotion rate exceeded: ${actionsThisCycle} >= ${this.optimizerConstraints.maxPromotionRate}`);
294
- }
295
- }
296
- // Check demotion rate
297
- if (action.type === 'demote') {
298
- if (actionsThisCycle >= this.optimizerConstraints.maxDemotionRate) {
299
- violations.push(`Demotion rate exceeded: ${actionsThisCycle} >= ${this.optimizerConstraints.maxDemotionRate}`);
300
- }
301
- }
302
- // Check drift magnitude
303
- if (action.magnitude > this.optimizerConstraints.maxDriftPerCycle) {
304
- violations.push(`Drift magnitude ${action.magnitude} exceeds limit ${this.optimizerConstraints.maxDriftPerCycle}`);
305
- }
306
- const allowed = violations.length === 0;
307
- if (allowed) {
308
- this.lastOptimizerAction = now;
309
- this.optimizerActionsThisCycle.set(cycleKey, actionsThisCycle + 1);
310
- }
311
- return {
312
- allowed,
313
- reason: allowed ? 'Action permitted' : `Constraint violations: ${violations.join(', ')}`,
314
- constraintViolations: violations,
315
- };
316
- }
317
- /**
318
- * Get current optimizer constraints
319
- */
320
- getConstraints() {
321
- return { ...this.optimizerConstraints };
322
- }
323
- /**
324
- * Reset optimizer action tracking (call at cycle boundaries)
325
- */
326
- resetOptimizerTracking() {
327
- this.optimizerActionsThisCycle.clear();
328
- }
329
- /**
330
- * Get all invariants
331
- */
332
- getInvariants() {
333
- return Array.from(this.invariants.values());
334
- }
335
- /**
336
- * Get pending amendments
337
- */
338
- getPendingAmendments() {
339
- return Array.from(this.amendments.values()).filter((a) => a.status === 'proposed');
340
- }
341
- }
342
- /**
343
- * Factory function to create a MetaGovernor instance
344
- */
345
- export function createMetaGovernor(config) {
346
- return new MetaGovernor(config);
347
- }
348
- //# sourceMappingURL=meta-governance.js.map