/**
 * WormholeService - Wormhole Compression for WARP Graphs
 *
 * Implements wormhole compression from Paper III (Computational Holography):
 * Compress multi-tick segments into single edges carrying sub-payloads.
 *
 * A wormhole is a compressed representation of a contiguous range of patches
 * from a single writer. It preserves provenance by storing the original
 * patches as a ProvenancePayload that can be replayed during materialization.
 *
 * ## Key Properties
 *
 * - **Provenance Preservation**: The wormhole contains the full sub-payload,
 *   allowing exact replay of the compressed segment.
 * - **Monoid Composition**: Two consecutive wormholes can be composed by
 *   concatenating their sub-payloads.
 * - **Materialization Equivalence**: A wormhole + remaining patches produces
 *   the same state as materializing all patches.
 *
 * @module domain/services/WormholeService
 */
import ProvenancePayload from './provenance/ProvenancePayload.ts';
import type CommitPort from '../../ports/CommitPort.ts';
import type BlobPort from '../../ports/BlobPort.ts';
import type CodecPort from '../../ports/CodecPort.ts';
import type BlobStoragePort from '../../ports/BlobStoragePort.ts';
import type CommitMessageCodecPort from '../../ports/CommitMessageCodecPort.ts';
import type WarpState from './state/WarpState.ts';
type PersistencePort = CommitPort & BlobPort;
/**
 * Represents a compressed range of patches (wormhole).
 *
 * A WormholeEdge contains:
 * - The SHA of the first (oldest) patch in the range (fromSha)
 * - The SHA of the last (newest) patch in the range (toSha)
 * - The writer ID who created all patches in the range
 * - A ProvenancePayload containing all patches for replay
 */
export interface WormholeEdge {
    /** SHA of the first (oldest) patch commit */
    fromSha: string;
    /** SHA of the last (newest) patch commit */
    toSha: string;
    /** Writer ID of all patches in the range */
    writerId: string;
    /** Sub-payload for replay */
    payload: InstanceType<typeof ProvenancePayload>;
    /** Number of patches compressed */
    patchCount: number;
}
interface CreateWormholeOptions {
    persistence: PersistencePort;
    graphName: string;
    fromSha: string;
    toSha: string;
    commitMessageCodec?: CommitMessageCodecPort;
    codec?: CodecPort;
    blobStorage?: BlobStoragePort;
    patchBlobStorage?: BlobStoragePort;
}
/**
 * Creates a wormhole compressing a range of patches.
 *
 * The range is specified by two patch SHAs from the same writer. The `fromSha`
 * must be an ancestor of `toSha` in the writer's patch chain. Both endpoints
 * are inclusive in the wormhole.
 *
 * @throws {WormholeError} If fromSha or toSha doesn't exist (E_WORMHOLE_SHA_NOT_FOUND)
 * @throws {WormholeError} If fromSha is not an ancestor of toSha (E_WORMHOLE_INVALID_RANGE)
 * @throws {WormholeError} If commits span multiple writers (E_WORMHOLE_MULTI_WRITER)
 * @throws {WormholeError} If a commit is not a patch commit (E_WORMHOLE_NOT_PATCH)
 * @throws {EncryptionError} If patches are encrypted but no patchBlobStorage is provided
 */
export declare function createWormhole({ persistence, graphName, fromSha, toSha, commitMessageCodec, codec, blobStorage, patchBlobStorage, }: CreateWormholeOptions): Promise<WormholeEdge>;
/**
 * Composes two consecutive wormholes into a single wormhole.
 *
 * The wormholes must be consecutive: the first wormhole's toSha must be
 * the parent of the second wormhole's fromSha.
 *
 * This leverages the ProvenancePayload monoid structure:
 * `composed.payload = first.payload.concat(second.payload)`
 *
 * @throws {WormholeError} If wormholes are from different writers (E_WORMHOLE_MULTI_WRITER)
 * @throws {WormholeError} If wormholes are not consecutive (E_WORMHOLE_INVALID_RANGE)
 */
export declare function composeWormholes(first: WormholeEdge, second: WormholeEdge, options?: {
    persistence?: CommitPort;
}): Promise<WormholeEdge>;
/**
 * Replays a wormhole's sub-payload to materialize the compressed state.
 *
 * This is equivalent to materializing all the patches in the wormhole
 * individually. The replay uses CRDT merge semantics as defined in JoinReducer.
 */
export declare function replayWormhole(wormhole: WormholeEdge, initialState?: WarpState): WarpState;
/**
 * Serializes a wormhole to a JSON-serializable object.
 */
export declare function serializeWormhole(wormhole: WormholeEdge): Record<string, unknown>;
/**
 * Deserializes a wormhole from a JSON object.
 *
 * @throws {WormholeError} If the JSON structure is invalid
 */
export declare function deserializeWormhole(json: Record<string, unknown>): WormholeEdge;
declare const _default: {
    createWormhole: typeof createWormhole;
    composeWormholes: typeof composeWormholes;
    replayWormhole: typeof replayWormhole;
    serializeWormhole: typeof serializeWormhole;
    deserializeWormhole: typeof deserializeWormhole;
};
export default _default;
