/** * Deterministic terminal-failure classifier — maps the structured sources the * engine already holds at the moment of failure (CFN failure analysis, ECS * stopped-task forensics, the raw terminal error) onto the canonical * `DeploymentFailure` record. Design: * the 2026-08-10 deployment-failure taxonomy design, § 4. * * Classification happens HERE, where `category`/`stopCode`/`rolloutState` * still exist as fields — never by regex over prose at render time (the * design's explicitly rejected alternative). Everything dynamic is masked * before it is bounded (mask-then-truncate). */ import { type DeploymentFailure, type DeploymentFailurePhase } from "@fjall/util"; import { type FailureAnalysis } from "@fjall/util/aws"; import type { ECSCompleteEvent } from "../../types/events.js"; /** * Bump when a mapping changes meaning — stored on every record so persisted * rows can be re-classified offline. "2" (FJL-901): ECS's rollback of the * service deployment CloudFormation started outranks a CloudFormation * analysis rooted at that service or at a cancel's collateral, and a rollback * ECS could not complete is `ecs.rollback_failed`. */ export declare const DEPLOYMENT_FAILURE_CLASSIFIER_VERSION = "2"; /** * Classify a failed CloudFormation stack operation from the analyser's * structured output. The analysis nests verbatim (wire form) so no detail the * monitor computed is lost. */ export declare function classifyFromFailureAnalysis(analysis: FailureAnalysis, stackName?: string): DeploymentFailure; /** * Classify a failed ECS stabilisation from the tail's structured completion * event. Returns undefined for a successful event. */ export declare function classifyFromEcsCompletion(event: ECSCompleteEvent): DeploymentFailure | undefined; export interface ClassifyUnclassifiedOptions { /** The pipeline phase, when the caller knows where the failure occurred. */ phase?: Exclude; /** Raw process/log output for excerpt extraction, when richer than the message. */ output?: string; } /** * The taxonomy's first-class fallback: nothing structured survived, so the * record is bounded and located rather than classified — bare `unclassified` * (phase unknown) or `unclassified.`, always carrying a masked excerpt * window when the source outgrows `detail`. */ export declare function classifyUnclassified(message: string, options?: ClassifyUnclassifiedOptions): DeploymentFailure; export interface ClassifyDeployFailureInput { /** The terminal Result error. */ error: Error; /** The last FailureAnalysis the CFN monitor emitted, when a stack failed. */ analysis?: FailureAnalysis; /** The ECS failure to classify from, as `pickEcsFailure` chose it. */ ecsFailure?: ECSCompleteEvent; } /** * Classify a terminal deploy failure from the richest structured source * available: CFN analysis first, unless ECS's rollback verdict is the cause * it points past, then ECS forensics, then the unclassified fallback over * the error message. */ export declare function classifyDeployFailure(input: ClassifyDeployFailureInput): DeploymentFailure; /** * The failed ECS completion a deploy's failure is classified from, chosen * the same way whatever order the tail emitted them in: the service the * analysis is rooted at (or whose rollout barrier it is rooted at), else the * strongest by `ecsFailureRank`, ties broken by service ARN. A root * CloudFormation only cancelled names whichever resource its cancel reached * first, so it chooses its service only when ECS rolled that service's * deployment back. After a stack rollback every service CloudFormation * rolled back reads as replaced, so the last completion to arrive explains * nothing. */ export declare function pickEcsFailure(failures: readonly ECSCompleteEvent[], analysis: FailureAnalysis | undefined): ECSCompleteEvent | undefined;