import type Database from "better-sqlite3";
import type { ModuleCommandResult } from "../../contracts/module-contract.js";
import type { PlanArtifactV1 } from "../../core/planning/plan-artifact-v1.js";
import { type PlanArtifactStoragePaths } from "../../core/planning/plan-artifact-storage.js";
export type PlanArtifactDraftIdempotencyStateV1 = {
    schemaVersion: 1;
    payloadDigest: string;
    planId: string;
    version: number;
    planRef: string;
    storagePath: string;
};
export declare function userSuppliedPlanArtifactVersion(raw: unknown): number | undefined;
export declare function resolveNextPlanArtifactVersion(workspacePath: string, planId: string): number;
/** Digest for idempotency per PLANNER_COMMANDS §7 (normalized body, planId, target version). */
export declare function planArtifactDraftPersistDigest(artifact: PlanArtifactV1, targetVersion: number): string;
export type PlanArtifactDraftPersistPrelude = {
    kind: "replay";
    artifact: PlanArtifactV1;
    storagePath: string;
    paths: PlanArtifactStoragePaths;
} | {
    kind: "conflict";
    code: "plan-artifact-version-conflict" | "idempotency-key-conflict";
    message: string;
} | {
    kind: "commit";
    targetVersion: number;
    digest: string;
};
export declare function preludePlanArtifactDraftPersist(args: {
    workspacePath: string;
    artifact: PlanArtifactV1;
    artifactRaw: unknown;
    clientMutationId?: string;
    effectiveConfig?: Record<string, unknown>;
    sqliteDb?: Database.Database;
}): PlanArtifactDraftPersistPrelude;
export type CommitPlanArtifactDraftPersistResult = {
    artifact: PlanArtifactV1;
    paths: PlanArtifactStoragePaths;
    storagePath: string;
};
/** Write artifact file + index; record idempotency when `clientMutationId` is set. */
export declare function commitPlanArtifactDraftPersist(args: {
    workspacePath: string;
    artifact: PlanArtifactV1;
    clientMutationId?: string;
    digest: string;
    effectiveConfig?: Record<string, unknown>;
    sqliteDb?: Database.Database;
}): CommitPlanArtifactDraftPersistResult;
export declare function planArtifactDraftPersistSuccessResult(args: {
    code: "plan-artifact-draft-persisted" | "plan-artifact-draft-idempotent-replay";
    artifact: PlanArtifactV1;
    storagePath: string;
    replayed: boolean;
}): ModuleCommandResult;
