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