pumuki-ast-hooks 5.3.20 → 5.3.22

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 (95) hide show
  1. package/docs/RELEASE_NOTES.md +35 -0
  2. package/docs/VIOLATIONS_RESOLUTION_PLAN.md +60 -59
  3. package/package.json +3 -3
  4. package/scripts/hooks-system/.AI_TOKEN_STATUS.txt +1 -1
  5. package/scripts/hooks-system/.audit-reports/notifications.log +935 -0
  6. package/scripts/hooks-system/.audit-reports/token-monitor.log +2809 -0
  7. package/scripts/hooks-system/application/CompositionRoot.js +38 -22
  8. package/scripts/hooks-system/application/services/AutonomousOrchestrator.js +0 -18
  9. package/scripts/hooks-system/application/services/ContextDetectionEngine.js +0 -58
  10. package/scripts/hooks-system/application/services/DynamicRulesLoader.js +2 -12
  11. package/scripts/hooks-system/application/services/GitFlowService.js +0 -80
  12. package/scripts/hooks-system/application/services/GitTreeState.js +2 -5
  13. package/scripts/hooks-system/application/services/HookSystemScheduler.js +0 -4
  14. package/scripts/hooks-system/application/services/IntelligentCommitAnalyzer.js +0 -25
  15. package/scripts/hooks-system/application/services/IntelligentGitTreeMonitor.js +0 -11
  16. package/scripts/hooks-system/application/services/PlatformAnalysisService.js +0 -19
  17. package/scripts/hooks-system/application/services/PlatformDetectionService.js +0 -19
  18. package/scripts/hooks-system/application/services/PlaybookRunner.js +1 -22
  19. package/scripts/hooks-system/application/services/PredictiveHookAdvisor.js +0 -19
  20. package/scripts/hooks-system/application/services/RealtimeGuardPlugin.js +0 -25
  21. package/scripts/hooks-system/application/services/RealtimeGuardService.js +71 -41
  22. package/scripts/hooks-system/application/services/SmartDirtyTreeAnalyzer.js +0 -11
  23. package/scripts/hooks-system/application/services/commit/CommitMessageGenerator.js +0 -11
  24. package/scripts/hooks-system/application/services/commit/FeatureDetector.js +0 -11
  25. package/scripts/hooks-system/application/services/evidence/EvidenceContextManager.js +0 -25
  26. package/scripts/hooks-system/application/services/guard/GuardAutoManagerService.js +31 -21
  27. package/scripts/hooks-system/application/services/guard/GuardConfig.js +15 -18
  28. package/scripts/hooks-system/application/services/guard/GuardEventLogger.js +0 -11
  29. package/scripts/hooks-system/application/services/guard/GuardHealthReminder.js +0 -26
  30. package/scripts/hooks-system/application/services/guard/GuardHeartbeatMonitor.js +6 -20
  31. package/scripts/hooks-system/application/services/guard/GuardLockManager.js +0 -11
  32. package/scripts/hooks-system/application/services/guard/GuardMonitorLoop.js +0 -25
  33. package/scripts/hooks-system/application/services/guard/GuardNotificationHandler.js +0 -11
  34. package/scripts/hooks-system/application/services/guard/GuardProcessManager.js +23 -11
  35. package/scripts/hooks-system/application/services/guard/GuardRecoveryService.js +0 -11
  36. package/scripts/hooks-system/application/services/installation/ConfigurationGeneratorService.js +0 -18
  37. package/scripts/hooks-system/application/services/installation/FileSystemInstallerService.js +0 -18
  38. package/scripts/hooks-system/application/services/installation/GitEnvironmentService.js +1 -19
  39. package/scripts/hooks-system/application/services/installation/HookInstaller.js +62 -24
  40. package/scripts/hooks-system/application/services/installation/IdeIntegrationService.js +0 -11
  41. package/scripts/hooks-system/application/services/installation/InstallService.js +1 -25
  42. package/scripts/hooks-system/application/services/installation/McpConfigurator.js +2 -19
  43. package/scripts/hooks-system/application/services/installation/PlatformDetectorService.js +0 -11
  44. package/scripts/hooks-system/application/services/installation/VSCodeTaskConfigurator.js +0 -11
  45. package/scripts/hooks-system/application/services/logging/AuditLogger.js +0 -8
  46. package/scripts/hooks-system/application/services/logging/UnifiedLogger.js +13 -15
  47. package/scripts/hooks-system/application/services/monitoring/ActivityMonitor.js +0 -33
  48. package/scripts/hooks-system/application/services/monitoring/AstMonitor.js +0 -27
  49. package/scripts/hooks-system/application/services/monitoring/DevDocsMonitor.js +0 -26
  50. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitor.js +0 -18
  51. package/scripts/hooks-system/application/services/monitoring/EvidenceMonitorService.js +4 -28
  52. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitor.js +0 -28
  53. package/scripts/hooks-system/application/services/monitoring/GitTreeMonitorService.js +0 -26
  54. package/scripts/hooks-system/application/services/monitoring/HealthCheckProviders.js +0 -4
  55. package/scripts/hooks-system/application/services/monitoring/HealthCheckService.js +0 -25
  56. package/scripts/hooks-system/application/services/monitoring/HeartbeatMonitorService.js +0 -26
  57. package/scripts/hooks-system/application/services/monitoring/TokenMonitor.js +0 -26
  58. package/scripts/hooks-system/application/services/notification/MacNotificationSender.js +0 -11
  59. package/scripts/hooks-system/application/services/notification/NotificationCenterService.js +0 -18
  60. package/scripts/hooks-system/application/services/notification/NotificationDispatcher.js +0 -11
  61. package/scripts/hooks-system/application/services/notification/components/NotificationCooldownManager.js +0 -18
  62. package/scripts/hooks-system/application/services/notification/components/NotificationDeduplicator.js +0 -18
  63. package/scripts/hooks-system/application/services/notification/components/NotificationQueue.js +0 -11
  64. package/scripts/hooks-system/application/services/notification/components/NotificationRetryExecutor.js +0 -20
  65. package/scripts/hooks-system/application/services/platform/PlatformHeuristics.js +0 -19
  66. package/scripts/hooks-system/application/services/recovery/AutoRecoveryManager.js +0 -19
  67. package/scripts/hooks-system/application/services/smart-commit/CommitMessageSuggester.js +0 -11
  68. package/scripts/hooks-system/application/services/smart-commit/FileContextGrouper.js +0 -19
  69. package/scripts/hooks-system/application/services/smart-commit/SmartCommitSummaryBuilder.js +0 -4
  70. package/scripts/hooks-system/application/services/token/CursorTokenService.js +0 -20
  71. package/scripts/hooks-system/application/services/token/TokenMetricsService.js +2 -12
  72. package/scripts/hooks-system/application/services/token/TokenMonitorService.js +0 -19
  73. package/scripts/hooks-system/application/services/token/TokenStatusReporter.js +0 -12
  74. package/scripts/hooks-system/bin/cli.js +15 -1
  75. package/scripts/hooks-system/bin/guard-env.sh +18 -38
  76. package/scripts/hooks-system/bin/guard-supervisor.js +5 -515
  77. package/scripts/hooks-system/bin/session-loader.sh +3 -262
  78. package/scripts/hooks-system/bin/start-guards.sh +21 -184
  79. package/scripts/hooks-system/bin/update-evidence.sh +10 -1161
  80. package/scripts/hooks-system/config/project.config.json +1 -1
  81. package/scripts/hooks-system/domain/events/index.js +31 -24
  82. package/scripts/hooks-system/infrastructure/ast/android/analyzers/AndroidAnalysisOrchestrator.js +3 -2
  83. package/scripts/hooks-system/infrastructure/ast/ast-core.js +12 -20
  84. package/scripts/hooks-system/infrastructure/ast/ast-intelligence.js +8 -18
  85. package/scripts/hooks-system/infrastructure/ast/backend/analyzers/BackendPatternDetector.js +2 -1
  86. package/scripts/hooks-system/infrastructure/ast/backend/ast-backend.js +18 -14
  87. package/scripts/hooks-system/infrastructure/ast/frontend/ast-frontend.js +196 -196
  88. package/scripts/hooks-system/infrastructure/ast/ios/analyzers/iOSASTIntelligentAnalyzer.js +3 -2
  89. package/scripts/hooks-system/infrastructure/hooks/skill-activation-prompt.js +3 -2
  90. package/scripts/hooks-system/infrastructure/logging/UnifiedLoggerFactory.js +5 -4
  91. package/scripts/hooks-system/infrastructure/mcp/ast-intelligence-automation.js +88 -0
  92. package/scripts/hooks-system/infrastructure/orchestration/intelligent-audit.js +17 -16
  93. package/scripts/hooks-system/infrastructure/shell/orchestrators/audit-orchestrator.sh +92 -54
  94. package/scripts/hooks-system/infrastructure/telemetry/metrics-server.js +3 -2
  95. package/scripts/hooks-system/infrastructure/validators/enforce-english-literals.js +6 -8
@@ -2,10 +2,6 @@ const McpConfigurator = require('./McpConfigurator');
2
2
  const HookInstaller = require('./HookInstaller');
3
3
  const VSCodeTaskConfigurator = require('./VSCodeTaskConfigurator');
4
4
 
5
- const {
6
- createMetricScope: createMetricScope
7
- } = require('../../../infrastructure/telemetry/metric-scope');
8
-
9
5
  const COLORS = {
10
6
  reset: '\x1b[0m',
11
7
  green: '\x1b[32m',
@@ -15,12 +11,6 @@ const COLORS = {
15
11
 
16
12
  class IdeIntegrationService {
17
13
  constructor(targetRoot, hookSystemRoot, logger = null) {
18
- const m_constructor = createMetricScope({
19
- hook: 'ide_integration_service',
20
- operation: 'constructor'
21
- });
22
-
23
- m_constructor.started();
24
14
  this.targetRoot = targetRoot || process.cwd();
25
15
  this.hookSystemRoot = hookSystemRoot;
26
16
  this.logger = logger;
@@ -28,7 +18,6 @@ class IdeIntegrationService {
28
18
  this.mcpConfigurator = new McpConfigurator(this.targetRoot, this.hookSystemRoot, this.logger);
29
19
  this.hookInstaller = new HookInstaller(this.targetRoot, this.hookSystemRoot, this.logger);
30
20
  this.vscodeConfigurator = new VSCodeTaskConfigurator(this.targetRoot, this.logger);
31
- m_constructor.success();
32
21
  }
33
22
 
34
23
  installCursorHooks(platforms) {
@@ -8,10 +8,6 @@ const ConfigurationGeneratorService = require('./ConfigurationGeneratorService')
8
8
  const IdeIntegrationService = require('./IdeIntegrationService');
9
9
  const UnifiedLogger = require('../logging/UnifiedLogger');
10
10
 
11
- const {
12
- createMetricScope: createMetricScope
13
- } = require('../../../infrastructure/telemetry/metric-scope');
14
-
15
11
  const COLORS = {
16
12
  reset: '\x1b[0m',
17
13
  blue: '\x1b[34m',
@@ -23,12 +19,6 @@ const COLORS = {
23
19
 
24
20
  class InstallService {
25
21
  constructor() {
26
- const m_constructor = createMetricScope({
27
- hook: 'install_service',
28
- operation: 'constructor'
29
- });
30
-
31
- m_constructor.started();
32
22
  this.targetRoot = process.cwd();
33
23
  // Assuming this script is located at scripts/hooks-system/application/services/installation/InstallService.js
34
24
  this.hookSystemRoot = path.resolve(__dirname, '../../../');
@@ -40,13 +30,7 @@ class InstallService {
40
30
  path.resolve(this.hookSystemRoot, '../package.json'),
41
31
  path.resolve(this.hookSystemRoot, '../../package.json'),
42
32
  (() => {
43
- try {
44
- m_constructor.success();
45
- return require.resolve('pumuki-ast-hooks/package.json');
46
- } catch {
47
- m_constructor.success();
48
- return null;
49
- }
33
+ try { return require.resolve('pumuki-ast-hooks/package.json'); } catch { return null; }
50
34
  })()
51
35
  ].filter(Boolean);
52
36
 
@@ -89,16 +73,9 @@ class InstallService {
89
73
  this.fsInstaller = new FileSystemInstallerService(this.targetRoot, this.hookSystemRoot, this.logger);
90
74
  this.configGenerator = new ConfigurationGeneratorService(this.targetRoot, this.hookSystemRoot);
91
75
  this.ideIntegration = new IdeIntegrationService(this.targetRoot, this.hookSystemRoot, this.logger);
92
- m_constructor.success();
93
76
  }
94
77
 
95
78
  async run() {
96
- const m_run = createMetricScope({
97
- hook: 'install_service',
98
- operation: 'run'
99
- });
100
-
101
- m_run.started();
102
79
  this.logger.info('INSTALLATION_STARTED', { targetRoot: this.targetRoot });
103
80
  this.printHeader();
104
81
 
@@ -147,7 +124,6 @@ class InstallService {
147
124
 
148
125
  this.logger.info('INSTALLATION_COMPLETED_SUCCESSFULLY');
149
126
  this.printFooter();
150
- m_run.success();
151
127
  }
152
128
 
153
129
  printHeader() {
@@ -3,10 +3,7 @@ const path = require('path');
3
3
  const { execSync } = require('child_process');
4
4
  const crypto = require('crypto');
5
5
  const os = require('os');
6
-
7
- const {
8
- createMetricScope: createMetricScope
9
- } = require('../../../infrastructure/telemetry/metric-scope');
6
+ const env = require('../../../config/env');
10
7
 
11
8
  const COLORS = {
12
9
  reset: '\x1b[0m',
@@ -35,7 +32,7 @@ function computeRepoFingerprint(repoRoot) {
35
32
 
36
33
  function computeServerIdForRepo(repoRoot) {
37
34
  const legacyServerId = 'ast-intelligence-automation';
38
- const forced = (process.env.MCP_SERVER_ID || '').trim();
35
+ const forced = (env.get('MCP_SERVER_ID', '') || '').trim();
39
36
  if (forced.length > 0) return forced;
40
37
 
41
38
  const repoName = path.basename(repoRoot || process.cwd());
@@ -46,26 +43,12 @@ function computeServerIdForRepo(repoRoot) {
46
43
 
47
44
  class McpConfigurator {
48
45
  constructor(targetRoot, hookSystemRoot, logger = null) {
49
- const m_constructor = createMetricScope({
50
- hook: 'mcp_configurator',
51
- operation: 'constructor'
52
- });
53
-
54
- m_constructor.started();
55
46
  this.targetRoot = targetRoot;
56
47
  this.hookSystemRoot = hookSystemRoot;
57
48
  this.logger = logger;
58
- m_constructor.success();
59
49
  }
60
50
 
61
51
  getGlobalWindsurfConfigPath() {
62
- const m_get_global_windsurf_config_path = createMetricScope({
63
- hook: 'mcp_configurator',
64
- operation: 'get_global_windsurf_config_path'
65
- });
66
-
67
- m_get_global_windsurf_config_path.started();
68
- m_get_global_windsurf_config_path.success();
69
52
  return path.join(os.homedir(), '.codeium', 'windsurf', 'mcp_config.json');
70
53
  }
71
54
 
@@ -1,20 +1,9 @@
1
1
  const glob = require('glob');
2
2
 
3
- const {
4
- createMetricScope: createMetricScope
5
- } = require('../../../infrastructure/telemetry/metric-scope');
6
-
7
3
  class PlatformDetectorService {
8
4
  constructor(targetRoot) {
9
- const m_constructor = createMetricScope({
10
- hook: 'platform_detector_service',
11
- operation: 'constructor'
12
- });
13
-
14
- m_constructor.started();
15
5
  this.targetRoot = targetRoot || process.cwd();
16
6
  this.platforms = [];
17
- m_constructor.success();
18
7
  }
19
8
 
20
9
  detect() {
@@ -1,18 +1,8 @@
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
-
8
4
  class VSCodeTaskConfigurator {
9
5
  constructor(targetRoot, logger = null) {
10
- const m_constructor = createMetricScope({
11
- hook: 'vscode_task_configurator',
12
- operation: 'constructor'
13
- });
14
-
15
- m_constructor.started();
16
6
  this.targetRoot = targetRoot;
17
7
  this.logger = logger;
18
8
  this.COLORS = {
@@ -21,7 +11,6 @@ class VSCodeTaskConfigurator {
21
11
  yellow: '\x1b[33m',
22
12
  cyan: '\x1b[36m'
23
13
  };
24
- m_constructor.success();
25
14
  }
26
15
 
27
16
  configure() {
@@ -3,11 +3,6 @@ const path = require('path');
3
3
 
4
4
  // Import recordMetric for prometheus metrics
5
5
  const { recordMetric } = require('../../../infrastructure/telemetry/metrics-logger');
6
-
7
- const {
8
- createMetricScope: createMetricScope
9
- } = require('../../../infrastructure/telemetry/metric-scope');
10
-
11
6
  class AuditLogger {
12
7
  /**
13
8
  * @param {Object} options
@@ -22,7 +17,6 @@ class AuditLogger {
22
17
  status: 'started',
23
18
  repoRoot: repoRoot.substring(0, 100)
24
19
  });
25
-
26
20
  this.repoRoot = repoRoot;
27
21
  this.logger = logger;
28
22
  this.logPath = filename
@@ -151,7 +145,6 @@ class AuditLogger {
151
145
  status: 'started',
152
146
  metaKeys: Object.keys(meta || {}).length
153
147
  });
154
-
155
148
  const forbidden = ['token', 'password', 'secret', 'authorization', 'auth', 'apiKey'];
156
149
  const clone = {};
157
150
  Object.entries(meta).forEach(([k, v]) => {
@@ -169,7 +162,6 @@ class AuditLogger {
169
162
  status: 'success',
170
163
  metaKeys: Object.keys(clone).length
171
164
  });
172
-
173
165
  return clone;
174
166
  }
175
167
  }
@@ -2,10 +2,6 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { ConfigurationError } = require('../../../domain/errors');
4
4
 
5
- const {
6
- createMetricScope: createMetricScope
7
- } = require('../../../infrastructure/telemetry/metric-scope');
8
-
9
5
  class UnifiedLogger {
10
6
  constructor({
11
7
  component = 'HookSystem',
@@ -13,12 +9,6 @@ class UnifiedLogger {
13
9
  file: fileConfig = { enabled: false },
14
10
  defaultData = {}
15
11
  } = {}) {
16
- const m_constructor = createMetricScope({
17
- hook: 'unified_logger',
18
- operation: 'constructor'
19
- });
20
-
21
- m_constructor.started();
22
12
  this.component = component;
23
13
  this.consoleConfig = {
24
14
  enabled: consoleConfig.enabled !== false,
@@ -51,7 +41,6 @@ class UnifiedLogger {
51
41
  // Directory creation might fail if race condition, can be ignored as next write will retry or fail
52
42
  }
53
43
  }
54
- m_constructor.success();
55
44
  }
56
45
 
57
46
  debug(event, data = {}, context = {}) {
@@ -108,10 +97,19 @@ class UnifiedLogger {
108
97
  this.rotateFileIfNeeded();
109
98
  fs.appendFileSync(this.fileConfig.path, `${JSON.stringify(entry)}\n`, 'utf8');
110
99
  } catch (error) {
111
- if (process.env.DEBUG) {
112
- console.error('[UnifiedLogger] Failed to write log file', {
113
- path: this.fileConfig.path,
114
- error: error.message
100
+ try {
101
+ const env = require('../../../config/env');
102
+ if (env.getBool('DEBUG', false)) {
103
+ console.error('[UnifiedLogger] Failed to write log file', {
104
+ path: this.fileConfig.path,
105
+ error: error.message
106
+ });
107
+ } else {
108
+ console.warn('[UnifiedLogger] File logging skipped due to error');
109
+ }
110
+ } catch (secondaryError) {
111
+ console.error('[UnifiedLogger] Secondary logging failure', {
112
+ error: secondaryError.message
115
113
  });
116
114
  }
117
115
  }
@@ -1,40 +1,22 @@
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
-
8
4
  class ActivityMonitor {
9
5
  constructor({
10
6
  repoRoot = process.cwd(),
11
7
  inactivityGraceMs = 420000, // 7 minutes
12
8
  logger = console
13
9
  } = {}) {
14
- const m_constructor = createMetricScope({
15
- hook: 'activity_monitor',
16
- operation: 'constructor'
17
- });
18
-
19
- m_constructor.started();
20
10
  this.repoRoot = repoRoot;
21
11
  this.inactivityGraceMs = inactivityGraceMs;
22
12
  this.logger = logger;
23
13
  this.lastUserActivityAt = Date.now();
24
14
  this.watcher = null;
25
15
  this.debounceTimer = null;
26
- m_constructor.success();
27
16
  }
28
17
 
29
18
  start() {
30
- const m_start = createMetricScope({
31
- hook: 'activity_monitor',
32
- operation: 'start'
33
- });
34
-
35
- m_start.started();
36
19
  if (this.watcher) {
37
- m_start.success();
38
20
  return;
39
21
  }
40
22
 
@@ -60,16 +42,9 @@ class ActivityMonitor {
60
42
  } catch (error) {
61
43
  this.logger.error('[ActivityMonitor] Failed to start watcher:', { error: error.message });
62
44
  }
63
- m_start.success();
64
45
  }
65
46
 
66
47
  stop() {
67
- const m_stop = createMetricScope({
68
- hook: 'activity_monitor',
69
- operation: 'stop'
70
- });
71
-
72
- m_stop.started();
73
48
  if (this.watcher) {
74
49
  this.watcher.close();
75
50
  this.watcher = null;
@@ -78,7 +53,6 @@ class ActivityMonitor {
78
53
  clearTimeout(this.debounceTimer);
79
54
  this.debounceTimer = null;
80
55
  }
81
- m_stop.success();
82
56
  }
83
57
 
84
58
  recordActivity(source = 'unknown') {
@@ -99,13 +73,6 @@ class ActivityMonitor {
99
73
  }
100
74
 
101
75
  getLastActivityTime() {
102
- const m_get_last_activity_time = createMetricScope({
103
- hook: 'activity_monitor',
104
- operation: 'get_last_activity_time'
105
- });
106
-
107
- m_get_last_activity_time.started();
108
- m_get_last_activity_time.success();
109
76
  return this.lastUserActivityAt;
110
77
  }
111
78
  }
@@ -2,10 +2,6 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { spawn } = require('child_process');
4
4
 
5
- const {
6
- createMetricScope: createMetricScope
7
- } = require('../../../infrastructure/telemetry/metric-scope');
8
-
9
5
  class AstMonitor {
10
6
  constructor({
11
7
  repoRoot = process.cwd(),
@@ -15,12 +11,6 @@ class AstMonitor {
15
11
  logger = console,
16
12
  notificationService = null
17
13
  } = {}) {
18
- const m_constructor = createMetricScope({
19
- hook: 'ast_monitor',
20
- operation: 'constructor'
21
- });
22
-
23
- m_constructor.started();
24
14
  this.repoRoot = repoRoot;
25
15
  this.debounceMs = debounceMs;
26
16
  this.cooldownMs = cooldownMs;
@@ -36,24 +26,15 @@ class AstMonitor {
36
26
  this.evidencePath = path.join(repoRoot, '.AI_EVIDENCE.json');
37
27
  this.tempDir = path.join(repoRoot, '.audit_tmp');
38
28
  this.astScript = path.join(repoRoot, 'infrastructure', 'ast', 'ast-intelligence.js');
39
- m_constructor.success();
40
29
  }
41
30
 
42
31
  start() {
43
- const m_start = createMetricScope({
44
- hook: 'ast_monitor',
45
- operation: 'start'
46
- });
47
-
48
- m_start.started();
49
32
  if (!this.enabled) {
50
33
  this.logger.info('[AstMonitor] AST Watch disabled');
51
- m_start.success();
52
34
  return;
53
35
  }
54
36
 
55
37
  if (this.watcher) {
56
- m_start.success();
57
38
  return;
58
39
  }
59
40
 
@@ -77,16 +58,9 @@ class AstMonitor {
77
58
  } catch (error) {
78
59
  this.logger.error('[AstMonitor] Failed to start watchers:', { error: error.message });
79
60
  }
80
- m_start.success();
81
61
  }
82
62
 
83
63
  stop() {
84
- const m_stop = createMetricScope({
85
- hook: 'ast_monitor',
86
- operation: 'stop'
87
- });
88
-
89
- m_stop.started();
90
64
  // fs.watch returns FSWatcher which has close().
91
65
  // Since we might have multiple watchers (one per dir), we should track them if we want to close properly.
92
66
  // For simplicity in this iteration, we assume the process exit handles it, or we rely on the debounce timer clear.
@@ -96,7 +70,6 @@ class AstMonitor {
96
70
  this.timer = null;
97
71
  }
98
72
  // Ideally we would close all FSWatchers here
99
- m_stop.success();
100
73
  }
101
74
 
102
75
  scheduleAnalysis() {
@@ -1,10 +1,6 @@
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
-
8
4
  class DevDocsMonitor {
9
5
  constructor({
10
6
  repoRoot = process.cwd(),
@@ -14,12 +10,6 @@ class DevDocsMonitor {
14
10
  logger = console,
15
11
  notificationService = null
16
12
  } = {}) {
17
- const m_constructor = createMetricScope({
18
- hook: 'dev_docs_monitor',
19
- operation: 'constructor'
20
- });
21
-
22
- m_constructor.started();
23
13
  this.repoRoot = repoRoot;
24
14
  this.checkIntervalMs = checkIntervalMs;
25
15
  this.staleThresholdMs = staleThresholdMs;
@@ -28,19 +18,11 @@ class DevDocsMonitor {
28
18
  this.notificationService = notificationService;
29
19
  this.timer = null;
30
20
  this.docsStatePath = path.join(repoRoot, '.audit_tmp', 'dev-docs-state.json');
31
- m_constructor.success();
32
21
  }
33
22
 
34
23
  start() {
35
- const m_start = createMetricScope({
36
- hook: 'dev_docs_monitor',
37
- operation: 'start'
38
- });
39
-
40
- m_start.started();
41
24
  if (!this.autoRefreshEnabled) {
42
25
  this.logger.info('[DevDocsMonitor] Auto-refresh disabled');
43
- m_start.success();
44
26
  return;
45
27
  }
46
28
 
@@ -50,21 +32,13 @@ class DevDocsMonitor {
50
32
  this.timer.unref();
51
33
  }
52
34
  this.logger.info('[DevDocsMonitor] Started');
53
- m_start.success();
54
35
  }
55
36
 
56
37
  stop() {
57
- const m_stop = createMetricScope({
58
- hook: 'dev_docs_monitor',
59
- operation: 'stop'
60
- });
61
-
62
- m_stop.started();
63
38
  if (this.timer) {
64
39
  clearInterval(this.timer);
65
40
  this.timer = null;
66
41
  }
67
- m_stop.success();
68
42
  }
69
43
 
70
44
  async checkDocs() {
@@ -3,18 +3,8 @@ 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
-
10
6
  class EvidenceMonitor {
11
7
  constructor(repoRoot, options = {}) {
12
- const m_constructor = createMetricScope({
13
- hook: 'evidence_monitor',
14
- operation: 'constructor'
15
- });
16
-
17
- m_constructor.started();
18
8
  this.repoRoot = repoRoot;
19
9
  this.staleThresholdMs = options.staleThresholdMs || 180000;
20
10
  this.pollIntervalMs = options.pollIntervalMs || 30000;
@@ -24,7 +14,6 @@ class EvidenceMonitor {
24
14
  this.evidencePath = path.join(repoRoot, '.AI_EVIDENCE.json');
25
15
  this.tempDir = path.join(repoRoot, '.audit_tmp');
26
16
  this.updateScript = this.resolveUpdateEvidenceScript();
27
- m_constructor.success();
28
17
  }
29
18
 
30
19
  resolveUpdateEvidenceScript() {
@@ -105,17 +94,10 @@ class EvidenceMonitor {
105
94
  }
106
95
 
107
96
  stop() {
108
- const m_stop = createMetricScope({
109
- hook: 'evidence_monitor',
110
- operation: 'stop'
111
- });
112
-
113
- m_stop.started();
114
97
  if (this.pollTimer) {
115
98
  clearInterval(this.pollTimer);
116
99
  this.pollTimer = null;
117
100
  }
118
- m_stop.success();
119
101
  }
120
102
  }
121
103
 
@@ -1,10 +1,7 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
3
  const { execSync } = require('child_process');
4
-
5
- const {
6
- createMetricScope: createMetricScope
7
- } = require('../../../infrastructure/telemetry/metric-scope');
4
+ const env = require('../../../config/env');
8
5
 
9
6
  function resolveUpdateEvidenceScript(repoRoot) {
10
7
  const candidates = [
@@ -29,18 +26,12 @@ class EvidenceMonitorService {
29
26
  updateScriptPath = resolveUpdateEvidenceScript(repoRoot) || path.join(process.cwd(), 'scripts', 'hooks-system', 'bin', 'update-evidence.sh'),
30
27
  notifier = () => { },
31
28
  logger = console,
32
- autoRefreshEnabled = process.env.HOOK_GUARD_AUTO_REFRESH !== 'false',
33
- autoRefreshCooldownMs = Number(process.env.HOOK_GUARD_AUTO_REFRESH_COOLDOWN || 180000),
34
- staleThresholdMs = Number(process.env.HOOK_GUARD_EVIDENCE_STALE_THRESHOLD || 10 * 60 * 1000),
29
+ autoRefreshEnabled = env.getBool('HOOK_GUARD_AUTO_REFRESH', true),
30
+ autoRefreshCooldownMs = env.getNumber('HOOK_GUARD_AUTO_REFRESH_COOLDOWN', 180000),
31
+ staleThresholdMs = env.getNumber('HOOK_GUARD_EVIDENCE_STALE_THRESHOLD', 10 * 60 * 1000),
35
32
  fsModule = fs,
36
33
  execFn = execSync
37
34
  } = {}) {
38
- const m_constructor = createMetricScope({
39
- hook: 'evidence_monitor_service',
40
- operation: 'constructor'
41
- });
42
-
43
- m_constructor.started();
44
35
  this.repoRoot = repoRoot;
45
36
  this.evidencePath = evidencePath;
46
37
  this.updateScriptPath = updateScriptPath;
@@ -53,28 +44,14 @@ class EvidenceMonitorService {
53
44
  this.exec = execFn;
54
45
  this.watchers = [];
55
46
  this.lastAutoRefresh = 0;
56
- m_constructor.success();
57
47
  }
58
48
 
59
49
  start() {
60
- const m_start = createMetricScope({
61
- hook: 'evidence_monitor_service',
62
- operation: 'start'
63
- });
64
-
65
- m_start.started();
66
50
  this.performInitialChecks();
67
51
  this.watchEvidenceFreshness();
68
- m_start.success();
69
52
  }
70
53
 
71
54
  stop() {
72
- const m_stop = createMetricScope({
73
- hook: 'evidence_monitor_service',
74
- operation: 'stop'
75
- });
76
-
77
- m_stop.started();
78
55
  this.watchers.forEach(watcher => {
79
56
  try {
80
57
  watcher.close();
@@ -83,7 +60,6 @@ class EvidenceMonitorService {
83
60
  }
84
61
  });
85
62
  this.watchers = [];
86
- m_stop.success();
87
63
  }
88
64
 
89
65
  performInitialChecks() {