monomind 1.18.13 → 1.19.0

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 (218) hide show
  1. package/.claude/agents/core/researcher.md +29 -24
  2. package/.claude/agents/github/code-review-swarm.md +1 -1
  3. package/.claude/agents/github/github-modes.md +1 -1
  4. package/.claude/agents/github/issue-tracker.md +1 -1
  5. package/.claude/agents/github/multi-repo-swarm.md +1 -1
  6. package/.claude/agents/github/pr-manager.md +1 -1
  7. package/.claude/agents/github/project-board-sync.md +1 -1
  8. package/.claude/agents/github/release-manager.md +1 -1
  9. package/.claude/agents/github/repo-architect.md +1 -1
  10. package/.claude/agents/github/swarm-issue.md +1 -1
  11. package/.claude/agents/github/swarm-pr.md +1 -1
  12. package/.claude/agents/github/sync-coordinator.md +1 -1
  13. package/.claude/agents/github/workflow-automation.md +1 -1
  14. package/.claude/agents/goal/goal-planner.md +1 -1
  15. package/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
  16. package/.claude/agents/testing/production-validator.md +8 -7
  17. package/.claude/agents/testing/testing-evidence-collector.md +3 -1
  18. package/.claude/commands/mastermind/_repeat.md +22 -3
  19. package/.claude/commands/mastermind/architect.md +1 -1
  20. package/.claude/commands/mastermind/autodev.md +1 -1
  21. package/.claude/commands/mastermind/build.md +1 -1
  22. package/.claude/commands/mastermind/code-review.md +5 -5
  23. package/.claude/commands/mastermind/debug.md +1 -1
  24. package/.claude/commands/mastermind/help.md +2 -2
  25. package/.claude/commands/mastermind/idea.md +1 -1
  26. package/.claude/commands/mastermind/improve.md +1 -1
  27. package/.claude/commands/mastermind/okf-export.md +14 -0
  28. package/.claude/commands/mastermind/okf-import.md +15 -0
  29. package/.claude/commands/mastermind/plan.md +1 -1
  30. package/.claude/commands/mastermind/research.md +1 -1
  31. package/.claude/commands/mastermind/review.md +12 -1
  32. package/.claude/commands/mastermind/runorg.md +1 -1
  33. package/.claude/commands/mastermind/taskdev.md +1 -1
  34. package/.claude/commands/mastermind/tdd.md +1 -1
  35. package/.claude/commands/mastermind/verify.md +1 -1
  36. package/.claude/helpers/graphify-freshen.cjs +16 -20
  37. package/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
  38. package/.claude/helpers/handlers/capture-handler.cjs +110 -0
  39. package/.claude/helpers/handlers/route-handler.cjs +180 -256
  40. package/.claude/helpers/handlers/session-handler.cjs +139 -142
  41. package/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
  42. package/.claude/helpers/handlers/task-handler.cjs +8 -155
  43. package/.claude/helpers/hook-handler.cjs +89 -5
  44. package/.claude/helpers/intelligence.cjs +164 -15
  45. package/.claude/helpers/learning-service.mjs +1 -0
  46. package/.claude/helpers/mastermind-activate.cjs +33 -51
  47. package/.claude/helpers/monolean-activate.cjs +13 -3
  48. package/.claude/helpers/monolean-propagate.cjs +7 -3
  49. package/.claude/helpers/router.cjs +47 -9
  50. package/.claude/helpers/utils/monograph.cjs +37 -20
  51. package/.claude/settings.json +0 -20
  52. package/.claude/skills/mastermind-skills/_repeat.md +29 -4
  53. package/.claude/skills/mastermind-skills/architect.md +5 -6
  54. package/.claude/skills/mastermind-skills/autodev.md +8 -5
  55. package/.claude/skills/mastermind-skills/review.md +25 -11
  56. package/.claude/skills/mastermind-skills/techport.md +37 -3
  57. package/.claude/skills/monodesign/document.md +9 -6
  58. package/.claude/skills/monodesign/extract.md +1 -1
  59. package/.claude/skills/monodesign/reference/document.md +1 -1
  60. package/.claude/skills/monodesign/reference/live.md +1 -1
  61. package/.claude/skills/monolean/SKILL.md +1 -1
  62. package/package.json +1 -1
  63. package/packages/@monomind/cli/.claude/agents/core/researcher.md +29 -24
  64. package/packages/@monomind/cli/.claude/agents/github/code-review-swarm.md +1 -1
  65. package/packages/@monomind/cli/.claude/agents/github/github-modes.md +1 -1
  66. package/packages/@monomind/cli/.claude/agents/github/issue-tracker.md +1 -1
  67. package/packages/@monomind/cli/.claude/agents/github/multi-repo-swarm.md +1 -1
  68. package/packages/@monomind/cli/.claude/agents/github/pr-manager.md +1 -1
  69. package/packages/@monomind/cli/.claude/agents/github/project-board-sync.md +1 -1
  70. package/packages/@monomind/cli/.claude/agents/github/release-manager.md +1 -1
  71. package/packages/@monomind/cli/.claude/agents/github/repo-architect.md +1 -1
  72. package/packages/@monomind/cli/.claude/agents/github/swarm-issue.md +1 -1
  73. package/packages/@monomind/cli/.claude/agents/github/swarm-pr.md +1 -1
  74. package/packages/@monomind/cli/.claude/agents/github/sync-coordinator.md +1 -1
  75. package/packages/@monomind/cli/.claude/agents/github/workflow-automation.md +1 -1
  76. package/packages/@monomind/cli/.claude/agents/goal/goal-planner.md +1 -1
  77. package/packages/@monomind/cli/.claude/agents/specialized/specialized-workflow-architect.md +11 -14
  78. package/packages/@monomind/cli/.claude/agents/testing/production-validator.md +8 -7
  79. package/packages/@monomind/cli/.claude/agents/testing/testing-evidence-collector.md +3 -1
  80. package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +22 -3
  81. package/packages/@monomind/cli/.claude/commands/mastermind/architect.md +1 -1
  82. package/packages/@monomind/cli/.claude/commands/mastermind/autodev.md +1 -1
  83. package/packages/@monomind/cli/.claude/commands/mastermind/build.md +1 -1
  84. package/packages/@monomind/cli/.claude/commands/mastermind/code-review.md +5 -5
  85. package/packages/@monomind/cli/.claude/commands/mastermind/debug.md +1 -1
  86. package/packages/@monomind/cli/.claude/commands/mastermind/help.md +2 -2
  87. package/packages/@monomind/cli/.claude/commands/mastermind/idea.md +1 -1
  88. package/packages/@monomind/cli/.claude/commands/mastermind/improve.md +1 -1
  89. package/packages/@monomind/cli/.claude/commands/mastermind/okf-export.md +14 -0
  90. package/packages/@monomind/cli/.claude/commands/mastermind/okf-import.md +15 -0
  91. package/packages/@monomind/cli/.claude/commands/mastermind/plan.md +1 -1
  92. package/packages/@monomind/cli/.claude/commands/mastermind/research.md +1 -1
  93. package/packages/@monomind/cli/.claude/commands/mastermind/review.md +12 -1
  94. package/packages/@monomind/cli/.claude/commands/mastermind/runorg.md +1 -1
  95. package/packages/@monomind/cli/.claude/commands/mastermind/taskdev.md +1 -1
  96. package/packages/@monomind/cli/.claude/commands/mastermind/tdd.md +1 -1
  97. package/packages/@monomind/cli/.claude/commands/mastermind/verify.md +1 -1
  98. package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +16 -20
  99. package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +11 -36
  100. package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +110 -0
  101. package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +180 -256
  102. package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +139 -142
  103. package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +15 -10
  104. package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +8 -155
  105. package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +89 -5
  106. package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +164 -15
  107. package/packages/@monomind/cli/.claude/helpers/learning-service.mjs +1 -0
  108. package/packages/@monomind/cli/.claude/helpers/mastermind-activate.cjs +33 -51
  109. package/packages/@monomind/cli/.claude/helpers/monolean-activate.cjs +13 -3
  110. package/packages/@monomind/cli/.claude/helpers/monolean-propagate.cjs +7 -3
  111. package/packages/@monomind/cli/.claude/helpers/router.cjs +47 -9
  112. package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +37 -20
  113. package/packages/@monomind/cli/.claude/skills/mastermind-skills/_repeat.md +29 -4
  114. package/packages/@monomind/cli/.claude/skills/mastermind-skills/architect.md +5 -6
  115. package/packages/@monomind/cli/.claude/skills/mastermind-skills/autodev.md +8 -5
  116. package/packages/@monomind/cli/.claude/skills/mastermind-skills/review.md +25 -11
  117. package/packages/@monomind/cli/.claude/skills/mastermind-skills/techport.md +37 -3
  118. package/packages/@monomind/cli/.claude/skills/monodesign/document.md +9 -6
  119. package/packages/@monomind/cli/.claude/skills/monodesign/extract.md +1 -1
  120. package/packages/@monomind/cli/.claude/skills/monodesign/reference/document.md +1 -1
  121. package/packages/@monomind/cli/.claude/skills/monodesign/reference/live.md +1 -1
  122. package/packages/@monomind/cli/.claude/skills/monolean/SKILL.md +1 -1
  123. package/packages/@monomind/cli/bin/mcp-server.js +11 -1
  124. package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +1 -2
  125. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +1 -59
  126. package/packages/@monomind/cli/dist/src/commands/agent.js +2 -3
  127. package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +1 -1
  128. package/packages/@monomind/cli/dist/src/commands/browse-action.js +94 -2
  129. package/packages/@monomind/cli/dist/src/commands/completions.js +11 -56
  130. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +1 -1
  131. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +1 -1
  132. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +2 -2
  133. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +1 -3
  134. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +2 -116
  135. package/packages/@monomind/cli/dist/src/commands/hive-mind.js +2 -5
  136. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +8 -7
  137. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +1 -1
  138. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +2 -2
  139. package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.d.ts +0 -3
  140. package/packages/@monomind/cli/dist/src/commands/hooks-extended-commands.js +0 -307
  141. package/packages/@monomind/cli/dist/src/commands/hooks.js +1 -12
  142. package/packages/@monomind/cli/dist/src/commands/index.d.ts +3 -51
  143. package/packages/@monomind/cli/dist/src/commands/index.js +36 -184
  144. package/packages/@monomind/cli/dist/src/commands/init-wizard.js +2 -4
  145. package/packages/@monomind/cli/dist/src/commands/mcp.js +32 -4
  146. package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +1 -2
  147. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +1 -118
  148. package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +1 -2
  149. package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +5 -171
  150. package/packages/@monomind/cli/dist/src/commands/memory.js +3 -6
  151. package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +3 -1
  152. package/packages/@monomind/cli/dist/src/commands/neural-core.js +145 -6
  153. package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +4 -4
  154. package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +1 -1
  155. package/packages/@monomind/cli/dist/src/commands/neural-registry.js +4 -4
  156. package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
  157. package/packages/@monomind/cli/dist/src/commands/neural.js +6 -6
  158. package/packages/@monomind/cli/dist/src/commands/performance.js +68 -58
  159. package/packages/@monomind/cli/dist/src/commands/providers.js +2 -131
  160. package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +0 -1
  161. package/packages/@monomind/cli/dist/src/commands/security-misc.js +69 -45
  162. package/packages/@monomind/cli/dist/src/commands/security.js +2 -4
  163. package/packages/@monomind/cli/dist/src/commands/session.js +1 -285
  164. package/packages/@monomind/cli/dist/src/commands/start.js +2 -41
  165. package/packages/@monomind/cli/dist/src/commands/status.js +18 -29
  166. package/packages/@monomind/cli/dist/src/commands/swarm.js +1 -1
  167. package/packages/@monomind/cli/dist/src/commands/task.js +2 -49
  168. package/packages/@monomind/cli/dist/src/commands/workflow.js +2 -104
  169. package/packages/@monomind/cli/dist/src/index.js +7 -0
  170. package/packages/@monomind/cli/dist/src/init/executor.js +3 -14
  171. package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -22
  172. package/packages/@monomind/cli/dist/src/init/settings-generator.js +0 -1
  173. package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -3
  174. package/packages/@monomind/cli/dist/src/init/types.js +0 -2
  175. package/packages/@monomind/cli/dist/src/mcp-client.js +0 -6
  176. package/packages/@monomind/cli/dist/src/mcp-server.js +16 -0
  177. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +0 -17
  178. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.d.ts +5 -5
  179. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/causal-infer.js +32 -46
  180. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.d.ts +2 -3
  181. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/consensus-verify.js +22 -20
  182. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.d.ts +3 -2
  183. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/memory-gate.js +32 -19
  184. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.d.ts +4 -4
  185. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/quantum-topology.js +11 -17
  186. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.d.ts +2 -3
  187. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/spectral-analyze.js +51 -32
  188. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +5 -9
  189. package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +2 -2
  190. package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +25 -3
  191. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.d.ts +0 -3
  192. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-routing.js +45 -159
  193. package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +1 -4
  194. package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
  195. package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -3
  196. package/packages/@monomind/cli/dist/src/mcp-tools/memory-tools.js +24 -0
  197. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +452 -7
  198. package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +4 -10
  199. package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +28 -54
  200. package/packages/@monomind/cli/dist/src/mcp-tools/performance-tools.js +5 -17
  201. package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.js +2 -2
  202. package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
  203. package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.d.ts +7 -2
  204. package/packages/@monomind/cli/dist/src/mcp-tools/quality-tools.js +7 -257
  205. package/packages/@monomind/cli/dist/src/memory/intelligence.d.ts +7 -8
  206. package/packages/@monomind/cli/dist/src/memory/intelligence.js +15 -16
  207. package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +1 -0
  208. package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +37 -0
  209. package/packages/@monomind/cli/dist/src/services/worker-daemon.d.ts +3 -21
  210. package/packages/@monomind/cli/dist/src/services/worker-daemon.js +13 -80
  211. package/packages/@monomind/cli/dist/src/suggest.js +0 -5
  212. package/packages/@monomind/cli/package.json +1 -1
  213. package/packages/@monomind/guidance/README.md +49 -1153
  214. package/packages/@monomind/guidance/package.json +1 -74
  215. package/.claude/helpers/auto-memory-hook.mjs +0 -503
  216. package/packages/@monomind/cli/.claude/helpers/auto-memory-hook.mjs +0 -503
  217. package/packages/@monomind/cli/dist/src/commands/deployment.d.ts +0 -10
  218. package/packages/@monomind/cli/dist/src/commands/deployment.js +0 -706
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * Pre-storage coherence gate for memory entries.
5
5
  * Validates that new entries are coherent with existing context before storage.
6
- *
7
- * Uses CohomologyEngine Sheaf Laplacian for coherence validation
6
+ * Uses cosine similarity on vectors to compute coherence energy.
7
+ * When no pre-computed embeddings are supplied, falls back to a deterministic
8
+ * hash-based vector (structural proxy, not semantic similarity).
8
9
  */
9
10
  import type { MCPTool } from './types.js';
10
11
  /**
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * Pre-storage coherence gate for memory entries.
5
5
  * Validates that new entries are coherent with existing context before storage.
6
- *
7
- * Uses CohomologyEngine Sheaf Laplacian for coherence validation
6
+ * Uses cosine similarity on vectors to compute coherence energy.
7
+ * When no pre-computed embeddings are supplied, falls back to a deterministic
8
+ * hash-based vector (structural proxy, not semantic similarity).
8
9
  */
9
10
  import { MemoryGateInputSchema, successResult, errorResult, cosineSimilarity, } from './types.js';
10
11
  // Default logger
@@ -18,31 +19,42 @@ const defaultLogger = {
18
19
  // Memory Gate Functions
19
20
  // ============================================================================
20
21
  /**
21
- * Generate embedding from value (simplified - in production use actual embedding model)
22
+ * Deterministic hash-based vector from value content.
23
+ * This is NOT a semantic embedding -- it produces a normalized vector
24
+ * derived from character codes via an LCG, so only identical (or
25
+ * near-identical) strings will be "similar". It serves as a
26
+ * structural-consistency proxy when no real embedding model is available.
27
+ *
28
+ * For real semantic similarity, use the generateEmbedding() from
29
+ * neural-tools.ts which tries ONNX first and falls back to a
30
+ * deterministic hash.
22
31
  */
23
- function generateEmbedding(value) {
24
- // Convert value to string representation
32
+ function hashVector(value) {
25
33
  const str = typeof value === 'string' ? value : JSON.stringify(value);
26
- // Simple hash-based embedding (for demo purposes)
27
- // In production, use actual embedding model
28
- const embedding = new Array(64).fill(0);
34
+ // Seed from string content
35
+ let seed = 0;
29
36
  for (let i = 0; i < str.length; i++) {
30
- const charCode = str.charCodeAt(i);
31
- const idx = i % embedding.length;
32
- embedding[idx] += charCode * (i + 1) * 0.001;
37
+ seed = ((seed * 1103515245 + 12345) & 0x7fffffff) ^ (str.charCodeAt(i) * (i + 1));
38
+ }
39
+ // Generate deterministic vector via LCG
40
+ const dims = 64;
41
+ const vec = new Array(dims);
42
+ for (let i = 0; i < dims; i++) {
43
+ seed = (seed * 1103515245 + 12345) & 0x7fffffff;
44
+ vec[i] = (seed / 0x7fffffff) * 2 - 1;
33
45
  }
34
46
  // Normalize
35
47
  let norm = 0;
36
- for (let i = 0; i < embedding.length; i++) {
37
- norm += embedding[i] * embedding[i];
48
+ for (let i = 0; i < dims; i++) {
49
+ norm += vec[i] * vec[i];
38
50
  }
39
51
  norm = Math.sqrt(norm);
40
52
  if (norm > 0) {
41
- for (let i = 0; i < embedding.length; i++) {
42
- embedding[i] /= norm;
53
+ for (let i = 0; i < dims; i++) {
54
+ vec[i] /= norm;
43
55
  }
44
56
  }
45
- return embedding;
57
+ return vec;
46
58
  }
47
59
  /**
48
60
  * Compute coherence energy using Sheaf Laplacian
@@ -123,8 +135,9 @@ async function handler(input, context) {
123
135
  warnThreshold,
124
136
  rejectThreshold,
125
137
  });
126
- // Generate embedding for the new value
127
- const newEmbedding = generateEmbedding(value);
138
+ // Generate hash-based vector for the new value (not a semantic embedding --
139
+ // only detects near-identical content, not semantic similarity)
140
+ const newEmbedding = hashVector(value);
128
141
  // If no existing context, always allow
129
142
  if (!existingVectors || existingVectors.length === 0) {
130
143
  const output = {
@@ -221,7 +234,7 @@ async function handler(input, context) {
221
234
  */
222
235
  export const memoryGateTool = {
223
236
  name: 'pr_memory_gate',
224
- description: 'Pre-storage coherence gate for memory entries. Validates new entries against existing context using Sheaf Laplacian energy. Blocks contradictory entries to maintain memory coherence.',
237
+ description: 'Pre-storage coherence gate for memory entries. Validates new entries against existing context vectors using cosine-similarity energy. When no pre-computed embeddings are supplied, uses a deterministic hash-based vector (structural proxy, not semantic). Blocks contradictory entries to maintain memory coherence.',
225
238
  category: 'memory',
226
239
  version: '0.1.3',
227
240
  tags: ['memory', 'coherence', 'gate', 'validation', 'ai-interpretability'],
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Quantum Topology Tool - pr_quantum_topology
2
+ * Computational Topology Tool - pr_quantum_topology
3
3
  *
4
- * Computes quantum topology features including Betti numbers and persistence diagrams.
4
+ * Computes topological features including Betti numbers (b0, b1) and
5
+ * persistence diagrams via Vietoris-Rips filtration.
5
6
  * Analyzes topological features of point clouds and simplicial complexes.
6
- *
7
- * Uses QuantumEngine from prime-radiant-advanced-wasm
7
+ * b2 (voids) is not computed -- requires boundary-operator linear algebra.
8
8
  */
9
9
  import type { MCPTool } from './types.js';
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Quantum Topology Tool - pr_quantum_topology
2
+ * Computational Topology Tool - pr_quantum_topology
3
3
  *
4
- * Computes quantum topology features including Betti numbers and persistence diagrams.
4
+ * Computes topological features including Betti numbers (b0, b1) and
5
+ * persistence diagrams via Vietoris-Rips filtration.
5
6
  * Analyzes topological features of point clouds and simplicial complexes.
6
- *
7
- * Uses QuantumEngine from prime-radiant-advanced-wasm
7
+ * b2 (voids) is not computed -- requires boundary-operator linear algebra.
8
8
  */
9
9
  import { TopologyInputSchema, successResult, errorResult, } from './types.js';
10
10
  // Default logger
@@ -163,14 +163,9 @@ function computeBettiNumbers(vertices, simplices, maxDimension) {
163
163
  const b1 = Math.max(0, edges - n + b0);
164
164
  bettiNumbers.push(b1);
165
165
  }
166
- // b2: Approximate from triangle/tetrahedron relationship
167
- if (maxDimension >= 2) {
168
- const triangles = simplexCounts[2] || 0;
169
- const tetrahedra = simplexCounts[3] || 0;
170
- // Simplified: b2 related to enclosed voids
171
- const b2 = Math.max(0, tetrahedra > 0 ? 1 : 0);
172
- bettiNumbers.push(b2);
173
- }
166
+ // b2 requires computing the rank of the boundary matrices (dim-2 and dim-3),
167
+ // which needs full boundary-operator linear algebra not implemented here.
168
+ // We do NOT fabricate b2 -- only b0 and b1 are reported.
174
169
  return bettiNumbers;
175
170
  }
176
171
  /**
@@ -256,7 +251,6 @@ function interpretBettiNumbers(bettiNumbers) {
256
251
  return {
257
252
  b0: `${bettiNumbers[0] || 0} connected component(s)`,
258
253
  b1: `${bettiNumbers[1] || 0} loop(s)/cycle(s)`,
259
- b2: `${bettiNumbers[2] || 0} void(s)/cavit${(bettiNumbers[2] || 0) === 1 ? 'y' : 'ies'}`,
260
254
  };
261
255
  }
262
256
  /**
@@ -274,7 +268,7 @@ async function handler(input, context) {
274
268
  }
275
269
  const { complex } = validationResult.data;
276
270
  const { vertices, maxDimension } = complex;
277
- logger.debug('Processing quantum topology', {
271
+ logger.debug('Processing computational topology', {
278
272
  vertexCount: vertices.length,
279
273
  maxDimension,
280
274
  });
@@ -338,7 +332,7 @@ async function handler(input, context) {
338
332
  },
339
333
  };
340
334
  const duration = performance.now() - startTime;
341
- logger.info('Quantum topology completed', {
335
+ logger.info('Topology computation completed', {
342
336
  bettiNumbers: bettiNumbers.join(', '),
343
337
  persistencePoints: persistenceDiagram.length,
344
338
  homologyClasses,
@@ -348,7 +342,7 @@ async function handler(input, context) {
348
342
  }
349
343
  catch (error) {
350
344
  const duration = performance.now() - startTime;
351
- logger.error('Quantum topology failed', {
345
+ logger.error('Topology computation failed', {
352
346
  error: error instanceof Error ? error.message : String(error),
353
347
  durationMs: duration.toFixed(2),
354
348
  });
@@ -360,7 +354,7 @@ async function handler(input, context) {
360
354
  */
361
355
  export const quantumTopologyTool = {
362
356
  name: 'pr_quantum_topology',
363
- description: 'Compute quantum topology features including Betti numbers and persistence diagrams. Analyzes topological features of point clouds. Uses QuantumEngine for persistent homology computation.',
357
+ description: 'Compute topological features via Vietoris-Rips filtration. Reports Betti numbers b0 (components) and b1 (loops) with persistence diagrams. b2 (voids) is not computed.',
364
358
  category: 'topology',
365
359
  version: '0.1.3',
366
360
  tags: ['topology', 'betti-numbers', 'persistence', 'homology', 'ai-interpretability'],
@@ -2,9 +2,8 @@
2
2
  * Spectral Analysis Tool - pr_spectral_analyze
3
3
  *
4
4
  * Analyzes stability of systems using spectral graph theory.
5
- * Computes eigenvalues, spectral gap, and stability metrics.
6
- *
7
- * Uses SpectralEngine from prime-radiant-advanced-wasm
5
+ * Computes eigenvalues via power iteration with Hotelling deflation,
6
+ * spectral gap, and stability metrics from the graph Laplacian.
8
7
  */
9
8
  import type { MCPTool } from './types.js';
10
9
  /**
@@ -2,9 +2,8 @@
2
2
  * Spectral Analysis Tool - pr_spectral_analyze
3
3
  *
4
4
  * Analyzes stability of systems using spectral graph theory.
5
- * Computes eigenvalues, spectral gap, and stability metrics.
6
- *
7
- * Uses SpectralEngine from prime-radiant-advanced-wasm
5
+ * Computes eigenvalues via power iteration with Hotelling deflation,
6
+ * spectral gap, and stability metrics from the graph Laplacian.
8
7
  */
9
8
  import { SpectralInputSchema, successResult, errorResult, } from './types.js';
10
9
  // Default logger
@@ -15,14 +14,32 @@ const defaultLogger = {
15
14
  error: (msg, meta) => console.error(`[pr_spectral_analyze] ${msg}`, meta),
16
15
  };
17
16
  /**
18
- * Power iteration method for finding dominant eigenvalue
17
+ * Simple deterministic hash to seed initial vectors reproducibly from matrix content
18
+ */
19
+ function matrixHash(matrix) {
20
+ let hash = 0;
21
+ for (let i = 0; i < matrix.length; i++) {
22
+ for (let j = 0; j < matrix[i].length; j++) {
23
+ // Combine with a simple LCG-style mixing
24
+ hash = ((hash * 1103515245 + 12345) & 0x7fffffff) ^ (matrix[i][j] * 1000003 | 0);
25
+ }
26
+ }
27
+ return hash;
28
+ }
29
+ /**
30
+ * Power iteration method for finding dominant eigenvalue.
31
+ * Returns both the eigenvalue and the converged eigenvector.
19
32
  */
20
- function powerIteration(matrix, maxIterations = 100, tolerance = 1e-10) {
33
+ function powerIteration(matrix, maxIterations = 100, tolerance = 1e-10, seed) {
21
34
  const n = matrix.length;
22
35
  if (n === 0)
23
- return 0;
24
- // Initialize random vector
25
- let v = new Array(n).fill(0).map(() => Math.random());
36
+ return { eigenvalue: 0, eigenvector: [] };
37
+ // Initialize with deterministic vector seeded from matrix content
38
+ let s = seed ?? matrixHash(matrix);
39
+ let v = new Array(n).fill(0).map(() => {
40
+ s = (s * 1103515245 + 12345) & 0x7fffffff;
41
+ return (s / 0x7fffffff) * 2 - 1;
42
+ });
26
43
  let eigenvalue = 0;
27
44
  for (let iter = 0; iter < maxIterations; iter++) {
28
45
  // Multiply matrix by vector
@@ -44,7 +61,7 @@ function powerIteration(matrix, maxIterations = 100, tolerance = 1e-10) {
44
61
  // Check convergence
45
62
  const newEigenvalue = maxComponent;
46
63
  if (Math.abs(newEigenvalue - eigenvalue) < tolerance) {
47
- return newEigenvalue;
64
+ return { eigenvalue: newEigenvalue, eigenvector: v };
48
65
  }
49
66
  eigenvalue = newEigenvalue;
50
67
  // Normalize
@@ -52,38 +69,40 @@ function powerIteration(matrix, maxIterations = 100, tolerance = 1e-10) {
52
69
  v[i] = w[i] / maxComponent;
53
70
  }
54
71
  }
55
- return eigenvalue;
72
+ return { eigenvalue, eigenvector: v };
56
73
  }
57
74
  /**
58
- * Compute approximate eigenvalues using QR iteration (simplified)
59
- * For production, consider using a proper numerical library
75
+ * Compute eigenvalues via repeated power-iteration with Hotelling deflation.
76
+ * Returns only eigenvalues actually computed (up to min(n, maxCount)).
77
+ * For production, consider using a proper numerical library.
60
78
  */
61
- function computeEigenvalues(matrix) {
79
+ function computeEigenvalues(matrix, maxCount = 10) {
62
80
  const n = matrix.length;
63
81
  if (n === 0)
64
82
  return [];
65
83
  if (n === 1)
66
84
  return [matrix[0][0]];
67
- // For small matrices, use characteristic polynomial roots (simplified)
68
- // For larger matrices, use power iteration for top k eigenvalues
69
85
  const eigenvalues = [];
70
- // Get dominant eigenvalue
71
- const lambda1 = powerIteration(matrix);
72
- eigenvalues.push(lambda1);
73
- // For spectral analysis, we mainly need the top eigenvalues and spectral gap
74
- // Use deflation to get second eigenvalue
75
- if (n > 1) {
76
- // Simplified: estimate second eigenvalue from trace
77
- let trace = 0;
86
+ // Work on a copy so deflation doesn't mutate the original
87
+ let current = matrix.map(row => [...row]);
88
+ const count = Math.min(n, maxCount);
89
+ for (let k = 0; k < count; k++) {
90
+ const { eigenvalue, eigenvector } = powerIteration(current, 200, 1e-10, matrixHash(current) + k);
91
+ // If power iteration didn't converge to anything meaningful, stop
92
+ if (Math.abs(eigenvalue) < 1e-12)
93
+ break;
94
+ eigenvalues.push(eigenvalue);
95
+ // Hotelling deflation: subtract lambda * v * v^T from the matrix
96
+ // to remove the dominant eigenvalue and find the next one
97
+ let vNorm = 0;
98
+ for (let i = 0; i < n; i++)
99
+ vNorm += eigenvector[i] * eigenvector[i];
100
+ if (vNorm < 1e-12)
101
+ break;
78
102
  for (let i = 0; i < n; i++) {
79
- trace += matrix[i][i];
80
- }
81
- // Second eigenvalue approximation
82
- const lambda2Approx = (trace - lambda1) / (n - 1);
83
- eigenvalues.push(lambda2Approx);
84
- // Add remaining approximate eigenvalues
85
- for (let i = 2; i < Math.min(n, 10); i++) {
86
- eigenvalues.push(lambda2Approx * (1 - i * 0.1)); // Decreasing approximation
103
+ for (let j = 0; j < n; j++) {
104
+ current[i][j] -= eigenvalue * (eigenvector[i] * eigenvector[j]) / vNorm;
105
+ }
87
106
  }
88
107
  }
89
108
  return eigenvalues.sort((a, b) => Math.abs(b) - Math.abs(a));
@@ -264,7 +283,7 @@ async function handler(input, context) {
264
283
  */
265
284
  export const spectralAnalyzeTool = {
266
285
  name: 'pr_spectral_analyze',
267
- description: 'Analyze stability using spectral graph theory. Computes eigenvalues, spectral gap, and stability metrics. Uses SpectralEngine for mathematical validation of system stability.',
286
+ description: 'Analyze stability using spectral graph theory. Computes eigenvalues via power iteration with Hotelling deflation, spectral gap, and stability metrics from the graph Laplacian.',
268
287
  category: 'spectral',
269
288
  version: '0.1.3',
270
289
  tags: ['spectral', 'eigenvalues', 'stability', 'graph-theory', 'ai-interpretability'],
@@ -162,15 +162,12 @@ export declare const CausalInputSchema: z.ZodObject<{
162
162
  }>;
163
163
  export type CausalInput = z.infer<typeof CausalInputSchema>;
164
164
  export interface CausalResult {
165
- effect: number;
166
165
  confounders: string[];
167
166
  interventionValid: boolean;
168
167
  backdoorPaths: string[][];
169
- confidence: number;
170
168
  }
171
169
  export interface CausalOutput {
172
- effect: number;
173
- confidence: number;
170
+ identifiability: number;
174
171
  backdoorPaths: string[];
175
172
  details: {
176
173
  confounders: string[];
@@ -240,8 +237,8 @@ export interface ConsensusOutput {
240
237
  details: {
241
238
  agreementRatio: number;
242
239
  coherenceEnergy: number;
243
- spectralStability: boolean;
244
- spectralGap: number;
240
+ connectivityStable: boolean;
241
+ degreeRatio: number;
245
242
  interpretation: string;
246
243
  agentCount: number;
247
244
  };
@@ -352,7 +349,6 @@ export interface TopologyOutput {
352
349
  interpretation: {
353
350
  b0: string;
354
351
  b1: string;
355
- b2: string;
356
352
  };
357
353
  vertexCount: number;
358
354
  maxDimension: number;
@@ -375,19 +371,19 @@ export declare const MemoryGateInputSchema: z.ZodObject<{
375
371
  }, "strip", z.ZodTypeAny, {
376
372
  key: string;
377
373
  value?: unknown;
374
+ existingVectors?: number[][] | undefined;
378
375
  thresholds?: {
379
376
  warn: number;
380
377
  reject: number;
381
378
  } | undefined;
382
- existingVectors?: number[][] | undefined;
383
379
  }, {
384
380
  key: string;
385
381
  value?: unknown;
382
+ existingVectors?: number[][] | undefined;
386
383
  thresholds?: {
387
384
  warn?: number | undefined;
388
385
  reject?: number | undefined;
389
386
  } | undefined;
390
- existingVectors?: number[][] | undefined;
391
387
  }>;
392
388
  export type MemoryGateInput = z.infer<typeof MemoryGateInputSchema>;
393
389
  export interface MemoryGateOutput {
@@ -85,9 +85,9 @@ const CAPABILITY_CATALOG = {
85
85
  },
86
86
  'intelligence-learning': {
87
87
  name: 'Intelligence & Learning',
88
- description: 'Neural pattern training (SONA), RL loops, Flash Attention, EWC++ consolidation.',
88
+ description: 'Pattern storage and cosine-similarity search (SONA/ReasoningBank) backed by real embeddings.',
89
89
  tools: ['neural_train', 'neural_predict', 'neural_status', 'neural_patterns', 'neural_optimize'],
90
- commands: ['neural train', 'neural predict', 'neural status', 'neural patterns', 'neural optimize'],
90
+ commands: [],
91
91
  agents: ['sona-learning-optimizer', 'safla-neural'],
92
92
  skills: ['reasoningbank-intelligence', 'memory-reasoningbank'],
93
93
  whenToUse: 'When optimizing agent routing, training patterns from outcomes, or adaptive learning.',
@@ -256,17 +256,28 @@ export const hiveMindTools = [
256
256
  updatedAt: now,
257
257
  };
258
258
  saveHiveState(state);
259
+ // Validate consensus strategy: gossip and crdt are planned but not implemented
260
+ const SUPPORTED_CONSENSUS = ['byzantine', 'bft', 'raft', 'quorum'];
261
+ const PLANNED_CONSENSUS = ['gossip', 'crdt'];
262
+ const requestedConsensus = input.consensus || 'byzantine';
263
+ const consensusWarning = PLANNED_CONSENSUS.includes(requestedConsensus)
264
+ ? `Strategy "${requestedConsensus}" is planned but not yet implemented; defaulting to "byzantine".`
265
+ : undefined;
266
+ const effectiveConsensus = PLANNED_CONSENSUS.includes(requestedConsensus)
267
+ ? 'byzantine'
268
+ : (SUPPORTED_CONSENSUS.includes(requestedConsensus) ? requestedConsensus : 'byzantine');
259
269
  return {
260
270
  success: true,
261
271
  hiveId,
262
272
  topology: state.topology,
263
- consensus: input.consensus || 'byzantine',
273
+ consensus: effectiveConsensus,
264
274
  queenId,
265
275
  neuralLearning: 'unavailable',
266
276
  status: 'initialized',
277
+ ...(consensusWarning ? { warning: consensusWarning } : {}),
267
278
  config: {
268
279
  topology: state.topology,
269
- consensus: input.consensus || 'byzantine',
280
+ consensus: effectiveConsensus,
270
281
  maxAgents: input.maxAgents || 15,
271
282
  persist: input.persist !== false,
272
283
  memoryBackend: input.memoryBackend || 'hybrid',
@@ -470,7 +481,18 @@ export const hiveMindTools = [
470
481
  handler: async (input) => {
471
482
  const state = loadHiveState();
472
483
  const action = input.action;
473
- const strategy = input.strategy || 'raft';
484
+ const rawStrategy = input.strategy || 'raft';
485
+ // Gossip and CRDT are planned but not yet implemented -- reject early
486
+ // with an honest message instead of silently falling through.
487
+ const UNIMPLEMENTED_STRATEGIES = ['gossip', 'crdt'];
488
+ if (UNIMPLEMENTED_STRATEGIES.includes(rawStrategy)) {
489
+ return {
490
+ action,
491
+ error: `Strategy "${rawStrategy}" is planned but not yet implemented. Available strategies: bft, raft, quorum.`,
492
+ availableStrategies: ['bft', 'raft', 'quorum'],
493
+ };
494
+ }
495
+ const strategy = rawStrategy;
474
496
  const totalNodes = state.workers.length;
475
497
  if (action === 'propose') {
476
498
  const proposalId = `proposal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
@@ -20,8 +20,5 @@ export declare const hooksBuildAgents: MCPTool;
20
20
  export declare const hooksTransfer: MCPTool;
21
21
  export declare const hooksSessionStart: MCPTool;
22
22
  export declare const hooksSessionEnd: MCPTool;
23
- export declare const hooksSessionRestore: MCPTool;
24
- export declare const hooksNotify: MCPTool;
25
- export declare const hooksInit: MCPTool;
26
23
  export declare const hooksIntelligence: MCPTool;
27
24
  //# sourceMappingURL=hooks-routing.d.ts.map