/** * Constrained patch validation and atomic application. * * Model output is never applied as a shell patch. Every operation is checked * against the repository root, its exact base hash, and an explicit scope. */ import type { PatchOperation, PatchSetV1 } from "../../core/contracts.ts"; export interface PatchPolicy { /** POSIX relative paths or directory prefixes ending in `/`. */ allowedPaths?: string[]; /** Additional protected paths or directory prefixes ending in `/`. */ protectedPaths?: string[]; maxOperations?: number; maxChangedBytes?: number; allowDeletes?: boolean; allowRenames?: boolean; /** Full content-addressed snapshot bound into the generation request. */ expectedSnapshotHash?: string; } export interface PreparedPatch { root: string; patch: PatchSetV1; operations: PreparedOperation[]; changedBytes: number; } export type PreparedOperation = { kind: "create"; path: string; absPath: string; content: string; mode: number; } | { kind: "edit"; path: string; absPath: string; before: string; after: string; mode: number; } | { kind: "delete"; path: string; absPath: string; before: string; mode: number; } | { kind: "rename"; from: string; absFrom: string; path: string; absPath: string; before: string; mode: number; }; export declare class PatchSafetyError extends Error { readonly code: string; readonly details: string[]; constructor(code: string, message: string, details?: string[]); } export interface ApplyResult { applied: string[]; patchHash: string; } export declare function normalizePatchPath(value: string): string; export declare function computePatchSnapshotHash(operations: readonly PatchOperation[]): string; /** * Rejects a model-proposed patch unless every operation stays inside reviewed * scope and still matches the exact snapshot it was generated against. */ export declare function preparePatch(rootInput: string, patch: PatchSetV1, policy?: PatchPolicy): Promise; /** * Writes a host-validated structured patch to the working tree. If something * fails, touched paths are restored before the error is rethrown. Atomicity is * per file — don't describe this as a filesystem-wide transaction, because it * isn't one. */ export declare function applyPatchAtomic(root: string, patch: PatchSetV1, policy?: PatchPolicy): Promise; //# sourceMappingURL=patch.d.ts.map