/** * PolicyValidator — Fail-Fast Policy Validation * * Pure functions. Single responsibility: validate SyncPolicy arrays * and default config at construction time. * * Every validation error is caught eagerly — no invalid configuration * survives past PolicyEngine construction. * * @module */ import type { SyncPolicy, CacheDirective } from './types.js'; /** Valid cache directives — binary vocabulary, no max-age. */ export declare const VALID_DIRECTIVES: ReadonlySet; /** * Validate an array of policies. Throws on the first invalid entry. * * Called at PolicyEngine construction time for fail-fast behavior. * * @throws {Error} Descriptive error identifying the invalid policy */ export declare function validatePolicies(policies: readonly SyncPolicy[]): void; /** * Validate the defaults config. Throws if cacheControl is invalid. * * @throws {Error} If the default cacheControl directive is not recognized */ export declare function validateDefaults(defaults?: { readonly cacheControl?: CacheDirective; }): void; /** * Warning produced when two policies potentially overlap. * * Overlapping policies are not an error (first-match-wins is deterministic), * but they can cause subtle configuration bugs when the user expects a * more-specific policy to fire but a broader one shadows it. * * @example * ```typescript * const warnings = detectOverlaps(policies); * warnings.forEach(w => console.warn(`[StateSync] ${w.message}`)); * ``` */ export interface OverlapWarning { /** Human-readable description of the overlap. */ readonly message: string; /** Index of the shadowing (earlier) policy. */ readonly shadowingIndex: number; /** Index of the shadowed (later) policy. */ readonly shadowedIndex: number; } /** * Detect potentially overlapping glob policies. * * Checks if a broader policy at index `i` could shadow a more-specific * policy at index `j > i`. Uses GlobMatcher to test if the earlier * pattern matches the later pattern's literal segments. * * This is a heuristic: it only catches cases where the later policy's * `match` string (treated as a literal tool name) would match the * earlier policy's glob. It does NOT do full set-intersection analysis. * * @param policies - The policies array to analyze * @returns Array of overlap warnings (empty if no overlaps detected) */ export declare function detectOverlaps(policies: readonly SyncPolicy[]): readonly OverlapWarning[]; //# sourceMappingURL=PolicyValidator.d.ts.map