@orkestrel/probe 0.0.19 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/server/helpers.ts","../../../src/server/parsers.ts","../../../src/server/Overlay.ts","../../../package.json","../../../src/server/stages/LintStage.ts","../../../src/server/stages/RuntimeStage.ts","../../../src/server/stages/TypeStage.ts","../../../src/server/Probe.ts","../../../src/server/ProbeServer.ts"],"sourcesContent":["import type { Issue, Stage } from '@src/core'\nimport type { Diagnostic, ListenerCapture, WorkspaceManifest } from './types.js'\nimport type { EventEmitter } from 'node:events'\nimport type { Dirent } from 'node:fs'\nimport type * as VitestNode from 'vitest/node'\nimport {\n\tcloseSync,\n\tconstants,\n\tftruncateSync,\n\tlstatSync,\n\topenSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { createRequire } from 'node:module'\nimport { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport {\n\tattempt,\n\tcompileGuard,\n\tisArray,\n\tisError,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisString,\n} from '@orkestrel/contract'\nimport { CLAIM_SHAPE, ProbeError, TYPE_MIRROR, isDraft, isProbeError } from '@src/core'\n\n/**\n * Rewrites one path into the forward-slash spelling this package compares and reports paths in.\n *\n * @remarks\n * Windows reports a path with backslashes and accepts either separator, so two spellings of one\n * file compare unequal until they are rewritten. Every path this package keys a map on, matches a\n * prefix against, or hands a caller passes through here first.\n *\n * @param path - The path to rewrite\n * @returns The same path with every backslash replaced by a forward slash\n *\n * @example\n * ```ts\n * normalizePath('src\\\\core\\\\greeting.ts') // 'src/core/greeting.ts'\n * normalizePath('src/core/greeting.ts') // 'src/core/greeting.ts'\n * ```\n */\nexport function normalizePath(path: string): string {\n\treturn path.replaceAll('\\\\', '/')\n}\n\n/**\n * Reads the condition code a native fault carries.\n *\n * @remarks\n * A caller catches `unknown`, so every reading of a caught value's own property calls into code\n * this package does not own: a proxy whose `has` trap throws and a value whose `code` getter throws\n * both arrive here. The read is guarded, so a fault that refuses inspection reports no code rather\n * than raising a second fault over the first. A `code` the host reports as anything other than a\n * string is no code this package compares against, so it reports none either.\n *\n * One reading serves every site that classifies a native fault, so a host condition is admitted the\n * same way wherever it is read.\n *\n * @param error - The caught value to read\n * @returns The fault's `code` when it carries a string one; `undefined` otherwise\n *\n * @example\n * ```ts\n * readFaultCode(Object.assign(new Error('no such file'), { code: 'ENOENT' })) // 'ENOENT'\n * readFaultCode(new Error('the runtime stage was destroyed')) // undefined\n * readFaultCode('ENOENT') // undefined\n * ```\n */\nexport function readFaultCode(error: unknown): string | undefined {\n\tif (!isObject(error)) return undefined\n\tconst fault = error\n\tconst reading = attempt(() => ('code' in fault ? fault.code : undefined))\n\tif (!reading.success) return undefined\n\treturn isString(reading.value) ? reading.value : undefined\n}\n\n/**\n * Reports whether one path resolves outside the root it is read against.\n *\n * @remarks\n * Containment decides which paths a claim may reach and which absolute paths a digest may rewrite,\n * so one reading serves every site that asks the question. A target resolving to the root itself is\n * contained, and each caller decides on its own what that empty relative path means for it.\n *\n * The test reads the relative path rather than a string prefix of the root, so a sibling directory\n * whose name begins with the root's own text is outside rather than beneath it. An absolute\n * relative path is the answer a host returns for two paths on different volumes, which no root\n * contains.\n *\n * @param root - The root the target is read against\n * @param target - The path to test, absolute or root-relative\n * @returns True if the target resolves outside the root; false otherwise\n *\n * @example\n * ```ts\n * escapesRoot('/srv/checkout', 'src/core/greeting.ts') // false\n * escapesRoot('/srv/checkout', '../secrets.env') // true\n * escapesRoot('/srv/checkout', '/srv/checkout-backup/secrets.env') // true\n * ```\n */\nexport function escapesRoot(root: string, target: string): boolean {\n\tconst path = relative(resolve(root), resolve(root, target))\n\treturn path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path)\n}\n\n/**\n * Resolves a path inside a target workspace and rejects traversal outside it.\n *\n * @remarks\n * A native `ENAMETOOLONG` or NUL-byte `ERR_INVALID_ARG_VALUE` fault is a claimant refusal. This\n * classifies the fault, not the author: a workspace nested deeply enough that this package's short\n * generated names overflow the host limit also reads as a claimant refusal.\n *\n * @param workspace - The target workspace root\n * @param target - A workspace-relative path\n * @param mutate - If `true`, refuses a symbolic link in an existing descendant; if `false`,\n * resolves lexically. Default: `false`\n * @returns The absolute contained path\n * @throws When the path resolves outside the workspace, mutation would cross a symbolic link, or\n * the target tree cannot be inspected\n *\n * @example\n * ```ts\n * resolveWorkspaceFile('/srv/checkout', 'src/core/greeting.ts')\n * // '/srv/checkout/src/core/greeting.ts'\n * resolveWorkspaceFile('/srv/checkout', '../secrets.env')\n * // throws: Path escapes the workspace: ../secrets.env\n * ```\n */\nexport function resolveWorkspaceFile(workspace: string, target: string, mutate = false): string {\n\tconst root = resolve(workspace)\n\tconst file = resolve(root, target)\n\tconst path = relative(root, file)\n\tif (path === '' || escapesRoot(root, file)) {\n\t\tthrow new ProbeError(`Path escapes the workspace: ${target}`, {\n\t\t\torigin: 'claimant',\n\t\t\tcode: 'refused',\n\t\t\tcontext: { path: target },\n\t\t})\n\t}\n\tif (!mutate) return file\n\ttry {\n\t\tconst canonical = realpathSync(root)\n\t\tlet descendant = root\n\t\tfor (const segment of path.split(sep)) {\n\t\t\tdescendant = resolve(descendant, segment)\n\t\t\tconst outcome = attempt(() => lstatSync(descendant))\n\t\t\tif (!outcome.success) {\n\t\t\t\tconst code = readFaultCode(outcome.error)\n\t\t\t\tif (code === 'ENOENT' || code === 'ENOTDIR') break\n\t\t\t\tthrow outcome.error\n\t\t\t}\n\t\t\tif (outcome.value.isSymbolicLink()) {\n\t\t\t\tthrow new ProbeError(`Path crosses a symbolic link: ${target}`, {\n\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { path: target },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst resolved = realpathSync(descendant)\n\t\t\tif (escapesRoot(canonical, resolved)) {\n\t\t\t\tthrow new ProbeError(`Path escapes the workspace: ${target}`, {\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { path: target },\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tif (isProbeError(error)) throw error\n\t\tconst code = readFaultCode(error)\n\t\tconst claimant = code === 'ENAMETOOLONG' || code === 'ERR_INVALID_ARG_VALUE'\n\t\tthrow new ProbeError(`The workspace path cannot be inspected: ${target}`, {\n\t\t\torigin: claimant ? 'claimant' : 'workspace',\n\t\t\tcode: claimant ? 'refused' : 'malformed',\n\t\t\tcontext: { path: target },\n\t\t\tcause: error,\n\t\t})\n\t}\n\treturn file\n}\n\n/**\n * Overwrites a file that already exists, through a descriptor that refuses a symbolic link at the\n * final component.\n *\n * @remarks\n * A containment walk and the write that follows it are separate calls, so a process that swaps the\n * final component between them decides where the bytes land. `writeFileSync` opens with the default\n * `w` flag, which follows a symbolic link at that component and creates the file when it is absent,\n * so the walk's reading does not bind the write. Opening `O_WRONLY | O_NOFOLLOW` moves that\n * decision into the call that writes: a link at the final component refuses the open, and the\n * omitted `O_CREAT` fails `ENOENT` for a target that has gone since the walk saw it. This is the\n * mutating counterpart of the `wx` flag every create in this package uses. Which code the refusal\n * carries is the host's; Linux with Node v22.22.2 reported `ELOOP` on 2026-08-24.\n *\n * Truncation runs through the held descriptor rather than through an `O_TRUNC` flag, so it reaches\n * the file the open bound. A Windows host refuses the numeric `O_TRUNC` without `O_CREAT` outright:\n * measured on 2026-08-26 on Windows 11 with Node v24.19.0 over NTFS, `openSync` reported `EINVAL`\n * for `O_WRONLY | O_TRUNC` and for `O_RDWR | O_TRUNC` while `O_WRONLY` alone opened, and adding\n * `O_CREAT` would trade that refusal for the create this function must never perform.\n *\n * A directory component stays open, because Node exposes no descriptor-relative call to walk and\n * write through one set of descriptors. Where a host's Node build defines no `O_NOFOLLOW`, that flag\n * contributes nothing to the flag set and the final component is open on that host too.\n *\n * @param file - The absolute path to overwrite\n * @param text - The text to write\n * @returns Nothing\n * @throws The host's own fault when the final component is a symbolic link, when the file is\n * absent, or when the host refuses the descriptor\n *\n * @example\n * ```ts\n * const file = resolveWorkspaceFile('/srv/checkout', 'tmp/probes/arm-type.ts', true)\n * writeFileSync(file, 'export type Signal = string\\n', { encoding: 'utf8', flag: 'wx' })\n * overwriteFile(file, 'export type Signal = number\\n')\n * readFileSync(file, 'utf8') // 'export type Signal = number\\n'\n * ```\n */\nexport function overwriteFile(file: string, text: string): void {\n\tconst descriptor = openSync(file, constants.O_WRONLY | constants.O_NOFOLLOW)\n\ttry {\n\t\tftruncateSync(descriptor, 0)\n\t\twriteFileSync(descriptor, text, 'utf8')\n\t} finally {\n\t\tcloseSync(descriptor)\n\t}\n}\n\n/**\n * Reports whether a fault means the host refuses the name a caller supplied for a file to create.\n *\n * @remarks\n * A host reports one refusal with a code of its own and several unrelated conditions with one\n * shared code, so the code alone does not separate a name the host will not accept from a file\n * that is merely absent. `ENAMETOOLONG` names the refusal outright. `ERR_INVALID_ARG_VALUE` names\n * every argument Node rejects, so it names the refusal only for a path carrying the NUL byte Node\n * refuses; the same code arrives for a bad `flag` and a bad encoding, which say nothing about the\n * name. An `ENOENT` raised while the parent stats as a directory names the refusal too, because an\n * ordinary absent file beneath an existing directory would have been created instead; a Windows\n * host reports an overlong component and a character its filesystem reserves that way. Measured on\n * 2026-08-21 on Windows 11 with Node v24.18.1 over NTFS, `writeFileSync` reported `ENOENT` for a\n * 300-character final component and never reported `ENAMETOOLONG`.\n *\n * This reads the fault the host reported rather than applying a length or character policy of its\n * own, so a host that accepts a name another host refuses is not second-guessed and no platform\n * branch decides the answer. Every read of the fault is guarded, so it is total over every value a\n * published caller can supply: a proxy whose `has` trap throws, a value whose `code` getter throws,\n * a fault carrying no code, and a parent this host cannot stat each report false.\n *\n * @param file - The path whose creation failed\n * @param error - The fault the failed operation raised\n * @returns True if the fault means the host refuses this name; false otherwise\n *\n * @example\n * ```ts\n * try {\n * \twriteFileSync('tmp/probes/greeting\\0.test.ts', '')\n * } catch (error) {\n * \tisRefusedName('tmp/probes/greeting\\0.test.ts', error) // true\n * }\n * isRefusedName('tmp/probes/greeting.test.ts', new Error('the runtime stage was destroyed')) // false\n * ```\n */\nexport function isRefusedName(file: string, error: unknown): boolean {\n\tconst code = readFaultCode(error)\n\tif (code === 'ENAMETOOLONG') return true\n\tif (code === 'ERR_INVALID_ARG_VALUE') return file.includes('\\0')\n\tif (code !== 'ENOENT') return false\n\tconst parent = attempt(() => statSync(dirname(file), { throwIfNoEntry: false }))\n\treturn parent.success && parent.value !== undefined && parent.value.isDirectory()\n}\n\n/**\n * Projects an absolute tool path into the workspace-relative form issues expose.\n *\n * @param workspace - The target workspace root\n * @param file - The path a tool reported\n * @returns A forward-slash workspace-relative path\n *\n * @example\n * ```ts\n * relativeWorkspaceFile('/srv/checkout', '/srv/checkout/src/core/greeting.ts')\n * // 'src/core/greeting.ts'\n * ```\n */\nexport function relativeWorkspaceFile(workspace: string, file: string): string {\n\treturn normalizePath(relative(resolve(workspace), resolve(file)))\n}\n\n/**\n * Projects the paths one tool named in a message into the forms this package's issues expose.\n *\n * @remarks\n * An issue's `path` is workspace-relative, and its message is prose a tool wrote about the same\n * tree. Left alone that prose names a file by the host's own layout, so one issue reports a path two\n * ways and a reader on another checkout is sent to a directory that is not theirs. Each spelling of\n * the root is removed: the absolute path, the backslash spelling a Windows tool writes, and the\n * `file:` URL a runtime names a module by. A root the host itself names ends in a separator, and the\n * paths beneath it continue straight from it rather than from one more separator. A path outside the\n * workspace stands as it is, because a relative spelling of it would name a file the tree does not\n * hold.\n *\n * A spelling of the root counts only where a path begins: at the start of the message, or after a\n * character no path carries. A directory whose own name ends in this root's text holds a different\n * tree, so the root inside a longer path names a file this workspace does not hold and that path\n * survives whole.\n *\n * Only the root is removed. A name is otherwise the tool's, including a `.probe-` name that reads\n * like a specification this package generates: the stage that wrote one knows the exact name it\n * wrote and renames that name itself, which is the only reading that separates its own file from a\n * file the target tree owns.\n *\n * Everything else the tool wrote survives verbatim, separators included. A message carries text\n * that is not a path — a runtime escapes a newline as a backslash when it prints a string inline,\n * and a compiler quotes a string literal with its escapes intact — so rewriting every separator\n * would corrupt the evidence the message exists to carry. The cost is that the path left behind\n * keeps the separator the tool chose, which on Windows is not the one `Issue.path` uses.\n *\n * @param workspace - The target workspace root\n * @param message - The message a tool reported\n * @returns The message with the host's own layout removed from every path that begins with it\n *\n * @example\n * ```ts\n * relativeWorkspaceMessage('/srv/checkout', 'Cannot read /srv/checkout/tsconfig.json')\n * // 'Cannot read tsconfig.json'\n * relativeWorkspaceMessage('/srv/checkout', 'Cannot read /mirror/srv/checkout/tsconfig.json')\n * // 'Cannot read /mirror/srv/checkout/tsconfig.json'\n * ```\n */\nexport function relativeWorkspaceMessage(workspace: string, message: string): string {\n\tconst root = resolve(workspace)\n\tconst forward = normalizePath(root)\n\tconst url = pathToFileURL(forward).href\n\t// On a host whose separator is a forward slash the native and forward-slash spellings are one\n\t// string, and a host root carries its separator already, so the set holds each distinct prefix\n\t// once and a root passes through as itself rather than as a doubled separator.\n\tconst spellings = new Set([\n\t\turl.endsWith('/') ? url : `${url}/`,\n\t\tforward.endsWith('/') ? forward : `${forward}/`,\n\t\troot.endsWith(sep) ? root : `${root}${sep}`,\n\t])\n\tlet text = message\n\tfor (const spelling of spellings) {\n\t\ttext = text.replaceAll(spelling, (match: string, offset: number, source: string) =>\n\t\t\t// A character a path carries sits before this occurrence, so the occurrence is inside a\n\t\t\t// longer path that another tree holds rather than at the start of one of this tree's own.\n\t\t\t// The character before offset 0 reads as empty, which no class matches.\n\t\t\t/[^\\s\"'`()[\\]{}<>,;:=|]/u.test(source.charAt(offset - 1)) ? match : '',\n\t\t)\n\t}\n\treturn text\n}\n\n/**\n * Scans the plain-text output of one compiler run into the diagnostics it reported.\n *\n * @remarks\n * Reads the shape `tsc --pretty false` prints: `path(line,column): error TSnnnn: message` for a\n * diagnostic about a file, and `error TSnnnn: message` for one about a project. A line that carries\n * neither prefix and begins with whitespace is an elaboration of the diagnostic above it and joins\n * that message with a newline; any other line is skipped, so a runtime's own failure text yields no\n * diagnostic and a caller reads that as the fault it is. The compiler counts lines and columns from\n * one and columns in UTF-16 code units, so each location is lowered to the zero-based UTF-16 point\n * `Diagnostic.range` fixes and `end` resolves to `start`, which is the extent this output carries.\n * A warning reads as a diagnostic, because the workspace's own gate reports it the same way. The\n * `TS\\d+` token that follows `error` or `warning` is what recognizes the line; nothing is captured\n * from it, because `Diagnostic` carries no field for it.\n *\n * @param text - The compiler's output\n * @returns One record per reported diagnostic, in the compiler's own order\n *\n * @example\n * ```ts\n * scanDiagnostics(\"src/a.ts(1,14): error TS2322: Type 'string' is not assignable to type 'number'.\")\n * // [{ path: 'src/a.ts', range: { start: { line: 0, character: 13 }, end: { line: 0, character: 13 } }, message: \"Type 'string' is not assignable to type 'number'.\" }]\n * scanDiagnostics('error TS5058: The specified path does not exist.')\n * // [{ message: 'The specified path does not exist.' }]\n * ```\n */\nexport function scanDiagnostics(text: string): readonly Diagnostic[] {\n\tconst diagnostics: Diagnostic[] = []\n\tfor (const line of text.split(/\\r\\n|\\n/)) {\n\t\tconst located = /^(.+)\\((\\d+),(\\d+)\\): (?:error|warning) TS\\d+: (.*)$/u.exec(line)\n\t\tif (located !== null) {\n\t\t\tconst row = Number.parseInt(located[2] ?? '1', 10) - 1\n\t\t\tconst column = Number.parseInt(located[3] ?? '1', 10) - 1\n\t\t\tconst point = { line: row, character: column }\n\t\t\tdiagnostics.push({\n\t\t\t\tpath: normalizePath(located[1] ?? ''),\n\t\t\t\trange: { start: point, end: point },\n\t\t\t\tmessage: located[4] ?? '',\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\t\tconst bare = /^(?:error|warning) TS\\d+: (.*)$/u.exec(line)\n\t\tif (bare !== null) {\n\t\t\tdiagnostics.push({ message: bare[1] ?? '' })\n\t\t\tcontinue\n\t\t}\n\t\tconst previous = diagnostics.at(-1)\n\t\tif (previous === undefined || !/^\\s+\\S/u.test(line)) continue\n\t\tdiagnostics[diagnostics.length - 1] = {\n\t\t\t...previous,\n\t\t\tmessage: `${previous.message}\\n${line}`,\n\t\t}\n\t}\n\treturn diagnostics\n}\n\n/**\n * Resolves one installed module from the target workspace.\n *\n * @param workspace - The target workspace root\n * @param specifier - The module specifier to resolve\n * @returns The installed module entry path\n * @throws When the workspace does not install the module\n *\n * @example\n * ```ts\n * resolveWorkspaceModule(process.cwd(), 'typescript/package.json') ===\n * \treadWorkspaceManifest(process.cwd(), 'typescript').path // true\n * ```\n */\nexport function resolveWorkspaceModule(workspace: string, specifier: string): string {\n\tconst outcome = attempt(() =>\n\t\tcreateRequire(resolve(workspace, 'package.json')).resolve(specifier),\n\t)\n\tif (outcome.success) return outcome.value\n\tconst error = outcome.error\n\tconst missing = readFaultCode(error) === 'MODULE_NOT_FOUND'\n\tthrow new ProbeError(`The workspace cannot resolve ${specifier}`, {\n\t\torigin: 'workspace',\n\t\tcode: missing ? 'missing' : 'malformed',\n\t\tcontext: { name: specifier },\n\t\tcause: error,\n\t})\n}\n\n/**\n * Loads the installed `vitest/node` module from a target workspace.\n *\n * @remarks\n * The only tool this package drives in process. The compiler is a process this package spawns\n * rather than a module it loads, so `typescript` is resolved through {@link resolveWorkspaceBinary}\n * instead.\n *\n * @param workspace - The target workspace root\n * @returns The installed `vitest/node` module\n * @throws When the workspace cannot load `vitest/node`\n *\n * @example\n * ```ts\n * const vitest = loadWorkspaceVitest(process.cwd())\n * typeof vitest.createVitest === 'function' // true\n * ```\n */\nexport function loadWorkspaceVitest(workspace: string): typeof VitestNode {\n\tconst outcome = attempt(() => {\n\t\tconst require = createRequire(resolve(workspace, 'package.json'))\n\t\treturn require('vitest/node')\n\t})\n\tif (outcome.success) return outcome.value\n\tconst error = outcome.error\n\tconst missing = readFaultCode(error) === 'MODULE_NOT_FOUND'\n\tthrow new ProbeError('The workspace cannot load vitest/node', {\n\t\torigin: 'workspace',\n\t\tcode: missing ? 'missing' : 'malformed',\n\t\tcontext: { name: 'vitest/node' },\n\t\tcause: error,\n\t})\n}\n\n/**\n * Reads one installed package manifest from the target workspace.\n *\n * @param workspace - The target workspace root\n * @param name - The installed package name\n * @returns The manifest's absolute path and parsed record\n * @throws When the package cannot be resolved, read, parsed, or does not publish a record manifest\n *\n * @example\n * ```ts\n * const manifest = readWorkspaceManifest(process.cwd(), 'typescript')\n * console.log(manifest.contents.version)\n * ```\n */\nexport function readWorkspaceManifest(workspace: string, name: string): WorkspaceManifest {\n\tlet path: string\n\ttry {\n\t\tpath = resolveWorkspaceModule(workspace, `${name}/package.json`)\n\t} catch (error) {\n\t\tif (!isProbeError(error)) throw error\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: error.code,\n\t\t\tcontext: { name },\n\t\t\tcause: error.cause,\n\t\t})\n\t}\n\tconst reading = attempt(() => readFileSync(path, 'utf8'))\n\tif (!reading.success) {\n\t\tconst error = reading.error\n\t\tconst code = readFaultCode(error)\n\t\tconst missing = code === 'ENOENT' || code === 'ENOTDIR'\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: missing ? 'missing' : 'malformed',\n\t\t\tcontext: { name, path },\n\t\t\tcause: error,\n\t\t})\n\t}\n\tconst parsing = attempt<unknown>(() => JSON.parse(reading.value))\n\tif (!parsing.success) {\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { name, path },\n\t\t\tcause: parsing.error,\n\t\t})\n\t}\n\tconst contents = parsing.value\n\tif (!isRecord(contents)) {\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { name, path },\n\t\t})\n\t}\n\treturn { path, contents }\n}\n\n/**\n * Resolves a package's portable JavaScript binary from the target workspace.\n *\n * @remarks\n * A package publishes its binaries under keys of its own choosing, and that key is often not the\n * package name: `typescript` publishes `tsc`. Name the key as `command` wherever the two differ.\n * Default: the package name.\n *\n * @param workspace - The target workspace root\n * @param name - The installed package name\n * @param command - The `bin` key to read. Default: `name`\n * @returns The absolute JavaScript entry named by the package's `bin` field\n * @throws When the package does not publish a binary under the requested key\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(process.cwd(), resolveWorkspaceBinary(process.cwd(), 'oxlint'))\n * // 'node_modules/oxlint/bin/oxlint'\n * relativeWorkspaceFile(process.cwd(), resolveWorkspaceBinary(process.cwd(), 'typescript', 'tsc'))\n * // 'node_modules/typescript/bin/tsc'\n * ```\n */\nexport function resolveWorkspaceBinary(workspace: string, name: string, command = name): string {\n\tconst manifest = readWorkspaceManifest(workspace, name)\n\tconst bin = manifest.contents.bin\n\tif (bin === undefined) {\n\t\tthrow new ProbeError(`${name} does not publish a bin field`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'missing',\n\t\t\tcontext: { name },\n\t\t})\n\t}\n\tif (isString(bin)) return resolve(manifest.path, '..', bin)\n\tif (!isRecord(bin) || !(command in bin)) {\n\t\tthrow new ProbeError(`${name} does not publish the ${command} binary`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'missing',\n\t\t\tcontext: { name },\n\t\t})\n\t}\n\tconst entry = bin[command]\n\tif (!isString(entry)) {\n\t\tthrow new ProbeError(`${name} publishes an invalid ${command} binary`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { name, value: entry },\n\t\t})\n\t}\n\treturn resolve(manifest.path, '..', entry)\n}\n\n/**\n * Selects the scoped TypeScript project for one candidate draft path.\n *\n * @param path - The workspace-relative candidate draft path\n * @returns The workspace-relative scoped project path\n * @throws When the path does not name a configured source or application environment\n *\n * @example\n * ```ts\n * inferTypeProject('src/core/greeting.ts') // 'configs/src/tsconfig.core.json'\n * inferTypeProject('tests/src/core/greeting.test.ts')\n * // throws: Cannot infer a scoped TypeScript project for tests/src/core/greeting.test.ts\n * ```\n */\nexport function inferTypeProject(path: string): string {\n\tconst [axis, environment] = normalizePath(path).split('/')\n\tif ((axis !== 'src' && axis !== 'app') || environment === undefined || environment === '') {\n\t\tthrow new ProbeError(`Cannot infer a scoped TypeScript project for ${path}`, {\n\t\t\torigin: 'claimant',\n\t\t\tcode: 'refused',\n\t\t\tcontext: { path },\n\t\t})\n\t}\n\treturn `configs/${axis}/tsconfig.${environment}.json`\n}\n\n/**\n * Selects the Vitest project whose environment matches one test path.\n *\n * @remarks\n * There is no root-project fallback. A path no configured project collects returns `undefined`,\n * and the runtime stage refuses that claimant test with `code: 'missing'` rather than running it\n * somewhere the workspace never configured.\n *\n * @param path - The workspace-relative test path\n * @returns The matching project's name, or `undefined` when no configured project collects the path\n *\n * @example\n * ```ts\n * inferTestProject('tmp/probes/greeting.test.ts') // 'probe'\n * inferTestProject('tests/src/server/helpers.test.ts') // 'src:server'\n * inferTestProject('tests/config.test.ts') // undefined\n * ```\n */\nexport function inferTestProject(path: string): string | undefined {\n\tconst [root, axis, environment] = normalizePath(path).split('/')\n\tif (root === 'tmp' && axis === 'probes') return 'probe'\n\tif (root !== 'tests' || axis === undefined || environment === undefined) return undefined\n\tif (axis !== 'src' && axis !== 'app') return undefined\n\treturn `${axis}:${environment}`\n}\n\n/**\n * Selects the Language Server Protocol language identifier for a source path.\n *\n * @param path - The source path whose extension selects the language\n * @returns The matching JavaScript or TypeScript language identifier\n *\n * @example\n * ```ts\n * inferDocumentLanguage('src/core/greeting.ts') // 'typescript'\n * inferDocumentLanguage('src/browser/Panel.tsx') // 'typescriptreact'\n * ```\n */\nexport function inferDocumentLanguage(path: string): string {\n\tconst extension = extname(path).toLowerCase()\n\tif (extension === '.tsx') return 'typescriptreact'\n\tif (extension === '.js' || extension === '.mjs' || extension === '.cjs') return 'javascript'\n\tif (extension === '.jsx') return 'javascriptreact'\n\treturn 'typescript'\n}\n\n/**\n * Builds the fresh sibling path a revision's file is written at, preserving the test's resolution\n * directory.\n *\n * @param workspace - The target workspace root\n * @param path - The workspace-relative test path\n * @param revision - The fresh revision identity\n * @returns The absolute sibling path\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(\n * \t'/srv/checkout',\n * \tbuildRevisionPath('/srv/checkout', 'tmp/probes/greeting.test.ts', '4821-9f0c'),\n * )\n * // 'tmp/probes/greeting.test.probe-4821-9f0c.ts'\n * ```\n */\nexport function buildRevisionPath(workspace: string, path: string, revision: string): string {\n\tconst file = resolveWorkspaceFile(workspace, path)\n\tconst extension = extname(file)\n\tconst stem = extension === '' ? file : file.slice(0, -extension.length)\n\treturn `${stem}.probe-${revision}${extension}`\n}\n\n/**\n * Filters one issue list to the distinct issues it carries, in the order they arrived.\n *\n * @remarks\n * A stage that reads one candidate through more than one tool run reports that candidate's\n * diagnostic once per run. Two issues are the same issue when their party, path, message, and range\n * all agree, because those are every value an issue carries.\n *\n * @param issues - The issues to filter\n * @returns The distinct issues, in the order the list carried them\n *\n * @example\n * ```ts\n * const issue: Issue = { origin: 'claimant', path: 'src/core/greeting.ts', message: 'not assignable' }\n * filterUniqueIssues([issue, { ...issue }]).length // 1\n * ```\n */\nexport function filterUniqueIssues(issues: readonly Issue[]): readonly Issue[] {\n\tconst seen = new Set<string>()\n\tconst distinct: Issue[] = []\n\tfor (const issue of issues) {\n\t\tconst key = JSON.stringify([issue.origin, issue.path, issue.message, issue.range])\n\t\tif (seen.has(key)) continue\n\t\tseen.add(key)\n\t\tdistinct.push(issue)\n\t}\n\treturn distinct\n}\n\n/**\n * Reports whether a path is a workspace module Vitest can cache.\n *\n * @param path - The candidate file path\n * @returns True if the path is a script, TypeScript, Vue, or JSON module; false otherwise\n *\n * @example\n * ```ts\n * matchesWorkspaceModule('src/core/greeting.ts') // true\n * matchesWorkspaceModule('src/styles/tokens.css') // false\n * ```\n */\nexport function matchesWorkspaceModule(path: string): boolean {\n\treturn /\\.(?:[cm]?[jt]sx?|vue|json)$/.test(path)\n}\n\n/**\n * Reports whether the host that wrote one file is still running.\n *\n * @remarks\n * Signal 0 delivers nothing and reports reachability alone. A process this one may not signal\n * reports `EPERM` and reads as running, and a non-positive identity names a process group rather\n * than a process, so both answer true: the safe direction is to keep a file this package cannot\n * account for.\n *\n * @param id - The process id a file's own revision names\n * @returns True if that process is running or cannot be judged; false otherwise\n *\n * @example\n * ```ts\n * matchesLiveProcess(process.pid) // true\n * matchesLiveProcess(0) // true\n * ```\n */\nexport function matchesLiveProcess(id: number): boolean {\n\tif (!isNumber(id) || !Number.isSafeInteger(id) || id <= 0) return true\n\ttry {\n\t\tprocess.kill(id, 0)\n\t\treturn true\n\t} catch (error) {\n\t\treturn readFaultCode(error) === 'EPERM'\n\t}\n}\n\n/**\n * Collects every regular file a target workspace holds, skipping the trees no inspection reads.\n *\n * @remarks\n * Skips a directory named `.git`, `dist`, or `node_modules` at any depth, and the directory\n * {@link TYPE_MIRROR} names, which would otherwise carry this package's own mirror into the walk. A\n * directory this host cannot list is skipped rather than raised, so one unreadable directory in a\n * consumer's tree is not a reason to refuse the whole walk. A symbolic link is not carried, whether\n * it names a file or a directory, so a file reached only through one is absent from the result; a\n * `Dirent` that is neither a directory nor a regular file is skipped the same way.\n *\n * @param workspace - The target workspace root\n * @returns The absolute path of every regular file the walk found\n *\n * @example\n * ```ts\n * collectWorkspaceFiles(process.cwd()).some((path) => path.endsWith('package.json')) // true\n * ```\n */\nexport function collectWorkspaceFiles(workspace: string): readonly string[] {\n\tconst excluded = normalizePath(resolveWorkspaceFile(workspace, TYPE_MIRROR))\n\tconst files: string[] = []\n\tconst directories = [resolve(workspace)]\n\twhile (directories.length > 0) {\n\t\tconst directory = directories.pop()\n\t\tif (directory === undefined) break\n\t\tlet entries: readonly Dirent[] = []\n\t\ttry {\n\t\t\tentries = readdirSync(directory, { withFileTypes: true })\n\t\t} catch {}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name === '.git' || entry.name === 'dist' || entry.name === 'node_modules') continue\n\t\t\tconst path = join(directory, entry.name)\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (normalizePath(path) !== excluded) directories.push(path)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (entry.isFile()) files.push(path)\n\t\t}\n\t}\n\treturn files\n}\n\n/**\n * Normalizes a caught or foreign error into readable text.\n *\n * @param value - The value to describe\n * @returns Its message when present, or its string representation\n *\n * @example\n * ```ts\n * describeUnknown(new Error('The lint stage has been destroyed'))\n * // 'The lint stage has been destroyed'\n * describeUnknown(17) // '17'\n * ```\n */\nexport function describeUnknown(value: unknown): string {\n\tif (isError(value)) return value.message\n\tif (isObject(value) && 'message' in value && isString(value.message)) {\n\t\treturn value.message\n\t}\n\treturn String(value)\n}\n\n/**\n * Guards one stage operation with the stage failure contract.\n *\n * @param stage - The stage serving the operation\n * @param operation - The operation to settle\n * @returns The operation's fulfilled value\n * @throws The original `ProbeError`, or an instrument-owned malformed failure retaining the cause\n *\n * @example\n * ```ts\n * await guardStage('type', stage.inspect(subject))\n * ```\n */\nexport async function guardStage<T>(stage: Stage, operation: Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await operation\n\t} catch (error) {\n\t\tif (isProbeError(error)) throw error\n\t\tthrow new ProbeError(`The ${stage} stage could not serve (${describeUnknown(error)})`, {\n\t\t\torigin: 'instrument',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { stage },\n\t\t\tcause: error,\n\t\t})\n\t}\n}\n\n/**\n * Names every draft member of a claim-shaped value whose `path` this package's guard refuses.\n *\n * @remarks\n * The published claim schema constrains `Draft.path` to a non-empty string and nothing else, while\n * `isDraft` also refuses an absolute path and one that escapes the workspace. That one member is\n * the whole of the difference between the advertised contract and the enforced one, so a caller\n * refused after satisfying the schema is refused here and nowhere else. The whole input must first\n * satisfy that schema. Each draft is then tested with `isDraft` itself rather than with a second\n * copy of its rule. Reports nothing for a value carrying no draft member, including one refused for\n * a member this contract does not declare.\n *\n * This function lives in the server helpers rather than in core: core's leaf pair, `helpers.ts` and\n * `validators.ts`, may not consume the shapes module this function reads `CLAIM_SHAPE` from, and\n * `ProbeServer` is the sole consumer of the result it returns.\n *\n * @param value - The rejected tool input\n * @returns The dotted member names, in `case` then `control` order, or an empty list\n *\n * @example\n * ```ts\n * const test = { path: 'tmp/probes/greeting.test.ts', text: '' }\n * findRefusedPaths({\n * \tproject: 'tsconfig.json',\n * \tcase: { files: [{ path: '../../etc/hosts', text: '' }], test },\n * \tcontrol: { files: [], test, stage: 'type', reason: 'must not compile' },\n * })\n * // ['case.files.0.path']\n * ```\n */\nexport function findRefusedPaths(value: unknown): readonly string[] {\n\tif (!compileGuard(CLAIM_SHAPE)(value)) return []\n\tconst members: string[] = []\n\tfor (const phase of ['case', 'control'] as const) {\n\t\tconst subject = value[phase]\n\t\tconst drafts = new Map<string, unknown>([[`${phase}.test`, subject.test]])\n\t\tfor (const [index, file] of subject.files.entries()) {\n\t\t\tdrafts.set(`${phase}.files.${index}`, file)\n\t\t}\n\t\tfor (const [member, draft] of drafts) {\n\t\t\tif (isDraft(draft)) continue\n\t\t\tmembers.push(`${member}.path`)\n\t\t}\n\t}\n\treturn members\n}\n\n/**\n * Rewrites every workspace-contained absolute path in a value to its workspace-relative form and\n * sorts every record's keys.\n *\n * @remarks\n * `tsc --showConfig` spells a path relative to the project file, so a printed record carries an\n * absolute path only where a project itself declares one. Rewriting a contained absolute path to\n * its relative form keeps one commit checked out at two roots reading to one digest. A path that\n * escapes the workspace is left as it stands, because rewriting it would name a file outside the\n * tree by a relative spelling. Key order is the compiler's own and it differs between the supported\n * majors, so sorting removes a difference that means nothing.\n *\n * @param workspace - The target workspace root\n * @param value - The value to rewrite\n * @returns The value with contained absolute paths made relative and every record key sorted\n *\n * @example\n * ```ts\n * normalizeValue('/srv/checkout', { rootDir: '/srv/checkout/src/core', strict: true })\n * // { rootDir: 'src/core', strict: true }\n * ```\n */\nexport function normalizeValue(workspace: string, value: unknown): unknown {\n\tconst root = resolve(workspace)\n\tif (isString(value)) {\n\t\tif (!isAbsolute(value)) return value\n\t\tconst path = relative(root, resolve(value))\n\t\tif (path === '') return '.'\n\t\tif (escapesRoot(root, value)) return value\n\t\treturn normalizePath(path)\n\t}\n\tif (isArray(value)) return value.map((entry) => normalizeValue(workspace, entry))\n\tif (isRecord(value)) {\n\t\tconst record: Record<string, unknown> = {}\n\t\tfor (const key of Object.keys(value).sort()) record[key] = normalizeValue(workspace, value[key])\n\t\treturn record\n\t}\n\treturn value\n}\n\n/**\n * Computes the canonical digest of one value as it stands in a target workspace.\n *\n * @remarks\n * Digests the normalized value rather than the value itself, so one commit read at two absolute\n * roots produces one digest and a digest carries no host path. The result is the leading 32 hex\n * characters of a SHA-256 over the normalized JSON.\n *\n * @param workspace - The target workspace root the value's paths are read against\n * @param value - The value to digest\n * @returns 32 lowercase hex characters\n *\n * @example\n * ```ts\n * computeDigest('/srv/checkout', { strict: true }).length // 32\n * ```\n */\nexport function computeDigest(workspace: string, value: unknown): string {\n\treturn createHash('sha256')\n\t\t.update(JSON.stringify(normalizeValue(workspace, value)))\n\t\t.digest('hex')\n\t\t.slice(0, 32)\n}\n\n/**\n * Records the listeners one emitter carries for a set of events.\n *\n * @param emitter - The emitter to read\n * @param events - The event names to record\n * @returns The listeners each named event carries at the moment of the call\n *\n * @example\n * ```ts\n * const capture = captureListeners(process, ['SIGTERM'])\n * capture.get('SIGTERM')?.length === process.listenerCount('SIGTERM') // true\n * ```\n */\nexport function captureListeners(\n\temitter: EventEmitter,\n\tevents: readonly string[],\n): ListenerCapture {\n\tconst capture = new Map<string, readonly Function[]>()\n\tfor (const event of events) capture.set(event, emitter.listeners(event))\n\treturn capture\n}\n\n/**\n * Removes every listener one emitter gained for the captured events since its capture.\n *\n * @remarks\n * Compares identity rather than name, so a listener whose name a dependency changes between\n * releases is still recognized and a listener that merely shares a name is still left alone. A\n * listener the capture already held survives, and a listener the capture held that has since been\n * removed is not restored.\n *\n * A gain is not evidence of who caused it, so this reads every gain as the callee's. Call it only\n * across a window nothing else can attach in — a synchronous call, or a call whose handlers land\n * before its first await and that is released as it returns — because a listener anyone else\n * attaches inside that window is removed with the rest. Where a caller cannot promise that window,\n * hold each handler as a field and remove it by reference instead of capturing at all.\n *\n * @param emitter - The emitter to release\n * @param capture - The listeners the emitter carried at capture time\n * @returns Nothing\n *\n * @example\n * ```ts\n * const capture = captureListeners(process, ['SIGTERM'])\n * process.on('SIGTERM', () => {})\n * releaseListeners(process, capture)\n * process.listenerCount('SIGTERM') === capture.get('SIGTERM')?.length // true\n * ```\n */\nexport function releaseListeners(emitter: EventEmitter, capture: ListenerCapture): void {\n\tfor (const [event, captured] of capture) {\n\t\tfor (const listener of emitter.listeners(event)) {\n\t\t\tif (captured.includes(listener)) continue\n\t\t\temitter.removeListener(event, listener)\n\t\t}\n\t}\n}\n","import type { ProjectConfig } from './types.js'\nimport { isArray, isRecord, parseJSON, isString } from '@orkestrel/contract'\n\n/**\n * Parses the configuration one compiler run printed for a TypeScript project.\n *\n * @remarks\n * Reads what `tsc --showConfig` writes: a JSON record carrying the resolved `compilerOptions`\n * beside the project's own file selection. `compilerOptions` is carried unvalidated, because a\n * caller digests it rather than reading a member out of it. `files` and `include` are read only\n * where the printed record carries one whose entries are all strings, so a member the compiler\n * printed in another shape reads as absent rather than as an empty selection. Text that is not a\n * JSON record, including the diagnostic the compiler prints for a project it refuses, yields\n * `undefined`.\n *\n * @param text - The compiler's printed configuration\n * @returns The project's resolved configuration, or `undefined` when the text carries no record\n *\n * @example\n * ```ts\n * parseProjectConfig('{\"compilerOptions\":{\"strict\":true}}')?.compilerOptions // { strict: true }\n * parseProjectConfig(\"error TS5058: The specified path does not exist.\") // undefined\n * ```\n */\nexport function parseProjectConfig(text: string): ProjectConfig | undefined {\n\tconst parsed = parseJSON(text)\n\tif (!isRecord(parsed)) return undefined\n\tconst files = parsed.files\n\tconst include = parsed.include\n\treturn {\n\t\tcompilerOptions: parsed.compilerOptions,\n\t\t...(isArray(files) && files.every(isString) ? { files } : {}),\n\t\t...(isArray(include) && include.every(isString) ? { include } : {}),\n\t}\n}\n\n/**\n * Parses the process id one revision identity names.\n *\n * @remarks\n * Every file and directory this package writes into a target carries the writing host's process id\n * and a fresh UUID, joined by `-`. A sweep reads that id to decide whether the host that wrote the\n * name is gone. The whole identity must match, so a name carrying anything else yields `undefined`\n * and the sweep leaves what it found alone.\n *\n * @param revision - The revision identity a name carries\n * @returns The process id it names, or `undefined` when the text is not a revision identity\n *\n * @example\n * ```ts\n * parseRevisionOwner('4821-1b4e28ba-2fa1-11d2-883f-0016d3cca427') // 4821\n * parseRevisionOwner('4821-9f0c') // undefined\n * ```\n */\nexport function parseRevisionOwner(revision: string): number | undefined {\n\tconst match = /^(\\d+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u.exec(\n\t\trevision,\n\t)\n\tconst owner = match?.[1]\n\treturn owner === undefined ? undefined : Number.parseInt(owner, 10)\n}\n","import type { OverlayInterface } from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport { normalizePath } from './helpers.js'\n\n/**\n * Implements `OverlayInterface` over a private map from normalized absolute path to candidate text,\n * minting at construction the `revision` a resident tool caches its answers against.\n *\n * @remarks\n * One overlay belongs to one inspection: the inspection creates it, records every candidate it\n * carries, and clears it when the inspection ends. Each stage adapts the same set to the host its\n * own tool expects rather than sharing one filesystem across tools. A fresh identity per instance\n * is what makes a resident tool re-read a path this overlay holds, so two inspections that supply\n * different text for one path never share a cached answer.\n *\n * A lookup key matches a recorded path exactly, after both pass through `normalizePath`, so a tool\n * that reports its own paths with backslashes still reaches a candidate recorded with forward\n * slashes. Case is never folded: the recorded spelling is what `paths` reports, what `covers`\n * compares a directory against, and what `text` answers under. A stage whose tool resolves two\n * spellings of one file name to one file therefore reports the path its tool served rather than\n * matching the two spellings here.\n *\n * @example\n * ```ts\n * const overlay = new Overlay()\n * const path = '/srv/checkout/src/core/factories.ts'\n * overlay.set(path, \"export function createGreeting(): string {\\n\\treturn 'hi'\\n}\\n\")\n * console.log(overlay.text(path))\n * overlay.clear()\n * ```\n */\nexport class Overlay implements OverlayInterface {\n\treadonly #revision = randomUUID()\n\treadonly #candidates = new Map<string, string>()\n\n\tget revision(): string {\n\t\treturn this.#revision\n\t}\n\n\tget paths(): readonly string[] {\n\t\treturn [...this.#candidates.keys()]\n\t}\n\n\t/**\n\t * Records one candidate's text against the absolute path it stands in for.\n\t *\n\t * @remarks\n\t * Recording a candidate under a path this overlay already holds replaces that candidate, the way\n\t * one file holds one text.\n\t *\n\t * @param path - The absolute path the candidate replaces\n\t * @param text - The candidate's full contents\n\t * @returns Nothing\n\t */\n\tset(path: string, text: string): void {\n\t\tthis.#candidates.set(normalizePath(path), text)\n\t}\n\n\t/**\n\t * Reads the candidate text recorded for one absolute path.\n\t *\n\t * @param path - The absolute path to read\n\t * @returns The recorded text, or `undefined` when this overlay holds no candidate there\n\t */\n\ttext(path: string): string | undefined {\n\t\treturn this.#candidates.get(normalizePath(path))\n\t}\n\n\t/**\n\t * Checks whether a candidate sits beneath one directory.\n\t *\n\t * @remarks\n\t * The answer is derived from the paths the overlay holds rather than stored, so it stops being\n\t * true exactly when the inspection that declared those candidates clears them. Both sides pass\n\t * through `normalizePath` first, because a tool that normalizes its own paths asks about a\n\t * directory in a spelling the recorded path may not share.\n\t *\n\t * @param directory - The absolute directory path to check\n\t * @returns True if a candidate path sits beneath the directory; false otherwise\n\t */\n\tcovers(directory: string): boolean {\n\t\tconst base = `${normalizePath(directory).replace(/\\/+$/, '')}/`\n\t\tfor (const path of this.#candidates.keys()) {\n\t\t\tif (path.startsWith(base)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\t/**\n\t * Releases every candidate.\n\t *\n\t * @returns Nothing\n\t */\n\tclear(): void {\n\t\tthis.#candidates.clear()\n\t}\n}\n","{\n\t\"name\": \"@orkestrel/probe\",\n\t\"version\": \"0.0.19\",\n\t\"description\": \"Prove a claim with type, lint, and runtime evidence from the workspace's own toolchain.\",\n\t\"keywords\": [\n\t\t\"agent\",\n\t\t\"lint\",\n\t\t\"mcp\",\n\t\t\"oxlint\",\n\t\t\"probe\",\n\t\t\"typescript\",\n\t\t\"vitest\"\n\t],\n\t\"homepage\": \"https://github.com/orkestrel/probe#readme\",\n\t\"bugs\": \"https://github.com/orkestrel/probe/issues\",\n\t\"license\": \"MIT\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/orkestrel/probe.git\"\n\t},\n\t\"bin\": {\n\t\t\"probe\": \"dist/bin/main.js\"\n\t},\n\t\"files\": [\n\t\t\"dist/src\",\n\t\t\"dist/bin\",\n\t\t\"README.md\"\n\t],\n\t\"type\": \"module\",\n\t\"sideEffects\": [\n\t\t\"./src/bin/main.ts\",\n\t\t\"./dist/bin/main.js\"\n\t],\n\t\"main\": \"./dist/src/core/index.cjs\",\n\t\"module\": \"./dist/src/core/index.js\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/src/core/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/src/core/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/src/core/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/src/core/index.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./server\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/src/server/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/src/server/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/src/server/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/src/server/index.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"scripts\": {\n\t\t\"clean\": \"node -e \\\"require('node:fs').rmSync('dist',{recursive:true,force:true})\\\"\",\n\t\t\"copy\": \"node -e \\\"const fs=require('node:fs'),p=require('node:path'),a=process.argv[1],b=process.argv[2];fs.mkdirSync(p.dirname(b),{recursive:true});fs.cpSync(a,b,{force:true});console.log('Copied: '+a+' to '+b)\\\"\",\n\t\t\"format\": \"oxfmt --config .oxfmtrc.json --write .\",\n\t\t\"format:check\": \"oxfmt --config .oxfmtrc.json --check .\",\n\t\t\"lint\": \"oxlint --config .oxlintrc.json --fix .\",\n\t\t\"lint:check\": \"oxlint --config .oxlintrc.json --deny-warnings .\",\n\t\t\"check\": \"tsc --noEmit --project tsconfig.json && npm run check:src\",\n\t\t\"check:src\": \"npm run check:src:core && npm run check:src:server && npm run check:src:bin\",\n\t\t\"check:src:core\": \"tsc --noEmit -p configs/src/tsconfig.core.json\",\n\t\t\"check:src:server\": \"tsc --noEmit -p configs/src/tsconfig.server.json\",\n\t\t\"check:src:bin\": \"tsc --noEmit -p configs/src/tsconfig.bin.json\",\n\t\t\"test\": \"npm run test:src && npm run test:policy && npm run test:config && npm run test:setup && npm run test:guides\",\n\t\t\"test:src\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core --project src:server --project src:bin\",\n\t\t\"test:src:core\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core\",\n\t\t\"test:src:server\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:server\",\n\t\t\"test:src:bin\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:bin\",\n\t\t\"test:policy\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project policy\",\n\t\t\"test:config\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project config\",\n\t\t\"test:setup\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project setup\",\n\t\t\"test:guides\": \"node --experimental-strip-types tests/guides.test.ts\",\n\t\t\"test:distribution\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project distribution\",\n\t\t\"test:probe\": \"vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe\",\n\t\t\"test:bench\": \"vitest bench --config vite.config.ts --no-cache --project probe\",\n\t\t\"build\": \"npm run clean && npm run build:src\",\n\t\t\"build:src\": \"npm run build:src:core && npm run build:src:server && npm run build:src:bin\",\n\t\t\"build:src:core\": \"vite build --config configs/src/vite.core.config.ts && npm run copy dist/src/core/index.d.ts dist/src/core/index.d.cts\",\n\t\t\"build:src:server\": \"vite build --config configs/src/vite.server.config.ts && npm run copy dist/src/server/index.d.ts dist/src/server/index.d.cts\",\n\t\t\"build:src:bin\": \"vite build --config configs/src/vite.bin.config.ts\",\n\t\t\"prepack\": \"npm run build\",\n\t\t\"prepublishOnly\": \"npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:distribution -- --mode release\"\n\t},\n\t\"dependencies\": {\n\t\t\"@orkestrel/contract\": \"^0.0.18\",\n\t\t\"@orkestrel/emitter\": \"^0.0.11\",\n\t\t\"@orkestrel/lsp\": \"^0.0.10\",\n\t\t\"@orkestrel/mcp\": \"^0.0.33\",\n\t\t\"@orkestrel/queue\": \"^0.0.15\",\n\t\t\"@orkestrel/timeout\": \"^0.0.12\",\n\t\t\"@orkestrel/tool\": \"^0.0.17\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@microsoft/api-extractor\": \"^7.59.3\",\n\t\t\"@orkestrel/guide\": \"^0.0.21\",\n\t\t\"@orkestrel/scaffold\": \"^0.0.80\",\n\t\t\"@orkestrel/test\": \"^0.0.24\",\n\t\t\"@types/node\": \"^26.6.3\",\n\t\t\"oxfmt\": \"^0.71.0\",\n\t\t\"oxlint\": \"^1.86.0\",\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vite\": \"^8.3.1\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"typescript\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"vitest\": {\n\t\t\t\"optional\": true\n\t\t}\n\t},\n\t\"engines\": {\n\t\t\"node\": \"^22.12.0 || >=24.0.0\"\n\t}\n}\n","import type { Case, Check, Draft, Issue, Stage } from '@src/core'\nimport type { InspectionOptions, LintStageInterface } from '../types.js'\nimport type { LSPClientInterface, LSPDiagnostic, LSPExit } from '@orkestrel/lsp'\nimport { pathToFileURL } from 'node:url'\nimport { createLSPClient } from '@orkestrel/lsp'\nimport { createStdioClientTransport } from '@orkestrel/lsp/server'\nimport { LINT_DEADLINE, ProbeError, createDestroyedError } from '@src/core'\nimport { isError } from '@orkestrel/contract'\nimport {\n\tdescribeUnknown,\n\tguardStage,\n\tinferDocumentLanguage,\n\tnormalizePath,\n\tresolveWorkspaceBinary,\n\tresolveWorkspaceFile,\n} from '../helpers.js'\n\n/**\n * Inspects virtual documents through one resident Oxlint language server.\n *\n * @remarks\n * Construction starts the target workspace's Oxlint binary with its Language Server Protocol mode\n * and hands the conversation to `@orkestrel/lsp`: `createStdioClientTransport` owns the child\n * process and its bytes, and `createLSPClient` owns the framing, the request correlation, the\n * capabilities this stage advertises, and the choice between pulled and pushed diagnostics. This\n * stage owns the workspace, the candidate identity, and the projection from a diagnostic to an\n * `Issue`.\n *\n * Each inspection opens the supplied text by URI, waits for the client's diagnostics, and closes the\n * document without writing it to disk. The caller's own signal is what bounds that wait, so a server\n * that admits a document and publishes nothing refuses the inspection when the caller's bound\n * expires rather than holding it for the life of the process. This stage mints no bound of its own\n * for the wait: a second one would race the caller's, and the answer would depend on scheduling.\n *\n * Teardown is bounded at both ends. Warming waits for the server's `initialize` response and the\n * ending waits for its `shutdown` reply, and the protocol leaves both answers to the server, so the\n * client's deadline bounds each exchange and the transport's cooperative window takes the ending\n * back with a signal when that window passes.\n *\n * The URI is the path the candidate declared, so the candidate receives exactly the rule set the\n * workspace's own lint gate applies to that path, including an override anchored to one directory,\n * one file name, or one exact file. A path the workspace's version-control ignore files exclude is\n * a path that gate never lints, and this stage reports the same nothing for it. Reuse of one\n * declared path across inspections is what the caller's own serialization protects: the stage\n * refuses a second inspection of a path it already has open rather than answering either one with\n * the other's diagnostics.\n *\n * @example\n * ```ts\n * const stage = new LintStage('/srv/checkout')\n * const check = await stage.inspect(subject, { signal: AbortSignal.timeout(30_000) })\n * await stage.destroy()\n * ```\n */\nexport class LintStage implements LintStageInterface {\n\treadonly #workspace: string\n\treadonly #documents = new Set<string>()\n\treadonly #warmth: Promise<LSPClientInterface>\n\t// Teardown reads the constructed client rather than the warming result, because a warming that\n\t// failed or that is still waiting for its answer still leaves a client and a child to release.\n\t#client: LSPClientInterface | undefined\n\t#ending: string | undefined\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before the\n\t// teardown it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t// The version every document this stage opens carries. It counts admissions across the stage's\n\t// whole life and never falls, because the gauge beside it does fall and a version that fell would\n\t// tell the server this text is older than the text it replaced.\n\t#revision = 0\n\n\t/**\n\t * Starts warming the target workspace's Oxlint language server.\n\t *\n\t * @param workspace - The target workspace root. Default: the current working directory\n\t */\n\tconstructor(workspace: string = process.cwd()) {\n\t\tthis.#workspace = workspace\n\t\tthis.#warmth = this.#warm()\n\t\t// Observe the stored promise here. Nothing reads it until an inspection or a teardown\n\t\t// arrives, and an unobserved rejection ends the host process. The stored promise keeps\n\t\t// rejecting, so an inspection still reports the warming failure.\n\t\tvoid this.#warmth.catch(() => {})\n\t}\n\n\tget stage(): Stage {\n\t\treturn 'lint'\n\t}\n\n\tget progress(): number {\n\t\treturn this.#progress\n\t}\n\n\tinspect(subject: Case, options?: InspectionOptions): Promise<Check> {\n\t\treturn guardStage(this.stage, this.#inspect(subject, options))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = guardStage(this.stage, this.#destroy())\n\t\treturn this.#closing\n\t}\n\n\tasync #inspect(subject: Case, options: InspectionOptions | undefined): Promise<Check> {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('lint stage')\n\t\t// The shared stage contract takes one argument, so this bound is optional in the type and\n\t\t// required in fact. Serving without it would mean minting a bound beside the caller's, which\n\t\t// is the racing pair this seam exists to remove.\n\t\tif (options === undefined) {\n\t\t\tthrow new ProbeError('The lint stage inspects only under a bound its caller supplies', {\n\t\t\t\torigin: 'claimant',\n\t\t\t\tcode: 'refused',\n\t\t\t\tcontext: { stage: this.stage },\n\t\t\t})\n\t\t}\n\t\tconst started = performance.now()\n\t\tconst client = await this.#warmed()\n\t\tif (this.#closing !== undefined) throw createDestroyedError('lint stage')\n\t\tconst issues: Issue[] = []\n\t\tfor (const draft of [...subject.files, subject.test]) {\n\t\t\tissues.push(...(await this.#document(client, draft, options.signal)))\n\t\t}\n\t\treturn {\n\t\t\tstage: this.stage,\n\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\tissues,\n\t\t}\n\t}\n\n\t// Releases the client, which ends its conversation and its child. The client asks the server to\n\t// shut down, bounds that reply, writes the `exit` the protocol leaves to the client to force,\n\t// and hands a child that outlives the cooperative window to a signal, so a server that answers\n\t// neither its ending nor its signal is released rather than deadlocking this call.\n\tasync #destroy(): Promise<void> {\n\t\tawait this.#client?.destroy()\n\t}\n\n\t// Builds the conversation and warms it. Everything before the first await runs while the\n\t// constructor is still on the stack, so teardown finds the client whatever the warming does\n\t// next; a workspace that publishes no Oxlint binary rejects here instead, and leaves none.\n\tasync #warm(): Promise<LSPClientInterface> {\n\t\tconst binary = resolveWorkspaceBinary(this.#workspace, 'oxlint')\n\t\tconst client = createLSPClient({\n\t\t\ttransport: createStdioClientTransport({\n\t\t\t\tserver: {\n\t\t\t\t\tcommand: [process.execPath, binary, '--lsp'],\n\t\t\t\t\tdirectory: this.#workspace,\n\t\t\t\t},\n\t\t\t\tgrace: LINT_DEADLINE / 2,\n\t\t\t}),\n\t\t\tworkspace: pathToFileURL(this.#workspace).href,\n\t\t\ttimeout: LINT_DEADLINE,\n\t\t})\n\t\tthis.#client = client\n\t\tclient.emitter.on('exit', (exit) => this.#retire(exit))\n\t\tawait client.start()\n\t\treturn client\n\t}\n\n\t// Reads the warmed client, phrasing a warming failure the way this stage reports one.\n\tasync #warmed(): Promise<LSPClientInterface> {\n\t\ttry {\n\t\t\treturn await this.#warmth\n\t\t} catch (error) {\n\t\t\tthrow this.#translate(error)\n\t\t}\n\t}\n\n\t// Names one ending for a message. The host announces an exit with exactly one non-null member,\n\t// and the client reports the signalled death and the code exit through the same event, so a\n\t// later inspection can say which one the server took.\n\t#retire(exit: LSPExit): void {\n\t\tthis.#ending = exit.signal === null ? `code ${exit.code}` : `signal ${exit.signal}`\n\t}\n\n\t// Opens one candidate at the path it was declared. Oxlint keys its overrides on globs, so any\n\t// identity distinct from that path selects a different rule set from the one the workspace's own\n\t// gate applies, and an override naming one exact file is reachable by nothing else. One URI\n\t// carries one open document, so a caller driving two inspections of one path at once is refused\n\t// rather than served an answer belonging to the other. The document is closed whatever the\n\t// inspection returned, so the same path is inspectable again.\n\tasync #document(\n\t\tclient: LSPClientInterface,\n\t\tdraft: Draft,\n\t\tsignal: AbortSignal,\n\t): Promise<readonly Issue[]> {\n\t\tconst uri = pathToFileURL(resolveWorkspaceFile(this.#workspace, draft.path)).href\n\t\tif (this.#documents.has(uri)) {\n\t\t\tthrow new ProbeError(`The lint stage is already inspecting ${draft.path}`, {\n\t\t\t\torigin: 'claimant',\n\t\t\t\tcode: 'refused',\n\t\t\t\tcontext: { stage: this.stage, path: draft.path },\n\t\t\t})\n\t\t}\n\t\tthis.#documents.add(uri)\n\t\t// Raise the gauge as the document is admitted rather than when its answer arrives, so a\n\t\t// coordinator comparing its snapshot reads claimant-owned work in flight, and lower it again\n\t\t// in the `finally` block before the close this stage owes its own instrument is awaited, so\n\t\t// an expiry during that cleanup reads level with the snapshot and names the instrument.\n\t\tthis.#progress += 1\n\t\tthis.#revision += 1\n\t\ttry {\n\t\t\tconst diagnostics = await client.open(\n\t\t\t\t{\n\t\t\t\t\turi,\n\t\t\t\t\tlanguageId: inferDocumentLanguage(draft.path),\n\t\t\t\t\tversion: this.#revision,\n\t\t\t\t\ttext: draft.text,\n\t\t\t\t},\n\t\t\t\t{ signal },\n\t\t\t)\n\t\t\treturn this.#issues(normalizePath(draft.path), diagnostics)\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw this.#abandoned(draft.path)\n\t\t\tthrow this.#translate(error, draft.path)\n\t\t} finally {\n\t\t\tthis.#progress -= 1\n\t\t\tthis.#documents.delete(uri)\n\t\t\t// A server that ended, and a client that is closing, can no longer be told the document\n\t\t\t// closed. Neither failure may replace the diagnosis the caller is receiving.\n\t\t\tawait client.close(uri).catch(() => undefined)\n\t\t}\n\t}\n\n\t// Names the caller's own bound as what ended one wait. The client reports its cancellation as a\n\t// transport failure, and `guardStage` would carry that to the caller as this stage's fault, which\n\t// tells a coordinator the instrument broke when the instrument was told to stop. A coordinator\n\t// that armed the signal replaces this with its own refusal; a coordinator of the caller's own\n\t// reads it directly.\n\t#abandoned(path: string): ProbeError {\n\t\treturn new ProbeError('The lint stage inspection stopped at the bound its caller supplied', {\n\t\t\torigin: 'claimant',\n\t\t\tcode: 'deadline',\n\t\t\tcontext: { stage: this.stage, path },\n\t\t})\n\t}\n\n\t// Phrases one failure the way this stage reports one. A destroyed stage refuses on its own\n\t// terms, a server that ended is named by the ending it took, and everything else is the\n\t// client's own coded failure, which `guardStage` carries to the caller as this stage's fault.\n\t#translate(error: unknown, path?: string): Error {\n\t\tif (this.#closing !== undefined) return createDestroyedError('lint stage')\n\t\tconst ending = this.#ending\n\t\tif (ending !== undefined) {\n\t\t\treturn this.#fault(`The Oxlint language server exited with ${ending}`, error, path)\n\t\t}\n\t\tif (isError(error)) return error\n\t\treturn this.#fault(describeUnknown(error), error, path)\n\t}\n\n\t// Every fault this stage reports about its own language server, under one category and naming\n\t// the stage that produced it. A caller catching one is told the inspection did not complete,\n\t// which is a different answer from a diagnostic about the candidate it supplied.\n\t#fault(message: string, cause?: unknown, path?: string): ProbeError {\n\t\treturn new ProbeError(message, {\n\t\t\torigin: 'instrument',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { stage: this.stage, ...(path === undefined ? {} : { path }) },\n\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t})\n\t}\n\n\t// Every issue here is one diagnostic Oxlint published about the text the caller supplied, so\n\t// each one is that code failing. A server this stage cannot drive rejects the inspection\n\t// instead, so no fault of its own reaches a caller as an issue. The published range is already\n\t// the zero-based UTF-16 span the issue stores, so no conversion happens here; each coordinate is\n\t// read once into a span this package owns rather than the diagnostic's own object being carried\n\t// into a value that outlives the inspection.\n\t#issues(path: string, diagnostics: readonly LSPDiagnostic[]): readonly Issue[] {\n\t\treturn diagnostics.map((diagnostic): Issue => ({\n\t\t\torigin: 'claimant',\n\t\t\tpath,\n\t\t\tmessage: diagnostic.message,\n\t\t\trange: {\n\t\t\t\tstart: {\n\t\t\t\t\tline: diagnostic.range.start.line,\n\t\t\t\t\tcharacter: diagnostic.range.start.character,\n\t\t\t\t},\n\t\t\t\tend: { line: diagnostic.range.end.line, character: diagnostic.range.end.character },\n\t\t\t},\n\t\t}))\n\t}\n}\n","import type { Case, Check, Draft, Issue, Stage } from '@src/core'\nimport type { OverlayInterface, StageInterface } from '../types.js'\nimport type {\n\tTestProjectConfiguration,\n\tUserProjectConfigFn,\n\tUserWorkspaceConfig,\n\tViteUserConfig,\n} from 'vitest/config'\nimport type { TestProject, TestRunResult, Vitest, createVitest } from 'vitest/node'\nimport {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\trealpathSync,\n\tunlinkSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { basename, dirname, extname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport { fileURLToPath } from 'node:url'\nimport { attempt, isArray, isNumber, isObject, isString } from '@orkestrel/contract'\nimport {\n\tPROBE_SPECIFICATIONS,\n\tProbeError,\n\tRUNTIME_PLUGIN,\n\tcreateDestroyedError,\n\tformatSpecification,\n\tisProbeError,\n\tmatchesSpecification,\n} from '@src/core'\nimport {\n\tbuildRevisionPath,\n\tcaptureListeners,\n\tcollectWorkspaceFiles,\n\tdescribeUnknown,\n\tguardStage,\n\tinferTestProject,\n\tisRefusedName,\n\tloadWorkspaceVitest,\n\tmatchesLiveProcess,\n\tmatchesWorkspaceModule,\n\tnormalizePath,\n\treleaseListeners,\n\trelativeWorkspaceFile,\n\trelativeWorkspaceMessage,\n\tresolveWorkspaceFile,\n} from '../helpers.js'\nimport { Overlay } from '../Overlay.js'\n\n/**\n * Inspects tests through one resident Vitest service from the target workspace.\n *\n * @remarks\n * Construction starts Vitest with the threads pool and instruments each inline or function-declared\n * project with a Vite plugin that reads the active inspection's candidate overlay. A selected\n * string-declared project reports a workspace issue because its configuration carries no runtime\n * overlay plugin. Every inspection writes one fresh sibling specification, invalidates each\n * workspace module whose disk content or candidate revision changed, runs that specification,\n * evicts its result, and deletes the file. Clearing the overlay makes the next snapshot differ from\n * the candidate revision, so the next inspection invalidates that module and reads disk again.\n * After the run, the stage checks each covered module reachable from the generated specification\n * against the overlay paths its loader served. A target-config loader that served first produces a\n * workspace issue; a module id probe's loader received but failed to match produces an instrument\n * issue.\n * The runtime overlay leaves bare specifier resolution to Vite: it replaces a bare import only\n * after Vite resolves that import to a covered file. The type stage overlays the declared test\n * path, while this stage executes a generated sibling and overlays only the candidate files.\n * This stage mints its overlay with the default exact-match sensitivity, because it declares no\n * file-name case sensitivity to Vite. A covered path whose spelling an importer wrote differs from\n * the recorded candidate path is therefore served by whatever answers first, and `#misses` reports\n * it as `The workspace configuration served this module before the runtime overlay` with origin\n * `workspace` rather than leaving it answered silently.\n *\n * Vite retains one unresolved URL for every specification path, so the stage replaces its whole\n * Vitest service after 64 specifications rather than deleting from each map that service owns. Any\n * bound holds the retention flat, because the replacement releases everything the instance held,\n * and 64 is the value chosen. The inspection that crosses the bound pays the replacement\n * synchronously: it closes the resident service and warms a new one before it runs. On 2026-08-20,\n * over this package's own workspace on the host `guides/probe.md` § Cost names, two runs of 66\n * inspections put that one at 480 ms and 269 ms against median inspections of 156 ms and 155 ms, so\n * budget one call in 64 at 110 ms to 330 ms above the rest.\n *\n * Every issue this stage emits names its party, and the stage emits an issue for every party\n * `Party` declares. An `origin: 'claimant'` issue is a failure Vitest reported about the candidate.\n * An `origin: 'workspace'` issue names the target tree: a project the root configuration declares\n * as a path string, into which the stage can install no overlay, and a specification path that\n * crosses a symbolic link, whose existing components this host cannot inspect, or whose directory\n * the target tree blocks probe from creating. An `origin: 'instrument'` issue names this package's\n * own machinery: a specification it could not write after its directory exists and the host did not\n * refuse the caller's own name, or one it could not run, evict, or delete, in each case for a\n * reason the target tree does not own, and a run that reported no test. An unmapped caller test and\n * a test whose named project is absent are claimant failures with `code: 'missing'`, and a declared\n * test path the host refuses to create is a claimant failure with `code: 'refused'`. Each is thrown\n * rather than reported, because a test that never ran is no evidence about the candidate.\n *\n * Physical containment covers the claim inputs, the target tree as the walk inspected it, and the\n * final component at the moment this stage writes or unlinks it: a specification is created with the\n * `wx` flag, which fails rather than following a symbolic link that appeared after the walk, and an\n * unlink names the final component itself rather than what it points at. A directory component\n * swapped for a symbolic link between the walk and the write stays open, because Node exposes no\n * descriptor-relative call to pin the walk and the write to one set of descriptors.\n *\n * @example\n * ```ts\n * const stage = new RuntimeStage('/srv/checkout')\n * const check = await stage.inspect(subject)\n * await stage.destroy()\n * ```\n */\nexport class RuntimeStage implements StageInterface {\n\treadonly #workspace: string\n\t#vitest: Promise<Vitest> | undefined\n\t#overlay: OverlayInterface = new Overlay()\n\treadonly #loads = new Set<string>()\n\treadonly #reads = new Set<string>()\n\treadonly #modules = new Map<string, string>()\n\treadonly #revisions = new Set<string>()\n\t#specifications = 0\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before the\n\t// teardown it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\n\t/**\n\t * Starts warming the target workspace's Vitest service.\n\t *\n\t * @remarks Loading starts during this call. A loader refusal rejects the owned warm operation\n\t * rather than construction, so `inspect` reports it and `destroy` remains available.\n\t *\n\t * @param workspace - The target workspace root. Default: the current working directory\n\t */\n\tconstructor(workspace: string = process.cwd()) {\n\t\tthis.#workspace = workspace\n\t\tthis.#store(this.#warm())\n\t}\n\n\tget stage(): Stage {\n\t\treturn 'runtime'\n\t}\n\n\tget progress(): number {\n\t\treturn this.#progress\n\t}\n\n\t/**\n\t * Inspects one case.\n\t *\n\t * @param subject - The candidate drafts and test to inspect\n\t * @returns One outcome for this stage\n\t * @throws When the workspace's own tool cannot start or has already been destroyed\n\t */\n\tinspect(subject: Case): Promise<Check> {\n\t\treturn guardStage(this.stage, this.#inspect(subject))\n\t}\n\n\t/**\n\t * Tears down the resident tool or the mirror and releases its resources.\n\t *\n\t * @remarks\n\t * A stage abandons every inspection it holds rather than waiting behind one, so teardown never\n\t * waits for an inspection to return. An abandoned inspection rejects, either at the stage's own\n\t * guard or as the owned tool closes. Teardown is bounded whatever the stage's own tool does: a\n\t * tool that answers neither its warming exchange nor its ending is signalled and released at the\n\t * stage's own deadline. A coordinator replaces a stage whose worker no longer returns because\n\t * teardown neither waits for an inspection nor waits past that deadline.\n\t *\n\t * @returns A promise that settles after the resident tool or the mirror releases its resources\n\t */\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = guardStage(this.stage, this.#destroy())\n\t\treturn this.#closing\n\t}\n\n\tasync #inspect(subject: Case): Promise<Check> {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('runtime stage')\n\t\tconst started = performance.now()\n\t\t// Vitest reports a failed run by setting `process.exitCode` on this host, and a stage that\n\t\t// runs a claim's negative control fails a run deliberately. Restore whatever the host had,\n\t\t// rather than assigning zero over a code the host set for itself.\n\t\tconst exitCode = process.exitCode\n\t\tconst vitest = await this.#runner()\n\t\tif (this.#closing !== undefined) throw createDestroyedError('runtime stage')\n\t\tconst project = this.#project(vitest, subject.test.path)\n\t\tif ('message' in project) {\n\t\t\treturn {\n\t\t\t\tstage: this.stage,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\tissues: [project],\n\t\t\t}\n\t\t}\n\t\tconst overlay = new Overlay()\n\t\tthis.#overlay = overlay\n\t\tthis.#loads.clear()\n\t\tthis.#reads.clear()\n\t\ttry {\n\t\t\tfor (const draft of subject.files) {\n\t\t\t\toverlay.set(resolveWorkspaceFile(this.#workspace, draft.path), draft.text)\n\t\t\t}\n\t\t\tthis.#revalidate(vitest)\n\t\t\tconst specification = this.#specification(subject.test)\n\t\t\tif (!isString(specification)) {\n\t\t\t\treturn {\n\t\t\t\t\tstage: this.stage,\n\t\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\t\tissues: [specification],\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Vitest stores a specification under the exact identifier it is handed, while its deletion\n\t\t\t// handler rewrites the path it is given to forward slashes before looking that key up. So on\n\t\t\t// a host whose separator is a backslash the native spelling is stored and never found again:\n\t\t\t// the eviction below misses, Vitest keeps the module in its file map, and every later run\n\t\t\t// returns it among that run's own results. The module a failed arming left behind then\n\t\t\t// reports as a claimant issue against a clean case and refuses its receipt. Hand Vitest one\n\t\t\t// identifier for the specification, its results, and its eviction. Read the host separator\n\t\t\t// rather than the platform name, for the reason `#invalidate` gives. The file itself is\n\t\t\t// written and deleted through the native path `relative` and `realpathSync` return from this\n\t\t\t// one.\n\t\t\tconst file = sep === '\\\\' ? normalizePath(specification) : specification\n\t\t\tthis.#specifications += 1\n\t\t\tthis.#revisions.add(file)\n\t\t\tlet issues: readonly Issue[] = []\n\t\t\tlet cleanup: readonly Issue[] = []\n\t\t\tconst task = project.createSpecification(file, undefined, 'threads')\n\t\t\tthis.#progress += 1\n\t\t\ttry {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await vitest.runTestSpecifications([task], false)\n\t\t\t\t\tissues = [\n\t\t\t\t\t\t...this.#issues(result, file, subject.test.path),\n\t\t\t\t\t\t...this.#misses(project, file),\n\t\t\t\t\t]\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (isProbeError(error)) throw error\n\t\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t\t`The runtime stage could not run the generated specification (${describeUnknown(error)})`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\t\tcontext: { stage: this.stage, path: subject.test.path },\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tthis.#progress -= 1\n\t\t\t\tprocess.exitCode = exitCode\n\t\t\t\tthis.#revisions.delete(file)\n\t\t\t\tcleanup = await this.#evict(vitest, file)\n\t\t\t\ttry {\n\t\t\t\t\tconst contained = resolveWorkspaceFile(\n\t\t\t\t\t\tthis.#workspace,\n\t\t\t\t\t\trelative(this.#workspace, file),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t)\n\t\t\t\t\tif (existsSync(contained)) unlinkSync(contained)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcleanup = [\n\t\t\t\t\t\t...cleanup,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\torigin:\n\t\t\t\t\t\t\t\tisProbeError(error) && error.origin === 'workspace' ? 'workspace' : 'instrument',\n\t\t\t\t\t\t\tpath: relativeWorkspaceFile(this.#workspace, file),\n\t\t\t\t\t\t\tmessage: `The runtime stage could not delete the generated specification (${describeUnknown(error)})`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstage: this.stage,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\tissues: [...issues, ...cleanup],\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#loads.clear()\n\t\t\tthis.#reads.clear()\n\t\t\toverlay.clear()\n\t\t}\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\ttry {\n\t\t\t// Remove the abandoned specifications first. An inspection the coordinator gave up on keeps\n\t\t\t// its file until the run it started finally settles, and a file left behind is ordinary\n\t\t\t// TypeScript in the target's tree: the workspace's own `check` and `lint:check` read it\n\t\t\t// and report its diagnostics as the consumer's own.\n\t\t\tfor (const file of this.#revisions) {\n\t\t\t\ttry {\n\t\t\t\t\tconst contained = resolveWorkspaceFile(\n\t\t\t\t\t\tthis.#workspace,\n\t\t\t\t\t\trelative(this.#workspace, file),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t)\n\t\t\t\t\tif (existsSync(contained)) unlinkSync(contained)\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tthis.#revisions.clear()\n\t\t\t// A stage whose warming failed holds nothing to release, so teardown settles rather than\n\t\t\t// re-reporting a failure already surfaced through `inspect`.\n\t\t\tconst vitest = await this.#vitest?.catch(() => undefined)\n\t\t\tif (vitest !== undefined) {\n\t\t\t\tvoid vitest.cancelCurrentRun('keyboard-input').catch(() => {})\n\t\t\t\tawait vitest.close()\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#modules.clear()\n\t\t\tthis.#loads.clear()\n\t\t\tthis.#reads.clear()\n\t\t\tthis.#overlay.clear()\n\t\t}\n\t}\n\n\tasync #warm(create?: typeof createVitest): Promise<Vitest> {\n\t\tconst factory = create ?? loadWorkspaceVitest(this.#workspace).createVitest\n\t\tthis.#sweep()\n\t\tconst output = new PassThrough()\n\t\toutput.resume()\n\t\t// Vitest installs one `SIGINT` and one `SIGTERM` handler per `createVitest` call, and each\n\t\t// one force exits this process about a millisecond after the signal arrives. Teardown takes\n\t\t// three orders of magnitude longer than that, so a host answering the signal gracefully\n\t\t// loses the race and leaves its generated files in the consumer's tree. Diff the listeners\n\t\t// across the call and remove exactly what appeared: the handler's name is an unexported\n\t\t// Vitest detail, and matching on it would both miss a rename and strip a coincidental name\n\t\t// match this stage does not own. Every warm strips, because every replacement and every\n\t\t// stage the coordinator recycles calls `createVitest` again. Vitest's `exit` handler is left\n\t\t// alone: it runs while the process is already leaving rather than racing a teardown.\n\t\t//\n\t\t// The call is not awaited here, and that is what makes the diff correct rather than merely\n\t\t// tidy. Vitest registers those handlers before its first await, so releasing them as the\n\t\t// call returns leaves no window a signal can arrive in. Releasing them after the promise\n\t\t// settles would leave the whole warm exposed, and would remove every termination listener\n\t\t// the host registered meanwhile — including the server's own, which starts after this\n\t\t// constructor returns.\n\t\tconst signals = captureListeners(process, ['SIGINT', 'SIGTERM'])\n\t\tlet warming: Promise<Vitest>\n\t\ttry {\n\t\t\t// Only standard output frames the Model Context Protocol transport. Preserve worker\n\t\t\t// diagnostics on standard error while draining standard output into a bounded stream.\n\t\t\twarming = factory(\n\t\t\t\t'test',\n\t\t\t\t{\n\t\t\t\t\troot: this.#workspace,\n\t\t\t\t\tconfig: resolveWorkspaceFile(this.#workspace, 'vite.config.ts'),\n\t\t\t\t\twatch: false,\n\t\t\t\t\trun: true,\n\t\t\t\t\tpool: 'threads',\n\t\t\t\t\treporters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tonInit() {},\n\t\t\t\t\t\t\tonTestRunEnd() {},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'orkestrel-project-instrumentation',\n\t\t\t\t\t\t\tenforce: 'post',\n\t\t\t\t\t\t\tconfig: this.#configure.bind(this),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{ stdout: output, stderr: process.stderr },\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthrow this.#configuration(error)\n\t\t} finally {\n\t\t\treleaseListeners(process, signals)\n\t\t}\n\t\ttry {\n\t\t\treturn await warming\n\t\t} catch (error) {\n\t\t\tthrow this.#configuration(error)\n\t\t}\n\t}\n\n\t#configure(config: ViteUserConfig): void {\n\t\tconst test = config.test\n\t\tif (test?.projects === undefined) return\n\t\t// Vite concatenates project arrays returned from config hooks. Replace the hook-owned slot so\n\t\t// each configured project keeps one identity while gaining the runtime adapter.\n\t\ttest.projects = test.projects.map((project) => this.#augment(project))\n\t}\n\n\t#augment(project: TestProjectConfiguration): TestProjectConfiguration {\n\t\tif (isString(project)) return project\n\t\tif (typeof project === 'function') return this.#wrap(project)\n\t\treturn Promise.resolve(project).then(this.#instrument.bind(this))\n\t}\n\n\t#wrap(project: UserProjectConfigFn): UserProjectConfigFn {\n\t\treturn async (environment) => this.#instrument(await project(environment))\n\t}\n\n\t#instrument(config: UserWorkspaceConfig): UserWorkspaceConfig {\n\t\treturn {\n\t\t\t...config,\n\t\t\tplugins: [\n\t\t\t\t...(config.plugins ?? []),\n\t\t\t\t{\n\t\t\t\t\tname: RUNTIME_PLUGIN,\n\t\t\t\t\tenforce: 'pre',\n\t\t\t\t\tresolveId: this.#resolve.bind(this),\n\t\t\t\t\tload: this.#load.bind(this),\n\t\t\t\t},\n\t\t\t],\n\t\t}\n\t}\n\n\t#resolve(id: string, importer: string | undefined): string | undefined {\n\t\tconst separator = id.indexOf('?')\n\t\tconst specifier = separator === -1 ? id : id.slice(0, separator)\n\t\tconst suffix = separator === -1 ? '' : id.slice(separator)\n\t\tif (!specifier.startsWith('.') && !isAbsolute(specifier)) return undefined\n\t\tif (importer === undefined && !isAbsolute(specifier)) return undefined\n\t\tconst imported = isAbsolute(specifier)\n\t\t\t? specifier\n\t\t\t: resolve(dirname(importer ?? this.#workspace), specifier)\n\t\tconst candidates = [imported]\n\t\tconst extension = extname(imported)\n\t\tif (extension === '.js') candidates.push(`${imported.slice(0, -extension.length)}.ts`)\n\t\tif (extension === '') candidates.push(`${imported}.ts`)\n\t\tfor (const candidate of candidates) {\n\t\t\tconst resolved = `${candidate}${suffix}`\n\t\t\tif (this.#overlay.text(candidate) !== undefined) return resolved\n\t\t}\n\t\treturn undefined\n\t}\n\n\t#load(id: string):\n\t\t| string\n\t\t| {\n\t\t\t\treadonly code: string\n\t\t\t\treadonly map: { readonly mappings: string }\n\t\t\t\treadonly moduleType: 'js'\n\t\t }\n\t\t| undefined {\n\t\tthis.#loads.add(normalizePath(id))\n\t\tconst separator = id.indexOf('?')\n\t\tconst path = separator === -1 ? id : id.slice(0, separator)\n\t\tconst text = this.#overlay.text(path)\n\t\tif (text === undefined) return undefined\n\t\tthis.#reads.add(normalizePath(path))\n\t\tif (separator !== -1 && /(?:^|&)raw(?:&|$)/u.test(id.slice(separator + 1))) {\n\t\t\treturn {\n\t\t\t\tcode: `export default ${JSON.stringify(text)}`,\n\t\t\t\tmap: { mappings: '' },\n\t\t\t\tmoduleType: 'js',\n\t\t\t}\n\t\t}\n\t\treturn text\n\t}\n\n\t#specification(test: Draft): string | Issue {\n\t\tlet creating = false\n\t\t// The sibling path the write aimed at, kept where the classification below can read it. That\n\t\t// path is composed inside the attempt because it carries a revision minted there, and the\n\t\t// classification needs the path itself rather than the fault's own text.\n\t\tlet generated: string | undefined\n\t\tconst outcome = attempt(() => {\n\t\t\t// The writing host's own process id leads the revision, so a later host can tell a file\n\t\t\t// whose writer is gone from one a live host still holds. Several hosts share one\n\t\t\t// workspace routinely — this package's own suite is one — and a sweep reading the name\n\t\t\t// alone deletes a neighbour's specification out from under its run. The same revision\n\t\t\t// goes into the file's own marker, so the sweep reads one value from two places.\n\t\t\tconst revision = `${process.pid}-${randomUUID()}`\n\t\t\tconst file = buildRevisionPath(this.#workspace, test.path, revision)\n\t\t\tgenerated = file\n\t\t\tconst target = relative(this.#workspace, file)\n\t\t\tresolveWorkspaceFile(this.#workspace, target, true)\n\t\t\t// The caller declared where its test lives, so creating that directory is part of what the\n\t\t\t// declaration asked for. `tmp` is ignored by version control and the coordinator's boot\n\t\t\t// tidies away the workbench it created, so the path the convention names is absent in a\n\t\t\t// fresh checkout of a target: a stage that refused over the absence alone refused the first\n\t\t\t// claim of every consumer. A directory the host will not create still refuses through the\n\t\t\t// issue a failed write reports.\n\t\t\tcreating = true\n\t\t\tmkdirSync(dirname(file), { recursive: true })\n\t\t\tcreating = false\n\t\t\tresolveWorkspaceFile(this.#workspace, target, true)\n\t\t\t// The marker goes in the file rather than in its name alone, because the name is the\n\t\t\t// caller's path and the text is the caller's test: without it nothing in the tree says\n\t\t\t// this package wrote the file, and the sweep would have to delete on a name.\n\t\t\twriteFileSync(file, formatSpecification(test.text, revision), {\n\t\t\t\tencoding: 'utf8',\n\t\t\t\tflag: 'wx',\n\t\t\t})\n\t\t\treturn file\n\t\t})\n\t\tif (outcome.success) return outcome.value\n\t\tif (isProbeError(outcome.error) && outcome.error.origin === 'claimant') {\n\t\t\tthrow new ProbeError(outcome.error.message, {\n\t\t\t\torigin: outcome.error.origin,\n\t\t\t\tcode: outcome.error.code,\n\t\t\t\tcontext: { ...outcome.error.context, path: test.path },\n\t\t\t\tcause: outcome.error.cause,\n\t\t\t})\n\t\t}\n\t\t// A create the host refused is the caller's name, not this package's machinery and not the\n\t\t// target tree. The directory exists by this point, so an ordinary absent file would have been\n\t\t// created; what remains is a name the host will not accept. `creating` bounds this to the\n\t\t// final write, leaving a directory the tree blocks to the workspace issue below.\n\t\tif (!creating && generated !== undefined && isRefusedName(generated, outcome.error)) {\n\t\t\tthrow new ProbeError(\n\t\t\t\t`The runtime stage cannot write a specification beside a test path the host refuses (${describeUnknown(outcome.error)})`,\n\t\t\t\t{\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { stage: this.stage, path: test.path },\n\t\t\t\t\tcause: outcome.error,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\torigin:\n\t\t\t\t(isProbeError(outcome.error) && outcome.error.origin === 'workspace') || creating\n\t\t\t\t\t? 'workspace'\n\t\t\t\t\t: 'instrument',\n\t\t\tpath: test.path,\n\t\t\tmessage: `The runtime stage could not write the generated specification (${describeUnknown(outcome.error)})`,\n\t\t}\n\t}\n\n\t// Returns the project or the issue that replaces it, never both and never neither. A pair of\n\t// independent optionals would let a caller write the combination carrying neither, and that branch\n\t// reports a clean check for a case whose test never ran.\n\t#project(vitest: Vitest, path: string): TestProject | Issue {\n\t\t// `inferTestProject` reads a workspace-relative path, and a caller declares whatever path it\n\t\t// holds. An absolute one splits into leading segments that match no project, which silently\n\t\t// selected the root project before this resolved.\n\t\tconst name = inferTestProject(relative(this.#workspace, resolve(this.#workspace, path)))\n\t\tif (name === undefined) {\n\t\t\tthrow new ProbeError(\n\t\t\t\t'The runtime stage found no configured Vitest project matching the test path',\n\t\t\t\t{\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'missing',\n\t\t\t\t\tcontext: { stage: this.stage, path },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst project = vitest.projects.find((candidate) => candidate.name === name)\n\t\tif (project === undefined) {\n\t\t\tthrow new ProbeError(`The runtime stage found no configured Vitest project named ${name}`, {\n\t\t\t\torigin: 'claimant',\n\t\t\t\tcode: 'missing',\n\t\t\t\tcontext: { stage: this.stage, path },\n\t\t\t})\n\t\t}\n\t\tif (!project.vite.config.plugins.some((plugin) => plugin.name === RUNTIME_PLUGIN)) {\n\t\t\treturn {\n\t\t\t\torigin: 'workspace',\n\t\t\t\tpath,\n\t\t\t\tmessage: `The runtime stage cannot instrument the string-declared Vitest project ${name} because its configuration carries no runtime overlay plugin`,\n\t\t\t}\n\t\t}\n\t\treturn project\n\t}\n\n\t// Importer reachability limits this reading to the graph the generated specification served. A\n\t// resident runner keeps older module nodes, and membership alone would report an unused candidate\n\t// because an earlier inspection imported the same path.\n\t#misses(project: TestProject, specification: string): readonly Issue[] {\n\t\tconst file = normalizePath(specification)\n\t\tconst issues: Issue[] = []\n\t\tfor (const path of this.#overlay.paths) {\n\t\t\tif (this.#reads.has(path)) continue\n\t\t\tlet served = false\n\t\t\tlet loaded = false\n\t\t\tfor (const environment of Object.values(project.vite.environments)) {\n\t\t\t\tconst modules = environment.moduleGraph.getModulesByFile(path)\n\t\t\t\tif (modules === undefined) continue\n\t\t\t\tfor (const module of modules) {\n\t\t\t\t\tconst pending = [...module.importers]\n\t\t\t\t\tconst seen = new Set(pending)\n\t\t\t\t\tlet reaches = false\n\t\t\t\t\twhile (pending.length > 0) {\n\t\t\t\t\t\tconst importer = pending.pop()\n\t\t\t\t\t\tif (importer === undefined) break\n\t\t\t\t\t\tif (importer.file !== null && normalizePath(importer.file) === file) {\n\t\t\t\t\t\t\treaches = true\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const parent of importer.importers) {\n\t\t\t\t\t\t\tif (seen.has(parent)) continue\n\t\t\t\t\t\t\tseen.add(parent)\n\t\t\t\t\t\t\tpending.push(parent)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!reaches) continue\n\t\t\t\t\tserved = true\n\t\t\t\t\tif (module.id !== null && this.#loads.has(normalizePath(module.id))) loaded = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!served) continue\n\t\t\tissues.push({\n\t\t\t\torigin: loaded ? 'instrument' : 'workspace',\n\t\t\t\tpath: relativeWorkspaceFile(this.#workspace, path),\n\t\t\t\tmessage: loaded\n\t\t\t\t\t? 'The runtime overlay did not resolve this module'\n\t\t\t\t\t: 'The workspace configuration served this module before the runtime overlay',\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\tasync #evict(vitest: Vitest, file: string): Promise<readonly Issue[]> {\n\t\ttry {\n\t\t\tconst ids: string[] = []\n\t\t\tfor (const [id, task] of vitest.state.idMap) {\n\t\t\t\tconst path = 'filepath' in task ? task.filepath : task.file.filepath\n\t\t\t\tif (resolve(path) === resolve(file)) ids.push(id)\n\t\t\t}\n\t\t\tfor (const id of ids) vitest.state.idMap.delete(id)\n\t\t\tvitest.state.pathsSet.delete(file)\n\t\t\tvitest.clearSpecificationsCache(file)\n\t\t\tvitest.invalidateFile(file)\n\t\t\tconst graphs = vitest.projects.flatMap((project) =>\n\t\t\t\tObject.values(project.vite.environments).map((environment) => environment.moduleGraph),\n\t\t\t)\n\t\t\tfor (const graph of graphs) {\n\t\t\t\tconst modules = graph.getModulesByFile(file)\n\t\t\t\tgraph.onFileDelete(file)\n\t\t\t\tif (modules === undefined) continue\n\t\t\t\tfor (const module of modules) {\n\t\t\t\t\tfor (const importer of module.importers) {\n\t\t\t\t\t\timporter.importedModules.delete(module)\n\t\t\t\t\t\timporter.acceptedHmrDeps.delete(module)\n\t\t\t\t\t}\n\t\t\t\t\tif (module.id !== null) graph.idToModuleMap.delete(module.id)\n\t\t\t\t\tgraph.urlToModuleMap.delete(module.url)\n\t\t\t\t}\n\t\t\t\tgraph.fileToModulesMap.delete(file)\n\t\t\t}\n\t\t\tvitest.watcher.onFileDelete(file)\n\t\t\tvitest.watcher.invalidates.delete(file)\n\t\t\tvitest.cache.results.removeFromCache(normalizePath(relative(this.#workspace, file)))\n\t\t\tawait vitest.cache.results.writeToCache()\n\t\t\treturn []\n\t\t} catch (error) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\tpath: relativeWorkspaceFile(this.#workspace, file),\n\t\t\t\t\tmessage: `The runtime stage could not evict the generated specification (${describeUnknown(error)})`,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t}\n\n\t// Reads the specification count rather than incrementing it. An inspection that writes no\n\t// specification retains no URL, so counting it would recycle a runner that never grew.\n\t#runner(): Promise<Vitest> {\n\t\t// Vite retains one unresolved URL for each fresh specification path. The\n\t\t// `PROBE_SPECIFICATIONS` lifetime bounds that internal map without giving up the resident\n\t\t// runner on each call.\n\t\tconst current = this.#vitest\n\t\tif (current !== undefined && this.#specifications < PROBE_SPECIFICATIONS) return current\n\t\tif (current !== undefined) return this.#store(this.#replace(current))\n\t\tconst runner = loadWorkspaceVitest(this.#workspace)\n\t\treturn this.#store(\n\t\t\tthis.#specifications < PROBE_SPECIFICATIONS\n\t\t\t\t? this.#warm(runner.createVitest)\n\t\t\t\t: this.#replace(undefined, runner.createVitest),\n\t\t)\n\t}\n\n\tasync #replace(\n\t\tcurrent: Promise<Vitest> | undefined,\n\t\tcreate?: typeof createVitest,\n\t): Promise<Vitest> {\n\t\tif (current !== undefined) {\n\t\t\tconst vitest = await current\n\t\t\tawait vitest.close()\n\t\t}\n\t\tif (this.#closing !== undefined) throw createDestroyedError('runtime stage')\n\t\tconst runner = create ?? loadWorkspaceVitest(this.#workspace).createVitest\n\t\tconst replacement = await this.#warm(runner)\n\t\tthis.#specifications = 0\n\t\treturn replacement\n\t}\n\n\t#store(vitest: Promise<Vitest>): Promise<Vitest> {\n\t\tthis.#vitest = vitest\n\t\tvoid vitest.catch(() => {\n\t\t\tif (this.#vitest === vitest) this.#vitest = undefined\n\t\t})\n\t\treturn vitest\n\t}\n\n\t#configuration(error: unknown): ProbeError {\n\t\tif (isProbeError(error)) return error\n\t\treturn new ProbeError(\n\t\t\t`The runtime stage could not load vite.config.ts (${describeUnknown(error)})`,\n\t\t\t{\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { stage: this.stage, path: 'vite.config.ts' },\n\t\t\t\tcause: error,\n\t\t\t},\n\t\t)\n\t}\n\n\t#revalidate(vitest: Vitest): void {\n\t\tconst modules = this.#snapshot()\n\t\tfor (const [path, digest] of modules) {\n\t\t\tif (this.#modules.get(path) === digest) continue\n\t\t\tthis.#invalidate(vitest, path)\n\t\t}\n\t\tfor (const path of this.#modules.keys()) {\n\t\t\tif (modules.has(path)) continue\n\t\t\tthis.#invalidate(vitest, path)\n\t\t}\n\t\tthis.#modules.clear()\n\t\tfor (const [path, digest] of modules) this.#modules.set(path, digest)\n\t}\n\n\t// Vite keys its module graph on the forward-slash spelling of a resolved id, and `invalidateFile`\n\t// looks that key up exactly. `collectWorkspaceFiles` builds each path with `join` and the overlay\n\t// holds paths `resolve` produced, so on a host whose separator is a backslash the native spelling\n\t// matches no key, the invalidation is dropped without an error, and the resident runner serves\n\t// the previous module. Read the host separator rather than the platform name, and rewrite only\n\t// where it is a backslash: a backslash is a legal filename character on a host whose separator is\n\t// a forward slash, so rewriting there would turn a key Vite holds into one it does not.\n\t#invalidate(vitest: Vitest, path: string): void {\n\t\tconst id = sep === '\\\\' ? normalizePath(path) : path\n\t\tvitest.invalidateFile(id)\n\t\tvitest.watcher.invalidates.add(id)\n\t}\n\n\t#snapshot(): ReadonlyMap<string, string> {\n\t\tconst modules = new Map<string, string>()\n\t\tfor (const path of collectWorkspaceFiles(this.#workspace)) {\n\t\t\tif (!matchesWorkspaceModule(path)) continue\n\t\t\ttry {\n\t\t\t\tconst digest = createHash('sha256').update(readFileSync(path)).digest('hex')\n\t\t\t\tmodules.set(path, digest)\n\t\t\t} catch {}\n\t\t}\n\t\tfor (const path of this.#overlay.paths) {\n\t\t\tmodules.set(path, `overlay:${this.#overlay.revision}`)\n\t\t}\n\t\treturn modules\n\t}\n\n\t// Removes the files a dead host left behind. Every inspection deletes its own file and teardown\n\t// deletes the ones it abandoned, so a file that outlives both belongs to a host that was killed.\n\t// No Vitest project collects it — the revision marker sits between the stem and the extension,\n\t// so a specification generated from a `.test.ts` path is not itself a `.test.ts` file — but it\n\t// is ordinary TypeScript in the target's tree, so the workspace's own `check` and `lint:check`\n\t// report its diagnostics against the consumer. These conditions together make one file this\n\t// package's to delete: the name carries a revision, the identity leading that revision names a\n\t// process that is gone, and the file is one `#owned` can attribute. A file failing any of them\n\t// stays where it is, whoever wrote it.\n\t#sweep(): void {\n\t\tfor (const path of collectWorkspaceFiles(this.#workspace)) {\n\t\t\tconst matches = [\n\t\t\t\t...basename(path).matchAll(\n\t\t\t\t\t/\\.probe-((\\d+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?=\\.|$)/gu,\n\t\t\t\t),\n\t\t\t]\n\t\t\tconst match = matches.at(-1)\n\t\t\tconst revision = match?.[1]\n\t\t\tconst owner = match?.[2]\n\t\t\tif (revision === undefined || owner === undefined) continue\n\t\t\tif (matchesLiveProcess(Number.parseInt(owner, 10))) continue\n\t\t\tif (!this.#owned(path, revision)) continue\n\t\t\ttry {\n\t\t\t\tunlinkSync(resolveWorkspaceFile(this.#workspace, relative(this.#workspace, path), true))\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Whether this package wrote one file. A name proves nothing on its own: a consumer's own file\n\t// can carry the same shape, and deleting it is data loss in their tree. A generated\n\t// specification carries the caller's own test text, so the marker this stage appends to it is\n\t// what attributes it, and the revision in the name must be the revision in the marker. The\n\t// coordinator's boot writes the same terminal marker on its dependencies, so every deletion uses\n\t// the same content-backed ownership rule.\n\t#owned(path: string, revision: string): boolean {\n\t\tconst outcome = attempt(() => readFileSync(path, 'utf8'))\n\t\treturn outcome.success && matchesSpecification(outcome.value, revision)\n\t}\n\n\t#issues(result: TestRunResult, file: string, original: string): readonly Issue[] {\n\t\tconst specification = this.#real(file)\n\t\tconst issues: Issue[] = []\n\t\tfor (const module of result.testModules) {\n\t\t\tconst before = issues.length\n\t\t\tfor (const error of module.errors()) {\n\t\t\t\tissues.push(this.#issue(error, specification, original))\n\t\t\t}\n\t\t\tfor (const test of module.children.allTests('failed')) {\n\t\t\t\tconst errors = test.result().errors ?? []\n\t\t\t\tfor (const error of errors) issues.push(this.#issue(error, specification, original))\n\t\t\t}\n\t\t\tconst state: string = module.state()\n\t\t\tif (state === 'passed') {\n\t\t\t\tif (Array.from(module.children.allTests()).length === 0) {\n\t\t\t\t\tissues.push({\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tpath: original,\n\t\t\t\t\t\tmessage: 'Vitest ran no tests in the module',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tfor (const test of module.children.allTests('skipped')) {\n\t\t\t\t\tissues.push({\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tpath: original,\n\t\t\t\t\t\tmessage: `Vitest did not run the test (${test.fullName})`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (state === 'skipped') {\n\t\t\t\tissues.push({\n\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\tpath: original,\n\t\t\t\t\tmessage: 'Vitest ran no tests in the module',\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (state === 'failed') {\n\t\t\t\tif (issues.length === before) {\n\t\t\t\t\tissues.push({\n\t\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\t\tpath: original,\n\t\t\t\t\t\tmessage: 'Vitest reported a failed test module',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (state === 'pending' || state === 'queued') {\n\t\t\t\tissues.push({\n\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\tpath: original,\n\t\t\t\t\tmessage: `Vitest did not finish the test module (${state})`,\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tissues.push({\n\t\t\t\torigin: 'instrument',\n\t\t\t\tpath: original,\n\t\t\t\tmessage: `Vitest reported an unrecognized test module state (${state})`,\n\t\t\t})\n\t\t}\n\t\tfor (const error of result.unhandledErrors) {\n\t\t\tissues.push(this.#issue(error, specification, original))\n\t\t}\n\t\tif (result.testModules.length === 0 && issues.length === 0) {\n\t\t\tissues.push({\n\t\t\t\torigin: 'instrument',\n\t\t\t\tpath: original,\n\t\t\t\tmessage: 'Vitest returned no test module',\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\t// Resolves one path through its real form, and leaves a path it cannot resolve as it stands.\n\t// `resolve` does not follow a symbolic link, so a workspace handed to this stage as a link\n\t// produces a specification path no reported frame ever equals, and the mapping that follows reports\n\t// the generated `probe-<revision>` file a caller cannot open instead of the test it declared.\n\t#real(path: string): string {\n\t\tconst outcome = attempt(() => realpathSync(path))\n\t\treturn outcome.success ? outcome.value : path\n\t}\n\n\t// Every error reaching here came out of a run Vitest completed over the candidate's own test,\n\t// so each one is that code failing rather than this stage faulting. `specification` arrives\n\t// already resolved through its real path, and every reported frame is resolved the same way, so\n\t// the two sides compare on one spelling. The message is rendered the way the issue's own `path`\n\t// is: a test that reads its own module reports the generated sibling this stage ran, and a\n\t// caller handed that name finds no file, because the sibling is deleted as the inspection ends.\n\t// The rename reads the exact name this stage generated rather than a name shaped like one, and\n\t// it reads the name alone: the sibling is written into the declared test's own directory, so\n\t// every spelling a tool can write — relative, absolute, or a `file:` URL — differs only in the\n\t// leading directories the workspace rewrite has already removed. That name carries the revision\n\t// minted for this run, so an occurrence of it names this file and no other.\n\t#issue(error: unknown, specification: string, original: string): Issue {\n\t\tconst message = relativeWorkspaceMessage(this.#workspace, describeUnknown(error)).replaceAll(\n\t\t\tbasename(specification),\n\t\t\tbasename(original),\n\t\t)\n\t\tif (!isObject(error) || !('stacks' in error)) {\n\t\t\treturn { origin: 'claimant', path: original, message }\n\t\t}\n\t\tconst stacks = error.stacks\n\t\tif (!isArray(stacks)) return { origin: 'claimant', path: original, message }\n\t\tfor (const stack of stacks) {\n\t\t\tif (!isObject(stack)) continue\n\t\t\tif (!('file' in stack) || !isString(stack.file)) continue\n\t\t\tconst declared = stack.file.startsWith('file:')\n\t\t\t\t? fileURLToPath(stack.file)\n\t\t\t\t: isAbsolute(stack.file)\n\t\t\t\t\t? stack.file\n\t\t\t\t\t: resolve(this.#workspace, stack.file)\n\t\t\tconst reported = this.#real(declared)\n\t\t\tconst path =\n\t\t\t\treported === specification\n\t\t\t\t\t? original\n\t\t\t\t\t: relativeWorkspaceFile(this.#real(this.#workspace), reported)\n\t\t\tif (!('line' in stack) || !isNumber(stack.line)) {\n\t\t\t\treturn { origin: 'claimant', path, message }\n\t\t\t}\n\t\t\t// A reported frame numbers its line and its column from one, so both are lowered into the\n\t\t\t// zero-based coordinates the issue stores. A frame names a point rather than a span, so\n\t\t\t// the end resolves to the start and the stored range is zero-width there. A frame\n\t\t\t// carrying no numeric column names the line alone, which starts at its first character.\n\t\t\tconst character = 'column' in stack && isNumber(stack.column) ? stack.column - 1 : 0\n\t\t\tconst position = { line: stack.line - 1, character }\n\t\t\treturn { origin: 'claimant', path, message, range: { start: position, end: position } }\n\t\t}\n\t\treturn { origin: 'claimant', path: original, message }\n\t}\n}\n","import type { Case, Check, Draft, Issue, Project, Stage } from '@src/core'\nimport type { Diagnostic, Execution, ProjectConfig, TypeStageInterface } from '../types.js'\nimport type { ChildProcess } from 'node:child_process'\nimport type { Dirent } from 'node:fs'\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trmSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { spawn, spawnSync } from 'node:child_process'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { basename, dirname, extname, join, resolve } from 'node:path'\nimport { attempt } from '@orkestrel/contract'\nimport {\n\tProbeError,\n\tTYPE_MIRROR,\n\tcreateDestroyedError,\n\tformatSpecification,\n\tmatchesSpecification,\n} from '@src/core'\nimport {\n\tcollectWorkspaceFiles,\n\tcomputeDigest,\n\tescapesRoot,\n\tfilterUniqueIssues,\n\tguardStage,\n\tinferTypeProject,\n\tmatchesLiveProcess,\n\tnormalizePath,\n\trelativeWorkspaceFile,\n\trelativeWorkspaceMessage,\n\tresolveWorkspaceBinary,\n\tresolveWorkspaceFile,\n\tscanDiagnostics,\n} from '../helpers.js'\nimport { parseProjectConfig, parseRevisionOwner } from '../parsers.js'\n\n/**\n * Inspects TypeScript source by running the target workspace's own compiler over a mirror of it.\n *\n * @remarks\n * The compiler is a process this stage spawns rather than a module it loads, so nothing here holds\n * a resident program and the host's event loop is free for the whole check. Construction sweeps a\n * mirror an earlier host left behind, copies the workspace into a fresh one under\n * {@link TYPE_MIRROR}, and builds each declared project's incremental state there, so the first\n * inspection is warm.\n *\n * Every inspection refreshes the mirror by content digest, writes each candidate draft and the test\n * at its mirrored declared path, and runs `tsc --noEmit --pretty false` once per distinct selected\n * project. A draft therefore shadows the file it replaces: a consumer of that path is checked\n * against the draft's text, and a draft importing a sibling draft resolves to the sibling draft.\n * Nothing is written outside `tmp/`, and the workspace's own copy of a drafted file never moves.\n *\n * Each run reads a scratch project this stage writes beside the mirrored project it extends, so\n * every relative path the project declares — its own `rootDir`, `include`, `paths`, and the\n * projects it extends — resolves inside the mirror without being rewritten. The scratch adds the\n * drafts as `files`, which the project's own `exclude` does not reach, and its incremental state\n * lives in the mirror so reuse survives the refresh.\n *\n * The diagnostics decide the outcome, never the exit code, which the supported compiler majors\n * disagree on. A diagnostic naming a project file, and one naming no file at all, is the target\n * tree's own configuration fault and raises rather than reporting, unless the `.json` file is one\n * the claim itself drafted; every other diagnostic is a claimant issue at the point the compiler\n * reported, which is the extent the plain-text output carries.\n *\n * @example\n * ```ts\n * const stage = new TypeStage('/srv/checkout')\n * const check = await stage.inspect(subject, 'configs/src/tsconfig.core.json')\n * await stage.destroy()\n * ```\n */\nexport class TypeStage implements TypeStageInterface {\n\treadonly #workspace: string\n\treadonly #compiler: string\n\treadonly #revision = `${process.pid}-${randomUUID()}`\n\treadonly #mirror: string\n\treadonly #configs = new Map<string, ProjectConfig>()\n\treadonly #mirrored = new Map<string, string>()\n\treadonly #drafts = new Set<string>()\n\treadonly #children = new Set<ChildProcess>()\n\treadonly #warming: Promise<void>\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before the\n\t// teardown it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\n\t/**\n\t * Resolves the target workspace's compiler and starts warming its mirror.\n\t *\n\t * @param workspace - The target workspace root. Default: the current working directory\n\t */\n\tconstructor(workspace: string = process.cwd()) {\n\t\tthis.#workspace = workspace\n\t\tthis.#compiler = resolveWorkspaceBinary(workspace, 'typescript', 'tsc')\n\t\tthis.#mirror = resolveWorkspaceFile(workspace, `${TYPE_MIRROR}/${this.#revision}`)\n\t\tthis.#warming = this.#warm()\n\t\t// Observe the stored promise here. Nothing reads it until an inspection or a teardown\n\t\t// arrives, and an unobserved rejection ends the host process. The stored promise keeps\n\t\t// rejecting, so an inspection still reports the warming failure.\n\t\tvoid this.#warming.catch(() => {})\n\t}\n\n\tget stage(): Stage {\n\t\treturn 'type'\n\t}\n\n\tget progress(): number {\n\t\treturn this.#progress\n\t}\n\n\t/**\n\t * Inspects one case, against a caller-named project where the caller names one.\n\t *\n\t * @remarks\n\t * The `project` parameter is this stage's own, not the stage contract's: the lint and runtime\n\t * stages read no project, so `StageInterface` declares one parameter and every caller that\n\t * needs this one holds a `TypeStage`.\n\t *\n\t * @param subject - The candidate drafts and test to inspect\n\t * @param project - The workspace-relative TypeScript project the candidate drafts are checked\n\t * against. Default: the scoped project each candidate path infers\n\t * @returns One outcome for this stage\n\t * @throws When the workspace refuses the mirror, when a project the run reads is malformed, or\n\t * when the stage has already been destroyed\n\t */\n\tinspect(subject: Case, project?: string): Promise<Check> {\n\t\treturn guardStage(this.stage, this.#inspect(subject, project))\n\t}\n\n\t/**\n\t * Resolves one project to the path and digest this stage applies for it.\n\t *\n\t * @remarks\n\t * Reads the configuration the compiler itself prints for the project as the mirror holds it,\n\t * refreshed from the workspace first on a cache miss, so the digest names the configuration the\n\t * check applies. The reading is cached per project for the life of the stage, so a draft written\n\t * afterward cannot move it.\n\t *\n\t * @param project - The workspace-relative TypeScript project to resolve\n\t * @returns The resolved workspace-relative path and the digest of its compiler options\n\t * @throws When the project escapes the workspace, when the compiler refuses it, or when the\n\t * stage has already been destroyed\n\t */\n\tresolve(project: string): Promise<Project> {\n\t\treturn guardStage(this.stage, this.#resolve(project))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = guardStage(this.stage, this.#destroy())\n\t\treturn this.#closing\n\t}\n\n\tasync #inspect(subject: Case, project?: string): Promise<Check> {\n\t\tthis.#refuseDestroyed()\n\t\tconst started = performance.now()\n\t\tawait this.#warming\n\t\tthis.#refuseDestroyed()\n\t\t// Every declared path is resolved before anything is written, so a draft that escapes the\n\t\t// workspace refuses the whole inspection rather than leaving earlier drafts in the mirror.\n\t\tconst test = resolveWorkspaceFile(this.#workspace, subject.test.path)\n\t\tconst resolved = subject.files.map((draft) => ({\n\t\t\tdraft,\n\t\t\tpath: resolveWorkspaceFile(this.#workspace, draft.path),\n\t\t}))\n\t\t// Keyed by the resolved project rather than by the caller's spelling of it, so `tsconfig.json`\n\t\t// and `./tsconfig.json` name one run instead of two.\n\t\tconst groups = new Map<string, Draft[]>([[this.#contain('tsconfig.json'), [subject.test]]])\n\t\tfor (const candidate of resolved) {\n\t\t\tconst selected = this.#contain(\n\t\t\t\tproject ?? inferTypeProject(relativeWorkspaceFile(this.#workspace, candidate.path)),\n\t\t\t)\n\t\t\tconst drafts = groups.get(selected)\n\t\t\tif (drafts === undefined) groups.set(selected, [candidate.draft])\n\t\t\telse drafts.push(candidate.draft)\n\t\t}\n\t\tthis.#progress += 1\n\t\t// Every selected project's configuration is read before any draft lands in the mirror, so a\n\t\t// claim drafting its own project file cannot move the digest that project resolves to.\n\t\tfor (const selected of groups.keys()) await this.#configure(selected)\n\t\tthis.#refuseDestroyed()\n\t\ttry {\n\t\t\tthis.#refresh()\n\t\t\tthis.#drafts.add(this.#place(subject.test.text, test))\n\t\t\tfor (const candidate of resolved) {\n\t\t\t\tthis.#drafts.add(this.#place(candidate.draft.text, candidate.path))\n\t\t\t}\n\t\t\tconst issues: Issue[] = []\n\t\t\tfor (const [selected, drafts] of groups) {\n\t\t\t\tthis.#refuseDestroyed()\n\t\t\t\tissues.push(...(await this.#check(selected, drafts)))\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstage: this.stage,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\t// One draft is checked by the project its claim names and again by the root project the\n\t\t\t\t// test is checked against, so the same diagnostic arrives twice for one candidate.\n\t\t\t\tissues: filterUniqueIssues(issues),\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#release()\n\t\t}\n\t}\n\n\tasync #resolve(project: string): Promise<Project> {\n\t\tthis.#refuseDestroyed()\n\t\tconst contained = this.#contain(project)\n\t\tthis.#progress += 1\n\t\tconst config = await this.#configure(contained)\n\t\treturn { path: contained, digest: computeDigest(this.#workspace, config.compilerOptions) }\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\t// Abandon every inspection in flight rather than waiting for one: the coordinator tears a\n\t\t// stage down exactly when it cannot wait. Terminating the compiler is what makes that\n\t\t// immediate, and warming is awaited afterwards because its own run is one of the terminated\n\t\t// children and the mirror it built is the resource this releases.\n\t\tconst children = [...this.#children]\n\t\tthis.#children.clear()\n\t\tfor (const child of children) this.#terminate(child)\n\t\tawait this.#warming.catch(() => undefined)\n\t\ttry {\n\t\t\trmSync(this.#mirror, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 })\n\t\t} catch {}\n\t\tthis.#configs.clear()\n\t\tthis.#mirrored.clear()\n\t\tthis.#drafts.clear()\n\t}\n\n\t// Builds each declared project's incremental state so the first inspection is warm. The runs are\n\t// independent — each reads the mirror and writes its own state file — so they run together and\n\t// the warm costs the slowest project rather than the sum of them all.\n\tasync #warm(): Promise<void> {\n\t\tthis.#sweep()\n\t\tthis.#createMirror()\n\t\tthis.#refresh()\n\t\tthis.#refuseDestroyed()\n\t\tawait Promise.all(this.#projects().map((project) => this.#check(project, [])))\n\t}\n\n\t#projects(): readonly string[] {\n\t\tconst projects = ['tsconfig.json']\n\t\tfor (const axis of ['src', 'app']) {\n\t\t\tconst directory = resolveWorkspaceFile(this.#workspace, `configs/${axis}`)\n\t\t\tlet names: readonly string[]\n\t\t\ttry {\n\t\t\t\tnames = readdirSync(directory)\n\t\t\t} catch {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const name of names.filter((entry) => /^tsconfig\\.[^.]+\\.json$/.test(entry)).sort()) {\n\t\t\t\tprojects.push(`configs/${axis}/${name}`)\n\t\t\t}\n\t\t}\n\t\treturn projects\n\t}\n\n\t// Refuses an inspection this stage was torn down during. The compiler runs in a child process,\n\t// so the host's loop is free while it works and a caller's deadline fires against this stage on\n\t// its own: nothing here yields for that. The refusal is what stops an abandoned inspection\n\t// running a compiler over a mirror this teardown is deleting.\n\t#refuseDestroyed(): void {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('type stage')\n\t}\n\n\t// Creates this stage's own mirror directory and the marker that attributes it. The marker is the\n\t// same one the runtime stage writes on the files it generates, so a sweep never deletes a\n\t// directory by its name alone.\n\t#createMirror(): void {\n\t\tconst marker = resolveWorkspaceFile(\n\t\t\tthis.#workspace,\n\t\t\t`${TYPE_MIRROR}/${this.#revision}/.probe/mirror.txt`,\n\t\t\ttrue,\n\t\t)\n\t\tmkdirSync(dirname(marker), { recursive: true })\n\t\twriteFileSync(marker, formatSpecification('', this.#revision), {\n\t\t\tencoding: 'utf8',\n\t\t\tflag: 'wx',\n\t\t})\n\t}\n\n\t// Removes the mirrors a dead host left behind. Every stage deletes its own at teardown, so one\n\t// that outlives its host belongs to a process that was killed. Three conditions together make a\n\t// directory this package's to delete: the name is a revision identity, the process it names is\n\t// gone, and the marker inside it names that same revision. A directory failing any of them stays\n\t// where it is, whoever wrote it.\n\t#sweep(): void {\n\t\tconst root = resolveWorkspaceFile(this.#workspace, TYPE_MIRROR)\n\t\tlet entries: readonly Dirent[] = []\n\t\ttry {\n\t\t\tentries = readdirSync(root, { withFileTypes: true })\n\t\t} catch {\n\t\t\treturn\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory()) continue\n\t\t\tconst owner = parseRevisionOwner(entry.name)\n\t\t\tif (owner === undefined || matchesLiveProcess(owner)) continue\n\t\t\tconst marker = attempt(() =>\n\t\t\t\treadFileSync(join(root, entry.name, '.probe', 'mirror.txt'), 'utf8'),\n\t\t\t)\n\t\t\tif (!marker.success || !matchesSpecification(marker.value, entry.name)) continue\n\t\t\ttry {\n\t\t\t\trmSync(join(root, entry.name), {\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tforce: true,\n\t\t\t\t\tmaxRetries: 5,\n\t\t\t\t\tretryDelay: 20,\n\t\t\t\t})\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Brings the mirror level with the workspace by content digest, so a file edited since the last\n\t// inspection is checked as it stands on disk and an untouched file is not copied again. A file\n\t// the workspace no longer holds is removed from the mirror, because a stale copy there would\n\t// shadow the deletion.\n\t#refresh(): void {\n\t\tconst present = new Set<string>()\n\t\tfor (const path of collectWorkspaceFiles(this.#workspace)) {\n\t\t\tconst contained = relativeWorkspaceFile(this.#workspace, path)\n\t\t\tpresent.add(contained)\n\t\t\tconst reading = attempt(() => readFileSync(path))\n\t\t\tif (!reading.success) continue\n\t\t\tconst digest = createHash('sha256').update(reading.value).digest('hex')\n\t\t\tif (this.#mirrored.get(contained) === digest) continue\n\t\t\tthis.#place(reading.value, path)\n\t\t\tthis.#mirrored.set(contained, digest)\n\t\t}\n\t\tfor (const contained of [...this.#mirrored.keys()]) {\n\t\t\tif (present.has(contained)) continue\n\t\t\tthis.#remove(contained)\n\t\t\tthis.#mirrored.delete(contained)\n\t\t}\n\t}\n\n\t// Releases the candidate text one inspection wrote. The copy is removed rather than restored, so\n\t// the next refresh reads the workspace's own file again and a draft that named no workspace file\n\t// leaves nothing behind.\n\t#release(): void {\n\t\tfor (const contained of this.#drafts) {\n\t\t\tthis.#remove(contained)\n\t\t\tthis.#mirrored.delete(contained)\n\t\t}\n\t\tthis.#drafts.clear()\n\t}\n\n\t// Puts one file's contents at its mirrored path and reports the workspace-relative path it took,\n\t// which is the key every record this stage keeps is held under.\n\t#place(text: string | Uint8Array, path: string): string {\n\t\tconst contained = relativeWorkspaceFile(this.#workspace, path)\n\t\tconst target = this.#mirrorPath(contained)\n\t\tconst written = attempt(() => {\n\t\t\tmkdirSync(dirname(target), { recursive: true })\n\t\t\twriteFileSync(target, text)\n\t\t})\n\t\tif (written.success) return contained\n\t\tthis.#displace(target)\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\twriteFileSync(target, text)\n\t\treturn contained\n\t}\n\n\t// Removes whatever in the mirror stands where one path must go. A workspace holding a file where\n\t// a draft declares a directory, and a claim declaring a file where an earlier draft made a\n\t// directory, both reach here: the mirror is this stage's own tree, so the path the write names\n\t// wins and the next refresh restores whatever the workspace still holds.\n\t#displace(target: string): void {\n\t\tconst ancestors: string[] = []\n\t\tlet directory = dirname(target)\n\t\twhile (directory !== this.#mirror && directory !== dirname(directory)) {\n\t\t\tancestors.unshift(directory)\n\t\t\tdirectory = dirname(directory)\n\t\t}\n\t\tfor (const ancestor of [...ancestors, target]) {\n\t\t\tconst reading = attempt(() => lstatSync(ancestor))\n\t\t\tif (!reading.success) continue\n\t\t\tif (ancestor !== target && reading.value.isDirectory()) continue\n\t\t\tif (ancestor === target && !reading.value.isDirectory()) continue\n\t\t\trmSync(ancestor, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 })\n\t\t\tthis.#mirrored.delete(relativeWorkspaceFile(this.#mirror, ancestor))\n\t\t}\n\t}\n\n\t// Spells one workspace-relative path inside this stage's own mirror.\n\t#mirrorPath(contained: string): string {\n\t\treturn join(this.#mirror, contained)\n\t}\n\n\t// Spells one project the way this stage keys it: resolved against the workspace, then reported\n\t// relative to it, so every spelling of one project reaches one run and one cached configuration.\n\t#contain(project: string): string {\n\t\treturn relativeWorkspaceFile(this.#workspace, resolveWorkspaceFile(this.#workspace, project))\n\t}\n\n\t#remove(contained: string): void {\n\t\ttry {\n\t\t\trmSync(this.#mirrorPath(contained), { force: true, maxRetries: 5, retryDelay: 20 })\n\t\t} catch {}\n\t}\n\n\t// Reads the configuration the compiler prints for one project against the mirror, refreshing the\n\t// mirror first on a cache miss so the digest names the configuration the mirror holds at that\n\t// moment. The reading is cached per project for the life of the stage, so a draft a later\n\t// inspection writes cannot move it.\n\tasync #configure(project: string): Promise<ProjectConfig> {\n\t\tconst contained = this.#contain(project)\n\t\tconst existing = this.#configs.get(contained)\n\t\tif (existing !== undefined) return existing\n\t\tthis.#refresh()\n\t\tconst execution = await this.#spawn(['--showConfig', '-p', contained], this.#mirror)\n\t\tthis.#refuseDestroyed()\n\t\tconst config = parseProjectConfig(execution.stdout)\n\t\tif (config === undefined) throw this.#fault(execution, contained)\n\t\tthis.#configs.set(contained, config)\n\t\treturn config\n\t}\n\n\t// Runs one project's compiler over the mirror and reports what it said about the drafts assigned\n\t// to that project. A run carrying no drafts is the warming run, which builds the incremental\n\t// state the inspections reuse. The diagnostics decide the outcome: a run that printed one is read\n\t// from it whatever stderr carries, and a run that printed none and exited zero is clean whatever\n\t// stderr carries. Only a run that printed no diagnostic and did not exit zero raises, because\n\t// that run reported nothing this stage can act on.\n\tasync #check(project: string, drafts: readonly Draft[]): Promise<readonly Issue[]> {\n\t\tconst config = await this.#configure(project)\n\t\tconst scratch = this.#scratch(this.#contain(project), config, drafts)\n\t\tconst execution = await this.#spawn(\n\t\t\t['--noEmit', '--pretty', 'false', '-p', `./${scratch}`],\n\t\t\tthis.#mirror,\n\t\t)\n\t\tthis.#refuseDestroyed()\n\t\tconst diagnostics = scanDiagnostics(execution.stdout)\n\t\tif (diagnostics.length === 0 && execution.status !== 0) {\n\t\t\tconst stderr = execution.stderr.trim()\n\t\t\tconst message =\n\t\t\t\tstderr !== ''\n\t\t\t\t\t? stderr\n\t\t\t\t\t: execution.status === undefined\n\t\t\t\t\t\t? 'The compiler reported no diagnostic and was ended by a signal'\n\t\t\t\t\t\t: `The compiler reported no diagnostic and exited ${execution.status}`\n\t\t\tthrow new ProbeError(this.#translate(message), {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t})\n\t\t}\n\t\treturn this.#issues(diagnostics, project)\n\t}\n\n\t// Writes the scratch project one run reads, beside the mirrored project it extends. Sitting in\n\t// that directory is what lets every relative path the extended chain declares resolve inside the\n\t// mirror unchanged, the project's own printed selection included.\n\t#scratch(project: string, config: ProjectConfig, drafts: readonly Draft[]): string {\n\t\tconst directory = dirname(project)\n\t\tconst stem = `${basename(project, extname(project))}.probe.json`\n\t\tconst contained = directory === '.' ? stem : `${directory}/${stem}`\n\t\tconst target = this.#mirrorPath(contained)\n\t\tconst buildinfo = join(this.#mirror, '.probe', `${project.replaceAll('/', '-')}.tsbuildinfo`)\n\t\t// The project's own selection is carried across rather than left to the compiler's default,\n\t\t// because naming `files` at all suppresses that default. A selection entry the mirror does not\n\t\t// hold is dropped, so a file the workspace deleted after this reading refuses nothing.\n\t\tconst selected = (config.files ?? []).filter((entry) =>\n\t\t\texistsSync(resolve(dirname(target), entry)),\n\t\t)\n\t\t// Each entry stays relative to the scratch project's own directory, so the mirror carries no\n\t\t// host layout and its incremental state keeps working from wherever the mirror sits.\n\t\tconst files = [\n\t\t\t...selected,\n\t\t\t...drafts.map((draft) =>\n\t\t\t\trelativeWorkspaceFile(dirname(target), this.#mirrorPath(this.#contain(draft.path))),\n\t\t\t),\n\t\t]\n\t\tconst body = {\n\t\t\textends: `./${basename(project)}`,\n\t\t\tcompilerOptions: {\n\t\t\t\tnoEmit: true,\n\t\t\t\tdeclaration: false,\n\t\t\t\temitDeclarationOnly: false,\n\t\t\t\tcomposite: false,\n\t\t\t\tincremental: true,\n\t\t\t\ttsBuildInfoFile: relativeWorkspaceFile(dirname(target), buildinfo),\n\t\t\t},\n\t\t\t...(files.length === 0 ? {} : { files }),\n\t\t}\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\twriteFileSync(target, `${JSON.stringify(body, undefined, '\\t')}\\n`, 'utf8')\n\t\treturn contained\n\t}\n\n\t#issues(diagnostics: readonly Diagnostic[], project: string): readonly Issue[] {\n\t\tconst issues: Issue[] = []\n\t\tfor (const diagnostic of diagnostics) {\n\t\t\tconst message = this.#translate(diagnostic.message)\n\t\t\tconst resolved =\n\t\t\t\tdiagnostic.path === undefined ? undefined : resolve(this.#mirror, diagnostic.path)\n\t\t\tconst drafted =\n\t\t\t\tresolved !== undefined &&\n\t\t\t\tthis.#drafts.has(\n\t\t\t\t\tescapesRoot(this.#mirror, resolved)\n\t\t\t\t\t\t? relativeWorkspaceFile(this.#workspace, resolved)\n\t\t\t\t\t\t: relativeWorkspaceFile(this.#mirror, resolved),\n\t\t\t\t)\n\t\t\t// A diagnostic against no file, and one against a `.json` file the claim itself did not\n\t\t\t// draft, names a configuration the target tree declares for itself. So the target holds\n\t\t\t// the only file that can close it, and reporting it as a candidate issue would charge a\n\t\t\t// claimant for a configuration nobody else owns. A `.json` file the claim drafted is the\n\t\t\t// claimant's like any other draft.\n\t\t\tif (resolved === undefined || (!drafted && extname(resolved) === '.json')) {\n\t\t\t\tthrow new ProbeError(message, {\n\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst path = escapesRoot(this.#mirror, resolved)\n\t\t\t\t? escapesRoot(this.#workspace, resolved)\n\t\t\t\t\t? normalizePath(resolved)\n\t\t\t\t\t: relativeWorkspaceFile(this.#workspace, resolved)\n\t\t\t\t: relativeWorkspaceFile(this.#mirror, resolved)\n\t\t\tissues.push({\n\t\t\t\torigin: 'claimant',\n\t\t\t\tpath,\n\t\t\t\tmessage,\n\t\t\t\t...(diagnostic.range === undefined ? {} : { range: diagnostic.range }),\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\t// Renders one message in the terms this package reports a path in. The mirror root is removed\n\t// first and the workspace root second, because the mirror sits inside the workspace and the\n\t// longer prefix is the one a compiler running there names a file by. What is left of a contained\n\t// path is the workspace-relative spelling a reader can open.\n\t#translate(message: string): string {\n\t\treturn relativeWorkspaceMessage(\n\t\t\tthis.#workspace,\n\t\t\trelativeWorkspaceMessage(this.#mirror, message),\n\t\t)\n\t}\n\n\t#fault(execution: Execution, project: string): ProbeError {\n\t\tconst reported = scanDiagnostics(execution.stdout).map((diagnostic) => diagnostic.message)\n\t\tconst text = reported.length > 0 ? reported.join('\\n') : execution.stdout.trim()\n\t\treturn new ProbeError(\n\t\t\tthis.#translate(text === '' ? 'The compiler printed no configuration' : text),\n\t\t\t{\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t},\n\t\t)\n\t}\n\n\t#spawn(args: readonly string[], cwd: string): Promise<Execution> {\n\t\tthis.#refuseDestroyed()\n\t\treturn new Promise<Execution>((settle, refuse) => {\n\t\t\tconst child = spawn(process.execPath, [this.#compiler, ...args], {\n\t\t\t\tcwd,\n\t\t\t\tstdio: ['ignore', 'pipe', 'pipe'],\n\t\t\t})\n\t\t\tconst output = child.stdout\n\t\t\tconst errors = child.stderr\n\t\t\tif (output === null || errors === null) {\n\t\t\t\tthis.#terminate(child)\n\t\t\t\trefuse(\n\t\t\t\t\tnew ProbeError('The compiler was spawned without its own output streams', {\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: this.stage },\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#children.add(child)\n\t\t\tlet stdout = ''\n\t\t\tlet stderr = ''\n\t\t\toutput.setEncoding('utf8')\n\t\t\terrors.setEncoding('utf8')\n\t\t\toutput.on('data', (chunk: string) => {\n\t\t\t\tstdout += chunk\n\t\t\t})\n\t\t\terrors.on('data', (chunk: string) => {\n\t\t\t\tstderr += chunk\n\t\t\t})\n\t\t\tchild.on('error', (error: unknown) => {\n\t\t\t\tthis.#children.delete(child)\n\t\t\t\trefuse(\n\t\t\t\t\tnew ProbeError('The workspace compiler could not be started', {\n\t\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: this.stage, path: this.#compiler },\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t})\n\t\t\tchild.on('close', (code: number | null) => {\n\t\t\t\tthis.#children.delete(child)\n\t\t\t\tsettle({ ...(code === null ? {} : { status: code }), stdout, stderr })\n\t\t\t})\n\t\t})\n\t}\n\n\t// Ends one compiler run. A Windows host never delivers a cooperative signal to a child, and the\n\t// compiler is spawned through the Node executable, so the whole tree is ended there by process\n\t// id; every other host receives the signal it handles.\n\t#terminate(child: ChildProcess): void {\n\t\tconst id = child.pid\n\t\tif (process.platform === 'win32' && id !== undefined) {\n\t\t\tspawnSync('taskkill', ['/pid', String(id), '/t', '/f'], { stdio: 'ignore' })\n\t\t\treturn\n\t\t}\n\t\tchild.kill('SIGTERM')\n\t}\n}\n","import type {\n\tCase,\n\tCheck,\n\tClaim,\n\tProbeEventMap,\n\tProbeInterface,\n\tProbeOptions,\n\tProject,\n\tToolchain,\n\tVerdict,\n} from '@src/core'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type { QueueInterface } from '@orkestrel/queue'\nimport type { TimeoutInterface } from '@orkestrel/timeout'\nimport type { Inspection, StageInterface } from './types.js'\nimport { existsSync, mkdirSync, rmdirSync, rmSync, writeFileSync } from 'node:fs'\nimport { randomUUID } from 'node:crypto'\nimport { basename, relative } from 'node:path'\nimport { Emitter } from '@orkestrel/emitter'\nimport { isString } from '@orkestrel/contract'\nimport { createQueue } from '@orkestrel/queue'\nimport { createTimeout } from '@orkestrel/timeout'\nimport {\n\tPROBE_DEADLINE,\n\tProbeError,\n\tcomputeReceipt,\n\tcreateDestroyedError,\n\tformatCheck,\n\tformatSpecification,\n\tisProbeError,\n} from '@src/core'\nimport { peerDependencies } from '../../package.json' with { type: 'json' }\nimport {\n\tbuildRevisionPath,\n\tcomputeDigest,\n\tdescribeUnknown,\n\toverwriteFile,\n\treadWorkspaceManifest,\n\tresolveWorkspaceFile,\n} from './helpers.js'\nimport { LintStage } from './stages/LintStage.js'\nimport { RuntimeStage } from './stages/RuntimeStage.js'\nimport { TypeStage } from './stages/TypeStage.js'\n\n/**\n * Answers claims through its type, lint, and runtime stages.\n *\n * @remarks\n * Construction resolves the target workspace's toolchain and begins warming every stage. The boot\n * controls mutate imported dependencies and refuse service unless the type and runtime stages\n * report their respective changes. One queue per stage admits inspections in arrival order, one at\n * a time, so a stage never serves two claims at once and the deadline covers active work rather\n * than queue wait. Each active stage inspection has a coordinator-owned deadline. An expiry at any\n * stage abandons that stage and replaces it before the next queued inspection begins, so one slow\n * claim costs that claim rather than the process. A failed boot is replaced the same way: the next\n * claim runs the controls again rather than inheriting a refusal.\n *\n * @example The claim that earns a receipt\n * ```ts\n * import type { Claim } from '@orkestrel/probe'\n * import { Probe } from '@orkestrel/probe/server'\n *\n * const claim: Claim = {\n * \tproject: 'configs/src/tsconfig.core.json',\n * \tcase: {\n * \t\tfiles: [\n * \t\t\t{\n * \t\t\t\tpath: 'src/core/factories.ts',\n * \t\t\t\ttext: \"export function createGreeting(): string {\\n\\treturn 'hi'\\n}\\n\",\n * \t\t\t},\n * \t\t],\n * \t\ttest: {\n * \t\t\tpath: 'tmp/probes/greeting.test.ts',\n * \t\t\ttext: \"import { expect, test } from 'vitest'\\nimport { createGreeting } from '../../src/core/factories.js'\\ntest('greets', () => expect(createGreeting()).toBe('hi'))\\n\",\n * \t\t},\n * \t},\n * \tcontrol: {\n * \t\tfiles: [\n * \t\t\t{\n * \t\t\t\tpath: 'src/core/factories.ts',\n * \t\t\t\ttext: \"export function createGreeting(): number {\\n\\treturn 'hi'\\n}\\n\",\n * \t\t\t},\n * \t\t],\n * \t\ttest: {\n * \t\t\tpath: 'tmp/probes/greeting.test.ts',\n * \t\t\ttext: \"import { expect, test } from 'vitest'\\nimport { createGreeting } from '../../src/core/factories.js'\\ntest('greets', () => expect(createGreeting()).toBe('hi'))\\n\",\n * \t\t},\n * \t\tstage: 'type',\n * \t\treason: 'a string returned as a number must not compile',\n * \t},\n * }\n *\n * const probe = new Probe({ workspace: process.cwd() })\n * const verdict = await probe.prove(claim)\n * verdict.digest // 'bdf03e5dfd6bd413ead671c7a2940fcf'\n * verdict.receipt // 'probe:bdf03e5dfd6bd413ead671c7a2940fcf:type:typescript@6.0.3:oxlint@1.86.0:vitest@4.1.11:configs/src/tsconfig.core.json@434f59254d58cf2683d453a26bd0d837'\n * await probe.destroy()\n * ```\n */\nexport class Probe implements ProbeInterface {\n\treadonly #workspace: string\n\treadonly #deadline: number\n\treadonly #emitter: Emitter<ProbeEventMap>\n\treadonly #toolchain: Toolchain\n\t#type: TypeStage\n\t#lint: LintStage\n\t#runtime: RuntimeStage\n\treadonly #typeQueue: QueueInterface<Inspection, Check>\n\treadonly #lintQueue: QueueInterface<Inspection, Check>\n\treadonly #runtimeQueue: QueueInterface<Inspection, Check>\n\treadonly #deadlines = new WeakSet<ProbeError>()\n\treadonly #surfaced = new WeakSet<ProbeError>()\n\t#typeTail = Promise.resolve()\n\t#arming: Promise<void>\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before\n\t// anything it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\n\t/**\n\t * Resolves the target toolchain and starts warming every stage.\n\t *\n\t * @param options - Workspace, deadline, and initial observation hooks\n\t */\n\tconstructor(options?: ProbeOptions) {\n\t\tthis.#workspace = options?.workspace ?? process.cwd()\n\t\tthis.#deadline = createTimeout({ ms: options?.deadline ?? PROBE_DEADLINE }).ms\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tthis.#toolchain = Object.freeze({\n\t\t\ttypescript: this.#version('typescript'),\n\t\t\toxlint: this.#version('oxlint'),\n\t\t\tvitest: this.#version('vitest'),\n\t\t})\n\t\tthis.#type = new TypeStage(this.#workspace)\n\t\tthis.#lint = new LintStage(this.#workspace)\n\t\tthis.#runtime = new RuntimeStage(this.#workspace)\n\t\t// One queue per stage, strictly ordered and one deep, is the only place this coordinator\n\t\t// serializes: a stage admits nothing itself. `retries: 0` keeps the queue from re-running an\n\t\t// inspection, because a stage that exceeded its deadline is recycled rather than retried, and\n\t\t// that recovery runs inside the handler so it finishes before the next claim is admitted.\n\t\tthis.#typeQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: this.#inspectType.bind(this),\n\t\t})\n\t\tthis.#lintQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: this.#inspectLint.bind(this),\n\t\t})\n\t\tthis.#runtimeQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: this.#inspectRuntime.bind(this),\n\t\t})\n\t\tthis.#arming = this.#arm()\n\t\t// Observe the stored promise here. Nothing else reads it until `prove` or `destroy`, and a\n\t\t// host that calls neither takes an unhandled rejection that ends the process. The stored\n\t\t// promise keeps rejecting, so `prove` still reports the arming failure to its caller.\n\t\tvoid this.#arming.catch(() => {})\n\t}\n\n\tget emitter(): EmitterInterface<ProbeEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget toolchain(): Toolchain {\n\t\treturn this.#toolchain\n\t}\n\n\tasync prove(claim: Claim): Promise<Verdict> {\n\t\ttry {\n\t\t\tthis.#support()\n\t\t\tthis.#admit(claim)\n\t\t\tawait this.#ready()\n\t\t\tif (this.#closing !== undefined) throw createDestroyedError('probe')\n\t\t\tconst started = performance.now()\n\t\t\tconst id = randomUUID()\n\t\t\t// Resolve the project before any inspection runs, so a project this workspace cannot parse\n\t\t\t// fails the claim outright rather than after every stage has paid for it.\n\t\t\tconst project = await this.#resolve(claim)\n\t\t\tconst digest = computeDigest(this.#workspace, {\n\t\t\t\tcase: claim.case,\n\t\t\t\tcontrol: claim.control,\n\t\t\t})\n\t\t\tconst subject = Object.freeze(await this.#inspect(claim.case, claim))\n\t\t\tconst control = Object.freeze(await this.#inspect(claim.control, claim))\n\t\t\tconst basis: Verdict = {\n\t\t\t\tid,\n\t\t\t\tdigest,\n\t\t\t\ttoolchain: this.#toolchain,\n\t\t\t\tproject,\n\t\t\t\treason: claim.control.reason,\n\t\t\t\tcase: subject,\n\t\t\t\tcontrol,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t}\n\t\t\tconst receipt = computeReceipt(basis, claim.control.stage)\n\t\t\tconst verdict: Verdict = receipt === undefined ? basis : { ...basis, receipt }\n\t\t\tthis.#emitter.emit('prove', verdict)\n\t\t\treturn verdict\n\t\t} catch (error) {\n\t\t\t// An arming failure reached the error channel as its attempt rejected. Reporting it here\n\t\t\t// too would show one refused boot as two faults.\n\t\t\tif (!isProbeError(error) || !this.#surfaced.has(error)) {\n\t\t\t\tthis.#emitter.emit('error', error)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\n\t}\n\n\t// Awaits the arming attempt in flight and starts one replacement for an attempt that failed.\n\t// Arming runs the boot controls through the same stages a claim uses, so the failure that ends\n\t// it is usually the workspace's — a stage that outran the deadline, a project that had no\n\t// Vitest environment yet — and those are repaired while this process keeps running. One\n\t// replacement per call bounds the cost: a workspace that still cannot arm pays one boot and\n\t// reports it, rather than looping. A caller that already started the replacement is joined\n\t// rather than replaced, so several callers waiting on one failed boot start one boot between\n\t// them.\n\tasync #ready(): Promise<void> {\n\t\tconst attempt = this.#arming\n\t\ttry {\n\t\t\tawait attempt\n\t\t\treturn\n\t\t} catch (error) {\n\t\t\tif (this.#closing !== undefined) throw error\n\t\t}\n\t\tif (this.#arming === attempt) {\n\t\t\tthis.#arming = this.#arm()\n\t\t\tvoid this.#arming.catch(() => {})\n\t\t}\n\t\tawait this.#arming\n\t}\n\n\tasync #arm(): Promise<void> {\n\t\tlet created: boolean\n\t\ttry {\n\t\t\tcreated = this.#workbench()\n\t\t} catch (error) {\n\t\t\t// The workbench refusal names the boot in its own message and reports the target tree's\n\t\t\t// fault, so it surfaces and rejects unchanged. Rewrapping it here would report a\n\t\t\t// directory this workspace blocks as this package refusing to serve.\n\t\t\tthis.#surface(error)\n\t\t\tthrow error\n\t\t}\n\t\ttry {\n\t\t\tawait this.#boot(created)\n\t\t} catch (error) {\n\t\t\t// A boot failure and a claim's own stage failure are otherwise one message: the controls\n\t\t\t// run through the same stages under the same deadline, so `The lint stage exceeded 6000\n\t\t\t// ms` reads as evidence about the candidate when it is the instrument refusing to serve.\n\t\t\tconst failure = new ProbeError(`The probe could not arm: ${describeUnknown(error)}`, {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcause: error,\n\t\t\t})\n\t\t\tthis.#surface(failure)\n\t\t\tthrow failure\n\t\t}\n\t\t// The boot control's own files are gone before this line, so a listener is told the\n\t\t// instrument serves only after the workspace holds nothing the control wrote.\n\t\tthis.#emitter.emit('arm', this.#toolchain)\n\t}\n\n\t// Reports an arming attempt's refusal as it happens. `arm` never fires for a rejected attempt\n\t// and the attempt is retained for the next `prove` to retry, so a host that waits for `arm` and\n\t// a host that calls nothing are both told nothing without this. Recording the failure is what\n\t// keeps `prove` from reporting one refusal a second time when the same attempt reaches it.\n\t// Observation only: the retry, its timing, and what the next caller reads are unchanged.\n\t#surface(error: unknown): void {\n\t\tif (isProbeError(error)) this.#surfaced.add(error)\n\t\tthis.#emitter.emit('error', error)\n\t}\n\n\t#workbench(): boolean {\n\t\tconst path = 'tmp/probes'\n\t\tconst directory = resolveWorkspaceFile(this.#workspace, path)\n\t\t// A returned `true` means this directory was absent before this call, so the boot teardown\n\t\t// that follows owns removing it again.\n\t\tconst created = !existsSync(directory)\n\t\ttry {\n\t\t\tmkdirSync(resolveWorkspaceFile(this.#workspace, path, true), { recursive: true })\n\t\t} catch (error) {\n\t\t\tconst code = isProbeError(error) && error.origin === 'workspace' ? error.code : 'malformed'\n\t\t\tthrow new ProbeError(\n\t\t\t\t`The probe could not create the boot workbench (${describeUnknown(error)})`,\n\t\t\t\t{\n\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\tcode,\n\t\t\t\t\tcontext: { path },\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn created\n\t}\n\n\tasync #boot(created: boolean): Promise<void> {\n\t\t// The dependencies that follow are real files in the target's tree, so they carry the same\n\t\t// revision identity a generated specification does: the writing host's process id, then a\n\t\t// fresh UUID. A boot the host does not survive leaves them behind, and the next runtime\n\t\t// warm sweeps a file whose writer is gone while leaving a live neighbour's alone.\n\t\tconst revision = `${process.pid}-${randomUUID()}`\n\t\tconst typeDependency = buildRevisionPath(this.#workspace, 'tmp/probes/arm-type.ts', revision)\n\t\tconst runtimeDependency = buildRevisionPath(\n\t\t\tthis.#workspace,\n\t\t\t'tmp/probes/arm-runtime.ts',\n\t\t\trevision,\n\t\t)\n\t\tconst typeModule = basename(typeDependency, '.ts')\n\t\tconst runtimeModule = basename(runtimeDependency, '.ts')\n\t\tconst typeTest = {\n\t\t\tpath: `tmp/probes/${typeModule}.test.ts`,\n\t\t\ttext: `import type { Signal } from './${typeModule}.js'\\nimport { expect, test } from 'vitest'\\nconst SIGNAL: Signal = 'before'\\ntest('revalidates a mutated type', () => {\\n\\texpect(SIGNAL).toBe('before')\\n})\\n`,\n\t\t}\n\t\tconst runtimeTest = {\n\t\t\tpath: `tmp/probes/${runtimeModule}.test.ts`,\n\t\t\ttext: `import { SIGNAL } from './${runtimeModule}.js'\\nimport { expect, test } from 'vitest'\\ntest('revalidates a mutated value', () => {\\n\\texpect(SIGNAL).toBe('before')\\n})\\n`,\n\t\t}\n\t\tconst typeClaim: Claim = {\n\t\t\tproject: 'tsconfig.json',\n\t\t\tcase: { files: [], test: typeTest },\n\t\t\tcontrol: {\n\t\t\t\tfiles: [],\n\t\t\t\ttest: typeTest,\n\t\t\t\tstage: 'type',\n\t\t\t\treason: 'the imported type changed on disk between the two inspections',\n\t\t\t},\n\t\t}\n\t\tconst runtimeClaim: Claim = {\n\t\t\tproject: 'tsconfig.json',\n\t\t\tcase: { files: [], test: runtimeTest },\n\t\t\tcontrol: {\n\t\t\t\tfiles: [],\n\t\t\t\ttest: runtimeTest,\n\t\t\t\tstage: 'runtime',\n\t\t\t\treason: 'the imported dependency changed after the resident runtime cached it',\n\t\t\t},\n\t\t}\n\t\ttry {\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, typeDependency), true)\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, runtimeDependency), true)\n\t\t\twriteFileSync(\n\t\t\t\ttypeDependency,\n\t\t\t\tformatSpecification('export type Signal = string\\n', revision),\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf8',\n\t\t\t\t\tflag: 'wx',\n\t\t\t\t},\n\t\t\t)\n\t\t\twriteFileSync(\n\t\t\t\truntimeDependency,\n\t\t\t\tformatSpecification(\"export const SIGNAL = 'before'\\n\", revision),\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf8',\n\t\t\t\t\tflag: 'wx',\n\t\t\t\t},\n\t\t\t)\n\t\t\tconst beforeType = await this.#inspect(typeClaim.case, typeClaim)\n\t\t\tconst beforeRuntime = await this.#inspect(runtimeClaim.case, runtimeClaim)\n\t\t\tconst before = [...beforeType, ...beforeRuntime]\n\t\t\tif (before.some((check) => check.issues.length > 0)) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot control did not begin clean\\n${before.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{ origin: 'instrument', code: 'malformed' },\n\t\t\t\t)\n\t\t\t}\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, typeDependency), true)\n\t\t\toverwriteFile(typeDependency, formatSpecification('export type Signal = number\\n', revision))\n\t\t\tconst afterType = await this.#inspect(typeClaim.control, typeClaim)\n\t\t\tconst type = afterType.find((check) => check.stage === typeClaim.control.stage)\n\t\t\tconst tolerant = afterType.find((check) => check.stage === 'runtime')\n\t\t\tif (type === undefined || type.issues.length === 0) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot type control did not detect a mutated dependency\\n${afterType.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: typeClaim.control.stage },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (tolerant === undefined || tolerant.issues.length > 0) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot type control did not remain runtime-clean\\n${afterType.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: 'runtime' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, runtimeDependency), true)\n\t\t\toverwriteFile(\n\t\t\t\truntimeDependency,\n\t\t\t\tformatSpecification(\"export const SIGNAL = 'after'\\n\", revision),\n\t\t\t)\n\t\t\tconst afterRuntime = await this.#inspect(runtimeClaim.control, runtimeClaim)\n\t\t\tconst runtime = afterRuntime.find((check) => check.stage === runtimeClaim.control.stage)\n\t\t\tif (runtime === undefined || runtime.issues.length === 0) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot runtime control did not detect a mutated dependency\\n${afterRuntime.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: runtimeClaim.control.stage },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t} finally {\n\t\t\trmSync(\n\t\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, typeDependency), true),\n\t\t\t\t{ force: true },\n\t\t\t)\n\t\t\trmSync(\n\t\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, runtimeDependency), true),\n\t\t\t\t{ force: true },\n\t\t\t)\n\t\t\tif (created) {\n\t\t\t\ttry {\n\t\t\t\t\trmdirSync(resolveWorkspaceFile(this.#workspace, 'tmp/probes', true))\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t#inspect(subject: Case, claim: Claim): Promise<readonly Check[]> {\n\t\tconst inspection: Inspection = { subject, claim }\n\t\tconst admitted = [\n\t\t\tthis.#typeQueue.enqueue(inspection),\n\t\t\tthis.#lintQueue.enqueue(inspection),\n\t\t\tthis.#runtimeQueue.enqueue(inspection),\n\t\t]\n\t\t// `Promise.all` reports the first rejection and stops observing the rest, and an unobserved\n\t\t// rejection ends the host process. Observe each one here; the caller still reads the first.\n\t\tfor (const pending of admitted) void pending.catch(() => {})\n\t\treturn Promise.all(admitted)\n\t}\n\n\tasync #inspectType(inspection: Inspection): Promise<Check> {\n\t\tconst release = await this.#admitType()\n\t\ttry {\n\t\t\tconst stage = this.#type\n\t\t\treturn await this.#inspectStage(\n\t\t\t\tstage,\n\t\t\t\tstage.progress,\n\t\t\t\t() => stage.inspect(inspection.subject, inspection.claim.project),\n\t\t\t\tinspection.claim,\n\t\t\t)\n\t\t} finally {\n\t\t\trelease()\n\t\t}\n\t}\n\n\t#inspectLint(inspection: Inspection): Promise<Check> {\n\t\tconst stage = this.#lint\n\t\t// The lint stage waits on a foreign language server's silence and reads this bound's signal to\n\t\t// end that wait. The other stages take no signal and are abandoned and replaced instead.\n\t\treturn this.#inspectStage(\n\t\t\tstage,\n\t\t\tstage.progress,\n\t\t\t(signal) => stage.inspect(inspection.subject, { signal }),\n\t\t\tinspection.claim,\n\t\t)\n\t}\n\n\t#inspectRuntime(inspection: Inspection): Promise<Check> {\n\t\tconst stage = this.#runtime\n\t\treturn this.#inspectStage(\n\t\t\tstage,\n\t\t\tstage.progress,\n\t\t\t() => stage.inspect(inspection.subject),\n\t\t\tinspection.claim,\n\t\t)\n\t}\n\n\tasync #inspectStage(\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t\toperation: (signal: AbortSignal) => Promise<Check>,\n\t\tclaim: Claim,\n\t): Promise<Check> {\n\t\ttry {\n\t\t\treturn await this.#bound(\n\t\t\t\toperation,\n\t\t\t\t`The ${stage.stage} stage exceeded ${this.#deadline} ms`,\n\t\t\t\tstage,\n\t\t\t\tprogress,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.#emitExpiry(stage, claim)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Arms the deadline before the operation begins and hands the operation this deadline's signal.\n\t// A stage that can cut its own wait short is then bounded by the deadline that reports the\n\t// overrun rather than by a second bound of its own, and a stage that reads no signal is abandoned\n\t// and replaced exactly as before.\n\tasync #bound<T>(\n\t\toperation: (signal: AbortSignal) => Promise<T>,\n\t\tmessage: string,\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t): Promise<T> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\tconst expiry = this.#expiry(timeout, message, stage, progress)\n\t\t// The refusal is held as well as raced. An operation this signal aborts rejects with its own\n\t\t// tool's cancellation, that rejection can settle the race first, and it names the tool rather\n\t\t// than the stage that overran — so an expired deadline answers with this refusal either way.\n\t\tconst refusal = expiry.catch((error: unknown) => error)\n\t\ttry {\n\t\t\treturn await Promise.race([operation(timeout.signal), expiry])\n\t\t} catch (error) {\n\t\t\tif (!timeout.expired) throw error\n\t\t\tawait this.#recycle(stage)\n\t\t\tthrow await refusal\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t}\n\n\t// Replaces the stage one expired deadline destroyed, so a single slow claim costs that claim\n\t// rather than the process. A resident server whose type, lint, or runtime stage stays destroyed\n\t// answers every later claim with the destruction of a stage that caller never asked about.\n\tasync #recycle(stage: StageInterface): Promise<boolean> {\n\t\tif (this.#closing !== undefined) return false\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\t// Teardown of a hung stage can reject or outlive its own deadline, and the replacement\n\t\t\t// must be installed either way: the field otherwise stays destroyed for the life of the\n\t\t\t// process and every later claim reports that instead of its own evidence.\n\t\t\tawait Promise.race([\n\t\t\t\tstage.destroy(),\n\t\t\t\tthis.#expiry(\n\t\t\t\t\ttimeout,\n\t\t\t\t\t`The ${stage.stage} stage recovery exceeded ${this.#deadline} ms`,\n\t\t\t\t\tstage,\n\t\t\t\t\tstage.progress,\n\t\t\t\t),\n\t\t\t])\n\t\t} catch {\n\t\t\t// The failure belongs to the stage being replaced, and the replacement that follows is\n\t\t\t// the recovery the caller is owed.\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t\tif (this.#closing !== undefined) return false\n\t\t// Identity, not kind: a second expiry racing this one names the stage this call already\n\t\t// replaced, and rebuilding on that report would discard a live stage the queues are using.\n\t\tif (stage === this.#type) {\n\t\t\tthis.#type = new TypeStage(this.#workspace)\n\t\t\treturn true\n\t\t}\n\t\tif (stage === this.#lint) {\n\t\t\tthis.#lint = new LintStage(this.#workspace)\n\t\t\treturn true\n\t\t}\n\t\tif (stage === this.#runtime) {\n\t\t\tthis.#runtime = new RuntimeStage(this.#workspace)\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\t// Holds every caller-selected project resolution and type inspection on one promise chain. A\n\t// resolve that recycled the shared caller-named service during an inspection would change the\n\t// service that inspection resumes with after its next cooperative yield.\n\tasync #admitType(): Promise<() => void> {\n\t\tconst previous = this.#typeTail\n\t\tconst turn = Promise.withResolvers<void>()\n\t\tthis.#typeTail = turn.promise\n\t\tawait previous\n\t\treturn turn.resolve\n\t}\n\n\tasync #resolve(claim: Claim): Promise<Project> {\n\t\tconst release = await this.#admitType()\n\t\ttry {\n\t\t\tconst stage = this.#type\n\t\t\ttry {\n\t\t\t\treturn await this.#bound(\n\t\t\t\t\t() => stage.resolve(claim.project),\n\t\t\t\t\t`The type stage project resolution exceeded ${this.#deadline} ms`,\n\t\t\t\t\tstage,\n\t\t\t\t\tstage.progress,\n\t\t\t\t)\n\t\t\t} catch (error) {\n\t\t\t\tthis.#emitExpiry(stage, claim)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t} finally {\n\t\t\trelease()\n\t\t}\n\t}\n\n\t#emitExpiry(stage: StageInterface, claim: Claim): void {\n\t\tif (stage === this.#type || stage === this.#lint || stage === this.#runtime) return\n\t\tthis.#emitter.emit('expire', claim)\n\t}\n\n\t// Rejects when the deadline fires, so a race against it settles even when the operation it\n\t// races never returns. The stage travels beside the message because a caller catching this\n\t// branches on the category and the budget, and reads the message only to print it.\n\t#expiry(\n\t\ttimeout: TimeoutInterface,\n\t\tmessage: string,\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t): Promise<never> {\n\t\treturn new Promise<never>((_resolve, reject) => {\n\t\t\ttimeout.signal.addEventListener(\n\t\t\t\t'abort',\n\t\t\t\t() => {\n\t\t\t\t\tconst error = new ProbeError(message, {\n\t\t\t\t\t\torigin: stage.progress > progress ? 'claimant' : 'instrument',\n\t\t\t\t\t\tcode: 'deadline',\n\t\t\t\t\t\tcontext: { stage: stage.stage, deadline: this.#deadline },\n\t\t\t\t\t})\n\t\t\t\t\tthis.#deadlines.add(error)\n\t\t\t\t\treject(error)\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t)\n\t\t})\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\ttry {\n\t\t\ttry {\n\t\t\t\tawait this.#arming\n\t\t\t} catch {}\n\t\t\t// Tear the stages down and leave the queues running. A queue holds no host resource — no\n\t\t\t// timer, no listener, no store — and stage teardown settles every entry still admitted, so\n\t\t\t// each caller reads the stage's own refusal. Destroying a queue instead abandons those\n\t\t\t// entries, and a stage rejecting after its queue stopped observing ends the host process.\n\t\t\tawait Promise.all([\n\t\t\t\tthis.#destroyStage(this.#type),\n\t\t\t\tthis.#destroyStage(this.#lint),\n\t\t\t\tthis.#destroyStage(this.#runtime),\n\t\t\t])\n\t\t} finally {\n\t\t\t// Release the listener graph last, and release it on the teardown that failed as well:\n\t\t\t// a stage whose teardown rejects is the moment a host most needs its listeners gone, and\n\t\t\t// a plain trailing statement is the one skipped on exactly that path. `destroy` is\n\t\t\t// idempotent, so no guard stands in front of it.\n\t\t\tthis.#emitter.destroy()\n\t\t}\n\t}\n\n\tasync #destroyStage(stage: StageInterface): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#bound(\n\t\t\t\t() => stage.destroy(),\n\t\t\t\t`The ${stage.stage} stage teardown exceeded ${this.#deadline} ms`,\n\t\t\t\tstage,\n\t\t\t\tstage.progress,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\t// A teardown overrun cannot replace the destroyed stage, and every sibling still receives\n\t\t\t// its own bound. A teardown that fails before the deadline keeps its original rejection.\n\t\t\tif (!isProbeError(error) || !this.#deadlines.has(error)) throw error\n\t\t}\n\t}\n\n\t#version(name: string): string {\n\t\tconst manifest = readWorkspaceManifest(this.#workspace, name)\n\t\tconst version = manifest.contents.version\n\t\tif (!isString(version)) {\n\t\t\tthrow new ProbeError(`${name} publishes no readable version`, {\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { name },\n\t\t\t})\n\t\t}\n\t\treturn version\n\t}\n\n\t// Refuses a control that is the case again. No stage inspects such a claim: the refusal answers\n\t// before any stage is asked for an inspection and before the instrument is awaited, so it reads\n\t// the same in every workspace state — construction has already begun arming and running the boot\n\t// controls by the time this is reached, and neither touches this claim. Such a control can only\n\t// break by nondeterminism, and the receipt it would earn that way attests a falsification that\n\t// never happened — the worst answer this package can return. Identity covers the whole case, the\n\t// candidate drafts and the test, and it is decided on the bytes rather than on the digest a\n\t// verdict carries: that digest rewrites every workspace-contained absolute string to its relative\n\t// form, so two drafts one byte apart can hash alike and a control the claimant can break would be\n\t// refused. The control's `stage` and `reason` describe the drafts rather than being them, so\n\t// neither rescues a control whose files and test are the case's. Drafts are paired by position,\n\t// because a shared path materializes the last draft that carries it and reordering the list\n\t// therefore changes what the stages read.\n\t#admit(claim: Claim): void {\n\t\tconst subject = claim.case\n\t\tconst control = claim.control\n\t\tif (subject.test.path !== control.test.path) return\n\t\tif (subject.test.text !== control.test.text) return\n\t\tif (subject.files.length !== control.files.length) return\n\t\tconst repeated = subject.files.every((draft, index) => {\n\t\t\tconst other = control.files[index]\n\t\t\treturn other !== undefined && other.path === draft.path && other.text === draft.text\n\t\t})\n\t\tif (!repeated) return\n\t\tthrow new ProbeError(\n\t\t\t'The control must differ from the case; it carries the same candidate drafts and the same test',\n\t\t\t{ origin: 'claimant', code: 'refused' },\n\t\t)\n\t}\n\n\t#support(): void {\n\t\tconst version = this.#toolchain.typescript\n\t\tconst range = peerDependencies.typescript\n\t\tconst supported = /^\\^(\\d+)\\./u.exec(range)?.[1]\n\t\tconst found = /^(\\d+)\\./u.exec(version)?.[1]\n\t\tif (supported === undefined || found !== supported) {\n\t\t\tthrow new ProbeError(`The supported TypeScript range is ${range}; found ${version}`, {\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { name: 'typescript', value: version },\n\t\t\t})\n\t\t}\n\t}\n}\n","import type { ProbeInterface, ProbeOptions, Verdict } from '@src/core'\nimport type { MCPCallResult, MCPExecutionContext } from '@orkestrel/mcp'\nimport type { ToolResult } from '@orkestrel/tool'\nimport type { ProbeServerInterface } from './types.js'\nimport { resolve } from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport { compileSchema, schemaToParameters } from '@orkestrel/contract'\nimport { createMCPLegacy, createMCPServer, isBoundedJSON } from '@orkestrel/mcp'\nimport { createStdioServer } from '@orkestrel/mcp/server'\nimport { createTool, createToolManager } from '@orkestrel/tool'\nimport {\n\tCLAIM_SHAPE,\n\tPROBE_KEYS,\n\tProbeError,\n\tcreateDestroyedError,\n\tformatReceipt,\n\tformatVerdict,\n\tisClaim,\n\tisVerdict,\n} from '@src/core'\nimport { version } from '../../package.json' with { type: 'json' }\nimport { findRefusedPaths } from './helpers.js'\nimport { Probe } from './Probe.js'\n\n/**\n * Implements `ProbeServerInterface` over a `PassThrough` stream this server owns, binding the\n * published `prove` tool and the dual-era dispatcher to this process's Model Context Protocol\n * stdio transport.\n *\n * @remarks\n * Construction snapshots the probe options, publishes the `prove` tool, and binds the dual-era\n * dispatcher to the stdio transport. An admitted `prove` call creates the probe and begins\n * workspace arming, so discovery does not depend on the workspace toolchain. Construction is held\n * before it begins, so teardown entered through a construction callback waits for the resulting\n * probe and releases it. A constructor refusal clears that held operation for a later retry.\n *\n * `start` seizes standard input and registers the signals a harness ends a child with, and records\n * whether standard input was already flowing. Every listener it attaches is held as a field, and\n * `destroy` removes exactly those by reference, so a listener a host registers while this server is\n * serving is still attached and still fires afterwards. The transport reads a stream this server\n * owns rather than this process's standard input, which is what makes that possible: the\n * transport's own listeners land on that stream, and the only listeners this server ever puts on\n * `process.stdin` are the `data`, `close`, and `error` forwarders into it. `destroy` pauses the\n * stream only when this server is what set it flowing and nothing else is reading it, so a process\n * that outlives this server reads its own standard input again and receives its own signals.\n * Teardown removes the signal handlers first: it takes seconds when a boot is in flight, and a\n * harness that signals again means to kill rather than to queue.\n *\n * @example\n * ```ts\n * const server = new ProbeServer({ workspace: process.cwd() })\n * server.start()\n * await server.destroy()\n * ```\n */\nexport class ProbeServer implements ProbeServerInterface {\n\treadonly #options: ProbeOptions\n\treadonly #stream: PassThrough\n\treadonly #transport: ReturnType<typeof createStdioServer>\n\treadonly #data: (chunk: Buffer) => void\n\treadonly #close: () => void\n\treadonly #error: (error: Error) => void\n\treadonly #signal: () => void\n\treadonly #server: ReturnType<typeof createMCPServer>\n\t#owns: boolean | undefined\n\t#construction: Promise<ProbeInterface> | undefined\n\t#closing: Promise<void> | undefined\n\n\t/**\n\t * Snapshots the probe options this server will use and binds the published schema to this\n\t * process's stdio transport. An admitted `prove` call creates the probe.\n\t *\n\t * @param options - Workspace, deadline, and initial observation hooks for the deferred probe\n\t */\n\tconstructor(options?: ProbeOptions) {\n\t\tconst workspace = options?.workspace\n\t\tconst deadline = options?.deadline\n\t\tconst on = options?.on\n\t\tconst error = options?.error\n\t\tthis.#options = Object.freeze({\n\t\t\tworkspace: resolve(workspace ?? process.cwd()),\n\t\t\t...(deadline === undefined ? {} : { deadline }),\n\t\t\t...(on === undefined ? {} : { on: Object.freeze({ ...on }) }),\n\t\t\t...(error === undefined ? {} : { error }),\n\t\t})\n\t\t// `@orkestrel/mcp` 0.0.19 attaches three anonymous listeners to whatever stream it is given\n\t\t// and detaches none of them when its transport closes. Give it a stream this server owns, so\n\t\t// those listeners are never on `process.stdin` and teardown never has to decide which\n\t\t// listeners there were the transport's. A later transport that detaches its own leaves this\n\t\t// arrangement doing the same work rather than making it wrong.\n\t\tthis.#stream = new PassThrough()\n\t\t// Hold the composed server rather than hand it straight to the transport. It resolves the\n\t\t// bounds it was configured with and publishes them on `limit`, so `#execute` reads the bounds\n\t\t// it admits its own answer by from the server that enforces them, and one number decides both.\n\t\tthis.#server = this.#publish()\n\t\tthis.#transport = createStdioServer(createMCPLegacy(this.#server), { input: this.#stream })\n\t\t// One stable reference per listener, bound once here, because an emitter removes a listener\n\t\t// by identity and a reference built at attach time cannot be rebuilt at release time.\n\t\tthis.#data = this.#receive.bind(this)\n\t\tthis.#close = this.#finish.bind(this)\n\t\tthis.#error = this.#fail.bind(this)\n\t\tthis.#signal = this.#release.bind(this)\n\t}\n\n\tstart(): void {\n\t\t// `#owns` records that this server is serving and `#closing` that teardown has begun. A second\n\t\t// call while serving would attach another listener set and forget the first, while a call after\n\t\t// teardown would write into a stream this server has already destroyed.\n\t\tif (this.#closing !== undefined) throw createDestroyedError('probe server')\n\t\tif (this.#owns !== undefined) return\n\t\t// The stream's flow is what this server takes from the process beside the listener sets. Read\n\t\t// it here, before anything attaches, because this is the only moment the\n\t\t// answer exists. Read `readableFlowing` rather than `isPaused()`: a stream nobody has read\n\t\t// reports `readableFlowing` as `null`, and `isPaused()` folds that into the same `false` an\n\t\t// already-flowing stream reports, so only the flow itself separates a flow this server is\n\t\t// about to start from one it found running.\n\t\tthis.#owns = process.stdin.readableFlowing !== true\n\t\t// Arm the transport before the forwarders, so the stream it reads has its reader attached\n\t\t// before the first chunk can arrive on it.\n\t\tthis.#transport.start()\n\t\tprocess.stdin.on('data', this.#data)\n\t\tprocess.stdin.on('close', this.#close)\n\t\tprocess.stdin.on('error', this.#error)\n\t\tprocess.on('SIGINT', this.#signal)\n\t\tprocess.on('SIGTERM', this.#signal)\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\t// Release the signal handlers before anything slow. Teardown awaits the boot in flight and\n\t\t// takes seconds; a harness that signals again inside that window is asking for the process\n\t\t// rather than for a second graceful attempt, and with these handlers gone it gets it.\n\t\tprocess.removeListener('SIGINT', this.#signal)\n\t\tprocess.removeListener('SIGTERM', this.#signal)\n\t\tthis.#transport.stop()\n\t\t// Take back exactly the forwarders `start` attached, by reference. Removing a `data`\n\t\t// listener does not pause the stream, so the flow is decided after they are off: pause only\n\t\t// when this server both started the flow and is the last thing reading it. A host that was\n\t\t// already reading its own standard input keeps reading it, a host that began reading while\n\t\t// this server was serving keeps reading it too, and a host that never read gets its paused\n\t\t// stream back.\n\t\tprocess.stdin.removeListener('data', this.#data)\n\t\tprocess.stdin.removeListener('close', this.#close)\n\t\tprocess.stdin.removeListener('error', this.#error)\n\t\tif (this.#owns === true && process.stdin.listenerCount('data') === 0) process.stdin.pause()\n\t\tthis.#owns = undefined\n\t\t// Safe only after the forwarders are off: a chunk arriving on a destroyed stream would raise\n\t\t// a write-after-destroy error nothing is left to answer.\n\t\tthis.#stream.destroy()\n\t\tconst construction = this.#construction\n\t\tif (construction === undefined) return\n\t\tconst probe = await construction.catch(() => undefined)\n\t\tif (probe !== undefined) await probe.destroy()\n\t}\n\n\t// Forwards one chunk of this process's standard input into the stream the transport reads.\n\t#receive(chunk: Buffer): void {\n\t\tthis.#stream.write(chunk)\n\t}\n\n\t// Ends the transport's stream when standard input closes, so buffered bytes are still framed\n\t// before the transport reads the close.\n\t#finish(): void {\n\t\tthis.#stream.end()\n\t}\n\n\t// Carries a standard input failure to the transport as its stream's own error.\n\t#fail(error: Error): void {\n\t\tthis.#stream.destroy(error)\n\t}\n\n\t// Answers a termination signal. One reference serves both signals, and each removal names its\n\t// own event, so `destroy` takes it off `SIGINT` and `SIGTERM` independently.\n\t#release(): void {\n\t\tvoid this.destroy()\n\t}\n\n\t// Advertises `prove` as the one tool this server publishes, and renders each verdict as the text\n\t// a client reads. The claim guard runs here rather than inside the probe, because a tool call\n\t// arrives as unknown JSON and the coordinator's contract begins at a `Claim`.\n\t#publish(): ReturnType<typeof createMCPServer> {\n\t\tconst parameters = schemaToParameters(compileSchema(CLAIM_SHAPE))\n\t\tif (parameters === undefined) {\n\t\t\tthrow new ProbeError('The claim schema cannot be advertised as tool parameters', {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t})\n\t\t}\n\t\tconst tools = createToolManager()\n\t\ttools.add(\n\t\t\tcreateTool({\n\t\t\t\tname: 'prove',\n\t\t\t\tdescription:\n\t\t\t\t\t\"Answers whether a TypeScript edit compiles, lints, and passes its test in this workspace — call it before relying on such a claim, instead of reasoning or writing a throwaway probe. Supply the edit you believe is correct and an edit that must break with the stage it breaks at; the closing line is a receipt only when the case ran clean and the control broke exactly at its declared stage, and no receipt otherwise. For a performance claim, measure before proving: write a guarded bench block — if (import.meta.env.MODE === 'benchmark') — beside the probe test, run the workspace bench script, and record only magnitudes; a settled ratio then proves here as an ordinary runtime claim.\",\n\t\t\t\tparameters,\n\t\t\t\texecute: this.#prove.bind(this),\n\t\t\t}),\n\t\t)\n\t\treturn createMCPServer({\n\t\t\tidentity: { name: 'probe', version },\n\t\t\ttools,\n\t\t\tlimit: { keys: PROBE_KEYS },\n\t\t\texecution: this.#execute.bind(this),\n\t\t})\n\t}\n\n\tasync #prove(input: Readonly<Record<string, unknown>>): Promise<Verdict> {\n\t\tif (!isClaim(input)) {\n\t\t\tconst refused = findRefusedPaths(input)\n\t\t\tthrow new ProbeError(\n\t\t\t\trefused.length === 0\n\t\t\t\t\t? 'The prove tool requires a claim matching the advertised schema'\n\t\t\t\t\t: `The prove tool refuses ${refused.join(', ')}: a draft path must stay inside the workspace, which the advertised schema does not constrain`,\n\t\t\t\t{\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { value: input },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst probe = await this.#resolveProbe()\n\t\treturn probe.prove(input)\n\t}\n\n\t// Returns the admitted-call probe, constructing it only after validation. Store the construction\n\t// before it starts so a callback that enters `destroy` while `new Probe` is still returning joins\n\t// that construction and releases its result. A refused constructor clears the stored promise, so\n\t// a later admitted call retries instead of retaining the refusal.\n\tasync #resolveProbe(): Promise<ProbeInterface> {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('probe server')\n\t\tconst current = this.#construction\n\t\tif (current !== undefined) return await current\n\t\tconst construction = Promise.resolve().then(() => new Probe(this.#options))\n\t\tthis.#construction = construction\n\t\ttry {\n\t\t\treturn await construction\n\t\t} catch (error) {\n\t\t\tif (this.#construction === construction) this.#construction = undefined\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #execute(context: MCPExecutionContext): Promise<ToolResult | MCPCallResult> {\n\t\tconst result = await context.tools.execute(context.call)\n\t\tif (!result.success) return result\n\t\tif (!isVerdict(result.value)) {\n\t\t\tthrow new ProbeError('The prove tool returned an invalid verdict', {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { value: result.value },\n\t\t\t})\n\t\t}\n\t\tconst record = result.value\n\t\tconst limit = this.#server.limit\n\t\tconst bounds = { bytes: limit.content, keys: limit.keys, depth: limit.depth }\n\t\tconst rendered: MCPCallResult = {\n\t\t\tresultType: 'complete',\n\t\t\tcontent: [{ type: 'text', text: formatVerdict(record) }],\n\t\t}\n\t\tconst minimal: MCPCallResult = {\n\t\t\tresultType: 'complete',\n\t\t\tcontent: [{ type: 'text', text: formatReceipt(record) }],\n\t\t}\n\t\t// Three answers, widest first, each admitted by the bounds this server publishes before it is\n\t\t// returned: the record beside its rendering, the rendering alone, then the receipt block. A\n\t\t// result those bounds refuse reaches the client as a JSON-RPC internal error instead, which\n\t\t// costs the receipt as well as the record, so each arm drops what the bounds refused rather\n\t\t// than dropping the answer. `isBoundedJSON` is also what admits a `Verdict` into a field the\n\t\t// protocol types as JSON, which is why the record is read against the bounds before the pair\n\t\t// carrying it is composed. The last arm returns whether or not it is admitted: it is a\n\t\t// handful of keys and a few short lines, so bounds that refuse it belong to a server that\n\t\t// could produce no answer at all.\n\t\tconst arms: readonly MCPCallResult[] = isBoundedJSON(record, bounds)\n\t\t\t? [{ ...rendered, structuredContent: record }, rendered, minimal]\n\t\t\t: [rendered, minimal]\n\t\treturn arms.find((arm) => isBoundedJSON(arm, bounds)) ?? minimal\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,cAAc,MAAsB;CACnD,OAAO,KAAK,WAAW,MAAM,GAAG;AACjC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAAc,OAAoC;CACjE,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO,KAAA;CAC7B,MAAM,QAAQ;CACd,MAAM,UAAU,cAAe,UAAU,QAAQ,MAAM,OAAO,KAAA,CAAU;CACxE,IAAI,CAAC,QAAQ,SAAS,OAAO,KAAA;CAC7B,OAAO,SAAS,QAAQ,KAAK,IAAI,QAAQ,QAAQ,KAAA;AAClD;;;;;;;;;;;;;;;;;;;;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
{"version":3,"file":"index.js","names":[],"sources":["../../../src/server/helpers.ts","../../../src/server/parsers.ts","../../../src/server/Overlay.ts","../../../package.json","../../../src/server/stages/LintStage.ts","../../../src/server/stages/RuntimeStage.ts","../../../src/server/stages/TypeStage.ts","../../../src/server/Probe.ts","../../../src/server/ProbeServer.ts"],"sourcesContent":["import type { Issue, Stage } from '@src/core'\nimport type { Diagnostic, ListenerCapture, WorkspaceManifest } from './types.js'\nimport type { EventEmitter } from 'node:events'\nimport type { Dirent } from 'node:fs'\nimport type * as VitestNode from 'vitest/node'\nimport {\n\tcloseSync,\n\tconstants,\n\tftruncateSync,\n\tlstatSync,\n\topenSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { createRequire } from 'node:module'\nimport { dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport {\n\tattempt,\n\tcompileGuard,\n\tisArray,\n\tisError,\n\tisNumber,\n\tisObject,\n\tisRecord,\n\tisString,\n} from '@orkestrel/contract'\nimport { CLAIM_SHAPE, ProbeError, TYPE_MIRROR, isDraft, isProbeError } from '@src/core'\n\n/**\n * Rewrites one path into the forward-slash spelling this package compares and reports paths in.\n *\n * @remarks\n * Windows reports a path with backslashes and accepts either separator, so two spellings of one\n * file compare unequal until they are rewritten. Every path this package keys a map on, matches a\n * prefix against, or hands a caller passes through here first.\n *\n * @param path - The path to rewrite\n * @returns The same path with every backslash replaced by a forward slash\n *\n * @example\n * ```ts\n * normalizePath('src\\\\core\\\\greeting.ts') // 'src/core/greeting.ts'\n * normalizePath('src/core/greeting.ts') // 'src/core/greeting.ts'\n * ```\n */\nexport function normalizePath(path: string): string {\n\treturn path.replaceAll('\\\\', '/')\n}\n\n/**\n * Reads the condition code a native fault carries.\n *\n * @remarks\n * A caller catches `unknown`, so every reading of a caught value's own property calls into code\n * this package does not own: a proxy whose `has` trap throws and a value whose `code` getter throws\n * both arrive here. The read is guarded, so a fault that refuses inspection reports no code rather\n * than raising a second fault over the first. A `code` the host reports as anything other than a\n * string is no code this package compares against, so it reports none either.\n *\n * One reading serves every site that classifies a native fault, so a host condition is admitted the\n * same way wherever it is read.\n *\n * @param error - The caught value to read\n * @returns The fault's `code` when it carries a string one; `undefined` otherwise\n *\n * @example\n * ```ts\n * readFaultCode(Object.assign(new Error('no such file'), { code: 'ENOENT' })) // 'ENOENT'\n * readFaultCode(new Error('the runtime stage was destroyed')) // undefined\n * readFaultCode('ENOENT') // undefined\n * ```\n */\nexport function readFaultCode(error: unknown): string | undefined {\n\tif (!isObject(error)) return undefined\n\tconst fault = error\n\tconst reading = attempt(() => ('code' in fault ? fault.code : undefined))\n\tif (!reading.success) return undefined\n\treturn isString(reading.value) ? reading.value : undefined\n}\n\n/**\n * Reports whether one path resolves outside the root it is read against.\n *\n * @remarks\n * Containment decides which paths a claim may reach and which absolute paths a digest may rewrite,\n * so one reading serves every site that asks the question. A target resolving to the root itself is\n * contained, and each caller decides on its own what that empty relative path means for it.\n *\n * The test reads the relative path rather than a string prefix of the root, so a sibling directory\n * whose name begins with the root's own text is outside rather than beneath it. An absolute\n * relative path is the answer a host returns for two paths on different volumes, which no root\n * contains.\n *\n * @param root - The root the target is read against\n * @param target - The path to test, absolute or root-relative\n * @returns True if the target resolves outside the root; false otherwise\n *\n * @example\n * ```ts\n * escapesRoot('/srv/checkout', 'src/core/greeting.ts') // false\n * escapesRoot('/srv/checkout', '../secrets.env') // true\n * escapesRoot('/srv/checkout', '/srv/checkout-backup/secrets.env') // true\n * ```\n */\nexport function escapesRoot(root: string, target: string): boolean {\n\tconst path = relative(resolve(root), resolve(root, target))\n\treturn path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path)\n}\n\n/**\n * Resolves a path inside a target workspace and rejects traversal outside it.\n *\n * @remarks\n * A native `ENAMETOOLONG` or NUL-byte `ERR_INVALID_ARG_VALUE` fault is a claimant refusal. This\n * classifies the fault, not the author: a workspace nested deeply enough that this package's short\n * generated names overflow the host limit also reads as a claimant refusal.\n *\n * @param workspace - The target workspace root\n * @param target - A workspace-relative path\n * @param mutate - If `true`, refuses a symbolic link in an existing descendant; if `false`,\n * resolves lexically. Default: `false`\n * @returns The absolute contained path\n * @throws When the path resolves outside the workspace, mutation would cross a symbolic link, or\n * the target tree cannot be inspected\n *\n * @example\n * ```ts\n * resolveWorkspaceFile('/srv/checkout', 'src/core/greeting.ts')\n * // '/srv/checkout/src/core/greeting.ts'\n * resolveWorkspaceFile('/srv/checkout', '../secrets.env')\n * // throws: Path escapes the workspace: ../secrets.env\n * ```\n */\nexport function resolveWorkspaceFile(workspace: string, target: string, mutate = false): string {\n\tconst root = resolve(workspace)\n\tconst file = resolve(root, target)\n\tconst path = relative(root, file)\n\tif (path === '' || escapesRoot(root, file)) {\n\t\tthrow new ProbeError(`Path escapes the workspace: ${target}`, {\n\t\t\torigin: 'claimant',\n\t\t\tcode: 'refused',\n\t\t\tcontext: { path: target },\n\t\t})\n\t}\n\tif (!mutate) return file\n\ttry {\n\t\tconst canonical = realpathSync(root)\n\t\tlet descendant = root\n\t\tfor (const segment of path.split(sep)) {\n\t\t\tdescendant = resolve(descendant, segment)\n\t\t\tconst outcome = attempt(() => lstatSync(descendant))\n\t\t\tif (!outcome.success) {\n\t\t\t\tconst code = readFaultCode(outcome.error)\n\t\t\t\tif (code === 'ENOENT' || code === 'ENOTDIR') break\n\t\t\t\tthrow outcome.error\n\t\t\t}\n\t\t\tif (outcome.value.isSymbolicLink()) {\n\t\t\t\tthrow new ProbeError(`Path crosses a symbolic link: ${target}`, {\n\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { path: target },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst resolved = realpathSync(descendant)\n\t\t\tif (escapesRoot(canonical, resolved)) {\n\t\t\t\tthrow new ProbeError(`Path escapes the workspace: ${target}`, {\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { path: target },\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tif (isProbeError(error)) throw error\n\t\tconst code = readFaultCode(error)\n\t\tconst claimant = code === 'ENAMETOOLONG' || code === 'ERR_INVALID_ARG_VALUE'\n\t\tthrow new ProbeError(`The workspace path cannot be inspected: ${target}`, {\n\t\t\torigin: claimant ? 'claimant' : 'workspace',\n\t\t\tcode: claimant ? 'refused' : 'malformed',\n\t\t\tcontext: { path: target },\n\t\t\tcause: error,\n\t\t})\n\t}\n\treturn file\n}\n\n/**\n * Overwrites a file that already exists, through a descriptor that refuses a symbolic link at the\n * final component.\n *\n * @remarks\n * A containment walk and the write that follows it are separate calls, so a process that swaps the\n * final component between them decides where the bytes land. `writeFileSync` opens with the default\n * `w` flag, which follows a symbolic link at that component and creates the file when it is absent,\n * so the walk's reading does not bind the write. Opening `O_WRONLY | O_NOFOLLOW` moves that\n * decision into the call that writes: a link at the final component refuses the open, and the\n * omitted `O_CREAT` fails `ENOENT` for a target that has gone since the walk saw it. This is the\n * mutating counterpart of the `wx` flag every create in this package uses. Which code the refusal\n * carries is the host's; Linux with Node v22.22.2 reported `ELOOP` on 2026-08-24.\n *\n * Truncation runs through the held descriptor rather than through an `O_TRUNC` flag, so it reaches\n * the file the open bound. A Windows host refuses the numeric `O_TRUNC` without `O_CREAT` outright:\n * measured on 2026-08-26 on Windows 11 with Node v24.19.0 over NTFS, `openSync` reported `EINVAL`\n * for `O_WRONLY | O_TRUNC` and for `O_RDWR | O_TRUNC` while `O_WRONLY` alone opened, and adding\n * `O_CREAT` would trade that refusal for the create this function must never perform.\n *\n * A directory component stays open, because Node exposes no descriptor-relative call to walk and\n * write through one set of descriptors. Where a host's Node build defines no `O_NOFOLLOW`, that flag\n * contributes nothing to the flag set and the final component is open on that host too.\n *\n * @param file - The absolute path to overwrite\n * @param text - The text to write\n * @returns Nothing\n * @throws The host's own fault when the final component is a symbolic link, when the file is\n * absent, or when the host refuses the descriptor\n *\n * @example\n * ```ts\n * const file = resolveWorkspaceFile('/srv/checkout', 'tmp/probes/arm-type.ts', true)\n * writeFileSync(file, 'export type Signal = string\\n', { encoding: 'utf8', flag: 'wx' })\n * overwriteFile(file, 'export type Signal = number\\n')\n * readFileSync(file, 'utf8') // 'export type Signal = number\\n'\n * ```\n */\nexport function overwriteFile(file: string, text: string): void {\n\tconst descriptor = openSync(file, constants.O_WRONLY | constants.O_NOFOLLOW)\n\ttry {\n\t\tftruncateSync(descriptor, 0)\n\t\twriteFileSync(descriptor, text, 'utf8')\n\t} finally {\n\t\tcloseSync(descriptor)\n\t}\n}\n\n/**\n * Reports whether a fault means the host refuses the name a caller supplied for a file to create.\n *\n * @remarks\n * A host reports one refusal with a code of its own and several unrelated conditions with one\n * shared code, so the code alone does not separate a name the host will not accept from a file\n * that is merely absent. `ENAMETOOLONG` names the refusal outright. `ERR_INVALID_ARG_VALUE` names\n * every argument Node rejects, so it names the refusal only for a path carrying the NUL byte Node\n * refuses; the same code arrives for a bad `flag` and a bad encoding, which say nothing about the\n * name. An `ENOENT` raised while the parent stats as a directory names the refusal too, because an\n * ordinary absent file beneath an existing directory would have been created instead; a Windows\n * host reports an overlong component and a character its filesystem reserves that way. Measured on\n * 2026-08-21 on Windows 11 with Node v24.18.1 over NTFS, `writeFileSync` reported `ENOENT` for a\n * 300-character final component and never reported `ENAMETOOLONG`.\n *\n * This reads the fault the host reported rather than applying a length or character policy of its\n * own, so a host that accepts a name another host refuses is not second-guessed and no platform\n * branch decides the answer. Every read of the fault is guarded, so it is total over every value a\n * published caller can supply: a proxy whose `has` trap throws, a value whose `code` getter throws,\n * a fault carrying no code, and a parent this host cannot stat each report false.\n *\n * @param file - The path whose creation failed\n * @param error - The fault the failed operation raised\n * @returns True if the fault means the host refuses this name; false otherwise\n *\n * @example\n * ```ts\n * try {\n * \twriteFileSync('tmp/probes/greeting\\0.test.ts', '')\n * } catch (error) {\n * \tisRefusedName('tmp/probes/greeting\\0.test.ts', error) // true\n * }\n * isRefusedName('tmp/probes/greeting.test.ts', new Error('the runtime stage was destroyed')) // false\n * ```\n */\nexport function isRefusedName(file: string, error: unknown): boolean {\n\tconst code = readFaultCode(error)\n\tif (code === 'ENAMETOOLONG') return true\n\tif (code === 'ERR_INVALID_ARG_VALUE') return file.includes('\\0')\n\tif (code !== 'ENOENT') return false\n\tconst parent = attempt(() => statSync(dirname(file), { throwIfNoEntry: false }))\n\treturn parent.success && parent.value !== undefined && parent.value.isDirectory()\n}\n\n/**\n * Projects an absolute tool path into the workspace-relative form issues expose.\n *\n * @param workspace - The target workspace root\n * @param file - The path a tool reported\n * @returns A forward-slash workspace-relative path\n *\n * @example\n * ```ts\n * relativeWorkspaceFile('/srv/checkout', '/srv/checkout/src/core/greeting.ts')\n * // 'src/core/greeting.ts'\n * ```\n */\nexport function relativeWorkspaceFile(workspace: string, file: string): string {\n\treturn normalizePath(relative(resolve(workspace), resolve(file)))\n}\n\n/**\n * Projects the paths one tool named in a message into the forms this package's issues expose.\n *\n * @remarks\n * An issue's `path` is workspace-relative, and its message is prose a tool wrote about the same\n * tree. Left alone that prose names a file by the host's own layout, so one issue reports a path two\n * ways and a reader on another checkout is sent to a directory that is not theirs. Each spelling of\n * the root is removed: the absolute path, the backslash spelling a Windows tool writes, and the\n * `file:` URL a runtime names a module by. A root the host itself names ends in a separator, and the\n * paths beneath it continue straight from it rather than from one more separator. A path outside the\n * workspace stands as it is, because a relative spelling of it would name a file the tree does not\n * hold.\n *\n * A spelling of the root counts only where a path begins: at the start of the message, or after a\n * character no path carries. A directory whose own name ends in this root's text holds a different\n * tree, so the root inside a longer path names a file this workspace does not hold and that path\n * survives whole.\n *\n * Only the root is removed. A name is otherwise the tool's, including a `.probe-` name that reads\n * like a specification this package generates: the stage that wrote one knows the exact name it\n * wrote and renames that name itself, which is the only reading that separates its own file from a\n * file the target tree owns.\n *\n * Everything else the tool wrote survives verbatim, separators included. A message carries text\n * that is not a path — a runtime escapes a newline as a backslash when it prints a string inline,\n * and a compiler quotes a string literal with its escapes intact — so rewriting every separator\n * would corrupt the evidence the message exists to carry. The cost is that the path left behind\n * keeps the separator the tool chose, which on Windows is not the one `Issue.path` uses.\n *\n * @param workspace - The target workspace root\n * @param message - The message a tool reported\n * @returns The message with the host's own layout removed from every path that begins with it\n *\n * @example\n * ```ts\n * relativeWorkspaceMessage('/srv/checkout', 'Cannot read /srv/checkout/tsconfig.json')\n * // 'Cannot read tsconfig.json'\n * relativeWorkspaceMessage('/srv/checkout', 'Cannot read /mirror/srv/checkout/tsconfig.json')\n * // 'Cannot read /mirror/srv/checkout/tsconfig.json'\n * ```\n */\nexport function relativeWorkspaceMessage(workspace: string, message: string): string {\n\tconst root = resolve(workspace)\n\tconst forward = normalizePath(root)\n\tconst url = pathToFileURL(forward).href\n\t// On a host whose separator is a forward slash the native and forward-slash spellings are one\n\t// string, and a host root carries its separator already, so the set holds each distinct prefix\n\t// once and a root passes through as itself rather than as a doubled separator.\n\tconst spellings = new Set([\n\t\turl.endsWith('/') ? url : `${url}/`,\n\t\tforward.endsWith('/') ? forward : `${forward}/`,\n\t\troot.endsWith(sep) ? root : `${root}${sep}`,\n\t])\n\tlet text = message\n\tfor (const spelling of spellings) {\n\t\ttext = text.replaceAll(spelling, (match: string, offset: number, source: string) =>\n\t\t\t// A character a path carries sits before this occurrence, so the occurrence is inside a\n\t\t\t// longer path that another tree holds rather than at the start of one of this tree's own.\n\t\t\t// The character before offset 0 reads as empty, which no class matches.\n\t\t\t/[^\\s\"'`()[\\]{}<>,;:=|]/u.test(source.charAt(offset - 1)) ? match : '',\n\t\t)\n\t}\n\treturn text\n}\n\n/**\n * Scans the plain-text output of one compiler run into the diagnostics it reported.\n *\n * @remarks\n * Reads the shape `tsc --pretty false` prints: `path(line,column): error TSnnnn: message` for a\n * diagnostic about a file, and `error TSnnnn: message` for one about a project. A line that carries\n * neither prefix and begins with whitespace is an elaboration of the diagnostic above it and joins\n * that message with a newline; any other line is skipped, so a runtime's own failure text yields no\n * diagnostic and a caller reads that as the fault it is. The compiler counts lines and columns from\n * one and columns in UTF-16 code units, so each location is lowered to the zero-based UTF-16 point\n * `Diagnostic.range` fixes and `end` resolves to `start`, which is the extent this output carries.\n * A warning reads as a diagnostic, because the workspace's own gate reports it the same way. The\n * `TS\\d+` token that follows `error` or `warning` is what recognizes the line; nothing is captured\n * from it, because `Diagnostic` carries no field for it.\n *\n * @param text - The compiler's output\n * @returns One record per reported diagnostic, in the compiler's own order\n *\n * @example\n * ```ts\n * scanDiagnostics(\"src/a.ts(1,14): error TS2322: Type 'string' is not assignable to type 'number'.\")\n * // [{ path: 'src/a.ts', range: { start: { line: 0, character: 13 }, end: { line: 0, character: 13 } }, message: \"Type 'string' is not assignable to type 'number'.\" }]\n * scanDiagnostics('error TS5058: The specified path does not exist.')\n * // [{ message: 'The specified path does not exist.' }]\n * ```\n */\nexport function scanDiagnostics(text: string): readonly Diagnostic[] {\n\tconst diagnostics: Diagnostic[] = []\n\tfor (const line of text.split(/\\r\\n|\\n/)) {\n\t\tconst located = /^(.+)\\((\\d+),(\\d+)\\): (?:error|warning) TS\\d+: (.*)$/u.exec(line)\n\t\tif (located !== null) {\n\t\t\tconst row = Number.parseInt(located[2] ?? '1', 10) - 1\n\t\t\tconst column = Number.parseInt(located[3] ?? '1', 10) - 1\n\t\t\tconst point = { line: row, character: column }\n\t\t\tdiagnostics.push({\n\t\t\t\tpath: normalizePath(located[1] ?? ''),\n\t\t\t\trange: { start: point, end: point },\n\t\t\t\tmessage: located[4] ?? '',\n\t\t\t})\n\t\t\tcontinue\n\t\t}\n\t\tconst bare = /^(?:error|warning) TS\\d+: (.*)$/u.exec(line)\n\t\tif (bare !== null) {\n\t\t\tdiagnostics.push({ message: bare[1] ?? '' })\n\t\t\tcontinue\n\t\t}\n\t\tconst previous = diagnostics.at(-1)\n\t\tif (previous === undefined || !/^\\s+\\S/u.test(line)) continue\n\t\tdiagnostics[diagnostics.length - 1] = {\n\t\t\t...previous,\n\t\t\tmessage: `${previous.message}\\n${line}`,\n\t\t}\n\t}\n\treturn diagnostics\n}\n\n/**\n * Resolves one installed module from the target workspace.\n *\n * @param workspace - The target workspace root\n * @param specifier - The module specifier to resolve\n * @returns The installed module entry path\n * @throws When the workspace does not install the module\n *\n * @example\n * ```ts\n * resolveWorkspaceModule(process.cwd(), 'typescript/package.json') ===\n * \treadWorkspaceManifest(process.cwd(), 'typescript').path // true\n * ```\n */\nexport function resolveWorkspaceModule(workspace: string, specifier: string): string {\n\tconst outcome = attempt(() =>\n\t\tcreateRequire(resolve(workspace, 'package.json')).resolve(specifier),\n\t)\n\tif (outcome.success) return outcome.value\n\tconst error = outcome.error\n\tconst missing = readFaultCode(error) === 'MODULE_NOT_FOUND'\n\tthrow new ProbeError(`The workspace cannot resolve ${specifier}`, {\n\t\torigin: 'workspace',\n\t\tcode: missing ? 'missing' : 'malformed',\n\t\tcontext: { name: specifier },\n\t\tcause: error,\n\t})\n}\n\n/**\n * Loads the installed `vitest/node` module from a target workspace.\n *\n * @remarks\n * The only tool this package drives in process. The compiler is a process this package spawns\n * rather than a module it loads, so `typescript` is resolved through {@link resolveWorkspaceBinary}\n * instead.\n *\n * @param workspace - The target workspace root\n * @returns The installed `vitest/node` module\n * @throws When the workspace cannot load `vitest/node`\n *\n * @example\n * ```ts\n * const vitest = loadWorkspaceVitest(process.cwd())\n * typeof vitest.createVitest === 'function' // true\n * ```\n */\nexport function loadWorkspaceVitest(workspace: string): typeof VitestNode {\n\tconst outcome = attempt(() => {\n\t\tconst require = createRequire(resolve(workspace, 'package.json'))\n\t\treturn require('vitest/node')\n\t})\n\tif (outcome.success) return outcome.value\n\tconst error = outcome.error\n\tconst missing = readFaultCode(error) === 'MODULE_NOT_FOUND'\n\tthrow new ProbeError('The workspace cannot load vitest/node', {\n\t\torigin: 'workspace',\n\t\tcode: missing ? 'missing' : 'malformed',\n\t\tcontext: { name: 'vitest/node' },\n\t\tcause: error,\n\t})\n}\n\n/**\n * Reads one installed package manifest from the target workspace.\n *\n * @param workspace - The target workspace root\n * @param name - The installed package name\n * @returns The manifest's absolute path and parsed record\n * @throws When the package cannot be resolved, read, parsed, or does not publish a record manifest\n *\n * @example\n * ```ts\n * const manifest = readWorkspaceManifest(process.cwd(), 'typescript')\n * console.log(manifest.contents.version)\n * ```\n */\nexport function readWorkspaceManifest(workspace: string, name: string): WorkspaceManifest {\n\tlet path: string\n\ttry {\n\t\tpath = resolveWorkspaceModule(workspace, `${name}/package.json`)\n\t} catch (error) {\n\t\tif (!isProbeError(error)) throw error\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: error.code,\n\t\t\tcontext: { name },\n\t\t\tcause: error.cause,\n\t\t})\n\t}\n\tconst reading = attempt(() => readFileSync(path, 'utf8'))\n\tif (!reading.success) {\n\t\tconst error = reading.error\n\t\tconst code = readFaultCode(error)\n\t\tconst missing = code === 'ENOENT' || code === 'ENOTDIR'\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: missing ? 'missing' : 'malformed',\n\t\t\tcontext: { name, path },\n\t\t\tcause: error,\n\t\t})\n\t}\n\tconst parsing = attempt<unknown>(() => JSON.parse(reading.value))\n\tif (!parsing.success) {\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { name, path },\n\t\t\tcause: parsing.error,\n\t\t})\n\t}\n\tconst contents = parsing.value\n\tif (!isRecord(contents)) {\n\t\tthrow new ProbeError(`${name} does not publish a readable manifest`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { name, path },\n\t\t})\n\t}\n\treturn { path, contents }\n}\n\n/**\n * Resolves a package's portable JavaScript binary from the target workspace.\n *\n * @remarks\n * A package publishes its binaries under keys of its own choosing, and that key is often not the\n * package name: `typescript` publishes `tsc`. Name the key as `command` wherever the two differ.\n * Default: the package name.\n *\n * @param workspace - The target workspace root\n * @param name - The installed package name\n * @param command - The `bin` key to read. Default: `name`\n * @returns The absolute JavaScript entry named by the package's `bin` field\n * @throws When the package does not publish a binary under the requested key\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(process.cwd(), resolveWorkspaceBinary(process.cwd(), 'oxlint'))\n * // 'node_modules/oxlint/bin/oxlint'\n * relativeWorkspaceFile(process.cwd(), resolveWorkspaceBinary(process.cwd(), 'typescript', 'tsc'))\n * // 'node_modules/typescript/bin/tsc'\n * ```\n */\nexport function resolveWorkspaceBinary(workspace: string, name: string, command = name): string {\n\tconst manifest = readWorkspaceManifest(workspace, name)\n\tconst bin = manifest.contents.bin\n\tif (bin === undefined) {\n\t\tthrow new ProbeError(`${name} does not publish a bin field`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'missing',\n\t\t\tcontext: { name },\n\t\t})\n\t}\n\tif (isString(bin)) return resolve(manifest.path, '..', bin)\n\tif (!isRecord(bin) || !(command in bin)) {\n\t\tthrow new ProbeError(`${name} does not publish the ${command} binary`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'missing',\n\t\t\tcontext: { name },\n\t\t})\n\t}\n\tconst entry = bin[command]\n\tif (!isString(entry)) {\n\t\tthrow new ProbeError(`${name} publishes an invalid ${command} binary`, {\n\t\t\torigin: 'workspace',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { name, value: entry },\n\t\t})\n\t}\n\treturn resolve(manifest.path, '..', entry)\n}\n\n/**\n * Selects the scoped TypeScript project for one candidate draft path.\n *\n * @param path - The workspace-relative candidate draft path\n * @returns The workspace-relative scoped project path\n * @throws When the path does not name a configured source or application environment\n *\n * @example\n * ```ts\n * inferTypeProject('src/core/greeting.ts') // 'configs/src/tsconfig.core.json'\n * inferTypeProject('tests/src/core/greeting.test.ts')\n * // throws: Cannot infer a scoped TypeScript project for tests/src/core/greeting.test.ts\n * ```\n */\nexport function inferTypeProject(path: string): string {\n\tconst [axis, environment] = normalizePath(path).split('/')\n\tif ((axis !== 'src' && axis !== 'app') || environment === undefined || environment === '') {\n\t\tthrow new ProbeError(`Cannot infer a scoped TypeScript project for ${path}`, {\n\t\t\torigin: 'claimant',\n\t\t\tcode: 'refused',\n\t\t\tcontext: { path },\n\t\t})\n\t}\n\treturn `configs/${axis}/tsconfig.${environment}.json`\n}\n\n/**\n * Selects the Vitest project whose environment matches one test path.\n *\n * @remarks\n * There is no root-project fallback. A path no configured project collects returns `undefined`,\n * and the runtime stage refuses that claimant test with `code: 'missing'` rather than running it\n * somewhere the workspace never configured.\n *\n * @param path - The workspace-relative test path\n * @returns The matching project's name, or `undefined` when no configured project collects the path\n *\n * @example\n * ```ts\n * inferTestProject('tmp/probes/greeting.test.ts') // 'probe'\n * inferTestProject('tests/src/server/helpers.test.ts') // 'src:server'\n * inferTestProject('tests/config.test.ts') // undefined\n * ```\n */\nexport function inferTestProject(path: string): string | undefined {\n\tconst [root, axis, environment] = normalizePath(path).split('/')\n\tif (root === 'tmp' && axis === 'probes') return 'probe'\n\tif (root !== 'tests' || axis === undefined || environment === undefined) return undefined\n\tif (axis !== 'src' && axis !== 'app') return undefined\n\treturn `${axis}:${environment}`\n}\n\n/**\n * Selects the Language Server Protocol language identifier for a source path.\n *\n * @param path - The source path whose extension selects the language\n * @returns The matching JavaScript or TypeScript language identifier\n *\n * @example\n * ```ts\n * inferDocumentLanguage('src/core/greeting.ts') // 'typescript'\n * inferDocumentLanguage('src/browser/Panel.tsx') // 'typescriptreact'\n * ```\n */\nexport function inferDocumentLanguage(path: string): string {\n\tconst extension = extname(path).toLowerCase()\n\tif (extension === '.tsx') return 'typescriptreact'\n\tif (extension === '.js' || extension === '.mjs' || extension === '.cjs') return 'javascript'\n\tif (extension === '.jsx') return 'javascriptreact'\n\treturn 'typescript'\n}\n\n/**\n * Builds the fresh sibling path a revision's file is written at, preserving the test's resolution\n * directory.\n *\n * @param workspace - The target workspace root\n * @param path - The workspace-relative test path\n * @param revision - The fresh revision identity\n * @returns The absolute sibling path\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(\n * \t'/srv/checkout',\n * \tbuildRevisionPath('/srv/checkout', 'tmp/probes/greeting.test.ts', '4821-9f0c'),\n * )\n * // 'tmp/probes/greeting.test.probe-4821-9f0c.ts'\n * ```\n */\nexport function buildRevisionPath(workspace: string, path: string, revision: string): string {\n\tconst file = resolveWorkspaceFile(workspace, path)\n\tconst extension = extname(file)\n\tconst stem = extension === '' ? file : file.slice(0, -extension.length)\n\treturn `${stem}.probe-${revision}${extension}`\n}\n\n/**\n * Filters one issue list to the distinct issues it carries, in the order they arrived.\n *\n * @remarks\n * A stage that reads one candidate through more than one tool run reports that candidate's\n * diagnostic once per run. Two issues are the same issue when their party, path, message, and range\n * all agree, because those are every value an issue carries.\n *\n * @param issues - The issues to filter\n * @returns The distinct issues, in the order the list carried them\n *\n * @example\n * ```ts\n * const issue: Issue = { origin: 'claimant', path: 'src/core/greeting.ts', message: 'not assignable' }\n * filterUniqueIssues([issue, { ...issue }]).length // 1\n * ```\n */\nexport function filterUniqueIssues(issues: readonly Issue[]): readonly Issue[] {\n\tconst seen = new Set<string>()\n\tconst distinct: Issue[] = []\n\tfor (const issue of issues) {\n\t\tconst key = JSON.stringify([issue.origin, issue.path, issue.message, issue.range])\n\t\tif (seen.has(key)) continue\n\t\tseen.add(key)\n\t\tdistinct.push(issue)\n\t}\n\treturn distinct\n}\n\n/**\n * Reports whether a path is a workspace module Vitest can cache.\n *\n * @param path - The candidate file path\n * @returns True if the path is a script, TypeScript, Vue, or JSON module; false otherwise\n *\n * @example\n * ```ts\n * matchesWorkspaceModule('src/core/greeting.ts') // true\n * matchesWorkspaceModule('src/styles/tokens.css') // false\n * ```\n */\nexport function matchesWorkspaceModule(path: string): boolean {\n\treturn /\\.(?:[cm]?[jt]sx?|vue|json)$/.test(path)\n}\n\n/**\n * Reports whether the host that wrote one file is still running.\n *\n * @remarks\n * Signal 0 delivers nothing and reports reachability alone. A process this one may not signal\n * reports `EPERM` and reads as running, and a non-positive identity names a process group rather\n * than a process, so both answer true: the safe direction is to keep a file this package cannot\n * account for.\n *\n * @param id - The process id a file's own revision names\n * @returns True if that process is running or cannot be judged; false otherwise\n *\n * @example\n * ```ts\n * matchesLiveProcess(process.pid) // true\n * matchesLiveProcess(0) // true\n * ```\n */\nexport function matchesLiveProcess(id: number): boolean {\n\tif (!isNumber(id) || !Number.isSafeInteger(id) || id <= 0) return true\n\ttry {\n\t\tprocess.kill(id, 0)\n\t\treturn true\n\t} catch (error) {\n\t\treturn readFaultCode(error) === 'EPERM'\n\t}\n}\n\n/**\n * Collects every regular file a target workspace holds, skipping the trees no inspection reads.\n *\n * @remarks\n * Skips a directory named `.git`, `dist`, or `node_modules` at any depth, and the directory\n * {@link TYPE_MIRROR} names, which would otherwise carry this package's own mirror into the walk. A\n * directory this host cannot list is skipped rather than raised, so one unreadable directory in a\n * consumer's tree is not a reason to refuse the whole walk. A symbolic link is not carried, whether\n * it names a file or a directory, so a file reached only through one is absent from the result; a\n * `Dirent` that is neither a directory nor a regular file is skipped the same way.\n *\n * @param workspace - The target workspace root\n * @returns The absolute path of every regular file the walk found\n *\n * @example\n * ```ts\n * collectWorkspaceFiles(process.cwd()).some((path) => path.endsWith('package.json')) // true\n * ```\n */\nexport function collectWorkspaceFiles(workspace: string): readonly string[] {\n\tconst excluded = normalizePath(resolveWorkspaceFile(workspace, TYPE_MIRROR))\n\tconst files: string[] = []\n\tconst directories = [resolve(workspace)]\n\twhile (directories.length > 0) {\n\t\tconst directory = directories.pop()\n\t\tif (directory === undefined) break\n\t\tlet entries: readonly Dirent[] = []\n\t\ttry {\n\t\t\tentries = readdirSync(directory, { withFileTypes: true })\n\t\t} catch {}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name === '.git' || entry.name === 'dist' || entry.name === 'node_modules') continue\n\t\t\tconst path = join(directory, entry.name)\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (normalizePath(path) !== excluded) directories.push(path)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (entry.isFile()) files.push(path)\n\t\t}\n\t}\n\treturn files\n}\n\n/**\n * Normalizes a caught or foreign error into readable text.\n *\n * @param value - The value to describe\n * @returns Its message when present, or its string representation\n *\n * @example\n * ```ts\n * describeUnknown(new Error('The lint stage has been destroyed'))\n * // 'The lint stage has been destroyed'\n * describeUnknown(17) // '17'\n * ```\n */\nexport function describeUnknown(value: unknown): string {\n\tif (isError(value)) return value.message\n\tif (isObject(value) && 'message' in value && isString(value.message)) {\n\t\treturn value.message\n\t}\n\treturn String(value)\n}\n\n/**\n * Guards one stage operation with the stage failure contract.\n *\n * @param stage - The stage serving the operation\n * @param operation - The operation to settle\n * @returns The operation's fulfilled value\n * @throws The original `ProbeError`, or an instrument-owned malformed failure retaining the cause\n *\n * @example\n * ```ts\n * await guardStage('type', stage.inspect(subject))\n * ```\n */\nexport async function guardStage<T>(stage: Stage, operation: Promise<T>): Promise<T> {\n\ttry {\n\t\treturn await operation\n\t} catch (error) {\n\t\tif (isProbeError(error)) throw error\n\t\tthrow new ProbeError(`The ${stage} stage could not serve (${describeUnknown(error)})`, {\n\t\t\torigin: 'instrument',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { stage },\n\t\t\tcause: error,\n\t\t})\n\t}\n}\n\n/**\n * Names every draft member of a claim-shaped value whose `path` this package's guard refuses.\n *\n * @remarks\n * The published claim schema constrains `Draft.path` to a non-empty string and nothing else, while\n * `isDraft` also refuses an absolute path and one that escapes the workspace. That one member is\n * the whole of the difference between the advertised contract and the enforced one, so a caller\n * refused after satisfying the schema is refused here and nowhere else. The whole input must first\n * satisfy that schema. Each draft is then tested with `isDraft` itself rather than with a second\n * copy of its rule. Reports nothing for a value carrying no draft member, including one refused for\n * a member this contract does not declare.\n *\n * This function lives in the server helpers rather than in core: core's leaf pair, `helpers.ts` and\n * `validators.ts`, may not consume the shapes module this function reads `CLAIM_SHAPE` from, and\n * `ProbeServer` is the sole consumer of the result it returns.\n *\n * @param value - The rejected tool input\n * @returns The dotted member names, in `case` then `control` order, or an empty list\n *\n * @example\n * ```ts\n * const test = { path: 'tmp/probes/greeting.test.ts', text: '' }\n * findRefusedPaths({\n * \tproject: 'tsconfig.json',\n * \tcase: { files: [{ path: '../../etc/hosts', text: '' }], test },\n * \tcontrol: { files: [], test, stage: 'type', reason: 'must not compile' },\n * })\n * // ['case.files.0.path']\n * ```\n */\nexport function findRefusedPaths(value: unknown): readonly string[] {\n\tif (!compileGuard(CLAIM_SHAPE)(value)) return []\n\tconst members: string[] = []\n\tfor (const phase of ['case', 'control'] as const) {\n\t\tconst subject = value[phase]\n\t\tconst drafts = new Map<string, unknown>([[`${phase}.test`, subject.test]])\n\t\tfor (const [index, file] of subject.files.entries()) {\n\t\t\tdrafts.set(`${phase}.files.${index}`, file)\n\t\t}\n\t\tfor (const [member, draft] of drafts) {\n\t\t\tif (isDraft(draft)) continue\n\t\t\tmembers.push(`${member}.path`)\n\t\t}\n\t}\n\treturn members\n}\n\n/**\n * Rewrites every workspace-contained absolute path in a value to its workspace-relative form and\n * sorts every record's keys.\n *\n * @remarks\n * `tsc --showConfig` spells a path relative to the project file, so a printed record carries an\n * absolute path only where a project itself declares one. Rewriting a contained absolute path to\n * its relative form keeps one commit checked out at two roots reading to one digest. A path that\n * escapes the workspace is left as it stands, because rewriting it would name a file outside the\n * tree by a relative spelling. Key order is the compiler's own and it differs between the supported\n * majors, so sorting removes a difference that means nothing.\n *\n * @param workspace - The target workspace root\n * @param value - The value to rewrite\n * @returns The value with contained absolute paths made relative and every record key sorted\n *\n * @example\n * ```ts\n * normalizeValue('/srv/checkout', { rootDir: '/srv/checkout/src/core', strict: true })\n * // { rootDir: 'src/core', strict: true }\n * ```\n */\nexport function normalizeValue(workspace: string, value: unknown): unknown {\n\tconst root = resolve(workspace)\n\tif (isString(value)) {\n\t\tif (!isAbsolute(value)) return value\n\t\tconst path = relative(root, resolve(value))\n\t\tif (path === '') return '.'\n\t\tif (escapesRoot(root, value)) return value\n\t\treturn normalizePath(path)\n\t}\n\tif (isArray(value)) return value.map((entry) => normalizeValue(workspace, entry))\n\tif (isRecord(value)) {\n\t\tconst record: Record<string, unknown> = {}\n\t\tfor (const key of Object.keys(value).sort()) record[key] = normalizeValue(workspace, value[key])\n\t\treturn record\n\t}\n\treturn value\n}\n\n/**\n * Computes the canonical digest of one value as it stands in a target workspace.\n *\n * @remarks\n * Digests the normalized value rather than the value itself, so one commit read at two absolute\n * roots produces one digest and a digest carries no host path. The result is the leading 32 hex\n * characters of a SHA-256 over the normalized JSON.\n *\n * @param workspace - The target workspace root the value's paths are read against\n * @param value - The value to digest\n * @returns 32 lowercase hex characters\n *\n * @example\n * ```ts\n * computeDigest('/srv/checkout', { strict: true }).length // 32\n * ```\n */\nexport function computeDigest(workspace: string, value: unknown): string {\n\treturn createHash('sha256')\n\t\t.update(JSON.stringify(normalizeValue(workspace, value)))\n\t\t.digest('hex')\n\t\t.slice(0, 32)\n}\n\n/**\n * Records the listeners one emitter carries for a set of events.\n *\n * @param emitter - The emitter to read\n * @param events - The event names to record\n * @returns The listeners each named event carries at the moment of the call\n *\n * @example\n * ```ts\n * const capture = captureListeners(process, ['SIGTERM'])\n * capture.get('SIGTERM')?.length === process.listenerCount('SIGTERM') // true\n * ```\n */\nexport function captureListeners(\n\temitter: EventEmitter,\n\tevents: readonly string[],\n): ListenerCapture {\n\tconst capture = new Map<string, readonly Function[]>()\n\tfor (const event of events) capture.set(event, emitter.listeners(event))\n\treturn capture\n}\n\n/**\n * Removes every listener one emitter gained for the captured events since its capture.\n *\n * @remarks\n * Compares identity rather than name, so a listener whose name a dependency changes between\n * releases is still recognized and a listener that merely shares a name is still left alone. A\n * listener the capture already held survives, and a listener the capture held that has since been\n * removed is not restored.\n *\n * A gain is not evidence of who caused it, so this reads every gain as the callee's. Call it only\n * across a window nothing else can attach in — a synchronous call, or a call whose handlers land\n * before its first await and that is released as it returns — because a listener anyone else\n * attaches inside that window is removed with the rest. Where a caller cannot promise that window,\n * hold each handler as a field and remove it by reference instead of capturing at all.\n *\n * @param emitter - The emitter to release\n * @param capture - The listeners the emitter carried at capture time\n * @returns Nothing\n *\n * @example\n * ```ts\n * const capture = captureListeners(process, ['SIGTERM'])\n * process.on('SIGTERM', () => {})\n * releaseListeners(process, capture)\n * process.listenerCount('SIGTERM') === capture.get('SIGTERM')?.length // true\n * ```\n */\nexport function releaseListeners(emitter: EventEmitter, capture: ListenerCapture): void {\n\tfor (const [event, captured] of capture) {\n\t\tfor (const listener of emitter.listeners(event)) {\n\t\t\tif (captured.includes(listener)) continue\n\t\t\temitter.removeListener(event, listener)\n\t\t}\n\t}\n}\n","import type { ProjectConfig } from './types.js'\nimport { isArray, isRecord, parseJSON, isString } from '@orkestrel/contract'\n\n/**\n * Parses the configuration one compiler run printed for a TypeScript project.\n *\n * @remarks\n * Reads what `tsc --showConfig` writes: a JSON record carrying the resolved `compilerOptions`\n * beside the project's own file selection. `compilerOptions` is carried unvalidated, because a\n * caller digests it rather than reading a member out of it. `files` and `include` are read only\n * where the printed record carries one whose entries are all strings, so a member the compiler\n * printed in another shape reads as absent rather than as an empty selection. Text that is not a\n * JSON record, including the diagnostic the compiler prints for a project it refuses, yields\n * `undefined`.\n *\n * @param text - The compiler's printed configuration\n * @returns The project's resolved configuration, or `undefined` when the text carries no record\n *\n * @example\n * ```ts\n * parseProjectConfig('{\"compilerOptions\":{\"strict\":true}}')?.compilerOptions // { strict: true }\n * parseProjectConfig(\"error TS5058: The specified path does not exist.\") // undefined\n * ```\n */\nexport function parseProjectConfig(text: string): ProjectConfig | undefined {\n\tconst parsed = parseJSON(text)\n\tif (!isRecord(parsed)) return undefined\n\tconst files = parsed.files\n\tconst include = parsed.include\n\treturn {\n\t\tcompilerOptions: parsed.compilerOptions,\n\t\t...(isArray(files) && files.every(isString) ? { files } : {}),\n\t\t...(isArray(include) && include.every(isString) ? { include } : {}),\n\t}\n}\n\n/**\n * Parses the process id one revision identity names.\n *\n * @remarks\n * Every file and directory this package writes into a target carries the writing host's process id\n * and a fresh UUID, joined by `-`. A sweep reads that id to decide whether the host that wrote the\n * name is gone. The whole identity must match, so a name carrying anything else yields `undefined`\n * and the sweep leaves what it found alone.\n *\n * @param revision - The revision identity a name carries\n * @returns The process id it names, or `undefined` when the text is not a revision identity\n *\n * @example\n * ```ts\n * parseRevisionOwner('4821-1b4e28ba-2fa1-11d2-883f-0016d3cca427') // 4821\n * parseRevisionOwner('4821-9f0c') // undefined\n * ```\n */\nexport function parseRevisionOwner(revision: string): number | undefined {\n\tconst match = /^(\\d+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u.exec(\n\t\trevision,\n\t)\n\tconst owner = match?.[1]\n\treturn owner === undefined ? undefined : Number.parseInt(owner, 10)\n}\n","import type { OverlayInterface } from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport { normalizePath } from './helpers.js'\n\n/**\n * Implements `OverlayInterface` over a private map from normalized absolute path to candidate text,\n * minting at construction the `revision` a resident tool caches its answers against.\n *\n * @remarks\n * One overlay belongs to one inspection: the inspection creates it, records every candidate it\n * carries, and clears it when the inspection ends. Each stage adapts the same set to the host its\n * own tool expects rather than sharing one filesystem across tools. A fresh identity per instance\n * is what makes a resident tool re-read a path this overlay holds, so two inspections that supply\n * different text for one path never share a cached answer.\n *\n * A lookup key matches a recorded path exactly, after both pass through `normalizePath`, so a tool\n * that reports its own paths with backslashes still reaches a candidate recorded with forward\n * slashes. Case is never folded: the recorded spelling is what `paths` reports, what `covers`\n * compares a directory against, and what `text` answers under. A stage whose tool resolves two\n * spellings of one file name to one file therefore reports the path its tool served rather than\n * matching the two spellings here.\n *\n * @example\n * ```ts\n * const overlay = new Overlay()\n * const path = '/srv/checkout/src/core/factories.ts'\n * overlay.set(path, \"export function createGreeting(): string {\\n\\treturn 'hi'\\n}\\n\")\n * console.log(overlay.text(path))\n * overlay.clear()\n * ```\n */\nexport class Overlay implements OverlayInterface {\n\treadonly #revision = randomUUID()\n\treadonly #candidates = new Map<string, string>()\n\n\tget revision(): string {\n\t\treturn this.#revision\n\t}\n\n\tget paths(): readonly string[] {\n\t\treturn [...this.#candidates.keys()]\n\t}\n\n\t/**\n\t * Records one candidate's text against the absolute path it stands in for.\n\t *\n\t * @remarks\n\t * Recording a candidate under a path this overlay already holds replaces that candidate, the way\n\t * one file holds one text.\n\t *\n\t * @param path - The absolute path the candidate replaces\n\t * @param text - The candidate's full contents\n\t * @returns Nothing\n\t */\n\tset(path: string, text: string): void {\n\t\tthis.#candidates.set(normalizePath(path), text)\n\t}\n\n\t/**\n\t * Reads the candidate text recorded for one absolute path.\n\t *\n\t * @param path - The absolute path to read\n\t * @returns The recorded text, or `undefined` when this overlay holds no candidate there\n\t */\n\ttext(path: string): string | undefined {\n\t\treturn this.#candidates.get(normalizePath(path))\n\t}\n\n\t/**\n\t * Checks whether a candidate sits beneath one directory.\n\t *\n\t * @remarks\n\t * The answer is derived from the paths the overlay holds rather than stored, so it stops being\n\t * true exactly when the inspection that declared those candidates clears them. Both sides pass\n\t * through `normalizePath` first, because a tool that normalizes its own paths asks about a\n\t * directory in a spelling the recorded path may not share.\n\t *\n\t * @param directory - The absolute directory path to check\n\t * @returns True if a candidate path sits beneath the directory; false otherwise\n\t */\n\tcovers(directory: string): boolean {\n\t\tconst base = `${normalizePath(directory).replace(/\\/+$/, '')}/`\n\t\tfor (const path of this.#candidates.keys()) {\n\t\t\tif (path.startsWith(base)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\t/**\n\t * Releases every candidate.\n\t *\n\t * @returns Nothing\n\t */\n\tclear(): void {\n\t\tthis.#candidates.clear()\n\t}\n}\n","{\n\t\"name\": \"@orkestrel/probe\",\n\t\"version\": \"0.0.20\",\n\t\"description\": \"Prove a claim with type, lint, and runtime evidence from the workspace's own toolchain.\",\n\t\"keywords\": [\n\t\t\"agent\",\n\t\t\"lint\",\n\t\t\"mcp\",\n\t\t\"oxlint\",\n\t\t\"probe\",\n\t\t\"typescript\",\n\t\t\"vitest\"\n\t],\n\t\"homepage\": \"https://github.com/orkestrel/probe#readme\",\n\t\"bugs\": \"https://github.com/orkestrel/probe/issues\",\n\t\"license\": \"MIT\",\n\t\"repository\": {\n\t\t\"type\": \"git\",\n\t\t\"url\": \"git+https://github.com/orkestrel/probe.git\"\n\t},\n\t\"bin\": {\n\t\t\"probe\": \"dist/bin/main.js\"\n\t},\n\t\"files\": [\n\t\t\"dist/src\",\n\t\t\"dist/bin\",\n\t\t\"README.md\"\n\t],\n\t\"type\": \"module\",\n\t\"sideEffects\": [\n\t\t\"./src/bin/main.ts\",\n\t\t\"./dist/bin/main.js\"\n\t],\n\t\"main\": \"./dist/src/core/index.cjs\",\n\t\"module\": \"./dist/src/core/index.js\",\n\t\"exports\": {\n\t\t\".\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/src/core/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/src/core/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/src/core/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/src/core/index.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./server\": {\n\t\t\t\"import\": {\n\t\t\t\t\"types\": \"./dist/src/server/index.d.ts\",\n\t\t\t\t\"default\": \"./dist/src/server/index.js\"\n\t\t\t},\n\t\t\t\"require\": {\n\t\t\t\t\"types\": \"./dist/src/server/index.d.cts\",\n\t\t\t\t\"default\": \"./dist/src/server/index.cjs\"\n\t\t\t}\n\t\t},\n\t\t\"./package.json\": \"./package.json\"\n\t},\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"scripts\": {\n\t\t\"clean\": \"node -e \\\"require('node:fs').rmSync('dist',{recursive:true,force:true})\\\"\",\n\t\t\"copy\": \"node -e \\\"const fs=require('node:fs'),p=require('node:path'),a=process.argv[1],b=process.argv[2];fs.mkdirSync(p.dirname(b),{recursive:true});fs.cpSync(a,b,{force:true});console.log('Copied: '+a+' to '+b)\\\"\",\n\t\t\"format\": \"oxfmt --config .oxfmtrc.json --write .\",\n\t\t\"format:check\": \"oxfmt --config .oxfmtrc.json --check .\",\n\t\t\"lint\": \"oxlint --config .oxlintrc.json --fix .\",\n\t\t\"lint:check\": \"oxlint --config .oxlintrc.json --deny-warnings .\",\n\t\t\"check\": \"tsc --noEmit --project tsconfig.json && npm run check:src\",\n\t\t\"check:src\": \"npm run check:src:core && npm run check:src:server && npm run check:src:bin\",\n\t\t\"check:src:core\": \"tsc --noEmit -p configs/src/tsconfig.core.json\",\n\t\t\"check:src:server\": \"tsc --noEmit -p configs/src/tsconfig.server.json\",\n\t\t\"check:src:bin\": \"tsc --noEmit -p configs/src/tsconfig.bin.json\",\n\t\t\"test\": \"npm run test:src && npm run test:policy && npm run test:config && npm run test:setup && npm run test:guides\",\n\t\t\"test:src\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core --project src:server --project src:bin\",\n\t\t\"test:src:core\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:core\",\n\t\t\"test:src:server\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:server\",\n\t\t\"test:src:bin\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project src:bin\",\n\t\t\"test:policy\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project policy\",\n\t\t\"test:config\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project config\",\n\t\t\"test:setup\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project setup\",\n\t\t\"test:guides\": \"node --experimental-strip-types tests/guides.test.ts\",\n\t\t\"test:distribution\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project distribution\",\n\t\t\"test:probe\": \"vitest run --config vite.config.ts --no-cache --reporter=verbose --project probe\",\n\t\t\"test:bench\": \"vitest bench --config vite.config.ts --no-cache --project probe\",\n\t\t\"build\": \"npm run clean && npm run build:src\",\n\t\t\"build:src\": \"npm run build:src:core && npm run build:src:server && npm run build:src:bin\",\n\t\t\"build:src:core\": \"vite build --config configs/src/vite.core.config.ts && npm run copy dist/src/core/index.d.ts dist/src/core/index.d.cts\",\n\t\t\"build:src:server\": \"vite build --config configs/src/vite.server.config.ts && npm run copy dist/src/server/index.d.ts dist/src/server/index.d.cts\",\n\t\t\"build:src:bin\": \"vite build --config configs/src/vite.bin.config.ts\",\n\t\t\"prepack\": \"npm run build\",\n\t\t\"prepublishOnly\": \"npm run format:check && npm run lint:check && npm run check && npm run build && npm test && npm run test:distribution -- --mode release\"\n\t},\n\t\"dependencies\": {\n\t\t\"@orkestrel/contract\": \"^0.0.19\",\n\t\t\"@orkestrel/emitter\": \"^0.0.11\",\n\t\t\"@orkestrel/lsp\": \"^0.0.10\",\n\t\t\"@orkestrel/mcp\": \"^0.0.36\",\n\t\t\"@orkestrel/queue\": \"^0.0.16\",\n\t\t\"@orkestrel/timeout\": \"^0.0.12\",\n\t\t\"@orkestrel/tool\": \"^0.0.18\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@microsoft/api-extractor\": \"^7.59.3\",\n\t\t\"@orkestrel/guide\": \"^0.0.24\",\n\t\t\"@orkestrel/scaffold\": \"^0.0.90\",\n\t\t\"@orkestrel/test\": \"^0.0.24\",\n\t\t\"@types/node\": \"^26.6.4\",\n\t\t\"oxfmt\": \"^0.71.0\",\n\t\t\"oxlint\": \"^1.86.0\",\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vite\": \"^8.3.2\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"typescript\": {\n\t\t\t\"optional\": true\n\t\t},\n\t\t\"vitest\": {\n\t\t\t\"optional\": true\n\t\t}\n\t},\n\t\"engines\": {\n\t\t\"node\": \"^22.12.0 || >=24.0.0\"\n\t}\n}\n","import type { Case, Check, Draft, Issue, Stage } from '@src/core'\nimport type { InspectionOptions, LintStageInterface } from '../types.js'\nimport type { LSPClientInterface, LSPDiagnostic, LSPExit } from '@orkestrel/lsp'\nimport { pathToFileURL } from 'node:url'\nimport { createLSPClient } from '@orkestrel/lsp'\nimport { createStdioClientTransport } from '@orkestrel/lsp/server'\nimport { LINT_DEADLINE, ProbeError, createDestroyedError } from '@src/core'\nimport { isError } from '@orkestrel/contract'\nimport {\n\tdescribeUnknown,\n\tguardStage,\n\tinferDocumentLanguage,\n\tnormalizePath,\n\tresolveWorkspaceBinary,\n\tresolveWorkspaceFile,\n} from '../helpers.js'\n\n/**\n * Inspects virtual documents through one resident Oxlint language server.\n *\n * @remarks\n * Construction starts the target workspace's Oxlint binary with its Language Server Protocol mode\n * and hands the conversation to `@orkestrel/lsp`: `createStdioClientTransport` owns the child\n * process and its bytes, and `createLSPClient` owns the framing, the request correlation, the\n * capabilities this stage advertises, and the choice between pulled and pushed diagnostics. This\n * stage owns the workspace, the candidate identity, and the projection from a diagnostic to an\n * `Issue`.\n *\n * Each inspection opens the supplied text by URI, waits for the client's diagnostics, and closes the\n * document without writing it to disk. The caller's own signal is what bounds that wait, so a server\n * that admits a document and publishes nothing refuses the inspection when the caller's bound\n * expires rather than holding it for the life of the process. This stage mints no bound of its own\n * for the wait: a second one would race the caller's, and the answer would depend on scheduling.\n *\n * Teardown is bounded at both ends. Warming waits for the server's `initialize` response and the\n * ending waits for its `shutdown` reply, and the protocol leaves both answers to the server, so the\n * client's deadline bounds each exchange and the transport's cooperative window takes the ending\n * back with a signal when that window passes.\n *\n * The URI is the path the candidate declared, so the candidate receives exactly the rule set the\n * workspace's own lint gate applies to that path, including an override anchored to one directory,\n * one file name, or one exact file. A path the workspace's version-control ignore files exclude is\n * a path that gate never lints, and this stage reports the same nothing for it. Reuse of one\n * declared path across inspections is what the caller's own serialization protects: the stage\n * refuses a second inspection of a path it already has open rather than answering either one with\n * the other's diagnostics.\n *\n * @example\n * ```ts\n * const stage = new LintStage('/srv/checkout')\n * const check = await stage.inspect(subject, { signal: AbortSignal.timeout(30_000) })\n * await stage.destroy()\n * ```\n */\nexport class LintStage implements LintStageInterface {\n\treadonly #workspace: string\n\treadonly #documents = new Set<string>()\n\treadonly #warmth: Promise<LSPClientInterface>\n\t// Teardown reads the constructed client rather than the warming result, because a warming that\n\t// failed or that is still waiting for its answer still leaves a client and a child to release.\n\t#client: LSPClientInterface | undefined\n\t#ending: string | undefined\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before the\n\t// teardown it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t// The version every document this stage opens carries. It counts admissions across the stage's\n\t// whole life and never falls, because the gauge beside it does fall and a version that fell would\n\t// tell the server this text is older than the text it replaced.\n\t#revision = 0\n\n\t/**\n\t * Starts warming the target workspace's Oxlint language server.\n\t *\n\t * @param workspace - The target workspace root. Default: the current working directory\n\t */\n\tconstructor(workspace: string = process.cwd()) {\n\t\tthis.#workspace = workspace\n\t\tthis.#warmth = this.#warm()\n\t\t// Observe the stored promise here. Nothing reads it until an inspection or a teardown\n\t\t// arrives, and an unobserved rejection ends the host process. The stored promise keeps\n\t\t// rejecting, so an inspection still reports the warming failure.\n\t\tvoid this.#warmth.catch(() => {})\n\t}\n\n\tget stage(): Stage {\n\t\treturn 'lint'\n\t}\n\n\tget progress(): number {\n\t\treturn this.#progress\n\t}\n\n\tinspect(subject: Case, options?: InspectionOptions): Promise<Check> {\n\t\treturn guardStage(this.stage, this.#inspect(subject, options))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = guardStage(this.stage, this.#destroy())\n\t\treturn this.#closing\n\t}\n\n\tasync #inspect(subject: Case, options: InspectionOptions | undefined): Promise<Check> {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('lint stage')\n\t\t// The shared stage contract takes one argument, so this bound is optional in the type and\n\t\t// required in fact. Serving without it would mean minting a bound beside the caller's, which\n\t\t// is the racing pair this seam exists to remove.\n\t\tif (options === undefined) {\n\t\t\tthrow new ProbeError('The lint stage inspects only under a bound its caller supplies', {\n\t\t\t\torigin: 'claimant',\n\t\t\t\tcode: 'refused',\n\t\t\t\tcontext: { stage: this.stage },\n\t\t\t})\n\t\t}\n\t\tconst started = performance.now()\n\t\tconst client = await this.#warmed()\n\t\tif (this.#closing !== undefined) throw createDestroyedError('lint stage')\n\t\tconst issues: Issue[] = []\n\t\tfor (const draft of [...subject.files, subject.test]) {\n\t\t\tissues.push(...(await this.#document(client, draft, options.signal)))\n\t\t}\n\t\treturn {\n\t\t\tstage: this.stage,\n\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\tissues,\n\t\t}\n\t}\n\n\t// Releases the client, which ends its conversation and its child. The client asks the server to\n\t// shut down, bounds that reply, writes the `exit` the protocol leaves to the client to force,\n\t// and hands a child that outlives the cooperative window to a signal, so a server that answers\n\t// neither its ending nor its signal is released rather than deadlocking this call.\n\tasync #destroy(): Promise<void> {\n\t\tawait this.#client?.destroy()\n\t}\n\n\t// Builds the conversation and warms it. Everything before the first await runs while the\n\t// constructor is still on the stack, so teardown finds the client whatever the warming does\n\t// next; a workspace that publishes no Oxlint binary rejects here instead, and leaves none.\n\tasync #warm(): Promise<LSPClientInterface> {\n\t\tconst binary = resolveWorkspaceBinary(this.#workspace, 'oxlint')\n\t\tconst client = createLSPClient({\n\t\t\ttransport: createStdioClientTransport({\n\t\t\t\tserver: {\n\t\t\t\t\tcommand: [process.execPath, binary, '--lsp'],\n\t\t\t\t\tdirectory: this.#workspace,\n\t\t\t\t},\n\t\t\t\tgrace: LINT_DEADLINE / 2,\n\t\t\t}),\n\t\t\tworkspace: pathToFileURL(this.#workspace).href,\n\t\t\ttimeout: LINT_DEADLINE,\n\t\t})\n\t\tthis.#client = client\n\t\tclient.emitter.on('exit', (exit) => this.#retire(exit))\n\t\tawait client.start()\n\t\treturn client\n\t}\n\n\t// Reads the warmed client, phrasing a warming failure the way this stage reports one.\n\tasync #warmed(): Promise<LSPClientInterface> {\n\t\ttry {\n\t\t\treturn await this.#warmth\n\t\t} catch (error) {\n\t\t\tthrow this.#translate(error)\n\t\t}\n\t}\n\n\t// Names one ending for a message. The host announces an exit with exactly one non-null member,\n\t// and the client reports the signalled death and the code exit through the same event, so a\n\t// later inspection can say which one the server took.\n\t#retire(exit: LSPExit): void {\n\t\tthis.#ending = exit.signal === null ? `code ${exit.code}` : `signal ${exit.signal}`\n\t}\n\n\t// Opens one candidate at the path it was declared. Oxlint keys its overrides on globs, so any\n\t// identity distinct from that path selects a different rule set from the one the workspace's own\n\t// gate applies, and an override naming one exact file is reachable by nothing else. One URI\n\t// carries one open document, so a caller driving two inspections of one path at once is refused\n\t// rather than served an answer belonging to the other. The document is closed whatever the\n\t// inspection returned, so the same path is inspectable again.\n\tasync #document(\n\t\tclient: LSPClientInterface,\n\t\tdraft: Draft,\n\t\tsignal: AbortSignal,\n\t): Promise<readonly Issue[]> {\n\t\tconst uri = pathToFileURL(resolveWorkspaceFile(this.#workspace, draft.path)).href\n\t\tif (this.#documents.has(uri)) {\n\t\t\tthrow new ProbeError(`The lint stage is already inspecting ${draft.path}`, {\n\t\t\t\torigin: 'claimant',\n\t\t\t\tcode: 'refused',\n\t\t\t\tcontext: { stage: this.stage, path: draft.path },\n\t\t\t})\n\t\t}\n\t\tthis.#documents.add(uri)\n\t\t// Raise the gauge as the document is admitted rather than when its answer arrives, so a\n\t\t// coordinator comparing its snapshot reads claimant-owned work in flight, and lower it again\n\t\t// in the `finally` block before the close this stage owes its own instrument is awaited, so\n\t\t// an expiry during that cleanup reads level with the snapshot and names the instrument.\n\t\tthis.#progress += 1\n\t\tthis.#revision += 1\n\t\ttry {\n\t\t\tconst diagnostics = await client.open(\n\t\t\t\t{\n\t\t\t\t\turi,\n\t\t\t\t\tlanguageId: inferDocumentLanguage(draft.path),\n\t\t\t\t\tversion: this.#revision,\n\t\t\t\t\ttext: draft.text,\n\t\t\t\t},\n\t\t\t\t{ signal },\n\t\t\t)\n\t\t\treturn this.#issues(normalizePath(draft.path), diagnostics)\n\t\t} catch (error) {\n\t\t\tif (signal.aborted) throw this.#abandoned(draft.path)\n\t\t\tthrow this.#translate(error, draft.path)\n\t\t} finally {\n\t\t\tthis.#progress -= 1\n\t\t\tthis.#documents.delete(uri)\n\t\t\t// A server that ended, and a client that is closing, can no longer be told the document\n\t\t\t// closed. Neither failure may replace the diagnosis the caller is receiving.\n\t\t\tawait client.close(uri).catch(() => undefined)\n\t\t}\n\t}\n\n\t// Names the caller's own bound as what ended one wait. The client reports its cancellation as a\n\t// transport failure, and `guardStage` would carry that to the caller as this stage's fault, which\n\t// tells a coordinator the instrument broke when the instrument was told to stop. A coordinator\n\t// that armed the signal replaces this with its own refusal; a coordinator of the caller's own\n\t// reads it directly.\n\t#abandoned(path: string): ProbeError {\n\t\treturn new ProbeError('The lint stage inspection stopped at the bound its caller supplied', {\n\t\t\torigin: 'claimant',\n\t\t\tcode: 'deadline',\n\t\t\tcontext: { stage: this.stage, path },\n\t\t})\n\t}\n\n\t// Phrases one failure the way this stage reports one. A destroyed stage refuses on its own\n\t// terms, a server that ended is named by the ending it took, and everything else is the\n\t// client's own coded failure, which `guardStage` carries to the caller as this stage's fault.\n\t#translate(error: unknown, path?: string): Error {\n\t\tif (this.#closing !== undefined) return createDestroyedError('lint stage')\n\t\tconst ending = this.#ending\n\t\tif (ending !== undefined) {\n\t\t\treturn this.#fault(`The Oxlint language server exited with ${ending}`, error, path)\n\t\t}\n\t\tif (isError(error)) return error\n\t\treturn this.#fault(describeUnknown(error), error, path)\n\t}\n\n\t// Every fault this stage reports about its own language server, under one category and naming\n\t// the stage that produced it. A caller catching one is told the inspection did not complete,\n\t// which is a different answer from a diagnostic about the candidate it supplied.\n\t#fault(message: string, cause?: unknown, path?: string): ProbeError {\n\t\treturn new ProbeError(message, {\n\t\t\torigin: 'instrument',\n\t\t\tcode: 'malformed',\n\t\t\tcontext: { stage: this.stage, ...(path === undefined ? {} : { path }) },\n\t\t\t...(cause === undefined ? {} : { cause }),\n\t\t})\n\t}\n\n\t// Every issue here is one diagnostic Oxlint published about the text the caller supplied, so\n\t// each one is that code failing. A server this stage cannot drive rejects the inspection\n\t// instead, so no fault of its own reaches a caller as an issue. The published range is already\n\t// the zero-based UTF-16 span the issue stores, so no conversion happens here; each coordinate is\n\t// read once into a span this package owns rather than the diagnostic's own object being carried\n\t// into a value that outlives the inspection.\n\t#issues(path: string, diagnostics: readonly LSPDiagnostic[]): readonly Issue[] {\n\t\treturn diagnostics.map((diagnostic): Issue => ({\n\t\t\torigin: 'claimant',\n\t\t\tpath,\n\t\t\tmessage: diagnostic.message,\n\t\t\trange: {\n\t\t\t\tstart: {\n\t\t\t\t\tline: diagnostic.range.start.line,\n\t\t\t\t\tcharacter: diagnostic.range.start.character,\n\t\t\t\t},\n\t\t\t\tend: { line: diagnostic.range.end.line, character: diagnostic.range.end.character },\n\t\t\t},\n\t\t}))\n\t}\n}\n","import type { Case, Check, Draft, Issue, Stage } from '@src/core'\nimport type { OverlayInterface, StageInterface } from '../types.js'\nimport type {\n\tTestProjectConfiguration,\n\tUserProjectConfigFn,\n\tUserWorkspaceConfig,\n\tViteUserConfig,\n} from 'vitest/config'\nimport type { TestProject, TestRunResult, Vitest, createVitest } from 'vitest/node'\nimport {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\trealpathSync,\n\tunlinkSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { basename, dirname, extname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport { fileURLToPath } from 'node:url'\nimport { attempt, isArray, isNumber, isObject, isString } from '@orkestrel/contract'\nimport {\n\tPROBE_SPECIFICATIONS,\n\tProbeError,\n\tRUNTIME_PLUGIN,\n\tcreateDestroyedError,\n\tformatSpecification,\n\tisProbeError,\n\tmatchesSpecification,\n} from '@src/core'\nimport {\n\tbuildRevisionPath,\n\tcaptureListeners,\n\tcollectWorkspaceFiles,\n\tdescribeUnknown,\n\tguardStage,\n\tinferTestProject,\n\tisRefusedName,\n\tloadWorkspaceVitest,\n\tmatchesLiveProcess,\n\tmatchesWorkspaceModule,\n\tnormalizePath,\n\treleaseListeners,\n\trelativeWorkspaceFile,\n\trelativeWorkspaceMessage,\n\tresolveWorkspaceFile,\n} from '../helpers.js'\nimport { Overlay } from '../Overlay.js'\n\n/**\n * Inspects tests through one resident Vitest service from the target workspace.\n *\n * @remarks\n * Construction starts Vitest with the threads pool and instruments each inline or function-declared\n * project with a Vite plugin that reads the active inspection's candidate overlay. A selected\n * string-declared project reports a workspace issue because its configuration carries no runtime\n * overlay plugin. Every inspection writes one fresh sibling specification, invalidates each\n * workspace module whose disk content or candidate revision changed, runs that specification,\n * evicts its result, and deletes the file. Clearing the overlay makes the next snapshot differ from\n * the candidate revision, so the next inspection invalidates that module and reads disk again.\n * After the run, the stage checks each covered module reachable from the generated specification\n * against the overlay paths its loader served. A target-config loader that served first produces a\n * workspace issue; a module id probe's loader received but failed to match produces an instrument\n * issue.\n * The runtime overlay leaves bare specifier resolution to Vite: it replaces a bare import only\n * after Vite resolves that import to a covered file. The type stage overlays the declared test\n * path, while this stage executes a generated sibling and overlays only the candidate files.\n * This stage mints its overlay with the default exact-match sensitivity, because it declares no\n * file-name case sensitivity to Vite. A covered path whose spelling an importer wrote differs from\n * the recorded candidate path is therefore served by whatever answers first, and `#misses` reports\n * it as `The workspace configuration served this module before the runtime overlay` with origin\n * `workspace` rather than leaving it answered silently.\n *\n * Vite retains one unresolved URL for every specification path, so the stage replaces its whole\n * Vitest service after 64 specifications rather than deleting from each map that service owns. Any\n * bound holds the retention flat, because the replacement releases everything the instance held,\n * and 64 is the value chosen. The inspection that crosses the bound pays the replacement\n * synchronously: it closes the resident service and warms a new one before it runs. On 2026-08-20,\n * over this package's own workspace on the host `guides/probe.md` § Cost names, two runs of 66\n * inspections put that one at 480 ms and 269 ms against median inspections of 156 ms and 155 ms, so\n * budget one call in 64 at 110 ms to 330 ms above the rest.\n *\n * Every issue this stage emits names its party, and the stage emits an issue for every party\n * `Party` declares. An `origin: 'claimant'` issue is a failure Vitest reported about the candidate.\n * An `origin: 'workspace'` issue names the target tree: a project the root configuration declares\n * as a path string, into which the stage can install no overlay, and a specification path that\n * crosses a symbolic link, whose existing components this host cannot inspect, or whose directory\n * the target tree blocks probe from creating. An `origin: 'instrument'` issue names this package's\n * own machinery: a specification it could not write after its directory exists and the host did not\n * refuse the caller's own name, or one it could not run, evict, or delete, in each case for a\n * reason the target tree does not own, and a run that reported no test. An unmapped caller test and\n * a test whose named project is absent are claimant failures with `code: 'missing'`, and a declared\n * test path the host refuses to create is a claimant failure with `code: 'refused'`. Each is thrown\n * rather than reported, because a test that never ran is no evidence about the candidate.\n *\n * Physical containment covers the claim inputs, the target tree as the walk inspected it, and the\n * final component at the moment this stage writes or unlinks it: a specification is created with the\n * `wx` flag, which fails rather than following a symbolic link that appeared after the walk, and an\n * unlink names the final component itself rather than what it points at. A directory component\n * swapped for a symbolic link between the walk and the write stays open, because Node exposes no\n * descriptor-relative call to pin the walk and the write to one set of descriptors.\n *\n * @example\n * ```ts\n * const stage = new RuntimeStage('/srv/checkout')\n * const check = await stage.inspect(subject)\n * await stage.destroy()\n * ```\n */\nexport class RuntimeStage implements StageInterface {\n\treadonly #workspace: string\n\t#vitest: Promise<Vitest> | undefined\n\t#overlay: OverlayInterface = new Overlay()\n\treadonly #loads = new Set<string>()\n\treadonly #reads = new Set<string>()\n\treadonly #modules = new Map<string, string>()\n\treadonly #revisions = new Set<string>()\n\t#specifications = 0\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before the\n\t// teardown it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\n\t/**\n\t * Starts warming the target workspace's Vitest service.\n\t *\n\t * @remarks Loading starts during this call. A loader refusal rejects the owned warm operation\n\t * rather than construction, so `inspect` reports it and `destroy` remains available.\n\t *\n\t * @param workspace - The target workspace root. Default: the current working directory\n\t */\n\tconstructor(workspace: string = process.cwd()) {\n\t\tthis.#workspace = workspace\n\t\tthis.#store(this.#warm())\n\t}\n\n\tget stage(): Stage {\n\t\treturn 'runtime'\n\t}\n\n\tget progress(): number {\n\t\treturn this.#progress\n\t}\n\n\t/**\n\t * Inspects one case.\n\t *\n\t * @param subject - The candidate drafts and test to inspect\n\t * @returns One outcome for this stage\n\t * @throws When the workspace's own tool cannot start or has already been destroyed\n\t */\n\tinspect(subject: Case): Promise<Check> {\n\t\treturn guardStage(this.stage, this.#inspect(subject))\n\t}\n\n\t/**\n\t * Tears down the resident tool or the mirror and releases its resources.\n\t *\n\t * @remarks\n\t * A stage abandons every inspection it holds rather than waiting behind one, so teardown never\n\t * waits for an inspection to return. An abandoned inspection rejects, either at the stage's own\n\t * guard or as the owned tool closes. Teardown is bounded whatever the stage's own tool does: a\n\t * tool that answers neither its warming exchange nor its ending is signalled and released at the\n\t * stage's own deadline. A coordinator replaces a stage whose worker no longer returns because\n\t * teardown neither waits for an inspection nor waits past that deadline.\n\t *\n\t * @returns A promise that settles after the resident tool or the mirror releases its resources\n\t */\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = guardStage(this.stage, this.#destroy())\n\t\treturn this.#closing\n\t}\n\n\tasync #inspect(subject: Case): Promise<Check> {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('runtime stage')\n\t\tconst started = performance.now()\n\t\t// Vitest reports a failed run by setting `process.exitCode` on this host, and a stage that\n\t\t// runs a claim's negative control fails a run deliberately. Restore whatever the host had,\n\t\t// rather than assigning zero over a code the host set for itself.\n\t\tconst exitCode = process.exitCode\n\t\tconst vitest = await this.#runner()\n\t\tif (this.#closing !== undefined) throw createDestroyedError('runtime stage')\n\t\tconst project = this.#project(vitest, subject.test.path)\n\t\tif ('message' in project) {\n\t\t\treturn {\n\t\t\t\tstage: this.stage,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\tissues: [project],\n\t\t\t}\n\t\t}\n\t\tconst overlay = new Overlay()\n\t\tthis.#overlay = overlay\n\t\tthis.#loads.clear()\n\t\tthis.#reads.clear()\n\t\ttry {\n\t\t\tfor (const draft of subject.files) {\n\t\t\t\toverlay.set(resolveWorkspaceFile(this.#workspace, draft.path), draft.text)\n\t\t\t}\n\t\t\tthis.#revalidate(vitest)\n\t\t\tconst specification = this.#specification(subject.test)\n\t\t\tif (!isString(specification)) {\n\t\t\t\treturn {\n\t\t\t\t\tstage: this.stage,\n\t\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\t\tissues: [specification],\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Vitest stores a specification under the exact identifier it is handed, while its deletion\n\t\t\t// handler rewrites the path it is given to forward slashes before looking that key up. So on\n\t\t\t// a host whose separator is a backslash the native spelling is stored and never found again:\n\t\t\t// the eviction below misses, Vitest keeps the module in its file map, and every later run\n\t\t\t// returns it among that run's own results. The module a failed arming left behind then\n\t\t\t// reports as a claimant issue against a clean case and refuses its receipt. Hand Vitest one\n\t\t\t// identifier for the specification, its results, and its eviction. Read the host separator\n\t\t\t// rather than the platform name, for the reason `#invalidate` gives. The file itself is\n\t\t\t// written and deleted through the native path `relative` and `realpathSync` return from this\n\t\t\t// one.\n\t\t\tconst file = sep === '\\\\' ? normalizePath(specification) : specification\n\t\t\tthis.#specifications += 1\n\t\t\tthis.#revisions.add(file)\n\t\t\tlet issues: readonly Issue[] = []\n\t\t\tlet cleanup: readonly Issue[] = []\n\t\t\tconst task = project.createSpecification(file, undefined, 'threads')\n\t\t\tthis.#progress += 1\n\t\t\ttry {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await vitest.runTestSpecifications([task], false)\n\t\t\t\t\tissues = [\n\t\t\t\t\t\t...this.#issues(result, file, subject.test.path),\n\t\t\t\t\t\t...this.#misses(project, file),\n\t\t\t\t\t]\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (isProbeError(error)) throw error\n\t\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t\t`The runtime stage could not run the generated specification (${describeUnknown(error)})`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\t\tcontext: { stage: this.stage, path: subject.test.path },\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tthis.#progress -= 1\n\t\t\t\tprocess.exitCode = exitCode\n\t\t\t\tthis.#revisions.delete(file)\n\t\t\t\tcleanup = await this.#evict(vitest, file)\n\t\t\t\ttry {\n\t\t\t\t\tconst contained = resolveWorkspaceFile(\n\t\t\t\t\t\tthis.#workspace,\n\t\t\t\t\t\trelative(this.#workspace, file),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t)\n\t\t\t\t\tif (existsSync(contained)) unlinkSync(contained)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tcleanup = [\n\t\t\t\t\t\t...cleanup,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\torigin:\n\t\t\t\t\t\t\t\tisProbeError(error) && error.origin === 'workspace' ? 'workspace' : 'instrument',\n\t\t\t\t\t\t\tpath: relativeWorkspaceFile(this.#workspace, file),\n\t\t\t\t\t\t\tmessage: `The runtime stage could not delete the generated specification (${describeUnknown(error)})`,\n\t\t\t\t\t\t},\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstage: this.stage,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\tissues: [...issues, ...cleanup],\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#loads.clear()\n\t\t\tthis.#reads.clear()\n\t\t\toverlay.clear()\n\t\t}\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\ttry {\n\t\t\t// Remove the abandoned specifications first. An inspection the coordinator gave up on keeps\n\t\t\t// its file until the run it started finally settles, and a file left behind is ordinary\n\t\t\t// TypeScript in the target's tree: the workspace's own `check` and `lint:check` read it\n\t\t\t// and report its diagnostics as the consumer's own.\n\t\t\tfor (const file of this.#revisions) {\n\t\t\t\ttry {\n\t\t\t\t\tconst contained = resolveWorkspaceFile(\n\t\t\t\t\t\tthis.#workspace,\n\t\t\t\t\t\trelative(this.#workspace, file),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t)\n\t\t\t\t\tif (existsSync(contained)) unlinkSync(contained)\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t\tthis.#revisions.clear()\n\t\t\t// A stage whose warming failed holds nothing to release, so teardown settles rather than\n\t\t\t// re-reporting a failure already surfaced through `inspect`.\n\t\t\tconst vitest = await this.#vitest?.catch(() => undefined)\n\t\t\tif (vitest !== undefined) {\n\t\t\t\tvoid vitest.cancelCurrentRun('keyboard-input').catch(() => {})\n\t\t\t\tawait vitest.close()\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#modules.clear()\n\t\t\tthis.#loads.clear()\n\t\t\tthis.#reads.clear()\n\t\t\tthis.#overlay.clear()\n\t\t}\n\t}\n\n\tasync #warm(create?: typeof createVitest): Promise<Vitest> {\n\t\tconst factory = create ?? loadWorkspaceVitest(this.#workspace).createVitest\n\t\tthis.#sweep()\n\t\tconst output = new PassThrough()\n\t\toutput.resume()\n\t\t// Vitest installs one `SIGINT` and one `SIGTERM` handler per `createVitest` call, and each\n\t\t// one force exits this process about a millisecond after the signal arrives. Teardown takes\n\t\t// three orders of magnitude longer than that, so a host answering the signal gracefully\n\t\t// loses the race and leaves its generated files in the consumer's tree. Diff the listeners\n\t\t// across the call and remove exactly what appeared: the handler's name is an unexported\n\t\t// Vitest detail, and matching on it would both miss a rename and strip a coincidental name\n\t\t// match this stage does not own. Every warm strips, because every replacement and every\n\t\t// stage the coordinator recycles calls `createVitest` again. Vitest's `exit` handler is left\n\t\t// alone: it runs while the process is already leaving rather than racing a teardown.\n\t\t//\n\t\t// The call is not awaited here, and that is what makes the diff correct rather than merely\n\t\t// tidy. Vitest registers those handlers before its first await, so releasing them as the\n\t\t// call returns leaves no window a signal can arrive in. Releasing them after the promise\n\t\t// settles would leave the whole warm exposed, and would remove every termination listener\n\t\t// the host registered meanwhile — including the server's own, which starts after this\n\t\t// constructor returns.\n\t\tconst signals = captureListeners(process, ['SIGINT', 'SIGTERM'])\n\t\tlet warming: Promise<Vitest>\n\t\ttry {\n\t\t\t// Only standard output frames the Model Context Protocol transport. Preserve worker\n\t\t\t// diagnostics on standard error while draining standard output into a bounded stream.\n\t\t\twarming = factory(\n\t\t\t\t'test',\n\t\t\t\t{\n\t\t\t\t\troot: this.#workspace,\n\t\t\t\t\tconfig: resolveWorkspaceFile(this.#workspace, 'vite.config.ts'),\n\t\t\t\t\twatch: false,\n\t\t\t\t\trun: true,\n\t\t\t\t\tpool: 'threads',\n\t\t\t\t\treporters: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tonInit() {},\n\t\t\t\t\t\t\tonTestRunEnd() {},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tplugins: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tname: 'orkestrel-project-instrumentation',\n\t\t\t\t\t\t\tenforce: 'post',\n\t\t\t\t\t\t\tconfig: this.#configure.bind(this),\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t\t{ stdout: output, stderr: process.stderr },\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthrow this.#configuration(error)\n\t\t} finally {\n\t\t\treleaseListeners(process, signals)\n\t\t}\n\t\ttry {\n\t\t\treturn await warming\n\t\t} catch (error) {\n\t\t\tthrow this.#configuration(error)\n\t\t}\n\t}\n\n\t#configure(config: ViteUserConfig): void {\n\t\tconst test = config.test\n\t\tif (test?.projects === undefined) return\n\t\t// Vite concatenates project arrays returned from config hooks. Replace the hook-owned slot so\n\t\t// each configured project keeps one identity while gaining the runtime adapter.\n\t\ttest.projects = test.projects.map((project) => this.#augment(project))\n\t}\n\n\t#augment(project: TestProjectConfiguration): TestProjectConfiguration {\n\t\tif (isString(project)) return project\n\t\tif (typeof project === 'function') return this.#wrap(project)\n\t\treturn Promise.resolve(project).then(this.#instrument.bind(this))\n\t}\n\n\t#wrap(project: UserProjectConfigFn): UserProjectConfigFn {\n\t\treturn async (environment) => this.#instrument(await project(environment))\n\t}\n\n\t#instrument(config: UserWorkspaceConfig): UserWorkspaceConfig {\n\t\treturn {\n\t\t\t...config,\n\t\t\tplugins: [\n\t\t\t\t...(config.plugins ?? []),\n\t\t\t\t{\n\t\t\t\t\tname: RUNTIME_PLUGIN,\n\t\t\t\t\tenforce: 'pre',\n\t\t\t\t\tresolveId: this.#resolve.bind(this),\n\t\t\t\t\tload: this.#load.bind(this),\n\t\t\t\t},\n\t\t\t],\n\t\t}\n\t}\n\n\t#resolve(id: string, importer: string | undefined): string | undefined {\n\t\tconst separator = id.indexOf('?')\n\t\tconst specifier = separator === -1 ? id : id.slice(0, separator)\n\t\tconst suffix = separator === -1 ? '' : id.slice(separator)\n\t\tif (!specifier.startsWith('.') && !isAbsolute(specifier)) return undefined\n\t\tif (importer === undefined && !isAbsolute(specifier)) return undefined\n\t\tconst imported = isAbsolute(specifier)\n\t\t\t? specifier\n\t\t\t: resolve(dirname(importer ?? this.#workspace), specifier)\n\t\tconst candidates = [imported]\n\t\tconst extension = extname(imported)\n\t\tif (extension === '.js') candidates.push(`${imported.slice(0, -extension.length)}.ts`)\n\t\tif (extension === '') candidates.push(`${imported}.ts`)\n\t\tfor (const candidate of candidates) {\n\t\t\tconst resolved = `${candidate}${suffix}`\n\t\t\tif (this.#overlay.text(candidate) !== undefined) return resolved\n\t\t}\n\t\treturn undefined\n\t}\n\n\t#load(id: string):\n\t\t| string\n\t\t| {\n\t\t\t\treadonly code: string\n\t\t\t\treadonly map: { readonly mappings: string }\n\t\t\t\treadonly moduleType: 'js'\n\t\t }\n\t\t| undefined {\n\t\tthis.#loads.add(normalizePath(id))\n\t\tconst separator = id.indexOf('?')\n\t\tconst path = separator === -1 ? id : id.slice(0, separator)\n\t\tconst text = this.#overlay.text(path)\n\t\tif (text === undefined) return undefined\n\t\tthis.#reads.add(normalizePath(path))\n\t\tif (separator !== -1 && /(?:^|&)raw(?:&|$)/u.test(id.slice(separator + 1))) {\n\t\t\treturn {\n\t\t\t\tcode: `export default ${JSON.stringify(text)}`,\n\t\t\t\tmap: { mappings: '' },\n\t\t\t\tmoduleType: 'js',\n\t\t\t}\n\t\t}\n\t\treturn text\n\t}\n\n\t#specification(test: Draft): string | Issue {\n\t\tlet creating = false\n\t\t// The sibling path the write aimed at, kept where the classification below can read it. That\n\t\t// path is composed inside the attempt because it carries a revision minted there, and the\n\t\t// classification needs the path itself rather than the fault's own text.\n\t\tlet generated: string | undefined\n\t\tconst outcome = attempt(() => {\n\t\t\t// The writing host's own process id leads the revision, so a later host can tell a file\n\t\t\t// whose writer is gone from one a live host still holds. Several hosts share one\n\t\t\t// workspace routinely — this package's own suite is one — and a sweep reading the name\n\t\t\t// alone deletes a neighbour's specification out from under its run. The same revision\n\t\t\t// goes into the file's own marker, so the sweep reads one value from two places.\n\t\t\tconst revision = `${process.pid}-${randomUUID()}`\n\t\t\tconst file = buildRevisionPath(this.#workspace, test.path, revision)\n\t\t\tgenerated = file\n\t\t\tconst target = relative(this.#workspace, file)\n\t\t\tresolveWorkspaceFile(this.#workspace, target, true)\n\t\t\t// The caller declared where its test lives, so creating that directory is part of what the\n\t\t\t// declaration asked for. `tmp` is ignored by version control and the coordinator's boot\n\t\t\t// tidies away the workbench it created, so the path the convention names is absent in a\n\t\t\t// fresh checkout of a target: a stage that refused over the absence alone refused the first\n\t\t\t// claim of every consumer. A directory the host will not create still refuses through the\n\t\t\t// issue a failed write reports.\n\t\t\tcreating = true\n\t\t\tmkdirSync(dirname(file), { recursive: true })\n\t\t\tcreating = false\n\t\t\tresolveWorkspaceFile(this.#workspace, target, true)\n\t\t\t// The marker goes in the file rather than in its name alone, because the name is the\n\t\t\t// caller's path and the text is the caller's test: without it nothing in the tree says\n\t\t\t// this package wrote the file, and the sweep would have to delete on a name.\n\t\t\twriteFileSync(file, formatSpecification(test.text, revision), {\n\t\t\t\tencoding: 'utf8',\n\t\t\t\tflag: 'wx',\n\t\t\t})\n\t\t\treturn file\n\t\t})\n\t\tif (outcome.success) return outcome.value\n\t\tif (isProbeError(outcome.error) && outcome.error.origin === 'claimant') {\n\t\t\tthrow new ProbeError(outcome.error.message, {\n\t\t\t\torigin: outcome.error.origin,\n\t\t\t\tcode: outcome.error.code,\n\t\t\t\tcontext: { ...outcome.error.context, path: test.path },\n\t\t\t\tcause: outcome.error.cause,\n\t\t\t})\n\t\t}\n\t\t// A create the host refused is the caller's name, not this package's machinery and not the\n\t\t// target tree. The directory exists by this point, so an ordinary absent file would have been\n\t\t// created; what remains is a name the host will not accept. `creating` bounds this to the\n\t\t// final write, leaving a directory the tree blocks to the workspace issue below.\n\t\tif (!creating && generated !== undefined && isRefusedName(generated, outcome.error)) {\n\t\t\tthrow new ProbeError(\n\t\t\t\t`The runtime stage cannot write a specification beside a test path the host refuses (${describeUnknown(outcome.error)})`,\n\t\t\t\t{\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { stage: this.stage, path: test.path },\n\t\t\t\t\tcause: outcome.error,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\torigin:\n\t\t\t\t(isProbeError(outcome.error) && outcome.error.origin === 'workspace') || creating\n\t\t\t\t\t? 'workspace'\n\t\t\t\t\t: 'instrument',\n\t\t\tpath: test.path,\n\t\t\tmessage: `The runtime stage could not write the generated specification (${describeUnknown(outcome.error)})`,\n\t\t}\n\t}\n\n\t// Returns the project or the issue that replaces it, never both and never neither. A pair of\n\t// independent optionals would let a caller write the combination carrying neither, and that branch\n\t// reports a clean check for a case whose test never ran.\n\t#project(vitest: Vitest, path: string): TestProject | Issue {\n\t\t// `inferTestProject` reads a workspace-relative path, and a caller declares whatever path it\n\t\t// holds. An absolute one splits into leading segments that match no project, which silently\n\t\t// selected the root project before this resolved.\n\t\tconst name = inferTestProject(relative(this.#workspace, resolve(this.#workspace, path)))\n\t\tif (name === undefined) {\n\t\t\tthrow new ProbeError(\n\t\t\t\t'The runtime stage found no configured Vitest project matching the test path',\n\t\t\t\t{\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'missing',\n\t\t\t\t\tcontext: { stage: this.stage, path },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst project = vitest.projects.find((candidate) => candidate.name === name)\n\t\tif (project === undefined) {\n\t\t\tthrow new ProbeError(`The runtime stage found no configured Vitest project named ${name}`, {\n\t\t\t\torigin: 'claimant',\n\t\t\t\tcode: 'missing',\n\t\t\t\tcontext: { stage: this.stage, path },\n\t\t\t})\n\t\t}\n\t\tif (!project.vite.config.plugins.some((plugin) => plugin.name === RUNTIME_PLUGIN)) {\n\t\t\treturn {\n\t\t\t\torigin: 'workspace',\n\t\t\t\tpath,\n\t\t\t\tmessage: `The runtime stage cannot instrument the string-declared Vitest project ${name} because its configuration carries no runtime overlay plugin`,\n\t\t\t}\n\t\t}\n\t\treturn project\n\t}\n\n\t// Importer reachability limits this reading to the graph the generated specification served. A\n\t// resident runner keeps older module nodes, and membership alone would report an unused candidate\n\t// because an earlier inspection imported the same path.\n\t#misses(project: TestProject, specification: string): readonly Issue[] {\n\t\tconst file = normalizePath(specification)\n\t\tconst issues: Issue[] = []\n\t\tfor (const path of this.#overlay.paths) {\n\t\t\tif (this.#reads.has(path)) continue\n\t\t\tlet served = false\n\t\t\tlet loaded = false\n\t\t\tfor (const environment of Object.values(project.vite.environments)) {\n\t\t\t\tconst modules = environment.moduleGraph.getModulesByFile(path)\n\t\t\t\tif (modules === undefined) continue\n\t\t\t\tfor (const module of modules) {\n\t\t\t\t\tconst pending = [...module.importers]\n\t\t\t\t\tconst seen = new Set(pending)\n\t\t\t\t\tlet reaches = false\n\t\t\t\t\twhile (pending.length > 0) {\n\t\t\t\t\t\tconst importer = pending.pop()\n\t\t\t\t\t\tif (importer === undefined) break\n\t\t\t\t\t\tif (importer.file !== null && normalizePath(importer.file) === file) {\n\t\t\t\t\t\t\treaches = true\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const parent of importer.importers) {\n\t\t\t\t\t\t\tif (seen.has(parent)) continue\n\t\t\t\t\t\t\tseen.add(parent)\n\t\t\t\t\t\t\tpending.push(parent)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!reaches) continue\n\t\t\t\t\tserved = true\n\t\t\t\t\tif (module.id !== null && this.#loads.has(normalizePath(module.id))) loaded = true\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!served) continue\n\t\t\tissues.push({\n\t\t\t\torigin: loaded ? 'instrument' : 'workspace',\n\t\t\t\tpath: relativeWorkspaceFile(this.#workspace, path),\n\t\t\t\tmessage: loaded\n\t\t\t\t\t? 'The runtime overlay did not resolve this module'\n\t\t\t\t\t: 'The workspace configuration served this module before the runtime overlay',\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\tasync #evict(vitest: Vitest, file: string): Promise<readonly Issue[]> {\n\t\ttry {\n\t\t\tconst ids: string[] = []\n\t\t\tfor (const [id, task] of vitest.state.idMap) {\n\t\t\t\tconst path = 'filepath' in task ? task.filepath : task.file.filepath\n\t\t\t\tif (resolve(path) === resolve(file)) ids.push(id)\n\t\t\t}\n\t\t\tfor (const id of ids) vitest.state.idMap.delete(id)\n\t\t\tvitest.state.pathsSet.delete(file)\n\t\t\tvitest.clearSpecificationsCache(file)\n\t\t\tvitest.invalidateFile(file)\n\t\t\tconst graphs = vitest.projects.flatMap((project) =>\n\t\t\t\tObject.values(project.vite.environments).map((environment) => environment.moduleGraph),\n\t\t\t)\n\t\t\tfor (const graph of graphs) {\n\t\t\t\tconst modules = graph.getModulesByFile(file)\n\t\t\t\tgraph.onFileDelete(file)\n\t\t\t\tif (modules === undefined) continue\n\t\t\t\tfor (const module of modules) {\n\t\t\t\t\tfor (const importer of module.importers) {\n\t\t\t\t\t\timporter.importedModules.delete(module)\n\t\t\t\t\t\timporter.acceptedHmrDeps.delete(module)\n\t\t\t\t\t}\n\t\t\t\t\tif (module.id !== null) graph.idToModuleMap.delete(module.id)\n\t\t\t\t\tgraph.urlToModuleMap.delete(module.url)\n\t\t\t\t}\n\t\t\t\tgraph.fileToModulesMap.delete(file)\n\t\t\t}\n\t\t\tvitest.watcher.onFileDelete(file)\n\t\t\tvitest.watcher.invalidates.delete(file)\n\t\t\tvitest.cache.results.removeFromCache(normalizePath(relative(this.#workspace, file)))\n\t\t\tawait vitest.cache.results.writeToCache()\n\t\t\treturn []\n\t\t} catch (error) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\tpath: relativeWorkspaceFile(this.#workspace, file),\n\t\t\t\t\tmessage: `The runtime stage could not evict the generated specification (${describeUnknown(error)})`,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t}\n\n\t// Reads the specification count rather than incrementing it. An inspection that writes no\n\t// specification retains no URL, so counting it would recycle a runner that never grew.\n\t#runner(): Promise<Vitest> {\n\t\t// Vite retains one unresolved URL for each fresh specification path. The\n\t\t// `PROBE_SPECIFICATIONS` lifetime bounds that internal map without giving up the resident\n\t\t// runner on each call.\n\t\tconst current = this.#vitest\n\t\tif (current !== undefined && this.#specifications < PROBE_SPECIFICATIONS) return current\n\t\tif (current !== undefined) return this.#store(this.#replace(current))\n\t\tconst runner = loadWorkspaceVitest(this.#workspace)\n\t\treturn this.#store(\n\t\t\tthis.#specifications < PROBE_SPECIFICATIONS\n\t\t\t\t? this.#warm(runner.createVitest)\n\t\t\t\t: this.#replace(undefined, runner.createVitest),\n\t\t)\n\t}\n\n\tasync #replace(\n\t\tcurrent: Promise<Vitest> | undefined,\n\t\tcreate?: typeof createVitest,\n\t): Promise<Vitest> {\n\t\tif (current !== undefined) {\n\t\t\tconst vitest = await current\n\t\t\tawait vitest.close()\n\t\t}\n\t\tif (this.#closing !== undefined) throw createDestroyedError('runtime stage')\n\t\tconst runner = create ?? loadWorkspaceVitest(this.#workspace).createVitest\n\t\tconst replacement = await this.#warm(runner)\n\t\tthis.#specifications = 0\n\t\treturn replacement\n\t}\n\n\t#store(vitest: Promise<Vitest>): Promise<Vitest> {\n\t\tthis.#vitest = vitest\n\t\tvoid vitest.catch(() => {\n\t\t\tif (this.#vitest === vitest) this.#vitest = undefined\n\t\t})\n\t\treturn vitest\n\t}\n\n\t#configuration(error: unknown): ProbeError {\n\t\tif (isProbeError(error)) return error\n\t\treturn new ProbeError(\n\t\t\t`The runtime stage could not load vite.config.ts (${describeUnknown(error)})`,\n\t\t\t{\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { stage: this.stage, path: 'vite.config.ts' },\n\t\t\t\tcause: error,\n\t\t\t},\n\t\t)\n\t}\n\n\t#revalidate(vitest: Vitest): void {\n\t\tconst modules = this.#snapshot()\n\t\tfor (const [path, digest] of modules) {\n\t\t\tif (this.#modules.get(path) === digest) continue\n\t\t\tthis.#invalidate(vitest, path)\n\t\t}\n\t\tfor (const path of this.#modules.keys()) {\n\t\t\tif (modules.has(path)) continue\n\t\t\tthis.#invalidate(vitest, path)\n\t\t}\n\t\tthis.#modules.clear()\n\t\tfor (const [path, digest] of modules) this.#modules.set(path, digest)\n\t}\n\n\t// Vite keys its module graph on the forward-slash spelling of a resolved id, and `invalidateFile`\n\t// looks that key up exactly. `collectWorkspaceFiles` builds each path with `join` and the overlay\n\t// holds paths `resolve` produced, so on a host whose separator is a backslash the native spelling\n\t// matches no key, the invalidation is dropped without an error, and the resident runner serves\n\t// the previous module. Read the host separator rather than the platform name, and rewrite only\n\t// where it is a backslash: a backslash is a legal filename character on a host whose separator is\n\t// a forward slash, so rewriting there would turn a key Vite holds into one it does not.\n\t#invalidate(vitest: Vitest, path: string): void {\n\t\tconst id = sep === '\\\\' ? normalizePath(path) : path\n\t\tvitest.invalidateFile(id)\n\t\tvitest.watcher.invalidates.add(id)\n\t}\n\n\t#snapshot(): ReadonlyMap<string, string> {\n\t\tconst modules = new Map<string, string>()\n\t\tfor (const path of collectWorkspaceFiles(this.#workspace)) {\n\t\t\tif (!matchesWorkspaceModule(path)) continue\n\t\t\ttry {\n\t\t\t\tconst digest = createHash('sha256').update(readFileSync(path)).digest('hex')\n\t\t\t\tmodules.set(path, digest)\n\t\t\t} catch {}\n\t\t}\n\t\tfor (const path of this.#overlay.paths) {\n\t\t\tmodules.set(path, `overlay:${this.#overlay.revision}`)\n\t\t}\n\t\treturn modules\n\t}\n\n\t// Removes the files a dead host left behind. Every inspection deletes its own file and teardown\n\t// deletes the ones it abandoned, so a file that outlives both belongs to a host that was killed.\n\t// No Vitest project collects it — the revision marker sits between the stem and the extension,\n\t// so a specification generated from a `.test.ts` path is not itself a `.test.ts` file — but it\n\t// is ordinary TypeScript in the target's tree, so the workspace's own `check` and `lint:check`\n\t// report its diagnostics against the consumer. These conditions together make one file this\n\t// package's to delete: the name carries a revision, the identity leading that revision names a\n\t// process that is gone, and the file is one `#owned` can attribute. A file failing any of them\n\t// stays where it is, whoever wrote it.\n\t#sweep(): void {\n\t\tfor (const path of collectWorkspaceFiles(this.#workspace)) {\n\t\t\tconst matches = [\n\t\t\t\t...basename(path).matchAll(\n\t\t\t\t\t/\\.probe-((\\d+)-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?=\\.|$)/gu,\n\t\t\t\t),\n\t\t\t]\n\t\t\tconst match = matches.at(-1)\n\t\t\tconst revision = match?.[1]\n\t\t\tconst owner = match?.[2]\n\t\t\tif (revision === undefined || owner === undefined) continue\n\t\t\tif (matchesLiveProcess(Number.parseInt(owner, 10))) continue\n\t\t\tif (!this.#owned(path, revision)) continue\n\t\t\ttry {\n\t\t\t\tunlinkSync(resolveWorkspaceFile(this.#workspace, relative(this.#workspace, path), true))\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Whether this package wrote one file. A name proves nothing on its own: a consumer's own file\n\t// can carry the same shape, and deleting it is data loss in their tree. A generated\n\t// specification carries the caller's own test text, so the marker this stage appends to it is\n\t// what attributes it, and the revision in the name must be the revision in the marker. The\n\t// coordinator's boot writes the same terminal marker on its dependencies, so every deletion uses\n\t// the same content-backed ownership rule.\n\t#owned(path: string, revision: string): boolean {\n\t\tconst outcome = attempt(() => readFileSync(path, 'utf8'))\n\t\treturn outcome.success && matchesSpecification(outcome.value, revision)\n\t}\n\n\t#issues(result: TestRunResult, file: string, original: string): readonly Issue[] {\n\t\tconst specification = this.#real(file)\n\t\tconst issues: Issue[] = []\n\t\tfor (const module of result.testModules) {\n\t\t\tconst before = issues.length\n\t\t\tfor (const error of module.errors()) {\n\t\t\t\tissues.push(this.#issue(error, specification, original))\n\t\t\t}\n\t\t\tfor (const test of module.children.allTests('failed')) {\n\t\t\t\tconst errors = test.result().errors ?? []\n\t\t\t\tfor (const error of errors) issues.push(this.#issue(error, specification, original))\n\t\t\t}\n\t\t\tconst state: string = module.state()\n\t\t\tif (state === 'passed') {\n\t\t\t\tif (Array.from(module.children.allTests()).length === 0) {\n\t\t\t\t\tissues.push({\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tpath: original,\n\t\t\t\t\t\tmessage: 'Vitest ran no tests in the module',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tfor (const test of module.children.allTests('skipped')) {\n\t\t\t\t\tissues.push({\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tpath: original,\n\t\t\t\t\t\tmessage: `Vitest did not run the test (${test.fullName})`,\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (state === 'skipped') {\n\t\t\t\tissues.push({\n\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\tpath: original,\n\t\t\t\t\tmessage: 'Vitest ran no tests in the module',\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (state === 'failed') {\n\t\t\t\tif (issues.length === before) {\n\t\t\t\t\tissues.push({\n\t\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\t\tpath: original,\n\t\t\t\t\t\tmessage: 'Vitest reported a failed test module',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (state === 'pending' || state === 'queued') {\n\t\t\t\tissues.push({\n\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\tpath: original,\n\t\t\t\t\tmessage: `Vitest did not finish the test module (${state})`,\n\t\t\t\t})\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tissues.push({\n\t\t\t\torigin: 'instrument',\n\t\t\t\tpath: original,\n\t\t\t\tmessage: `Vitest reported an unrecognized test module state (${state})`,\n\t\t\t})\n\t\t}\n\t\tfor (const error of result.unhandledErrors) {\n\t\t\tissues.push(this.#issue(error, specification, original))\n\t\t}\n\t\tif (result.testModules.length === 0 && issues.length === 0) {\n\t\t\tissues.push({\n\t\t\t\torigin: 'instrument',\n\t\t\t\tpath: original,\n\t\t\t\tmessage: 'Vitest returned no test module',\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\t// Resolves one path through its real form, and leaves a path it cannot resolve as it stands.\n\t// `resolve` does not follow a symbolic link, so a workspace handed to this stage as a link\n\t// produces a specification path no reported frame ever equals, and the mapping that follows reports\n\t// the generated `probe-<revision>` file a caller cannot open instead of the test it declared.\n\t#real(path: string): string {\n\t\tconst outcome = attempt(() => realpathSync(path))\n\t\treturn outcome.success ? outcome.value : path\n\t}\n\n\t// Every error reaching here came out of a run Vitest completed over the candidate's own test,\n\t// so each one is that code failing rather than this stage faulting. `specification` arrives\n\t// already resolved through its real path, and every reported frame is resolved the same way, so\n\t// the two sides compare on one spelling. The message is rendered the way the issue's own `path`\n\t// is: a test that reads its own module reports the generated sibling this stage ran, and a\n\t// caller handed that name finds no file, because the sibling is deleted as the inspection ends.\n\t// The rename reads the exact name this stage generated rather than a name shaped like one, and\n\t// it reads the name alone: the sibling is written into the declared test's own directory, so\n\t// every spelling a tool can write — relative, absolute, or a `file:` URL — differs only in the\n\t// leading directories the workspace rewrite has already removed. That name carries the revision\n\t// minted for this run, so an occurrence of it names this file and no other.\n\t#issue(error: unknown, specification: string, original: string): Issue {\n\t\tconst message = relativeWorkspaceMessage(this.#workspace, describeUnknown(error)).replaceAll(\n\t\t\tbasename(specification),\n\t\t\tbasename(original),\n\t\t)\n\t\tif (!isObject(error) || !('stacks' in error)) {\n\t\t\treturn { origin: 'claimant', path: original, message }\n\t\t}\n\t\tconst stacks = error.stacks\n\t\tif (!isArray(stacks)) return { origin: 'claimant', path: original, message }\n\t\tfor (const stack of stacks) {\n\t\t\tif (!isObject(stack)) continue\n\t\t\tif (!('file' in stack) || !isString(stack.file)) continue\n\t\t\tconst declared = stack.file.startsWith('file:')\n\t\t\t\t? fileURLToPath(stack.file)\n\t\t\t\t: isAbsolute(stack.file)\n\t\t\t\t\t? stack.file\n\t\t\t\t\t: resolve(this.#workspace, stack.file)\n\t\t\tconst reported = this.#real(declared)\n\t\t\tconst path =\n\t\t\t\treported === specification\n\t\t\t\t\t? original\n\t\t\t\t\t: relativeWorkspaceFile(this.#real(this.#workspace), reported)\n\t\t\tif (!('line' in stack) || !isNumber(stack.line)) {\n\t\t\t\treturn { origin: 'claimant', path, message }\n\t\t\t}\n\t\t\t// A reported frame numbers its line and its column from one, so both are lowered into the\n\t\t\t// zero-based coordinates the issue stores. A frame names a point rather than a span, so\n\t\t\t// the end resolves to the start and the stored range is zero-width there. A frame\n\t\t\t// carrying no numeric column names the line alone, which starts at its first character.\n\t\t\tconst character = 'column' in stack && isNumber(stack.column) ? stack.column - 1 : 0\n\t\t\tconst position = { line: stack.line - 1, character }\n\t\t\treturn { origin: 'claimant', path, message, range: { start: position, end: position } }\n\t\t}\n\t\treturn { origin: 'claimant', path: original, message }\n\t}\n}\n","import type { Case, Check, Draft, Issue, Project, Stage } from '@src/core'\nimport type { Diagnostic, Execution, ProjectConfig, TypeStageInterface } from '../types.js'\nimport type { ChildProcess } from 'node:child_process'\nimport type { Dirent } from 'node:fs'\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trmSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { spawn, spawnSync } from 'node:child_process'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { basename, dirname, extname, join, resolve } from 'node:path'\nimport { attempt } from '@orkestrel/contract'\nimport {\n\tProbeError,\n\tTYPE_MIRROR,\n\tcreateDestroyedError,\n\tformatSpecification,\n\tmatchesSpecification,\n} from '@src/core'\nimport {\n\tcollectWorkspaceFiles,\n\tcomputeDigest,\n\tescapesRoot,\n\tfilterUniqueIssues,\n\tguardStage,\n\tinferTypeProject,\n\tmatchesLiveProcess,\n\tnormalizePath,\n\trelativeWorkspaceFile,\n\trelativeWorkspaceMessage,\n\tresolveWorkspaceBinary,\n\tresolveWorkspaceFile,\n\tscanDiagnostics,\n} from '../helpers.js'\nimport { parseProjectConfig, parseRevisionOwner } from '../parsers.js'\n\n/**\n * Inspects TypeScript source by running the target workspace's own compiler over a mirror of it.\n *\n * @remarks\n * The compiler is a process this stage spawns rather than a module it loads, so nothing here holds\n * a resident program and the host's event loop is free for the whole check. Construction sweeps a\n * mirror an earlier host left behind, copies the workspace into a fresh one under\n * {@link TYPE_MIRROR}, and builds each declared project's incremental state there, so the first\n * inspection is warm.\n *\n * Every inspection refreshes the mirror by content digest, writes each candidate draft and the test\n * at its mirrored declared path, and runs `tsc --noEmit --pretty false` once per distinct selected\n * project. A draft therefore shadows the file it replaces: a consumer of that path is checked\n * against the draft's text, and a draft importing a sibling draft resolves to the sibling draft.\n * Nothing is written outside `tmp/`, and the workspace's own copy of a drafted file never moves.\n *\n * Each run reads a scratch project this stage writes beside the mirrored project it extends, so\n * every relative path the project declares — its own `rootDir`, `include`, `paths`, and the\n * projects it extends — resolves inside the mirror without being rewritten. The scratch adds the\n * drafts as `files`, which the project's own `exclude` does not reach, and its incremental state\n * lives in the mirror so reuse survives the refresh.\n *\n * The diagnostics decide the outcome, never the exit code, which the supported compiler majors\n * disagree on. A diagnostic naming a project file, and one naming no file at all, is the target\n * tree's own configuration fault and raises rather than reporting, unless the `.json` file is one\n * the claim itself drafted; every other diagnostic is a claimant issue at the point the compiler\n * reported, which is the extent the plain-text output carries.\n *\n * @example\n * ```ts\n * const stage = new TypeStage('/srv/checkout')\n * const check = await stage.inspect(subject, 'configs/src/tsconfig.core.json')\n * await stage.destroy()\n * ```\n */\nexport class TypeStage implements TypeStageInterface {\n\treadonly #workspace: string\n\treadonly #compiler: string\n\treadonly #revision = `${process.pid}-${randomUUID()}`\n\treadonly #mirror: string\n\treadonly #configs = new Map<string, ProjectConfig>()\n\treadonly #mirrored = new Map<string, string>()\n\treadonly #drafts = new Set<string>()\n\treadonly #children = new Set<ChildProcess>()\n\treadonly #warming: Promise<void>\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before the\n\t// teardown it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\n\t/**\n\t * Resolves the target workspace's compiler and starts warming its mirror.\n\t *\n\t * @param workspace - The target workspace root. Default: the current working directory\n\t */\n\tconstructor(workspace: string = process.cwd()) {\n\t\tthis.#workspace = workspace\n\t\tthis.#compiler = resolveWorkspaceBinary(workspace, 'typescript', 'tsc')\n\t\tthis.#mirror = resolveWorkspaceFile(workspace, `${TYPE_MIRROR}/${this.#revision}`)\n\t\tthis.#warming = this.#warm()\n\t\t// Observe the stored promise here. Nothing reads it until an inspection or a teardown\n\t\t// arrives, and an unobserved rejection ends the host process. The stored promise keeps\n\t\t// rejecting, so an inspection still reports the warming failure.\n\t\tvoid this.#warming.catch(() => {})\n\t}\n\n\tget stage(): Stage {\n\t\treturn 'type'\n\t}\n\n\tget progress(): number {\n\t\treturn this.#progress\n\t}\n\n\t/**\n\t * Inspects one case, against a caller-named project where the caller names one.\n\t *\n\t * @remarks\n\t * The `project` parameter is this stage's own, not the stage contract's: the lint and runtime\n\t * stages read no project, so `StageInterface` declares one parameter and every caller that\n\t * needs this one holds a `TypeStage`.\n\t *\n\t * @param subject - The candidate drafts and test to inspect\n\t * @param project - The workspace-relative TypeScript project the candidate drafts are checked\n\t * against. Default: the scoped project each candidate path infers\n\t * @returns One outcome for this stage\n\t * @throws When the workspace refuses the mirror, when a project the run reads is malformed, or\n\t * when the stage has already been destroyed\n\t */\n\tinspect(subject: Case, project?: string): Promise<Check> {\n\t\treturn guardStage(this.stage, this.#inspect(subject, project))\n\t}\n\n\t/**\n\t * Resolves one project to the path and digest this stage applies for it.\n\t *\n\t * @remarks\n\t * Reads the configuration the compiler itself prints for the project as the mirror holds it,\n\t * refreshed from the workspace first on a cache miss, so the digest names the configuration the\n\t * check applies. The reading is cached per project for the life of the stage, so a draft written\n\t * afterward cannot move it.\n\t *\n\t * @param project - The workspace-relative TypeScript project to resolve\n\t * @returns The resolved workspace-relative path and the digest of its compiler options\n\t * @throws When the project escapes the workspace, when the compiler refuses it, or when the\n\t * stage has already been destroyed\n\t */\n\tresolve(project: string): Promise<Project> {\n\t\treturn guardStage(this.stage, this.#resolve(project))\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = guardStage(this.stage, this.#destroy())\n\t\treturn this.#closing\n\t}\n\n\tasync #inspect(subject: Case, project?: string): Promise<Check> {\n\t\tthis.#refuseDestroyed()\n\t\tconst started = performance.now()\n\t\tawait this.#warming\n\t\tthis.#refuseDestroyed()\n\t\t// Every declared path is resolved before anything is written, so a draft that escapes the\n\t\t// workspace refuses the whole inspection rather than leaving earlier drafts in the mirror.\n\t\tconst test = resolveWorkspaceFile(this.#workspace, subject.test.path)\n\t\tconst resolved = subject.files.map((draft) => ({\n\t\t\tdraft,\n\t\t\tpath: resolveWorkspaceFile(this.#workspace, draft.path),\n\t\t}))\n\t\t// Keyed by the resolved project rather than by the caller's spelling of it, so `tsconfig.json`\n\t\t// and `./tsconfig.json` name one run instead of two.\n\t\tconst groups = new Map<string, Draft[]>([[this.#contain('tsconfig.json'), [subject.test]]])\n\t\tfor (const candidate of resolved) {\n\t\t\tconst selected = this.#contain(\n\t\t\t\tproject ?? inferTypeProject(relativeWorkspaceFile(this.#workspace, candidate.path)),\n\t\t\t)\n\t\t\tconst drafts = groups.get(selected)\n\t\t\tif (drafts === undefined) groups.set(selected, [candidate.draft])\n\t\t\telse drafts.push(candidate.draft)\n\t\t}\n\t\tthis.#progress += 1\n\t\t// Every selected project's configuration is read before any draft lands in the mirror, so a\n\t\t// claim drafting its own project file cannot move the digest that project resolves to.\n\t\tfor (const selected of groups.keys()) await this.#configure(selected)\n\t\tthis.#refuseDestroyed()\n\t\ttry {\n\t\t\tthis.#refresh()\n\t\t\tthis.#drafts.add(this.#place(subject.test.text, test))\n\t\t\tfor (const candidate of resolved) {\n\t\t\t\tthis.#drafts.add(this.#place(candidate.draft.text, candidate.path))\n\t\t\t}\n\t\t\tconst issues: Issue[] = []\n\t\t\tfor (const [selected, drafts] of groups) {\n\t\t\t\tthis.#refuseDestroyed()\n\t\t\t\tissues.push(...(await this.#check(selected, drafts)))\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tstage: this.stage,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t\t// One draft is checked by the project its claim names and again by the root project the\n\t\t\t\t// test is checked against, so the same diagnostic arrives twice for one candidate.\n\t\t\t\tissues: filterUniqueIssues(issues),\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.#release()\n\t\t}\n\t}\n\n\tasync #resolve(project: string): Promise<Project> {\n\t\tthis.#refuseDestroyed()\n\t\tconst contained = this.#contain(project)\n\t\tthis.#progress += 1\n\t\tconst config = await this.#configure(contained)\n\t\treturn { path: contained, digest: computeDigest(this.#workspace, config.compilerOptions) }\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\t// Abandon every inspection in flight rather than waiting for one: the coordinator tears a\n\t\t// stage down exactly when it cannot wait. Terminating the compiler is what makes that\n\t\t// immediate, and warming is awaited afterwards because its own run is one of the terminated\n\t\t// children and the mirror it built is the resource this releases.\n\t\tconst children = [...this.#children]\n\t\tthis.#children.clear()\n\t\tfor (const child of children) this.#terminate(child)\n\t\tawait this.#warming.catch(() => undefined)\n\t\ttry {\n\t\t\trmSync(this.#mirror, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 })\n\t\t} catch {}\n\t\tthis.#configs.clear()\n\t\tthis.#mirrored.clear()\n\t\tthis.#drafts.clear()\n\t}\n\n\t// Builds each declared project's incremental state so the first inspection is warm. The runs are\n\t// independent — each reads the mirror and writes its own state file — so they run together and\n\t// the warm costs the slowest project rather than the sum of them all.\n\tasync #warm(): Promise<void> {\n\t\tthis.#sweep()\n\t\tthis.#createMirror()\n\t\tthis.#refresh()\n\t\tthis.#refuseDestroyed()\n\t\tawait Promise.all(this.#projects().map((project) => this.#check(project, [])))\n\t}\n\n\t#projects(): readonly string[] {\n\t\tconst projects = ['tsconfig.json']\n\t\tfor (const axis of ['src', 'app']) {\n\t\t\tconst directory = resolveWorkspaceFile(this.#workspace, `configs/${axis}`)\n\t\t\tlet names: readonly string[]\n\t\t\ttry {\n\t\t\t\tnames = readdirSync(directory)\n\t\t\t} catch {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfor (const name of names.filter((entry) => /^tsconfig\\.[^.]+\\.json$/.test(entry)).sort()) {\n\t\t\t\tprojects.push(`configs/${axis}/${name}`)\n\t\t\t}\n\t\t}\n\t\treturn projects\n\t}\n\n\t// Refuses an inspection this stage was torn down during. The compiler runs in a child process,\n\t// so the host's loop is free while it works and a caller's deadline fires against this stage on\n\t// its own: nothing here yields for that. The refusal is what stops an abandoned inspection\n\t// running a compiler over a mirror this teardown is deleting.\n\t#refuseDestroyed(): void {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('type stage')\n\t}\n\n\t// Creates this stage's own mirror directory and the marker that attributes it. The marker is the\n\t// same one the runtime stage writes on the files it generates, so a sweep never deletes a\n\t// directory by its name alone.\n\t#createMirror(): void {\n\t\tconst marker = resolveWorkspaceFile(\n\t\t\tthis.#workspace,\n\t\t\t`${TYPE_MIRROR}/${this.#revision}/.probe/mirror.txt`,\n\t\t\ttrue,\n\t\t)\n\t\tmkdirSync(dirname(marker), { recursive: true })\n\t\twriteFileSync(marker, formatSpecification('', this.#revision), {\n\t\t\tencoding: 'utf8',\n\t\t\tflag: 'wx',\n\t\t})\n\t}\n\n\t// Removes the mirrors a dead host left behind. Every stage deletes its own at teardown, so one\n\t// that outlives its host belongs to a process that was killed. Three conditions together make a\n\t// directory this package's to delete: the name is a revision identity, the process it names is\n\t// gone, and the marker inside it names that same revision. A directory failing any of them stays\n\t// where it is, whoever wrote it.\n\t#sweep(): void {\n\t\tconst root = resolveWorkspaceFile(this.#workspace, TYPE_MIRROR)\n\t\tlet entries: readonly Dirent[] = []\n\t\ttry {\n\t\t\tentries = readdirSync(root, { withFileTypes: true })\n\t\t} catch {\n\t\t\treturn\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (!entry.isDirectory()) continue\n\t\t\tconst owner = parseRevisionOwner(entry.name)\n\t\t\tif (owner === undefined || matchesLiveProcess(owner)) continue\n\t\t\tconst marker = attempt(() =>\n\t\t\t\treadFileSync(join(root, entry.name, '.probe', 'mirror.txt'), 'utf8'),\n\t\t\t)\n\t\t\tif (!marker.success || !matchesSpecification(marker.value, entry.name)) continue\n\t\t\ttry {\n\t\t\t\trmSync(join(root, entry.name), {\n\t\t\t\t\trecursive: true,\n\t\t\t\t\tforce: true,\n\t\t\t\t\tmaxRetries: 5,\n\t\t\t\t\tretryDelay: 20,\n\t\t\t\t})\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t// Brings the mirror level with the workspace by content digest, so a file edited since the last\n\t// inspection is checked as it stands on disk and an untouched file is not copied again. A file\n\t// the workspace no longer holds is removed from the mirror, because a stale copy there would\n\t// shadow the deletion.\n\t#refresh(): void {\n\t\tconst present = new Set<string>()\n\t\tfor (const path of collectWorkspaceFiles(this.#workspace)) {\n\t\t\tconst contained = relativeWorkspaceFile(this.#workspace, path)\n\t\t\tpresent.add(contained)\n\t\t\tconst reading = attempt(() => readFileSync(path))\n\t\t\tif (!reading.success) continue\n\t\t\tconst digest = createHash('sha256').update(reading.value).digest('hex')\n\t\t\tif (this.#mirrored.get(contained) === digest) continue\n\t\t\tthis.#place(reading.value, path)\n\t\t\tthis.#mirrored.set(contained, digest)\n\t\t}\n\t\tfor (const contained of [...this.#mirrored.keys()]) {\n\t\t\tif (present.has(contained)) continue\n\t\t\tthis.#remove(contained)\n\t\t\tthis.#mirrored.delete(contained)\n\t\t}\n\t}\n\n\t// Releases the candidate text one inspection wrote. The copy is removed rather than restored, so\n\t// the next refresh reads the workspace's own file again and a draft that named no workspace file\n\t// leaves nothing behind.\n\t#release(): void {\n\t\tfor (const contained of this.#drafts) {\n\t\t\tthis.#remove(contained)\n\t\t\tthis.#mirrored.delete(contained)\n\t\t}\n\t\tthis.#drafts.clear()\n\t}\n\n\t// Puts one file's contents at its mirrored path and reports the workspace-relative path it took,\n\t// which is the key every record this stage keeps is held under.\n\t#place(text: string | Uint8Array, path: string): string {\n\t\tconst contained = relativeWorkspaceFile(this.#workspace, path)\n\t\tconst target = this.#mirrorPath(contained)\n\t\tconst written = attempt(() => {\n\t\t\tmkdirSync(dirname(target), { recursive: true })\n\t\t\twriteFileSync(target, text)\n\t\t})\n\t\tif (written.success) return contained\n\t\tthis.#displace(target)\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\twriteFileSync(target, text)\n\t\treturn contained\n\t}\n\n\t// Removes whatever in the mirror stands where one path must go. A workspace holding a file where\n\t// a draft declares a directory, and a claim declaring a file where an earlier draft made a\n\t// directory, both reach here: the mirror is this stage's own tree, so the path the write names\n\t// wins and the next refresh restores whatever the workspace still holds.\n\t#displace(target: string): void {\n\t\tconst ancestors: string[] = []\n\t\tlet directory = dirname(target)\n\t\twhile (directory !== this.#mirror && directory !== dirname(directory)) {\n\t\t\tancestors.unshift(directory)\n\t\t\tdirectory = dirname(directory)\n\t\t}\n\t\tfor (const ancestor of [...ancestors, target]) {\n\t\t\tconst reading = attempt(() => lstatSync(ancestor))\n\t\t\tif (!reading.success) continue\n\t\t\tif (ancestor !== target && reading.value.isDirectory()) continue\n\t\t\tif (ancestor === target && !reading.value.isDirectory()) continue\n\t\t\trmSync(ancestor, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 })\n\t\t\tthis.#mirrored.delete(relativeWorkspaceFile(this.#mirror, ancestor))\n\t\t}\n\t}\n\n\t// Spells one workspace-relative path inside this stage's own mirror.\n\t#mirrorPath(contained: string): string {\n\t\treturn join(this.#mirror, contained)\n\t}\n\n\t// Spells one project the way this stage keys it: resolved against the workspace, then reported\n\t// relative to it, so every spelling of one project reaches one run and one cached configuration.\n\t#contain(project: string): string {\n\t\treturn relativeWorkspaceFile(this.#workspace, resolveWorkspaceFile(this.#workspace, project))\n\t}\n\n\t#remove(contained: string): void {\n\t\ttry {\n\t\t\trmSync(this.#mirrorPath(contained), { force: true, maxRetries: 5, retryDelay: 20 })\n\t\t} catch {}\n\t}\n\n\t// Reads the configuration the compiler prints for one project against the mirror, refreshing the\n\t// mirror first on a cache miss so the digest names the configuration the mirror holds at that\n\t// moment. The reading is cached per project for the life of the stage, so a draft a later\n\t// inspection writes cannot move it.\n\tasync #configure(project: string): Promise<ProjectConfig> {\n\t\tconst contained = this.#contain(project)\n\t\tconst existing = this.#configs.get(contained)\n\t\tif (existing !== undefined) return existing\n\t\tthis.#refresh()\n\t\tconst execution = await this.#spawn(['--showConfig', '-p', contained], this.#mirror)\n\t\tthis.#refuseDestroyed()\n\t\tconst config = parseProjectConfig(execution.stdout)\n\t\tif (config === undefined) throw this.#fault(execution, contained)\n\t\tthis.#configs.set(contained, config)\n\t\treturn config\n\t}\n\n\t// Runs one project's compiler over the mirror and reports what it said about the drafts assigned\n\t// to that project. A run carrying no drafts is the warming run, which builds the incremental\n\t// state the inspections reuse. The diagnostics decide the outcome: a run that printed one is read\n\t// from it whatever stderr carries, and a run that printed none and exited zero is clean whatever\n\t// stderr carries. Only a run that printed no diagnostic and did not exit zero raises, because\n\t// that run reported nothing this stage can act on.\n\tasync #check(project: string, drafts: readonly Draft[]): Promise<readonly Issue[]> {\n\t\tconst config = await this.#configure(project)\n\t\tconst scratch = this.#scratch(this.#contain(project), config, drafts)\n\t\tconst execution = await this.#spawn(\n\t\t\t['--noEmit', '--pretty', 'false', '-p', `./${scratch}`],\n\t\t\tthis.#mirror,\n\t\t)\n\t\tthis.#refuseDestroyed()\n\t\tconst diagnostics = scanDiagnostics(execution.stdout)\n\t\tif (diagnostics.length === 0 && execution.status !== 0) {\n\t\t\tconst stderr = execution.stderr.trim()\n\t\t\tconst message =\n\t\t\t\tstderr !== ''\n\t\t\t\t\t? stderr\n\t\t\t\t\t: execution.status === undefined\n\t\t\t\t\t\t? 'The compiler reported no diagnostic and was ended by a signal'\n\t\t\t\t\t\t: `The compiler reported no diagnostic and exited ${execution.status}`\n\t\t\tthrow new ProbeError(this.#translate(message), {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t})\n\t\t}\n\t\treturn this.#issues(diagnostics, project)\n\t}\n\n\t// Writes the scratch project one run reads, beside the mirrored project it extends. Sitting in\n\t// that directory is what lets every relative path the extended chain declares resolve inside the\n\t// mirror unchanged, the project's own printed selection included.\n\t#scratch(project: string, config: ProjectConfig, drafts: readonly Draft[]): string {\n\t\tconst directory = dirname(project)\n\t\tconst stem = `${basename(project, extname(project))}.probe.json`\n\t\tconst contained = directory === '.' ? stem : `${directory}/${stem}`\n\t\tconst target = this.#mirrorPath(contained)\n\t\tconst buildinfo = join(this.#mirror, '.probe', `${project.replaceAll('/', '-')}.tsbuildinfo`)\n\t\t// The project's own selection is carried across rather than left to the compiler's default,\n\t\t// because naming `files` at all suppresses that default. A selection entry the mirror does not\n\t\t// hold is dropped, so a file the workspace deleted after this reading refuses nothing.\n\t\tconst selected = (config.files ?? []).filter((entry) =>\n\t\t\texistsSync(resolve(dirname(target), entry)),\n\t\t)\n\t\t// Each entry stays relative to the scratch project's own directory, so the mirror carries no\n\t\t// host layout and its incremental state keeps working from wherever the mirror sits.\n\t\tconst files = [\n\t\t\t...selected,\n\t\t\t...drafts.map((draft) =>\n\t\t\t\trelativeWorkspaceFile(dirname(target), this.#mirrorPath(this.#contain(draft.path))),\n\t\t\t),\n\t\t]\n\t\tconst body = {\n\t\t\textends: `./${basename(project)}`,\n\t\t\tcompilerOptions: {\n\t\t\t\tnoEmit: true,\n\t\t\t\tdeclaration: false,\n\t\t\t\temitDeclarationOnly: false,\n\t\t\t\tcomposite: false,\n\t\t\t\tincremental: true,\n\t\t\t\ttsBuildInfoFile: relativeWorkspaceFile(dirname(target), buildinfo),\n\t\t\t},\n\t\t\t...(files.length === 0 ? {} : { files }),\n\t\t}\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\twriteFileSync(target, `${JSON.stringify(body, undefined, '\\t')}\\n`, 'utf8')\n\t\treturn contained\n\t}\n\n\t#issues(diagnostics: readonly Diagnostic[], project: string): readonly Issue[] {\n\t\tconst issues: Issue[] = []\n\t\tfor (const diagnostic of diagnostics) {\n\t\t\tconst message = this.#translate(diagnostic.message)\n\t\t\tconst resolved =\n\t\t\t\tdiagnostic.path === undefined ? undefined : resolve(this.#mirror, diagnostic.path)\n\t\t\tconst drafted =\n\t\t\t\tresolved !== undefined &&\n\t\t\t\tthis.#drafts.has(\n\t\t\t\t\tescapesRoot(this.#mirror, resolved)\n\t\t\t\t\t\t? relativeWorkspaceFile(this.#workspace, resolved)\n\t\t\t\t\t\t: relativeWorkspaceFile(this.#mirror, resolved),\n\t\t\t\t)\n\t\t\t// A diagnostic against no file, and one against a `.json` file the claim itself did not\n\t\t\t// draft, names a configuration the target tree declares for itself. So the target holds\n\t\t\t// the only file that can close it, and reporting it as a candidate issue would charge a\n\t\t\t// claimant for a configuration nobody else owns. A `.json` file the claim drafted is the\n\t\t\t// claimant's like any other draft.\n\t\t\tif (resolved === undefined || (!drafted && extname(resolved) === '.json')) {\n\t\t\t\tthrow new ProbeError(message, {\n\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst path = escapesRoot(this.#mirror, resolved)\n\t\t\t\t? escapesRoot(this.#workspace, resolved)\n\t\t\t\t\t? normalizePath(resolved)\n\t\t\t\t\t: relativeWorkspaceFile(this.#workspace, resolved)\n\t\t\t\t: relativeWorkspaceFile(this.#mirror, resolved)\n\t\t\tissues.push({\n\t\t\t\torigin: 'claimant',\n\t\t\t\tpath,\n\t\t\t\tmessage,\n\t\t\t\t...(diagnostic.range === undefined ? {} : { range: diagnostic.range }),\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\t// Renders one message in the terms this package reports a path in. The mirror root is removed\n\t// first and the workspace root second, because the mirror sits inside the workspace and the\n\t// longer prefix is the one a compiler running there names a file by. What is left of a contained\n\t// path is the workspace-relative spelling a reader can open.\n\t#translate(message: string): string {\n\t\treturn relativeWorkspaceMessage(\n\t\t\tthis.#workspace,\n\t\t\trelativeWorkspaceMessage(this.#mirror, message),\n\t\t)\n\t}\n\n\t#fault(execution: Execution, project: string): ProbeError {\n\t\tconst reported = scanDiagnostics(execution.stdout).map((diagnostic) => diagnostic.message)\n\t\tconst text = reported.length > 0 ? reported.join('\\n') : execution.stdout.trim()\n\t\treturn new ProbeError(\n\t\t\tthis.#translate(text === '' ? 'The compiler printed no configuration' : text),\n\t\t\t{\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t},\n\t\t)\n\t}\n\n\t#spawn(args: readonly string[], cwd: string): Promise<Execution> {\n\t\tthis.#refuseDestroyed()\n\t\treturn new Promise<Execution>((settle, refuse) => {\n\t\t\tconst child = spawn(process.execPath, [this.#compiler, ...args], {\n\t\t\t\tcwd,\n\t\t\t\tstdio: ['ignore', 'pipe', 'pipe'],\n\t\t\t})\n\t\t\tconst output = child.stdout\n\t\t\tconst errors = child.stderr\n\t\t\tif (output === null || errors === null) {\n\t\t\t\tthis.#terminate(child)\n\t\t\t\trefuse(\n\t\t\t\t\tnew ProbeError('The compiler was spawned without its own output streams', {\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: this.stage },\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.#children.add(child)\n\t\t\tlet stdout = ''\n\t\t\tlet stderr = ''\n\t\t\toutput.setEncoding('utf8')\n\t\t\terrors.setEncoding('utf8')\n\t\t\toutput.on('data', (chunk: string) => {\n\t\t\t\tstdout += chunk\n\t\t\t})\n\t\t\terrors.on('data', (chunk: string) => {\n\t\t\t\tstderr += chunk\n\t\t\t})\n\t\t\tchild.on('error', (error: unknown) => {\n\t\t\t\tthis.#children.delete(child)\n\t\t\t\trefuse(\n\t\t\t\t\tnew ProbeError('The workspace compiler could not be started', {\n\t\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: this.stage, path: this.#compiler },\n\t\t\t\t\t\tcause: error,\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t})\n\t\t\tchild.on('close', (code: number | null) => {\n\t\t\t\tthis.#children.delete(child)\n\t\t\t\tsettle({ ...(code === null ? {} : { status: code }), stdout, stderr })\n\t\t\t})\n\t\t})\n\t}\n\n\t// Ends one compiler run. A Windows host never delivers a cooperative signal to a child, and the\n\t// compiler is spawned through the Node executable, so the whole tree is ended there by process\n\t// id; every other host receives the signal it handles.\n\t#terminate(child: ChildProcess): void {\n\t\tconst id = child.pid\n\t\tif (process.platform === 'win32' && id !== undefined) {\n\t\t\tspawnSync('taskkill', ['/pid', String(id), '/t', '/f'], { stdio: 'ignore' })\n\t\t\treturn\n\t\t}\n\t\tchild.kill('SIGTERM')\n\t}\n}\n","import type {\n\tCase,\n\tCheck,\n\tClaim,\n\tProbeEventMap,\n\tProbeInterface,\n\tProbeOptions,\n\tProject,\n\tToolchain,\n\tVerdict,\n} from '@src/core'\nimport type { EmitterInterface } from '@orkestrel/emitter'\nimport type { QueueInterface } from '@orkestrel/queue'\nimport type { TimeoutInterface } from '@orkestrel/timeout'\nimport type { Inspection, StageInterface } from './types.js'\nimport { existsSync, mkdirSync, rmdirSync, rmSync, writeFileSync } from 'node:fs'\nimport { randomUUID } from 'node:crypto'\nimport { basename, relative } from 'node:path'\nimport { Emitter } from '@orkestrel/emitter'\nimport { isString } from '@orkestrel/contract'\nimport { createQueue } from '@orkestrel/queue'\nimport { createTimeout } from '@orkestrel/timeout'\nimport {\n\tPROBE_DEADLINE,\n\tProbeError,\n\tcomputeReceipt,\n\tcreateDestroyedError,\n\tformatCheck,\n\tformatSpecification,\n\tisProbeError,\n} from '@src/core'\nimport { peerDependencies } from '../../package.json' with { type: 'json' }\nimport {\n\tbuildRevisionPath,\n\tcomputeDigest,\n\tdescribeUnknown,\n\toverwriteFile,\n\treadWorkspaceManifest,\n\tresolveWorkspaceFile,\n} from './helpers.js'\nimport { LintStage } from './stages/LintStage.js'\nimport { RuntimeStage } from './stages/RuntimeStage.js'\nimport { TypeStage } from './stages/TypeStage.js'\n\n/**\n * Answers claims through its type, lint, and runtime stages.\n *\n * @remarks\n * Construction resolves the target workspace's toolchain and begins warming every stage. The boot\n * controls mutate imported dependencies and refuse service unless the type and runtime stages\n * report their respective changes. One queue per stage admits inspections in arrival order, one at\n * a time, so a stage never serves two claims at once and the deadline covers active work rather\n * than queue wait. Each active stage inspection has a coordinator-owned deadline. An expiry at any\n * stage abandons that stage and replaces it before the next queued inspection begins, so one slow\n * claim costs that claim rather than the process. A failed boot is replaced the same way: the next\n * claim runs the controls again rather than inheriting a refusal.\n *\n * @example The claim that earns a receipt\n * ```ts\n * import type { Claim } from '@orkestrel/probe'\n * import { Probe } from '@orkestrel/probe/server'\n *\n * const claim: Claim = {\n * \tproject: 'configs/src/tsconfig.core.json',\n * \tcase: {\n * \t\tfiles: [\n * \t\t\t{\n * \t\t\t\tpath: 'src/core/factories.ts',\n * \t\t\t\ttext: \"export function createGreeting(): string {\\n\\treturn 'hi'\\n}\\n\",\n * \t\t\t},\n * \t\t],\n * \t\ttest: {\n * \t\t\tpath: 'tmp/probes/greeting.test.ts',\n * \t\t\ttext: \"import { expect, test } from 'vitest'\\nimport { createGreeting } from '../../src/core/factories.js'\\ntest('greets', () => expect(createGreeting()).toBe('hi'))\\n\",\n * \t\t},\n * \t},\n * \tcontrol: {\n * \t\tfiles: [\n * \t\t\t{\n * \t\t\t\tpath: 'src/core/factories.ts',\n * \t\t\t\ttext: \"export function createGreeting(): number {\\n\\treturn 'hi'\\n}\\n\",\n * \t\t\t},\n * \t\t],\n * \t\ttest: {\n * \t\t\tpath: 'tmp/probes/greeting.test.ts',\n * \t\t\ttext: \"import { expect, test } from 'vitest'\\nimport { createGreeting } from '../../src/core/factories.js'\\ntest('greets', () => expect(createGreeting()).toBe('hi'))\\n\",\n * \t\t},\n * \t\tstage: 'type',\n * \t\treason: 'a string returned as a number must not compile',\n * \t},\n * }\n *\n * const probe = new Probe({ workspace: process.cwd() })\n * const verdict = await probe.prove(claim)\n * verdict.digest // 'bdf03e5dfd6bd413ead671c7a2940fcf'\n * verdict.receipt // 'probe:bdf03e5dfd6bd413ead671c7a2940fcf:type:typescript@6.0.3:oxlint@1.86.0:vitest@4.1.11:configs/src/tsconfig.core.json@434f59254d58cf2683d453a26bd0d837'\n * await probe.destroy()\n * ```\n */\nexport class Probe implements ProbeInterface {\n\treadonly #workspace: string\n\treadonly #deadline: number\n\treadonly #emitter: Emitter<ProbeEventMap>\n\treadonly #toolchain: Toolchain\n\t#type: TypeStage\n\t#lint: LintStage\n\t#runtime: RuntimeStage\n\treadonly #typeQueue: QueueInterface<Inspection, Check>\n\treadonly #lintQueue: QueueInterface<Inspection, Check>\n\treadonly #runtimeQueue: QueueInterface<Inspection, Check>\n\treadonly #deadlines = new WeakSet<ProbeError>()\n\treadonly #surfaced = new WeakSet<ProbeError>()\n\t#typeTail = Promise.resolve()\n\t#arming: Promise<void>\n\t// The teardown latch and the destroyed reading are one field: `destroy` assigns it before\n\t// anything it starts can suspend, so every later read of `#closing !== undefined` answers the\n\t// question a second flag would have answered, and no second write can drift from this one.\n\t#closing: Promise<void> | undefined\n\n\t/**\n\t * Resolves the target toolchain and starts warming every stage.\n\t *\n\t * @param options - Workspace, deadline, and initial observation hooks\n\t */\n\tconstructor(options?: ProbeOptions) {\n\t\tthis.#workspace = options?.workspace ?? process.cwd()\n\t\tthis.#deadline = createTimeout({ ms: options?.deadline ?? PROBE_DEADLINE }).ms\n\t\tthis.#emitter = new Emitter({\n\t\t\t...(options?.on === undefined ? {} : { on: options.on }),\n\t\t\t...(options?.error === undefined ? {} : { error: options.error }),\n\t\t})\n\t\tthis.#toolchain = Object.freeze({\n\t\t\ttypescript: this.#version('typescript'),\n\t\t\toxlint: this.#version('oxlint'),\n\t\t\tvitest: this.#version('vitest'),\n\t\t})\n\t\tthis.#type = new TypeStage(this.#workspace)\n\t\tthis.#lint = new LintStage(this.#workspace)\n\t\tthis.#runtime = new RuntimeStage(this.#workspace)\n\t\t// One queue per stage, strictly ordered and one deep, is the only place this coordinator\n\t\t// serializes: a stage admits nothing itself. `retries: 0` keeps the queue from re-running an\n\t\t// inspection, because a stage that exceeded its deadline is recycled rather than retried, and\n\t\t// that recovery runs inside the handler so it finishes before the next claim is admitted.\n\t\tthis.#typeQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: this.#inspectType.bind(this),\n\t\t})\n\t\tthis.#lintQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: this.#inspectLint.bind(this),\n\t\t})\n\t\tthis.#runtimeQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: this.#inspectRuntime.bind(this),\n\t\t})\n\t\tthis.#arming = this.#arm()\n\t\t// Observe the stored promise here. Nothing else reads it until `prove` or `destroy`, and a\n\t\t// host that calls neither takes an unhandled rejection that ends the process. The stored\n\t\t// promise keeps rejecting, so `prove` still reports the arming failure to its caller.\n\t\tvoid this.#arming.catch(() => {})\n\t}\n\n\tget emitter(): EmitterInterface<ProbeEventMap> {\n\t\treturn this.#emitter\n\t}\n\n\tget toolchain(): Toolchain {\n\t\treturn this.#toolchain\n\t}\n\n\tasync prove(claim: Claim): Promise<Verdict> {\n\t\ttry {\n\t\t\tthis.#support()\n\t\t\tthis.#admit(claim)\n\t\t\tawait this.#ready()\n\t\t\tif (this.#closing !== undefined) throw createDestroyedError('probe')\n\t\t\tconst started = performance.now()\n\t\t\tconst id = randomUUID()\n\t\t\t// Resolve the project before any inspection runs, so a project this workspace cannot parse\n\t\t\t// fails the claim outright rather than after every stage has paid for it.\n\t\t\tconst project = await this.#resolve(claim)\n\t\t\tconst digest = computeDigest(this.#workspace, {\n\t\t\t\tcase: claim.case,\n\t\t\t\tcontrol: claim.control,\n\t\t\t})\n\t\t\tconst subject = Object.freeze(await this.#inspect(claim.case, claim))\n\t\t\tconst control = Object.freeze(await this.#inspect(claim.control, claim))\n\t\t\tconst basis: Verdict = {\n\t\t\t\tid,\n\t\t\t\tdigest,\n\t\t\t\ttoolchain: this.#toolchain,\n\t\t\t\tproject,\n\t\t\t\treason: claim.control.reason,\n\t\t\t\tcase: subject,\n\t\t\t\tcontrol,\n\t\t\t\telapsed: Math.round(performance.now() - started),\n\t\t\t}\n\t\t\tconst receipt = computeReceipt(basis, claim.control.stage)\n\t\t\tconst verdict: Verdict = receipt === undefined ? basis : { ...basis, receipt }\n\t\t\tthis.#emitter.emit('prove', verdict)\n\t\t\treturn verdict\n\t\t} catch (error) {\n\t\t\t// An arming failure reached the error channel as its attempt rejected. Reporting it here\n\t\t\t// too would show one refused boot as two faults.\n\t\t\tif (!isProbeError(error) || !this.#surfaced.has(error)) {\n\t\t\t\tthis.#emitter.emit('error', error)\n\t\t\t}\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\n\t}\n\n\t// Awaits the arming attempt in flight and starts one replacement for an attempt that failed.\n\t// Arming runs the boot controls through the same stages a claim uses, so the failure that ends\n\t// it is usually the workspace's — a stage that outran the deadline, a project that had no\n\t// Vitest environment yet — and those are repaired while this process keeps running. One\n\t// replacement per call bounds the cost: a workspace that still cannot arm pays one boot and\n\t// reports it, rather than looping. A caller that already started the replacement is joined\n\t// rather than replaced, so several callers waiting on one failed boot start one boot between\n\t// them.\n\tasync #ready(): Promise<void> {\n\t\tconst attempt = this.#arming\n\t\ttry {\n\t\t\tawait attempt\n\t\t\treturn\n\t\t} catch (error) {\n\t\t\tif (this.#closing !== undefined) throw error\n\t\t}\n\t\tif (this.#arming === attempt) {\n\t\t\tthis.#arming = this.#arm()\n\t\t\tvoid this.#arming.catch(() => {})\n\t\t}\n\t\tawait this.#arming\n\t}\n\n\tasync #arm(): Promise<void> {\n\t\tlet created: boolean\n\t\ttry {\n\t\t\tcreated = this.#workbench()\n\t\t} catch (error) {\n\t\t\t// The workbench refusal names the boot in its own message and reports the target tree's\n\t\t\t// fault, so it surfaces and rejects unchanged. Rewrapping it here would report a\n\t\t\t// directory this workspace blocks as this package refusing to serve.\n\t\t\tthis.#surface(error)\n\t\t\tthrow error\n\t\t}\n\t\ttry {\n\t\t\tawait this.#boot(created)\n\t\t} catch (error) {\n\t\t\t// A boot failure and a claim's own stage failure are otherwise one message: the controls\n\t\t\t// run through the same stages under the same deadline, so `The lint stage exceeded 6000\n\t\t\t// ms` reads as evidence about the candidate when it is the instrument refusing to serve.\n\t\t\tconst failure = new ProbeError(`The probe could not arm: ${describeUnknown(error)}`, {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcause: error,\n\t\t\t})\n\t\t\tthis.#surface(failure)\n\t\t\tthrow failure\n\t\t}\n\t\t// The boot control's own files are gone before this line, so a listener is told the\n\t\t// instrument serves only after the workspace holds nothing the control wrote.\n\t\tthis.#emitter.emit('arm', this.#toolchain)\n\t}\n\n\t// Reports an arming attempt's refusal as it happens. `arm` never fires for a rejected attempt\n\t// and the attempt is retained for the next `prove` to retry, so a host that waits for `arm` and\n\t// a host that calls nothing are both told nothing without this. Recording the failure is what\n\t// keeps `prove` from reporting one refusal a second time when the same attempt reaches it.\n\t// Observation only: the retry, its timing, and what the next caller reads are unchanged.\n\t#surface(error: unknown): void {\n\t\tif (isProbeError(error)) this.#surfaced.add(error)\n\t\tthis.#emitter.emit('error', error)\n\t}\n\n\t#workbench(): boolean {\n\t\tconst path = 'tmp/probes'\n\t\tconst directory = resolveWorkspaceFile(this.#workspace, path)\n\t\t// A returned `true` means this directory was absent before this call, so the boot teardown\n\t\t// that follows owns removing it again.\n\t\tconst created = !existsSync(directory)\n\t\ttry {\n\t\t\tmkdirSync(resolveWorkspaceFile(this.#workspace, path, true), { recursive: true })\n\t\t} catch (error) {\n\t\t\tconst code = isProbeError(error) && error.origin === 'workspace' ? error.code : 'malformed'\n\t\t\tthrow new ProbeError(\n\t\t\t\t`The probe could not create the boot workbench (${describeUnknown(error)})`,\n\t\t\t\t{\n\t\t\t\t\torigin: 'workspace',\n\t\t\t\t\tcode,\n\t\t\t\t\tcontext: { path },\n\t\t\t\t\tcause: error,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\treturn created\n\t}\n\n\tasync #boot(created: boolean): Promise<void> {\n\t\t// The dependencies that follow are real files in the target's tree, so they carry the same\n\t\t// revision identity a generated specification does: the writing host's process id, then a\n\t\t// fresh UUID. A boot the host does not survive leaves them behind, and the next runtime\n\t\t// warm sweeps a file whose writer is gone while leaving a live neighbour's alone.\n\t\tconst revision = `${process.pid}-${randomUUID()}`\n\t\tconst typeDependency = buildRevisionPath(this.#workspace, 'tmp/probes/arm-type.ts', revision)\n\t\tconst runtimeDependency = buildRevisionPath(\n\t\t\tthis.#workspace,\n\t\t\t'tmp/probes/arm-runtime.ts',\n\t\t\trevision,\n\t\t)\n\t\tconst typeModule = basename(typeDependency, '.ts')\n\t\tconst runtimeModule = basename(runtimeDependency, '.ts')\n\t\tconst typeTest = {\n\t\t\tpath: `tmp/probes/${typeModule}.test.ts`,\n\t\t\ttext: `import type { Signal } from './${typeModule}.js'\\nimport { expect, test } from 'vitest'\\nconst SIGNAL: Signal = 'before'\\ntest('revalidates a mutated type', () => {\\n\\texpect(SIGNAL).toBe('before')\\n})\\n`,\n\t\t}\n\t\tconst runtimeTest = {\n\t\t\tpath: `tmp/probes/${runtimeModule}.test.ts`,\n\t\t\ttext: `import { SIGNAL } from './${runtimeModule}.js'\\nimport { expect, test } from 'vitest'\\ntest('revalidates a mutated value', () => {\\n\\texpect(SIGNAL).toBe('before')\\n})\\n`,\n\t\t}\n\t\tconst typeClaim: Claim = {\n\t\t\tproject: 'tsconfig.json',\n\t\t\tcase: { files: [], test: typeTest },\n\t\t\tcontrol: {\n\t\t\t\tfiles: [],\n\t\t\t\ttest: typeTest,\n\t\t\t\tstage: 'type',\n\t\t\t\treason: 'the imported type changed on disk between the two inspections',\n\t\t\t},\n\t\t}\n\t\tconst runtimeClaim: Claim = {\n\t\t\tproject: 'tsconfig.json',\n\t\t\tcase: { files: [], test: runtimeTest },\n\t\t\tcontrol: {\n\t\t\t\tfiles: [],\n\t\t\t\ttest: runtimeTest,\n\t\t\t\tstage: 'runtime',\n\t\t\t\treason: 'the imported dependency changed after the resident runtime cached it',\n\t\t\t},\n\t\t}\n\t\ttry {\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, typeDependency), true)\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, runtimeDependency), true)\n\t\t\twriteFileSync(\n\t\t\t\ttypeDependency,\n\t\t\t\tformatSpecification('export type Signal = string\\n', revision),\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf8',\n\t\t\t\t\tflag: 'wx',\n\t\t\t\t},\n\t\t\t)\n\t\t\twriteFileSync(\n\t\t\t\truntimeDependency,\n\t\t\t\tformatSpecification(\"export const SIGNAL = 'before'\\n\", revision),\n\t\t\t\t{\n\t\t\t\t\tencoding: 'utf8',\n\t\t\t\t\tflag: 'wx',\n\t\t\t\t},\n\t\t\t)\n\t\t\tconst beforeType = await this.#inspect(typeClaim.case, typeClaim)\n\t\t\tconst beforeRuntime = await this.#inspect(runtimeClaim.case, runtimeClaim)\n\t\t\tconst before = [...beforeType, ...beforeRuntime]\n\t\t\tif (before.some((check) => check.issues.length > 0)) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot control did not begin clean\\n${before.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{ origin: 'instrument', code: 'malformed' },\n\t\t\t\t)\n\t\t\t}\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, typeDependency), true)\n\t\t\toverwriteFile(typeDependency, formatSpecification('export type Signal = number\\n', revision))\n\t\t\tconst afterType = await this.#inspect(typeClaim.control, typeClaim)\n\t\t\tconst type = afterType.find((check) => check.stage === typeClaim.control.stage)\n\t\t\tconst tolerant = afterType.find((check) => check.stage === 'runtime')\n\t\t\tif (type === undefined || type.issues.length === 0) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot type control did not detect a mutated dependency\\n${afterType.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: typeClaim.control.stage },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (tolerant === undefined || tolerant.issues.length > 0) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot type control did not remain runtime-clean\\n${afterType.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: 'runtime' },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, runtimeDependency), true)\n\t\t\toverwriteFile(\n\t\t\t\truntimeDependency,\n\t\t\t\tformatSpecification(\"export const SIGNAL = 'after'\\n\", revision),\n\t\t\t)\n\t\t\tconst afterRuntime = await this.#inspect(runtimeClaim.control, runtimeClaim)\n\t\t\tconst runtime = afterRuntime.find((check) => check.stage === runtimeClaim.control.stage)\n\t\t\tif (runtime === undefined || runtime.issues.length === 0) {\n\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t`The probe boot runtime control did not detect a mutated dependency\\n${afterRuntime.map(formatCheck).join('\\n')}`,\n\t\t\t\t\t{\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { stage: runtimeClaim.control.stage },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\t}\n\t\t} finally {\n\t\t\trmSync(\n\t\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, typeDependency), true),\n\t\t\t\t{ force: true },\n\t\t\t)\n\t\t\trmSync(\n\t\t\t\tresolveWorkspaceFile(this.#workspace, relative(this.#workspace, runtimeDependency), true),\n\t\t\t\t{ force: true },\n\t\t\t)\n\t\t\tif (created) {\n\t\t\t\ttry {\n\t\t\t\t\trmdirSync(resolveWorkspaceFile(this.#workspace, 'tmp/probes', true))\n\t\t\t\t} catch {}\n\t\t\t}\n\t\t}\n\t}\n\n\t#inspect(subject: Case, claim: Claim): Promise<readonly Check[]> {\n\t\tconst inspection: Inspection = { subject, claim }\n\t\tconst admitted = [\n\t\t\tthis.#typeQueue.enqueue(inspection),\n\t\t\tthis.#lintQueue.enqueue(inspection),\n\t\t\tthis.#runtimeQueue.enqueue(inspection),\n\t\t]\n\t\t// `Promise.all` reports the first rejection and stops observing the rest, and an unobserved\n\t\t// rejection ends the host process. Observe each one here; the caller still reads the first.\n\t\tfor (const pending of admitted) void pending.catch(() => {})\n\t\treturn Promise.all(admitted)\n\t}\n\n\tasync #inspectType(inspection: Inspection): Promise<Check> {\n\t\tconst release = await this.#admitType()\n\t\ttry {\n\t\t\tconst stage = this.#type\n\t\t\treturn await this.#inspectStage(\n\t\t\t\tstage,\n\t\t\t\tstage.progress,\n\t\t\t\t() => stage.inspect(inspection.subject, inspection.claim.project),\n\t\t\t\tinspection.claim,\n\t\t\t)\n\t\t} finally {\n\t\t\trelease()\n\t\t}\n\t}\n\n\t#inspectLint(inspection: Inspection): Promise<Check> {\n\t\tconst stage = this.#lint\n\t\t// The lint stage waits on a foreign language server's silence and reads this bound's signal to\n\t\t// end that wait. The other stages take no signal and are abandoned and replaced instead.\n\t\treturn this.#inspectStage(\n\t\t\tstage,\n\t\t\tstage.progress,\n\t\t\t(signal) => stage.inspect(inspection.subject, { signal }),\n\t\t\tinspection.claim,\n\t\t)\n\t}\n\n\t#inspectRuntime(inspection: Inspection): Promise<Check> {\n\t\tconst stage = this.#runtime\n\t\treturn this.#inspectStage(\n\t\t\tstage,\n\t\t\tstage.progress,\n\t\t\t() => stage.inspect(inspection.subject),\n\t\t\tinspection.claim,\n\t\t)\n\t}\n\n\tasync #inspectStage(\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t\toperation: (signal: AbortSignal) => Promise<Check>,\n\t\tclaim: Claim,\n\t): Promise<Check> {\n\t\ttry {\n\t\t\treturn await this.#bound(\n\t\t\t\toperation,\n\t\t\t\t`The ${stage.stage} stage exceeded ${this.#deadline} ms`,\n\t\t\t\tstage,\n\t\t\t\tprogress,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthis.#emitExpiry(stage, claim)\n\t\t\tthrow error\n\t\t}\n\t}\n\n\t// Arms the deadline before the operation begins and hands the operation this deadline's signal.\n\t// A stage that can cut its own wait short is then bounded by the deadline that reports the\n\t// overrun rather than by a second bound of its own, and a stage that reads no signal is abandoned\n\t// and replaced exactly as before.\n\tasync #bound<T>(\n\t\toperation: (signal: AbortSignal) => Promise<T>,\n\t\tmessage: string,\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t): Promise<T> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\tconst expiry = this.#expiry(timeout, message, stage, progress)\n\t\t// The refusal is held as well as raced. An operation this signal aborts rejects with its own\n\t\t// tool's cancellation, that rejection can settle the race first, and it names the tool rather\n\t\t// than the stage that overran — so an expired deadline answers with this refusal either way.\n\t\tconst refusal = expiry.catch((error: unknown) => error)\n\t\ttry {\n\t\t\treturn await Promise.race([operation(timeout.signal), expiry])\n\t\t} catch (error) {\n\t\t\tif (!timeout.expired) throw error\n\t\t\tawait this.#recycle(stage)\n\t\t\tthrow await refusal\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t}\n\n\t// Replaces the stage one expired deadline destroyed, so a single slow claim costs that claim\n\t// rather than the process. A resident server whose type, lint, or runtime stage stays destroyed\n\t// answers every later claim with the destruction of a stage that caller never asked about.\n\tasync #recycle(stage: StageInterface): Promise<boolean> {\n\t\tif (this.#closing !== undefined) return false\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\t// Teardown of a hung stage can reject or outlive its own deadline, and the replacement\n\t\t\t// must be installed either way: the field otherwise stays destroyed for the life of the\n\t\t\t// process and every later claim reports that instead of its own evidence.\n\t\t\tawait Promise.race([\n\t\t\t\tstage.destroy(),\n\t\t\t\tthis.#expiry(\n\t\t\t\t\ttimeout,\n\t\t\t\t\t`The ${stage.stage} stage recovery exceeded ${this.#deadline} ms`,\n\t\t\t\t\tstage,\n\t\t\t\t\tstage.progress,\n\t\t\t\t),\n\t\t\t])\n\t\t} catch {\n\t\t\t// The failure belongs to the stage being replaced, and the replacement that follows is\n\t\t\t// the recovery the caller is owed.\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t\tif (this.#closing !== undefined) return false\n\t\t// Identity, not kind: a second expiry racing this one names the stage this call already\n\t\t// replaced, and rebuilding on that report would discard a live stage the queues are using.\n\t\tif (stage === this.#type) {\n\t\t\tthis.#type = new TypeStage(this.#workspace)\n\t\t\treturn true\n\t\t}\n\t\tif (stage === this.#lint) {\n\t\t\tthis.#lint = new LintStage(this.#workspace)\n\t\t\treturn true\n\t\t}\n\t\tif (stage === this.#runtime) {\n\t\t\tthis.#runtime = new RuntimeStage(this.#workspace)\n\t\t\treturn true\n\t\t}\n\t\treturn false\n\t}\n\n\t// Holds every caller-selected project resolution and type inspection on one promise chain. A\n\t// resolve that recycled the shared caller-named service during an inspection would change the\n\t// service that inspection resumes with after its next cooperative yield.\n\tasync #admitType(): Promise<() => void> {\n\t\tconst previous = this.#typeTail\n\t\tconst turn = Promise.withResolvers<void>()\n\t\tthis.#typeTail = turn.promise\n\t\tawait previous\n\t\treturn turn.resolve\n\t}\n\n\tasync #resolve(claim: Claim): Promise<Project> {\n\t\tconst release = await this.#admitType()\n\t\ttry {\n\t\t\tconst stage = this.#type\n\t\t\ttry {\n\t\t\t\treturn await this.#bound(\n\t\t\t\t\t() => stage.resolve(claim.project),\n\t\t\t\t\t`The type stage project resolution exceeded ${this.#deadline} ms`,\n\t\t\t\t\tstage,\n\t\t\t\t\tstage.progress,\n\t\t\t\t)\n\t\t\t} catch (error) {\n\t\t\t\tthis.#emitExpiry(stage, claim)\n\t\t\t\tthrow error\n\t\t\t}\n\t\t} finally {\n\t\t\trelease()\n\t\t}\n\t}\n\n\t#emitExpiry(stage: StageInterface, claim: Claim): void {\n\t\tif (stage === this.#type || stage === this.#lint || stage === this.#runtime) return\n\t\tthis.#emitter.emit('expire', claim)\n\t}\n\n\t// Rejects when the deadline fires, so a race against it settles even when the operation it\n\t// races never returns. The stage travels beside the message because a caller catching this\n\t// branches on the category and the budget, and reads the message only to print it.\n\t#expiry(\n\t\ttimeout: TimeoutInterface,\n\t\tmessage: string,\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t): Promise<never> {\n\t\treturn new Promise<never>((_resolve, reject) => {\n\t\t\ttimeout.signal.addEventListener(\n\t\t\t\t'abort',\n\t\t\t\t() => {\n\t\t\t\t\tconst error = new ProbeError(message, {\n\t\t\t\t\t\torigin: stage.progress > progress ? 'claimant' : 'instrument',\n\t\t\t\t\t\tcode: 'deadline',\n\t\t\t\t\t\tcontext: { stage: stage.stage, deadline: this.#deadline },\n\t\t\t\t\t})\n\t\t\t\t\tthis.#deadlines.add(error)\n\t\t\t\t\treject(error)\n\t\t\t\t},\n\t\t\t\t{ once: true },\n\t\t\t)\n\t\t})\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\ttry {\n\t\t\ttry {\n\t\t\t\tawait this.#arming\n\t\t\t} catch {}\n\t\t\t// Tear the stages down and leave the queues running. A queue holds no host resource — no\n\t\t\t// timer, no listener, no store — and stage teardown settles every entry still admitted, so\n\t\t\t// each caller reads the stage's own refusal. Destroying a queue instead abandons those\n\t\t\t// entries, and a stage rejecting after its queue stopped observing ends the host process.\n\t\t\tawait Promise.all([\n\t\t\t\tthis.#destroyStage(this.#type),\n\t\t\t\tthis.#destroyStage(this.#lint),\n\t\t\t\tthis.#destroyStage(this.#runtime),\n\t\t\t])\n\t\t} finally {\n\t\t\t// Release the listener graph last, and release it on the teardown that failed as well:\n\t\t\t// a stage whose teardown rejects is the moment a host most needs its listeners gone, and\n\t\t\t// a plain trailing statement is the one skipped on exactly that path. `destroy` is\n\t\t\t// idempotent, so no guard stands in front of it.\n\t\t\tthis.#emitter.destroy()\n\t\t}\n\t}\n\n\tasync #destroyStage(stage: StageInterface): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#bound(\n\t\t\t\t() => stage.destroy(),\n\t\t\t\t`The ${stage.stage} stage teardown exceeded ${this.#deadline} ms`,\n\t\t\t\tstage,\n\t\t\t\tstage.progress,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\t// A teardown overrun cannot replace the destroyed stage, and every sibling still receives\n\t\t\t// its own bound. A teardown that fails before the deadline keeps its original rejection.\n\t\t\tif (!isProbeError(error) || !this.#deadlines.has(error)) throw error\n\t\t}\n\t}\n\n\t#version(name: string): string {\n\t\tconst manifest = readWorkspaceManifest(this.#workspace, name)\n\t\tconst version = manifest.contents.version\n\t\tif (!isString(version)) {\n\t\t\tthrow new ProbeError(`${name} publishes no readable version`, {\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { name },\n\t\t\t})\n\t\t}\n\t\treturn version\n\t}\n\n\t// Refuses a control that is the case again. No stage inspects such a claim: the refusal answers\n\t// before any stage is asked for an inspection and before the instrument is awaited, so it reads\n\t// the same in every workspace state — construction has already begun arming and running the boot\n\t// controls by the time this is reached, and neither touches this claim. Such a control can only\n\t// break by nondeterminism, and the receipt it would earn that way attests a falsification that\n\t// never happened — the worst answer this package can return. Identity covers the whole case, the\n\t// candidate drafts and the test, and it is decided on the bytes rather than on the digest a\n\t// verdict carries: that digest rewrites every workspace-contained absolute string to its relative\n\t// form, so two drafts one byte apart can hash alike and a control the claimant can break would be\n\t// refused. The control's `stage` and `reason` describe the drafts rather than being them, so\n\t// neither rescues a control whose files and test are the case's. Drafts are paired by position,\n\t// because a shared path materializes the last draft that carries it and reordering the list\n\t// therefore changes what the stages read.\n\t#admit(claim: Claim): void {\n\t\tconst subject = claim.case\n\t\tconst control = claim.control\n\t\tif (subject.test.path !== control.test.path) return\n\t\tif (subject.test.text !== control.test.text) return\n\t\tif (subject.files.length !== control.files.length) return\n\t\tconst repeated = subject.files.every((draft, index) => {\n\t\t\tconst other = control.files[index]\n\t\t\treturn other !== undefined && other.path === draft.path && other.text === draft.text\n\t\t})\n\t\tif (!repeated) return\n\t\tthrow new ProbeError(\n\t\t\t'The control must differ from the case; it carries the same candidate drafts and the same test',\n\t\t\t{ origin: 'claimant', code: 'refused' },\n\t\t)\n\t}\n\n\t#support(): void {\n\t\tconst version = this.#toolchain.typescript\n\t\tconst range = peerDependencies.typescript\n\t\tconst supported = /^\\^(\\d+)\\./u.exec(range)?.[1]\n\t\tconst found = /^(\\d+)\\./u.exec(version)?.[1]\n\t\tif (supported === undefined || found !== supported) {\n\t\t\tthrow new ProbeError(`The supported TypeScript range is ${range}; found ${version}`, {\n\t\t\t\torigin: 'workspace',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { name: 'typescript', value: version },\n\t\t\t})\n\t\t}\n\t}\n}\n","import type { ProbeInterface, ProbeOptions, Verdict } from '@src/core'\nimport type { MCPCallResult, MCPExecutionContext } from '@orkestrel/mcp'\nimport type { ToolResult } from '@orkestrel/tool'\nimport type { ProbeServerInterface } from './types.js'\nimport { resolve } from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport { compileSchema, schemaToParameters } from '@orkestrel/contract'\nimport { createMCPLegacy, createMCPServer, isBoundedJSON } from '@orkestrel/mcp'\nimport { createStdioServer } from '@orkestrel/mcp/server'\nimport { createTool, createToolManager } from '@orkestrel/tool'\nimport {\n\tCLAIM_SHAPE,\n\tPROBE_KEYS,\n\tProbeError,\n\tcreateDestroyedError,\n\tformatReceipt,\n\tformatVerdict,\n\tisClaim,\n\tisVerdict,\n} from '@src/core'\nimport { version } from '../../package.json' with { type: 'json' }\nimport { findRefusedPaths } from './helpers.js'\nimport { Probe } from './Probe.js'\n\n/**\n * Implements `ProbeServerInterface` over a `PassThrough` stream this server owns, binding the\n * published `prove` tool and the dual-era dispatcher to this process's Model Context Protocol\n * stdio transport.\n *\n * @remarks\n * Construction snapshots the probe options, publishes the `prove` tool, and binds the dual-era\n * dispatcher to the stdio transport. An admitted `prove` call creates the probe and begins\n * workspace arming, so discovery does not depend on the workspace toolchain. Construction is held\n * before it begins, so teardown entered through a construction callback waits for the resulting\n * probe and releases it. A constructor refusal clears that held operation for a later retry.\n *\n * `start` seizes standard input and registers the signals a harness ends a child with, and records\n * whether standard input was already flowing. Every listener it attaches is held as a field, and\n * `destroy` removes exactly those by reference, so a listener a host registers while this server is\n * serving is still attached and still fires afterwards. The transport reads a stream this server\n * owns rather than this process's standard input, which is what makes that possible: the\n * transport's own listeners land on that stream, and the only listeners this server ever puts on\n * `process.stdin` are the `data`, `close`, and `error` forwarders into it. `destroy` pauses the\n * stream only when this server is what set it flowing and nothing else is reading it, so a process\n * that outlives this server reads its own standard input again and receives its own signals.\n * Teardown removes the signal handlers first: it takes seconds when a boot is in flight, and a\n * harness that signals again means to kill rather than to queue.\n *\n * @example\n * ```ts\n * const server = new ProbeServer({ workspace: process.cwd() })\n * server.start()\n * await server.destroy()\n * ```\n */\nexport class ProbeServer implements ProbeServerInterface {\n\treadonly #options: ProbeOptions\n\treadonly #stream: PassThrough\n\treadonly #transport: ReturnType<typeof createStdioServer>\n\treadonly #data: (chunk: Buffer) => void\n\treadonly #close: () => void\n\treadonly #error: (error: Error) => void\n\treadonly #signal: () => void\n\treadonly #server: ReturnType<typeof createMCPServer>\n\t#owns: boolean | undefined\n\t#construction: Promise<ProbeInterface> | undefined\n\t#closing: Promise<void> | undefined\n\n\t/**\n\t * Snapshots the probe options this server will use and binds the published schema to this\n\t * process's stdio transport. An admitted `prove` call creates the probe.\n\t *\n\t * @param options - Workspace, deadline, and initial observation hooks for the deferred probe\n\t */\n\tconstructor(options?: ProbeOptions) {\n\t\tconst workspace = options?.workspace\n\t\tconst deadline = options?.deadline\n\t\tconst on = options?.on\n\t\tconst error = options?.error\n\t\tthis.#options = Object.freeze({\n\t\t\tworkspace: resolve(workspace ?? process.cwd()),\n\t\t\t...(deadline === undefined ? {} : { deadline }),\n\t\t\t...(on === undefined ? {} : { on: Object.freeze({ ...on }) }),\n\t\t\t...(error === undefined ? {} : { error }),\n\t\t})\n\t\t// `@orkestrel/mcp` 0.0.19 attaches three anonymous listeners to whatever stream it is given\n\t\t// and detaches none of them when its transport closes. Give it a stream this server owns, so\n\t\t// those listeners are never on `process.stdin` and teardown never has to decide which\n\t\t// listeners there were the transport's. A later transport that detaches its own leaves this\n\t\t// arrangement doing the same work rather than making it wrong.\n\t\tthis.#stream = new PassThrough()\n\t\t// Hold the composed server rather than hand it straight to the transport. It resolves the\n\t\t// bounds it was configured with and publishes them on `limit`, so `#execute` reads the bounds\n\t\t// it admits its own answer by from the server that enforces them, and one number decides both.\n\t\tthis.#server = this.#publish()\n\t\tthis.#transport = createStdioServer(createMCPLegacy(this.#server), { input: this.#stream })\n\t\t// One stable reference per listener, bound once here, because an emitter removes a listener\n\t\t// by identity and a reference built at attach time cannot be rebuilt at release time.\n\t\tthis.#data = this.#receive.bind(this)\n\t\tthis.#close = this.#finish.bind(this)\n\t\tthis.#error = this.#fail.bind(this)\n\t\tthis.#signal = this.#release.bind(this)\n\t}\n\n\tstart(): void {\n\t\t// `#owns` records that this server is serving and `#closing` that teardown has begun. A second\n\t\t// call while serving would attach another listener set and forget the first, while a call after\n\t\t// teardown would write into a stream this server has already destroyed.\n\t\tif (this.#closing !== undefined) throw createDestroyedError('probe server')\n\t\tif (this.#owns !== undefined) return\n\t\t// The stream's flow is what this server takes from the process beside the listener sets. Read\n\t\t// it here, before anything attaches, because this is the only moment the\n\t\t// answer exists. Read `readableFlowing` rather than `isPaused()`: a stream nobody has read\n\t\t// reports `readableFlowing` as `null`, and `isPaused()` folds that into the same `false` an\n\t\t// already-flowing stream reports, so only the flow itself separates a flow this server is\n\t\t// about to start from one it found running.\n\t\tthis.#owns = process.stdin.readableFlowing !== true\n\t\t// Arm the transport before the forwarders, so the stream it reads has its reader attached\n\t\t// before the first chunk can arrive on it.\n\t\tthis.#transport.start()\n\t\tprocess.stdin.on('data', this.#data)\n\t\tprocess.stdin.on('close', this.#close)\n\t\tprocess.stdin.on('error', this.#error)\n\t\tprocess.on('SIGINT', this.#signal)\n\t\tprocess.on('SIGTERM', this.#signal)\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\t// Release the signal handlers before anything slow. Teardown awaits the boot in flight and\n\t\t// takes seconds; a harness that signals again inside that window is asking for the process\n\t\t// rather than for a second graceful attempt, and with these handlers gone it gets it.\n\t\tprocess.removeListener('SIGINT', this.#signal)\n\t\tprocess.removeListener('SIGTERM', this.#signal)\n\t\tthis.#transport.stop()\n\t\t// Take back exactly the forwarders `start` attached, by reference. Removing a `data`\n\t\t// listener does not pause the stream, so the flow is decided after they are off: pause only\n\t\t// when this server both started the flow and is the last thing reading it. A host that was\n\t\t// already reading its own standard input keeps reading it, a host that began reading while\n\t\t// this server was serving keeps reading it too, and a host that never read gets its paused\n\t\t// stream back.\n\t\tprocess.stdin.removeListener('data', this.#data)\n\t\tprocess.stdin.removeListener('close', this.#close)\n\t\tprocess.stdin.removeListener('error', this.#error)\n\t\tif (this.#owns === true && process.stdin.listenerCount('data') === 0) process.stdin.pause()\n\t\tthis.#owns = undefined\n\t\t// Safe only after the forwarders are off: a chunk arriving on a destroyed stream would raise\n\t\t// a write-after-destroy error nothing is left to answer.\n\t\tthis.#stream.destroy()\n\t\tconst construction = this.#construction\n\t\tif (construction === undefined) return\n\t\tconst probe = await construction.catch(() => undefined)\n\t\tif (probe !== undefined) await probe.destroy()\n\t}\n\n\t// Forwards one chunk of this process's standard input into the stream the transport reads.\n\t#receive(chunk: Buffer): void {\n\t\tthis.#stream.write(chunk)\n\t}\n\n\t// Ends the transport's stream when standard input closes, so buffered bytes are still framed\n\t// before the transport reads the close.\n\t#finish(): void {\n\t\tthis.#stream.end()\n\t}\n\n\t// Carries a standard input failure to the transport as its stream's own error.\n\t#fail(error: Error): void {\n\t\tthis.#stream.destroy(error)\n\t}\n\n\t// Answers a termination signal. One reference serves both signals, and each removal names its\n\t// own event, so `destroy` takes it off `SIGINT` and `SIGTERM` independently.\n\t#release(): void {\n\t\tvoid this.destroy()\n\t}\n\n\t// Advertises `prove` as the one tool this server publishes, and renders each verdict as the text\n\t// a client reads. The claim guard runs here rather than inside the probe, because a tool call\n\t// arrives as unknown JSON and the coordinator's contract begins at a `Claim`.\n\t#publish(): ReturnType<typeof createMCPServer> {\n\t\tconst parameters = schemaToParameters(compileSchema(CLAIM_SHAPE))\n\t\tif (parameters === undefined) {\n\t\t\tthrow new ProbeError('The claim schema cannot be advertised as tool parameters', {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t})\n\t\t}\n\t\tconst tools = createToolManager()\n\t\ttools.add(\n\t\t\tcreateTool({\n\t\t\t\tname: 'prove',\n\t\t\t\tdescription:\n\t\t\t\t\t\"Answers whether a TypeScript edit compiles, lints, and passes its test in this workspace — call it before relying on such a claim, instead of reasoning or writing a throwaway probe. Supply the edit you believe is correct and an edit that must break with the stage it breaks at; the closing line is a receipt only when the case ran clean and the control broke exactly at its declared stage, and no receipt otherwise. For a performance claim, measure before proving: write a guarded bench block — if (import.meta.env.MODE === 'benchmark') — beside the probe test, run the workspace bench script, and record only magnitudes; a settled ratio then proves here as an ordinary runtime claim.\",\n\t\t\t\tparameters,\n\t\t\t\texecute: this.#prove.bind(this),\n\t\t\t}),\n\t\t)\n\t\treturn createMCPServer({\n\t\t\tidentity: { name: 'probe', version },\n\t\t\ttools,\n\t\t\tlimit: { keys: PROBE_KEYS },\n\t\t\texecution: this.#execute.bind(this),\n\t\t})\n\t}\n\n\tasync #prove(input: Readonly<Record<string, unknown>>): Promise<Verdict> {\n\t\tif (!isClaim(input)) {\n\t\t\tconst refused = findRefusedPaths(input)\n\t\t\tthrow new ProbeError(\n\t\t\t\trefused.length === 0\n\t\t\t\t\t? 'The prove tool requires a claim matching the advertised schema'\n\t\t\t\t\t: `The prove tool refuses ${refused.join(', ')}: a draft path must stay inside the workspace, which the advertised schema does not constrain`,\n\t\t\t\t{\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { value: input },\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst probe = await this.#resolveProbe()\n\t\treturn probe.prove(input)\n\t}\n\n\t// Returns the admitted-call probe, constructing it only after validation. Store the construction\n\t// before it starts so a callback that enters `destroy` while `new Probe` is still returning joins\n\t// that construction and releases its result. A refused constructor clears the stored promise, so\n\t// a later admitted call retries instead of retaining the refusal.\n\tasync #resolveProbe(): Promise<ProbeInterface> {\n\t\tif (this.#closing !== undefined) throw createDestroyedError('probe server')\n\t\tconst current = this.#construction\n\t\tif (current !== undefined) return await current\n\t\tconst construction = Promise.resolve().then(() => new Probe(this.#options))\n\t\tthis.#construction = construction\n\t\ttry {\n\t\t\treturn await construction\n\t\t} catch (error) {\n\t\t\tif (this.#construction === construction) this.#construction = undefined\n\t\t\tthrow error\n\t\t}\n\t}\n\n\tasync #execute(context: MCPExecutionContext): Promise<ToolResult | MCPCallResult> {\n\t\tconst result = await context.tools.execute(context.call)\n\t\tif (!result.success) return result\n\t\tif (!isVerdict(result.value)) {\n\t\t\tthrow new ProbeError('The prove tool returned an invalid verdict', {\n\t\t\t\torigin: 'instrument',\n\t\t\t\tcode: 'malformed',\n\t\t\t\tcontext: { value: result.value },\n\t\t\t})\n\t\t}\n\t\tconst record = result.value\n\t\tconst limit = this.#server.limit\n\t\tconst bounds = { bytes: limit.content, keys: limit.keys, depth: limit.depth }\n\t\tconst rendered: MCPCallResult = {\n\t\t\tresultType: 'complete',\n\t\t\tcontent: [{ type: 'text', text: formatVerdict(record) }],\n\t\t}\n\t\tconst minimal: MCPCallResult = {\n\t\t\tresultType: 'complete',\n\t\t\tcontent: [{ type: 'text', text: formatReceipt(record) }],\n\t\t}\n\t\t// Three answers, widest first, each admitted by the bounds this server publishes before it is\n\t\t// returned: the record beside its rendering, the rendering alone, then the receipt block. A\n\t\t// result those bounds refuse reaches the client as a JSON-RPC internal error instead, which\n\t\t// costs the receipt as well as the record, so each arm drops what the bounds refused rather\n\t\t// than dropping the answer. `isBoundedJSON` is also what admits a `Verdict` into a field the\n\t\t// protocol types as JSON, which is why the record is read against the bounds before the pair\n\t\t// carrying it is composed. The last arm returns whether or not it is admitted: it is a\n\t\t// handful of keys and a few short lines, so bounds that refuse it belong to a server that\n\t\t// could produce no answer at all.\n\t\tconst arms: readonly MCPCallResult[] = isBoundedJSON(record, bounds)\n\t\t\t? [{ ...rendered, structuredContent: record }, rendered, minimal]\n\t\t\t: [rendered, minimal]\n\t\treturn arms.find((arm) => isBoundedJSON(arm, bounds)) ?? minimal\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,cAAc,MAAsB;CACnD,OAAO,KAAK,WAAW,MAAM,GAAG;AACjC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAgB,cAAc,OAAoC;CACjE,IAAI,CAAC,SAAS,KAAK,GAAG,OAAO,KAAA;CAC7B,MAAM,QAAQ;CACd,MAAM,UAAU,cAAe,UAAU,QAAQ,MAAM,OAAO,KAAA,CAAU;CACxE,IAAI,CAAC,QAAQ,SAAS,OAAO,KAAA;CAC7B,OAAO,SAAS,QAAQ,KAAK,IAAI,QAAQ,QAAQ,KAAA;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,YAAY,MAAc,QAAyB;CAClE,MAAM,OAAO,SAAS,QAAQ,IAAI,GAAG,QAAQ,MAAM,MAAM,CAAC;CAC1D,OAAO,SAAS,QAAQ,KAAK,W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