snow-flow 2.0.4 → 2.0.6

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 (74) hide show
  1. package/dist/config/snow-flow-config.d.ts +1492 -0
  2. package/dist/config/snow-flow-config.js +938 -0
  3. package/dist/coordination/coordination-engine.d.ts +41 -0
  4. package/dist/coordination/coordination-engine.js +324 -0
  5. package/dist/coordination/coordination.test.d.ts +6 -0
  6. package/dist/coordination/example.d.ts +31 -0
  7. package/dist/coordination/example.js +394 -0
  8. package/dist/coordination/execution-patterns.d.ts +43 -0
  9. package/dist/coordination/execution-patterns.js +507 -0
  10. package/dist/coordination/factory.d.ts +94 -0
  11. package/dist/coordination/factory.js +433 -0
  12. package/dist/coordination/index.d.ts +71 -0
  13. package/dist/coordination/index.js +135 -0
  14. package/dist/coordination/progress-monitor.d.ts +71 -0
  15. package/dist/coordination/progress-monitor.js +505 -0
  16. package/dist/coordination/quality-gates.d.ts +124 -0
  17. package/dist/coordination/quality-gates.js +577 -0
  18. package/dist/coordination/shared-memory.d.ts +39 -0
  19. package/dist/coordination/shared-memory.js +289 -0
  20. package/dist/coordination/task-dependencies.d.ts +50 -0
  21. package/dist/coordination/task-dependencies.js +407 -0
  22. package/dist/coordination/team-coordinator.d.ts +59 -0
  23. package/dist/coordination/team-coordinator.js +550 -0
  24. package/dist/coordination/types.d.ts +152 -0
  25. package/dist/coordination/types.js +3 -0
  26. package/dist/memory/hierarchical-memory-system.d.ts +90 -0
  27. package/dist/memory/hierarchical-memory-system.js +400 -0
  28. package/dist/memory/index.d.ts +9 -0
  29. package/dist/memory/index.js +20 -0
  30. package/dist/memory/mcp-integration-example.d.ts +6 -0
  31. package/dist/memory/mcp-integration-example.js +281 -0
  32. package/dist/memory/memory-client.d.ts +199 -0
  33. package/dist/memory/memory-client.js +364 -0
  34. package/dist/memory/memory-manager.d.ts +29 -0
  35. package/dist/memory/memory-manager.js +280 -0
  36. package/dist/memory/memory-operations.d.ts +179 -0
  37. package/dist/memory/memory-operations.js +691 -0
  38. package/dist/memory/memory-system.d.ts +152 -0
  39. package/dist/memory/memory-system.js +632 -0
  40. package/dist/memory/memory-test.d.ts +6 -0
  41. package/dist/memory/memory-test.js +161 -0
  42. package/dist/memory/servicenow-artifact-indexer.d.ts +119 -0
  43. package/dist/memory/servicenow-artifact-indexer.js +560 -0
  44. package/dist/memory/snow-flow-memory-patterns.d.ts +213 -0
  45. package/dist/memory/snow-flow-memory-patterns.js +200 -0
  46. package/dist/memory/snow-memory.d.ts +54 -0
  47. package/dist/memory/snow-memory.js +301 -0
  48. package/dist/memory/swarm-memory.d.ts +135 -0
  49. package/dist/memory/swarm-memory.js +378 -0
  50. package/memory/claude-flow-data.json +5 -0
  51. package/memory/servicenow_artifacts/000d9224c895221055906c7518aa2d3d.json +30 -0
  52. package/memory/servicenow_artifacts/0196b66173303010e46b4a2214f6a7a2.json +36 -0
  53. package/memory/servicenow_artifacts/125e5d1d837e2a102a7ea130ceaad397.json +30 -0
  54. package/memory/servicenow_artifacts/7637c1f2b7112210a5e5911cde11a972.json +30 -0
  55. package/memory/servicenow_artifacts/default_documentation_tables_1754056582292.json +55 -0
  56. package/memory/servicenow_artifacts/default_documentation_tables_1754057477189.json +55 -0
  57. package/memory/sessions/README.md +32 -0
  58. package/memory/update-set-sessions/01f82af583faea102a7ea130ceaad3d4.json +9 -0
  59. package/memory/update-set-sessions/27718fb983faea102a7ea130ceaad34b.json +9 -0
  60. package/memory/update-set-sessions/412e9bf6833e22502a7ea130ceaad30a.json +8 -0
  61. package/memory/update-set-sessions/66fc5a79837aea102a7ea130ceaad3ab.json +9 -0
  62. package/memory/update-set-sessions/71a30ff5837eea102a7ea130ceaad37f.json +9 -0
  63. package/memory/update-set-sessions/74fba27983faea102a7ea130ceaad3bd.json +9 -0
  64. package/memory/update-set-sessions/a0b147b5837eea102a7ea130ceaad344.json +58 -0
  65. package/memory/update-set-sessions/b13f5eb983baea102a7ea130ceaad33e.json +9 -0
  66. package/package.json +1 -1
  67. package/reports/swarm-auto-centralized-1752649029776.json +13 -0
  68. package/scripts/postinstall.js +30 -0
  69. package/scripts/update-version.js +31 -0
  70. package/servicenow/widgets/openai_incident_classifier/client_controller.js +284 -0
  71. package/servicenow/widgets/openai_incident_classifier/server_script.js +314 -0
  72. package/servicenow/widgets/openai_incident_classifier/style.css +354 -0
  73. package/servicenow/widgets/openai_incident_classifier/template.html +167 -0
  74. package/servicenow/widgets/openai_incident_classifier/widget.json +86 -0
@@ -0,0 +1,577 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BusinessLogicGate = exports.ServiceNowGate = exports.PerformanceGate = exports.SecurityGate = exports.CodeQualityGate = exports.QualityGateManager = void 0;
4
+ const eventemitter3_1 = require("eventemitter3");
5
+ const logger_1 = require("../utils/logger");
6
+ class QualityGateManager extends eventemitter3_1.EventEmitter {
7
+ constructor(config = {}) {
8
+ super();
9
+ this.gates = new Map();
10
+ this.gateResults = new Map();
11
+ this.config = {
12
+ enableBlocking: true,
13
+ enableScoring: true,
14
+ minPassingScore: 0.7,
15
+ enableMetrics: true,
16
+ timeoutMs: 30000,
17
+ ...config
18
+ };
19
+ logger_1.logger.info('🛡️ Quality Gate Manager initialized', { config: this.config });
20
+ }
21
+ addGate(taskId, gate) {
22
+ if (!this.gates.has(taskId)) {
23
+ this.gates.set(taskId, []);
24
+ }
25
+ this.gates.get(taskId).push(gate);
26
+ logger_1.logger.debug('🚪 Added quality gate', {
27
+ taskId,
28
+ gateName: gate.name,
29
+ blocking: gate.blocking
30
+ });
31
+ }
32
+ async validateTask(taskId, result) {
33
+ const startTime = Date.now();
34
+ try {
35
+ logger_1.logger.info('🔍 Starting quality gate validation', { taskId });
36
+ const gates = this.gates.get(taskId) || [];
37
+ if (gates.length === 0) {
38
+ logger_1.logger.debug('⚠️ No quality gates configured for task', { taskId });
39
+ return this.createPassingResult(taskId, startTime);
40
+ }
41
+ const validationResults = [];
42
+ let overallPassed = true;
43
+ let blockingFailure = false;
44
+ // Execute all quality gates
45
+ for (const gate of gates) {
46
+ try {
47
+ logger_1.logger.debug('🔍 Executing quality gate', {
48
+ taskId,
49
+ gateName: gate.name
50
+ });
51
+ const validation = await this.executeGateWithTimeout(gate, result);
52
+ validationResults.push(validation);
53
+ if (!validation.passed) {
54
+ if (gate.blocking) {
55
+ blockingFailure = true;
56
+ overallPassed = false;
57
+ logger_1.logger.warn('🚫 Blocking quality gate failed', {
58
+ taskId,
59
+ gateName: gate.name,
60
+ error: validation.error
61
+ });
62
+ }
63
+ else {
64
+ logger_1.logger.warn('⚠️ Non-blocking quality gate failed', {
65
+ taskId,
66
+ gateName: gate.name,
67
+ error: validation.error
68
+ });
69
+ }
70
+ }
71
+ }
72
+ catch (error) {
73
+ logger_1.logger.error('❌ Quality gate execution failed', {
74
+ taskId,
75
+ gateName: gate.name,
76
+ error: error.message
77
+ });
78
+ const failedValidation = {
79
+ passed: false,
80
+ error: `Gate execution failed: ${error.message}`,
81
+ suggestions: ['Check gate configuration', 'Verify input data format']
82
+ };
83
+ validationResults.push(failedValidation);
84
+ if (gate.blocking) {
85
+ blockingFailure = true;
86
+ overallPassed = false;
87
+ }
88
+ }
89
+ }
90
+ const result_obj = {
91
+ gateName: `quality_gates_${taskId}`,
92
+ passed: overallPassed,
93
+ blocking: blockingFailure,
94
+ validations: validationResults,
95
+ overallScore: this.calculateOverallScore(validationResults),
96
+ executionTime: Date.now() - startTime
97
+ };
98
+ // Store results for analytics
99
+ if (!this.gateResults.has(taskId)) {
100
+ this.gateResults.set(taskId, []);
101
+ }
102
+ this.gateResults.get(taskId).push(result_obj);
103
+ // Emit events
104
+ if (overallPassed) {
105
+ this.emit('gate:passed', { taskId, result: result_obj });
106
+ logger_1.logger.info('✅ Quality gates passed', {
107
+ taskId,
108
+ gatesCount: gates.length,
109
+ score: result_obj.overallScore
110
+ });
111
+ }
112
+ else {
113
+ this.emit('gate:failed', { taskId, result: result_obj });
114
+ logger_1.logger.error('❌ Quality gates failed', {
115
+ taskId,
116
+ blocking: blockingFailure,
117
+ failedGates: validationResults.filter(v => !v.passed).length
118
+ });
119
+ }
120
+ return result_obj;
121
+ }
122
+ catch (error) {
123
+ logger_1.logger.error('💥 Quality gate validation crashed', { taskId, error: error.message });
124
+ return {
125
+ gateName: `quality_gates_${taskId}`,
126
+ passed: false,
127
+ blocking: true,
128
+ validations: [{
129
+ passed: false,
130
+ error: `Validation system error: ${error.message}`
131
+ }],
132
+ executionTime: Date.now() - startTime
133
+ };
134
+ }
135
+ }
136
+ async executeGateWithTimeout(gate, result) {
137
+ return new Promise(async (resolve, reject) => {
138
+ const timeout = setTimeout(() => {
139
+ reject(new Error(`Quality gate '${gate.name}' timed out after ${this.config.timeoutMs}ms`));
140
+ }, this.config.timeoutMs);
141
+ try {
142
+ const validation = await gate.validate(result);
143
+ clearTimeout(timeout);
144
+ resolve(validation);
145
+ }
146
+ catch (error) {
147
+ clearTimeout(timeout);
148
+ reject(error);
149
+ }
150
+ });
151
+ }
152
+ calculateOverallScore(validations) {
153
+ if (!this.config.enableScoring || validations.length === 0) {
154
+ return 1.0;
155
+ }
156
+ const scores = validations
157
+ .filter(v => typeof v.score === 'number')
158
+ .map(v => v.score);
159
+ if (scores.length === 0) {
160
+ // Fall back to pass/fail scoring
161
+ const passed = validations.filter(v => v.passed).length;
162
+ return passed / validations.length;
163
+ }
164
+ return scores.reduce((sum, score) => sum + score, 0) / scores.length;
165
+ }
166
+ createPassingResult(taskId, startTime) {
167
+ return {
168
+ gateName: `quality_gates_${taskId}`,
169
+ passed: true,
170
+ blocking: false,
171
+ validations: [],
172
+ overallScore: 1.0,
173
+ executionTime: Date.now() - startTime
174
+ };
175
+ }
176
+ // Analytics and reporting
177
+ async getGateStatistics(taskId) {
178
+ const allResults = taskId
179
+ ? this.gateResults.get(taskId) || []
180
+ : Array.from(this.gateResults.values()).flat();
181
+ if (allResults.length === 0) {
182
+ return {
183
+ totalExecutions: 0,
184
+ passRate: 0,
185
+ averageScore: 0,
186
+ averageExecutionTime: 0,
187
+ mostCommonFailures: []
188
+ };
189
+ }
190
+ const passed = allResults.filter(r => r.passed).length;
191
+ const scores = allResults
192
+ .filter(r => typeof r.overallScore === 'number')
193
+ .map(r => r.overallScore);
194
+ const failures = allResults
195
+ .filter(r => !r.passed)
196
+ .flatMap(r => r.validations)
197
+ .filter(v => !v.passed && v.error)
198
+ .map(v => v.error)
199
+ .reduce((counts, error) => {
200
+ counts[error] = (counts[error] || 0) + 1;
201
+ return counts;
202
+ }, {});
203
+ const mostCommonFailures = Object.entries(failures)
204
+ .sort(([, a], [, b]) => b - a)
205
+ .slice(0, 5)
206
+ .map(([error, count]) => ({ error, count }));
207
+ return {
208
+ totalExecutions: allResults.length,
209
+ passRate: passed / allResults.length,
210
+ averageScore: scores.length > 0 ? scores.reduce((sum, s) => sum + s, 0) / scores.length : 0,
211
+ averageExecutionTime: allResults.reduce((sum, r) => sum + r.executionTime, 0) / allResults.length,
212
+ mostCommonFailures
213
+ };
214
+ }
215
+ // Predefined Quality Gates
216
+ createCodeQualityGate(options = {}) {
217
+ return new CodeQualityGate(options);
218
+ }
219
+ createSecurityGate(options = {}) {
220
+ return new SecurityGate(options);
221
+ }
222
+ createPerformanceGate(options = {}) {
223
+ return new PerformanceGate(options);
224
+ }
225
+ createServiceNowGate(options = {}) {
226
+ return new ServiceNowGate(options);
227
+ }
228
+ createBusinessLogicGate(options = {}) {
229
+ return new BusinessLogicGate(options);
230
+ }
231
+ }
232
+ exports.QualityGateManager = QualityGateManager;
233
+ // Predefined Quality Gate Implementations
234
+ class CodeQualityGate {
235
+ constructor(options = {}) {
236
+ this.name = 'Code Quality';
237
+ this.blocking = options.blocking ?? true;
238
+ this.options = {
239
+ maxComplexity: 10,
240
+ minCoverage: 80,
241
+ maxLines: 1000,
242
+ requireDocumentation: true,
243
+ checkNaming: true,
244
+ blocking: true,
245
+ ...options
246
+ };
247
+ }
248
+ async validate(result) {
249
+ const issues = [];
250
+ const warnings = [];
251
+ let score = 1.0;
252
+ // Check code complexity
253
+ if (result.code && result.complexity > this.options.maxComplexity) {
254
+ issues.push(`Code complexity ${result.complexity} exceeds maximum ${this.options.maxComplexity}`);
255
+ score -= 0.3;
256
+ }
257
+ // Check test coverage
258
+ if (result.coverage && result.coverage < this.options.minCoverage) {
259
+ issues.push(`Test coverage ${result.coverage}% below minimum ${this.options.minCoverage}%`);
260
+ score -= 0.2;
261
+ }
262
+ // Check code length
263
+ if (result.code && result.code.split('\n').length > this.options.maxLines) {
264
+ warnings.push(`Code is very long (${result.code.split('\n').length} lines)`);
265
+ score -= 0.1;
266
+ }
267
+ // Check documentation
268
+ if (this.options.requireDocumentation && result.code && !this.hasDocumentation(result.code)) {
269
+ warnings.push('Missing documentation');
270
+ score -= 0.1;
271
+ }
272
+ return {
273
+ passed: issues.length === 0,
274
+ score: Math.max(score, 0),
275
+ error: issues.length > 0 ? issues.join('; ') : undefined,
276
+ warnings,
277
+ suggestions: this.generateCodeSuggestions(issues, warnings)
278
+ };
279
+ }
280
+ hasDocumentation(code) {
281
+ return /\/\*\*|\*\/|\/\//.test(code);
282
+ }
283
+ generateCodeSuggestions(issues, warnings) {
284
+ const suggestions = [];
285
+ if (issues.some(i => i.includes('complexity'))) {
286
+ suggestions.push('Consider breaking down complex functions into smaller ones');
287
+ suggestions.push('Use early returns to reduce nesting');
288
+ }
289
+ if (issues.some(i => i.includes('coverage'))) {
290
+ suggestions.push('Add more unit tests');
291
+ suggestions.push('Test edge cases and error conditions');
292
+ }
293
+ if (warnings.some(w => w.includes('documentation'))) {
294
+ suggestions.push('Add JSDoc comments to public functions');
295
+ suggestions.push('Document complex business logic');
296
+ }
297
+ return suggestions;
298
+ }
299
+ }
300
+ exports.CodeQualityGate = CodeQualityGate;
301
+ class SecurityGate {
302
+ constructor(options = {}) {
303
+ this.name = 'Security Review';
304
+ this.blocking = true;
305
+ this.options = {
306
+ checkInjection: true,
307
+ checkXSS: true,
308
+ checkAuth: true,
309
+ checkSecrets: true,
310
+ checkPermissions: true,
311
+ ...options
312
+ };
313
+ }
314
+ async validate(result) {
315
+ const vulnerabilities = [];
316
+ let score = 1.0;
317
+ if (result.code) {
318
+ // Check for SQL injection vulnerabilities
319
+ if (this.options.checkInjection && this.hasSQLInjectionRisk(result.code)) {
320
+ vulnerabilities.push('Potential SQL injection vulnerability detected');
321
+ score -= 0.4;
322
+ }
323
+ // Check for XSS vulnerabilities
324
+ if (this.options.checkXSS && this.hasXSSRisk(result.code)) {
325
+ vulnerabilities.push('Potential XSS vulnerability detected');
326
+ score -= 0.3;
327
+ }
328
+ // Check for hardcoded secrets
329
+ if (this.options.checkSecrets && this.hasHardcodedSecrets(result.code)) {
330
+ vulnerabilities.push('Hardcoded secrets or credentials detected');
331
+ score -= 0.5;
332
+ }
333
+ }
334
+ // Check ServiceNow specific security
335
+ if (result.servicenow) {
336
+ if (this.options.checkAuth && !this.hasProperAuthentication(result.servicenow)) {
337
+ vulnerabilities.push('Missing or weak authentication controls');
338
+ score -= 0.3;
339
+ }
340
+ if (this.options.checkPermissions && !this.hasProperPermissions(result.servicenow)) {
341
+ vulnerabilities.push('Insufficient access controls');
342
+ score -= 0.2;
343
+ }
344
+ }
345
+ return {
346
+ passed: vulnerabilities.length === 0,
347
+ score: Math.max(score, 0),
348
+ error: vulnerabilities.length > 0 ? vulnerabilities.join('; ') : undefined,
349
+ suggestions: this.generateSecuritySuggestions(vulnerabilities)
350
+ };
351
+ }
352
+ hasSQLInjectionRisk(code) {
353
+ const patterns = [
354
+ /query\s*\+\s*['"`]/i,
355
+ /\$\{.*\}/,
356
+ /\.addQuery\(/i
357
+ ];
358
+ return patterns.some(pattern => pattern.test(code));
359
+ }
360
+ hasXSSRisk(code) {
361
+ const patterns = [
362
+ /innerHTML\s*=/i,
363
+ /document\.write\(/i,
364
+ /eval\(/i
365
+ ];
366
+ return patterns.some(pattern => pattern.test(code));
367
+ }
368
+ hasHardcodedSecrets(code) {
369
+ const patterns = [
370
+ /password\s*=\s*['"][^'"]+['"]/i,
371
+ /api[_-]?key\s*=\s*['"][^'"]+['"]/i,
372
+ /secret\s*=\s*['"][^'"]+['"]/i,
373
+ /token\s*=\s*['"][^'"]+['"]/i
374
+ ];
375
+ return patterns.some(pattern => pattern.test(code));
376
+ }
377
+ hasProperAuthentication(servicenow) {
378
+ return servicenow.authMethod && servicenow.authMethod !== 'none';
379
+ }
380
+ hasProperPermissions(servicenow) {
381
+ return servicenow.accessControls && servicenow.accessControls.length > 0;
382
+ }
383
+ generateSecuritySuggestions(vulnerabilities) {
384
+ const suggestions = [];
385
+ if (vulnerabilities.some(v => v.includes('injection'))) {
386
+ suggestions.push('Use parameterized queries or prepared statements');
387
+ suggestions.push('Validate and sanitize all user inputs');
388
+ }
389
+ if (vulnerabilities.some(v => v.includes('XSS'))) {
390
+ suggestions.push('Use proper output encoding');
391
+ suggestions.push('Implement Content Security Policy (CSP)');
392
+ }
393
+ if (vulnerabilities.some(v => v.includes('secrets'))) {
394
+ suggestions.push('Use environment variables for secrets');
395
+ suggestions.push('Implement secure credential management');
396
+ }
397
+ return suggestions;
398
+ }
399
+ }
400
+ exports.SecurityGate = SecurityGate;
401
+ class PerformanceGate {
402
+ constructor(options = {}) {
403
+ this.name = 'Performance Validation';
404
+ this.blocking = false;
405
+ this.options = {
406
+ maxResponseTime: 5000,
407
+ maxMemoryUsage: 100,
408
+ minThroughput: 100,
409
+ blocking: false,
410
+ ...options
411
+ };
412
+ }
413
+ async validate(result) {
414
+ const issues = [];
415
+ let score = 1.0;
416
+ if (result.performance) {
417
+ const perf = result.performance;
418
+ if (perf.responseTime > this.options.maxResponseTime) {
419
+ issues.push(`Response time ${perf.responseTime}ms exceeds maximum ${this.options.maxResponseTime}ms`);
420
+ score -= 0.3;
421
+ }
422
+ if (perf.memoryUsage > this.options.maxMemoryUsage) {
423
+ issues.push(`Memory usage ${perf.memoryUsage}MB exceeds maximum ${this.options.maxMemoryUsage}MB`);
424
+ score -= 0.2;
425
+ }
426
+ if (perf.throughput < this.options.minThroughput) {
427
+ issues.push(`Throughput ${perf.throughput} below minimum ${this.options.minThroughput}`);
428
+ score -= 0.2;
429
+ }
430
+ }
431
+ return {
432
+ passed: issues.length === 0,
433
+ score: Math.max(score, 0),
434
+ error: issues.length > 0 ? issues.join('; ') : undefined,
435
+ suggestions: this.generatePerformanceSuggestions(issues)
436
+ };
437
+ }
438
+ generatePerformanceSuggestions(issues) {
439
+ const suggestions = [];
440
+ if (issues.some(i => i.includes('response time'))) {
441
+ suggestions.push('Optimize database queries');
442
+ suggestions.push('Implement caching strategies');
443
+ suggestions.push('Consider pagination for large datasets');
444
+ }
445
+ if (issues.some(i => i.includes('memory'))) {
446
+ suggestions.push('Review object lifecycle management');
447
+ suggestions.push('Implement lazy loading');
448
+ }
449
+ return suggestions;
450
+ }
451
+ }
452
+ exports.PerformanceGate = PerformanceGate;
453
+ class ServiceNowGate {
454
+ constructor(options = {}) {
455
+ this.name = 'ServiceNow Compliance';
456
+ this.blocking = true;
457
+ this.options = {
458
+ checkScope: true,
459
+ checkUpdateSet: true,
460
+ checkNaming: true,
461
+ checkDependencies: true,
462
+ blocking: true,
463
+ ...options
464
+ };
465
+ }
466
+ async validate(result) {
467
+ const issues = [];
468
+ let score = 1.0;
469
+ // Check ServiceNow specific requirements
470
+ if (this.options.checkScope && !this.hasValidScope(result)) {
471
+ issues.push('Invalid or missing ServiceNow scope configuration');
472
+ score -= 0.3;
473
+ }
474
+ if (this.options.checkUpdateSet && !this.hasValidUpdateSet(result)) {
475
+ issues.push('Missing or invalid update set tracking');
476
+ score -= 0.4;
477
+ }
478
+ if (this.options.checkNaming && !this.hasValidNaming(result)) {
479
+ issues.push('ServiceNow naming conventions not followed');
480
+ score -= 0.2;
481
+ }
482
+ if (this.options.checkDependencies && !this.hasValidDependencies(result)) {
483
+ issues.push('Missing or invalid ServiceNow dependencies');
484
+ score -= 0.2;
485
+ }
486
+ return {
487
+ passed: issues.length === 0,
488
+ score: Math.max(score, 0),
489
+ error: issues.length > 0 ? issues.join('; ') : undefined,
490
+ suggestions: this.generateServiceNowSuggestions(issues)
491
+ };
492
+ }
493
+ hasValidScope(result) {
494
+ return result.servicenow?.scope && result.servicenow.scope.length > 0;
495
+ }
496
+ hasValidUpdateSet(result) {
497
+ return result.servicenow?.updateSet || result.updateSetId;
498
+ }
499
+ hasValidNaming(result) {
500
+ // Check if names follow ServiceNow conventions
501
+ if (result.name) {
502
+ return /^[a-z][a-z0-9_]*$/.test(result.name);
503
+ }
504
+ return true;
505
+ }
506
+ hasValidDependencies(result) {
507
+ // Check for required ServiceNow dependencies
508
+ return true; // Simplified - would check actual dependencies
509
+ }
510
+ generateServiceNowSuggestions(issues) {
511
+ const suggestions = [];
512
+ if (issues.some(i => i.includes('scope'))) {
513
+ suggestions.push('Configure proper ServiceNow application scope');
514
+ }
515
+ if (issues.some(i => i.includes('update set'))) {
516
+ suggestions.push('Ensure all changes are tracked in update sets');
517
+ }
518
+ if (issues.some(i => i.includes('naming'))) {
519
+ suggestions.push('Follow ServiceNow naming conventions (lowercase, underscores)');
520
+ }
521
+ return suggestions;
522
+ }
523
+ }
524
+ exports.ServiceNowGate = ServiceNowGate;
525
+ class BusinessLogicGate {
526
+ constructor(options = {}) {
527
+ this.name = 'Business Logic Validation';
528
+ this.blocking = true;
529
+ this.options = {
530
+ checkRequirements: true,
531
+ checkOutputs: true,
532
+ checkErrorHandling: true,
533
+ blocking: true,
534
+ ...options
535
+ };
536
+ }
537
+ async validate(result) {
538
+ const issues = [];
539
+ let score = 1.0;
540
+ // Check business requirements compliance
541
+ if (this.options.checkRequirements && !this.meetsBusinessRequirements(result)) {
542
+ issues.push('Does not meet specified business requirements');
543
+ score -= 0.4;
544
+ }
545
+ // Check expected outputs
546
+ if (this.options.checkOutputs && !this.hasExpectedOutputs(result)) {
547
+ issues.push('Missing expected outputs or data structures');
548
+ score -= 0.3;
549
+ }
550
+ // Check error handling
551
+ if (this.options.checkErrorHandling && !this.hasProperErrorHandling(result)) {
552
+ issues.push('Insufficient error handling implementation');
553
+ score -= 0.2;
554
+ }
555
+ return {
556
+ passed: issues.length === 0,
557
+ score: Math.max(score, 0),
558
+ error: issues.length > 0 ? issues.join('; ') : undefined,
559
+ suggestions: ['Review business requirements', 'Implement comprehensive error handling']
560
+ };
561
+ }
562
+ meetsBusinessRequirements(result) {
563
+ // Simplified - would check against actual business requirements
564
+ return result.businessLogic && Object.keys(result.businessLogic).length > 0;
565
+ }
566
+ hasExpectedOutputs(result) {
567
+ return result.outputs && Array.isArray(result.outputs) && result.outputs.length > 0;
568
+ }
569
+ hasProperErrorHandling(result) {
570
+ if (result.code) {
571
+ return /try\s*\{|catch\s*\(|throw\s+|error/i.test(result.code);
572
+ }
573
+ return true;
574
+ }
575
+ }
576
+ exports.BusinessLogicGate = BusinessLogicGate;
577
+ //# sourceMappingURL=quality-gates.js.map
@@ -0,0 +1,39 @@
1
+ import { EventEmitter } from 'eventemitter3';
2
+ import { MemoryValue } from './types';
3
+ import { SnowAgent } from '../types/snow-flow.types';
4
+ export declare class SharedMemoryManager extends EventEmitter {
5
+ private memory;
6
+ private subscribers;
7
+ private versionCounters;
8
+ private accessLogs;
9
+ private readonly ttl;
10
+ private cleanupInterval;
11
+ constructor(ttl?: number);
12
+ store(key: string, value: any, notifySubscribers?: boolean): Promise<void>;
13
+ get(key: string): Promise<any>;
14
+ subscribe(key: string, agent: SnowAgent, callback: (key: string, value: any, version: number) => Promise<void>): Promise<void>;
15
+ unsubscribe(key: string, agent: SnowAgent): Promise<void>;
16
+ getHistory(key: string, limit?: number): Promise<MemoryValue[]>;
17
+ getKeys(pattern?: string): Promise<string[]>;
18
+ delete(key: string): Promise<boolean>;
19
+ clear(): Promise<void>;
20
+ getStats(): Promise<MemoryStats>;
21
+ compareAndSwap(key: string, expectedValue: any, newValue: any): Promise<boolean>;
22
+ atomicUpdate(key: string, updateFunction: (currentValue: any) => any): Promise<any>;
23
+ private getNextVersion;
24
+ private notifySubscribers;
25
+ private logAccess;
26
+ private calculateSize;
27
+ private isExpired;
28
+ private cleanupExpiredEntries;
29
+ destroy(): void;
30
+ }
31
+ interface MemoryStats {
32
+ totalEntries: number;
33
+ totalSize: number;
34
+ subscriberCount: number;
35
+ oldestEntryAge: number;
36
+ averageEntrySize: number;
37
+ }
38
+ export {};
39
+ //# sourceMappingURL=shared-memory.d.ts.map