/**
 * Where saved trails live on disk — the only thing `codegraph ui` ever writes.
 *
 * Every other module under `api/` is a reader. This one holds the single write
 * path in the whole viewer, and it is scoped as narrowly as a write can be: one
 * directory, `<CODEGRAPH_DIR>/ui/trails/`, inside the project the server was
 * started on, one JSON file per trail. It never touches source, never touches
 * the index, and never writes anywhere a `codegraph init` would not already
 * have created. `.codegraph/.gitignore` ignores everything but itself, so a
 * saved trail is local by default; exporting one to commit is a copy the reader
 * makes deliberately.
 *
 * Two rules hold it inside the boundary described in `../security.ts`:
 *
 * - **The directory is resolved through `resolveProjectFile`**, exactly like a
 *   source read, so a trail id that tried to be a path is refused by the same
 *   chokepoint that refuses `?file=../../.ssh/id_rsa`. It is belt and braces on
 *   top of {@link isTrailId}, which already refuses anything but a slug.
 * - **A write is atomic.** Temp file in the same directory, then rename. A
 *   half-written trail read back by the list would look like a corrupt one, and
 *   the list would then have to decide whether to hide it — which is a decision
 *   nobody should have to make about a file they saved a second ago.
 *
 * The format is deliberately plain: a reader can open one in an editor, and a
 * hop is described by what it IS (a qualified name in a file) rather than by the
 * node id it happened to have. Node ids contain a start line, so any edit above
 * a symbol renames it — a trail keyed on ids would not survive its own project.
 */
/** Where trails live, relative to the project root. Forward slashes always. */
export declare const TRAILS_RELATIVE_DIR: string;
/** The only `version` this build writes, and the only one it reads. */
export declare const TRAIL_FORMAT_VERSION = 1;
/** Trail files read from the directory before the list stops looking. */
export declare const MAX_TRAILS = 200;
/** Hops one trail may carry. Past this it is a history, not a tour. */
export declare const MAX_TRAIL_HOPS = 64;
/** Characters in a trail's name. */
export declare const MAX_TRAIL_NAME = 120;
/** Characters in a trail's note. */
export declare const MAX_TRAIL_NOTE = 600;
/** Bytes a single trail file may be before it is skipped as not-ours. */
export declare const MAX_TRAIL_FILE_BYTES: number;
/** How a reader got from the previous hop to this one. Mirrors the viewer's `HopDirection`. */
export type StoredHopDirection = 'start' | 'down' | 'up';
/**
 * One hop, described by what it is rather than by the id it had.
 *
 * `id` is kept as a HINT — when the file has not changed it resolves in one
 * lookup — but `qualifiedName` + `kind` + `file` is what the trail is actually
 * keyed on, and what lets it survive a re-index.
 */
export interface StoredHop {
    dir: StoredHopDirection;
    name: string;
    qualifiedName: string;
    kind: string;
    /** Project-relative, forward slashes. */
    file: string;
    line: number;
    /** The node id at save time. A fast path, never the identity. */
    id: string;
}
export interface StoredTrail {
    version: number;
    /** Slug, and the file's basename. */
    id: string;
    name: string;
    note: string;
    /** Whoever saved it — git's `user.name`, or the OS user. */
    author: string;
    createdAt: string;
    updatedAt: string;
    hops: StoredHop[];
}
/**
 * Whether a string is a trail id we would have written.
 *
 * Lowercase slug characters only: no dot, no separator, no leading dash. This
 * is what makes `<id>.json` a filename rather than a path expression, and it
 * runs before the id is ever joined to anything.
 */
export declare function isTrailId(value: string): boolean;
/**
 * `Read a file with these lines` -> `read-a-file-with-these-lines`.
 *
 * Names that carry no ASCII letters or digits at all (a trail named entirely in
 * Chinese, or in emoji) slug to nothing; they get `trail`, and the collision
 * handling in {@link saveTrail} keeps them distinct from each other.
 */
export declare function slugify(name: string): string;
/** The absolute trails directory, having been through the read chokepoint. */
export declare function trailsDirectory(projectRoot: string): string;
/**
 * The absolute path of one trail file.
 *
 * @throws {ApiError} `bad-request` when the id is not a slug we would have
 *   written — checked before the join, so nothing path-shaped is ever built.
 */
export declare function trailPath(projectRoot: string, id: string): string;
/**
 * Parse a file into a trail, or `null` if it is not one.
 *
 * Everything is re-validated rather than trusted: the directory is a place a
 * user may hand-edit a file, or drop one somebody else exported, and a trail
 * that half-parsed would draw a row with holes in it. A file that fails is
 * skipped and counted, never repaired in place.
 */
export declare function parseTrail(id: string, text: string): StoredTrail | null;
export interface StoredTrailList {
    trails: StoredTrail[];
    /** Files in the directory that were not readable trails. */
    skipped: number;
}
/**
 * Every trail in the project, newest save first.
 *
 * A missing directory is the ordinary state of a project nobody has saved a
 * trail in — an empty list, never an error.
 */
export declare function listStoredTrails(projectRoot: string): StoredTrailList;
/** One trail by id, or `null` when there is no such file. */
export declare function readStoredTrail(projectRoot: string, id: string): StoredTrail | null;
/**
 * Write a trail, atomically.
 *
 * Temp file beside the target then `rename`, so a reader either sees the
 * previous trail or the new one and never a partial file. The temp name carries
 * the pid: two `codegraph ui` processes on one project is unusual but not
 * forbidden, and two writers sharing a temp name would corrupt each other's.
 */
export declare function writeStoredTrail(projectRoot: string, trail: StoredTrail): void;
/** Remove a trail. Returns false when there was nothing there. */
export declare function deleteStoredTrail(projectRoot: string, id: string): boolean;
/**
 * An id nothing in `taken` is using, preferring the plain slug.
 *
 * A save under a name that is already there REPLACES it — that is what a reader
 * pressing Save with the same name means — so the caller passes the ids of
 * trails carrying a *different* name, and this only steps aside for those.
 */
export declare function uniqueTrailId(base: string, taken: ReadonlySet<string>): string;
//# sourceMappingURL=trail-store.d.ts.map