pumuki 6.3.313 → 6.3.314

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.
@@ -1,5 +1,9 @@
1
1
  import type { AiEvidenceV2_1 } from '../evidence/schema';
2
2
  import { readEvidence } from '../evidence/readEvidence';
3
+ import {
4
+ extractEvidenceBlockingCauses,
5
+ formatEvidenceBlockingCause,
6
+ } from '../evidence/blockingCauses';
3
7
  import type { AiGateCheckResult } from '../gate/evaluateAiGate';
4
8
  import { appendTrackingActionableContext } from '../git/aiGateRepoPolicyFindings';
5
9
  import {
@@ -51,6 +55,13 @@ const withTrackingContext = (params: {
51
55
  });
52
56
  };
53
57
 
58
+ const normalizeNotificationStage = (stage: string): PumukiNotificationStage => {
59
+ if (stage === 'PRE_WRITE' || stage === 'PRE_COMMIT' || stage === 'PRE_PUSH' || stage === 'CI') {
60
+ return stage;
61
+ }
62
+ return 'PRE_COMMIT';
63
+ };
64
+
54
65
  export const shouldEmitAuditSummaryNotificationForStage = (
55
66
  stage: AuditSummaryNotificationStage,
56
67
  env: NodeJS.ProcessEnv = process.env
@@ -66,6 +77,25 @@ export const toAuditSummaryEventFromEvidence = (
66
77
  ): PumukiCriticalNotificationEvent => {
67
78
  const enterpriseSeverity = evidence.severity_metrics.by_enterprise_severity;
68
79
  const severity = evidence.severity_metrics.by_severity;
80
+ const blockingCauses = extractEvidenceBlockingCauses(evidence);
81
+ if (blockingCauses.length > 0) {
82
+ const primaryCause = blockingCauses[0]!;
83
+ return {
84
+ kind: 'gate.blocked',
85
+ stage: normalizeNotificationStage(evidence.snapshot.stage),
86
+ totalViolations: evidence.severity_metrics.total_violations,
87
+ causeCode: primaryCause.code,
88
+ causeMessage: formatEvidenceBlockingCause(primaryCause),
89
+ remediation: primaryCause.remediation ?? 'Corrige la violación indicada y vuelve a intentar el commit.',
90
+ blockingCauses: blockingCauses.map((cause) => ({
91
+ code: cause.code,
92
+ ruleId: cause.ruleId,
93
+ file: cause.file,
94
+ message: formatEvidenceBlockingCause(cause),
95
+ remediation: cause.remediation,
96
+ })),
97
+ };
98
+ }
69
99
  return {
70
100
  kind: 'audit.summary',
71
101
  totalViolations: evidence.severity_metrics.total_violations,
@@ -76,6 +106,7 @@ export const toAuditSummaryEventFromEvidence = (
76
106
 
77
107
  export const toAuditSummaryEventFromAiGate = (params: {
78
108
  aiGateResult: Pick<AiGateCheckResult, 'violations'>;
109
+ stage?: PumukiNotificationStage;
79
110
  }): PumukiCriticalNotificationEvent => {
80
111
  const criticalViolations = params.aiGateResult.violations.reduce(
81
112
  (total, violation) => (violation.severity === 'ERROR' ? total + 1 : total),
@@ -85,6 +116,23 @@ export const toAuditSummaryEventFromAiGate = (params: {
85
116
  (total, violation) => (violation.severity === 'WARN' ? total + 1 : total),
86
117
  0
87
118
  );
119
+ if (params.aiGateResult.violations.length > 0) {
120
+ const primaryViolation = params.aiGateResult.violations[0]!;
121
+ return {
122
+ kind: 'gate.blocked',
123
+ stage: params.stage ?? 'PRE_WRITE',
124
+ totalViolations: params.aiGateResult.violations.length,
125
+ causeCode: primaryViolation.code,
126
+ causeMessage: primaryViolation.message,
127
+ remediation: 'Corrige la violación indicada y vuelve a intentar el commit.',
128
+ blockingCauses: params.aiGateResult.violations.map((violation) => ({
129
+ code: violation.code,
130
+ ruleId: violation.code,
131
+ message: violation.message,
132
+ remediation: 'Corrige la violación indicada y vuelve a intentar el commit.',
133
+ })),
134
+ };
135
+ }
88
136
  return {
89
137
  kind: 'audit.summary',
90
138
  totalViolations: params.aiGateResult.violations.length,
@@ -144,6 +192,7 @@ export const emitAuditSummaryNotificationFromAiGate = (
144
192
  }
145
193
  const event = toAuditSummaryEventFromAiGate({
146
194
  aiGateResult: params.aiGateResult,
195
+ stage: params.stage,
147
196
  });
148
197
  return activeDependencies.emitSystemNotification({
149
198
  event,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pumuki",
3
- "version": "6.3.313",
3
+ "version": "6.3.314",
4
4
  "description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -8,24 +8,24 @@ export const buildAuditSummaryPayload = (
8
8
  ): SystemNotificationPayload => {
9
9
  if (event.criticalViolations > 0) {
10
10
  return {
11
- title: 'AST Audit Blocked',
12
- message: `🔴 ${event.criticalViolations} CRITICAL, ${event.highViolations} HIGH violations`,
11
+ title: 'Pumuki audit: resumen',
12
+ message: `Hay ${event.criticalViolations} críticas y ${event.highViolations} high. Abre el bloqueo detallado para ver regla, fichero y solución.`,
13
13
  };
14
14
  }
15
15
  if (event.highViolations > 0) {
16
16
  return {
17
- title: 'AST Audit Blocked',
18
- message: `🟡 ${event.highViolations} HIGH violations found`,
17
+ title: 'Pumuki audit: resumen',
18
+ message: `Hay ${event.highViolations} high. Abre el bloqueo detallado para ver regla, fichero y solución.`,
19
19
  };
20
20
  }
21
21
  if (event.totalViolations > 0) {
22
22
  return {
23
- title: 'AST Audit Blocked',
24
- message: `🔴 ${event.totalViolations} violations block the gate`,
23
+ title: 'Pumuki audit: resumen',
24
+ message: `Hay ${event.totalViolations} violaciones. Abre el bloqueo detallado para ver regla, fichero y solución.`,
25
25
  };
26
26
  }
27
27
  return {
28
- title: 'AST Audit Complete',
29
- message: 'No violations found',
28
+ title: 'Pumuki audit: OK',
29
+ message: 'No se han detectado violaciones.',
30
30
  };
31
31
  };