/** * Relocated-store guard — never CREATE an empty project store where a project * used to live (T12558). * * After `cleo project reroot` the old root has no `.cleo/`. A command run there, * or after `git checkout -- .` restores the tracked `.cleo/project-id`, would * otherwise open `/.cleo/cleo.db` fresh: an empty store, every read * answering "nothing" with `success: true`. This guard runs on the physical * open, only when the project store file does not exist yet, and refuses with * `E_PROJECT_MOVED` when either: * * - the old root carries the reroot tombstone (`.cleo-moved.json`), or * - the declared id's location at this path is `missing` in the registry and * the registry row names another path that exists — the project is live * somewhere else on this device. * * A `candidate` location (a clone that declares a registered id) is NOT refused: * a clone legitimately starts with an empty store of its own (T12470). * * @task T12558 */ import { type ProjectMovedEvidence } from '../project-tombstone.js'; /** A root a project was relocated away from, and the proof. */ export interface RelocatedRoot { /** The relocated project. */ projectId: string; /** Its live root now. */ movedTo: string; /** What proved it: a valid tombstone, or the registry (reroot geometry). */ via: ProjectMovedEvidence; } /** * Detect whether `root` is a directory a project was rerooted away from. * Read-only. * * @param root - Candidate project root. * @param globalDbPath - The global registry store path. * @returns The relocation, or `null` when `root` may hold a store. * * @example * ```ts * const moved = detectRelocatedRoot('/work/mono', globalDbPath); * ``` */ export declare function detectRelocatedRoot(root: string, globalDbPath: string): RelocatedRoot | null; /** * Let THIS process create a store at `root` even though it is a relocated * root — the explicit, audited opt-out behind `cleo init --here`. * * @param root - The root the operator adopted. * * @example * ```ts * allowStoreAtRelocatedRoot('/work/mono'); * ``` */ export declare function allowStoreAtRelocatedRoot(root: string): void; /** * Refuse to create a project store where a project used to live. * * @param dbPath - The project-scope store path about to be opened. * @param globalDbPath - The global registry store path. * @throws CleoError (`E_PROJECT_MOVED`, exit PROJECT_MOVED) naming the new root. * * @example * ```ts * assertStoreNotRelocated('/work/mono/.cleo/cleo.db', '/home/u/.local/share/cleo/cleo.db'); * ``` */ export declare function assertStoreNotRelocated(dbPath: string, globalDbPath: string): void; //# sourceMappingURL=relocated-store-guard.d.ts.map