pumuki-ast-hooks 5.3.19 → 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 (75) hide show
  1. package/docs/VIOLATIONS_RESOLUTION_PLAN.md +38 -34
  2. package/package.json +7 -1
  3. package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +18 -0
  4. package/scripts/hooks-system/application/services/ContextDetectionEngine.js +58 -0
  5. package/scripts/hooks-system/application/services/DynamicRulesLoader.js +11 -0
  6. package/scripts/hooks-system/application/services/GitFlowService.js +80 -0
  7. package/scripts/hooks-system/application/services/GitTreeState.js +4 -0
  8. package/scripts/hooks-system/application/services/HookSystemScheduler.js +4 -0
  9. package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +25 -0
  10. package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +11 -0
  11. package/scripts/hooks-system/application/services/PlatformAnalysisService.js +19 -0
  12. package/scripts/hooks-system/application/services/PlatformDetectionService.js +19 -0
  13. package/scripts/hooks-system/application/services/PlaybookRunner.js +22 -1
  14. package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +19 -0
  15. package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +25 -0
  16. package/scripts/hooks-system/application/services/RealtimeGuardService.js +27 -0
  17. package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +11 -0
  18. package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +11 -0
  19. package/scripts/hooks-system/application/services/commit/FeatureDetector.js +11 -0
  20. package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +25 -0
  21. package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +19 -0
  22. package/scripts/hooks-system/application/services/guard/GuardConfig.js +11 -0
  23. package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +11 -0
  24. package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +26 -0
  25. package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +11 -0
  26. package/scripts/hooks-system/application/services/guard/GuardLockManager.js +11 -0
  27. package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +25 -0
  28. package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +11 -0
  29. package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +11 -0
  30. package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +11 -0
  31. package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +18 -0
  32. package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +18 -0
  33. package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +18 -0
  34. package/scripts/hooks-system/application/services/installation/HookInstaller.js +19 -0
  35. package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +11 -0
  36. package/scripts/hooks-system/application/services/installation/InstallService.js +25 -1
  37. package/scripts/hooks-system/application/services/installation/McpConfigurator.js +18 -0
  38. package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +11 -0
  39. package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +11 -0
  40. package/scripts/hooks-system/application/services/logging/AuditLogger.js +4 -0
  41. package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +11 -0
  42. package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +33 -0
  43. package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +27 -0
  44. package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +26 -0
  45. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +18 -0
  46. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +25 -0
  47. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +28 -0
  48. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +26 -0
  49. package/scripts/hooks-system/application/services/monitoring/HealthCheckProviders.js +4 -0
  50. package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +25 -0
  51. package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +26 -0
  52. package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +26 -0
  53. package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +11 -0
  54. package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +18 -0
  55. package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +11 -0
  56. package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +18 -0
  57. package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +18 -0
  58. package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +11 -0
  59. package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +20 -0
  60. package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +19 -0
  61. package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +19 -0
  62. package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +11 -0
  63. package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +19 -0
  64. package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +4 -0
  65. package/scripts/hooks-system/application/services/token/CursorTokenService.js +20 -0
  66. package/scripts/hooks-system/application/services/token/TokenMetricsService.js +11 -0
  67. package/scripts/hooks-system/application/services/token/TokenMonitorService.js +19 -0
  68. package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +12 -0
  69. package/scripts/hooks-system/config/project.config.json +1 -1
  70. package/scripts/hooks-system/domain/events/index.js +25 -6
  71. package/scripts/hooks-system/domain/exceptions/index.js +87 -0
  72. package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +7 -9
  73. package/scripts/hooks-system/infrastructure/config/config.js +5 -0
  74. package/scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh +54 -92
  75. package/scripts/hooks-system/infrastructure/telemetry/metric-scope.js +98 -0
@@ -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 DevDocsMonitor {
5
9
  constructor({
6
10
  repoRoot = process.cwd(),
@@ -10,6 +14,12 @@ class DevDocsMonitor {
10
14
  logger = console,
11
15
  notificationService = null
12
16
  } = {}) {
17
+ const m_constructor = createMetricScope({
18
+ hook: 'dev_docs_monitor',
19
+ operation: 'constructor'
20
+ });
21
+
22
+ m_constructor.started();
13
23
  this.repoRoot = repoRoot;
14
24
  this.checkIntervalMs = checkIntervalMs;
15
25
  this.staleThresholdMs = staleThresholdMs;
@@ -18,11 +28,19 @@ class DevDocsMonitor {
18
28
  this.notificationService = notificationService;
19
29
  this.timer = null;
20
30
  this.docsStatePath = path.join(repoRoot, '.audit_tmp', 'dev-docs-state.json');
31
+ m_constructor.success();
21
32
  }
22
33
 
23
34
  start() {
35
+ const m_start = createMetricScope({
36
+ hook: 'dev_docs_monitor',
37
+ operation: 'start'
38
+ });
39
+
40
+ m_start.started();
24
41
  if (!this.autoRefreshEnabled) {
25
42
  this.logger.info('[DevDocsMonitor] Auto-refresh disabled');
43
+ m_start.success();
26
44
  return;
27
45
  }
28
46
 
@@ -32,13 +50,21 @@ class DevDocsMonitor {
32
50
  this.timer.unref();
33
51
  }
34
52
  this.logger.info('[DevDocsMonitor] Started');
53
+ m_start.success();
35
54
  }
36
55
 
37
56
  stop() {
57
+ const m_stop = createMetricScope({
58
+ hook: 'dev_docs_monitor',
59
+ operation: 'stop'
60
+ });
61
+
62
+ m_stop.started();
38
63
  if (this.timer) {
39
64
  clearInterval(this.timer);
40
65
  this.timer = null;
41
66
  }
67
+ m_stop.success();
42
68
  }
43
69
 
44
70
  async checkDocs() {
@@ -3,8 +3,18 @@ const path = require('path');
3
3
  const { execSync } = require('child_process');
4
4
  const { ConfigurationError, DomainError } = require('../../../domain/errors');
5
5
 
6
+ const {
7
+ createMetricScope: createMetricScope
8
+ } = require('../../../infrastructure/telemetry/metric-scope');
9
+
6
10
  class EvidenceMonitor {
7
11
  constructor(repoRoot, options = {}) {
12
+ const m_constructor = createMetricScope({
13
+ hook: 'evidence_monitor',
14
+ operation: 'constructor'
15
+ });
16
+
17
+ m_constructor.started();
8
18
  this.repoRoot = repoRoot;
9
19
  this.staleThresholdMs = options.staleThresholdMs || 180000;
10
20
  this.pollIntervalMs = options.pollIntervalMs || 30000;
@@ -14,6 +24,7 @@ class EvidenceMonitor {
14
24
  this.evidencePath = path.join(repoRoot, '.AI_EVIDENCE.json');
15
25
  this.tempDir = path.join(repoRoot, '.audit_tmp');
16
26
  this.updateScript = this.resolveUpdateEvidenceScript();
27
+ m_constructor.success();
17
28
  }
18
29
 
19
30
  resolveUpdateEvidenceScript() {
@@ -94,10 +105,17 @@ class EvidenceMonitor {
94
105
  }
95
106
 
96
107
  stop() {
108
+ const m_stop = createMetricScope({
109
+ hook: 'evidence_monitor',
110
+ operation: 'stop'
111
+ });
112
+
113
+ m_stop.started();
97
114
  if (this.pollTimer) {
98
115
  clearInterval(this.pollTimer);
99
116
  this.pollTimer = null;
100
117
  }
118
+ m_stop.success();
101
119
  }
102
120
  }
103
121
 
@@ -2,6 +2,10 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { execSync } = require('child_process');
4
4
 
5
+ const {
6
+ createMetricScope: createMetricScope
7
+ } = require('../../../infrastructure/telemetry/metric-scope');
8
+
5
9
  function resolveUpdateEvidenceScript(repoRoot) {
6
10
  const candidates = [
7
11
  path.join(repoRoot, 'scripts/hooks-system/bin/update-evidence.sh'),
@@ -31,6 +35,12 @@ class EvidenceMonitorService {
31
35
  fsModule = fs,
32
36
  execFn = execSync
33
37
  } = {}) {
38
+ const m_constructor = createMetricScope({
39
+ hook: 'evidence_monitor_service',
40
+ operation: 'constructor'
41
+ });
42
+
43
+ m_constructor.started();
34
44
  this.repoRoot = repoRoot;
35
45
  this.evidencePath = evidencePath;
36
46
  this.updateScriptPath = updateScriptPath;
@@ -43,14 +53,28 @@ class EvidenceMonitorService {
43
53
  this.exec = execFn;
44
54
  this.watchers = [];
45
55
  this.lastAutoRefresh = 0;
56
+ m_constructor.success();
46
57
  }
47
58
 
48
59
  start() {
60
+ const m_start = createMetricScope({
61
+ hook: 'evidence_monitor_service',
62
+ operation: 'start'
63
+ });
64
+
65
+ m_start.started();
49
66
  this.performInitialChecks();
50
67
  this.watchEvidenceFreshness();
68
+ m_start.success();
51
69
  }
52
70
 
53
71
  stop() {
72
+ const m_stop = createMetricScope({
73
+ hook: 'evidence_monitor_service',
74
+ operation: 'stop'
75
+ });
76
+
77
+ m_stop.started();
54
78
  this.watchers.forEach(watcher => {
55
79
  try {
56
80
  watcher.close();
@@ -59,6 +83,7 @@ class EvidenceMonitorService {
59
83
  }
60
84
  });
61
85
  this.watchers = [];
86
+ m_stop.success();
62
87
  }
63
88
 
64
89
  performInitialChecks() {
@@ -2,8 +2,18 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { execSync } = require('child_process');
4
4
 
5
+ const {
6
+ createMetricScope: createMetricScope
7
+ } = require('../../../infrastructure/telemetry/metric-scope');
8
+
5
9
  class GitTreeMonitor {
6
10
  constructor(repoRoot, options = {}) {
11
+ const m_constructor = createMetricScope({
12
+ hook: 'git_tree_monitor',
13
+ operation: 'constructor'
14
+ });
15
+
16
+ m_constructor.started();
7
17
  this.repoRoot = repoRoot;
8
18
  this.stagedThreshold = options.stagedThreshold || 10;
9
19
  this.unstagedThreshold = options.unstagedThreshold || 15;
@@ -17,6 +27,7 @@ class GitTreeMonitor {
17
27
  this.timer = null;
18
28
  this.lastState = null;
19
29
  this.loadState();
30
+ m_constructor.success();
20
31
  }
21
32
 
22
33
  loadState() {
@@ -39,6 +50,12 @@ class GitTreeMonitor {
39
50
  }
40
51
 
41
52
  getTreeState() {
53
+ const m_get_tree_state = createMetricScope({
54
+ hook: 'git_tree_monitor',
55
+ operation: 'get_tree_state'
56
+ });
57
+
58
+ m_get_tree_state.started();
42
59
  try {
43
60
  const stagedRaw = execSync('git diff --cached --name-only', {
44
61
  cwd: this.repoRoot,
@@ -58,6 +75,8 @@ class GitTreeMonitor {
58
75
  const untracked = untrackedRaw ? untrackedRaw.split('\n').length : 0;
59
76
  const total = staged + unstaged + untracked;
60
77
 
78
+ m_get_tree_state.success();
79
+
61
80
  return {
62
81
  staged,
63
82
  unstaged,
@@ -69,6 +88,7 @@ class GitTreeMonitor {
69
88
  timestamp: Date.now()
70
89
  };
71
90
  } catch (error) {
91
+ m_get_tree_state.success();
72
92
  return {
73
93
  staged: 0,
74
94
  unstaged: 0,
@@ -79,6 +99,7 @@ class GitTreeMonitor {
79
99
  timestamp: Date.now()
80
100
  };
81
101
  }
102
+ m_get_tree_state.success();
82
103
  }
83
104
 
84
105
  startMonitoring(onStateChange) {
@@ -109,10 +130,17 @@ class GitTreeMonitor {
109
130
  }
110
131
 
111
132
  stop() {
133
+ const m_stop = createMetricScope({
134
+ hook: 'git_tree_monitor',
135
+ operation: 'stop'
136
+ });
137
+
138
+ m_stop.started();
112
139
  if (this.timer) {
113
140
  clearInterval(this.timer);
114
141
  this.timer = null;
115
142
  }
143
+ m_stop.success();
116
144
  }
117
145
 
118
146
  isActive() {
@@ -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) {