import { type SyncRequest, type SyncResponse } from '../sync/SyncProtocol.ts';
import SyncTrustGate from '../sync/SyncTrustGate.ts';
import { type ServeOptions, type ServerHandle } from './SyncServerLauncher.ts';
import type SyncHttpClientPort from '../../../ports/SyncHttpClientPort.ts';
import type OperationPolicyPort from '../../../ports/OperationPolicyPort.ts';
import type { SyncHost, ApplySyncResult, SyncRemote, SyncWithResult, SyncWithOptions } from './SyncControllerTypes.ts';
export type { SyncHost, SkippedWriter, ApplySyncResult, SyncWithResult, SyncWithOptions } from './SyncControllerTypes.ts';
export default class SyncController {
    readonly _host: SyncHost;
    readonly _trustGate: SyncTrustGate | null;
    private _httpClient;
    private _operationPolicy;
    constructor(host: SyncHost, options?: {
        trustGate?: SyncTrustGate;
        httpClient?: SyncHttpClientPort;
        operationPolicy?: OperationPolicyPort;
    });
    /**
     * Lazily resolves the sync HTTP client. Defaults to the platform
     * fetch-based adapter, loaded via dynamic import to keep the
     * `from 'infrastructure/*'` wall clean at the module graph level.
     */
    private _resolveHttpClient;
    private _resolveOperationPolicy;
    /** Returns the current frontier — a Map of writerId → tip SHA. */
    getFrontier(): Promise<Map<string, string>>;
    /** Checks whether any writer tip has changed since the last materialize. */
    hasFrontierChanged(): Promise<boolean>;
    /** Returns a lightweight status snapshot. O(writers), no materialization. */
    status(): Promise<{
        cachedState: 'fresh' | 'stale' | 'none';
        patchesSinceCheckpoint: number;
        tombstoneRatio: number;
        writers: number;
        frontier: Record<string, string>;
    }>;
    /** Creates a sync request containing the local frontier. */
    createSyncRequest(): Promise<SyncRequest>;
    /** Processes an incoming sync request and returns patches the requester needs. */
    processSyncRequest(request: SyncRequest): Promise<SyncResponse>;
    /** Applies a sync response to local state, evaluating trust if configured. */
    applySyncResponse(response: SyncResponse): Promise<ApplySyncResult>;
    private _evaluateWriters;
    private _acceptSyncResponseWithoutReading;
    private _applySyncResponseWithGate;
    /** Checks if sync is needed with a remote frontier. */
    syncNeeded(remoteFrontier: Map<string, string>): Promise<boolean>;
    /** Syncs with a remote peer (HTTP or direct graph instance). */
    syncWith(remote: SyncRemote, options?: SyncWithOptions): Promise<SyncWithResult>;
    /**
     * Performs one sync HTTP exchange via the SyncHttpClientPort.
     *
     * Serialization, signing, network I/O, and response decoding all
     * live inside the adapter — this method just converts the port's
     * typed result back into the controller's throw-based idiom (used
     * by the retry loop to decide whether to back off).
     */
    private _fetchSyncResponse;
    /** Starts a built-in sync server for this graph. */
    serve(options: ServeOptions): Promise<ServerHandle>;
}
