/** * Sensitive-operation confirmation and cancellation logging. * * Provides utilities for gating sensitive operations behind user confirmation * and logging cancellation events to an append-only NDJSON log file. * * The cancellation log lives at `.aidlc/state//cancellations.log` * and follows the same append-only NDJSON pattern as transitions.log. * * Requirements: 13.1, 13.3, 13.6, 13.7 */ /** Describes a sensitive operation requiring confirmation. */ export interface SensitiveOperation { /** What's being done (e.g., "delete production database"). */ operation: string; /** What it affects (e.g., "users table in prod-db"). */ impact: string; /** Whether the operation can be undone. */ reversible: boolean; } /** Result of a confirmation request. */ export interface ConfirmationResult { /** Whether the user confirmed the operation. */ confirmed: boolean; /** Reason for cancellation (present when confirmed is false). */ reason?: string; } /** A single entry in the cancellation log (NDJSON). */ export interface CancellationEntry { /** ISO 8601 UTC timestamp of the cancellation. */ at: string; /** The operation that was cancelled. */ operation: string; /** What the operation would have affected. */ impact: string; /** Reason for cancellation. */ reason: string; } /** * Request confirmation for a sensitive operation. * * In non-interactive mode, always declines with a standard reason. * In interactive mode, the caller is responsible for prompting the user * and passing the result through; this function handles the non-interactive * gate and structures the result. * * @param op - The sensitive operation details. * @param opts - Options: `nonInteractive` forces automatic decline. * @returns A ConfirmationResult indicating whether to proceed. */ export declare function requestConfirmation(op: SensitiveOperation, opts?: { nonInteractive?: boolean; }): ConfirmationResult; /** * Append a cancellation entry to the instance's cancellations.log. * * Creates the file and parent directories if they do not exist. * Uses O_APPEND for atomic line appends under concurrent writes. * * @param stateDir - Absolute path to the `.aidlc/state/` directory. * @param instance - Instance name (directory namespace). * @param entry - The cancellation entry to log. */ export declare function logCancellation(stateDir: string, instance: string, entry: CancellationEntry): void; /** * Read all cancellation entries from the instance's cancellations.log. * * - Returns an empty array if the file does not exist. * - Skips empty lines. * - Skips malformed JSON lines (logs a warning to stderr). * * @param stateDir - Absolute path to the `.aidlc/state/` directory. * @param instance - Instance name (directory namespace). * @returns Array of parsed CancellationEntry records. */ export declare function readCancellations(stateDir: string, instance: string): CancellationEntry[]; /** * Combined helper: request confirmation for a sensitive operation, and if * declined, log the cancellation event automatically. * * @param op - The sensitive operation. * @param stateDir - Absolute path to `.aidlc/state/`. * @param instance - Lifecycle instance name. * @param opts - Options: `nonInteractive` forces automatic decline. * @returns The ConfirmationResult (callers should check `.confirmed`). */ export declare function confirmOrLog(op: SensitiveOperation, stateDir: string, instance: string, opts?: { nonInteractive?: boolean; }): ConfirmationResult; //# sourceMappingURL=confirmation.d.ts.map