/**
 * `GET/POST/DELETE /api/trails` — saved trails, the reader's own tours through
 * the graph (design spec §3.12).
 *
 * A trail is the path of symbols someone walked to explain something: "how a
 * request is served", "everything the token expiry touches". The viewer already
 * carries one in the URL; this is the same walk given a name and kept, so the
 * next person — or the same person next week — starts at the explanation rather
 * than at the search box.
 *
 * ## The one thing this feature has to get right
 *
 * **A trail must survive a re-index.** A node's id contains its start line, so
 * inserting an import at the top of a file renames every symbol below it. A
 * trail keyed on ids would break the first time anybody edited the code it
 * describes — which is exactly when it matters. So a hop is stored as what it
 * *is* — qualified name, kind, file — with the id kept only as a fast path, and
 * every hop is re-resolved against the current index on the way out:
 *
 * - the recorded id still names the same symbol → `ok`
 * - the qualified name resolves somewhere else → `moved`, and the row says
 *   where from
 * - the name is now carried by several symbols and none is in the recorded
 *   file → `ambiguous`, best guess offered and labelled as one
 * - nothing answers to it → `missing`, and the row says "moved or renamed"
 *
 * Nothing is silently dropped and nothing is silently guessed: a trail that has
 * decayed says so on its own row, which is the point at which its author can
 * fix it.
 *
 * ## What it opens
 *
 * A trail with a hole in it cannot be handed to the viewer whole — the `t`
 * param is a PATH, and stitching hop 2 to hop 4 would draw an adjacency that
 * does not exist. So the payload carries the longest run of consecutive
 * resolved hops, and the row says when that is less than the whole trail.
 *
 * Storage — the only write `codegraph ui` makes — is `./trail-store.ts`.
 */
import type { CodeGraph } from '../../index';
import { type StoredHop, type StoredHopDirection, type StoredTrail } from './trail-store';
/** How a saved hop fared against the current index. */
export type WireTrailHopStatus = 'ok' | 'moved' | 'ambiguous' | 'missing';
export interface WireTrailHop {
    dir: StoredHopDirection;
    /** The name as it was when the trail was saved. */
    name: string;
    qualifiedName: string;
    kind: string;
    /** Where the symbol was when the trail was saved. */
    savedFile: string;
    savedLine: number;
    status: WireTrailHopStatus;
    /** The symbol's id NOW. Null when nothing answers to it any more. */
    id: string | null;
    file: string | null;
    line: number | null;
    /** Finished screen wording for a status that is not `ok`; null when it is. */
    note: string | null;
}
export interface WireTrail {
    id: string;
    name: string;
    note: string;
    author: string;
    createdAt: string;
    updatedAt: string;
    hops: WireTrailHop[];
    /** Hops that still resolve to a symbol in this index. */
    resolved: number;
    /** Every hop resolved, and none of them moved. */
    intact: boolean;
    /**
     * The longest run of CONSECUTIVE resolved hops, encoded as the `t` param.
     * Null when nothing in the trail resolves. Never stitched across a hole: the
     * trail is a path, and a fabricated adjacency is worse than a short one.
     */
    encoded: string | null;
    /** 1-based index of the first hop `encoded` carries. */
    openFrom: number;
    /** How many hops `encoded` carries. */
    openCount: number;
    /** The symbol the trail opens at — the last hop of that run. */
    openId: string | null;
}
export interface WireTrails {
    trails: WireTrail[];
    /** Writes are off. The viewer hides Save and Delete, and says why. */
    readOnly: boolean;
    readOnlyReason: string | null;
    /** Project-relative directory the files live in. The screen names it. */
    directory: string;
    /** Files in that directory that were not readable trails. */
    skipped: number;
    /** The list stopped at {@link MAX_TRAILS}. */
    bounded: boolean;
    /** The id just written, on the answer to a POST. */
    saved?: string;
    /** That POST replaced a trail of the same name. */
    replaced?: boolean;
    /** The id just removed, on the answer to a DELETE. */
    deleted?: string;
}
/**
 * Re-resolve one saved hop against the index as it is now.
 *
 * Order matters: the recorded id first, because in the common case (nothing
 * above the symbol changed) it is one lookup and exactly right. It is still
 * verified against the qualified name — an id is a hash of position as well as
 * identity, and a recycled one pointing at a different symbol would put a
 * stranger in the middle of somebody's explanation.
 */
export declare function resolveHop(cg: CodeGraph, hop: StoredHop): WireTrailHop;
/**
 * Turn resolved hops into something the viewer can open.
 *
 * The longest CONSECUTIVE run, not every resolved hop: skipping a missing hop
 * would encode a step from A to C that no edge supports, and the Flow strip
 * reads a trail as exactly that sequence of edges. The first hop of the run is
 * always written as `start`, because a run beginning mid-trail arrived from
 * nothing the viewer can draw.
 */
export declare function encodeResolvedRun(hops: readonly WireTrailHop[]): {
    encoded: string | null;
    openFrom: number;
    openCount: number;
    openId: string | null;
};
export declare function resolveTrail(cg: CodeGraph, stored: StoredTrail): WireTrail;
export interface TrailsOptions {
    /** Writes refused, and the sentence saying why. */
    readOnly: boolean;
    readOnlyReason: string | null;
}
export declare function buildTrails(cg: CodeGraph, projectRoot: string, options: TrailsOptions): WireTrails;
/** What a POST body has to be. Everything else about a hop comes from the graph. */
export interface SaveTrailRequest {
    name: string;
    note?: string;
    hops: Array<{
        dir?: string;
        id: string;
    }>;
}
/**
 * Save a trail.
 *
 * The client sends ids and directions and nothing else: the name, kind, file
 * and line of every hop are read out of the index here. A client that supplied
 * its own metadata could save a trail describing symbols that are not in the
 * graph, and the whole value of the feature is that a trail is a claim the
 * index can re-check.
 *
 * A save under a name that already exists REPLACES that trail, keeping its
 * `createdAt`. That is what pressing Save with the same name means, and the
 * answer says `replaced` so the screen can too.
 */
export declare function saveTrail(cg: CodeGraph, projectRoot: string, body: unknown, options: TrailsOptions): WireTrails;
export declare function removeTrail(cg: CodeGraph, projectRoot: string, id: string, options: TrailsOptions): WireTrails;
export declare function trailAuthor(projectRoot: string): string;
/** Test seam: forget the cached author. */
export declare function resetTrailAuthor(): void;
//# sourceMappingURL=trails.d.ts.map