/**
 * TransferOrchestrator — drives a planned session handoff through the §L3/§L5
 * ordered sequence: active(S) → transferring(e+1) → [drain, flush ledger, target
 * pulls+verifies] → active(T, e+2) → S-release. Claim-before-release, fenced by
 * (status, epoch): there is no double-run (only one machine is `active` at the top
 * epoch) and no no-owner gap (`transferring` still names S as the draining owner).
 *
 * The orchestrator enforces the two §L5 timing contracts:
 *  - Drain bound (`transferDrainTimeoutMs`): a long reply/tool-call must NOT block a
 *    transfer; on timeout the source abandons its partial output (NOT emitted).
 *  - Output exclusion (`transferOutputCutoffMs`): T holds its CONTINUATION until the
 *    cutoff has elapsed since the `transferring` write, so S's drain window and T's
 *    emission window are disjoint by construction — exactly one continuation per turn.
 *
 * All I/O (CAS, drain, ledger flush, mesh transfer, claim, clock) is injected so the
 * sequence + timing logic is deterministic and unit-testable; the real wiring (real
 * SessionMigrator drain, real git ledger flush, real mesh client) lands in Track H.
 */
export type LedgerEntryStatus = 'reply_committed' | 'cursor_advanced' | 'in_flight';
export interface LedgerSnapshot {
    sessionKey: string;
    generatedAt: number;
    entries: Array<{
        messageId: string;
        status: LedgerEntryStatus;
        replyMarker?: string;
        updatedAt: number;
    }>;
    snapshotSha256: string;
}
/**
 * Verify a ledger snapshot at the transfer handoff (§L5): the SHA256 must match the
 * SyncManifest-covered value AND every entry must be terminal (nothing `in_flight`).
 * An `in_flight` entry means a turn was still processing at flush time — the target
 * must NOT resume from it (it waits for a terminal re-flush, or treats it as the
 * interrupted-drain case on failover). Pure.
 */
export declare function verifyLedgerSnapshot(snapshot: LedgerSnapshot, expectedSha256: string, computeSha256: (s: LedgerSnapshot) => string): {
    ok: true;
} | {
    ok: false;
    reason: 'sha-mismatch' | 'in-flight-entry';
};
export interface TransferRequest {
    sessionKey: string;
    source: string;
    target: string;
    reason: 'pin' | 'rebalance' | 'failover';
    /** Whether the source machine is alive (planned transfer) or gone (failover). */
    sourceAlive: boolean;
    /** The ownership epoch the orchestrator observed before starting. */
    baseEpoch: number;
}
export interface TransferOrchestratorConfig {
    transferDrainTimeoutMs: number;
    transferOutputCutoffMs: number;
}
export declare const DEFAULT_TRANSFER_CONFIG: TransferOrchestratorConfig;
export interface TransferOrchestratorDeps {
    /** CAS the record source→transferring(epoch+1). */
    casToTransferring: (sessionKey: string, target: string, expectedEpoch: number) => {
        ok: boolean;
        epoch: number;
    };
    /** Quiesce + drain the in-flight reply on the source, bounded by timeoutMs. */
    drain: (sessionKey: string, timeoutMs: number) => Promise<{
        drained: boolean;
        abandonedPartial: boolean;
    }>;
    /** Source flushes its ledger snapshot synchronously (returns the snapshot + its ref). */
    flushLedger: (sessionKey: string) => Promise<{
        snapshot: LedgerSnapshot;
        ledgerSnapshotRef: string;
        syncManifestRef: string;
    }>;
    /** Send the transfer MeshRpc to the target; the target pulls + verifies the snapshot. */
    sendTransferRpc: (target: string, refs: {
        sessionKey: string;
        ledgerSnapshotRef: string;
        syncManifestRef: string;
    }) => Promise<{
        ok: boolean;
        verified: boolean;
        reason?: string;
    }>;
    /** Target CASes itself to active(owner=T, epoch+2). */
    targetClaim: (sessionKey: string, expectedEpoch: number) => {
        ok: boolean;
        epoch: number;
    };
    /** Cleanup: source releases (NOT a precondition for T's claim — runs after). */
    releaseSource: (sessionKey: string) => void;
    /** Raise a deduped Attention item on sync corruption / unrecoverable handoff. */
    raiseAttention?: (title: string, body: string) => void;
    now: () => number;
    sleep: (ms: number) => Promise<void>;
    log?: (line: string) => void;
}
export type TransferStatus = 'transferred' | 'aborted-cas-lost' | 'sync-corrupted' | 'target-claim-failed';
export interface TransferOutcome {
    ok: boolean;
    status: TransferStatus;
    drainAbandoned?: boolean;
    finalEpoch?: number;
    detail?: string;
}
export declare class TransferOrchestrator {
    private readonly deps;
    private readonly cfg;
    constructor(deps: TransferOrchestratorDeps, cfg?: TransferOrchestratorConfig);
    transfer(req: TransferRequest): Promise<TransferOutcome>;
}
//# sourceMappingURL=TransferOrchestrator.d.ts.map