import { Effect, FileSystem, Path } from "effect";
import { type FoundryExecutionEvidence, type FoundryExecutionEvidenceIdentity, type FoundryExecutionOutcome, type FoundryGenerationRejection, type FoundryInvocationEvidence, type FoundryRequestDiagnostic, type FoundryRequestReturn, type FoundryRequestUnknownReason, type FoundryTrialCheckpoint, type FoundryTrialIdentity } from "../protocols/foundry-execution-evidence.js";
declare const FoundryExecutionEvidenceError_base: new = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
readonly _tag: "FoundryExecutionEvidenceError";
} & Readonly;
export declare class FoundryExecutionEvidenceError extends FoundryExecutionEvidenceError_base<{
readonly reason: "invalid-evidence" | "already-started" | "unsafe-path" | "persistence-failure" | "unresolved-exposure" | "invalid-transition";
readonly cause?: unknown;
}> {
get message(): string;
}
/**
* Check raw Effect Causes before squashing, which can discard a later reason.
* Also accepts nested domain errors and aggregate causes without classifying
* provider text or a matching string tag as a trusted evidence failure.
*/
export declare function findFoundryExecutionEvidenceError(cause: unknown): FoundryExecutionEvidenceError | undefined;
export type FoundryAuthoringRequestRecorder = {
readonly beginInvocation: (input: Omit) => Effect.Effect;
readonly beginRequest: (input: {
readonly invocationId: number;
readonly retryOrdinal: number;
}) => Effect.Effect;
readonly recordReturned: (requestId: number, response: FoundryRequestReturn) => Effect.Effect;
readonly recordUnknown: (requestId: number, reason: FoundryRequestUnknownReason, diagnostic?: FoundryRequestDiagnostic) => Effect.Effect;
readonly endInvocation: (invocationId: number, state: Exclude) => Effect.Effect;
};
export type FoundryExecutionEvidenceStore = {
readonly path: string;
/** Last successfully persisted state; not an exposure seal. */
readonly snapshot: Effect.Effect;
readonly recorder: FoundryAuthoringRequestRecorder;
/**
* Candidate-owner checkpoint, not a session/exposure seal. Exactly once;
* no further requests after this write, even on a failed/unknown trial.
*/
readonly checkpointTrial: (checkpoint: FoundryTrialCheckpoint) => Effect.Effect;
/** Called by the existing outer owner only after execution and session cleanup. */
readonly seal: (input: {
readonly outcome: FoundryExecutionOutcome;
readonly generationRejection?: FoundryGenerationRejection;
}) => Effect.Effect;
};
/**
* Read-only early rejection before any session acquisition. This is not a
* claim: begin still owns the exclusive mkdir after readiness and closes races.
* Any existing claim, including an empty/open/unknown one, remains nonreusable.
*/
export declare const assertFoundryExecutionUnclaimed: (input: FoundryExecutionEvidenceIdentity) => Effect.Effect;
/**
* Begin a new immutable execution identity. Existing directories are never
* reused, reclaimed, deleted, or inferred complete from observer/diagnostic data.
*
* Serial atomic replacements cover process interruption and reported IO errors,
* not power-loss durability: the existing atomic writer does not fsync.
*/
export declare const beginFoundryExecutionEvidence: (input: FoundryExecutionEvidenceIdentity & {
/** Use session.calls/plannedModelCalls as-is; retries are already reserved. */
readonly maximumPhysicalRequests: number;
readonly upstreamEvidenceRequired?: true;
readonly trial?: FoundryTrialIdentity;
}) => Effect.Effect<{
path: string;
snapshot: Effect.Effect;
recorder: FoundryAuthoringRequestRecorder;
checkpointTrial: (checkpoint: FoundryTrialCheckpoint) => Effect.Effect;
seal: ({ outcome, generationRejection }: {
readonly outcome: FoundryExecutionOutcome;
readonly generationRejection?: FoundryGenerationRejection;
}) => Effect.Effect<{
readonly version: 1;
readonly kind: "foundry-execution-evidence";
readonly durability: "process-and-reported-io-v1";
readonly identity: FoundryExecutionEvidenceIdentity;
readonly maximumPhysicalRequests: number;
readonly upstreamEvidenceRequired?: true;
readonly trial?: FoundryTrialIdentity;
readonly trialCheckpoint?: FoundryTrialCheckpoint;
readonly revision: number;
readonly invocations: readonly FoundryInvocationEvidence[];
readonly requests: readonly import("../protocols/foundry-execution-evidence.js").FoundryPhysicalRequestEvidence[];
} & {
readonly state: "sealed";
readonly terminal: {
readonly outcome: FoundryExecutionOutcome;
readonly requestExposure: "closed" | "unknown";
readonly generationRejection?: FoundryGenerationRejection;
};
}, FoundryExecutionEvidenceError, never>;
}, FoundryExecutionEvidenceError, FileSystem.FileSystem | Path.Path>;
/** Read exact private metadata; missing/legacy journals never become a snapshot. */
export declare const readFoundryExecutionEvidence: (input: FoundryExecutionEvidenceIdentity) => Effect.Effect;
export {};