musubi-sdd 5.0.0 → 5.6.1

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 (232) hide show
  1. package/README.ja.md +106 -48
  2. package/README.md +110 -32
  3. package/bin/musubi-analyze.js +74 -67
  4. package/bin/musubi-browser.js +27 -26
  5. package/bin/musubi-change.js +48 -47
  6. package/bin/musubi-checkpoint.js +10 -7
  7. package/bin/musubi-convert.js +25 -25
  8. package/bin/musubi-costs.js +27 -10
  9. package/bin/musubi-gui.js +52 -46
  10. package/bin/musubi-init.js +1952 -10
  11. package/bin/musubi-orchestrate.js +327 -239
  12. package/bin/musubi-remember.js +69 -56
  13. package/bin/musubi-resolve.js +53 -45
  14. package/bin/musubi-trace.js +51 -22
  15. package/bin/musubi-validate.js +39 -30
  16. package/bin/musubi-workflow.js +33 -34
  17. package/bin/musubi.js +39 -2
  18. package/package.json +1 -1
  19. package/src/agents/agent-loop.js +94 -95
  20. package/src/agents/agentic/code-generator.js +119 -109
  21. package/src/agents/agentic/code-reviewer.js +105 -108
  22. package/src/agents/agentic/index.js +4 -4
  23. package/src/agents/browser/action-executor.js +13 -13
  24. package/src/agents/browser/ai-comparator.js +11 -10
  25. package/src/agents/browser/context-manager.js +6 -6
  26. package/src/agents/browser/index.js +5 -5
  27. package/src/agents/browser/nl-parser.js +31 -46
  28. package/src/agents/browser/screenshot.js +2 -2
  29. package/src/agents/browser/test-generator.js +6 -4
  30. package/src/agents/function-tool.js +71 -65
  31. package/src/agents/index.js +7 -7
  32. package/src/agents/schema-generator.js +98 -94
  33. package/src/analyzers/ast-extractor.js +164 -145
  34. package/src/analyzers/codegraph-auto-update.js +858 -0
  35. package/src/analyzers/complexity-analyzer.js +536 -0
  36. package/src/analyzers/context-optimizer.js +247 -125
  37. package/src/analyzers/impact-analyzer.js +1 -1
  38. package/src/analyzers/large-project-analyzer.js +766 -0
  39. package/src/analyzers/repository-map.js +83 -80
  40. package/src/analyzers/security-analyzer.js +19 -11
  41. package/src/analyzers/stuck-detector.js +19 -17
  42. package/src/converters/index.js +78 -57
  43. package/src/converters/ir/types.js +12 -12
  44. package/src/converters/parsers/musubi-parser.js +134 -126
  45. package/src/converters/parsers/openapi-parser.js +70 -53
  46. package/src/converters/parsers/speckit-parser.js +239 -175
  47. package/src/converters/writers/musubi-writer.js +123 -118
  48. package/src/converters/writers/speckit-writer.js +124 -113
  49. package/src/generators/rust-migration-generator.js +512 -0
  50. package/src/gui/public/index.html +1365 -1211
  51. package/src/gui/server.js +41 -40
  52. package/src/gui/services/file-watcher.js +23 -8
  53. package/src/gui/services/project-scanner.js +26 -20
  54. package/src/gui/services/replanning-service.js +27 -23
  55. package/src/gui/services/traceability-service.js +8 -8
  56. package/src/gui/services/workflow-service.js +14 -7
  57. package/src/index.js +151 -0
  58. package/src/integrations/cicd.js +90 -104
  59. package/src/integrations/codegraph-mcp.js +643 -0
  60. package/src/integrations/documentation.js +142 -103
  61. package/src/integrations/examples.js +95 -80
  62. package/src/integrations/github-client.js +17 -17
  63. package/src/integrations/index.js +5 -5
  64. package/src/integrations/mcp/index.js +21 -21
  65. package/src/integrations/mcp/mcp-context-provider.js +76 -78
  66. package/src/integrations/mcp/mcp-discovery.js +74 -72
  67. package/src/integrations/mcp/mcp-tool-registry.js +99 -94
  68. package/src/integrations/mcp-connector.js +70 -66
  69. package/src/integrations/platforms.js +50 -49
  70. package/src/integrations/tool-discovery.js +37 -31
  71. package/src/llm-providers/anthropic-provider.js +11 -11
  72. package/src/llm-providers/base-provider.js +16 -18
  73. package/src/llm-providers/copilot-provider.js +22 -19
  74. package/src/llm-providers/index.js +26 -25
  75. package/src/llm-providers/ollama-provider.js +11 -11
  76. package/src/llm-providers/openai-provider.js +12 -12
  77. package/src/managers/agent-memory.js +36 -24
  78. package/src/managers/checkpoint-manager.js +4 -8
  79. package/src/managers/delta-spec.js +19 -19
  80. package/src/managers/index.js +13 -4
  81. package/src/managers/memory-condenser.js +35 -45
  82. package/src/managers/repo-skill-manager.js +57 -31
  83. package/src/managers/skill-loader.js +25 -22
  84. package/src/managers/skill-tools.js +36 -72
  85. package/src/managers/workflow.js +30 -22
  86. package/src/monitoring/cost-tracker.js +53 -44
  87. package/src/monitoring/incident-manager.js +123 -103
  88. package/src/monitoring/index.js +144 -134
  89. package/src/monitoring/observability.js +82 -59
  90. package/src/monitoring/quality-dashboard.js +51 -39
  91. package/src/monitoring/release-manager.js +70 -50
  92. package/src/orchestration/agent-skill-binding.js +39 -47
  93. package/src/orchestration/error-handler.js +65 -107
  94. package/src/orchestration/guardrails/base-guardrail.js +26 -24
  95. package/src/orchestration/guardrails/guardrail-rules.js +50 -64
  96. package/src/orchestration/guardrails/index.js +5 -5
  97. package/src/orchestration/guardrails/input-guardrail.js +58 -45
  98. package/src/orchestration/guardrails/output-guardrail.js +104 -81
  99. package/src/orchestration/guardrails/safety-check.js +79 -79
  100. package/src/orchestration/index.js +38 -55
  101. package/src/orchestration/mcp-tool-adapters.js +96 -99
  102. package/src/orchestration/orchestration-engine.js +21 -21
  103. package/src/orchestration/pattern-registry.js +60 -45
  104. package/src/orchestration/patterns/auto.js +34 -47
  105. package/src/orchestration/patterns/group-chat.js +59 -65
  106. package/src/orchestration/patterns/handoff.js +67 -65
  107. package/src/orchestration/patterns/human-in-loop.js +51 -72
  108. package/src/orchestration/patterns/nested.js +25 -40
  109. package/src/orchestration/patterns/sequential.js +35 -34
  110. package/src/orchestration/patterns/swarm.js +63 -56
  111. package/src/orchestration/patterns/triage.js +150 -109
  112. package/src/orchestration/reasoning/index.js +9 -9
  113. package/src/orchestration/reasoning/planning-engine.js +143 -140
  114. package/src/orchestration/reasoning/reasoning-engine.js +206 -144
  115. package/src/orchestration/reasoning/self-correction.js +121 -128
  116. package/src/orchestration/replanning/adaptive-goal-modifier.js +107 -112
  117. package/src/orchestration/replanning/alternative-generator.js +37 -42
  118. package/src/orchestration/replanning/config.js +63 -59
  119. package/src/orchestration/replanning/goal-progress-tracker.js +98 -100
  120. package/src/orchestration/replanning/index.js +24 -20
  121. package/src/orchestration/replanning/plan-evaluator.js +49 -50
  122. package/src/orchestration/replanning/plan-monitor.js +32 -28
  123. package/src/orchestration/replanning/proactive-path-optimizer.js +175 -178
  124. package/src/orchestration/replanning/replan-history.js +33 -26
  125. package/src/orchestration/replanning/replanning-engine.js +106 -108
  126. package/src/orchestration/skill-executor.js +107 -109
  127. package/src/orchestration/skill-registry.js +85 -89
  128. package/src/orchestration/workflow-examples.js +228 -231
  129. package/src/orchestration/workflow-executor.js +65 -68
  130. package/src/orchestration/workflow-orchestrator.js +72 -73
  131. package/src/phase4-integration.js +47 -40
  132. package/src/phase5-integration.js +89 -30
  133. package/src/reporters/coverage-report.js +82 -30
  134. package/src/reporters/hierarchical-reporter.js +498 -0
  135. package/src/reporters/traceability-matrix-report.js +29 -20
  136. package/src/resolvers/issue-resolver.js +43 -31
  137. package/src/steering/advanced-validation.js +133 -124
  138. package/src/steering/auto-updater.js +60 -73
  139. package/src/steering/index.js +6 -6
  140. package/src/steering/quality-metrics.js +41 -35
  141. package/src/steering/steering-auto-update.js +83 -86
  142. package/src/steering/steering-validator.js +98 -106
  143. package/src/steering/template-constraints.js +53 -54
  144. package/src/templates/agents/claude-code/CLAUDE.md +32 -32
  145. package/src/templates/agents/claude-code/skills/agent-assistant/SKILL.md +13 -5
  146. package/src/templates/agents/claude-code/skills/ai-ml-engineer/mlops-guide.md +23 -23
  147. package/src/templates/agents/claude-code/skills/ai-ml-engineer/model-card-template.md +60 -41
  148. package/src/templates/agents/claude-code/skills/api-designer/api-patterns.md +27 -19
  149. package/src/templates/agents/claude-code/skills/api-designer/openapi-template.md +11 -7
  150. package/src/templates/agents/claude-code/skills/bug-hunter/SKILL.md +4 -3
  151. package/src/templates/agents/claude-code/skills/bug-hunter/root-cause-analysis.md +37 -15
  152. package/src/templates/agents/claude-code/skills/change-impact-analyzer/dependency-graph-patterns.md +36 -42
  153. package/src/templates/agents/claude-code/skills/change-impact-analyzer/impact-analysis-template.md +69 -60
  154. package/src/templates/agents/claude-code/skills/cloud-architect/aws-patterns.md +31 -38
  155. package/src/templates/agents/claude-code/skills/cloud-architect/azure-patterns.md +28 -23
  156. package/src/templates/agents/claude-code/skills/code-reviewer/SKILL.md +61 -0
  157. package/src/templates/agents/claude-code/skills/code-reviewer/best-practices.md +27 -0
  158. package/src/templates/agents/claude-code/skills/code-reviewer/review-checklist.md +29 -10
  159. package/src/templates/agents/claude-code/skills/code-reviewer/review-standards.md +29 -24
  160. package/src/templates/agents/claude-code/skills/constitution-enforcer/SKILL.md +8 -6
  161. package/src/templates/agents/claude-code/skills/constitution-enforcer/constitutional-articles.md +62 -26
  162. package/src/templates/agents/claude-code/skills/constitution-enforcer/phase-minus-one-gates.md +35 -16
  163. package/src/templates/agents/claude-code/skills/database-administrator/backup-recovery.md +27 -17
  164. package/src/templates/agents/claude-code/skills/database-administrator/tuning-guide.md +25 -20
  165. package/src/templates/agents/claude-code/skills/database-schema-designer/schema-patterns.md +39 -22
  166. package/src/templates/agents/claude-code/skills/devops-engineer/ci-cd-templates.md +25 -22
  167. package/src/templates/agents/claude-code/skills/issue-resolver/SKILL.md +24 -21
  168. package/src/templates/agents/claude-code/skills/orchestrator/SKILL.md +148 -63
  169. package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +35 -16
  170. package/src/templates/agents/claude-code/skills/orchestrator/selection-matrix.md +69 -64
  171. package/src/templates/agents/claude-code/skills/performance-engineer/optimization-playbook.md +47 -47
  172. package/src/templates/agents/claude-code/skills/performance-optimizer/SKILL.md +69 -0
  173. package/src/templates/agents/claude-code/skills/performance-optimizer/benchmark-template.md +63 -45
  174. package/src/templates/agents/claude-code/skills/performance-optimizer/optimization-patterns.md +33 -35
  175. package/src/templates/agents/claude-code/skills/project-manager/SKILL.md +7 -6
  176. package/src/templates/agents/claude-code/skills/project-manager/agile-ceremonies.md +47 -28
  177. package/src/templates/agents/claude-code/skills/project-manager/project-templates.md +94 -78
  178. package/src/templates/agents/claude-code/skills/quality-assurance/SKILL.md +20 -17
  179. package/src/templates/agents/claude-code/skills/quality-assurance/qa-plan-template.md +63 -49
  180. package/src/templates/agents/claude-code/skills/release-coordinator/SKILL.md +5 -5
  181. package/src/templates/agents/claude-code/skills/release-coordinator/feature-flag-guide.md +30 -26
  182. package/src/templates/agents/claude-code/skills/release-coordinator/release-plan-template.md +67 -35
  183. package/src/templates/agents/claude-code/skills/requirements-analyst/ears-format.md +54 -42
  184. package/src/templates/agents/claude-code/skills/requirements-analyst/validation-rules.md +36 -33
  185. package/src/templates/agents/claude-code/skills/security-auditor/SKILL.md +77 -19
  186. package/src/templates/agents/claude-code/skills/security-auditor/audit-checklists.md +24 -24
  187. package/src/templates/agents/claude-code/skills/security-auditor/owasp-top-10.md +61 -20
  188. package/src/templates/agents/claude-code/skills/security-auditor/vulnerability-patterns.md +43 -11
  189. package/src/templates/agents/claude-code/skills/site-reliability-engineer/SKILL.md +1 -0
  190. package/src/templates/agents/claude-code/skills/site-reliability-engineer/incident-response-template.md +55 -25
  191. package/src/templates/agents/claude-code/skills/site-reliability-engineer/observability-patterns.md +78 -68
  192. package/src/templates/agents/claude-code/skills/site-reliability-engineer/slo-sli-guide.md +73 -53
  193. package/src/templates/agents/claude-code/skills/software-developer/solid-principles.md +83 -37
  194. package/src/templates/agents/claude-code/skills/software-developer/test-first-workflow.md +38 -31
  195. package/src/templates/agents/claude-code/skills/steering/SKILL.md +1 -0
  196. package/src/templates/agents/claude-code/skills/steering/auto-update-rules.md +31 -0
  197. package/src/templates/agents/claude-code/skills/system-architect/adr-template.md +25 -7
  198. package/src/templates/agents/claude-code/skills/system-architect/c4-model-guide.md +74 -61
  199. package/src/templates/agents/claude-code/skills/technical-writer/doc-templates/documentation-templates.md +70 -52
  200. package/src/templates/agents/claude-code/skills/test-engineer/SKILL.md +2 -0
  201. package/src/templates/agents/claude-code/skills/test-engineer/ears-test-mapping.md +75 -71
  202. package/src/templates/agents/claude-code/skills/test-engineer/test-types.md +85 -63
  203. package/src/templates/agents/claude-code/skills/traceability-auditor/coverage-matrix-template.md +39 -36
  204. package/src/templates/agents/claude-code/skills/traceability-auditor/gap-detection-rules.md +22 -17
  205. package/src/templates/agents/claude-code/skills/ui-ux-designer/SKILL.md +1 -0
  206. package/src/templates/agents/claude-code/skills/ui-ux-designer/accessibility-guidelines.md +49 -75
  207. package/src/templates/agents/claude-code/skills/ui-ux-designer/design-system-components.md +71 -59
  208. package/src/templates/agents/codex/AGENTS.md +74 -42
  209. package/src/templates/agents/cursor/AGENTS.md +74 -42
  210. package/src/templates/agents/gemini-cli/GEMINI.md +74 -42
  211. package/src/templates/agents/github-copilot/AGENTS.md +83 -51
  212. package/src/templates/agents/qwen-code/QWEN.md +74 -42
  213. package/src/templates/agents/windsurf/AGENTS.md +74 -42
  214. package/src/templates/architectures/README.md +41 -0
  215. package/src/templates/architectures/clean-architecture/README.md +113 -0
  216. package/src/templates/architectures/event-driven/README.md +162 -0
  217. package/src/templates/architectures/hexagonal/README.md +130 -0
  218. package/src/templates/index.js +6 -1
  219. package/src/templates/locale-manager.js +16 -16
  220. package/src/templates/shared/delta-spec-template.md +20 -13
  221. package/src/templates/shared/github-actions/musubi-issue-resolver.yml +5 -5
  222. package/src/templates/shared/github-actions/musubi-security-check.yml +3 -3
  223. package/src/templates/shared/github-actions/musubi-validate.yml +4 -4
  224. package/src/templates/shared/steering/structure.md +95 -0
  225. package/src/templates/skills/browser-agent.md +21 -16
  226. package/src/templates/skills/web-gui.md +8 -0
  227. package/src/templates/template-constraints.js +50 -53
  228. package/src/validators/advanced-validation.js +30 -36
  229. package/src/validators/constitutional-validator.js +77 -73
  230. package/src/validators/critic-system.js +49 -59
  231. package/src/validators/delta-format.js +59 -55
  232. package/src/validators/traceability-validator.js +7 -11
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Monitoring Module - SRE, Observability, and Release Management
3
- *
3
+ *
4
4
  * Provides monitoring capabilities for MUSUBI-powered applications:
5
5
  * - SLI/SLO definition and tracking
6
6
  * - Alerting rules generation
@@ -18,7 +18,7 @@ const SLOType = {
18
18
  LATENCY: 'latency',
19
19
  THROUGHPUT: 'throughput',
20
20
  ERROR_RATE: 'error-rate',
21
- CORRECTNESS: 'correctness'
21
+ CORRECTNESS: 'correctness',
22
22
  };
23
23
 
24
24
  /**
@@ -27,7 +27,7 @@ const SLOType = {
27
27
  const AlertSeverity = {
28
28
  CRITICAL: 'critical',
29
29
  WARNING: 'warning',
30
- INFO: 'info'
30
+ INFO: 'info',
31
31
  };
32
32
 
33
33
  /**
@@ -37,7 +37,7 @@ const MetricType = {
37
37
  COUNTER: 'counter',
38
38
  GAUGE: 'gauge',
39
39
  HISTOGRAM: 'histogram',
40
- SUMMARY: 'summary'
40
+ SUMMARY: 'summary',
41
41
  };
42
42
 
43
43
  /**
@@ -62,16 +62,16 @@ class SLI {
62
62
  switch (this.type) {
63
63
  case SLOType.AVAILABILITY:
64
64
  return `sum(rate(${this.metric}_success_total[5m])) / sum(rate(${this.metric}_total[5m]))`;
65
-
65
+
66
66
  case SLOType.LATENCY:
67
67
  return `histogram_quantile(0.95, sum(rate(${this.metric}_bucket[5m])) by (le))`;
68
-
68
+
69
69
  case SLOType.ERROR_RATE:
70
70
  return `sum(rate(${this.metric}_errors_total[5m])) / sum(rate(${this.metric}_total[5m]))`;
71
-
71
+
72
72
  case SLOType.THROUGHPUT:
73
73
  return `sum(rate(${this.metric}_total[5m]))`;
74
-
74
+
75
75
  default:
76
76
  return this.goodEventsQuery || this.metric;
77
77
  }
@@ -84,7 +84,7 @@ class SLI {
84
84
  type: this.type,
85
85
  metric: this.metric,
86
86
  unit: this.unit,
87
- prometheusQuery: this.toPrometheusQuery()
87
+ prometheusQuery: this.toPrometheusQuery(),
88
88
  };
89
89
  }
90
90
  }
@@ -101,7 +101,7 @@ class SLO {
101
101
  this.window = options.window || '30d'; // Measurement window
102
102
  this.burnRateThresholds = options.burnRateThresholds || {
103
103
  critical: 14.4, // 1 hour to exhaust error budget
104
- warning: 6 // 6 hours to exhaust error budget
104
+ warning: 6, // 6 hours to exhaust error budget
105
105
  };
106
106
  }
107
107
 
@@ -112,7 +112,7 @@ class SLO {
112
112
  return {
113
113
  total: 1 - this.target,
114
114
  remaining: null, // Calculated at runtime
115
- consumptionRate: null
115
+ consumptionRate: null,
116
116
  };
117
117
  }
118
118
 
@@ -121,22 +121,22 @@ class SLO {
121
121
  */
122
122
  toBurnRateAlert() {
123
123
  const shortWindow = '5m';
124
- const longWindow = '1h';
125
-
124
+ const _longWindow = '1h';
125
+
126
126
  return {
127
127
  name: `${this.name}_high_burn_rate`,
128
128
  expr: `(
129
129
  ${this.sli.toPrometheusQuery()}
130
- ) < ${this.target - ((1 - this.target) * this.burnRateThresholds.critical)}`,
130
+ ) < ${this.target - (1 - this.target) * this.burnRateThresholds.critical}`,
131
131
  for: shortWindow,
132
132
  labels: {
133
133
  severity: AlertSeverity.CRITICAL,
134
- slo: this.name
134
+ slo: this.name,
135
135
  },
136
136
  annotations: {
137
137
  summary: `High burn rate on SLO: ${this.name}`,
138
- description: `Error budget will be exhausted within 1 hour at current rate`
139
- }
138
+ description: `Error budget will be exhausted within 1 hour at current rate`,
139
+ },
140
140
  };
141
141
  }
142
142
 
@@ -149,7 +149,7 @@ class SLO {
149
149
  targetPercentage: `${(this.target * 100).toFixed(2)}%`,
150
150
  window: this.window,
151
151
  errorBudget: this.calculateErrorBudget(),
152
- burnRateAlert: this.toBurnRateAlert()
152
+ burnRateAlert: this.toBurnRateAlert(),
153
153
  };
154
154
  }
155
155
  }
@@ -176,7 +176,9 @@ class AlertRule {
176
176
  for: ${this.for}
177
177
  labels:
178
178
  severity: ${this.severity}
179
- ${Object.entries(this.labels).map(([k, v]) => ` ${k}: ${v}`).join('\n')}
179
+ ${Object.entries(this.labels)
180
+ .map(([k, v]) => ` ${k}: ${v}`)
181
+ .join('\n')}
180
182
  annotations:
181
183
  summary: "${this.annotations.summary || this.name}"
182
184
  description: "${this.annotations.description || ''}"`;
@@ -189,7 +191,7 @@ ${Object.entries(this.labels).map(([k, v]) => ` ${k}: ${v}`).join('\n')}
189
191
  for: this.for,
190
192
  severity: this.severity,
191
193
  labels: this.labels,
192
- annotations: this.annotations
194
+ annotations: this.annotations,
193
195
  };
194
196
  }
195
197
  }
@@ -214,7 +216,7 @@ class HealthCheck {
214
216
  name: check.name,
215
217
  type: check.type || 'dependency',
216
218
  critical: check.critical !== false,
217
- check: check.check
219
+ check: check.check,
218
220
  });
219
221
  return this;
220
222
  }
@@ -231,22 +233,20 @@ class HealthCheck {
231
233
  const startTime = Date.now();
232
234
  const checkResult = await Promise.race([
233
235
  check.check(),
234
- new Promise((_, reject) =>
235
- setTimeout(() => reject(new Error('Timeout')), this.timeout)
236
- )
236
+ new Promise((_, reject) => setTimeout(() => reject(new Error('Timeout')), this.timeout)),
237
237
  ]);
238
-
238
+
239
239
  results.push({
240
240
  name: check.name,
241
241
  status: 'healthy',
242
242
  latency: Date.now() - startTime,
243
- details: checkResult
243
+ details: checkResult,
244
244
  });
245
245
  } catch (error) {
246
246
  results.push({
247
247
  name: check.name,
248
248
  status: 'unhealthy',
249
- error: error.message
249
+ error: error.message,
250
250
  });
251
251
  if (check.critical) healthy = false;
252
252
  }
@@ -255,7 +255,7 @@ class HealthCheck {
255
255
  return {
256
256
  status: healthy ? 'healthy' : 'unhealthy',
257
257
  timestamp: new Date().toISOString(),
258
- checks: results
258
+ checks: results,
259
259
  };
260
260
  }
261
261
 
@@ -263,7 +263,7 @@ class HealthCheck {
263
263
  * Generate Express.js health endpoint handler
264
264
  */
265
265
  toExpressHandler() {
266
- const check = this;
266
+ const _check = this;
267
267
  return `
268
268
  app.get('${this.endpoint}', async (req, res) => {
269
269
  const health = await healthCheck.execute();
@@ -289,8 +289,8 @@ app.get('${this.endpoint}/ready', async (req, res) => {
289
289
  checks: this.checks.map(c => ({
290
290
  name: c.name,
291
291
  type: c.type,
292
- critical: c.critical
293
- }))
292
+ critical: c.critical,
293
+ })),
294
294
  };
295
295
  }
296
296
  }
@@ -361,9 +361,8 @@ class MonitoringConfig extends EventEmitter {
361
361
  * Define a health check
362
362
  */
363
363
  defineHealthCheck(healthCheck) {
364
- const hcInstance = healthCheck instanceof HealthCheck
365
- ? healthCheck
366
- : new HealthCheck(healthCheck);
364
+ const hcInstance =
365
+ healthCheck instanceof HealthCheck ? healthCheck : new HealthCheck(healthCheck);
367
366
  this.healthChecks.set(hcInstance.name, hcInstance);
368
367
  this.emit('healthCheckAdded', hcInstance);
369
368
  return this;
@@ -384,7 +383,7 @@ class MonitoringConfig extends EventEmitter {
384
383
  name: metric.name,
385
384
  type: metric.type || MetricType.COUNTER,
386
385
  help: metric.help || '',
387
- labels: metric.labels || []
386
+ labels: metric.labels || [],
388
387
  });
389
388
  return this;
390
389
  }
@@ -394,22 +393,24 @@ class MonitoringConfig extends EventEmitter {
394
393
  */
395
394
  toPrometheusConfig() {
396
395
  const rules = [];
397
-
396
+
398
397
  // Generate SLO-based alerts
399
398
  for (const slo of this.slos.values()) {
400
399
  rules.push(slo.toBurnRateAlert());
401
400
  }
402
-
401
+
403
402
  // Add custom alerts
404
403
  for (const alert of this.alerts.values()) {
405
404
  rules.push(alert.toJSON());
406
405
  }
407
406
 
408
407
  return {
409
- groups: [{
410
- name: `${this.serviceName}-alerts`,
411
- rules
412
- }]
408
+ groups: [
409
+ {
410
+ name: `${this.serviceName}-alerts`,
411
+ rules,
412
+ },
413
+ ],
413
414
  };
414
415
  }
415
416
 
@@ -427,10 +428,12 @@ class MonitoringConfig extends EventEmitter {
427
428
  type: 'gauge',
428
429
  title: slo.name,
429
430
  gridPos: { x: 0, y, w: 8, h: 6 },
430
- targets: [{
431
- expr: slo.sli.toPrometheusQuery(),
432
- legendFormat: slo.name
433
- }],
431
+ targets: [
432
+ {
433
+ expr: slo.sli.toPrometheusQuery(),
434
+ legendFormat: slo.name,
435
+ },
436
+ ],
434
437
  fieldConfig: {
435
438
  defaults: {
436
439
  thresholds: {
@@ -438,14 +441,14 @@ class MonitoringConfig extends EventEmitter {
438
441
  steps: [
439
442
  { color: 'red', value: null },
440
443
  { color: 'yellow', value: slo.target - 0.01 },
441
- { color: 'green', value: slo.target }
442
- ]
444
+ { color: 'green', value: slo.target },
445
+ ],
443
446
  },
444
447
  min: 0,
445
448
  max: 1,
446
- unit: 'percentunit'
447
- }
448
- }
449
+ unit: 'percentunit',
450
+ },
451
+ },
449
452
  });
450
453
  y += 6;
451
454
  }
@@ -457,7 +460,7 @@ class MonitoringConfig extends EventEmitter {
457
460
  timezone: 'browser',
458
461
  panels,
459
462
  refresh: '30s',
460
- time: { from: 'now-24h', to: 'now' }
463
+ time: { from: 'now-24h', to: 'now' },
461
464
  };
462
465
  }
463
466
 
@@ -473,7 +476,7 @@ class MonitoringConfig extends EventEmitter {
473
476
  healthChecks: [...this.healthChecks.values()].map(h => h.toJSON()),
474
477
  metrics: [...this.metrics.values()],
475
478
  prometheus: this.toPrometheusConfig(),
476
- grafana: this.toGrafanaDashboard()
479
+ grafana: this.toGrafanaDashboard(),
477
480
  };
478
481
  }
479
482
  }
@@ -485,48 +488,51 @@ const SLOTemplates = {
485
488
  /**
486
489
  * API Availability SLO
487
490
  */
488
- API_AVAILABILITY: (target = 0.999) => new SLO({
489
- name: 'api-availability',
490
- description: 'API endpoint availability',
491
- sli: {
492
- name: 'api-success-rate',
493
- type: SLOType.AVAILABILITY,
494
- metric: 'http_requests'
495
- },
496
- target,
497
- window: '30d'
498
- }),
491
+ API_AVAILABILITY: (target = 0.999) =>
492
+ new SLO({
493
+ name: 'api-availability',
494
+ description: 'API endpoint availability',
495
+ sli: {
496
+ name: 'api-success-rate',
497
+ type: SLOType.AVAILABILITY,
498
+ metric: 'http_requests',
499
+ },
500
+ target,
501
+ window: '30d',
502
+ }),
499
503
 
500
504
  /**
501
505
  * API Latency SLO
502
506
  */
503
- API_LATENCY: (target = 0.95, thresholdMs = 200) => new SLO({
504
- name: 'api-latency',
505
- description: `95th percentile latency under ${thresholdMs}ms`,
506
- sli: {
507
- name: 'api-response-time',
508
- type: SLOType.LATENCY,
509
- metric: 'http_request_duration_seconds',
510
- threshold: thresholdMs / 1000
511
- },
512
- target,
513
- window: '30d'
514
- }),
507
+ API_LATENCY: (target = 0.95, thresholdMs = 200) =>
508
+ new SLO({
509
+ name: 'api-latency',
510
+ description: `95th percentile latency under ${thresholdMs}ms`,
511
+ sli: {
512
+ name: 'api-response-time',
513
+ type: SLOType.LATENCY,
514
+ metric: 'http_request_duration_seconds',
515
+ threshold: thresholdMs / 1000,
516
+ },
517
+ target,
518
+ window: '30d',
519
+ }),
515
520
 
516
521
  /**
517
522
  * Error Rate SLO
518
523
  */
519
- ERROR_RATE: (target = 0.99) => new SLO({
520
- name: 'error-rate',
521
- description: 'Low error rate objective',
522
- sli: {
523
- name: 'error-rate-indicator',
524
- type: SLOType.ERROR_RATE,
525
- metric: 'http_requests'
526
- },
527
- target,
528
- window: '7d'
529
- })
524
+ ERROR_RATE: (target = 0.99) =>
525
+ new SLO({
526
+ name: 'error-rate',
527
+ description: 'Low error rate objective',
528
+ sli: {
529
+ name: 'error-rate-indicator',
530
+ type: SLOType.ERROR_RATE,
531
+ metric: 'http_requests',
532
+ },
533
+ target,
534
+ window: '7d',
535
+ }),
530
536
  };
531
537
 
532
538
  /**
@@ -536,58 +542,62 @@ const AlertTemplates = {
536
542
  /**
537
543
  * High Error Rate Alert
538
544
  */
539
- HIGH_ERROR_RATE: (threshold = 0.05) => new AlertRule({
540
- name: 'HighErrorRate',
541
- expr: `sum(rate(http_requests_errors_total[5m])) / sum(rate(http_requests_total[5m])) > ${threshold}`,
542
- for: '5m',
543
- severity: AlertSeverity.CRITICAL,
544
- annotations: {
545
- summary: 'High error rate detected',
546
- description: `Error rate is above ${threshold * 100}%`
547
- }
548
- }),
545
+ HIGH_ERROR_RATE: (threshold = 0.05) =>
546
+ new AlertRule({
547
+ name: 'HighErrorRate',
548
+ expr: `sum(rate(http_requests_errors_total[5m])) / sum(rate(http_requests_total[5m])) > ${threshold}`,
549
+ for: '5m',
550
+ severity: AlertSeverity.CRITICAL,
551
+ annotations: {
552
+ summary: 'High error rate detected',
553
+ description: `Error rate is above ${threshold * 100}%`,
554
+ },
555
+ }),
549
556
 
550
557
  /**
551
558
  * High Latency Alert
552
559
  */
553
- HIGH_LATENCY: (thresholdMs = 500) => new AlertRule({
554
- name: 'HighLatency',
555
- expr: `histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)) > ${thresholdMs / 1000}`,
556
- for: '5m',
557
- severity: AlertSeverity.WARNING,
558
- annotations: {
559
- summary: 'High latency detected',
560
- description: `P95 latency is above ${thresholdMs}ms`
561
- }
562
- }),
560
+ HIGH_LATENCY: (thresholdMs = 500) =>
561
+ new AlertRule({
562
+ name: 'HighLatency',
563
+ expr: `histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)) > ${thresholdMs / 1000}`,
564
+ for: '5m',
565
+ severity: AlertSeverity.WARNING,
566
+ annotations: {
567
+ summary: 'High latency detected',
568
+ description: `P95 latency is above ${thresholdMs}ms`,
569
+ },
570
+ }),
563
571
 
564
572
  /**
565
573
  * Service Down Alert
566
574
  */
567
- SERVICE_DOWN: () => new AlertRule({
568
- name: 'ServiceDown',
569
- expr: 'up == 0',
570
- for: '1m',
571
- severity: AlertSeverity.CRITICAL,
572
- annotations: {
573
- summary: 'Service is down',
574
- description: 'Service instance is not responding'
575
- }
576
- }),
575
+ SERVICE_DOWN: () =>
576
+ new AlertRule({
577
+ name: 'ServiceDown',
578
+ expr: 'up == 0',
579
+ for: '1m',
580
+ severity: AlertSeverity.CRITICAL,
581
+ annotations: {
582
+ summary: 'Service is down',
583
+ description: 'Service instance is not responding',
584
+ },
585
+ }),
577
586
 
578
587
  /**
579
588
  * High Memory Usage Alert
580
589
  */
581
- HIGH_MEMORY: (threshold = 0.9) => new AlertRule({
582
- name: 'HighMemoryUsage',
583
- expr: `process_resident_memory_bytes / node_memory_MemTotal_bytes > ${threshold}`,
584
- for: '5m',
585
- severity: AlertSeverity.WARNING,
586
- annotations: {
587
- summary: 'High memory usage',
588
- description: `Memory usage is above ${threshold * 100}%`
589
- }
590
- })
590
+ HIGH_MEMORY: (threshold = 0.9) =>
591
+ new AlertRule({
592
+ name: 'HighMemoryUsage',
593
+ expr: `process_resident_memory_bytes / node_memory_MemTotal_bytes > ${threshold}`,
594
+ for: '5m',
595
+ severity: AlertSeverity.WARNING,
596
+ annotations: {
597
+ summary: 'High memory usage',
598
+ description: `Memory usage is above ${threshold * 100}%`,
599
+ },
600
+ }),
591
601
  };
592
602
 
593
603
  /**
@@ -610,28 +620,28 @@ module.exports = {
610
620
  AlertRule,
611
621
  HealthCheck,
612
622
  MonitoringConfig,
613
-
623
+
614
624
  // Constants
615
625
  SLOType,
616
626
  AlertSeverity,
617
627
  MetricType,
618
-
628
+
619
629
  // Templates
620
630
  SLOTemplates,
621
631
  AlertTemplates,
622
-
632
+
623
633
  // Factory
624
634
  createMonitoringConfig,
625
-
635
+
626
636
  // Release Manager
627
637
  ...releaseManagerModule,
628
-
638
+
629
639
  // Incident Manager
630
640
  ...incidentManagerModule,
631
-
641
+
632
642
  // Observability
633
643
  ...observabilityModule,
634
-
644
+
635
645
  // Cost Tracker
636
- ...costTrackerModule
646
+ ...costTrackerModule,
637
647
  };