import { type FileHandle } from "node:fs/promises";
import { type BoundFileObject, type ExecResult, type ExecutionEnv, ExecutionError, type ExecutionEnvExecOptions, FileError, type FileInfo, type Result } from "../harness/types.js";
import { type InheritEnvForm, type SecretEnvFinding } from "../../core/secret-env.js";
import { type EngineNotice } from "../../core/engine-notice.js";
import type { ExecutionEnvModelShell, ExecutionEnvCapabilities, SymlinkChain } from "../harness/types.js";
import { type ShellKindAnswer, type DroppedShellState } from "../../core/model-shell.js";
import type { BackgroundHardKillOutcome, BackgroundShellCapability, BackgroundShellId, BackgroundPoll, BackgroundSpawnOptions } from "../../core/background-shell.js";
import { BackgroundShellError } from "../../core/background-shell.js";
import type { SchedulerCapability, ScheduledIntent, SchedulerContext, ScheduledTaskId, ScheduledTaskSummary } from "../../core/scheduler.js";
import { SchedulerError } from "../../core/scheduler.js";
/** Convert user-facing timeout seconds into a positive, timer-safe millisecond delay. */
export declare function resolveExecTimeoutMs(timeoutSeconds: unknown): number | undefined;
/** review finding (win32): `where bash.exe` can resolve to `System32\bash.exe` — the
 *  WSL LAUNCHER, not a native shell. Running it drops into a Linux subsystem where Windows cwd/paths
 *  do not exist; silently adopting it is exactly the "wrong shell, false green" failure D1 forbids.
 *  Filter it (and the WindowsApps alias) out of PATH discovery; Git-Bash candidates are tried first. */
export declare function isWslBashLauncher(p: string): boolean;
/** Shell discovery for the platform (ask ①: exported as the single SDK source so a host
 *  adapter does not mirror the platform logic). Explicit `customShellPath` wins (missing → err);
 *  win32 = Git-Bash discovery (ProgramFiles → PATH, WSL launcher filtered) with fail-loud
 *  `shell_unavailable` (never a silent cmd.exe fallback); POSIX = /bin/bash → PATH bash → sh. */
export declare function getShellConfig(customShellPath?: string): Promise<Result<{
    shell: string;
    args: string[];
}, ExecutionError>>;
/** What {@link resolveModelShell} looks at: the platform, whether a path exists, whether it is an executable file, the Program Files roots. */
export interface ModelShellCandidateProbe {
    readonly platform: NodeJS.Platform;
    readonly exists: (path: string) => Promise<boolean>;
    readonly executable: (path: string) => Promise<boolean>;
    readonly programFiles: readonly (string | undefined)[];
}
/** Where a start runs: the environment's working directory and the PATH its child receives. */
export interface ModelShellPlace {
    readonly cwd: string;
    readonly searchPath: readonly string[];
}
/** The entries of the PATH a composed child environment holds, as `platform` reads it: the name compared as the platform compares
 *  names (win32 case-blind: `Path`), the list split on the platform's separator (`;` on win32, `:` elsewhere); `[]` when there is none. */
export declare function modelShellSearchPath(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): readonly string[];
/** One candidate asked what it is ({@link SHELL_KIND_QUESTION}), once per environment: the absolute program (what makes the asked
 *  and the started one the same), in the environment's own cwd (not a call's — the question is asked before any call), in the fixed
 *  least environment {@link shellKindQuestionEnv} reads out of this process's own as the scrub hands it on when the question is asked
 *  (no `shellEnv`, no earlier snapshot), stdin closed, five seconds — settled at the bound, its pipe closed then (a descendant
 *  that keeps it holds nothing up) — and only the first {@link SHELL_KIND_ANSWER_KEPT_BYTES} bytes of what it prints kept. Only a run
 *  that ends with status 0 and answers as {@link readShellKindAnswer} reads is an answer. The answer is the program's own report of
 *  what it is. */
export declare function askShellKind(path: string, cwd: string): Promise<ShellKindAnswer>;
/** The program a start for model text runs on, the one that was asked: its absolute path and the shell kind and version it reported. */
export type ResolvedModelShell = {
    readonly path: string;
    readonly shell: ShellKindAnswerOk["shell"];
    readonly version: string;
};
type ShellKindAnswerOk = Extract<ShellKindAnswer, {
    ok: true;
}>;
/** The absolute program a start for model text runs on, the one that was asked, with the shell kind and version it reported: the
 *  host's `shellPath` alone, fixed as one absolute program ({@link programOf}; nothing there keeps {@link getShellConfig}'s sentence),
 *  taken when it answers bash or zsh; else the candidates in order — on win32 Git Bash under each Program Files root, else `/bin/bash`
 *  (each asked when it exists), then `bash` found by the same {@link programOf} on the child's PATH, then (POSIX) `/bin/zsh` and `zsh`
 *  on that PATH — each asked once, its name never trusted. The first that answers bash 3.2 or later is taken; only where none does,
 *  the first that answered zsh (a bash comes first wherever there is one). Never `sh`, never a candidate that is not fully qualified
 *  (a relative `ProgramFiles`); otherwise `shell_unavailable` names each candidate and why. */
export declare function resolveModelShell(shellPath: string | undefined, place: ModelShellPlace, probe?: ModelShellCandidateProbe, ask?: (path: string, cwd: string) => Promise<ShellKindAnswer>): Promise<Result<ResolvedModelShell, ExecutionError>>;
/** test seam (mirrors the notice-seat announce reset): the once-per-process fallback latches. */
export declare function __resetSecretScrubAnnouncement(): void;
/** RB-235: the spool-reclaim decision, extracted PURE so every rule is unit-pinnable.
 *  Both reclaim sites (foreground `reclaimSpool`, background `syncSpool`) route through this one
 *  function so they cannot drift apart.
 *
 *  The hazard: `truncateSync(path, 0)` while the writer is LIVE races its O_APPEND appends — a
 *  buffered write landing between the caller's stat and the truncate is destroyed whole
 *  (stdio-block granularity) and NO reader-side counter ever sees it (`truncated` /
 *  `bytesDroppedBeforeCursor` / `bytesFromStart` all undercount by exactly the raced amount). An
 *  earlier narrowing kept the truncate but moved it to the HARD cap, so live truncations became rare
 *  instead of routine; an external black-box audit of that build still measured whole 8192-byte
 *  blocks disappearing, so rarity was never the fix. Ruled 2026-08-03: drop truncate-under-a-live-
 *  writer entirely.
 *
 *  The rule, in one line: **the file of a writer that can still append is append-only.** While the
 *  writer lives, only the reader's cursor moves; physical reclamation happens after it is terminal.
 *   - writer LIVE                                  → never reclaim (no window exists to lose bytes in);
 *   - writer TERMINAL + fully consumed             → truncate at the ROTATE mark (race-free);
 *   - writer TERMINAL + reader behind at HARD cap  → truncate, byte-accounting the unread remainder
 *     (`skippedBytes` → recordSkippedBytes, the honest `[... N bytes truncated ...]` disclosure).
 *
 *  Cost, stated honestly: a live producer that outruns the reader is no longer capped on disk — its
 *  spool grows for as long as it runs (bounded by the exec timeout / background hard wall, reclaimed
 *  in full at its death). Capping it would mean destroying bytes we cannot count, which is the defect
 *  itself; no portable Node syscall releases the consumed prefix of a file another process is
 *  appending to. The reader stays bounded regardless — `skipAhead` drops the un-retainable middle and
 *  accounts every skipped byte. The same unbounded-while-live posture already holds for the retain
 *  lane (design/128) and for the detached-descendant residual (RB-26), and matches the CC anchor's
 *  shape (named temp files, no rotation at all) with the file never outliving its writer.
 *
 *  RESIDUAL, unchanged by this rule: `writerLive` describes the DIRECT child. A detached descendant
 *  holding the same fd can still append after the child is reaped, so a terminal-writer truncate can
 *  in principle race it — the documented RB-26 posture, and undetectable from this side of the fd. */
export declare function decideSpoolReclaim(args: {
    size: number;
    cursor: number;
    writerLive: boolean;
    rotateBytes?: number;
    hardCapBytes?: number;
}): {
    reclaim: false;
} | {
    reclaim: true;
    skippedBytes: number;
};
/** design/128 T1-1: open the spool file pair ALL-OR-NOTHING — a failure opening the
 *  second file must close the first fd before rethrowing (the caller's catch only clears its references, so
 *  a half-open pair would leak fdOut for the env's lifetime). `wx` + 0600 (never follow / never reuse an
 *  existing path). Exported for direct fault-injection tests (pre-create a path → EEXIST). `a` (not
 *  `w`): O_APPEND makes every child/descendant write an atomic append at the current end — which is
 *  what lets the foreground quota rotation truncate a fully-consumed file to zero and have the next
 *  write land at offset 0 (a plain-fd writer would keep its own offset and leave an unreadable hole). */
export declare function openSpoolPair(base: string): {
    outPath: string;
    errPath: string;
    fds: [number, number];
};
/** How many dropped variables an environment's {@link NodeExecutionEnv.modelShellDropped} record keeps. */
export declare const MODEL_SHELL_DROPPED_KEPT = 32;
/** The keys of the two shared start routines: module symbols, so no ordinary subclass method takes their place (reflection can still reach them). */
declare const RUN_SHELL: unique symbol;
declare const START_BACKGROUND: unique symbol;
export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCapability, SchedulerCapability {
    cwd: string;
    /** `ExecutionEnv.capabilities`: the engine's own host — commands are this process's children on its own disk, not
     *  contained, not snapshotable; its resolver always answers; it keeps the byte floor exactly when its starts are confined
     *  (`readFloorConfinement: "os"` on a host where the probe applied), and otherwise does not. */
    readonly capabilities: ExecutionEnvCapabilities;
    /** Every start carrying a floor runs under that floor's seatbelt profile (the probe applied at construction). */
    private readonly confined;
    /** Each profile's apply, once per text: `undefined` applied, else the launcher's reason. */
    private readonly profileApplies;
    /** `ExecutionEnv.homeDir` = the `HOME` the shell child receives (its `~`/`$HOME`/`${HOME}` all expand to it unless an inherited absolute `BASH_ENV` or a `shellPath` launcher rebinds `HOME` first — outside this reading), read LIVE off the same `shellEnv`-over-`inheritEnv` merge each exec gets; ABSENT when the
     *  child gets none (an allowlist that withholds it: `~` then falls back to passwd while `$HOME` is empty — two values, no single home, home-relative operands stay fail-closed). Residual: a per-exec `env.HOME` override. */
    get homeDir(): string | undefined;
    /** `ExecutionEnv.cdPath` = the `CDPATH` the shell child receives, read LIVE off the same merge each exec gets (never the
     *  engine process's own environment): its entries, `[]` when the child gets none. Residual: a per-exec `env.CDPATH`. */
    get cdPath(): readonly string[];
    /** `ExecutionEnv.searchPath` = the `PATH` the shell child receives, read LIVE off the same merge each exec gets: its entries,
     *  `[]` when the child gets none. Residual: a per-exec `env.PATH`. */
    get searchPath(): readonly string[];
    /** `ExecutionEnv.receivedEnvNames` = the names a start for model text hands its shell, with no call layer and after the table
     *  ({@link childEnvForRead}, the one composition every name reader here reads), read LIVE; `[]` when no child would be spawned at
     *  all. Residual: a per-exec `env` adding one (the engine's own tools add only `PWD`). */
    get receivedEnvNames(): readonly string[];
    /** `ExecutionEnv.configuredStartupFileNames` = the startup-file variables (`BASH_ENV`, `ENV`) `shellEnv` sets, as written there,
     *  whether or not a start hands them on (this environment's starts do not; a launcher the host configured may set them again). */
    get configuredStartupFileNames(): readonly string[];
    /** `ExecutionEnv.withheldEnv` = what the same merge withholds from the shell child (an entry `shellEnv` re-supplies is
     *  no loss), read LIVE; `[]` when no child would be spawned at all. Residual: a per-exec `env` re-supplying one. */
    get withheldEnv(): readonly SecretEnvFinding[];
    /** The environment the next start for model text would hand its shell, for a READ: the same composition a start makes
     *  ({@link modelShellSpawnEnv}) with no call layer — `shellEnv` without any variable a row of `SHELL_STATE_ENV` holds, over this
     *  process's inheritance, then the host's own variables by each row's rule — recording nothing (the scrub seat is the reader's
     *  collector or a no-op: a read announces nothing). Every name reader above reads this one composition. `undefined` when no child
     *  would be spawned at all — the policy is refused against the own credentials declared since construction, or `shellEnv` is no
     *  grant, and every spawn throws that reason — so a reader sees "the child gets none", never a throw. */
    private childEnvForRead;
    /** The environment a shell child is started with (exec and the background start alike), or the composition's refusal,
     *  thrown for the start's `try`. The allow list was judged and copied at construction, so a refusal of the list itself
     *  can only come from a declaration made since: that one is said in this environment's words and, at the first start it
     *  refuses, once on `onNotice` (`config.inherit_env_declared_late`, `detail: { index, name }`); the notice stays readable as
     *  {@link lateDeclarationNotice}. Every refusal says the whole sentence and carries a bounded restatement of it
     *  (`briefMessage` on the failure it settles as) for a reader that has already shown the sentence. A grant's refusal is the
     *  composition's own sentence, unchanged. */
    private spawnEnv;
    private shellPath?;
    private shellEnv?;
    private inheritEnv;
    /** `ExecutionEnv.inheritEnvForms`: frozen copy of the caller-writable `inheritEnv` forms declared at construction, or absent. */
    readonly inheritEnvForms?: readonly InheritEnvForm[];
    private readonly scheduler?;
    private readonly bgShells;
    private bgCounter;
    private readonly retainBackgroundProcesses;
    private readonly onSecretEnvScrub?;
    private readonly onNotice?;
    /** The `config.inherit_env_declared_late` notice this environment raised: once per environment, at the first start it refuses
     *  (absent until then) — the one value the environment's seat was handed and `lateDeclarationNotice` answers. */
    private lateDeclarationRaised;
    /** `ExecutionEnv.lateDeclarationNotice` — see there. A read: it announces nothing. */
    get lateDeclarationNotice(): EngineNotice | undefined;
    /** design/128 T1-1: the env-owned spool dir (mkdtemp under os tmp — unpredictable, never the cwd). It exists only while
     *  {@link spoolPairs} is non-empty: the last pair's release removes it, the next mint makes a fresh one. */
    private bgSpoolDir?;
    /** The `outPath` of every spool pair this env minted and has not released — the one fact the dir's lifetime reads. A
     *  retain-lane bg pair is never released (its files outlive the run by design), so it keeps the dir. */
    private readonly spoolPairs;
    readonly backgroundCapabilities: BackgroundShellCapability["backgroundCapabilities"];
    constructor(options: {
        cwd: string;
        shellPath?: string;
        shellEnv?: NodeJS.ProcessEnv;
        /** VENDORED EDIT (D1, security): how much of `process.env` the shell child inherits. Default `"scrub"` =
         *  fail-closed (drop secret-pattern keys, keep PATH/build/locale). `"all"` = full inherit (trusted env) but for the
         *  credential names of the engine's own `SEMA_` namespace (the namespace rule: `SEMA_MODEL_KEY_<entry>`,
         *  `SEMA_WEBSEARCH_KEY_<provider>`; the host's explicit grants below re-supply one); `string[]` = strict allowlist.
         *  `shellEnv`/per-exec `env` always pass through (`hostChildEnv`'s grants: one that is
         *  not a map of variable names to strings throws here and at the spawn). Any other value — an unknown
         *  word, a non-string, a list entry that is not a variable name — throws here (`inheritEnvPolicyProblem`'s
         *  reason), the same judgment the oracle gate's `inheritEnv` meets. Whatever the policy, the deployment's own
         *  credentials (`declareWithheldEnv`: by name, and by a value equal to a declared or engine-held credential value)
         *  are withheld from the inherited part; a list naming a declared name throws here when the declaration came
         *  first, and every spawn refuses it (`spawn_error` / `spawn_failed`) whenever it came — a declaration made after
         *  construction in this environment's words, said once on `onNotice` (`config.inherit_env_declared_late`). */
        inheritEnv?: "all" | "scrub" | string[];
        /** Optional declaration of which `inheritEnv` forms this host's callers can write (`INHERIT_ENV_FORMS`). Validated and frozen once here. */
        inheritEnvForms?: readonly InheritEnvForm[];
        /** design/105: inject a resident scheduler daemon backend (the shell daemon). Absent ⇒ scheduling INERT. */
        scheduler?: SchedulerCapability;
        /**
         * design/128 T1-1 — deliver-a-living-service mode (default false). When true, background processes
         * OUTLIVE the run: `disposeBackgroundShells()` becomes a no-op (the runner's every-exit-path dispose
         * included) and background stdio is spooled to env-owned temp files (0600, `wx`, unpredictable path)
         * so the child never dies of EPIPE after the host exits. DEPLOYMENT-declared at env construction (the
         * env lane; `TaskSpec.retainBackgroundProcesses` is the task lane, without this spooling guarantee on
         * every platform — docs/background-process-lifetime.md). The 2h bg-timeout reaper and `killBackground` still work
         * while the host lives; after host exit, cleanup is the deployment's responsibility (e.g. the TB
         * container teardown) — the retained shells' spool files, and the dir holding them, are never released
         * by the env (every other spool pair is, and the dir goes with the last one). v1 covers processes spawned via `execBackground` only (a detach-adopted
         * foreground exec keeps pipe stdio — best-effort survival). Incompatible with durable-suspend
         * deployments (their pre-suspend dispose becomes a no-op too — do not combine).
         */
        retainBackgroundProcesses?: boolean;
        /** The D1 scrub decision's observation seat: called with every NON-EMPTY finding set withheld from a
         *  shell child — the default "scrub" leg's, the `"all"` leg's names of the engine's own namespace (kind
         *  `namespace-rule`), and on any leg the declared own credentials the inherited part
         *  held (kind `own-credential`). Absent ⇒ a once-per-process console summary (loud enough to notice,
         *  quiet enough not to spam). An allow list withholds nothing else, so it reports nothing. */
        onSecretEnvScrub?: (findings: readonly SecretEnvFinding[]) => void;
        /** #1081 — the structured-notice seat for the SAME withheld-keys disclosure (`EngineNotice`,
         *  `code: "config.secret_env_scrubbed"`, `detail.names`); independent of `onSecretEnvScrub` (a raw
         *  findings collector) except: that seat wired alone stays console-silent, as before this existed. The same seat hears
         *  this environment's own faults: `config.inherit_env_declared_late` (an own-credential declaration made after
         *  construction now names an `inheritEnv` entry; once per environment), `config.read_floor_confinement_unavailable`, and the two
         *  staging-file notices of a whole-file replace (`fs.staging_file_swept`, `fs.staging_file_left`). Absent ⇒ the process's default
         *  notice seat (`setDefaultEngineNoticeSeat`), else one process line — never silence. */
        onNotice?: (notice: EngineNotice) => void;
        /** Confine every start that carries a byte floor (`ExecutionEnvExecOptions.readFloor`) at the OS: `"os"` = on macOS,
         *  when the seatbelt base applies here (probed once, now), each such start runs under `sandbox-exec -p <the floor's
         *  profile>` and the environment declares `keepsReadFloor: true`; a floor the profile cannot express, or a profile that
         *  does not apply, refuses that start (`sandbox_unavailable`, naming why) — it never runs unconfined. On any
         *  other host, or when the probe does not apply, the environment declares `false` and says so once on `onNotice`
         *  (`config.read_floor_confinement_unavailable`). Absent = no confinement (`false`). Any other value throws. */
        readFloorConfinement?: "os";
    });
    get schedulerCapabilities(): SchedulerCapability["schedulerCapabilities"];
    schedule(intent: ScheduledIntent, ctx: SchedulerContext): Promise<Result<{
        id: ScheduledTaskId;
    }, SchedulerError>>;
    cancel(id: ScheduledTaskId, ctx: SchedulerContext): Promise<Result<void, SchedulerError>>;
    list(ctx: SchedulerContext): Promise<Result<ScheduledTaskSummary[], SchedulerError>>;
    absolutePath(path: string): Promise<Result<string, FileError>>;
    joinPath(parts: string[]): Promise<Result<string, FileError>>;
    /** The program and arguments ONE shell start spawns: the shell as it is, or — on a confined environment, for a start
     *  carrying a floor — the shell under that floor's seatbelt profile; a floor the profile cannot express, or a profile the
     *  host does not apply, is the reason the start is refused (the command never runs, confined or not). */
    private startOf;
    exec(command: string, options?: ExecutionEnvExecOptions): Promise<Result<ExecResult, ExecutionError>>;
    /** `ExecutionEnv.modelShell`: the start for model-written shell text, on the one absolute program {@link resolveModelShell} asked for this
     *  environment (asked once, in the environment's cwd; `ready` reports its answer, `{ shell: "bash" | "zsh", version }`), with the child
     *  environment of {@link modelShellSpawnEnv}. Each start ends in `this.exec` / `this.spawnBackground`, so a subclass's override of either
     *  sees every start for model text; the start rides on the call's options under a module symbol, and the base's method reached with
     *  those options (an override's `super` call that hands them on, spread or not) starts the asked shell with that environment. Each start
     *  reads `shellEnv` once; the PATH the program is found on comes from this process's inheritance as it stands at the lookup, the
     *  question is asked in its own least environment ({@link askShellKind}), and the child's is composed when the child is started — a
     *  declaration made in between is judged by the child's. A composition that refuses is that start's failure (`spawn_error` /
     *  `spawn_failed`), and the next start composes again. A start an override hands on to ANOTHER environment's method is started by
     *  that environment's own start (its asked shell, its composition), never by this one's, and only where that shell is of the kind
     *  this one's start resolved — the kind the leg read the text for; another kind starts nothing ({@link modelStartAt}). */
    get modelShell(): Required<ExecutionEnvModelShell>;
    /** The shell this environment starts model text on (a bash, else a zsh), resolved once per environment object, on the PATH of the first question's composition
     *  ({@link modelShellSearchPath}) — kept while it holds: a resolution that found no shell to start (no bash and no zsh) while a candidate
     *  gave no answer at all (it could not be started, timed out or was ended by a signal: `askShellKindOnce`'s `ran: false`) is not kept,
     *  and the next reading or start asks again; a resolution that found one, a candidate that answered (not a bash, a bash below 3.2) or a
     *  path that is not there is kept. */
    private modelShellResolved?;
    private modelShellPath;
    /** `ExecutionEnv.modelShellDropped`: what the starts of this environment did not pass ({@link DroppedShellState}), each variable once
     *  (by where it came from), up to {@link MODEL_SHELL_DROPPED_KEPT} variables; past that, `more` says there were others and nothing else
     *  is kept. One record object for the environment's life, which the run tells as each tool call ends; an environment made from this one
     *  by `Object.create` shares it. */
    get modelShellDropped(): {
        readonly entries: readonly DroppedShellState[];
        readonly more: boolean;
    };
    private readonly modelShellDroppedRecord;
    /** A bash start's child environment: the start's one composition with the call's `env` laid over it (a copy without any variable a
     *  row of `SHELL_STATE_ENV` holds, `configuredShellLayer`), then the host process's own variables by each row's rule
     *  (`inheritedShellState`); what was left out is recorded in {@link modelShellDropped}. */
    private modelShellSpawnEnv;
    /** The one foreground start: `exec` on the shell {@link getShellConfig} finds, a bash start on its bash. Keyed by a module symbol and
     *  read off this prototype, so no ordinary subclass method takes its place (reflection can reach the symbol). */
    private [RUN_SHELL];
    readTextFile(path: string, abortSignal?: AbortSignal): Promise<Result<string, FileError>>;
    readTextLines(path: string, options?: {
        maxLines?: number;
        abortSignal?: AbortSignal;
    }): Promise<Result<string[], FileError>>;
    readBinaryFile(path: string, abortSignal?: AbortSignal, maxBytes?: number): Promise<Result<Uint8Array, FileError>>;
    /** RB-221: whole-file replace via same-directory staging + fsync + rename.
     *  The former single-step `writeFile` was an in-place O_TRUNC: an abort mid-write
     *  (Esc during a large Write — ctx.signal reaches here directly), ENOSPC, or a crash left the target as
     *  a torn prefix of the NEW content with the original unrecoverable. Post-fix contract: the target is
     *  either fully old or fully new; `aborted` means it was never touched — the in-place fallback legs
     *  judge the signal once, before their first byte, so they answer `aborted` (untouched), `ok` or their own
     *  error, never `aborted` after a truncation. Known semantic change (same as CC): rename breaks a hard link —
     *  the other link keeps the old content. The replacement is a new inode made by the writing process: its owner
     *  is the writer and its group follows the new-file rule, so the target's group bits can land on another group;
     *  no fchown (KL-3120-b). */
    writeFile(path: string, content: string | Uint8Array, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
    /** RB-221: the historical single-step in-place overwrite — kept for targets where
     *  staging+rename would change node identity (symlink chains, non-regular files) and as the
     *  CC-parity fallback for filesystems where the rename cannot work. NOT atomic by design, and
     *  deliberately not cancellable: the signal is judged once, here, before the first byte, and not again —
     *  so `aborted` never describes a target this write has truncated. */
    private writeFileInPlace;
    /** Atomic exclusive create ({@link FileSystem.writeFileExclusive}): Node `wx` flag = one
     *  `open(O_CREAT|O_EXCL)` syscall — an existing file returns FileError `"already_exists"` and is left
     *  untouched. The EEXIST→already_exists mapping lives HERE, on the exclusive-open step only — a parent
     *  `mkdir` can also throw EEXIST (parent path component is a regular file) and that is NOT "the target
     *  already exists" (fable review). Parent directories are created like writeFile.
     *
     *  The signal is judged before the first byte — at entry and after the parent `mkdir` — and is not handed to the write: the
     *  exclusive open creates the target itself, so a write cancelled after it would leave a new file holding a prefix of the
     *  content under an `aborted` answer. `aborted` therefore means no file was created; a write whose open has begun runs to its
     *  end and answers `ok` or its own error (the same rule as the in-place legs of {@link NodeExecutionEnv.writeFile}). */
    writeFileExclusive(path: string, content: string | Uint8Array, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
    appendFile(path: string, content: string | Uint8Array): Promise<Result<void, FileError>>;
    fileInfo(path: string): Promise<Result<FileInfo, FileError>>;
    /**
     * design/381 DV-8 — {@link FileInfo.mode}'s write half, applied to the descriptor of the one placed open a bound read takes
     * ({@link openPlaced}): no link anywhere on the canonical path is followed (`precondition_failed`), a FIFO swapped in is
     * refused without waiting (`invalid`), and a platform that cannot place an opened object answers `not_supported` — a
     * restore must never re-permission a file a link led it to. Absent on platforms without the permission face
     * ({@link HAS_POSIX_MODE_FACE}), where the caller's disclosure is the honest answer.
     */
    setFileMode(path: string, mode: number, abortSignal?: AbortSignal): Promise<Result<void, FileError>>;
    listDir(path: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>>;
    canonicalPath(path: string): Promise<Result<string, FileError>>;
    /** {@link FileSystem.fileIdentity}: `stat` (links followed) read as BIGINT — an inode past 2^53 (an APFS volume root)
     *  is not exact as a number, and two inodes that collapse to one number would name two directories as one. */
    fileIdentity(path: string): Promise<Result<string, FileError>>;
    /** {@link FileSystem.openBound}: the object of the one placed open ({@link openPlaced}), held. It reads by position from its
     *  descriptor and sizes by `fstat`; a directory lists by {@link listOpenDirectory}. */
    openBound(path: string, abortSignal?: AbortSignal): Promise<Result<BoundFileObject, FileError>>;
    /** The one open a bound read ({@link openBound}) and a mode change ({@link setFileMode}) take at a canonical `resolved`:
     *  read-only, never blocking (a FIFO swapped in is refused, not waited on), and placed at `resolved` by ONE kernel
     *  observation — on darwin the open itself, which refuses a link on any component of the path ({@link O_NOFOLLOW_ANY}; a
     *  kernel that does not refuse them answers `not_supported`); on Linux the kernel's path of the opened descriptor
     *  ({@link heldPlace}). A platform with neither (win32, the BSDs) answers `not_supported` and opens nothing. A link where
     *  the open stood is `precondition_failed`; an opened object that is not a regular file or a directory is `invalid` (one the
     *  kernel will not open read-only, a socket, keeps the kernel's answer); a signal cancelled by the time it is placed is
     *  `aborted`, nothing handed back. The caller owns the handle. */
    private openPlaced;
    /** Where is the object just opened ({@link openPlaced}, Linux) against the canonical `resolved`? The descriptor answers for
     *  itself: the kernel's path of the held object (`/proc/self/fd/<fd>`) must be `resolved` — whatever the path named before
     *  or after (`elsewhere` when it is another); an unreadable answer (no `/proc`) is `unobservable`: this host cannot place
     *  the object, answered `not_supported`, the member's absence on this target. */
    private heldPlace;
    /** The platform's listing of a directory already held open ({@link openBound}): Linux through the descriptor
     *  (`/proc/self/fd/<fd>` — the listing is of the held object whatever the path names); darwin, which cannot enumerate an
     *  open directory from Node (`/dev/fd/<fd>` of a directory answers ENOTDIR), lists the PATH once and requires it to
     *  name the held object afterwards — a path swapped away and back during that one listing can list another directory's
     *  entry NAMES (never bytes). Those entries are judged as names under the held directory's own spelling: a read-deny row
     *  that names the other directory's real location does not reach them (KL-1311a2-g). */
    protected listOpenDirectory(held: FileHandle, resolved: string, identity: string, abortSignal?: AbortSignal): Promise<Result<FileInfo[], FileError>>;
    readLink(path: string): Promise<Result<string, FileError>>;
    /**
     * The LEAF symlink chain ({@link FileSystem.canonicalChain}): {@link walkSymlinkChain} over {@link readLinkTarget}
     * (not the `readLink` method: a wrapper counting or overriding it sees only a caller's own calls).
     */
    canonicalChain(path: string): Promise<Result<SymlinkChain, FileError>>;
    exists(path: string): Promise<Result<boolean, FileError>>;
    createDir(path: string, options?: {
        recursive?: boolean;
    }): Promise<Result<void, FileError>>;
    remove(path: string, options?: {
        recursive?: boolean;
        force?: boolean;
    }): Promise<Result<void, FileError>>;
    createTempDir(prefix?: string): Promise<Result<string, FileError>>;
    createTempFile(options?: {
        prefix?: string;
        suffix?: string;
    }): Promise<Result<string, FileError>>;
    /** design/116 detach: adopt a RUNNING foreground child as a background shell. Pre-fills the bg tails with
     *  the output captured so far (so the first background read has the full history), attaches fresh data/close
     *  handlers, and arms the default bg timeout. Returns undefined when the live-shell limit is hit (detach
     *  refused; the exec keeps running in the foreground). */
    private adoptRunningChild;
    spawnBackground(command: string, options?: BackgroundSpawnOptions): Promise<Result<{
        shellId: BackgroundShellId;
    }, BackgroundShellError>>;
    /** The one background start: `spawnBackground` on the shell {@link getShellConfig} finds, a bash start on its bash. Keyed by a module
     *  symbol and read off this prototype, so no ordinary subclass method takes its place (reflection can reach the symbol). */
    private [START_BACKGROUND];
    pollBackground(shellId: BackgroundShellId): Promise<Result<BackgroundPoll, BackgroundShellError>>;
    killBackground(shellId: BackgroundShellId): Promise<Result<void, BackgroundShellError>>;
    /** The synchronous hard kill seat ({@link BackgroundShellCapability.killBackgroundNow}). Reads process truth,
     *  never `entry.status` (other stops flip it before their attempt, which can fail or wait on a timer). Once
     *  node has observed the leader's exit its pid may name a stranger: `already_gone`, nothing signalled. Before
     *  that the leader is still our child (live or an unreaped zombie), so ONE `kill(-pid, SIGKILL)` reaches its
     *  group and nothing else — no descendant snapshot (a process that left the group is outside this seat).
     *  win32 has no synchronous hard kill: no process groups, and the tree kill's MSYS group discovery needs its
     *  deferred step, so this seat answers `no_pgid` and the caller's ordinary kill (the ladder) does the work.
     *  Only a landed signal sets the latch; a refused one is `no_pgid`. */
    killBackgroundNow(shellId: BackgroundShellId): BackgroundHardKillOutcome;
    /** design/128 T1-1: incrementally read a retained shell's spool files into the in-memory tails, so
     *  pollBackground serves the same cursor semantics whether stdio came over pipes or spool files.
     *  Bounded single read per stream per poll (the tail keeps only its rolling window anyway).
     *  reads are positioned by spool.fileCursor (the FILE offset — rotation truncates
     *  the file), while poll slicing keeps using the logical stream totalBytes; the two advance in
     *  lockstep here but are NOT interchangeable after a rotation. */
    private syncSpool;
    /** The one seat that opens a spool pair (foreground exec and background spawn alike), inside the env's spool dir: made on
     *  the first mint after the dir was last removed, so a command never runs against a dir an idle reap or a temp cleaner took. */
    private mintSpoolPair;
    /** The one seat that gives a spool pair back: unlinks both files (a descendant still writing keeps its fd into the unlinked
     *  inode — no EPIPE), forgets the pair, and removes the dir once no pair is left in it. Idempotent. */
    private releaseSpoolPair;
    /** Removes the spool dir (and whatever a failed unlink stranded in it) when no pair of this env lives in it. A retain-lane
     *  bg pair is never released, so it keeps its dir; the rest is gone with its last pair. Best-effort, never throws. */
    private reapSpoolDirIfIdle;
    /** +: reclaim an EPHEMERAL spool (detach-adopted, or any non-retain bg
     *  spawn — the whole unix bg lane is spool-backed now) — fold the final residue into the tails,
     *  unlink both files, and drop the spool reference (later syncs become no-ops). Idempotent;
     *  never touches the spool of a design/128 retain-lane shell that has a process (no `ephemeral` flag). A still-writing detached
     *  descendant keeps its fd into the unlinked inode (RB-26 posture — no EPIPE, auto-reclaim at
     *  its exit). */
    private reclaimEphemeralSpool;
    disposeBackgroundShells(opts?: {
        except?: readonly BackgroundShellId[];
    }): Promise<void>;
    cleanup(): Promise<void>;
}
export {};
