/**
 * PatchDiscovery — read-only patch chain traversal helpers.
 *
 * Extracted from PatchController: lamport resolution, patch chain loading,
 * writer discovery, and tick enumeration. All methods are pure reads
 * against persistence — no state mutations.
 *
 * @module domain/services/controllers/PatchDiscovery
 */
import type Patch from '../../types/Patch.ts';
import type { CorePersistence } from '../../types/WarpPersistence.ts';
import type LoggerPort from '../../../ports/LoggerPort.ts';
import type PatchJournalPort from '../../../ports/PatchJournalPort.ts';
import type CodecPort from '../../../ports/CodecPort.ts';
import type BlobStoragePort from '../../../ports/BlobStoragePort.ts';
import type CommitMessageCodecPort from '../../../ports/CommitMessageCodecPort.ts';
/**
 * The host surface that PatchDiscovery reads from.
 *
 * Documents the exact WarpRuntime fields accessed during patch-chain
 * traversal, enabling lightweight mocks in unit tests.
 *
 * TODO(0025B1): `_codec` points at `CodecPort` which today parameterizes
 * decode loosely. When cycle 0025B1 lands `CodecPort<T>` /
 * `DecoderPort<T>`, the downstream callers that hydrate a Patch out
 * of the decoded value can drop their parser indirection.
 */
export interface PatchDiscoveryHost {
    readonly _graphName: string;
    readonly _persistence: CorePersistence;
    readonly _maxObservedLamport: number;
    readonly _codec: CodecPort;
    readonly _logger: LoggerPort | null;
    readonly _patchJournal: PatchJournalPort | null | undefined;
    readonly _blobStorage: BlobStoragePort | null | undefined;
    readonly _patchBlobStorage: BlobStoragePort | null | undefined;
    readonly _commitMessageCodec: CommitMessageCodecPort;
}
export interface LamportResult {
    lamport: number;
    parentSha: string | null;
}
export interface PatchEntry {
    patch: Patch;
    sha: string;
}
export interface PerWriterTicks {
    ticks: number[];
    tipSha: string | null;
    tickShas: Record<number, string>;
}
export interface DiscoverTicksResult {
    ticks: number[];
    maxTick: number;
    perWriter: Map<string, PerWriterTicks>;
}
/**
 * Read-only patch-chain traversal. No state mutations.
 */
export declare class PatchDiscovery {
    private readonly _host;
    constructor(host: PatchDiscoveryHost);
    /**
     * Gets the next lamport timestamp for a specific writer ref.
     */
    nextLamportFor(writerRef: string): Promise<LamportResult>;
    private _nextLamportForWriter;
    /**
     * Loads a patch chain walking backwards from a tip SHA.
     * Returns patches in chronological order (oldest first).
     */
    loadPatchChainFromSha(tipSha: string, stopAtSha?: string | null): Promise<PatchEntry[]>;
    /**
     * Loads all patches from a writer's ref chain.
     */
    loadWriterPatches(writerId: string, stopAtSha?: string | null): Promise<PatchEntry[]>;
    /**
     * Discovers all writers that have written to this graph.
     */
    discoverWriters(): Promise<string[]>;
    /**
     * Discovers all distinct Lamport ticks across all writers.
     */
    discoverTicks(): Promise<DiscoverTicksResult>;
}
