claude-flow-novice 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/.claude/agents/cfn-loop/product-owner.md +54 -4
  2. package/.claude/commands/cfn-claude-sync.md +303 -0
  3. package/.claude/commands/cfn-loop-epic.md +290 -0
  4. package/.claude/commands/cfn-loop-single.md +168 -0
  5. package/.claude/commands/cfn-loop-sprints.md +384 -0
  6. package/.claude/commands/cfn-loop.md +180 -0
  7. package/.claude/commands/metrics-summary.md +58 -0
  8. package/.claude/commands/parse-epic.md +357 -0
  9. package/.claude/settings.json +4 -4
  10. package/.claude/settings.local.json +9 -2
  11. package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
  12. package/.claude-flow-novice/dist/mcp/server.js +21 -2
  13. package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
  14. package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
  16. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
  17. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
  18. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
  19. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  20. package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
  21. package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
  22. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
  23. package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
  24. package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
  25. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
  26. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
  28. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
  30. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
  32. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
  33. package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
  34. package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
  35. package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
  36. package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
  37. package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
  38. package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
  39. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
  40. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
  41. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
  42. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
  44. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
  46. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
  48. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
  50. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
  52. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
  54. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
  56. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
  58. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
  60. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
  61. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
  62. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
  63. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
  64. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
  65. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
  66. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
  67. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
  68. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
  69. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
  70. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
  71. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
  72. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
  74. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
  76. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
  78. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
  80. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
  82. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
  84. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
  86. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
  88. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
  90. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
  92. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
  94. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
  96. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
  98. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
  100. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
  102. package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
  103. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
  104. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
  105. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
  106. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
  108. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
  110. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
  112. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
  114. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
  115. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
  116. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
  117. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
  118. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
  120. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
  122. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
  124. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
  126. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
  128. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
  130. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
  132. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
  134. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
  136. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
  137. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
  138. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
  139. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
  140. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
  142. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
  143. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
  144. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
  145. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
  146. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
  147. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
  148. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
  149. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
  150. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
  152. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
  154. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
  156. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
  158. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
  160. package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
  161. package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
  162. package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
  163. package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
  164. package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
  165. package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
  166. package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
  168. package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
  169. package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
  170. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  171. package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
  172. package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
  173. package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
  174. package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
  175. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
  176. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
  177. package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
  178. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
  179. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
  180. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
  181. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
  182. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
  183. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
  184. package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
  185. package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
  186. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
  187. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
  188. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
  189. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
  190. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
  191. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
  192. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
  193. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
  195. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
  197. package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
  198. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
  199. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
  201. package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
  203. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
  205. package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
  207. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
  209. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
  211. package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
  213. package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
  214. package/.claude-flow-novice/metrics.db +0 -0
  215. package/.claude-flow-novice/metrics.db-shm +0 -0
  216. package/.claude-flow-novice/metrics.db-wal +0 -0
  217. package/CLAUDE.md +29 -0
  218. package/README.md +27 -0
  219. package/config/hooks/post-edit-pipeline.js +36 -2
  220. package/examples/metrics-counter-demo.ts +106 -0
  221. package/examples/persistent-metrics-demo.ts +83 -0
  222. package/examples/phase-5-multi-level-control.ts +282 -0
  223. package/examples/session-pool-optimizer-example.ts +311 -0
  224. package/package.json +15 -3
  225. package/scripts/check-routing-stats.cjs +122 -0
  226. package/scripts/pre-publish-validation.cjs +212 -0
  227. package/scripts/test-provider-routing.cjs +228 -0
  228. package/scripts/test-routing-telemetry.cjs +147 -0
  229. package/scripts/test-zai-10k.cjs +81 -0
  230. package/scripts/test-zai-api.cjs +191 -0
  231. package/scripts/test-zai-diagnostic.cjs +151 -0
  232. package/scripts/test-zai-final.cjs +128 -0
  233. package/scripts/test-zai-with-env.cjs +85 -0
  234. package/scripts/validate-coordination-cli.js +69 -0
  235. package/scripts/validate-coordination-toggle-integration.cjs +501 -0
  236. package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
  237. package/src/observability/metrics-counter.ts +347 -0
  238. package/src/observability/metrics-storage.ts +356 -0
  239. package/src/observability/telemetry.ts +658 -0
  240. package/src/slash-commands/cfn-claude-sync.js +533 -0
  241. package/src/slash-commands/index.js +5 -0
  242. package/src/slash-commands/metrics-summary-class.js +74 -0
  243. package/src/slash-commands/metrics-summary.js +335 -0
  244. package/src/slash-commands/register-all-commands.js +12 -0
@@ -0,0 +1,424 @@
1
+ /**
2
+ * Deadlock Detection Engine
3
+ *
4
+ * Implements Tarjan's strongly connected components (SCC) algorithm for efficient
5
+ * cycle detection in agent dependency graphs. Detects circular wait conditions
6
+ * in <50ms for graphs with 50+ nodes.
7
+ *
8
+ * @module coordination/v2/deadlock/deadlock-detector
9
+ */ import { EventEmitter } from 'events';
10
+ /**
11
+ * Deadlock Detection Engine using Tarjan's SCC algorithm
12
+ *
13
+ * Efficiently detects circular wait conditions in agent dependency graphs.
14
+ * Emits events when deadlocks are detected for resolution handling.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const detector = new DeadlockDetector({
19
+ * detectionInterval: 500,
20
+ * maxDetectionTime: 50
21
+ * });
22
+ *
23
+ * detector.on('deadlock', (cycle: DeadlockCycle) => {
24
+ * console.log(`Deadlock detected: ${cycle.agents.join(' -> ')}`);
25
+ * });
26
+ *
27
+ * // Register agents and dependencies
28
+ * detector.registerAgent('agent-1', { state: 'waiting', priority: 5 });
29
+ * detector.addDependency('agent-1', 'agent-2', 'agent');
30
+ *
31
+ * // Start automatic detection
32
+ * detector.startDetection();
33
+ * ```
34
+ */ export class DeadlockDetector extends EventEmitter {
35
+ config;
36
+ agents = new Map();
37
+ detectionTimer;
38
+ metrics;
39
+ index = 0;
40
+ stack = [];
41
+ tarjanData = new Map();
42
+ operationLock = Promise.resolve();
43
+ constructor(config = {}){
44
+ super(), this.config = config;
45
+ this.metrics = {
46
+ totalDetections: 0,
47
+ deadlocksDetected: 0,
48
+ avgDetectionTime: 0,
49
+ maxDetectionTime: 0,
50
+ lastDetectionTime: 0,
51
+ graphSize: 0
52
+ };
53
+ }
54
+ /**
55
+ * Register an agent in the dependency graph
56
+ *
57
+ * @param agentId - Unique agent identifier
58
+ * @param options - Agent configuration
59
+ */ registerAgent(agentId, options = {}) {
60
+ const maxAgents = this.config.maxAgents || 1000;
61
+ if (this.agents.size >= maxAgents && !this.agents.has(agentId)) {
62
+ throw new Error(`Agent limit reached (${maxAgents} max)`);
63
+ }
64
+ const node = {
65
+ agentId,
66
+ holdingResources: new Set(options.holdingResources || []),
67
+ waitingForResources: new Set(options.waitingForResources || []),
68
+ state: options.state || 'idle',
69
+ stateChangedAt: Date.now(),
70
+ priority: options.priority
71
+ };
72
+ this.agents.set(agentId, node);
73
+ }
74
+ /**
75
+ * Unregister an agent from the dependency graph
76
+ *
77
+ * @param agentId - Agent identifier to remove
78
+ */ unregisterAgent(agentId) {
79
+ this.agents.delete(agentId);
80
+ }
81
+ /**
82
+ * Add a dependency relationship between agents/resources
83
+ *
84
+ * @param fromAgentId - Agent waiting for resource
85
+ * @param toResourceId - Resource or agent being waited on
86
+ * @param resourceType - Type of the resource
87
+ */ async addDependency(fromAgentId, toResourceId, resourceType = 'other') {
88
+ return this.withLock(async ()=>{
89
+ const agent = this.agents.get(fromAgentId);
90
+ if (!agent) {
91
+ throw new Error(`Agent not registered: ${fromAgentId}`);
92
+ }
93
+ // SEC-DOS-001: Enforce edge limit per agent
94
+ const maxEdgesPerAgent = this.config.maxEdgesPerAgent || 100;
95
+ if (agent.waitingForResources.size >= maxEdgesPerAgent) {
96
+ throw new Error(`Edge limit reached for agent ${fromAgentId} (${maxEdgesPerAgent} max)`);
97
+ }
98
+ agent.waitingForResources.add(toResourceId);
99
+ // If resource is another agent, update their holding resources
100
+ if (resourceType === 'agent') {
101
+ const targetAgent = this.agents.get(toResourceId);
102
+ if (targetAgent) {
103
+ targetAgent.holdingResources.add(fromAgentId);
104
+ }
105
+ }
106
+ });
107
+ }
108
+ /**
109
+ * Remove a dependency relationship
110
+ *
111
+ * @param fromAgentId - Agent that was waiting
112
+ * @param toResourceId - Resource that was being waited on
113
+ */ async removeDependency(fromAgentId, toResourceId) {
114
+ return this.withLock(async ()=>{
115
+ const agent = this.agents.get(fromAgentId);
116
+ if (agent) {
117
+ agent.waitingForResources.delete(toResourceId);
118
+ }
119
+ const targetAgent = this.agents.get(toResourceId);
120
+ if (targetAgent) {
121
+ targetAgent.holdingResources.delete(fromAgentId);
122
+ }
123
+ });
124
+ }
125
+ /**
126
+ * Update agent state
127
+ *
128
+ * @param agentId - Agent to update
129
+ * @param state - New state
130
+ */ updateAgentState(agentId, state) {
131
+ const agent = this.agents.get(agentId);
132
+ if (agent) {
133
+ agent.state = state;
134
+ agent.stateChangedAt = Date.now();
135
+ }
136
+ }
137
+ /**
138
+ * Detect deadlocks using Tarjan's SCC algorithm
139
+ *
140
+ * Finds all strongly connected components in the wait-for graph.
141
+ * Components with size ≥ minCycleLength are considered deadlocks.
142
+ *
143
+ * @returns Array of detected deadlock cycles
144
+ */ async detectDeadlocks() {
145
+ const maxDetectionTime = this.config.maxDetectionTime || 50;
146
+ const controller = new AbortController();
147
+ const timeout = setTimeout(()=>controller.abort(), maxDetectionTime);
148
+ try {
149
+ return await this.detectWithTimeout(controller.signal);
150
+ } catch (error) {
151
+ if (controller.signal.aborted) {
152
+ this.emit('warning', {
153
+ type: 'detection-timeout',
154
+ maxTime: maxDetectionTime,
155
+ graphSize: this.agents.size
156
+ });
157
+ return []; // Return empty on timeout to prevent hanging
158
+ }
159
+ throw error;
160
+ } finally{
161
+ clearTimeout(timeout);
162
+ }
163
+ }
164
+ /**
165
+ * Internal detection with timeout enforcement (SEC-DOS-002)
166
+ *
167
+ * @param signal - AbortSignal for timeout control
168
+ * @returns Array of detected deadlock cycles
169
+ */ async detectWithTimeout(signal) {
170
+ const startTime = performance.now();
171
+ const cycles = [];
172
+ // Reset Tarjan algorithm state
173
+ this.index = 0;
174
+ this.stack = [];
175
+ this.tarjanData.clear();
176
+ // Run Tarjan's algorithm for each unvisited node
177
+ for (const agentId of Array.from(this.agents.keys())){
178
+ if (signal.aborted) {
179
+ throw new Error('Detection aborted due to timeout');
180
+ }
181
+ if (!this.tarjanData.has(agentId)) {
182
+ this.strongConnect(agentId, cycles);
183
+ }
184
+ }
185
+ // Update metrics
186
+ const detectionTime = performance.now() - startTime;
187
+ this.updateMetrics(detectionTime, cycles.length);
188
+ // Emit deadlock events
189
+ cycles.forEach((cycle)=>{
190
+ this.emit('deadlock', cycle);
191
+ });
192
+ // Check if detection exceeded time limit
193
+ if (this.config.maxDetectionTime && detectionTime > this.config.maxDetectionTime) {
194
+ this.emit('warning', {
195
+ type: 'slow-detection',
196
+ detectionTime,
197
+ maxTime: this.config.maxDetectionTime,
198
+ graphSize: this.agents.size
199
+ });
200
+ }
201
+ return cycles;
202
+ }
203
+ /**
204
+ * Tarjan's strongly connected components algorithm (recursive DFS)
205
+ *
206
+ * @param agentId - Current agent being visited
207
+ * @param cycles - Array to collect detected cycles
208
+ */ strongConnect(agentId, cycles) {
209
+ const agent = this.agents.get(agentId);
210
+ if (!agent) return;
211
+ // Initialize node data
212
+ const nodeData = {
213
+ index: this.index,
214
+ lowLink: this.index,
215
+ onStack: true
216
+ };
217
+ this.tarjanData.set(agentId, nodeData);
218
+ this.index++;
219
+ this.stack.push(agentId);
220
+ // Visit all waiting dependencies
221
+ for (const waitingFor of Array.from(agent.waitingForResources)){
222
+ // Only follow agent dependencies for cycle detection
223
+ const waitingAgent = this.agents.get(waitingFor);
224
+ if (!waitingAgent) continue;
225
+ const waitingData = this.tarjanData.get(waitingFor);
226
+ if (!waitingData) {
227
+ // Not visited yet, recurse
228
+ this.strongConnect(waitingFor, cycles);
229
+ const updatedWaitingData = this.tarjanData.get(waitingFor);
230
+ nodeData.lowLink = Math.min(nodeData.lowLink, updatedWaitingData.lowLink);
231
+ } else if (waitingData.onStack) {
232
+ // Already on stack, found back edge
233
+ nodeData.lowLink = Math.min(nodeData.lowLink, waitingData.index);
234
+ }
235
+ }
236
+ // If this is a root node, extract SCC
237
+ if (nodeData.lowLink === nodeData.index) {
238
+ const scc = [];
239
+ let currentAgentId;
240
+ do {
241
+ currentAgentId = this.stack.pop();
242
+ const currentData = this.tarjanData.get(currentAgentId);
243
+ currentData.onStack = false;
244
+ scc.push(currentAgentId);
245
+ }while (currentAgentId !== agentId)
246
+ // Check if SCC is a deadlock (cycle with ≥ minCycleLength nodes)
247
+ const minCycleLength = this.config.minCycleLength || 2;
248
+ if (scc.length >= minCycleLength) {
249
+ const cycle = this.createDeadlockCycle(scc);
250
+ cycles.push(cycle);
251
+ }
252
+ }
253
+ }
254
+ /**
255
+ * Create a DeadlockCycle object from detected SCC
256
+ *
257
+ * @param agentIds - Agents involved in the cycle
258
+ * @returns Deadlock cycle metadata
259
+ */ createDeadlockCycle(agentIds) {
260
+ const resources = new Set();
261
+ let totalPriority = 0;
262
+ // Collect all resources and calculate severity
263
+ agentIds.forEach((agentId)=>{
264
+ const agent = this.agents.get(agentId);
265
+ if (agent) {
266
+ agent.waitingForResources.forEach((res)=>resources.add(res));
267
+ totalPriority += agent.priority || 0;
268
+ }
269
+ });
270
+ // Calculate severity (higher for longer cycles and higher priority agents)
271
+ const severity = agentIds.length * 10 + (totalPriority / agentIds.length || 0);
272
+ // Determine resolution strategy (prioritize cycle complexity)
273
+ let resolution = 'abort';
274
+ if (agentIds.length === 2) {
275
+ resolution = 'priority-based'; // Simple cycle, use priority
276
+ } else if (agentIds.length > 5) {
277
+ resolution = 'timeout'; // Complex cycle, use timeout
278
+ } else if (severity > 50) {
279
+ resolution = 'rollback'; // High priority agents, try rollback
280
+ }
281
+ return {
282
+ cycleId: `cycle-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
283
+ agents: agentIds,
284
+ resources: Array.from(resources),
285
+ detectedAt: Date.now(),
286
+ severity,
287
+ resolution
288
+ };
289
+ }
290
+ /**
291
+ * Update detection metrics
292
+ *
293
+ * @param detectionTime - Time taken for detection in ms
294
+ * @param cyclesFound - Number of cycles detected
295
+ */ updateMetrics(detectionTime, cyclesFound) {
296
+ if (!this.config.enableMetrics) return;
297
+ this.metrics.totalDetections++;
298
+ this.metrics.deadlocksDetected += cyclesFound;
299
+ this.metrics.lastDetectionTime = detectionTime;
300
+ this.metrics.maxDetectionTime = Math.max(this.metrics.maxDetectionTime, detectionTime);
301
+ this.metrics.graphSize = this.agents.size;
302
+ // Calculate running average
303
+ const totalTime = this.metrics.avgDetectionTime * (this.metrics.totalDetections - 1) + detectionTime;
304
+ this.metrics.avgDetectionTime = totalTime / this.metrics.totalDetections;
305
+ }
306
+ /**
307
+ * Start automatic deadlock detection
308
+ *
309
+ * Runs detection at configured intervals
310
+ */ startDetection() {
311
+ if (this.detectionTimer) {
312
+ return; // Already running
313
+ }
314
+ const interval = this.config.detectionInterval || 1000;
315
+ this.detectionTimer = setInterval(()=>{
316
+ if (this.agents.size > 0) {
317
+ this.detectDeadlocks().catch((error)=>{
318
+ this.emit('error', {
319
+ type: 'detection-error',
320
+ error: error instanceof Error ? error.message : String(error)
321
+ });
322
+ });
323
+ }
324
+ }, interval);
325
+ this.emit('detection-started', {
326
+ interval
327
+ });
328
+ }
329
+ /**
330
+ * Stop automatic deadlock detection
331
+ */ stopDetection() {
332
+ if (this.detectionTimer) {
333
+ clearInterval(this.detectionTimer);
334
+ this.detectionTimer = undefined;
335
+ this.emit('detection-stopped');
336
+ }
337
+ }
338
+ /**
339
+ * Get current detection metrics
340
+ *
341
+ * @returns Performance metrics
342
+ */ getMetrics() {
343
+ return {
344
+ ...this.metrics
345
+ };
346
+ }
347
+ /**
348
+ * Get current dependency graph state
349
+ *
350
+ * @returns Map of agent nodes
351
+ */ getGraph() {
352
+ return new Map(this.agents);
353
+ }
354
+ /**
355
+ * Clear all agents and dependencies
356
+ */ clear() {
357
+ this.agents.clear();
358
+ this.tarjanData.clear();
359
+ this.stack = [];
360
+ this.index = 0;
361
+ }
362
+ /**
363
+ * Export graph to DOT format for visualization
364
+ *
365
+ * @returns DOT format string
366
+ */ toDot() {
367
+ let dot = 'digraph WaitForGraph {\n';
368
+ dot += ' rankdir=LR;\n';
369
+ dot += ' node [shape=box];\n\n';
370
+ // Add nodes
371
+ for (const [agentId, agent] of Array.from(this.agents)){
372
+ let color = 'white';
373
+ if (agent.state === 'waiting') color = 'yellow';
374
+ if (agent.state === 'blocked') color = 'red';
375
+ if (agent.state === 'working') color = 'lightgreen';
376
+ dot += ` "${agentId}" [style=filled, fillcolor=${color}, label="${agentId}\\n${agent.state}"];\n`;
377
+ }
378
+ dot += '\n';
379
+ // Add edges (wait-for relationships)
380
+ for (const [agentId, agent] of Array.from(this.agents)){
381
+ for (const waitingFor of Array.from(agent.waitingForResources)){
382
+ dot += ` "${agentId}" -> "${waitingFor}" [label="waits for"];\n`;
383
+ }
384
+ }
385
+ dot += '}\n';
386
+ return dot;
387
+ }
388
+ /**
389
+ * Cleanup resources
390
+ */ destroy() {
391
+ this.stopDetection();
392
+ this.clear();
393
+ this.removeAllListeners();
394
+ }
395
+ /**
396
+ * Lock helper for atomic operations (SEC-RACE-001 fix)
397
+ *
398
+ * Prevents TOCTOU race conditions by ensuring exclusive access
399
+ * to shared state during critical sections.
400
+ *
401
+ * Rust equivalent pattern:
402
+ * ```rust
403
+ * async fn with_lock<T, F>(&self, f: F) -> T
404
+ * where F: FnOnce() -> T {
405
+ * let _guard = self.lock.lock().await;
406
+ * f()
407
+ * }
408
+ * ```
409
+ */ async withLock(fn) {
410
+ const currentLock = this.operationLock;
411
+ let resolveLock;
412
+ this.operationLock = new Promise((resolve)=>{
413
+ resolveLock = resolve;
414
+ });
415
+ try {
416
+ await currentLock;
417
+ return await fn();
418
+ } finally{
419
+ resolveLock();
420
+ }
421
+ }
422
+ }
423
+
424
+ //# sourceMappingURL=deadlock-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/coordination/v2/deadlock/deadlock-detector.ts"],"names":["EventEmitter","DeadlockDetector","agents","Map","detectionTimer","metrics","index","stack","tarjanData","operationLock","Promise","resolve","config","totalDetections","deadlocksDetected","avgDetectionTime","maxDetectionTime","lastDetectionTime","graphSize","registerAgent","agentId","options","maxAgents","size","has","Error","node","holdingResources","Set","waitingForResources","state","stateChangedAt","Date","now","priority","set","unregisterAgent","delete","addDependency","fromAgentId","toResourceId","resourceType","withLock","agent","get","maxEdgesPerAgent","add","targetAgent","removeDependency","updateAgentState","detectDeadlocks","controller","AbortController","timeout","setTimeout","abort","detectWithTimeout","signal","error","aborted","emit","type","maxTime","clearTimeout","startTime","performance","cycles","clear","Array","from","keys","strongConnect","detectionTime","updateMetrics","length","forEach","cycle","nodeData","lowLink","onStack","push","waitingFor","waitingAgent","waitingData","updatedWaitingData","Math","min","scc","currentAgentId","pop","currentData","minCycleLength","createDeadlockCycle","agentIds","resources","totalPriority","res","severity","resolution","cycleId","random","toString","slice","detectedAt","cyclesFound","enableMetrics","max","totalTime","startDetection","interval","detectionInterval","setInterval","catch","message","String","stopDetection","clearInterval","undefined","getMetrics","getGraph","toDot","dot","color","destroy","removeAllListeners","fn","currentLock","resolveLock"],"mappings":"AAAA;;;;;;;;CAQC,GAED,SAASA,YAAY,QAAQ,SAAS;AAmGtC;;;;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AQ;YAEvCD,OAAO,CAAC,GAAG,EAAErG,QAAQ,2BAA2B,EAAEsG,MAAM,SAAS,EAAEtG,QAAQ,GAAG,EAAEuB,MAAMb,KAAK,CAAC,KAAK,CAAC;QACpG;QAEA2F,OAAO;QAEP,qCAAqC;QACrC,KAAK,MAAM,CAACrG,SAASuB,MAAM,IAAIyB,MAAMC,IAAI,CAAC,IAAI,CAACnE,MAAM,EAAG;YACtD,KAAK,MAAM+E,cAAcb,MAAMC,IAAI,CAAC1B,MAAMd,mBAAmB,EAAG;gBAC9D4F,OAAO,CAAC,GAAG,EAAErG,QAAQ,MAAM,EAAE6D,WAAW,wBAAwB,CAAC;YACnE;QACF;QAEAwC,OAAO;QACP,OAAOA;IACT;IAEA;;GAEC,GACDE,UAAgB;QACd,IAAI,CAACR,aAAa;QAClB,IAAI,CAAChD,KAAK;QACV,IAAI,CAACyD,kBAAkB;IACzB;IAEA;;;;;;;;;;;;;;GAcC,GACD,MAAclF,SAAYmF,EAAoB,EAAc;QAC1D,MAAMC,cAAc,IAAI,CAACrH,aAAa;QACtC,IAAIsH;QACJ,IAAI,CAACtH,aAAa,GAAG,IAAIC,QAAQ,CAACC;YAChCoH,cAAcpH;QAChB;QAEA,IAAI;YACF,MAAMmH;YACN,OAAO,MAAMD;QACf,SAAU;YACRE;QACF;IACF;AACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Deadlock Detection & Recovery Module
3
+ *
4
+ * Export deadlock detection components for agent coordination
5
+ *
6
+ * @module coordination/v2/deadlock
7
+ */ export { DeadlockDetector } from './deadlock-detector.js';
8
+
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../src/coordination/v2/deadlock/index.ts"],"names":["DeadlockDetector"],"mappings":"AAAA;;;;;;CAMC,GAED,SACEA,gBAAgB,QAMX,yBAAyB"}