@junando/core 0.12.2 → 0.13.0

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/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import pino from "pino";
4
4
  import { Writable } from "node:stream";
5
5
  import { Redis } from "ioredis";
6
6
  //#region src/shared/constants.d.ts
7
- declare enum AlertType {
7
+ export declare enum AlertType {
8
8
  Error = "http_500",
9
9
  Warning = "latency_spike",
10
10
  Success = "recovery"
@@ -15,60 +15,63 @@ interface AlertTypeConfig {
15
15
  readonly summary: (service: string, i: number, count: number) => string;
16
16
  }
17
17
  declare const _alertTypeConfigs: Record<AlertType, AlertTypeConfig>;
18
- declare const ALERT_TYPE_LABELS: Readonly<typeof _alertTypeConfigs>;
19
- declare enum LLMProviderType {
18
+ export declare const ALERT_TYPE_LABELS: Readonly<typeof _alertTypeConfigs>;
19
+ export declare enum LLMProviderType {
20
20
  Gemini = "gemini",
21
21
  Claude = "claude",
22
22
  OpenRouter = "openrouter",
23
23
  Qwen = "qwen"
24
24
  }
25
- declare const HTTP_TIMEOUT_MS: Readonly<{
25
+ export declare const HTTP_TIMEOUT_MS: Readonly<{
26
26
  Default: 5000;
27
27
  LLM: 30000;
28
+ SlackResponseUrl: 500;
29
+ RollbackHandler: 2000;
28
30
  }>;
29
- declare const CIRCUIT_BREAKER: Readonly<{
31
+ export declare const CIRCUIT_BREAKER: Readonly<{
30
32
  Timeout: 10000;
31
33
  ErrorThresholdPercentage: 70;
32
34
  ResetTimeoutMs: 30000;
33
35
  }>;
34
- declare const LLM_MAX_TOKENS = 1024;
35
- declare const RATE_LIMITER: Readonly<{
36
+ export declare const LLM_MAX_TOKENS = 1024;
37
+ export declare const RATE_LIMITER: Readonly<{
36
38
  MinTimeMs: 100;
37
39
  MaxConcurrent: 5;
38
40
  }>;
39
- declare const DEV_SERVER_PORT = 4000;
40
- declare const DEDUP_TTL_MS_MULTIPLIER = 1000;
41
- declare const HOUR_MS = 3600000;
42
- declare const LLM_FALLBACK_DEFAULTS: Readonly<{
41
+ export declare const DEV_SERVER_PORT = 4000;
42
+ export declare const DEDUP_TTL_MS_MULTIPLIER = 1000;
43
+ export declare const HOUR_MS = 3600000;
44
+ export declare const LLM_FALLBACK_DEFAULTS: Readonly<{
43
45
  TimeoutMs: 60000;
44
46
  Models: string[];
45
47
  }>;
46
- declare const LLM_MODELS: Readonly<{
48
+ export declare const LLM_MODELS: Readonly<{
47
49
  Gemini: "gemini-2.0-flash";
48
50
  Claude: "claude-haiku-4-5";
49
51
  OpenRouter: "qwen/qwen-2.5-72b-instruct";
50
52
  }>;
51
- declare const SLACK_API_URL = "https://slack.com/api/chat.postMessage";
52
- declare const TEAMS_WEBHOOK_TIMEOUT_MS = 10000;
53
+ export declare const SLACK_API_URL = "https://slack.com/api/chat.postMessage";
54
+ export declare const ROLLBACK_ACTION_ID = "trigger_rollback";
55
+ export declare const TEAMS_WEBHOOK_TIMEOUT_MS = 10000;
53
56
  declare const _urgencyEmoji: Record<string, string>;
54
- declare const URGENCY_EMOJI: Readonly<typeof _urgencyEmoji>;
55
- declare const REDIS_KEY_PREFIX = "junando:dedup:";
56
- declare const WEBHOOK_DEFAULTS: Readonly<{
57
+ export declare const URGENCY_EMOJI: Readonly<typeof _urgencyEmoji>;
58
+ export declare const REDIS_KEY_PREFIX = "junando:dedup:";
59
+ export declare const WEBHOOK_DEFAULTS: Readonly<{
57
60
  AlertmanagerUrl: "http://localhost:9093";
58
61
  WebhookUrl: "http://localhost:4000/webhook/alert";
59
62
  }>;
60
- declare const PAYLOAD_DEFAULTS: Readonly<{
63
+ export declare const PAYLOAD_DEFAULTS: Readonly<{
61
64
  Version: "4";
62
65
  TruncatedAlerts: 0;
63
66
  Receiver: "junando";
64
67
  }>;
65
68
  //#endregion
66
69
  //#region src/domain/entities/alert.d.ts
67
- declare const AlertStatusSchema: z.ZodEnum<{
70
+ export declare const AlertStatusSchema: z.ZodEnum<{
68
71
  firing: "firing";
69
72
  resolved: "resolved";
70
73
  }>;
71
- declare const NormalizedAlertSchema: z.ZodObject<{
74
+ export declare const NormalizedAlertSchema: z.ZodObject<{
72
75
  fingerprint: z.ZodString;
73
76
  alertName: z.ZodString;
74
77
  status: z.ZodEnum<{
@@ -84,7 +87,7 @@ declare const NormalizedAlertSchema: z.ZodObject<{
84
87
  labels: z.ZodRecord<z.ZodString, z.ZodString>;
85
88
  annotations: z.ZodRecord<z.ZodString, z.ZodString>;
86
89
  }, z.core.$strip>;
87
- declare const AlertmanagerPayloadSchema: z.ZodObject<{
90
+ export declare const AlertmanagerPayloadSchema: z.ZodObject<{
88
91
  version: z.ZodDefault<z.ZodString>;
89
92
  groupKey: z.ZodString;
90
93
  truncatedAlerts: z.ZodDefault<z.ZodNumber>;
@@ -109,13 +112,13 @@ declare const AlertmanagerPayloadSchema: z.ZodObject<{
109
112
  fingerprint: z.ZodOptional<z.ZodString>;
110
113
  }, z.core.$strip>>;
111
114
  }, z.core.$strip>;
112
- type AlertStatus = z.infer<typeof AlertStatusSchema>;
113
- type NormalizedAlert = z.infer<typeof NormalizedAlertSchema>;
114
- type AlertmanagerPayload = z.infer<typeof AlertmanagerPayloadSchema>;
115
- type AlertErrorType = NormalizedAlert['alertType'];
115
+ export type AlertStatus = z.infer<typeof AlertStatusSchema>;
116
+ export type NormalizedAlert = z.infer<typeof NormalizedAlertSchema>;
117
+ export type AlertmanagerPayload = z.infer<typeof AlertmanagerPayloadSchema>;
118
+ export type AlertErrorType = NormalizedAlert['alertType'];
116
119
  //#endregion
117
120
  //#region src/domain/entities/cluster.d.ts
118
- declare const AlertClusterSchema: z.ZodObject<{
121
+ export declare const AlertClusterSchema: z.ZodObject<{
119
122
  fingerprint: z.ZodString;
120
123
  serviceName: z.ZodString;
121
124
  alertType: z.ZodEnum<typeof AlertType>;
@@ -132,16 +135,16 @@ declare const AlertClusterSchema: z.ZodObject<{
132
135
  }>>;
133
136
  labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
134
137
  }, z.core.$strip>;
135
- type AlertCluster = z.infer<typeof AlertClusterSchema>;
138
+ export type AlertCluster = z.infer<typeof AlertClusterSchema>;
136
139
  //#endregion
137
140
  //#region src/domain/entities/incident.d.ts
138
- declare const UrgencyLevelSchema: z.ZodEnum<{
141
+ export declare const UrgencyLevelSchema: z.ZodEnum<{
139
142
  critical: "critical";
140
143
  high: "high";
141
144
  low: "low";
142
145
  medium: "medium";
143
146
  }>;
144
- declare const LLMAnalysisSchema: z.ZodObject<{
147
+ export declare const LLMAnalysisSchema: z.ZodObject<{
145
148
  probable_cause: z.ZodString;
146
149
  impacted_services: z.ZodArray<z.ZodString>;
147
150
  recommended_steps: z.ZodArray<z.ZodString>;
@@ -153,7 +156,7 @@ declare const LLMAnalysisSchema: z.ZodObject<{
153
156
  }>;
154
157
  requires_rollback: z.ZodBoolean;
155
158
  }, z.core.$strip>;
156
- declare const IncidentSchema: z.ZodObject<{
159
+ export declare const IncidentSchema: z.ZodObject<{
157
160
  cluster: z.ZodObject<{
158
161
  fingerprint: z.ZodString;
159
162
  serviceName: z.ZodString;
@@ -186,29 +189,29 @@ declare const IncidentSchema: z.ZodObject<{
186
189
  }, z.core.$strip>>;
187
190
  processedAt: z.ZodString;
188
191
  }, z.core.$strip>;
189
- type UrgencyLevel = z.infer<typeof UrgencyLevelSchema>;
190
- type LLMAnalysis = z.infer<typeof LLMAnalysisSchema>;
191
- type Incident = z.infer<typeof IncidentSchema>;
192
+ export type UrgencyLevel = z.infer<typeof UrgencyLevelSchema>;
193
+ export type LLMAnalysis = z.infer<typeof LLMAnalysisSchema>;
194
+ export type Incident = z.infer<typeof IncidentSchema>;
192
195
  //#endregion
193
196
  //#region src/domain/entities/rule.d.ts
194
- declare enum RuleActionType {
197
+ export declare enum RuleActionType {
195
198
  Suppress = "suppress",
196
199
  Route = "route",
197
200
  Escalate = "escalate",
198
201
  Tag = "tag"
199
202
  }
200
- declare enum SeverityLevel {
203
+ export declare enum SeverityLevel {
201
204
  Critical = "critical",
202
205
  High = "high",
203
206
  Medium = "medium",
204
207
  Low = "low"
205
208
  }
206
209
  /** Rule evaluation points in the pipeline */
207
- declare enum RuleEvaluationPhase {
210
+ export declare enum RuleEvaluationPhase {
208
211
  PreLlm = "pre-llm",
209
212
  PostLlm = "post-llm"
210
213
  }
211
- interface RuleCondition {
214
+ export interface RuleCondition {
212
215
  serviceName?: string;
213
216
  alertType?: AlertType;
214
217
  severity?: SeverityLevel;
@@ -227,7 +230,7 @@ interface RuleCondition {
227
230
  requiresRollback?: boolean;
228
231
  impactedServices?: string[];
229
232
  }
230
- declare const RuleConditionSchema: z.ZodObject<{
233
+ export declare const RuleConditionSchema: z.ZodObject<{
231
234
  serviceName: z.ZodOptional<z.ZodString>;
232
235
  alertType: z.ZodOptional<z.ZodEnum<typeof AlertType>>;
233
236
  severity: z.ZodOptional<z.ZodEnum<typeof SeverityLevel>>;
@@ -250,7 +253,7 @@ declare const RuleConditionSchema: z.ZodObject<{
250
253
  requiresRollback: z.ZodOptional<z.ZodBoolean>;
251
254
  impactedServices: z.ZodOptional<z.ZodArray<z.ZodString>>;
252
255
  }, z.core.$strip>;
253
- type RuleAction = {
256
+ export type RuleAction = {
254
257
  type: RuleActionType.Suppress;
255
258
  } | {
256
259
  type: RuleActionType.Route;
@@ -263,7 +266,7 @@ type RuleAction = {
263
266
  key: string;
264
267
  value: string;
265
268
  };
266
- declare const RuleActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
269
+ export declare const RuleActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
267
270
  type: z.ZodLiteral<RuleActionType.Suppress>;
268
271
  }, z.core.$strip>, z.ZodObject<{
269
272
  type: z.ZodLiteral<RuleActionType.Route>;
@@ -276,7 +279,7 @@ declare const RuleActionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
276
279
  key: z.ZodString;
277
280
  value: z.ZodString;
278
281
  }, z.core.$strip>], "type">;
279
- interface Rule {
282
+ export interface Rule {
280
283
  id: string;
281
284
  name?: string;
282
285
  condition: RuleCondition;
@@ -285,7 +288,7 @@ interface Rule {
285
288
  urgencyLevel?: z.infer<typeof UrgencyLevelSchema>;
286
289
  requiresRollback?: boolean;
287
290
  }
288
- declare const RuleSchema: z.ZodObject<{
291
+ export declare const RuleSchema: z.ZodObject<{
289
292
  id: z.ZodString;
290
293
  name: z.ZodOptional<z.ZodString>;
291
294
  condition: z.ZodObject<{
@@ -332,10 +335,10 @@ declare const RuleSchema: z.ZodObject<{
332
335
  }>>;
333
336
  requiresRollback: z.ZodOptional<z.ZodBoolean>;
334
337
  }, z.core.$strip>;
335
- interface RuleSection {
338
+ export interface RuleSection {
336
339
  rules: Rule[];
337
340
  }
338
- declare const RuleSectionSchema: z.ZodObject<{
341
+ export declare const RuleSectionSchema: z.ZodObject<{
339
342
  rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
340
343
  id: z.ZodString;
341
344
  name: z.ZodOptional<z.ZodString>;
@@ -384,11 +387,11 @@ declare const RuleSectionSchema: z.ZodObject<{
384
387
  requiresRollback: z.ZodOptional<z.ZodBoolean>;
385
388
  }, z.core.$strip>>>;
386
389
  }, z.core.$strip>;
387
- interface RuleConfiguration {
390
+ export interface RuleConfiguration {
388
391
  [RuleEvaluationPhase.PreLlm]: RuleSection;
389
392
  [RuleEvaluationPhase.PostLlm]: RuleSection;
390
393
  }
391
- declare const RuleConfigurationSchema: z.ZodObject<{
394
+ export declare const RuleConfigurationSchema: z.ZodObject<{
392
395
  "pre-llm": z.ZodObject<{
393
396
  rules: z.ZodDefault<z.ZodArray<z.ZodObject<{
394
397
  id: z.ZodString;
@@ -488,11 +491,11 @@ declare const RuleConfigurationSchema: z.ZodObject<{
488
491
  }, z.core.$strip>>>;
489
492
  }, z.core.$strip>;
490
493
  }, z.core.$strip>;
491
- type ValidatedRuleCondition = z.infer<typeof RuleConditionSchema>;
492
- type ValidatedRuleAction = z.infer<typeof RuleActionSchema>;
493
- type ValidatedRule = z.infer<typeof RuleSchema>;
494
- type ValidatedRuleSection = z.infer<typeof RuleSectionSchema>;
495
- type ValidatedRuleConfiguration = z.infer<typeof RuleConfigurationSchema>;
494
+ export type ValidatedRuleCondition = z.infer<typeof RuleConditionSchema>;
495
+ export type ValidatedRuleAction = z.infer<typeof RuleActionSchema>;
496
+ export type ValidatedRule = z.infer<typeof RuleSchema>;
497
+ export type ValidatedRuleSection = z.infer<typeof RuleSectionSchema>;
498
+ export type ValidatedRuleConfiguration = z.infer<typeof RuleConfigurationSchema>;
496
499
  //#endregion
497
500
  //#region src/domain/entities/traceability.d.ts
498
501
  interface TraceabilityDocument {
@@ -509,7 +512,7 @@ interface TraceabilityDocument {
509
512
  }
510
513
  //#endregion
511
514
  //#region src/domain/value-objects/fingerprint.d.ts
512
- declare class Fingerprint {
515
+ export declare class Fingerprint {
513
516
  readonly value: string;
514
517
  private constructor();
515
518
  static fromAlert(alert: NormalizedAlert): Fingerprint;
@@ -553,6 +556,13 @@ interface IAlertQueue {
553
556
  interface ITraceRepository {
554
557
  findByTraceId(traceId: string): Promise<Record<string, unknown>[]>;
555
558
  }
559
+ /**
560
+ * Reason a parse attempt could not produce a diagnosis.
561
+ * `unparseable_response` — non-empty raw text that neither JSON nor regex
562
+ * stage could extract a usable analysis from.
563
+ * `empty_response` — the provider returned an empty (or whitespace-only) string.
564
+ */
565
+ type LlmDegradedReason = 'unparseable_response' | 'empty_response';
556
566
  /**
557
567
  * Structured result of an LLM analysis call.
558
568
  * Carries the diagnosis plus the observability metadata that feeds the
@@ -560,7 +570,8 @@ interface ITraceRepository {
560
570
  * total tokens = promptTokens + completionTokens).
561
571
  */
562
572
  interface LLMResult {
563
- analysis: LLMAnalysis;
573
+ analysis: LLMAnalysis | null;
574
+ degradedReason?: LlmDegradedReason;
564
575
  provider: string;
565
576
  model: string;
566
577
  latencyMs: number;
@@ -579,11 +590,11 @@ interface ILLMProvider {
579
590
  * Terminal outcome of a single notification send.
580
591
  * Feeds the `notify` section of the wide event.
581
592
  */
582
- declare const NotifyOutcome: {
593
+ export declare const NotifyOutcome: {
583
594
  readonly Success: 'success';
584
595
  readonly Failure: 'failure';
585
596
  };
586
- type NotifyOutcome = (typeof NotifyOutcome)[keyof typeof NotifyOutcome];
597
+ export type NotifyOutcome = (typeof NotifyOutcome)[keyof typeof NotifyOutcome];
587
598
  /**
588
599
  * Structured result of a notification send.
589
600
  * Adapters throw on failure (the caller records NotifyOutcome.Failure and
@@ -643,9 +654,43 @@ interface IRuleEngine {
643
654
  */
644
655
  evaluatePostLlm(cluster: AlertCluster, analysis: LLMAnalysis): RuleActionResult;
645
656
  }
657
+ /**
658
+ * Request dispatched to a rollback action handler.
659
+ * Minimal incident metadata encoded in the Slack button value plus the user
660
+ * who triggered the action.
661
+ */
662
+ interface RollbackActionRequest {
663
+ fingerprint: string;
664
+ serviceName: string;
665
+ endpointPath: string;
666
+ alertType: AlertType;
667
+ urgencyLevel?: 'low' | 'medium' | 'high' | 'critical';
668
+ triggeredBy: {
669
+ id?: string;
670
+ username?: string;
671
+ channel: 'slack' | 'teams';
672
+ };
673
+ correlationId?: string;
674
+ messageTs?: string;
675
+ }
676
+ /**
677
+ * Result of a rollback action handler invocation.
678
+ */
679
+ interface RollbackActionResult {
680
+ ok: boolean;
681
+ message: string;
682
+ }
683
+ /**
684
+ * Configurable rollback action handler.
685
+ * Implementations wire Junando to a team's deployment pipeline.
686
+ * The default no-op adapter logs and returns success so nothing breaks.
687
+ */
688
+ interface IRollbackActionHandler {
689
+ handle(request: RollbackActionRequest): Promise<RollbackActionResult>;
690
+ }
646
691
  //#endregion
647
692
  //#region src/domain/services/clustering.service.d.ts
648
- declare class ClusteringService {
693
+ export declare class ClusteringService {
649
694
  /**
650
695
  * Groups alerts by fingerprint and builds AlertCluster objects.
651
696
  * 300 alerts with the same root cause → 1 cluster with 2 representative traces.
@@ -656,7 +701,143 @@ declare class ClusteringService {
656
701
  }
657
702
  //#endregion
658
703
  //#region src/application/dtos/normalize-payload.d.ts
659
- declare function normalizePayload(payload: AlertmanagerPayload): NormalizedAlert[];
704
+ export declare function normalizePayload(payload: AlertmanagerPayload): NormalizedAlert[];
705
+ //#endregion
706
+ //#region src/shared/logger/enums.d.ts
707
+ /**
708
+ * Pipeline component taxonomy.
709
+ *
710
+ * `component` (not `service`) distinguishes pipeline stages in wide events.
711
+ * `service` stays constant ("junando"); `component` tells you WHERE the event
712
+ * was emitted from.
713
+ */
714
+ export declare const Component: {
715
+ readonly Webhook: 'webhook';
716
+ readonly Worker: 'worker';
717
+ readonly UseCase: 'useCase';
718
+ readonly Llm: 'llm';
719
+ readonly Notifier: 'notifier';
720
+ readonly Dedup: 'dedup';
721
+ readonly Traces: 'traces';
722
+ readonly Ingest: 'ingest';
723
+ readonly Rollback: 'rollback';
724
+ };
725
+ export type Component = (typeof Component)[keyof typeof Component];
726
+ /**
727
+ * Pipeline stages that write their results into the WideEventBuilder.
728
+ */
729
+ export declare const Stage: {
730
+ readonly Dedup: 'dedup';
731
+ readonly RulesPre: 'rulesPre';
732
+ readonly Traces: 'traces';
733
+ readonly Llm: 'llm';
734
+ readonly RulesPost: 'rulesPost';
735
+ readonly Notify: 'notify';
736
+ };
737
+ export type Stage = (typeof Stage)[keyof typeof Stage];
738
+ /**
739
+ * Terminal outcomes for a wide event across all entry points.
740
+ */
741
+ export declare const Outcome: {
742
+ readonly Success: 'success';
743
+ readonly Suppressed: 'suppressed';
744
+ readonly Degraded: 'degraded';
745
+ readonly Error: 'error';
746
+ readonly Accepted: 'accepted';
747
+ readonly Empty: 'empty';
748
+ readonly ParseError: 'parse_error';
749
+ };
750
+ export type Outcome = (typeof Outcome)[keyof typeof Outcome];
751
+ /**
752
+ * Reason recorded for a tail-sampling decision.
753
+ */
754
+ export declare const SamplingDecision: {
755
+ readonly Error: 'error';
756
+ readonly Slow: 'slow';
757
+ readonly Random: 'random';
758
+ readonly Skipped: 'skipped';
759
+ };
760
+ export type SamplingDecision = (typeof SamplingDecision)[keyof typeof SamplingDecision];
761
+ //#endregion
762
+ //#region src/shared/logger/wide-event-builder.d.ts
763
+ interface ClusterSection {
764
+ fingerprint: string;
765
+ serviceName: string;
766
+ alertCount: number;
767
+ spanCount: number;
768
+ /** Number of representative traces that failed to fetch (fail-open). */
769
+ traceErrors?: number;
770
+ }
771
+ interface DedupSection {
772
+ isNew: boolean;
773
+ ttlSeconds: number;
774
+ /** Fail-open error message when the store was unreachable (e.g. Redis down). */
775
+ error?: string;
776
+ }
777
+ interface RuleSection$1 {
778
+ matched: boolean;
779
+ suppressed: boolean;
780
+ /** ID of the rule that matched, when the engine reports one. */
781
+ matchedRuleId?: string;
782
+ }
783
+ interface LlmSection {
784
+ provider: string;
785
+ model: string;
786
+ latencyMs: number;
787
+ /** Present only when parseAnalysis produced a diagnosis. */
788
+ urgency?: string;
789
+ /** Present only when analysis is null — why no diagnosis was produced. */
790
+ degradedReason?: string;
791
+ tokens: number;
792
+ }
793
+ interface NotifySection {
794
+ channels: string[];
795
+ outcome: string;
796
+ latencyMs: number;
797
+ }
798
+ interface RollbackSection {
799
+ actionId: string;
800
+ channel: string;
801
+ outcome: 'ok' | 'error';
802
+ handlerMessage: string;
803
+ }
804
+ interface ErrorSection {
805
+ message: string;
806
+ name?: string;
807
+ stack?: string;
808
+ }
809
+ interface WideEvent {
810
+ requestId: string;
811
+ correlationId?: string;
812
+ timestamp: string;
813
+ component: Component;
814
+ version?: string;
815
+ outcome?: Outcome;
816
+ cluster?: ClusterSection;
817
+ dedup?: DedupSection;
818
+ rule?: RuleSection$1;
819
+ llm?: LlmSection;
820
+ notify?: NotifySection;
821
+ rollback?: RollbackSection;
822
+ durationMs?: number;
823
+ error?: ErrorSection;
824
+ /** Present only when the 256 KB guard truncated the event. */
825
+ _truncated?: boolean;
826
+ }
827
+ /** Fields the builder owns — callers cannot set or merge them. */
828
+ type BuilderOwnedKey = 'requestId' | 'component' | 'timestamp' | '_truncated';
829
+ /** Keys callers may write via set()/merge(). */
830
+ type SettableKey = Exclude<keyof WideEvent, BuilderOwnedKey>;
831
+ export declare class WideEventBuilder {
832
+ private readonly requestId;
833
+ private readonly component;
834
+ private fields;
835
+ constructor(requestId: string, component: Component);
836
+ set<K extends SettableKey>(key: K, value: WideEvent[K]): this;
837
+ merge(obj: Partial<WideEvent>): this;
838
+ flush(): WideEvent;
839
+ private enforceSizeLimit;
840
+ }
660
841
  //#endregion
661
842
  //#region src/shared/logger/index.d.ts
662
843
  type Logger = pino.Logger;
@@ -669,7 +850,7 @@ interface LoggerOptions {
669
850
  * Module-level callers get a proxy that automatically starts writing to Loki
670
851
  * once reinitLogger() is called inside the handler after loadConfig().
671
852
  */
672
- declare function createLogger(levelOrOptions?: string | LoggerOptions): Logger;
853
+ export declare function createLogger(levelOrOptions?: string | LoggerOptions): Logger;
673
854
  /**
674
855
  * Re-creates the root logger with current env vars (including LOKI_URL).
675
856
  * Call this inside your Lambda handler immediately after loadConfig():
@@ -678,7 +859,7 @@ declare function createLogger(levelOrOptions?: string | LoggerOptions): Logger;
678
859
  * const config = await loadConfig();
679
860
  * reinitLogger(); // all module-level proxy loggers now write to Loki
680
861
  */
681
- declare function reinitLogger(opts?: LoggerOptions): void;
862
+ export declare function reinitLogger(opts?: LoggerOptions): void;
682
863
  //#endregion
683
864
  //#region src/application/use-cases/process-incident.use-case.d.ts
684
865
  interface Dependencies {
@@ -692,7 +873,7 @@ interface Dependencies {
692
873
  onClustersBuilt?: (count: number) => void;
693
874
  ruleEngine?: IRuleEngine;
694
875
  }
695
- declare class ProcessIncidentUseCase {
876
+ export declare class ProcessIncidentUseCase {
696
877
  private readonly deps;
697
878
  private readonly clustering;
698
879
  private readonly wideEventsEnabled;
@@ -706,14 +887,14 @@ declare class ProcessIncidentUseCase {
706
887
  }
707
888
  //#endregion
708
889
  //#region src/infrastructure/dedup/redis-dedup.adapter.d.ts
709
- declare class RedisDeduplicationStore implements IDeduplicationStore {
890
+ export declare class RedisDeduplicationStore implements IDeduplicationStore {
710
891
  private readonly redis;
711
892
  private readonly keyPrefix;
712
893
  constructor(redis: Redis);
713
894
  isNew(fingerprint: string, ttlSeconds: number): Promise<DedupResult>;
714
895
  reset(fingerprint: string): Promise<void>;
715
896
  }
716
- declare class InMemoryDeduplicationStore implements IDeduplicationStore {
897
+ export declare class InMemoryDeduplicationStore implements IDeduplicationStore {
717
898
  private readonly store;
718
899
  isNew(fingerprint: string, ttlSeconds: number): Promise<DedupResult>;
719
900
  reset(fingerprint: string): Promise<void>;
@@ -738,7 +919,7 @@ interface OpenSearchIndexerDeps {
738
919
  region: string;
739
920
  fetcher: OpenSearchHttpFetcher;
740
921
  }
741
- declare class OpenSearchIndexer implements IIndexer<TraceabilityDocument> {
922
+ export declare class OpenSearchIndexer implements IIndexer<TraceabilityDocument> {
742
923
  private readonly endpoint;
743
924
  private readonly indexName;
744
925
  private readonly region;
@@ -746,7 +927,7 @@ declare class OpenSearchIndexer implements IIndexer<TraceabilityDocument> {
746
927
  constructor(deps: OpenSearchIndexerDeps);
747
928
  index(doc: TraceabilityDocument): Promise<void>;
748
929
  }
749
- declare class InMemoryIndexer implements IIndexer<TraceabilityDocument> {
930
+ export declare class InMemoryIndexer implements IIndexer<TraceabilityDocument> {
750
931
  readonly indexed: TraceabilityDocument[];
751
932
  index(doc: TraceabilityDocument): Promise<void>;
752
933
  }
@@ -756,7 +937,7 @@ declare class InMemoryIndexer implements IIndexer<TraceabilityDocument> {
756
937
  * Gemini LLM provider using Google Generative AI SDK.
757
938
  * Wrapped with circuit breaker for resilience.
758
939
  */
759
- declare class GeminiProvider implements ILLMProvider {
940
+ export declare class GeminiProvider implements ILLMProvider {
760
941
  private readonly apiKey;
761
942
  private readonly model;
762
943
  private readonly breaker;
@@ -769,7 +950,7 @@ declare class GeminiProvider implements ILLMProvider {
769
950
  * Claude LLM provider using Anthropic SDK.
770
951
  * Supports Claude Haiku and other models.
771
952
  */
772
- declare class ClaudeProvider implements ILLMProvider {
953
+ export declare class ClaudeProvider implements ILLMProvider {
773
954
  private readonly apiKey;
774
955
  private readonly model;
775
956
  constructor(apiKey: string, model?: string);
@@ -779,7 +960,7 @@ declare class ClaudeProvider implements ILLMProvider {
779
960
  * Mock LLM provider for testing and local development.
780
961
  * Returns deterministic responses without external API calls.
781
962
  */
782
- declare class MockLLMProvider implements ILLMProvider {
963
+ export declare class MockLLMProvider implements ILLMProvider {
783
964
  readonly callLog: Array<{
784
965
  cluster: AlertCluster;
785
966
  }>;
@@ -793,7 +974,7 @@ interface FallbackOptions {
793
974
  fallbackModels?: string[];
794
975
  fallbackTimeoutMs?: number;
795
976
  }
796
- declare function createLLMProvider(provider: string, apiKey: string, model?: string, options?: FallbackOptions): ILLMProvider;
977
+ export declare function createLLMProvider(provider: string, apiKey: string, model?: string, options?: FallbackOptions): ILLMProvider;
797
978
  //#endregion
798
979
  //#region src/shared/config/index.d.ts
799
980
  declare enum NodeEnvironment {
@@ -818,6 +999,8 @@ declare const ConfigSchema: z.ZodObject<{
818
999
  slackBotToken: z.ZodOptional<z.ZodString>;
819
1000
  slackSigningSecret: z.ZodOptional<z.ZodString>;
820
1001
  slackChannel: z.ZodOptional<z.ZodString>;
1002
+ rollbackActionEnabled: z.ZodDefault<z.ZodBoolean>;
1003
+ rollbackActionAllowedSlackUserIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
821
1004
  teamsWebhookUrl: z.ZodOptional<z.ZodString>;
822
1005
  lokiUrl: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
823
1006
  redisUrl: z.ZodString;
@@ -837,7 +1020,33 @@ declare const ConfigSchema: z.ZodObject<{
837
1020
  rulesConfigPath: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
838
1021
  }, z.core.$strip>;
839
1022
  type Config = z.infer<typeof ConfigSchema>;
840
- declare function loadConfig(): Promise<Config>;
1023
+ export declare function loadConfig(): Promise<Config>;
1024
+ //#endregion
1025
+ //#region src/infrastructure/rules/channel-registry.d.ts
1026
+ export declare class ChannelRegistry {
1027
+ private readonly _channels;
1028
+ private _default;
1029
+ /**
1030
+ * Register a notifier for a given channel name.
1031
+ * Overwrites any existing registration for that name.
1032
+ */
1033
+ register(channel: string, notifier: INotifier): void;
1034
+ /**
1035
+ * Set the default notifier to use when a channel is not found.
1036
+ */
1037
+ setDefault(notifier: INotifier): void;
1038
+ /**
1039
+ * Resolve a channel name to its notifier instance.
1040
+ * Falls back to the default notifier if the channel is unknown.
1041
+ *
1042
+ * @throws {Error} if the channel is unknown and no default is set
1043
+ */
1044
+ resolve(channel: string): INotifier;
1045
+ /**
1046
+ * Check if a channel is registered.
1047
+ */
1048
+ has(channel: string): boolean;
1049
+ }
841
1050
  //#endregion
842
1051
  //#region src/infrastructure/notifier/factory.d.ts
843
1052
  /**
@@ -851,10 +1060,31 @@ declare function loadConfig(): Promise<Config>;
851
1060
  * When `config.rulesConfigPath` is NOT set:
852
1061
  * - Returns the default notifier directly (backward-compatible)
853
1062
  */
854
- declare function createNotifier(config: Config): INotifier;
1063
+ export declare function createNotifier(config: Config): INotifier;
1064
+ //#endregion
1065
+ //#region src/infrastructure/rollback/factory.d.ts
1066
+ /**
1067
+ * Creates the rollback action handler for the application.
1068
+ *
1069
+ * In the first slice the factory always returns the no-op handler. Later slices
1070
+ * can add env-based selection (e.g. a custom handler registered via config).
1071
+ */
1072
+ export declare function createRollbackActionHandler(_config: Config): IRollbackActionHandler;
1073
+ //#endregion
1074
+ //#region src/infrastructure/rollback/noop-rollback-action.handler.d.ts
1075
+ /**
1076
+ * Default rollback action handler.
1077
+ *
1078
+ * Logs the request and returns success so teams without a custom deployment
1079
+ * pipeline still see a safe, predictable behavior when the rollback button is
1080
+ * clicked. Never throws.
1081
+ */
1082
+ export declare class NoopRollbackActionHandler implements IRollbackActionHandler {
1083
+ handle(request: RollbackActionRequest): Promise<RollbackActionResult>;
1084
+ }
855
1085
  //#endregion
856
1086
  //#region src/infrastructure/notifier/slack.adapter.d.ts
857
- declare class SlackNotifier implements INotifier {
1087
+ export declare class SlackNotifier implements INotifier {
858
1088
  private readonly botToken;
859
1089
  private readonly channel;
860
1090
  constructor(botToken: string, channel: string);
@@ -862,7 +1092,7 @@ declare class SlackNotifier implements INotifier {
862
1092
  private buildAnalysisMessage;
863
1093
  private buildFallbackMessage;
864
1094
  }
865
- declare class ConsoleNotifier implements INotifier {
1095
+ export declare class ConsoleNotifier implements INotifier {
866
1096
  readonly sent: Array<{
867
1097
  cluster: AlertCluster;
868
1098
  analysis: LLMAnalysis | null;
@@ -871,10 +1101,10 @@ declare class ConsoleNotifier implements INotifier {
871
1101
  }
872
1102
  //#endregion
873
1103
  //#region src/infrastructure/notifier/teams.adapter.d.ts
874
- declare class TeamsNotifierError extends Error {
1104
+ export declare class TeamsNotifierError extends Error {
875
1105
  constructor(message: string);
876
1106
  }
877
- declare class TeamsNotifier implements INotifier {
1107
+ export declare class TeamsNotifier implements INotifier {
878
1108
  private readonly webhookUrl;
879
1109
  private readonly timeoutMs;
880
1110
  private readonly hostForErrors;
@@ -882,42 +1112,13 @@ declare class TeamsNotifier implements INotifier {
882
1112
  send(cluster: AlertCluster, analysis: LLMAnalysis | null, _channel?: string): Promise<NotifyResult>;
883
1113
  }
884
1114
  //#endregion
885
- //#region src/infrastructure/rules/channel-registry.d.ts
886
- declare class ChannelRegistry {
887
- private readonly _channels;
888
- private _default;
889
- /**
890
- * Register a notifier for a given channel name.
891
- * Overwrites any existing registration for that name.
892
- */
893
- register(channel: string, notifier: INotifier): void;
894
- /**
895
- * Set the default notifier to use when a channel is not found.
896
- */
897
- setDefault(notifier: INotifier): void;
898
- /**
899
- * Resolve a channel name to its notifier instance.
900
- * Falls back to the default notifier if the channel is unknown.
901
- *
902
- * @throws {Error} if the channel is unknown and no default is set
903
- */
904
- resolve(channel: string): INotifier;
905
- /**
906
- * Check if a channel is registered.
907
- */
908
- has(channel: string): boolean;
909
- }
910
- //#endregion
911
1115
  //#region src/infrastructure/notifier/routing-notifier.d.ts
912
- declare class RoutingNotifier implements INotifier {
1116
+ export declare class RoutingNotifier implements INotifier {
913
1117
  private readonly registry;
914
1118
  private readonly defaultNotifier;
915
1119
  constructor(registry: ChannelRegistry, defaultNotifier: INotifier);
916
- /**
917
- * Implements INotifier.send sends via default notifier.
918
- * Backward-compatible with existing call sites that don't use rule actions.
919
- */
920
- send(cluster: AlertCluster, analysis: LLMAnalysis | null): Promise<NotifyResult>;
1120
+ /** Routes to `channel` when given, else to the default notifier. */
1121
+ send(cluster: AlertCluster, analysis: LLMAnalysis | null, channel?: string): Promise<NotifyResult>;
921
1122
  /**
922
1123
  * Dispatch notifications based on rule engine actions.
923
1124
  *
@@ -934,6 +1135,11 @@ declare class RoutingNotifier implements INotifier {
934
1135
  * Falls back to default notifier if channel is unknown.
935
1136
  */
936
1137
  private tryResolveAndSend;
1138
+ /**
1139
+ * Guards channel resolution only — a delivery failure must propagate so the
1140
+ * use case can let SQS retry it.
1141
+ */
1142
+ private resolveOrDefault;
937
1143
  }
938
1144
  //#endregion
939
1145
  //#region src/infrastructure/queue/sqs.adapter.d.ts
@@ -942,7 +1148,7 @@ interface SendMessageParams {
942
1148
  messageGroupId: string;
943
1149
  messageDeduplicationId: string;
944
1150
  }
945
- declare class SQSAlertQueue implements IAlertQueue {
1151
+ export declare class SQSAlertQueue implements IAlertQueue {
946
1152
  private readonly queueUrl;
947
1153
  private readonly region?;
948
1154
  private sqsClient;
@@ -951,16 +1157,16 @@ declare class SQSAlertQueue implements IAlertQueue {
951
1157
  sendMessage(params: SendMessageParams): Promise<void>;
952
1158
  publish(alert: NormalizedAlert): Promise<void>;
953
1159
  }
954
- declare class InMemoryAlertQueue implements IAlertQueue {
1160
+ export declare class InMemoryAlertQueue implements IAlertQueue {
955
1161
  readonly published: NormalizedAlert[];
956
1162
  publish(alert: NormalizedAlert): Promise<void>;
957
1163
  }
958
1164
  //#endregion
959
1165
  //#region src/infrastructure/queue/sqs-lag-poller.d.ts
960
- declare function startSqsLagPoller(queueUrl: string, intervalMs: number, region?: string): () => void;
1166
+ export declare function startSqsLagPoller(queueUrl: string, intervalMs: number, region?: string): () => void;
961
1167
  //#endregion
962
1168
  //#region src/infrastructure/traces/loki-trace.adapter.d.ts
963
- declare class LokiTraceRepository implements ITraceRepository {
1169
+ export declare class LokiTraceRepository implements ITraceRepository {
964
1170
  private readonly lokiUrl;
965
1171
  private readonly apiKey?;
966
1172
  constructor(lokiUrl: string, apiKey?: string | undefined);
@@ -968,7 +1174,7 @@ declare class LokiTraceRepository implements ITraceRepository {
968
1174
  private parseResponse;
969
1175
  private tryParseJSON;
970
1176
  }
971
- declare class MockTraceRepository implements ITraceRepository {
1177
+ export declare class MockTraceRepository implements ITraceRepository {
972
1178
  private readonly fixtures;
973
1179
  constructor(fixtures?: Map<string, Record<string, unknown>[]>);
974
1180
  findByTraceId(traceId: string): Promise<Record<string, unknown>[]>;
@@ -982,7 +1188,7 @@ declare class MockTraceRepository implements ITraceRepository {
982
1188
  *
983
1189
  * @throws {Error} if YAML is malformed or Zod validation fails
984
1190
  */
985
- declare function parseRuleConfig(yamlString: string): ValidatedRuleConfiguration;
1191
+ export declare function parseRuleConfig(yamlString: string): ValidatedRuleConfiguration;
986
1192
  //#endregion
987
1193
  //#region src/infrastructure/rules/condition-evaluator.d.ts
988
1194
  type Predicate = (cluster: AlertCluster, analysis?: LLMAnalysis) => boolean;
@@ -994,7 +1200,7 @@ type Predicate = (cluster: AlertCluster, analysis?: LLMAnalysis) => boolean;
994
1200
  * All specified conditions must match (AND logic).
995
1201
  * If no fields are specified, the predicate returns true (match-all).
996
1202
  */
997
- declare function compileCondition(condition: ValidatedRuleCondition): Predicate;
1203
+ export declare function compileCondition(condition: ValidatedRuleCondition): Predicate;
998
1204
  //#endregion
999
1205
  //#region src/infrastructure/rules/action-dispatcher.d.ts
1000
1206
  /**
@@ -1004,10 +1210,10 @@ declare function compileCondition(condition: ValidatedRuleCondition): Predicate;
1004
1210
  *
1005
1211
  * Pure function — no I/O, no side effects beyond the returned result.
1006
1212
  */
1007
- declare function dispatchActions(actions: RuleAction[]): RuleActionResult;
1213
+ export declare function dispatchActions(actions: RuleAction[]): RuleActionResult;
1008
1214
  //#endregion
1009
1215
  //#region src/infrastructure/rules/rule-engine.d.ts
1010
- declare class RuleEngine implements IRuleEngine {
1216
+ export declare class RuleEngine implements IRuleEngine {
1011
1217
  private readonly preLlmRules;
1012
1218
  private readonly postLlmRules;
1013
1219
  constructor(config: ValidatedRuleConfiguration);
@@ -1028,7 +1234,7 @@ declare class RuleEngine implements IRuleEngine {
1028
1234
  }
1029
1235
  //#endregion
1030
1236
  //#region src/shared/factory-registry.d.ts
1031
- declare class FactoryRegistry<T> {
1237
+ export declare class FactoryRegistry<T> {
1032
1238
  private readonly _factories;
1033
1239
  private _default;
1034
1240
  /**
@@ -1061,7 +1267,7 @@ declare class FactoryRegistry<T> {
1061
1267
  * Call this at the END of the Lambda handler, after all business logic completes.
1062
1268
  * Errors are swallowed — Loki is best-effort; CloudWatch is the primary sink.
1063
1269
  */
1064
- declare function flushLoki(): Promise<void>;
1270
+ export declare function flushLoki(): Promise<void>;
1065
1271
  //#endregion
1066
- export { ALERT_TYPE_LABELS, AlertCluster, AlertClusterSchema, AlertErrorType, AlertStatus, AlertStatusSchema, AlertType, AlertmanagerPayload, AlertmanagerPayloadSchema, CIRCUIT_BREAKER, ChannelRegistry, ClaudeProvider, ClusteringService, type Config, ConsoleNotifier, DEDUP_TTL_MS_MULTIPLIER, DEV_SERVER_PORT, type DedupResult, FactoryRegistry, Fingerprint, GeminiProvider, HOUR_MS, HTTP_TIMEOUT_MS, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type IRuleEngine, type ITraceRepository, InMemoryAlertQueue, InMemoryDeduplicationStore, InMemoryIndexer, Incident, IncidentSchema, LLMAnalysis, LLMAnalysisSchema, LLMProviderType, type LLMResult, LLM_FALLBACK_DEFAULTS, LLM_MAX_TOKENS, LLM_MODELS, type Logger, type LoggerOptions, LokiTraceRepository, MockLLMProvider, MockTraceRepository, NormalizedAlert, NormalizedAlertSchema, NotifyOutcome, type NotifyResult, type OpenSearchHttpFetcher, type OpenSearchHttpResponse, OpenSearchIndexer, type OpenSearchIndexerDeps, PAYLOAD_DEFAULTS, ProcessIncidentUseCase, RATE_LIMITER, REDIS_KEY_PREFIX, RedisDeduplicationStore, RoutingNotifier, Rule, RuleAction, type RuleActionResult, RuleActionSchema, RuleActionType, RuleCondition, RuleConditionSchema, RuleConfiguration, RuleConfigurationSchema, RuleEngine, RuleEvaluationPhase, RuleSchema, RuleSection, RuleSectionSchema, SLACK_API_URL, SQSAlertQueue, SeverityLevel, type SignedHttpRequest, SlackNotifier, TEAMS_WEBHOOK_TIMEOUT_MS, TeamsNotifier, TeamsNotifierError, type TraceabilityDocument, URGENCY_EMOJI, UrgencyLevel, UrgencyLevelSchema, ValidatedRule, ValidatedRuleAction, ValidatedRuleCondition, ValidatedRuleConfiguration, ValidatedRuleSection, WEBHOOK_DEFAULTS, compileCondition, createLLMProvider, createLogger, createNotifier, dispatchActions, flushLoki, loadConfig, index_d_exports as metrics, normalizePayload, parseRuleConfig, reinitLogger, startSqsLagPoller };
1272
+ export { type Config, type DedupResult, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type IRollbackActionHandler, type IRuleEngine, type ITraceRepository, type LLMResult, type LlmDegradedReason, type Logger, type LoggerOptions, type NotifyResult, type OpenSearchHttpFetcher, type OpenSearchHttpResponse, type OpenSearchIndexerDeps, type RollbackActionRequest, type RollbackActionResult, type RuleActionResult, type SignedHttpRequest, type TraceabilityDocument, index_d_exports as metrics };
1067
1273
  //# sourceMappingURL=index.d.ts.map