/** * Size-bounded log files: rotate `x.jsonl` -> `x.1.jsonl` -> … -> delete. * * Lives in `@fjall/util` because three packages write persistent logs into * the same state root and only one of them had a bound. The CLI's logger * owned this class privately; `components/infrastructure` could not reach * it across the package boundary, so its validation log had no cap at all * and grew to hundreds of megabytes on a developer machine over one release * cycle. A rotation policy that only one of several writers can reach is * not a policy. */ /** Construction options. */ export interface FileRotatorOptions { maxFiles: number; } export declare class FileRotator { private maxFiles; constructor(options: FileRotatorOptions); /** * Check if a file needs rotation based on size */ needsRotation(filePath: string, maxFileSize: number): boolean; /** Rotate log files: current -> .1 -> .2 -> delete oldest */ rotate(filePath: string): void; /** Check if rotation is needed and perform it if so */ rotateIfNeeded(filePath: string, maxFileSize: number): boolean; /** Get all rotated file paths for a given log file */ getRotatedFiles(filePath: string): string[]; /** Clean up all log files (main and rotated) */ cleanAll(filePath: string): void; } /** * The bound every Fjall log file shares. * * Coupled values: the CLI's `LOGGER_DEFAULTS` and the infrastructure * validation log both derive from here, so a change to the retention budget * cannot apply to one writer and silently miss the other. */ export declare const LOG_ROTATION_DEFAULTS: { readonly MAX_FILE_SIZE: number; readonly MAX_FILES: 5; }; /** The resolved rotation budget one writer applies. */ export interface LogRotationBudget { maxFileSize: number; maxFiles: number; } /** * The rotation budget with its env overrides applied: `FJALL_LOG_MAX_SIZE` * (bytes per file) and `FJALL_LOG_MAX_FILES`. Invalid values — empty, * non-numeric, zero, negative — fall back to the defaults. * * Every writer that rotates against `LOG_ROTATION_DEFAULTS` must resolve * through here, or the overrides govern one log stream and silently miss * the other (the CLI honoured them while the infrastructure validation log * hardcoded the defaults). Resolved per call, never at module load: the * CDK subprocess imports its writer long before a command's environment is * readable. */ export declare function resolveLogRotationBudget(): LogRotationBudget;