/**
 * Cross-call source dedup for `codegraph_explore` (CG-18).
 *
 * The session record (CG-17) knows what earlier calls already sent. This module
 * is the algebra that turns that record into a decision for the call being
 * rendered: of the line ranges this call WOULD emit, which does the agent
 * already hold, and what is genuinely new.
 *
 * Three rules shape everything here, and all three come from the same place —
 * an insufficient-feeling response is what sends an agent to Read, and one or
 * two of those early in a session teach it to abandon codegraph entirely
 * (CLAUDE.md):
 *
 *   1. **A pointer, never a bare omission.** Removed source is replaced by a
 *      back-reference naming the file, the symbols, and the line span, worded so
 *      it is unmistakable that the source was already delivered IN THIS
 *      CONVERSATION and is still current. Silence reads as "codegraph didn't
 *      find it".
 *   2. **Only prove-it dedup.** A span is withheld only when the file's bytes
 *      are byte-identical to what was served (a content fingerprint, not an
 *      mtime and not the index's drift flag). An edit between calls means the
 *      agent's copy is wrong, so the source is re-emitted in full.
 *   3. **Cut chunks, not slivers.** Only a covered run of at least
 *      {@link EXPLORE_DEDUP.MIN_COVERED_LINES} lines is worth replacing. Below
 *      that the pointer costs more than the source, and shattering a block into
 *      one-line fragments produces exactly the ragged output that reads as a
 *      failure. Everything not withheld is emitted — where the algebra is
 *      unsure, it re-serves.
 *
 * Which way to be wrong, restated for this layer: re-serving something the agent
 * has is a few hundred wasted chars; withholding something it never saw is a
 * Read. Every threshold below leans to the first.
 */
import type { ExploreLineRange, ExploreProjectState } from './explore-session-state';
export declare const EXPLORE_DEDUP: {
    /**
     * Shortest already-served run that may be replaced by a back-reference.
     *
     * Sized against what dedup is actually FOR — a later call re-serving a whole
     * method or file it already sent. A shorter covered run is either a signature
     * line in a skeleton render or the ±3 lines of context padding around a
     * cluster, and swapping either for a pointer trades bytes for noise: the
     * pointer sentence is itself ~140 chars, so under this length dedup would
     * make the response BIGGER while making it read as full of holes.
     */
    readonly MIN_COVERED_LINES: 8;
    /**
     * Below this many chars of NEW source, a file's remainder is folded into its
     * back-reference instead of being fenced on its own.
     *
     * The shape this exists for, seen on the CG-17 fixture: a third call whose
     * only unheld line was the file's trailing blank one, rendered as a code fence
     * containing `228\t`. A fence holding two lines of nothing reads as a broken
     * response, and reading as broken is the expensive failure — it is the thing
     * that sends an agent to Read and keeps it there. So a remainder this small is
     * dropped rather than shown. It is the one place this module withholds
     * something the agent has not seen, and it is bounded to ~two lines that sit
     * directly against source the agent does hold; the file is still named, with
     * its symbols, so one follow-up explore fetches it whole.
     */
    readonly MIN_DELTA_CHARS: 160;
    /** Line spans named in one pointer before it summarises the rest. */
    readonly MAX_SPANS_IN_POINTER: 4;
    /** Symbols named in one pointer before it summarises the rest. */
    readonly MAX_SYMBOLS_IN_POINTER: 5;
};
/**
 * Kill switch: `CODEGRAPH_EXPLORE_DEDUP=0` renders every call as if the session
 * had no history. Read per call (not memoized) so a test can toggle it.
 */
export declare function exploreDedupEnabled(): boolean;
/**
 * Identity of the bytes a call served for one file.
 *
 * This — not the index's drift flag — is what gates dedup. `isFileStaleOnDisk`
 * answers "did the file change since the last INDEX SYNC", which is a different
 * question with a different answer: two calls inside one drift window served the
 * same current bytes (dedup is correct), while a file edited and re-synced
 * between two calls is never "stale" and yet the agent's copy is now wrong
 * (dedup would be actively harmful). Length is prefixed so a hash prefix
 * collision cannot alias two files of different size.
 */
export declare function fileFingerprint(content: string): string;
/** Sort + merge overlapping/adjacent spans into the smallest equivalent set. */
export declare function mergeRanges(ranges: ReadonlyArray<ExploreLineRange>): ExploreLineRange[];
/** The parts of `range` that `served` covers. */
export declare function intersectRange(range: ExploreLineRange, served: ReadonlyArray<ExploreLineRange>): ExploreLineRange[];
/** The parts of `range` that `cut` does NOT cover. */
export declare function subtractRange(range: ExploreLineRange, cut: ReadonlyArray<ExploreLineRange>): ExploreLineRange[];
/** What one intended span becomes once the session's history is applied. */
export interface RangeDedup {
    /** Spans to render now — everything not proven-already-held. */
    emit: ExploreLineRange[];
    /** Spans replaced by a back-reference. */
    covered: ExploreLineRange[];
}
/**
 * Split one intended span into what to emit and what to point back at.
 *
 * Covered runs shorter than {@link EXPLORE_DEDUP.MIN_COVERED_LINES} are left in
 * the emit set on purpose (rule 3 above) — so a span the agent holds "almost
 * all of" still comes back whole rather than as a stutter of fragments around
 * pointers.
 */
export declare function dedupeRange(range: ExploreLineRange, served: ReadonlyArray<ExploreLineRange>, minCovered?: number): RangeDedup;
/**
 * Every line span this session has already served for one file, but ONLY from
 * calls that served the SAME BYTES.
 *
 * A record with no fingerprint is ignored rather than trusted: it cannot prove
 * the agent's copy matches the file on disk now, and an unprovable match is
 * exactly the case where re-serving is right.
 */
export declare function servedRangesForFile(prior: ExploreProjectState | null, filePath: string, fingerprint: string): ExploreLineRange[];
/** `L12`, `L12-40`, capped with a `+N more` tail. */
export declare function formatSpans(spans: ReadonlyArray<ExploreLineRange>): string;
/**
 * The line that replaces withheld source.
 *
 * It has one job: make the agent reach into its own context instead of into
 * Read. So it carries the three things needed to find the source it already has
 * — path, symbols, line spans — plus the two facts that make using it safe:
 * that it came from THIS conversation, and that the file has not changed since
 * (which is checked, not asserted — see {@link fileFingerprint}). It never says
 * "omitted", and it never steers to Read.
 */
export declare function formatBackReference(filePath: string, covered: ReadonlyArray<ExploreLineRange>, symbols: ReadonlyArray<string>, opts: {
    partial: boolean;
}): string;
/** Symbol names whose definitions fall inside the withheld spans. */
export declare function symbolsInSpans(nodes: ReadonlyArray<{
    name: string;
    kind: string;
    startLine: number;
    endLine: number;
}>, spans: ReadonlyArray<ExploreLineRange>): string[];
//# sourceMappingURL=explore-dedup.d.ts.map