import { x as HarnessState } from "./config-XC40aztM.mjs"; import { r as HarnessStateParseReporter } from "./index-ZZd-GRFZ.mjs"; //#region src/models/harnessCache.d.ts interface LoadedHarnessState { /** Undefined when this process is running off the environment fallback. */ filePath?: string; owned: boolean; state: HarnessState; } //#endregion //#region src/services/harnessStore/index.d.ts /** * Who owns the harness state, and where it lives. * * The state used to be the environment: twenty variables that every reader * re-parsed and every writer mutated globally. The file is the authority now, * and the environment is a projection published for the readers that can only * see an environment, which are bash hooks, the shell launchers, packages that * do not depend on this one, and any process spawned by any of them. * * OWNERSHIP IS PER PROCESS, AND THAT IS THE WHOLE DESIGN: * Doom Team subagents run detached, in their own process group, from an * environment snapshot taken at spawn. A child can outlive its parent. If it * shared the parent's file it would corrupt a session it does not own, and if * that file sat in the parent's run directory the parent's shutdown sweep would * delete it from under a live run. So every process writes a file it owns: * `owner.pid` records who, and a process that finds someone else's file copies * it before its first write. * * AVOID: * - Treating the file as shared mutable state between processes. Atomic writes * prevent torn reads, not lost updates * - Reading the environment directly for anything this exposes */ /** Points at the state file. The one variable that is not derived. */ declare const HARNESS_STATE_POINTER = "DOOMPI_STATE"; interface HarnessStateFile { version: number; owner: { pid: number; startedAt: string; }; state: HarnessState; } interface HarnessStateTransactionSnapshot { readonly filePath?: string; readonly owned: boolean; readonly state: HarnessState; readonly environment: Readonly>; } /** Drops the cached state. For tests, and for a process changing identity. */ declare function resetHarnessStore(): void; /** * Reads the state for this process, once. * * A missing pointer means nobody wrote a file for this process, so the * environment is all there is: a nested run, a third-party spawn, or a caller * older than the store. A pointer that cannot be read is reported and then * treated the same way, because a session that starts degraded beats a session * that does not start at all. */ declare function loadHarnessState(environment?: NodeJS.ProcessEnv, report?: HarnessStateParseReporter): LoadedHarnessState; /** Captures the owned state pointer and every projected harness variable. */ declare function snapshotHarnessState(environment?: NodeJS.ProcessEnv): HarnessStateTransactionSnapshot; /** Restores a snapshot only while the current process still owns its state pointer. */ declare function restoreHarnessStateSnapshot(snapshot: HarnessStateTransactionSnapshot, environment?: NodeJS.ProcessEnv): void; declare function getHarnessState(report?: HarnessStateParseReporter): HarnessState; /** * Starts a session: writes the file and publishes the derived environment. * * The environment is a parameter because the caller is usually describing a * process other than itself. The launcher builds the environment for the Pi it * is about to spawn, and Doom Team builds the snapshot for a detached child, so * neither should touch its own `process.env` to do it. */ declare function createHarnessSession(state: HarnessState, options: { directory: string; environment: NodeJS.ProcessEnv; /** * Leave the file for a process that does not exist yet to claim. * * What a spawner wants: the child owns its state from its first read, in a * directory the spawner manages, so the parent cleaning up its own session * cannot pull the file out from under a detached run. */ unclaimed?: boolean; }): string; /** * Applies a patch to this process's state. * * Copy on write: a process holding a file it does not own writes its own copy * and repoints itself at it, so a child can never rewrite its parent's session. */ declare function updateHarnessState(patch: Partial, environment?: NodeJS.ProcessEnv): HarnessState; /** Removes this process's own state file. Safe when there is none. */ declare function disposeHarnessState(environment?: NodeJS.ProcessEnv): void; declare function harnessRoot(state?: Pick): string; /** * The repository root, or a hard error. * * Separate from `requireHarnessPaths` because most callers only need the root, * and separate from `harnessRoot` because falling back to `process.cwd()` would * quietly operate on whatever directory the session happens to sit in. A caller * that asks for the root wants the session's repository or nothing. */ declare function requireHarnessRoot(state?: Pick): string; /** The root and the run's scratch directory, for callers that write to disk. */ declare function requireHarnessPaths(state?: Pick): { root: string; temporaryDirectory: string; }; //#endregion export { disposeHarnessState as a, loadHarnessState as c, resetHarnessStore as d, restoreHarnessStateSnapshot as f, LoadedHarnessState as h, createHarnessSession as i, requireHarnessPaths as l, updateHarnessState as m, HarnessStateFile as n, getHarnessState as o, snapshotHarnessState as p, HarnessStateTransactionSnapshot as r, harnessRoot as s, HARNESS_STATE_POINTER as t, requireHarnessRoot as u }; //# sourceMappingURL=index-D3iKH7c8.d.mts.map