import type { SessionStorage } from "../session.js";
/** The entries this prepare appended through the watched storage — recorded once a branch is armed (`ids` set). */
export interface OwnAppends {
    ids: Set<string> | undefined;
}
/** The branch a `resumeAt` acquire wrote: the watched storage, the leaf the request found, the leaf it set, and the own appends since. */
export interface ResumeAtBranch {
    storage: SessionStorage;
    leafBefore: string | null;
    leafSet: string | null;
    own: OwnAppends;
}
/**
 * Wrap a storage so a `SessionError("conflict")` from any append/leaf write flips `ref.hit`, and every append
 * that lands is recorded on `own` while a branch is armed. The harness flattens a mid-run storage failure into
 * a generic error (and, since a lost CAS makes every subsequent append fail, even its failure-reporting append
 * fails) — so the conflict code is gone by the time the task result is assembled. Catching it here, at the
 * storage boundary, keeps it recoverable as `TaskResult.errorCode = "conflict"`. Per-task and non-mutating (a
 * Proxy over the shared storage), so it never stacks across tasks on a cached session.
 */
export declare function detectConflicts(storage: SessionStorage, ref: {
    hit: boolean;
}, own: OwnAppends): SessionStorage;
/**
 * Put a refused prepare's `resumeAt` branch back: the leaf returns to `leafBefore` when it still sits on the
 * branch leaf or on this prepare's own appends above it, and the write is conditional on the leaf just
 * verified. A no-op when the leaf is already there. Throws a sentence naming both leaves when the leaf is
 * not this request's to take back or the write cannot land. `signal` aborted before the write starts ⇒ no
 * write (the caller's bound expired and the view is being dropped); a storage write already in flight cannot
 * be called back — the storage contract carries no cancellation.
 */
export declare function writeBranchBack(branch: ResumeAtBranch, sessionId: string, signal?: AbortSignal): Promise<void>;
/**
 * The session cleanup's write-back leg: {@link writeBranchBack} bounded like every other cleanup leg (a throw or
 * a timeout goes to `report`, never to the caller). A write-back still pending when the bound expires does not
 * START its write afterwards — the view it would write through is being dropped.
 */
export declare function settleBranchWriteBack(branch: ResumeAtBranch, sessionId: string, label: string, report: (err: Error) => void): Promise<void>;
