@orkestrel/probe 0.0.2 → 0.0.3

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.cjs","names":["#revision","#candidates","#workspace","#deadline","#warmth","#responses","#failures","#documents","#publishes","#refusals","#warm","#progress","#destroyed","#document","#closing","#destroy","#warmed","#fail","#ending","#release","#expiry","#child","#retire","#request","#notify","#read","#exit","#close","#sequence","#fault","#describe","#reachable","#send","#buffer","#frame","#receive","#issues","#workspace","#modules","#revisions","#vitest","#warm","#progress","#destroyed","#runner","#project","#overlay","#revalidate","#specification","#specifications","#issues","#evict","#closing","#destroy","#sweep","#configure","#augment","#wrap","#instrument","#resolve","#load","#replace","#snapshot","#invalidate","#walk","#alive","#owned","#real","#issue","#workspace","#typescript","#services","#resident","#options","#files","#diagnostics","#warm","#progress","#destroyed","#configure","#service","#overlay","#record","#issues","#unblock","#closing","#destroy","#recycled","#projects","#translate","#version","#snapshot","#recycle","#issue","#workspace","#deadline","#emitter","#toolchain","#typeQueue","#lintQueue","#runtimeQueue","#version","#type","#lint","#runtime","#inspectStage","#arming","#arm","#support","#ready","#destroyed","#inspect","#closing","#destroy","#workbench","#boot","#expiry","#recycle","#probe","#stream","#transport","#data","#close","#error","#signal","#publish","#receive","#finish","#fail","#release","#closing","#owns","#destroy"],"sources":["../../../src/server/helpers.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 { ListenerCapture, WorkspaceManifest } from './types.js'\nimport type { EventEmitter } from 'node:events'\nimport type * as TypeScript from 'typescript'\nimport type * as VitestNode from 'vitest/node'\nimport { lstatSync, readFileSync, realpathSync, statSync } from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { createRequire } from 'node:module'\nimport { dirname, extname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport { attempt, compileGuard, isArray, isRecord } from '@orkestrel/contract'\nimport { CLAIM_SHAPE, ProbeError, isDraft } 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 * 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 === '' || path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path)) {\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 error = outcome.error\n\t\t\t\tif (\n\t\t\t\t\ttypeof error === 'object' &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t'code' in error &&\n\t\t\t\t\t(error.code === 'ENOENT' || error.code === 'ENOTDIR')\n\t\t\t\t) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tthrow 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\tconst remainder = relative(canonical, resolved)\n\t\t\tif (remainder === '..' || remainder.startsWith(`..${sep}`) || isAbsolute(remainder)) {\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 (error instanceof ProbeError) throw error\n\t\tconst claimant =\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\t'code' in error &&\n\t\t\t(error.code === 'ENAMETOOLONG' || error.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 * 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 when the fault means the host refuses this name; false otherwise\n *\n * @example\n * ```ts\n * try {\n * \twriteFileSync('tmp/probe/greeting\\0.test.ts', '')\n * } catch (error) {\n * \tisRefusedName('tmp/probe/greeting\\0.test.ts', error) // true\n * }\n * isRefusedName('tmp/probe/greeting.test.ts', new Error('the runtime stage was destroyed')) // false\n * ```\n */\nexport function isRefusedName(file: string, error: unknown): boolean {\n\tif (typeof error !== 'object' || error === null) return false\n\tconst fault = error\n\tconst reading = attempt(() => ('code' in fault ? fault.code : undefined))\n\tif (!reading.success) return false\n\tconst code = reading.value\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 * 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 =\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t'code' in error &&\n\t\terror.code === '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 one installed tool module from a target workspace.\n *\n * @param workspace - The target workspace root\n * @param specifier - The module specifier to load\n * @returns The installed module\n * @throws When the workspace cannot load the module\n *\n * @example\n * ```ts\n * const typescript = loadWorkspaceModule(process.cwd(), 'typescript')\n * console.log(typescript.version)\n * ```\n */\nexport function loadWorkspaceModule(workspace: string, specifier: 'typescript'): typeof TypeScript\nexport function loadWorkspaceModule(workspace: string, specifier: 'vitest/node'): typeof VitestNode\nexport function loadWorkspaceModule(\n\tworkspace: string,\n\tspecifier: 'typescript' | 'vitest/node',\n): typeof TypeScript | typeof VitestNode {\n\tconst outcome = attempt(() => {\n\t\tconst require = createRequire(resolve(workspace, 'package.json'))\n\t\treturn specifier === 'typescript' ? require('typescript') : require('vitest/node')\n\t})\n\tif (outcome.success) return outcome.value\n\tconst error = outcome.error\n\tconst missing =\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t'code' in error &&\n\t\terror.code === 'MODULE_NOT_FOUND'\n\tthrow new ProbeError(`The workspace cannot load ${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 * 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 (!(error instanceof ProbeError)) 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 missing =\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\t'code' in error &&\n\t\t\t(error.code === 'ENOENT' || error.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 * @param workspace - The target workspace root\n * @param name - The installed package name and binary key\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 name\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(process.cwd(), resolveWorkspaceBinary(process.cwd(), 'oxlint'))\n * // 'node_modules/oxlint/bin/oxlint'\n * resolveWorkspaceBinary(process.cwd(), 'typescript')\n * // throws: typescript does not publish the typescript binary\n * ```\n */\nexport function resolveWorkspaceBinary(workspace: string, name: string): 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 (typeof bin === 'string') return resolve(manifest.path, '..', bin)\n\tif (!isRecord(bin) || !(name in bin)) {\n\t\tthrow new ProbeError(`${name} does not publish the ${name} 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[name]\n\tif (typeof entry !== 'string') {\n\t\tthrow new ProbeError(`${name} publishes an invalid ${name} 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/probe/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 === 'probe') 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 * Creates a fresh sibling identity while preserving a test's resolution 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 An absolute sibling file path\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(\n * \t'/srv/checkout',\n * \tcreateRevisionFile('/srv/checkout', 'tmp/probe/greeting.test.ts', '4821-9f0c'),\n * )\n * // 'tmp/probe/greeting.test.probe-4821-9f0c.ts'\n * ```\n */\nexport function createRevisionFile(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 * Reports whether a path is a workspace module Vitest can cache.\n *\n * @param path - The candidate file path\n * @returns True for script, TypeScript, Vue, and JSON modules; 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 * Reads a JSON-RPC frame's declared byte length.\n *\n * @param header - The frame header text without its terminating empty line\n * @returns The non-negative content length, or `undefined` for an invalid header\n *\n * @example\n * ```ts\n * parseContentLength('Content-Length: 128') // 128\n * parseContentLength('Content-Type: application/json') // undefined\n * ```\n */\nexport function parseContentLength(header: string): number | undefined {\n\tconst match = /(?:^|\\r\\n)Content-Length:\\s*(\\d+)(?:\\r\\n|$)/i.exec(header)\n\tconst text = match?.[1]\n\tif (text === undefined) return undefined\n\tconst length = Number.parseInt(text, 10)\n\treturn Number.isSafeInteger(length) && length >= 0 ? length : undefined\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 (value instanceof Error) return value.message\n\tif (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'message' in value &&\n\t\ttypeof value.message === 'string'\n\t) {\n\t\treturn value.message\n\t}\n\treturn String(value)\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/probe/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 * A parsed TypeScript project carries the absolute root it was parsed at, so the same commit\n * checked out at two paths produces two values that describe one configuration. Rewriting those\n * members makes the value portable and stops a host path leaking into anything derived from it. A\n * path that escapes the workspace is left as it stands, because rewriting it would name a file\n * outside the tree by a relative spelling. Key order is the parser's, not the configuration's, so\n * 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 (typeof value === 'string') {\n\t\tif (!isAbsolute(value)) return value\n\t\tconst path = relative(root, resolve(value))\n\t\tif (path === '') return '.'\n\t\tif (path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path)) 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 { OverlayInterface } from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport { normalizePath } from './helpers.js'\n\n/**\n * Holds the candidate drafts one inspection substitutes for the files a tool would read from disk.\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 * @example\n * ```ts\n * const overlay = new Overlay()\n * overlay.set('/srv/checkout/src/core/greeting.ts', \"export const GREETING = 'hi'\\n\")\n * console.log(overlay.text('/srv/checkout/src/core/greeting.ts'))\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 * @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.2\",\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: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:guides\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project guides\",\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.13\",\n\t\t\"@orkestrel/emitter\": \"^0.0.7\",\n\t\t\"@orkestrel/mcp\": \"^0.0.20\",\n\t\t\"@orkestrel/queue\": \"^0.0.9\",\n\t\t\"@orkestrel/timeout\": \"^0.0.7\",\n\t\t\"@orkestrel/tool\": \"^0.0.11\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@microsoft/api-extractor\": \"^7.58.13\",\n\t\t\"@orkestrel/guide\": \"^0.0.12\",\n\t\t\"@orkestrel/scaffold\": \"^0.0.46\",\n\t\t\"@orkestrel/test\": \"^0.0.8\",\n\t\t\"@types/node\": \"^26.2.0\",\n\t\t\"oxfmt\": \"^0.64.0\",\n\t\t\"oxlint\": \"^1.79.0\",\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vite\": \"~8.2.2\",\n\t\t\"vite-plugin-dts\": \"^5.0.3\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"oxlint\": \"^1.77.0\",\n\t\t\"typescript\": \"^6.0.0\",\n\t\t\"vitest\": \"^4.1.0\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"oxlint\": {\n\t\t\t\"optional\": true\n\t\t},\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 { StageInterface } from '../types.js'\nimport type { ChildProcessWithoutNullStreams } from 'node:child_process'\nimport type { TimeoutInterface } from '@orkestrel/timeout'\nimport { spawn } from 'node:child_process'\nimport { pathToFileURL } from 'node:url'\nimport { createTimeout } from '@orkestrel/timeout'\nimport { ProbeError, createDestroyedError } from '@src/core'\nimport {\n\tdescribeUnknown,\n\tinferDocumentLanguage,\n\tnormalizePath,\n\tparseContentLength,\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\n * mode. Each inspection opens the supplied text by URI, waits for published diagnostics, and\n * closes the document without writing it to disk.\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\n * `destroy` bounds each exchange and takes the ending back with a signal when the bound 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)\n * await stage.destroy()\n * ```\n */\nexport class LintStage implements StageInterface {\n\treadonly #workspace: string\n\t// The bound on every exchange teardown has with the language server, warming included. The\n\t// protocol leaves both the warming answer and the ending to the server, so each one is a wait\n\t// this stage takes back rather than a wait it can rely on.\n\treadonly #deadline = 2_000\n\treadonly #warmth: Promise<ChildProcessWithoutNullStreams>\n\treadonly #responses = new Map<number, (value: unknown) => void>()\n\treadonly #failures = new Map<number, (error: Error) => void>()\n\treadonly #documents = new Map<string, string>()\n\treadonly #publishes = new Map<string, (issues: readonly Issue[]) => void>()\n\treadonly #refusals = new Map<string, (error: Error) => void>()\n\t#child: ChildProcessWithoutNullStreams | undefined\n\t#buffer = Buffer.alloc(0)\n\t#sequence = 0\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t#destroyed = false\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\tasync inspect(subject: Case): Promise<Check> {\n\t\tif (this.#destroyed) throw createDestroyedError('lint stage')\n\t\tconst started = performance.now()\n\t\tawait this.#warmth\n\t\tif (this.#destroyed) 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(draft)))\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\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#destroyed = true\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\t// A server that failed to warm still leaves a child to release, so read the spawned child\n\t\t// rather than the warming result.\n\t\tconst child = await this.#warmed()\n\t\t// Abandon every document in flight rather than waiting for it: a server that never publishes\n\t\t// its diagnostics would otherwise hold teardown open for the life of the process.\n\t\tthis.#fail(createDestroyedError('lint stage'))\n\t\tif (child === undefined || this.#ending !== undefined) return\n\t\tconst released = new Promise<void>((resolve) => {\n\t\t\tchild.once('exit', () => resolve())\n\t\t\tchild.once('close', () => resolve())\n\t\t})\n\t\tawait this.#release(child, released)\n\t}\n\n\t// Reads the warmed language server, or the spawned child when warming failed or outran the\n\t// deadline. Warming waits for the `initialize` response, and the protocol leaves that answer to\n\t// the server: one that accepts the connection and answers nothing has broken no rule, and\n\t// waiting on it holds teardown open for the life of the host. Teardown needs the child rather\n\t// than the warming result, and `#warm` has the child before it sends anything, so the bound\n\t// costs the answer and nothing else. The abandoned warming promise keeps its constructor's\n\t// observer, so nothing rejects into the host.\n\tasync #warmed(): Promise<ChildProcessWithoutNullStreams | undefined> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\treturn await Promise.race([this.#warmth, this.#expiry(timeout)])\n\t\t} catch {\n\t\t\treturn this.#child\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t}\n\n\t// Ends the conversation under a deadline and signals the child when that deadline passes. The\n\t// protocol leaves the ending to the server: a server that answers `shutdown` and then ignores\n\t// `exit` has broken no rule, and one that answers neither is unreachable rather than dead. Both\n\t// leave teardown waiting for the life of the host and leak the child with it, so this bounds\n\t// the whole exchange at two seconds and then takes the ending back. `SIGKILL` cannot be\n\t// handled, so the child ends and its own `exit` event settles the wait.\n\tasync #release(child: ChildProcessWithoutNullStreams, released: Promise<void>): Promise<void> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\tawait Promise.race([this.#retire(child).then(() => released), this.#expiry(timeout)])\n\t\t} catch {\n\t\t\tchild.kill('SIGKILL')\n\t\t\tawait released\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t}\n\n\t// Asks the language server to shut down and signals it when that conversation fails. A server\n\t// that died mid-teardown, or that never answers, still has to release its resources, and\n\t// teardown must not wait on a reply a dead pipe swallowed.\n\tasync #retire(child: ChildProcessWithoutNullStreams): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#request('shutdown', undefined)\n\t\t\tthis.#notify('exit', undefined)\n\t\t} catch {\n\t\t\tchild.kill('SIGKILL')\n\t\t}\n\t}\n\n\t// Rejects when the teardown deadline fires, so a race against it settles even when the server\n\t// it waits on answers nothing.\n\t#expiry(timeout: TimeoutInterface): 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\treject(\n\t\t\t\t\t\tnew ProbeError(`The Oxlint language server did not exit within ${timeout.ms} ms`, {\n\t\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\t\tcode: 'deadline',\n\t\t\t\t\t\t\tcontext: { stage: this.stage, deadline: timeout.ms },\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t{ once: true },\n\t\t\t)\n\t\t})\n\t}\n\n\tasync #warm(): Promise<ChildProcessWithoutNullStreams> {\n\t\tconst binary = resolveWorkspaceBinary(this.#workspace, 'oxlint')\n\t\tconst child = spawn(process.execPath, [binary, '--lsp'], {\n\t\t\tcwd: this.#workspace,\n\t\t\tstdio: 'pipe',\n\t\t})\n\t\tthis.#child = child\n\t\tchild.stderr.resume()\n\t\tchild.stdout.on('data', (chunk: Buffer) => this.#read(chunk))\n\t\t// A write racing the server's death reports `EPIPE` on this stream rather than throwing, and\n\t\t// an unobserved stream error ends the resident host. Report it as a stage fault so the\n\t\t// inspection that raced the death is refused rather than left waiting for a reply the pipe\n\t\t// swallowed.\n\t\tchild.stdin.on('error', (error) => this.#fail(error))\n\t\tchild.on('error', (error) => this.#fail(error))\n\t\tchild.on('exit', (code, signal) => this.#exit(code, signal))\n\t\tawait this.#request('initialize', {\n\t\t\tprocessId: process.pid,\n\t\t\trootUri: pathToFileURL(this.#workspace).href,\n\t\t\tcapabilities: {},\n\t\t\tworkspaceFolders: [\n\t\t\t\t{\n\t\t\t\t\turi: pathToFileURL(this.#workspace).href,\n\t\t\t\t\tname: 'workspace',\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t\tthis.#notify('initialized', {})\n\t\treturn child\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 and one publication, so a caller driving two inspections of one path\n\t// at once is refused rather than served an answer belonging to the other.\n\t#document(draft: Draft): Promise<readonly Issue[]> {\n\t\tconst uri = pathToFileURL(resolveWorkspaceFile(this.#workspace, draft.path)).href\n\t\tif (this.#publishes.has(uri)) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew ProbeError(`The lint stage is already inspecting ${draft.path}`, {\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { stage: this.stage, path: draft.path },\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tconst diagnostics = new Promise<readonly Issue[]>((resolve, reject) => {\n\t\t\tthis.#documents.set(uri, normalizePath(draft.path))\n\t\t\tthis.#publishes.set(uri, resolve)\n\t\t\tthis.#refusals.set(uri, reject)\n\t\t})\n\t\t// Attach the cleanup before opening the document. An open that throws would otherwise leave\n\t\t// this promise pending with no handler, and the next failure rejects it into the host.\n\t\tconst inspected = diagnostics.finally(() => this.#close(uri))\n\t\ttry {\n\t\t\tthis.#notify('textDocument/didOpen', {\n\t\t\t\ttextDocument: {\n\t\t\t\t\turi,\n\t\t\t\t\tlanguageId: inferDocumentLanguage(draft.path),\n\t\t\t\t\tversion: this.#sequence,\n\t\t\t\t\ttext: draft.text,\n\t\t\t\t},\n\t\t\t})\n\t\t\tthis.#progress += 1\n\t\t} catch (error) {\n\t\t\tthis.#refusals.get(uri)?.(this.#fault(describeUnknown(error), error, draft.path))\n\t\t}\n\t\treturn inspected\n\t}\n\n\t// How the language server ended, or `undefined` while it runs. Node records a signal death on\n\t// `signalCode`, an exit on `exitCode`, and a child that never spawned on `exitCode` too, and it\n\t// sets each one before the event that announces it. Reading the child covers every ending,\n\t// including the spawn failure, which reports `error` and `close` and never `exit`.\n\tget #ending(): string | undefined {\n\t\tconst child = this.#child\n\t\tif (child === undefined) return undefined\n\t\tif (child.exitCode === null && child.signalCode === null) return undefined\n\t\treturn this.#describe(child.exitCode, child.signalCode)\n\t}\n\n\t// Names one ending for a message. Node announces an exit with exactly one non-null argument.\n\t#describe(code: number | null, signal: NodeJS.Signals | null): string {\n\t\treturn signal === null ? `code ${code}` : `signal ${signal}`\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// Whether the language server can still receive a message. A server that ended, and one that\n\t// closed its input while its process lives, both take no further writes.\n\tget #reachable(): boolean {\n\t\treturn this.#ending === undefined && this.#child?.stdin.writable === true\n\t}\n\n\t// Releases one document. The deletes run before the notification because an unreachable server\n\t// refuses the write, and a throw here would replace the diagnosis the caller is receiving and\n\t// leave this document registered for the life of the stage.\n\t#close(uri: string): void {\n\t\tthis.#documents.delete(uri)\n\t\tthis.#publishes.delete(uri)\n\t\tthis.#refusals.delete(uri)\n\t\tif (this.#destroyed || !this.#reachable) return\n\t\tthis.#notify('textDocument/didClose', { textDocument: { uri } })\n\t}\n\n\t#request(method: string, params: unknown): Promise<unknown> {\n\t\tthis.#sequence += 1\n\t\tconst id = this.#sequence\n\t\tconst response = new Promise<unknown>((resolve, reject) => {\n\t\t\tthis.#responses.set(id, resolve)\n\t\t\tthis.#failures.set(id, reject)\n\t\t})\n\t\ttry {\n\t\t\tthis.#send({ jsonrpc: '2.0', id, method, params })\n\t\t} catch (error) {\n\t\t\t// Forget the request before refusing it. A request the stage never sent has no reply to\n\t\t\t// wait for, and leaving its entry behind holds this promise for the life of the stage.\n\t\t\tconst reject = this.#failures.get(id)\n\t\t\tthis.#responses.delete(id)\n\t\t\tthis.#failures.delete(id)\n\t\t\treject?.(this.#fault(describeUnknown(error), error))\n\t\t}\n\t\treturn response\n\t}\n\n\t#notify(method: string, params: unknown): void {\n\t\tthis.#sequence += 1\n\t\tthis.#send({ jsonrpc: '2.0', method, params })\n\t}\n\n\t#send(message: unknown): void {\n\t\tconst child = this.#child\n\t\tif (this.#ending !== undefined) {\n\t\t\tthrow this.#fault(`The Oxlint language server exited with ${this.#ending}`)\n\t\t}\n\t\tif (child === undefined) throw this.#fault('The Oxlint language server is not running')\n\t\t// A server that closed its input is unreachable while its process still lives, so a write\n\t\t// here would neither fail nor ever be answered.\n\t\tif (!child.stdin.writable) throw this.#fault('The Oxlint language server closed its input')\n\t\tconst content = JSON.stringify(message)\n\t\tconst header = `Content-Length: ${Buffer.byteLength(content)}\\r\\n\\r\\n`\n\t\tchild.stdin.write(header + content)\n\t}\n\n\t#read(chunk: Buffer): void {\n\t\tthis.#buffer = Buffer.concat([this.#buffer, chunk])\n\t\twhile (this.#frame()) {}\n\t}\n\n\t#frame(): boolean {\n\t\tconst boundary = this.#buffer.indexOf('\\r\\n\\r\\n')\n\t\tif (boundary < 0) return false\n\t\tconst header = this.#buffer.subarray(0, boundary).toString('ascii')\n\t\tconst length = parseContentLength(header)\n\t\tif (length === undefined) {\n\t\t\tthis.#fail(this.#fault('Oxlint sent an invalid JSON-RPC frame header'))\n\t\t\treturn false\n\t\t}\n\t\tconst start = boundary + 4\n\t\tconst end = start + length\n\t\tif (this.#buffer.length < end) return false\n\t\tconst content = this.#buffer.subarray(start, end).toString('utf8')\n\t\tthis.#buffer = this.#buffer.subarray(end)\n\t\ttry {\n\t\t\tconst message: unknown = JSON.parse(content)\n\t\t\tthis.#receive(message)\n\t\t} catch (error) {\n\t\t\tthis.#fail(this.#fault(`Oxlint sent invalid JSON: ${describeUnknown(error)}`, error))\n\t\t}\n\t\treturn true\n\t}\n\n\t#receive(message: unknown): void {\n\t\tif (typeof message !== 'object' || message === null) return\n\t\tif ('id' in message && typeof message.id === 'number') {\n\t\t\tconst id = message.id\n\t\t\tconst resolve = this.#responses.get(id)\n\t\t\tconst reject = this.#failures.get(id)\n\t\t\tthis.#responses.delete(id)\n\t\t\tthis.#failures.delete(id)\n\t\t\tif ('error' in message && message.error !== undefined) {\n\t\t\t\treject?.(this.#fault(describeUnknown(message.error)))\n\t\t\t} else {\n\t\t\t\tresolve?.('result' in message ? message.result : undefined)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif (!('method' in message) || message.method !== 'textDocument/publishDiagnostics') return\n\t\tif (!('params' in message) || typeof message.params !== 'object' || message.params === null) {\n\t\t\treturn\n\t\t}\n\t\tconst params = message.params\n\t\tif (!('uri' in params) || typeof params.uri !== 'string') return\n\t\tif (!('diagnostics' in params) || !Array.isArray(params.diagnostics)) return\n\t\tconst publish = this.#publishes.get(params.uri)\n\t\tif (publish === undefined) return\n\t\tpublish(this.#issues(params.uri, params.diagnostics))\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.\n\t#issues(uri: string, diagnostics: readonly unknown[]): readonly Issue[] {\n\t\tconst path = this.#documents.get(uri)\n\t\tif (path === undefined) return []\n\t\tconst issues: Issue[] = []\n\t\tfor (const diagnostic of diagnostics) {\n\t\t\tif (typeof diagnostic !== 'object' || diagnostic === null) continue\n\t\t\tif (!('message' in diagnostic) || typeof diagnostic.message !== 'string') continue\n\t\t\tif (\n\t\t\t\t!('range' in diagnostic) ||\n\t\t\t\ttypeof diagnostic.range !== 'object' ||\n\t\t\t\tdiagnostic.range === null\n\t\t\t) {\n\t\t\t\tissues.push({ origin: 'claimant', path, message: diagnostic.message })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst range = diagnostic.range\n\t\t\tif (!('start' in range) || typeof range.start !== 'object' || range.start === null) {\n\t\t\t\tissues.push({ origin: 'claimant', path, message: diagnostic.message })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst start = range.start\n\t\t\tif (!('line' in start) || typeof start.line !== 'number') {\n\t\t\t\tissues.push({ origin: 'claimant', path, message: diagnostic.message })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tissues.push({\n\t\t\t\torigin: 'claimant',\n\t\t\t\tpath,\n\t\t\t\tmessage: diagnostic.message,\n\t\t\t\tline: start.line + 1,\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\t#fail(error: Error): void {\n\t\tfor (const reject of this.#failures.values()) reject(error)\n\t\tfor (const reject of this.#refusals.values()) reject(error)\n\t\tthis.#responses.clear()\n\t\tthis.#failures.clear()\n\t\tthis.#publishes.clear()\n\t\tthis.#refusals.clear()\n\t}\n\n\t// Settles everything the ended server can no longer answer. A teardown in flight is registered\n\t// here too: its own `shutdown` request is the last thing outstanding, and a server that exits\n\t// without replying leaves teardown waiting on it unless this refuses it.\n\t#exit(code: number | null, signal: NodeJS.Signals | null): void {\n\t\tthis.#fail(\n\t\t\tthis.#fault(`The Oxlint language server exited with ${this.#describe(code, signal)}`),\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 type { Dirent } from 'node:fs'\nimport {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\tunlinkSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport { fileURLToPath } from 'node:url'\nimport { attempt } from '@orkestrel/contract'\nimport {\n\tProbeError,\n\tcreateDestroyedError,\n\tformatSpecification,\n\tmatchesSpecification,\n} from '@src/core'\nimport {\n\tcaptureListeners,\n\tcreateRevisionFile,\n\tdescribeUnknown,\n\tinferTestProject,\n\tisRefusedName,\n\tloadWorkspaceModule,\n\tmatchesWorkspaceModule,\n\tnormalizePath,\n\treleaseListeners,\n\trelativeWorkspaceFile,\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 *\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 * The write path's physical-containment guarantee covers the claim inputs and the target tree as\n * inspected. A concurrent process that mutates a path component between the final inspection and\n * the write is outside that guarantee.\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>\n\t#overlay: OverlayInterface = new Overlay()\n\treadonly #modules = new Map<string, string>()\n\treadonly #revisions = new Set<string>()\n\t#specifications = 0\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t#destroyed = false\n\n\t/**\n\t * Starts warming the target workspace's Vitest service.\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\tconst vitest = loadWorkspaceModule(this.#workspace, 'vitest/node')\n\t\tthis.#vitest = this.#warm(vitest.createVitest)\n\t\t// Observe the stored promise here. A stage the coordinator builds to replace a hung one may\n\t\t// never be inspected or destroyed, and an unobserved rejection ends the host process. The\n\t\t// stored promise keeps rejecting, so an inspection still reports the warming failure.\n\t\tvoid this.#vitest.catch(() => {})\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\tasync inspect(subject: Case): Promise<Check> {\n\t\tif (this.#destroyed) 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.#destroyed) 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\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 (typeof specification !== 'string') {\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 = this.#issues(result, file, subject.test.path)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof ProbeError) 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\terror instanceof ProbeError && error.origin === 'workspace'\n\t\t\t\t\t\t\t\t\t? 'workspace'\n\t\t\t\t\t\t\t\t\t: '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\toverlay.clear()\n\t\t}\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#destroyed = true\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\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 its constructor already surfaced.\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.#overlay.clear()\n\t\t}\n\t}\n\n\tasync #warm(create: typeof createVitest): Promise<Vitest> {\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\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\treturn create(\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} finally {\n\t\t\treleaseListeners(process, signals)\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 (typeof project === 'string') 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: 'orkestrel-runtime-overlay',\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.lastIndexOf('?')\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.#load(resolved) !== undefined) return resolved\n\t\t}\n\t\treturn undefined\n\t}\n\n\t#load(id: string): string | undefined {\n\t\tconst text = this.#overlay.text(id)\n\t\tif (text !== undefined) return text\n\t\tconst separator = id.lastIndexOf('?')\n\t\tif (separator === -1) return undefined\n\t\tconst query = id.slice(separator + 1)\n\t\tif (\n\t\t\t!query.startsWith('v=') ||\n\t\t\tquery.length === 2 ||\n\t\t\tquery.includes('&') ||\n\t\t\tquery.includes('#') ||\n\t\t\tquery.slice(2).includes('?')\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.#overlay.text(id.slice(0, separator))\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 = createRevisionFile(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 (outcome.error instanceof ProbeError && 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(outcome.error instanceof ProbeError && 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 (\n\t\t\t!project.vite.config.plugins.some((plugin) => plugin.name === 'orkestrel-runtime-overlay')\n\t\t) {\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\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. A 64-specification\n\t\t// lifetime bounds that internal map without giving up the resident runner on each call.\n\t\tif (this.#specifications < 64) return this.#vitest\n\t\tthis.#specifications = 0\n\t\tthis.#vitest = this.#replace(this.#vitest)\n\t\tvoid this.#vitest.catch(() => {})\n\t\treturn this.#vitest\n\t}\n\n\tasync #replace(current: Promise<Vitest>): Promise<Vitest> {\n\t\tconst vitest = await current\n\t\tawait vitest.close()\n\t\tif (this.#destroyed) throw createDestroyedError('runtime stage')\n\t\tconst runner = loadWorkspaceModule(this.#workspace, 'vitest/node')\n\t\treturn this.#warm(runner.createVitest)\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. `#walk` builds each path with `join` and the overlay holds paths\n\t// `resolve` produced, so on a host whose separator is a backslash the native spelling matches no\n\t// key, the invalidation is dropped without an error, and the resident runner serves the previous\n\t// module. Read the host separator rather than the platform name, and rewrite only where it is a\n\t// backslash: a backslash is a legal filename character on a host whose separator is a forward\n\t// 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 this.#walk()) {\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 this.#walk()) {\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 (this.#alive(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// Whether the host that wrote one specification is still running. Signal 0 delivers nothing and\n\t// reports reachability alone. A host this process may not signal reports `EPERM` and is read as\n\t// alive, and a non-positive identity names a process group rather than a process, so both leave\n\t// the file where it is: the safe direction is to keep a file this stage cannot account for.\n\t#alive(id: number): boolean {\n\t\tif (!Number.isSafeInteger(id) || id <= 0) return true\n\t\ttry {\n\t\t\tprocess.kill(id, 0)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\treturn error instanceof Error && 'code' in error && error.code === 'EPERM'\n\t\t}\n\t}\n\n\t// Yields every file the target workspace holds, skipping the trees no inspection reads: version\n\t// control, build output, and installed packages. A directory this host cannot list is skipped\n\t// rather than raised: the walk runs at construction and before every inspection, and one\n\t// unreadable directory in a consumer's tree is not a reason to refuse the workspace.\n\t*#walk(): Generator<string> {\n\t\tconst directories = [resolve(this.#workspace)]\n\t\twhile (directories.length > 0) {\n\t\t\tconst directory = directories.pop()\n\t\t\tif (directory === undefined) break\n\t\t\tlet entries: readonly Dirent[] = []\n\t\t\ttry {\n\t\t\t\tentries = readdirSync(directory, { withFileTypes: true })\n\t\t\t} catch {}\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (entry.name === '.git' || entry.name === 'dist' || entry.name === 'node_modules') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst path = join(directory, entry.name)\n\t\t\t\tif (entry.isDirectory()) {\n\t\t\t\t\tdirectories.push(path)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (entry.isFile()) yield path\n\t\t\t}\n\t\t}\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.\n\t#issue(error: unknown, specification: string, original: string): Issue {\n\t\tconst message = describeUnknown(error)\n\t\tif (typeof error !== 'object' || error === null || !('stacks' in error)) {\n\t\t\treturn { origin: 'claimant', path: original, message }\n\t\t}\n\t\tconst stacks = error.stacks\n\t\tif (!Array.isArray(stacks)) return { origin: 'claimant', path: original, message }\n\t\tfor (const stack of stacks) {\n\t\t\tif (typeof stack !== 'object' || stack === null) continue\n\t\t\tif (!('file' in stack) || typeof stack.file !== 'string') 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) || typeof stack.line !== 'number') {\n\t\t\t\treturn { origin: 'claimant', path, message }\n\t\t\t}\n\t\t\treturn { origin: 'claimant', path, message, line: stack.line }\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 { OverlayInterface, TypeStageInterface } from '../types.js'\nimport type * as TypeScript from 'typescript'\nimport type {\n\tCompilerOptions,\n\tDiagnostic,\n\tDiagnosticMessageChain,\n\tIScriptSnapshot,\n\tLanguageService,\n} from 'typescript'\nimport { readdirSync, statSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { setImmediate } from 'node:timers/promises'\nimport { ProbeError, createDestroyedError } from '@src/core'\nimport {\n\tcomputeDigest,\n\tinferTypeProject,\n\tloadWorkspaceModule,\n\tnormalizePath,\n\trelativeWorkspaceFile,\n\tresolveWorkspaceFile,\n} from '../helpers.js'\nimport { Overlay } from '../Overlay.js'\n\n/**\n * Inspects TypeScript source through resident language services from the target workspace.\n *\n * @remarks\n * Construction starts loading the workspace's compiler and warming one service per project the\n * workspace declares. A candidate draft is checked against the project a call names, or\n * against its own scoped environment project when a call names none, while the test uses the root\n * project. Disk snapshots use their modification time as the service version so dependency edits\n * cannot leave a warm answer stale. Candidate text lives in an overlay the inspection owns, and\n * the language-service host answers existence, reads, and versions from it, so a candidate that\n * exists only as text is importable and a candidate that shadows a disk file is checked as the\n * text the case supplied. A project outside the declared set holds one recycled slot, so a caller\n * varying the project cannot grow the resident set. A language service checks one candidate\n * synchronously, so the stage hands the host's event loop back at each candidate boundary: a\n * caller's deadline is answered within one candidate's check rather than after the whole\n * inspection, and an inspection abandoned at that deadline stops at the next boundary.\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 #typescript: Promise<typeof TypeScript>\n\treadonly #services = new Map<string, LanguageService>()\n\treadonly #resident = new Set<string>()\n\treadonly #options = new Map<string, CompilerOptions>()\n\treadonly #files = new Map<string, readonly string[]>()\n\treadonly #diagnostics = new Map<string, readonly Diagnostic[]>()\n\t#overlay: OverlayInterface = new Overlay()\n\t#recycled: string | undefined\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t#destroyed = false\n\n\t/**\n\t * Starts warming the target workspace's TypeScript service.\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\tconst typescript = loadWorkspaceModule(this.#workspace, 'typescript')\n\t\tthis.#typescript = this.#warm(typescript)\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.#typescript.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 resident compiler cannot start or the stage has already been destroyed\n\t */\n\tasync inspect(subject: Case, project?: string): Promise<Check> {\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t\tconst started = performance.now()\n\t\tconst typescript = await this.#typescript\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\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\tconst selections = resolved.map((candidate) => ({\n\t\t\tdraft: candidate.draft,\n\t\t\tproject: project ?? inferTypeProject(relativeWorkspaceFile(this.#workspace, candidate.path)),\n\t\t}))\n\t\tthis.#configure(this.#service(typescript, 'tsconfig.json'), 'tsconfig.json')\n\t\tfor (const selection of selections) {\n\t\t\tthis.#configure(this.#service(typescript, selection.project), selection.project)\n\t\t}\n\t\t// Each inspection owns its candidate set and reads it through its own reference, so the\n\t\t// clear that follows releases what this inspection recorded and nothing else. The resident\n\t\t// services read whichever overlay is installed, so a caller admits one inspection at a\n\t\t// time the way `Probe` does.\n\t\tconst overlay = new Overlay()\n\t\tthis.#overlay = overlay\n\t\ttry {\n\t\t\tthis.#record(subject.test, overlay)\n\t\t\tfor (const draft of subject.files) this.#record(draft, overlay)\n\t\t\tthis.#progress += 1\n\t\t\tconst issues: Issue[] = []\n\t\t\tconst projects = new Set<string>()\n\t\t\tconst root = this.#service(typescript, 'tsconfig.json')\n\t\t\tissues.push(...this.#issues(typescript, root, subject.test, 'tsconfig.json', false, true))\n\t\t\tprojects.add('tsconfig.json')\n\t\t\tawait this.#unblock()\n\t\t\tfor (const selection of selections) {\n\t\t\t\tconst draft = selection.draft\n\t\t\t\tconst selected = selection.project\n\t\t\t\tconst service = this.#service(typescript, selected)\n\t\t\t\tissues.push(\n\t\t\t\t\t...this.#issues(\n\t\t\t\t\t\ttypescript,\n\t\t\t\t\t\tservice,\n\t\t\t\t\t\tdraft,\n\t\t\t\t\t\tselected,\n\t\t\t\t\t\tproject !== undefined,\n\t\t\t\t\t\t!projects.has(selected),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\tprojects.add(selected)\n\t\t\t\tawait this.#unblock()\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,\n\t\t\t}\n\t\t} finally {\n\t\t\toverlay.clear()\n\t\t}\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 parse this stage itself applies, filling its cache when the project is not already\n\t * resident, so the reported digest is the configuration the inspection is judged under rather\n\t * than a second parse a caller ran. The returned record is a value copy, so a later eviction\n\t * does not 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, cannot be parsed, or the stage has already\n\t * been destroyed\n\t */\n\tasync resolve(project: string): Promise<Project> {\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t\tconst typescript = await this.#typescript\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t\tconst resolved = resolveWorkspaceFile(this.#workspace, project)\n\t\tthis.#service(typescript, project)\n\t\treturn {\n\t\t\tpath: relativeWorkspaceFile(this.#workspace, resolved),\n\t\t\tdigest: computeDigest(this.#workspace, this.#options.get(resolved) ?? {}),\n\t\t}\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#destroyed = true\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\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. Warming is awaited because the services it\n\t\t// creates are the resources this releases.\n\t\tawait this.#typescript.catch(() => undefined)\n\t\tfor (const service of this.#services.values()) service.dispose()\n\t\tthis.#services.clear()\n\t\tthis.#resident.clear()\n\t\tthis.#recycled = undefined\n\t\tthis.#options.clear()\n\t\tthis.#files.clear()\n\t\tthis.#diagnostics.clear()\n\t}\n\n\tasync #warm(typescript: typeof TypeScript): Promise<typeof TypeScript> {\n\t\tfor (const project of this.#projects()) {\n\t\t\tthis.#resident.add(resolveWorkspaceFile(this.#workspace, project))\n\t\t\tthis.#service(typescript, project)\n\t\t}\n\t\treturn typescript\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// Hands the host's event loop back after one candidate's check, and refuses an inspection this\n\t// stage was torn down during. A language service checks a candidate synchronously, so an\n\t// inspection that never yielded held the loop for its whole duration: the coordinator's\n\t// deadline could not fire against this stage, and the lint child's frames and the runtime\n\t// worker's messages queued behind it until the last candidate finished, which reported one\n\t// stage's overrun against another. Yielding bounds that hold to one candidate. The refusal is\n\t// what stops an abandoned inspection reaching a disposed service and building a replacement\n\t// this stage would then own past its own teardown.\n\tasync #unblock(): Promise<void> {\n\t\tawait setImmediate()\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t}\n\n\t// Resolution happens here rather than in the overlay, because the workspace a candidate's\n\t// declared path is relative to is the stage's knowledge. A path that escapes the workspace\n\t// throws before the overlay records it, and the inspection's clear releases the rest.\n\t#record(draft: Draft, overlay: OverlayInterface): void {\n\t\toverlay.set(resolveWorkspaceFile(this.#workspace, draft.path), draft.text)\n\t}\n\n\t// Keyed by the resolved project file rather than by the caller's spelling of it, so\n\t// `tsconfig.json` and `./tsconfig.json` reach one resident service instead of two.\n\t#service(typescript: typeof TypeScript, project: string): LanguageService {\n\t\tconst path = resolveWorkspaceFile(this.#workspace, project)\n\t\tconst existing = this.#services.get(path)\n\t\tif (existing !== undefined) return existing\n\t\t// The compiler builds a project diagnostic's own file name in the forward-slash spelling and\n\t\t// then asserts it equals the path the caller handed in. So a native path reaches this seam,\n\t\t// a malformed project makes the compiler construct that diagnostic, and the assertion fails\n\t\t// as a raw `Debug Failure` naming this host's directory layout, outside this package's\n\t\t// failure contract. Hand the compiler the forward-slash spelling, which it accepts on every\n\t\t// host, and it returns the diagnostic instead. Every cache here stays keyed by the native\n\t\t// `path`, so nothing this stage stores or reports moves with it.\n\t\tconst spelling = normalizePath(path)\n\t\tconst config = typescript.readConfigFile(spelling, typescript.sys.readFile)\n\t\tif (config.error !== undefined) {\n\t\t\tthrow new ProbeError(this.#translate(typescript, config.error.messageText, path), {\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\tconst parsed = typescript.parseJsonConfigFileContent(\n\t\t\tconfig.config,\n\t\t\ttypescript.sys,\n\t\t\tdirname(spelling),\n\t\t\tundefined,\n\t\t\tspelling,\n\t\t)\n\t\tif (parsed.errors.length > 0) {\n\t\t\tthrow new ProbeError(this.#translate(typescript, parsed.errors[0]?.messageText, path), {\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\tthis.#options.set(path, parsed.options)\n\t\tthis.#files.set(path, parsed.fileNames)\n\t\tconst service = typescript.createLanguageService({\n\t\t\tgetCompilationSettings: () => this.#options.get(path) ?? {},\n\t\t\tgetScriptFileNames: () => [...(this.#files.get(path) ?? []), ...this.#overlay.paths],\n\t\t\tgetScriptVersion: (file) => this.#version(file),\n\t\t\tgetScriptSnapshot: (file) => this.#snapshot(typescript, file),\n\t\t\tgetCurrentDirectory: () => this.#workspace,\n\t\t\tgetDefaultLibFileName: (options) => typescript.getDefaultLibFilePath(options),\n\t\t\tfileExists: (file) =>\n\t\t\t\tthis.#overlay.text(file) !== undefined || typescript.sys.fileExists(file),\n\t\t\treadFile: (file) => this.#overlay.text(file) ?? typescript.sys.readFile(file),\n\t\t\t// Listings stay on disk. A candidate that entered one would reach the file set this\n\t\t\t// stage caches per project at service creation, and outlive the inspection that\n\t\t\t// declared it, so glob and directory-discovery imports fail closed.\n\t\t\treadDirectory: typescript.sys.readDirectory,\n\t\t\tdirectoryExists: (directory) =>\n\t\t\t\ttypescript.sys.directoryExists(directory) || this.#overlay.covers(directory),\n\t\t\tgetDirectories: typescript.sys.getDirectories,\n\t\t\tuseCaseSensitiveFileNames: () => typescript.sys.useCaseSensitiveFileNames,\n\t\t\tgetNewLine: () => typescript.sys.newLine,\n\t\t})\n\t\tthis.#services.set(path, service)\n\t\tif (!this.#resident.has(path)) this.#recycle(path)\n\t\treturn service\n\t}\n\n\t// Renders one project diagnostic in the terms this package reports a path in. The compiler names\n\t// the project by the absolute path this stage handed it, and it spells that path either way: the\n\t// native spelling where it echoes what it was given, the forward-slash spelling where it derived\n\t// the path itself. So a caller reads whichever spelling the diagnostic happened to take, and on a\n\t// host whose separator is a backslash that is this host's own directory layout rather than the\n\t// project the caller named. Normalizing the message first makes one replacement cover both\n\t// spellings, and the caller reads the workspace-relative project it asked for.\n\t#translate(\n\t\ttypescript: typeof TypeScript,\n\t\tmessage: string | DiagnosticMessageChain | undefined,\n\t\tpath: string,\n\t): string {\n\t\treturn normalizePath(typescript.flattenDiagnosticMessageText(message, '\\n')).replaceAll(\n\t\t\tnormalizePath(path),\n\t\t\trelativeWorkspaceFile(this.#workspace, path),\n\t\t)\n\t}\n\n\t#configure(service: LanguageService, project: string): void {\n\t\tconst path = resolveWorkspaceFile(this.#workspace, project)\n\t\tif (this.#diagnostics.has(path)) return\n\t\tthis.#diagnostics.set(path, service.getCompilerOptionsDiagnostics())\n\t}\n\n\t// Holds one caller-named project beside the resident set warming created. `project` arrives\n\t// from the wire validated only as a non-empty string, so keeping a language service per\n\t// distinct string would let a caller grow this stage without bound for the life of the process.\n\t#recycle(path: string): void {\n\t\tconst previous = this.#recycled\n\t\tthis.#recycled = path\n\t\tif (previous === undefined || previous === path) return\n\t\tthis.#services.get(previous)?.dispose()\n\t\tthis.#services.delete(previous)\n\t\tthis.#options.delete(previous)\n\t\tthis.#files.delete(previous)\n\t\tthis.#diagnostics.delete(previous)\n\t}\n\n\t#version(file: string): string {\n\t\tif (this.#overlay.text(file) !== undefined) return `virtual:${this.#overlay.revision}`\n\t\ttry {\n\t\t\treturn `disk:${statSync(file).mtimeMs}`\n\t\t} catch {\n\t\t\treturn 'missing'\n\t\t}\n\t}\n\n\t#snapshot(typescript: typeof TypeScript, file: string): IScriptSnapshot | undefined {\n\t\tconst text = this.#overlay.text(file) ?? typescript.sys.readFile(file)\n\t\treturn text === undefined ? undefined : typescript.ScriptSnapshot.fromString(text)\n\t}\n\n\t#issues(\n\t\ttypescript: typeof TypeScript,\n\t\tservice: LanguageService,\n\t\tdraft: Draft,\n\t\tproject: string,\n\t\tselected: boolean,\n\t\tconfigure: boolean,\n\t): readonly Issue[] {\n\t\tconst path = resolveWorkspaceFile(this.#workspace, draft.path)\n\t\tconst configuration = resolveWorkspaceFile(this.#workspace, project)\n\t\tconst diagnostics = [\n\t\t\t...(configure ? (this.#diagnostics.get(configuration) ?? []) : []),\n\t\t\t...service.getSyntacticDiagnostics(path),\n\t\t\t...service.getSemanticDiagnostics(path),\n\t\t]\n\t\treturn diagnostics.map((diagnostic) => this.#issue(typescript, diagnostic, project, selected))\n\t}\n\n\t#issue(\n\t\ttypescript: typeof TypeScript,\n\t\tdiagnostic: Diagnostic,\n\t\tproject: string,\n\t\tselected: boolean,\n\t): Issue {\n\t\tconst message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n\t\tif (diagnostic.file === undefined) {\n\t\t\tif (selected) {\n\t\t\t\tthrow new ProbeError(message, {\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn { origin: 'instrument', path: project, message }\n\t\t}\n\t\tconst path = relativeWorkspaceFile(this.#workspace, diagnostic.file.fileName)\n\t\tif (diagnostic.start === undefined) return { origin: 'claimant', path, message }\n\t\tconst position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)\n\t\treturn { origin: 'claimant', path, message, line: position.line + 1 }\n\t}\n}\n","import type {\n\tCase,\n\tCheck,\n\tClaim,\n\tProbeEventMap,\n\tProbeInterface,\n\tProbeOptions,\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 { createQueue } from '@orkestrel/queue'\nimport { createTimeout } from '@orkestrel/timeout'\nimport {\n\tProbeError,\n\tcomputeReceipt,\n\tcreateDestroyedError,\n\tformatCheck,\n\tformatSpecification,\n} from '@src/core'\nimport { peerDependencies } from '../../package.json' with { type: 'json' }\nimport {\n\tcomputeDigest,\n\tcreateRevisionFile,\n\tdescribeUnknown,\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 resident TypeScript, Oxlint, and Vitest 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\n * ```ts\n * const probe = new Probe({ workspace: '/srv/checkout' })\n * const verdict = await probe.prove(claim)\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\t#arming: Promise<void>\n\t#closing: Promise<void> | undefined\n\t#destroyed = false\n\n\t/**\n\t * Resolves the target toolchain and starts warming the resident stages.\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 ?? 30_000 }).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: (inspection) =>\n\t\t\t\tthis.#inspectStage(\n\t\t\t\t\tthis.#type,\n\t\t\t\t\tthis.#type.progress,\n\t\t\t\t\tthis.#type.inspect(inspection.subject, inspection.claim.project),\n\t\t\t\t\tinspection.claim,\n\t\t\t\t),\n\t\t})\n\t\tthis.#lintQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: (inspection) =>\n\t\t\t\tthis.#inspectStage(\n\t\t\t\t\tthis.#lint,\n\t\t\t\t\tthis.#lint.progress,\n\t\t\t\t\tthis.#lint.inspect(inspection.subject),\n\t\t\t\t\tinspection.claim,\n\t\t\t\t),\n\t\t})\n\t\tthis.#runtimeQueue = createQueue<Inspection, Check>({\n\t\t\tconcurrency: 1,\n\t\t\tretries: 0,\n\t\t\thandler: (inspection) =>\n\t\t\t\tthis.#inspectStage(\n\t\t\t\t\tthis.#runtime,\n\t\t\t\t\tthis.#runtime.progress,\n\t\t\t\t\tthis.#runtime.inspect(inspection.subject),\n\t\t\t\t\tinspection.claim,\n\t\t\t\t),\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\tawait this.#ready()\n\t\t\tif (this.#destroyed) 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.#type.resolve(claim.project)\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\tthis.#emitter.emit('error', error)\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.#destroyed = true\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.#destroyed) 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\tconst created = this.#workbench()\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\tthrow 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}\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#workbench(): boolean {\n\t\tconst path = 'tmp/probe'\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 =\n\t\t\t\terror instanceof ProbeError && 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 = createRevisionFile(this.#workspace, 'tmp/probe/arm-type.ts', revision)\n\t\tconst runtimeDependency = createRevisionFile(\n\t\t\tthis.#workspace,\n\t\t\t'tmp/probe/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/probe/${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/probe/${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 after the resident type host cached it',\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\twriteFileSync(\n\t\t\t\ttypeDependency,\n\t\t\t\tformatSpecification('export type Signal = number\\n', revision),\n\t\t\t\t'utf8',\n\t\t\t)\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\twriteFileSync(\n\t\t\t\truntimeDependency,\n\t\t\t\tformatSpecification(\"export const SIGNAL = 'after'\\n\", revision),\n\t\t\t\t'utf8',\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/probe', 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 #inspectStage(\n\t\tstage: StageInterface,\n\t\tprogress: number,\n\t\toperation: Promise<Check>,\n\t\tclaim: Claim,\n\t): Promise<Check> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\treturn await Promise.race([\n\t\t\t\toperation,\n\t\t\t\tthis.#expiry(\n\t\t\t\t\ttimeout,\n\t\t\t\t\t`The ${stage.stage} stage exceeded ${this.#deadline} ms`,\n\t\t\t\t\tstage,\n\t\t\t\t\tprogress,\n\t\t\t\t),\n\t\t\t])\n\t\t} catch (error) {\n\t\t\tif (!timeout.expired) throw error\n\t\t\t// The recovery runs before this handler returns, so the replacement is installed before\n\t\t\t// the queue admits the next inspection and the claim behind this one meets a stage that\n\t\t\t// serves rather than one that reports a stranger's expiry.\n\t\t\tif (await this.#recycle(stage)) this.#emitter.emit('expire', claim)\n\t\t\tthrow error\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\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.#destroyed) 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// 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\treject(\n\t\t\t\t\t\tnew ProbeError(message, {\n\t\t\t\t\t\t\torigin: stage.progress > progress ? 'claimant' : 'instrument',\n\t\t\t\t\t\t\tcode: 'deadline',\n\t\t\t\t\t\t\tcontext: { stage: stage.stage, deadline: this.#deadline },\n\t\t\t\t\t\t}),\n\t\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\tawait this.#arming\n\t\t} catch {}\n\t\t// Tear the stages down and leave the queues running. A queue holds no host resource — no\n\t\t// timer, no listener, no store — and stage teardown settles every entry still admitted, so\n\t\t// each caller reads the stage's own refusal. Destroying a queue instead abandons those\n\t\t// entries, and a stage rejecting after its queue stopped observing ends the host process.\n\t\tawait Promise.all([this.#type.destroy(), this.#lint.destroy(), this.#runtime.destroy()])\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 (typeof version !== 'string') {\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#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 } from '@src/core'\nimport type { ProbeServerInterface } from './types.js'\nimport { PassThrough } from 'node:stream'\nimport { compileSchema, schemaToParameters } from '@orkestrel/contract'\nimport { createMCPLegacy, createMCPServer } from '@orkestrel/mcp'\nimport { createStdioServer } from '@orkestrel/mcp/server'\nimport { createTool, createToolManager } from '@orkestrel/tool'\nimport {\n\tCLAIM_SHAPE,\n\tProbeError,\n\tcreateDestroyedError,\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 * Serves one probe over this process's Model Context Protocol stdio transport.\n *\n * @remarks\n * Construction creates the probe, publishes the `prove` tool, and binds the dual-era dispatcher to\n * the stdio transport. The probe begins warming there, so a harness that spawns the entry pays\n * arming while its client is still handshaking.\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 #probe: ProbeInterface\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\t#owns: boolean | undefined\n\t#closing: Promise<void> | undefined\n\n\t/**\n\t * Creates the probe this server publishes and binds it to this process's stdio transport.\n\t *\n\t * @param options - Workspace, deadline, and initial observation hooks for the probe it creates\n\t */\n\tconstructor(options?: ProbeOptions) {\n\t\tthis.#probe = new Probe(options)\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\tthis.#transport = createStdioServer(createMCPLegacy(this.#publish()), { 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\tawait this.#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: async (input) => {\n\t\t\t\t\tif (!isClaim(input)) {\n\t\t\t\t\t\tconst refused = findRefusedPaths(input)\n\t\t\t\t\t\tthrow new ProbeError(\n\t\t\t\t\t\t\trefused.length === 0\n\t\t\t\t\t\t\t\t? 'The prove tool requires a claim matching the advertised schema'\n\t\t\t\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\t\t\t{\n\t\t\t\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\t\t\t\tcode: 'refused',\n\t\t\t\t\t\t\t\tcontext: { value: input },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\treturn this.#probe.prove(input)\n\t\t\t\t},\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\texecution: async ({ call }) => {\n\t\t\t\tconst result = await tools.execute(call)\n\t\t\t\tif (!result.success) return result\n\t\t\t\tif (!isVerdict(result.value)) {\n\t\t\t\t\tthrow new ProbeError('The prove tool returned an invalid verdict', {\n\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\tcode: 'malformed',\n\t\t\t\t\t\tcontext: { value: result.value },\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tresultType: 'complete',\n\t\t\t\t\tcontent: [{ type: 'text', text: formatVerdict(result.value) }],\n\t\t\t\t}\n\t\t\t},\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,cAAc,MAAsB;CACnD,OAAO,KAAK,WAAW,MAAM,GAAG;AACjC;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,qBAAqB,WAAmB,QAAgB,SAAS,OAAe;CAC/F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GACN,aACC;GACD;GACA,SAAS,OAAO,UAAU;IACzB,IAAI,EAAA,GAAC,UAAA,QAAA,CAAQ,KAAK,GAAG;KACpB,MAAM,UAAU,iBAAiB,KAAK;KACtC,MAAM,IAAI,UAAA,WACT,QAAQ,WAAW,IAChB,mEACA,0BAA0B,QAAQ,KAAK,IAAI,EAAE,gGAChD;MACC,QAAQ;MACR,MAAM;MACN,SAAS,EAAE,OAAO,MAAM;KACzB,CACD;IACD;IACA,OAAO,KAAKD,OAAO,MAAM,KAAK;GAC/B;EACD,CAAC,CACF;EACA,QAAA,GAAO,eAAA,gBAAA,CAAgB;GACtB,UAAU;IAAE,MAAM;IAAS;GAAQ;GACnC;GACA,WAAW,OAAO,EAAE,WAAW;IAC9B,MAAM,SAAS,MAAM,MAAM,QAAQ,IAAI;IACvC,IAAI,CAAC,OAAO,SAAS,OAAO;IAC5B,IAAI,EAAA,GAAC,UAAA,UAAA,CAAU,OAAO,KAAK,GAC1B,MAAM,IAAI,UAAA,WAAW,8CAA8C;KAClE,QAAQ;KACR,MAAM;KACN,SAAS,EAAE,OAAO,OAAO,MAAM;IAChC,CAAC;IAEF,OAAO;KACN,YAAY;KACZ,SAAS,CAAC;MAAE,MAAM;MAAQ,OAAA,GAAM,UAAA,cAAA,CAAc,OAAO,KAAK;KAAE,CAAC;IAC9D;GACD;EACD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"index.cjs","names":["#revision","#candidates","#workspace","#deadline","#warmth","#responses","#failures","#documents","#publishes","#refusals","#warm","#progress","#destroyed","#document","#closing","#destroy","#warmed","#fail","#ending","#release","#expiry","#child","#retire","#request","#notify","#read","#exit","#close","#sequence","#fault","#describe","#reachable","#send","#buffer","#frame","#receive","#issues","#workspace","#modules","#revisions","#vitest","#warm","#progress","#destroyed","#runner","#project","#overlay","#revalidate","#specification","#specifications","#issues","#evict","#closing","#destroy","#sweep","#configure","#augment","#wrap","#instrument","#resolve","#load","#replace","#snapshot","#invalidate","#walk","#alive","#owned","#real","#issue","#workspace","#typescript","#services","#resident","#options","#files","#diagnostics","#warm","#progress","#destroyed","#configure","#service","#overlay","#record","#issues","#unblock","#closing","#destroy","#recycled","#projects","#translate","#compilationSettings","#scriptFiles","#version","#snapshot","#directory","#defaultLibrary","#fileExists","#readFile","#directoryExists","#caseSensitive","#newline","#recycle","#issue","#workspace","#deadline","#emitter","#toolchain","#typeQueue","#lintQueue","#runtimeQueue","#version","#type","#lint","#runtime","#inspectType","#inspectLint","#inspectRuntime","#arming","#arm","#support","#ready","#destroyed","#inspect","#closing","#destroy","#workbench","#boot","#inspectStage","#expiry","#recycle","#probe","#stream","#transport","#data","#close","#error","#signal","#publish","#receive","#finish","#fail","#release","#closing","#owns","#destroy","#prove","#execute"],"sources":["../../../src/server/helpers.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 { ListenerCapture, WorkspaceManifest } from './types.js'\nimport type { EventEmitter } from 'node:events'\nimport type * as TypeScript from 'typescript'\nimport type * as VitestNode from 'vitest/node'\nimport { lstatSync, readFileSync, realpathSync, statSync } from 'node:fs'\nimport { createHash } from 'node:crypto'\nimport { createRequire } from 'node:module'\nimport { dirname, extname, isAbsolute, relative, resolve, sep } from 'node:path'\nimport { attempt, compileGuard, isArray, isRecord } from '@orkestrel/contract'\nimport { CLAIM_SHAPE, ProbeError, isDraft } 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 * 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 === '' || path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path)) {\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 error = outcome.error\n\t\t\t\tif (\n\t\t\t\t\ttypeof error === 'object' &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t'code' in error &&\n\t\t\t\t\t(error.code === 'ENOENT' || error.code === 'ENOTDIR')\n\t\t\t\t) {\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t\tthrow 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\tconst remainder = relative(canonical, resolved)\n\t\t\tif (remainder === '..' || remainder.startsWith(`..${sep}`) || isAbsolute(remainder)) {\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 (error instanceof ProbeError) throw error\n\t\tconst claimant =\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\t'code' in error &&\n\t\t\t(error.code === 'ENAMETOOLONG' || error.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 * 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 when the fault means the host refuses this name; false otherwise\n *\n * @example\n * ```ts\n * try {\n * \twriteFileSync('tmp/probe/greeting\\0.test.ts', '')\n * } catch (error) {\n * \tisRefusedName('tmp/probe/greeting\\0.test.ts', error) // true\n * }\n * isRefusedName('tmp/probe/greeting.test.ts', new Error('the runtime stage was destroyed')) // false\n * ```\n */\nexport function isRefusedName(file: string, error: unknown): boolean {\n\tif (typeof error !== 'object' || error === null) return false\n\tconst fault = error\n\tconst reading = attempt(() => ('code' in fault ? fault.code : undefined))\n\tif (!reading.success) return false\n\tconst code = reading.value\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 * 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 =\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t'code' in error &&\n\t\terror.code === '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 one installed tool module from a target workspace.\n *\n * @param workspace - The target workspace root\n * @param specifier - The module specifier to load\n * @returns The installed module\n * @throws When the workspace cannot load the module\n *\n * @example\n * ```ts\n * const typescript = loadWorkspaceModule(process.cwd(), 'typescript')\n * console.log(typescript.version)\n * ```\n */\nexport function loadWorkspaceModule(workspace: string, specifier: 'typescript'): typeof TypeScript\nexport function loadWorkspaceModule(workspace: string, specifier: 'vitest/node'): typeof VitestNode\nexport function loadWorkspaceModule(\n\tworkspace: string,\n\tspecifier: 'typescript' | 'vitest/node',\n): typeof TypeScript | typeof VitestNode {\n\tconst outcome = attempt(() => {\n\t\tconst require = createRequire(resolve(workspace, 'package.json'))\n\t\treturn specifier === 'typescript' ? require('typescript') : require('vitest/node')\n\t})\n\tif (outcome.success) return outcome.value\n\tconst error = outcome.error\n\tconst missing =\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t'code' in error &&\n\t\terror.code === 'MODULE_NOT_FOUND'\n\tthrow new ProbeError(`The workspace cannot load ${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 * 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 (!(error instanceof ProbeError)) 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 missing =\n\t\t\ttypeof error === 'object' &&\n\t\t\terror !== null &&\n\t\t\t'code' in error &&\n\t\t\t(error.code === 'ENOENT' || error.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 * @param workspace - The target workspace root\n * @param name - The installed package name and binary key\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 name\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(process.cwd(), resolveWorkspaceBinary(process.cwd(), 'oxlint'))\n * // 'node_modules/oxlint/bin/oxlint'\n * resolveWorkspaceBinary(process.cwd(), 'typescript')\n * // throws: typescript does not publish the typescript binary\n * ```\n */\nexport function resolveWorkspaceBinary(workspace: string, name: string): 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 (typeof bin === 'string') return resolve(manifest.path, '..', bin)\n\tif (!isRecord(bin) || !(name in bin)) {\n\t\tthrow new ProbeError(`${name} does not publish the ${name} 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[name]\n\tif (typeof entry !== 'string') {\n\t\tthrow new ProbeError(`${name} publishes an invalid ${name} 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/probe/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 === 'probe') 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 * Creates a fresh sibling identity while preserving a test's resolution 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 An absolute sibling file path\n *\n * @example\n * ```ts\n * relativeWorkspaceFile(\n * \t'/srv/checkout',\n * \tcreateRevisionFile('/srv/checkout', 'tmp/probe/greeting.test.ts', '4821-9f0c'),\n * )\n * // 'tmp/probe/greeting.test.probe-4821-9f0c.ts'\n * ```\n */\nexport function createRevisionFile(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 * Reports whether a path is a workspace module Vitest can cache.\n *\n * @param path - The candidate file path\n * @returns True for script, TypeScript, Vue, and JSON modules; 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 * Reads a JSON-RPC frame's declared byte length.\n *\n * @param header - The frame header text without its terminating empty line\n * @returns The non-negative content length, or `undefined` for an invalid header\n *\n * @example\n * ```ts\n * parseContentLength('Content-Length: 128') // 128\n * parseContentLength('Content-Type: application/json') // undefined\n * ```\n */\nexport function parseContentLength(header: string): number | undefined {\n\tconst match = /(?:^|\\r\\n)Content-Length:\\s*(\\d+)(?:\\r\\n|$)/i.exec(header)\n\tconst text = match?.[1]\n\tif (text === undefined) return undefined\n\tconst length = Number.parseInt(text, 10)\n\treturn Number.isSafeInteger(length) && length >= 0 ? length : undefined\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 (value instanceof Error) return value.message\n\tif (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'message' in value &&\n\t\ttypeof value.message === 'string'\n\t) {\n\t\treturn value.message\n\t}\n\treturn String(value)\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/probe/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 * A parsed TypeScript project carries the absolute root it was parsed at, so the same commit\n * checked out at two paths produces two values that describe one configuration. Rewriting those\n * members makes the value portable and stops a host path leaking into anything derived from it. A\n * path that escapes the workspace is left as it stands, because rewriting it would name a file\n * outside the tree by a relative spelling. Key order is the parser's, not the configuration's, so\n * 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 (typeof value === 'string') {\n\t\tif (!isAbsolute(value)) return value\n\t\tconst path = relative(root, resolve(value))\n\t\tif (path === '') return '.'\n\t\tif (path === '..' || path.startsWith(`..${sep}`) || isAbsolute(path)) 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 { OverlayInterface } from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport { normalizePath } from './helpers.js'\n\n/**\n * Holds the candidate drafts one inspection substitutes for the files a tool would read from disk.\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 * @example\n * ```ts\n * const overlay = new Overlay()\n * overlay.set('/srv/checkout/src/core/greeting.ts', \"export const GREETING = 'hi'\\n\")\n * console.log(overlay.text('/srv/checkout/src/core/greeting.ts'))\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 * @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.3\",\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: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:guides\": \"vitest run --config vite.config.ts --no-cache --reporter=dot --project guides\",\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.13\",\n\t\t\"@orkestrel/emitter\": \"^0.0.7\",\n\t\t\"@orkestrel/mcp\": \"^0.0.21\",\n\t\t\"@orkestrel/queue\": \"^0.0.10\",\n\t\t\"@orkestrel/timeout\": \"^0.0.7\",\n\t\t\"@orkestrel/tool\": \"^0.0.11\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@microsoft/api-extractor\": \"^7.59.0\",\n\t\t\"@orkestrel/guide\": \"^0.0.12\",\n\t\t\"@orkestrel/scaffold\": \"^0.0.49\",\n\t\t\"@orkestrel/test\": \"^0.0.10\",\n\t\t\"@types/node\": \"^26.2.0\",\n\t\t\"oxfmt\": \"^0.64.0\",\n\t\t\"oxlint\": \"^1.79.0\",\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vite\": \"^8.2.2\",\n\t\t\"vite-plugin-dts\": \"^5.0.3\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependencies\": {\n\t\t\"oxlint\": \"^1.79.0\",\n\t\t\"typescript\": \"^6.0.3\",\n\t\t\"vitest\": \"^4.1.11\"\n\t},\n\t\"peerDependenciesMeta\": {\n\t\t\"oxlint\": {\n\t\t\t\"optional\": true\n\t\t},\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 { StageInterface } from '../types.js'\nimport type { ChildProcessWithoutNullStreams } from 'node:child_process'\nimport type { TimeoutInterface } from '@orkestrel/timeout'\nimport { spawn } from 'node:child_process'\nimport { pathToFileURL } from 'node:url'\nimport { createTimeout } from '@orkestrel/timeout'\nimport { ProbeError, createDestroyedError } from '@src/core'\nimport {\n\tdescribeUnknown,\n\tinferDocumentLanguage,\n\tnormalizePath,\n\tparseContentLength,\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\n * mode. Each inspection opens the supplied text by URI, waits for published diagnostics, and\n * closes the document without writing it to disk.\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\n * `destroy` bounds each exchange and takes the ending back with a signal when the bound 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)\n * await stage.destroy()\n * ```\n */\nexport class LintStage implements StageInterface {\n\treadonly #workspace: string\n\t// The bound on every exchange teardown has with the language server, warming included. The\n\t// protocol leaves both the warming answer and the ending to the server, so each one is a wait\n\t// this stage takes back rather than a wait it can rely on.\n\treadonly #deadline = 2_000\n\treadonly #warmth: Promise<ChildProcessWithoutNullStreams>\n\treadonly #responses = new Map<number, (value: unknown) => void>()\n\treadonly #failures = new Map<number, (error: Error) => void>()\n\treadonly #documents = new Map<string, string>()\n\treadonly #publishes = new Map<string, (issues: readonly Issue[]) => void>()\n\treadonly #refusals = new Map<string, (error: Error) => void>()\n\t#child: ChildProcessWithoutNullStreams | undefined\n\t#buffer = Buffer.alloc(0)\n\t#sequence = 0\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t#destroyed = false\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\tasync inspect(subject: Case): Promise<Check> {\n\t\tif (this.#destroyed) throw createDestroyedError('lint stage')\n\t\tconst started = performance.now()\n\t\tawait this.#warmth\n\t\tif (this.#destroyed) 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(draft)))\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\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#destroyed = true\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\n\t}\n\n\tasync #destroy(): Promise<void> {\n\t\t// A server that failed to warm still leaves a child to release, so read the spawned child\n\t\t// rather than the warming result.\n\t\tconst child = await this.#warmed()\n\t\t// Abandon every document in flight rather than waiting for it: a server that never publishes\n\t\t// its diagnostics would otherwise hold teardown open for the life of the process.\n\t\tthis.#fail(createDestroyedError('lint stage'))\n\t\tif (child === undefined || this.#ending !== undefined) return\n\t\tconst released = new Promise<void>((resolve) => {\n\t\t\tchild.once('exit', () => resolve())\n\t\t\tchild.once('close', () => resolve())\n\t\t})\n\t\tawait this.#release(child, released)\n\t}\n\n\t// Reads the warmed language server, or the spawned child when warming failed or outran the\n\t// deadline. Warming waits for the `initialize` response, and the protocol leaves that answer to\n\t// the server: one that accepts the connection and answers nothing has broken no rule, and\n\t// waiting on it holds teardown open for the life of the host. Teardown needs the child rather\n\t// than the warming result, and `#warm` has the child before it sends anything, so the bound\n\t// costs the answer and nothing else. The abandoned warming promise keeps its constructor's\n\t// observer, so nothing rejects into the host.\n\tasync #warmed(): Promise<ChildProcessWithoutNullStreams | undefined> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\treturn await Promise.race([this.#warmth, this.#expiry(timeout)])\n\t\t} catch {\n\t\t\treturn this.#child\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t}\n\n\t// Ends the conversation under a deadline and signals the child when that deadline passes. The\n\t// protocol leaves the ending to the server: a server that answers `shutdown` and then ignores\n\t// `exit` has broken no rule, and one that answers neither is unreachable rather than dead. Both\n\t// leave teardown waiting for the life of the host and leak the child with it, so this bounds\n\t// the whole exchange at two seconds and then takes the ending back. `SIGKILL` cannot be\n\t// handled, so the child ends and its own `exit` event settles the wait.\n\tasync #release(child: ChildProcessWithoutNullStreams, released: Promise<void>): Promise<void> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\tawait Promise.race([this.#retire(child).then(() => released), this.#expiry(timeout)])\n\t\t} catch {\n\t\t\tchild.kill('SIGKILL')\n\t\t\tawait released\n\t\t} finally {\n\t\t\ttimeout.clear()\n\t\t}\n\t}\n\n\t// Asks the language server to shut down and signals it when that conversation fails. A server\n\t// that died mid-teardown, or that never answers, still has to release its resources, and\n\t// teardown must not wait on a reply a dead pipe swallowed.\n\tasync #retire(child: ChildProcessWithoutNullStreams): Promise<void> {\n\t\ttry {\n\t\t\tawait this.#request('shutdown', undefined)\n\t\t\tthis.#notify('exit', undefined)\n\t\t} catch {\n\t\t\tchild.kill('SIGKILL')\n\t\t}\n\t}\n\n\t// Rejects when the teardown deadline fires, so a race against it settles even when the server\n\t// it waits on answers nothing.\n\t#expiry(timeout: TimeoutInterface): 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\treject(\n\t\t\t\t\t\tnew ProbeError(`The Oxlint language server did not exit within ${timeout.ms} ms`, {\n\t\t\t\t\t\t\torigin: 'instrument',\n\t\t\t\t\t\t\tcode: 'deadline',\n\t\t\t\t\t\t\tcontext: { stage: this.stage, deadline: timeout.ms },\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t{ once: true },\n\t\t\t)\n\t\t})\n\t}\n\n\tasync #warm(): Promise<ChildProcessWithoutNullStreams> {\n\t\tconst binary = resolveWorkspaceBinary(this.#workspace, 'oxlint')\n\t\tconst child = spawn(process.execPath, [binary, '--lsp'], {\n\t\t\tcwd: this.#workspace,\n\t\t\tstdio: 'pipe',\n\t\t})\n\t\tthis.#child = child\n\t\tchild.stderr.resume()\n\t\tchild.stdout.on('data', (chunk: Buffer) => this.#read(chunk))\n\t\t// A write racing the server's death reports `EPIPE` on this stream rather than throwing, and\n\t\t// an unobserved stream error ends the resident host. Report it as a stage fault so the\n\t\t// inspection that raced the death is refused rather than left waiting for a reply the pipe\n\t\t// swallowed.\n\t\tchild.stdin.on('error', (error) => this.#fail(error))\n\t\tchild.on('error', (error) => this.#fail(error))\n\t\tchild.on('exit', (code, signal) => this.#exit(code, signal))\n\t\tawait this.#request('initialize', {\n\t\t\tprocessId: process.pid,\n\t\t\trootUri: pathToFileURL(this.#workspace).href,\n\t\t\tcapabilities: {},\n\t\t\tworkspaceFolders: [\n\t\t\t\t{\n\t\t\t\t\turi: pathToFileURL(this.#workspace).href,\n\t\t\t\t\tname: 'workspace',\n\t\t\t\t},\n\t\t\t],\n\t\t})\n\t\tthis.#notify('initialized', {})\n\t\treturn child\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 and one publication, so a caller driving two inspections of one path\n\t// at once is refused rather than served an answer belonging to the other.\n\t#document(draft: Draft): Promise<readonly Issue[]> {\n\t\tconst uri = pathToFileURL(resolveWorkspaceFile(this.#workspace, draft.path)).href\n\t\tif (this.#publishes.has(uri)) {\n\t\t\treturn Promise.reject(\n\t\t\t\tnew ProbeError(`The lint stage is already inspecting ${draft.path}`, {\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { stage: this.stage, path: draft.path },\n\t\t\t\t}),\n\t\t\t)\n\t\t}\n\t\tconst diagnostics = new Promise<readonly Issue[]>((resolve, reject) => {\n\t\t\tthis.#documents.set(uri, normalizePath(draft.path))\n\t\t\tthis.#publishes.set(uri, resolve)\n\t\t\tthis.#refusals.set(uri, reject)\n\t\t})\n\t\t// Attach the cleanup before opening the document. An open that throws would otherwise leave\n\t\t// this promise pending with no handler, and the next failure rejects it into the host.\n\t\tconst inspected = diagnostics.finally(() => this.#close(uri))\n\t\ttry {\n\t\t\tthis.#notify('textDocument/didOpen', {\n\t\t\t\ttextDocument: {\n\t\t\t\t\turi,\n\t\t\t\t\tlanguageId: inferDocumentLanguage(draft.path),\n\t\t\t\t\tversion: this.#sequence,\n\t\t\t\t\ttext: draft.text,\n\t\t\t\t},\n\t\t\t})\n\t\t\tthis.#progress += 1\n\t\t} catch (error) {\n\t\t\tthis.#refusals.get(uri)?.(this.#fault(describeUnknown(error), error, draft.path))\n\t\t}\n\t\treturn inspected\n\t}\n\n\t// How the language server ended, or `undefined` while it runs. Node records a signal death on\n\t// `signalCode`, an exit on `exitCode`, and a child that never spawned on `exitCode` too, and it\n\t// sets each one before the event that announces it. Reading the child covers every ending,\n\t// including the spawn failure, which reports `error` and `close` and never `exit`.\n\tget #ending(): string | undefined {\n\t\tconst child = this.#child\n\t\tif (child === undefined) return undefined\n\t\tif (child.exitCode === null && child.signalCode === null) return undefined\n\t\treturn this.#describe(child.exitCode, child.signalCode)\n\t}\n\n\t// Names one ending for a message. Node announces an exit with exactly one non-null argument.\n\t#describe(code: number | null, signal: NodeJS.Signals | null): string {\n\t\treturn signal === null ? `code ${code}` : `signal ${signal}`\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// Whether the language server can still receive a message. A server that ended, and one that\n\t// closed its input while its process lives, both take no further writes.\n\tget #reachable(): boolean {\n\t\treturn this.#ending === undefined && this.#child?.stdin.writable === true\n\t}\n\n\t// Releases one document. The deletes run before the notification because an unreachable server\n\t// refuses the write, and a throw here would replace the diagnosis the caller is receiving and\n\t// leave this document registered for the life of the stage.\n\t#close(uri: string): void {\n\t\tthis.#documents.delete(uri)\n\t\tthis.#publishes.delete(uri)\n\t\tthis.#refusals.delete(uri)\n\t\tif (this.#destroyed || !this.#reachable) return\n\t\tthis.#notify('textDocument/didClose', { textDocument: { uri } })\n\t}\n\n\t#request(method: string, params: unknown): Promise<unknown> {\n\t\tthis.#sequence += 1\n\t\tconst id = this.#sequence\n\t\tconst response = new Promise<unknown>((resolve, reject) => {\n\t\t\tthis.#responses.set(id, resolve)\n\t\t\tthis.#failures.set(id, reject)\n\t\t})\n\t\ttry {\n\t\t\tthis.#send({ jsonrpc: '2.0', id, method, params })\n\t\t} catch (error) {\n\t\t\t// Forget the request before refusing it. A request the stage never sent has no reply to\n\t\t\t// wait for, and leaving its entry behind holds this promise for the life of the stage.\n\t\t\tconst reject = this.#failures.get(id)\n\t\t\tthis.#responses.delete(id)\n\t\t\tthis.#failures.delete(id)\n\t\t\treject?.(this.#fault(describeUnknown(error), error))\n\t\t}\n\t\treturn response\n\t}\n\n\t#notify(method: string, params: unknown): void {\n\t\tthis.#sequence += 1\n\t\tthis.#send({ jsonrpc: '2.0', method, params })\n\t}\n\n\t#send(message: unknown): void {\n\t\tconst child = this.#child\n\t\tif (this.#ending !== undefined) {\n\t\t\tthrow this.#fault(`The Oxlint language server exited with ${this.#ending}`)\n\t\t}\n\t\tif (child === undefined) throw this.#fault('The Oxlint language server is not running')\n\t\t// A server that closed its input is unreachable while its process still lives, so a write\n\t\t// here would neither fail nor ever be answered.\n\t\tif (!child.stdin.writable) throw this.#fault('The Oxlint language server closed its input')\n\t\tconst content = JSON.stringify(message)\n\t\tconst header = `Content-Length: ${Buffer.byteLength(content)}\\r\\n\\r\\n`\n\t\tchild.stdin.write(header + content)\n\t}\n\n\t#read(chunk: Buffer): void {\n\t\tthis.#buffer = Buffer.concat([this.#buffer, chunk])\n\t\twhile (this.#frame()) {}\n\t}\n\n\t#frame(): boolean {\n\t\tconst boundary = this.#buffer.indexOf('\\r\\n\\r\\n')\n\t\tif (boundary < 0) return false\n\t\tconst header = this.#buffer.subarray(0, boundary).toString('ascii')\n\t\tconst length = parseContentLength(header)\n\t\tif (length === undefined) {\n\t\t\tthis.#fail(this.#fault('Oxlint sent an invalid JSON-RPC frame header'))\n\t\t\treturn false\n\t\t}\n\t\tconst start = boundary + 4\n\t\tconst end = start + length\n\t\tif (this.#buffer.length < end) return false\n\t\tconst content = this.#buffer.subarray(start, end).toString('utf8')\n\t\tthis.#buffer = this.#buffer.subarray(end)\n\t\ttry {\n\t\t\tconst message: unknown = JSON.parse(content)\n\t\t\tthis.#receive(message)\n\t\t} catch (error) {\n\t\t\tthis.#fail(this.#fault(`Oxlint sent invalid JSON: ${describeUnknown(error)}`, error))\n\t\t}\n\t\treturn true\n\t}\n\n\t#receive(message: unknown): void {\n\t\tif (typeof message !== 'object' || message === null) return\n\t\tif ('id' in message && typeof message.id === 'number') {\n\t\t\tconst id = message.id\n\t\t\tconst resolve = this.#responses.get(id)\n\t\t\tconst reject = this.#failures.get(id)\n\t\t\tthis.#responses.delete(id)\n\t\t\tthis.#failures.delete(id)\n\t\t\tif ('error' in message && message.error !== undefined) {\n\t\t\t\treject?.(this.#fault(describeUnknown(message.error)))\n\t\t\t} else {\n\t\t\t\tresolve?.('result' in message ? message.result : undefined)\n\t\t\t}\n\t\t\treturn\n\t\t}\n\t\tif (!('method' in message) || message.method !== 'textDocument/publishDiagnostics') return\n\t\tif (!('params' in message) || typeof message.params !== 'object' || message.params === null) {\n\t\t\treturn\n\t\t}\n\t\tconst params = message.params\n\t\tif (!('uri' in params) || typeof params.uri !== 'string') return\n\t\tif (!('diagnostics' in params) || !Array.isArray(params.diagnostics)) return\n\t\tconst publish = this.#publishes.get(params.uri)\n\t\tif (publish === undefined) return\n\t\tpublish(this.#issues(params.uri, params.diagnostics))\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.\n\t#issues(uri: string, diagnostics: readonly unknown[]): readonly Issue[] {\n\t\tconst path = this.#documents.get(uri)\n\t\tif (path === undefined) return []\n\t\tconst issues: Issue[] = []\n\t\tfor (const diagnostic of diagnostics) {\n\t\t\tif (typeof diagnostic !== 'object' || diagnostic === null) continue\n\t\t\tif (!('message' in diagnostic) || typeof diagnostic.message !== 'string') continue\n\t\t\tif (\n\t\t\t\t!('range' in diagnostic) ||\n\t\t\t\ttypeof diagnostic.range !== 'object' ||\n\t\t\t\tdiagnostic.range === null\n\t\t\t) {\n\t\t\t\tissues.push({ origin: 'claimant', path, message: diagnostic.message })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst range = diagnostic.range\n\t\t\tif (!('start' in range) || typeof range.start !== 'object' || range.start === null) {\n\t\t\t\tissues.push({ origin: 'claimant', path, message: diagnostic.message })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst start = range.start\n\t\t\tif (!('line' in start) || typeof start.line !== 'number') {\n\t\t\t\tissues.push({ origin: 'claimant', path, message: diagnostic.message })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tissues.push({\n\t\t\t\torigin: 'claimant',\n\t\t\t\tpath,\n\t\t\t\tmessage: diagnostic.message,\n\t\t\t\tline: start.line + 1,\n\t\t\t})\n\t\t}\n\t\treturn issues\n\t}\n\n\t#fail(error: Error): void {\n\t\tfor (const reject of this.#failures.values()) reject(error)\n\t\tfor (const reject of this.#refusals.values()) reject(error)\n\t\tthis.#responses.clear()\n\t\tthis.#failures.clear()\n\t\tthis.#publishes.clear()\n\t\tthis.#refusals.clear()\n\t}\n\n\t// Settles everything the ended server can no longer answer. A teardown in flight is registered\n\t// here too: its own `shutdown` request is the last thing outstanding, and a server that exits\n\t// without replying leaves teardown waiting on it unless this refuses it.\n\t#exit(code: number | null, signal: NodeJS.Signals | null): void {\n\t\tthis.#fail(\n\t\t\tthis.#fault(`The Oxlint language server exited with ${this.#describe(code, signal)}`),\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 type { Dirent } from 'node:fs'\nimport {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\tunlinkSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { createHash, randomUUID } from 'node:crypto'\nimport { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from 'node:path'\nimport { PassThrough } from 'node:stream'\nimport { fileURLToPath } from 'node:url'\nimport { attempt } from '@orkestrel/contract'\nimport {\n\tProbeError,\n\tcreateDestroyedError,\n\tformatSpecification,\n\tmatchesSpecification,\n} from '@src/core'\nimport {\n\tcaptureListeners,\n\tcreateRevisionFile,\n\tdescribeUnknown,\n\tinferTestProject,\n\tisRefusedName,\n\tloadWorkspaceModule,\n\tmatchesWorkspaceModule,\n\tnormalizePath,\n\treleaseListeners,\n\trelativeWorkspaceFile,\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 *\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 * The write path's physical-containment guarantee covers the claim inputs and the target tree as\n * inspected. A concurrent process that mutates a path component between the final inspection and\n * the write is outside that guarantee.\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>\n\t#overlay: OverlayInterface = new Overlay()\n\treadonly #modules = new Map<string, string>()\n\treadonly #revisions = new Set<string>()\n\t#specifications = 0\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t#destroyed = false\n\n\t/**\n\t * Starts warming the target workspace's Vitest service.\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\tconst vitest = loadWorkspaceModule(this.#workspace, 'vitest/node')\n\t\tthis.#vitest = this.#warm(vitest.createVitest)\n\t\t// Observe the stored promise here. A stage the coordinator builds to replace a hung one may\n\t\t// never be inspected or destroyed, and an unobserved rejection ends the host process. The\n\t\t// stored promise keeps rejecting, so an inspection still reports the warming failure.\n\t\tvoid this.#vitest.catch(() => {})\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\tasync inspect(subject: Case): Promise<Check> {\n\t\tif (this.#destroyed) 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.#destroyed) 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\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 (typeof specification !== 'string') {\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 = this.#issues(result, file, subject.test.path)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof ProbeError) 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\terror instanceof ProbeError && error.origin === 'workspace'\n\t\t\t\t\t\t\t\t\t? 'workspace'\n\t\t\t\t\t\t\t\t\t: '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\toverlay.clear()\n\t\t}\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#destroyed = true\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\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 its constructor already surfaced.\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.#overlay.clear()\n\t\t}\n\t}\n\n\tasync #warm(create: typeof createVitest): Promise<Vitest> {\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\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\treturn create(\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} finally {\n\t\t\treleaseListeners(process, signals)\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 (typeof project === 'string') 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: 'orkestrel-runtime-overlay',\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.lastIndexOf('?')\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.#load(resolved) !== undefined) return resolved\n\t\t}\n\t\treturn undefined\n\t}\n\n\t#load(id: string): string | undefined {\n\t\tconst text = this.#overlay.text(id)\n\t\tif (text !== undefined) return text\n\t\tconst separator = id.lastIndexOf('?')\n\t\tif (separator === -1) return undefined\n\t\tconst query = id.slice(separator + 1)\n\t\tif (\n\t\t\t!query.startsWith('v=') ||\n\t\t\tquery.length === 2 ||\n\t\t\tquery.includes('&') ||\n\t\t\tquery.includes('#') ||\n\t\t\tquery.slice(2).includes('?')\n\t\t) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn this.#overlay.text(id.slice(0, separator))\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 = createRevisionFile(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 (outcome.error instanceof ProbeError && 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(outcome.error instanceof ProbeError && 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 (\n\t\t\t!project.vite.config.plugins.some((plugin) => plugin.name === 'orkestrel-runtime-overlay')\n\t\t) {\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\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. A 64-specification\n\t\t// lifetime bounds that internal map without giving up the resident runner on each call.\n\t\tif (this.#specifications < 64) return this.#vitest\n\t\tthis.#specifications = 0\n\t\tthis.#vitest = this.#replace(this.#vitest)\n\t\tvoid this.#vitest.catch(() => {})\n\t\treturn this.#vitest\n\t}\n\n\tasync #replace(current: Promise<Vitest>): Promise<Vitest> {\n\t\tconst vitest = await current\n\t\tawait vitest.close()\n\t\tif (this.#destroyed) throw createDestroyedError('runtime stage')\n\t\tconst runner = loadWorkspaceModule(this.#workspace, 'vitest/node')\n\t\treturn this.#warm(runner.createVitest)\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. `#walk` builds each path with `join` and the overlay holds paths\n\t// `resolve` produced, so on a host whose separator is a backslash the native spelling matches no\n\t// key, the invalidation is dropped without an error, and the resident runner serves the previous\n\t// module. Read the host separator rather than the platform name, and rewrite only where it is a\n\t// backslash: a backslash is a legal filename character on a host whose separator is a forward\n\t// 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 this.#walk()) {\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 this.#walk()) {\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 (this.#alive(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// Whether the host that wrote one specification is still running. Signal 0 delivers nothing and\n\t// reports reachability alone. A host this process may not signal reports `EPERM` and is read as\n\t// alive, and a non-positive identity names a process group rather than a process, so both leave\n\t// the file where it is: the safe direction is to keep a file this stage cannot account for.\n\t#alive(id: number): boolean {\n\t\tif (!Number.isSafeInteger(id) || id <= 0) return true\n\t\ttry {\n\t\t\tprocess.kill(id, 0)\n\t\t\treturn true\n\t\t} catch (error) {\n\t\t\treturn error instanceof Error && 'code' in error && error.code === 'EPERM'\n\t\t}\n\t}\n\n\t// Yields every file the target workspace holds, skipping the trees no inspection reads: version\n\t// control, build output, and installed packages. A directory this host cannot list is skipped\n\t// rather than raised: the walk runs at construction and before every inspection, and one\n\t// unreadable directory in a consumer's tree is not a reason to refuse the workspace.\n\t*#walk(): Generator<string> {\n\t\tconst directories = [resolve(this.#workspace)]\n\t\twhile (directories.length > 0) {\n\t\t\tconst directory = directories.pop()\n\t\t\tif (directory === undefined) break\n\t\t\tlet entries: readonly Dirent[] = []\n\t\t\ttry {\n\t\t\t\tentries = readdirSync(directory, { withFileTypes: true })\n\t\t\t} catch {}\n\t\t\tfor (const entry of entries) {\n\t\t\t\tif (entry.name === '.git' || entry.name === 'dist' || entry.name === 'node_modules') {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tconst path = join(directory, entry.name)\n\t\t\t\tif (entry.isDirectory()) {\n\t\t\t\t\tdirectories.push(path)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif (entry.isFile()) yield path\n\t\t\t}\n\t\t}\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.\n\t#issue(error: unknown, specification: string, original: string): Issue {\n\t\tconst message = describeUnknown(error)\n\t\tif (typeof error !== 'object' || error === null || !('stacks' in error)) {\n\t\t\treturn { origin: 'claimant', path: original, message }\n\t\t}\n\t\tconst stacks = error.stacks\n\t\tif (!Array.isArray(stacks)) return { origin: 'claimant', path: original, message }\n\t\tfor (const stack of stacks) {\n\t\t\tif (typeof stack !== 'object' || stack === null) continue\n\t\t\tif (!('file' in stack) || typeof stack.file !== 'string') 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) || typeof stack.line !== 'number') {\n\t\t\t\treturn { origin: 'claimant', path, message }\n\t\t\t}\n\t\t\treturn { origin: 'claimant', path, message, line: stack.line }\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 { OverlayInterface, TypeStageInterface } from '../types.js'\nimport type * as TypeScript from 'typescript'\nimport type {\n\tCompilerOptions,\n\tDiagnostic,\n\tDiagnosticMessageChain,\n\tIScriptSnapshot,\n\tLanguageService,\n\tLanguageServiceHost,\n} from 'typescript'\nimport { readdirSync, statSync } from 'node:fs'\nimport { dirname } from 'node:path'\nimport { setImmediate } from 'node:timers/promises'\nimport { ProbeError, createDestroyedError } from '@src/core'\nimport {\n\tcomputeDigest,\n\tinferTypeProject,\n\tloadWorkspaceModule,\n\tnormalizePath,\n\trelativeWorkspaceFile,\n\tresolveWorkspaceFile,\n} from '../helpers.js'\nimport { Overlay } from '../Overlay.js'\n\n/**\n * Inspects TypeScript source through resident language services from the target workspace.\n *\n * @remarks\n * Construction starts loading the workspace's compiler and warming one service per project the\n * workspace declares. A candidate draft is checked against the project a call names, or\n * against its own scoped environment project when a call names none, while the test uses the root\n * project. Disk snapshots use their modification time as the service version so dependency edits\n * cannot leave a warm answer stale. Candidate text lives in an overlay the inspection owns, and\n * the language-service host answers existence, reads, and versions from it, so a candidate that\n * exists only as text is importable and a candidate that shadows a disk file is checked as the\n * text the case supplied. A project outside the declared set holds one recycled slot, so a caller\n * varying the project cannot grow the resident set. A language service checks one candidate\n * synchronously, so the stage hands the host's event loop back at each candidate boundary: a\n * caller's deadline is answered within one candidate's check rather than after the whole\n * inspection, and an inspection abandoned at that deadline stops at the next boundary.\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 #typescript: Promise<typeof TypeScript>\n\treadonly #services = new Map<string, LanguageService>()\n\treadonly #resident = new Set<string>()\n\treadonly #options = new Map<string, CompilerOptions>()\n\treadonly #files = new Map<string, readonly string[]>()\n\treadonly #diagnostics = new Map<string, readonly Diagnostic[]>()\n\t#overlay: OverlayInterface = new Overlay()\n\t#recycled: string | undefined\n\t#closing: Promise<void> | undefined\n\t#progress = 0\n\t#destroyed = false\n\n\t/**\n\t * Starts warming the target workspace's TypeScript service.\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\tconst typescript = loadWorkspaceModule(this.#workspace, 'typescript')\n\t\tthis.#typescript = this.#warm(typescript)\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.#typescript.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 resident compiler cannot start or the stage has already been destroyed\n\t */\n\tasync inspect(subject: Case, project?: string): Promise<Check> {\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t\tconst started = performance.now()\n\t\tconst typescript = await this.#typescript\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\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\tconst selections = resolved.map((candidate) => ({\n\t\t\tdraft: candidate.draft,\n\t\t\tproject: project ?? inferTypeProject(relativeWorkspaceFile(this.#workspace, candidate.path)),\n\t\t}))\n\t\tthis.#configure(this.#service(typescript, 'tsconfig.json'), 'tsconfig.json')\n\t\tfor (const selection of selections) {\n\t\t\tthis.#configure(this.#service(typescript, selection.project), selection.project)\n\t\t}\n\t\t// Each inspection owns its candidate set and reads it through its own reference, so the\n\t\t// clear that follows releases what this inspection recorded and nothing else. The resident\n\t\t// services read whichever overlay is installed, so a caller admits one inspection at a\n\t\t// time the way `Probe` does.\n\t\tconst overlay = new Overlay()\n\t\tthis.#overlay = overlay\n\t\ttry {\n\t\t\tthis.#record(subject.test, overlay)\n\t\t\tfor (const draft of subject.files) this.#record(draft, overlay)\n\t\t\tthis.#progress += 1\n\t\t\tconst issues: Issue[] = []\n\t\t\tconst projects = new Set<string>()\n\t\t\tconst root = this.#service(typescript, 'tsconfig.json')\n\t\t\tissues.push(...this.#issues(typescript, root, subject.test, 'tsconfig.json', false, true))\n\t\t\tprojects.add('tsconfig.json')\n\t\t\tawait this.#unblock()\n\t\t\tfor (const selection of selections) {\n\t\t\t\tconst draft = selection.draft\n\t\t\t\tconst selected = selection.project\n\t\t\t\tconst service = this.#service(typescript, selected)\n\t\t\t\tissues.push(\n\t\t\t\t\t...this.#issues(\n\t\t\t\t\t\ttypescript,\n\t\t\t\t\t\tservice,\n\t\t\t\t\t\tdraft,\n\t\t\t\t\t\tselected,\n\t\t\t\t\t\tproject !== undefined,\n\t\t\t\t\t\t!projects.has(selected),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\tprojects.add(selected)\n\t\t\t\tawait this.#unblock()\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,\n\t\t\t}\n\t\t} finally {\n\t\t\toverlay.clear()\n\t\t}\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 parse this stage itself applies, filling its cache when the project is not already\n\t * resident, so the reported digest is the configuration the inspection is judged under rather\n\t * than a second parse a caller ran. The returned record is a value copy, so a later eviction\n\t * does not 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, cannot be parsed, or the stage has already\n\t * been destroyed\n\t */\n\tasync resolve(project: string): Promise<Project> {\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t\tconst typescript = await this.#typescript\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t\tconst resolved = resolveWorkspaceFile(this.#workspace, project)\n\t\tthis.#service(typescript, project)\n\t\treturn {\n\t\t\tpath: relativeWorkspaceFile(this.#workspace, resolved),\n\t\t\tdigest: computeDigest(this.#workspace, this.#options.get(resolved) ?? {}),\n\t\t}\n\t}\n\n\tdestroy(): Promise<void> {\n\t\tif (this.#closing !== undefined) return this.#closing\n\t\tthis.#destroyed = true\n\t\tthis.#closing = this.#destroy()\n\t\treturn this.#closing\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. Warming is awaited because the services it\n\t\t// creates are the resources this releases.\n\t\tawait this.#typescript.catch(() => undefined)\n\t\tfor (const service of this.#services.values()) service.dispose()\n\t\tthis.#services.clear()\n\t\tthis.#resident.clear()\n\t\tthis.#recycled = undefined\n\t\tthis.#options.clear()\n\t\tthis.#files.clear()\n\t\tthis.#diagnostics.clear()\n\t}\n\n\tasync #warm(typescript: typeof TypeScript): Promise<typeof TypeScript> {\n\t\tfor (const project of this.#projects()) {\n\t\t\tthis.#resident.add(resolveWorkspaceFile(this.#workspace, project))\n\t\t\tthis.#service(typescript, project)\n\t\t}\n\t\treturn typescript\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// Hands the host's event loop back after one candidate's check, and refuses an inspection this\n\t// stage was torn down during. A language service checks a candidate synchronously, so an\n\t// inspection that never yielded held the loop for its whole duration: the coordinator's\n\t// deadline could not fire against this stage, and the lint child's frames and the runtime\n\t// worker's messages queued behind it until the last candidate finished, which reported one\n\t// stage's overrun against another. Yielding bounds that hold to one candidate. The refusal is\n\t// what stops an abandoned inspection reaching a disposed service and building a replacement\n\t// this stage would then own past its own teardown.\n\tasync #unblock(): Promise<void> {\n\t\tawait setImmediate()\n\t\tif (this.#destroyed) throw createDestroyedError('type stage')\n\t}\n\n\t// Resolution happens here rather than in the overlay, because the workspace a candidate's\n\t// declared path is relative to is the stage's knowledge. A path that escapes the workspace\n\t// throws before the overlay records it, and the inspection's clear releases the rest.\n\t#record(draft: Draft, overlay: OverlayInterface): void {\n\t\toverlay.set(resolveWorkspaceFile(this.#workspace, draft.path), draft.text)\n\t}\n\n\t// Keyed by the resolved project file rather than by the caller's spelling of it, so\n\t// `tsconfig.json` and `./tsconfig.json` reach one resident service instead of two.\n\t#service(typescript: typeof TypeScript, project: string): LanguageService {\n\t\tconst path = resolveWorkspaceFile(this.#workspace, project)\n\t\tconst existing = this.#services.get(path)\n\t\tif (existing !== undefined) return existing\n\t\t// The compiler builds a project diagnostic's own file name in the forward-slash spelling and\n\t\t// then asserts it equals the path the caller handed in. So a native path reaches this seam,\n\t\t// a malformed project makes the compiler construct that diagnostic, and the assertion fails\n\t\t// as a raw `Debug Failure` naming this host's directory layout, outside this package's\n\t\t// failure contract. Hand the compiler the forward-slash spelling, which it accepts on every\n\t\t// host, and it returns the diagnostic instead. Every cache here stays keyed by the native\n\t\t// `path`, so nothing this stage stores or reports moves with it.\n\t\tconst spelling = normalizePath(path)\n\t\tconst config = typescript.readConfigFile(spelling, typescript.sys.readFile)\n\t\tif (config.error !== undefined) {\n\t\t\tthrow new ProbeError(this.#translate(typescript, config.error.messageText, path), {\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\tconst parsed = typescript.parseJsonConfigFileContent(\n\t\t\tconfig.config,\n\t\t\ttypescript.sys,\n\t\t\tdirname(spelling),\n\t\t\tundefined,\n\t\t\tspelling,\n\t\t)\n\t\tif (parsed.errors.length > 0) {\n\t\t\tthrow new ProbeError(this.#translate(typescript, parsed.errors[0]?.messageText, path), {\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\tthis.#options.set(path, parsed.options)\n\t\tthis.#files.set(path, parsed.fileNames)\n\t\tconst host: LanguageServiceHost = {\n\t\t\tgetCompilationSettings: this.#compilationSettings.bind(this, path),\n\t\t\tgetScriptFileNames: this.#scriptFiles.bind(this, path),\n\t\t\tgetScriptVersion: this.#version.bind(this),\n\t\t\tgetScriptSnapshot: this.#snapshot.bind(this, typescript),\n\t\t\tgetCurrentDirectory: this.#directory.bind(this),\n\t\t\tgetDefaultLibFileName: this.#defaultLibrary.bind(this, typescript),\n\t\t\tfileExists: this.#fileExists.bind(this, typescript),\n\t\t\treadFile: this.#readFile.bind(this, typescript),\n\t\t\t// Listings stay on disk. A candidate that entered one would reach the file set this\n\t\t\t// stage caches per project at service creation, and outlive the inspection that\n\t\t\t// declared it, so glob and directory-discovery imports fail closed.\n\t\t\treadDirectory: typescript.sys.readDirectory,\n\t\t\tdirectoryExists: this.#directoryExists.bind(this, typescript),\n\t\t\tgetDirectories: typescript.sys.getDirectories,\n\t\t\tuseCaseSensitiveFileNames: this.#caseSensitive.bind(this, typescript),\n\t\t\tgetNewLine: this.#newline.bind(this, typescript),\n\t\t}\n\t\tconst service = typescript.createLanguageService(host)\n\t\tthis.#services.set(path, service)\n\t\tif (!this.#resident.has(path)) this.#recycle(path)\n\t\treturn service\n\t}\n\n\t#compilationSettings(path: string): CompilerOptions {\n\t\treturn this.#options.get(path) ?? {}\n\t}\n\n\t#scriptFiles(path: string): string[] {\n\t\treturn [...(this.#files.get(path) ?? []), ...this.#overlay.paths]\n\t}\n\n\t#directory(): string {\n\t\treturn this.#workspace\n\t}\n\n\t#defaultLibrary(typescript: typeof TypeScript, options: CompilerOptions): string {\n\t\treturn typescript.getDefaultLibFilePath(options)\n\t}\n\n\t#fileExists(typescript: typeof TypeScript, file: string): boolean {\n\t\treturn this.#overlay.text(file) !== undefined || typescript.sys.fileExists(file)\n\t}\n\n\t#readFile(typescript: typeof TypeScript, file: string): string | undefined {\n\t\treturn this.#overlay.text(file) ?? typescript.sys.readFile(file)\n\t}\n\n\t#directoryExists(typescript: typeof TypeScript, directory: string): boolean {\n\t\treturn typescript.sys.directoryExists(directory) || this.#overlay.covers(directory)\n\t}\n\n\t#caseSensitive(typescript: typeof TypeScript): boolean {\n\t\treturn typescript.sys.useCaseSensitiveFileNames\n\t}\n\n\t#newline(typescript: typeof TypeScript): string {\n\t\treturn typescript.sys.newLine\n\t}\n\n\t// Renders one project diagnostic in the terms this package reports a path in. The compiler names\n\t// the project by the absolute path this stage handed it, and it spells that path either way: the\n\t// native spelling where it echoes what it was given, the forward-slash spelling where it derived\n\t// the path itself. So a caller reads whichever spelling the diagnostic happened to take, and on a\n\t// host whose separator is a backslash that is this host's own directory layout rather than the\n\t// project the caller named. Normalizing the message first makes one replacement cover both\n\t// spellings, and the caller reads the workspace-relative project it asked for.\n\t#translate(\n\t\ttypescript: typeof TypeScript,\n\t\tmessage: string | DiagnosticMessageChain | undefined,\n\t\tpath: string,\n\t): string {\n\t\treturn normalizePath(typescript.flattenDiagnosticMessageText(message, '\\n')).replaceAll(\n\t\t\tnormalizePath(path),\n\t\t\trelativeWorkspaceFile(this.#workspace, path),\n\t\t)\n\t}\n\n\t#configure(service: LanguageService, project: string): void {\n\t\tconst path = resolveWorkspaceFile(this.#workspace, project)\n\t\tif (this.#diagnostics.has(path)) return\n\t\tthis.#diagnostics.set(path, service.getCompilerOptionsDiagnostics())\n\t}\n\n\t// Holds one caller-named project beside the resident set warming created. `project` arrives\n\t// from the wire validated only as a non-empty string, so keeping a language service per\n\t// distinct string would let a caller grow this stage without bound for the life of the process.\n\t#recycle(path: string): void {\n\t\tconst previous = this.#recycled\n\t\tthis.#recycled = path\n\t\tif (previous === undefined || previous === path) return\n\t\tthis.#services.get(previous)?.dispose()\n\t\tthis.#services.delete(previous)\n\t\tthis.#options.delete(previous)\n\t\tthis.#files.delete(previous)\n\t\tthis.#diagnostics.delete(previous)\n\t}\n\n\t#version(file: string): string {\n\t\tif (this.#overlay.text(file) !== undefined) return `virtual:${this.#overlay.revision}`\n\t\ttry {\n\t\t\treturn `disk:${statSync(file).mtimeMs}`\n\t\t} catch {\n\t\t\treturn 'missing'\n\t\t}\n\t}\n\n\t#snapshot(typescript: typeof TypeScript, file: string): IScriptSnapshot | undefined {\n\t\tconst text = this.#overlay.text(file) ?? typescript.sys.readFile(file)\n\t\treturn text === undefined ? undefined : typescript.ScriptSnapshot.fromString(text)\n\t}\n\n\t#issues(\n\t\ttypescript: typeof TypeScript,\n\t\tservice: LanguageService,\n\t\tdraft: Draft,\n\t\tproject: string,\n\t\tselected: boolean,\n\t\tconfigure: boolean,\n\t): readonly Issue[] {\n\t\tconst path = resolveWorkspaceFile(this.#workspace, draft.path)\n\t\tconst configuration = resolveWorkspaceFile(this.#workspace, project)\n\t\tconst diagnostics = [\n\t\t\t...(configure ? (this.#diagnostics.get(configuration) ?? []) : []),\n\t\t\t...service.getSyntacticDiagnostics(path),\n\t\t\t...service.getSemanticDiagnostics(path),\n\t\t]\n\t\treturn diagnostics.map((diagnostic) => this.#issue(typescript, diagnostic, project, selected))\n\t}\n\n\t#issue(\n\t\ttypescript: typeof TypeScript,\n\t\tdiagnostic: Diagnostic,\n\t\tproject: string,\n\t\tselected: boolean,\n\t): Issue {\n\t\tconst message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\\n')\n\t\tif (diagnostic.file === undefined) {\n\t\t\tif (selected) {\n\t\t\t\tthrow new ProbeError(message, {\n\t\t\t\t\torigin: 'claimant',\n\t\t\t\t\tcode: 'refused',\n\t\t\t\t\tcontext: { stage: this.stage, project },\n\t\t\t\t})\n\t\t\t}\n\t\t\treturn { origin: 'instrument', path: project, message }\n\t\t}\n\t\tconst path = relativeWorkspaceFile(this.#workspace, diagnostic.file.fileName)\n\t\tif (diagnostic.start === undefined) return { origin: 'claimant', path, message }\n\t\tconst position = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start)\n\t\treturn { origin: 'claimant', path, message, line: position.line + 1 }\n\t}\n}\n","import type {\n\tCase,\n\tCheck,\n\tClaim,\n\tProbeEventMap,\n\tProbeInterface,\n\tProbeOptions,\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 { createQueue } from '@orkestrel/queue'\nimport { createTimeout } from '@orkestrel/timeout'\nimport {\n\tProbeError,\n\tcomputeReceipt,\n\tcreateDestroyedError,\n\tformatCheck,\n\tformatSpecification,\n} from '@src/core'\nimport { peerDependencies } from '../../package.json' with { type: 'json' }\nimport {\n\tcomputeDigest,\n\tcreateRevisionFile,\n\tdescribeUnknown,\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 resident TypeScript, Oxlint, and Vitest 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\n * ```ts\n * const probe = new Probe({ workspace: '/srv/checkout' })\n * const verdict = await probe.prove(claim)\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\t#arming: Promise<void>\n\t#closing: Promise<void> | undefined\n\t#destroyed = false\n\n\t/**\n\t * Resolves the target toolchain and starts warming the resident stages.\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 ?? 30_000 }).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\tawait this.#ready()\n\t\t\tif (this.#destroyed) 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.#type.resolve(claim.project)\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\tthis.#emitter.emit('error', error)\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.#destroyed = true\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.#destroyed) 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\tconst created = this.#workbench()\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\tthrow 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}\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#workbench(): boolean {\n\t\tconst path = 'tmp/probe'\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 =\n\t\t\t\terror instanceof ProbeError && 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 = createRevisionFile(this.#workspace, 'tmp/probe/arm-type.ts', revision)\n\t\tconst runtimeDependency = createRevisionFile(\n\t\t\tthis.#workspace,\n\t\t\t'tmp/probe/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/probe/${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/probe/${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 after the resident type host cached it',\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\twriteFileSync(\n\t\t\t\ttypeDependency,\n\t\t\t\tformatSpecification('export type Signal = number\\n', revision),\n\t\t\t\t'utf8',\n\t\t\t)\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\twriteFileSync(\n\t\t\t\truntimeDependency,\n\t\t\t\tformatSpecification(\"export const SIGNAL = 'after'\\n\", revision),\n\t\t\t\t'utf8',\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/probe', 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\t#inspectType(inspection: Inspection): Promise<Check> {\n\t\treturn this.#inspectStage(\n\t\t\tthis.#type,\n\t\t\tthis.#type.progress,\n\t\t\tthis.#type.inspect(inspection.subject, inspection.claim.project),\n\t\t\tinspection.claim,\n\t\t)\n\t}\n\n\t#inspectLint(inspection: Inspection): Promise<Check> {\n\t\treturn this.#inspectStage(\n\t\t\tthis.#lint,\n\t\t\tthis.#lint.progress,\n\t\t\tthis.#lint.inspect(inspection.subject),\n\t\t\tinspection.claim,\n\t\t)\n\t}\n\n\t#inspectRuntime(inspection: Inspection): Promise<Check> {\n\t\treturn this.#inspectStage(\n\t\t\tthis.#runtime,\n\t\t\tthis.#runtime.progress,\n\t\t\tthis.#runtime.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: Promise<Check>,\n\t\tclaim: Claim,\n\t): Promise<Check> {\n\t\tconst timeout = createTimeout({ ms: this.#deadline })\n\t\ttimeout.start()\n\t\ttry {\n\t\t\treturn await Promise.race([\n\t\t\t\toperation,\n\t\t\t\tthis.#expiry(\n\t\t\t\t\ttimeout,\n\t\t\t\t\t`The ${stage.stage} stage exceeded ${this.#deadline} ms`,\n\t\t\t\t\tstage,\n\t\t\t\t\tprogress,\n\t\t\t\t),\n\t\t\t])\n\t\t} catch (error) {\n\t\t\tif (!timeout.expired) throw error\n\t\t\t// The recovery runs before this handler returns, so the replacement is installed before\n\t\t\t// the queue admits the next inspection and the claim behind this one meets a stage that\n\t\t\t// serves rather than one that reports a stranger's expiry.\n\t\t\tif (await this.#recycle(stage)) this.#emitter.emit('expire', claim)\n\t\t\tthrow error\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\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.#destroyed) 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// 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\treject(\n\t\t\t\t\t\tnew ProbeError(message, {\n\t\t\t\t\t\t\torigin: stage.progress > progress ? 'claimant' : 'instrument',\n\t\t\t\t\t\t\tcode: 'deadline',\n\t\t\t\t\t\t\tcontext: { stage: stage.stage, deadline: this.#deadline },\n\t\t\t\t\t\t}),\n\t\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\tawait this.#arming\n\t\t} catch {}\n\t\t// Tear the stages down and leave the queues running. A queue holds no host resource — no\n\t\t// timer, no listener, no store — and stage teardown settles every entry still admitted, so\n\t\t// each caller reads the stage's own refusal. Destroying a queue instead abandons those\n\t\t// entries, and a stage rejecting after its queue stopped observing ends the host process.\n\t\tawait Promise.all([this.#type.destroy(), this.#lint.destroy(), this.#runtime.destroy()])\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 (typeof version !== 'string') {\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#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 { PassThrough } from 'node:stream'\nimport { compileSchema, schemaToParameters } from '@orkestrel/contract'\nimport { createMCPLegacy, createMCPServer } from '@orkestrel/mcp'\nimport { createStdioServer } from '@orkestrel/mcp/server'\nimport { createTool, createToolManager } from '@orkestrel/tool'\nimport {\n\tCLAIM_SHAPE,\n\tProbeError,\n\tcreateDestroyedError,\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 * Serves one probe over this process's Model Context Protocol stdio transport.\n *\n * @remarks\n * Construction creates the probe, publishes the `prove` tool, and binds the dual-era dispatcher to\n * the stdio transport. The probe begins warming there, so a harness that spawns the entry pays\n * arming while its client is still handshaking.\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 #probe: ProbeInterface\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\t#owns: boolean | undefined\n\t#closing: Promise<void> | undefined\n\n\t/**\n\t * Creates the probe this server publishes and binds it to this process's stdio transport.\n\t *\n\t * @param options - Workspace, deadline, and initial observation hooks for the probe it creates\n\t */\n\tconstructor(options?: ProbeOptions) {\n\t\tthis.#probe = new Probe(options)\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\tthis.#transport = createStdioServer(createMCPLegacy(this.#publish()), { 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\tawait this.#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\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\treturn this.#probe.prove(input)\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}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