/** * Design-time workflow validation for `weft validate`. * * Analyses workflow definitions for common anti-patterns: * * 1. **Unbounded retry policy** — an activity whose `retry.maxAttempts` is * `Infinity` (or the workflow registration specifies `retry.maxAttempts` * equal to `Infinity`). Unbounded retries can loop indefinitely on * persistent failures, consuming resources without ever propagating the * error. * * 2. **Stateful activity without compensator** — an activity definition that * is not marked `idempotent: true` and has no `compensate` function. * Without a compensator, the activity cannot participate in saga-style * rollback, leaving partial writes stranded on failure. * * 3. **Non-serializable activity input/output** — detected by passing a * sentinel object through `JSON.stringify`; non-serializable values * (functions, Symbols, circular references) cannot survive checkpoint * persistence. * * @module diagnostics/validate */ import type { ActivityDefinition, WorkflowDefinition } from '../core/types.ts'; export type ValidationIssueSeverity = 'error' | 'warning'; export type ValidationIssueCode = 'unbounded-retry' | 'stateful-without-compensator' | 'non-serializable-input'; export interface ValidationIssue { severity: ValidationIssueSeverity; code: ValidationIssueCode; workflowType: string; activityName?: string; message: string; } export interface ValidationReport { /** Total number of workflow definitions scanned. */ workflowCount: number; /** All detected issues across all registrations. */ issues: ValidationIssue[]; /** `true` when there are no `error`-severity issues. */ valid: boolean; } /** * Validate a collection of workflow definitions for common anti-patterns. * * @param registrations A record of workflow type name to WorkflowDefinition. * @param activities Optional standalone ActivityDefinition objects to check * in addition to activities embedded in workflow definitions. */ export declare function validateRegistrations(registrations: Record, activities?: ActivityDefinition[]): ValidationReport; export declare function loadRegistrationsFromModule(modulePath: string): Promise<{ registrations: Record; activities: ActivityDefinition[]; }>; /** * Format a validation report as human-readable text for console output. */ export declare function formatValidationReport(report: ValidationReport, entryPath: string): string;