@junando/core 0.12.2 → 0.12.3

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;
@@ -579,11 +582,11 @@ interface ILLMProvider {
579
582
  * Terminal outcome of a single notification send.
580
583
  * Feeds the `notify` section of the wide event.
581
584
  */
582
- declare const NotifyOutcome: {
585
+ export declare const NotifyOutcome: {
583
586
  readonly Success: 'success';
584
587
  readonly Failure: 'failure';
585
588
  };
586
- type NotifyOutcome = (typeof NotifyOutcome)[keyof typeof NotifyOutcome];
589
+ export type NotifyOutcome = (typeof NotifyOutcome)[keyof typeof NotifyOutcome];
587
590
  /**
588
591
  * Structured result of a notification send.
589
592
  * Adapters throw on failure (the caller records NotifyOutcome.Failure and
@@ -643,9 +646,43 @@ interface IRuleEngine {
643
646
  */
644
647
  evaluatePostLlm(cluster: AlertCluster, analysis: LLMAnalysis): RuleActionResult;
645
648
  }
649
+ /**
650
+ * Request dispatched to a rollback action handler.
651
+ * Minimal incident metadata encoded in the Slack button value plus the user
652
+ * who triggered the action.
653
+ */
654
+ interface RollbackActionRequest {
655
+ fingerprint: string;
656
+ serviceName: string;
657
+ endpointPath: string;
658
+ alertType: AlertType;
659
+ urgencyLevel?: 'low' | 'medium' | 'high' | 'critical';
660
+ triggeredBy: {
661
+ id?: string;
662
+ username?: string;
663
+ channel: 'slack' | 'teams';
664
+ };
665
+ correlationId?: string;
666
+ messageTs?: string;
667
+ }
668
+ /**
669
+ * Result of a rollback action handler invocation.
670
+ */
671
+ interface RollbackActionResult {
672
+ ok: boolean;
673
+ message: string;
674
+ }
675
+ /**
676
+ * Configurable rollback action handler.
677
+ * Implementations wire Junando to a team's deployment pipeline.
678
+ * The default no-op adapter logs and returns success so nothing breaks.
679
+ */
680
+ interface IRollbackActionHandler {
681
+ handle(request: RollbackActionRequest): Promise<RollbackActionResult>;
682
+ }
646
683
  //#endregion
647
684
  //#region src/domain/services/clustering.service.d.ts
648
- declare class ClusteringService {
685
+ export declare class ClusteringService {
649
686
  /**
650
687
  * Groups alerts by fingerprint and builds AlertCluster objects.
651
688
  * 300 alerts with the same root cause → 1 cluster with 2 representative traces.
@@ -656,7 +693,140 @@ declare class ClusteringService {
656
693
  }
657
694
  //#endregion
658
695
  //#region src/application/dtos/normalize-payload.d.ts
659
- declare function normalizePayload(payload: AlertmanagerPayload): NormalizedAlert[];
696
+ export declare function normalizePayload(payload: AlertmanagerPayload): NormalizedAlert[];
697
+ //#endregion
698
+ //#region src/shared/logger/enums.d.ts
699
+ /**
700
+ * Pipeline component taxonomy.
701
+ *
702
+ * `component` (not `service`) distinguishes pipeline stages in wide events.
703
+ * `service` stays constant ("junando"); `component` tells you WHERE the event
704
+ * was emitted from.
705
+ */
706
+ export declare const Component: {
707
+ readonly Webhook: 'webhook';
708
+ readonly Worker: 'worker';
709
+ readonly UseCase: 'useCase';
710
+ readonly Llm: 'llm';
711
+ readonly Notifier: 'notifier';
712
+ readonly Dedup: 'dedup';
713
+ readonly Traces: 'traces';
714
+ readonly Ingest: 'ingest';
715
+ readonly Rollback: 'rollback';
716
+ };
717
+ export type Component = (typeof Component)[keyof typeof Component];
718
+ /**
719
+ * Pipeline stages that write their results into the WideEventBuilder.
720
+ */
721
+ export declare const Stage: {
722
+ readonly Dedup: 'dedup';
723
+ readonly RulesPre: 'rulesPre';
724
+ readonly Traces: 'traces';
725
+ readonly Llm: 'llm';
726
+ readonly RulesPost: 'rulesPost';
727
+ readonly Notify: 'notify';
728
+ };
729
+ export type Stage = (typeof Stage)[keyof typeof Stage];
730
+ /**
731
+ * Terminal outcomes for a wide event across all entry points.
732
+ */
733
+ export declare const Outcome: {
734
+ readonly Success: 'success';
735
+ readonly Suppressed: 'suppressed';
736
+ readonly Degraded: 'degraded';
737
+ readonly Error: 'error';
738
+ readonly Accepted: 'accepted';
739
+ readonly Empty: 'empty';
740
+ readonly ParseError: 'parse_error';
741
+ };
742
+ export type Outcome = (typeof Outcome)[keyof typeof Outcome];
743
+ /**
744
+ * Reason recorded for a tail-sampling decision.
745
+ */
746
+ export declare const SamplingDecision: {
747
+ readonly Error: 'error';
748
+ readonly Slow: 'slow';
749
+ readonly Random: 'random';
750
+ readonly Skipped: 'skipped';
751
+ };
752
+ export type SamplingDecision = (typeof SamplingDecision)[keyof typeof SamplingDecision];
753
+ //#endregion
754
+ //#region src/shared/logger/wide-event-builder.d.ts
755
+ interface ClusterSection {
756
+ fingerprint: string;
757
+ serviceName: string;
758
+ alertCount: number;
759
+ spanCount: number;
760
+ /** Number of representative traces that failed to fetch (fail-open). */
761
+ traceErrors?: number;
762
+ }
763
+ interface DedupSection {
764
+ isNew: boolean;
765
+ ttlSeconds: number;
766
+ /** Fail-open error message when the store was unreachable (e.g. Redis down). */
767
+ error?: string;
768
+ }
769
+ interface RuleSection$1 {
770
+ matched: boolean;
771
+ suppressed: boolean;
772
+ /** ID of the rule that matched, when the engine reports one. */
773
+ matchedRuleId?: string;
774
+ }
775
+ interface LlmSection {
776
+ provider: string;
777
+ model: string;
778
+ latencyMs: number;
779
+ urgency: string;
780
+ tokens: number;
781
+ }
782
+ interface NotifySection {
783
+ channels: string[];
784
+ outcome: string;
785
+ latencyMs: number;
786
+ }
787
+ interface RollbackSection {
788
+ actionId: string;
789
+ channel: string;
790
+ outcome: 'ok' | 'error';
791
+ handlerMessage: string;
792
+ }
793
+ interface ErrorSection {
794
+ message: string;
795
+ name?: string;
796
+ stack?: string;
797
+ }
798
+ interface WideEvent {
799
+ requestId: string;
800
+ correlationId?: string;
801
+ timestamp: string;
802
+ component: Component;
803
+ version?: string;
804
+ outcome?: Outcome;
805
+ cluster?: ClusterSection;
806
+ dedup?: DedupSection;
807
+ rule?: RuleSection$1;
808
+ llm?: LlmSection;
809
+ notify?: NotifySection;
810
+ rollback?: RollbackSection;
811
+ durationMs?: number;
812
+ error?: ErrorSection;
813
+ /** Present only when the 256 KB guard truncated the event. */
814
+ _truncated?: boolean;
815
+ }
816
+ /** Fields the builder owns — callers cannot set or merge them. */
817
+ type BuilderOwnedKey = 'requestId' | 'component' | 'timestamp' | '_truncated';
818
+ /** Keys callers may write via set()/merge(). */
819
+ type SettableKey = Exclude<keyof WideEvent, BuilderOwnedKey>;
820
+ export declare class WideEventBuilder {
821
+ private readonly requestId;
822
+ private readonly component;
823
+ private fields;
824
+ constructor(requestId: string, component: Component);
825
+ set<K extends SettableKey>(key: K, value: WideEvent[K]): this;
826
+ merge(obj: Partial<WideEvent>): this;
827
+ flush(): WideEvent;
828
+ private enforceSizeLimit;
829
+ }
660
830
  //#endregion
661
831
  //#region src/shared/logger/index.d.ts
662
832
  type Logger = pino.Logger;
@@ -669,7 +839,7 @@ interface LoggerOptions {
669
839
  * Module-level callers get a proxy that automatically starts writing to Loki
670
840
  * once reinitLogger() is called inside the handler after loadConfig().
671
841
  */
672
- declare function createLogger(levelOrOptions?: string | LoggerOptions): Logger;
842
+ export declare function createLogger(levelOrOptions?: string | LoggerOptions): Logger;
673
843
  /**
674
844
  * Re-creates the root logger with current env vars (including LOKI_URL).
675
845
  * Call this inside your Lambda handler immediately after loadConfig():
@@ -678,7 +848,7 @@ declare function createLogger(levelOrOptions?: string | LoggerOptions): Logger;
678
848
  * const config = await loadConfig();
679
849
  * reinitLogger(); // all module-level proxy loggers now write to Loki
680
850
  */
681
- declare function reinitLogger(opts?: LoggerOptions): void;
851
+ export declare function reinitLogger(opts?: LoggerOptions): void;
682
852
  //#endregion
683
853
  //#region src/application/use-cases/process-incident.use-case.d.ts
684
854
  interface Dependencies {
@@ -692,7 +862,7 @@ interface Dependencies {
692
862
  onClustersBuilt?: (count: number) => void;
693
863
  ruleEngine?: IRuleEngine;
694
864
  }
695
- declare class ProcessIncidentUseCase {
865
+ export declare class ProcessIncidentUseCase {
696
866
  private readonly deps;
697
867
  private readonly clustering;
698
868
  private readonly wideEventsEnabled;
@@ -706,14 +876,14 @@ declare class ProcessIncidentUseCase {
706
876
  }
707
877
  //#endregion
708
878
  //#region src/infrastructure/dedup/redis-dedup.adapter.d.ts
709
- declare class RedisDeduplicationStore implements IDeduplicationStore {
879
+ export declare class RedisDeduplicationStore implements IDeduplicationStore {
710
880
  private readonly redis;
711
881
  private readonly keyPrefix;
712
882
  constructor(redis: Redis);
713
883
  isNew(fingerprint: string, ttlSeconds: number): Promise<DedupResult>;
714
884
  reset(fingerprint: string): Promise<void>;
715
885
  }
716
- declare class InMemoryDeduplicationStore implements IDeduplicationStore {
886
+ export declare class InMemoryDeduplicationStore implements IDeduplicationStore {
717
887
  private readonly store;
718
888
  isNew(fingerprint: string, ttlSeconds: number): Promise<DedupResult>;
719
889
  reset(fingerprint: string): Promise<void>;
@@ -738,7 +908,7 @@ interface OpenSearchIndexerDeps {
738
908
  region: string;
739
909
  fetcher: OpenSearchHttpFetcher;
740
910
  }
741
- declare class OpenSearchIndexer implements IIndexer<TraceabilityDocument> {
911
+ export declare class OpenSearchIndexer implements IIndexer<TraceabilityDocument> {
742
912
  private readonly endpoint;
743
913
  private readonly indexName;
744
914
  private readonly region;
@@ -746,7 +916,7 @@ declare class OpenSearchIndexer implements IIndexer<TraceabilityDocument> {
746
916
  constructor(deps: OpenSearchIndexerDeps);
747
917
  index(doc: TraceabilityDocument): Promise<void>;
748
918
  }
749
- declare class InMemoryIndexer implements IIndexer<TraceabilityDocument> {
919
+ export declare class InMemoryIndexer implements IIndexer<TraceabilityDocument> {
750
920
  readonly indexed: TraceabilityDocument[];
751
921
  index(doc: TraceabilityDocument): Promise<void>;
752
922
  }
@@ -756,7 +926,7 @@ declare class InMemoryIndexer implements IIndexer<TraceabilityDocument> {
756
926
  * Gemini LLM provider using Google Generative AI SDK.
757
927
  * Wrapped with circuit breaker for resilience.
758
928
  */
759
- declare class GeminiProvider implements ILLMProvider {
929
+ export declare class GeminiProvider implements ILLMProvider {
760
930
  private readonly apiKey;
761
931
  private readonly model;
762
932
  private readonly breaker;
@@ -769,7 +939,7 @@ declare class GeminiProvider implements ILLMProvider {
769
939
  * Claude LLM provider using Anthropic SDK.
770
940
  * Supports Claude Haiku and other models.
771
941
  */
772
- declare class ClaudeProvider implements ILLMProvider {
942
+ export declare class ClaudeProvider implements ILLMProvider {
773
943
  private readonly apiKey;
774
944
  private readonly model;
775
945
  constructor(apiKey: string, model?: string);
@@ -779,7 +949,7 @@ declare class ClaudeProvider implements ILLMProvider {
779
949
  * Mock LLM provider for testing and local development.
780
950
  * Returns deterministic responses without external API calls.
781
951
  */
782
- declare class MockLLMProvider implements ILLMProvider {
952
+ export declare class MockLLMProvider implements ILLMProvider {
783
953
  readonly callLog: Array<{
784
954
  cluster: AlertCluster;
785
955
  }>;
@@ -793,7 +963,7 @@ interface FallbackOptions {
793
963
  fallbackModels?: string[];
794
964
  fallbackTimeoutMs?: number;
795
965
  }
796
- declare function createLLMProvider(provider: string, apiKey: string, model?: string, options?: FallbackOptions): ILLMProvider;
966
+ export declare function createLLMProvider(provider: string, apiKey: string, model?: string, options?: FallbackOptions): ILLMProvider;
797
967
  //#endregion
798
968
  //#region src/shared/config/index.d.ts
799
969
  declare enum NodeEnvironment {
@@ -818,6 +988,8 @@ declare const ConfigSchema: z.ZodObject<{
818
988
  slackBotToken: z.ZodOptional<z.ZodString>;
819
989
  slackSigningSecret: z.ZodOptional<z.ZodString>;
820
990
  slackChannel: z.ZodOptional<z.ZodString>;
991
+ rollbackActionEnabled: z.ZodDefault<z.ZodBoolean>;
992
+ rollbackActionAllowedSlackUserIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
821
993
  teamsWebhookUrl: z.ZodOptional<z.ZodString>;
822
994
  lokiUrl: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
823
995
  redisUrl: z.ZodString;
@@ -837,7 +1009,33 @@ declare const ConfigSchema: z.ZodObject<{
837
1009
  rulesConfigPath: z.ZodPipe<z.ZodOptional<z.ZodString>, z.ZodTransform<string | undefined, string | undefined>>;
838
1010
  }, z.core.$strip>;
839
1011
  type Config = z.infer<typeof ConfigSchema>;
840
- declare function loadConfig(): Promise<Config>;
1012
+ export declare function loadConfig(): Promise<Config>;
1013
+ //#endregion
1014
+ //#region src/infrastructure/rules/channel-registry.d.ts
1015
+ export declare class ChannelRegistry {
1016
+ private readonly _channels;
1017
+ private _default;
1018
+ /**
1019
+ * Register a notifier for a given channel name.
1020
+ * Overwrites any existing registration for that name.
1021
+ */
1022
+ register(channel: string, notifier: INotifier): void;
1023
+ /**
1024
+ * Set the default notifier to use when a channel is not found.
1025
+ */
1026
+ setDefault(notifier: INotifier): void;
1027
+ /**
1028
+ * Resolve a channel name to its notifier instance.
1029
+ * Falls back to the default notifier if the channel is unknown.
1030
+ *
1031
+ * @throws {Error} if the channel is unknown and no default is set
1032
+ */
1033
+ resolve(channel: string): INotifier;
1034
+ /**
1035
+ * Check if a channel is registered.
1036
+ */
1037
+ has(channel: string): boolean;
1038
+ }
841
1039
  //#endregion
842
1040
  //#region src/infrastructure/notifier/factory.d.ts
843
1041
  /**
@@ -851,10 +1049,31 @@ declare function loadConfig(): Promise<Config>;
851
1049
  * When `config.rulesConfigPath` is NOT set:
852
1050
  * - Returns the default notifier directly (backward-compatible)
853
1051
  */
854
- declare function createNotifier(config: Config): INotifier;
1052
+ export declare function createNotifier(config: Config): INotifier;
1053
+ //#endregion
1054
+ //#region src/infrastructure/rollback/factory.d.ts
1055
+ /**
1056
+ * Creates the rollback action handler for the application.
1057
+ *
1058
+ * In the first slice the factory always returns the no-op handler. Later slices
1059
+ * can add env-based selection (e.g. a custom handler registered via config).
1060
+ */
1061
+ export declare function createRollbackActionHandler(_config: Config): IRollbackActionHandler;
1062
+ //#endregion
1063
+ //#region src/infrastructure/rollback/noop-rollback-action.handler.d.ts
1064
+ /**
1065
+ * Default rollback action handler.
1066
+ *
1067
+ * Logs the request and returns success so teams without a custom deployment
1068
+ * pipeline still see a safe, predictable behavior when the rollback button is
1069
+ * clicked. Never throws.
1070
+ */
1071
+ export declare class NoopRollbackActionHandler implements IRollbackActionHandler {
1072
+ handle(request: RollbackActionRequest): Promise<RollbackActionResult>;
1073
+ }
855
1074
  //#endregion
856
1075
  //#region src/infrastructure/notifier/slack.adapter.d.ts
857
- declare class SlackNotifier implements INotifier {
1076
+ export declare class SlackNotifier implements INotifier {
858
1077
  private readonly botToken;
859
1078
  private readonly channel;
860
1079
  constructor(botToken: string, channel: string);
@@ -862,7 +1081,7 @@ declare class SlackNotifier implements INotifier {
862
1081
  private buildAnalysisMessage;
863
1082
  private buildFallbackMessage;
864
1083
  }
865
- declare class ConsoleNotifier implements INotifier {
1084
+ export declare class ConsoleNotifier implements INotifier {
866
1085
  readonly sent: Array<{
867
1086
  cluster: AlertCluster;
868
1087
  analysis: LLMAnalysis | null;
@@ -871,10 +1090,10 @@ declare class ConsoleNotifier implements INotifier {
871
1090
  }
872
1091
  //#endregion
873
1092
  //#region src/infrastructure/notifier/teams.adapter.d.ts
874
- declare class TeamsNotifierError extends Error {
1093
+ export declare class TeamsNotifierError extends Error {
875
1094
  constructor(message: string);
876
1095
  }
877
- declare class TeamsNotifier implements INotifier {
1096
+ export declare class TeamsNotifier implements INotifier {
878
1097
  private readonly webhookUrl;
879
1098
  private readonly timeoutMs;
880
1099
  private readonly hostForErrors;
@@ -882,42 +1101,13 @@ declare class TeamsNotifier implements INotifier {
882
1101
  send(cluster: AlertCluster, analysis: LLMAnalysis | null, _channel?: string): Promise<NotifyResult>;
883
1102
  }
884
1103
  //#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
1104
  //#region src/infrastructure/notifier/routing-notifier.d.ts
912
- declare class RoutingNotifier implements INotifier {
1105
+ export declare class RoutingNotifier implements INotifier {
913
1106
  private readonly registry;
914
1107
  private readonly defaultNotifier;
915
1108
  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>;
1109
+ /** Routes to `channel` when given, else to the default notifier. */
1110
+ send(cluster: AlertCluster, analysis: LLMAnalysis | null, channel?: string): Promise<NotifyResult>;
921
1111
  /**
922
1112
  * Dispatch notifications based on rule engine actions.
923
1113
  *
@@ -934,6 +1124,11 @@ declare class RoutingNotifier implements INotifier {
934
1124
  * Falls back to default notifier if channel is unknown.
935
1125
  */
936
1126
  private tryResolveAndSend;
1127
+ /**
1128
+ * Guards channel resolution only — a delivery failure must propagate so the
1129
+ * use case can let SQS retry it.
1130
+ */
1131
+ private resolveOrDefault;
937
1132
  }
938
1133
  //#endregion
939
1134
  //#region src/infrastructure/queue/sqs.adapter.d.ts
@@ -942,7 +1137,7 @@ interface SendMessageParams {
942
1137
  messageGroupId: string;
943
1138
  messageDeduplicationId: string;
944
1139
  }
945
- declare class SQSAlertQueue implements IAlertQueue {
1140
+ export declare class SQSAlertQueue implements IAlertQueue {
946
1141
  private readonly queueUrl;
947
1142
  private readonly region?;
948
1143
  private sqsClient;
@@ -951,16 +1146,16 @@ declare class SQSAlertQueue implements IAlertQueue {
951
1146
  sendMessage(params: SendMessageParams): Promise<void>;
952
1147
  publish(alert: NormalizedAlert): Promise<void>;
953
1148
  }
954
- declare class InMemoryAlertQueue implements IAlertQueue {
1149
+ export declare class InMemoryAlertQueue implements IAlertQueue {
955
1150
  readonly published: NormalizedAlert[];
956
1151
  publish(alert: NormalizedAlert): Promise<void>;
957
1152
  }
958
1153
  //#endregion
959
1154
  //#region src/infrastructure/queue/sqs-lag-poller.d.ts
960
- declare function startSqsLagPoller(queueUrl: string, intervalMs: number, region?: string): () => void;
1155
+ export declare function startSqsLagPoller(queueUrl: string, intervalMs: number, region?: string): () => void;
961
1156
  //#endregion
962
1157
  //#region src/infrastructure/traces/loki-trace.adapter.d.ts
963
- declare class LokiTraceRepository implements ITraceRepository {
1158
+ export declare class LokiTraceRepository implements ITraceRepository {
964
1159
  private readonly lokiUrl;
965
1160
  private readonly apiKey?;
966
1161
  constructor(lokiUrl: string, apiKey?: string | undefined);
@@ -968,7 +1163,7 @@ declare class LokiTraceRepository implements ITraceRepository {
968
1163
  private parseResponse;
969
1164
  private tryParseJSON;
970
1165
  }
971
- declare class MockTraceRepository implements ITraceRepository {
1166
+ export declare class MockTraceRepository implements ITraceRepository {
972
1167
  private readonly fixtures;
973
1168
  constructor(fixtures?: Map<string, Record<string, unknown>[]>);
974
1169
  findByTraceId(traceId: string): Promise<Record<string, unknown>[]>;
@@ -982,7 +1177,7 @@ declare class MockTraceRepository implements ITraceRepository {
982
1177
  *
983
1178
  * @throws {Error} if YAML is malformed or Zod validation fails
984
1179
  */
985
- declare function parseRuleConfig(yamlString: string): ValidatedRuleConfiguration;
1180
+ export declare function parseRuleConfig(yamlString: string): ValidatedRuleConfiguration;
986
1181
  //#endregion
987
1182
  //#region src/infrastructure/rules/condition-evaluator.d.ts
988
1183
  type Predicate = (cluster: AlertCluster, analysis?: LLMAnalysis) => boolean;
@@ -994,7 +1189,7 @@ type Predicate = (cluster: AlertCluster, analysis?: LLMAnalysis) => boolean;
994
1189
  * All specified conditions must match (AND logic).
995
1190
  * If no fields are specified, the predicate returns true (match-all).
996
1191
  */
997
- declare function compileCondition(condition: ValidatedRuleCondition): Predicate;
1192
+ export declare function compileCondition(condition: ValidatedRuleCondition): Predicate;
998
1193
  //#endregion
999
1194
  //#region src/infrastructure/rules/action-dispatcher.d.ts
1000
1195
  /**
@@ -1004,10 +1199,10 @@ declare function compileCondition(condition: ValidatedRuleCondition): Predicate;
1004
1199
  *
1005
1200
  * Pure function — no I/O, no side effects beyond the returned result.
1006
1201
  */
1007
- declare function dispatchActions(actions: RuleAction[]): RuleActionResult;
1202
+ export declare function dispatchActions(actions: RuleAction[]): RuleActionResult;
1008
1203
  //#endregion
1009
1204
  //#region src/infrastructure/rules/rule-engine.d.ts
1010
- declare class RuleEngine implements IRuleEngine {
1205
+ export declare class RuleEngine implements IRuleEngine {
1011
1206
  private readonly preLlmRules;
1012
1207
  private readonly postLlmRules;
1013
1208
  constructor(config: ValidatedRuleConfiguration);
@@ -1028,7 +1223,7 @@ declare class RuleEngine implements IRuleEngine {
1028
1223
  }
1029
1224
  //#endregion
1030
1225
  //#region src/shared/factory-registry.d.ts
1031
- declare class FactoryRegistry<T> {
1226
+ export declare class FactoryRegistry<T> {
1032
1227
  private readonly _factories;
1033
1228
  private _default;
1034
1229
  /**
@@ -1061,7 +1256,7 @@ declare class FactoryRegistry<T> {
1061
1256
  * Call this at the END of the Lambda handler, after all business logic completes.
1062
1257
  * Errors are swallowed — Loki is best-effort; CloudWatch is the primary sink.
1063
1258
  */
1064
- declare function flushLoki(): Promise<void>;
1259
+ export declare function flushLoki(): Promise<void>;
1065
1260
  //#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 };
1261
+ export { type Config, type DedupResult, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type IRollbackActionHandler, type IRuleEngine, type ITraceRepository, type LLMResult, 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
1262
  //# sourceMappingURL=index.d.ts.map