import * as Cause from "effect/Cause"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Option from "effect/Option"; import * as Path from "effect/Path"; import * as Semaphore from "effect/Semaphore"; import { type AppError } from "../app-error/index.js"; /** Run one semantic closure's mutations under its closure identity. */ export declare const withWorkspaceClosure: (closureId: string) => (effect: Effect.Effect) => Effect.Effect; export interface WorkspaceTransactionArgs { readonly workspaceDir: string; /** In-process admission owned by the workspace service instance. */ readonly semaphore: Semaphore.Semaphore; /** Authoritative files or directories that the transition may mutate. */ readonly targets: ReadonlyArray; /** Desired, lock, canonical, projection, and native-configuration mutation. */ readonly transition: Effect.Effect; /** Confirms the complete durable postcondition before the transaction commits. */ readonly validate: (value: A) => Effect.Effect; /** Observes the start of rollback restoration; never controls it. */ readonly onRestorationStarted?: Effect.Effect; } declare const WorkspaceRestorationIncomplete_base: new = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & { readonly _tag: "WorkspaceRestorationIncomplete"; } & Readonly; /** * Restoration did not complete: the typed fact the terminal resolution * derives outcome, disposition, and exit status from. The pre-change * snapshots survive in the OS-temporary snapshot directory; nothing about * this failure persists in the workspace, and the next mutation converges * from the current workspace state. */ export declare class WorkspaceRestorationIncomplete extends WorkspaceRestorationIncomplete_base<{ readonly terminationCause: "failure" | "interruption"; readonly transitionCause: Cause.Cause; readonly restorationCause: unknown; /** OS-temporary directory preserving the pre-change snapshots, when any were taken. */ readonly snapshotDir: string | undefined; /** Protected paths, workspace-root-relative where possible, left as the failure left them. */ readonly retained: ReadonlyArray; /** Closures whose rollback did not complete, when closure-scoped. */ readonly closureIds?: ReadonlyArray; }> { } /** Render the typed restoration failure for boundaries without a resolution. */ export declare const restorationIncompleteToAppError: (error: WorkspaceRestorationIncomplete) => AppError; /** * Surface the typed restoration failure as its AppError rendering at a * boundary whose error contract is AppError. Inside a plan-family apply this * is type-satisfaction only: nested transactions reuse the outer snapshot * store and never fail restoration themselves. */ export declare const surfaceRestorationIncomplete: (effect: Effect.Effect) => Effect.Effect; /** * Settle one closure: its commits stand, so its snapshots leave the * restoration set and a later closure touching the same target takes a fresh * post-commit preimage. No-op outside a transaction. */ export declare const settleWorkspaceClosure: (closureId: string) => Effect.Effect; /** * Roll back one failed closure: restore and verify exactly its snapshots, in * reverse order, leaving every other closure's work in place. A restoration * that does not complete and verify records a pending typed failure the * transaction surfaces at its end — the truth travels in memory, never * through a later workspace write. No-op outside a transaction. */ export declare const rollbackWorkspaceClosure: (closureId: string) => Effect.Effect; /** Snapshot a path before its first mutation when a workspace transaction is active. */ export declare const protectWorkspacePath: (target: string) => Effect.Effect; /** * Closure rollbacks that could not complete and verify, with the snapshot * store that still preserves their pre-change bytes. Read at the end of a * plan apply so the terminal resolution derives retained state from the * in-memory facts alone. `None` outside a transaction. */ export declare const readPendingClosureRestorationFailures: Effect.Effect; }>; readonly snapshotDir: string | undefined; }>>; /** * Protect the first ancestor a recursive directory creation is about to * create, so restoration removes the created directory chain instead of * leaving empty parents behind. No-op outside a transaction or when the * directory already exists. */ export declare const protectCreatedAncestors: (fs: FileSystem.FileSystem, path: Path.Path, directory: string) => Effect.Effect; /** * Run one coupled workspace mutation under the workspace transition lock. * * Every authoritative target is snapshotted into a uniquely prefixed * OS-temporary directory before the transition begins. A failed transition or * postcondition check restores and verifies the exact pre-operation paths and * removes the snapshots; a restoration that does not complete and verify * fails with the typed {@link WorkspaceRestorationIncomplete}, preserving the * snapshot directory for manual inspection. Nothing about a failure persists * in the workspace: the next mutation plans from the current workspace state. * * The invocation-level transition hold is reused when a plan-family apply * already acquired it; otherwise this transaction acquires its own for the * duration of the mutation. */ export declare const runWorkspaceTransaction: (args: WorkspaceTransactionArgs) => Effect.Effect; export {}; //# sourceMappingURL=transaction.d.ts.map