/**
 * The tracked-cwd liveness probe and its diagnosis, shared by the three sites that spawn into the tracked
 * logical cwd: the shell's foreground and background legs, and the watch tool's background leg. A second
 * copy of either half would be a second answer to "is this directory usable?" and a second refusal
 * wording for the same fact, so both are minted here once and each leg passes only its own tool name.
 */
import type { ExecutionEnv } from "../../internal/harness-types.js";
/**
 * Is `dir` USABLE as a spawn cwd? "Dead" is the whole class, not just deletion: gone, replaced by a FILE
 * of the same name or standing under one, or a symlink that does not resolve to a directory. `fileInfo`
 * is lstat-semantics, so a symlink is judged by FOLLOWING it (`canonicalPath`, then one probe of the
 * target — a link retargeted at a file resolves perfectly well and is still not a cwd).
 *
 * One reading at every step (the initial lstat, the link's resolution, the target's own): an error means
 * death only when it SAYS so — refusing a command, or resetting somebody's working directory, over one
 * flaky or unclassified answer would be worse than the failure being diagnosed. A link chain that loops
 * says so (`symlink_loop`), and so does a dangling one (`not_found`); a probe that answered `unknown`
 * leaves the spawn to run and report its own error.
 */
export declare function isDeadCwd(env: ExecutionEnv, dir: string, signal?: AbortSignal): Promise<boolean>;
/**
 * Dead-cwd diagnosis for a never-started command (spawn_error / shell_unavailable): a command that
 * DELETED or REPLACED the tracked cwd (e.g. `opam clean` after `cd` into a build dir) leaves the
 * persistent session pinned to a dead directory — every later spawn fails ENOENT/ENOTDIR with a message
 * blaming the SHELL BINARY ("spawn /bin/bash ENOENT"), the model concludes bash is gone, and the run is
 * permanently disabled (TB compile-compcert, 14 contaminated calls). The env can't distinguish this (spawn
 * reports the same code either way), so probe here:
 *  - tracked cwd dead + task root alive → SELF-HEAL: reset the tracked cwd to the root, tell the model
 *    what happened and that a retry works;
 *  - tracked cwd dead + root ALSO dead (never promise a retry that must fail) → honest
 *    unrecoverable verdict;
 *  - cwd IS the root and it's dead (`rm -rf "$PWD"` in place — a diverged-guard would
 *    skip diagnosis entirely) → honest root-gone verdict (no reset target exists);
 *  - the caller knows NO root (`root === undefined` — a direct mount that was never handed one) → say the
 *    cwd is gone and that this tool has no reset target, and stop there. Calling that directory "the task
 *    root" or declaring the tree unrecoverable would both be claims the caller cannot back: the root may
 *    well be alive, and a `cd` to it recovers. Nothing is reset.
 *  - cwd healthy → return undefined (the spawn failure has another cause; keep the original error).
 * Returns the model-facing message, or undefined when this is not a dead-cwd case. Uses only the public
 * env faces (`fileInfo`/`canonicalPath`) — works for any env that maps never-started failures to
 * spawn_error/shell_unavailable (contract note on ExecutionErrorCode).
 *
 * Every sentence states what the probes established — which directory is not there — and never WHY: a previous command, the
 * device moving the task's directory away and an operator's cleanup leave the same probe answer, so naming one of them is a
 * guess handed to the person as a fact. Where no directory is left at all, the sentence ends with the one way on
 * ({@link NO_DIRECTORY_WAY_ON}).
 *
 * `root` is REQUIRED-but-nullable on purpose (not an optional parameter): a caller without a root has to
 * say so at the call site, so "this mount has no root" can never be spelled the same way as "I forgot".
 */
export declare function diagnoseDeadCwd(env: ExecutionEnv, toolName: string, effectiveCwd: string, root: string | undefined, cwdRef?: {
    current: string;
}, signal?: AbortSignal): Promise<string | undefined>;
/** The way on when neither the working directory nor the task root is there: nothing this task runs can bring a directory back, so the
 *  move is outside it — one sentence, read by both arms that end there. */
export declare const NO_DIRECTORY_WAY_ON = "To go on, start a new task, or start this one again pointed at a directory that exists.";
