pumuki-ast-hooks 5.3.18 → 5.3.20

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 (91) hide show
  1. package/docs/VIOLATIONS_RESOLUTION_PLAN.md +39 -37
  2. package/package.json +8 -2
  3. package/scripts/hooks-system/application/CompositionRoot.js +24 -73
  4. package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +18 -0
  5. package/scripts/hooks-system/application/services/ContextDetectionEngine.js +58 -0
  6. package/scripts/hooks-system/application/services/DynamicRulesLoader.js +12 -2
  7. package/scripts/hooks-system/application/services/GitFlowService.js +80 -0
  8. package/scripts/hooks-system/application/services/GitTreeState.js +143 -13
  9. package/scripts/hooks-system/application/services/HookSystemScheduler.js +47 -0
  10. package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +25 -0
  11. package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +11 -0
  12. package/scripts/hooks-system/application/services/PlatformAnalysisService.js +19 -0
  13. package/scripts/hooks-system/application/services/PlatformDetectionService.js +19 -0
  14. package/scripts/hooks-system/application/services/PlaybookRunner.js +22 -1
  15. package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +19 -0
  16. package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +25 -0
  17. package/scripts/hooks-system/application/services/RealtimeGuardService.js +41 -84
  18. package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +11 -0
  19. package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +11 -0
  20. package/scripts/hooks-system/application/services/commit/FeatureDetector.js +11 -0
  21. package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +25 -0
  22. package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +21 -31
  23. package/scripts/hooks-system/application/services/guard/GuardConfig.js +18 -15
  24. package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +11 -0
  25. package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +26 -0
  26. package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +20 -6
  27. package/scripts/hooks-system/application/services/guard/GuardLockManager.js +11 -0
  28. package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +25 -0
  29. package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +11 -0
  30. package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +10 -28
  31. package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +11 -0
  32. package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +18 -0
  33. package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +18 -0
  34. package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +18 -3
  35. package/scripts/hooks-system/application/services/installation/HookInstaller.js +19 -0
  36. package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +11 -0
  37. package/scripts/hooks-system/application/services/installation/InstallService.js +25 -1
  38. package/scripts/hooks-system/application/services/installation/McpConfigurator.js +19 -2
  39. package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +11 -0
  40. package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +11 -0
  41. package/scripts/hooks-system/application/services/logging/AuditLogger.js +90 -1
  42. package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +15 -13
  43. package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +33 -0
  44. package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +27 -0
  45. package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +26 -0
  46. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +19 -0
  47. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +27 -6
  48. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +28 -0
  49. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +26 -0
  50. package/scripts/hooks-system/application/services/monitoring/HealthCheckProviders.js +4 -0
  51. package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +25 -0
  52. package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +26 -0
  53. package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +26 -0
  54. package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +11 -0
  55. package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +18 -0
  56. package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +11 -0
  57. package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +18 -0
  58. package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +18 -0
  59. package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +11 -0
  60. package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +20 -0
  61. package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +19 -0
  62. package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +19 -0
  63. package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +11 -0
  64. package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +19 -0
  65. package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +4 -0
  66. package/scripts/hooks-system/application/services/token/CursorTokenService.js +20 -0
  67. package/scripts/hooks-system/application/services/token/TokenMetricsService.js +11 -13
  68. package/scripts/hooks-system/application/services/token/TokenMonitorService.js +19 -0
  69. package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +12 -0
  70. package/scripts/hooks-system/bin/__tests__/evidence-update.spec.js +49 -0
  71. package/scripts/hooks-system/bin/cli.js +1 -15
  72. package/scripts/hooks-system/config/project.config.json +1 -1
  73. package/scripts/hooks-system/domain/events/index.js +24 -31
  74. package/scripts/hooks-system/domain/exceptions/index.js +87 -0
  75. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +2 -3
  76. package/scripts/hooks-system/infrastructure/ast/ast-core.js +20 -12
  77. package/scripts/hooks-system/infrastructure/ast/ast-intelligence.js +18 -8
  78. package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +1 -2
  79. package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +14 -18
  80. package/scripts/hooks-system/infrastructure/ast/frontend/ast-frontend.js +196 -196
  81. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/__tests__/iOSASTIntelligentAnalyzer.spec.js +66 -0
  82. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +2 -3
  83. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSArchitectureRules.js +24 -86
  84. package/scripts/hooks-system/infrastructure/config/config.js +5 -0
  85. package/scripts/hooks-system/infrastructure/hooks/skill-activation-prompt.js +2 -3
  86. package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +5 -35
  87. package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +16 -86
  88. package/scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh +54 -92
  89. package/scripts/hooks-system/infrastructure/telemetry/metric-scope.js +98 -0
  90. package/scripts/hooks-system/infrastructure/telemetry/metrics-server.js +2 -51
  91. package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +8 -6
@@ -1,3 +1,7 @@
1
+ const {
2
+ createMetricScope: createMetricScope
3
+ } = require('../../../infrastructure/telemetry/metric-scope');
4
+
1
5
  class GitTreeMonitorService {
2
6
  constructor({
3
7
  repoRoot = process.cwd(),
@@ -10,6 +14,12 @@ class GitTreeMonitorService {
10
14
  logger = console,
11
15
  debugLogger = null
12
16
  } = {}) {
17
+ const m_constructor = createMetricScope({
18
+ hook: 'git_tree_monitor_service',
19
+ operation: 'constructor'
20
+ });
21
+
22
+ m_constructor.started();
13
23
  this.repoRoot = repoRoot;
14
24
  this.limit = limit;
15
25
  this.warning = warning;
@@ -23,10 +33,18 @@ class GitTreeMonitorService {
23
33
  this.lastCritical = 0;
24
34
  this.lastWarning = 0;
25
35
  this.wasOverLimit = false;
36
+ m_constructor.success();
26
37
  }
27
38
 
28
39
  start() {
40
+ const m_start = createMetricScope({
41
+ hook: 'git_tree_monitor_service',
42
+ operation: 'start'
43
+ });
44
+
45
+ m_start.started();
29
46
  if (!Number.isFinite(this.limit) || this.limit <= 0 || typeof this.getState !== 'function') {
47
+ m_start.success();
30
48
  return;
31
49
  }
32
50
  this.check('startup');
@@ -36,13 +54,21 @@ class GitTreeMonitorService {
36
54
  this.timer.unref();
37
55
  }
38
56
  }
57
+ m_start.success();
39
58
  }
40
59
 
41
60
  stop() {
61
+ const m_stop = createMetricScope({
62
+ hook: 'git_tree_monitor_service',
63
+ operation: 'stop'
64
+ });
65
+
66
+ m_stop.started();
42
67
  if (this.timer) {
43
68
  clearInterval(this.timer);
44
69
  this.timer = null;
45
70
  }
71
+ m_stop.success();
46
72
  }
47
73
 
48
74
  check(reason) {
@@ -1,6 +1,10 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
+ const {
5
+ createMetricScope: createMetricScope
6
+ } = require('../../../infrastructure/telemetry/metric-scope');
7
+
4
8
  const defaultHeartbeatPath = repoRoot => path.join(repoRoot, '.audit_tmp', 'guard-heartbeat.json');
5
9
  const defaultTokenUsagePath = repoRoot => path.join(repoRoot, '.audit_tmp', 'token-usage.jsonl');
6
10
  const defaultEvidencePath = repoRoot => path.join(repoRoot, '.AI_EVIDENCE.json');
@@ -1,6 +1,10 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
+ const {
5
+ createMetricScope: createMetricScope
6
+ } = require('../../../infrastructure/telemetry/metric-scope');
7
+
4
8
  class HealthCheckService {
5
9
  constructor({
6
10
  repoRoot = process.cwd(),
@@ -12,6 +16,12 @@ class HealthCheckService {
12
16
  intervalMs = 0,
13
17
  timers = { setInterval, clearInterval }
14
18
  } = {}) {
19
+ const m_constructor = createMetricScope({
20
+ hook: 'health_check_service',
21
+ operation: 'constructor'
22
+ });
23
+
24
+ m_constructor.started();
15
25
  this.repoRoot = repoRoot;
16
26
  this.providers = Array.isArray(providers) ? providers : [];
17
27
  this.notificationCenter = notificationCenter;
@@ -22,9 +32,16 @@ class HealthCheckService {
22
32
  this.timers = timers;
23
33
  this.history = [];
24
34
  this.timerRef = null;
35
+ m_constructor.success();
25
36
  }
26
37
 
27
38
  start(reason = 'startup') {
39
+ const m_start = createMetricScope({
40
+ hook: 'health_check_service',
41
+ operation: 'start'
42
+ });
43
+
44
+ m_start.started();
28
45
  this.collect(reason);
29
46
  if (this.intervalMs > 0) {
30
47
  this.timerRef = this.timers.setInterval(() => this.collect('interval'), this.intervalMs);
@@ -32,13 +49,21 @@ class HealthCheckService {
32
49
  this.timerRef.unref();
33
50
  }
34
51
  }
52
+ m_start.success();
35
53
  }
36
54
 
37
55
  stop() {
56
+ const m_stop = createMetricScope({
57
+ hook: 'health_check_service',
58
+ operation: 'stop'
59
+ });
60
+
61
+ m_stop.started();
38
62
  if (this.timerRef) {
39
63
  this.timers.clearInterval(this.timerRef);
40
64
  this.timerRef = null;
41
65
  }
66
+ m_stop.success();
42
67
  }
43
68
 
44
69
  async collect(reason = 'manual') {
@@ -1,6 +1,10 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
+ const {
5
+ createMetricScope: createMetricScope
6
+ } = require('../../../infrastructure/telemetry/metric-scope');
7
+
4
8
  class HeartbeatMonitorService {
5
9
  constructor({
6
10
  repoRoot = process.cwd(),
@@ -9,6 +13,12 @@ class HeartbeatMonitorService {
9
13
  statusProvider = () => null,
10
14
  logger = console
11
15
  } = {}) {
16
+ const m_constructor = createMetricScope({
17
+ hook: 'heartbeat_monitor_service',
18
+ operation: 'constructor'
19
+ });
20
+
21
+ m_constructor.started();
12
22
  this.repoRoot = repoRoot;
13
23
  this.heartbeatPath = heartbeatPath;
14
24
  this.intervalMs = intervalMs;
@@ -16,10 +26,18 @@ class HeartbeatMonitorService {
16
26
  this.logger = logger;
17
27
  this.timer = null;
18
28
  this.lastStatus = null;
29
+ m_constructor.success();
19
30
  }
20
31
 
21
32
  start() {
33
+ const m_start = createMetricScope({
34
+ hook: 'heartbeat_monitor_service',
35
+ operation: 'start'
36
+ });
37
+
38
+ m_start.started();
22
39
  if (!Number.isFinite(this.intervalMs) || this.intervalMs <= 0) {
40
+ m_start.success();
23
41
  return;
24
42
  }
25
43
  this.emitHeartbeat();
@@ -27,13 +45,21 @@ class HeartbeatMonitorService {
27
45
  if (this.timer && typeof this.timer.unref === 'function') {
28
46
  this.timer.unref();
29
47
  }
48
+ m_start.success();
30
49
  }
31
50
 
32
51
  stop() {
52
+ const m_stop = createMetricScope({
53
+ hook: 'heartbeat_monitor_service',
54
+ operation: 'stop'
55
+ });
56
+
57
+ m_stop.started();
33
58
  if (this.timer) {
34
59
  clearInterval(this.timer);
35
60
  this.timer = null;
36
61
  }
62
+ m_stop.success();
37
63
  }
38
64
 
39
65
  emitHeartbeat() {
@@ -3,11 +3,22 @@ const path = require('path');
3
3
  const { spawn, spawnSync } = require('child_process');
4
4
  const { ConfigurationError } = require('../../../domain/errors');
5
5
 
6
+ const {
7
+ createMetricScope: createMetricScope
8
+ } = require('../../../infrastructure/telemetry/metric-scope');
9
+
6
10
  class TokenMonitor {
7
11
  constructor(repoRoot, options = {}) {
12
+ const m_constructor = createMetricScope({
13
+ hook: 'token_monitor',
14
+ operation: 'constructor'
15
+ });
16
+
17
+ m_constructor.started();
8
18
  this.repoRoot = repoRoot;
9
19
  this.scriptPath = path.join(repoRoot, 'infrastructure', 'watchdog', 'token-monitor-loop.sh');
10
20
  this.process = null;
21
+ m_constructor.success();
11
22
  }
12
23
 
13
24
  isAvailable() {
@@ -15,6 +26,12 @@ class TokenMonitor {
15
26
  }
16
27
 
17
28
  start() {
29
+ const m_start = createMetricScope({
30
+ hook: 'token_monitor',
31
+ operation: 'start'
32
+ });
33
+
34
+ m_start.started();
18
35
  if (!this.isAvailable()) {
19
36
  throw new ConfigurationError('Token monitor script not found', 'scriptPath');
20
37
  }
@@ -42,14 +59,23 @@ class TokenMonitor {
42
59
  this.process = null;
43
60
  });
44
61
 
62
+ m_start.success();
63
+
45
64
  return this.process;
46
65
  }
47
66
 
48
67
  stop() {
68
+ const m_stop = createMetricScope({
69
+ hook: 'token_monitor',
70
+ operation: 'stop'
71
+ });
72
+
73
+ m_stop.started();
49
74
  if (this.process && this.process.kill) {
50
75
  this.process.kill('SIGTERM');
51
76
  this.process = null;
52
77
  }
78
+ m_stop.success();
53
79
  }
54
80
 
55
81
  isRunning() {
@@ -1,11 +1,22 @@
1
1
  const { spawnSync } = require('child_process');
2
2
  const fs = require('fs');
3
3
 
4
+ const {
5
+ createMetricScope: createMetricScope
6
+ } = require('../../../infrastructure/telemetry/metric-scope');
7
+
4
8
  class MacNotificationSender {
5
9
  constructor(logger) {
10
+ const m_constructor = createMetricScope({
11
+ hook: 'mac_notification_sender',
12
+ operation: 'constructor'
13
+ });
14
+
15
+ m_constructor.started();
6
16
  this.logger = logger;
7
17
  this.terminalNotifierPath = this.resolveTerminalNotifier();
8
18
  this.osascriptPath = this.resolveOsascript();
19
+ m_constructor.success();
9
20
  }
10
21
 
11
22
  resolveTerminalNotifier() {
@@ -21,8 +21,18 @@ const NotificationQueue = require('./components/NotificationQueue');
21
21
  const NotificationRetryExecutor = require('./components/NotificationRetryExecutor');
22
22
  const NotificationDispatcher = require('./NotificationDispatcher');
23
23
 
24
+ const {
25
+ createMetricScope: createMetricScope
26
+ } = require('../../../infrastructure/telemetry/metric-scope');
27
+
24
28
  class NotificationCenterService {
25
29
  constructor(config = {}) {
30
+ const m_constructor = createMetricScope({
31
+ hook: 'notification_center_service',
32
+ operation: 'constructor'
33
+ });
34
+
35
+ m_constructor.started();
26
36
  this.repoRoot = config.repoRoot || process.cwd();
27
37
  this.enabled = config.enabled !== false;
28
38
 
@@ -83,6 +93,7 @@ class NotificationCenterService {
83
93
  totalFailed: 0,
84
94
  totalRetries: 0
85
95
  };
96
+ m_constructor.success();
86
97
  }
87
98
 
88
99
  /**
@@ -173,6 +184,13 @@ class NotificationCenterService {
173
184
  * Gets service statistics
174
185
  */
175
186
  getStats() {
187
+ const m_get_stats = createMetricScope({
188
+ hook: 'notification_center_service',
189
+ operation: 'get_stats'
190
+ });
191
+
192
+ m_get_stats.started();
193
+ m_get_stats.success();
176
194
  return {
177
195
  ...this.stats,
178
196
  queueSize: this.queue.size(),
@@ -1,9 +1,20 @@
1
+ const {
2
+ createMetricScope: createMetricScope
3
+ } = require('../../../infrastructure/telemetry/metric-scope');
4
+
1
5
  class NotificationDispatcher {
2
6
  constructor(sender, retryExecutor, cooldownManager, logger) {
7
+ const m_constructor = createMetricScope({
8
+ hook: 'notification_dispatcher',
9
+ operation: 'constructor'
10
+ });
11
+
12
+ m_constructor.started();
3
13
  this.sender = sender;
4
14
  this.retryExecutor = retryExecutor;
5
15
  this.cooldownManager = cooldownManager;
6
16
  this.logger = logger;
17
+ m_constructor.success();
7
18
  }
8
19
 
9
20
  async dispatch(notification, stats) {
@@ -1,9 +1,20 @@
1
+ const {
2
+ createMetricScope: createMetricScope
3
+ } = require('../../../infrastructure/telemetry/metric-scope');
4
+
1
5
  class NotificationCooldownManager {
2
6
  constructor(defaultCooldownMs = 60000, cooldownsByType = {}, logger = null) {
7
+ const m_constructor = createMetricScope({
8
+ hook: 'notification_cooldown_manager',
9
+ operation: 'constructor'
10
+ });
11
+
12
+ m_constructor.started();
3
13
  this.cooldowns = new Map();
4
14
  this.defaultCooldownMs = defaultCooldownMs;
5
15
  this.cooldownsByType = cooldownsByType;
6
16
  this.logger = logger;
17
+ m_constructor.success();
7
18
  }
8
19
 
9
20
  isInCooldown(notification) {
@@ -49,6 +60,13 @@ class NotificationCooldownManager {
49
60
  }
50
61
 
51
62
  getStats() {
63
+ const m_get_stats = createMetricScope({
64
+ hook: 'notification_cooldown_manager',
65
+ operation: 'get_stats'
66
+ });
67
+
68
+ m_get_stats.started();
69
+ m_get_stats.success();
52
70
  return {
53
71
  activeCooldowns: this.cooldowns.size
54
72
  };
@@ -1,10 +1,21 @@
1
1
  const crypto = require('crypto');
2
2
 
3
+ const {
4
+ createMetricScope: createMetricScope
5
+ } = require('../../../infrastructure/telemetry/metric-scope');
6
+
3
7
  class NotificationDeduplicator {
4
8
  constructor(windowMs = 5000, logger = null) {
9
+ const m_constructor = createMetricScope({
10
+ hook: 'notification_deduplicator',
11
+ operation: 'constructor'
12
+ });
13
+
14
+ m_constructor.started();
5
15
  this.deduplicationMap = new Map();
6
16
  this.windowMs = windowMs;
7
17
  this.logger = logger;
18
+ m_constructor.success();
8
19
  }
9
20
 
10
21
  isDuplicate(notification) {
@@ -54,6 +65,13 @@ class NotificationDeduplicator {
54
65
  }
55
66
 
56
67
  getStats() {
68
+ const m_get_stats = createMetricScope({
69
+ hook: 'notification_deduplicator',
70
+ operation: 'get_stats'
71
+ });
72
+
73
+ m_get_stats.started();
74
+ m_get_stats.success();
57
75
  return {
58
76
  size: this.deduplicationMap.size
59
77
  };
@@ -1,7 +1,18 @@
1
+ const {
2
+ createMetricScope: createMetricScope
3
+ } = require('../../../infrastructure/telemetry/metric-scope');
4
+
1
5
  class NotificationQueue {
2
6
  constructor(maxSize = 100) {
7
+ const m_constructor = createMetricScope({
8
+ hook: 'notification_queue',
9
+ operation: 'constructor'
10
+ });
11
+
12
+ m_constructor.started();
3
13
  this.maxSize = maxSize;
4
14
  this.items = [];
15
+ m_constructor.success();
5
16
  }
6
17
 
7
18
  enqueue(item) {
@@ -1,12 +1,29 @@
1
+ const {
2
+ createMetricScope: createMetricScope
3
+ } = require('../../../infrastructure/telemetry/metric-scope');
4
+
1
5
  class NotificationRetryExecutor {
2
6
  constructor(sender, config = {}, logger = null) {
7
+ const m_constructor = createMetricScope({
8
+ hook: 'notification_retry_executor',
9
+ operation: 'constructor'
10
+ });
11
+
12
+ m_constructor.started();
3
13
  this.sender = sender;
4
14
  this.maxRetries = config.maxRetries || 2;
5
15
  this.retryDelayMs = config.retryDelayMs || 1000;
6
16
  this.logger = logger;
17
+ m_constructor.success();
7
18
  }
8
19
 
9
20
  async execute(notification, options = {}) {
21
+ const m_execute = createMetricScope({
22
+ hook: 'notification_retry_executor',
23
+ operation: 'execute'
24
+ });
25
+
26
+ m_execute.started();
10
27
  const currentRetries = notification.retries || 0;
11
28
  const remainingRetries = currentRetries < this.maxRetries ? this.maxRetries - currentRetries : 0;
12
29
 
@@ -21,6 +38,7 @@ class NotificationRetryExecutor {
21
38
  if (attempt > 0) {
22
39
  this.logRetrySuccess(notification, attempt);
23
40
  }
41
+ m_execute.success();
24
42
  return { success: true, attempts: attempt + 1 };
25
43
  }
26
44
  } catch (error) {
@@ -28,6 +46,8 @@ class NotificationRetryExecutor {
28
46
  }
29
47
  }
30
48
 
49
+ m_execute.success();
50
+
31
51
  return { success: false, attempts: remainingRetries + 1 };
32
52
  }
33
53
 
@@ -1,9 +1,20 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
+ const {
5
+ createMetricScope: createMetricScope
6
+ } = require('../../../infrastructure/telemetry/metric-scope');
7
+
4
8
  class PlatformHeuristics {
5
9
  constructor(platformDetector) {
10
+ const m_constructor = createMetricScope({
11
+ hook: 'platform_heuristics',
12
+ operation: 'constructor'
13
+ });
14
+
15
+ m_constructor.started();
6
16
  this.platformDetector = platformDetector;
17
+ m_constructor.success();
7
18
  }
8
19
 
9
20
  detectFromASTSystemFiles(files) {
@@ -129,6 +140,12 @@ class PlatformHeuristics {
129
140
  }
130
141
 
131
142
  getPlatformFrequencyInHistory(platform, commits) {
143
+ const m_get_platform_frequency_in_history = createMetricScope({
144
+ hook: 'platform_heuristics',
145
+ operation: 'get_platform_frequency_in_history'
146
+ });
147
+
148
+ m_get_platform_frequency_in_history.started();
132
149
  if (!commits || commits.length === 0) return 0;
133
150
 
134
151
  const platformCommits = commits.filter(commit =>
@@ -137,6 +154,8 @@ class PlatformHeuristics {
137
154
  )
138
155
  );
139
156
 
157
+ m_get_platform_frequency_in_history.success();
158
+
140
159
  return platformCommits.length / commits.length;
141
160
  }
142
161
  }
@@ -1,5 +1,9 @@
1
1
  const path = require('path');
2
2
 
3
+ const {
4
+ createMetricScope: createMetricScope
5
+ } = require('../../../infrastructure/telemetry/metric-scope');
6
+
3
7
  class AutoRecoveryManager {
4
8
  constructor({
5
9
  repoRoot = process.cwd(),
@@ -11,6 +15,12 @@ class AutoRecoveryManager {
11
15
  baseBackoffMs = 2000,
12
16
  jitter = 0.25
13
17
  } = {}) {
18
+ const m_constructor = createMetricScope({
19
+ hook: 'auto_recovery_manager',
20
+ operation: 'constructor'
21
+ });
22
+
23
+ m_constructor.started();
14
24
  this.repoRoot = repoRoot;
15
25
  this.logger = logger || console;
16
26
  this.notificationCenter = notificationCenter;
@@ -23,14 +33,23 @@ class AutoRecoveryManager {
23
33
  : [AutoRecoveryManager.createSupervisorRestartStrategy()];
24
34
  this.attempts = new Map();
25
35
  this.timeouts = new Map();
36
+ m_constructor.success();
26
37
  }
27
38
 
28
39
  static createSupervisorRestartStrategy() {
40
+ const m_create_supervisor_restart_strategy = createMetricScope({
41
+ hook: 'auto_recovery_manager',
42
+ operation: 'create_supervisor_restart_strategy'
43
+ });
44
+
45
+ m_create_supervisor_restart_strategy.started();
46
+ m_create_supervisor_restart_strategy.success();
29
47
  return {
30
48
  id: 'guard-supervisor-restart',
31
49
  condition: ({ reason }) => reason && reason.startsWith('heartbeat-'),
32
50
  action: async ({ logger }) => {
33
51
  logger.info('Attempting guard-supervisor restart via start-guards.sh');
52
+ m_create_supervisor_restart_strategy.success();
34
53
  return AutoRecoveryManager.runScript('start-guards.sh', ['restart']);
35
54
  }
36
55
  };
@@ -1,7 +1,17 @@
1
1
  const path = require('path');
2
2
 
3
+ const {
4
+ createMetricScope: createMetricScope
5
+ } = require('../../../infrastructure/telemetry/metric-scope');
6
+
3
7
  class CommitMessageSuggester {
4
8
  constructor(featureDetector) {
9
+ const m_constructor = createMetricScope({
10
+ hook: 'commit_message_suggester',
11
+ operation: 'constructor'
12
+ });
13
+
14
+ m_constructor.started();
5
15
  this.featureDetector = featureDetector;
6
16
  this.commitTypePatterns = {
7
17
  feat: ['feature/', 'feat/', 'add', 'new', 'create', 'implement'],
@@ -12,6 +22,7 @@ class CommitMessageSuggester {
12
22
  chore: ['chore/', 'config/', 'build/', 'ci/'],
13
23
  style: ['style/', 'css/', 'scss/', 'styling']
14
24
  };
25
+ m_constructor.success();
15
26
  }
16
27
 
17
28
  suggest(group) {
@@ -1,9 +1,20 @@
1
1
  const path = require('path');
2
2
 
3
+ const {
4
+ createMetricScope: createMetricScope
5
+ } = require('../../../infrastructure/telemetry/metric-scope');
6
+
3
7
  class FileContextGrouper {
4
8
  constructor(featureDetector, platformDetector = null) {
9
+ const m_constructor = createMetricScope({
10
+ hook: 'file_context_grouper',
11
+ operation: 'constructor'
12
+ });
13
+
14
+ m_constructor.started();
5
15
  this.featureDetector = featureDetector;
6
16
  this.platformDetector = platformDetector;
17
+ m_constructor.success();
7
18
  }
8
19
 
9
20
  group(files) {
@@ -89,10 +100,18 @@ class FileContextGrouper {
89
100
  }
90
101
 
91
102
  getContextDirectory(file) {
103
+ const m_get_context_directory = createMetricScope({
104
+ hook: 'file_context_grouper',
105
+ operation: 'get_context_directory'
106
+ });
107
+
108
+ m_get_context_directory.started();
92
109
  const parts = file.split(path.sep);
93
110
  if (parts.length <= 2) {
111
+ m_get_context_directory.success();
94
112
  return parts[0] || 'root';
95
113
  }
114
+ m_get_context_directory.success();
96
115
  return parts.slice(0, 2).join(path.sep);
97
116
  }
98
117
 
@@ -1,3 +1,7 @@
1
+ const {
2
+ createMetricScope: createMetricScope
3
+ } = require('../../../infrastructure/telemetry/metric-scope');
4
+
1
5
  class SmartCommitSummaryBuilder {
2
6
  build(suggestions, orphans) {
3
7
  const lines = [];