@orkestrel/capture 0.0.9 → 0.0.10
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.
- package/README.md +4 -2
- package/dist/src/core/index.cjs +75 -22
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +124 -51
- package/dist/src/core/index.d.ts +124 -51
- package/dist/src/core/index.js +73 -22
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +1012 -316
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +523 -22
- package/dist/src/server/index.d.ts +523 -22
- package/dist/src/server/index.js +991 -319
- package/dist/src/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/server/constants.ts","../../../src/server/helpers.ts","../../../src/server/CaptureDiscovery.ts","../../../src/server/CaptureIntegrity.ts","../../../src/server/CaptureInvocation.ts","../../../src/server/CapturePreflight.ts","../../../src/server/CaptureRegistrar.ts","../../../src/server/CaptureRunner.ts","../../../src/server/CaptureSheets.ts","../../../src/server/CaptureCLI.ts","../../../src/server/factories.ts"],"sourcesContent":["/**\n * Names the executable subcommand each runner command answers to.\n *\n * @remarks\n * The frame-placing command is `capture` in the request protocol and `frames` on the command line,\n * because `capture capture` would stutter. The usage text prints the command-line name.\n *\n * @example\n * ```ts\n * CAPTURE_COMMAND_NAMES.capture // 'frames'\n * ```\n */\nexport const CAPTURE_COMMAND_NAMES = Object.freeze({\n\tjourney: 'journey',\n\tcapture: 'frames',\n\tstale: 'stale',\n} as const)\n\n/**\n * Holds the exit status each runner outcome maps to.\n *\n * @remarks `passed` is every stage green with work run, `failed` is a failed stage or an empty\n * workload, and `usage` is a refused command line or selection.\n *\n * @example\n * ```ts\n * CAPTURE_EXIT.usage // 64\n * ```\n */\nexport const CAPTURE_EXIT = Object.freeze({ passed: 0, failed: 1, usage: 64 } as const)\n\n/**\n * Names the exclusive workspace invocation marker.\n * @example\n * ```ts\n * CAPTURE_OWNER_FILE // '.capture-owner'\n * ```\n */\nexport const CAPTURE_OWNER_FILE = '.capture-owner'\n\n/**\n * Holds the largest process id a POSIX or Windows host can assign, the signed 32-bit maximum.\n * @example\n * ```ts\n * CAPTURE_PID_LIMIT // 2147483647\n * ```\n */\nexport const CAPTURE_PID_LIMIT = 2_147_483_647\n\n/**\n * Caps each refusal population so hostile records cannot flood a terminal or agent context.\n * @example\n * ```ts\n * CAPTURE_REFUSAL_LIMIT // 16\n * ```\n */\nexport const CAPTURE_REFUSAL_LIMIT = 16\n\n/**\n * Bounds external diagnostic text while retaining the number of omitted characters.\n * @example\n * ```ts\n * CAPTURE_MESSAGE_LIMIT // 1024\n * ```\n */\nexport const CAPTURE_MESSAGE_LIMIT = 1024\n\n/**\n * Names the selected journey stage and the narrow and remaining frame stages.\n *\n * @example\n * ```ts\n * CAPTURE_STAGES.first // 'narrow'\n * ```\n */\nexport const CAPTURE_STAGES = Object.freeze({\n\tselected: 'selected',\n\tfirst: 'narrow',\n\trest: 'rest',\n} as const)\n\n/**\n * Defines each command's frozen options for Node's standard argument parser.\n *\n * @remarks A boolean option whose default is `true` reads only its `--no-` form, which sets it to\n * `false`; `bail` is the one such option.\n *\n * @example\n * ```ts\n * CAPTURE_COMMAND_OPTIONS.journey.variant.multiple // true\n * ```\n */\nexport const CAPTURE_COMMAND_OPTIONS = Object.freeze({\n\tjourney: Object.freeze({\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tchanged: Object.freeze({ type: 'string' }),\n\t\tplan: Object.freeze({ type: 'boolean' }),\n\t\tbail: Object.freeze({ type: 'boolean', default: true }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tcapture: Object.freeze({\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tchanged: Object.freeze({ type: 'string' }),\n\t\tplan: Object.freeze({ type: 'boolean' }),\n\t\tbail: Object.freeze({ type: 'boolean', default: true }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tstale: Object.freeze({\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tportfolio: Object.freeze({ type: 'string' }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tpreflight: Object.freeze({\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tportfolio: Object.freeze({ type: 'string' }),\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tjourneys: Object.freeze({ type: 'string' }),\n\t\tchecks: Object.freeze({ type: 'string' }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tsheets: Object.freeze({\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tportfolio: Object.freeze({ type: 'string' }),\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tjourneys: Object.freeze({ type: 'string' }),\n\t\tchecks: Object.freeze({ type: 'string' }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t\toutput: Object.freeze({ type: 'string' }),\n\t}),\n\tregistry: Object.freeze({\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tbail: Object.freeze({ type: 'boolean', default: true }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tprogress: Object.freeze({}),\n} as const)\n\n/**\n * Lists the words a tag name can never be, because a tag filter reads them as operators.\n *\n * @example\n * ```ts\n * CAPTURE_TAG_OPERATORS.includes('and') // true\n * ```\n */\nexport const CAPTURE_TAG_OPERATORS: readonly string[] = Object.freeze(['and', 'or', 'not'])\n\n/**\n * Names the environment variable that turns frame capture on for a Vitest child.\n *\n * @example\n * ```ts\n * process.env[CAPTURE_FLAG] = CAPTURE_FLAG_VALUE\n * ```\n */\nexport const CAPTURE_FLAG = 'CAPTURE'\n\n/**\n * Holds the one value of the capture variable that turns frame capture on.\n *\n * @example\n * ```ts\n * CAPTURE_FLAG_VALUE // '1'\n * ```\n */\nexport const CAPTURE_FLAG_VALUE = '1'\n\n/**\n * Names the repository-relative path of the Vitest entry the runner spawns through Node.\n *\n * @example\n * ```ts\n * resolve(root, CAPTURE_VITEST_ENTRY)\n * ```\n */\nexport const CAPTURE_VITEST_ENTRY = 'node_modules/vitest/vitest.mjs'\n\n/**\n * Names the directory beneath a portfolio or request directory that holds one invocation's records.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_RUNS_DIRECTORY}/a/narrow/light-390.json`\n * ```\n */\nexport const CAPTURE_RUNS_DIRECTORY = 'runs'\n\n/**\n * Names the ending of the progress file each stage writes beneath its invocation's run directory.\n *\n * @remarks The stage's name precedes it, so `selected` writes `selected.progress.jsonl`.\n *\n * @example\n * ```ts\n * `tmp/capture/${CAPTURE_RUNS_DIRECTORY}/a/selected${CAPTURE_PROGRESS_SUFFIX}`\n * ```\n */\nexport const CAPTURE_PROGRESS_SUFFIX = '.progress.jsonl'\n\n/**\n * Names the prefixes a journey wrapper derives its own paths from.\n *\n * @remarks `scratch` precedes the variant in the sibling of the evidence root a run without frame\n * capture writes to, and `direct` precedes the random identity of a run no runner started.\n *\n * @example\n * ```ts\n * `tmp/captures/${CAPTURE_WRAPPER_PREFIXES.scratch}light-390` // 'tmp/captures/no-capture-light-390'\n * ```\n */\nexport const CAPTURE_WRAPPER_PREFIXES = Object.freeze({\n\tscratch: 'no-capture-',\n\tdirect: 'direct-',\n} as const)\n\n/** Names the create-only child record beneath an invocation's run directory.\n * @example\n * ```ts\n * CAPTURE_SURVIVORS_FILE // 'survivors.json'\n * ```\n */\nexport const CAPTURE_SURVIVORS_FILE = 'survivors.json'\n\n/**\n * Holds the byte count under which an image is too small to be a real frame.\n *\n * @example\n * ```ts\n * bytes.length < CAPTURE_MINIMUM_IMAGE // true for a blank placeholder\n * ```\n */\nexport const CAPTURE_MINIMUM_IMAGE = 4000\n\n/**\n * Bounds decoded image memory, row metadata, and PNG input bytes independently of untrusted headers.\n *\n * @remarks The pixel budget admits the fleet's 2880 × 6000 and 1170 × 15000 Chromium full-page\n * frames with 19.5% margin over 17,550,000 pixels. The byte budget adds 20% to the largest RGBA\n * scanlines for deflate overhead, chunk framing, and metadata, before any read or compressed copy.\n * A valid 1 × 1 PNG padded to the derived byte boundary peaked at 171 MiB process RSS.\n * Isolated Windows Node runs on 2026-10-28 measured the fixture peaks noted beside each bound;\n * these measurements are not a universal process RSS ceiling.\n * @example\n * ```ts\n * CAPTURE_PNG_LIMITS.pixels // 20971520\n * ```\n */\nexport const CAPTURE_PNG_LIMITS = Object.freeze({\n\t// Bounds inflated storage; stored-deflate RGBA at this pixel boundary peaked at 438 MiB RSS.\n\tpixels: 20 * 1024 * 1024,\n\t// Bounds row metadata; the 131072 × 160 RGBA fixture peaked at 456 MiB RSS.\n\tside: 131_072,\n\t// Allows 20% over maximum RGBA scanlines for deflate, chunks, and metadata.\n\tbytes: Math.ceil((4 * (20 * 1024 * 1024) + 131_072) * 1.2),\n} as const)\n\n/** Bounds a synchronous ownership retry sequence in milliseconds, including host contention.\n * @example\n * ```ts\n * CAPTURE_OWNER_TIMEOUT // 1000\n * ```\n */\nexport const CAPTURE_OWNER_TIMEOUT = 1000\n\n/** Yields between ownership probes in milliseconds so filesystem contention can settle.\n * @example\n * ```ts\n * CAPTURE_OWNER_BACKOFF // 10\n * ```\n */\nexport const CAPTURE_OWNER_BACKOFF = 10\n\n/**\n * Names the first word of the line a reader prints, followed by its JSON report.\n *\n * @example\n * ```ts\n * `${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify(report)}\\n`\n * ```\n */\nexport const CAPTURE_REPORT_LINES = Object.freeze({\n\tpreflight: 'READER',\n\tsheets: 'SHEETS',\n} as const)\n\n/**\n * Holds the contact-sheet geometry: how wide a cell shrinks toward, how tall it may grow, the mark\n * that stands in for an unreadable image, the gap between neighbors, and how many cells, rows, and\n * pairs a row and a sheet hold.\n *\n * @example\n * ```ts\n * CAPTURE_SHEET.cell // 320\n * ```\n */\nexport const CAPTURE_SHEET = Object.freeze({\n\tcell: 320,\n\tlimit: 400,\n\tmark: Object.freeze({ width: 160, height: 20, present: 220, absent: 20 }),\n\tgap: 12,\n\tpairs: 2,\n\trows: 4,\n} as const)\n\n/**\n * Names the contact-sheet files: the sheet prefix and digits, and the two index documents.\n *\n * @example\n * ```ts\n * `${CAPTURE_SHEET_FILES.prefix}001.png` // 'sheet-001.png'\n * ```\n */\nexport const CAPTURE_SHEET_FILES = Object.freeze({\n\tprefix: 'sheet-',\n\tdigits: 3,\n\tindex: 'index.json',\n\tnotes: 'index.md',\n} as const)\n\n/**\n * Names the one stage a registry refresh runs every selected producing variant's complete journey in.\n *\n * @example\n * ```ts\n * `runs/${id}/${CAPTURE_REGISTRY_STAGE}/light-390.json` // 'runs/<id>/registry/light-390.json'\n * ```\n */\nexport const CAPTURE_REGISTRY_STAGE = 'registry'\n\n/**\n * Names the first word of the line the registry refresh prints, followed by its JSON summary.\n *\n * @example\n * ```ts\n * `${CAPTURE_REGISTRY_LINE} ${JSON.stringify(summary)}\\n`\n * ```\n */\nexport const CAPTURE_REGISTRY_LINE = 'REGISTRY'\n\n/**\n * Names the executable's subcommands in the order its usage text lists them.\n *\n * @remarks\n * `frames` runs the `capture` request command, so `capture capture` never stutters. The other\n * names are their own commands.\n *\n * @example\n * ```ts\n * CAPTURE_SUBCOMMANDS.includes('registry') // true\n * ```\n */\nexport const CAPTURE_SUBCOMMANDS: readonly string[] = Object.freeze([\n\t'journey',\n\t'frames',\n\t'stale',\n\t'preflight',\n\t'sheets',\n\t'registry',\n\t'progress',\n])\n\n/**\n * Holds the repository-relative paths the executable falls back to when the command line names none.\n *\n * @remarks\n * `config` is the journey wrapper a scaffold-born browser application carries, `requests` is the\n * one default directory the runner publishes its request file to, and `journeys` is the directory\n * of journey artifacts the readers read. The runner hands the directory it uses to every child in\n * `CAPTURE_REQUESTS`, and `readCaptureRequest` and `answerCaptureDiscovery` read it from there when\n * the wrapper names none, so a wrapper never repeats this value. `--config` replaces the wrapper\n * and `--journeys` the artifacts.\n *\n * @example\n * ```ts\n * CAPTURE_DEFAULTS.config // 'configs/app/vite.journey.config.ts'\n * ```\n */\nexport const CAPTURE_DEFAULTS = Object.freeze({\n\tconfig: 'configs/app/vite.journey.config.ts',\n\trequests: 'tmp/capture',\n\tjourneys: 'tmp/journey',\n} as const)\n\n/**\n * Names the environment variable that carries the absolute request directory to a Vitest child.\n *\n * @remarks\n * The runner sets it on every child it spawns, the discovery child included. A wrapper that names no\n * request directory reads it, so the runner and the wrapper agree without a repeated constant.\n *\n * @example\n * ```ts\n * process.env[CAPTURE_REQUESTS_FLAG] // '/repo/tmp/capture' inside a runner's child\n * ```\n */\nexport const CAPTURE_REQUESTS_FLAG = 'CAPTURE_REQUESTS'\n\n/**\n * Holds the discovery exchange's fixed names and bound.\n *\n * @remarks\n * `phase` is the value that marks a request as a discovery request, `description` is the file the\n * wrapper writes inside the invocation directory, `arguments` are the Vitest arguments that list the\n * configuration's test files without collecting a test, `deadline` is the longest, in milliseconds,\n * the discovery child may run.\n *\n * @example\n * ```ts\n * CAPTURE_DISCOVERY.phase // 'discover'\n * ```\n */\nexport const CAPTURE_DISCOVERY = Object.freeze({\n\tphase: 'discover',\n\tdescription: 'description.json',\n\targuments: Object.freeze(['list', '--filesOnly']),\n\tdeadline: 60_000,\n} as const)\n\n/**\n * Holds the usage text the executable prints when it is given no subcommand or an unknown one.\n *\n * @example\n * ```ts\n * CAPTURE_USAGE.split('\\n')[0] // 'Usage: capture <command> [arguments]'\n * ```\n */\nexport const CAPTURE_USAGE = [\n\t'Usage: capture <command> [arguments]',\n\t'Commands:',\n\t' journey <selector> [--variant <name>]... [--case <full name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' journey --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' frames <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' frames --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--state <name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' stale <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--portfolio <name>] [--mode <name>] [--config <file>]',\n\t' preflight <selector> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--mode <name>] [--config <file>] [--journeys <directory>] [--checks <module>]',\n\t' sheets <selector> --output <new directory> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--mode <name>] [--config <file>] [--journeys <directory>] [--checks <module>]',\n\t' registry [--variant <name>]... [--no-bail] [--mode <name>] [--config <file>]',\n\t' progress',\n\t'--changed takes one Git ref; HEAD selects uncommitted work. It cannot accompany a selector.',\n\t'--plan requires --changed and prints paths and commands after read-only discovery; no execution child starts.',\n\t'--no-bail runs every selected case after a failure; by default a stage stops at its first failed case.',\n\t'progress prints where the stage that is running, or that ran last, stands, from its progress file.',\n\t'Only --variant repeats. Every flag except --plan and --no-bail takes one nonempty value, as --flag value or --flag=value; use --flag=-x for a value beginning with a dash. The -- terminator is refused.',\n\t'Exit: 0 passed, 1 failed or refused by the evidence, 64 refused usage.',\n].join('\\n')\n","import type { ParseArgsOptionsConfig } from 'node:util'\nimport type { ProgressInitEvent, ProgressRun } from '@orkestrel/test/server'\nimport type {\n\tCaptureCollectionReceipt,\n\tCaptureDestination,\n\tCaptureDigest,\n\tCaptureLookup,\n\tCaptureLookupJournal,\n\tCapturePortfolioRoot,\n\tCaptureProvided,\n\tCaptureRegistry,\n\tCaptureRequest,\n\tCaptureViewport,\n} from '@src/core'\nimport type {\n\tCaptureArgumentsOptions,\n\tCaptureChange,\n\tCaptureChangePlan,\n\tCaptureCommand,\n\tCaptureDescriptionExpectation,\n\tCaptureDiscoveryConfig,\n\tCaptureDiscoveryOptions,\n\tCaptureFileSnapshot,\n\tCaptureHashHandler,\n\tCaptureHolder,\n\tCaptureHostDescription,\n\tCaptureHostEntry,\n\tCaptureImageResult,\n\tCaptureIntegrityOptions,\n\tCaptureInputHandler,\n\tCaptureParsedArguments,\n\tCapturePicture,\n\tCaptureProducer,\n\tCaptureProgress,\n\tCaptureProject,\n\tCaptureReaderCommand,\n\tCaptureReaderDefaults,\n\tCaptureReceiptInput,\n\tCaptureRetractionHandler,\n\tCaptureTerminationHandler,\n\tCaptureRegistryArguments,\n\tCaptureRequestOptions,\n\tCaptureRunnerArguments,\n\tCaptureStagePlan,\n\tCaptureWrapperConfig,\n\tCaptureWrapperOptions,\n\tCaptureWrapperOverride,\n} from './types.js'\nimport { createHash, randomUUID } from 'node:crypto'\nimport {\n\texistsSync,\n\tcloseSync,\n\tfstatSync,\n\topenSync,\n\treadSync,\n\tglobSync,\n\tlstatSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trealpathSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { dirname, isAbsolute, matchesGlob, relative, resolve, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { parseArgs } from 'node:util'\nimport { crc32, deflateSync, inflateSync } from 'node:zlib'\nimport {\n\tarrayOf,\n\tattempt,\n\tisArray,\n\tisError,\n\tisFunction,\n\tisRecord,\n\tisString,\n\tparseJSON,\n\tpreview,\n} from '@orkestrel/contract'\nimport { inspectProcess } from '@orkestrel/process/server'\nimport {\n\tcomputeProgress,\n\tcomputeProgressRun,\n\tcreateProgressPlugin,\n\textractProgressEvents,\n\treadFileSnapshot,\n\trenderProgress,\n} from '@orkestrel/test/server'\nimport {\n\tCAPTURE_LOOKUPS_FILE,\n\tCAPTURE_MANIFEST_FILE,\n\tCAPTURE_OWNER_PREFIX,\n\tCAPTURE_PNG_SIGNATURE,\n\tCAPTURE_REGISTRY_FILE,\n\tCAPTURE_REQUEST_PREFIX,\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tbuildCaptureTags,\n\tcollectCaptureAncestors,\n\tdescribeCaptureDeclaration,\n\tdescribeCaptureDestination,\n\tdescribeCaptureError,\n\tisCaptureGeometry,\n\tisCaptureError,\n\tisCapturePath,\n\tisCapturePattern,\n\tisCaptureReceipt,\n\tisCaptureRegistry,\n\tisCaptureSegment,\n\tisCaptureSelector,\n\tmatchesCaptureMembers,\n\tmatchesCaptureSelector,\n\treadCaptureReport,\n\trequireCaptureUnique,\n\tresolveCaptureKey,\n\tresolveCaptureOwner,\n\tresolveLookupKey,\n\tvalidateCaptureReceipt,\n} from '@src/core'\nimport {\n\tCAPTURE_COMMAND_NAMES,\n\tCAPTURE_COMMAND_OPTIONS,\n\tCAPTURE_DEFAULTS,\n\tCAPTURE_DISCOVERY,\n\tCAPTURE_EXIT,\n\tCAPTURE_FLAG,\n\tCAPTURE_FLAG_VALUE,\n\tCAPTURE_PID_LIMIT,\n\tCAPTURE_PNG_LIMITS,\n\tCAPTURE_PROGRESS_SUFFIX,\n\tCAPTURE_REQUESTS_FLAG,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_STAGES,\n\tCAPTURE_REFUSAL_LIMIT,\n\tCAPTURE_MESSAGE_LIMIT,\n\tCAPTURE_TAG_OPERATORS,\n\tCAPTURE_WRAPPER_PREFIXES,\n} from './constants.js'\n\n/**\n * Hashes exact source or image bytes with SHA-256.\n *\n * @param bytes - The bytes, or the explicitly encoded UTF-8 text\n * @returns The lowercase hexadecimal digest\n *\n * @example\n * ```ts\n * computeCaptureHash('') // 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n * ```\n */\nexport function computeCaptureHash(bytes: string | Uint8Array): string {\n\treturn createHash('sha256').update(bytes).digest('hex')\n}\n\n/**\n * Classifies changed paths through accepted patterns and reduces owners by ancestry.\n *\n * @param paths - Git paths, including removed paths that no longer exist\n * @param entries - The authenticated accepted registry destinations\n * @returns Sorted path classifications and sorted minimal owners; shared patterns take precedence\n * @example\n * ```ts\n * buildCaptureChangePlan(['README.md'], []).changes\n * // [{ path: 'README.md', classification: 'outside', owners: [] }]\n * ```\n */\nexport function buildCaptureChangePlan(\n\tpaths: readonly string[],\n\tentries: readonly CaptureDestination[],\n): CaptureChangePlan {\n\tconst population = [...new Set(entries.map(resolveCaptureOwner))].toSorted()\n\tconst changes = [...new Set(paths)].toSorted().map((path): CaptureChange => {\n\t\tif (\n\t\t\tentries.some((entry) =>\n\t\t\t\t[...entry.sources.shared, ...entry.sources.tests].some((pattern) =>\n\t\t\t\t\tmatchesGlob(path, pattern),\n\t\t\t\t),\n\t\t\t)\n\t\t)\n\t\t\treturn { path, classification: 'shared', owners: population }\n\t\tconst owners = [\n\t\t\t...new Set(\n\t\t\t\tentries\n\t\t\t\t\t.filter((entry) => entry.sources.own.some((pattern) => matchesGlob(path, pattern)))\n\t\t\t\t\t.map(resolveCaptureOwner),\n\t\t\t),\n\t\t].toSorted()\n\t\treturn { path, classification: owners.length === 0 ? 'outside' : 'own', owners }\n\t})\n\tconst owners = [\n\t\t...new Set(\n\t\t\tchanges\n\t\t\t\t.filter((change) => change.classification === 'own')\n\t\t\t\t.flatMap((change) => change.owners),\n\t\t),\n\t].toSorted()\n\treturn {\n\t\tchanges,\n\t\towners: owners.filter(\n\t\t\t(owner) =>\n\t\t\t\t!owners.some((ancestor) => ancestor !== owner && matchesCaptureSelector(owner, ancestor)),\n\t\t),\n\t}\n}\n\n/**\n * Renders an exact owner command with the selected variants and filters in host shell syntax.\n *\n * @param command - The request command, translated to its executable name, or the registry command\n * @param parsed - The parsed flags, a `false` bail rendered as `--no-bail` on every command but `stale`; changed and plan flags are deliberately replaced by the owner\n * @param selector - The explicit owner or all selector; omitted for a registry refresh\n * @param root - The workspace that makes the wrapper path relative\n * @returns The command ready to copy into the host shell\n * @example\n * ```ts\n * renderCaptureCommand('journey', { config: '/repo/journey.ts', variants: [] }, 'pages:mail', '/repo')\n * // 'capture journey pages:mail --config journey.ts'\n * ```\n */\nexport function renderCaptureCommand(\n\tcommand: CaptureCommand | 'registry',\n\tparsed: CaptureRunnerArguments,\n\tselector: string | undefined,\n\troot: string,\n): string {\n\tconst config = resolveCaptureRelative(root, parsed.config)\n\treturn [\n\t\t'capture',\n\t\tcommand === 'registry' ? command : CAPTURE_COMMAND_NAMES[command],\n\t\t...(selector === undefined ? [] : [selector]),\n\t\t...parsed.variants.flatMap((variant) => ['--variant', variant]),\n\t\t...(parsed.mode === undefined ? [] : ['--mode', parsed.mode]),\n\t\t...(parsed.case === undefined\n\t\t\t? []\n\t\t\t: parsed.case.startsWith('-')\n\t\t\t\t? [`--case=${parsed.case}`]\n\t\t\t\t: ['--case', parsed.case]),\n\t\t...(parsed.state === undefined ? [] : ['--state', parsed.state]),\n\t\t...(parsed.bail === false && command !== 'stale' ? ['--no-bail'] : []),\n\t\t...(config.startsWith('-') ? [`--config=${config}`] : ['--config', config]),\n\t]\n\t\t.map((argument) =>\n\t\t\t/^[\\w./:-]+$/u.test(argument)\n\t\t\t\t? argument\n\t\t\t\t: process.platform === 'win32'\n\t\t\t\t\t? `'${argument.replaceAll(\"'\", \"''\")}'`\n\t\t\t\t\t: `'${argument.replaceAll(\"'\", \"'\\\\''\")}'`,\n\t\t)\n\t\t.join(' ')\n}\n\n/**\n * Normalizes a host path to forward slashes.\n *\n * @param path - A host path\n * @returns The same path with every backslash replaced by a slash\n *\n * @example\n * ```ts\n * normalizeSlashes('tmp\\\\captures\\\\a.png') // 'tmp/captures/a.png'\n * ```\n */\nexport function normalizeSlashes(path: string): string {\n\treturn path.replaceAll('\\\\', '/')\n}\n\n/**\n * Finds the nearest existing path without following a dangling link.\n *\n * @example\n * ```ts\n * readCaptureAncestor('/workspace/missing/file') // '/workspace'\n * ```\n */\nexport function readCaptureAncestor(path: string): string {\n\ttry {\n\t\tlstatSync(path)\n\t\treturn path\n\t} catch (error) {\n\t\tif (!isError(error) || !('code' in error) || error.code !== 'ENOENT' || dirname(path) === path)\n\t\t\tthrow error\n\t\treturn readCaptureAncestor(dirname(path))\n\t}\n}\n\n/**\n * Resolves an existing path or its nearest existing ancestor to its physical destination.\n *\n * @example\n * ```ts\n * resolveCapturePhysical('/workspace/alias/new') // '/workspace/target/new'\n * ```\n */\nexport function resolveCapturePhysical(path: string): string {\n\tconst ancestor = readCaptureAncestor(path)\n\treturn resolve(realpathSync(ancestor), relative(ancestor, path))\n}\n\n/**\n * Validates a physical destination against a physical root before any read or write.\n *\n * @returns The physical destination, including its missing suffix\n * @throws Thrown when the destination or an existing ancestor escapes the root.\n * @example\n * ```ts\n * requireCaptureContained('/workspace', '/workspace/tmp/new') // '/workspace/tmp/new'\n * ```\n */\nexport function requireCaptureContained(root: string, path: string): string {\n\tconst physical = resolveCapturePhysical(path)\n\tconst suffix = relative(realpathSync(root), physical)\n\tif (isAbsolute(suffix) || suffix === '..' || suffix.startsWith(`..${sep}`))\n\t\tthrow new CaptureError(`Physical path resolves outside integrity root: ${path}`, {\n\t\t\tcode: 'CONTAINMENT',\n\t\t})\n\treturn physical\n}\n\n/** Validates a supplied path argument before work and classifies an outside value as usage.\n * @param root - The repository root\n * @param path - The supplied path resolved against the root\n * @param flag - The command line flag that supplied the path\n * @returns The contained physical path\n * @example\n * ```ts\n * requireCaptureArgument('/workspace', '/workspace/checks.ts', '--checks')\n * ```\n */\nexport function requireCaptureArgument(root: string, path: string, flag: string): string {\n\ttry {\n\t\treturn requireCaptureContained(root, path)\n\t} catch (error) {\n\t\tthrow new CaptureError(\n\t\t\t`${flag} ${isCaptureError(error) && error.code === 'CONTAINMENT' ? 'resolves outside the repository' : 'cannot resolve its filesystem path'}: ${preview(path)}; supply a contained repository path`,\n\t\t\t{ code: 'USAGE', cause: error },\n\t\t)\n\t}\n}\n\n/** Recognizes filesystem contention codes that ownership arbitration can retry.\n * @param error - The host operation's refusal\n * @param platform - The host contract; Windows permission errors can reflect handles without delete sharing\n * @returns Whether the error names temporary ownership contention\n * @example\n * ```ts\n * matchesCaptureTransient(Object.assign(new Error('busy'), { code: 'EBUSY' })) // true\n * ```\n */\nexport function matchesCaptureTransient(\n\terror: unknown,\n\tplatform: NodeJS.Platform = process.platform,\n): boolean {\n\treturn (\n\t\terror instanceof Error &&\n\t\t'code' in error &&\n\t\t['EBUSY', 'EMFILE', ...(platform === 'win32' ? ['EPERM', 'EACCES'] : [])].includes(\n\t\t\tString(error.code),\n\t\t)\n\t)\n}\n\n/**\n * Names a sheet group by portfolio, owner, and state independently of its output variant.\n *\n * @example\n * ```ts\n * resolveCaptureSheetIdentity(entry) // '[\"states\",\"pages:mail\",\"mail-screen\"]'\n * ```\n */\nexport function resolveCaptureSheetIdentity(entry: CaptureDestination): string {\n\treturn JSON.stringify([entry.portfolio, resolveCaptureOwner(entry), entry.state])\n}\n\n/**\n * Splits a list into consecutive pages with at most the requested size.\n *\n * @example\n * ```ts\n * splitCapturePages([1, 2, 3], 2) // [[1, 2], [3]]\n * ```\n */\nexport function splitCapturePages<T>(\n\tentries: readonly T[],\n\tsize: number,\n): ReadonlyArray<readonly T[]> {\n\treturn Array.from({ length: Math.ceil(entries.length / size) }, (_, index) =>\n\t\tentries.slice(index * size, index * size + size),\n\t)\n}\n\n/**\n * Compares file content, size, modification time, and change time across two snapshots.\n *\n * @example\n * ```ts\n * matchesCaptureFile(previous, undefined) // false\n * ```\n */\nexport function matchesCaptureFile(\n\tprevious: CaptureFileSnapshot,\n\tcurrent: CaptureFileSnapshot | undefined,\n): boolean {\n\treturn (\n\t\tcurrent !== undefined &&\n\t\tcurrent.image.digest === previous.image.digest &&\n\t\tcurrent.image.size === previous.image.size &&\n\t\tcurrent.image.modified === previous.image.modified &&\n\t\tcurrent.changed === previous.changed\n\t)\n}\n\n/**\n * Merges unique lookup populations with incoming identities replacing inherited ones.\n *\n * @example\n * ```ts\n * mergeCaptureLookups([lookup], [lookup]) // [lookup]\n * ```\n */\nexport function mergeCaptureLookups(\n\tprevious: readonly CaptureLookup[],\n\tlookups: readonly CaptureLookup[],\n): readonly CaptureLookup[] {\n\trequireCaptureUnique(previous.map(resolveLookupKey), 'inherited lookup identities')\n\trequireCaptureUnique(lookups.map(resolveLookupKey), 'incoming lookup identities')\n\tconst replaced = new Set(lookups.map(resolveLookupKey))\n\treturn [...previous.filter((entry) => !replaced.has(resolveLookupKey(entry))), ...lookups]\n}\n\n/**\n * Describes a refusal with its key path, bounded preview, correction, and member differences.\n *\n * @example\n * ```ts\n * describeCaptureFault('--variant[0]', 'bad/name', 'a portable segment')\n * ```\n */\nexport function describeCaptureFault(\n\tpath: string,\n\tvalue: unknown,\n\texpected: string,\n\tcandidates: readonly string[] = [],\n\trequired: readonly string[] = [],\n\tallowed: readonly string[] = required,\n): string {\n\tconst keys = isRecord(value) ? Object.keys(value) : []\n\tconst missing = required.filter((key) => !isRecord(value) || value[key] === undefined)\n\tconst unexpected = keys.filter((key) => !allowed.includes(key))\n\tconst population = [...new Set([...required, ...keys])]\n\tconst members = isRecord(value)\n\t\t? `; members: {${population\n\t\t\t\t.slice(0, CAPTURE_REFUSAL_LIMIT)\n\t\t\t\t.map((key) => `${preview(`${path}.${key}`)}: ${preview(value[key])}`)\n\t\t\t\t.join(\n\t\t\t\t\t', ',\n\t\t\t\t)}${population.length > CAPTURE_REFUSAL_LIMIT ? `, … ${String(population.length - CAPTURE_REFUSAL_LIMIT)} more` : ''}}`\n\t\t: ''\n\treturn `${path.length > 80 ? preview(path) : path}: received ${preview(value)}${members}; expected ${expected}; valid candidates: ${describeCaptureMembers(candidates)}; missing: ${describeCaptureMembers(missing)}; unexpected: ${describeCaptureMembers(unexpected)}`\n}\n\n/**\n * Describes a bounded member population and the number omitted from its preview.\n * @example\n * ```ts\n * describeCaptureMembers(['wide', 'phone']) // '[\"wide\",\"phone\"]'\n * ```\n */\nexport function describeCaptureMembers(members: readonly string[]): string {\n\treturn `[${members.slice(0, CAPTURE_REFUSAL_LIMIT).map(preview).join(',')}${members.length > CAPTURE_REFUSAL_LIMIT ? `, … ${String(members.length - CAPTURE_REFUSAL_LIMIT)} more` : ''}]`\n}\n\n/**\n * Caps external diagnostic text and names the number of omitted characters.\n * @example\n * ```ts\n * describeCaptureOutput('short diagnostic') // 'short diagnostic'\n * ```\n */\nexport function describeCaptureOutput(output: string): string {\n\treturn output.length <= CAPTURE_MESSAGE_LIMIT\n\t\t? output\n\t\t: `${output.slice(0, CAPTURE_MESSAGE_LIMIT)}… ${String(output.length - CAPTURE_MESSAGE_LIMIT)} more characters`\n}\n\n/**\n * Maps usage refusals to exit 64 and every other failure to exit 1.\n *\n * @example\n * ```ts\n * resolveCaptureExit(new CaptureError('Invalid flag', { code: 'USAGE' })) // 64\n * ```\n */\nexport function resolveCaptureExit(error: unknown): number {\n\treturn isCaptureError(error) && error.code === 'USAGE' ? CAPTURE_EXIT.usage : CAPTURE_EXIT.failed\n}\n\n/**\n * Settles independent request removal and child termination without hiding either failure.\n *\n * @returns Every removal, termination, or unconfirmed-exit failure\n * @example\n * ```ts\n * await settleCaptureShutdown(() => invocation.retract(), [() => child.stop()]) // []\n * ```\n */\nexport async function settleCaptureShutdown(\n\tretract: CaptureRetractionHandler,\n\tterminations: readonly CaptureTerminationHandler[],\n): Promise<readonly unknown[]> {\n\tconst removal = attempt(retract)\n\tconst results = await Promise.allSettled(terminations.map(async (terminate) => await terminate()))\n\treturn [\n\t\t...(removal.success ? [] : [removal.error]),\n\t\t...results.flatMap((result) =>\n\t\t\tresult.status === 'rejected'\n\t\t\t\t? [result.reason]\n\t\t\t\t: result.value\n\t\t\t\t\t? []\n\t\t\t\t\t: [new CaptureError('Capture child termination was not confirmed', { code: 'STAGE' })],\n\t\t),\n\t]\n}\n\n/**\n * Computes the digest of both pattern declarations and expanded path and hash membership.\n *\n * @param patterns - The supplied native glob patterns\n * @param files - The expanded file hashes\n * @returns A deterministic digest retaining the original evidence populations\n *\n * @example\n * ```ts\n * buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64) }).patterns // ['src/**']\n * ```\n */\nexport function buildCaptureDigest(\n\tpatterns: readonly string[],\n\tfiles: Readonly<Record<string, string>>,\n): CaptureDigest {\n\tconst ordered = Object.entries(files).toSorted(([left], [right]) =>\n\t\tleft.localeCompare(right, 'en'),\n\t)\n\treturn {\n\t\tpatterns: patterns.toSorted(),\n\t\tfiles: Object.fromEntries(ordered),\n\t\tdigest: computeCaptureHash(JSON.stringify([patterns.toSorted(), ordered])),\n\t}\n}\n\n/**\n * Computes the key under which a pattern list's matched subset of one input population is memoized.\n *\n * @remarks\n * The key joins the population's digest with the sorted patterns, so a list in any order over one\n * population shares a key, and one population never answers for another.\n *\n * @param inputs - The digested input population the patterns match against\n * @param patterns - The native glob patterns, in any order\n * @returns The memo key of the population and the pattern list\n *\n * @example\n * ```ts\n * const inputs = buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64) })\n * computeCaptureMatchKey(inputs, ['src/*.ts', 'src/*.md']) === computeCaptureMatchKey(inputs, ['src/*.md', 'src/*.ts']) // true\n * ```\n */\nexport function computeCaptureMatchKey(inputs: CaptureDigest, patterns: readonly string[]): string {\n\treturn JSON.stringify([inputs.digest, patterns.toSorted()])\n}\n\n/**\n * Filters an input population's paths that match any listed pattern.\n *\n * @remarks\n * Each path is matched with the `matchesGlob` function from `node:path`.\n *\n * @param inputs - The digested input population whose paths are matched\n * @param patterns - The native glob patterns\n * @returns The population's paths that match at least one pattern, in population order\n *\n * @example\n * ```ts\n * const inputs = buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64), 'src/b.md': 'e'.repeat(64) })\n * filterCaptureInputs(inputs, ['src/*.ts']) // Set { 'src/a.ts' }\n * ```\n */\nexport function filterCaptureInputs(\n\tinputs: CaptureDigest,\n\tpatterns: readonly string[],\n): ReadonlySet<string> {\n\treturn new Set(\n\t\tObject.keys(inputs.files).filter((path) =>\n\t\t\tpatterns.some((pattern) => matchesGlob(path, pattern)),\n\t\t),\n\t)\n}\n\n/**\n * Stores each distinct lookup input population once in a manifest-bound journal.\n *\n * @param lookups - The expanded passing case evidence to publish\n * @param collections - The independently authenticated collection receipts\n * @param manifest - The predecessor manifest digest, absent before the first capture\n * @returns The journal with content-addressed input maps and ordered lookup references\n *\n * @example\n * ```ts\n * buildCaptureLookupJournal([], []).inputs // {}\n * ```\n */\nexport function buildCaptureLookupJournal(\n\tlookups: readonly CaptureLookup[],\n\tcollections: readonly CaptureCollectionReceipt[],\n\tmanifest?: string,\n): CaptureLookupJournal {\n\tconst populations = new Map<Readonly<Record<string, string>>, CaptureDigest>()\n\tconst references = lookups.map((lookup) => {\n\t\tconst known = populations.get(lookup.inputs)\n\t\tconst population = known ?? buildCaptureDigest([], lookup.inputs)\n\t\tif (known === undefined) populations.set(lookup.inputs, population)\n\t\treturn { ...lookup, inputs: population.digest }\n\t})\n\treturn {\n\t\tversion: CAPTURE_VERSION,\n\t\t...(manifest === undefined ? {} : { manifest }),\n\t\tinputs: Object.fromEntries(\n\t\t\t[...populations.values()].map((population) => [population.digest, population.files]),\n\t\t),\n\t\tlookups: references,\n\t\tcollections,\n\t}\n}\n\n/**\n * Resolves journal lookup references after verifying each stored input population's digest.\n *\n * @param journal - A structurally validated lookup journal\n * @returns Every expanded lookup in its stored order, sharing the verified input maps\n * @throws Thrown when an input digest differs from its map or a lookup names an unknown digest.\n *\n * @example\n * ```ts\n * readCaptureLookups(buildCaptureLookupJournal([], [])) // []\n * ```\n */\nexport function readCaptureLookups(journal: CaptureLookupJournal): readonly CaptureLookup[] {\n\tconst populations = new Map(\n\t\tObject.entries(journal.inputs).map(([digest, inputs]) => {\n\t\t\tif (buildCaptureDigest([], inputs).digest !== digest)\n\t\t\t\tthrow new CaptureError(`Lookup input digest differs from its map: ${digest}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\treturn [digest, inputs] as const\n\t\t}),\n\t)\n\treturn journal.lookups.map((lookup) => {\n\t\tconst inputs = populations.get(lookup.inputs)\n\t\tif (inputs === undefined)\n\t\t\tthrow new CaptureError(`Lookup names an unknown inputs digest: ${lookup.inputs}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\treturn { ...lookup, inputs }\n\t})\n}\n\n/**\n * Computes the registry identity from its authenticated receipts and exact output population.\n *\n * @param registry - The registry fields before its digest is attached\n * @returns The deterministic SHA-256 registry identity\n *\n * @example\n * ```ts\n * computeRegistryDigest({ version: 1, receipts: [], entries: [] }).length // 64\n * ```\n */\nexport function computeRegistryDigest(\n\tregistry: Pick<CaptureRegistry, 'version' | 'receipts' | 'entries'>,\n): string {\n\treturn computeCaptureHash(\n\t\tJSON.stringify([\n\t\t\tregistry.version,\n\t\t\tregistry.receipts\n\t\t\t\t.map((receipt) =>\n\t\t\t\t\tJSON.stringify([\n\t\t\t\t\t\treceipt.version,\n\t\t\t\t\t\treceipt.variant,\n\t\t\t\t\t\treceipt.time,\n\t\t\t\t\t\treceipt.complete,\n\t\t\t\t\t\treceipt.report.file,\n\t\t\t\t\t\treceipt.report.digest,\n\t\t\t\t\t\tObject.entries(receipt.inputs).toSorted(([left], [right]) =>\n\t\t\t\t\t\t\tleft.localeCompare(right, 'en'),\n\t\t\t\t\t\t),\n\t\t\t\t\t\treceipt.declarations.map(describeCaptureDeclaration).toSorted(),\n\t\t\t\t\t\treceipt.registry.map(describeCaptureDestination).toSorted(),\n\t\t\t\t\t]),\n\t\t\t\t)\n\t\t\t\t.toSorted(),\n\t\t\tregistry.entries.map(describeCaptureDestination).toSorted(),\n\t\t]),\n\t)\n}\n\n/**\n * Imports complete receipts only after their actual exits and exact report bytes validate.\n *\n * @param inputs - Verifier-owned reporter bytes, receipt declarations, and process outcomes\n * @returns The registry document to publish through the verifier's owned evidence path\n * @throws Thrown for caps, signals, unsuccessful exits, altered reports, or incomplete coverage.\n * @remarks This pure importer starts no process and changes no retained receipt or manifest.\n *\n * @example\n * ```ts\n * const registry = buildCaptureRegistry([{ receipt, report: text, outcome: { code: 0, signal: null }, capped: false }])\n * registry.digest.length // 64\n * ```\n */\nexport function buildCaptureRegistry(inputs: readonly CaptureReceiptInput[]): CaptureRegistry {\n\tif (inputs.length === 0)\n\t\tthrow new CaptureError('A registry requires complete-run receipts', { code: 'EVIDENCE' })\n\tfor (const input of inputs) {\n\t\tif (\n\t\t\tinput.capped ||\n\t\t\tinput.outcome.code !== 0 ||\n\t\t\tinput.outcome.signal !== null ||\n\t\t\t!isCaptureReceipt(input.receipt) ||\n\t\t\t!input.receipt.complete ||\n\t\t\tcomputeCaptureHash(input.report) !== input.receipt.report.digest\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Registry receipt requires an uncapped successful exit and unchanged report',\n\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t)\n\t\tvalidateCaptureReceipt(input.receipt, readCaptureReport(parseJSON(input.report)))\n\t}\n\tconst receipts = inputs.map((input) => input.receipt)\n\trequireCaptureUnique(\n\t\treceipts.map((receipt) => receipt.variant),\n\t\t'complete receipt variants',\n\t\ttrue,\n\t)\n\tconst entries = receipts.flatMap((receipt) => receipt.registry)\n\trequireCaptureUnique(entries.map(resolveCaptureKey), 'registry identities', true)\n\trequireCaptureUnique(\n\t\tentries.map((entry) => entry.file),\n\t\t'registry paths',\n\t\ttrue,\n\t)\n\tconst registry = { version: CAPTURE_VERSION, receipts, entries }\n\treturn { ...registry, digest: computeRegistryDigest(registry) }\n}\n\n/**\n * Checks whether bytes open with the eight-byte PNG signature.\n *\n * @param bytes - The leading bytes of a file\n * @returns True if the first eight bytes equal the signature; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureSignature(Uint8Array.from([137, 80, 78, 71, 13, 10, 26, 10])) // true\n * ```\n */\nexport function matchesCaptureSignature(bytes: Uint8Array): boolean {\n\treturn Buffer.from(CAPTURE_PNG_SIGNATURE).equals(bytes.subarray(0, CAPTURE_PNG_SIGNATURE.length))\n}\n\n/**\n * Computes the PNG Paeth predictor used by both image readers.\n *\n * @param left - The reconstructed left byte\n * @param up - The reconstructed byte above\n * @param corner - The reconstructed upper-left byte\n * @returns The closest neighbor to the linear estimate\n *\n * @example\n * ```ts\n * predictCaptureByte(10, 20, 10) // 20\n * ```\n */\nexport function predictCaptureByte(left: number, up: number, corner: number): number {\n\tconst estimate = left + up - corner\n\tconst distances = [\n\t\tMath.abs(estimate - left),\n\t\tMath.abs(estimate - up),\n\t\tMath.abs(estimate - corner),\n\t]\n\treturn (distances[0] ?? 0) <= (distances[1] ?? 0) && (distances[0] ?? 0) <= (distances[2] ?? 0)\n\t\t? left\n\t\t: (distances[1] ?? 0) <= (distances[2] ?? 0)\n\t\t\t? up\n\t\t\t: corner\n}\n\n/**\n * Reads PNG compressed-data chunks while refusing truncated or corrupt image bytes.\n *\n * @param bytes - The complete PNG\n * @param offset - The next chunk header. Default: 8.\n * @returns Ordered compressed-data chunks\n * @throws Thrown for truncated chunks, bad checksums, or a missing closing chunk.\n *\n * @example\n * ```ts\n * readCaptureChunks(encodeCapturePicture(picture)).length // 1\n * ```\n */\nexport function readCaptureChunks(bytes: Buffer, offset = 8): readonly Buffer[] {\n\trequireCaptureImageSize(bytes.length)\n\t// Each verified chunk names the next offset. The byte budget bounds this log, without a\n\t// recursive call stack or an arbitrary cap on a valid encoder's IDAT population.\n\tconst positions = [offset]\n\tconst chunks: Buffer[] = []\n\tfor (const position of positions) {\n\t\tif (!Number.isSafeInteger(position) || position < 8 || position + 12 > bytes.length)\n\t\t\tthrow new CaptureError('Truncated capture PNG', { code: 'EVIDENCE' })\n\t\tconst length = bytes.readUInt32BE(position)\n\t\tconst end = position + 12 + length\n\t\tif (end > bytes.length)\n\t\t\tthrow new CaptureError('Truncated capture PNG chunk', { code: 'EVIDENCE' })\n\t\tconst name = bytes.toString('latin1', position + 4, position + 8)\n\t\tif (crc32(bytes.subarray(position + 4, end - 4)) >>> 0 !== bytes.readUInt32BE(end - 4))\n\t\t\tthrow new CaptureError('Capture PNG checksum differs', { code: 'EVIDENCE' })\n\t\tif (name === 'IEND') {\n\t\t\tif (length !== 0 || end !== bytes.length)\n\t\t\t\tthrow new CaptureError('Invalid capture PNG closing chunk', { code: 'EVIDENCE' })\n\t\t\treturn chunks\n\t\t}\n\t\tif (name === 'IDAT' && length > 0) chunks.push(bytes.subarray(position + 8, end - 4))\n\t\tpositions.push(end)\n\t}\n\tthrow new CaptureError('Missing capture PNG closing chunk', { code: 'EVIDENCE' })\n}\n\n/**\n * Reads an image only after its opened file's size is inside the compressed-byte budget.\n * @throws Thrown when the file is oversized, unreadable, or changes size during the read.\n * @example\n * ```ts\n * const bytes = readCaptureImage('/workspace/tmp/captures/mail.png')\n * ```\n */\nexport function readCaptureImage(file: string): Buffer {\n\tconst descriptor = openSync(file, 'r')\n\ttry {\n\t\tconst size = fstatSync(descriptor).size\n\t\trequireCaptureImageSize(size)\n\t\tconst bytes = Buffer.alloc(size)\n\t\tif (\n\t\t\treadSync(descriptor, bytes, 0, size, 0) !== size ||\n\t\t\treadSync(descriptor, Buffer.alloc(1), 0, 1, size) !== 0\n\t\t)\n\t\t\tthrow new CaptureError('Capture PNG read is incomplete or its size changed', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\treturn bytes\n\t} finally {\n\t\tcloseSync(descriptor)\n\t}\n}\n\n/**\n * Refuses compressed image bytes before file reads or chunk-buffer allocation.\n * @example\n * ```ts\n * requireCaptureImageSize(4096) // undefined\n * ```\n */\nexport function requireCaptureImageSize(size: number): void {\n\tif (!Number.isSafeInteger(size) || size < 0 || size > CAPTURE_PNG_LIMITS.bytes)\n\t\tthrow new CaptureError('Capture PNG exceeds the file budget', { code: 'EVIDENCE' })\n}\n\n/**\n * Reconstructs one filtered PNG scanline from its filter byte and the row above.\n *\n * @param filter - The scanline's filter type, from 0 through 4\n * @param line - The filtered bytes of the row, without the filter byte\n * @param above - The reconstructed row above, or `undefined` for the first row\n * @param channels - The number of bytes in one pixel\n * @returns The reconstructed row\n *\n * @example\n * ```ts\n * unfilterCaptureRow(1, Uint8Array.from([1, 1, 1, 1]), undefined, 1) // Uint8Array [1, 2, 3, 4]\n * ```\n */\nexport function unfilterCaptureRow(\n\tfilter: number,\n\tline: Uint8Array,\n\tabove: Uint8Array | undefined,\n\tchannels: number,\n): Uint8Array {\n\t// Each byte reads reconstructed bytes before it, so the row is written once per index, in order.\n\tconst bytes = new Uint8Array(line.length)\n\tfor (const [index, value] of line.entries()) {\n\t\tconst left = index >= channels ? (bytes[index - channels] ?? 0) : 0\n\t\tconst up = above?.[index] ?? 0\n\t\tconst corner = index >= channels ? (above?.[index - channels] ?? 0) : 0\n\t\tconst predicted =\n\t\t\tfilter === 1\n\t\t\t\t? left\n\t\t\t\t: filter === 2\n\t\t\t\t\t? up\n\t\t\t\t\t: filter === 3\n\t\t\t\t\t\t? (left + up) >> 1\n\t\t\t\t\t\t: filter === 4\n\t\t\t\t\t\t\t? predictCaptureByte(left, up, corner)\n\t\t\t\t\t\t\t: 0\n\t\tbytes[index] = (value + predicted) & 255\n\t}\n\treturn bytes\n}\n\n/**\n * Inflates a PNG's compressed stream, refusing one that is corrupt or longer than declared.\n *\n * @param data - The concatenated data-chunk payloads\n * @param length - The inflated length the header's dimensions declare\n * @returns The inflated scanlines\n * @throws Thrown when the stream is not valid deflate data or inflates past `length`.\n *\n * @example\n * ```ts\n * inflateCaptureStream(deflateSync(Buffer.from([1, 2, 3])), 3) // Buffer <01 02 03>\n * ```\n */\nexport function inflateCaptureStream(data: Buffer, length: number): Buffer {\n\ttry {\n\t\treturn inflateSync(data, { maxOutputLength: length })\n\t} catch (error) {\n\t\tthrow new CaptureError('Capture PNG stream is corrupt or longer than declared', {\n\t\t\tcode: 'EVIDENCE',\n\t\t\tcause: error,\n\t\t})\n\t}\n}\n\n/**\n * Decodes the eight-bit, non-interlaced PNGs the capture readers consume.\n *\n * @remarks\n * It reads grayscale, grayscale with alpha, RGB, and RGBA, the colour types an encoder writes for a\n * browser capture. A grayscale sample fills all three channels, and an alpha channel is dropped.\n * Indexed colour, other bit depths, and interlacing are refused.\n *\n * @param bytes - The exact physical image bytes\n * @returns Image dimensions and RGB pixels\n * @throws Thrown for unsupported, malformed, or truncated images.\n *\n * @example\n * ```ts\n * decodeCapturePicture(encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) })).pixels // Uint8Array [1, 2, 3]\n * ```\n */\nexport function decodeCapturePicture(bytes: Buffer): CapturePicture {\n\trequireCaptureImageSize(bytes.length)\n\tif (\n\t\tbytes.length < 33 ||\n\t\t!matchesCaptureSignature(bytes) ||\n\t\tbytes.toString('latin1', 12, 16) !== 'IHDR' ||\n\t\tbytes.readUInt32BE(8) !== 13\n\t)\n\t\tthrow new CaptureError('Invalid capture PNG header', { code: 'EVIDENCE' })\n\tconst width = bytes.readUInt32BE(16)\n\tconst height = bytes.readUInt32BE(20)\n\tconst channels =\n\t\tbytes[25] === 6 ? 4 : bytes[25] === 2 ? 3 : bytes[25] === 4 ? 2 : bytes[25] === 0 ? 1 : 0\n\tconst gray = bytes[25] === 0 || bytes[25] === 4\n\tif (\n\t\twidth === 0 ||\n\t\theight === 0 ||\n\t\tchannels === 0 ||\n\t\tbytes[24] !== 8 ||\n\t\tbytes[26] !== 0 ||\n\t\tbytes[27] !== 0 ||\n\t\tbytes[28] !== 0\n\t)\n\t\tthrow new CaptureError('Unsupported capture PNG encoding', { code: 'EVIDENCE' })\n\tconst stride = width * channels\n\tconst length = (stride + 1) * height\n\tif (!Number.isSafeInteger(length))\n\t\tthrow new CaptureError('Invalid capture PNG dimensions', { code: 'EVIDENCE' })\n\tif (width * height > CAPTURE_PNG_LIMITS.pixels)\n\t\tthrow new CaptureError('Capture PNG exceeds the pixel budget', { code: 'EVIDENCE' })\n\tif (width > CAPTURE_PNG_LIMITS.side || height > CAPTURE_PNG_LIMITS.side)\n\t\tthrow new CaptureError('Capture PNG exceeds the dimension budget', { code: 'EVIDENCE' })\n\tconst chunks = readCaptureChunks(bytes)\n\tconst raw = inflateCaptureStream(\n\t\tchunks.length === 1 && chunks[0] !== undefined ? chunks[0] : Buffer.concat(chunks),\n\t\tlength,\n\t)\n\tif (raw.length !== length)\n\t\tthrow new CaptureError('Capture PNG scanline length differs', { code: 'EVIDENCE' })\n\t// Each row is written once, in order, and an unfiltered row reads the reconstructed slice above it.\n\tconst rows = new Uint8Array(stride * height)\n\tfor (const row of new Array(height).keys()) {\n\t\tconst filter = raw[row * (stride + 1)]\n\t\tif (filter === undefined || filter > 4)\n\t\t\tthrow new CaptureError('Unsupported capture PNG filter', { code: 'EVIDENCE' })\n\t\tconst line = raw.subarray(row * (stride + 1) + 1, (row + 1) * (stride + 1))\n\t\trows.set(\n\t\t\tfilter === 0\n\t\t\t\t? line\n\t\t\t\t: unfilterCaptureRow(\n\t\t\t\t\t\tfilter,\n\t\t\t\t\t\tline,\n\t\t\t\t\t\trow === 0 ? undefined : rows.subarray((row - 1) * stride, row * stride),\n\t\t\t\t\t\tchannels,\n\t\t\t\t\t),\n\t\t\trow * stride,\n\t\t)\n\t}\n\tif (channels === 3) return { width, height, pixels: rows }\n\tconst pixels = new Uint8Array(width * height * 3)\n\tconst columns = Array.from({ length: width }, (_, column) => column)\n\tfor (const row of new Array(height).keys()) {\n\t\tfor (const column of columns) {\n\t\t\tconst source = (row * width + column) * channels\n\t\t\tconst target = (row * width + column) * 3\n\t\t\tpixels[target] = rows[source] ?? 0\n\t\t\tpixels[target + 1] = rows[source + (gray ? 0 : 1)] ?? 0\n\t\t\tpixels[target + 2] = rows[source + (gray ? 0 : 2)] ?? 0\n\t\t}\n\t}\n\treturn { width, height, pixels }\n}\n\n/**\n * Encodes an unsigned 32-bit integer as four big-endian bytes.\n *\n * @param value - An integer from 0 through 4294967295\n * @returns The four bytes, most significant first\n *\n * @example\n * ```ts\n * encodeCaptureWord(258) // Buffer <00 00 01 02>\n * ```\n */\nexport function encodeCaptureWord(value: number): Buffer {\n\treturn Buffer.from([24, 16, 8, 0].map((shift) => (value >>> shift) & 255))\n}\n\n/**\n * Encodes one checked PNG chunk for contact-sheet output.\n *\n * @param name - The four-byte chunk name\n * @param data - The chunk payload\n * @returns Header, payload, and checksum bytes\n *\n * @example\n * ```ts\n * encodeCaptureChunk('IEND', Buffer.alloc(0)).length // 12\n * ```\n */\nexport function encodeCaptureChunk(name: string, data: Buffer): Buffer {\n\tconst header = Buffer.concat([encodeCaptureWord(data.length), Buffer.from(name, 'latin1')])\n\tconst tail = encodeCaptureWord(crc32(Buffer.concat([header.subarray(4), data])) >>> 0)\n\treturn Buffer.concat([header, data, tail])\n}\n\n/**\n * Encodes an RGB picture using the contact-sheet writer's native PNG format.\n *\n * @param picture - The complete RGB pixel buffer\n * @param compressed - If `true`, compresses scanlines; if `false`, stores them in the deflate stream. Default: `true`.\n * @returns A PNG file\n * @throws Thrown when dimensions and pixel length disagree.\n *\n * @example\n * ```ts\n * encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) }).subarray(1, 4).toString() // 'PNG'\n * ```\n */\nexport function encodeCapturePicture(picture: CapturePicture, compressed = true): Buffer {\n\tif (\n\t\t!Number.isSafeInteger(picture.width) ||\n\t\t!Number.isSafeInteger(picture.height) ||\n\t\tpicture.width <= 0 ||\n\t\tpicture.height <= 0 ||\n\t\tpicture.pixels.length !== picture.width * picture.height * 3\n\t)\n\t\tthrow new CaptureError('Invalid capture picture dimensions', { code: 'EVIDENCE' })\n\tconst stride = picture.width * 3\n\tconst raw = Buffer.concat(\n\t\tArray.from({ length: picture.height }, (_, row) =>\n\t\t\tBuffer.concat([Buffer.from([0]), picture.pixels.subarray(row * stride, (row + 1) * stride)]),\n\t\t),\n\t)\n\treturn Buffer.concat([\n\t\tBuffer.from(CAPTURE_PNG_SIGNATURE),\n\t\tencodeCaptureChunk(\n\t\t\t'IHDR',\n\t\t\tBuffer.concat([\n\t\t\t\tencodeCaptureWord(picture.width),\n\t\t\t\tencodeCaptureWord(picture.height),\n\t\t\t\tBuffer.from([8, 2, 0, 0, 0]),\n\t\t\t]),\n\t\t),\n\t\tencodeCaptureChunk('IDAT', deflateSync(raw, { level: compressed ? 6 : 0 })),\n\t\tencodeCaptureChunk('IEND', Buffer.alloc(0)),\n\t])\n}\n\n/**\n * Scales a picture with an exact area average and clips its displayed height.\n *\n * @param picture - The source RGB picture\n * @param factor - The integer reduction factor\n * @param limit - The maximum displayed height\n * @returns A separately owned scaled picture\n *\n * @example\n * ```ts\n * shrinkCapturePicture({ width: 2, height: 2, pixels: new Uint8Array(12) }, 2, 8).width // 1\n * ```\n */\nexport function shrinkCapturePicture(\n\tpicture: CapturePicture,\n\tfactor: number,\n\tlimit: number,\n): CapturePicture {\n\tconst width = Math.max(1, Math.ceil(picture.width / factor))\n\tconst height = Math.min(Math.max(1, Math.ceil(picture.height / factor)), limit)\n\t// One shared offset list; each output channel sums its block with no per-pixel allocation.\n\tconst span = Array.from(\n\t\t{ length: Math.ceil(Math.min(factor, Math.max(picture.width, picture.height))) },\n\t\t(_, index) => index,\n\t)\n\t// A clipped height can be fractional or negative, so the length follows the array-length rule.\n\tconst pixels = new Uint8Array(\n\t\tMath.min(Math.max(Math.trunc(width * height * 3) || 0, 0), Number.MAX_SAFE_INTEGER),\n\t)\n\tconst offsets = Array.from({ length: Math.min(width * 3, pixels.length) }, (_, offset) => offset)\n\t// Each output row is written once per byte, in order; a partial last row stops at the length.\n\tconst lines = pixels.length === 0 ? 0 : Math.ceil(pixels.length / (width * 3))\n\tfor (const y of new Array(lines).keys()) {\n\t\tconst rows = Math.min(factor, picture.height - y * factor)\n\t\tfor (const offset of offsets) {\n\t\t\tconst index = y * width * 3 + offset\n\t\t\tif (index >= pixels.length) break\n\t\t\tconst channel = offset % 3\n\t\t\tconst x = Math.floor(offset / 3)\n\t\t\tconst columns = Math.min(factor, picture.width - x * factor)\n\t\t\tconst sum = span.reduce((total, row) => {\n\t\t\t\tif (row >= rows) return total\n\t\t\t\tconst start = (y * factor + row) * picture.width * 3 + x * Math.ceil(factor) * 3 + channel\n\t\t\t\treturn span.reduce(\n\t\t\t\t\t(block, column) =>\n\t\t\t\t\t\tcolumn >= columns ? block : block + (picture.pixels[start + column * 3] ?? 0),\n\t\t\t\t\ttotal,\n\t\t\t\t)\n\t\t\t}, 0)\n\t\t\tpixels[index] = Math.round(sum / (rows * columns))\n\t\t}\n\t}\n\treturn { width, height, pixels }\n}\n\n/**\n * Composes pictures on the contact-sheet gray background.\n *\n * @param pictures - The ordered source cells or rows\n * @param vertical - If `true`, stacks rows; if `false`, places cells side by side\n * @param gap - The space between source pictures. Default: 6.\n * @returns A separately owned composite\n * @throws Thrown for an empty picture selection, with the `USAGE` condition.\n * @throws Thrown with the `EVIDENCE` condition when a width, a height, or the gap is not a whole\n * number from 0 to `CAPTURE_PNG_LIMITS.side`, or when the composite exceeds that side or the\n * `CAPTURE_PNG_LIMITS.pixels` budget.\n *\n * @example\n * ```ts\n * composeCapturePictures([picture, picture], false).width // picture.width * 2 + 6\n * ```\n */\nexport function composeCapturePictures(\n\tpictures: readonly CapturePicture[],\n\tvertical: boolean,\n\tgap = 6,\n): CapturePicture {\n\tif (pictures.length === 0)\n\t\tthrow new CaptureError('Empty contact-sheet picture selection', { code: 'USAGE' })\n\tconst { side, pixels: budget } = CAPTURE_PNG_LIMITS\n\tconst faults = [\n\t\t...pictures.flatMap((picture, position) =>\n\t\t\t(['width', 'height'] as const).flatMap((axis) =>\n\t\t\t\tNumber.isSafeInteger(picture[axis]) && picture[axis] >= 0 && picture[axis] <= side\n\t\t\t\t\t? []\n\t\t\t\t\t: [`pictures[${String(position)}].${axis} is ${preview(picture[axis])}`],\n\t\t\t),\n\t\t),\n\t\t...(Number.isSafeInteger(gap) && gap >= 0 && gap <= side ? [] : [`gap is ${preview(gap)}`]),\n\t]\n\tconst width = vertical\n\t\t? pictures.reduce((widest, entry) => Math.max(widest, entry.width), -Infinity)\n\t\t: pictures.reduce((sum, entry) => sum + entry.width, 0) + gap * (pictures.length - 1)\n\tconst height = vertical\n\t\t? pictures.reduce((sum, entry) => sum + entry.height, 0) + gap * (pictures.length - 1)\n\t\t: pictures.reduce((tallest, entry) => Math.max(tallest, entry.height), -Infinity)\n\tif (faults.length > 0 || width > side || height > side || width * height > budget)\n\t\tthrow new CaptureError(\n\t\t\t`Contact-sheet geometry is out of range: ${\n\t\t\t\tfaults.length === 0\n\t\t\t\t\t? `composite is ${String(width)} × ${String(height)}`\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...faults.slice(0, CAPTURE_REFUSAL_LIMIT),\n\t\t\t\t\t\t\t...(faults.length > CAPTURE_REFUSAL_LIMIT\n\t\t\t\t\t\t\t\t? [`… ${String(faults.length - CAPTURE_REFUSAL_LIMIT)} more`]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t].join('; ')\n\t\t\t}; expected whole numbers from 0 to ${String(side)} for every width, height, and gap, and a composite of at most ${String(side)} per side and ${String(budget)} pixels`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst offsets = pictures.map((_picture, position) =>\n\t\tpictures\n\t\t\t.slice(0, position)\n\t\t\t.reduce((sum, entry) => sum + (vertical ? entry.height : entry.width) + gap, 0),\n\t)\n\t// Each picture owns the span from its offset to the next one; inside it, the picture's row is\n\t// copied and the rest is the gray gap. Spans are written once each, in index order.\n\tconst pixels = new Uint8Array(width * height * 3)\n\tconst spans = pictures.map((picture, position) => ({\n\t\tpicture,\n\t\tstart: offsets[position] ?? 0,\n\t\tend: Math.min(offsets[position + 1] ?? Infinity, vertical ? height : width),\n\t}))\n\tif (vertical) {\n\t\tfor (const { picture, start, end } of spans) {\n\t\t\tfor (const row of new Array(Math.max(0, end - start)).keys()) {\n\t\t\t\tconst copied = row < picture.height ? picture.width : 0\n\t\t\t\tconst target = (start + row) * width * 3\n\t\t\t\tpixels.set(\n\t\t\t\t\tpicture.pixels.subarray(row * picture.width * 3, (row * picture.width + copied) * 3),\n\t\t\t\t\ttarget,\n\t\t\t\t)\n\t\t\t\tpixels.fill(128, target + copied * 3, target + width * 3)\n\t\t\t}\n\t\t}\n\t\treturn { width, height, pixels }\n\t}\n\tfor (const row of new Array(height).keys()) {\n\t\tfor (const { picture, start, end } of spans) {\n\t\t\tconst copied = row < picture.height ? Math.min(picture.width, end - start) : 0\n\t\t\tconst target = (row * width + start) * 3\n\t\t\tpixels.set(\n\t\t\t\tpicture.pixels.subarray(row * picture.width * 3, (row * picture.width + copied) * 3),\n\t\t\t\ttarget,\n\t\t\t)\n\t\t\tpixels.fill(128, target + copied * 3, (row * width + end) * 3)\n\t\t}\n\t}\n\treturn { width, height, pixels }\n}\n\n/**\n * Reads the process id that a request file, or its temporary sibling, names.\n *\n * @param name - A file name from the request directory\n * @returns The process id the name carries, from 1 to `CAPTURE_PID_LIMIT`, or `undefined` for any\n * other name\n *\n * @example\n * ```ts\n * readCaptureRequestOwner('journey-selection-4242.json') // 4242\n * readCaptureRequestOwner('journey-selection-4242.json.tmp') // 4242\n * readCaptureRequestOwner('journey-selection.json') // undefined\n * readCaptureRequestOwner('journey-selection-4294967296.json') // undefined\n * ```\n */\nexport function readCaptureRequestOwner(name: string): number | undefined {\n\tconst match = new RegExp(`^${CAPTURE_REQUEST_PREFIX}-(\\\\d+)\\\\.json(?:\\\\.tmp)?$`, 'u').exec(name)\n\tconst pid = Number(match?.[1])\n\treturn Number.isSafeInteger(pid) && pid > 0 && pid <= CAPTURE_PID_LIMIT ? pid : undefined\n}\n\n/**\n * Describes the request holders that keep a workspace busy, naming apart those the host could not inspect.\n *\n * @param holders - The holders `CaptureInvocationInterface.holders` lists\n * @param directory - The workspace-relative request directory that holds their request files\n * @returns The running holders' sentence, then the uninspected holders' sentence with its correction\n *\n * @example\n * ```ts\n * describeCaptureHolders([{ pid: 4242, inspected: true }], 'tmp/capture')\n * // 'Another runner holds this workspace (process 4242)'\n * ```\n */\nexport function describeCaptureHolders(\n\tholders: readonly CaptureHolder[],\n\tdirectory: string,\n): string {\n\tconst running = holders.filter((holder) => holder.inspected).map((holder) => holder.pid)\n\tconst unknown = holders.filter((holder) => !holder.inspected).map((holder) => holder.pid)\n\treturn [\n\t\t...(running.length === 0\n\t\t\t? []\n\t\t\t: [`Another runner holds this workspace (process ${running.join(', ')})`]),\n\t\t...(unknown.length === 0\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t`Request holder process ${unknown.join(', ')} could not be inspected; confirm no capture process or surviving child is running before deleting its request file in ${directory}`,\n\t\t\t\t]),\n\t].join('. ')\n}\n\n/**\n * Resolves a path to the slash-separated form the evidence documents store, relative to a root.\n *\n * @param root - The absolute workspace path\n * @param target - The absolute or workspace-relative path\n * @returns The path relative to the root, with every backslash replaced by a slash\n *\n * @example\n * ```ts\n * resolveCaptureRelative(process.cwd(), resolve('tmp', 'units')) // 'tmp/units'\n * ```\n */\nexport function resolveCaptureRelative(root: string, target: string): string {\n\treturn normalizeSlashes(relative(root, resolve(root, target)))\n}\n\n/**\n * Escapes every regular-expression metacharacter so a case name matches only itself.\n *\n * @param text - The literal text\n * @returns The text with each metacharacter backslash-quoted\n *\n * @example\n * ```ts\n * escapeCapturePattern('renders (a.b) + c') // 'renders \\\\(a\\\\.b\\\\) \\\\+ c'\n * ```\n */\nexport function escapeCapturePattern(text: string): string {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/gu, '\\\\$&')\n}\n\n/**\n * Builds the tag expression that selects an owner population, and its capture tags for frames.\n *\n * @remarks\n * A journey selects `owner:<selector>`. A capture intersects that with the capture tag the\n * selector names, which is its scope and part: the first two segments. The `all` selector unions\n * every declared scope. Colons stay part of a tag name.\n *\n * @param command - The runner command\n * @param selector - The requested owner path or `all`\n * @param selectors - Every owner path the wrapper declares, without the `owner:` prefix\n * @returns The expression for `--tags-filter`\n *\n * @example\n * ```ts\n * buildCaptureFilter('journey', 'pages:mail', ['pages', 'pages:mail']) // 'owner:pages:mail'\n * buildCaptureFilter('capture', 'pages:mail', ['pages', 'pages:mail']) // 'owner:pages:mail && pages:mail'\n * ```\n */\nexport function buildCaptureFilter(\n\tcommand: CaptureCommand,\n\tselector: string,\n\tselectors: readonly string[],\n): string {\n\tconst scopes = selectors.filter((entry) => !entry.includes(':'))\n\tconst owner =\n\t\tselector === 'all'\n\t\t\t? `(${scopes.map((scope) => `${CAPTURE_OWNER_PREFIX}${scope}`).join(' || ')})`\n\t\t\t: `${CAPTURE_OWNER_PREFIX}${selector}`\n\tconst capture =\n\t\tselector === 'all' ? `(${scopes.join(' || ')})` : selector.split(':').slice(0, 2).join(':')\n\treturn command === 'journey' ? owner : `${owner} && ${capture}`\n}\n\n/**\n * Plans one selected journey stage or narrow and remaining frame stages.\n *\n * @remarks\n * Journeys run every selected variant together. Frame captures stage the first variant alone and\n * the remaining variants together. Empty stages are dropped and no unselected variant is added.\n *\n * @param variants - The selected variants in declaration order\n * @param first - The variant the wrapper stages alone first\n * @param command - The journey or capture command whose stage contract applies\n * @returns The non-empty stages in run order\n *\n * @example\n * ```ts\n * resolveCaptureStages(['wide', 'compact'], 'compact', 'capture')\n * // [{ name: 'narrow', variants: ['compact'] }, { name: 'rest', variants: ['wide'] }]\n * ```\n */\nexport function resolveCaptureStages(\n\tvariants: readonly string[],\n\tfirst: string,\n\tcommand: CaptureRequest['command'],\n): readonly CaptureStagePlan[] {\n\tif (command === 'journey')\n\t\treturn variants.length === 0 ? [] : [{ name: CAPTURE_STAGES.selected, variants: [...variants] }]\n\tconst stages: readonly CaptureStagePlan[] = [\n\t\t{ name: CAPTURE_STAGES.first, variants: variants.filter((variant) => variant === first) },\n\t\t{ name: CAPTURE_STAGES.rest, variants: variants.filter((variant) => variant !== first) },\n\t]\n\treturn stages.filter((stage) => stage.variants.length > 0)\n}\n\n/**\n * Resolves selected producing variants in declaration order and requires their projects.\n *\n * @param selected - Explicit variants, or an empty list for every declared variant\n * @param projects - The discovered host projects\n * @returns The declared variants the selection includes\n * @throws Thrown as USAGE for an unknown variant or HOST for missing variant projects.\n * @example\n * ```ts\n * const variants = resolveCaptureVariants(['light-390'], projects)\n * // ['light-390'] when the wrapper declares its project\n * ```\n */\nexport function resolveCaptureVariants(\n\tselected: readonly string[],\n\tprojects: readonly CaptureProject[],\n): readonly string[] {\n\tconst declared = [...new Set(projects.flatMap((project) => project.variants))]\n\tfor (const variant of selected) {\n\t\tif (!declared.includes(variant))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown variant; ${describeCaptureFault('--variant', variant, 'a variant declared by the wrapper', declared)}`,\n\t\t\t\t{ code: 'USAGE', context: { variant } },\n\t\t\t)\n\t}\n\tconst variants = declared.filter((variant) => selected.length === 0 || selected.includes(variant))\n\tif (variants.length === 0)\n\t\tthrow new CaptureError('The wrapper declares no journey variants', { code: 'HOST' })\n\tfor (const variant of variants) {\n\t\tif (!projects.some((project) => project.variant === variant))\n\t\t\tthrow new CaptureError(`The wrapper declares no journey project for ${variant}`, {\n\t\t\t\tcode: 'HOST',\n\t\t\t\tcontext: { variant },\n\t\t\t})\n\t}\n\treturn variants\n}\n\n/**\n * Refuses unknown command selections from the wrapper before authenticating disk evidence.\n * @example\n * ```ts\n * requireCaptureSelection('all', [], projects) // undefined for declared wrapper projects\n * ```\n */\nexport function requireCaptureSelection(\n\tselector: string,\n\tvariants: readonly string[],\n\tprojects: readonly CaptureProject[],\n\toutputs: readonly string[] = [],\n\tportfolio?: string,\n): void {\n\tconst selectors = [\n\t\t...new Set(\n\t\t\tprojects.flatMap((project) => [\n\t\t\t\t...project.tags\n\t\t\t\t\t.filter((tag) => tag.startsWith(CAPTURE_OWNER_PREFIX))\n\t\t\t\t\t.map((tag) => tag.slice(CAPTURE_OWNER_PREFIX.length)),\n\t\t\t\t...project.standalone.map((entry) => entry.portfolio),\n\t\t\t]),\n\t\t),\n\t]\n\tconst fault = describeCaptureSelectorFault(selector, selectors)\n\tif (fault !== undefined) throw new CaptureError(fault, { code: 'USAGE' })\n\tconst portfolios = [\n\t\t...new Set(\n\t\t\tprojects.flatMap((project) =>\n\t\t\t\t[...project.portfolios, ...project.standalone].map((entry) => entry.portfolio),\n\t\t\t),\n\t\t),\n\t]\n\tif (portfolio !== undefined && !portfolios.includes(portfolio))\n\t\tthrow new CaptureError(\n\t\t\tdescribeCaptureFault(\n\t\t\t\t'--portfolio',\n\t\t\t\tportfolio,\n\t\t\t\t'a portfolio declared by the wrapper',\n\t\t\t\tportfolios,\n\t\t\t),\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst declared = [...new Set([...projects.flatMap((project) => project.variants), ...outputs])]\n\tfor (const variant of variants)\n\t\tif (!declared.includes(variant))\n\t\t\tthrow new CaptureError(\n\t\t\t\tdescribeCaptureFault(\n\t\t\t\t\t'--variant',\n\t\t\t\t\tvariant,\n\t\t\t\t\t'a variant declared by the wrapper or registry output population',\n\t\t\t\t\tdeclared,\n\t\t\t\t),\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n}\n\n/**\n * Reads output variant candidates without authenticating or accepting registry evidence.\n * @remarks Missing, unreadable, or malformed registries supply no candidate hints; the integrity engine still authenticates every accepted read.\n * @example\n * ```ts\n * readCaptureVariants('/workspace', '/workspace/tmp/captures/states/registry.json') // [] when absent\n * ```\n */\nexport function readCaptureVariants(root: string, file: string): readonly string[] {\n\tconst read = attempt(() => parseJSON(readFileSync(requireCaptureContained(root, file), 'utf8')))\n\treturn read.success && isCaptureRegistry(read.value)\n\t\t? [...new Set(read.value.entries.map((entry) => entry.variant))]\n\t\t: []\n}\n\n/**\n * Builds the exact Node argument array that spawns one Vitest stage.\n *\n * @remarks\n * Each value is its own array element, so no shell quoting applies and a case name keeps its\n * spaces and quotes. An exact case adds `-t` with the anchored pattern for that case and the\n * final case, so the final case still writes the run record.\n *\n * @param options - The entry, wrapper, report and progress files, projects, tag filter, bail switch, and optional exact case and mode\n * @returns The arguments after the Node executable\n *\n * @example\n * ```ts\n * const args = buildCaptureArguments({\n * \tentry: '/repo/node_modules/vitest/vitest.mjs',\n * \tconfig: '/repo/vite.journey.config.ts',\n * \treport: '/repo/tmp/units/runs/a/journey-selected.json',\n * \tprogress: '/repo/tmp/units/runs/a/selected.progress.jsonl',\n * \tprojects: ['journey:light-390'],\n * \tfilter: 'owner:pages:mail',\n * \tfinal: 'closes the run',\n * })\n * args.includes('--bail=1') // true\n * ```\n */\nexport function buildCaptureArguments(options: CaptureArgumentsOptions): readonly string[] {\n\tconst separator = options.case === undefined ? ' ' : readCaptureSeparator(options.entry)\n\treturn [\n\t\toptions.entry,\n\t\t'run',\n\t\t'--config',\n\t\toptions.config,\n\t\t...(options.mode === undefined\n\t\t\t? []\n\t\t\t: options.mode.startsWith('-')\n\t\t\t\t? [`--mode=${options.mode}`]\n\t\t\t\t: ['--mode', options.mode]),\n\t\t'--configLoader',\n\t\t'runner',\n\t\t'--no-cache',\n\t\t...(options.bail === false ? [] : ['--bail=1']),\n\t\t'--reporter=dot',\n\t\t'--reporter=json',\n\t\t`--outputFile.json=${options.report}`,\n\t\t`--outputFile.progress=${options.progress}`,\n\t\t...options.projects.flatMap((project) => ['--project', project]),\n\t\t...(options.filter === undefined ? [] : ['--tags-filter', options.filter]),\n\t\t...(options.case === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t'-t',\n\t\t\t\t\t`^(?:${[options.case, options.final].map((name) => escapeCapturePattern((options.titles?.[name] ?? [name]).join(separator))).join('|')})$`,\n\t\t\t\t]),\n\t]\n}\n\n/**\n * Reads the installed workspace Vitest's exact title separator, refusing unsupported majors.\n * @example\n * ```ts\n * readCaptureSeparator('/workspace/node_modules/vitest/vitest.mjs') // ' > ' on Vitest 5\n * ```\n */\nexport function readCaptureSeparator(entry: string): string {\n\tconst file = resolve(dirname(entry), 'package.json')\n\tconst loaded = attempt(() => parseJSON(readFileSync(file, 'utf8')))\n\tif (!loaded.success)\n\t\tthrow new CaptureError(`Cannot read installed Vitest manifest: ${file}`, {\n\t\t\tcode: 'HOST',\n\t\t\tcause: loaded.error,\n\t\t})\n\tconst manifest: unknown = loaded.value\n\tconst version = isRecord(manifest) ? manifest.version : undefined\n\tif (typeof version === 'string' && version.split('.')[0] === '5') return ' > '\n\tthrow new CaptureError(\n\t\tdescribeCaptureFault('vitest.version', version, 'a supported installed Vitest major', ['5']),\n\t\t{ code: 'HOST' },\n\t)\n}\n\n/**\n * Reads original title segments from the accepted registry's authenticated JSON reporter files.\n * @param root - The repository root that contains the registry and its reporters\n * @param file - The accepted registry path\n * @param selector - The optional owner selector that bounds the case candidates\n * @returns Exact case names mapped to their original title segments within the selected owners\n * @example\n * ```ts\n * const titles = readCaptureTitles('/workspace', '/workspace/tmp/captures/states/registry.json')\n * ```\n */\nexport function readCaptureTitles(\n\troot: string,\n\tfile: string,\n\tselector?: string,\n): Readonly<Record<string, readonly string[]>> {\n\tconst path = requireCaptureContained(root, file)\n\tconst loaded = attempt(() => readFileSync(path, 'utf8'))\n\tif (!loaded.success)\n\t\tthrow new CaptureError(\n\t\t\t`Missing accepted registry; run the explicit complete-registry refresh: capture registry. Registry path: ${file}`,\n\t\t\t{ code: 'EVIDENCE', cause: loaded.error },\n\t\t)\n\tconst registry: unknown = parseJSON(loaded.value)\n\tif (!isCaptureRegistry(registry))\n\t\tthrow new CaptureError('Invalid accepted registry for case titles', { code: 'EVIDENCE' })\n\treturn Object.fromEntries(\n\t\tregistry.receipts.flatMap((receipt) => {\n\t\t\tconst text = readFileSync(\n\t\t\t\trequireCaptureContained(root, resolve(root, receipt.report.file)),\n\t\t\t\t'utf8',\n\t\t\t)\n\t\t\tif (computeCaptureHash(text) !== receipt.report.digest)\n\t\t\t\tthrow new CaptureError('Registry reporter digest differs for case titles', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst report: unknown = parseJSON(text)\n\t\t\tif (!isRecord(report) || !arrayOf(isRecord)(report.testResults))\n\t\t\t\tthrow new CaptureError('Invalid registry reporter for case titles', { code: 'EVIDENCE' })\n\t\t\tconst selected =\n\t\t\t\tselector === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: new Set(\n\t\t\t\t\t\t\treadCaptureReport(report)\n\t\t\t\t\t\t\t\t.assertions.filter((entry) => matchesCaptureSelector(entry.owner, selector))\n\t\t\t\t\t\t\t\t.map((entry) => entry.case),\n\t\t\t\t\t\t)\n\t\t\treturn report.testResults.flatMap((result) =>\n\t\t\t\t!arrayOf(isRecord)(result.assertionResults)\n\t\t\t\t\t? []\n\t\t\t\t\t: result.assertionResults.flatMap((assertion) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t!isString(assertion.fullName) ||\n\t\t\t\t\t\t\t\t!isString(assertion.title) ||\n\t\t\t\t\t\t\t\t!arrayOf(isString)(assertion.ancestorTitles)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\treturn []\n\t\t\t\t\t\t\tconst titles = [...assertion.ancestorTitles, assertion.title]\n\t\t\t\t\t\t\tif (titles.join(' ') !== assertion.fullName)\n\t\t\t\t\t\t\t\tthrow new CaptureError('Registry reporter title segments differ from its case', {\n\t\t\t\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\treturn selected === undefined || selected.has(assertion.fullName)\n\t\t\t\t\t\t\t\t? [[assertion.fullName, titles] as const]\n\t\t\t\t\t\t\t\t: []\n\t\t\t\t\t\t}),\n\t\t\t)\n\t\t}),\n\t)\n}\n\n/**\n * Parses standard option tokens and refuses empty values, terminators, and repeated single options.\n *\n * @remarks A boolean option whose default is `true` reads its `--no-` form as `false` and refuses\n * its positive form, so `--no-bail` is the one spelling of `bail`; the `--no-` form of any other\n * option is refused as unknown. An option and its `--no-` form repeat each other.\n *\n * @param argv - The arguments after the subcommand\n * @param options - The command's frozen Node option definitions\n * @param usage - The command syntax appended to every parser refusal\n * @returns Typed values, positionals, and the tokens that supplied them\n * @example\n * ```ts\n * readCaptureOptions(['--case=-draft'], CAPTURE_COMMAND_OPTIONS.journey, 'Usage: capture journey <selector>').values.case // '-draft'\n * readCaptureOptions(['--no-bail'], CAPTURE_COMMAND_OPTIONS.journey, 'Usage: capture journey <selector>').values.bail // false\n * ```\n */\nexport function readCaptureOptions<Options extends ParseArgsOptionsConfig>(\n\targv: readonly string[],\n\toptions: Options,\n\tusage: string,\n): CaptureParsedArguments<Options> {\n\ttry {\n\t\tconst parsed = parseArgs({\n\t\t\targs: [...argv],\n\t\t\toptions,\n\t\t\ttokens: true,\n\t\t\tstrict: true,\n\t\t\tallowPositionals: true,\n\t\t\tallowNegative: true,\n\t\t})\n\t\tfor (const token of parsed.tokens) {\n\t\t\tif (token.kind === 'option-terminator')\n\t\t\t\tthrow new CaptureError('The -- option terminator is refused', { code: 'USAGE' })\n\t\t\tif (token.kind !== 'option') continue\n\t\t\tif (token.rawName === `--no-${token.name}` && options[token.name]?.default !== true)\n\t\t\t\tthrow new CaptureError(`Unknown option '${token.rawName}'`, { code: 'USAGE' })\n\t\t\tif (token.rawName === `--${token.name}` && options[token.name]?.default === true)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Unknown option '${token.rawName}'; ${token.name} is on by default, and --no-${token.name} turns it off`,\n\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t)\n\t\t\tif (token.value === '')\n\t\t\t\tthrow new CaptureError(`Missing value: --${token.name}`, { code: 'USAGE' })\n\t\t\tif (\n\t\t\t\toptions[token.name]?.multiple !== true &&\n\t\t\t\tparsed.tokens.some(\n\t\t\t\t\t(earlier) =>\n\t\t\t\t\t\tearlier.kind === 'option' && earlier.name === token.name && earlier.index < token.index,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Repeated option: --${token.name}`, { code: 'USAGE' })\n\t\t}\n\t\treturn parsed\n\t} catch (error) {\n\t\tthrow new CaptureError(`${describeCaptureError(error)}\\n${usage}`, {\n\t\t\tcode: 'USAGE',\n\t\t\tcause: error,\n\t\t})\n\t}\n}\n\n/**\n * Reads the runner's command line into one selector, its flags, and the resolved wrapper path.\n *\n * @remarks\n * `--state` belongs to `capture` and `stale`, and `--portfolio` to `stale`. Journey and capture\n * accept `--changed <ref>` instead of a selector, with optional valueless `--plan`, and valueless\n * `--no-bail`, which sets `bail` to `false`. Every other\n * flag takes one nonempty value, either separated or in equals form, and only `--variant` repeats.\n * A value beginning with a dash requires equals form. A bare invocation leaves its selector absent\n * so the caller can print usage with the declared selectors.\n *\n * @param argv - The arguments after the entry name\n * @param command - The runner command the flags belong to\n * @param root - The absolute workspace path the wrapper path resolves against\n * @param fallback - The repository-relative wrapper path used when `--config` is absent\n * @returns The parsed arguments with an absolute wrapper path\n * @throws Thrown as a `USAGE` capture error for an unknown, repeated, misplaced, or valueless flag, a\n * second selector, a repeated or invalid variant, an invalid state, or an empty case.\n *\n * @example\n * ```ts\n * readCaptureArguments(['pages:mail', '--variant', 'light-390'], 'journey', '/repo', 'vite.journey.config.ts')\n * // { selector: 'pages:mail', config: '/repo/vite.journey.config.ts', variants: ['light-390'] }\n * ```\n */\nexport function readCaptureArguments(\n\targv: readonly string[],\n\tcommand: CaptureCommand,\n\troot: string,\n\tfallback: string,\n): CaptureRunnerArguments {\n\tconst usage = `Usage: capture ${CAPTURE_COMMAND_NAMES[command]} <selector> [options]${command === 'stale' ? '' : `; capture ${CAPTURE_COMMAND_NAMES[command]} --changed <ref> [--plan] [options]`}`\n\tconst { values, positionals: positional } = readCaptureOptions(\n\t\targv,\n\t\tCAPTURE_COMMAND_OPTIONS[command],\n\t\tusage,\n\t)\n\tif (positional.length > 1)\n\t\tthrow new CaptureError('Expected exactly one selector', { code: 'USAGE' })\n\tconst variants = values.variant ?? []\n\tif (new Set(variants).size !== variants.length)\n\t\tthrow new CaptureError('Repeated variant', { code: 'USAGE' })\n\tconst invalid = variants.findIndex((variant) => !isCaptureSegment(variant))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid variant identity; ${describeCaptureFault(`--variant[${String(invalid)}]`, variants[invalid], \"a portable nonempty identity segment; valid values come from the wrapper's variant declarations\")}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst state = 'state' in values && typeof values.state === 'string' ? values.state : undefined\n\tif (state !== undefined && !isCaptureSegment(state))\n\t\tthrow new CaptureError(\n\t\t\t`Invalid state identity; ${describeCaptureFault('--state', state, \"a portable nonempty state identity; valid values come from the selected case's state declarations\")}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst name = values.case\n\tconst mode = values.mode\n\tif (name !== undefined && name.trim() === '')\n\t\tthrow new CaptureError('Empty case name', { code: 'USAGE' })\n\tconst portfolio =\n\t\t'portfolio' in values && typeof values.portfolio === 'string' ? values.portfolio : undefined\n\tconst selector = positional.at(0)\n\tconst changed =\n\t\t'changed' in values && typeof values.changed === 'string' ? values.changed : undefined\n\tconst plan = 'plan' in values && values.plan === true\n\tconst bail = !('bail' in values) || values.bail !== false\n\tif (changed !== undefined && selector !== undefined)\n\t\tthrow new CaptureError(\n\t\t\t'A selector cannot be combined with --changed; use --changed <ref> alone',\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tif (plan && changed === undefined)\n\t\tthrow new CaptureError('--plan requires --changed <ref>', { code: 'USAGE' })\n\treturn {\n\t\t...(selector === undefined ? {} : { selector }),\n\t\t...(changed === undefined ? {} : { changed }),\n\t\t...(plan ? { plan: true } : {}),\n\t\t...(bail ? {} : { bail: false }),\n\t\tconfig: resolve(root, values.config ?? fallback),\n\t\t...(mode === undefined ? {} : { mode }),\n\t\tvariants,\n\t\t...(name === undefined ? {} : { case: name }),\n\t\t...(state === undefined ? {} : { state }),\n\t\t...(portfolio === undefined ? {} : { portfolio }),\n\t}\n}\n\n/**\n * Reads the physical portfolio roots a wrapper declares and refuses a malformed or repeated root.\n *\n * @param value - The wrapper's declaration, expected to be a list of roots\n * @param subject - The name of the declaration in a refusal\n * @returns The validated roots in declaration order\n * @throws Thrown as a `HOST` capture error when the declaration is not a list or a root is malformed, and\n * as an `EVIDENCE` capture error when a portfolio name repeats, case-folded.\n *\n * @example\n * ```ts\n * readCapturePortfolios([{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }], 'portfolios')\n * ```\n */\nexport function readCapturePortfolios(\n\tvalue: unknown,\n\tsubject: string,\n): readonly CapturePortfolioRoot[] {\n\tif (!isArray(value))\n\t\tthrow new CaptureError(\n\t\t\t`The wrapper provides no ${subject}; ${describeCaptureFault(subject, value, 'a list of portfolio roots', ['portfolio', 'directory', 'scoped'])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tconst roots = value.map((root, index): CapturePortfolioRoot => {\n\t\tconst keys = ['portfolio', 'directory', 'scoped']\n\t\tif (\n\t\t\t!isRecord(root) ||\n\t\t\t!isCaptureSegment(root.portfolio) ||\n\t\t\t!isCapturePath(root.directory) ||\n\t\t\ttypeof root.scoped !== 'boolean' ||\n\t\t\tObject.keys(root).some((key) => !keys.includes(key))\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The wrapper provides an invalid ${subject} root; ${describeCaptureFault(`${subject}[${String(index)}]`, root, '{ portfolio: portable segment, directory: contained portable path, scoped: boolean }', keys, keys)}`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\treturn { portfolio: root.portfolio, directory: root.directory, scoped: root.scoped }\n\t})\n\trequireCaptureUnique(\n\t\troots.map((root) => root.portfolio),\n\t\tsubject,\n\t\ttrue,\n\t)\n\treturn roots\n}\n\n/**\n * Reads one wrapper project's host declarations from its Vitest test configuration.\n *\n * @remarks\n * The label is the project's `name` or its `label` member. Tags must not contain whitespace or a\n * tag-filter operator, and a variant must be a portable identity. The project's own `variant` must\n * be one of the declared `variants`, and so must the `first` stage variant. Portfolio roots and\n * the final case are required, and standalone roots default to none. `uniform` is an optional\n * list of unique valid owner selectors for the preflight's frame scan. Default: every scope.\n * An empty list judges none; the declaration never narrows the other readings.\n *\n * @param test - The project's `test` configuration, or any value the wrapper supplied in its place\n * @returns The validated project declaration\n * @throws Thrown as a `HOST` capture error when a declaration is missing or malformed.\n *\n * @example\n * ```ts\n * const project = readCaptureProject({\n * \tname: 'journey:light-390',\n * \ttags: [{ name: 'owner:pages:mail' }],\n * \tprovide: {\n * \t\tvariant: 'light-390',\n * \t\tvariants: [{ name: 'light-390' }],\n * \t\tdirectory: '/repo/tmp/captures/states',\n * \t\trecord: 'tmp/captures/states/runs/a/light-390.json',\n * \t\tinputs: ['src/**'],\n * \t\tfinal: 'closes the run',\n * \t\tfirst: 'light-390',\n * \t\tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * \t},\n * })\n * project.variant // 'light-390'\n * ```\n */\nexport function readCaptureProject(test: unknown): CaptureProject {\n\tconst name: unknown = isRecord(test) ? test.name : undefined\n\tconst label =\n\t\ttypeof name === 'string'\n\t\t\t? name\n\t\t\t: isRecord(name) && typeof name.label === 'string'\n\t\t\t\t? name.label\n\t\t\t\t: undefined\n\tif (label === undefined)\n\t\tthrow new CaptureError(\n\t\t\t'Unsupported journey project name: expected a string or an object with a string label',\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tconst entries: unknown = isRecord(test) ? test.tags : undefined\n\tconst tags: unknown = (isArray(entries) ? entries : []).map((tag): unknown =>\n\t\tisRecord(tag) ? tag.name : undefined,\n\t)\n\tif (\n\t\t!arrayOf(isString)(tags) ||\n\t\ttags.some((tag) => /[\\s!*&|()]/u.test(tag) || CAPTURE_TAG_OPERATORS.includes(tag))\n\t)\n\t\tthrow new CaptureError('The wrapper declares an invalid tag name', { code: 'HOST' })\n\tconst provided: unknown = isRecord(test) ? test.provide : undefined\n\tconst declared: unknown = isRecord(provided) ? provided.variants : undefined\n\tif (!isArray(declared))\n\t\tthrow new CaptureError('A journey project provides no variants', { code: 'HOST' })\n\tconst variants = declared.map((entry): unknown => (isRecord(entry) ? entry.name : undefined))\n\tif (!arrayOf(isString)(variants))\n\t\tthrow new CaptureError('A journey variant has no name', { code: 'HOST' })\n\tif (\n\t\t!isRecord(provided) ||\n\t\t!isString(provided.directory) ||\n\t\t!isString(provided.record) ||\n\t\t!arrayOf(isCapturePattern)(provided.inputs)\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`The wrapper provides no bounded integrity host declaration; ${describeCaptureFault('test.provide', provided, '{ directory: string workspace path, record: string run path, inputs: portable glob[] }', ['directory', 'record', 'inputs'], ['directory', 'record', 'inputs'], isRecord(provided) ? Object.keys(provided) : [])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tconst invalid = variants.findIndex((variant) => !isCaptureSegment(variant))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`A journey variant has an invalid identity; ${describeCaptureFault(`test.provide.variants[${String(invalid)}].name`, variants[invalid], 'a portable nonempty variant identity segment', variants.some(isCaptureSegment) ? variants.filter(isCaptureSegment) : ['<portable variant name>'])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\trequireCaptureUnique(variants, 'journey variants', true)\n\tconst variant = provided.variant\n\tif (!isString(variant) || !variants.includes(variant))\n\t\tthrow new CaptureError(`The project ${label} provides no declared variant`, { code: 'HOST' })\n\tconst first = provided.first\n\tif (!isString(first) || !variants.includes(first))\n\t\tthrow new CaptureError('The wrapper provides no first-stage variant among its variants', {\n\t\t\tcode: 'HOST',\n\t\t})\n\tconst final = provided.final\n\tif (!isString(final) || final.trim() === '')\n\t\tthrow new CaptureError('The wrapper provides no final case', { code: 'HOST' })\n\tconst uniform = provided.uniform\n\tif (uniform !== undefined && !arrayOf(isCaptureSelector)(uniform))\n\t\tthrow new CaptureError('The wrapper uniform scopes must be a list of valid owner selectors', {\n\t\t\tcode: 'HOST',\n\t\t})\n\tif (uniform !== undefined) requireCaptureUnique(uniform, 'uniform scopes')\n\tconst portfolios = readCapturePortfolios(provided.portfolios, 'portfolios')\n\tif (portfolios.length === 0)\n\t\tthrow new CaptureError('The wrapper provides no portfolio roots', { code: 'HOST' })\n\tconst standalone =\n\t\tprovided.standalone === undefined\n\t\t\t? []\n\t\t\t: readCapturePortfolios(provided.standalone, 'standalone portfolios')\n\trequireCaptureUnique(\n\t\t[...portfolios, ...standalone].map((root) => root.portfolio),\n\t\t'portfolio names',\n\t\ttrue,\n\t)\n\treturn {\n\t\tname: label,\n\t\tvariant,\n\t\ttags,\n\t\tvariants,\n\t\tdirectory: provided.directory,\n\t\trecord: provided.record,\n\t\tinputs: provided.inputs,\n\t\tfinal,\n\t\tfirst,\n\t\t...(uniform === undefined ? {} : { uniform }),\n\t\tportfolios,\n\t\tstandalone,\n\t}\n}\n\n/**\n * Describes a project's portfolio roots as comparable lines, primary roots apart from standalone ones.\n *\n * @param project - The project whose roots to describe\n * @returns One line per root, naming its kind, portfolio, directory, and scoping\n *\n * @example\n * ```ts\n * describeCapturePortfolios({\n * \tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * \tstandalone: [],\n * }) // ['primary states tmp/captures/states true']\n * ```\n */\nexport function describeCapturePortfolios(\n\tproject: Pick<CaptureProject, 'portfolios' | 'standalone'>,\n): readonly string[] {\n\treturn [\n\t\t...project.portfolios.map(\n\t\t\t(root) => `primary ${root.portfolio} ${root.directory} ${String(root.scoped)}`,\n\t\t),\n\t\t...project.standalone.map(\n\t\t\t(root) => `standalone ${root.portfolio} ${root.directory} ${String(root.scoped)}`,\n\t\t),\n\t]\n}\n\n/**\n * Refuses a wrapper project set whose members repeat or disagree on a host declaration.\n *\n * @remarks\n * Project labels are unique and so is each project's own variant, case-folded. Every project must\n * declare the same primary directory, inputs, variants, first-stage variant, final case, and\n * portfolio roots, because the runner builds one engine for the whole set. Uniform declarations\n * must also agree as populations, with absence distinct from an empty list.\n *\n * @param projects - The wrapper's projects\n * @returns The first project, whose declarations every other project matches\n * @throws Thrown as a `HOST` capture error when the set is empty or its members disagree, and as an\n * `EVIDENCE` capture error when a label or variant repeats.\n *\n * @example\n * ```ts\n * requireCaptureProjects([project]) // project\n * ```\n */\nexport function requireCaptureProjects(projects: readonly CaptureProject[]): CaptureProject {\n\tconst first = projects.at(0)\n\tif (first === undefined)\n\t\tthrow new CaptureError('No host project declares integrity inputs', { code: 'HOST' })\n\trequireCaptureUnique(\n\t\tprojects.map((project) => project.name),\n\t\t'journey projects',\n\t)\n\trequireCaptureUnique(\n\t\tprojects.map((project) => project.variant),\n\t\t'journey project variants',\n\t\ttrue,\n\t)\n\tif (\n\t\tprojects.some(\n\t\t\t(project) =>\n\t\t\t\tproject.directory !== first.directory ||\n\t\t\t\tproject.final !== first.final ||\n\t\t\t\tproject.first !== first.first ||\n\t\t\t\t(project.uniform === undefined || first.uniform === undefined\n\t\t\t\t\t? project.uniform !== first.uniform\n\t\t\t\t\t: !matchesCaptureMembers(project.uniform, first.uniform)) ||\n\t\t\t\t!matchesCaptureMembers(project.inputs, first.inputs) ||\n\t\t\t\t!matchesCaptureMembers(project.variants, first.variants) ||\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tdescribeCapturePortfolios(project),\n\t\t\t\t\tdescribeCapturePortfolios(first),\n\t\t\t\t),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Host project integrity declarations disagree', { code: 'HOST' })\n\treturn first\n}\n\n/**\n * Describes why a selector names nothing the wrapper declares, naming the first unknown segment.\n *\n * @remarks\n * The depth of a segment decides its label: the first segment is a scope and every deeper one an\n * owner. `all` and every declared owner path, ancestors included, name something.\n *\n * @param selector - The requested owner path or `all`\n * @param selectors - Every owner path the wrapper declares, ancestors included\n * @returns The refusal text, or `undefined` when the selector names a declared population\n *\n * @example\n * ```ts\n * describeCaptureSelectorFault('pages:mail', ['pages', 'pages:mail']) // undefined\n * describeCaptureSelectorFault('pages:none', ['pages', 'pages:mail'])?.includes('selector: received \"pages:none\"') // true\n * ```\n */\nexport function describeCaptureSelectorFault(\n\tselector: string,\n\tselectors: readonly string[],\n): string | undefined {\n\tif (selector === 'all' || selectors.includes(selector)) return undefined\n\tconst parts = selector.split(':')\n\tconst missing = parts.findIndex(\n\t\t(_part, index) => !selectors.includes(parts.slice(0, index + 1).join(':')),\n\t)\n\treturn `Unknown ${missing === 0 ? 'scope' : 'owner'}: ${preview(parts[missing] ?? selector)}; ${describeCaptureFault('selector', selector, 'all or a declared colon-separated owner selector; obsolete owner paths are not aliases', ['all', ...selectors])}`\n}\n\n/**\n * Builds the refusal a wrapper raises for a request file it cannot accept as its parent's.\n *\n * @param file - The absolute request path, named in the message\n * @param cause - The underlying failure, when there is one\n * @returns A `HOST` capture error naming the file\n *\n * @example\n * ```ts\n * buildCaptureRequestRefusal('/repo/tmp/units/journey-selection-4242.json').message\n * // 'Invalid journey selection request: /repo/tmp/units/journey-selection-4242.json'\n * ```\n */\nexport function buildCaptureRequestRefusal(file: string, cause?: unknown): CaptureError {\n\treturn new CaptureError(`Invalid journey selection request: ${file}`, {\n\t\tcode: 'HOST',\n\t\tcontext: { file },\n\t\t...(cause === undefined ? {} : { cause }),\n\t})\n}\n\n/**\n * Reads and validates the request the runner wrote for the wrapper process that is its child.\n *\n * @remarks\n * Only the file named by `ppid` is read, so a request a stopped runner left never reaches a run\n * that has no runner parent. Every refusal names its cause: a file that does not parse, a record\n * whose `pid` differs from the parent's, arguments that differ from the process's own, an\n * unsupported version, an identity that is not a portable segment, a wrapper path that is not\n * `config`, a state on a command that cannot carry one, and a command, selector, variant list, or\n * case the wrapper does not declare.\n *\n * @param options - The parent id, the process arguments, the request directory, and the wrapper's declarations\n * @returns The validated request, or `undefined` when the parent wrote none\n * @throws Thrown as a `HOST` capture error when a request exists and fails any check.\n *\n * @example\n * ```ts\n * const request = readCaptureRequest({\n * \tppid: process.ppid,\n * \targv: process.argv.slice(1),\n * \tdirectory: '/repo/tmp/units',\n * \tconfig: 'configs/vite.journey.config.ts',\n * \towners: ['pages:mail'],\n * \tvariants: ['light-390'],\n * })\n * request?.selector // 'pages:mail', or undefined when no runner is the parent\n * ```\n */\nexport function readCaptureRequest(options: CaptureRequestOptions): CaptureRequest | undefined {\n\tconst file = resolve(\n\t\tresolveCaptureRequests(options.directory),\n\t\t`${CAPTURE_REQUEST_PREFIX}-${String(options.ppid)}.json`,\n\t)\n\tif (!existsSync(file)) return undefined\n\tconst read = attempt(() => readFileSync(file, 'utf8'))\n\tif (!read.success) throw buildCaptureRequestRefusal(file, read.error)\n\tconst parsed = parseJSON(read.value)\n\tif (!isRecord(parsed)) throw buildCaptureRequestRefusal(file)\n\tif (parsed.phase !== undefined)\n\t\tthrow buildCaptureRequestRefusal(\n\t\t\tfile,\n\t\t\tnew CaptureError('Journey selection request belongs to the discovery phase', {\n\t\t\t\tcode: 'HOST',\n\t\t\t}),\n\t\t)\n\tif (parsed.pid !== options.ppid)\n\t\tthrow buildCaptureRequestRefusal(\n\t\t\tfile,\n\t\t\tnew CaptureError('Journey selection request does not belong to the parent process', {\n\t\t\t\tcode: 'HOST',\n\t\t\t}),\n\t\t)\n\tconst args = arrayOf(isString)(parsed.args) ? parsed.args : undefined\n\tif (\n\t\targs === undefined ||\n\t\targs.length !== options.argv.length ||\n\t\t!args.every((argument, index) => argument === options.argv[index])\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`Journey selection request arguments differ from the process arguments: ${file}`,\n\t\t\t{ code: 'HOST', context: { file } },\n\t\t)\n\tif (parsed.version !== 1)\n\t\tthrow new CaptureError('Journey selection request has invalid version', { code: 'HOST' })\n\tif (!isCaptureSegment(parsed.id) || !isCaptureSegment(parsed.stage))\n\t\tthrow new CaptureError('Journey selection request has invalid identity', { code: 'HOST' })\n\tif (parsed.config !== options.config)\n\t\tthrow new CaptureError('Journey selection request has invalid config', { code: 'HOST' })\n\tif (parsed.mode !== undefined && (typeof parsed.mode !== 'string' || parsed.mode.trim() === ''))\n\t\tthrow new CaptureError('Journey selection request has invalid mode', { code: 'HOST' })\n\tconst command =\n\t\tparsed.command === 'journey' || parsed.command === 'capture' ? parsed.command : undefined\n\tif (\n\t\tparsed.state !== undefined &&\n\t\t(typeof parsed.state !== 'string' || parsed.state.trim() === '' || command !== 'capture')\n\t)\n\t\tthrow new CaptureError('Journey selection request has invalid state', { code: 'HOST' })\n\tconst selector = typeof parsed.selector === 'string' ? parsed.selector : undefined\n\tconst variants = arrayOf(isString)(parsed.variants) ? parsed.variants : undefined\n\tif (\n\t\tcommand === undefined ||\n\t\tselector === undefined ||\n\t\tselector.trim() === '' ||\n\t\t(selector !== 'all' &&\n\t\t\t!options.owners.some((owner) => matchesCaptureSelector(owner, selector))) ||\n\t\tvariants === undefined ||\n\t\tvariants.length === 0 ||\n\t\tnew Set(variants).size !== variants.length ||\n\t\tvariants.some((variant) => !options.variants.includes(variant)) ||\n\t\t(parsed.case !== undefined && (typeof parsed.case !== 'string' || parsed.case.trim() === ''))\n\t)\n\t\tthrow new CaptureError(\n\t\t\t'Journey selection request has invalid command, selector, variants, or case',\n\t\t\t{ code: 'HOST' },\n\t\t)\n\treturn {\n\t\tversion: 1,\n\t\tid: parsed.id,\n\t\tstage: parsed.stage,\n\t\tconfig: options.config,\n\t\tpid: options.ppid,\n\t\tcommand,\n\t\t...(typeof parsed.mode === 'string' ? { mode: parsed.mode } : {}),\n\t\tselector,\n\t\t...(typeof parsed.case === 'string' ? { case: parsed.case } : {}),\n\t\tvariants,\n\t\targs,\n\t\t...(typeof parsed.state === 'string' ? { state: parsed.state } : {}),\n\t}\n}\n\n/**\n * Reads a reader's command line into its selection, its flags, and the resolved paths.\n *\n * @remarks\n * The first argument is the selector and every flag after it takes one nonempty value, separated\n * or in equals form. Only `--variant` repeats. `--output` belongs to sheets; the preflight option\n * table refuses it before discovery. `--mode` selects the wrapper's Vitest mode. The wrapper, the journey artifact directory, and the checks module\n * resolve against `root`; `defaults` supplies the first two when the command line names neither.\n *\n * @param argv - The arguments after the entry name\n * @param root - The absolute workspace path the paths resolve against\n * @param defaults - The repository-relative wrapper and journey artifact directory to fall back to\n * @param command - The reader command whose option table applies. Default: `sheets`\n * @returns The reader options and the optional contact-sheet directory\n * @throws Thrown as a `USAGE` capture error for an absent selector, an unknown, repeated, or\n * valueless flag.\n *\n * @example\n * ```ts\n * readCaptureReaderArguments(['pages:mail', '--variant', 'light-390'], '/repo', {\n * \tconfig: 'configs/vite.journey.config.ts',\n * \tjourneys: 'tmp/journey',\n * }).reader.selection // { selector: 'pages:mail', variants: ['light-390'] }\n * ```\n */\nexport function readCaptureReaderArguments(\n\targv: readonly string[],\n\troot: string,\n\tdefaults: CaptureReaderDefaults,\n\tcommand: 'preflight' | 'sheets' = 'sheets',\n): CaptureReaderCommand {\n\tconst usage = `Usage: capture ${command} <selector> ${command === 'sheets' ? '--output <directory> ' : ''}[options]`\n\tconst { values, positionals, tokens } = readCaptureOptions(\n\t\targv,\n\t\tCAPTURE_COMMAND_OPTIONS[command],\n\t\tusage,\n\t)\n\tconst selector = positionals.at(0)\n\tif (selector === undefined || positionals.length !== 1 || tokens.at(0)?.kind !== 'positional')\n\t\tthrow new CaptureError(usage, { code: 'USAGE' })\n\tconst variants = values.variant ?? []\n\tconst state = values.state\n\tconst name = values.case\n\tconst portfolio = values.portfolio\n\tconst checks = values.checks\n\tconst output = 'output' in values && typeof values.output === 'string' ? values.output : undefined\n\tconst mode = values.mode\n\treturn {\n\t\treader: {\n\t\t\troot: resolve(root),\n\t\t\tconfig: resolve(root, values.config ?? defaults.config),\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\tjourneys: resolve(root, values.journeys ?? defaults.journeys),\n\t\t\tselection: {\n\t\t\t\tselector,\n\t\t\t\t...(variants.length === 0 ? {} : { variants }),\n\t\t\t\t...(state === undefined ? {} : { state }),\n\t\t\t\t...(name === undefined ? {} : { case: name }),\n\t\t\t\t...(portfolio === undefined ? {} : { portfolio }),\n\t\t\t},\n\t\t\t...(checks === undefined ? {} : { checks: resolve(root, checks) }),\n\t\t\t...(defaults.requests === undefined ? {} : { requests: defaults.requests }),\n\t\t},\n\t\t...(output === undefined ? {} : { output: resolve(root, output) }),\n\t}\n}\n\n/**\n * Reads the viewport a wrapper project's producing variant declares.\n *\n * @param test - The project's `test` configuration, or any value the wrapper supplied in its place\n * @returns The producing variant's name and pixel geometry\n * @throws Thrown as a `HOST` capture error when the project declares no variant geometry or its\n * producing variant has none.\n *\n * @example\n * ```ts\n * readCaptureViewport({\n * \tprovide: { variant: 'light-390', variants: [{ name: 'light-390', width: 390, height: 844 }] },\n * }) // { name: 'light-390', width: 390, height: 844 }\n * ```\n */\nexport function readCaptureViewport(test: unknown): CaptureViewport {\n\tconst provided: unknown = isRecord(test) ? test.provide : undefined\n\tconst declared: unknown = isRecord(provided) ? provided.variants : undefined\n\tconst variant: unknown = isRecord(provided) ? provided.variant : undefined\n\tif (!arrayOf(isCaptureGeometry)(declared))\n\t\tthrow new CaptureError('A reader project declares no viewport geometry', { code: 'HOST' })\n\tconst viewport = declared.find((entry) => entry.name === variant)\n\tif (viewport === undefined)\n\t\tthrow new CaptureError('A reader project has no declared producing viewport', { code: 'HOST' })\n\treturn { name: viewport.name, width: viewport.width, height: viewport.height }\n}\n\n/**\n * Derives the integrity engine's options from a wrapper project's host declarations.\n *\n * @remarks\n * Without `standalone` the engine reads the project's primary directory and every portfolio root the\n * project authorizes. With one, the engine reads that root alone, keeping its registry, manifest, and\n * lookups beside its own directory.\n *\n * @param root - The absolute workspace path\n * @param project - The wrapper project whose declarations the engine adopts\n * @param standalone - The standalone root to read through, when a selection names one\n * @returns The options the engine is constructed with\n * @throws Thrown as a `HOST` capture error when the directory leaves the repository.\n *\n * @example\n * ```ts\n * buildCaptureIntegrityOptions(root, project).manifest // 'tmp/captures/states/manifest.json'\n * ```\n */\nexport function buildCaptureIntegrityOptions(\n\troot: string,\n\tproject: CaptureProject,\n\tstandalone?: CapturePortfolioRoot,\n): CaptureIntegrityOptions {\n\tconst directory =\n\t\tstandalone === undefined\n\t\t\t? resolveCaptureRelative(root, project.directory)\n\t\t\t: standalone.directory\n\tif (!isCapturePath(directory))\n\t\tthrow new CaptureError('The wrapper provides a directory outside the repository', {\n\t\t\tcode: 'HOST',\n\t\t\tcontext: { directory },\n\t\t})\n\treturn {\n\t\troot,\n\t\tdirectory,\n\t\tinputs: project.inputs,\n\t\tregistry: `${directory}/${CAPTURE_REGISTRY_FILE}`,\n\t\tmanifest: `${directory}/${CAPTURE_MANIFEST_FILE}`,\n\t\tlookups: `${directory}/${CAPTURE_LOOKUPS_FILE}`,\n\t\tportfolios: standalone === undefined ? project.portfolios : [standalone],\n\t}\n}\n\n/**\n * Reports a portfolio, owner, and viewport whose frames mix cropped, viewport-sized, and page-sized images.\n *\n * @remarks\n * Only a frame at its own producing variant counts, so an auxiliary output variant never joins its\n * producer's group. A frame narrower than its viewport reads `crop`, one as tall as the viewport\n * reads `viewport`, and any other reads `page`. The observation names the mixture without inferring\n * which framing was intended.\n *\n * @param images - The selected images, decoded\n * @param producers - The wrapper's producing viewports\n * @returns One observation per group that holds more than one kind\n *\n * @example\n * ```ts\n * scanCaptureFrames(images, producers) // ['Mixed framing: states/pages:mail@390: page, viewport']\n * ```\n */\nexport function scanCaptureFrames(\n\timages: readonly CaptureImageResult[],\n\tproducers: readonly CaptureProducer[],\n): readonly string[] {\n\tconst families = [\n\t\t...new Set(images.map(({ entry }) => `${entry.portfolio}/${resolveCaptureOwner(entry)}`)),\n\t]\n\treturn families.flatMap((family) =>\n\t\t[...new Set(producers.map((producer) => producer.width))].flatMap((width) => {\n\t\t\tconst kinds = [\n\t\t\t\t...new Set(\n\t\t\t\t\timages.flatMap(({ entry, picture }) => {\n\t\t\t\t\t\tconst viewport = producers.find((producer) => producer.project === entry.project)\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t`${entry.portfolio}/${resolveCaptureOwner(entry)}` !== family ||\n\t\t\t\t\t\t\tviewport?.width !== width ||\n\t\t\t\t\t\t\tentry.variant !== viewport.name\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn []\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tpicture.width < viewport.width\n\t\t\t\t\t\t\t\t? 'crop'\n\t\t\t\t\t\t\t\t: picture.height === viewport.height\n\t\t\t\t\t\t\t\t\t? 'viewport'\n\t\t\t\t\t\t\t\t\t: 'page',\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 kinds.length > 1\n\t\t\t\t? [`Mixed framing: ${family}@${String(width)}: ${kinds.join(', ')}`]\n\t\t\t\t: []\n\t\t}),\n\t)\n}\n\n/**\n * Groups the selected images whose bytes are identical.\n *\n * @param images - The selected images, decoded\n * @returns One list of files per digest shared by more than one image\n *\n * @example\n * ```ts\n * collectCaptureIdentical(images) // [['tmp/captures/a.png', 'tmp/captures/b.png']]\n * ```\n */\nexport function collectCaptureIdentical(\n\timages: readonly CaptureImageResult[],\n): ReadonlyArray<readonly string[]> {\n\treturn [...new Set(images.map((image) => image.digest))]\n\t\t.map((digest) =>\n\t\t\timages.filter((image) => image.digest === digest).map((image) => image.entry.file),\n\t\t)\n\t\t.filter((files) => files.length > 1)\n}\n\n/**\n * Finds the journey artifact lines that report an uncaught, unhandled, or logged error.\n *\n * @param file - The artifact's repository-relative path, which prefixes each finding\n * @param text - The artifact's text\n * @returns One finding per matching line\n *\n * @example\n * ```ts\n * collectCaptureErrors('tmp/journey/light-390.txt', 'ok\\nUncaught TypeError') // ['tmp/journey/light-390.txt: Uncaught TypeError']\n * ```\n */\nexport function collectCaptureErrors(file: string, text: string): readonly string[] {\n\treturn text\n\t\t.split(/\\r\\n|\\n/u)\n\t\t.filter((line) => /\\b(uncaught|unhandled|error:)/iu.test(line))\n\t\t.map((line) => `${file}: ${line}`)\n}\n\n/**\n * Resolves one entry of a wrapper's project list to the project it declares.\n *\n * @remarks\n * A factory entry is called with the serve command and the requested mode, or the default test\n * mode, as Vitest calls it, and a promise is awaited. The result is the project as plain data: the runner reads\n * and validates it, so one reader owns every refusal.\n *\n * @param input - The entry as the wrapper declared it: an inline project, a promise of one, or a factory\n * @returns The resolved project, whatever it holds\n *\n * @example\n * ```ts\n * const project = await resolveCaptureWrapperProject(wrapper.test.projects[0])\n * ```\n */\nexport async function resolveCaptureWrapperProject(\n\tinput: unknown,\n\tmode = 'test',\n): Promise<unknown> {\n\treturn isFunction(input) ? await input({ command: 'serve', mode }) : await input\n}\n\n/**\n * Reads one wrapper project, as the description file holds it, into its host declarations and viewport.\n *\n * @remarks\n * The viewport is read when the project declares geometry for its producing variant and is absent\n * otherwise, because a runner command needs none and only a reader refuses its absence.\n *\n * @param value - The resolved project as plain data\n * @returns The validated project and, when it declares one, its producing viewport\n * @throws Thrown as a `HOST` capture error when the project is a path or a non-record, or when its\n * declarations are malformed.\n *\n * @example\n * ```ts\n * const { project } = readCaptureEntry({ test: { name: 'journey:light-390', provide } })\n * project.variant // 'light-390'\n * ```\n */\nexport function readCaptureEntry(value: unknown): CaptureHostEntry {\n\tif (!isRecord(value))\n\t\tthrow new CaptureError('The journey wrapper must declare inline projects', { code: 'HOST' })\n\tconst project = readCaptureProject(value.test)\n\tconst viewport = attempt(() => readCaptureViewport(value.test))\n\treturn { project, ...(viewport.success ? { viewport: viewport.value } : {}) }\n}\n\n/**\n * Resolves the directory that holds the runner's request files for the process that reads them.\n *\n * @remarks\n * A directory the wrapper names wins. Otherwise the directory the runner handed this child in\n * `CAPTURE_REQUESTS` applies, and a process the runner did not start reads `CAPTURE_DEFAULTS.requests`\n * beneath its working directory. The one default therefore lives here and in the executable, and a\n * consumer never has to repeat it.\n *\n * @param directory - The directory the wrapper declares, when it declares one\n * @returns The absolute directory\n *\n * @example\n * ```ts\n * resolveCaptureRequests('/repo/tmp/units') // '/repo/tmp/units'\n * ```\n */\nexport function resolveCaptureRequests(directory?: string): string {\n\treturn resolve(directory ?? process.env[CAPTURE_REQUESTS_FLAG] ?? CAPTURE_DEFAULTS.requests)\n}\n\n/**\n * Builds the empty Node configuration a wrapper returns once it has answered a discovery request.\n *\n * @remarks\n * It carries no project, no setup file, and no include pattern, so Vitest collects no test, starts\n * no browser, and initializes no output for a discovery child.\n *\n * @returns A fresh configuration object\n *\n * @example\n * ```ts\n * export default (await answerCaptureDiscovery(options)) ? buildCaptureDiscoveryConfig() : config\n * ```\n */\nexport function buildCaptureDiscoveryConfig(): CaptureDiscoveryConfig {\n\treturn { test: { include: [], passWithNoTests: true, watch: false } }\n}\n\n/**\n * Accepts the description a wrapper wrote only when it answers this exchange and no other.\n *\n * @remarks\n * Every echo must match: the invocation, the challenge, the wrapper path, the runner as the\n * wrapper's parent, and the child the runner spawned as the writer. Each project then passes the same\n * reader the wrapper's own declarations pass through, and the list may not be empty.\n *\n * @param value - The parsed description file\n * @param expected - What the request and the spawn establish\n * @returns The validated description\n * @throws Thrown as a `HOST` capture error naming the first echo that differs, a malformed\n * document, an empty project list, or a malformed project.\n *\n * @example\n * ```ts\n * const description = readCaptureDescription(parseJSON(text), expected)\n * ```\n */\nexport function readCaptureDescription(\n\tvalue: unknown,\n\texpected: CaptureDescriptionExpectation,\n): CaptureHostDescription {\n\tconst keys = ['version', 'id', 'nonce', 'config', 'parent', 'pid', 'projects']\n\tif (\n\t\t!isRecord(value) ||\n\t\tvalue.version !== CAPTURE_VERSION ||\n\t\t!isArray(value.projects) ||\n\t\tkeys.some((key) => value[key] === undefined) ||\n\t\tObject.keys(value).some((key) => !keys.includes(key))\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`The host description is malformed; ${describeCaptureFault('description', value, '{ version: 1, id: invocation id, nonce: challenge, config: wrapper path, parent: parent pid, pid: discovery child pid, projects: project[] }', keys, keys)}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tif (value.id !== expected.id)\n\t\tthrow new CaptureError(\n\t\t\t`The host description answers another invocation; ${describeCaptureFault('description.id', value.id, 'the active invocation id', [expected.id])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tif (value.nonce !== expected.nonce)\n\t\tthrow new CaptureError(\n\t\t\t`The host description answers another challenge (a replay); ${describeCaptureFault('description.nonce', value.nonce, 'the active discovery challenge', [expected.nonce])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tif (value.config !== expected.config)\n\t\tthrow new CaptureError(\n\t\t\t`The host description names another wrapper; ${describeCaptureFault('description.config', value.config, 'the requested wrapper path', [expected.config])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tif (value.parent !== expected.parent)\n\t\tthrow new CaptureError(\n\t\t\t`The host description was written for another parent process; ${describeCaptureFault('description.parent', value.parent, 'the parent process id', [String(expected.parent)])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tif (expected.pid === undefined || value.pid !== expected.pid)\n\t\tthrow new CaptureError(\n\t\t\t`The host description was not written by the discovery child; ${describeCaptureFault('description.pid', value.pid, 'the spawned discovery child process id', expected.pid === undefined ? [] : [String(expected.pid)])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tif (value.projects.length === 0)\n\t\tthrow new CaptureError(\n\t\t\t`The wrapper declares no projects; ${describeCaptureFault('description.projects', value.projects, 'a nonempty list of wrapper projects', ['{ test: project configuration }'])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\treturn {\n\t\tversion: CAPTURE_VERSION,\n\t\tid: expected.id,\n\t\tnonce: expected.nonce,\n\t\tconfig: expected.config,\n\t\tparent: expected.parent,\n\t\tpid: expected.pid,\n\t\tprojects: value.projects.map(readCaptureEntry),\n\t}\n}\n\n/**\n * Answers the runner's discovery request from the wrapper, before the wrapper does any other work.\n *\n * @remarks\n * The wrapper calls it once, ahead of anything that sets up a browser, initializes an output\n * directory, or collects a test, and returns `buildCaptureDiscoveryConfig()` when it answered. It\n * reads only the request file its parent process wrote and answers `false` when there is none, or\n * when the file is no discovery request, so an execution child falls through to `readCaptureRequest`.\n * A discovery request is accepted only from its own parent with the exact arguments it recorded, the\n * wrapper path it names, and an identity and challenge that are portable segments. The wrapper\n * describes every project from its own declarations and writes one description, atomically, to the\n * invocation directory; a second answer from another process is refused as a replay, while the same\n * process may answer again if Vitest loads its configuration twice.\n *\n * @param options - The parent id, the process arguments, the request directory, the wrapper path, and the wrapper's `test.projects`\n * @returns True once the description is written; false when the request is no discovery request\n * @throws Thrown as a `HOST` capture error for a discovery request that fails any check or a\n * replayed answer. It does not judge the projects: the runner reads and refuses a malformed one.\n *\n * @example\n * ```ts\n * const answered = await answerCaptureDiscovery({\n * \tppid: process.ppid,\n * \targv: process.argv.slice(1),\n * \tconfig: 'configs/vite.journey.config.ts',\n * \tprojects,\n * })\n * ```\n */\nexport async function answerCaptureDiscovery(options: CaptureDiscoveryOptions): Promise<boolean> {\n\tconst directory = resolveCaptureRequests(options.directory)\n\tconst file = resolve(directory, `${CAPTURE_REQUEST_PREFIX}-${String(options.ppid)}.json`)\n\tif (!existsSync(file)) return false\n\tconst read = attempt(() => readFileSync(file, 'utf8'))\n\tif (!read.success) return false\n\tconst parsed = parseJSON(read.value)\n\tif (!isRecord(parsed) || parsed.phase !== CAPTURE_DISCOVERY.phase) return false\n\tif (parsed.pid !== options.ppid)\n\t\tthrow buildCaptureRequestRefusal(\n\t\t\tfile,\n\t\t\tnew CaptureError('Discovery request does not belong to the parent process', {\n\t\t\t\tcode: 'HOST',\n\t\t\t}),\n\t\t)\n\tconst args = arrayOf(isString)(parsed.args) ? parsed.args : undefined\n\tif (\n\t\targs === undefined ||\n\t\targs.length !== options.argv.length ||\n\t\t!args.every((argument, index) => argument === options.argv[index])\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`Discovery request arguments differ from the process arguments: ${file}`,\n\t\t\t{ code: 'HOST', context: { file } },\n\t\t)\n\tif (parsed.version !== CAPTURE_VERSION)\n\t\tthrow new CaptureError('Discovery request has invalid version', { code: 'HOST' })\n\tif (!isCaptureSegment(parsed.id) || !isCaptureSegment(parsed.nonce))\n\t\tthrow new CaptureError('Discovery request has invalid identity', { code: 'HOST' })\n\tif (parsed.config !== options.config)\n\t\tthrow new CaptureError('Discovery request has invalid config', { code: 'HOST' })\n\tif (parsed.mode !== undefined && (typeof parsed.mode !== 'string' || parsed.mode.trim() === ''))\n\t\tthrow new CaptureError('Discovery request has invalid mode', { code: 'HOST' })\n\tconst answer = resolve(\n\t\tdirectory,\n\t\tCAPTURE_RUNS_DIRECTORY,\n\t\tparsed.id,\n\t\tCAPTURE_DISCOVERY.description,\n\t)\n\tconst prior = existsSync(answer) ? parseJSON(readFileSync(answer, 'utf8')) : undefined\n\tif (prior !== undefined && !(isRecord(prior) && prior.pid === process.pid))\n\t\tthrow new CaptureError(`Discovery was already answered for this request: ${file}`, {\n\t\t\tcode: 'HOST',\n\t\t\tcontext: { file },\n\t\t})\n\t// The projects travel as plain data; the runner reads and judges them, so one reader owns every refusal.\n\tconst mode = typeof parsed.mode === 'string' ? parsed.mode : undefined\n\tconst projects = await Promise.all(\n\t\toptions.projects.map((input) => resolveCaptureWrapperProject(input, mode)),\n\t)\n\twriteCaptureDocument(answer, {\n\t\tversion: CAPTURE_VERSION,\n\t\tid: parsed.id,\n\t\tnonce: parsed.nonce,\n\t\tconfig: options.config,\n\t\tparent: options.ppid,\n\t\tpid: process.pid,\n\t\tprojects,\n\t})\n\treturn true\n}\n\n/**\n * Lists a directory through a reader, answering an empty list for a missing directory.\n *\n * @param directory - The absolute directory to list\n * @param list - Reads the directory's entries, such as `readdirSync` with its options\n * @returns The entries the reader returned, or none when the directory is missing\n * @throws Thrown as an `EVIDENCE` capture error naming the directory for any other failure to read it.\n *\n * @example\n * ```ts\n * readCaptureListing('/repo/tmp/captures/states/pages', (path) => readdirSync(path)) // ['inbox--light-390.png']\n * ```\n */\nexport function readCaptureListing<TEntry>(\n\tdirectory: string,\n\tlist: (path: string) => readonly TEntry[],\n): readonly TEntry[] {\n\tconst listed = attempt(() => list(directory))\n\tif (listed.success) return listed.value\n\tif (isError(listed.error) && 'code' in listed.error && listed.error.code === 'ENOENT') return []\n\tthrow new CaptureError(`Cannot list capture frames under ${directory}`, {\n\t\tcode: 'EVIDENCE',\n\t\tcause: listed.error,\n\t\tcontext: { directory },\n\t})\n}\n\n/**\n * Lists the frames a portfolio directory holds, as paths relative to it, in sorted order.\n *\n * @remarks\n * A frame is a `.png` file at the directory's top level or directly inside one of the scope\n * directories. The run records directory holds no frame, and every other directory is unknown. A\n * missing directory, or one removed between the listing and its read, holds no frame.\n *\n * @param directory - The absolute portfolio directory\n * @param scopes - The scope directories the owners declare, each an owner path's first segment\n * @returns Each frame's slash-separated path relative to the directory\n * @throws Thrown as an `EVIDENCE` capture error for a frame beneath the run records, an unknown\n * directory, a directory inside a scope, or a directory the host refuses to read.\n *\n * @example\n * ```ts\n * readCaptureFrames('/repo/tmp/captures/states', ['pages']) // ['pages/inbox--light-390.png']\n * ```\n */\nexport function readCaptureFrames(directory: string, scopes: readonly string[]): readonly string[] {\n\treturn readCaptureListing(directory, (path) => readdirSync(path, { withFileTypes: true }))\n\t\t.flatMap((entry): readonly string[] => {\n\t\t\tif (!entry.isDirectory()) return entry.name.endsWith('.png') ? [entry.name] : []\n\t\t\tif (entry.name === CAPTURE_RUNS_DIRECTORY) {\n\t\t\t\tconst frames = readCaptureListing(resolve(directory, entry.name), (path) =>\n\t\t\t\t\treaddirSync(path, { recursive: true, encoding: 'utf8' }),\n\t\t\t\t).filter((name) => name.endsWith('.png'))\n\t\t\t\tif (frames.length > 0)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`Frames sit beneath the run records: ${describeCaptureMembers(frames.map(normalizeSlashes))}`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { directory } },\n\t\t\t\t\t)\n\t\t\t\treturn []\n\t\t\t}\n\t\t\tif (!scopes.includes(entry.name))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Unknown capture directory: ${describeCaptureFault('directory', entry.name, 'a scope the owners declare, or the run records', [...scopes, CAPTURE_RUNS_DIRECTORY])}`,\n\t\t\t\t\t{ code: 'EVIDENCE', context: { directory } },\n\t\t\t\t)\n\t\t\treturn readCaptureListing(resolve(directory, entry.name), (path) =>\n\t\t\t\treaddirSync(path, { withFileTypes: true }),\n\t\t\t).flatMap((file): readonly string[] => {\n\t\t\t\tif (file.isDirectory())\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`Unknown capture directory: ${preview(`${entry.name}/${file.name}`)}; a scope holds frames only`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { directory } },\n\t\t\t\t\t)\n\t\t\t\treturn file.name.endsWith('.png') ? [`${entry.name}/${file.name}`] : []\n\t\t\t})\n\t\t})\n\t\t.toSorted()\n}\n\n/**\n * Reads the progress file of the stage that is running, or that ran last, in a workspace.\n *\n * @remarks\n * The file is the most recently modified `<stage>.progress.jsonl` beneath the request directory's\n * run directories. The progress file is an observation of the run and never evidence. A partial\n * last line, which the reporter can still be appending, is not read, so a file with no complete\n * line holds no run. For each run with no `end` line, `alive` reads the process id its `init` line\n * records: a writer that has ended turns the run `interrupted`, measured to the time of its last\n * line, and a writer the host cannot inspect, or an id that is not a positive safe integer, lists\n * the run's id in `uninspected`.\n *\n * @param root - The absolute workspace path\n * @param requests - The workspace-relative request directory\n * @param now - The wall-clock time of the reading, in milliseconds since the Unix epoch. Default: `Date.now()`\n * @param alive - Reads whether a writer process exists, or `undefined` when the host cannot tell. Default: `inspectProcess` from `@orkestrel/process/server`\n * @returns The workspace-relative file, one reading per process that wrote it, and the writers the host could not inspect\n * @throws Thrown as a `STAGE` capture error when no stage has written a progress file, or when the\n * file cannot be read or holds a complete line that is not a progress event.\n *\n * @example\n * ```ts\n * readCaptureProgress('/repo', 'tmp/capture').runs[0]?.state // 'live' while the stage runs\n * ```\n */\nexport function readCaptureProgress(\n\troot: string,\n\trequests: string,\n\tnow: number = Date.now(),\n\talive: (pid: number) => boolean | undefined = inspectProcess,\n): CaptureProgress {\n\tconst runs = resolve(root, requests, CAPTURE_RUNS_DIRECTORY)\n\tconst [newest] = globSync(`*/*${CAPTURE_PROGRESS_SUFFIX}`, { cwd: runs })\n\t\t.flatMap((name) => {\n\t\t\tconst stat = attempt(() => statSync(resolve(runs, name)))\n\t\t\treturn stat.success && stat.value.isFile()\n\t\t\t\t? [{ file: resolveCaptureRelative(root, resolve(runs, name)), time: stat.value.mtimeMs }]\n\t\t\t\t: []\n\t\t})\n\t\t.toSorted((left, right) => right.time - left.time || right.file.localeCompare(left.file))\n\tif (newest === undefined)\n\t\tthrow new CaptureError(\n\t\t\t`No stage has written a progress file under ${resolveCaptureRelative(root, runs)}; run a journey, frames, or registry command first`,\n\t\t\t{ code: 'STAGE', context: { directory: resolveCaptureRelative(root, runs) } },\n\t\t)\n\tconst read = attempt(() =>\n\t\textractProgressEvents(readFileSnapshot(resolve(root, newest.file)).toString('utf8')),\n\t)\n\tif (!read.success)\n\t\tthrow new CaptureError(\n\t\t\t`Cannot read the progress file ${newest.file}: ${describeCaptureOutput(describeCaptureError(read.error))}`,\n\t\t\t{ code: 'STAGE', cause: read.error, context: { file: newest.file } },\n\t\t)\n\tconst events = read.value\n\tconst computed = computeProgress(events, now)\n\tconst writers = new Map(\n\t\tcomputed\n\t\t\t.filter((run) => run.state === 'live')\n\t\t\t.map((run) => [\n\t\t\t\trun.pid,\n\t\t\t\tNumber.isSafeInteger(run.pid) && run.pid > 0 ? alive(run.pid) : undefined,\n\t\t\t]),\n\t)\n\treturn {\n\t\tfile: newest.file,\n\t\truns: computed.map((run): ProgressRun => {\n\t\t\tif (writers.get(run.pid) !== false) return run\n\t\t\t// An interrupted run wrote no end line, so its clock stops at the time of its last line.\n\t\t\tconst own = events.filter((event) => event.pid === run.pid)\n\t\t\tconst init = own.findLast((event): event is ProgressInitEvent => event.event === 'init')\n\t\t\tconst last = own.at(-1)\n\t\t\tconst ended =\n\t\t\t\tinit === undefined || last === undefined\n\t\t\t\t\t? run\n\t\t\t\t\t: (computeProgressRun(own, init.wall + last.time - init.time) ?? run)\n\t\t\treturn { ...ended, state: 'interrupted', running: [], remaining: undefined }\n\t\t}),\n\t\tuninspected: [...writers].flatMap(([pid, answer]) => (answer === undefined ? [pid] : [])),\n\t}\n}\n\n/**\n * Renders a progress reading as the text `capture progress` prints.\n *\n * @param progress - The reading `readCaptureProgress` returns\n * @returns The file line, then each run as `renderProgress` from `@orkestrel/test/server` renders it,\n * followed by an unknown-state line for each run whose writer the host could not inspect\n *\n * @example\n * ```ts\n * renderCaptureProgress({ file: 'tmp/capture/runs/a/selected.progress.jsonl', runs: [], uninspected: [] })\n * // 'progress tmp/capture/runs/a/selected.progress.jsonl\\nNo run has written a complete progress line yet'\n * ```\n */\nexport function renderCaptureProgress(progress: CaptureProgress): string {\n\treturn [\n\t\t`progress ${progress.file}`,\n\t\t...(progress.runs.length === 0\n\t\t\t? ['No run has written a complete progress line yet']\n\t\t\t: progress.runs.flatMap((run) => [\n\t\t\t\t\trenderProgress([run]),\n\t\t\t\t\t...(progress.uninspected.includes(run.pid)\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t` state unknown: the host could not inspect writer ${String(run.pid)}, so the run might have ended without its end line`,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: []),\n\t\t\t\t])),\n\t].join('\\n')\n}\n\n/**\n * Builds the values capture merges into one variant's Vitest project.\n *\n * @param options - The wrapper's declarations\n * @param variant - The variant the project produces\n * @param provided - The variant's frame directory, run record path, capture switch, and runner request\n * @returns The owner tags, the provided values, and the `readCaptureFrames` browser command over the directory\n *\n * @example\n * ```ts\n * buildCaptureOverride(options, variant, { directory, record, capture: true }).test.provide.record\n * // 'tmp/captures/states/runs/run-1/selected/light-390.json'\n * ```\n */\nexport function buildCaptureOverride(\n\toptions: Omit<CaptureWrapperOptions<unknown>, 'url' | 'project'>,\n\tvariant: CaptureViewport,\n\tprovided: Pick<CaptureProvided, 'directory' | 'record' | 'capture' | 'request'>,\n): CaptureWrapperOverride {\n\tconst scopes = [\n\t\t...new Set(options.owners.flatMap((owner) => collectCaptureAncestors(owner).slice(0, 1))),\n\t]\n\treturn {\n\t\ttest: {\n\t\t\ttags: buildCaptureTags(options.owners).map((name) => ({ name })),\n\t\t\tprovide: {\n\t\t\t\tvariant: variant.name,\n\t\t\t\tvariants: options.variants,\n\t\t\t\tdirectory: provided.directory,\n\t\t\t\trecord: provided.record,\n\t\t\t\tinputs: options.inputs,\n\t\t\t\tsources: options.sources,\n\t\t\t\tfinal: options.final,\n\t\t\t\tfirst: options.first,\n\t\t\t\t...(options.uniform === undefined ? {} : { uniform: options.uniform }),\n\t\t\t\tportfolios: options.portfolios,\n\t\t\t\tcapture: provided.capture,\n\t\t\t\t...(provided.request === undefined ? {} : { request: provided.request }),\n\t\t\t},\n\t\t\tbrowser: {\n\t\t\t\tcommands: { readCaptureFrames: () => readCaptureFrames(provided.directory, scopes) },\n\t\t\t},\n\t\t},\n\t}\n}\n\n/**\n * Builds a journey wrapper's Vitest configuration as plain data, answering discovery first.\n *\n * @remarks\n * Call it inside the wrapper's own `defineConfig` callback, before any other work: capture imports\n * neither Vite nor Vitest, so the result is data the wrapper returns. The wrapper path is `url`\n * relative to the working directory, which is the workspace root for every child the runner\n * spawns. During a discovery request it describes each variant's project as `{ name, tags,\n * provide }`, with the name the host's `project` chose, and returns `buildCaptureDiscoveryConfig()`.\n * Otherwise it reads the runner's request, provides each project the values `CaptureProvided`\n * declares except `standalone`, and registers the browser command `readCaptureFrames`, which lists the frames under\n * the provided directory. With the capture variable unset, each variant writes to its own scratch\n * sibling of the evidence root, emptied first. The result's root `plugins` holds one\n * `createProgressPlugin()`, so a stage the runner passes `--outputFile.progress` writes its\n * progress file.\n *\n * @param options - The wrapper path, variants, owners, stage and final names, evidence root, inputs, sources, portfolios, and project builder\n * @returns The discovery configuration while discovery runs, and otherwise the progress plugin and one project per variant\n * @throws Thrown as a `HOST` capture error, before any directory work, for a `url` that is no\n * `file:` URL, an evidence root that is not a portable relative path, or a variant name that is no\n * capture segment, and later for an invalid owner or a runner request that fails its checks; and as\n * a `CONTAINMENT` capture error for a wrapper or scratch path outside the workspace.\n *\n * @example\n * ```ts\n * export default defineConfig(({ mode }) =>\n * \tbuildCaptureWrapper({ ...declarations, url: import.meta.url, project: (variant, override) => appJourney(variant, mode, override) }),\n * )\n * ```\n */\nexport async function buildCaptureWrapper<TProject>(\n\toptions: CaptureWrapperOptions<TProject>,\n): Promise<CaptureWrapperConfig<TProject> | CaptureDiscoveryConfig> {\n\tconst root = process.cwd()\n\tconst path = attempt(() => fileURLToPath(options.url))\n\tif (!path.success)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid wrapper url; ${describeCaptureFault('url', options.url, \"the wrapper module's import.meta.url, a file: URL\")}`,\n\t\t\t{ code: 'HOST', cause: path.error },\n\t\t)\n\trequireCaptureContained(root, path.value)\n\tif (!isCapturePath(options.directory))\n\t\tthrow new CaptureError(\n\t\t\t`Invalid evidence root; ${describeCaptureFault('directory', options.directory, 'a portable workspace-relative path')}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\t// A variant name becomes a scratch directory segment that is emptied, so it must name one segment.\n\tconst invalid = options.variants.findIndex((variant) => !isCaptureSegment(variant.name))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid variant name; ${describeCaptureFault(`variants[${String(invalid)}].name`, options.variants[invalid]?.name, 'a portable nonempty identity segment')}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\t// A scratch directory is emptied when capture is off, so it must not overlap a root it would empty.\n\tconst roots = [options.directory, ...options.portfolios.map((entry) => entry.directory)]\n\tfor (const variant of options.variants) {\n\t\tconst scratch = resolve(\n\t\t\troot,\n\t\t\tdirname(options.directory),\n\t\t\t`${CAPTURE_WRAPPER_PREFIXES.scratch}${variant.name}`,\n\t\t)\n\t\tconst overlap = roots.find((entry) =>\n\t\t\t[relative(resolve(root, entry), scratch), relative(scratch, resolve(root, entry))].some(\n\t\t\t\t(step) => step === '' || (!step.startsWith('..') && !isAbsolute(step)),\n\t\t\t),\n\t\t)\n\t\tif (overlap !== undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Invalid evidence root; the no-capture scratch directory ${resolveCaptureRelative(root, scratch)} of variant ${variant.name} overlaps ${overlap}, which it would empty`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t}\n\tconst config = resolveCaptureRelative(root, path.value)\n\tconst argv = process.argv.slice(1)\n\tconst capture = process.env[CAPTURE_FLAG] === CAPTURE_FLAG_VALUE\n\tconst evidence = resolve(root, options.directory)\n\tconst answered = await answerCaptureDiscovery({\n\t\tppid: process.ppid,\n\t\targv,\n\t\tconfig,\n\t\tprojects: options.variants.map((variant) => () => {\n\t\t\tconst override = buildCaptureOverride(options, variant, {\n\t\t\t\tdirectory: evidence,\n\t\t\t\trecord: `${options.directory}/${CAPTURE_RUNS_DIRECTORY}/${CAPTURE_DISCOVERY.phase}/${variant.name}.json`,\n\t\t\t\tcapture,\n\t\t\t})\n\t\t\tconst project: unknown = options.project(variant, override)\n\t\t\treturn {\n\t\t\t\ttest: {\n\t\t\t\t\tname: isRecord(project) && isRecord(project.test) ? project.test.name : undefined,\n\t\t\t\t\ttags: override.test.tags,\n\t\t\t\t\tprovide: override.test.provide,\n\t\t\t\t},\n\t\t\t}\n\t\t}),\n\t})\n\tif (answered) return buildCaptureDiscoveryConfig()\n\tconst request = readCaptureRequest({\n\t\tppid: process.ppid,\n\t\targv,\n\t\tconfig,\n\t\towners: options.owners,\n\t\tvariants: options.variants.map((variant) => variant.name),\n\t})\n\tconst invocation =\n\t\trequest === undefined\n\t\t\t? `${CAPTURE_WRAPPER_PREFIXES.direct}${randomUUID()}`\n\t\t\t: `${request.id}/${request.stage}`\n\treturn {\n\t\tplugins: [createProgressPlugin()],\n\t\ttest: {\n\t\t\tprojects: options.variants.map((variant) => {\n\t\t\t\tconst directory = capture\n\t\t\t\t\t? evidence\n\t\t\t\t\t: requireCaptureContained(\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\t\tdirname(options.directory),\n\t\t\t\t\t\t\t\t`${CAPTURE_WRAPPER_PREFIXES.scratch}${variant.name}`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\tif (!capture) {\n\t\t\t\t\trmSync(directory, { recursive: true, force: true })\n\t\t\t\t\tmkdirSync(directory, { recursive: true })\n\t\t\t\t}\n\t\t\t\treturn options.project(\n\t\t\t\t\tvariant,\n\t\t\t\t\tbuildCaptureOverride(options, variant, {\n\t\t\t\t\t\tdirectory,\n\t\t\t\t\t\trecord: `${options.directory}/${CAPTURE_RUNS_DIRECTORY}/${invocation}/${variant.name}.json`,\n\t\t\t\t\t\tcapture,\n\t\t\t\t\t\t...(request === undefined ? {} : { request }),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t},\n\t}\n}\n\n/**\n * Reads the registry command line into the wrapper path, the variants to refresh, and the mode.\n *\n * @remarks\n * The command takes no selector: it refreshes every producing variant the wrapper declares, or the\n * variants named by repeated `--variant` flags. Every flag but valueless `--no-bail` takes one\n * value, and only `--variant` repeats. `--mode` is forwarded to the wrapper's Vitest process\n * unread, and `--no-bail` sets `bail` to `false`.\n *\n * @param argv - The arguments after the subcommand\n * @param root - The absolute workspace path the wrapper path resolves against\n * @param fallback - The repository-relative wrapper path used when `--config` is absent\n * @returns The parsed arguments with an absolute wrapper path\n * @throws Thrown as a `USAGE` capture error for a positional argument, an unknown, repeated, or\n * valueless flag, or a repeated or invalid variant.\n *\n * @example\n * ```ts\n * readCaptureRegistryArguments(['--variant', 'light-390'], '/repo', 'vite.journey.config.ts')\n * // { config: '/repo/vite.journey.config.ts', variants: ['light-390'] }\n * ```\n */\nexport function readCaptureRegistryArguments(\n\targv: readonly string[],\n\troot: string,\n\tfallback: string,\n): CaptureRegistryArguments {\n\tconst usage =\n\t\t'Usage: capture registry [--variant <name>]... [--no-bail] [--mode <name>] [--config <file>]'\n\tconst { values, positionals } = readCaptureOptions(argv, CAPTURE_COMMAND_OPTIONS.registry, usage)\n\tif (positionals.length > 0)\n\t\tthrow new CaptureError(\n\t\t\t`Unexpected argument ${JSON.stringify(positionals[0]?.slice(0, 80))}: the registry command takes no selector and refreshes every producing variant, or those named by --variant. ${usage}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst variants = values.variant ?? []\n\tif (new Set(variants).size !== variants.length)\n\t\tthrow new CaptureError('Repeated variant', { code: 'USAGE' })\n\tconst invalid = variants.findIndex((variant) => !isCaptureSegment(variant))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid variant identity; ${describeCaptureFault(`--variant[${String(invalid)}]`, variants[invalid], \"a portable nonempty identity segment; valid values come from the wrapper's variant declarations\")}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst mode = values.mode\n\treturn {\n\t\tconfig: resolve(root, values.config ?? fallback),\n\t\tvariants,\n\t\t...(mode === undefined ? {} : { mode }),\n\t\t...(values.bail === false ? { bail: false } : {}),\n\t}\n}\n\n/**\n * Reads the bounded input population a project declares, as file paths and content hashes.\n *\n * @remarks\n * The expansion is the one the integrity engine takes: the native glob over the patterns, regular\n * files only, sorted, each path contained in the workspace. A pattern that matches nothing\n * contributes no file.\n *\n * @param root - The absolute workspace path\n * @param patterns - The project's native input patterns\n * @param hash - Digests each file's exact bytes. Default: `computeCaptureHash`\n * @param read - Reads a contained input through the owning operation's snapshot memo, when supplied\n * @returns The workspace-relative path of every matched file and its digest\n * @throws Thrown as a `CONTAINMENT` capture error for a matched path the evidence cannot hold, and as\n * an `EVIDENCE` capture error for a path that matches under two spellings.\n *\n * @example\n * ```ts\n * readCaptureInputs(process.cwd(), ['src/**']) // { 'src/a.ts': '3f2a…' }\n * ```\n */\nexport function readCaptureInputs(\n\troot: string,\n\tpatterns: readonly string[],\n\thash: CaptureHashHandler = computeCaptureHash,\n\tread?: CaptureInputHandler,\n): Readonly<Record<string, string>> {\n\tconst files = [...new Set(globSync([...patterns], { cwd: root }).map(normalizeSlashes))]\n\t\t.filter((file) => {\n\t\t\tif (!isCapturePath(file))\n\t\t\t\tthrow new CaptureError(`Input path cannot be held as evidence: ${JSON.stringify(file)}`, {\n\t\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t\t})\n\t\t\treturn statSync(requireCaptureContained(root, resolve(root, file))).isFile()\n\t\t})\n\t\t.toSorted()\n\trequireCaptureUnique(files, 'input paths', true)\n\treturn Object.fromEntries(\n\t\tfiles.flatMap((file) => {\n\t\t\tconst digest =\n\t\t\t\tread === undefined\n\t\t\t\t\t? hash(readFileSync(requireCaptureContained(root, resolve(root, file))))\n\t\t\t\t\t: read(file)\n\t\t\treturn digest === undefined ? [] : [[file, digest]]\n\t\t}),\n\t)\n}\n\n/**\n * Writes one JSON document atomically, so a reader sees the old bytes or the new and never a part.\n *\n * @remarks\n * The document is written to a unique temporary sibling, flushed, and renamed over the target. The\n * signal is checked after the flush and before the rename, and the temporary file never outlives the\n * call.\n *\n * @param path - The absolute target path, whose directory is created when missing\n * @param value - The value to serialize\n * @param signal - Aborts the write before the rename when it fires\n *\n * @example\n * ```ts\n * writeCaptureDocument('/repo/tmp/captures/states/registry.json', registry)\n * ```\n */\nexport function writeCaptureDocument(path: string, value: unknown, signal?: AbortSignal): void {\n\tmkdirSync(dirname(path), { recursive: true })\n\tconst temporary = `${path}.${randomUUID()}.tmp`\n\ttry {\n\t\twriteFileSync(temporary, `${JSON.stringify(value)}\\n`, { flag: 'wx', flush: true })\n\t\tsignal?.throwIfAborted()\n\t\trenameSync(temporary, path)\n\t} finally {\n\t\trmSync(temporary, { force: true })\n\t}\n}\n","import type {\n\tCaptureDiscoveryInterface,\n\tCaptureExecutionResult,\n\tCaptureDiscoveryRequest,\n\tCaptureDiscoveryRunOptions,\n\tCaptureHostDescription,\n} from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport { existsSync, readFileSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { attempt, parseJSON } from '@orkestrel/contract'\nimport { CAPTURE_VERSION, CaptureError, describeCaptureError, isCapturePath } from '@src/core'\nimport { CAPTURE_DISCOVERY, CAPTURE_VITEST_ENTRY } from './constants.js'\nimport {\n\treadCaptureDescription,\n\tresolveCaptureRelative,\n\trequireCaptureArgument,\n} from './helpers.js'\n\n/**\n * Reads a consumer's wrapper by running the consumer's installed Vitest in discovery mode.\n *\n * @remarks\n * The runner never loads the wrapper itself, so it imports neither Vite nor Vitest. It publishes an\n * atomic request with the `discover` phase, spawns the consumer's own Vitest entry through Node as\n * `list --filesOnly --config <wrapper> --configLoader runner`, and reads back the description the\n * wrapper writes when it calls `answerCaptureDiscovery`. The child is bounded by a deadline and\n * recorded by the invocation, so an interrupt ends it with the rest of its tree. The description is\n * accepted only after the child exited zero and every echo in it matches this exchange: the\n * invocation, the challenge, the wrapper, this process as the wrapper's parent, and the spawned\n * child as its writer. A wrapper that never answers, answers another exchange, or answers twice\n * from different processes is refused.\n *\n * @example\n * ```ts\n * const discovery = new CaptureDiscovery({ root: process.cwd(), config, invocation })\n * const { projects } = await discovery.describe()\n * ```\n */\nexport class CaptureDiscovery implements CaptureDiscoveryInterface {\n\treadonly #options: CaptureDiscoveryRunOptions\n\n\t/**\n\t * Binds the workspace, the wrapper, and the invocation that owns the child.\n\t *\n\t * @param options - The workspace, the absolute wrapper path, the invocation, and the optional mode and deadline\n\t */\n\tconstructor(options: CaptureDiscoveryRunOptions) {\n\t\tthis.#options = options\n\t}\n\n\tasync describe(): Promise<CaptureHostDescription> {\n\t\tconst { root, config, invocation, mode, deadline } = this.#options\n\t\tinvocation.prepare()\n\t\trequireCaptureArgument(root, resolve(root, config), '--config')\n\t\tconst relative = resolveCaptureRelative(root, config)\n\t\tif (!isCapturePath(relative))\n\t\t\tthrow new CaptureError('Config must be a contained repository path', { code: 'USAGE' })\n\t\tif (!existsSync(resolve(root, config)))\n\t\t\tthrow new CaptureError(`Cannot find the journey wrapper: ${relative}`, {\n\t\t\t\tcode: 'USAGE',\n\t\t\t\tcontext: { config: relative },\n\t\t\t})\n\t\tconst entry = resolve(root, CAPTURE_VITEST_ENTRY)\n\t\tif (!existsSync(entry))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot find the consumer's installed Vitest: ${CAPTURE_VITEST_ENTRY}; install vitest in the workspace`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\tconst nonce = randomUUID()\n\t\tconst args = [\n\t\t\tentry,\n\t\t\t...CAPTURE_DISCOVERY.arguments,\n\t\t\t'--config',\n\t\t\tresolve(root, config),\n\t\t\t...(mode === undefined ? [] : mode.startsWith('-') ? [`--mode=${mode}`] : ['--mode', mode]),\n\t\t\t'--configLoader',\n\t\t\t'runner',\n\t\t]\n\t\tconst request: CaptureDiscoveryRequest = {\n\t\t\tversion: CAPTURE_VERSION,\n\t\t\tphase: CAPTURE_DISCOVERY.phase,\n\t\t\tid: invocation.id,\n\t\t\tnonce,\n\t\t\tconfig: relative,\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\tpid: process.pid,\n\t\t\targs,\n\t\t}\n\t\tconst answer = resolve(invocation.directory, CAPTURE_DISCOVERY.description)\n\t\tconst log = resolve(invocation.directory, 'discovery.log')\n\t\tconst limit = deadline ?? CAPTURE_DISCOVERY.deadline\n\t\tinvocation.prepare()\n\t\trmSync(answer, { force: true })\n\t\tconst result = await this.#run(request, args, log, limit)\n\t\tif (invocation.interrupted)\n\t\t\tthrow new CaptureError('Runner interrupted', {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcontext: { phase: 'discover' },\n\t\t\t})\n\t\tif (result.expired === true)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Discovery of ${relative} did not finish within ${String(limit)} ms; the child was ended`,\n\t\t\t\t{ code: 'HOST', context: { config: relative } },\n\t\t\t)\n\t\tif (result.code !== 0 || result.signal !== null)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Discovery of ${relative} did not exit successfully (${String(result.code ?? result.signal)}); see ${log}`,\n\t\t\t\t{ code: 'HOST', context: { config: relative } },\n\t\t\t)\n\t\tif (!existsSync(answer))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The wrapper ${relative} answered no discovery request; call answerCaptureDiscovery before any other work`,\n\t\t\t\t{ code: 'HOST', context: { config: relative } },\n\t\t\t)\n\t\tconst read = attempt(() => parseJSON(readFileSync(answer, 'utf8')))\n\t\tif (!read.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The host description cannot be read: ${describeCaptureError(read.error)}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t\tcause: read.error,\n\t\t\t\t},\n\t\t\t)\n\t\treturn readCaptureDescription(read.value, {\n\t\t\tid: invocation.id,\n\t\t\tnonce,\n\t\t\tconfig: relative,\n\t\t\tparent: process.pid,\n\t\t\tpid: result.pid,\n\t\t})\n\t}\n\n\t// Publishes the request for the length of the child, and withdraws it whatever the child does.\n\tasync #run(\n\t\trequest: CaptureDiscoveryRequest,\n\t\targs: readonly string[],\n\t\tlog: string,\n\t\tdeadline: number,\n\t): Promise<CaptureExecutionResult> {\n\t\tconst { invocation } = this.#options\n\t\ttry {\n\t\t\tinvocation.publish(request)\n\t\t\treturn await invocation.spawn(args, log, true, deadline)\n\t\t} finally {\n\t\t\tinvocation.retract()\n\t\t}\n\t}\n}\n","import type {\n\tCaptureCollectionReceipt,\n\tCaptureDestination,\n\tCaptureDigest,\n\tCaptureFreshness,\n\tCaptureLookup,\n\tCaptureRegistry,\n\tCaptureRun,\n\tCaptureStamp,\n\tCaptureStatus,\n\tCaptureStoredManifest,\n} from '@src/core'\nimport type {\n\tCaptureChangePlan,\n\tCaptureCheckOptions,\n\tCaptureCheckResult,\n\tCaptureCollectionEvidence,\n\tCaptureDirectoryResult,\n\tCaptureEvidence,\n\tCaptureFileSnapshot,\n\tCaptureHashHandler,\n\tCaptureIntegrityInterface,\n\tCaptureIntegrityOptions,\n\tCaptureLookupOptions,\n\tCaptureLookupResult,\n\tCaptureReadOptions,\n\tCaptureReadResult,\n\tCaptureSnapshot,\n\tCaptureStageOptions,\n\tCaptureStageResult,\n\tCaptureStaleOptions,\n} from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { dirname, isAbsolute, matchesGlob, relative, resolve, sep } from 'node:path'\nimport { isRecord, parseJSON } from '@orkestrel/contract'\nimport { executeSync } from '@orkestrel/process/server'\nimport {\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tcollectCaptureChanges,\n\tcollectCaptureDuplicates,\n\tdescribeCaptureDeclaration,\n\tdescribeCaptureDestination,\n\tdescribeCaptureError,\n\tdescribeCaptureIdentity,\n\tdescribeCaptureRequest,\n\tisCaptureError,\n\tisCaptureLookupJournal,\n\tisCapturePath,\n\tisCapturePattern,\n\tisCaptureRegistry,\n\tisCaptureRequest,\n\tisCaptureRun,\n\tisCaptureSegment,\n\tisCaptureSelector,\n\tisCaptureStoredManifest,\n\tmatchesCaptureMembers,\n\tmatchesCaptureSelector,\n\treadCaptureDirty,\n\treadCaptureReport,\n\trequireCaptureUnique,\n\tresolveCaptureKey,\n\tresolveCaptureOwner,\n\tresolveCaptureStatus,\n\tvalidateCaptureReceipt,\n\tvalidateCaptureRun,\n} from '@src/core'\nimport {\n\tbuildCaptureChangePlan,\n\tbuildCaptureDigest,\n\tbuildCaptureLookupJournal,\n\tcomputeCaptureHash,\n\tcomputeRegistryDigest,\n\tmatchesCaptureSignature,\n\tnormalizeSlashes,\n\treadCaptureLookups,\n\treadCaptureInputs,\n\tmatchesCaptureFile,\n\tmergeCaptureLookups,\n\treadCaptureAncestor,\n\tresolveCapturePhysical,\n\tdescribeCaptureSelectorFault,\n\tdescribeCaptureFault,\n\treadCaptureImage,\n\tdescribeCaptureOutput,\n\tfilterCaptureInputs,\n\tcomputeCaptureMatchKey,\n} from './helpers.js'\n\n/**\n * Validates capture transactions, freshness, and state lookup against real filesystem evidence.\n *\n * @remarks\n * The host supplies every product path, portfolio mapping, and source population; the engine\n * infers none of them from a name. Construct it through `createCaptureIntegrity`, or directly\n * with the same options.\n *\n * @example\n * ```ts\n * const integrity = new CaptureIntegrity({\n * \troot: process.cwd(),\n * \tdirectory: 'tmp/captures/states',\n * \tinputs: ['src/**'],\n * \tregistry: 'tmp/captures/states/registry.json',\n * \tmanifest: 'tmp/captures/states/manifest.json',\n * \tlookups: 'tmp/captures/states/lookups.json',\n * \tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * })\n * ```\n */\nexport class CaptureIntegrity implements CaptureIntegrityInterface {\n\treadonly #options: CaptureIntegrityOptions\n\treadonly #root: string\n\treadonly #roots: ReadonlyMap<string, string>\n\treadonly #hash: CaptureHashHandler\n\t// Glob answers read no disk and the key carries the population digest, so every stamp shares them.\n\treadonly #matches = new Map<string, ReadonlySet<string>>()\n\n\t/**\n\t * Binds the engine to an explicit workspace and host portfolio mapping.\n\t *\n\t * @param options - The workspace, evidence paths, authorized physical roots, and optional file hash\n\t * @throws Thrown when the root is not absolute, a path escapes the root, or a portfolio is invalid.\n\t */\n\tconstructor(options: CaptureIntegrityOptions) {\n\t\tif (!isAbsolute(options.root))\n\t\t\tthrow new CaptureError('Integrity root must be absolute', { code: 'HOST' })\n\t\tthis.#root = realpathSync(options.root)\n\t\tthis.#hash = options.hash ?? computeCaptureHash\n\t\tthis.#options = {\n\t\t\t...options,\n\t\t\tinputs: [...options.inputs],\n\t\t\tportfolios: options.portfolios.map((entry) => ({ ...entry })),\n\t\t}\n\t\tif (options.inputs.length === 0 || !options.inputs.every(isCapturePattern))\n\t\t\tthrow new CaptureError('Invalid bounded host inputs', { code: 'HOST' })\n\t\tfor (const path of [options.directory, options.manifest, options.registry, options.lookups])\n\t\t\tthis.#resolve(path)\n\t\tif (options.portfolios.length === 0)\n\t\t\tthrow new CaptureError('Missing host portfolio roots', { code: 'HOST' })\n\t\trequireCaptureUnique(\n\t\t\toptions.portfolios.map((entry) => entry.portfolio),\n\t\t\t'portfolio identities',\n\t\t\ttrue,\n\t\t)\n\t\trequireCaptureUnique(\n\t\t\toptions.portfolios.map((entry) => entry.directory),\n\t\t\t'portfolio roots',\n\t\t\ttrue,\n\t\t)\n\t\tif (!options.portfolios.every((entry) => isCaptureSegment(entry.portfolio)))\n\t\t\tthrow new CaptureError('Invalid portfolio identity', { code: 'HOST' })\n\t\tthis.#roots = new Map(\n\t\t\toptions.portfolios.map((entry) => [entry.directory, this.#resolve(entry.directory)] as const),\n\t\t)\n\t\tif (!this.#roots.has(options.directory))\n\t\t\tthrow new CaptureError('Primary run directory has no authorized portfolio root', {\n\t\t\t\tcode: 'HOST',\n\t\t\t})\n\t\tfor (const entry of options.portfolios) this.#path(entry.directory)\n\t}\n\n\t/**\n\t * Classifies changes since a Git merge-base through the accepted registry.\n\t *\n\t * @param ref - The Git ref whose merge-base with HEAD bounds tracked changes; HEAD selects uncommitted work\n\t * @returns Every tracked or untracked changed path and the reduced owner selection\n\t * @throws Thrown when Git refuses the ref or the accepted registry cannot be authenticated.\n\t * @example\n\t * ```ts\n\t * const plan = integrity.changed('HEAD')\n\t * ```\n\t */\n\tchanged(ref: string): CaptureChangePlan {\n\t\tconst registry = this.#registry(new Map(), new Map())\n\t\ttry {\n\t\t\tconst commit = this.#git([\n\t\t\t\t'rev-parse',\n\t\t\t\t'--verify',\n\t\t\t\t'--end-of-options',\n\t\t\t\t`${ref}^{commit}`,\n\t\t\t]).trim()\n\t\t\tconst base = this.#git(['merge-base', commit, 'HEAD']).trim()\n\t\t\tconst tracked = this.#git(['diff', '--name-only', '--no-renames', '-z', base, '--'])\n\t\t\tconst untracked = this.#git(['ls-files', '--others', '--exclude-standard', '-z'])\n\t\t\treturn buildCaptureChangePlan(\n\t\t\t\t[tracked, untracked].flatMap((text) => text.split('\\0').filter((path) => path !== '')),\n\t\t\t\tregistry.entries,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthrow new CaptureError(describeCaptureError(error), { code: 'HOST', cause: error })\n\t\t}\n\t}\n\n\t/**\n\t * Validates an executed stage before atomically publishing its authorized evidence.\n\t *\n\t * @param options - The exact stage and the runner-owned child execution callback\n\t * @returns The committed stage evidence after every selected sibling validates\n\t * @throws Thrown when execution, identity, records, reporter results, paths, inputs, registry\n\t * evidence, projection, or atomic publication fails. Precommit failures preserve prior\n\t * manifest bytes, and journey requests publish no image stamps.\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await integrity.stamp(stage)\n\t * ```\n\t */\n\tasync stamp(options: CaptureStageOptions): Promise<CaptureStageResult> {\n\t\tconst request = options.request\n\t\tif (!isCaptureRequest(request))\n\t\t\tthrow new CaptureError('Invalid capture stage request', { code: 'HOST' })\n\t\trequireCaptureUnique(request.variants, 'requested variants', true)\n\t\trequireCaptureUnique(\n\t\t\toptions.projects.map((project) => project.name),\n\t\t\t'selected projects',\n\t\t\ttrue,\n\t\t)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\trequest.variants,\n\t\t\t\toptions.projects.map((project) => project.variant),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Selected projects differ from requested variants', { code: 'HOST' })\n\t\tthis.#path(request.config)\n\t\tthis.#path(options.report)\n\t\tif (options.report !== this.#reportPath(request.args))\n\t\t\tthrow new CaptureError('Reporter path differs from requested argv', { code: 'HOST' })\n\t\tfor (const project of options.projects) {\n\t\t\tif (!matchesCaptureMembers(project.inputs, this.#options.inputs))\n\t\t\t\tthrow new CaptureError('Project input population differs from host inputs', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\tif (\n\t\t\t\tproject.record !==\n\t\t\t\t`${this.#options.directory}/runs/${request.id}/${request.stage}/${project.variant}.json`\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Selected record path differs from stage identity', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\tthis.#path(project.record)\n\t\t}\n\t\toptions.signal?.throwIfAborted()\n\t\tif (request.state !== undefined && request.case === undefined)\n\t\t\tthrow new CaptureError('State request must name its resolved declaring case', {\n\t\t\t\tcode: 'SELECTION',\n\t\t\t})\n\t\tconst evidence = this.#evidence(new Map())\n\t\tthis.#uniqueRegistry(evidence.registry.entries)\n\t\tconst before = this.#snapshot(options)\n\t\tconst outcome = await options.execute()\n\t\tconst started = performance.now()\n\t\toptions.signal?.throwIfAborted()\n\t\tif (outcome.code !== 0 || outcome.signal !== null)\n\t\t\tthrow new CaptureError('Capture stage child did not exit successfully', {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcontext: { code: outcome.code, signal: outcome.signal },\n\t\t\t})\n\t\t// The record pass reads each file once; the final check below rereads disk with its own memo.\n\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst digests = new Map<string, CaptureDigest>()\n\t\tconst stable = new Map<string, true>()\n\t\tconst reporter = this.#fresh(options.report, before, snapshots)\n\t\tconst report = readCaptureReport(this.#json(options.report))\n\t\tif (report.start < before.time || report.end > Date.now())\n\t\t\tthrow new CaptureError('Reporter does not belong to this execution', { code: 'EVIDENCE' })\n\t\tif (report.assertions.some((entry) => !request.variants.includes(entry.variant)))\n\t\t\tthrow new CaptureError('Reporter contains an unrequested producing variant', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst records = options.projects.map((project) => {\n\t\t\tconst file = this.#fresh(project.record, before, snapshots)\n\t\t\tconst run = this.#json(project.record)\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\trun.variant !== project.variant ||\n\t\t\t\tdescribeCaptureRequest(run.request) !== describeCaptureRequest(request)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Invalid or mismatched final record: ${project.record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (Date.parse(run.time) < before.time || Date.parse(run.time) > report.end)\n\t\t\t\tthrow new CaptureError('Final record time does not belong to this execution', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureRun(run, report, project.name)\n\t\t\tif (run.artifact === undefined)\n\t\t\t\tthrow new CaptureError(`Final record names no journey artifact: ${project.record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst artifact = this.#fresh(run.artifact.file, before, snapshots)\n\t\t\tif (artifact.image.digest !== run.artifact.digest)\n\t\t\t\tthrow new CaptureError(`Journey artifact differs from its record: ${run.artifact.file}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tfor (const destination of run.registry) this.#destination(destination)\n\t\t\tconst snapshot = before.projects.find((entry) => entry.project === project.name)\n\t\t\tif (snapshot === undefined)\n\t\t\t\tthrow new CaptureError('Missing pre-execution project snapshot', { code: 'EVIDENCE' })\n\t\t\tthis.#attest(run, evidence, snapshot.inputs.files, snapshots)\n\t\t\tfor (const destination of run.registry)\n\t\t\t\tthis.#stable(destination, snapshot.inputs, snapshots, digests, stable)\n\t\t\treturn { file, run, artifact }\n\t\t})\n\t\tconst entries = records.flatMap(({ run }) => run.entries)\n\t\tthis.#uniqueRegistry(entries)\n\t\tconst images = entries.map((entry) => this.#fresh(entry.file, before, snapshots, true))\n\t\tconst identities = new Map<string, string>()\n\t\tconst physical = Map.groupBy(this.#images(), (file) => this.#physicalIdentity(file, identities))\n\t\tif (\n\t\t\tentries.some(\n\t\t\t\t(entry) => (physical.get(this.#physicalIdentity(entry.file, identities))?.length ?? 0) > 1,\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Duplicate physical capture output', { code: 'EVIDENCE' })\n\t\tconst provenance = request.command === 'capture' ? this.#provenance() : undefined\n\t\tconst stamps: readonly CaptureStamp[] = entries.map((entry) => {\n\t\t\tconst image = images.find((snapshot) => snapshot.file === entry.file)\n\t\t\tif (image === undefined || provenance === undefined)\n\t\t\t\tthrow new CaptureError('Missing capture provenance', { code: 'EVIDENCE' })\n\t\t\treturn {\n\t\t\t\t...entry,\n\t\t\t\tidentity: {\n\t\t\t\t\tid: request.id,\n\t\t\t\t\tstage: request.stage,\n\t\t\t\t\tpid: request.pid,\n\t\t\t\t\tconfig: request.config,\n\t\t\t\t},\n\t\t\t\ttime: new Date().toISOString(),\n\t\t\t\t...provenance,\n\t\t\t\town: this.#digest(entry.sources.own, snapshots, digests).files,\n\t\t\t\tshared: this.#digest(entry.sources.shared, snapshots, digests),\n\t\t\t\ttests: this.#digest(entry.sources.tests, snapshots, digests).files,\n\t\t\t\timage: image.image,\n\t\t\t\tregistry: evidence.registry.digest,\n\t\t\t}\n\t\t})\n\t\tconst lookups: readonly CaptureLookup[] = records.flatMap(({ run, file }) => {\n\t\t\tconst project = options.projects.find((entry) => entry.variant === run.variant)\n\t\t\tif (project === undefined)\n\t\t\t\tthrow new CaptureError('Missing selected project', { code: 'EVIDENCE' })\n\t\t\tconst inputs = this.#digest(project.inputs, snapshots, digests).files\n\t\t\treturn run.declarations\n\t\t\t\t.filter((entry) => run.passed.includes(entry.case))\n\t\t\t\t.map((entry) => ({\n\t\t\t\t\tregistry: evidence.registry.digest,\n\t\t\t\t\tvariant: run.variant,\n\t\t\t\t\tcase: entry.case,\n\t\t\t\t\towner: entry.owner,\n\t\t\t\t\tstates: entry.states,\n\t\t\t\t\tinputs,\n\t\t\t\t\trun: { file: file.file, digest: file.image.digest },\n\t\t\t\t}))\n\t\t})\n\t\tconst collected: readonly CaptureCollectionReceipt[] = records.map(({ run, file }) => {\n\t\t\tconst project = options.projects.find((entry) => entry.variant === run.variant)\n\t\t\tconst snapshot = before.projects.find((entry) => entry.project === project?.name)\n\t\t\tif (project === undefined || snapshot === undefined)\n\t\t\t\tthrow new CaptureError('Missing full-collection input snapshot', { code: 'EVIDENCE' })\n\t\t\treturn {\n\t\t\t\tregistry: evidence.registry.digest,\n\t\t\t\tvariant: run.variant,\n\t\t\t\tproject: project.name,\n\t\t\t\tinputs: snapshot.inputs,\n\t\t\t\trun: { file: file.file, digest: file.image.digest },\n\t\t\t\treport: { file: reporter.file, digest: reporter.image.digest },\n\t\t\t}\n\t\t})\n\t\tconst collections = this.#mergeCollections(evidence.collections, collected)\n\t\tconst merged = mergeCaptureLookups(evidence.lookups, lookups)\n\t\tconst finalSnapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst redigests = new Map<string, CaptureDigest>()\n\t\tconst restable = new Map<string, true>()\n\t\tfor (const record of records) {\n\t\t\tconst project = before.projects.find((entry) =>\n\t\t\t\toptions.projects.some(\n\t\t\t\t\t(selected) => selected.name === entry.project && selected.variant === record.run.variant,\n\t\t\t\t),\n\t\t\t)\n\t\t\tif (project === undefined)\n\t\t\t\tthrow new CaptureError('Missing final input snapshot', { code: 'EVIDENCE' })\n\t\t\tfor (const destination of record.run.registry)\n\t\t\t\tthis.#stable(destination, project.inputs, finalSnapshots, redigests, restable)\n\t\t\tif (\n\t\t\t\tthis.#digest(project.inputs.patterns, finalSnapshots, redigests).digest !==\n\t\t\t\tproject.inputs.digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Bounded host inputs or membership changed during execution', {\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t})\n\t\t}\n\t\tfor (const path of [this.#options.manifest, this.#options.registry, this.#options.lookups]) {\n\t\t\tif (\n\t\t\t\tthis.#file(path, finalSnapshots)?.image.digest !==\n\t\t\t\tbefore.files.find((file) => file.file === path)?.image.digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Evidence changed during the stage: ${path}`, { code: 'STAGE' })\n\t\t}\n\t\tif (\n\t\t\tthis.#file(options.report, finalSnapshots)?.image.digest !== reporter.image.digest ||\n\t\t\trecords.some(\n\t\t\t\t(record) =>\n\t\t\t\t\tthis.#file(record.file.file, finalSnapshots)?.image.digest !== record.file.image.digest ||\n\t\t\t\t\tthis.#file(record.artifact.file, finalSnapshots)?.image.digest !==\n\t\t\t\t\t\trecord.artifact.image.digest,\n\t\t\t) ||\n\t\t\timages.some((image) => !matchesCaptureFile(image, this.#file(image.file, finalSnapshots)))\n\t\t)\n\t\t\tthrow new CaptureError('Stage output changed before commit', { code: 'STAGE' })\n\t\toptions.signal?.throwIfAborted()\n\t\tif (request.command === 'capture' && stamps.length > 0) {\n\t\t\tconst inherited = Object.entries(evidence.manifest?.entries ?? {})\n\t\t\tconst replaced = new Set(stamps.map(resolveCaptureKey))\n\t\t\tconst next: CaptureStoredManifest = {\n\t\t\t\tcollections,\n\t\t\t\tversion: CAPTURE_VERSION,\n\t\t\t\tregistry: evidence.registry,\n\t\t\t\tentries: Object.fromEntries([\n\t\t\t\t\t...inherited.filter(([key]) => !replaced.has(key)),\n\t\t\t\t\t...stamps.map((stamp) => [resolveCaptureKey(stamp), stamp] as const),\n\t\t\t\t]),\n\t\t\t\tlookups: merged,\n\t\t\t}\n\t\t\tif (!isCaptureStoredManifest(next))\n\t\t\t\tthrow new CaptureError('Invalid next manifest', { code: 'EVIDENCE' })\n\t\t\tthis.#commit(this.#options.manifest, next, options.signal)\n\t\t} else if (request.command === 'journey' && collected.length > 0) {\n\t\t\tconst manifest = before.files.find((file) => file.file === this.#options.manifest)?.image\n\t\t\t\t.digest\n\t\t\tthis.#commit(\n\t\t\t\tthis.#options.lookups,\n\t\t\t\tbuildCaptureLookupJournal(merged, collections, manifest),\n\t\t\t\toptions.signal,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\trequest,\n\t\t\tentries: stamps,\n\t\t\tlookups,\n\t\t\tduration: performance.now() - started,\n\t\t\tprojects: records.map(({ run, file }) => ({\n\t\t\t\tproject: options.projects.find((project) => project.variant === run.variant)?.name ?? '',\n\t\t\t\tvariant: run.variant,\n\t\t\t\trecord: { file: file.file, digest: file.image.digest },\n\t\t\t\tdeclarations: run.declarations,\n\t\t\t\tpassed: run.passed,\n\t\t\t})),\n\t\t}\n\t}\n\n\t/**\n\t * Reads current full-collection evidence and selects exact declaration destinations.\n\t *\n\t * @param options - The explicit selection; omitted variants derive from authenticated mappings\n\t * @returns The accepted registry identity and exactly selected destinations\n\t * @throws Thrown with explicit preparation when declarations lack current authenticated evidence.\n\t *\n\t * @example\n\t * ```ts\n\t * const { entries } = await integrity.read({ selector: 'pages:mail' })\n\t * ```\n\t */\n\tasync read(options: CaptureReadOptions): Promise<CaptureReadResult> {\n\t\ttry {\n\t\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\t\tconst digests = new Map<string, CaptureDigest>()\n\t\t\tconst evidence = this.#evidence(snapshots)\n\t\t\tconst collections = this.#collections(evidence, snapshots)\n\t\t\tconst populated = this.#population(evidence, collections)\n\t\t\tconst destinations = this.#destinations(populated)\n\t\t\tthis.#uniqueRegistry(destinations)\n\t\t\tconst variants = this.#variants(destinations, options)\n\t\t\tconst entries = this.#select(populated, destinations, { ...options, variants }, false)\n\t\t\tconst inputs = this.#digest(this.#options.inputs, snapshots, digests)\n\t\t\tfor (const variant of new Set(entries.map((entry) => this.#producer(entry, populated)))) {\n\t\t\t\tconst anchor = evidence.registry.receipts.find((receipt) => receipt.variant === variant)\n\t\t\t\tif (anchor !== undefined && collectCaptureChanges(anchor.inputs, inputs.files).length === 0)\n\t\t\t\t\tcontinue\n\t\t\t\tif (\n\t\t\t\t\t!collections.some(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.run.variant === variant && entry.receipt.inputs.digest === inputs.digest,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`No current full-collection evidence for producing variant: ${variant}`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { variant } },\n\t\t\t\t\t)\n\t\t\t}\n\t\t\t// The final check rereads disk; the read's memo would hide a change made since it measured.\n\t\t\tif (this.#digest(this.#options.inputs, new Map(), new Map()).digest !== inputs.digest)\n\t\t\t\tthrow new CaptureError('Declaration inputs changed during the read', { code: 'EVIDENCE' })\n\t\t\treturn { registry: evidence.registry.digest, entries }\n\t\t} catch (error) {\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureError(error)}. Prepare the explicit complete-registry refresh, or an explicit capture-free owner/case run whose full collection equals that anchor for each affected producing variant; this read starts no process.`,\n\t\t\t\t{ code: isCaptureError(error) ? error.code : 'EVIDENCE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Checks the explicitly selected output population without changing evidence or images.\n\t *\n\t * @param selection - The selected owners, optional output variants, state, and portfolio, and\n\t * the wrapper's declared producing variants. Default variants: every output variant of the\n\t * selected registry destinations.\n\t * @returns Freshness classifications and warnings for the selected population\n\t * @throws Thrown when required evidence, schema, containment, or selection is invalid, or when\n\t * variants are omitted and a declared producing variant has no registry evidence.\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await integrity.check({ selector: 'pages:mail' })\n\t * ```\n\t */\n\tasync check(selection: CaptureStaleOptions): Promise<CaptureCheckResult> {\n\t\tconst started = performance.now()\n\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst digests = new Map<string, CaptureDigest>()\n\t\tconst previous = this.#evidence(snapshots)\n\t\tconst evidence = this.#population(previous, this.#collections(previous, snapshots))\n\t\t// Destinations alone cannot show a producing variant whose full collection never arrived.\n\t\tconst attested = new Set([\n\t\t\t...evidence.registry.receipts.map((receipt) => receipt.variant),\n\t\t\t...evidence.runs.map(({ run }) => run.variant),\n\t\t])\n\t\tconst unattested =\n\t\t\tselection.variants === undefined\n\t\t\t\t? (selection.declared ?? []).filter((variant) => !attested.has(variant))\n\t\t\t\t: []\n\t\tif (unattested.length > 0)\n\t\t\tthrow new CaptureError(`Unattested declared variant: ${unattested.join(', ')}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\tcontext: { variants: unattested },\n\t\t\t})\n\t\tconst registry = this.#destinations(evidence)\n\t\tconst options: CaptureCheckOptions = {\n\t\t\t...selection,\n\t\t\tvariants: this.#variants(registry, selection),\n\t\t}\n\t\tconst required = this.#select(evidence, registry, options, false)\n\t\tconst disk = this.#images()\n\t\tconst identities = new Map<string, string>()\n\t\tconst physical = Map.groupBy(disk, (file) => this.#physicalIdentity(file, identities))\n\t\tconst duplicates = collectCaptureDuplicates(registry.map(resolveCaptureKey), true)\n\t\tconst entries: CaptureFreshness[] = required.map((entry) => {\n\t\t\tconst key = resolveCaptureKey(entry)\n\t\t\tconst stamp = evidence.manifest?.entries[key]\n\t\t\tconst image = this.#file(entry.file, snapshots)\n\t\t\tconst own = this.#digest(entry.sources.own, snapshots, digests)\n\t\t\tconst shared = this.#digest(entry.sources.shared, snapshots, digests)\n\t\t\tconst findings: Array<{ readonly status: CaptureStatus; readonly reason: string }> = []\n\t\t\tif (duplicates.includes(key))\n\t\t\t\tfindings.push({ status: 'duplicate', reason: 'Repeated registry identity' })\n\t\t\tif ((physical.get(this.#physicalIdentity(entry.file, identities))?.length ?? 0) > 1)\n\t\t\t\tfindings.push({ status: 'duplicate', reason: 'Several paths name the same physical image' })\n\t\t\tif (image === undefined)\n\t\t\t\tfindings.push({ status: 'missing', reason: 'Required image is absent' })\n\t\t\tif (stamp === undefined)\n\t\t\t\tfindings.push({ status: 'unstamped', reason: 'Required image has no authorized stamp' })\n\t\t\telse {\n\t\t\t\tif (stamp.file !== entry.file || resolveCaptureOwner(stamp) !== resolveCaptureOwner(entry))\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'orphan',\n\t\t\t\t\t\treason: 'Stamp names an obsolete physical location or owner',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\timage !== undefined &&\n\t\t\t\t\t(image.image.digest !== stamp.image.digest ||\n\t\t\t\t\t\timage.image.size !== stamp.image.size ||\n\t\t\t\t\t\timage.image.modified !== stamp.image.modified)\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'unstamped',\n\t\t\t\t\t\treason: 'Image digest, size, or modification time differs',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\t!matchesCaptureMembers(stamp.sources.shared, entry.sources.shared) ||\n\t\t\t\t\tshared.digest !== stamp.shared.digest\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'stale-shared',\n\t\t\t\t\t\treason: 'Shared source patterns, membership, or hashes changed',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\t!matchesCaptureMembers(stamp.sources.own, entry.sources.own) ||\n\t\t\t\t\tcollectCaptureChanges(stamp.own, own.files).length > 0 ||\n\t\t\t\t\tentry.sources.own.some(\n\t\t\t\t\t\t(pattern) => !Object.keys(own.files).some((file) => matchesGlob(file, pattern)),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'stale-own',\n\t\t\t\t\t\treason: 'Own source patterns, membership, or hashes changed',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\tstamp.case !== entry.case ||\n\t\t\t\t\tstamp.project !== entry.project ||\n\t\t\t\t\tstamp.portfolio !== entry.portfolio\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'orphan',\n\t\t\t\t\t\treason: 'Stamp declaring case, project, or portfolio is obsolete',\n\t\t\t\t\t})\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfile: entry.file,\n\t\t\t\tstate: entry.state,\n\t\t\t\tvariant: entry.variant,\n\t\t\t\tstatus: resolveCaptureStatus(findings.map((finding) => finding.status)),\n\t\t\t\treasons: findings.map((finding) => finding.reason),\n\t\t\t}\n\t\t})\n\t\tconst extras = disk\n\t\t\t.filter(\n\t\t\t\t(file) =>\n\t\t\t\t\t!required.some((entry) => entry.file === file) &&\n\t\t\t\t\tthis.#attributable(file, required, registry, options),\n\t\t\t)\n\t\t\t.map((file) => {\n\t\t\t\tconst name = file.slice(file.lastIndexOf('/') + 1, -4)\n\t\t\t\tconst separator = name.lastIndexOf('--')\n\t\t\t\treturn {\n\t\t\t\t\tfile,\n\t\t\t\t\tstate: separator < 0 ? name : name.slice(0, separator),\n\t\t\t\t\tvariant: separator < 0 ? '' : name.slice(separator + 2),\n\t\t\t\t\tstatus: 'orphan' as const,\n\t\t\t\t\treasons: ['Physical PNG has no selected canonical registry destination'],\n\t\t\t\t}\n\t\t\t})\n\t\tconst warnings = required.flatMap((entry) => {\n\t\t\tconst stamp = evidence.manifest?.entries[resolveCaptureKey(entry)]\n\t\t\tif (stamp === undefined) return []\n\t\t\tconst files = collectCaptureChanges(\n\t\t\t\tstamp.tests,\n\t\t\t\tthis.#digest(entry.sources.tests, snapshots, digests).files,\n\t\t\t)\n\t\t\treturn files.length === 0 ? [] : [{ files, cases: [entry.case] }]\n\t\t})\n\t\treturn {\n\t\t\trequired,\n\t\t\tentries: [...entries, ...extras],\n\t\t\twarnings,\n\t\t\tduration: performance.now() - started,\n\t\t}\n\t}\n\n\t/**\n\t * Resolves an explicitly requested state through fresh registry and passing case evidence.\n\t *\n\t * @param options - The original selector, producing variants, state, and optional exact case\n\t * @returns The agreed declaring case, output mappings, and validated lookup receipts\n\t * @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection;\n\t * the message names the explicit refresh command.\n\t *\n\t * @example\n\t * ```ts\n\t * const { case: name } = await integrity.lookup({ selector: 'pages:mail', state: 'inbox', variants: ['light-390'] })\n\t * ```\n\t */\n\tasync lookup(options: CaptureLookupOptions): Promise<CaptureLookupResult> {\n\t\ttry {\n\t\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\t\tconst digests = new Map<string, CaptureDigest>()\n\t\t\tconst evidence = this.#evidence(snapshots)\n\t\t\tconst entries = this.#select(evidence, this.#destinations(evidence), options, true)\n\t\t\tthis.#uniqueRegistry(entries)\n\t\t\tconst cases = [...new Set(entries.map((entry) => entry.case))]\n\t\t\tconst [name] = cases\n\t\t\tif (\n\t\t\t\tname === undefined ||\n\t\t\t\tcases.length !== 1 ||\n\t\t\t\t(options.case !== undefined && options.case !== name)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t'State declaring case disagrees with the exact case or producing variants',\n\t\t\t\t\t{ code: 'SELECTION' },\n\t\t\t\t)\n\t\t\tconst lookups = entries.map((entry) => {\n\t\t\t\tconst run = evidence.runs.find((record) =>\n\t\t\t\t\trecord.run.registry.some(\n\t\t\t\t\t\t(destination) =>\n\t\t\t\t\t\t\tdescribeCaptureDestination(destination) === describeCaptureDestination(entry),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\tconst lookup = evidence.lookups.find(\n\t\t\t\t\t(candidate) =>\n\t\t\t\t\t\tcandidate.case === entry.case &&\n\t\t\t\t\t\tcandidate.variant === run?.run.variant &&\n\t\t\t\t\t\tcandidate.states.includes(options.state),\n\t\t\t\t)\n\t\t\t\tif (\n\t\t\t\t\tlookup === undefined ||\n\t\t\t\t\tlookup.registry !== evidence.registry.digest ||\n\t\t\t\t\t!matchesCaptureSelector(lookup.owner, options.selector) ||\n\t\t\t\t\tcollectCaptureChanges(\n\t\t\t\t\t\tlookup.inputs,\n\t\t\t\t\t\tthis.#digest(this.#options.inputs, snapshots, digests).files,\n\t\t\t\t\t).length > 0\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`Missing or stale state lookup: ${entry.state} in ${entry.project}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\tconst stamp = evidence.manifest?.entries[resolveCaptureKey(entry)]\n\t\t\t\tif (\n\t\t\t\t\tstamp !== undefined &&\n\t\t\t\t\tdescribeCaptureIdentity(stamp) !== describeCaptureIdentity(entry)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError('State lookup disagrees with the manifest identity', {\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t})\n\t\t\t\treturn lookup\n\t\t\t})\n\t\t\treturn { case: name, entries, lookups }\n\t\t} catch (error) {\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureError(error)}. Refresh explicitly with: capture journey ${options.selector}${options.variants.map((variant) => ` --variant ${variant}`).join('')}${options.case === undefined ? '' : ` --case ${JSON.stringify(options.case)}`}. Registry declaration changes require the complete-registry refresh: capture registry.`,\n\t\t\t\t{ code: isCaptureError(error) ? error.code : 'EVIDENCE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\t// Omitted output variants mean every variant the selected registry destinations declare.\n\t#variants(\n\t\tdestinations: readonly CaptureDestination[],\n\t\toptions: CaptureReadOptions,\n\t): readonly string[] {\n\t\treturn (\n\t\t\toptions.variants ?? [\n\t\t\t\t...new Set(\n\t\t\t\t\tdestinations\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\t\tmatchesCaptureSelector(resolveCaptureOwner(entry), options.selector) &&\n\t\t\t\t\t\t\t\t(options.portfolio === undefined || entry.portfolio === options.portfolio),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((entry) => entry.variant),\n\t\t\t\t),\n\t\t\t]\n\t\t)\n\t}\n\n\t#mergeCollections(\n\t\tprevious: readonly CaptureCollectionReceipt[],\n\t\treceipts: readonly CaptureCollectionReceipt[],\n\t): readonly CaptureCollectionReceipt[] {\n\t\trequireCaptureUnique(\n\t\t\tprevious.map((entry) => entry.run.file),\n\t\t\t'inherited collection records',\n\t\t\ttrue,\n\t\t)\n\t\trequireCaptureUnique(\n\t\t\treceipts.map((entry) => entry.run.file),\n\t\t\t'incoming collection records',\n\t\t\ttrue,\n\t\t)\n\t\tconst replaced = new Set(receipts.map((entry) => entry.run.file))\n\t\tconst merged = [...previous.filter((entry) => !replaced.has(entry.run.file)), ...receipts]\n\t\t// Keep one lineage origin and the latest collection per producing variant.\n\t\treturn merged.filter(\n\t\t\t(entry, index) =>\n\t\t\t\tmerged.findIndex((candidate) => candidate.variant === entry.variant) === index ||\n\t\t\t\tmerged.findLastIndex((candidate) => candidate.variant === entry.variant) === index,\n\t\t)\n\t}\n\n\t#collections(\n\t\tevidence: CaptureEvidence,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t): readonly CaptureCollectionEvidence[] {\n\t\tconst collections = evidence.collections.map((receipt) => {\n\t\t\tconst file = this.#file(receipt.run.file, snapshots)\n\t\t\tconst report = this.#file(receipt.report.file, snapshots)\n\t\t\tif (\n\t\t\t\tfile === undefined ||\n\t\t\t\treport === undefined ||\n\t\t\t\tfile.image.digest !== receipt.run.digest ||\n\t\t\t\treport.image.digest !== receipt.report.digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Collection record or report bytes changed: ${receipt.variant}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (\n\t\t\t\treceipt.inputs.digest !==\n\t\t\t\tbuildCaptureDigest(receipt.inputs.patterns, receipt.inputs.files).digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Invalid collection input digest', { code: 'EVIDENCE' })\n\t\t\tfor (const path of Object.keys(receipt.inputs.files)) this.#path(path)\n\t\t\tconst run = this.#json(receipt.run.file)\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\trun.variant !== receipt.variant ||\n\t\t\t\treceipt.run.file !==\n\t\t\t\t\t`${this.#options.directory}/runs/${run.request.id}/${run.request.stage}/${run.variant}.json` ||\n\t\t\t\treceipt.report.file !== this.#reportPath(run.request.args)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Collection has no matching authorized runner record', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureRun(run, readCaptureReport(this.#json(receipt.report.file)), receipt.project)\n\t\t\tthis.#uniqueRegistry(run.registry)\n\t\t\tfor (const destination of run.registry) this.#destination(destination)\n\t\t\treturn { receipt, file, run }\n\t\t})\n\t\tfor (const collection of collections) {\n\t\t\tconst anchor = evidence.registry.receipts.find(\n\t\t\t\t(receipt) => receipt.variant === collection.run.variant,\n\t\t\t)\n\t\t\tconst baseline =\n\t\t\t\tanchor ??\n\t\t\t\tcollections.find(\n\t\t\t\t\t(candidate) =>\n\t\t\t\t\t\tcandidate.run.variant === collection.run.variant &&\n\t\t\t\t\t\tevidence.registry.receipts.some(\n\t\t\t\t\t\t\t(receipt) =>\n\t\t\t\t\t\t\t\tcollectCaptureChanges(receipt.inputs, candidate.receipt.inputs.files).length === 0,\n\t\t\t\t\t\t),\n\t\t\t\t)?.run\n\t\t\tif (baseline === undefined)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Collection has no complete-anchor provenance: ${collection.run.variant}`,\n\t\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t\t)\n\t\t\tif (\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tbaseline.declarations.map(describeCaptureDeclaration),\n\t\t\t\t\tcollection.run.declarations.map(describeCaptureDeclaration),\n\t\t\t\t) ||\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tbaseline.registry.map(describeCaptureDestination),\n\t\t\t\t\tcollection.run.registry.map(describeCaptureDestination),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Collection declarations differ from the complete anchor', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t}\n\t\treturn collections\n\t}\n\n\t#population(\n\t\tevidence: CaptureEvidence,\n\t\tcollections: readonly CaptureCollectionEvidence[],\n\t): CaptureEvidence {\n\t\treturn { ...evidence, runs: collections.map(({ file, run }) => ({ file, run })) }\n\t}\n\n\t// A physical path resolves inside the integrity root, whatever its portfolio.\n\t#resolve(file: string): string {\n\t\tif (!isCapturePath(file))\n\t\t\tthrow new CaptureError(`Invalid serialized path: ${file}`, { code: 'CONTAINMENT' })\n\t\tconst path = resolve(this.#root, ...file.split('/'))\n\t\tthis.#contained(path)\n\t\tconst ancestor = readCaptureAncestor(path)\n\t\tthis.#contained(realpathSync(ancestor))\n\t\treturn path\n\t}\n\n\t// A path under a portfolio root also resolves inside that root's physical directory.\n\t#path(file: string, paths?: Map<string, string>): string {\n\t\tconst known = paths?.get(file)\n\t\tif (known !== undefined) return known\n\t\tconst path = this.#resolve(file)\n\t\tfor (const [directory, authorized] of this.#roots) {\n\t\t\tif (file !== directory && !file.startsWith(`${directory}/`)) continue\n\t\t\tconst suffix = relative(authorized, resolveCapturePhysical(path))\n\t\t\tif (isAbsolute(suffix) || suffix === '..' || suffix.startsWith(`..${sep}`))\n\t\t\t\tthrow new CaptureError(`Physical path resolves outside authorized capture root: ${file}`, {\n\t\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t\t})\n\t\t}\n\t\tpaths?.set(file, path)\n\t\treturn path\n\t}\n\n\t#contained(path: string): void {\n\t\tconst suffix = relative(this.#root, path)\n\t\tif (isAbsolute(suffix) || suffix === '..' || suffix.startsWith(`..${sep}`))\n\t\t\tthrow new CaptureError(`Physical path resolves outside integrity root: ${path}`, {\n\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t})\n\t}\n\n\t// Reads each path once per pass; the pass owns the memo and discards it when it ends.\n\t#file(\n\t\tfile: string,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tpaths?: Map<string, string>,\n\t): CaptureFileSnapshot | undefined {\n\t\tif (snapshots.has(file)) return snapshots.get(file)\n\t\tconst snapshot = this.#readFile(file, paths)\n\t\tsnapshots.set(file, snapshot)\n\t\treturn snapshot\n\t}\n\n\t#readFile(file: string, paths?: Map<string, string>): CaptureFileSnapshot | undefined {\n\t\tconst path = this.#path(file, paths)\n\t\tif (!existsSync(path)) return undefined\n\t\tconst stat = statSync(path)\n\t\tif (!stat.isFile())\n\t\t\tthrow new CaptureError(`Expected a physical file: ${file}`, { code: 'CONTAINMENT' })\n\t\treturn {\n\t\t\tfile,\n\t\t\timage: {\n\t\t\t\tdigest: this.#hash(\n\t\t\t\t\tfile.toLowerCase().endsWith('.png') ? readCaptureImage(path) : readFileSync(path),\n\t\t\t\t),\n\t\t\t\tsize: stat.size,\n\t\t\t\tmodified: stat.mtimeMs,\n\t\t\t},\n\t\t\tchanged: stat.ctimeMs,\n\t\t}\n\t}\n\n\t#json(file: string, paths?: Map<string, string>): unknown {\n\t\tconst document: unknown = parseJSON(readFileSync(this.#path(file, paths), 'utf8'))\n\t\tif (!isRecord(document))\n\t\t\tthrow new CaptureError(`Invalid JSON document: ${file}`, { code: 'EVIDENCE' })\n\t\treturn document\n\t}\n\n\t// Expands each pattern list once per pass; the digest sorts its patterns, so sorted lists share a key.\n\t#digest(\n\t\tpatterns: readonly string[],\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tdigests: Map<string, CaptureDigest>,\n\t): CaptureDigest {\n\t\tif (!patterns.every(isCapturePattern))\n\t\t\tthrow new CaptureError('Invalid source attribution pattern', { code: 'HOST' })\n\t\trequireCaptureUnique(patterns, 'source patterns', true)\n\t\tconst key = JSON.stringify(patterns.toSorted())\n\t\tconst known = digests.get(key)\n\t\tif (known !== undefined) return known\n\t\tconst digest = buildCaptureDigest(\n\t\t\tpatterns,\n\t\t\treadCaptureInputs(\n\t\t\t\tthis.#root,\n\t\t\t\tpatterns,\n\t\t\t\tthis.#hash,\n\t\t\t\t(file) => this.#file(file, snapshots)?.image.digest,\n\t\t\t),\n\t\t)\n\t\tdigests.set(key, digest)\n\t\treturn digest\n\t}\n\n\t#images(): readonly string[] {\n\t\tconst pending: CaptureDirectoryResult[] = this.#options.portfolios.map((entry) => ({\n\t\t\tdirectory: entry.directory,\n\t\t\tancestors: [],\n\t\t}))\n\t\tconst files: string[] = []\n\t\tfor (const result of pending) {\n\t\t\tconst directory = result.directory\n\t\t\tconst path = this.#path(directory)\n\t\t\tif (!existsSync(path)) continue\n\t\t\tconst physical = realpathSync(path)\n\t\t\tif (result.ancestors.includes(physical))\n\t\t\t\tthrow new CaptureError('Cyclic portfolio directory alias', { code: 'CONTAINMENT' })\n\t\t\tconst entries = readdirSync(path)\n\t\t\trequireCaptureUnique(entries, 'physical path spellings', true)\n\t\t\tfor (const name of entries) {\n\t\t\t\tconst file = `${directory}/${name}`\n\t\t\t\tconst target = this.#path(file)\n\t\t\t\tif (statSync(target).isDirectory())\n\t\t\t\t\tpending.push({ directory: file, ancestors: [...result.ancestors, physical] })\n\t\t\t\telse if (name.toLowerCase().endsWith('.png')) files.push(file)\n\t\t\t}\n\t\t}\n\t\treturn files.toSorted()\n\t}\n\n\t#snapshot(options: CaptureStageOptions): CaptureSnapshot {\n\t\tconst files = [\n\t\t\t...new Set([\n\t\t\t\t...this.#images(),\n\t\t\t\toptions.report,\n\t\t\t\t...options.projects.map((project) => project.record),\n\t\t\t\tthis.#options.manifest,\n\t\t\t\tthis.#options.registry,\n\t\t\t\tthis.#options.lookups,\n\t\t\t]),\n\t\t]\n\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst digests = new Map<string, CaptureDigest>()\n\t\treturn {\n\t\t\ttime: Date.now(),\n\t\t\tprojects: options.projects.map((project) => {\n\t\t\t\tif (project.inputs.length === 0)\n\t\t\t\t\tthrow new CaptureError('Missing bounded host input population', { code: 'HOST' })\n\t\t\t\treturn { project: project.name, inputs: this.#digest(project.inputs, snapshots, digests) }\n\t\t\t}),\n\t\t\tfiles: files.flatMap((file) => {\n\t\t\t\tconst snapshot = this.#file(file, snapshots)\n\t\t\t\treturn snapshot === undefined ? [] : [snapshot]\n\t\t\t}),\n\t\t}\n\t}\n\n\t#fresh(\n\t\tfile: string,\n\t\tbefore: CaptureSnapshot,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\timage = false,\n\t): CaptureFileSnapshot {\n\t\tconst current = this.#file(file, snapshots)\n\t\tconst previous = before.files.find((entry) => entry.file === file)\n\t\tif (\n\t\t\tcurrent === undefined ||\n\t\t\tcurrent.image.modified < before.time ||\n\t\t\tcurrent.changed < before.time ||\n\t\t\t(previous !== undefined && matchesCaptureFile(previous, current))\n\t\t)\n\t\t\tthrow new CaptureError(`Missing or stale execution output: ${file}`, { code: 'STAGE' })\n\t\tif (image && !matchesCaptureSignature(readCaptureImage(this.#path(file))))\n\t\t\tthrow new CaptureError(`Capture output is not a PNG: ${file}`, { code: 'EVIDENCE' })\n\t\treturn current\n\t}\n\n\t#stable(\n\t\tentry: CaptureDestination,\n\t\tbefore: CaptureDigest,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tdigests: Map<string, CaptureDigest>,\n\t\tstable: Map<string, true>,\n\t): void {\n\t\tconst key = JSON.stringify([\n\t\t\tbefore.digest,\n\t\t\tentry.sources.own.toSorted(),\n\t\t\tentry.sources.shared.toSorted(),\n\t\t\tentry.sources.tests.toSorted(),\n\t\t])\n\t\tif (stable.has(key)) return\n\t\tfor (const patterns of [entry.sources.own, entry.sources.shared, entry.sources.tests]) {\n\t\t\tconst current = this.#digest(patterns, snapshots, digests)\n\t\t\tif (Object.keys(current.files).some((file) => before.files[file] === undefined))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Attribution outside the predeclared host population: ${entry.file}`,\n\t\t\t\t\t{ code: 'STAGE' },\n\t\t\t\t)\n\t\t\tconst matched = this.#match(before, patterns)\n\t\t\tconst previous = Object.fromEntries(\n\t\t\t\tObject.entries(before.files).filter(([file]) => matched.has(file)),\n\t\t\t)\n\t\t\tif (collectCaptureChanges(previous, current.files).length > 0)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Attributed inputs or membership changed during execution: ${entry.file}`,\n\t\t\t\t\t{ code: 'STAGE' },\n\t\t\t\t)\n\t\t\t// Every current file is a member of the predeclared population, so its subsets answer here.\n\t\t\tif (\n\t\t\t\tpatterns.some((pattern) => {\n\t\t\t\t\tconst files = this.#match(before, [pattern])\n\t\t\t\t\treturn !Object.keys(current.files).some((file) => files.has(file))\n\t\t\t\t})\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Declared source pattern has no files: ${entry.file}`, {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t}\n\t\tstable.set(key, true)\n\t}\n\n\t#match(inputs: CaptureDigest, patterns: readonly string[]): ReadonlySet<string> {\n\t\tconst key = computeCaptureMatchKey(inputs, patterns)\n\t\tconst known = this.#matches.get(key)\n\t\tif (known !== undefined) return known\n\t\tconst matched = filterCaptureInputs(inputs, patterns)\n\t\tthis.#matches.set(key, matched)\n\t\treturn matched\n\t}\n\n\t#destination(entry: CaptureDestination, paths?: Map<string, string>): void {\n\t\tconst portfolio = this.#options.portfolios.find(\n\t\t\t(candidate) => candidate.portfolio === entry.portfolio,\n\t\t)\n\t\tif (portfolio === undefined)\n\t\t\tthrow new CaptureError(`Unknown portfolio: ${entry.portfolio}`, { code: 'SELECTION' })\n\t\tconst expected = `${portfolio.directory}/${portfolio.scoped ? `${entry.scope}/` : ''}${entry.state}--${entry.variant}.png`\n\t\tif (entry.file !== expected)\n\t\t\tthrow new CaptureError(`Noncanonical physical destination: ${entry.file}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tthis.#path(entry.file, paths)\n\t}\n\n\t#uniqueRegistry(entries: readonly CaptureDestination[]): void {\n\t\trequireCaptureUnique(entries.map(resolveCaptureKey), 'registry identities', true)\n\t\trequireCaptureUnique(\n\t\t\tentries.map((entry) => entry.file),\n\t\t\t'registry paths',\n\t\t\ttrue,\n\t\t)\n\t}\n\n\t#registry(\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tpaths: Map<string, string>,\n\t): CaptureRegistry {\n\t\tif (!existsSync(this.#path(this.#options.registry, paths)))\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Missing accepted registry; run the explicit complete-registry refresh',\n\t\t\t\t{\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t},\n\t\t\t)\n\t\tconst registry = this.#json(this.#options.registry, paths)\n\t\tif (\n\t\t\t!isCaptureRegistry(registry) ||\n\t\t\tregistry.digest !== computeRegistryDigest(registry) ||\n\t\t\tregistry.receipts.length === 0\n\t\t)\n\t\t\tthrow new CaptureError('Invalid accepted registry schema or digest', { code: 'EVIDENCE' })\n\t\trequireCaptureUnique(\n\t\t\tregistry.receipts.map((receipt) => receipt.variant),\n\t\t\t'complete receipt variants',\n\t\t\ttrue,\n\t\t)\n\t\tfor (const receipt of registry.receipts) {\n\t\t\tconst report = this.#file(receipt.report.file, snapshots, paths)\n\t\t\tif (!receipt.complete || report?.image.digest !== receipt.report.digest)\n\t\t\t\tthrow new CaptureError('Registry receipt is incomplete or its report changed', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureReceipt(receipt, readCaptureReport(this.#json(receipt.report.file, paths)))\n\t\t\tfor (const path of Object.keys(receipt.inputs)) this.#path(path, paths)\n\t\t\trequireCaptureUnique(Object.keys(receipt.inputs), 'receipt input paths', true)\n\t\t}\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tregistry.entries.map(describeCaptureDestination),\n\t\t\t\tregistry.receipts.flatMap((receipt) => receipt.registry.map(describeCaptureDestination)),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Registry entries differ from complete receipts', { code: 'EVIDENCE' })\n\t\tfor (const entry of registry.entries) this.#destination(entry, paths)\n\t\treturn registry\n\t}\n\n\t#evidence(snapshots: Map<string, CaptureFileSnapshot | undefined>): CaptureEvidence {\n\t\tconst paths = new Map<string, string>()\n\t\tconst registry = this.#registry(snapshots, paths)\n\t\tconst manifest = existsSync(this.#path(this.#options.manifest, paths))\n\t\t\t? this.#json(this.#options.manifest, paths)\n\t\t\t: undefined\n\t\tif (manifest !== undefined && !isCaptureStoredManifest(manifest))\n\t\t\tthrow new CaptureError('Invalid inherited manifest schema', { code: 'EVIDENCE' })\n\t\tif (manifest !== undefined) {\n\t\t\trequireCaptureUnique(Object.keys(manifest.entries), 'manifest keys', true)\n\t\t\tif (manifest.registry.digest !== computeRegistryDigest(manifest.registry))\n\t\t\t\tthrow new CaptureError('Invalid inherited registry digest', { code: 'EVIDENCE' })\n\t\t\tfor (const [key, stamp] of Object.entries(manifest.entries)) {\n\t\t\t\tif (key !== resolveCaptureKey(stamp))\n\t\t\t\t\tthrow new CaptureError('Manifest key differs from stamp identity', { code: 'EVIDENCE' })\n\t\t\t\tif (\n\t\t\t\t\tstamp.shared.digest !==\n\t\t\t\t\t\tbuildCaptureDigest(stamp.shared.patterns, stamp.shared.files).digest ||\n\t\t\t\t\t!matchesCaptureMembers(stamp.shared.patterns, stamp.sources.shared)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError('Invalid inherited shared digest', { code: 'EVIDENCE' })\n\t\t\t\tthis.#path(stamp.file, paths)\n\t\t\t\tfor (const path of [\n\t\t\t\t\t...Object.keys(stamp.own),\n\t\t\t\t\t...Object.keys(stamp.shared.files),\n\t\t\t\t\t...Object.keys(stamp.tests),\n\t\t\t\t])\n\t\t\t\t\tthis.#path(path, paths)\n\t\t\t}\n\t\t}\n\t\tconst separate: unknown = existsSync(this.#path(this.#options.lookups, paths))\n\t\t\t? this.#json(this.#options.lookups, paths)\n\t\t\t: undefined\n\t\tif (separate !== undefined && !isCaptureLookupJournal(separate))\n\t\t\tthrow new CaptureError('Invalid separate lookup schema', { code: 'EVIDENCE' })\n\t\tconst manifestDigest = this.#file(this.#options.manifest, snapshots, paths)?.image.digest\n\t\tconst current =\n\t\t\tseparate !== undefined && separate.manifest === manifestDigest\n\t\t\t\t? readCaptureLookups(separate)\n\t\t\t\t: []\n\t\tconst lookups = mergeCaptureLookups(manifest?.lookups ?? [], current).filter(\n\t\t\t(entry) => entry.registry === registry.digest,\n\t\t)\n\t\tconst populations = new Map<Readonly<Record<string, string>>, true>()\n\t\tconst references = Map.groupBy(lookups, (entry) => entry.run.file)\n\t\tconst runs = [...references].map(([file, referenced]) => {\n\t\t\tconst snapshot = this.#file(file, snapshots, paths)\n\t\t\tif (\n\t\t\t\tsnapshot === undefined ||\n\t\t\t\treferenced.some((entry) => entry.run.digest !== snapshot.image.digest)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Lookup run record is missing or changed: ${file}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst run = this.#json(file, paths)\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\tfile !==\n\t\t\t\t\t`${this.#options.directory}/runs/${run.request.id}/${run.request.stage}/${run.variant}.json`\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Lookup has no authorized runner record', { code: 'EVIDENCE' })\n\t\t\tconst projects = [...new Set(run.registry.map((entry) => entry.project))]\n\t\t\tif (projects.length > 1)\n\t\t\t\tthrow new CaptureError('Lookup record mixes producing projects', { code: 'EVIDENCE' })\n\t\t\tvalidateCaptureRun(\n\t\t\t\trun,\n\t\t\t\treadCaptureReport(this.#json(this.#reportPath(run.request.args, paths), paths)),\n\t\t\t\tprojects[0] ?? '',\n\t\t\t)\n\t\t\tconst anchor = registry.receipts.find((entry) => entry.variant === run.variant)\n\t\t\tif (\n\t\t\t\tanchor !== undefined &&\n\t\t\t\t(!matchesCaptureMembers(\n\t\t\t\t\tanchor.declarations.map(describeCaptureDeclaration),\n\t\t\t\t\trun.declarations.map(describeCaptureDeclaration),\n\t\t\t\t) ||\n\t\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\t\tanchor.registry.map(describeCaptureDestination),\n\t\t\t\t\t\trun.registry.map(describeCaptureDestination),\n\t\t\t\t\t))\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Lookup declarations disagree with the accepted registry', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst declarations = new Map(run.declarations.map((entry) => [entry.case, entry]))\n\t\t\tconst passed = new Set(run.passed)\n\t\t\tfor (const entry of referenced) {\n\t\t\t\tconst declaration = declarations.get(entry.case)\n\t\t\t\tif (\n\t\t\t\t\tdeclaration === undefined ||\n\t\t\t\t\tdeclaration.owner !== entry.owner ||\n\t\t\t\t\trun.variant !== entry.variant ||\n\t\t\t\t\t!passed.has(entry.case) ||\n\t\t\t\t\t!matchesCaptureMembers(declaration.states, entry.states)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError('Lookup differs from its passing declaration', {\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t})\n\t\t\t\tif (!populations.has(entry.inputs)) {\n\t\t\t\t\tfor (const path of Object.keys(entry.inputs)) this.#path(path, paths)\n\t\t\t\t\tpopulations.set(entry.inputs, true)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const destination of run.registry) this.#destination(destination, paths)\n\t\t\treturn { file: snapshot, run }\n\t\t})\n\t\tconst collections = this.#mergeCollections(\n\t\t\t(manifest?.collections ?? []).filter((entry) => entry.registry === registry.digest),\n\t\t\t(separate?.manifest === manifestDigest ? (separate?.collections ?? []) : []).filter(\n\t\t\t\t(entry) => entry.registry === registry.digest,\n\t\t\t),\n\t\t)\n\t\treturn { registry, ...(manifest === undefined ? {} : { manifest }), lookups, runs, collections }\n\t}\n\n\t#attest(\n\t\trun: CaptureRun,\n\t\tevidence: CaptureEvidence,\n\t\tinputs: Readonly<Record<string, string>>,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t): void {\n\t\tconst receipt = evidence.registry.receipts.find((entry) => entry.variant === run.variant)\n\t\tconst previous =\n\t\t\tevidence.runs.find((entry) => entry.run.variant === run.variant)?.run ??\n\t\t\tthis.#collections(evidence, snapshots).find((entry) => entry.run.variant === run.variant)?.run\n\t\tconst declarations = receipt?.declarations ?? previous?.declarations\n\t\tconst registry = receipt?.registry ?? previous?.registry\n\t\tif (declarations !== undefined && registry !== undefined) {\n\t\t\tif (\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tdeclarations.map(describeCaptureDeclaration),\n\t\t\t\t\trun.declarations.map(describeCaptureDeclaration),\n\t\t\t\t) ||\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tregistry.map(describeCaptureDestination),\n\t\t\t\t\trun.registry.map(describeCaptureDestination),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t'Collected registry declarations changed; run the explicit complete-registry refresh',\n\t\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t\t)\n\t\t} else if (\n\t\t\t!evidence.registry.receipts.some(\n\t\t\t\t(entry) => collectCaptureChanges(entry.inputs, inputs).length === 0,\n\t\t\t)\n\t\t) {\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Unattested producing variant; run the explicit complete-registry refresh before its owner lookup refresh',\n\t\t\t\t{ code: 'EVIDENCE', context: { variant: run.variant } },\n\t\t\t)\n\t\t}\n\t}\n\n\t#destinations(evidence: CaptureEvidence): readonly CaptureDestination[] {\n\t\tconst anchored = new Set(evidence.registry.receipts.map((entry) => entry.variant))\n\t\tconst variants = [...new Set(evidence.runs.map((entry) => entry.run.variant))].filter(\n\t\t\t(variant) => !anchored.has(variant),\n\t\t)\n\t\treturn [\n\t\t\t...evidence.registry.entries,\n\t\t\t...variants.flatMap((variant) => {\n\t\t\t\tconst runs = evidence.runs.filter((entry) => entry.run.variant === variant)\n\t\t\t\tconst [first] = runs\n\t\t\t\tif (first === undefined) return []\n\t\t\t\tfor (const entry of runs) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\t\t\tfirst.run.registry.map(describeCaptureDestination),\n\t\t\t\t\t\t\tentry.run.registry.map(describeCaptureDestination),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new CaptureError('Scoped registry attestations disagree', { code: 'EVIDENCE' })\n\t\t\t\t}\n\t\t\t\treturn first.run.registry\n\t\t\t}),\n\t\t]\n\t}\n\n\t#select(\n\t\tevidence: CaptureEvidence,\n\t\tentries: readonly CaptureDestination[],\n\t\toptions: CaptureCheckOptions | CaptureLookupOptions,\n\t\tattributed: boolean,\n\t): readonly CaptureDestination[] {\n\t\tconst selectors = [\n\t\t\t...new Set(\n\t\t\t\tentries.flatMap((entry) => {\n\t\t\t\t\tconst parts = resolveCaptureOwner(entry).split(':')\n\t\t\t\t\treturn parts.map((_part, index) => parts.slice(0, index + 1).join(':'))\n\t\t\t\t}),\n\t\t\t),\n\t\t]\n\t\tconst fault = describeCaptureSelectorFault(options.selector, selectors)\n\t\tif (fault !== undefined) throw new CaptureError(fault, { code: 'USAGE' })\n\t\tif (\n\t\t\toptions.portfolio !== undefined &&\n\t\t\t!this.#options.portfolios.some((entry) => entry.portfolio === options.portfolio)\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown portfolio; ${describeCaptureFault(\n\t\t\t\t\t'selection.portfolio',\n\t\t\t\t\toptions.portfolio,\n\t\t\t\t\t'an authorized portfolio',\n\t\t\t\t\tthis.#options.portfolios.map((entry) => entry.portfolio),\n\t\t\t\t)}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tif (\n\t\t\t!isCaptureSelector(options.selector) ||\n\t\t\t!options.variants.every(isCaptureSegment) ||\n\t\t\t(options.state !== undefined && !isCaptureSegment(options.state)) ||\n\t\t\t(options.case !== undefined && options.case.trim() === '')\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Invalid capture selection; ${describeCaptureFault('selection', options, 'portable variants and state, a nonempty case, and an authorized portfolio; valid values come from the selected registry destinations', ['selector', 'variants', 'state', 'case', 'portfolio'], ['selector', 'variants'], ['selector', 'variants', 'state', 'case', 'portfolio'])}; ${describeCaptureFault(\n\t\t\t\t\t'selection.portfolio',\n\t\t\t\t\toptions.portfolio,\n\t\t\t\t\t'an authorized portfolio when supplied',\n\t\t\t\t\tthis.#options.portfolios.map((entry) => entry.portfolio),\n\t\t\t\t)}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\trequireCaptureUnique(options.variants, 'selected variants', true)\n\t\tconst scoped = entries.filter(\n\t\t\t(entry) =>\n\t\t\t\tmatchesCaptureSelector(resolveCaptureOwner(entry), options.selector) &&\n\t\t\t\t(options.portfolio === undefined || entry.portfolio === options.portfolio),\n\t\t)\n\t\tif (scoped.length === 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Empty selector; ${describeCaptureFault('selector', options.selector, 'a declared selector with destinations in the selected portfolio', ['all', ...selectors])}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'USAGE',\n\t\t\t\t},\n\t\t\t)\n\t\t// An omitted variant list derives from the scoped destinations, so an unknown selector reads as\n\t\t// that before an empty list reads as an invalid one.\n\t\tif (options.variants.length === 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Invalid capture selection; ${describeCaptureFault('selection.variants', options.variants, 'a nonempty selected variant list', [...new Set(scoped.map((entry) => entry.variant))])}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tconst variants = [\n\t\t\t...new Set(\n\t\t\t\tattributed\n\t\t\t\t\t? entries.map((entry) => this.#producer(entry, evidence))\n\t\t\t\t\t: entries.map((entry) => entry.variant),\n\t\t\t),\n\t\t]\n\t\tconst unknown = options.variants.find((variant) => !variants.includes(variant))\n\t\tif (unknown !== undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown or unattested selected variant; ${describeCaptureFault('selection.variants', unknown, 'an attested registry variant', variants)}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tconst selected = scoped.filter(\n\t\t\t(entry) =>\n\t\t\t\toptions.variants.includes(attributed ? this.#producer(entry, evidence) : entry.variant) &&\n\t\t\t\t(options.state === undefined || entry.state === options.state) &&\n\t\t\t\t(options.case === undefined || entry.case === options.case),\n\t\t)\n\t\tif (selected.length === 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Empty selection or state outside selector/case; ${describeCaptureFault('selection.state', options.state, 'a state in the selected selector/case', [...new Set(scoped.map((entry) => entry.state))])}; ${describeCaptureFault('selection.case', options.case, 'a case in the selected selector', [...new Set(scoped.map((entry) => entry.case))])}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'USAGE',\n\t\t\t\t},\n\t\t\t)\n\t\treturn selected\n\t}\n\n\t#producer(destination: CaptureDestination, evidence: CaptureEvidence): string {\n\t\tconst sources = [...evidence.registry.receipts, ...evidence.runs.map((entry) => entry.run)]\n\t\tconst variants = [\n\t\t\t...new Set(\n\t\t\t\tsources\n\t\t\t\t\t.filter((source) =>\n\t\t\t\t\t\tsource.registry.some(\n\t\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\t\tdescribeCaptureDestination(entry) === describeCaptureDestination(destination),\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\t.map((source) => source.variant),\n\t\t\t),\n\t\t]\n\t\tif (variants.length !== 1 || variants[0] === undefined)\n\t\t\tthrow new CaptureError('Destination has no unique producing variant', { code: 'EVIDENCE' })\n\t\treturn variants[0]\n\t}\n\n\t#reportPath(args: readonly string[], paths?: Map<string, string>): string {\n\t\tconst outputs = args.filter((argument) => argument.startsWith('--outputFile.json='))\n\t\tif (outputs.length !== 1 || outputs[0] === undefined)\n\t\t\tthrow new CaptureError('Request has no unique JSON reporter path', { code: 'HOST' })\n\t\tconst file: string = normalizeSlashes(\n\t\t\trelative(this.#root, resolve(this.#root, outputs[0].slice('--outputFile.json='.length))),\n\t\t)\n\t\tthis.#path(file, paths)\n\t\treturn file\n\t}\n\n\t#physicalIdentity(file: string, identities: Map<string, string>): string {\n\t\tconst known = identities.get(file)\n\t\tif (known !== undefined) return known\n\t\tconst path = this.#path(file)\n\t\tif (!existsSync(path)) {\n\t\t\tidentities.set(file, path)\n\t\t\treturn path\n\t\t}\n\t\t// Native file identifiers can exceed the exact integer range of a Number.\n\t\tconst stat = statSync(path, { bigint: true })\n\t\tconst identity = stat.ino === 0n ? realpathSync(path) : `${stat.dev}:${stat.ino}`\n\t\tidentities.set(file, identity)\n\t\treturn identity\n\t}\n\n\t#attributable(\n\t\tfile: string,\n\t\tselected: readonly CaptureDestination[],\n\t\tregistry: readonly CaptureDestination[],\n\t\toptions: CaptureCheckOptions,\n\t): boolean {\n\t\tif (\n\t\t\toptions.portfolio !== undefined &&\n\t\t\t!this.#options.portfolios.some(\n\t\t\t\t(entry) => entry.portfolio === options.portfolio && file.startsWith(`${entry.directory}/`),\n\t\t\t)\n\t\t)\n\t\t\treturn false\n\t\tif (registry.some((entry) => entry.file === file)) return false\n\t\tconst name = file.slice(file.lastIndexOf('/') + 1)\n\t\tif (selected.some((entry) => name === `${entry.state}--${entry.variant}.png`)) return true\n\t\tif (options.state !== undefined || options.case !== undefined) return false\n\t\tif (!options.variants.some((variant) => name.endsWith(`--${variant}.png`))) return false\n\t\tif (options.selector === 'all') return true\n\t\treturn selected.some((entry) => {\n\t\t\tconst portfolio = this.#options.portfolios.find(\n\t\t\t\t(candidate) => candidate.portfolio === entry.portfolio,\n\t\t\t)\n\t\t\treturn (\n\t\t\t\tportfolio !== undefined &&\n\t\t\t\toptions.selector === entry.scope &&\n\t\t\t\tfile.startsWith(`${portfolio.directory}/${portfolio.scoped ? `${entry.scope}/` : ''}`)\n\t\t\t)\n\t\t})\n\t}\n\n\t// Runs one Git read in the workspace; a synchronous read of provenance starts no supervised child.\n\t#git(args: readonly string[]): string {\n\t\tconst result = executeSync(\n\t\t\t{ file: 'git', arguments: args },\n\t\t\t{ workspace: this.#root, timeout: 30_000, limit: 64 * 1024 * 1024, strict: false },\n\t\t)\n\t\tif (result.failed || result.truncated)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Git read failed${result.expired ? ' (deadline expired)' : ''}${result.truncated ? ' (output truncated)' : ''}: ${describeCaptureOutput(result.stderr.trim() || String(result.code ?? result.signal))}`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\treturn result.stdout\n\t}\n\n\t#provenance(): { readonly commit: string; readonly dirty: readonly string[] } {\n\t\tconst root = this.#git(['rev-parse', '--show-toplevel']).trim()\n\t\tif (realpathSync(root) !== this.#root)\n\t\t\tthrow new CaptureError('Integrity root differs from the Git workspace root', {\n\t\t\t\tcode: 'HOST',\n\t\t\t})\n\t\tconst commit = this.#git(['rev-parse', 'HEAD']).trim()\n\t\tconst dirty = readCaptureDirty(\n\t\t\tthis.#git(['status', '--porcelain=v1', '-z', '--untracked-files=all']),\n\t\t)\n\t\tif (!/^[a-f0-9]{40,64}$/u.test(commit) || !dirty.every(isCapturePath))\n\t\t\tthrow new CaptureError('Invalid Git provenance', { code: 'EVIDENCE' })\n\t\treturn { commit, dirty }\n\t}\n\n\t#commit(file: string, value: unknown, signal?: AbortSignal): void {\n\t\tconst target = this.#path(file)\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\tthis.#path(file)\n\t\tconst temporary = `${file}.${randomUUID()}.tmp`\n\t\tconst path = this.#path(temporary)\n\t\ttry {\n\t\t\twriteFileSync(path, `${JSON.stringify(value)}\\n`, { flag: 'wx', flush: true })\n\t\t\tsignal?.throwIfAborted()\n\t\t\tthis.#path(file)\n\t\t\tthis.#path(temporary)\n\t\t\trenameSync(path, target)\n\t\t} finally {\n\t\t\tif (existsSync(path)) rmSync(path)\n\t\t}\n\t}\n}\n","import type { DuplexInterface } from '@orkestrel/process'\nimport type { CaptureRequest } from '@src/core'\nimport type {\n\tCaptureDiscoveryRequest,\n\tCaptureExecutionResult,\n\tCaptureHolder,\n\tCaptureInvocationInterface,\n\tCaptureInvocationOptions,\n\tCaptureOwnership,\n} from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport {\n\tappendFileSync,\n\tlinkSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { resolve } from 'node:path'\nimport { StringDecoder } from 'node:string_decoder'\nimport { attempt, isRecord, parseJSON, preview } from '@orkestrel/contract'\nimport { createDuplex, inspectProcess } from '@orkestrel/process/server'\nimport { createTimeout } from '@orkestrel/timeout'\nimport {\n\tCAPTURE_REQUEST_PREFIX,\n\tCaptureError,\n\tdescribeCaptureError,\n\tisCaptureError,\n} from '@src/core'\nimport {\n\tCAPTURE_FLAG,\n\tCAPTURE_FLAG_VALUE,\n\tCAPTURE_REFUSAL_LIMIT,\n\tCAPTURE_REQUESTS_FLAG,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_SURVIVORS_FILE,\n\tCAPTURE_OWNER_FILE,\n\tCAPTURE_OWNER_TIMEOUT,\n\tCAPTURE_OWNER_BACKOFF,\n} from './constants.js'\nimport {\n\treadCaptureRequestOwner,\n\tsettleCaptureShutdown,\n\tmatchesCaptureTransient,\n} from './helpers.js'\n\n/**\n * Owns one runner invocation's identity, request file, children, and interruption.\n *\n * @remarks\n * The runner creates one for discovery and each changed owner, so the abort controller, session\n * registry, and spawn log belong to an invocation. Interruption derives from the controller's\n * signal. Sessions end the Windows process tree, or signal the POSIX group with SIGTERM and then\n * SIGKILL after a 250 ms grace. A linked timeout ends discovery without interrupting the invocation.\n * Raw stdout is decoded across chunk boundaries and flushed at termination. A writer failure or\n * an observation cutoff refuses the stage rather than accepting incomplete evidence.\n *\n * @example\n * ```ts\n * const invocation = new CaptureInvocation({\n * \tcommand: 'journey',\n * \troot: process.cwd(),\n * \trequests: 'tmp/units',\n * \tstdout: (text) => process.stdout.write(text),\n * \tstderr: (text) => process.stderr.write(text),\n * })\n * invocation.attach()\n * ```\n */\nexport class CaptureInvocation implements CaptureInvocationInterface {\n\treadonly #options: CaptureInvocationOptions\n\treadonly #id = randomUUID()\n\treadonly #controller = new AbortController()\n\treadonly #children = new Set<DuplexInterface>()\n\treadonly #unconfirmed = new Set<number>()\n\treadonly #launches: string[] = []\n\treadonly #interrupt = this.#abort.bind(this)\n\treadonly #request: string\n\treadonly #directory: string\n\treadonly #lock: string\n\t#lease: string | undefined\n\t#termination: Promise<readonly unknown[]> | undefined\n\n\t/**\n\t * Creates the invocation entity for one runner call.\n\t *\n\t * @param options - The command, the workspace, the request directory, and the output writers\n\t */\n\tconstructor(options: CaptureInvocationOptions) {\n\t\tthis.#options = options\n\t\tthis.#request = resolve(\n\t\t\toptions.root,\n\t\t\toptions.requests,\n\t\t\t`${CAPTURE_REQUEST_PREFIX}-${String(process.pid)}.json`,\n\t\t)\n\t\tthis.#directory = resolve(options.root, options.requests, CAPTURE_RUNS_DIRECTORY, this.#id)\n\t\tthis.#lock = resolve(options.root, options.requests, CAPTURE_OWNER_FILE)\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget request(): string {\n\t\treturn this.#request\n\t}\n\n\tget directory(): string {\n\t\treturn this.#directory\n\t}\n\n\tget signal(): AbortSignal {\n\t\treturn this.#controller.signal\n\t}\n\n\tget interrupted(): boolean {\n\t\treturn this.#controller.signal.aborted\n\t}\n\n\tattach(): void {\n\t\tprocess.on('SIGINT', this.#interrupt)\n\t\tprocess.on('SIGTERM', this.#interrupt)\n\t}\n\n\tasync release(): Promise<void> {\n\t\tconst failures: unknown[] = []\n\t\tconst kept: string[] = []\n\t\ttry {\n\t\t\tif (this.#termination !== undefined) await this.#termination\n\t\t\tfailures.push(\n\t\t\t\t...(await settleCaptureShutdown(\n\t\t\t\t\t() => this.retract(),\n\t\t\t\t\t[...this.#children].map((child) => () => this.#stop(child)),\n\t\t\t\t)),\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tfailures.push(error)\n\t\t} finally {\n\t\t\tprocess.off('SIGINT', this.#interrupt)\n\t\t\tprocess.off('SIGTERM', this.#interrupt)\n\t\t\tif (this.#lease !== undefined) {\n\t\t\t\tconst removal = attempt(() => {\n\t\t\t\t\tconst deadline = performance.now() + CAPTURE_OWNER_TIMEOUT\n\t\t\t\t\tconst marker = attempt(() => this.#read(deadline))\n\t\t\t\t\tif (!marker.success) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tmarker.error instanceof Error &&\n\t\t\t\t\t\t\t'code' in marker.error &&\n\t\t\t\t\t\t\tmarker.error.code === 'ENOENT'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tthrow marker.error\n\t\t\t\t\t}\n\t\t\t\t\tif (this.#owner(marker.value).id !== this.id) return\n\t\t\t\t\tif (this.#unconfirmed.size > 0) {\n\t\t\t\t\t\tkept.push(`ownership marker retained: ${this.#lock}`)\n\t\t\t\t\t\tconst record = attempt(() => this.#record())\n\t\t\t\t\t\tif (record.success) kept.push(`child record: ${record.value}`)\n\t\t\t\t\t\telse failures.push(record.error)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthis.#remove(deadline)\n\t\t\t\t})\n\t\t\t\tif (removal.success && this.#unconfirmed.size === 0) this.#lease = undefined\n\t\t\t\telse if (!removal.success) failures.push(removal.error)\n\t\t\t}\n\t\t}\n\t\tif (failures.length > 0 || this.#unconfirmed.size > 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture shutdown failed${this.#unconfirmed.size === 0 ? '' : `; child termination was not confirmed for process ${[...this.#unconfirmed].join(', ')}`}${kept.map((entry) => `; ${entry}`).join('')}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\tcause: new AggregateError(failures),\n\t\t\t\t},\n\t\t\t)\n\t}\n\n\tprepare(): void {\n\t\tconst requests = resolve(this.#options.root, this.#options.requests)\n\t\tattempt(() => mkdirSync(requests, { recursive: true }))\n\t\tthis.#claim()\n\t\tfor (const name of readdirSync(requests)) {\n\t\t\tconst pid = readCaptureRequestOwner(name)\n\t\t\tif (pid === undefined || pid === process.pid) continue\n\t\t\t// A directory under a request file's name survives the nonrecursive removal, as a claim temporary does.\n\t\t\tif (this.#alive(pid) === false)\n\t\t\t\tattempt(() => rmSync(resolve(requests, name), { force: true }))\n\t\t}\n\t}\n\n\tholders(): readonly CaptureHolder[] {\n\t\tconst requests = resolve(this.#options.root, this.#options.requests)\n\t\tconst pids = new Set(\n\t\t\treaddirSync(requests).flatMap((name) => {\n\t\t\t\tconst pid = readCaptureRequestOwner(name)\n\t\t\t\treturn pid === undefined || (pid === process.pid && this.#lease !== undefined) ? [] : [pid]\n\t\t\t}),\n\t\t)\n\t\treturn [...pids].flatMap((pid) => {\n\t\t\tconst alive = this.#alive(pid)\n\t\t\treturn alive === false ? [] : [{ pid, inspected: alive === true }]\n\t\t})\n\t}\n\n\tpublish(request: CaptureRequest | CaptureDiscoveryRequest): void {\n\t\tthis.#claim()\n\t\twriteFileSync(`${this.#request}.tmp`, `${JSON.stringify(request)}\\n`)\n\t\trenameSync(`${this.#request}.tmp`, this.#request)\n\t}\n\n\tretract(): void {\n\t\tif (this.#lease === undefined) return\n\t\tconst results = [\n\t\t\tattempt(() => rmSync(this.#request, { force: true })),\n\t\t\tattempt(() => rmSync(`${this.#request}.tmp`, { force: true })),\n\t\t]\n\t\tconst failures = results.flatMap((result) => (result.success ? [] : [result.error]))\n\t\tif (failures.length > 0)\n\t\t\tthrow new CaptureError('Capture request removal failed', {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcause: new AggregateError(failures),\n\t\t\t})\n\t}\n\n\tlaunched(log: string): boolean {\n\t\treturn this.#launches.includes(log)\n\t}\n\n\tasync spawn(\n\t\targs: readonly string[],\n\t\tlog: string,\n\t\tcapture: boolean,\n\t\tdeadline?: number,\n\t): Promise<CaptureExecutionResult> {\n\t\tthis.signal.throwIfAborted()\n\t\tconst timeout =\n\t\t\tdeadline === undefined ? undefined : createTimeout({ ms: deadline, signal: this.signal })\n\t\t// Keep the armed signal: a later parent abort clears the handle's expiry reading.\n\t\tconst expiry = timeout?.signal\n\t\tconst failure = new AbortController()\n\t\tconst decoder = new StringDecoder('utf8')\n\t\tconst signal = AbortSignal.any([\n\t\t\tthis.signal,\n\t\t\tfailure.signal,\n\t\t\t...(expiry === undefined ? [] : [expiry]),\n\t\t])\n\t\ttry {\n\t\t\tmkdirSync(this.#directory, { recursive: true })\n\t\t\twriteFileSync(log, '')\n\t\t\tconst session = createDuplex({\n\t\t\t\tcommand: {\n\t\t\t\t\tfile: process.execPath,\n\t\t\t\t\targuments: args,\n\t\t\t\t\t// The merge drops every inherited name an override claims by case, the unset flag included.\n\t\t\t\t\tenvironment: {\n\t\t\t\t\t\t[CAPTURE_REQUESTS_FLAG]: resolve(this.#options.root, this.#options.requests),\n\t\t\t\t\t\t[CAPTURE_FLAG]: capture ? CAPTURE_FLAG_VALUE : undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tworkspace: this.#options.root,\n\t\t\t\tgrace: 250,\n\t\t\t\tsignal,\n\t\t\t\ton: {\n\t\t\t\t\tstdout: (bytes) => {\n\t\t\t\t\t\tconst text = decoder.write(Buffer.from(bytes))\n\t\t\t\t\t\tthis.#options.stdout(text)\n\t\t\t\t\t\tappendFileSync(log, text)\n\t\t\t\t\t},\n\t\t\t\t\tstderr: (text) => {\n\t\t\t\t\t\tthis.#options.stderr(text)\n\t\t\t\t\t\tappendFileSync(log, text)\n\t\t\t\t\t},\n\t\t\t\t\terror: (error) =>\n\t\t\t\t\t\tfailure.abort(\n\t\t\t\t\t\t\tnew CaptureError(`Capture child failed: ${describeCaptureError(error)}`, {\n\t\t\t\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t// Session listeners isolate throws; a lost tee must still refuse all evidence.\n\t\t\t\terror: (error) =>\n\t\t\t\t\tfailure.abort(\n\t\t\t\t\t\tnew CaptureError('Capture child output could not be recorded', {\n\t\t\t\t\t\t\tcode: 'STAGE',\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})\n\t\t\tthis.#children.add(session)\n\t\t\tthis.#launches.push(log)\n\t\t\ttry {\n\t\t\t\ttimeout?.start()\n\t\t\t\tthis.#options.stdout(`pid=${String(session.pid)}\\n`)\n\t\t\t\tawait session.end()\n\t\t\t\tconst outcome = await session.exit\n\t\t\t\tconst tail = decoder.end()\n\t\t\t\t// The tail is written outside the session's listener isolation, so its failure joins the same refusal.\n\t\t\t\ttry {\n\t\t\t\t\tif (tail !== '') {\n\t\t\t\t\t\tthis.#options.stdout(tail)\n\t\t\t\t\t\tappendFileSync(log, tail)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailure.abort(\n\t\t\t\t\t\tnew CaptureError('Capture child output could not be recorded', {\n\t\t\t\t\t\t\tcode: 'STAGE',\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\tfailure.signal.throwIfAborted()\n\t\t\t\tif (!outcome.drained)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t'Capture child observation was cut off before its output drained',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tcode: outcome.code,\n\t\t\t\t\tsignal: outcome.signal,\n\t\t\t\t\t...(session.pid === undefined ? {} : { pid: session.pid }),\n\t\t\t\t\t...(expiry?.aborted === true ? { expired: true } : {}),\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait this.#stop(session)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (isCaptureError(error)) throw error\n\t\t\tthrow new CaptureError('Capture child execution failed', { code: 'STAGE', cause: error })\n\t\t} finally {\n\t\t\ttimeout?.clear()\n\t\t}\n\t}\n\n\t#abort(): void {\n\t\tif (this.signal.aborted) return\n\t\tthis.#controller.abort(new CaptureError('Runner interrupted', { code: 'STAGE' }))\n\t\tthis.#termination = settleCaptureShutdown(\n\t\t\t() => this.retract(),\n\t\t\t[...this.#children].map((child) => () => this.#stop(child)),\n\t\t)\n\t}\n\n\tasync #stop(child: DuplexInterface): Promise<boolean> {\n\t\tif (child.pid !== undefined) this.#unconfirmed.add(child.pid)\n\t\tconst confirmed = await (this.#options.terminate === undefined\n\t\t\t? child.stop()\n\t\t\t: this.#options.terminate(child))\n\t\tif (confirmed && child.pid !== undefined) this.#unconfirmed.delete(child.pid)\n\t\tif (confirmed) {\n\t\t\tawait child.destroy()\n\t\t\tthis.#children.delete(child)\n\t\t}\n\t\treturn confirmed\n\t}\n\n\t#read(deadline: number): string {\n\t\tconst result = attempt(() =>\n\t\t\tthis.#options.ownership?.read === undefined\n\t\t\t\t? readFileSync(this.#lock, 'utf8')\n\t\t\t\t: this.#options.ownership.read(this.#lock),\n\t\t)\n\t\tif (result.success) return result.value\n\t\tif (!matchesCaptureTransient(result.error, this.#options.ownership?.platform))\n\t\t\tthrow result.error\n\t\tthis.#backoff(deadline, result.error)\n\t\treturn this.#read(deadline)\n\t}\n\n\t#remove(deadline: number): void {\n\t\tconst result = attempt(() => {\n\t\t\t// Re-read on every retry, including after a failed unlink.\n\t\t\tif (this.#owner(this.#read(deadline)).id !== this.id) return\n\t\t\tif (this.#options.ownership?.remove === undefined) rmSync(this.#lock, { force: true })\n\t\t\telse this.#options.ownership.remove(this.#lock)\n\t\t})\n\t\tif (result.success) return\n\t\tif (result.error instanceof Error && 'code' in result.error && result.error.code === 'ENOENT')\n\t\t\treturn\n\t\tif (!matchesCaptureTransient(result.error, this.#options.ownership?.platform))\n\t\t\tthrow result.error\n\t\tthis.#backoff(deadline, result.error)\n\t\tthis.#remove(deadline)\n\t}\n\n\t#record(retry = true): string {\n\t\tconst file = resolve(this.#directory, CAPTURE_SURVIVORS_FILE)\n\t\tconst text = JSON.stringify({\n\t\t\tpid: process.pid,\n\t\t\tid: this.id,\n\t\t\tcommand: this.#options.command,\n\t\t\tchildren: [...this.#unconfirmed],\n\t\t\tat: new Date().toISOString(),\n\t\t})\n\t\ttry {\n\t\t\tif (this.#options.ownership?.write === undefined) writeFileSync(file, text, { flag: 'wx' })\n\t\t\telse this.#options.ownership.write(file, text)\n\t\t\treturn file\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\terror instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)\n\t\t\tif (code === 'EEXIST') return file\n\t\t\tif (code === 'ENOENT' && retry) {\n\t\t\t\tmkdirSync(this.#directory, { recursive: true })\n\t\t\t\treturn this.#record(false)\n\t\t\t}\n\t\t\tthrow new CaptureError(`Cannot write capture child record (${code}): ${file}`, {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcause: error,\n\t\t\t})\n\t\t}\n\t}\n\n\t#write(file: string, text: string): void {\n\t\ttry {\n\t\t\tif (this.#options.ownership?.write === undefined) writeFileSync(file, text, { flag: 'wx' })\n\t\t\telse this.#options.ownership.write(file, text)\n\t\t} catch (error) {\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot write capture ownership temporary (${error instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)}): ${file}`,\n\t\t\t\t{ code: 'STAGE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\t#backoff(deadline: number, error?: unknown): void {\n\t\tconst left = deadline - performance.now()\n\t\tif (left <= 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\terror === undefined\n\t\t\t\t\t? `Capture ownership marker kept changing until the deadline: ${this.#lock}; rerun after serializing capture commands`\n\t\t\t\t\t: `Capture ownership marker is temporarily unavailable (${error instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)}): ${this.#lock}; rerun after serializing capture commands`,\n\t\t\t\t{ code: 'STAGE', ...(error === undefined ? {} : { cause: error }) },\n\t\t\t)\n\t\tAtomics.wait(\n\t\t\tnew Int32Array(new SharedArrayBuffer(4)),\n\t\t\t0,\n\t\t\t0,\n\t\t\tMath.min(CAPTURE_OWNER_BACKOFF, left),\n\t\t)\n\t}\n\n\t#claim(): void {\n\t\tif (this.#lease !== undefined) return\n\t\tconst directory = attempt(() => statSync(resolve(this.#options.root, this.#options.requests)))\n\t\tif (!directory.success || !directory.value.isDirectory())\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture request directory is unavailable: ${resolve(this.#options.root, this.#options.requests)}`,\n\t\t\t\t{ code: 'STAGE', ...(!directory.success ? { cause: directory.error } : {}) },\n\t\t\t)\n\t\tconst requests = resolve(this.#options.root, this.#options.requests)\n\t\tfor (const name of readdirSync(requests)) {\n\t\t\tif (!name.startsWith(`${CAPTURE_OWNER_FILE}.`) || !name.endsWith('.tmp')) continue\n\t\t\tconst [pid] = name.slice(CAPTURE_OWNER_FILE.length + 1).split('.')\n\t\t\tif (\n\t\t\t\tpid !== undefined &&\n\t\t\t\t/^\\d+$/u.test(pid) &&\n\t\t\t\tNumber.isSafeInteger(Number(pid)) &&\n\t\t\t\tNumber(pid) > 0 &&\n\t\t\t\tthis.#alive(Number(pid)) === false\n\t\t\t)\n\t\t\t\tattempt(() => rmSync(resolve(requests, name), { force: true }))\n\t\t}\n\t\tconst temporary = `${this.#lock}.${String(process.pid)}.${this.id}.tmp`\n\t\ttry {\n\t\t\tthis.#write(temporary, JSON.stringify({ pid: process.pid, id: this.id }))\n\t\t\tconst deadline = performance.now() + CAPTURE_OWNER_TIMEOUT\n\t\t\tthis.#acquire(temporary, deadline)\n\t\t} catch (error) {\n\t\t\tif (isCaptureError(error)) throw error\n\t\t\tconst code =\n\t\t\t\terror instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)\n\t\t\tconst unsupported = [\n\t\t\t\t'ENOTSUP',\n\t\t\t\t'EOPNOTSUPP',\n\t\t\t\t'ENOSYS',\n\t\t\t\t'EXDEV',\n\t\t\t\t...((this.#options.ownership?.platform ?? process.platform) === 'win32' ? [] : ['EPERM']),\n\t\t\t].includes(code)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot link capture ownership (${code}): ${this.#lock}${unsupported ? '; the store directory must support hard links' : '; inspect the filesystem error and rerun'}`,\n\t\t\t\t{ code: 'STAGE', cause: error },\n\t\t\t)\n\t\t} finally {\n\t\t\t// A leftover names this live pid, so a later claim sweeps it after this process ends.\n\t\t\tattempt(() => rmSync(temporary, { force: true }))\n\t\t}\n\t}\n\n\t#acquire(temporary: string, deadline: number): void {\n\t\tconst opened = attempt(() =>\n\t\t\tthis.#options.ownership?.link === undefined\n\t\t\t\t? linkSync(temporary, this.#lock)\n\t\t\t\t: this.#options.ownership.link(temporary, this.#lock),\n\t\t)\n\t\tif (opened.success) {\n\t\t\tthis.#lease = this.id\n\t\t\treturn\n\t\t}\n\t\tif (matchesCaptureTransient(opened.error, this.#options.ownership?.platform)) {\n\t\t\tthis.#backoff(deadline, opened.error)\n\t\t\treturn this.#acquire(temporary, deadline)\n\t\t}\n\t\tif (\n\t\t\t!(opened.error instanceof Error) ||\n\t\t\t!('code' in opened.error) ||\n\t\t\topened.error.code !== 'EEXIST'\n\t\t)\n\t\t\tthrow opened.error\n\t\tconst marker = attempt(() => this.#read(deadline))\n\t\tif (!marker.success) {\n\t\t\tif (\n\t\t\t\tmarker.error instanceof Error &&\n\t\t\t\t'code' in marker.error &&\n\t\t\t\tmarker.error.code === 'ENOENT'\n\t\t\t) {\n\t\t\t\tthis.#backoff(deadline)\n\t\t\t\treturn this.#acquire(temporary, deadline)\n\t\t\t}\n\t\t\tif (isCaptureError(marker.error)) throw marker.error\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is unreadable: ${this.#lock}; rerun after inspecting the filesystem error`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\tcause: marker.error,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst owner = attempt(() => this.#owner(marker.value))\n\t\tconst alive = owner.success ? this.#alive(owner.value.pid) : undefined\n\t\t// Confirm the content after the liveness probe, or after a yield for malformed content.\n\t\tif (!owner.success) this.#backoff(deadline)\n\t\tconst confirmed = attempt(() => this.#read(deadline))\n\t\tif (!confirmed.success) {\n\t\t\tif (\n\t\t\t\tconfirmed.error instanceof Error &&\n\t\t\t\t'code' in confirmed.error &&\n\t\t\t\tconfirmed.error.code === 'ENOENT'\n\t\t\t) {\n\t\t\t\tthis.#backoff(deadline)\n\t\t\t\treturn this.#acquire(temporary, deadline)\n\t\t\t}\n\t\t\tif (isCaptureError(confirmed.error)) throw confirmed.error\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is unreadable: ${this.#lock}; rerun after inspecting the filesystem error`,\n\t\t\t\t{ code: 'STAGE', cause: confirmed.error },\n\t\t\t)\n\t\t}\n\t\tif (confirmed.value !== marker.value) {\n\t\t\tthis.#backoff(deadline)\n\t\t\treturn this.#acquire(temporary, deadline)\n\t\t}\n\t\tif (!owner.success) throw owner.error\n\t\tthis.#refuse(owner.value, alive)\n\t}\n\n\t#alive(pid: number): boolean | undefined {\n\t\treturn (this.#options.ownership?.alive ?? inspectProcess)(pid)\n\t}\n\n\t#owner(marker: string): CaptureOwnership {\n\t\tif (marker === '')\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is empty; confirm no capture process or surviving child is running and inspect this file: ${this.#lock}; its holder cannot be established`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\tconst owner = attempt(() => parseJSON(marker))\n\t\tif (\n\t\t\t!owner.success ||\n\t\t\t!isRecord(owner.value) ||\n\t\t\ttypeof owner.value.pid !== 'number' ||\n\t\t\t!Number.isSafeInteger(owner.value.pid) ||\n\t\t\towner.value.pid <= 0 ||\n\t\t\ttypeof owner.value.id !== 'string' ||\n\t\t\towner.value.id === ''\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is malformed; expected { pid: positive integer, id: nonempty string }, received ${preview(marker)}; confirm no capture process or surviving child is running and inspect this file: ${this.#lock}`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\treturn {\n\t\t\tpid: owner.value.pid,\n\t\t\tid: owner.value.id,\n\t\t}\n\t}\n\n\t#refuse(holder: CaptureOwnership, alive: boolean | undefined): never {\n\t\tif (alive === false)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership process ${String(holder.pid)} is not running; invocation ${preview(holder.id)}. ${this.#survivors(holder)} Confirm no capture process or surviving child is running and re-read ${this.#lock} to confirm it still names pid ${String(holder.pid)} before you delete this file and rerun`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\tif (alive === undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership process ${String(holder.pid)} could not be inspected; invocation ${preview(holder.id)}; serialize capture commands. Confirm no capture process or surviving child is running and re-read ${this.#lock} to confirm it still names pid ${String(holder.pid)} before deleting`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\tthrow new CaptureError(\n\t\t\t`Another runner holds this workspace (process ${preview(holder.pid)}); invocation ${preview(holder.id)}; serialize capture commands. If this pid is not a capture run, confirm no capture process or surviving child is running and re-read ${this.#lock} to confirm it still names pid ${String(holder.pid)} before deleting`,\n\t\t\t{ code: 'STAGE' },\n\t\t)\n\t}\n\n\t#survivors(holder: CaptureOwnership): string {\n\t\t// Only an id of the shape this class generates names a directory under the runs directory.\n\t\tif (!/^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/u.test(holder.id))\n\t\t\treturn `Invocation ${preview(holder.id)} is not an invocation id; no child record is read.`\n\t\tconst file = resolve(\n\t\t\tthis.#options.root,\n\t\t\tthis.#options.requests,\n\t\t\tCAPTURE_RUNS_DIRECTORY,\n\t\t\tholder.id,\n\t\t\tCAPTURE_SURVIVORS_FILE,\n\t\t)\n\t\ttry {\n\t\t\tconst record: unknown = parseJSON(\n\t\t\t\tthis.#options.ownership?.read === undefined\n\t\t\t\t\t? readFileSync(file, 'utf8')\n\t\t\t\t\t: this.#options.ownership.read(file),\n\t\t\t)\n\t\t\tif (\n\t\t\t\t!isRecord(record) ||\n\t\t\t\trecord.pid !== holder.pid ||\n\t\t\t\trecord.id !== holder.id ||\n\t\t\t\ttypeof record.command !== 'string' ||\n\t\t\t\trecord.command === '' ||\n\t\t\t\ttypeof record.at !== 'string' ||\n\t\t\t\t!Number.isFinite(Date.parse(record.at)) ||\n\t\t\t\t!Array.isArray(record.children) ||\n\t\t\t\t!record.children.every(\n\t\t\t\t\t(pid: unknown) => typeof pid === 'number' && Number.isSafeInteger(pid) && pid > 0,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn `Child record could not be read (EINVAL): ${file}.`\n\t\t\tconst omitted = record.children.length - CAPTURE_REFUSAL_LIMIT\n\t\t\treturn `Unconfirmed child processes: ${[...record.children.slice(0, CAPTURE_REFUSAL_LIMIT), ...(omitted > 0 ? [`… ${String(omitted)} more`] : [])].join(', ')}; stop them before deleting. Child record: ${file}.`\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\terror instanceof SyntaxError\n\t\t\t\t\t? 'EINVAL'\n\t\t\t\t\t: error instanceof Error && 'code' in error\n\t\t\t\t\t\t? String(error.code)\n\t\t\t\t\t\t: describeCaptureError(error)\n\t\t\treturn code === 'ENOENT'\n\t\t\t\t? `No child record exists at ${file}.`\n\t\t\t\t: `Child record could not be read (${code}): ${file}.`\n\t\t}\n\t}\n}\n","import type { CaptureDestination, CaptureStoredManifest } from '@src/core'\nimport type {\n\tCaptureArtifactResult,\n\tCaptureCheckFrame,\n\tCaptureDecodedImage,\n\tCaptureJudgedFrame,\n\tCaptureJudgedRecord,\n\tCaptureProducer,\n\tCaptureProject,\n\tCapturePreflightInterface,\n\tCapturePreflightResult,\n\tCaptureReaderOptions,\n\tCaptureReaderSelection,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { existsSync, readFileSync, realpathSync, rmSync } from 'node:fs'\nimport { isAbsolute, relative, resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport {\n\tarrayOf,\n\tattempt,\n\tisArray,\n\tisFunction,\n\tisRecord,\n\tisString,\n\tparseJSON,\n} from '@orkestrel/contract'\nimport {\n\tCAPTURE_MANIFEST_FILE,\n\tCAPTURE_REGISTRY_FILE,\n\tCaptureError,\n\tdescribeCaptureError,\n\tisCapturePath,\n\tisCaptureError,\n\tisCaptureRun,\n\tisCaptureStoredManifest,\n\tmatchesCaptureSelector,\n\treadCaptureArtifact,\n\tresolveCaptureKey,\n\tresolveCaptureOwner,\n} from '@src/core'\nimport {\n\tCAPTURE_DEFAULTS,\n\tCAPTURE_EXIT,\n\tCAPTURE_MINIMUM_IMAGE,\n\tCAPTURE_REPORT_LINES,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_SHEET,\n} from './constants.js'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport {\n\tbuildCaptureIntegrityOptions,\n\tcollectCaptureErrors,\n\tscanCaptureFrames,\n\tcollectCaptureIdentical,\n\tcomputeCaptureHash,\n\tdecodeCapturePicture,\n\trequireCaptureProjects,\n\tresolveCaptureRelative,\n\trequireCaptureContained,\n\tresolveCaptureExit,\n\treadCaptureImage,\n\trequireCaptureSelection,\n\treadCaptureVariants,\n\tshrinkCapturePicture,\n\trequireCaptureArgument,\n} from './helpers.js'\n\n/**\n * Reads the selected population's frames and reports their freshness, mixed observations, and coverage.\n *\n * @remarks\n * A successful preflight is iteration evidence and never assembled-portfolio acceptance. The reader\n * reads the host's wrapper through a `CaptureDiscovery`, the consumer's own Vitest in discovery\n * mode, and reads its projects the way the runner does: it names no portfolio, owner, variant, or\n * path the wrapper does not declare, and it imports neither Vite nor Vitest. It\n * judges each frame by the artifact the frame's own stamp names, never by a variant's latest file.\n * Rules that belong to one product, such as a page-title check or a pixel comparison, live in a\n * host module named by the `checks` option. The reader loads that module through the runtime's own\n * module loader by its file URL, reads its `CAPTURE_CHECKS` export, a list of readers from a frame to\n * its findings, and appends every finding to the report.\n * The wrapper's optional `uniform` owner selectors restrict only mixed observations;\n * absence judges every scope, and an empty list judges none.\n *\n * @example\n * ```ts\n * const preflight = new CapturePreflight({\n * \troot: process.cwd(),\n * \tconfig: `${process.cwd()}/configs/app/vite.journey.config.ts`,\n * \tselection: { selector: 'pages:mail' },\n * \tjourneys: `${process.cwd()}/tmp/journey`,\n * })\n * const exit = await preflight.execute()\n * ```\n */\nexport class CapturePreflight implements CapturePreflightInterface {\n\treadonly #options: CaptureReaderOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds one explicit workspace, wrapper, and selection.\n\t *\n\t * @param options - The host configuration and the exact requested bounds\n\t */\n\tconstructor(options: CaptureReaderOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\t/**\n\t * Reads the authenticated selection, uniform scopes, and the host's declared viewports.\n\t *\n\t * @returns The engine, the selected destinations, the viewports, the uniform scopes, and the primary run directory\n\t * @throws Thrown when the wrapper, the registry, or the selection is invalid.\n\t *\n\t * @example\n\t * ```ts\n\t * const { population } = await preflight.read()\n\t * ```\n\t */\n\tasync read(): Promise<CaptureReaderSelection> {\n\t\tconst { root, config, selection } = this.#options\n\t\tconst invocation = new CaptureInvocation({\n\t\t\tcommand: 'stale',\n\t\t\troot,\n\t\t\trequests: this.#options.requests ?? CAPTURE_DEFAULTS.requests,\n\t\t\tstdout: () => undefined,\n\t\t\tstderr: this.#stderr,\n\t\t})\n\t\tinvocation.attach()\n\t\ttry {\n\t\t\tconst loaded = await this.#load(config, invocation)\n\t\t\trequireCaptureArgument(root, resolve(root, this.#options.journeys), '--journeys')\n\t\t\tif (this.#options.checks !== undefined)\n\t\t\t\trequireCaptureArgument(root, resolve(root, this.#options.checks), '--checks')\n\t\t\tif (!isCapturePath(resolveCaptureRelative(root, config)))\n\t\t\t\tthrow new CaptureError('Reader config must be a contained repository path', {\n\t\t\t\t\tcode: 'USAGE',\n\t\t\t\t})\n\t\t\trequireCaptureSelection(\n\t\t\t\tselection.selector,\n\t\t\t\t[],\n\t\t\t\tloaded.map((entry) => entry.project),\n\t\t\t\t[],\n\t\t\t\tselection.portfolio,\n\t\t\t)\n\t\t\tconst primary = requireCaptureProjects(loaded.map((entry) => entry.project))\n\t\t\t// A standalone root has no stamping route and is read only when a selection names it.\n\t\t\tconst standalone = primary.standalone.find(\n\t\t\t\t(entry) =>\n\t\t\t\t\tselection.portfolio === entry.portfolio ||\n\t\t\t\t\tselection.selector === entry.portfolio ||\n\t\t\t\t\tselection.selector.startsWith(`${entry.portfolio}:`),\n\t\t\t)\n\t\t\tconst options = buildCaptureIntegrityOptions(root, primary, standalone)\n\t\t\trequireCaptureSelection(\n\t\t\t\tselection.selector,\n\t\t\t\tselection.variants ?? [],\n\t\t\t\tloaded.map((entry) => entry.project),\n\t\t\t\treadCaptureVariants(root, resolve(root, options.directory, CAPTURE_REGISTRY_FILE)),\n\t\t\t)\n\t\t\tconst integrity = new CaptureIntegrity(options)\n\t\t\tconst population = await integrity.read(selection)\n\t\t\t// A standalone root's producers belong to another wrapper, so only the primary population is mapped.\n\t\t\tif (\n\t\t\t\tstandalone === undefined &&\n\t\t\t\tpopulation.entries.some(\n\t\t\t\t\t(entry) => !loaded.some((candidate) => candidate.producer.project === entry.project),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Authenticated destination has no actual wrapper project', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\treturn {\n\t\t\t\tintegrity,\n\t\t\t\tpopulation,\n\t\t\t\tvariants: loaded.map((entry) => entry.producer),\n\t\t\t\tdirectory: options.directory,\n\t\t\t\t...(primary.uniform === undefined ? {} : { uniform: primary.uniform }),\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (resolveCaptureExit(error) === 64)\n\t\t\t\trmSync(invocation.directory, { recursive: true, force: true })\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tawait invocation\n\t\t\t\t.release()\n\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Judges every selected frame and returns the mixed observations, freshness, images, and issues.\n\t *\n\t * @returns The preflight result without upgrading any freshness classification\n\t * @throws Thrown when the selection or an artifact cannot be read.\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await preflight.check()\n\t * ```\n\t */\n\tasync check(): Promise<CapturePreflightResult> {\n\t\tconst source = await this.read()\n\t\tconst freshness = await source.integrity.check({\n\t\t\t...this.#options.selection,\n\t\t\tvariants: [...new Set(source.population.entries.map((entry) => entry.variant))],\n\t\t})\n\t\tconst judged = this.#artifacts(source)\n\t\tconst checks = await this.#checks()\n\t\tconst results = judged.map(({ entry, artifact, issues }) => {\n\t\t\tconst result = this.#image(entry)\n\t\t\tconst findings = checks.flatMap((check) => {\n\t\t\t\tconst found: unknown = check({ entry, picture: result.image?.picture, artifact })\n\t\t\t\tif (!arrayOf(isString)(found))\n\t\t\t\t\tthrow new CaptureError('A host check returned something other than a list of findings', {\n\t\t\t\t\t\tcode: 'HOST',\n\t\t\t\t\t})\n\t\t\t\treturn found\n\t\t\t})\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tresult.image === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t...result.image,\n\t\t\t\t\t\t\t\tpicture: { width: result.image.picture.width, height: result.image.picture.height },\n\t\t\t\t\t\t\t\tthumbnail: shrinkCapturePicture(\n\t\t\t\t\t\t\t\t\tresult.image.picture,\n\t\t\t\t\t\t\t\t\tMath.max(1, Math.ceil(result.image.picture.width / CAPTURE_SHEET.cell)),\n\t\t\t\t\t\t\t\t\tCAPTURE_SHEET.limit,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t},\n\t\t\t\tissues: [...issues, ...result.issues, ...findings],\n\t\t\t}\n\t\t})\n\t\tconst images = results.flatMap((result) => (result.image === undefined ? [] : [result.image]))\n\t\tconst result: CapturePreflightResult = {\n\t\t\tselection: source.population,\n\t\t\tvariants: source.variants,\n\t\t\tdirectory: source.directory,\n\t\t\tfreshness,\n\t\t\timages,\n\t\t\tmixed: scanCaptureFrames(\n\t\t\t\timages.filter(\n\t\t\t\t\t({ entry }) =>\n\t\t\t\t\t\tsource.uniform === undefined ||\n\t\t\t\t\t\tsource.uniform.some((scope) =>\n\t\t\t\t\t\t\tmatchesCaptureSelector(resolveCaptureOwner(entry), scope),\n\t\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tsource.variants,\n\t\t\t),\n\t\t\tissues: [...new Set(results.flatMap((image) => image.issues))],\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * Executes the check and prints its report.\n\t *\n\t * @returns Exit 0 for current frames without defects, 1 for any defect, or 64 for refused usage\n\t *\n\t * @example\n\t * ```ts\n\t * const exit = await preflight.execute() // 0\n\t * ```\n\t */\n\tasync execute(): Promise<number> {\n\t\ttry {\n\t\t\tconst result = await this.check()\n\t\t\tconst issues = result.issues\n\t\t\tthis.#stdout(\n\t\t\t\t`${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify({\n\t\t\t\t\tselection: result.selection,\n\t\t\t\t\tfreshness: result.freshness,\n\t\t\t\t\tmixed: result.mixed,\n\t\t\t\t\tissues,\n\t\t\t\t\tidentical: collectCaptureIdentical(result.images),\n\t\t\t\t\tsizes: result.images.map(({ entry, picture, size }) => ({\n\t\t\t\t\t\tfile: entry.file,\n\t\t\t\t\t\twidth: picture.width,\n\t\t\t\t\t\theight: picture.height,\n\t\t\t\t\t\tbytes: size,\n\t\t\t\t\t})),\n\t\t\t\t\tacceptance: false,\n\t\t\t\t})}\\n`,\n\t\t\t)\n\t\t\treturn issues.length > 0 ||\n\t\t\t\tresult.freshness.entries.some((entry) => entry.status !== 'current')\n\t\t\t\t? CAPTURE_EXIT.failed\n\t\t\t\t: CAPTURE_EXIT.passed\n\t\t} catch (error) {\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t}\n\t}\n\n\t// Discovers the wrapper through the consumer's own Vitest and keeps each project beside its producing viewport.\n\tasync #load(\n\t\tconfig: string,\n\t\tinvocation: CaptureInvocation,\n\t): Promise<\n\t\tReadonlyArray<{ readonly project: CaptureProject; readonly producer: CaptureProducer }>\n\t> {\n\t\tconst { root, deadline, mode } = this.#options\n\t\t// A discovery child's output is the runner's log, never the reader's report.\n\t\tinvocation.prepare()\n\t\trequireCaptureArgument(root, resolve(root, this.#options.journeys), '--journeys')\n\t\tif (this.#options.checks !== undefined)\n\t\t\trequireCaptureArgument(root, resolve(root, this.#options.checks), '--checks')\n\t\tconst description = await new CaptureDiscovery({\n\t\t\troot,\n\t\t\tconfig,\n\t\t\tinvocation,\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\t...(deadline === undefined ? {} : { deadline }),\n\t\t}).describe()\n\t\treturn description.projects.map(({ project, viewport }) => {\n\t\t\tif (viewport === undefined)\n\t\t\t\tthrow new CaptureError('A reader project declares no viewport geometry', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\treturn { project, producer: { ...viewport, project: project.name } }\n\t\t})\n\t}\n\n\t// Loads the host's check readers; a reader without a checks module has none.\n\tasync #checks(): Promise<ReadonlyArray<(frame: CaptureCheckFrame) => unknown>> {\n\t\tconst { checks, root } = this.#options\n\t\tif (checks === undefined) return []\n\t\tconst loaded: unknown = await this.#import(resolve(root, checks)).catch((error: unknown) => {\n\t\t\tthrow new CaptureError(`Cannot load the checks module: ${checks}`, {\n\t\t\t\tcode: 'HOST',\n\t\t\t\tcause: error,\n\t\t\t})\n\t\t})\n\t\tconst list: unknown = isRecord(loaded) ? loaded.CAPTURE_CHECKS : undefined\n\t\tif (!isArray(list) || !list.every(isFunction))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The checks module exports no CAPTURE_CHECKS list of readers: ${checks}`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\treturn list\n\t}\n\n\t// Imports a host module by its file URL; the specifier is computed, so a bundler leaves it alone.\n\tasync #import(file: string): Promise<unknown> {\n\t\treturn await import(/* @vite-ignore */ pathToFileURL(file).href)\n\t}\n\n\t// Decodes one selected image, reporting the reason an unreadable or tiny one cannot be judged.\n\t#image(entry: CaptureDestination): {\n\t\treadonly image: CaptureDecodedImage | undefined\n\t\treadonly issues: readonly string[]\n\t} {\n\t\tconst read = attempt(() => {\n\t\t\tconst bytes = readCaptureImage(resolve(this.#options.root, entry.file))\n\t\t\tif (bytes.length < CAPTURE_MINIMUM_IMAGE)\n\t\t\t\tthrow new CaptureError(`Image under 4 KB: ${entry.file}`, { code: 'EVIDENCE' })\n\t\t\tconst image = {\n\t\t\t\tentry,\n\t\t\t\tpicture: decodeCapturePicture(bytes),\n\t\t\t\tdigest: computeCaptureHash(bytes),\n\t\t\t\tsize: bytes.length,\n\t\t\t}\n\t\t\treturn image\n\t\t})\n\t\treturn read.success\n\t\t\t? { image: read.value, issues: [] }\n\t\t\t: {\n\t\t\t\t\timage: undefined,\n\t\t\t\t\tissues: [`Cannot read image ${entry.file}: ${describeCaptureError(read.error)}`],\n\t\t\t\t}\n\t}\n\n\t// Judges each frame by the artifact its own stamp's run record names, then runs the host's checks.\n\t#artifacts(result: CaptureReaderSelection): readonly CaptureJudgedFrame[] {\n\t\tconst stored = this.#manifest(result.directory)\n\t\tconst located = result.population.entries.map((entry) => ({\n\t\t\tentry,\n\t\t\tlocation: attempt(() => this.#locate(entry, stored, result.variants, result.directory)),\n\t\t}))\n\t\tconst paths = new Set(\n\t\t\tlocated.flatMap(({ location }) => (location.success ? [location.value.record] : [])),\n\t\t)\n\t\tconst records = new Map(\n\t\t\t[...paths].map((record) => [record, attempt(() => this.#artifact(record))] as const),\n\t\t)\n\t\tconst judged = located.map(({ entry, location }): CaptureJudgedFrame => {\n\t\t\tif (!location.success)\n\t\t\t\treturn { entry, artifact: undefined, issues: [describeCaptureError(location.error)] }\n\t\t\tconst outcome = records.get(location.value.record)\n\t\t\tif (outcome === undefined)\n\t\t\t\tthrow new CaptureError(`Judged run record was not read: ${location.value.record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (!outcome.success)\n\t\t\t\treturn { entry, artifact: undefined, issues: [describeCaptureError(outcome.error)] }\n\t\t\tconst artifact = outcome.value\n\t\t\tconst lines = readCaptureArtifact(artifact.text)\n\t\t\tconst covered =\n\t\t\t\tartifact.run.passed.includes(location.value.case) &&\n\t\t\t\tartifact.run.entries.some(\n\t\t\t\t\t(emitted) => resolveCaptureKey(emitted) === resolveCaptureKey(entry),\n\t\t\t\t)\n\t\t\treturn {\n\t\t\t\tentry,\n\t\t\t\tartifact,\n\t\t\t\tissues: [\n\t\t\t\t\t...(covered ? [] : [`Judged record does not cover ${entry.file}: ${artifact.record}`]),\n\t\t\t\t\t...(lines.records.includes(artifact.record)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [`Judged journey artifact does not cover its record: ${artifact.file}`]),\n\t\t\t\t\t...(lines.cases.includes(location.value.case)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [`Judged journey artifact does not cover ${location.value.case}: ${artifact.file}`]),\n\t\t\t\t],\n\t\t\t}\n\t\t})\n\t\tconst artifacts = [\n\t\t\t...new Map(\n\t\t\t\tjudged.flatMap(({ artifact }) =>\n\t\t\t\t\tartifact === undefined ? [] : [[artifact.file, artifact] as const],\n\t\t\t\t),\n\t\t\t).values(),\n\t\t]\n\t\tconst errors = artifacts.flatMap((artifact) =>\n\t\t\tcollectCaptureErrors(artifact.file, artifact.text),\n\t\t)\n\t\treturn judged.map((frame) => ({\n\t\t\t...frame,\n\t\t\tissues: [\n\t\t\t\t...frame.issues,\n\t\t\t\t...errors.filter(\n\t\t\t\t\t(error) => frame.artifact !== undefined && error.startsWith(`${frame.artifact.file}:`),\n\t\t\t\t),\n\t\t\t],\n\t\t}))\n\t}\n\n\t// Reads the stamps the engine's check validated; an absent manifest holds no stamps.\n\t#manifest(directory: string): CaptureStoredManifest | undefined {\n\t\tconst file = resolve(this.#options.root, directory, CAPTURE_MANIFEST_FILE)\n\t\tif (!existsSync(file)) return undefined\n\t\tconst manifest = parseJSON(readFileSync(file, 'utf8'))\n\t\tif (!isCaptureStoredManifest(manifest))\n\t\t\tthrow new CaptureError('Invalid stamped manifest schema', { code: 'EVIDENCE' })\n\t\treturn manifest\n\t}\n\n\t// Resolves the run record a judged frame's stamp names through its wrapper's producing variant.\n\t#locate(\n\t\tentry: CaptureDestination,\n\t\tstored: CaptureStoredManifest | undefined,\n\t\tproducers: readonly CaptureProducer[],\n\t\tdirectory: string,\n\t): CaptureJudgedRecord {\n\t\tconst stamp = stored?.entries[resolveCaptureKey(entry)]\n\t\tif (stamp === undefined)\n\t\t\tthrow new CaptureError(`Judged frame has no stamped run record: ${entry.file}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst producer = producers.find((candidate) => candidate.project === entry.project)?.name\n\t\tif (producer === undefined)\n\t\t\tthrow new CaptureError(`No journey artifact mapping for project: ${entry.project}`, {\n\t\t\t\tcode: 'HOST',\n\t\t\t})\n\t\tconst record = `${directory}/${CAPTURE_RUNS_DIRECTORY}/${stamp.identity.id}/${stamp.identity.stage}/${producer}.json`\n\t\tif (!isCapturePath(record))\n\t\t\tthrow new CaptureError(`Invalid judged run record path: ${record}`, { code: 'EVIDENCE' })\n\t\treturn { record, case: stamp.case }\n\t}\n\n\t// Reads a judged record and the artifact it names, refusing changed or unbound artifact bytes.\n\t#artifact(record: string): CaptureArtifactResult {\n\t\tconst { root, journeys } = this.#options\n\t\trequireCaptureContained(root, resolve(root, journeys))\n\t\tconst run = parseJSON(readFileSync(resolve(root, record), 'utf8'))\n\t\tif (!isCaptureRun(run))\n\t\t\tthrow new CaptureError(`Invalid judged run record: ${record}`, { code: 'EVIDENCE' })\n\t\tif (run.artifact === undefined)\n\t\t\tthrow new CaptureError(`Judged record names no journey artifact: ${record}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst file = run.artifact.file\n\t\tconst path = resolve(root, file)\n\t\tconst physical = attempt(() => requireCaptureContained(journeys, path))\n\t\tconst contained = relative(journeys, path)\n\t\tif (\n\t\t\tcontained === '' ||\n\t\t\tcontained.startsWith('..') ||\n\t\t\tisAbsolute(contained) ||\n\t\t\t(!physical.success && isCaptureError(physical.error)) ||\n\t\t\t(physical.success && physical.value === realpathSync(journeys))\n\t\t)\n\t\t\tthrow new CaptureError(`Judged journey artifact is outside the journeys directory: ${file}`, {\n\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t})\n\t\tif (!physical.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot read judged journey artifact: ${file}: ${describeCaptureError(physical.error)}`,\n\t\t\t\t{ code: 'EVIDENCE', cause: physical.error },\n\t\t\t)\n\t\tconst bytes = attempt(() => readFileSync(physical.value))\n\t\tif (!bytes.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot read judged journey artifact: ${file}: ${describeCaptureError(bytes.error)}`,\n\t\t\t\t{ code: 'EVIDENCE', cause: bytes.error },\n\t\t\t)\n\t\tif (computeCaptureHash(bytes.value) !== run.artifact.digest)\n\t\t\tthrow new CaptureError(`Judged journey artifact differs from its record: ${file}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\treturn { record, run, file, text: bytes.value.toString('utf8') }\n\t}\n}\n","import type { CaptureRequest } from '@src/core'\nimport type {\n\tCaptureExecutionResult,\n\tCaptureInvocationInterface,\n\tCaptureIntegrityOptions,\n\tCaptureProject,\n\tCaptureReceiptInput,\n\tCaptureRegistrarInterface,\n\tCaptureRegistrarOptions,\n\tCaptureRegistryArguments,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { existsSync, readFileSync, renameSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { attempt, parseJSON } from '@orkestrel/contract'\nimport {\n\tCAPTURE_REGISTRY_FILE,\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tdescribeCaptureError,\n\tdescribeCaptureRequest,\n\tisCapturePath,\n\tisCaptureRegistry,\n\tisCaptureLookupJournal,\n\tisCaptureStoredManifest,\n\tisCaptureRun,\n\treadCaptureReport,\n\tvalidateCaptureRun,\n} from '@src/core'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport {\n\tCAPTURE_EXIT,\n\tCAPTURE_PROGRESS_SUFFIX,\n\tCAPTURE_REGISTRY_LINE,\n\tCAPTURE_REGISTRY_STAGE,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_VITEST_ENTRY,\n} from './constants.js'\nimport {\n\tbuildCaptureArguments,\n\trequireCaptureContained,\n\tdescribeCaptureFault,\n\tdescribeCaptureHolders,\n\tbuildCaptureIntegrityOptions,\n\tbuildCaptureRegistry,\n\tcomputeCaptureHash,\n\treadCaptureInputs,\n\treadCaptureRegistryArguments,\n\trequireCaptureProjects,\n\tresolveCaptureRelative,\n\twriteCaptureDocument,\n\tresolveCaptureExit,\n} from './helpers.js'\n\n/**\n * Refreshes the accepted registry from one complete capture-free journey stage over the selected variants.\n *\n * @remarks\n * The refresh is the one route that bootstraps or replaces the registry the stage transaction\n * requires, so it cannot stamp through the integrity engine. It reads the wrapper through the same\n * discovery the runner uses, takes the same invocation entity, request file, and Vitest child, and runs\n * every selected producing variant in one stage, one child that receives each variant's project, with\n * the `all` selector and no capture variable. The stage passes no tag filter, so it runs the whole\n * suite, which stands in for the consumer's complete test run. It reads the stage's reporter once and each variant's\n * final record, takes each project's input population before and after, and builds one receipt per\n * variant, all naming the one reporter, through `buildCaptureRegistry`. The registry is written to a\n * candidate beside its target, read back through the integrity engine, and only then renamed into\n * place, so a registry the engine would refuse never replaces a good one. With `--variant`, the\n * existing registry's receipts for the other declared variants are kept. It never widens a scoped\n * run into a refresh and refuses while another runner holds a request file in the request directory.\n * Before any stage, it reads the inherited manifest and lookup journal and refuses an unsupported\n * schema with the file to inspect and repair.\n *\n * @example\n * ```ts\n * const registrar = new CaptureRegistrar({\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/capture',\n * \targv: [],\n * })\n * const exit = await registrar.execute()\n * ```\n */\nexport class CaptureRegistrar implements CaptureRegistrarInterface {\n\treadonly #options: CaptureRegistrarOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds the workspace, the wrapper default, the request directory, and the command line.\n\t *\n\t * @param options - The workspace, the wrapper default, the request directory, the command line, and optional output writers\n\t */\n\tconstructor(options: CaptureRegistrarOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\tasync execute(): Promise<number> {\n\t\tconst { root, requests, argv, config } = this.#options\n\t\tconst invocation = new CaptureInvocation({\n\t\t\tcommand: 'journey',\n\t\t\troot,\n\t\t\trequests,\n\t\t\tstdout: this.#stdout,\n\t\t\tstderr: this.#stderr,\n\t\t})\n\t\tinvocation.attach()\n\t\ttry {\n\t\t\tinvocation.prepare()\n\t\t\tconst parsed = readCaptureRegistryArguments(argv, root, config)\n\t\t\tconst description = await new CaptureDiscovery({\n\t\t\t\troot,\n\t\t\t\tconfig: parsed.config,\n\t\t\t\tinvocation,\n\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t\t...(this.#options.deadline === undefined ? {} : { deadline: this.#options.deadline }),\n\t\t\t}).describe()\n\t\t\treturn await this.#refresh(\n\t\t\t\tinvocation,\n\t\t\t\tparsed,\n\t\t\t\tdescription.projects.map((entry) => entry.project),\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tif (resolveCaptureExit(error) === 64)\n\t\t\t\trmSync(invocation.directory, { recursive: true, force: true })\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t} finally {\n\t\t\tawait invocation\n\t\t\t\t.release()\n\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t)\n\t\t}\n\t}\n\n\tasync #refresh(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tparsed: CaptureRegistryArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst { root } = this.#options\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst declared = [...new Set(projects.flatMap((project) => project.variants))]\n\t\tfor (const variant of parsed.variants) {\n\t\t\tif (!declared.includes(variant))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Unknown variant; ${describeCaptureFault('--variant', variant, 'a producing variant declared by the wrapper', declared)}`,\n\t\t\t\t\t{ code: 'USAGE', context: { variant } },\n\t\t\t\t)\n\t\t}\n\t\tconst variants = declared.filter(\n\t\t\t(variant) => parsed.variants.length === 0 || parsed.variants.includes(variant),\n\t\t)\n\t\tconst selected = variants.map((variant) => {\n\t\t\tconst project = projects.find((candidate) => candidate.variant === variant)\n\t\t\tif (project === undefined)\n\t\t\t\tthrow new CaptureError(`The wrapper declares no journey project for ${variant}`, {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t\tcontext: { variant },\n\t\t\t\t})\n\t\t\treturn project\n\t\t})\n\t\tconst directory = resolveCaptureRelative(root, primary.directory)\n\t\tconst target = `${directory}/${CAPTURE_REGISTRY_FILE}`\n\t\tconst candidate = `${target}.${invocation.id}.candidate`\n\t\t// Validate the physical publication roots before a stage can write a run or a candidate.\n\t\tconst options = buildCaptureIntegrityOptions(root, primary)\n\t\tconst integrity = new CaptureIntegrity({\n\t\t\t...options,\n\t\t\tregistry: candidate,\n\t\t})\n\t\tthis.#inherit(options)\n\t\tconst holders = invocation.holders()\n\t\tif (holders.length > 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureHolders(holders, this.#options.requests)}; the registry refresh starts only while no runner is mid-stage`,\n\t\t\t\t{ code: 'STAGE', context: { holders: holders.map((holder) => holder.pid) } },\n\t\t\t)\n\t\t// A receipt this run keeps must still match its reporter bytes, so an altered one refuses before any journey runs.\n\t\tconst retained = parsed.variants.length === 0 ? [] : this.#retain(target, variants, declared)\n\t\tif (retained.length > 0) buildCaptureRegistry(retained)\n\t\tif (invocation.interrupted) return CAPTURE_EXIT.failed\n\t\tconst imports = await this.#stage(invocation, parsed, primary, selected)\n\t\tif (invocation.interrupted) return CAPTURE_EXIT.failed\n\t\tconst registry = buildCaptureRegistry([...retained, ...imports])\n\t\tconst path = resolve(root, candidate)\n\t\trequireCaptureContained(root, path)\n\t\ttry {\n\t\t\twriteCaptureDocument(path, registry, invocation.signal)\n\t\t\t// The engine reads the candidate exactly as it will read the registry, before anything is replaced.\n\t\t\tawait integrity.read({ selector: 'all' })\n\t\t\tinvocation.signal.throwIfAborted()\n\t\t\trequireCaptureContained(root, path)\n\t\t\trequireCaptureContained(root, resolve(root, target))\n\t\t\trenameSync(path, resolve(root, target))\n\t\t} finally {\n\t\t\tif (attempt(() => requireCaptureContained(root, path)).success) rmSync(path, { force: true })\n\t\t}\n\t\tthis.#stdout(\n\t\t\t`${CAPTURE_REGISTRY_LINE} ${JSON.stringify({\n\t\t\t\tfile: target,\n\t\t\t\tdigest: registry.digest,\n\t\t\t\tvariants: registry.receipts.map((receipt) => receipt.variant),\n\t\t\t\trefreshed: variants,\n\t\t\t\tentries: registry.entries.length,\n\t\t\t})}\\n`,\n\t\t)\n\t\treturn CAPTURE_EXIT.passed\n\t}\n\n\t#inherit(options: CaptureIntegrityOptions): void {\n\t\tfor (const [file, guard] of [\n\t\t\t[options.manifest, isCaptureStoredManifest],\n\t\t\t[options.lookups, isCaptureLookupJournal],\n\t\t] as const) {\n\t\t\tconst path = resolve(options.root, file)\n\t\t\ttry {\n\t\t\t\trequireCaptureContained(options.root, path)\n\t\t\t\tif (!existsSync(path)) continue\n\t\t\t\tif (!guard(parseJSON(readFileSync(path, 'utf8'))))\n\t\t\t\t\tthrow new CaptureError('Invalid inherited evidence schema', { code: 'EVIDENCE' })\n\t\t\t} catch (error) {\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Cannot refresh the registry with inherited evidence at ${JSON.stringify(file)}: ${describeCaptureError(error)}; inspect and repair this file before retrying`,\n\t\t\t\t\t{ code: 'EVIDENCE', cause: error, context: { file } },\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #stage(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tparsed: CaptureRegistryArguments,\n\t\tprimary: CaptureProject,\n\t\tselected: readonly CaptureProject[],\n\t): Promise<readonly CaptureReceiptInput[]> {\n\t\tconst { root } = this.#options\n\t\tconst stage = CAPTURE_REGISTRY_STAGE\n\t\tconst variants = selected.map((project) => project.variant)\n\t\tconst reportFile = resolve(invocation.directory, `${stage}.json`)\n\t\tconst log = resolve(invocation.directory, `${stage}.log`)\n\t\tconst records = `${resolveCaptureRelative(root, primary.directory)}/${CAPTURE_RUNS_DIRECTORY}/${invocation.id}/${stage}`\n\t\tconst args = buildCaptureArguments({\n\t\t\tentry: resolve(root, CAPTURE_VITEST_ENTRY),\n\t\t\tconfig: parsed.config,\n\t\t\treport: reportFile,\n\t\t\tprogress: resolve(invocation.directory, `${stage}${CAPTURE_PROGRESS_SUFFIX}`),\n\t\t\t...(parsed.bail === undefined ? {} : { bail: parsed.bail }),\n\t\t\tprojects: selected.map((project) => project.name),\n\t\t\tfinal: primary.final,\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t})\n\t\tconst request: CaptureRequest = {\n\t\t\tversion: 1,\n\t\t\tid: invocation.id,\n\t\t\tstage,\n\t\t\tconfig: resolveCaptureRelative(root, parsed.config),\n\t\t\tpid: process.pid,\n\t\t\tcommand: 'journey',\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\tselector: 'all',\n\t\t\tvariants,\n\t\t\targs,\n\t\t}\n\t\tconst snapshots = selected.map((project) => ({\n\t\t\tproject,\n\t\t\tbefore: readCaptureInputs(root, project.inputs),\n\t\t}))\n\t\tconst started = Date.now()\n\t\trmSync(reportFile, { force: true })\n\t\tthis.#stdout(\n\t\t\t`registry ${stage}: ${variants.join(', ')}; all; report=${reportFile}; records=${records}/<variant>.json\\n`,\n\t\t)\n\t\tconst outcome = await this.#run(invocation, request, log)\n\t\tif (invocation.interrupted)\n\t\t\tthrow new CaptureError('Runner interrupted', { code: 'STAGE', context: { stage, variants } })\n\t\tconst subject = `The registry journey for ${variants.join(', ')} in stage ${stage}`\n\t\tif (outcome.code !== 0 || outcome.signal !== null)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${subject} did not exit successfully (${String(outcome.code ?? outcome.signal)})`,\n\t\t\t\t{ code: 'STAGE', context: { stage, variants, code: outcome.code, signal: outcome.signal } },\n\t\t\t)\n\t\tif (!existsSync(reportFile))\n\t\t\tthrow new CaptureError(`${subject} wrote no reporter at ${reportFile}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\tcontext: { stage, variants },\n\t\t\t})\n\t\tconst text = readFileSync(reportFile, 'utf8')\n\t\tconst report = readCaptureReport(parseJSON(text))\n\t\tif (report.start < started || report.end > Date.now())\n\t\t\tthrow new CaptureError('Reporter does not belong to this refresh', { code: 'EVIDENCE' })\n\t\tconst file = resolveCaptureRelative(root, reportFile)\n\t\tconst digest = computeCaptureHash(text)\n\t\treturn snapshots.map(({ project, before }) => {\n\t\t\tconst variant = project.variant\n\t\t\tconst record = `${records}/${variant}.json`\n\t\t\tif (!existsSync(resolve(root, record)))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`The registry journey for ${variant} wrote no final record at ${record}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t\tcontext: { variant },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\tconst run: unknown = parseJSON(readFileSync(resolve(root, record), 'utf8'))\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\trun.variant !== variant ||\n\t\t\t\tdescribeCaptureRequest(run.request) !== describeCaptureRequest(request)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Invalid or mismatched final record: ${record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (Date.parse(run.time) < started || Date.parse(run.time) > report.end)\n\t\t\t\tthrow new CaptureError('Final record time does not belong to this refresh', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureRun(run, report, project.name)\n\t\t\tif (!run.complete)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`The registry journey for ${variant} was not a complete run; a refresh imports complete runs only`,\n\t\t\t\t\t{ code: 'EVIDENCE', context: { variant } },\n\t\t\t\t)\n\t\t\tif (JSON.stringify(readCaptureInputs(root, project.inputs)) !== JSON.stringify(before))\n\t\t\t\tthrow new CaptureError('Bounded host inputs or membership changed during the refresh', {\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\tcontext: { variant },\n\t\t\t\t})\n\t\t\treturn {\n\t\t\t\treceipt: {\n\t\t\t\t\tversion: CAPTURE_VERSION,\n\t\t\t\t\tvariant,\n\t\t\t\t\ttime: run.time,\n\t\t\t\t\treport: { file, digest },\n\t\t\t\t\tinputs: before,\n\t\t\t\t\tdeclarations: run.declarations,\n\t\t\t\t\tregistry: run.registry,\n\t\t\t\t\tcomplete: run.complete,\n\t\t\t\t},\n\t\t\t\treport: text,\n\t\t\t\toutcome,\n\t\t\t\tcapped: false,\n\t\t\t}\n\t\t})\n\t}\n\n\tasync #run(\n\t\tinvocation: CaptureInvocationInterface,\n\t\trequest: CaptureRequest,\n\t\tlog: string,\n\t): Promise<CaptureExecutionResult> {\n\t\ttry {\n\t\t\tinvocation.publish(request)\n\t\t\treturn await invocation.spawn(request.args, log, false)\n\t\t} finally {\n\t\t\tinvocation.retract()\n\t\t}\n\t}\n\n\t#retain(\n\t\ttarget: string,\n\t\trefreshed: readonly string[],\n\t\tdeclared: readonly string[],\n\t): readonly CaptureReceiptInput[] {\n\t\tconst { root } = this.#options\n\t\tconst path = resolve(root, target)\n\t\tif (!existsSync(path)) return []\n\t\tconst registry: unknown = parseJSON(readFileSync(path, 'utf8'))\n\t\tif (!isCaptureRegistry(registry))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The existing registry is invalid and cannot keep the variants this run leaves out; refresh every producing variant to replace it: ${target}`,\n\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t)\n\t\treturn registry.receipts\n\t\t\t.filter(\n\t\t\t\t(receipt) => declared.includes(receipt.variant) && !refreshed.includes(receipt.variant),\n\t\t\t)\n\t\t\t.map((receipt) => {\n\t\t\t\tif (!isCapturePath(receipt.report.file) || !existsSync(resolve(root, receipt.report.file)))\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`The retained receipt for ${receipt.variant} has no reporter at ${JSON.stringify(receipt.report.file)}; refresh every producing variant`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { variant: receipt.variant } },\n\t\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\treceipt,\n\t\t\t\t\treport: readFileSync(resolve(root, receipt.report.file), 'utf8'),\n\t\t\t\t\toutcome: { code: 0, signal: null },\n\t\t\t\t\tcapped: false,\n\t\t\t\t}\n\t\t\t})\n\t}\n}\n","import type { CapturePortfolioRoot, CaptureRequest } from '@src/core'\nimport type {\n\tCaptureChangePlan,\n\tCaptureIntegrityInterface,\n\tCaptureIntegrityOptions,\n\tCaptureInvocationInterface,\n\tCaptureOutcome,\n\tCaptureOwnerOutcome,\n\tCaptureProject,\n\tCaptureRunnerArguments,\n\tCaptureRunnerInterface,\n\tCaptureRunnerOptions,\n\tCaptureRunPlan,\n\tCaptureStagePlan,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { attempt } from '@orkestrel/contract'\nimport {\n\tCAPTURE_LOOKUPS_FILE,\n\tCAPTURE_MANIFEST_FILE,\n\tCAPTURE_OWNER_PREFIX,\n\tCAPTURE_REGISTRY_FILE,\n\tCaptureError,\n\tdescribeCaptureError,\n\tisCaptureError,\n\tisCapturePath,\n} from '@src/core'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport {\n\tCAPTURE_COMMAND_NAMES,\n\tCAPTURE_EXIT,\n\tCAPTURE_PROGRESS_SUFFIX,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_STAGES,\n\tCAPTURE_VITEST_ENTRY,\n} from './constants.js'\nimport {\n\tbuildCaptureArguments,\n\tbuildCaptureFilter,\n\tdescribeCaptureSelectorFault,\n\treadCaptureArguments,\n\trenderCaptureCommand,\n\trequireCaptureProjects,\n\tresolveCaptureRelative,\n\tresolveCaptureStages,\n\tresolveCaptureVariants,\n\tresolveCaptureExit,\n\treadCaptureTitles,\n\tdescribeCaptureMembers,\n\tdescribeCaptureFault,\n\trequireCaptureSelection,\n\treadCaptureVariants,\n} from './helpers.js'\n\n/**\n * Drives selected owners through one journey stage or staged frame captures.\n *\n * @remarks\n * The wrapper and the installed Vitest supply the registry and the execution protocol, and the\n * wrapper's provided values supply every name the runner uses: the variants, the first-stage\n * variant, the final case, and the portfolio roots. The runner never loads the wrapper itself: a\n * `CaptureDiscovery` runs the consumer's installed Vitest in discovery mode and reads back the host\n * description the wrapper writes, so the runner imports neither Vite nor Vitest. It creates one\n * discovery invocation per `execute` call and a separate invocation per changed owner, and holds\n * none of that call's state itself.\n *\n * @example\n * ```ts\n * const runner = new CaptureRunner({\n * \tcommand: 'journey',\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/units',\n * \targv: ['pages:mail', '--variant', 'light-390'],\n * })\n * const exit = await runner.execute()\n * ```\n */\nexport class CaptureRunner implements CaptureRunnerInterface {\n\treadonly #options: CaptureRunnerOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds the command, the workspace, and the command line.\n\t *\n\t * @param options - The command, the workspace, the wrapper default, the request directory, and the command line\n\t */\n\tconstructor(options: CaptureRunnerOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\tasync execute(): Promise<number> {\n\t\tconst { command, root, requests, argv, config } = this.#options\n\t\tconst invocation = new CaptureInvocation({\n\t\t\tcommand,\n\t\t\troot,\n\t\t\trequests,\n\t\t\tstdout: this.#stdout,\n\t\t\tstderr: this.#stderr,\n\t\t})\n\t\tinvocation.attach()\n\t\tconst argumentsResult = attempt(() => readCaptureArguments(argv, command, root, config))\n\t\ttry {\n\t\t\tinvocation.prepare()\n\t\t\tif (!argumentsResult.success) throw argumentsResult.error\n\t\t\tconst parsed = argumentsResult.value\n\t\t\tconst description = await new CaptureDiscovery({\n\t\t\t\troot,\n\t\t\t\tconfig: parsed.config,\n\t\t\t\tinvocation,\n\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t\t...(this.#options.deadline === undefined ? {} : { deadline: this.#options.deadline }),\n\t\t\t}).describe()\n\t\t\tconst projects = description.projects.map((entry) => entry.project)\n\t\t\tif (parsed.selector !== undefined) {\n\t\t\t\trequireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio)\n\t\t\t}\n\t\t\tif (command !== 'stale' && parsed.variants.length > 0)\n\t\t\t\tresolveCaptureVariants(parsed.variants, projects)\n\t\t\tif (command !== 'stale' && parsed.case !== undefined) {\n\t\t\t\tthis.#case(requireCaptureProjects(projects), parsed.case, parsed.selector)\n\t\t\t}\n\t\t\tif (command !== 'stale' && parsed.changed !== undefined) {\n\t\t\t\tawait invocation.release()\n\t\t\t\tinvocation.attach()\n\t\t\t\tconst code = await this.#changed(invocation, command, parsed, projects)\n\t\t\t\tif (code === 64) rmSync(invocation.directory, { recursive: true, force: true })\n\t\t\t\treturn code\n\t\t\t}\n\t\t\treturn command === 'stale'\n\t\t\t\t? await this.#check(parsed, projects)\n\t\t\t\t: await this.#run(invocation, command, parsed, projects)\n\t\t} catch (error) {\n\t\t\tif (resolveCaptureExit(error) === 64)\n\t\t\t\trmSync(invocation.directory, { recursive: true, force: true })\n\t\t\tconst ran = Object.values(CAPTURE_STAGES).filter((stage) =>\n\t\t\t\tinvocation.launched(resolve(invocation.directory, `${command}-${stage}.log`)),\n\t\t\t)\n\t\t\tconst next = renderCaptureCommand(\n\t\t\t\tcommand,\n\t\t\t\t{\n\t\t\t\t\tconfig: argumentsResult.success ? argumentsResult.value.config : resolve(root, config),\n\t\t\t\t\tvariants: [],\n\t\t\t\t},\n\t\t\t\t'all',\n\t\t\t\troot,\n\t\t\t)\n\t\t\tthis.#stderr(\n\t\t\t\t`${describeCaptureError(error)}\\n${ran.length === 0 ? 'No execution child ran; the command was refused before execution.' : `Execution stopped after stages: ${ran.join(', ')}; no later stage ran.`}\\nNEXT ${next}\\n`,\n\t\t\t)\n\t\t\treturn resolveCaptureExit(error)\n\t\t} finally {\n\t\t\tawait invocation\n\t\t\t\t.release()\n\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t)\n\t\t}\n\t}\n\n\tasync #changed(\n\t\tdiscovery: CaptureInvocationInterface,\n\t\tcommand: CaptureRequest['command'],\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst { root, requests } = this.#options\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst plan = this.#changes(parsed, primary)\n\t\tfor (const change of plan.changes) this.#stdout(`CHANGE ${JSON.stringify(change)}\\n`)\n\t\tconst commands = plan.owners.map((owner) => renderCaptureCommand(command, parsed, owner, root))\n\t\tconst shared = plan.changes.filter((change) => change.classification === 'shared')\n\t\tconst complete = renderCaptureCommand(\n\t\t\t'journey',\n\t\t\t{\n\t\t\t\tconfig: parsed.config,\n\t\t\t\tvariants: parsed.variants,\n\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t},\n\t\t\t'all',\n\t\t\troot,\n\t\t)\n\t\tfor (const next of commands) this.#stdout(`COMMAND ${next}\\n`)\n\t\tconst variants = resolveCaptureVariants(parsed.variants, projects)\n\t\tif (shared.length > 0) {\n\t\t\tthis.#stderr(\n\t\t\t\t`Shared journey inputs cannot be narrowed because every destination reads them: ${describeCaptureMembers(shared.map((change) => change.path))}\\n`,\n\t\t\t)\n\t\t\tthis.#stdout(\n\t\t\t\t`SUMMARY ${JSON.stringify({ run: [], passed: [], failed: [], notrun: plan.owners, reason: 'shared inputs require an explicit journey selection' })}\\n`,\n\t\t\t)\n\t\t\tfor (const next of [...commands, complete]) this.#stdout(`NEXT ${next}\\n`)\n\t\t\treturn CAPTURE_EXIT.usage\n\t\t}\n\t\tif (plan.owners.length === 0) {\n\t\t\tthis.#stdout(\n\t\t\t\t`No journey input changed\\nSUMMARY ${JSON.stringify({ run: [], passed: [], failed: [], notrun: [], reason: 'only outside paths or no changed paths' })}\\nNEXT ${complete}\\n`,\n\t\t\t)\n\t\t\treturn parsed.plan ? CAPTURE_EXIT.passed : CAPTURE_EXIT.failed\n\t\t}\n\t\tconst selectors = [...new Set(projects.flatMap((project) => project.tags))]\n\t\t\t.filter((tag) => tag.startsWith(CAPTURE_OWNER_PREFIX))\n\t\t\t.map((tag) => tag.slice(CAPTURE_OWNER_PREFIX.length))\n\t\tfor (const owner of plan.owners) {\n\t\t\tconst fault = describeCaptureSelectorFault(owner, selectors)\n\t\t\tif (fault !== undefined) throw new CaptureError(fault, { code: 'HOST' })\n\t\t\tif (parsed.case !== undefined) this.#case(primary, parsed.case, owner)\n\t\t\tif (parsed.plan) await this.#resolve(this.#integrity(primary), parsed, owner, variants)\n\t\t}\n\t\tif (parsed.plan) {\n\t\t\tthis.#stdout(\n\t\t\t\t`SUMMARY ${JSON.stringify({ run: [], passed: [], failed: [], notrun: plan.owners, reason: '--plan starts no execution child' })}\\n`,\n\t\t\t)\n\t\t\tfor (const next of commands) this.#stdout(`NEXT ${next}\\n`)\n\t\t\treturn CAPTURE_EXIT.passed\n\t\t}\n\t\tconst outcomes: CaptureOwnerOutcome[] = []\n\t\tfor (const owner of plan.owners) {\n\t\t\tif (discovery.interrupted) break\n\t\t\tconst invocation = new CaptureInvocation({\n\t\t\t\tcommand,\n\t\t\t\troot,\n\t\t\t\trequests,\n\t\t\t\tstdout: this.#stdout,\n\t\t\t\tstderr: this.#stderr,\n\t\t\t})\n\t\t\tinvocation.attach()\n\t\t\ttry {\n\t\t\t\tinvocation.prepare()\n\t\t\t\tconst code = await this.#run(\n\t\t\t\t\tinvocation,\n\t\t\t\t\tcommand,\n\t\t\t\t\t{ ...parsed, selector: owner },\n\t\t\t\t\tprojects,\n\t\t\t\t).catch((error: unknown) => {\n\t\t\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\t\t\treturn resolveCaptureExit(error)\n\t\t\t\t})\n\t\t\t\toutcomes.push({\n\t\t\t\t\towner,\n\t\t\t\t\tcode,\n\t\t\t\t\tran: Object.values(CAPTURE_STAGES).some((stage) =>\n\t\t\t\t\t\tinvocation.launched(resolve(invocation.directory, `${command}-${stage}.log`)),\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t} finally {\n\t\t\t\tawait invocation\n\t\t\t\t\t.release()\n\t\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tif (outcomes.some((outcome) => outcome.code !== CAPTURE_EXIT.passed)) break\n\t\t}\n\t\tconst failed = outcomes.filter((outcome) => outcome.code !== CAPTURE_EXIT.passed)\n\t\tconst notrun = plan.owners.filter(\n\t\t\t(owner) => !outcomes.some((outcome) => outcome.owner === owner && outcome.ran),\n\t\t)\n\t\tthis.#stdout(\n\t\t\t`SUMMARY ${JSON.stringify({\n\t\t\t\trun: outcomes.filter((outcome) => outcome.ran).map((outcome) => outcome.owner),\n\t\t\t\tpassed: outcomes\n\t\t\t\t\t.filter((outcome) => outcome.code === CAPTURE_EXIT.passed)\n\t\t\t\t\t.map((outcome) => outcome.owner),\n\t\t\t\tfailed: failed.map((outcome) => outcome.owner),\n\t\t\t\tnotrun,\n\t\t\t\treason: discovery.interrupted\n\t\t\t\t\t? 'interrupted'\n\t\t\t\t\t: failed.length > 0\n\t\t\t\t\t\t? 'stopped at the first red owner'\n\t\t\t\t\t\t: 'every selected owner passed',\n\t\t\t})}\\n`,\n\t\t)\n\t\tfor (const owner of [...new Set([...failed.map((outcome) => outcome.owner), ...notrun])])\n\t\t\tthis.#stdout(`NEXT ${renderCaptureCommand(command, parsed, owner, root)}\\n`)\n\t\tif (failed.length === 0 && notrun.length === 0) this.#stdout(`NEXT ${complete}\\n`)\n\t\treturn failed.at(0)?.code ?? (discovery.interrupted ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed)\n\t}\n\n\t#case(primary: CaptureProject, name: string, selector?: string): void {\n\t\tconst { root } = this.#options\n\t\tconst titles = readCaptureTitles(\n\t\t\troot,\n\t\t\tresolve(root, primary.directory, CAPTURE_REGISTRY_FILE),\n\t\t\tselector,\n\t\t)\n\t\tif (!Object.hasOwn(titles, name))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown case; ${describeCaptureFault('--case', name, \"a case in the selected owner's accepted registry reporter collection\", Object.keys(titles))}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t}\n\n\t#changes(parsed: CaptureRunnerArguments, primary: CaptureProject): CaptureChangePlan {\n\t\ttry {\n\t\t\tif (parsed.changed === undefined)\n\t\t\t\tthrow new CaptureError('Missing value: --changed', { code: 'USAGE' })\n\t\t\treturn this.#integrity(primary).changed(parsed.changed)\n\t\t} catch (error) {\n\t\t\tconst command = renderCaptureCommand(\n\t\t\t\t'journey',\n\t\t\t\t{ config: parsed.config, variants: [] },\n\t\t\t\t'all',\n\t\t\t\tthis.#options.root,\n\t\t\t)\n\t\t\tconst registry = renderCaptureCommand(\n\t\t\t\t'registry',\n\t\t\t\t{ config: parsed.config, variants: [] },\n\t\t\t\tundefined,\n\t\t\t\tthis.#options.root,\n\t\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureError(error)}\\nNo owner ran; changed selection was refused.\\n${isCaptureError(error) && error.code === 'EVIDENCE' ? `NEXT ${registry}\\n` : ''}NEXT ${command}`,\n\t\t\t\t{ code: isCaptureError(error) ? error.code : 'EVIDENCE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\tasync #run(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tcommand: CaptureRequest['command'],\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst { root } = this.#options\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst selectors = [...new Set(projects.flatMap((project) => project.tags))]\n\t\t\t.filter((tag) => tag.startsWith(CAPTURE_OWNER_PREFIX))\n\t\t\t.map((tag) => tag.slice(CAPTURE_OWNER_PREFIX.length))\n\t\tconst selector = parsed.selector\n\t\tif (selector === undefined) throw new CaptureError(this.#usage(selectors), { code: 'USAGE' })\n\t\tconst fault = describeCaptureSelectorFault(selector, selectors)\n\t\tif (fault !== undefined) throw new CaptureError(fault, { code: 'USAGE', context: { selector } })\n\t\tconst variants = resolveCaptureVariants(parsed.variants, projects)\n\t\tconst integrity = this.#integrity(primary)\n\t\tconst selected = await this.#resolve(integrity, parsed, selector, variants)\n\t\tconst plan: CaptureRunPlan = {\n\t\t\tcommand,\n\t\t\tprojects,\n\t\t\tselector,\n\t\t\tfilter: buildCaptureFilter(command, selector, selectors),\n\t\t\t...(selected === undefined ? {} : { case: selected }),\n\t\t\t...(parsed.state === undefined ? {} : { state: parsed.state }),\n\t\t\tfinal: primary.final,\n\t\t\tdirectory: resolveCaptureRelative(root, primary.directory),\n\t\t\tconfig: resolveCaptureRelative(root, parsed.config),\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t...(parsed.bail === undefined ? {} : { bail: parsed.bail }),\n\t\t}\n\t\tconst outcomes: CaptureOutcome[] = []\n\t\tconst stages = resolveCaptureStages(variants, primary.first, command)\n\t\tconst completed: CaptureStagePlan[] = []\n\t\ttry {\n\t\t\tfor (const stage of stages) {\n\t\t\t\tif (invocation.interrupted) return CAPTURE_EXIT.failed\n\t\t\t\toutcomes.push(...(await this.#stage(invocation, integrity, plan, stage)))\n\t\t\t\tcompleted.push(stage)\n\t\t\t}\n\t\t\tfor (const outcome of outcomes) {\n\t\t\t\tthis.#stdout(`${outcome.project}: ${String(outcome.count)} owner-bearing passed cases\\n`)\n\t\t\t}\n\t\t\tif (outcomes.every((outcome) => outcome.count === 0))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t'Empty selected workload: no requested project held applicable work',\n\t\t\t\t\t{ code: 'STAGE' },\n\t\t\t\t)\n\t\t\treturn CAPTURE_EXIT.passed\n\t\t} finally {\n\t\t\tconst ran = stages.filter((stage) =>\n\t\t\t\tinvocation.launched(resolve(invocation.directory, `${command}-${stage.name}.log`)),\n\t\t\t)\n\t\t\tconst notrun = stages.filter((stage) => !ran.includes(stage))\n\t\t\tconst failed = ran.filter((stage) => !completed.includes(stage))\n\t\t\tconst passed =\n\t\t\t\tcompleted.length === stages.length && outcomes.some((outcome) => outcome.count > 0)\n\t\t\tthis.#stdout(\n\t\t\t\t`STAGES ${JSON.stringify({\n\t\t\t\t\tselector,\n\t\t\t\t\trun: ran.map((stage) => stage.name),\n\t\t\t\t\tpassed: completed.map((stage) => stage.name),\n\t\t\t\t\tfailed: failed.map((stage) => stage.name),\n\t\t\t\t\tnotrun: notrun.map((stage) => stage.name),\n\t\t\t\t\treason: invocation.interrupted\n\t\t\t\t\t\t? 'interrupted; no later stage ran'\n\t\t\t\t\t\t: passed\n\t\t\t\t\t\t\t? 'selected workload passed'\n\t\t\t\t\t\t\t: failed.length > 0\n\t\t\t\t\t\t\t\t? 'stage failed; no later stage ran'\n\t\t\t\t\t\t\t\t: notrun.length > 0\n\t\t\t\t\t\t\t\t\t? 'refused before execution'\n\t\t\t\t\t\t\t\t\t: 'empty selected workload',\n\t\t\t\t})}\\n`,\n\t\t\t)\n\t\t\tthis.#stdout(\n\t\t\t\t`NEXT ${renderCaptureCommand(passed ? 'journey' : command, passed ? { config: parsed.config, variants: [] } : parsed, passed ? 'all' : selector, root)}\\n`,\n\t\t\t)\n\t\t}\n\t}\n\n\tasync #stage(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tintegrity: CaptureIntegrityInterface,\n\t\tplan: CaptureRunPlan,\n\t\tstage: CaptureStagePlan,\n\t): Promise<readonly CaptureOutcome[]> {\n\t\tconst { root } = this.#options\n\t\tconst report = resolve(invocation.directory, `${plan.command}-${stage.name}.json`)\n\t\tconst log = resolve(invocation.directory, `${plan.command}-${stage.name}.log`)\n\t\tconst selected = stage.variants.flatMap((variant) =>\n\t\t\tplan.projects.filter((project) => project.variant === variant),\n\t\t)\n\t\tconst args = buildCaptureArguments({\n\t\t\tentry: resolve(root, CAPTURE_VITEST_ENTRY),\n\t\t\tconfig: resolve(root, plan.config),\n\t\t\treport,\n\t\t\tprogress: resolve(invocation.directory, `${stage.name}${CAPTURE_PROGRESS_SUFFIX}`),\n\t\t\t...(plan.bail === undefined ? {} : { bail: plan.bail }),\n\t\t\tprojects: selected.map((project) => project.name),\n\t\t\tfilter: plan.filter,\n\t\t\t...(plan.mode === undefined ? {} : { mode: plan.mode }),\n\t\t\t...(plan.case === undefined ? {} : { case: plan.case }),\n\t\t\t...(plan.case === undefined\n\t\t\t\t? {}\n\t\t\t\t: {\n\t\t\t\t\t\ttitles: readCaptureTitles(root, resolve(root, plan.directory, CAPTURE_REGISTRY_FILE)),\n\t\t\t\t\t}),\n\t\t\tfinal: plan.final,\n\t\t})\n\t\tconst request: CaptureRequest = {\n\t\t\tversion: 1,\n\t\t\tid: invocation.id,\n\t\t\tstage: stage.name,\n\t\t\tconfig: plan.config,\n\t\t\tpid: process.pid,\n\t\t\tcommand: plan.command,\n\t\t\t...(plan.mode === undefined ? {} : { mode: plan.mode }),\n\t\t\tselector: plan.selector,\n\t\t\t...(plan.case === undefined ? {} : { case: plan.case }),\n\t\t\t...(plan.state === undefined ? {} : { state: plan.state }),\n\t\t\tvariants: stage.variants,\n\t\t\targs,\n\t\t}\n\t\trmSync(report, { force: true })\n\t\ttry {\n\t\t\tinvocation.publish(request)\n\t\t\tthis.#stdout(\n\t\t\t\t`${plan.command} ${stage.name}: ${stage.variants.join(', ')}; ${plan.selector}${plan.case === undefined ? '' : ' (case-scoped)'}; report=${report}; records=${plan.directory}/${CAPTURE_RUNS_DIRECTORY}/${invocation.id}/${stage.name}/<variant>.json\\n`,\n\t\t\t)\n\t\t\tconst result = await integrity.stamp({\n\t\t\t\trequest,\n\t\t\t\treport: resolveCaptureRelative(root, report),\n\t\t\t\tsignal: invocation.signal,\n\t\t\t\tprojects: selected.map((project) => ({\n\t\t\t\t\tname: project.name,\n\t\t\t\t\tvariant: project.variant,\n\t\t\t\t\tinputs: project.inputs,\n\t\t\t\t\trecord: `${resolveCaptureRelative(root, project.directory)}/${CAPTURE_RUNS_DIRECTORY}/${request.id}/${request.stage}/${project.variant}.json`,\n\t\t\t\t})),\n\t\t\t\texecute: () => invocation.spawn(args, log, plan.command === 'capture'),\n\t\t\t})\n\t\t\tthis.#stdout(\n\t\t\t\t`INTEGRITY ${JSON.stringify({\n\t\t\t\t\tcommand: plan.command,\n\t\t\t\t\tstage: stage.name,\n\t\t\t\t\tvariants: stage.variants,\n\t\t\t\t\tstamps: result.entries.length,\n\t\t\t\t\tlookups: result.lookups.length,\n\t\t\t\t\tduration: result.duration,\n\t\t\t\t})}\\n`,\n\t\t\t)\n\t\t\tconst outcomes = result.projects.map((project) => ({\n\t\t\t\tproject: project.project,\n\t\t\t\tvariant: project.variant,\n\t\t\t\tcount: project.passed.length,\n\t\t\t}))\n\t\t\tif (stage.name === CAPTURE_STAGES.first && outcomes.every((outcome) => outcome.count === 0)) {\n\t\t\t\tthis.#stdout(\n\t\t\t\t\t`${stage.variants.join(', ')} is inapplicable; the rest stage carries ${plan.selector} when requested\\n`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn outcomes\n\t\t} finally {\n\t\t\tinvocation.retract()\n\t\t}\n\t}\n\n\tasync #resolve(\n\t\tintegrity: CaptureIntegrityInterface,\n\t\tparsed: CaptureRunnerArguments,\n\t\tselector: string,\n\t\tvariants: readonly string[],\n\t): Promise<string | undefined> {\n\t\tif (parsed.state === undefined) return parsed.case\n\t\treturn await integrity\n\t\t\t.lookup({\n\t\t\t\tselector,\n\t\t\t\tvariants,\n\t\t\t\tstate: parsed.state,\n\t\t\t\t...(parsed.case === undefined ? {} : { case: parsed.case }),\n\t\t\t})\n\t\t\t.then((result) => result.case)\n\t}\n\n\t#integrity(\n\t\tprimary: CaptureProject,\n\t\tstandalone?: CapturePortfolioRoot,\n\t): CaptureIntegrityInterface {\n\t\tconst { root } = this.#options\n\t\tconst directory =\n\t\t\tstandalone === undefined\n\t\t\t\t? resolveCaptureRelative(root, primary.directory)\n\t\t\t\t: standalone.directory\n\t\tif (!isCapturePath(directory))\n\t\t\tthrow new CaptureError('The wrapper provides a directory outside the repository', {\n\t\t\t\tcode: 'HOST',\n\t\t\t\tcontext: { directory },\n\t\t\t})\n\t\tconst options: CaptureIntegrityOptions = {\n\t\t\troot,\n\t\t\tdirectory,\n\t\t\tinputs: primary.inputs,\n\t\t\tregistry: `${directory}/${CAPTURE_REGISTRY_FILE}`,\n\t\t\tmanifest: `${directory}/${CAPTURE_MANIFEST_FILE}`,\n\t\t\tlookups: `${directory}/${CAPTURE_LOOKUPS_FILE}`,\n\t\t\tportfolios: standalone === undefined ? primary.portfolios : [standalone],\n\t\t}\n\t\tconst create = this.#options.integrity\n\t\treturn create === undefined ? new CaptureIntegrity(options) : create(options)\n\t}\n\n\tasync #check(\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst selector = parsed.selector\n\t\tif (selector === undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Usage: capture ${CAPTURE_COMMAND_NAMES.stale} <selector> [--variant <output>] [--state <state>] [--case <full name>] [--portfolio <name>]`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tconst primary = requireCaptureProjects(projects)\n\t\t// A standalone root has no stamping route and is read only when a selection names it.\n\t\tconst standalone = primary.standalone.find(\n\t\t\t(root) =>\n\t\t\t\tparsed.portfolio === root.portfolio ||\n\t\t\t\tselector === root.portfolio ||\n\t\t\t\tselector.startsWith(`${root.portfolio}:`),\n\t\t)\n\t\trequireCaptureSelection(\n\t\t\tselector,\n\t\t\tparsed.variants,\n\t\t\tprojects,\n\t\t\treadCaptureVariants(\n\t\t\t\tthis.#options.root,\n\t\t\t\tresolve(\n\t\t\t\t\tthis.#options.root,\n\t\t\t\t\tstandalone?.directory ?? primary.directory,\n\t\t\t\t\tCAPTURE_REGISTRY_FILE,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\t\t// An omitted variant list reads every output variant of the selected registry destinations,\n\t\t// and refuses a declared producing variant the registry never attested.\n\t\tconst result = await this.#integrity(primary, standalone).check({\n\t\t\tselector,\n\t\t\tdeclared: [...new Set(projects.flatMap((project) => project.variants))],\n\t\t\t...(parsed.variants.length === 0 ? {} : { variants: parsed.variants }),\n\t\t\t...(parsed.case === undefined ? {} : { case: parsed.case }),\n\t\t\t...(parsed.state === undefined ? {} : { state: parsed.state }),\n\t\t\t...(parsed.portfolio === undefined ? {} : { portfolio: parsed.portfolio }),\n\t\t})\n\t\tthis.#stdout(`INTEGRITY ${JSON.stringify({ command: 'stale', ...result })}\\n`)\n\t\treturn result.entries.every((entry) => entry.status === 'current')\n\t\t\t? CAPTURE_EXIT.passed\n\t\t\t: CAPTURE_EXIT.failed\n\t}\n\n\t#usage(selectors: readonly string[]): string {\n\t\tconst { command } = this.#options\n\t\tconst state = command === 'capture' ? ' [--state <name>]' : ''\n\t\treturn `Usage: capture ${CAPTURE_COMMAND_NAMES[command]} <selector> [--variant <name>] [--case <full name>]${state} [--config <file>]\\nOr: capture ${CAPTURE_COMMAND_NAMES[command]} --changed <ref> [--plan] [--variant <name>] [--case <full name>]${state} [--config <file>]\\nSelectors:\\n${describeCaptureMembers(selectors.toSorted())}\\nall (every declared scope; name it explicitly)`\n\t}\n}\n","import type {\n\tCapturePicture,\n\tCapturePreflightResult,\n\tCaptureSheetCell,\n\tCaptureSheetGroup,\n\tCaptureSheetOptions,\n\tCaptureSheetPage,\n\tCaptureSheetRow,\n\tCaptureSheetsInterface,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { existsSync, mkdirSync, realpathSync, writeFileSync } from 'node:fs'\nimport { dirname, relative, resolve } from 'node:path'\nimport { attempt } from '@orkestrel/contract'\nimport { CaptureError, describeCaptureError, isCapturePath, resolveCaptureOwner } from '@src/core'\nimport {\n\tCAPTURE_EXIT,\n\tCAPTURE_REPORT_LINES,\n\tCAPTURE_SHEET,\n\tCAPTURE_SHEET_FILES,\n\tCAPTURE_DEFAULTS,\n} from './constants.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport { CapturePreflight } from './CapturePreflight.js'\nimport {\n\tcomposeCapturePictures,\n\tencodeCapturePicture,\n\tnormalizeSlashes,\n\tresolveCapturePhysical,\n\tresolveCaptureSheetIdentity,\n\tsplitCapturePages,\n\tresolveCaptureExit,\n\trequireCaptureArgument,\n} from './helpers.js'\n\n/**\n * Composes exactly the authenticated sparse state and output pairs for iteration review.\n *\n * @remarks\n * Sheets remain preflight artifacts, never assembled-portfolio acceptance. The class reads the\n * selection through `CapturePreflight`, so it judges the same population the preflight does and\n * keeps its refusals. It writes the sheets, an index of every cell, and a notes document into a new\n * directory that is contained in the workspace, has an existing parent, and lies outside every\n * selected capture directory. A frame whose image cannot be read shows as a red mark and is indexed\n * as `missing`.\n *\n * @example\n * ```ts\n * const sheets = new CaptureSheets({ reader, output: `${process.cwd()}/tmp/sheets` })\n * const exit = await sheets.execute()\n * ```\n */\nexport class CaptureSheets implements CaptureSheetsInterface {\n\treadonly #options: CaptureSheetOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds a read selection and a new output directory.\n\t *\n\t * @param options - The explicit host, selection, and sheet destination\n\t */\n\tconstructor(options: CaptureSheetOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.reader.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.reader.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\t/**\n\t * Reads selected physical images, writes complete indexed sheets, and retains all refusals.\n\t *\n\t * @returns Exit 0 for current selected images without preflight defects, 1 for any defect or containment refusal, or 64 for refused usage\n\t *\n\t * @example\n\t * ```ts\n\t * const exit = await sheets.execute() // 0\n\t * ```\n\t */\n\tasync execute(): Promise<number> {\n\t\ttry {\n\t\t\tconst { reader } = this.#options\n\t\t\tconst invocation = new CaptureInvocation({\n\t\t\t\tcommand: 'stale',\n\t\t\t\troot: reader.root,\n\t\t\t\trequests: reader.requests ?? CAPTURE_DEFAULTS.requests,\n\t\t\t\tstdout: this.#stdout,\n\t\t\t\tstderr: this.#stderr,\n\t\t\t})\n\t\t\ttry {\n\t\t\t\tinvocation.prepare()\n\t\t\t\tthis.#output()\n\t\t\t} finally {\n\t\t\t\tawait invocation\n\t\t\t\t\t.release()\n\t\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tconst result = await new CapturePreflight(reader).check()\n\t\t\tconst groups = this.#groups(result)\n\t\t\tconst rows = splitCapturePages(groups, CAPTURE_SHEET.pairs).map((pair): CaptureSheetRow => ({\n\t\t\t\tgroups: pair,\n\t\t\t\tpicture: composeCapturePictures(\n\t\t\t\t\tpair.map((entry) => entry.picture),\n\t\t\t\t\tfalse,\n\t\t\t\t\tCAPTURE_SHEET.gap,\n\t\t\t\t),\n\t\t\t}))\n\t\t\tconst sheets = splitCapturePages(rows, CAPTURE_SHEET.rows).map(\n\t\t\t\t(page, index): CaptureSheetPage => ({\n\t\t\t\t\tfile: `${CAPTURE_SHEET_FILES.prefix}${String(index + 1).padStart(CAPTURE_SHEET_FILES.digits, '0')}.png`,\n\t\t\t\t\trows: page,\n\t\t\t\t\tpicture: composeCapturePictures(\n\t\t\t\t\t\tpage.map((row) => row.picture),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tCAPTURE_SHEET.gap,\n\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t)\n\t\t\tconst output = this.#output(result)\n\t\t\tmkdirSync(output)\n\t\t\tfor (const sheet of sheets)\n\t\t\t\twriteFileSync(resolve(output, sheet.file), encodeCapturePicture(sheet.picture))\n\t\t\tconst index = {\n\t\t\t\tselection: result.selection,\n\t\t\t\tfreshness: result.freshness,\n\t\t\t\tmixed: result.mixed,\n\t\t\t\tissues: result.issues,\n\t\t\t\tacceptance: false,\n\t\t\t\tsheets: sheets.map((sheet) => ({\n\t\t\t\t\tfile: sheet.file,\n\t\t\t\t\twidth: sheet.picture.width,\n\t\t\t\t\theight: sheet.picture.height,\n\t\t\t\t\trows: sheet.rows.map((row) =>\n\t\t\t\t\t\trow.groups.map((group) => ({\n\t\t\t\t\t\t\tidentity: group.identity,\n\t\t\t\t\t\t\tcells: group.cells.map(({ picture, ...cell }) => ({\n\t\t\t\t\t\t\t\t...cell,\n\t\t\t\t\t\t\t\tdisplayed: { width: picture.width, height: picture.height },\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})),\n\t\t\t}\n\t\t\twriteFileSync(\n\t\t\t\tresolve(output, CAPTURE_SHEET_FILES.index),\n\t\t\t\t`${JSON.stringify(index, undefined, 2)}\\n`,\n\t\t\t)\n\t\t\twriteFileSync(\n\t\t\t\tresolve(output, CAPTURE_SHEET_FILES.notes),\n\t\t\t\t`${this.#notes(result, sheets, output).join('\\n')}\\n`,\n\t\t\t)\n\t\t\tthis.#stdout(`${CAPTURE_REPORT_LINES.sheets} ${JSON.stringify(index)}\\n`)\n\t\t\treturn result.issues.length > 0 ||\n\t\t\t\tresult.freshness.entries.some((entry) => entry.status !== 'current')\n\t\t\t\t? CAPTURE_EXIT.failed\n\t\t\t\t: CAPTURE_EXIT.passed\n\t\t} catch (error) {\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t}\n\t}\n\n\t// Refuses an output directory that exists, escapes the workspace, or overlaps a selected capture directory.\n\t#output(result?: CapturePreflightResult): string {\n\t\tconst { root } = this.#options.reader\n\t\tconst output = resolve(this.#options.output)\n\t\tif (result === undefined) requireCaptureArgument(root, output, '--output')\n\t\tconst local = normalizeSlashes(relative(root, output))\n\t\tconst parent = attempt(() =>\n\t\t\tnormalizeSlashes(relative(realpathSync(root), realpathSync(dirname(output)))),\n\t\t)\n\t\tif (\n\t\t\t!isCapturePath(local) ||\n\t\t\t!parent.success ||\n\t\t\t(parent.value !== '' && !isCapturePath(parent.value)) ||\n\t\t\tresult?.selection.entries.some((entry) => {\n\t\t\t\tconst suffix = normalizeSlashes(\n\t\t\t\t\trelative(\n\t\t\t\t\t\tresolveCapturePhysical(resolve(root, dirname(entry.file))),\n\t\t\t\t\t\tresolveCapturePhysical(output),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn suffix === '' || isCapturePath(suffix)\n\t\t\t}) ||\n\t\t\texistsSync(output)\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Contact sheets require a new contained directory outside selected capture directories with an existing parent',\n\t\t\t\t{ code: 'CONTAINMENT' },\n\t\t\t)\n\t\treturn output\n\t}\n\n\t// Gathers the selected destinations by portfolio, owner, and state, each as a row of shrunk cells.\n\t#groups(result: CapturePreflightResult): readonly CaptureSheetGroup[] {\n\t\tconst identities = [\n\t\t\t...new Set(result.selection.entries.map((entry) => resolveCaptureSheetIdentity(entry))),\n\t\t]\n\t\treturn identities.map((identity): CaptureSheetGroup => {\n\t\t\tconst cells = result.selection.entries\n\t\t\t\t.filter((entry) => resolveCaptureSheetIdentity(entry) === identity)\n\t\t\t\t.map((entry): CaptureSheetCell => {\n\t\t\t\t\tconst image = result.images.find((candidate) => candidate.entry.file === entry.file)\n\t\t\t\t\tconst factor =\n\t\t\t\t\t\timage === undefined\n\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t: Math.max(1, Math.ceil(image.picture.width / CAPTURE_SHEET.cell))\n\t\t\t\t\tconst picture: CapturePicture =\n\t\t\t\t\t\timage === undefined\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\twidth: CAPTURE_SHEET.mark.width,\n\t\t\t\t\t\t\t\t\theight: CAPTURE_SHEET.mark.height,\n\t\t\t\t\t\t\t\t\tpixels: Uint8Array.from(\n\t\t\t\t\t\t\t\t\t\t{ length: CAPTURE_SHEET.mark.width * CAPTURE_SHEET.mark.height * 3 },\n\t\t\t\t\t\t\t\t\t\t(_, index) =>\n\t\t\t\t\t\t\t\t\t\t\tindex % 3 === 0 ? CAPTURE_SHEET.mark.present : CAPTURE_SHEET.mark.absent,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: image.thumbnail\n\t\t\t\t\treturn {\n\t\t\t\t\t\tentry,\n\t\t\t\t\t\tpicture,\n\t\t\t\t\t\tsource:\n\t\t\t\t\t\t\timage === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: { width: image.picture.width, height: image.picture.height, bytes: image.size },\n\t\t\t\t\t\tfactor,\n\t\t\t\t\t\tclipped:\n\t\t\t\t\t\t\timage !== undefined && Math.ceil(image.picture.height / factor) > CAPTURE_SHEET.limit,\n\t\t\t\t\t\tfreshness: result.freshness.entries.find((candidate) => candidate.file === entry.file),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\treturn {\n\t\t\t\tidentity,\n\t\t\t\tcells,\n\t\t\t\tpicture: composeCapturePictures(\n\t\t\t\t\tcells.map((cell) => cell.picture),\n\t\t\t\t\tfalse,\n\t\t\t\t),\n\t\t\t}\n\t\t})\n\t}\n\n\t// Writes the notes document: the mixed observations, then each sheet with its cells described.\n\t#notes(\n\t\tresult: CapturePreflightResult,\n\t\tsheets: readonly CaptureSheetPage[],\n\t\toutput: string,\n\t): readonly string[] {\n\t\treturn [\n\t\t\t'# Contact sheets',\n\t\t\t'',\n\t\t\t'Iteration evidence only. Assembled-portfolio acceptance remains withheld.',\n\t\t\t'',\n\t\t\t'## Mixed observations',\n\t\t\t'',\n\t\t\t...(result.mixed.length === 0\n\t\t\t\t? ['No mixed geometry reported for this selection.']\n\t\t\t\t: result.mixed.map((observation) => `- ${observation}`)),\n\t\t\t'',\n\t\t\t...sheets.flatMap((sheet) => [\n\t\t\t\t`## ${sheet.file}`,\n\t\t\t\t'',\n\t\t\t\t``,\n\t\t\t\t'',\n\t\t\t\t...sheet.rows.flatMap((row) =>\n\t\t\t\t\trow.groups.flatMap((group) =>\n\t\t\t\t\t\tgroup.cells.map((cell) => {\n\t\t\t\t\t\t\tconst link = normalizeSlashes(\n\t\t\t\t\t\t\t\trelative(output, resolve(this.#options.reader.root, cell.entry.file)),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tconst source =\n\t\t\t\t\t\t\t\tcell.source === undefined\n\t\t\t\t\t\t\t\t\t? 'unreadable'\n\t\t\t\t\t\t\t\t\t: `${String(cell.source.width)} x ${String(cell.source.height)}`\n\t\t\t\t\t\t\treturn `- ${cell.entry.portfolio} / ${resolveCaptureOwner(cell.entry)} / ${cell.entry.state} / ${cell.entry.variant}: [${cell.entry.file}](${link}); producer ${cell.entry.project}; ${cell.freshness?.status ?? 'missing'}; source ${source}; displayed ${String(cell.picture.width)} x ${String(cell.picture.height)}${cell.clipped ? '; clipped' : ''}`\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]),\n\t\t]\n\t}\n}\n","import type { CaptureCLIInterface, CaptureCLIOptions, CaptureWriteHandler } from './types.js'\nimport { CaptureError, describeCaptureError, isCaptureError } from '@src/core'\nimport { CapturePreflight } from './CapturePreflight.js'\nimport { CaptureRegistrar } from './CaptureRegistrar.js'\nimport { CaptureRunner } from './CaptureRunner.js'\nimport { CaptureSheets } from './CaptureSheets.js'\nimport {\n\tCAPTURE_COMMAND_OPTIONS,\n\tCAPTURE_DEFAULTS,\n\tCAPTURE_EXIT,\n\tCAPTURE_SUBCOMMANDS,\n\tCAPTURE_USAGE,\n} from './constants.js'\nimport {\n\treadCaptureOptions,\n\treadCaptureProgress,\n\treadCaptureReaderArguments,\n\trenderCaptureProgress,\n\tresolveCaptureExit,\n} from './helpers.js'\n\n/**\n * Dispatches capture commands and maps usage and evidence refusals to their exit codes.\n *\n * @remarks\n * The executable's whole behaviour: it reads the subcommand, hands the rest of the command line to\n * the runner, the registry refresh, the preflight, or the contact sheets, or prints the progress of\n * the stage that ran last, and turns a refused usage into exit 64 and any other capture refusal\n * into exit 1, writing the refusal to its error writer. An error that is not a capture refusal\n * propagates.\n *\n * @example\n * ```ts\n * const exit = await new CaptureCLI().execute(['journey', 'pages:mail'])\n * ```\n */\nexport class CaptureCLI implements CaptureCLIInterface {\n\treadonly #root: string\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/** Creates the executable with the working directory and process writers as defaults. */\n\tconstructor(options: CaptureCLIOptions = {}) {\n\t\tthis.#root = options.root ?? process.cwd()\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\t/**\n\t * Executes one command line and returns its exit code after every child has settled.\n\t *\n\t * @param args - The arguments following the executable name\n\t * @returns 0 for passed work, 1 for failed evidence, or 64 for refused usage\n\t * @example\n\t * ```ts\n\t * await new CaptureCLI().execute([]) // 64, with usage written to stderr\n\t * ```\n\t */\n\tasync execute(args: readonly string[]): Promise<number> {\n\t\ttry {\n\t\t\tconst [name, ...argv] = args\n\t\t\tconst root = this.#root\n\t\t\tif (name === undefined || !CAPTURE_SUBCOMMANDS.includes(name))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`${name === undefined ? 'No command given' : `Unknown command ${JSON.stringify(name.slice(0, 80))}`}.\\n${CAPTURE_USAGE}`,\n\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t)\n\t\t\tswitch (name) {\n\t\t\t\tcase 'journey':\n\t\t\t\tcase 'frames':\n\t\t\t\tcase 'stale': {\n\t\t\t\t\tconst command = name === 'frames' ? 'capture' : name === 'stale' ? 'stale' : 'journey'\n\t\t\t\t\treturn await new CaptureRunner({\n\t\t\t\t\t\tcommand,\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tconfig: CAPTURE_DEFAULTS.config,\n\t\t\t\t\t\trequests: CAPTURE_DEFAULTS.requests,\n\t\t\t\t\t\targv,\n\t\t\t\t\t\tstdout: this.#stdout,\n\t\t\t\t\t\tstderr: this.#stderr,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t\tcase 'registry': {\n\t\t\t\t\treturn await new CaptureRegistrar({\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tconfig: CAPTURE_DEFAULTS.config,\n\t\t\t\t\t\trequests: CAPTURE_DEFAULTS.requests,\n\t\t\t\t\t\targv,\n\t\t\t\t\t\tstdout: this.#stdout,\n\t\t\t\t\t\tstderr: this.#stderr,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t\tcase 'progress': {\n\t\t\t\t\tconst usage = 'Usage: capture progress'\n\t\t\t\t\tconst { positionals } = readCaptureOptions(argv, CAPTURE_COMMAND_OPTIONS.progress, usage)\n\t\t\t\t\tif (positionals.length > 0)\n\t\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t\t`Unexpected argument ${JSON.stringify(positionals[0]?.slice(0, 80))}: the progress command takes no argument. ${usage}`,\n\t\t\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t\t\t)\n\t\t\t\t\tthis.#stdout(\n\t\t\t\t\t\t`${renderCaptureProgress(readCaptureProgress(root, CAPTURE_DEFAULTS.requests))}\\n`,\n\t\t\t\t\t)\n\t\t\t\t\treturn CAPTURE_EXIT.passed\n\t\t\t\t}\n\t\t\t\tcase 'preflight': {\n\t\t\t\t\tconst { reader } = readCaptureReaderArguments(argv, root, CAPTURE_DEFAULTS, 'preflight')\n\t\t\t\t\treturn await new CapturePreflight({\n\t\t\t\t\t\t...reader,\n\t\t\t\t\t\tstdout: this.#stdout,\n\t\t\t\t\t\tstderr: this.#stderr,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tconst { reader, output } = readCaptureReaderArguments(argv, root, CAPTURE_DEFAULTS)\n\t\t\t\t\tif (output === undefined)\n\t\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t\t'The sheets command requires --output <new directory>, which must not exist and must sit outside the selected capture directories',\n\t\t\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t\t\t)\n\t\t\t\t\treturn await new CaptureSheets({\n\t\t\t\t\t\treader: { ...reader, stdout: this.#stdout, stderr: this.#stderr },\n\t\t\t\t\t\toutput,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!isCaptureError(error)) throw error\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t}\n\t}\n}\n","import type {\n\tCaptureCLIInterface,\n\tCaptureCLIOptions,\n\tCaptureDiscoveryInterface,\n\tCaptureDiscoveryRunOptions,\n\tCaptureIntegrityInterface,\n\tCaptureIntegrityOptions,\n\tCapturePreflightInterface,\n\tCaptureReaderOptions,\n\tCaptureRegistrarInterface,\n\tCaptureRegistrarOptions,\n\tCaptureRunnerInterface,\n\tCaptureRunnerOptions,\n\tCaptureSheetOptions,\n\tCaptureSheetsInterface,\n} from './types.js'\nimport { CaptureCLI } from './CaptureCLI.js'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CapturePreflight } from './CapturePreflight.js'\nimport { CaptureRegistrar } from './CaptureRegistrar.js'\nimport { CaptureRunner } from './CaptureRunner.js'\nimport { CaptureSheets } from './CaptureSheets.js'\n\n/**\n * Creates the integrity engine bound to an explicit workspace and host portfolio mapping.\n *\n * @param options - The workspace, evidence paths, authorized physical roots, and optional file hash\n * @returns A new engine that stamps stages, reads declarations, checks freshness, and resolves states\n * @throws Thrown when the root is not absolute, a path escapes the root, or a portfolio is invalid.\n *\n * @example\n * ```ts\n * const integrity = createCaptureIntegrity({\n * \troot: process.cwd(),\n * \tdirectory: 'tmp/captures/states',\n * \tinputs: ['src/**'],\n * \tregistry: 'tmp/captures/states/registry.json',\n * \tmanifest: 'tmp/captures/states/manifest.json',\n * \tlookups: 'tmp/captures/states/lookups.json',\n * \tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * })\n * ```\n */\nexport function createCaptureIntegrity(\n\toptions: CaptureIntegrityOptions,\n): CaptureIntegrityInterface {\n\treturn new CaptureIntegrity(options)\n}\n\n/**\n * Creates the runner that drives owner-selected journeys for one command line.\n *\n * @param options - The command, the workspace, the wrapper default, the request directory, the command line, and optional output and engine seams\n * @returns A new runner whose `execute` runs the command and returns its exit status\n *\n * @example\n * ```ts\n * const runner = createCaptureRunner({\n * \tcommand: 'journey',\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/units',\n * \targv: ['pages:mail', '--variant', 'light-390'],\n * })\n * const exit = await runner.execute() // 0 when every stage passed\n * ```\n */\nexport function createCaptureRunner(options: CaptureRunnerOptions): CaptureRunnerInterface {\n\treturn new CaptureRunner(options)\n}\n\n/**\n * Creates the preflight that judges the selected frames' freshness, mixed observations, and coverage.\n *\n * @param options - The workspace, the wrapper, the selection, the journey artifact directory, and optional checks module and output seams\n * @returns A new preflight whose `execute` prints its report and returns the exit status\n *\n * @example\n * ```ts\n * const preflight = createCapturePreflight({\n * \troot: process.cwd(),\n * \tconfig: `${process.cwd()}/configs/app/vite.journey.config.ts`,\n * \tselection: { selector: 'pages:mail' },\n * \tjourneys: `${process.cwd()}/tmp/journey`,\n * })\n * const exit = await preflight.execute() // 0 when every selected frame is current and sound\n * ```\n */\nexport function createCapturePreflight(options: CaptureReaderOptions): CapturePreflightInterface {\n\treturn new CapturePreflight(options)\n}\n\n/**\n * Creates the contact-sheet writer for the selected frames.\n *\n * @param options - The reader options that select the frames and the new directory that receives the sheets\n * @returns A new writer whose `execute` writes the sheets and returns the exit status\n *\n * @example\n * ```ts\n * const sheets = createCaptureSheets({ reader, output: `${process.cwd()}/tmp/sheets` })\n * const exit = await sheets.execute() // 0 when every selected frame is current and sound\n * ```\n */\nexport function createCaptureSheets(options: CaptureSheetOptions): CaptureSheetsInterface {\n\treturn new CaptureSheets(options)\n}\n\n/**\n * Creates the discovery that reads a consumer's wrapper through the consumer's own Vitest.\n *\n * @param options - The workspace, the absolute wrapper path, the invocation that owns the child, and the optional mode and deadline\n * @returns A new discovery whose `describe` publishes the request and returns the wrapper's host description\n *\n * @example\n * ```ts\n * const discovery = createCaptureDiscovery({ root: process.cwd(), config, invocation })\n * const { projects } = await discovery.describe()\n * ```\n */\nexport function createCaptureDiscovery(\n\toptions: CaptureDiscoveryRunOptions,\n): CaptureDiscoveryInterface {\n\treturn new CaptureDiscovery(options)\n}\n\n/**\n * Creates the registry refresh that runs each producing variant's complete journey and publishes the registry.\n *\n * @param options - The workspace, the wrapper default, the request directory, the command line, and optional output seams\n * @returns A new refresh whose `execute` publishes `registry.json` and returns the exit status\n *\n * @example\n * ```ts\n * const registrar = createCaptureRegistrar({\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/capture',\n * \targv: ['--variant', 'light-390'],\n * })\n * const exit = await registrar.execute() // 0 when the registry was published\n * ```\n */\nexport function createCaptureRegistrar(\n\toptions: CaptureRegistrarOptions,\n): CaptureRegistrarInterface {\n\treturn new CaptureRegistrar(options)\n}\n\n/**\n * Creates the executable's command dispatcher over a workspace and injected writers.\n *\n * @param options - The workspace and the report and diagnostic writers; default: the working directory and the process streams\n * @returns A new dispatcher whose `execute` runs one command line and returns its exit code\n *\n * @example\n * ```ts\n * const exit = await createCaptureCLI().execute(['journey', 'pages:mail']) // 0 when the journey passed\n * ```\n */\nexport function createCaptureCLI(options: CaptureCLIOptions = {}): CaptureCLIInterface {\n\treturn new CaptureCLI(options)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,IAAa,wBAAwB,OAAO,OAAO;CAClD,SAAS;CACT,SAAS;CACT,OAAO;AACR,CAAU;;;;;;;;;;;;AAaV,IAAa,eAAe,OAAO,OAAO;CAAE,QAAQ;CAAG,QAAQ;CAAG,OAAO;AAAG,CAAU;;;;;;;;AAStF,IAAa,qBAAqB;;;;;;;;AASlC,IAAa,oBAAoB;;;;;;;;AASjC,IAAa,wBAAwB;;;;;;;;AASrC,IAAa,wBAAwB;;;;;;;;;AAUrC,IAAa,iBAAiB,OAAO,OAAO;CAC3C,UAAU;CACV,OAAO;CACP,MAAM;AACP,CAAU;;;;;;;;;;;;AAaV,IAAa,0BAA0B,OAAO,OAAO;CACpD,SAAS,OAAO,OAAO;EACtB,QAAQ,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;EACxC,SAAS,OAAO,OAAO;GAAE,MAAM;GAAU,UAAU;EAAK,CAAC;EACzD,MAAM,OAAO,OAAO,EAAE,MAAM,SAAS,CAAC;EACtC,SAAS,OA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,OAAO,IAAI,iBAAiB,OAAO;AACpC;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,oBAAoB,SAAuD;CAC1F,OAAO,IAAI,cAAc,OAAO;AACjC;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,uBAAuB,SAA0D;CAChG,OAAO,IAAI,iBAAiB,OAAO;AACpC;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,SAAsD;CACzF,OAAO,IAAI,cAAc,OAAO;AACjC;;;;;;;;;;;;;AAcA,SAAgB,uBACf,SAC4B;CAC5B,OAAO,IAAI,iBAAiB,OAAO;AACpC;;;;;;;;;;;;;;;;;;AAmBA,SAAgB,uBACf,SAC4B;CAC5B,OAAO,IAAI,iBAAiB,OAAO;AACpC;;;;;;;;;;;;AAaA,SAAgB,iBAAiB,UAA6B,CAAC,GAAwB;CACtF,OAAO,IAAI,WAAW,OAAO;AAC9B"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/server/constants.ts","../../../src/server/helpers.ts","../../../src/server/CaptureDiscovery.ts","../../../src/server/CaptureIntegrity.ts","../../../src/server/CaptureInvocation.ts","../../../src/server/CapturePreflight.ts","../../../src/server/CaptureRegistrar.ts","../../../src/server/CaptureRunner.ts","../../../src/server/CaptureSheets.ts","../../../src/server/CaptureCLI.ts","../../../src/server/factories.ts"],"sourcesContent":["import type { CaptureErrorCode, CaptureStatus } from '@src/core'\n\n/**\n * Names the command that clears each refusal condition, or none where no command clears it.\n *\n * @remarks\n * `registry` is the complete-registry refresh, and `journey` is the selected owner's journey, which\n * refreshes its state lookups. A runner prints the command on stdout after the report line it\n * follows, ahead of the refusal on stderr, and on stderr after the refusal when no report line\n * precedes it; a condition with no command prints none.\n *\n * @example\n * ```ts\n * CAPTURE_RECOVERIES.REGISTRY // 'registry'\n * ```\n */\nexport const CAPTURE_RECOVERIES: Readonly<\n\tRecord<CaptureErrorCode, 'registry' | 'journey' | undefined>\n> = Object.freeze({\n\tUSAGE: undefined,\n\tSELECTION: undefined,\n\tHOST: undefined,\n\tSTAGE: undefined,\n\tEVIDENCE: undefined,\n\tREGISTRY: 'registry',\n\tLOOKUP: 'journey',\n\tCONTAINMENT: undefined,\n})\n\n/**\n * Names the command that clears each freshness classification, or none where no command clears it.\n *\n * @remarks\n * `capture` is a frames run over the read selection. A `duplicate` or an `orphan` names a registry\n * or a file that no frames run changes, and a `current` frame needs nothing.\n *\n * @example\n * ```ts\n * CAPTURE_STATUS_RECOVERIES['stale-own'] // 'capture'\n * ```\n */\nexport const CAPTURE_STATUS_RECOVERIES: Readonly<Record<CaptureStatus, 'capture' | undefined>> =\n\tObject.freeze({\n\t\tcurrent: undefined,\n\t\tduplicate: undefined,\n\t\torphan: undefined,\n\t\tmissing: 'capture',\n\t\tunstamped: 'capture',\n\t\t'stale-shared': 'capture',\n\t\t'stale-own': 'capture',\n\t})\n\n/**\n * Names the executable subcommand each runner command answers to.\n *\n * @remarks\n * The frame-placing command is `capture` in the request protocol and `frames` on the command line,\n * because `capture capture` would stutter. The usage text prints the command-line name.\n *\n * @example\n * ```ts\n * CAPTURE_COMMAND_NAMES.capture // 'frames'\n * ```\n */\nexport const CAPTURE_COMMAND_NAMES = Object.freeze({\n\tjourney: 'journey',\n\tcapture: 'frames',\n\tstale: 'stale',\n} as const)\n\n/**\n * Holds the exit status each runner outcome maps to.\n *\n * @remarks `passed` is every stage green with work run, `failed` is a failed stage or an empty\n * workload, and `usage` is a refused command line or selection.\n *\n * @example\n * ```ts\n * CAPTURE_EXIT.usage // 64\n * ```\n */\nexport const CAPTURE_EXIT = Object.freeze({ passed: 0, failed: 1, usage: 64 } as const)\n\n/**\n * Names the exclusive workspace invocation marker.\n * @example\n * ```ts\n * CAPTURE_OWNER_FILE // '.capture-owner'\n * ```\n */\nexport const CAPTURE_OWNER_FILE = '.capture-owner'\n\n/**\n * Holds the largest process id a POSIX or Windows host can assign, the signed 32-bit maximum.\n * @example\n * ```ts\n * CAPTURE_PID_LIMIT // 2147483647\n * ```\n */\nexport const CAPTURE_PID_LIMIT = 2_147_483_647\n\n/**\n * Caps each refusal population so hostile records cannot flood a terminal or agent context.\n * @example\n * ```ts\n * CAPTURE_REFUSAL_LIMIT // 16\n * ```\n */\nexport const CAPTURE_REFUSAL_LIMIT = 16\n\n/**\n * Bounds external diagnostic text while retaining the number of omitted characters.\n * @example\n * ```ts\n * CAPTURE_MESSAGE_LIMIT // 1024\n * ```\n */\nexport const CAPTURE_MESSAGE_LIMIT = 1024\n\n/**\n * Names the selected journey stage and the narrow and remaining frame stages.\n *\n * @example\n * ```ts\n * CAPTURE_STAGES.first // 'narrow'\n * ```\n */\nexport const CAPTURE_STAGES = Object.freeze({\n\tselected: 'selected',\n\tfirst: 'narrow',\n\trest: 'rest',\n} as const)\n\n/**\n * Defines each command's frozen options for Node's standard argument parser.\n *\n * @remarks A boolean option whose default is `true` reads only its `--no-` form, which sets it to\n * `false`; `bail` is the one such option.\n *\n * @example\n * ```ts\n * CAPTURE_COMMAND_OPTIONS.journey.variant.multiple // true\n * ```\n */\nexport const CAPTURE_COMMAND_OPTIONS = Object.freeze({\n\tjourney: Object.freeze({\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tchanged: Object.freeze({ type: 'string' }),\n\t\tplan: Object.freeze({ type: 'boolean' }),\n\t\tbail: Object.freeze({ type: 'boolean', default: true }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tcapture: Object.freeze({\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tchanged: Object.freeze({ type: 'string' }),\n\t\tplan: Object.freeze({ type: 'boolean' }),\n\t\tbail: Object.freeze({ type: 'boolean', default: true }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tstale: Object.freeze({\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tportfolio: Object.freeze({ type: 'string' }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tpreflight: Object.freeze({\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tportfolio: Object.freeze({ type: 'string' }),\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tjourneys: Object.freeze({ type: 'string' }),\n\t\tchecks: Object.freeze({ type: 'string' }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tsheets: Object.freeze({\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tstate: Object.freeze({ type: 'string' }),\n\t\tcase: Object.freeze({ type: 'string' }),\n\t\tportfolio: Object.freeze({ type: 'string' }),\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tjourneys: Object.freeze({ type: 'string' }),\n\t\tchecks: Object.freeze({ type: 'string' }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t\toutput: Object.freeze({ type: 'string' }),\n\t}),\n\tregistry: Object.freeze({\n\t\tvariant: Object.freeze({ type: 'string', multiple: true }),\n\t\tconfig: Object.freeze({ type: 'string' }),\n\t\tbail: Object.freeze({ type: 'boolean', default: true }),\n\t\tmode: Object.freeze({ type: 'string' }),\n\t}),\n\tprogress: Object.freeze({}),\n} as const)\n\n/**\n * Lists the words a tag name can never be, because a tag filter reads them as operators.\n *\n * @example\n * ```ts\n * CAPTURE_TAG_OPERATORS.includes('and') // true\n * ```\n */\nexport const CAPTURE_TAG_OPERATORS: readonly string[] = Object.freeze(['and', 'or', 'not'])\n\n/**\n * Names the environment variable that turns frame capture on for a Vitest child.\n *\n * @example\n * ```ts\n * process.env[CAPTURE_FLAG] = CAPTURE_FLAG_VALUE\n * ```\n */\nexport const CAPTURE_FLAG = 'CAPTURE'\n\n/**\n * Holds the one value of the capture variable that turns frame capture on.\n *\n * @example\n * ```ts\n * CAPTURE_FLAG_VALUE // '1'\n * ```\n */\nexport const CAPTURE_FLAG_VALUE = '1'\n\n/**\n * Names the repository-relative path of the Vitest entry the runner spawns through Node.\n *\n * @example\n * ```ts\n * resolve(root, CAPTURE_VITEST_ENTRY)\n * ```\n */\nexport const CAPTURE_VITEST_ENTRY = 'node_modules/vitest/vitest.mjs'\n\n/**\n * Names the directory beneath a portfolio or request directory that holds one invocation's records.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_RUNS_DIRECTORY}/a/narrow/light-390.json`\n * ```\n */\nexport const CAPTURE_RUNS_DIRECTORY = 'runs'\n\n/**\n * Names the ending of the progress file each stage writes beneath its invocation's run directory.\n *\n * @remarks The stage's name precedes it, so `selected` writes `selected.progress.jsonl`.\n *\n * @example\n * ```ts\n * `tmp/capture/${CAPTURE_RUNS_DIRECTORY}/a/selected${CAPTURE_PROGRESS_SUFFIX}`\n * ```\n */\nexport const CAPTURE_PROGRESS_SUFFIX = '.progress.jsonl'\n\n/**\n * Names the prefixes a journey wrapper derives its own paths from.\n *\n * @remarks `scratch` precedes the variant in the sibling of the evidence root a run without frame\n * capture writes to, and `direct` precedes the random identity of a run no runner started.\n *\n * @example\n * ```ts\n * `tmp/captures/${CAPTURE_WRAPPER_PREFIXES.scratch}light-390` // 'tmp/captures/no-capture-light-390'\n * ```\n */\nexport const CAPTURE_WRAPPER_PREFIXES = Object.freeze({\n\tscratch: 'no-capture-',\n\tdirect: 'direct-',\n} as const)\n\n/** Names the create-only child record beneath an invocation's run directory.\n * @example\n * ```ts\n * CAPTURE_SURVIVORS_FILE // 'survivors.json'\n * ```\n */\nexport const CAPTURE_SURVIVORS_FILE = 'survivors.json'\n\n/**\n * Holds the byte count under which an image is too small to be a real frame.\n *\n * @example\n * ```ts\n * bytes.length < CAPTURE_MINIMUM_IMAGE // true for a blank placeholder\n * ```\n */\nexport const CAPTURE_MINIMUM_IMAGE = 4000\n\n/**\n * Bounds decoded image memory, row metadata, and PNG input bytes independently of untrusted headers.\n *\n * @remarks The pixel budget admits the fleet's 2880 × 6000 and 1170 × 15000 Chromium full-page\n * frames with 19.5% margin over 17,550,000 pixels. The byte budget adds 20% to the largest RGBA\n * scanlines for deflate overhead, chunk framing, and metadata, before any read or compressed copy.\n * A valid 1 × 1 PNG padded to the derived byte boundary peaked at 171 MiB process RSS.\n * Isolated Windows Node runs on 2026-10-28 measured the fixture peaks noted beside each bound;\n * these measurements are not a universal process RSS ceiling.\n * @example\n * ```ts\n * CAPTURE_PNG_LIMITS.pixels // 20971520\n * ```\n */\nexport const CAPTURE_PNG_LIMITS = Object.freeze({\n\t// Bounds inflated storage; stored-deflate RGBA at this pixel boundary peaked at 438 MiB RSS.\n\tpixels: 20 * 1024 * 1024,\n\t// Bounds row metadata; the 131072 × 160 RGBA fixture peaked at 456 MiB RSS.\n\tside: 131_072,\n\t// Allows 20% over maximum RGBA scanlines for deflate, chunks, and metadata.\n\tbytes: Math.ceil((4 * (20 * 1024 * 1024) + 131_072) * 1.2),\n} as const)\n\n/** Bounds a synchronous ownership retry sequence in milliseconds, including host contention.\n * @example\n * ```ts\n * CAPTURE_OWNER_TIMEOUT // 1000\n * ```\n */\nexport const CAPTURE_OWNER_TIMEOUT = 1000\n\n/** Yields between ownership probes in milliseconds so filesystem contention can settle.\n * @example\n * ```ts\n * CAPTURE_OWNER_BACKOFF // 10\n * ```\n */\nexport const CAPTURE_OWNER_BACKOFF = 10\n\n/**\n * Names the first word of the line a reader prints, followed by its JSON report.\n *\n * @example\n * ```ts\n * `${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify(report)}\\n`\n * ```\n */\nexport const CAPTURE_REPORT_LINES = Object.freeze({\n\tpreflight: 'READER',\n\tsheets: 'SHEETS',\n} as const)\n\n/**\n * Holds the contact-sheet geometry: how wide a cell shrinks toward, how tall it may grow, the mark\n * that stands in for an unreadable image, the gap between neighbors, and how many cells, rows, and\n * pairs a row and a sheet hold.\n *\n * @example\n * ```ts\n * CAPTURE_SHEET.cell // 320\n * ```\n */\nexport const CAPTURE_SHEET = Object.freeze({\n\tcell: 320,\n\tlimit: 400,\n\tmark: Object.freeze({ width: 160, height: 20, present: 220, absent: 20 }),\n\tgap: 12,\n\tpairs: 2,\n\trows: 4,\n} as const)\n\n/**\n * Names the contact-sheet files: the sheet prefix and digits, and the two index documents.\n *\n * @example\n * ```ts\n * `${CAPTURE_SHEET_FILES.prefix}001.png` // 'sheet-001.png'\n * ```\n */\nexport const CAPTURE_SHEET_FILES = Object.freeze({\n\tprefix: 'sheet-',\n\tdigits: 3,\n\tindex: 'index.json',\n\tnotes: 'index.md',\n} as const)\n\n/**\n * Names the one stage a registry refresh runs every selected producing variant's complete journey in.\n *\n * @example\n * ```ts\n * `runs/${id}/${CAPTURE_REGISTRY_STAGE}/light-390.json` // 'runs/<id>/registry/light-390.json'\n * ```\n */\nexport const CAPTURE_REGISTRY_STAGE = 'registry'\n\n/**\n * Names the first word of the line the registry refresh prints, followed by its JSON summary.\n *\n * @example\n * ```ts\n * `${CAPTURE_REGISTRY_LINE} ${JSON.stringify(summary)}\\n`\n * ```\n */\nexport const CAPTURE_REGISTRY_LINE = 'REGISTRY'\n\n/**\n * Names the executable's subcommands in the order its usage text lists them.\n *\n * @remarks\n * `frames` runs the `capture` request command, so `capture capture` never stutters. The other\n * names are their own commands.\n *\n * @example\n * ```ts\n * CAPTURE_SUBCOMMANDS.includes('registry') // true\n * ```\n */\nexport const CAPTURE_SUBCOMMANDS: readonly string[] = Object.freeze([\n\t'journey',\n\t'frames',\n\t'stale',\n\t'preflight',\n\t'sheets',\n\t'registry',\n\t'progress',\n])\n\n/**\n * Holds the repository-relative paths the executable falls back to when the command line names none.\n *\n * @remarks\n * `config` is the journey wrapper a scaffold-born browser application carries, `requests` is the\n * one default directory the runner publishes its request file to, and `journeys` is the directory\n * of journey artifacts the readers read. The runner hands the directory it uses to every child in\n * `CAPTURE_REQUESTS`, and `readCaptureRequest` and `answerCaptureDiscovery` read it from there when\n * the wrapper names none, so a wrapper never repeats this value. `--config` replaces the wrapper\n * and `--journeys` the artifacts.\n *\n * @example\n * ```ts\n * CAPTURE_DEFAULTS.config // 'configs/app/vite.journey.config.ts'\n * ```\n */\nexport const CAPTURE_DEFAULTS = Object.freeze({\n\tconfig: 'configs/app/vite.journey.config.ts',\n\trequests: 'tmp/capture',\n\tjourneys: 'tmp/journey',\n} as const)\n\n/**\n * Names the environment variable that carries the absolute request directory to a Vitest child.\n *\n * @remarks\n * The runner sets it on every child it spawns, the discovery child included. A wrapper that names no\n * request directory reads it, so the runner and the wrapper agree without a repeated constant.\n *\n * @example\n * ```ts\n * process.env[CAPTURE_REQUESTS_FLAG] // '/repo/tmp/capture' inside a runner's child\n * ```\n */\nexport const CAPTURE_REQUESTS_FLAG = 'CAPTURE_REQUESTS'\n\n/**\n * Holds the discovery exchange's fixed names and bound.\n *\n * @remarks\n * `phase` is the value that marks a request as a discovery request, `description` is the file the\n * wrapper writes inside the invocation directory, `arguments` are the Vitest arguments that list the\n * configuration's test files without collecting a test, `deadline` is the longest, in milliseconds,\n * the discovery child may run.\n *\n * @example\n * ```ts\n * CAPTURE_DISCOVERY.phase // 'discover'\n * ```\n */\nexport const CAPTURE_DISCOVERY = Object.freeze({\n\tphase: 'discover',\n\tdescription: 'description.json',\n\targuments: Object.freeze(['list', '--filesOnly']),\n\tdeadline: 60_000,\n} as const)\n\n/**\n * Holds the usage text the executable prints when it is given no subcommand or an unknown one.\n *\n * @example\n * ```ts\n * CAPTURE_USAGE.split('\\n')[0] // 'Usage: capture <command> [arguments]'\n * ```\n */\nexport const CAPTURE_USAGE = [\n\t'Usage: capture <command> [arguments]',\n\t'Commands:',\n\t' journey <selector> [--variant <name>]... [--case <full name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' journey --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' frames <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' frames --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--state <name>] [--no-bail] [--mode <name>] [--config <file>]',\n\t' stale <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--portfolio <name>] [--mode <name>] [--config <file>]',\n\t' preflight <selector> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--mode <name>] [--config <file>] [--journeys <directory>] [--checks <module>]',\n\t' sheets <selector> --output <new directory> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--mode <name>] [--config <file>] [--journeys <directory>] [--checks <module>]',\n\t' registry [--variant <name>]... [--no-bail] [--mode <name>] [--config <file>]',\n\t' progress',\n\t'--changed takes one Git ref; HEAD selects uncommitted work. It cannot accompany a selector.',\n\t'--plan requires --changed and prints paths and commands after read-only discovery; no execution child starts.',\n\t'--no-bail runs every selected case after a failure; by default a stage stops at its first failed case.',\n\t'progress prints where the stage that is running, or that ran last, stands, from its progress file.',\n\t'Only --variant repeats. Every flag except --plan and --no-bail takes one nonempty value, as --flag value or --flag=value; use --flag=-x for a value beginning with a dash. The -- terminator is refused.',\n\t'Exit: 0 passed, 1 failed or refused by the evidence, 64 refused usage.',\n].join('\\n')\n","import type { ParseArgsOptionsConfig } from 'node:util'\nimport type { ProgressInitEvent, ProgressRun } from '@orkestrel/test/server'\nimport type {\n\tCaptureCollectionReceipt,\n\tCaptureDestination,\n\tCaptureDigest,\n\tCaptureExpandedManifest,\n\tCaptureLookup,\n\tCaptureLookupJournal,\n\tCaptureManifestDocument,\n\tCapturePortfolioRoot,\n\tCaptureProvided,\n\tCaptureRegistry,\n\tCaptureRequest,\n\tCaptureViewport,\n} from '@src/core'\nimport type {\n\tCaptureArgumentsOptions,\n\tCaptureChange,\n\tCaptureChangePlan,\n\tCaptureCommand,\n\tCaptureDescriptionExpectation,\n\tCaptureDiscoveryConfig,\n\tCaptureDiscoveryOptions,\n\tCaptureEvidence,\n\tCaptureFileSnapshot,\n\tCaptureHashHandler,\n\tCaptureHolder,\n\tCaptureHostDescription,\n\tCaptureHostEntry,\n\tCaptureImageResult,\n\tCaptureIntegrityOptions,\n\tCaptureInputHandler,\n\tCaptureParsedArguments,\n\tCapturePicture,\n\tCapturePreflightResult,\n\tCaptureProducer,\n\tCaptureProgress,\n\tCaptureProject,\n\tCaptureReaderCommand,\n\tCaptureReaderDefaults,\n\tCaptureReaderReport,\n\tCaptureReceiptInput,\n\tCaptureRetractionHandler,\n\tCaptureTerminationHandler,\n\tCaptureRegistryArguments,\n\tCaptureRequestOptions,\n\tCaptureRunnerArguments,\n\tCaptureStagePlan,\n\tCaptureWrapperConfig,\n\tCaptureWrapperOptions,\n\tCaptureWrapperOverride,\n} from './types.js'\nimport { createHash, randomUUID } from 'node:crypto'\nimport {\n\texistsSync,\n\tcloseSync,\n\tfstatSync,\n\topenSync,\n\treadSync,\n\tglobSync,\n\tlstatSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trealpathSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { dirname, isAbsolute, matchesGlob, relative, resolve, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { parseArgs } from 'node:util'\nimport { crc32, deflateSync, inflateSync } from 'node:zlib'\nimport {\n\tarrayOf,\n\tattempt,\n\tisArray,\n\tisError,\n\tisFunction,\n\tisRecord,\n\tisString,\n\tparseJSON,\n\tpreview,\n} from '@orkestrel/contract'\nimport { inspectProcess } from '@orkestrel/process/server'\nimport {\n\tcomputeProgress,\n\tcomputeProgressRun,\n\tcreateProgressPlugin,\n\textractProgressEvents,\n\treadFileSnapshot,\n\trenderProgress,\n} from '@orkestrel/test/server'\nimport {\n\tCAPTURE_LOOKUPS_FILE,\n\tCAPTURE_MANIFEST_FILE,\n\tCAPTURE_OWNER_PREFIX,\n\tCAPTURE_PNG_SIGNATURE,\n\tCAPTURE_REGISTRY_FILE,\n\tCAPTURE_REQUEST_PREFIX,\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tbuildCaptureTags,\n\tcollectCaptureAncestors,\n\tdescribeCaptureDeclaration,\n\tdescribeCaptureDestination,\n\tdescribeCaptureError,\n\tisCaptureGeometry,\n\tisCaptureError,\n\tisCaptureLookupJournal,\n\tisCaptureManifestDocument,\n\tisCapturePath,\n\tisCapturePattern,\n\tisCaptureReceipt,\n\tisCaptureRegistry,\n\tisCaptureSegment,\n\tisCaptureSelector,\n\tmatchesCaptureMembers,\n\tmatchesCaptureSelector,\n\treadCaptureReport,\n\trequireCaptureUnique,\n\tresolveCaptureKey,\n\tresolveCaptureOwner,\n\tresolveLookupKey,\n\tvalidateCaptureReceipt,\n} from '@src/core'\nimport {\n\tCAPTURE_COMMAND_NAMES,\n\tCAPTURE_COMMAND_OPTIONS,\n\tCAPTURE_DEFAULTS,\n\tCAPTURE_DISCOVERY,\n\tCAPTURE_EXIT,\n\tCAPTURE_FLAG,\n\tCAPTURE_FLAG_VALUE,\n\tCAPTURE_PID_LIMIT,\n\tCAPTURE_PNG_LIMITS,\n\tCAPTURE_PROGRESS_SUFFIX,\n\tCAPTURE_REQUESTS_FLAG,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_STAGES,\n\tCAPTURE_REFUSAL_LIMIT,\n\tCAPTURE_MESSAGE_LIMIT,\n\tCAPTURE_TAG_OPERATORS,\n\tCAPTURE_WRAPPER_PREFIXES,\n} from './constants.js'\n\n/**\n * Hashes exact source or image bytes with SHA-256.\n *\n * @param bytes - The bytes, or the explicitly encoded UTF-8 text\n * @returns The lowercase hexadecimal digest\n *\n * @example\n * ```ts\n * computeCaptureHash('') // 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'\n * ```\n */\nexport function computeCaptureHash(bytes: string | Uint8Array): string {\n\treturn createHash('sha256').update(bytes).digest('hex')\n}\n\n/**\n * Classifies changed paths through accepted patterns and reduces owners by ancestry.\n *\n * @param paths - Git paths, including removed paths that no longer exist\n * @param entries - The authenticated accepted registry destinations\n * @returns Sorted path classifications and sorted minimal owners; shared patterns take precedence\n * @example\n * ```ts\n * buildCaptureChangePlan(['README.md'], []).changes\n * // [{ path: 'README.md', classification: 'outside', owners: [] }]\n * ```\n */\nexport function buildCaptureChangePlan(\n\tpaths: readonly string[],\n\tentries: readonly CaptureDestination[],\n): CaptureChangePlan {\n\tconst population = [...new Set(entries.map(resolveCaptureOwner))].toSorted()\n\tconst changes = [...new Set(paths)].toSorted().map((path): CaptureChange => {\n\t\tif (\n\t\t\tentries.some((entry) =>\n\t\t\t\t[...entry.sources.shared, ...entry.sources.tests].some((pattern) =>\n\t\t\t\t\tmatchesGlob(path, pattern),\n\t\t\t\t),\n\t\t\t)\n\t\t)\n\t\t\treturn { path, classification: 'shared', owners: population }\n\t\tconst owners = [\n\t\t\t...new Set(\n\t\t\t\tentries\n\t\t\t\t\t.filter((entry) => entry.sources.own.some((pattern) => matchesGlob(path, pattern)))\n\t\t\t\t\t.map(resolveCaptureOwner),\n\t\t\t),\n\t\t].toSorted()\n\t\treturn { path, classification: owners.length === 0 ? 'outside' : 'own', owners }\n\t})\n\tconst owners = [\n\t\t...new Set(\n\t\t\tchanges\n\t\t\t\t.filter((change) => change.classification === 'own')\n\t\t\t\t.flatMap((change) => change.owners),\n\t\t),\n\t].toSorted()\n\treturn {\n\t\tchanges,\n\t\towners: owners.filter(\n\t\t\t(owner) =>\n\t\t\t\t!owners.some((ancestor) => ancestor !== owner && matchesCaptureSelector(owner, ancestor)),\n\t\t),\n\t}\n}\n\n/**\n * Renders an exact owner command with the selected variants and filters in host shell syntax.\n *\n * @remarks\n * A flag is rendered only when the rendered command's `CAPTURE_COMMAND_OPTIONS` entry declares it,\n * so a journey drops `--state`, a registry refresh drops `--case`, and only `stale` keeps\n * `--portfolio`. `--changed` and `--plan` are never rendered.\n *\n * @param command - The request command, translated to its executable name, or the registry command\n * @param parsed - The parsed flags, a `false` bail rendered as `--no-bail`; changed and plan flags are deliberately replaced by the owner\n * @param selector - The explicit owner or all selector; omitted for a registry refresh\n * @param root - The workspace that makes the wrapper path relative\n * @returns The command ready to copy into the host shell\n * @example\n * ```ts\n * renderCaptureCommand('journey', { config: '/repo/journey.ts', variants: [] }, 'pages:mail', '/repo')\n * // 'capture journey pages:mail --config journey.ts'\n * ```\n */\nexport function renderCaptureCommand(\n\tcommand: CaptureCommand | 'registry',\n\tparsed: CaptureRunnerArguments,\n\tselector: string | undefined,\n\troot: string,\n): string {\n\tconst config = resolveCaptureRelative(root, parsed.config)\n\tconst options = CAPTURE_COMMAND_OPTIONS[command]\n\treturn [\n\t\t'capture',\n\t\tcommand === 'registry' ? command : CAPTURE_COMMAND_NAMES[command],\n\t\t...(selector === undefined ? [] : [selector]),\n\t\t...(Object.hasOwn(options, 'variant')\n\t\t\t? parsed.variants.flatMap((variant) => ['--variant', variant])\n\t\t\t: []),\n\t\t...(parsed.mode === undefined || !Object.hasOwn(options, 'mode')\n\t\t\t? []\n\t\t\t: ['--mode', parsed.mode]),\n\t\t...(parsed.case === undefined || !Object.hasOwn(options, 'case')\n\t\t\t? []\n\t\t\t: parsed.case.startsWith('-')\n\t\t\t\t? [`--case=${parsed.case}`]\n\t\t\t\t: ['--case', parsed.case]),\n\t\t...(parsed.state === undefined || !Object.hasOwn(options, 'state')\n\t\t\t? []\n\t\t\t: ['--state', parsed.state]),\n\t\t...(parsed.portfolio === undefined || !Object.hasOwn(options, 'portfolio')\n\t\t\t? []\n\t\t\t: ['--portfolio', parsed.portfolio]),\n\t\t...(parsed.bail === false && Object.hasOwn(options, 'bail') ? ['--no-bail'] : []),\n\t\t...(config.startsWith('-') ? [`--config=${config}`] : ['--config', config]),\n\t]\n\t\t.map((argument) =>\n\t\t\t/^[\\w./:-]+$/u.test(argument)\n\t\t\t\t? argument\n\t\t\t\t: process.platform === 'win32'\n\t\t\t\t\t? `'${argument.replaceAll(\"'\", \"''\")}'`\n\t\t\t\t\t: `'${argument.replaceAll(\"'\", \"'\\\\''\")}'`,\n\t\t)\n\t\t.join(' ')\n}\n\n/**\n * Normalizes a host path to forward slashes.\n *\n * @param path - A host path\n * @returns The same path with every backslash replaced by a slash\n *\n * @example\n * ```ts\n * normalizeSlashes('tmp\\\\captures\\\\a.png') // 'tmp/captures/a.png'\n * ```\n */\nexport function normalizeSlashes(path: string): string {\n\treturn path.replaceAll('\\\\', '/')\n}\n\n/**\n * Finds the nearest existing path without following a dangling link.\n *\n * @example\n * ```ts\n * readCaptureAncestor('/workspace/missing/file') // '/workspace'\n * ```\n */\nexport function readCaptureAncestor(path: string): string {\n\ttry {\n\t\tlstatSync(path)\n\t\treturn path\n\t} catch (error) {\n\t\tif (!isError(error) || !('code' in error) || error.code !== 'ENOENT' || dirname(path) === path)\n\t\t\tthrow error\n\t\treturn readCaptureAncestor(dirname(path))\n\t}\n}\n\n/**\n * Resolves an existing path or its nearest existing ancestor to its physical destination.\n *\n * @example\n * ```ts\n * resolveCapturePhysical('/workspace/alias/new') // '/workspace/target/new'\n * ```\n */\nexport function resolveCapturePhysical(path: string): string {\n\tconst ancestor = readCaptureAncestor(path)\n\treturn resolve(realpathSync(ancestor), relative(ancestor, path))\n}\n\n/**\n * Validates a physical destination against a physical root before any read or write.\n *\n * @returns The physical destination, including its missing suffix\n * @throws Thrown when the destination or an existing ancestor escapes the root.\n * @example\n * ```ts\n * requireCaptureContained('/workspace', '/workspace/tmp/new') // '/workspace/tmp/new'\n * ```\n */\nexport function requireCaptureContained(root: string, path: string): string {\n\tconst physical = resolveCapturePhysical(path)\n\tconst suffix = relative(realpathSync(root), physical)\n\tif (isAbsolute(suffix) || suffix === '..' || suffix.startsWith(`..${sep}`))\n\t\tthrow new CaptureError(`Physical path resolves outside integrity root: ${path}`, {\n\t\t\tcode: 'CONTAINMENT',\n\t\t})\n\treturn physical\n}\n\n/** Validates a supplied path argument before work and classifies an outside value as usage.\n * @param root - The repository root\n * @param path - The supplied path resolved against the root\n * @param flag - The command line flag that supplied the path\n * @returns The contained physical path\n * @example\n * ```ts\n * requireCaptureArgument('/workspace', '/workspace/checks.ts', '--checks')\n * ```\n */\nexport function requireCaptureArgument(root: string, path: string, flag: string): string {\n\ttry {\n\t\treturn requireCaptureContained(root, path)\n\t} catch (error) {\n\t\tthrow new CaptureError(\n\t\t\t`${flag} ${isCaptureError(error) && error.code === 'CONTAINMENT' ? 'resolves outside the repository' : 'cannot resolve its filesystem path'}: ${preview(path)}; supply a contained repository path`,\n\t\t\t{ code: 'USAGE', cause: error },\n\t\t)\n\t}\n}\n\n/** Recognizes filesystem contention codes that ownership arbitration can retry.\n * @param error - The host operation's refusal\n * @param platform - The host contract; Windows permission errors can reflect handles without delete sharing\n * @returns Whether the error names temporary ownership contention\n * @example\n * ```ts\n * matchesCaptureTransient(Object.assign(new Error('busy'), { code: 'EBUSY' })) // true\n * ```\n */\nexport function matchesCaptureTransient(\n\terror: unknown,\n\tplatform: NodeJS.Platform = process.platform,\n): boolean {\n\treturn (\n\t\terror instanceof Error &&\n\t\t'code' in error &&\n\t\t['EBUSY', 'EMFILE', ...(platform === 'win32' ? ['EPERM', 'EACCES'] : [])].includes(\n\t\t\tString(error.code),\n\t\t)\n\t)\n}\n\n/**\n * Names a sheet group by portfolio, owner, and state independently of its output variant.\n *\n * @example\n * ```ts\n * resolveCaptureSheetIdentity(entry) // '[\"states\",\"pages:mail\",\"mail-screen\"]'\n * ```\n */\nexport function resolveCaptureSheetIdentity(entry: CaptureDestination): string {\n\treturn JSON.stringify([entry.portfolio, resolveCaptureOwner(entry), entry.state])\n}\n\n/**\n * Splits a list into consecutive pages with at most the requested size.\n *\n * @example\n * ```ts\n * splitCapturePages([1, 2, 3], 2) // [[1, 2], [3]]\n * ```\n */\nexport function splitCapturePages<T>(\n\tentries: readonly T[],\n\tsize: number,\n): ReadonlyArray<readonly T[]> {\n\treturn Array.from({ length: Math.ceil(entries.length / size) }, (_, index) =>\n\t\tentries.slice(index * size, index * size + size),\n\t)\n}\n\n/**\n * Compares file content, size, modification time, and change time across two snapshots.\n *\n * @example\n * ```ts\n * matchesCaptureFile(previous, undefined) // false\n * ```\n */\nexport function matchesCaptureFile(\n\tprevious: CaptureFileSnapshot,\n\tcurrent: CaptureFileSnapshot | undefined,\n): boolean {\n\treturn (\n\t\tcurrent !== undefined &&\n\t\tcurrent.image.digest === previous.image.digest &&\n\t\tcurrent.image.size === previous.image.size &&\n\t\tcurrent.image.modified === previous.image.modified &&\n\t\tcurrent.changed === previous.changed\n\t)\n}\n\n/**\n * Merges unique lookup populations with incoming identities replacing inherited ones.\n *\n * @example\n * ```ts\n * mergeCaptureLookups([lookup], [lookup]) // [lookup]\n * ```\n */\nexport function mergeCaptureLookups(\n\tprevious: readonly CaptureLookup[],\n\tlookups: readonly CaptureLookup[],\n): readonly CaptureLookup[] {\n\trequireCaptureUnique(previous.map(resolveLookupKey), 'inherited lookup identities')\n\trequireCaptureUnique(lookups.map(resolveLookupKey), 'incoming lookup identities')\n\tconst replaced = new Set(lookups.map(resolveLookupKey))\n\treturn [...previous.filter((entry) => !replaced.has(resolveLookupKey(entry))), ...lookups]\n}\n\n/**\n * Describes a refusal with its key path, bounded preview, correction, and member differences.\n *\n * @example\n * ```ts\n * describeCaptureFault('--variant[0]', 'bad/name', 'a portable segment')\n * ```\n */\nexport function describeCaptureFault(\n\tpath: string,\n\tvalue: unknown,\n\texpected: string,\n\tcandidates: readonly string[] = [],\n\trequired: readonly string[] = [],\n\tallowed: readonly string[] = required,\n): string {\n\tconst keys = isRecord(value) ? Object.keys(value) : []\n\tconst missing = required.filter((key) => !isRecord(value) || value[key] === undefined)\n\tconst unexpected = keys.filter((key) => !allowed.includes(key))\n\tconst population = [...new Set([...required, ...keys])]\n\tconst members = isRecord(value)\n\t\t? `; members: {${population\n\t\t\t\t.slice(0, CAPTURE_REFUSAL_LIMIT)\n\t\t\t\t.map((key) => `${preview(`${path}.${key}`)}: ${preview(value[key])}`)\n\t\t\t\t.join(\n\t\t\t\t\t', ',\n\t\t\t\t)}${population.length > CAPTURE_REFUSAL_LIMIT ? `, … ${String(population.length - CAPTURE_REFUSAL_LIMIT)} more` : ''}}`\n\t\t: ''\n\treturn `${path.length > 80 ? preview(path) : path}: received ${preview(value)}${members}; expected ${expected}; valid candidates: ${describeCaptureMembers(candidates)}; missing: ${describeCaptureMembers(missing)}; unexpected: ${describeCaptureMembers(unexpected)}`\n}\n\n/**\n * Describes a bounded member population and the number omitted from its preview.\n * @example\n * ```ts\n * describeCaptureMembers(['wide', 'phone']) // '[\"wide\",\"phone\"]'\n * ```\n */\nexport function describeCaptureMembers(members: readonly string[]): string {\n\treturn `[${members.slice(0, CAPTURE_REFUSAL_LIMIT).map(preview).join(',')}${members.length > CAPTURE_REFUSAL_LIMIT ? `, … ${String(members.length - CAPTURE_REFUSAL_LIMIT)} more` : ''}]`\n}\n\n/**\n * Caps external diagnostic text and names the number of omitted characters.\n * @example\n * ```ts\n * describeCaptureOutput('short diagnostic') // 'short diagnostic'\n * ```\n */\nexport function describeCaptureOutput(output: string): string {\n\treturn output.length <= CAPTURE_MESSAGE_LIMIT\n\t\t? output\n\t\t: `${output.slice(0, CAPTURE_MESSAGE_LIMIT)}… ${String(output.length - CAPTURE_MESSAGE_LIMIT)} more characters`\n}\n\n/**\n * Maps usage refusals to exit 64 and every other failure to exit 1.\n *\n * @example\n * ```ts\n * resolveCaptureExit(new CaptureError('Invalid flag', { code: 'USAGE' })) // 64\n * ```\n */\nexport function resolveCaptureExit(error: unknown): number {\n\treturn isCaptureError(error) && error.code === 'USAGE' ? CAPTURE_EXIT.usage : CAPTURE_EXIT.failed\n}\n\n/**\n * Settles independent request removal and child termination without hiding either failure.\n *\n * @returns Every removal, termination, or unconfirmed-exit failure\n * @example\n * ```ts\n * await settleCaptureShutdown(() => invocation.retract(), [() => child.stop()]) // []\n * ```\n */\nexport async function settleCaptureShutdown(\n\tretract: CaptureRetractionHandler,\n\tterminations: readonly CaptureTerminationHandler[],\n): Promise<readonly unknown[]> {\n\tconst removal = attempt(retract)\n\tconst results = await Promise.allSettled(terminations.map(async (terminate) => await terminate()))\n\treturn [\n\t\t...(removal.success ? [] : [removal.error]),\n\t\t...results.flatMap((result) =>\n\t\t\tresult.status === 'rejected'\n\t\t\t\t? [result.reason]\n\t\t\t\t: result.value\n\t\t\t\t\t? []\n\t\t\t\t\t: [new CaptureError('Capture child termination was not confirmed', { code: 'STAGE' })],\n\t\t),\n\t]\n}\n\n/**\n * Computes the digest of both pattern declarations and expanded path and hash membership.\n *\n * @param patterns - The supplied native glob patterns\n * @param files - The expanded file hashes\n * @returns A deterministic digest retaining the original evidence populations\n *\n * @example\n * ```ts\n * buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64) }).patterns // ['src/**']\n * ```\n */\nexport function buildCaptureDigest(\n\tpatterns: readonly string[],\n\tfiles: Readonly<Record<string, string>>,\n): CaptureDigest {\n\tconst ordered = Object.entries(files).toSorted(([left], [right]) =>\n\t\tleft.localeCompare(right, 'en'),\n\t)\n\treturn {\n\t\tpatterns: patterns.toSorted(),\n\t\tfiles: Object.fromEntries(ordered),\n\t\tdigest: computeCaptureHash(JSON.stringify([patterns.toSorted(), ordered])),\n\t}\n}\n\n/**\n * Computes the key under which a pattern list's matched subset of one input population is memoized.\n *\n * @remarks\n * The key joins the population's digest with the sorted patterns, so a list in any order over one\n * population shares a key, and one population never answers for another.\n *\n * @param inputs - The digested input population the patterns match against\n * @param patterns - The native glob patterns, in any order\n * @returns The memo key of the population and the pattern list\n *\n * @example\n * ```ts\n * const inputs = buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64) })\n * computeCaptureMatchKey(inputs, ['src/*.ts', 'src/*.md']) === computeCaptureMatchKey(inputs, ['src/*.md', 'src/*.ts']) // true\n * ```\n */\nexport function computeCaptureMatchKey(inputs: CaptureDigest, patterns: readonly string[]): string {\n\treturn JSON.stringify([inputs.digest, patterns.toSorted()])\n}\n\n/**\n * Filters an input population's paths that match any listed pattern.\n *\n * @remarks\n * Each path is matched with the `matchesGlob` function from `node:path`.\n *\n * @param inputs - The digested input population whose paths are matched\n * @param patterns - The native glob patterns\n * @returns The population's paths that match at least one pattern, in population order\n *\n * @example\n * ```ts\n * const inputs = buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64), 'src/b.md': 'e'.repeat(64) })\n * filterCaptureInputs(inputs, ['src/*.ts']) // Set { 'src/a.ts' }\n * ```\n */\nexport function filterCaptureInputs(\n\tinputs: CaptureDigest,\n\tpatterns: readonly string[],\n): ReadonlySet<string> {\n\treturn new Set(\n\t\tObject.keys(inputs.files).filter((path) =>\n\t\t\tpatterns.some((pattern) => matchesGlob(path, pattern)),\n\t\t),\n\t)\n}\n\n/**\n * Stores each distinct lookup input population once in a manifest-bound journal.\n *\n * @param lookups - The expanded passing case evidence to publish\n * @param collections - The independently authenticated collection receipts\n * @param manifest - The predecessor manifest digest, absent before the first capture\n * @returns The journal with content-addressed input maps and ordered lookup references\n *\n * @example\n * ```ts\n * buildCaptureLookupJournal([], []).populations // {}\n * ```\n */\nexport function buildCaptureLookupJournal(\n\tlookups: readonly CaptureLookup[],\n\tcollections: readonly CaptureCollectionReceipt[],\n\tmanifest?: string,\n): CaptureLookupJournal {\n\tconst memo = new Map<Readonly<Record<string, string>>, CaptureDigest>()\n\tconst references = lookups.map((lookup) => ({\n\t\t...lookup,\n\t\tinputs: computeCaptureTableKey(lookup.inputs, memo),\n\t}))\n\treturn {\n\t\tversion: CAPTURE_VERSION,\n\t\t...(manifest === undefined ? {} : { manifest }),\n\t\tpopulations: buildCaptureTable(memo),\n\t\tlookups: references,\n\t\tcollections,\n\t}\n}\n\n/**\n * Admits a decoded lookup journal, checking its declared version before its schema.\n *\n * @param value - The decoded journal file\n * @param file - The journal path each refusal names\n * @returns The journal, whose table digests `readCaptureLookups` verifies\n * @throws Thrown with the removal and the refresh commands when the journal declares another\n * protocol version, and thrown naming the file when its schema is invalid.\n *\n * @example\n * ```ts\n * readCaptureLookupJournal(JSON.parse(text), 'tmp/captures/states/lookups.json').lookups.length\n * ```\n */\nexport function readCaptureLookupJournal(value: unknown, file: string): CaptureLookupJournal {\n\trequireCaptureVersion(value, 'Lookup journal', file, [file])\n\tif (!isCaptureLookupJournal(value))\n\t\tthrow new CaptureError(`Invalid lookup journal schema: ${file}`, {\n\t\t\tcode: 'EVIDENCE',\n\t\t\tcontext: { file },\n\t\t})\n\treturn value\n}\n\n/**\n * Resolves journal lookup references after verifying each stored input population's digest.\n *\n * @param journal - A structurally validated lookup journal\n * @param file - The journal path each refusal names\n * @returns Every expanded lookup in its stored order, sharing the verified input maps\n * @throws Thrown when a population does not hash to its key or a lookup names an unknown key.\n *\n * @example\n * ```ts\n * readCaptureLookups(buildCaptureLookupJournal([], []), 'tmp/captures/states/lookups.json') // []\n * ```\n */\nexport function readCaptureLookups(\n\tjournal: CaptureLookupJournal,\n\tfile: string,\n): readonly CaptureLookup[] {\n\tconst subject = `Lookup journal at ${file}`\n\tconst populations = readCaptureTable(journal.populations, subject)\n\treturn journal.lookups.map((lookup) => ({\n\t\t...lookup,\n\t\tinputs: requireCaptureTableEntry(populations, lookup.inputs, subject, 'inputs'),\n\t}))\n}\n\n/**\n * Computes the table key of a file map, the digest from `buildCaptureDigest([], files)`, once per map.\n *\n * @remarks\n * The memo belongs to one document build: it holds each map by identity beside its ordered,\n * digested population, so equal maps from different objects share one key.\n *\n * @param files - The path-to-hash map a document stores once\n * @param memo - The build's memo from each map to its ordered, digested population\n * @returns The digest that names the map in the document's population table\n *\n * @example\n * ```ts\n * const memo = new Map()\n * computeCaptureTableKey({ 'src/a.ts': 'f'.repeat(64) }, memo).length // 64\n * ```\n */\nexport function computeCaptureTableKey(\n\tfiles: Readonly<Record<string, string>>,\n\tmemo: Map<Readonly<Record<string, string>>, CaptureDigest>,\n): string {\n\tconst known = memo.get(files)\n\tif (known !== undefined) return known.digest\n\tconst population = buildCaptureDigest([], files)\n\tmemo.set(files, population)\n\treturn population.digest\n}\n\n/**\n * Builds a document's population table from the memo its table keys were computed through.\n *\n * @param memo - The memo `computeCaptureTableKey` filled for one document build\n * @returns Each distinct ordered map under its digest, in the order the build first met it\n *\n * @example\n * ```ts\n * const memo = new Map()\n * const key = computeCaptureTableKey({ 'src/a.ts': 'f'.repeat(64) }, memo)\n * buildCaptureTable(memo)[key] // { 'src/a.ts': 'ffff…' }\n * ```\n */\nexport function buildCaptureTable(\n\tmemo: ReadonlyMap<Readonly<Record<string, string>>, CaptureDigest>,\n): Readonly<Record<string, Readonly<Record<string, string>>>> {\n\treturn Object.fromEntries(\n\t\t[...memo.values()].map((population) => [population.digest, population.files]),\n\t)\n}\n\n/**\n * Reads a document's population table after verifying that each map hashes to the key it is stored under.\n *\n * @param table - The stored table from each digest to its path-to-hash map\n * @param subject - The document and its path, which open the refusal message\n * @returns Each verified map by its digest\n * @throws Thrown when a stored map does not hash to its key.\n *\n * @example\n * ```ts\n * readCaptureTable({}, 'Manifest at tmp/captures/states/manifest.json').size // 0\n * ```\n */\nexport function readCaptureTable(\n\ttable: Readonly<Record<string, Readonly<Record<string, string>>>>,\n\tsubject: string,\n): ReadonlyMap<string, Readonly<Record<string, string>>> {\n\treturn new Map(\n\t\tObject.entries(table).map(([digest, files]) => {\n\t\t\tif (buildCaptureDigest([], files).digest !== digest)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`${subject} stores a population that does not hash to its key: ${digest}`,\n\t\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t\t)\n\t\t\treturn [digest, files] as const\n\t\t}),\n\t)\n}\n\n/**\n * Returns the verified map a table key names, refusing a key the table does not hold.\n *\n * @param table - The verified table `readCaptureTable` returns\n * @param key - The digest a stored member names\n * @param subject - The document and its path, which open the refusal message\n * @param field - The referencing field the refusal message names\n * @returns The file map stored under the key\n * @throws Thrown when the table holds no map under the key.\n *\n * @example\n * ```ts\n * requireCaptureTableEntry(new Map([[key, files]]), key, 'Manifest at manifest.json', 'inputs') === files // true\n * ```\n */\nexport function requireCaptureTableEntry(\n\ttable: ReadonlyMap<string, Readonly<Record<string, string>>>,\n\tkey: string,\n\tsubject: string,\n\tfield: string,\n): Readonly<Record<string, string>> {\n\tconst files = table.get(key)\n\tif (files === undefined)\n\t\tthrow new CaptureError(`${subject} names an unknown ${field} digest: ${key}`, {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\treturn files\n}\n\n/**\n * Stores each distinct file map of an expanded manifest once, in a table keyed by the map's digest.\n *\n * @param manifest - The expanded manifest the engine publishes\n * @returns The document whose stamps, lookups, and collections name their maps by table key\n *\n * @example\n * ```ts\n * const document = buildCaptureManifestDocument(manifest)\n * Object.keys(document.populations) // one digest per distinct shared or input map\n * ```\n */\nexport function buildCaptureManifestDocument(\n\tmanifest: CaptureExpandedManifest,\n): CaptureManifestDocument {\n\tconst memo = new Map<Readonly<Record<string, string>>, CaptureDigest>()\n\tconst entries = Object.fromEntries(\n\t\tObject.entries(manifest.entries).map(([key, stamp]) => [\n\t\t\tkey,\n\t\t\t{\n\t\t\t\t...stamp,\n\t\t\t\tshared: { ...stamp.shared, files: computeCaptureTableKey(stamp.shared.files, memo) },\n\t\t\t},\n\t\t]),\n\t)\n\tconst lookups = manifest.lookups.map((lookup) => ({\n\t\t...lookup,\n\t\tinputs: computeCaptureTableKey(lookup.inputs, memo),\n\t}))\n\tconst collections = manifest.collections?.map((receipt) => ({\n\t\t...receipt,\n\t\tinputs: { ...receipt.inputs, files: computeCaptureTableKey(receipt.inputs.files, memo) },\n\t}))\n\treturn {\n\t\tversion: manifest.version,\n\t\tpopulations: buildCaptureTable(memo),\n\t\tregistry: manifest.registry,\n\t\tentries,\n\t\tlookups,\n\t\t...(collections === undefined ? {} : { collections }),\n\t}\n}\n\n/**\n * Admits a stored manifest and expands every table reference into the file map it names.\n *\n * @param value - The decoded manifest file\n * @param file - The manifest path each refusal names\n * @returns The expanded manifest, whose references to one key share one verified map\n * @throws Thrown with the removal and the refresh commands when the document declares another\n * protocol version, and thrown when its schema is invalid, a table map does not hash to its key,\n * or a reference names no table key.\n *\n * @example\n * ```ts\n * const manifest = readCaptureManifest(JSON.parse(text), 'tmp/captures/states/manifest.json')\n * manifest.lookups[0]?.inputs // the expanded input map\n * ```\n */\nexport function readCaptureManifest(value: unknown, file: string): CaptureExpandedManifest {\n\trequireCaptureVersion(value, 'Manifest', file, [file, 'its lookup journal'])\n\tif (!isCaptureManifestDocument(value))\n\t\tthrow new CaptureError(`Invalid inherited manifest schema: ${file}`, { code: 'EVIDENCE' })\n\tconst subject = `Manifest at ${file}`\n\tconst table = readCaptureTable(value.populations, subject)\n\treturn {\n\t\tversion: value.version,\n\t\tregistry: value.registry,\n\t\tentries: Object.fromEntries(\n\t\t\tObject.entries(value.entries).map(([key, stamp]) => [\n\t\t\t\tkey,\n\t\t\t\t{\n\t\t\t\t\t...stamp,\n\t\t\t\t\tshared: {\n\t\t\t\t\t\t...stamp.shared,\n\t\t\t\t\t\tfiles: requireCaptureTableEntry(table, stamp.shared.files, subject, 'shared.files'),\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]),\n\t\t),\n\t\tlookups: value.lookups.map((lookup) => ({\n\t\t\t...lookup,\n\t\t\tinputs: requireCaptureTableEntry(table, lookup.inputs, subject, 'inputs'),\n\t\t})),\n\t\t...(value.collections === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tcollections: value.collections.map((receipt) => ({\n\t\t\t\t\t\t...receipt,\n\t\t\t\t\t\tinputs: {\n\t\t\t\t\t\t\t...receipt.inputs,\n\t\t\t\t\t\t\tfiles: requireCaptureTableEntry(table, receipt.inputs.files, subject, 'inputs.files'),\n\t\t\t\t\t\t},\n\t\t\t\t\t})),\n\t\t\t\t}),\n\t}\n}\n\n/**\n * Refuses a document that declares a numeric version other than `CAPTURE_VERSION`, naming what to remove and the refresh commands.\n *\n * @remarks\n * A document with no numeric version passes, so the schema check that follows names that fault.\n * No document of another version is converted.\n *\n * @param value - The decoded document\n * @param subject - The document kind that opens the refusal, such as `Registry`\n * @param file - The document path the refusal names\n * @param removal - The paths, or the phrases naming them, to remove before the refresh\n * @throws Thrown as an `EVIDENCE` capture error whose context carries `file` and `version` when the\n * document declares another numeric version.\n *\n * @example\n * ```ts\n * requireCaptureVersion({ version: 1 }, 'Registry', 'registry.json', ['registry.json'])\n * // throws: Registry version 1 at registry.json is not version 2, … Remove registry.json, then refresh explicitly with: capture registry, then capture frames all\n * ```\n */\nexport function requireCaptureVersion(\n\tvalue: unknown,\n\tsubject: string,\n\tfile: string,\n\tremoval: readonly string[],\n): void {\n\tconst version = isRecord(value) ? value.version : undefined\n\tif (typeof version === 'number' && version !== CAPTURE_VERSION)\n\t\tthrow new CaptureError(\n\t\t\t`${subject} version ${String(version)} at ${file} is not version ${String(CAPTURE_VERSION)}, and no other version is converted. Remove ${new Intl.ListFormat('en', { type: 'conjunction' }).format(removal)}, then refresh explicitly with: capture registry, then capture frames all`,\n\t\t\t{ code: 'EVIDENCE', context: { file, version } },\n\t\t)\n}\n\n/**\n * Checks whether an error is the refusal `requireCaptureVersion` throws for another document version.\n *\n * @remarks\n * A caller that adds its own recovery to a refusal passes this one through unchanged, because it\n * already names the removal and the refresh.\n *\n * @param error - The caught value\n * @returns True if it is an `EVIDENCE` capture error whose context carries a file and a numeric version; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureVersionRefusal(captureError(() => requireCaptureVersion({ version: 1 }, 'Registry', file, [file]))) // true\n * matchesCaptureVersionRefusal(new Error('Invalid')) // false\n * ```\n */\nexport function matchesCaptureVersionRefusal(error: unknown): boolean {\n\treturn (\n\t\tisCaptureError(error) &&\n\t\terror.code === 'EVIDENCE' &&\n\t\ttypeof error.context?.file === 'string' &&\n\t\ttypeof error.context.version === 'number'\n\t)\n}\n\n/**\n * Classifies a failure raised while reading the accepted registry as the registry condition.\n *\n * @remarks\n * The complete-registry refresh clears every such failure but a document of another version, whose\n * refusal names its own removal and refresh.\n *\n * @param error - The value a registry read threw\n * @returns A `REGISTRY` capture error with the same message and the original as its cause, for a\n * value that is not a capture error or is an `EVIDENCE` capture error other than a version refusal;\n * otherwise the value itself\n *\n * @example\n * ```ts\n * resolveCaptureRegistryFault(new CaptureError('Invalid accepted registry schema or digest', { code: 'EVIDENCE' })) // a REGISTRY capture error\n * resolveCaptureRegistryFault(new CaptureError('Unknown portfolio: x', { code: 'SELECTION' })) // the same error\n * ```\n */\nexport function resolveCaptureRegistryFault(error: unknown): unknown {\n\treturn isCaptureError(error) && (error.code !== 'EVIDENCE' || matchesCaptureVersionRefusal(error))\n\t\t? error\n\t\t: new CaptureError(describeCaptureError(error), { code: 'REGISTRY', cause: error })\n}\n\n/**\n * Collects the variants that produce each destination across the registry receipts and the lookup runs.\n *\n * @param evidence - The accepted registry and the authenticated lookup runs\n * @returns Each destination description mapped to its distinct producing variants, in first-seen order\n *\n * @example\n * ```ts\n * collectCaptureProducers({ registry, runs: [] }).get(describeCaptureDestination(destination)) // ['light-390']\n * ```\n */\nexport function collectCaptureProducers(\n\tevidence: Pick<CaptureEvidence, 'registry' | 'runs'>,\n): ReadonlyMap<string, readonly string[]> {\n\tconst sources = [...evidence.registry.receipts, ...evidence.runs.map((entry) => entry.run)]\n\tconst attributions = Map.groupBy(\n\t\tsources.flatMap((source) =>\n\t\t\tsource.registry.map((entry) => ({\n\t\t\t\tdescription: describeCaptureDestination(entry),\n\t\t\t\tvariant: source.variant,\n\t\t\t})),\n\t\t),\n\t\t(entry) => entry.description,\n\t)\n\treturn new Map(\n\t\t[...attributions].map(([description, entries]) => [\n\t\t\tdescription,\n\t\t\t[...new Set(entries.map((entry) => entry.variant))],\n\t\t]),\n\t)\n}\n\n/**\n * Returns the one variant that produces a destination, refusing a destination with none or several.\n *\n * @param destination - The destination whose producer is read\n * @param producers - The map `collectCaptureProducers` returns\n * @returns The destination's unique producing variant\n * @throws Thrown as an `EVIDENCE` capture error when no variant or more than one produces the destination.\n *\n * @example\n * ```ts\n * requireCaptureProducer(destination, collectCaptureProducers({ registry, runs: [] })) // 'light-390'\n * ```\n */\nexport function requireCaptureProducer(\n\tdestination: CaptureDestination,\n\tproducers: ReadonlyMap<string, readonly string[]>,\n): string {\n\tconst variants = producers.get(describeCaptureDestination(destination)) ?? []\n\tif (variants.length !== 1 || variants[0] === undefined)\n\t\tthrow new CaptureError('Destination has no unique producing variant', { code: 'EVIDENCE' })\n\treturn variants[0]\n}\n\n/**\n * Computes the registry identity from its authenticated receipts and exact output population.\n *\n * @param registry - The registry fields before its digest is attached\n * @returns The deterministic SHA-256 registry identity\n *\n * @example\n * ```ts\n * computeRegistryDigest({ version: 2, receipts: [], entries: [] }).length // 64\n * ```\n */\nexport function computeRegistryDigest(\n\tregistry: Pick<CaptureRegistry, 'version' | 'receipts' | 'entries'>,\n): string {\n\treturn computeCaptureHash(\n\t\tJSON.stringify([\n\t\t\tregistry.version,\n\t\t\tregistry.receipts\n\t\t\t\t.map((receipt) =>\n\t\t\t\t\tJSON.stringify([\n\t\t\t\t\t\treceipt.version,\n\t\t\t\t\t\treceipt.variant,\n\t\t\t\t\t\treceipt.time,\n\t\t\t\t\t\treceipt.complete,\n\t\t\t\t\t\treceipt.report.file,\n\t\t\t\t\t\treceipt.report.digest,\n\t\t\t\t\t\tObject.entries(receipt.inputs).toSorted(([left], [right]) =>\n\t\t\t\t\t\t\tleft.localeCompare(right, 'en'),\n\t\t\t\t\t\t),\n\t\t\t\t\t\treceipt.declarations.map(describeCaptureDeclaration).toSorted(),\n\t\t\t\t\t\treceipt.registry.map(describeCaptureDestination).toSorted(),\n\t\t\t\t\t]),\n\t\t\t\t)\n\t\t\t\t.toSorted(),\n\t\t\tregistry.entries.map(describeCaptureDestination).toSorted(),\n\t\t]),\n\t)\n}\n\n/**\n * Imports complete receipts only after their actual exits and exact report bytes validate.\n *\n * @param inputs - Verifier-owned reporter bytes, receipt declarations, and process outcomes\n * @returns The registry document to publish through the verifier's owned evidence path\n * @throws Thrown for caps, signals, unsuccessful exits, altered reports, or incomplete coverage.\n * @remarks This pure importer starts no process and changes no retained receipt or manifest.\n *\n * @example\n * ```ts\n * const registry = buildCaptureRegistry([{ receipt, report: text, outcome: { code: 0, signal: null }, capped: false }])\n * registry.digest.length // 64\n * ```\n */\nexport function buildCaptureRegistry(inputs: readonly CaptureReceiptInput[]): CaptureRegistry {\n\tif (inputs.length === 0)\n\t\tthrow new CaptureError('A registry requires complete-run receipts', { code: 'EVIDENCE' })\n\tfor (const input of inputs) {\n\t\tif (\n\t\t\tinput.capped ||\n\t\t\tinput.outcome.code !== 0 ||\n\t\t\tinput.outcome.signal !== null ||\n\t\t\t!isCaptureReceipt(input.receipt) ||\n\t\t\t!input.receipt.complete ||\n\t\t\tcomputeCaptureHash(input.report) !== input.receipt.report.digest\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Registry receipt requires an uncapped successful exit and unchanged report',\n\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t)\n\t\tvalidateCaptureReceipt(input.receipt, readCaptureReport(parseJSON(input.report)))\n\t}\n\tconst receipts = inputs.map((input) => input.receipt)\n\trequireCaptureUnique(\n\t\treceipts.map((receipt) => receipt.variant),\n\t\t'complete receipt variants',\n\t\ttrue,\n\t)\n\tconst entries = receipts.flatMap((receipt) => receipt.registry)\n\trequireCaptureUnique(entries.map(resolveCaptureKey), 'registry identities', true)\n\trequireCaptureUnique(\n\t\tentries.map((entry) => entry.file),\n\t\t'registry paths',\n\t\ttrue,\n\t)\n\tconst registry: Pick<CaptureRegistry, 'version' | 'receipts' | 'entries'> = {\n\t\tversion: CAPTURE_VERSION,\n\t\treceipts,\n\t\tentries,\n\t}\n\treturn { ...registry, digest: computeRegistryDigest(registry) }\n}\n\n/**\n * Checks whether bytes open with the eight-byte PNG signature.\n *\n * @param bytes - The leading bytes of a file\n * @returns True if the first eight bytes equal the signature; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureSignature(Uint8Array.from([137, 80, 78, 71, 13, 10, 26, 10])) // true\n * ```\n */\nexport function matchesCaptureSignature(bytes: Uint8Array): boolean {\n\treturn Buffer.from(CAPTURE_PNG_SIGNATURE).equals(bytes.subarray(0, CAPTURE_PNG_SIGNATURE.length))\n}\n\n/**\n * Computes the PNG Paeth predictor used by both image readers.\n *\n * @param left - The reconstructed left byte\n * @param up - The reconstructed byte above\n * @param corner - The reconstructed upper-left byte\n * @returns The closest neighbor to the linear estimate\n *\n * @example\n * ```ts\n * predictCaptureByte(10, 20, 10) // 20\n * ```\n */\nexport function predictCaptureByte(left: number, up: number, corner: number): number {\n\tconst estimate = left + up - corner\n\tconst west = Math.abs(estimate - left)\n\tconst north = Math.abs(estimate - up)\n\tconst diagonal = Math.abs(estimate - corner)\n\treturn west <= north && west <= diagonal ? left : north <= diagonal ? up : corner\n}\n\n/**\n * Reads PNG compressed-data chunks while refusing truncated or corrupt image bytes.\n *\n * @param bytes - The complete PNG\n * @param offset - The next chunk header. Default: 8.\n * @returns Ordered compressed-data chunks\n * @throws Thrown for bytes over the file budget; a truncated chunk, which a file with no closing\n * chunk also meets; a bad checksum; a closing chunk that is not empty and last; an IHDR chunk\n * anywhere but offset 8; a critical chunk other than IHDR, PLTE, IDAT, and IEND; or IDAT chunks\n * that are not consecutive.\n *\n * @example\n * ```ts\n * readCaptureChunks(encodeCapturePicture(picture)).length // 1\n * ```\n */\nexport function readCaptureChunks(bytes: Buffer, offset = 8): readonly Buffer[] {\n\trequireCaptureImageSize(bytes.length)\n\tconst positions = scanCaptureChunks(bytes, offset, Infinity)\n\t// Each type is read once as a big-endian word; a refusal alone renders it as text.\n\tconst types = positions.map((position) => bytes.readUInt32BE(position + 4))\n\tconst header = Buffer.from('IHDR', 'latin1').readUInt32BE(0)\n\tconst palette = Buffer.from('PLTE', 'latin1').readUInt32BE(0)\n\tconst data = Buffer.from('IDAT', 'latin1').readUInt32BE(0)\n\tconst end = Buffer.from('IEND', 'latin1').readUInt32BE(0)\n\tconst last = positions.at(-1)\n\t// The walk ends at the closing chunk or refuses, so this guard narrows `last` and never throws.\n\tif (last === undefined || types.at(-1) !== end)\n\t\tthrow new CaptureError(\n\t\t\t`Missing capture PNG closing chunk: ${last === undefined ? `no chunk follows offset ${preview(offset)}` : `the last chunk is ${preview(bytes.toString('latin1', last + 4, last + 8))} at offset ${String(last)}`}; expected an empty IEND chunk that ends the file`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst first = types.indexOf(data)\n\tconst final = types.lastIndexOf(data)\n\tconst placed = positions.find((position, index) => types[index] === header && position !== 8)\n\tif (placed !== undefined)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid capture PNG chunk order: ${describeCaptureChunk(bytes, placed)}; expected one IHDR chunk, at offset 8`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\t// Bit 5 of a type's first byte is clear for a critical chunk.\n\tconst unknown = positions.find(\n\t\t(position, index) =>\n\t\t\t((bytes[position + 4] ?? 0) & 32) === 0 &&\n\t\t\t![header, palette, data, end].includes(types[index] ?? 0),\n\t)\n\tif (unknown !== undefined)\n\t\tthrow new CaptureError(\n\t\t\t`Unsupported capture PNG chunk: critical ${describeCaptureChunk(bytes, unknown)}; expected a critical chunk to be IHDR, PLTE, IDAT, or IEND`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst gap = types.findIndex((type, index) => index > first && index < final && type !== data)\n\tconst resume = gap === -1 ? -1 : types.indexOf(data, gap)\n\tconst resumed = positions[resume]\n\tconst before = positions[resume - 1]\n\tif (resumed !== undefined && before !== undefined)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid capture PNG chunk order: ${describeCaptureChunk(bytes, resumed)} follows ${preview(bytes.toString('latin1', before + 4, before + 8))} at offset ${String(before)}; expected every IDAT chunk in one consecutive run`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\treturn positions.flatMap((position, index) => {\n\t\tconst length = bytes.readUInt32BE(position)\n\t\treturn types[index] === data && length > 0\n\t\t\t? [bytes.subarray(position + 8, position + 8 + length)]\n\t\t\t: []\n\t})\n}\n\n/**\n * Walks a PNG's checked chunks from one header and returns each header's offset, up to the closing chunk.\n *\n * @remarks\n * The walk reads at most `count` chunks, and never more than the bytes can hold, so an infinite or\n * very large count ends at the closing chunk or at a refusal. Each level halves the count, so the\n * call depth grows with the logarithm of the chunks the bytes can hold.\n *\n * @param bytes - The complete PNG\n * @param position - The offset of the first chunk header to read\n * @param count - The most chunks to read\n * @returns The offset of each chunk header read, in order\n * @throws Thrown for a truncated chunk, a bad checksum, or a closing chunk that is not empty and last.\n *\n * @example\n * ```ts\n * scanCaptureChunks(encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) }), 8, Infinity) // [8, 33, 57]\n * ```\n */\nexport function scanCaptureChunks(\n\tbytes: Buffer,\n\tposition: number,\n\tcount: number,\n): readonly number[] {\n\t// A chunk spans at least 12 bytes, so the bytes hold fewer chunks than this.\n\tconst limit = Math.min(count, Math.floor(bytes.length / 12) + 1)\n\tif (limit >= 2) {\n\t\tconst half = Math.ceil(limit / 2)\n\t\tconst head = scanCaptureChunks(bytes, position, half)\n\t\tconst last = head.at(-1)\n\t\tif (last === undefined || bytes.toString('latin1', last + 4, last + 8) === 'IEND') return head\n\t\treturn [\n\t\t\t...head,\n\t\t\t...scanCaptureChunks(bytes, last + 12 + bytes.readUInt32BE(last), limit - half),\n\t\t]\n\t}\n\tif (!(limit >= 1)) return []\n\tif (!Number.isSafeInteger(position) || position < 8 || position + 12 > bytes.length)\n\t\tthrow new CaptureError(\n\t\t\t`Truncated capture PNG: no 12-byte chunk frame fits at offset ${preview(position)} in ${String(bytes.length)} bytes; expected a whole offset from 8 with 12 bytes after it`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst end = position + 12 + bytes.readUInt32BE(position)\n\tif (end > bytes.length)\n\t\tthrow new CaptureError(\n\t\t\t`Truncated capture PNG chunk: ${describeCaptureChunk(bytes, position)} ends at byte ${String(end)}; expected it to end within the file's ${String(bytes.length)} bytes`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst stored = bytes.readUInt32BE(end - 4)\n\tconst computed = crc32(bytes.subarray(position + 4, end - 4)) >>> 0\n\tif (computed !== stored)\n\t\tthrow new CaptureError(\n\t\t\t`Capture PNG checksum differs: ${describeCaptureChunk(bytes, position)} stores ${stored.toString(16).padStart(8, '0')}; expected ${computed.toString(16).padStart(8, '0')}`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tif (\n\t\tbytes.toString('latin1', position + 4, position + 8) === 'IEND' &&\n\t\t(end !== position + 12 || end !== bytes.length)\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid capture PNG closing chunk: ${describeCaptureChunk(bytes, position)} ends at byte ${String(end)} of ${String(bytes.length)}; expected an empty IEND chunk that ends the file`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\treturn [position]\n}\n\n/**\n * Describes the PNG chunk whose header sits at an offset by its type, offset, and length.\n *\n * @remarks The type is untrusted file bytes, so it is JSON-encoded and length-capped.\n *\n * @param bytes - The complete PNG\n * @param position - The offset of the chunk header, with its 8 header bytes inside `bytes`\n * @returns The chunk's description for a refusal\n *\n * @example\n * ```ts\n * describeCaptureChunk(encodeCapturePicture(picture), 8) // '\"IHDR\" at offset 8 with length 13'\n * ```\n */\nexport function describeCaptureChunk(bytes: Buffer, position: number): string {\n\treturn `${preview(bytes.toString('latin1', position + 4, position + 8))} at offset ${String(position)} with length ${String(bytes.readUInt32BE(position))}`\n}\n\n/**\n * Reads an image only after its opened file's size is inside the compressed-byte budget.\n * @throws Thrown when the file is oversized, unreadable, or changes size during the read.\n * @example\n * ```ts\n * const bytes = readCaptureImage('/workspace/tmp/captures/mail.png')\n * ```\n */\nexport function readCaptureImage(file: string): Buffer {\n\tconst descriptor = openSync(file, 'r')\n\ttry {\n\t\tconst size = fstatSync(descriptor).size\n\t\trequireCaptureImageSize(size)\n\t\tconst bytes = Buffer.alloc(size)\n\t\tif (\n\t\t\treadSync(descriptor, bytes, 0, size, 0) !== size ||\n\t\t\treadSync(descriptor, Buffer.alloc(1), 0, 1, size) !== 0\n\t\t)\n\t\t\tthrow new CaptureError('Capture PNG read is incomplete or its size changed', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\treturn bytes\n\t} finally {\n\t\tcloseSync(descriptor)\n\t}\n}\n\n/**\n * Refuses compressed image bytes before file reads or chunk-buffer allocation.\n * @example\n * ```ts\n * requireCaptureImageSize(4096) // undefined\n * ```\n */\nexport function requireCaptureImageSize(size: number): void {\n\tif (!Number.isSafeInteger(size) || size < 0 || size > CAPTURE_PNG_LIMITS.bytes)\n\t\tthrow new CaptureError(\n\t\t\t`Capture PNG size is outside the file budget: ${preview(size)} bytes; expected a whole number of bytes from 0 to ${String(CAPTURE_PNG_LIMITS.bytes)}`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n}\n\n/**\n * Reconstructs one filtered PNG scanline from its filter byte and the row above.\n *\n * @param filter - The scanline's filter type, from 0 through 4\n * @param line - The filtered bytes of the row, without the filter byte\n * @param above - The reconstructed row above, or `undefined` for the first row\n * @param channels - The number of bytes in one pixel\n * @returns The reconstructed row\n *\n * @example\n * ```ts\n * unfilterCaptureRow(1, Uint8Array.from([1, 1, 1, 1]), undefined, 1) // Uint8Array [1, 2, 3, 4]\n * ```\n */\nexport function unfilterCaptureRow(\n\tfilter: number,\n\tline: Uint8Array,\n\tabove: Uint8Array | undefined,\n\tchannels: number,\n): Uint8Array {\n\t// Each byte reads reconstructed bytes before it, so the row is written once per index, in order.\n\t// The filter is chosen once per row; any other filter value predicts 0 and copies the line.\n\tconst bytes = new Uint8Array(line.length)\n\tif (filter === 1)\n\t\tfor (const index of line.keys())\n\t\t\tbytes[index] =\n\t\t\t\t((line[index] ?? 0) + (index >= channels ? (bytes[index - channels] ?? 0) : 0)) & 255\n\telse if (filter === 2)\n\t\tfor (const index of line.keys())\n\t\t\tbytes[index] = ((line[index] ?? 0) + (above?.[index] ?? 0)) & 255\n\telse if (filter === 3)\n\t\tfor (const index of line.keys())\n\t\t\tbytes[index] =\n\t\t\t\t((line[index] ?? 0) +\n\t\t\t\t\t(((index >= channels ? (bytes[index - channels] ?? 0) : 0) + (above?.[index] ?? 0)) >>\n\t\t\t\t\t\t1)) &\n\t\t\t\t255\n\telse if (filter === 4)\n\t\tfor (const index of line.keys())\n\t\t\tbytes[index] =\n\t\t\t\t((line[index] ?? 0) +\n\t\t\t\t\tpredictCaptureByte(\n\t\t\t\t\t\tindex >= channels ? (bytes[index - channels] ?? 0) : 0,\n\t\t\t\t\t\tabove?.[index] ?? 0,\n\t\t\t\t\t\tindex >= channels ? (above?.[index - channels] ?? 0) : 0,\n\t\t\t\t\t)) &\n\t\t\t\t255\n\telse bytes.set(line)\n\treturn bytes\n}\n\n/**\n * Inflates a PNG's compressed stream, refusing one that is corrupt or longer than declared.\n *\n * @param data - The concatenated data-chunk payloads\n * @param length - The inflated length the header's dimensions declare, a whole number from 1 to\n * `Number.MAX_SAFE_INTEGER`; any other value gives an unspecified result that might throw\n * @returns The inflated scanlines\n * @throws Thrown when the stream is not valid deflate data or inflates past `length`.\n *\n * @example\n * ```ts\n * inflateCaptureStream(deflateSync(Buffer.from([1, 2, 3])), 3) // Buffer <01 02 03>\n * ```\n */\nexport function inflateCaptureStream(data: Buffer, length: number): Buffer {\n\ttry {\n\t\treturn inflateSync(data, { maxOutputLength: length })\n\t} catch (error) {\n\t\tthrow new CaptureError(\n\t\t\t`Capture PNG stream is corrupt or longer than declared: ${preview(isError(error) ? error.message : error)} in ${String(data.length)} compressed bytes; expected a zlib stream that inflates to at most ${preview(length)} bytes`,\n\t\t\t{ code: 'EVIDENCE', cause: error },\n\t\t)\n\t}\n}\n\n/**\n * Decodes the eight-bit, non-interlaced PNGs the capture readers consume.\n *\n * @remarks\n * It reads grayscale, grayscale with alpha, RGB, and RGBA, the colour types an encoder writes for a\n * browser capture. A grayscale sample fills all three channels, and an alpha channel is dropped.\n * Indexed colour, other bit depths, and interlacing are refused.\n *\n * @param bytes - The exact physical image bytes\n * @returns Image dimensions and RGB pixels\n * @throws Thrown for unsupported, malformed, or truncated images.\n *\n * @example\n * ```ts\n * decodeCapturePicture(encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) })).pixels // Uint8Array [1, 2, 3]\n * ```\n */\nexport function decodeCapturePicture(bytes: Buffer): CapturePicture {\n\trequireCaptureImageSize(bytes.length)\n\tif (\n\t\tbytes.length < 33 ||\n\t\t!matchesCaptureSignature(bytes) ||\n\t\tbytes.toString('latin1', 12, 16) !== 'IHDR' ||\n\t\tbytes.readUInt32BE(8) !== 13\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid capture PNG header: ${\n\t\t\t\tbytes.length < 33\n\t\t\t\t\t? `the file is ${String(bytes.length)} bytes`\n\t\t\t\t\t: !matchesCaptureSignature(bytes)\n\t\t\t\t\t\t? `the signature is ${bytes.toString('hex', 0, 8)}`\n\t\t\t\t\t\t: `the first chunk is ${preview(bytes.toString('latin1', 12, 16))} with length ${String(bytes.readUInt32BE(8))}`\n\t\t\t}; expected at least 33 bytes that open with the signature ${Buffer.from(CAPTURE_PNG_SIGNATURE).toString('hex')} and an IHDR chunk with length 13`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\t// The header's checksum is checked before any of its fields is judged.\n\tscanCaptureChunks(bytes, 8, 1)\n\tconst width = bytes.readUInt32BE(16)\n\tconst height = bytes.readUInt32BE(20)\n\tconst channels =\n\t\tbytes[25] === 6 ? 4 : bytes[25] === 2 ? 3 : bytes[25] === 4 ? 2 : bytes[25] === 0 ? 1 : 0\n\tconst gray = bytes[25] === 0 || bytes[25] === 4\n\tif (channels === 0 || bytes[24] !== 8 || bytes[26] !== 0 || bytes[27] !== 0 || bytes[28] !== 0)\n\t\tthrow new CaptureError(\n\t\t\t`Unsupported capture PNG encoding: bit depth ${String(bytes[24])}, colour type ${String(bytes[25])}, compression ${String(bytes[26])}, filter ${String(bytes[27])}, interlace ${String(bytes[28])}; expected bit depth 8, colour type 0, 2, 4, or 6, compression 0, filter 0, and interlace 0`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst size = `${String(width)} × ${String(height)}`\n\tif (width === 0 || height === 0)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid capture PNG dimensions: ${size}; expected a width and a height of at least 1`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst stride = width * channels\n\tconst length = (stride + 1) * height\n\tif (!Number.isSafeInteger(length))\n\t\tthrow new CaptureError(\n\t\t\t`Invalid capture PNG dimensions: ${size} at ${String(channels)} bytes per pixel; expected scanlines of at most ${String(Number.MAX_SAFE_INTEGER)} bytes in all`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tif (width * height > CAPTURE_PNG_LIMITS.pixels)\n\t\tthrow new CaptureError(\n\t\t\t`Capture PNG exceeds the pixel budget: ${size} is ${String(width * height)} pixels; expected at most ${String(CAPTURE_PNG_LIMITS.pixels)} pixels`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tif (width > CAPTURE_PNG_LIMITS.side || height > CAPTURE_PNG_LIMITS.side)\n\t\tthrow new CaptureError(\n\t\t\t`Capture PNG exceeds the dimension budget: ${size}; expected at most ${String(CAPTURE_PNG_LIMITS.side)} pixels per side`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\tconst chunks = readCaptureChunks(bytes)\n\tconst raw = inflateCaptureStream(\n\t\tchunks.length === 1 && chunks[0] !== undefined ? chunks[0] : Buffer.concat(chunks),\n\t\tlength,\n\t)\n\tif (raw.length !== length)\n\t\tthrow new CaptureError(\n\t\t\t`Capture PNG scanline length differs: the stream inflates to ${String(raw.length)} bytes; expected ${String(length)} bytes for ${size} at ${String(channels)} bytes per pixel and one filter byte per row`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\t// Each row is written once, in order, and an unfiltered row reads the reconstructed slice above it.\n\tconst rows = new Uint8Array(stride * height)\n\tfor (const row of new Array(height).keys()) {\n\t\tconst filter = raw[row * (stride + 1)]\n\t\tif (filter === undefined || filter > 4)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unsupported capture PNG filter: type ${String(filter)} on row ${String(row)}; expected a type from 0 to 4`,\n\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t)\n\t\tconst line = raw.subarray(row * (stride + 1) + 1, (row + 1) * (stride + 1))\n\t\trows.set(\n\t\t\tfilter === 0\n\t\t\t\t? line\n\t\t\t\t: unfilterCaptureRow(\n\t\t\t\t\t\tfilter,\n\t\t\t\t\t\tline,\n\t\t\t\t\t\trow === 0 ? undefined : rows.subarray((row - 1) * stride, row * stride),\n\t\t\t\t\t\tchannels,\n\t\t\t\t\t),\n\t\t\trow * stride,\n\t\t)\n\t}\n\tif (channels === 3) return { width, height, pixels: rows }\n\tconst pixels = new Uint8Array(width * height * 3)\n\tconst columns = Array.from({ length: width }, (_, column) => column)\n\tfor (const row of new Array(height).keys()) {\n\t\tfor (const column of columns) {\n\t\t\tconst source = (row * width + column) * channels\n\t\t\tconst target = (row * width + column) * 3\n\t\t\tpixels[target] = rows[source] ?? 0\n\t\t\tpixels[target + 1] = rows[source + (gray ? 0 : 1)] ?? 0\n\t\t\tpixels[target + 2] = rows[source + (gray ? 0 : 2)] ?? 0\n\t\t}\n\t}\n\treturn { width, height, pixels }\n}\n\n/**\n * Encodes an unsigned 32-bit integer as four big-endian bytes.\n *\n * @param value - An integer from 0 through 4294967295\n * @returns The four bytes, most significant first\n *\n * @example\n * ```ts\n * encodeCaptureWord(258) // Buffer <00 00 01 02>\n * ```\n */\nexport function encodeCaptureWord(value: number): Buffer {\n\treturn Buffer.from([24, 16, 8, 0].map((shift) => (value >>> shift) & 255))\n}\n\n/**\n * Encodes one checked PNG chunk for contact-sheet output.\n *\n * @param name - The four-byte chunk name\n * @param data - The chunk payload\n * @returns Header, payload, and checksum bytes\n *\n * @example\n * ```ts\n * encodeCaptureChunk('IEND', Buffer.alloc(0)).length // 12\n * ```\n */\nexport function encodeCaptureChunk(name: string, data: Buffer): Buffer {\n\tconst header = Buffer.concat([encodeCaptureWord(data.length), Buffer.from(name, 'latin1')])\n\tconst tail = encodeCaptureWord(crc32(Buffer.concat([header.subarray(4), data])) >>> 0)\n\treturn Buffer.concat([header, data, tail])\n}\n\n/**\n * Encodes an RGB picture using the contact-sheet writer's native PNG format.\n *\n * @param picture - The complete RGB pixel buffer\n * @param compressed - If `true`, compresses scanlines; if `false`, stores them in the deflate stream. Default: `true`.\n * @returns A PNG file\n * @throws Thrown when a dimension is not a whole number of at least 1, or when the pixel length is\n * not `width * height * 3`.\n *\n * @example\n * ```ts\n * encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) }).subarray(1, 4).toString() // 'PNG'\n * ```\n */\nexport function encodeCapturePicture(picture: CapturePicture, compressed = true): Buffer {\n\tif (\n\t\t!Number.isSafeInteger(picture.width) ||\n\t\t!Number.isSafeInteger(picture.height) ||\n\t\tpicture.width <= 0 ||\n\t\tpicture.height <= 0 ||\n\t\tpicture.pixels.length !== picture.width * picture.height * 3\n\t)\n\t\tthrow new CaptureError('Invalid capture picture dimensions', { code: 'EVIDENCE' })\n\tconst stride = picture.width * 3\n\tconst raw = Buffer.concat(\n\t\tArray.from({ length: picture.height }, (_, row) =>\n\t\t\tBuffer.concat([Buffer.from([0]), picture.pixels.subarray(row * stride, (row + 1) * stride)]),\n\t\t),\n\t)\n\treturn Buffer.concat([\n\t\tBuffer.from(CAPTURE_PNG_SIGNATURE),\n\t\tencodeCaptureChunk(\n\t\t\t'IHDR',\n\t\t\tBuffer.concat([\n\t\t\t\tencodeCaptureWord(picture.width),\n\t\t\t\tencodeCaptureWord(picture.height),\n\t\t\t\tBuffer.from([8, 2, 0, 0, 0]),\n\t\t\t]),\n\t\t),\n\t\tencodeCaptureChunk('IDAT', deflateSync(raw, { level: compressed ? 6 : 0 })),\n\t\tencodeCaptureChunk('IEND', Buffer.alloc(0)),\n\t])\n}\n\n/**\n * Sums a run of samples three bytes apart, one channel of consecutive RGB pixels.\n *\n * @remarks\n * The caller bounds the run: the call reads one sample per column, inside the bytes or not, so a\n * count that is not above 0 sums nothing and a fractional count reads its ceiling. Each sample reads\n * `pixels[index] ?? 0` at the index the call computes, so an index outside the bytes, a fractional\n * index, or a `NaN` index reads 0. For whole-number arguments, the sum equals the direct sum of\n * those samples where every number the call computes from its arguments is a safe integer, each\n * sample index among them.\n *\n * @param pixels - The source RGB bytes\n * @param start - The index of the first sample\n * @param columns - The number of samples to sum\n * @returns The sum, reading an index outside the bytes or a fractional index as 0\n * @throws Thrown as an `EVIDENCE` capture error when `columns` is `Infinity`.\n *\n * @example\n * ```ts\n * sumCaptureRow(Uint8Array.from([1, 0, 0, 2, 0, 0, 3]), 0, 3) // 6\n * ```\n */\nexport function sumCaptureRow(pixels: Uint8Array, start: number, columns: number): number {\n\t// Halving keeps the recursion depth logarithmic in the run; a leaf reads up to eight samples.\n\tif (columns > 8) {\n\t\tif (columns === Infinity)\n\t\t\tthrow new CaptureError('Capture sum columns must be a finite sample count, not Infinity', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst half = Math.ceil(columns / 2)\n\t\treturn (\n\t\t\tsumCaptureRow(pixels, start, half) + sumCaptureRow(pixels, start + half * 3, columns - half)\n\t\t)\n\t}\n\treturn (\n\t\t(columns > 0 ? (pixels[start] ?? 0) : 0) +\n\t\t(columns > 1 ? (pixels[start + 3] ?? 0) : 0) +\n\t\t(columns > 2 ? (pixels[start + 6] ?? 0) : 0) +\n\t\t(columns > 3 ? (pixels[start + 9] ?? 0) : 0) +\n\t\t(columns > 4 ? (pixels[start + 12] ?? 0) : 0) +\n\t\t(columns > 5 ? (pixels[start + 15] ?? 0) : 0) +\n\t\t(columns > 6 ? (pixels[start + 18] ?? 0) : 0) +\n\t\t(columns > 7 ? (pixels[start + 21] ?? 0) : 0)\n\t)\n}\n\n/**\n * Sums one channel of a picture over a block of source rows.\n *\n * @remarks\n * Source row `top + row` starts its block at `(top + row) * picture.width * 3 + left`, and each row\n * contributes `columns` samples through `sumCaptureRow`. The caller bounds the block: the call reads\n * `rows × columns` samples, inside the bytes or not, so a row count that is not above 0 sums nothing\n * and a fractional row count reads its ceiling. For whole-number arguments, the sum equals the\n * direct sum of those samples where every number the call computes from its arguments is a safe\n * integer, each row number, each intermediate sum and product of a row start, and each sample index\n * among them.\n *\n * @param picture - The source RGB picture\n * @param top - The block's first source row\n * @param left - The byte offset of the block's first sample inside a row, its channel included\n * @param row - The first row to sum, counted from `top`\n * @param rows - The number of rows to sum\n * @param columns - The number of samples to sum in each row\n * @returns The block's sum\n * @throws Thrown as an `EVIDENCE` capture error when `rows` is `Infinity`, or when `columns` is\n * `Infinity` and the block reads a row.\n *\n * @example\n * ```ts\n * sumCaptureBlock({ width: 2, height: 2, pixels: Uint8Array.from([1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0]) }, 0, 0, 0, 2, 2) // 10\n * ```\n */\nexport function sumCaptureBlock(\n\tpicture: CapturePicture,\n\ttop: number,\n\tleft: number,\n\trow: number,\n\trows: number,\n\tcolumns: number,\n): number {\n\tif (rows > 2) {\n\t\tif (rows === Infinity)\n\t\t\tthrow new CaptureError('Capture sum rows must be a finite row count, not Infinity', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst half = Math.ceil(rows / 2)\n\t\treturn (\n\t\t\tsumCaptureBlock(picture, top, left, row, half, columns) +\n\t\t\tsumCaptureBlock(picture, top, left, row + half, rows - half, columns)\n\t\t)\n\t}\n\treturn (\n\t\t(rows > 0\n\t\t\t? sumCaptureRow(picture.pixels, (top + row) * picture.width * 3 + left, columns)\n\t\t\t: 0) +\n\t\t(rows > 1\n\t\t\t? sumCaptureRow(picture.pixels, (top + (row + 1)) * picture.width * 3 + left, columns)\n\t\t\t: 0)\n\t)\n}\n\n/**\n * Scales a picture with an exact area average and clips its displayed height.\n *\n * @param picture - The source RGB picture\n * @param factor - The reduction factor, a whole number of at least 1; any other value gives an\n * unspecified result that might throw\n * @param limit - The maximum displayed height, a whole number of at least 1; any other value gives\n * an unspecified result that might throw\n * @returns A separately owned scaled picture\n *\n * @example\n * ```ts\n * shrinkCapturePicture({ width: 2, height: 2, pixels: new Uint8Array(12) }, 2, 8).width // 1\n * ```\n */\nexport function shrinkCapturePicture(\n\tpicture: CapturePicture,\n\tfactor: number,\n\tlimit: number,\n): CapturePicture {\n\tconst width = Math.max(1, Math.ceil(picture.width / factor))\n\tconst height = Math.min(Math.max(1, Math.ceil(picture.height / factor)), limit)\n\t// A block reaches at most this many rows and columns; `Array.from` applies the array-length rule.\n\tconst reach = Array.from({\n\t\tlength: Math.ceil(Math.min(factor, Math.max(picture.width, picture.height))),\n\t}).length\n\t// A clipped height can be fractional or negative, so the length follows the array-length rule.\n\tconst pixels = new Uint8Array(\n\t\tMath.min(Math.max(Math.trunc(width * height * 3) || 0, 0), Number.MAX_SAFE_INTEGER),\n\t)\n\tconst offsets = Array.from({ length: Math.min(width * 3, pixels.length) }, (_, offset) => offset)\n\t// Each output row is written once per byte, in order; a partial last row stops at the length.\n\tconst lines = pixels.length === 0 ? 0 : Math.ceil(pixels.length / (width * 3))\n\tfor (const y of new Array(lines).keys()) {\n\t\tconst rows = Math.min(factor, picture.height - y * factor)\n\t\tfor (const offset of offsets) {\n\t\t\tconst index = y * width * 3 + offset\n\t\t\tif (index >= pixels.length) break\n\t\t\tconst x = Math.floor(offset / 3)\n\t\t\tconst columns = Math.min(factor, picture.width - x * factor)\n\t\t\tpixels[index] = Math.round(\n\t\t\t\tsumCaptureBlock(\n\t\t\t\t\tpicture,\n\t\t\t\t\ty * factor,\n\t\t\t\t\tx * Math.ceil(factor) * 3 + (offset % 3),\n\t\t\t\t\t0,\n\t\t\t\t\trows > 0 ? Math.min(reach, Math.ceil(rows)) : 0,\n\t\t\t\t\tcolumns > 0 ? Math.min(reach, Math.ceil(columns)) : 0,\n\t\t\t\t) /\n\t\t\t\t\t(rows * columns),\n\t\t\t)\n\t\t}\n\t}\n\treturn { width, height, pixels }\n}\n\n/**\n * Composes pictures on the contact-sheet gray background.\n *\n * @param pictures - The ordered source cells or rows\n * @param vertical - If `true`, stacks rows; if `false`, places cells side by side\n * @param gap - The space between source pictures. Default: 6.\n * @returns A separately owned composite\n * @throws Thrown for an empty picture selection, with the `USAGE` condition.\n * @throws Thrown with the `EVIDENCE` condition when a width, a height, or the gap is not a whole\n * number from 0 to `CAPTURE_PNG_LIMITS.side`, or when the composite exceeds that side or the\n * `CAPTURE_PNG_LIMITS.pixels` budget.\n *\n * @example\n * ```ts\n * composeCapturePictures([picture, picture], false).width // picture.width * 2 + 6\n * ```\n */\nexport function composeCapturePictures(\n\tpictures: readonly CapturePicture[],\n\tvertical: boolean,\n\tgap = 6,\n): CapturePicture {\n\tif (pictures.length === 0)\n\t\tthrow new CaptureError('Empty contact-sheet picture selection', { code: 'USAGE' })\n\tconst { side, pixels: budget } = CAPTURE_PNG_LIMITS\n\tconst faults = [\n\t\t...pictures.flatMap((picture, position) =>\n\t\t\t(['width', 'height'] as const).flatMap((axis) =>\n\t\t\t\tNumber.isSafeInteger(picture[axis]) && picture[axis] >= 0 && picture[axis] <= side\n\t\t\t\t\t? []\n\t\t\t\t\t: [`pictures[${String(position)}].${axis} is ${preview(picture[axis])}`],\n\t\t\t),\n\t\t),\n\t\t...(Number.isSafeInteger(gap) && gap >= 0 && gap <= side ? [] : [`gap is ${preview(gap)}`]),\n\t]\n\tconst { width, height } = computeCaptureComposite(pictures, vertical, gap)\n\tif (faults.length > 0 || !matchesCaptureLimits({ width, height }))\n\t\tthrow new CaptureError(\n\t\t\t`Contact-sheet geometry is out of range: ${\n\t\t\t\tfaults.length === 0\n\t\t\t\t\t? `composite is ${String(width)} × ${String(height)}`\n\t\t\t\t\t: [\n\t\t\t\t\t\t\t...faults.slice(0, CAPTURE_REFUSAL_LIMIT),\n\t\t\t\t\t\t\t...(faults.length > CAPTURE_REFUSAL_LIMIT\n\t\t\t\t\t\t\t\t? [`… ${String(faults.length - CAPTURE_REFUSAL_LIMIT)} more`]\n\t\t\t\t\t\t\t\t: []),\n\t\t\t\t\t\t].join('; ')\n\t\t\t}; expected whole numbers from 0 to ${String(side)} for every width, height, and gap, and a composite of at most ${String(side)} per side and ${String(budget)} pixels`,\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n\t// Each picture's span runs from the end before it to its own: the picture's row, then gray gap.\n\tconst ends: number[] = []\n\tfor (const picture of pictures)\n\t\tends.push((ends.at(-1) ?? 0) + (vertical ? picture.height : picture.width) + gap)\n\t// An empty span writes nothing, so dropping it bounds the row loop by the composite's width.\n\tconst spans = pictures\n\t\t.map((picture, position) => ({\n\t\t\tpicture,\n\t\t\tstart: ends[position - 1] ?? 0,\n\t\t\tend: Math.min(ends[position] ?? 0, vertical ? height : width),\n\t\t}))\n\t\t.filter((span) => span.end > span.start)\n\t// Spans are written once each, in index order.\n\tconst pixels = new Uint8Array(width * height * 3)\n\tif (vertical) {\n\t\tfor (const { picture, start, end } of spans) {\n\t\t\tfor (const row of new Array(Math.max(0, end - start)).keys()) {\n\t\t\t\tconst copied = row < picture.height ? picture.width : 0\n\t\t\t\tconst target = (start + row) * width * 3\n\t\t\t\tpixels.set(\n\t\t\t\t\tpicture.pixels.subarray(row * picture.width * 3, (row * picture.width + copied) * 3),\n\t\t\t\t\ttarget,\n\t\t\t\t)\n\t\t\t\tpixels.fill(128, target + copied * 3, target + width * 3)\n\t\t\t}\n\t\t}\n\t\treturn { width, height, pixels }\n\t}\n\tfor (const row of new Array(height).keys()) {\n\t\tfor (const { picture, start, end } of spans) {\n\t\t\tconst copied = row < picture.height ? Math.min(picture.width, end - start) : 0\n\t\t\tconst target = (row * width + start) * 3\n\t\t\tpixels.set(\n\t\t\t\tpicture.pixels.subarray(row * picture.width * 3, (row * picture.width + copied) * 3),\n\t\t\t\ttarget,\n\t\t\t)\n\t\t\tpixels.fill(128, target + copied * 3, (row * width + end) * 3)\n\t\t}\n\t}\n\treturn { width, height, pixels }\n}\n\n/**\n * Computes the width and height of the composite that `composeCapturePictures` builds from\n * pictures of these sizes.\n *\n * @param pictures - The ordered source sizes\n * @param vertical - If `true`, stacks them; if `false`, places them side by side\n * @param gap - The space between source pictures. Default: 6.\n * @returns The composite's width and height, each 0 for no pictures\n *\n * @example\n * ```ts\n * computeCaptureComposite([{ width: 4, height: 2 }, { width: 3, height: 5 }], false) // { width: 13, height: 5 }\n * ```\n */\nexport function computeCaptureComposite(\n\tpictures: ReadonlyArray<Pick<CapturePicture, 'width' | 'height'>>,\n\tvertical: boolean,\n\tgap = 6,\n): Pick<CapturePicture, 'width' | 'height'> {\n\tconst span = gap * Math.max(0, pictures.length - 1)\n\treturn vertical\n\t\t? {\n\t\t\t\twidth: pictures.reduce((widest, entry) => Math.max(widest, entry.width), 0),\n\t\t\t\theight: pictures.reduce((sum, entry) => sum + entry.height, 0) + span,\n\t\t\t}\n\t\t: {\n\t\t\t\twidth: pictures.reduce((sum, entry) => sum + entry.width, 0) + span,\n\t\t\t\theight: pictures.reduce((tallest, entry) => Math.max(tallest, entry.height), 0),\n\t\t\t}\n}\n\n/**\n * Checks whether a picture size fits `CAPTURE_PNG_LIMITS`, per side and in pixels.\n *\n * @param picture - The size to check\n * @returns True if neither side passes `CAPTURE_PNG_LIMITS.side` and the area does not pass\n * `CAPTURE_PNG_LIMITS.pixels`; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureLimits({ width: 13040, height: 1636 }) // false\n * ```\n */\nexport function matchesCaptureLimits(picture: Pick<CapturePicture, 'width' | 'height'>): boolean {\n\tconst { side, pixels } = CAPTURE_PNG_LIMITS\n\treturn picture.width <= side && picture.height <= side && picture.width * picture.height <= pixels\n}\n\n/**\n * Splits contact-sheet rows into consecutive pages of at most `size` rows whose stacked composite\n * fits `CAPTURE_PNG_LIMITS`.\n *\n * @remarks\n * A page takes each next row while it holds fewer than `size` rows and the stacked composite,\n * with `gap` between rows, still fits; otherwise the row opens the next page.\n *\n * @param rows - The ordered rows, each with its composite width and height\n * @param size - The most rows a page holds, a whole number of at least 1; any other value gives an\n * unspecified result that might throw\n * @param gap - The space between stacked rows\n * @returns The pages, in order\n * @throws Thrown with the `USAGE` condition when one row alone does not fit `CAPTURE_PNG_LIMITS`,\n * naming its composite, the limits, and the narrower `--variant` selection that recovers.\n *\n * @example\n * ```ts\n * splitCaptureSheets([{ width: 13040, height: 400 }, { width: 13040, height: 400 }], 4, 12).length // 1\n * ```\n */\nexport function splitCaptureSheets<T extends Pick<CapturePicture, 'width' | 'height'>>(\n\trows: readonly T[],\n\tsize: number,\n\tgap: number,\n): ReadonlyArray<readonly T[]> {\n\tconst wide = rows.find((row) => !matchesCaptureLimits(row))\n\tif (wide !== undefined)\n\t\tthrow new CaptureError(\n\t\t\t`Contact-sheet row is out of range: composite is ${String(wide.width)} × ${String(wide.height)}; expected at most ${String(CAPTURE_PNG_LIMITS.side)} per side and ${String(CAPTURE_PNG_LIMITS.pixels)} pixels; select fewer variants with --variant`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\t// Each record holds its page's first row and the page's stacked size through this row.\n\tconst marks: Array<{ readonly first: number; readonly width: number; readonly height: number }> =\n\t\t[]\n\tfor (const [index, row] of rows.entries()) {\n\t\tconst last = marks.at(-1)\n\t\tconst joined =\n\t\t\tlast === undefined\n\t\t\t\t? undefined\n\t\t\t\t: {\n\t\t\t\t\t\tfirst: last.first,\n\t\t\t\t\t\twidth: Math.max(last.width, row.width),\n\t\t\t\t\t\theight: last.height + gap + row.height,\n\t\t\t\t\t}\n\t\tmarks.push(\n\t\t\tjoined !== undefined && index - joined.first < size && matchesCaptureLimits(joined)\n\t\t\t\t? joined\n\t\t\t\t: { first: index, width: row.width, height: row.height },\n\t\t)\n\t}\n\tconst starts = marks.flatMap((mark, index) => (mark.first === index ? [index] : []))\n\treturn starts.map((first, page) => rows.slice(first, starts[page + 1] ?? rows.length))\n}\n\n/**\n * Reads the process id that a request file, or its temporary sibling, names.\n *\n * @param name - A file name from the request directory\n * @returns The process id the name carries, from 1 to `CAPTURE_PID_LIMIT`, or `undefined` for any\n * other name\n *\n * @example\n * ```ts\n * readCaptureRequestOwner('journey-selection-4242.json') // 4242\n * readCaptureRequestOwner('journey-selection-4242.json.tmp') // 4242\n * readCaptureRequestOwner('journey-selection.json') // undefined\n * readCaptureRequestOwner('journey-selection-4294967296.json') // undefined\n * ```\n */\nexport function readCaptureRequestOwner(name: string): number | undefined {\n\tconst match = new RegExp(`^${CAPTURE_REQUEST_PREFIX}-(\\\\d+)\\\\.json(?:\\\\.tmp)?$`, 'u').exec(name)\n\tconst pid = Number(match?.[1])\n\treturn Number.isSafeInteger(pid) && pid > 0 && pid <= CAPTURE_PID_LIMIT ? pid : undefined\n}\n\n/**\n * Describes the request holders that keep a workspace busy, naming apart those the host could not inspect.\n *\n * @param holders - The holders `CaptureInvocationInterface.holders` lists\n * @param directory - The workspace-relative request directory that holds their request files\n * @returns The running holders' sentence, then the uninspected holders' sentence with its correction\n *\n * @example\n * ```ts\n * describeCaptureHolders([{ pid: 4242, inspected: true }], 'tmp/capture')\n * // 'Another runner holds this workspace (process 4242)'\n * ```\n */\nexport function describeCaptureHolders(\n\tholders: readonly CaptureHolder[],\n\tdirectory: string,\n): string {\n\tconst running = holders.filter((holder) => holder.inspected).map((holder) => holder.pid)\n\tconst unknown = holders.filter((holder) => !holder.inspected).map((holder) => holder.pid)\n\treturn [\n\t\t...(running.length === 0\n\t\t\t? []\n\t\t\t: [`Another runner holds this workspace (process ${running.join(', ')})`]),\n\t\t...(unknown.length === 0\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t`Request holder process ${unknown.join(', ')} could not be inspected; confirm no capture process or surviving child is running before deleting its request file in ${directory}`,\n\t\t\t\t]),\n\t].join('. ')\n}\n\n/**\n * Resolves a path to the slash-separated form the evidence documents store, relative to a root.\n *\n * @param root - The absolute workspace path\n * @param target - The absolute or workspace-relative path\n * @returns The path relative to the root, with every backslash replaced by a slash\n *\n * @example\n * ```ts\n * resolveCaptureRelative(process.cwd(), resolve('tmp', 'units')) // 'tmp/units'\n * ```\n */\nexport function resolveCaptureRelative(root: string, target: string): string {\n\treturn normalizeSlashes(relative(root, resolve(root, target)))\n}\n\n/**\n * Escapes every regular-expression metacharacter so a case name matches only itself.\n *\n * @param text - The literal text\n * @returns The text with each metacharacter backslash-quoted\n *\n * @example\n * ```ts\n * escapeCapturePattern('renders (a.b) + c') // 'renders \\\\(a\\\\.b\\\\) \\\\+ c'\n * ```\n */\nexport function escapeCapturePattern(text: string): string {\n\treturn text.replace(/[.*+?^${}()|[\\]\\\\]/gu, '\\\\$&')\n}\n\n/**\n * Builds the tag expression that selects an owner population, and its capture tags for frames.\n *\n * @remarks\n * A journey selects `owner:<selector>`. A capture intersects that with the capture tag the\n * selector names, which is its scope and part: the first two segments. The `all` selector unions\n * every declared scope. Colons stay part of a tag name.\n *\n * @param command - The runner command\n * @param selector - The requested owner path or `all`\n * @param selectors - Every owner path the wrapper declares, without the `owner:` prefix\n * @returns The expression for `--tags-filter`\n *\n * @example\n * ```ts\n * buildCaptureFilter('journey', 'pages:mail', ['pages', 'pages:mail']) // 'owner:pages:mail'\n * buildCaptureFilter('capture', 'pages:mail', ['pages', 'pages:mail']) // 'owner:pages:mail && pages:mail'\n * ```\n */\nexport function buildCaptureFilter(\n\tcommand: CaptureCommand,\n\tselector: string,\n\tselectors: readonly string[],\n): string {\n\tconst scopes = selectors.filter((entry) => !entry.includes(':'))\n\tconst owner =\n\t\tselector === 'all'\n\t\t\t? `(${scopes.map((scope) => `${CAPTURE_OWNER_PREFIX}${scope}`).join(' || ')})`\n\t\t\t: `${CAPTURE_OWNER_PREFIX}${selector}`\n\tconst capture =\n\t\tselector === 'all' ? `(${scopes.join(' || ')})` : selector.split(':').slice(0, 2).join(':')\n\treturn command === 'journey' ? owner : `${owner} && ${capture}`\n}\n\n/**\n * Plans one selected journey stage or narrow and remaining frame stages.\n *\n * @remarks\n * Journeys run every selected variant together. Frame captures stage the first variant alone and\n * the remaining variants together. Empty stages are dropped and no unselected variant is added.\n *\n * @param variants - The selected variants in declaration order\n * @param first - The variant the wrapper stages alone first\n * @param command - The journey or capture command whose stage contract applies\n * @returns The non-empty stages in run order\n *\n * @example\n * ```ts\n * resolveCaptureStages(['wide', 'compact'], 'compact', 'capture')\n * // [{ name: 'narrow', variants: ['compact'] }, { name: 'rest', variants: ['wide'] }]\n * ```\n */\nexport function resolveCaptureStages(\n\tvariants: readonly string[],\n\tfirst: string,\n\tcommand: CaptureRequest['command'],\n): readonly CaptureStagePlan[] {\n\tif (command === 'journey')\n\t\treturn variants.length === 0 ? [] : [{ name: CAPTURE_STAGES.selected, variants: [...variants] }]\n\tconst stages: readonly CaptureStagePlan[] = [\n\t\t{ name: CAPTURE_STAGES.first, variants: variants.filter((variant) => variant === first) },\n\t\t{ name: CAPTURE_STAGES.rest, variants: variants.filter((variant) => variant !== first) },\n\t]\n\treturn stages.filter((stage) => stage.variants.length > 0)\n}\n\n/**\n * Resolves selected producing variants in declaration order and requires their projects.\n *\n * @param selected - Explicit variants, or an empty list for every declared variant\n * @param projects - The discovered host projects\n * @returns The declared variants the selection includes\n * @throws Thrown as USAGE for an unknown variant or HOST for missing variant projects.\n * @example\n * ```ts\n * const variants = resolveCaptureVariants(['light-390'], projects)\n * // ['light-390'] when the wrapper declares its project\n * ```\n */\nexport function resolveCaptureVariants(\n\tselected: readonly string[],\n\tprojects: readonly CaptureProject[],\n): readonly string[] {\n\tconst declared = [...new Set(projects.flatMap((project) => project.variants))]\n\tfor (const variant of selected) {\n\t\tif (!declared.includes(variant))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown variant; ${describeCaptureFault('--variant', variant, 'a variant declared by the wrapper', declared)}`,\n\t\t\t\t{ code: 'USAGE', context: { variant } },\n\t\t\t)\n\t}\n\tconst variants = declared.filter((variant) => selected.length === 0 || selected.includes(variant))\n\tif (variants.length === 0)\n\t\tthrow new CaptureError('The wrapper declares no journey variants', { code: 'HOST' })\n\tfor (const variant of variants) {\n\t\tif (!projects.some((project) => project.variant === variant))\n\t\t\tthrow new CaptureError(`The wrapper declares no journey project for ${variant}`, {\n\t\t\t\tcode: 'HOST',\n\t\t\t\tcontext: { variant },\n\t\t\t})\n\t}\n\treturn variants\n}\n\n/**\n * Collects the owner selectors the projects' owner tags declare, once each, in tag order.\n *\n * @param projects - The discovered host projects\n * @returns Each tagged owner selector, ancestors included where the wrapper tags them\n * @example\n * ```ts\n * collectCaptureOwners(projects) // ['pages', 'pages:mail'] for owner:pages and owner:pages:mail tags\n * ```\n */\nexport function collectCaptureOwners(projects: readonly CaptureProject[]): readonly string[] {\n\treturn [...new Set(projects.flatMap((project) => project.tags))]\n\t\t.filter((tag) => tag.startsWith(CAPTURE_OWNER_PREFIX))\n\t\t.map((tag) => tag.slice(CAPTURE_OWNER_PREFIX.length))\n}\n\n/**\n * Refuses unknown command selections from the wrapper before authenticating disk evidence.\n * @example\n * ```ts\n * requireCaptureSelection('all', [], projects) // undefined for declared wrapper projects\n * ```\n */\nexport function requireCaptureSelection(\n\tselector: string,\n\tvariants: readonly string[],\n\tprojects: readonly CaptureProject[],\n\toutputs: readonly string[] = [],\n\tportfolio?: string,\n): void {\n\tconst selectors = [\n\t\t...new Set(\n\t\t\tprojects.flatMap((project) => [\n\t\t\t\t...collectCaptureOwners([project]),\n\t\t\t\t...project.standalone.map((entry) => entry.portfolio),\n\t\t\t]),\n\t\t),\n\t]\n\tconst fault = describeCaptureSelectorFault(selector, selectors)\n\tif (fault !== undefined) throw new CaptureError(fault, { code: 'USAGE' })\n\tconst portfolios = [\n\t\t...new Set(\n\t\t\tprojects.flatMap((project) =>\n\t\t\t\t[...project.portfolios, ...project.standalone].map((entry) => entry.portfolio),\n\t\t\t),\n\t\t),\n\t]\n\tif (portfolio !== undefined && !portfolios.includes(portfolio))\n\t\tthrow new CaptureError(\n\t\t\tdescribeCaptureFault(\n\t\t\t\t'--portfolio',\n\t\t\t\tportfolio,\n\t\t\t\t'a portfolio declared by the wrapper',\n\t\t\t\tportfolios,\n\t\t\t),\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst declared = [...new Set([...projects.flatMap((project) => project.variants), ...outputs])]\n\tfor (const variant of variants)\n\t\tif (!declared.includes(variant))\n\t\t\tthrow new CaptureError(\n\t\t\t\tdescribeCaptureFault(\n\t\t\t\t\t'--variant',\n\t\t\t\t\tvariant,\n\t\t\t\t\t'a variant declared by the wrapper or registry output population',\n\t\t\t\t\tdeclared,\n\t\t\t\t),\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n}\n\n/**\n * Picks the standalone portfolio root a selection names by its selector or its portfolio.\n *\n * @remarks\n * A standalone root has no stamping route and no registry refresh, so a selection reads it only\n * when it names the root's portfolio. Every other selection reads the primary directory.\n *\n * @param roots - The wrapper's standalone roots\n * @param selector - The selected owner selector\n * @param portfolio - The selected portfolio, when the selection names one\n * @returns The named standalone root, or `undefined` for a primary selection\n * @example\n * ```ts\n * const vue = { portfolio: 'vue', directory: 'tmp/captures/vue', scoped: false }\n * resolveCaptureStandalone([vue], 'vue:home') // vue\n * resolveCaptureStandalone([vue], 'pages:mail') // undefined\n * ```\n */\nexport function resolveCaptureStandalone(\n\troots: readonly CapturePortfolioRoot[],\n\tselector: string,\n\tportfolio?: string,\n): CapturePortfolioRoot | undefined {\n\treturn roots.find(\n\t\t(root) =>\n\t\t\tportfolio === root.portfolio ||\n\t\t\tselector === root.portfolio ||\n\t\t\tselector.startsWith(`${root.portfolio}:`),\n\t)\n}\n\n/**\n * Reads output variant candidates without authenticating or accepting registry evidence.\n * @remarks Missing, unreadable, or malformed registries supply no candidate hints; the integrity engine still authenticates every accepted read.\n * @example\n * ```ts\n * readCaptureVariants('/workspace', '/workspace/tmp/captures/states/registry.json') // [] when absent\n * ```\n */\nexport function readCaptureVariants(root: string, file: string): readonly string[] {\n\tconst read = attempt(() => parseJSON(readFileSync(requireCaptureContained(root, file), 'utf8')))\n\treturn read.success && isCaptureRegistry(read.value)\n\t\t? [...new Set(read.value.entries.map((entry) => entry.variant))]\n\t\t: []\n}\n\n/**\n * Builds the exact Node argument array that spawns one Vitest stage.\n *\n * @remarks\n * Each value is its own array element, so no shell quoting applies and a case name keeps its\n * spaces and quotes. An exact case adds `-t` with the anchored pattern for that case and the\n * final case, so the final case still writes the run record.\n *\n * @param options - The entry, wrapper, report and progress files, projects, tag filter, bail switch, and optional exact case and mode\n * @returns The arguments after the Node executable\n *\n * @example\n * ```ts\n * const args = buildCaptureArguments({\n * \tentry: '/repo/node_modules/vitest/vitest.mjs',\n * \tconfig: '/repo/vite.journey.config.ts',\n * \treport: '/repo/tmp/units/runs/a/journey-selected.json',\n * \tprogress: '/repo/tmp/units/runs/a/selected.progress.jsonl',\n * \tprojects: ['journey:light-390'],\n * \tfilter: 'owner:pages:mail',\n * \tfinal: 'closes the run',\n * })\n * args.includes('--bail=1') // true\n * ```\n */\nexport function buildCaptureArguments(options: CaptureArgumentsOptions): readonly string[] {\n\tconst separator = options.case === undefined ? ' ' : readCaptureSeparator(options.entry)\n\treturn [\n\t\toptions.entry,\n\t\t'run',\n\t\t'--config',\n\t\toptions.config,\n\t\t...(options.mode === undefined\n\t\t\t? []\n\t\t\t: options.mode.startsWith('-')\n\t\t\t\t? [`--mode=${options.mode}`]\n\t\t\t\t: ['--mode', options.mode]),\n\t\t'--configLoader',\n\t\t'runner',\n\t\t'--no-cache',\n\t\t...(options.bail === false ? [] : ['--bail=1']),\n\t\t'--reporter=dot',\n\t\t'--reporter=json',\n\t\t`--outputFile.json=${options.report}`,\n\t\t`--outputFile.progress=${options.progress}`,\n\t\t...options.projects.flatMap((project) => ['--project', project]),\n\t\t...(options.filter === undefined ? [] : ['--tags-filter', options.filter]),\n\t\t...(options.case === undefined\n\t\t\t? []\n\t\t\t: [\n\t\t\t\t\t'-t',\n\t\t\t\t\t`^(?:${[options.case, options.final].map((name) => escapeCapturePattern((options.titles?.[name] ?? [name]).join(separator))).join('|')})$`,\n\t\t\t\t]),\n\t]\n}\n\n/**\n * Reads the installed workspace Vitest's exact title separator, refusing unsupported majors.\n * @example\n * ```ts\n * readCaptureSeparator('/workspace/node_modules/vitest/vitest.mjs') // ' > ' on Vitest 5\n * ```\n */\nexport function readCaptureSeparator(entry: string): string {\n\tconst file = resolve(dirname(entry), 'package.json')\n\tconst loaded = attempt(() => parseJSON(readFileSync(file, 'utf8')))\n\tif (!loaded.success)\n\t\tthrow new CaptureError(`Cannot read installed Vitest manifest: ${file}`, {\n\t\t\tcode: 'HOST',\n\t\t\tcause: loaded.error,\n\t\t})\n\tconst manifest: unknown = loaded.value\n\tconst version = isRecord(manifest) ? manifest.version : undefined\n\tif (typeof version === 'string' && version.split('.')[0] === '5') return ' > '\n\tthrow new CaptureError(\n\t\tdescribeCaptureFault('vitest.version', version, 'a supported installed Vitest major', ['5']),\n\t\t{ code: 'HOST' },\n\t)\n}\n\n/**\n * Reads original title segments from the accepted registry's authenticated JSON reporter files.\n * @param root - The repository root that contains the registry and its reporters\n * @param file - The accepted registry path\n * @param selector - The optional owner selector that bounds the case candidates\n * @returns Exact case names mapped to their original title segments within the selected owners\n * @throws Thrown with the removal of the registry and the manifest and lookup journal beside it,\n * and the refresh commands, when the registry declares another protocol version; thrown as a\n * `REGISTRY` capture error when the registry or a reporter it names is absent, unreadable, or fails\n * authentication.\n * @example\n * ```ts\n * const titles = readCaptureTitles('/workspace', '/workspace/tmp/captures/states/registry.json')\n * ```\n */\nexport function readCaptureTitles(\n\troot: string,\n\tfile: string,\n\tselector?: string,\n): Readonly<Record<string, readonly string[]>> {\n\ttry {\n\t\tconst path = requireCaptureContained(root, file)\n\t\tconst loaded = attempt(() => readFileSync(path, 'utf8'))\n\t\tif (!loaded.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Missing accepted registry; run the explicit complete-registry refresh: capture registry. Registry path: ${file}`,\n\t\t\t\t{ code: 'EVIDENCE', cause: loaded.error },\n\t\t\t)\n\t\tconst registry: unknown = parseJSON(loaded.value)\n\t\trequireCaptureVersion(registry, 'Registry', file, [\n\t\t\tfile,\n\t\t\tresolve(dirname(file), CAPTURE_MANIFEST_FILE),\n\t\t\tresolve(dirname(file), CAPTURE_LOOKUPS_FILE),\n\t\t])\n\t\tif (!isCaptureRegistry(registry))\n\t\t\tthrow new CaptureError('Invalid accepted registry for case titles', { code: 'EVIDENCE' })\n\t\treturn Object.fromEntries(\n\t\t\tregistry.receipts.flatMap((receipt) => {\n\t\t\t\tconst text = readFileSync(\n\t\t\t\t\trequireCaptureContained(root, resolve(root, receipt.report.file)),\n\t\t\t\t\t'utf8',\n\t\t\t\t)\n\t\t\t\tif (computeCaptureHash(text) !== receipt.report.digest)\n\t\t\t\t\tthrow new CaptureError('Registry reporter digest differs for case titles', {\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t})\n\t\t\t\tconst report: unknown = parseJSON(text)\n\t\t\t\tif (!isRecord(report) || !arrayOf(isRecord)(report.testResults))\n\t\t\t\t\tthrow new CaptureError('Invalid registry reporter for case titles', { code: 'EVIDENCE' })\n\t\t\t\tconst selected =\n\t\t\t\t\tselector === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: new Set(\n\t\t\t\t\t\t\t\treadCaptureReport(report)\n\t\t\t\t\t\t\t\t\t.assertions.filter((entry) => matchesCaptureSelector(entry.owner, selector))\n\t\t\t\t\t\t\t\t\t.map((entry) => entry.case),\n\t\t\t\t\t\t\t)\n\t\t\t\treturn report.testResults.flatMap((result) =>\n\t\t\t\t\t!arrayOf(isRecord)(result.assertionResults)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: result.assertionResults.flatMap((assertion) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t!isString(assertion.fullName) ||\n\t\t\t\t\t\t\t\t\t!isString(assertion.title) ||\n\t\t\t\t\t\t\t\t\t!arrayOf(isString)(assertion.ancestorTitles)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\treturn []\n\t\t\t\t\t\t\t\tconst titles = [...assertion.ancestorTitles, assertion.title]\n\t\t\t\t\t\t\t\tif (titles.join(' ') !== assertion.fullName)\n\t\t\t\t\t\t\t\t\tthrow new CaptureError('Registry reporter title segments differ from its case', {\n\t\t\t\t\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\treturn selected === undefined || selected.has(assertion.fullName)\n\t\t\t\t\t\t\t\t\t? [[assertion.fullName, titles] as const]\n\t\t\t\t\t\t\t\t\t: []\n\t\t\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t)\n\t} catch (error) {\n\t\tthrow resolveCaptureRegistryFault(error)\n\t}\n}\n\n/**\n * Parses standard option tokens and refuses empty values, terminators, and repeated single options.\n *\n * @remarks A boolean option whose default is `true` reads its `--no-` form as `false` and refuses\n * its positive form, so `--no-bail` is the one spelling of `bail`; the `--no-` form of any other\n * option is refused as unknown. An option and its `--no-` form repeat each other.\n *\n * @param argv - The arguments after the subcommand\n * @param options - The command's frozen Node option definitions\n * @param usage - The command syntax appended to every parser refusal\n * @returns Typed values, positionals, and the tokens that supplied them\n * @example\n * ```ts\n * readCaptureOptions(['--case=-draft'], CAPTURE_COMMAND_OPTIONS.journey, 'Usage: capture journey <selector>').values.case // '-draft'\n * readCaptureOptions(['--no-bail'], CAPTURE_COMMAND_OPTIONS.journey, 'Usage: capture journey <selector>').values.bail // false\n * ```\n */\nexport function readCaptureOptions<Options extends ParseArgsOptionsConfig>(\n\targv: readonly string[],\n\toptions: Options,\n\tusage: string,\n): CaptureParsedArguments<Options> {\n\ttry {\n\t\tconst parsed = parseArgs({\n\t\t\targs: [...argv],\n\t\t\toptions,\n\t\t\ttokens: true,\n\t\t\tstrict: true,\n\t\t\tallowPositionals: true,\n\t\t\tallowNegative: true,\n\t\t})\n\t\tfor (const token of parsed.tokens) {\n\t\t\tif (token.kind === 'option-terminator')\n\t\t\t\tthrow new CaptureError('The -- option terminator is refused', { code: 'USAGE' })\n\t\t\tif (token.kind !== 'option') continue\n\t\t\tif (token.rawName === `--no-${token.name}` && options[token.name]?.default !== true)\n\t\t\t\tthrow new CaptureError(`Unknown option '${token.rawName}'`, { code: 'USAGE' })\n\t\t\tif (token.rawName === `--${token.name}` && options[token.name]?.default === true)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Unknown option '${token.rawName}'; ${token.name} is on by default, and --no-${token.name} turns it off`,\n\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t)\n\t\t\tif (token.value === '')\n\t\t\t\tthrow new CaptureError(`Missing value: --${token.name}`, { code: 'USAGE' })\n\t\t\tif (\n\t\t\t\toptions[token.name]?.multiple !== true &&\n\t\t\t\tparsed.tokens.some(\n\t\t\t\t\t(earlier) =>\n\t\t\t\t\t\tearlier.kind === 'option' && earlier.name === token.name && earlier.index < token.index,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Repeated option: --${token.name}`, { code: 'USAGE' })\n\t\t}\n\t\treturn parsed\n\t} catch (error) {\n\t\tthrow new CaptureError(`${describeCaptureError(error)}\\n${usage}`, {\n\t\t\tcode: 'USAGE',\n\t\t\tcause: error,\n\t\t})\n\t}\n}\n\n/**\n * Reads the runner's command line into one selector, its flags, and the resolved wrapper path.\n *\n * @remarks\n * `--state` belongs to `capture` and `stale`, and `--portfolio` to `stale`. Journey and capture\n * accept `--changed <ref>` instead of a selector, with optional valueless `--plan`, and valueless\n * `--no-bail`, which sets `bail` to `false`. Every other\n * flag takes one nonempty value, either separated or in equals form, and only `--variant` repeats.\n * A value beginning with a dash requires equals form. A bare invocation leaves its selector absent\n * so the caller can print usage with the declared selectors.\n *\n * @param argv - The arguments after the entry name\n * @param command - The runner command the flags belong to\n * @param root - The absolute workspace path the wrapper path resolves against\n * @param fallback - The repository-relative wrapper path used when `--config` is absent\n * @returns The parsed arguments with an absolute wrapper path\n * @throws Thrown as a `USAGE` capture error for an unknown, repeated, misplaced, or valueless flag, a\n * second selector, a repeated or invalid variant, an invalid state, or an empty case.\n *\n * @example\n * ```ts\n * readCaptureArguments(['pages:mail', '--variant', 'light-390'], 'journey', '/repo', 'vite.journey.config.ts')\n * // { selector: 'pages:mail', config: '/repo/vite.journey.config.ts', variants: ['light-390'] }\n * ```\n */\nexport function readCaptureArguments(\n\targv: readonly string[],\n\tcommand: CaptureCommand,\n\troot: string,\n\tfallback: string,\n): CaptureRunnerArguments {\n\tconst usage = `Usage: capture ${CAPTURE_COMMAND_NAMES[command]} <selector> [options]${command === 'stale' ? '' : `; capture ${CAPTURE_COMMAND_NAMES[command]} --changed <ref> [--plan] [options]`}`\n\tconst { values, positionals: positional } = readCaptureOptions(\n\t\targv,\n\t\tCAPTURE_COMMAND_OPTIONS[command],\n\t\tusage,\n\t)\n\tif (positional.length > 1)\n\t\tthrow new CaptureError('Expected exactly one selector', { code: 'USAGE' })\n\tconst variants = values.variant ?? []\n\tif (new Set(variants).size !== variants.length)\n\t\tthrow new CaptureError('Repeated variant', { code: 'USAGE' })\n\tconst invalid = variants.findIndex((variant) => !isCaptureSegment(variant))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid variant identity; ${describeCaptureFault(`--variant[${String(invalid)}]`, variants[invalid], \"a portable nonempty identity segment; valid values come from the wrapper's variant declarations\")}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst state = 'state' in values && typeof values.state === 'string' ? values.state : undefined\n\tif (state !== undefined && !isCaptureSegment(state))\n\t\tthrow new CaptureError(\n\t\t\t`Invalid state identity; ${describeCaptureFault('--state', state, \"a portable nonempty state identity; valid values come from the selected case's state declarations\")}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst name = values.case\n\tconst mode = values.mode\n\tif (name !== undefined && name.trim() === '')\n\t\tthrow new CaptureError('Empty case name', { code: 'USAGE' })\n\tconst portfolio =\n\t\t'portfolio' in values && typeof values.portfolio === 'string' ? values.portfolio : undefined\n\tconst selector = positional.at(0)\n\tconst changed =\n\t\t'changed' in values && typeof values.changed === 'string' ? values.changed : undefined\n\tconst plan = 'plan' in values && values.plan === true\n\tconst bail = !('bail' in values) || values.bail !== false\n\tif (changed !== undefined && selector !== undefined)\n\t\tthrow new CaptureError(\n\t\t\t'A selector cannot be combined with --changed; use --changed <ref> alone',\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tif (plan && changed === undefined)\n\t\tthrow new CaptureError('--plan requires --changed <ref>', { code: 'USAGE' })\n\treturn {\n\t\t...(selector === undefined ? {} : { selector }),\n\t\t...(changed === undefined ? {} : { changed }),\n\t\t...(plan ? { plan: true } : {}),\n\t\t...(bail ? {} : { bail: false }),\n\t\tconfig: resolve(root, values.config ?? fallback),\n\t\t...(mode === undefined ? {} : { mode }),\n\t\tvariants,\n\t\t...(name === undefined ? {} : { case: name }),\n\t\t...(state === undefined ? {} : { state }),\n\t\t...(portfolio === undefined ? {} : { portfolio }),\n\t}\n}\n\n/**\n * Reads the physical portfolio roots a wrapper declares and refuses a malformed or repeated root.\n *\n * @param value - The wrapper's declaration, expected to be a list of roots\n * @param subject - The name of the declaration in a refusal\n * @returns The validated roots in declaration order\n * @throws Thrown as a `HOST` capture error when the declaration is not a list or a root is malformed, and\n * as an `EVIDENCE` capture error when a portfolio name repeats, case-folded.\n *\n * @example\n * ```ts\n * readCapturePortfolios([{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }], 'portfolios')\n * ```\n */\nexport function readCapturePortfolios(\n\tvalue: unknown,\n\tsubject: string,\n): readonly CapturePortfolioRoot[] {\n\tif (!isArray(value))\n\t\tthrow new CaptureError(\n\t\t\t`The wrapper provides no ${subject}; ${describeCaptureFault(subject, value, 'a list of portfolio roots', ['portfolio', 'directory', 'scoped'])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tconst roots = value.map((root, index): CapturePortfolioRoot => {\n\t\tconst keys = ['portfolio', 'directory', 'scoped']\n\t\tif (\n\t\t\t!isRecord(root) ||\n\t\t\t!isCaptureSegment(root.portfolio) ||\n\t\t\t!isCapturePath(root.directory) ||\n\t\t\ttypeof root.scoped !== 'boolean' ||\n\t\t\tObject.keys(root).some((key) => !keys.includes(key))\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The wrapper provides an invalid ${subject} root; ${describeCaptureFault(`${subject}[${String(index)}]`, root, '{ portfolio: portable segment, directory: contained portable path, scoped: boolean }', keys, keys)}`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\treturn { portfolio: root.portfolio, directory: root.directory, scoped: root.scoped }\n\t})\n\trequireCaptureUnique(\n\t\troots.map((root) => root.portfolio),\n\t\tsubject,\n\t\ttrue,\n\t)\n\treturn roots\n}\n\n/**\n * Reads one wrapper project's host declarations from its Vitest test configuration.\n *\n * @remarks\n * The label is the project's `name` or its `label` member. Tags must not contain whitespace or a\n * tag-filter operator, and a variant must be a portable identity. The project's own `variant` must\n * be one of the declared `variants`, and so must the `first` stage variant. Portfolio roots and\n * the final case are required, and standalone roots default to none. `uniform` is an optional\n * list of unique valid owner selectors for the preflight's frame scan. Default: every scope.\n * An empty list judges none; the declaration never narrows the other readings.\n *\n * @param test - The project's `test` configuration, or any value the wrapper supplied in its place\n * @returns The validated project declaration\n * @throws Thrown as a `HOST` capture error when a declaration is missing or malformed.\n *\n * @example\n * ```ts\n * const project = readCaptureProject({\n * \tname: 'journey:light-390',\n * \ttags: [{ name: 'owner:pages:mail' }],\n * \tprovide: {\n * \t\tvariant: 'light-390',\n * \t\tvariants: [{ name: 'light-390' }],\n * \t\tdirectory: '/repo/tmp/captures/states',\n * \t\trecord: 'tmp/captures/states/runs/a/light-390.json',\n * \t\tinputs: ['src/**'],\n * \t\tfinal: 'closes the run',\n * \t\tfirst: 'light-390',\n * \t\tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * \t},\n * })\n * project.variant // 'light-390'\n * ```\n */\nexport function readCaptureProject(test: unknown): CaptureProject {\n\tconst name: unknown = isRecord(test) ? test.name : undefined\n\tconst label =\n\t\ttypeof name === 'string'\n\t\t\t? name\n\t\t\t: isRecord(name) && typeof name.label === 'string'\n\t\t\t\t? name.label\n\t\t\t\t: undefined\n\tif (label === undefined)\n\t\tthrow new CaptureError(\n\t\t\t'Unsupported journey project name: expected a string or an object with a string label',\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tconst entries: unknown = isRecord(test) ? test.tags : undefined\n\tconst tags: unknown = (isArray(entries) ? entries : []).map((tag): unknown =>\n\t\tisRecord(tag) ? tag.name : undefined,\n\t)\n\tif (\n\t\t!arrayOf(isString)(tags) ||\n\t\ttags.some((tag) => /[\\s!*&|()]/u.test(tag) || CAPTURE_TAG_OPERATORS.includes(tag))\n\t)\n\t\tthrow new CaptureError('The wrapper declares an invalid tag name', { code: 'HOST' })\n\tconst provided: unknown = isRecord(test) ? test.provide : undefined\n\tconst declared: unknown = isRecord(provided) ? provided.variants : undefined\n\tif (!isArray(declared))\n\t\tthrow new CaptureError('A journey project provides no variants', { code: 'HOST' })\n\tconst variants = declared.map((entry): unknown => (isRecord(entry) ? entry.name : undefined))\n\tif (!arrayOf(isString)(variants))\n\t\tthrow new CaptureError('A journey variant has no name', { code: 'HOST' })\n\tif (\n\t\t!isRecord(provided) ||\n\t\t!isString(provided.directory) ||\n\t\t!isString(provided.record) ||\n\t\t!arrayOf(isCapturePattern)(provided.inputs)\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`The wrapper provides no bounded integrity host declaration; ${describeCaptureFault('test.provide', provided, '{ directory: string workspace path, record: string run path, inputs: portable glob[] }', ['directory', 'record', 'inputs'], ['directory', 'record', 'inputs'], isRecord(provided) ? Object.keys(provided) : [])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tconst invalid = variants.findIndex((variant) => !isCaptureSegment(variant))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`A journey variant has an invalid identity; ${describeCaptureFault(`test.provide.variants[${String(invalid)}].name`, variants[invalid], 'a portable nonempty variant identity segment', variants.some(isCaptureSegment) ? variants.filter(isCaptureSegment) : ['<portable variant name>'])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\trequireCaptureUnique(variants, 'journey variants', true)\n\tconst variant = provided.variant\n\tif (!isString(variant) || !variants.includes(variant))\n\t\tthrow new CaptureError(`The project ${label} provides no declared variant`, { code: 'HOST' })\n\tconst first = provided.first\n\tif (!isString(first) || !variants.includes(first))\n\t\tthrow new CaptureError('The wrapper provides no first-stage variant among its variants', {\n\t\t\tcode: 'HOST',\n\t\t})\n\tconst final = provided.final\n\tif (!isString(final) || final.trim() === '')\n\t\tthrow new CaptureError('The wrapper provides no final case', { code: 'HOST' })\n\tconst uniform = provided.uniform\n\tif (uniform !== undefined && !arrayOf(isCaptureSelector)(uniform))\n\t\tthrow new CaptureError('The wrapper uniform scopes must be a list of valid owner selectors', {\n\t\t\tcode: 'HOST',\n\t\t})\n\tif (uniform !== undefined) requireCaptureUnique(uniform, 'uniform scopes')\n\tconst portfolios = readCapturePortfolios(provided.portfolios, 'portfolios')\n\tif (portfolios.length === 0)\n\t\tthrow new CaptureError('The wrapper provides no portfolio roots', { code: 'HOST' })\n\tconst standalone =\n\t\tprovided.standalone === undefined\n\t\t\t? []\n\t\t\t: readCapturePortfolios(provided.standalone, 'standalone portfolios')\n\trequireCaptureUnique(\n\t\t[...portfolios, ...standalone].map((root) => root.portfolio),\n\t\t'portfolio names',\n\t\ttrue,\n\t)\n\treturn {\n\t\tname: label,\n\t\tvariant,\n\t\ttags,\n\t\tvariants,\n\t\tdirectory: provided.directory,\n\t\trecord: provided.record,\n\t\tinputs: provided.inputs,\n\t\tfinal,\n\t\tfirst,\n\t\t...(uniform === undefined ? {} : { uniform }),\n\t\tportfolios,\n\t\tstandalone,\n\t}\n}\n\n/**\n * Describes a project's portfolio roots as comparable lines, primary roots apart from standalone ones.\n *\n * @param project - The project whose roots to describe\n * @returns One line per root, naming its kind, portfolio, directory, and scoping\n *\n * @example\n * ```ts\n * describeCapturePortfolios({\n * \tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * \tstandalone: [],\n * }) // ['primary states tmp/captures/states true']\n * ```\n */\nexport function describeCapturePortfolios(\n\tproject: Pick<CaptureProject, 'portfolios' | 'standalone'>,\n): readonly string[] {\n\treturn [\n\t\t...project.portfolios.map(\n\t\t\t(root) => `primary ${root.portfolio} ${root.directory} ${String(root.scoped)}`,\n\t\t),\n\t\t...project.standalone.map(\n\t\t\t(root) => `standalone ${root.portfolio} ${root.directory} ${String(root.scoped)}`,\n\t\t),\n\t]\n}\n\n/**\n * Refuses a wrapper project set whose members repeat or disagree on a host declaration.\n *\n * @remarks\n * Project labels are unique and so is each project's own variant, case-folded. Every project must\n * declare the same primary directory, inputs, variants, first-stage variant, final case, and\n * portfolio roots, because the runner builds one engine for the whole set. Uniform declarations\n * must also agree as populations, with absence distinct from an empty list.\n *\n * @param projects - The wrapper's projects\n * @returns The first project, whose declarations every other project matches\n * @throws Thrown as a `HOST` capture error when the set is empty or its members disagree, and as an\n * `EVIDENCE` capture error when a label or variant repeats.\n *\n * @example\n * ```ts\n * requireCaptureProjects([project]) // project\n * ```\n */\nexport function requireCaptureProjects(projects: readonly CaptureProject[]): CaptureProject {\n\tconst first = projects.at(0)\n\tif (first === undefined)\n\t\tthrow new CaptureError('No host project declares integrity inputs', { code: 'HOST' })\n\trequireCaptureUnique(\n\t\tprojects.map((project) => project.name),\n\t\t'journey projects',\n\t)\n\trequireCaptureUnique(\n\t\tprojects.map((project) => project.variant),\n\t\t'journey project variants',\n\t\ttrue,\n\t)\n\tif (\n\t\tprojects.some(\n\t\t\t(project) =>\n\t\t\t\tproject.directory !== first.directory ||\n\t\t\t\tproject.final !== first.final ||\n\t\t\t\tproject.first !== first.first ||\n\t\t\t\t(project.uniform === undefined || first.uniform === undefined\n\t\t\t\t\t? project.uniform !== first.uniform\n\t\t\t\t\t: !matchesCaptureMembers(project.uniform, first.uniform)) ||\n\t\t\t\t!matchesCaptureMembers(project.inputs, first.inputs) ||\n\t\t\t\t!matchesCaptureMembers(project.variants, first.variants) ||\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tdescribeCapturePortfolios(project),\n\t\t\t\t\tdescribeCapturePortfolios(first),\n\t\t\t\t),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Host project integrity declarations disagree', { code: 'HOST' })\n\treturn first\n}\n\n/**\n * Describes why a selector names nothing the wrapper declares, naming the first unknown segment.\n *\n * @remarks\n * The depth of a segment decides its label: the first segment is a scope and every deeper one an\n * owner. `all` and every declared owner path, ancestors included, name something.\n *\n * @param selector - The requested owner path or `all`\n * @param selectors - Every owner path the wrapper declares, ancestors included\n * @returns The refusal text, or `undefined` when the selector names a declared population\n *\n * @example\n * ```ts\n * describeCaptureSelectorFault('pages:mail', ['pages', 'pages:mail']) // undefined\n * describeCaptureSelectorFault('pages:none', ['pages', 'pages:mail'])?.includes('selector: received \"pages:none\"') // true\n * ```\n */\nexport function describeCaptureSelectorFault(\n\tselector: string,\n\tselectors: readonly string[],\n): string | undefined {\n\tif (selector === 'all' || selectors.includes(selector)) return undefined\n\tconst parts = selector.split(':')\n\tconst missing = parts.findIndex(\n\t\t(_part, index) => !selectors.includes(parts.slice(0, index + 1).join(':')),\n\t)\n\treturn `Unknown ${missing === 0 ? 'scope' : 'owner'}: ${preview(parts[missing] ?? selector)}; ${describeCaptureFault('selector', selector, 'all or a declared colon-separated owner selector; obsolete owner paths are not aliases', ['all', ...selectors])}`\n}\n\n/**\n * Builds the refusal a wrapper raises for a request file it cannot accept as its parent's.\n *\n * @param file - The absolute request path, named in the message\n * @param cause - The underlying failure, when there is one\n * @returns A `HOST` capture error naming the file\n *\n * @example\n * ```ts\n * buildCaptureRequestRefusal('/repo/tmp/units/journey-selection-4242.json').message\n * // 'Invalid journey selection request: /repo/tmp/units/journey-selection-4242.json'\n * ```\n */\nexport function buildCaptureRequestRefusal(file: string, cause?: unknown): CaptureError {\n\treturn new CaptureError(`Invalid journey selection request: ${file}`, {\n\t\tcode: 'HOST',\n\t\tcontext: { file },\n\t\t...(cause === undefined ? {} : { cause }),\n\t})\n}\n\n/**\n * Reads and validates the request the runner wrote for the wrapper process that is its child.\n *\n * @remarks\n * Only the file named by `ppid` is read, so a request a stopped runner left never reaches a run\n * that has no runner parent. Every refusal names its cause: a file that does not parse, a record\n * whose `pid` differs from the parent's, arguments that differ from the process's own, an\n * unsupported version, an identity that is not a portable segment, a wrapper path that is not\n * `config`, a state on a command that cannot carry one, and a command, selector, variant list, or\n * case the wrapper does not declare.\n *\n * @param options - The parent id, the process arguments, the request directory, and the wrapper's declarations\n * @returns The validated request, or `undefined` when the parent wrote none\n * @throws Thrown as a `HOST` capture error when a request exists and fails any check.\n *\n * @example\n * ```ts\n * const request = readCaptureRequest({\n * \tppid: process.ppid,\n * \targv: process.argv.slice(1),\n * \tdirectory: '/repo/tmp/units',\n * \tconfig: 'configs/vite.journey.config.ts',\n * \towners: ['pages:mail'],\n * \tvariants: ['light-390'],\n * })\n * request?.selector // 'pages:mail', or undefined when no runner is the parent\n * ```\n */\nexport function readCaptureRequest(options: CaptureRequestOptions): CaptureRequest | undefined {\n\tconst file = resolve(\n\t\tresolveCaptureRequests(options.directory),\n\t\t`${CAPTURE_REQUEST_PREFIX}-${String(options.ppid)}.json`,\n\t)\n\tif (!existsSync(file)) return undefined\n\tconst read = attempt(() => readFileSync(file, 'utf8'))\n\tif (!read.success) throw buildCaptureRequestRefusal(file, read.error)\n\tconst parsed = parseJSON(read.value)\n\tif (!isRecord(parsed)) throw buildCaptureRequestRefusal(file)\n\tif (parsed.phase !== undefined)\n\t\tthrow buildCaptureRequestRefusal(\n\t\t\tfile,\n\t\t\tnew CaptureError('Journey selection request belongs to the discovery phase', {\n\t\t\t\tcode: 'HOST',\n\t\t\t}),\n\t\t)\n\tif (parsed.pid !== options.ppid)\n\t\tthrow buildCaptureRequestRefusal(\n\t\t\tfile,\n\t\t\tnew CaptureError('Journey selection request does not belong to the parent process', {\n\t\t\t\tcode: 'HOST',\n\t\t\t}),\n\t\t)\n\tconst args = arrayOf(isString)(parsed.args) ? parsed.args : undefined\n\tif (\n\t\targs === undefined ||\n\t\targs.length !== options.argv.length ||\n\t\t!args.every((argument, index) => argument === options.argv[index])\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`Journey selection request arguments differ from the process arguments: ${file}`,\n\t\t\t{ code: 'HOST', context: { file } },\n\t\t)\n\tif (parsed.version !== CAPTURE_VERSION)\n\t\tthrow new CaptureError('Journey selection request has invalid version', { code: 'HOST' })\n\tif (!isCaptureSegment(parsed.id) || !isCaptureSegment(parsed.stage))\n\t\tthrow new CaptureError('Journey selection request has invalid identity', { code: 'HOST' })\n\tif (parsed.config !== options.config)\n\t\tthrow new CaptureError('Journey selection request has invalid config', { code: 'HOST' })\n\tif (parsed.mode !== undefined && (typeof parsed.mode !== 'string' || parsed.mode.trim() === ''))\n\t\tthrow new CaptureError('Journey selection request has invalid mode', { code: 'HOST' })\n\tconst command =\n\t\tparsed.command === 'journey' || parsed.command === 'capture' ? parsed.command : undefined\n\tif (\n\t\tparsed.state !== undefined &&\n\t\t(typeof parsed.state !== 'string' || parsed.state.trim() === '' || command !== 'capture')\n\t)\n\t\tthrow new CaptureError('Journey selection request has invalid state', { code: 'HOST' })\n\tconst selector = typeof parsed.selector === 'string' ? parsed.selector : undefined\n\tconst variants = arrayOf(isString)(parsed.variants) ? parsed.variants : undefined\n\tif (\n\t\tcommand === undefined ||\n\t\tselector === undefined ||\n\t\tselector.trim() === '' ||\n\t\t(selector !== 'all' &&\n\t\t\t!options.owners.some((owner) => matchesCaptureSelector(owner, selector))) ||\n\t\tvariants === undefined ||\n\t\tvariants.length === 0 ||\n\t\tnew Set(variants).size !== variants.length ||\n\t\tvariants.some((variant) => !options.variants.includes(variant)) ||\n\t\t(parsed.case !== undefined && (typeof parsed.case !== 'string' || parsed.case.trim() === ''))\n\t)\n\t\tthrow new CaptureError(\n\t\t\t'Journey selection request has invalid command, selector, variants, or case',\n\t\t\t{ code: 'HOST' },\n\t\t)\n\treturn {\n\t\tversion: CAPTURE_VERSION,\n\t\tid: parsed.id,\n\t\tstage: parsed.stage,\n\t\tconfig: options.config,\n\t\tpid: options.ppid,\n\t\tcommand,\n\t\t...(typeof parsed.mode === 'string' ? { mode: parsed.mode } : {}),\n\t\tselector,\n\t\t...(typeof parsed.case === 'string' ? { case: parsed.case } : {}),\n\t\tvariants,\n\t\targs,\n\t\t...(typeof parsed.state === 'string' ? { state: parsed.state } : {}),\n\t}\n}\n\n/**\n * Reads a reader's command line into its selection, its flags, and the resolved paths.\n *\n * @remarks\n * The first argument is the selector and every flag after it takes one nonempty value, separated\n * or in equals form. Only `--variant` repeats. `--output` belongs to sheets; the preflight option\n * table refuses it before discovery. `--mode` selects the wrapper's Vitest mode. The wrapper, the journey artifact directory, and the checks module\n * resolve against `root`; `defaults` supplies the first two when the command line names neither.\n *\n * @param argv - The arguments after the entry name\n * @param root - The absolute workspace path the paths resolve against\n * @param defaults - The repository-relative wrapper and journey artifact directory to fall back to\n * @param command - The reader command whose option table applies. Default: `sheets`\n * @returns The reader options and the optional contact-sheet directory\n * @throws Thrown as a `USAGE` capture error for an absent selector, an unknown, repeated, or\n * valueless flag.\n *\n * @example\n * ```ts\n * readCaptureReaderArguments(['pages:mail', '--variant', 'light-390'], '/repo', {\n * \tconfig: 'configs/vite.journey.config.ts',\n * \tjourneys: 'tmp/journey',\n * }).reader.selection // { selector: 'pages:mail', variants: ['light-390'] }\n * ```\n */\nexport function readCaptureReaderArguments(\n\targv: readonly string[],\n\troot: string,\n\tdefaults: CaptureReaderDefaults,\n\tcommand: 'preflight' | 'sheets' = 'sheets',\n): CaptureReaderCommand {\n\tconst usage = `Usage: capture ${command} <selector> ${command === 'sheets' ? '--output <directory> ' : ''}[options]`\n\tconst { values, positionals, tokens } = readCaptureOptions(\n\t\targv,\n\t\tCAPTURE_COMMAND_OPTIONS[command],\n\t\tusage,\n\t)\n\tconst selector = positionals.at(0)\n\tif (selector === undefined || positionals.length !== 1 || tokens.at(0)?.kind !== 'positional')\n\t\tthrow new CaptureError(usage, { code: 'USAGE' })\n\tconst variants = values.variant ?? []\n\tconst state = values.state\n\tconst name = values.case\n\tconst portfolio = values.portfolio\n\tconst checks = values.checks\n\tconst output = 'output' in values && typeof values.output === 'string' ? values.output : undefined\n\tconst mode = values.mode\n\treturn {\n\t\treader: {\n\t\t\troot: resolve(root),\n\t\t\tconfig: resolve(root, values.config ?? defaults.config),\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\tjourneys: resolve(root, values.journeys ?? defaults.journeys),\n\t\t\tselection: {\n\t\t\t\tselector,\n\t\t\t\t...(variants.length === 0 ? {} : { variants }),\n\t\t\t\t...(state === undefined ? {} : { state }),\n\t\t\t\t...(name === undefined ? {} : { case: name }),\n\t\t\t\t...(portfolio === undefined ? {} : { portfolio }),\n\t\t\t},\n\t\t\t...(checks === undefined ? {} : { checks: resolve(root, checks) }),\n\t\t\t...(defaults.requests === undefined ? {} : { requests: defaults.requests }),\n\t\t},\n\t\t...(output === undefined ? {} : { output: resolve(root, output) }),\n\t}\n}\n\n/**\n * Reads the viewport a wrapper project's producing variant declares.\n *\n * @param test - The project's `test` configuration, or any value the wrapper supplied in its place\n * @returns The producing variant's name and pixel geometry\n * @throws Thrown as a `HOST` capture error when the project declares no variant geometry or its\n * producing variant has none.\n *\n * @example\n * ```ts\n * readCaptureViewport({\n * \tprovide: { variant: 'light-390', variants: [{ name: 'light-390', width: 390, height: 844 }] },\n * }) // { name: 'light-390', width: 390, height: 844 }\n * ```\n */\nexport function readCaptureViewport(test: unknown): CaptureViewport {\n\tconst provided: unknown = isRecord(test) ? test.provide : undefined\n\tconst declared: unknown = isRecord(provided) ? provided.variants : undefined\n\tconst variant: unknown = isRecord(provided) ? provided.variant : undefined\n\tif (!arrayOf(isCaptureGeometry)(declared))\n\t\tthrow new CaptureError('A reader project declares no viewport geometry', { code: 'HOST' })\n\tconst viewport = declared.find((entry) => entry.name === variant)\n\tif (viewport === undefined)\n\t\tthrow new CaptureError('A reader project has no declared producing viewport', { code: 'HOST' })\n\treturn { name: viewport.name, width: viewport.width, height: viewport.height }\n}\n\n/**\n * Derives the integrity engine's options from a wrapper project's host declarations.\n *\n * @remarks\n * Without `standalone` the engine reads the project's primary directory and every portfolio root the\n * project authorizes. With one, the engine reads that root alone, keeping its registry, manifest, and\n * lookups beside its own directory.\n *\n * @param root - The absolute workspace path\n * @param project - The wrapper project whose declarations the engine adopts\n * @param standalone - The standalone root to read through, when a selection names one\n * @returns The options the engine is constructed with\n * @throws Thrown as a `HOST` capture error when the directory leaves the repository.\n *\n * @example\n * ```ts\n * buildCaptureIntegrityOptions(root, project).manifest // 'tmp/captures/states/manifest.json'\n * ```\n */\nexport function buildCaptureIntegrityOptions(\n\troot: string,\n\tproject: CaptureProject,\n\tstandalone?: CapturePortfolioRoot,\n): CaptureIntegrityOptions {\n\tconst directory =\n\t\tstandalone === undefined\n\t\t\t? resolveCaptureRelative(root, project.directory)\n\t\t\t: standalone.directory\n\tif (!isCapturePath(directory))\n\t\tthrow new CaptureError('The wrapper provides a directory outside the repository', {\n\t\t\tcode: 'HOST',\n\t\t\tcontext: { directory },\n\t\t})\n\treturn {\n\t\troot,\n\t\tdirectory,\n\t\tinputs: project.inputs,\n\t\tregistry: `${directory}/${CAPTURE_REGISTRY_FILE}`,\n\t\tmanifest: `${directory}/${CAPTURE_MANIFEST_FILE}`,\n\t\tlookups: `${directory}/${CAPTURE_LOOKUPS_FILE}`,\n\t\tportfolios: standalone === undefined ? project.portfolios : [standalone],\n\t}\n}\n\n/**\n * Reports a portfolio, owner, and viewport whose frames mix cropped, viewport-sized, and page-sized images.\n *\n * @remarks\n * Only a frame at its own producing variant counts, so an auxiliary output variant never joins its\n * producer's group. A frame narrower than its viewport reads `crop`, one as tall as the viewport\n * reads `viewport`, and any other reads `page`. The observation names the mixture without inferring\n * which framing was intended.\n *\n * @param images - The selected images, decoded\n * @param producers - The wrapper's producing viewports\n * @returns One observation per group that holds more than one kind\n *\n * @example\n * ```ts\n * scanCaptureFrames(images, producers) // ['Mixed framing: states/pages:mail@390: page, viewport']\n * ```\n */\nexport function scanCaptureFrames(\n\timages: readonly CaptureImageResult[],\n\tproducers: readonly CaptureProducer[],\n): readonly string[] {\n\tconst families = [\n\t\t...new Set(images.map(({ entry }) => `${entry.portfolio}/${resolveCaptureOwner(entry)}`)),\n\t]\n\treturn families.flatMap((family) =>\n\t\t[...new Set(producers.map((producer) => producer.width))].flatMap((width) => {\n\t\t\tconst kinds = [\n\t\t\t\t...new Set(\n\t\t\t\t\timages.flatMap(({ entry, picture }) => {\n\t\t\t\t\t\tconst viewport = producers.find((producer) => producer.project === entry.project)\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t`${entry.portfolio}/${resolveCaptureOwner(entry)}` !== family ||\n\t\t\t\t\t\t\tviewport?.width !== width ||\n\t\t\t\t\t\t\tentry.variant !== viewport.name\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn []\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\tpicture.width < viewport.width\n\t\t\t\t\t\t\t\t? 'crop'\n\t\t\t\t\t\t\t\t: picture.height === viewport.height\n\t\t\t\t\t\t\t\t\t? 'viewport'\n\t\t\t\t\t\t\t\t\t: 'page',\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 kinds.length > 1\n\t\t\t\t? [`Mixed framing: ${family}@${String(width)}: ${kinds.join(', ')}`]\n\t\t\t\t: []\n\t\t}),\n\t)\n}\n\n/**\n * Groups the selected images whose bytes are identical.\n *\n * @param images - The selected images, decoded\n * @returns One list of files per digest shared by more than one image\n *\n * @example\n * ```ts\n * collectCaptureIdentical(images) // [['tmp/captures/a.png', 'tmp/captures/b.png']]\n * ```\n */\nexport function collectCaptureIdentical(\n\timages: readonly CaptureImageResult[],\n): ReadonlyArray<readonly string[]> {\n\t// A group keeps the order in which its digest first appears and lists its images in input order.\n\treturn [...Map.groupBy(images, (image) => image.digest).values()]\n\t\t.filter((group) => group.length > 1)\n\t\t.map((group) => group.map((image) => image.entry.file))\n}\n\n/**\n * Builds the report a preflight prints and a contact-sheet index carries from one preflight result.\n *\n * @param result - The judged selection\n * @returns The selection, freshness, mixed observations, issues, identical groups, image sizes, and `acceptance: false`\n *\n * @example\n * ```ts\n * buildCaptureReaderReport(await preflight.check()).acceptance // false\n * ```\n */\nexport function buildCaptureReaderReport(result: CapturePreflightResult): CaptureReaderReport {\n\treturn {\n\t\tselection: result.selection,\n\t\tfreshness: result.freshness,\n\t\tmixed: result.mixed,\n\t\tissues: result.issues,\n\t\tidentical: collectCaptureIdentical(result.images),\n\t\tsizes: result.images.map(({ entry, picture, size }) => ({\n\t\t\tfile: entry.file,\n\t\t\twidth: picture.width,\n\t\t\theight: picture.height,\n\t\t\tbytes: size,\n\t\t})),\n\t\tacceptance: false,\n\t}\n}\n\n/**\n * Finds the journey artifact lines that report an uncaught, unhandled, or logged error.\n *\n * @param file - The artifact's repository-relative path, which prefixes each finding\n * @param text - The artifact's text\n * @returns One finding per matching line\n *\n * @example\n * ```ts\n * collectCaptureErrors('tmp/journey/light-390.txt', 'ok\\nUncaught TypeError') // ['tmp/journey/light-390.txt: Uncaught TypeError']\n * ```\n */\nexport function collectCaptureErrors(file: string, text: string): readonly string[] {\n\treturn text\n\t\t.split(/\\r\\n|\\n/u)\n\t\t.filter((line) => /\\b(uncaught|unhandled|error:)/iu.test(line))\n\t\t.map((line) => `${file}: ${line}`)\n}\n\n/**\n * Resolves one entry of a wrapper's project list to the project it declares.\n *\n * @remarks\n * A factory entry is called with the serve command and the requested mode, or the default test\n * mode, as Vitest calls it, and a promise is awaited. The result is the project as plain data: the runner reads\n * and validates it, so one reader owns every refusal.\n *\n * @param input - The entry as the wrapper declared it: an inline project, a promise of one, or a factory\n * @returns The resolved project, whatever it holds\n *\n * @example\n * ```ts\n * const project = await resolveCaptureWrapperProject(wrapper.test.projects[0])\n * ```\n */\nexport async function resolveCaptureWrapperProject(\n\tinput: unknown,\n\tmode = 'test',\n): Promise<unknown> {\n\treturn isFunction(input) ? await input({ command: 'serve', mode }) : await input\n}\n\n/**\n * Reads one wrapper project, as the description file holds it, into its host declarations and viewport.\n *\n * @remarks\n * The viewport is read when the project declares geometry for its producing variant and is absent\n * otherwise, because a runner command needs none and only a reader refuses its absence.\n *\n * @param value - The resolved project as plain data\n * @returns The validated project and, when it declares one, its producing viewport\n * @throws Thrown as a `HOST` capture error when the project is a path or a non-record, or when its\n * declarations are malformed.\n *\n * @example\n * ```ts\n * const { project } = readCaptureEntry({ test: { name: 'journey:light-390', provide } })\n * project.variant // 'light-390'\n * ```\n */\nexport function readCaptureEntry(value: unknown): CaptureHostEntry {\n\tif (!isRecord(value))\n\t\tthrow new CaptureError('The journey wrapper must declare inline projects', { code: 'HOST' })\n\tconst project = readCaptureProject(value.test)\n\tconst viewport = attempt(() => readCaptureViewport(value.test))\n\treturn { project, ...(viewport.success ? { viewport: viewport.value } : {}) }\n}\n\n/**\n * Resolves the directory that holds the runner's request files for the process that reads them.\n *\n * @remarks\n * A directory the wrapper names wins. Otherwise the directory the runner handed this child in\n * `CAPTURE_REQUESTS` applies, and a process the runner did not start reads `CAPTURE_DEFAULTS.requests`\n * beneath its working directory. The one default therefore lives here and in the executable, and a\n * consumer never has to repeat it.\n *\n * @param directory - The directory the wrapper declares, when it declares one\n * @returns The absolute directory\n *\n * @example\n * ```ts\n * resolveCaptureRequests('/repo/tmp/units') // '/repo/tmp/units'\n * ```\n */\nexport function resolveCaptureRequests(directory?: string): string {\n\treturn resolve(directory ?? process.env[CAPTURE_REQUESTS_FLAG] ?? CAPTURE_DEFAULTS.requests)\n}\n\n/**\n * Builds the empty Node configuration a wrapper returns once it has answered a discovery request.\n *\n * @remarks\n * It carries no project, no setup file, and no include pattern, so Vitest collects no test, starts\n * no browser, and initializes no output for a discovery child.\n *\n * @returns A fresh configuration object\n *\n * @example\n * ```ts\n * export default (await answerCaptureDiscovery(options)) ? buildCaptureDiscoveryConfig() : config\n * ```\n */\nexport function buildCaptureDiscoveryConfig(): CaptureDiscoveryConfig {\n\treturn { test: { include: [], passWithNoTests: true, watch: false } }\n}\n\n/**\n * Accepts the description a wrapper wrote only when it answers this exchange and no other.\n *\n * @remarks\n * Every echo must match: the invocation, the challenge, the wrapper path, the runner as the\n * wrapper's parent, and the child the runner spawned as the writer. Each project then passes the same\n * reader the wrapper's own declarations pass through, and the list may not be empty.\n *\n * @param value - The parsed description file\n * @param expected - What the request and the spawn establish\n * @returns The validated description\n * @throws Thrown as a `HOST` capture error naming the first echo that differs, a malformed\n * document, an empty project list, or a malformed project.\n *\n * @example\n * ```ts\n * const description = readCaptureDescription(parseJSON(text), expected)\n * ```\n */\nexport function readCaptureDescription(\n\tvalue: unknown,\n\texpected: CaptureDescriptionExpectation,\n): CaptureHostDescription {\n\tconst keys = ['version', 'id', 'nonce', 'config', 'parent', 'pid', 'projects']\n\tif (\n\t\t!isRecord(value) ||\n\t\tvalue.version !== CAPTURE_VERSION ||\n\t\t!isArray(value.projects) ||\n\t\tkeys.some((key) => value[key] === undefined) ||\n\t\tObject.keys(value).some((key) => !keys.includes(key))\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`The host description is malformed; ${describeCaptureFault('description', value, `{ version: ${String(CAPTURE_VERSION)}, id: invocation id, nonce: challenge, config: wrapper path, parent: parent pid, pid: discovery child pid, projects: project[] }`, keys, keys)}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tif (value.id !== expected.id)\n\t\tthrow new CaptureError(\n\t\t\t`The host description answers another invocation; ${describeCaptureFault('description.id', value.id, 'the active invocation id', [expected.id])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tif (value.nonce !== expected.nonce)\n\t\tthrow new CaptureError(\n\t\t\t`The host description answers another challenge (a replay); ${describeCaptureFault('description.nonce', value.nonce, 'the active discovery challenge', [expected.nonce])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tif (value.config !== expected.config)\n\t\tthrow new CaptureError(\n\t\t\t`The host description names another wrapper; ${describeCaptureFault('description.config', value.config, 'the requested wrapper path', [expected.config])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\tif (value.parent !== expected.parent)\n\t\tthrow new CaptureError(\n\t\t\t`The host description was written for another parent process; ${describeCaptureFault('description.parent', value.parent, 'the parent process id', [String(expected.parent)])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tif (expected.pid === undefined || value.pid !== expected.pid)\n\t\tthrow new CaptureError(\n\t\t\t`The host description was not written by the discovery child; ${describeCaptureFault('description.pid', value.pid, 'the spawned discovery child process id', expected.pid === undefined ? [] : [String(expected.pid)])}`,\n\t\t\t{\n\t\t\t\tcode: 'HOST',\n\t\t\t},\n\t\t)\n\tif (value.projects.length === 0)\n\t\tthrow new CaptureError(\n\t\t\t`The wrapper declares no projects; ${describeCaptureFault('description.projects', value.projects, 'a nonempty list of wrapper projects', ['{ test: project configuration }'])}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\treturn {\n\t\tversion: CAPTURE_VERSION,\n\t\tid: expected.id,\n\t\tnonce: expected.nonce,\n\t\tconfig: expected.config,\n\t\tparent: expected.parent,\n\t\tpid: expected.pid,\n\t\tprojects: value.projects.map(readCaptureEntry),\n\t}\n}\n\n/**\n * Answers the runner's discovery request from the wrapper, before the wrapper does any other work.\n *\n * @remarks\n * The wrapper calls it once, ahead of anything that sets up a browser, initializes an output\n * directory, or collects a test, and returns `buildCaptureDiscoveryConfig()` when it answered. It\n * reads only the request file its parent process wrote and answers `false` when there is none, or\n * when the file is no discovery request, so an execution child falls through to `readCaptureRequest`.\n * A discovery request is accepted only from its own parent with the exact arguments it recorded, the\n * wrapper path it names, and an identity and challenge that are portable segments. The wrapper\n * describes every project from its own declarations and writes one description, atomically, to the\n * invocation directory; a second answer from another process is refused as a replay, while the same\n * process may answer again if Vitest loads its configuration twice.\n *\n * @param options - The parent id, the process arguments, the request directory, the wrapper path, and the wrapper's `test.projects`\n * @returns True once the description is written; false when the request is no discovery request\n * @throws Thrown as a `HOST` capture error for a discovery request that fails any check or a\n * replayed answer. It does not judge the projects: the runner reads and refuses a malformed one.\n *\n * @example\n * ```ts\n * const answered = await answerCaptureDiscovery({\n * \tppid: process.ppid,\n * \targv: process.argv.slice(1),\n * \tconfig: 'configs/vite.journey.config.ts',\n * \tprojects,\n * })\n * ```\n */\nexport async function answerCaptureDiscovery(options: CaptureDiscoveryOptions): Promise<boolean> {\n\tconst directory = resolveCaptureRequests(options.directory)\n\tconst file = resolve(directory, `${CAPTURE_REQUEST_PREFIX}-${String(options.ppid)}.json`)\n\tif (!existsSync(file)) return false\n\tconst read = attempt(() => readFileSync(file, 'utf8'))\n\tif (!read.success) return false\n\tconst parsed = parseJSON(read.value)\n\tif (!isRecord(parsed) || parsed.phase !== CAPTURE_DISCOVERY.phase) return false\n\tif (parsed.pid !== options.ppid)\n\t\tthrow buildCaptureRequestRefusal(\n\t\t\tfile,\n\t\t\tnew CaptureError('Discovery request does not belong to the parent process', {\n\t\t\t\tcode: 'HOST',\n\t\t\t}),\n\t\t)\n\tconst args = arrayOf(isString)(parsed.args) ? parsed.args : undefined\n\tif (\n\t\targs === undefined ||\n\t\targs.length !== options.argv.length ||\n\t\t!args.every((argument, index) => argument === options.argv[index])\n\t)\n\t\tthrow new CaptureError(\n\t\t\t`Discovery request arguments differ from the process arguments: ${file}`,\n\t\t\t{ code: 'HOST', context: { file } },\n\t\t)\n\tif (parsed.version !== CAPTURE_VERSION)\n\t\tthrow new CaptureError('Discovery request has invalid version', { code: 'HOST' })\n\tif (!isCaptureSegment(parsed.id) || !isCaptureSegment(parsed.nonce))\n\t\tthrow new CaptureError('Discovery request has invalid identity', { code: 'HOST' })\n\tif (parsed.config !== options.config)\n\t\tthrow new CaptureError('Discovery request has invalid config', { code: 'HOST' })\n\tif (parsed.mode !== undefined && (typeof parsed.mode !== 'string' || parsed.mode.trim() === ''))\n\t\tthrow new CaptureError('Discovery request has invalid mode', { code: 'HOST' })\n\tconst answer = resolve(\n\t\tdirectory,\n\t\tCAPTURE_RUNS_DIRECTORY,\n\t\tparsed.id,\n\t\tCAPTURE_DISCOVERY.description,\n\t)\n\tconst prior = existsSync(answer) ? parseJSON(readFileSync(answer, 'utf8')) : undefined\n\tif (prior !== undefined && !(isRecord(prior) && prior.pid === process.pid))\n\t\tthrow new CaptureError(`Discovery was already answered for this request: ${file}`, {\n\t\t\tcode: 'HOST',\n\t\t\tcontext: { file },\n\t\t})\n\t// The projects travel as plain data; the runner reads and judges them, so one reader owns every refusal.\n\tconst mode = typeof parsed.mode === 'string' ? parsed.mode : undefined\n\tconst projects = await Promise.all(\n\t\toptions.projects.map((input) => resolveCaptureWrapperProject(input, mode)),\n\t)\n\twriteCaptureDocument(answer, {\n\t\tversion: CAPTURE_VERSION,\n\t\tid: parsed.id,\n\t\tnonce: parsed.nonce,\n\t\tconfig: options.config,\n\t\tparent: options.ppid,\n\t\tpid: process.pid,\n\t\tprojects,\n\t})\n\treturn true\n}\n\n/**\n * Lists a directory through a reader, answering an empty list for a missing directory.\n *\n * @param directory - The absolute directory to list\n * @param list - Reads the directory's entries, such as `readdirSync` with its options\n * @returns The entries the reader returned, or none when the directory is missing\n * @throws Thrown as an `EVIDENCE` capture error naming the directory for any other failure to read it.\n *\n * @example\n * ```ts\n * readCaptureListing('/repo/tmp/captures/states/pages', (path) => readdirSync(path)) // ['inbox--light-390.png']\n * ```\n */\nexport function readCaptureListing<TEntry>(\n\tdirectory: string,\n\tlist: (path: string) => readonly TEntry[],\n): readonly TEntry[] {\n\tconst listed = attempt(() => list(directory))\n\tif (listed.success) return listed.value\n\tif (isError(listed.error) && 'code' in listed.error && listed.error.code === 'ENOENT') return []\n\tthrow new CaptureError(`Cannot list capture frames under ${directory}`, {\n\t\tcode: 'EVIDENCE',\n\t\tcause: listed.error,\n\t\tcontext: { directory },\n\t})\n}\n\n/**\n * Lists the frames a portfolio directory holds, as paths relative to it, in sorted order.\n *\n * @remarks\n * A frame is a `.png` file at the directory's top level or directly inside one of the scope\n * directories. The run records directory holds no frame, and every other directory is unknown. A\n * missing directory, or one removed between the listing and its read, holds no frame.\n *\n * @param directory - The absolute portfolio directory\n * @param scopes - The scope directories the owners declare, each an owner path's first segment\n * @returns Each frame's slash-separated path relative to the directory\n * @throws Thrown as an `EVIDENCE` capture error for a frame beneath the run records, an unknown\n * directory, a directory inside a scope, or a directory the host refuses to read.\n *\n * @example\n * ```ts\n * readCaptureFrames('/repo/tmp/captures/states', ['pages']) // ['pages/inbox--light-390.png']\n * ```\n */\nexport function readCaptureFrames(directory: string, scopes: readonly string[]): readonly string[] {\n\treturn readCaptureListing(directory, (path) => readdirSync(path, { withFileTypes: true }))\n\t\t.flatMap((entry): readonly string[] => {\n\t\t\tif (!entry.isDirectory()) return entry.name.endsWith('.png') ? [entry.name] : []\n\t\t\tif (entry.name === CAPTURE_RUNS_DIRECTORY) {\n\t\t\t\tconst frames = readCaptureListing(resolve(directory, entry.name), (path) =>\n\t\t\t\t\treaddirSync(path, { recursive: true, encoding: 'utf8' }),\n\t\t\t\t).filter((name) => name.endsWith('.png'))\n\t\t\t\tif (frames.length > 0)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`Frames sit beneath the run records: ${describeCaptureMembers(frames.map(normalizeSlashes))}`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { directory } },\n\t\t\t\t\t)\n\t\t\t\treturn []\n\t\t\t}\n\t\t\tif (!scopes.includes(entry.name))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Unknown capture directory: ${describeCaptureFault('directory', entry.name, 'a scope the owners declare, or the run records', [...scopes, CAPTURE_RUNS_DIRECTORY])}`,\n\t\t\t\t\t{ code: 'EVIDENCE', context: { directory } },\n\t\t\t\t)\n\t\t\treturn readCaptureListing(resolve(directory, entry.name), (path) =>\n\t\t\t\treaddirSync(path, { withFileTypes: true }),\n\t\t\t).flatMap((file): readonly string[] => {\n\t\t\t\tif (file.isDirectory())\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`Unknown capture directory: ${preview(`${entry.name}/${file.name}`)}; a scope holds frames only`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { directory } },\n\t\t\t\t\t)\n\t\t\t\treturn file.name.endsWith('.png') ? [`${entry.name}/${file.name}`] : []\n\t\t\t})\n\t\t})\n\t\t.toSorted()\n}\n\n/**\n * Reads the progress file of the stage that is running, or that ran last, in a workspace.\n *\n * @remarks\n * The file is the most recently modified `<stage>.progress.jsonl` beneath the request directory's\n * run directories. The progress file is an observation of the run and never evidence. A partial\n * last line, which the reporter can still be appending, is not read, so a file with no complete\n * line holds no run. For each run with no `end` line, `alive` reads the process id its `init` line\n * records: a writer that has ended turns the run `interrupted`, measured to the time of its last\n * line, and a writer the host cannot inspect, or an id that is not a positive safe integer, lists\n * the run's id in `uninspected`.\n *\n * @param root - The absolute workspace path\n * @param requests - The workspace-relative request directory\n * @param now - The wall-clock time of the reading, in milliseconds since the Unix epoch. Default: `Date.now()`\n * @param alive - Reads whether a writer process exists, or `undefined` when the host cannot tell. Default: `inspectProcess` from `@orkestrel/process/server`\n * @returns The workspace-relative file, one reading per process that wrote it, and the writers the host could not inspect\n * @throws Thrown as a `STAGE` capture error when no stage has written a progress file, or when the\n * file cannot be read or holds a complete line that is not a progress event.\n *\n * @example\n * ```ts\n * readCaptureProgress('/repo', 'tmp/capture').runs[0]?.state // 'live' while the stage runs\n * ```\n */\nexport function readCaptureProgress(\n\troot: string,\n\trequests: string,\n\tnow: number = Date.now(),\n\talive: (pid: number) => boolean | undefined = inspectProcess,\n): CaptureProgress {\n\tconst runs = resolve(root, requests, CAPTURE_RUNS_DIRECTORY)\n\tconst [newest] = globSync(`*/*${CAPTURE_PROGRESS_SUFFIX}`, { cwd: runs })\n\t\t.flatMap((name) => {\n\t\t\tconst stat = attempt(() => statSync(resolve(runs, name)))\n\t\t\treturn stat.success && stat.value.isFile()\n\t\t\t\t? [{ file: resolveCaptureRelative(root, resolve(runs, name)), time: stat.value.mtimeMs }]\n\t\t\t\t: []\n\t\t})\n\t\t.toSorted((left, right) => right.time - left.time || right.file.localeCompare(left.file))\n\tif (newest === undefined)\n\t\tthrow new CaptureError(\n\t\t\t`No stage has written a progress file under ${resolveCaptureRelative(root, runs)}; run a journey, frames, or registry command first`,\n\t\t\t{ code: 'STAGE', context: { directory: resolveCaptureRelative(root, runs) } },\n\t\t)\n\tconst read = attempt(() =>\n\t\textractProgressEvents(readFileSnapshot(resolve(root, newest.file)).toString('utf8')),\n\t)\n\tif (!read.success)\n\t\tthrow new CaptureError(\n\t\t\t`Cannot read the progress file ${newest.file}: ${describeCaptureOutput(describeCaptureError(read.error))}`,\n\t\t\t{ code: 'STAGE', cause: read.error, context: { file: newest.file } },\n\t\t)\n\tconst events = read.value\n\tconst computed = computeProgress(events, now)\n\tconst writers = new Map(\n\t\tcomputed\n\t\t\t.filter((run) => run.state === 'live')\n\t\t\t.map((run) => [\n\t\t\t\trun.pid,\n\t\t\t\tNumber.isSafeInteger(run.pid) && run.pid > 0 ? alive(run.pid) : undefined,\n\t\t\t]),\n\t)\n\treturn {\n\t\tfile: newest.file,\n\t\truns: computed.map((run): ProgressRun => {\n\t\t\tif (writers.get(run.pid) !== false) return run\n\t\t\t// An interrupted run wrote no end line, so its clock stops at the time of its last line.\n\t\t\tconst own = events.filter((event) => event.pid === run.pid)\n\t\t\tconst init = own.findLast((event): event is ProgressInitEvent => event.event === 'init')\n\t\t\tconst last = own.at(-1)\n\t\t\tconst ended =\n\t\t\t\tinit === undefined || last === undefined\n\t\t\t\t\t? run\n\t\t\t\t\t: (computeProgressRun(own, init.wall + last.time - init.time) ?? run)\n\t\t\treturn { ...ended, state: 'interrupted', running: [], remaining: undefined }\n\t\t}),\n\t\tuninspected: [...writers].flatMap(([pid, answer]) => (answer === undefined ? [pid] : [])),\n\t}\n}\n\n/**\n * Renders a progress reading as the text `capture progress` prints.\n *\n * @param progress - The reading `readCaptureProgress` returns\n * @returns The file line, then each run as `renderProgress` from `@orkestrel/test/server` renders it,\n * followed by an unknown-state line for each run whose writer the host could not inspect\n *\n * @example\n * ```ts\n * renderCaptureProgress({ file: 'tmp/capture/runs/a/selected.progress.jsonl', runs: [], uninspected: [] })\n * // 'progress tmp/capture/runs/a/selected.progress.jsonl\\nNo run has written a complete progress line yet'\n * ```\n */\nexport function renderCaptureProgress(progress: CaptureProgress): string {\n\treturn [\n\t\t`progress ${progress.file}`,\n\t\t...(progress.runs.length === 0\n\t\t\t? ['No run has written a complete progress line yet']\n\t\t\t: progress.runs.flatMap((run) => [\n\t\t\t\t\trenderProgress([run]),\n\t\t\t\t\t...(progress.uninspected.includes(run.pid)\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t` state unknown: the host could not inspect writer ${String(run.pid)}, so the run might have ended without its end line`,\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t: []),\n\t\t\t\t])),\n\t].join('\\n')\n}\n\n/**\n * Builds the values capture merges into one variant's Vitest project.\n *\n * @param options - The wrapper's declarations\n * @param variant - The variant the project produces\n * @param provided - The variant's frame directory, run record path, capture switch, and runner request\n * @returns The owner tags, the provided values, and the `readCaptureFrames` browser command over the directory\n *\n * @example\n * ```ts\n * buildCaptureOverride(options, variant, { directory, record, capture: true }).test.provide.record\n * // 'tmp/captures/states/runs/run-1/selected/light-390.json'\n * ```\n */\nexport function buildCaptureOverride(\n\toptions: Omit<CaptureWrapperOptions<unknown>, 'url' | 'project'>,\n\tvariant: CaptureViewport,\n\tprovided: Pick<CaptureProvided, 'directory' | 'record' | 'capture' | 'request'>,\n): CaptureWrapperOverride {\n\tconst scopes = [\n\t\t...new Set(options.owners.flatMap((owner) => collectCaptureAncestors(owner).slice(0, 1))),\n\t]\n\treturn {\n\t\ttest: {\n\t\t\ttags: buildCaptureTags(options.owners).map((name) => ({ name })),\n\t\t\tprovide: {\n\t\t\t\tvariant: variant.name,\n\t\t\t\tvariants: options.variants,\n\t\t\t\tdirectory: provided.directory,\n\t\t\t\trecord: provided.record,\n\t\t\t\tinputs: options.inputs,\n\t\t\t\tsources: options.sources,\n\t\t\t\tfinal: options.final,\n\t\t\t\tfirst: options.first,\n\t\t\t\t...(options.uniform === undefined ? {} : { uniform: options.uniform }),\n\t\t\t\tportfolios: options.portfolios,\n\t\t\t\tcapture: provided.capture,\n\t\t\t\t...(provided.request === undefined ? {} : { request: provided.request }),\n\t\t\t},\n\t\t\tbrowser: {\n\t\t\t\tcommands: { readCaptureFrames: () => readCaptureFrames(provided.directory, scopes) },\n\t\t\t},\n\t\t},\n\t}\n}\n\n/**\n * Builds a journey wrapper's Vitest configuration as plain data, answering discovery first.\n *\n * @remarks\n * Call it inside the wrapper's own `defineConfig` callback, before any other work: capture imports\n * neither Vite nor Vitest, so the result is data the wrapper returns. The wrapper path is `url`\n * relative to the working directory, which is the workspace root for every child the runner\n * spawns. During a discovery request it describes each variant's project as `{ name, tags,\n * provide }`, with the name the host's `project` chose, and returns `buildCaptureDiscoveryConfig()`.\n * Otherwise it reads the runner's request, provides each project the values `CaptureProvided`\n * declares except `standalone`, and registers the browser command `readCaptureFrames`, which lists the frames under\n * the provided directory. With the capture variable unset, each variant writes to its own scratch\n * sibling of the evidence root, emptied first. The result's root `plugins` holds one\n * `createProgressPlugin()`, so a stage the runner passes `--outputFile.progress` writes its\n * progress file.\n *\n * @param options - The wrapper path, variants, owners, stage and final names, evidence root, inputs, sources, portfolios, and project builder\n * @returns The discovery configuration while discovery runs, and otherwise the progress plugin and one project per variant\n * @throws Thrown as a `HOST` capture error, before any directory work, for a `url` that is no\n * `file:` URL, an evidence root that is not a portable relative path, or a variant name that is no\n * capture segment, and later for an invalid owner or a runner request that fails its checks; and as\n * a `CONTAINMENT` capture error for a wrapper or scratch path outside the workspace.\n *\n * @example\n * ```ts\n * export default defineConfig(({ mode }) =>\n * \tbuildCaptureWrapper({ ...declarations, url: import.meta.url, project: (variant, override) => appJourney(variant, mode, override) }),\n * )\n * ```\n */\nexport async function buildCaptureWrapper<TProject>(\n\toptions: CaptureWrapperOptions<TProject>,\n): Promise<CaptureWrapperConfig<TProject> | CaptureDiscoveryConfig> {\n\tconst root = process.cwd()\n\tconst path = attempt(() => fileURLToPath(options.url))\n\tif (!path.success)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid wrapper url; ${describeCaptureFault('url', options.url, \"the wrapper module's import.meta.url, a file: URL\")}`,\n\t\t\t{ code: 'HOST', cause: path.error },\n\t\t)\n\trequireCaptureContained(root, path.value)\n\tif (!isCapturePath(options.directory))\n\t\tthrow new CaptureError(\n\t\t\t`Invalid evidence root; ${describeCaptureFault('directory', options.directory, 'a portable workspace-relative path')}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\t// A variant name becomes a scratch directory segment that is emptied, so it must name one segment.\n\tconst invalid = options.variants.findIndex((variant) => !isCaptureSegment(variant.name))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid variant name; ${describeCaptureFault(`variants[${String(invalid)}].name`, options.variants[invalid]?.name, 'a portable nonempty identity segment')}`,\n\t\t\t{ code: 'HOST' },\n\t\t)\n\t// A scratch directory is emptied when capture is off, so it must not overlap a root it would empty.\n\tconst roots = [options.directory, ...options.portfolios.map((entry) => entry.directory)]\n\tfor (const variant of options.variants) {\n\t\tconst scratch = resolve(\n\t\t\troot,\n\t\t\tdirname(options.directory),\n\t\t\t`${CAPTURE_WRAPPER_PREFIXES.scratch}${variant.name}`,\n\t\t)\n\t\tconst overlap = roots.find((entry) =>\n\t\t\t[relative(resolve(root, entry), scratch), relative(scratch, resolve(root, entry))].some(\n\t\t\t\t(step) => step === '' || (!step.startsWith('..') && !isAbsolute(step)),\n\t\t\t),\n\t\t)\n\t\tif (overlap !== undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Invalid evidence root; the no-capture scratch directory ${resolveCaptureRelative(root, scratch)} of variant ${variant.name} overlaps ${overlap}, which it would empty`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t}\n\tconst config = resolveCaptureRelative(root, path.value)\n\tconst argv = process.argv.slice(1)\n\tconst capture = process.env[CAPTURE_FLAG] === CAPTURE_FLAG_VALUE\n\tconst evidence = resolve(root, options.directory)\n\tconst answered = await answerCaptureDiscovery({\n\t\tppid: process.ppid,\n\t\targv,\n\t\tconfig,\n\t\tprojects: options.variants.map((variant) => () => {\n\t\t\tconst override = buildCaptureOverride(options, variant, {\n\t\t\t\tdirectory: evidence,\n\t\t\t\trecord: `${options.directory}/${CAPTURE_RUNS_DIRECTORY}/${CAPTURE_DISCOVERY.phase}/${variant.name}.json`,\n\t\t\t\tcapture,\n\t\t\t})\n\t\t\tconst project: unknown = options.project(variant, override)\n\t\t\treturn {\n\t\t\t\ttest: {\n\t\t\t\t\tname: isRecord(project) && isRecord(project.test) ? project.test.name : undefined,\n\t\t\t\t\ttags: override.test.tags,\n\t\t\t\t\tprovide: override.test.provide,\n\t\t\t\t},\n\t\t\t}\n\t\t}),\n\t})\n\tif (answered) return buildCaptureDiscoveryConfig()\n\tconst request = readCaptureRequest({\n\t\tppid: process.ppid,\n\t\targv,\n\t\tconfig,\n\t\towners: options.owners,\n\t\tvariants: options.variants.map((variant) => variant.name),\n\t})\n\tconst invocation =\n\t\trequest === undefined\n\t\t\t? `${CAPTURE_WRAPPER_PREFIXES.direct}${randomUUID()}`\n\t\t\t: `${request.id}/${request.stage}`\n\treturn {\n\t\tplugins: [createProgressPlugin()],\n\t\ttest: {\n\t\t\tprojects: options.variants.map((variant) => {\n\t\t\t\tconst directory = capture\n\t\t\t\t\t? evidence\n\t\t\t\t\t: requireCaptureContained(\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\tresolve(\n\t\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\t\tdirname(options.directory),\n\t\t\t\t\t\t\t\t`${CAPTURE_WRAPPER_PREFIXES.scratch}${variant.name}`,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\tif (!capture) {\n\t\t\t\t\trmSync(directory, { recursive: true, force: true })\n\t\t\t\t\tmkdirSync(directory, { recursive: true })\n\t\t\t\t}\n\t\t\t\treturn options.project(\n\t\t\t\t\tvariant,\n\t\t\t\t\tbuildCaptureOverride(options, variant, {\n\t\t\t\t\t\tdirectory,\n\t\t\t\t\t\trecord: `${options.directory}/${CAPTURE_RUNS_DIRECTORY}/${invocation}/${variant.name}.json`,\n\t\t\t\t\t\tcapture,\n\t\t\t\t\t\t...(request === undefined ? {} : { request }),\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}),\n\t\t},\n\t}\n}\n\n/**\n * Reads the registry command line into the wrapper path, the variants to refresh, and the mode.\n *\n * @remarks\n * The command takes no selector: it refreshes every producing variant the wrapper declares, or the\n * variants named by repeated `--variant` flags. Every flag but valueless `--no-bail` takes one\n * value, and only `--variant` repeats. `--mode` is forwarded to the wrapper's Vitest process\n * unread, and `--no-bail` sets `bail` to `false`.\n *\n * @param argv - The arguments after the subcommand\n * @param root - The absolute workspace path the wrapper path resolves against\n * @param fallback - The repository-relative wrapper path used when `--config` is absent\n * @returns The parsed arguments with an absolute wrapper path\n * @throws Thrown as a `USAGE` capture error for a positional argument, an unknown, repeated, or\n * valueless flag, or a repeated or invalid variant.\n *\n * @example\n * ```ts\n * readCaptureRegistryArguments(['--variant', 'light-390'], '/repo', 'vite.journey.config.ts')\n * // { config: '/repo/vite.journey.config.ts', variants: ['light-390'] }\n * ```\n */\nexport function readCaptureRegistryArguments(\n\targv: readonly string[],\n\troot: string,\n\tfallback: string,\n): CaptureRegistryArguments {\n\tconst usage =\n\t\t'Usage: capture registry [--variant <name>]... [--no-bail] [--mode <name>] [--config <file>]'\n\tconst { values, positionals } = readCaptureOptions(argv, CAPTURE_COMMAND_OPTIONS.registry, usage)\n\tif (positionals.length > 0)\n\t\tthrow new CaptureError(\n\t\t\t`Unexpected argument ${JSON.stringify(positionals[0]?.slice(0, 80))}: the registry command takes no selector and refreshes every producing variant, or those named by --variant. ${usage}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst variants = values.variant ?? []\n\tif (new Set(variants).size !== variants.length)\n\t\tthrow new CaptureError('Repeated variant', { code: 'USAGE' })\n\tconst invalid = variants.findIndex((variant) => !isCaptureSegment(variant))\n\tif (invalid !== -1)\n\t\tthrow new CaptureError(\n\t\t\t`Invalid variant identity; ${describeCaptureFault(`--variant[${String(invalid)}]`, variants[invalid], \"a portable nonempty identity segment; valid values come from the wrapper's variant declarations\")}`,\n\t\t\t{ code: 'USAGE' },\n\t\t)\n\tconst mode = values.mode\n\treturn {\n\t\tconfig: resolve(root, values.config ?? fallback),\n\t\tvariants,\n\t\t...(mode === undefined ? {} : { mode }),\n\t\t...(values.bail === false ? { bail: false } : {}),\n\t}\n}\n\n/**\n * Reads the bounded input population a project declares, as file paths and content hashes.\n *\n * @remarks\n * The expansion is the one the integrity engine takes: the native glob over the patterns, regular\n * files only, sorted, each path contained in the workspace. A pattern that matches nothing\n * contributes no file.\n *\n * @param root - The absolute workspace path\n * @param patterns - The project's native input patterns\n * @param hash - Digests each file's exact bytes. Default: `computeCaptureHash`\n * @param read - Reads a contained input through the owning operation's snapshot memo, when supplied\n * @returns The workspace-relative path of every matched file and its digest\n * @throws Thrown as a `CONTAINMENT` capture error for a matched path the evidence cannot hold, and as\n * an `EVIDENCE` capture error for a path that matches under two spellings.\n *\n * @example\n * ```ts\n * readCaptureInputs(process.cwd(), ['src/**']) // { 'src/a.ts': '3f2a…' }\n * ```\n */\nexport function readCaptureInputs(\n\troot: string,\n\tpatterns: readonly string[],\n\thash: CaptureHashHandler = computeCaptureHash,\n\tread?: CaptureInputHandler,\n): Readonly<Record<string, string>> {\n\tconst files = [...new Set(globSync([...patterns], { cwd: root }).map(normalizeSlashes))]\n\t\t.filter((file) => {\n\t\t\tif (!isCapturePath(file))\n\t\t\t\tthrow new CaptureError(`Input path cannot be held as evidence: ${JSON.stringify(file)}`, {\n\t\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t\t})\n\t\t\treturn statSync(requireCaptureContained(root, resolve(root, file))).isFile()\n\t\t})\n\t\t.toSorted()\n\trequireCaptureUnique(files, 'input paths', true)\n\treturn Object.fromEntries(\n\t\tfiles.flatMap((file) => {\n\t\t\tconst digest =\n\t\t\t\tread === undefined\n\t\t\t\t\t? hash(readFileSync(requireCaptureContained(root, resolve(root, file))))\n\t\t\t\t\t: read(file)\n\t\t\treturn digest === undefined ? [] : [[file, digest]]\n\t\t}),\n\t)\n}\n\n/**\n * Writes one JSON document atomically, so a reader sees the old bytes or the new and never a part.\n *\n * @remarks\n * The document is written to a unique temporary sibling, flushed, and renamed over the target. The\n * signal is checked after the flush and before the rename, and the temporary file never outlives the\n * call.\n *\n * @param path - The absolute target path, whose directory is created when missing\n * @param value - The value to serialize\n * @param signal - Aborts the write before the rename when it fires\n *\n * @example\n * ```ts\n * writeCaptureDocument('/repo/tmp/captures/states/registry.json', registry)\n * ```\n */\nexport function writeCaptureDocument(path: string, value: unknown, signal?: AbortSignal): void {\n\tmkdirSync(dirname(path), { recursive: true })\n\tconst temporary = `${path}.${randomUUID()}.tmp`\n\ttry {\n\t\twriteFileSync(temporary, `${JSON.stringify(value)}\\n`, { flag: 'wx', flush: true })\n\t\tsignal?.throwIfAborted()\n\t\trenameSync(temporary, path)\n\t} finally {\n\t\trmSync(temporary, { force: true })\n\t}\n}\n","import type {\n\tCaptureDiscoveryInterface,\n\tCaptureExecutionResult,\n\tCaptureDiscoveryRequest,\n\tCaptureDiscoveryRunOptions,\n\tCaptureHostDescription,\n} from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport { existsSync, readFileSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { attempt, parseJSON } from '@orkestrel/contract'\nimport { CAPTURE_VERSION, CaptureError, describeCaptureError, isCapturePath } from '@src/core'\nimport { CAPTURE_DISCOVERY, CAPTURE_VITEST_ENTRY } from './constants.js'\nimport {\n\treadCaptureDescription,\n\tresolveCaptureRelative,\n\trequireCaptureArgument,\n} from './helpers.js'\n\n/**\n * Reads a consumer's wrapper by running the consumer's installed Vitest in discovery mode.\n *\n * @remarks\n * The runner never loads the wrapper itself, so it imports neither Vite nor Vitest. It publishes an\n * atomic request with the `discover` phase, spawns the consumer's own Vitest entry through Node as\n * `list --filesOnly --config <wrapper> --configLoader runner`, and reads back the description the\n * wrapper writes when it calls `answerCaptureDiscovery`. The child is bounded by a deadline and\n * recorded by the invocation, so an interrupt ends it with the rest of its tree. The description is\n * accepted only after the child exited zero and every echo in it matches this exchange: the\n * invocation, the challenge, the wrapper, this process as the wrapper's parent, and the spawned\n * child as its writer. A wrapper that never answers, answers another exchange, or answers twice\n * from different processes is refused.\n *\n * @example\n * ```ts\n * const discovery = new CaptureDiscovery({ root: process.cwd(), config, invocation })\n * const { projects } = await discovery.describe()\n * ```\n */\nexport class CaptureDiscovery implements CaptureDiscoveryInterface {\n\treadonly #options: CaptureDiscoveryRunOptions\n\n\t/**\n\t * Binds the workspace, the wrapper, and the invocation that owns the child.\n\t *\n\t * @param options - The workspace, the absolute wrapper path, the invocation, and the optional mode and deadline\n\t */\n\tconstructor(options: CaptureDiscoveryRunOptions) {\n\t\tthis.#options = options\n\t}\n\n\tasync describe(): Promise<CaptureHostDescription> {\n\t\tconst { root, config, invocation, mode, deadline } = this.#options\n\t\tinvocation.prepare()\n\t\trequireCaptureArgument(root, resolve(root, config), '--config')\n\t\tconst relative = resolveCaptureRelative(root, config)\n\t\tif (!isCapturePath(relative))\n\t\t\tthrow new CaptureError('Config must be a contained repository path', { code: 'USAGE' })\n\t\tif (!existsSync(resolve(root, config)))\n\t\t\tthrow new CaptureError(`Cannot find the journey wrapper: ${relative}`, {\n\t\t\t\tcode: 'USAGE',\n\t\t\t\tcontext: { config: relative },\n\t\t\t})\n\t\tconst entry = resolve(root, CAPTURE_VITEST_ENTRY)\n\t\tif (!existsSync(entry))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot find the consumer's installed Vitest: ${CAPTURE_VITEST_ENTRY}; install vitest in the workspace`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\tconst nonce = randomUUID()\n\t\tconst args = [\n\t\t\tentry,\n\t\t\t...CAPTURE_DISCOVERY.arguments,\n\t\t\t'--config',\n\t\t\tresolve(root, config),\n\t\t\t...(mode === undefined ? [] : mode.startsWith('-') ? [`--mode=${mode}`] : ['--mode', mode]),\n\t\t\t'--configLoader',\n\t\t\t'runner',\n\t\t]\n\t\tconst request: CaptureDiscoveryRequest = {\n\t\t\tversion: CAPTURE_VERSION,\n\t\t\tphase: CAPTURE_DISCOVERY.phase,\n\t\t\tid: invocation.id,\n\t\t\tnonce,\n\t\t\tconfig: relative,\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\tpid: process.pid,\n\t\t\targs,\n\t\t}\n\t\tconst answer = resolve(invocation.directory, CAPTURE_DISCOVERY.description)\n\t\tconst log = resolve(invocation.directory, 'discovery.log')\n\t\tconst limit = deadline ?? CAPTURE_DISCOVERY.deadline\n\t\tinvocation.prepare()\n\t\trmSync(answer, { force: true })\n\t\tconst result = await this.#run(request, args, log, limit)\n\t\tif (invocation.interrupted)\n\t\t\tthrow new CaptureError('Runner interrupted', {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcontext: { phase: 'discover' },\n\t\t\t})\n\t\tif (result.expired === true)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Discovery of ${relative} did not finish within ${String(limit)} ms; the child was ended`,\n\t\t\t\t{ code: 'HOST', context: { config: relative } },\n\t\t\t)\n\t\tif (result.code !== 0 || result.signal !== null)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Discovery of ${relative} did not exit successfully (${String(result.code ?? result.signal)}); see ${log}`,\n\t\t\t\t{ code: 'HOST', context: { config: relative } },\n\t\t\t)\n\t\tif (!existsSync(answer))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The wrapper ${relative} answered no discovery request; call answerCaptureDiscovery before any other work`,\n\t\t\t\t{ code: 'HOST', context: { config: relative } },\n\t\t\t)\n\t\tconst read = attempt(() => parseJSON(readFileSync(answer, 'utf8')))\n\t\tif (!read.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The host description cannot be read: ${describeCaptureError(read.error)}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t\tcause: read.error,\n\t\t\t\t},\n\t\t\t)\n\t\treturn readCaptureDescription(read.value, {\n\t\t\tid: invocation.id,\n\t\t\tnonce,\n\t\t\tconfig: relative,\n\t\t\tparent: process.pid,\n\t\t\tpid: result.pid,\n\t\t})\n\t}\n\n\t// Publishes the request for the length of the child, and withdraws it whatever the child does.\n\tasync #run(\n\t\trequest: CaptureDiscoveryRequest,\n\t\targs: readonly string[],\n\t\tlog: string,\n\t\tdeadline: number,\n\t): Promise<CaptureExecutionResult> {\n\t\tconst { invocation } = this.#options\n\t\ttry {\n\t\t\tinvocation.publish(request)\n\t\t\treturn await invocation.spawn(args, log, true, deadline)\n\t\t} finally {\n\t\t\tinvocation.retract()\n\t\t}\n\t}\n}\n","import type {\n\tCaptureCollectionReceipt,\n\tCaptureDestination,\n\tCaptureDigest,\n\tCaptureFreshness,\n\tCaptureLookup,\n\tCaptureRegistry,\n\tCaptureRun,\n\tCaptureStamp,\n\tCaptureExpandedManifest,\n\tCaptureStatus,\n} from '@src/core'\nimport type {\n\tCaptureChangePlan,\n\tCaptureCheckOptions,\n\tCaptureCheckResult,\n\tCaptureCollectionEvidence,\n\tCaptureDirectoryResult,\n\tCaptureEvidence,\n\tCaptureFileSnapshot,\n\tCaptureHashHandler,\n\tCaptureIntegrityInterface,\n\tCaptureIntegrityOptions,\n\tCaptureLookupOptions,\n\tCaptureLookupResult,\n\tCaptureReadOptions,\n\tCaptureReadResult,\n\tCaptureSnapshot,\n\tCaptureStageOptions,\n\tCaptureStageResult,\n\tCaptureStaleOptions,\n} from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { dirname, isAbsolute, matchesGlob, relative, resolve, sep } from 'node:path'\nimport { isRecord, parseJSON } from '@orkestrel/contract'\nimport { executeSync } from '@orkestrel/process/server'\nimport {\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tcollectCaptureChanges,\n\tcollectCaptureDuplicates,\n\tdescribeCaptureDeclaration,\n\tdescribeCaptureDestination,\n\tdescribeCaptureError,\n\tdescribeCaptureIdentity,\n\tdescribeCaptureRequest,\n\tisCaptureError,\n\tisCaptureManifestDocument,\n\tisCapturePath,\n\tisCapturePattern,\n\tisCaptureRegistry,\n\tisCaptureRequest,\n\tisCaptureRun,\n\tisCaptureSegment,\n\tisCaptureSelector,\n\tmatchesCaptureMembers,\n\tmatchesCaptureSelector,\n\treadCaptureDirty,\n\treadCaptureReport,\n\trequireCaptureUnique,\n\tresolveCaptureKey,\n\tresolveCaptureOwner,\n\tresolveCaptureStatus,\n\tvalidateCaptureReceipt,\n\tvalidateCaptureRun,\n} from '@src/core'\nimport {\n\tbuildCaptureChangePlan,\n\tbuildCaptureDigest,\n\tbuildCaptureLookupJournal,\n\tbuildCaptureManifestDocument,\n\treadCaptureManifest,\n\tcomputeCaptureHash,\n\tcomputeRegistryDigest,\n\tmatchesCaptureSignature,\n\tnormalizeSlashes,\n\treadCaptureLookups,\n\treadCaptureInputs,\n\tmatchesCaptureFile,\n\tmergeCaptureLookups,\n\treadCaptureAncestor,\n\tresolveCapturePhysical,\n\tdescribeCaptureSelectorFault,\n\tdescribeCaptureFault,\n\treadCaptureImage,\n\tdescribeCaptureOutput,\n\tfilterCaptureInputs,\n\tcomputeCaptureMatchKey,\n\tcollectCaptureProducers,\n\tmatchesCaptureVersionRefusal,\n\treadCaptureLookupJournal,\n\trequireCaptureProducer,\n\trequireCaptureVersion,\n\tresolveCaptureRegistryFault,\n} from './helpers.js'\n\n/**\n * Validates capture transactions, freshness, and state lookup against real filesystem evidence.\n *\n * @remarks\n * The host supplies every product path, portfolio mapping, and source population; the engine\n * infers none of them from a name. Construct it through `createCaptureIntegrity`, or directly\n * with the same options.\n *\n * @example\n * ```ts\n * const integrity = new CaptureIntegrity({\n * \troot: process.cwd(),\n * \tdirectory: 'tmp/captures/states',\n * \tinputs: ['src/**'],\n * \tregistry: 'tmp/captures/states/registry.json',\n * \tmanifest: 'tmp/captures/states/manifest.json',\n * \tlookups: 'tmp/captures/states/lookups.json',\n * \tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * })\n * ```\n */\nexport class CaptureIntegrity implements CaptureIntegrityInterface {\n\treadonly #options: CaptureIntegrityOptions\n\treadonly #root: string\n\treadonly #roots: ReadonlyMap<string, string>\n\treadonly #hash: CaptureHashHandler\n\t// Glob answers read no disk and the key carries the population digest, so every stamp shares them.\n\treadonly #matches = new Map<string, ReadonlySet<string>>()\n\n\t/**\n\t * Binds the engine to an explicit workspace and host portfolio mapping.\n\t *\n\t * @param options - The workspace, evidence paths, authorized physical roots, and optional file hash\n\t * @throws Thrown when the root is not absolute, a path escapes the root, or a portfolio is invalid.\n\t */\n\tconstructor(options: CaptureIntegrityOptions) {\n\t\tif (!isAbsolute(options.root))\n\t\t\tthrow new CaptureError('Integrity root must be absolute', { code: 'HOST' })\n\t\tthis.#root = realpathSync(options.root)\n\t\tthis.#hash = options.hash ?? computeCaptureHash\n\t\tthis.#options = {\n\t\t\t...options,\n\t\t\tinputs: [...options.inputs],\n\t\t\tportfolios: options.portfolios.map((entry) => ({ ...entry })),\n\t\t}\n\t\tif (options.inputs.length === 0 || !options.inputs.every(isCapturePattern))\n\t\t\tthrow new CaptureError('Invalid bounded host inputs', { code: 'HOST' })\n\t\tfor (const path of [options.directory, options.manifest, options.registry, options.lookups])\n\t\t\tthis.#resolve(path)\n\t\tif (options.portfolios.length === 0)\n\t\t\tthrow new CaptureError('Missing host portfolio roots', { code: 'HOST' })\n\t\trequireCaptureUnique(\n\t\t\toptions.portfolios.map((entry) => entry.portfolio),\n\t\t\t'portfolio identities',\n\t\t\ttrue,\n\t\t)\n\t\trequireCaptureUnique(\n\t\t\toptions.portfolios.map((entry) => entry.directory),\n\t\t\t'portfolio roots',\n\t\t\ttrue,\n\t\t)\n\t\tif (!options.portfolios.every((entry) => isCaptureSegment(entry.portfolio)))\n\t\t\tthrow new CaptureError('Invalid portfolio identity', { code: 'HOST' })\n\t\tthis.#roots = new Map(\n\t\t\toptions.portfolios.map((entry) => [entry.directory, this.#resolve(entry.directory)] as const),\n\t\t)\n\t\tif (!this.#roots.has(options.directory))\n\t\t\tthrow new CaptureError('Primary run directory has no authorized portfolio root', {\n\t\t\t\tcode: 'HOST',\n\t\t\t})\n\t\tfor (const entry of options.portfolios) this.#path(entry.directory)\n\t}\n\n\t/**\n\t * Classifies changes since a Git merge-base through the accepted registry.\n\t *\n\t * @param ref - The Git ref whose merge-base with HEAD bounds tracked changes; HEAD selects uncommitted work\n\t * @returns Every tracked or untracked changed path and the reduced owner selection\n\t * @throws Thrown when Git refuses the ref or the accepted registry cannot be authenticated.\n\t * @example\n\t * ```ts\n\t * const plan = integrity.changed('HEAD')\n\t * ```\n\t */\n\tchanged(ref: string): CaptureChangePlan {\n\t\tconst registry = this.#registry(new Map(), new Map())\n\t\ttry {\n\t\t\tconst commit = this.#git([\n\t\t\t\t'rev-parse',\n\t\t\t\t'--verify',\n\t\t\t\t'--end-of-options',\n\t\t\t\t`${ref}^{commit}`,\n\t\t\t]).trim()\n\t\t\tconst base = this.#git(['merge-base', commit, 'HEAD']).trim()\n\t\t\tconst tracked = this.#git(['diff', '--name-only', '--no-renames', '-z', base, '--'])\n\t\t\tconst untracked = this.#git(['ls-files', '--others', '--exclude-standard', '-z'])\n\t\t\treturn buildCaptureChangePlan(\n\t\t\t\t[tracked, untracked].flatMap((text) => text.split('\\0').filter((path) => path !== '')),\n\t\t\t\tregistry.entries,\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tthrow new CaptureError(describeCaptureError(error), { code: 'HOST', cause: error })\n\t\t}\n\t}\n\n\t/**\n\t * Validates an executed stage before atomically publishing its authorized evidence.\n\t *\n\t * @param options - The exact stage and the runner-owned child execution callback\n\t * @returns The committed stage evidence after every selected sibling validates\n\t * @throws Thrown when execution, identity, records, reporter results, paths, inputs, registry\n\t * evidence, projection, or atomic publication fails. Precommit failures preserve prior\n\t * manifest bytes, and journey requests publish no image stamps.\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await integrity.stamp(stage)\n\t * ```\n\t */\n\tasync stamp(options: CaptureStageOptions): Promise<CaptureStageResult> {\n\t\tconst request = options.request\n\t\tif (!isCaptureRequest(request))\n\t\t\tthrow new CaptureError('Invalid capture stage request', { code: 'HOST' })\n\t\trequireCaptureUnique(request.variants, 'requested variants', true)\n\t\trequireCaptureUnique(\n\t\t\toptions.projects.map((project) => project.name),\n\t\t\t'selected projects',\n\t\t\ttrue,\n\t\t)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\trequest.variants,\n\t\t\t\toptions.projects.map((project) => project.variant),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Selected projects differ from requested variants', { code: 'HOST' })\n\t\tthis.#path(request.config)\n\t\tthis.#path(options.report)\n\t\tif (options.report !== this.#reportPath(request.args))\n\t\t\tthrow new CaptureError('Reporter path differs from requested argv', { code: 'HOST' })\n\t\tfor (const project of options.projects) {\n\t\t\tif (!matchesCaptureMembers(project.inputs, this.#options.inputs))\n\t\t\t\tthrow new CaptureError('Project input population differs from host inputs', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\tif (\n\t\t\t\tproject.record !==\n\t\t\t\t`${this.#options.directory}/runs/${request.id}/${request.stage}/${project.variant}.json`\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Selected record path differs from stage identity', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\tthis.#path(project.record)\n\t\t}\n\t\toptions.signal?.throwIfAborted()\n\t\tif (request.state !== undefined && request.case === undefined)\n\t\t\tthrow new CaptureError('State request must name its resolved declaring case', {\n\t\t\t\tcode: 'SELECTION',\n\t\t\t})\n\t\tconst evidence = this.#evidence(new Map())\n\t\tthis.#uniqueRegistry(evidence.registry.entries)\n\t\tconst before = this.#snapshot(options)\n\t\tconst outcome = await options.execute()\n\t\tconst started = performance.now()\n\t\toptions.signal?.throwIfAborted()\n\t\tif (outcome.code !== 0 || outcome.signal !== null)\n\t\t\tthrow new CaptureError('Capture stage child did not exit successfully', {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcontext: { code: outcome.code, signal: outcome.signal },\n\t\t\t})\n\t\t// The record pass reads each file once; the final check below rereads disk with its own memo.\n\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst digests = new Map<string, CaptureDigest>()\n\t\tconst stable = new Map<string, true>()\n\t\tconst reporter = this.#fresh(options.report, before, snapshots)\n\t\tconst report = readCaptureReport(this.#json(options.report))\n\t\tif (report.start < before.time || report.end > Date.now())\n\t\t\tthrow new CaptureError('Reporter does not belong to this execution', { code: 'EVIDENCE' })\n\t\tif (report.assertions.some((entry) => !request.variants.includes(entry.variant)))\n\t\t\tthrow new CaptureError('Reporter contains an unrequested producing variant', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst records = options.projects.map((project) => {\n\t\t\tconst file = this.#fresh(project.record, before, snapshots)\n\t\t\tconst run = this.#json(project.record)\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\trun.variant !== project.variant ||\n\t\t\t\tdescribeCaptureRequest(run.request) !== describeCaptureRequest(request)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Invalid or mismatched final record: ${project.record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (Date.parse(run.time) < before.time || Date.parse(run.time) > report.end)\n\t\t\t\tthrow new CaptureError('Final record time does not belong to this execution', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureRun(run, report, project.name)\n\t\t\tif (run.artifact === undefined)\n\t\t\t\tthrow new CaptureError(`Final record names no journey artifact: ${project.record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst artifact = this.#fresh(run.artifact.file, before, snapshots)\n\t\t\tif (artifact.image.digest !== run.artifact.digest)\n\t\t\t\tthrow new CaptureError(`Journey artifact differs from its record: ${run.artifact.file}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tfor (const destination of run.registry) this.#destination(destination)\n\t\t\tconst snapshot = before.projects.find((entry) => entry.project === project.name)\n\t\t\tif (snapshot === undefined)\n\t\t\t\tthrow new CaptureError('Missing pre-execution project snapshot', { code: 'EVIDENCE' })\n\t\t\tthis.#attest(run, evidence, snapshot.inputs.files, snapshots)\n\t\t\tfor (const destination of run.registry)\n\t\t\t\tthis.#stable(destination, snapshot.inputs, snapshots, digests, stable)\n\t\t\treturn { file, run, artifact }\n\t\t})\n\t\tconst entries = records.flatMap(({ run }) => run.entries)\n\t\tthis.#uniqueRegistry(entries)\n\t\tconst images = entries.map((entry) => this.#fresh(entry.file, before, snapshots, true))\n\t\tconst identities = new Map<string, string>()\n\t\tconst physical = Map.groupBy(this.#images(), (file) => this.#physicalIdentity(file, identities))\n\t\tif (\n\t\t\tentries.some(\n\t\t\t\t(entry) => (physical.get(this.#physicalIdentity(entry.file, identities))?.length ?? 0) > 1,\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Duplicate physical capture output', { code: 'EVIDENCE' })\n\t\tconst provenance = request.command === 'capture' ? this.#provenance() : undefined\n\t\tconst stamps: readonly CaptureStamp[] = entries.map((entry) => {\n\t\t\tconst image = images.find((snapshot) => snapshot.file === entry.file)\n\t\t\tif (image === undefined || provenance === undefined)\n\t\t\t\tthrow new CaptureError('Missing capture provenance', { code: 'EVIDENCE' })\n\t\t\treturn {\n\t\t\t\t...entry,\n\t\t\t\tidentity: {\n\t\t\t\t\tid: request.id,\n\t\t\t\t\tstage: request.stage,\n\t\t\t\t\tpid: request.pid,\n\t\t\t\t\tconfig: request.config,\n\t\t\t\t},\n\t\t\t\ttime: new Date().toISOString(),\n\t\t\t\t...provenance,\n\t\t\t\town: this.#digest(entry.sources.own, snapshots, digests).files,\n\t\t\t\tshared: this.#digest(entry.sources.shared, snapshots, digests),\n\t\t\t\ttests: this.#digest(entry.sources.tests, snapshots, digests).files,\n\t\t\t\timage: image.image,\n\t\t\t\tregistry: evidence.registry.digest,\n\t\t\t}\n\t\t})\n\t\tconst lookups: readonly CaptureLookup[] = records.flatMap(({ run, file }) => {\n\t\t\tconst project = options.projects.find((entry) => entry.variant === run.variant)\n\t\t\tif (project === undefined)\n\t\t\t\tthrow new CaptureError('Missing selected project', { code: 'EVIDENCE' })\n\t\t\tconst inputs = this.#digest(project.inputs, snapshots, digests).files\n\t\t\treturn run.declarations\n\t\t\t\t.filter((entry) => run.passed.includes(entry.case))\n\t\t\t\t.map((entry) => ({\n\t\t\t\t\tregistry: evidence.registry.digest,\n\t\t\t\t\tvariant: run.variant,\n\t\t\t\t\tcase: entry.case,\n\t\t\t\t\towner: entry.owner,\n\t\t\t\t\tstates: entry.states,\n\t\t\t\t\tinputs,\n\t\t\t\t\trun: { file: file.file, digest: file.image.digest },\n\t\t\t\t}))\n\t\t})\n\t\tconst collected: readonly CaptureCollectionReceipt[] = records.map(({ run, file }) => {\n\t\t\tconst project = options.projects.find((entry) => entry.variant === run.variant)\n\t\t\tconst snapshot = before.projects.find((entry) => entry.project === project?.name)\n\t\t\tif (project === undefined || snapshot === undefined)\n\t\t\t\tthrow new CaptureError('Missing full-collection input snapshot', { code: 'EVIDENCE' })\n\t\t\treturn {\n\t\t\t\tregistry: evidence.registry.digest,\n\t\t\t\tvariant: run.variant,\n\t\t\t\tproject: project.name,\n\t\t\t\tinputs: snapshot.inputs,\n\t\t\t\trun: { file: file.file, digest: file.image.digest },\n\t\t\t\treport: { file: reporter.file, digest: reporter.image.digest },\n\t\t\t}\n\t\t})\n\t\tconst collections = this.#mergeCollections(evidence.collections, collected)\n\t\tconst merged = mergeCaptureLookups(evidence.lookups, lookups)\n\t\tconst finalSnapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst redigests = new Map<string, CaptureDigest>()\n\t\tconst restable = new Map<string, true>()\n\t\tfor (const record of records) {\n\t\t\tconst project = before.projects.find((entry) =>\n\t\t\t\toptions.projects.some(\n\t\t\t\t\t(selected) => selected.name === entry.project && selected.variant === record.run.variant,\n\t\t\t\t),\n\t\t\t)\n\t\t\tif (project === undefined)\n\t\t\t\tthrow new CaptureError('Missing final input snapshot', { code: 'EVIDENCE' })\n\t\t\tfor (const destination of record.run.registry)\n\t\t\t\tthis.#stable(destination, project.inputs, finalSnapshots, redigests, restable)\n\t\t\tif (\n\t\t\t\tthis.#digest(project.inputs.patterns, finalSnapshots, redigests).digest !==\n\t\t\t\tproject.inputs.digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Bounded host inputs or membership changed during execution', {\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t})\n\t\t}\n\t\tfor (const path of [this.#options.manifest, this.#options.registry, this.#options.lookups]) {\n\t\t\tif (\n\t\t\t\tthis.#file(path, finalSnapshots)?.image.digest !==\n\t\t\t\tbefore.files.find((file) => file.file === path)?.image.digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Evidence changed during the stage: ${path}`, { code: 'STAGE' })\n\t\t}\n\t\tif (\n\t\t\tthis.#file(options.report, finalSnapshots)?.image.digest !== reporter.image.digest ||\n\t\t\trecords.some(\n\t\t\t\t(record) =>\n\t\t\t\t\tthis.#file(record.file.file, finalSnapshots)?.image.digest !== record.file.image.digest ||\n\t\t\t\t\tthis.#file(record.artifact.file, finalSnapshots)?.image.digest !==\n\t\t\t\t\t\trecord.artifact.image.digest,\n\t\t\t) ||\n\t\t\timages.some((image) => !matchesCaptureFile(image, this.#file(image.file, finalSnapshots)))\n\t\t)\n\t\t\tthrow new CaptureError('Stage output changed before commit', { code: 'STAGE' })\n\t\toptions.signal?.throwIfAborted()\n\t\tif (request.command === 'capture' && stamps.length > 0) {\n\t\t\tconst inherited = Object.entries(evidence.manifest?.entries ?? {})\n\t\t\tconst replaced = new Set(stamps.map(resolveCaptureKey))\n\t\t\tconst next: CaptureExpandedManifest = {\n\t\t\t\tcollections,\n\t\t\t\tversion: CAPTURE_VERSION,\n\t\t\t\tregistry: evidence.registry,\n\t\t\t\tentries: Object.fromEntries([\n\t\t\t\t\t...inherited.filter(([key]) => !replaced.has(key)),\n\t\t\t\t\t...stamps.map((stamp) => [resolveCaptureKey(stamp), stamp] as const),\n\t\t\t\t]),\n\t\t\t\tlookups: merged,\n\t\t\t}\n\t\t\tconst document = buildCaptureManifestDocument(next)\n\t\t\tif (!isCaptureManifestDocument(document))\n\t\t\t\tthrow new CaptureError('Invalid next manifest', { code: 'EVIDENCE' })\n\t\t\tthis.#commit(this.#options.manifest, document, options.signal)\n\t\t} else if (request.command === 'journey' && collected.length > 0) {\n\t\t\tconst manifest = before.files.find((file) => file.file === this.#options.manifest)?.image\n\t\t\t\t.digest\n\t\t\tthis.#commit(\n\t\t\t\tthis.#options.lookups,\n\t\t\t\tbuildCaptureLookupJournal(merged, collections, manifest),\n\t\t\t\toptions.signal,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\trequest,\n\t\t\tentries: stamps,\n\t\t\tlookups,\n\t\t\tduration: performance.now() - started,\n\t\t\tprojects: records.map(({ run, file }) => ({\n\t\t\t\tproject: options.projects.find((project) => project.variant === run.variant)?.name ?? '',\n\t\t\t\tvariant: run.variant,\n\t\t\t\trecord: { file: file.file, digest: file.image.digest },\n\t\t\t\tdeclarations: run.declarations,\n\t\t\t\tpassed: run.passed,\n\t\t\t})),\n\t\t}\n\t}\n\n\t/**\n\t * Reads current full-collection evidence and selects exact declaration destinations.\n\t *\n\t * @param options - The explicit selection; omitted variants derive from authenticated mappings\n\t * @returns The accepted registry identity and exactly selected destinations\n\t * @throws Thrown with explicit preparation when declarations lack current authenticated evidence.\n\t *\n\t * @example\n\t * ```ts\n\t * const { entries } = await integrity.read({ selector: 'pages:mail' })\n\t * ```\n\t */\n\tasync read(options: CaptureReadOptions): Promise<CaptureReadResult> {\n\t\ttry {\n\t\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\t\tconst digests = new Map<string, CaptureDigest>()\n\t\t\tconst evidence = this.#evidence(snapshots)\n\t\t\tconst collections = this.#collections(evidence, snapshots)\n\t\t\tconst populated = this.#population(evidence, collections)\n\t\t\tconst destinations = this.#destinations(populated)\n\t\t\tthis.#uniqueRegistry(destinations)\n\t\t\tconst variants = this.#variants(destinations, options)\n\t\t\tconst entries = this.#select(destinations, { ...options, variants })\n\t\t\tconst inputs = this.#digest(this.#options.inputs, snapshots, digests)\n\t\t\tconst producers = collectCaptureProducers(populated)\n\t\t\tfor (const variant of new Set(\n\t\t\t\tentries.map((entry) => requireCaptureProducer(entry, producers)),\n\t\t\t)) {\n\t\t\t\tconst anchor = evidence.registry.receipts.find((receipt) => receipt.variant === variant)\n\t\t\t\tif (anchor !== undefined && collectCaptureChanges(anchor.inputs, inputs.files).length === 0)\n\t\t\t\t\tcontinue\n\t\t\t\tif (\n\t\t\t\t\t!collections.some(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.run.variant === variant && entry.receipt.inputs.digest === inputs.digest,\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`No current full-collection evidence for producing variant: ${variant}`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { variant } },\n\t\t\t\t\t)\n\t\t\t}\n\t\t\t// The final check rereads disk; the read's memo would hide a change made since it measured.\n\t\t\tif (this.#digest(this.#options.inputs, new Map(), new Map()).digest !== inputs.digest)\n\t\t\t\tthrow new CaptureError('Declaration inputs changed during the read', { code: 'EVIDENCE' })\n\t\t\treturn { registry: evidence.registry.digest, entries }\n\t\t} catch (error) {\n\t\t\tif (matchesCaptureVersionRefusal(error)) throw error\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureError(error)}. Prepare the explicit complete-registry refresh, or an explicit capture-free owner/case run whose full collection equals that anchor for each affected producing variant; this read starts no process.`,\n\t\t\t\t{ code: isCaptureError(error) ? error.code : 'EVIDENCE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Checks the explicitly selected output population without changing evidence or images.\n\t *\n\t * @param selection - The selected owners, optional output variants, state, and portfolio, and\n\t * the wrapper's declared producing variants. Default variants: every output variant of the\n\t * selected registry destinations.\n\t * @returns Freshness classifications and warnings for the selected population\n\t * @throws Thrown when required evidence, schema, containment, or selection is invalid, or when\n\t * variants are omitted and a declared producing variant has no registry evidence.\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await integrity.check({ selector: 'pages:mail' })\n\t * ```\n\t */\n\tasync check(selection: CaptureStaleOptions): Promise<CaptureCheckResult> {\n\t\tconst started = performance.now()\n\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst digests = new Map<string, CaptureDigest>()\n\t\tconst previous = this.#evidence(snapshots)\n\t\tconst evidence = this.#population(previous, this.#collections(previous, snapshots))\n\t\t// Destinations alone cannot show a producing variant whose full collection never arrived.\n\t\tconst attested = new Set([\n\t\t\t...evidence.registry.receipts.map((receipt) => receipt.variant),\n\t\t\t...evidence.runs.map(({ run }) => run.variant),\n\t\t])\n\t\tconst unattested =\n\t\t\tselection.variants === undefined\n\t\t\t\t? (selection.declared ?? []).filter((variant) => !attested.has(variant))\n\t\t\t\t: []\n\t\tif (unattested.length > 0)\n\t\t\tthrow new CaptureError(`Unattested declared variant: ${unattested.join(', ')}`, {\n\t\t\t\tcode: 'REGISTRY',\n\t\t\t\tcontext: { variants: unattested },\n\t\t\t})\n\t\tconst registry = this.#destinations(evidence)\n\t\tconst options: CaptureCheckOptions = {\n\t\t\t...selection,\n\t\t\tvariants: this.#variants(registry, selection),\n\t\t}\n\t\tconst required = this.#select(registry, options)\n\t\tconst disk = this.#images()\n\t\tconst identities = new Map<string, string>()\n\t\tconst physical = Map.groupBy(disk, (file) => this.#physicalIdentity(file, identities))\n\t\tconst duplicates = collectCaptureDuplicates(registry.map(resolveCaptureKey), true)\n\t\tconst entries: CaptureFreshness[] = required.map((entry) => {\n\t\t\tconst key = resolveCaptureKey(entry)\n\t\t\tconst stamp = evidence.manifest?.entries[key]\n\t\t\tconst image = this.#file(entry.file, snapshots)\n\t\t\tconst own = this.#digest(entry.sources.own, snapshots, digests)\n\t\t\tconst shared = this.#digest(entry.sources.shared, snapshots, digests)\n\t\t\tconst findings: Array<{ readonly status: CaptureStatus; readonly reason: string }> = []\n\t\t\tif (duplicates.includes(key))\n\t\t\t\tfindings.push({ status: 'duplicate', reason: 'Repeated registry identity' })\n\t\t\tif ((physical.get(this.#physicalIdentity(entry.file, identities))?.length ?? 0) > 1)\n\t\t\t\tfindings.push({ status: 'duplicate', reason: 'Several paths name the same physical image' })\n\t\t\tif (image === undefined)\n\t\t\t\tfindings.push({ status: 'missing', reason: 'Required image is absent' })\n\t\t\tif (stamp === undefined)\n\t\t\t\tfindings.push({ status: 'unstamped', reason: 'Required image has no authorized stamp' })\n\t\t\telse {\n\t\t\t\tif (stamp.file !== entry.file || resolveCaptureOwner(stamp) !== resolveCaptureOwner(entry))\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'orphan',\n\t\t\t\t\t\treason: 'Stamp names an obsolete physical location or owner',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\timage !== undefined &&\n\t\t\t\t\t(image.image.digest !== stamp.image.digest ||\n\t\t\t\t\t\timage.image.size !== stamp.image.size ||\n\t\t\t\t\t\timage.image.modified !== stamp.image.modified)\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'unstamped',\n\t\t\t\t\t\treason: 'Image digest, size, or modification time differs',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\t!matchesCaptureMembers(stamp.sources.shared, entry.sources.shared) ||\n\t\t\t\t\tshared.digest !== stamp.shared.digest\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'stale-shared',\n\t\t\t\t\t\treason: 'Shared source patterns, membership, or hashes changed',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\t!matchesCaptureMembers(stamp.sources.own, entry.sources.own) ||\n\t\t\t\t\tcollectCaptureChanges(stamp.own, own.files).length > 0 ||\n\t\t\t\t\tentry.sources.own.some(\n\t\t\t\t\t\t(pattern) => !Object.keys(own.files).some((file) => matchesGlob(file, pattern)),\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'stale-own',\n\t\t\t\t\t\treason: 'Own source patterns, membership, or hashes changed',\n\t\t\t\t\t})\n\t\t\t\tif (\n\t\t\t\t\tstamp.case !== entry.case ||\n\t\t\t\t\tstamp.project !== entry.project ||\n\t\t\t\t\tstamp.portfolio !== entry.portfolio\n\t\t\t\t)\n\t\t\t\t\tfindings.push({\n\t\t\t\t\t\tstatus: 'orphan',\n\t\t\t\t\t\treason: 'Stamp declaring case, project, or portfolio is obsolete',\n\t\t\t\t\t})\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tfile: entry.file,\n\t\t\t\tstate: entry.state,\n\t\t\t\tvariant: entry.variant,\n\t\t\t\tstatus: resolveCaptureStatus(findings.map((finding) => finding.status)),\n\t\t\t\treasons: findings.map((finding) => finding.reason),\n\t\t\t}\n\t\t})\n\t\tconst extras = disk\n\t\t\t.filter(\n\t\t\t\t(file) =>\n\t\t\t\t\t!required.some((entry) => entry.file === file) &&\n\t\t\t\t\tthis.#attributable(file, required, registry, options),\n\t\t\t)\n\t\t\t.map((file) => {\n\t\t\t\tconst name = file.slice(file.lastIndexOf('/') + 1, -4)\n\t\t\t\tconst separator = name.lastIndexOf('--')\n\t\t\t\treturn {\n\t\t\t\t\tfile,\n\t\t\t\t\tstate: separator < 0 ? name : name.slice(0, separator),\n\t\t\t\t\tvariant: separator < 0 ? '' : name.slice(separator + 2),\n\t\t\t\t\tstatus: 'orphan' as const,\n\t\t\t\t\treasons: ['Physical PNG has no selected canonical registry destination'],\n\t\t\t\t}\n\t\t\t})\n\t\tconst warnings = required.flatMap((entry) => {\n\t\t\tconst stamp = evidence.manifest?.entries[resolveCaptureKey(entry)]\n\t\t\tif (stamp === undefined) return []\n\t\t\tconst files = collectCaptureChanges(\n\t\t\t\tstamp.tests,\n\t\t\t\tthis.#digest(entry.sources.tests, snapshots, digests).files,\n\t\t\t)\n\t\t\treturn files.length === 0 ? [] : [{ files, cases: [entry.case] }]\n\t\t})\n\t\treturn {\n\t\t\trequired,\n\t\t\tentries: [...entries, ...extras],\n\t\t\twarnings,\n\t\t\tduration: performance.now() - started,\n\t\t}\n\t}\n\n\t/**\n\t * Resolves an explicitly requested state through fresh registry and passing case evidence.\n\t *\n\t * @param options - The original selector, producing variants, state, and optional exact case\n\t * @returns The agreed declaring case, output mappings, and validated lookup receipts\n\t * @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection; a\n\t * refusal of the requested state names the owner's journey refresh, and a fault in the evidence\n\t * read keeps its own message.\n\t *\n\t * @example\n\t * ```ts\n\t * const { case: name } = await integrity.lookup({ selector: 'pages:mail', state: 'inbox', variants: ['light-390'] })\n\t * ```\n\t */\n\tasync lookup(options: CaptureLookupOptions): Promise<CaptureLookupResult> {\n\t\ttry {\n\t\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\t\tconst digests = new Map<string, CaptureDigest>()\n\t\t\tconst evidence = this.#evidence(snapshots)\n\t\t\tconst entries = this.#select(\n\t\t\t\tthis.#destinations(evidence),\n\t\t\t\toptions,\n\t\t\t\tcollectCaptureProducers(evidence),\n\t\t\t)\n\t\t\tthis.#uniqueRegistry(entries)\n\t\t\tconst cases = [...new Set(entries.map((entry) => entry.case))]\n\t\t\tconst [name] = cases\n\t\t\tif (\n\t\t\t\tname === undefined ||\n\t\t\t\tcases.length !== 1 ||\n\t\t\t\t(options.case !== undefined && options.case !== name)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t'State declaring case disagrees with the exact case or producing variants',\n\t\t\t\t\t{ code: 'SELECTION' },\n\t\t\t\t)\n\t\t\tconst lookups = entries.map((entry) => {\n\t\t\t\tconst run = evidence.runs.find((record) =>\n\t\t\t\t\trecord.run.registry.some(\n\t\t\t\t\t\t(destination) =>\n\t\t\t\t\t\t\tdescribeCaptureDestination(destination) === describeCaptureDestination(entry),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\tconst lookup = evidence.lookups.find(\n\t\t\t\t\t(candidate) =>\n\t\t\t\t\t\tcandidate.case === entry.case &&\n\t\t\t\t\t\tcandidate.variant === run?.run.variant &&\n\t\t\t\t\t\tcandidate.states.includes(options.state),\n\t\t\t\t)\n\t\t\t\tif (\n\t\t\t\t\tlookup === undefined ||\n\t\t\t\t\tlookup.registry !== evidence.registry.digest ||\n\t\t\t\t\t!matchesCaptureSelector(lookup.owner, options.selector) ||\n\t\t\t\t\tcollectCaptureChanges(\n\t\t\t\t\t\tlookup.inputs,\n\t\t\t\t\t\tthis.#digest(this.#options.inputs, snapshots, digests).files,\n\t\t\t\t\t).length > 0\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`Missing or stale state lookup: ${entry.state} in ${entry.project}`,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'LOOKUP',\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\tconst stamp = evidence.manifest?.entries[resolveCaptureKey(entry)]\n\t\t\t\tif (\n\t\t\t\t\tstamp !== undefined &&\n\t\t\t\t\tdescribeCaptureIdentity(stamp) !== describeCaptureIdentity(entry)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError('State lookup disagrees with the manifest identity', {\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t})\n\t\t\t\treturn lookup\n\t\t\t})\n\t\t\treturn { case: name, entries, lookups }\n\t\t} catch (error) {\n\t\t\tif (matchesCaptureVersionRefusal(error)) throw error\n\t\t\tconst code = isCaptureError(error) ? error.code : 'EVIDENCE'\n\t\t\t// The journey refresh answers the lookup's own refusals, never a fault in the evidence it read.\n\t\t\tthrow new CaptureError(\n\t\t\t\tcode === 'LOOKUP' || code === 'USAGE' || code === 'SELECTION'\n\t\t\t\t\t? `${describeCaptureError(error)}. Refresh explicitly with: capture journey ${options.selector}${options.variants.map((variant) => ` --variant ${variant}`).join('')}${options.case === undefined ? '' : ` --case ${JSON.stringify(options.case)}`}. Registry declaration changes require the complete-registry refresh: capture registry.`\n\t\t\t\t\t: describeCaptureError(error),\n\t\t\t\t{ code, cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\t// Omitted output variants mean every variant the selected registry destinations declare.\n\t#variants(\n\t\tdestinations: readonly CaptureDestination[],\n\t\toptions: CaptureReadOptions,\n\t): readonly string[] {\n\t\treturn (\n\t\t\toptions.variants ?? [\n\t\t\t\t...new Set(\n\t\t\t\t\tdestinations\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\t\tmatchesCaptureSelector(resolveCaptureOwner(entry), options.selector) &&\n\t\t\t\t\t\t\t\t(options.portfolio === undefined || entry.portfolio === options.portfolio),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((entry) => entry.variant),\n\t\t\t\t),\n\t\t\t]\n\t\t)\n\t}\n\n\t#mergeCollections(\n\t\tprevious: readonly CaptureCollectionReceipt[],\n\t\treceipts: readonly CaptureCollectionReceipt[],\n\t): readonly CaptureCollectionReceipt[] {\n\t\trequireCaptureUnique(\n\t\t\tprevious.map((entry) => entry.run.file),\n\t\t\t'inherited collection records',\n\t\t\ttrue,\n\t\t)\n\t\trequireCaptureUnique(\n\t\t\treceipts.map((entry) => entry.run.file),\n\t\t\t'incoming collection records',\n\t\t\ttrue,\n\t\t)\n\t\tconst replaced = new Set(receipts.map((entry) => entry.run.file))\n\t\tconst merged = [...previous.filter((entry) => !replaced.has(entry.run.file)), ...receipts]\n\t\t// Keep one lineage origin and the latest collection per producing variant.\n\t\treturn merged.filter(\n\t\t\t(entry, index) =>\n\t\t\t\tmerged.findIndex((candidate) => candidate.variant === entry.variant) === index ||\n\t\t\t\tmerged.findLastIndex((candidate) => candidate.variant === entry.variant) === index,\n\t\t)\n\t}\n\n\t#collections(\n\t\tevidence: CaptureEvidence,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t): readonly CaptureCollectionEvidence[] {\n\t\tconst collections = evidence.collections.map((receipt) => {\n\t\t\tconst file = this.#file(receipt.run.file, snapshots)\n\t\t\tconst report = this.#file(receipt.report.file, snapshots)\n\t\t\tif (\n\t\t\t\tfile === undefined ||\n\t\t\t\treport === undefined ||\n\t\t\t\tfile.image.digest !== receipt.run.digest ||\n\t\t\t\treport.image.digest !== receipt.report.digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Collection record or report bytes changed: ${receipt.variant}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (\n\t\t\t\treceipt.inputs.digest !==\n\t\t\t\tbuildCaptureDigest(receipt.inputs.patterns, receipt.inputs.files).digest\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Invalid collection input digest', { code: 'EVIDENCE' })\n\t\t\tfor (const path of Object.keys(receipt.inputs.files)) this.#path(path)\n\t\t\tconst run = this.#json(receipt.run.file)\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\trun.variant !== receipt.variant ||\n\t\t\t\treceipt.run.file !==\n\t\t\t\t\t`${this.#options.directory}/runs/${run.request.id}/${run.request.stage}/${run.variant}.json` ||\n\t\t\t\treceipt.report.file !== this.#reportPath(run.request.args)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Collection has no matching authorized runner record', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureRun(run, readCaptureReport(this.#json(receipt.report.file)), receipt.project)\n\t\t\tthis.#uniqueRegistry(run.registry)\n\t\t\tfor (const destination of run.registry) this.#destination(destination)\n\t\t\treturn { receipt, file, run }\n\t\t})\n\t\tfor (const collection of collections) {\n\t\t\tconst anchor = evidence.registry.receipts.find(\n\t\t\t\t(receipt) => receipt.variant === collection.run.variant,\n\t\t\t)\n\t\t\tconst baseline =\n\t\t\t\tanchor ??\n\t\t\t\tcollections.find(\n\t\t\t\t\t(candidate) =>\n\t\t\t\t\t\tcandidate.run.variant === collection.run.variant &&\n\t\t\t\t\t\tevidence.registry.receipts.some(\n\t\t\t\t\t\t\t(receipt) =>\n\t\t\t\t\t\t\t\tcollectCaptureChanges(receipt.inputs, candidate.receipt.inputs.files).length === 0,\n\t\t\t\t\t\t),\n\t\t\t\t)?.run\n\t\t\tif (baseline === undefined)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Collection has no complete-anchor provenance: ${collection.run.variant}`,\n\t\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t\t)\n\t\t\tif (\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tbaseline.declarations.map(describeCaptureDeclaration),\n\t\t\t\t\tcollection.run.declarations.map(describeCaptureDeclaration),\n\t\t\t\t) ||\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tbaseline.registry.map(describeCaptureDestination),\n\t\t\t\t\tcollection.run.registry.map(describeCaptureDestination),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Collection declarations differ from the complete anchor', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t}\n\t\treturn collections\n\t}\n\n\t#population(\n\t\tevidence: CaptureEvidence,\n\t\tcollections: readonly CaptureCollectionEvidence[],\n\t): CaptureEvidence {\n\t\treturn { ...evidence, runs: collections.map(({ file, run }) => ({ file, run })) }\n\t}\n\n\t// A physical path resolves inside the integrity root, whatever its portfolio.\n\t#resolve(file: string): string {\n\t\tif (!isCapturePath(file))\n\t\t\tthrow new CaptureError(`Invalid serialized path: ${file}`, { code: 'CONTAINMENT' })\n\t\tconst path = resolve(this.#root, ...file.split('/'))\n\t\tthis.#contained(path)\n\t\tconst ancestor = readCaptureAncestor(path)\n\t\tthis.#contained(realpathSync(ancestor))\n\t\treturn path\n\t}\n\n\t// A path under a portfolio root also resolves inside that root's physical directory.\n\t#path(file: string, paths?: Map<string, string>): string {\n\t\tconst known = paths?.get(file)\n\t\tif (known !== undefined) return known\n\t\tconst path = this.#resolve(file)\n\t\tfor (const [directory, authorized] of this.#roots) {\n\t\t\tif (file !== directory && !file.startsWith(`${directory}/`)) continue\n\t\t\tconst suffix = relative(authorized, resolveCapturePhysical(path))\n\t\t\tif (isAbsolute(suffix) || suffix === '..' || suffix.startsWith(`..${sep}`))\n\t\t\t\tthrow new CaptureError(`Physical path resolves outside authorized capture root: ${file}`, {\n\t\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t\t})\n\t\t}\n\t\tpaths?.set(file, path)\n\t\treturn path\n\t}\n\n\t#contained(path: string): void {\n\t\tconst suffix = relative(this.#root, path)\n\t\tif (isAbsolute(suffix) || suffix === '..' || suffix.startsWith(`..${sep}`))\n\t\t\tthrow new CaptureError(`Physical path resolves outside integrity root: ${path}`, {\n\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t})\n\t}\n\n\t// Reads each path once per pass; the pass owns the memo and discards it when it ends.\n\t#file(\n\t\tfile: string,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tpaths?: Map<string, string>,\n\t): CaptureFileSnapshot | undefined {\n\t\tif (snapshots.has(file)) return snapshots.get(file)\n\t\tconst snapshot = this.#readFile(file, paths)\n\t\tsnapshots.set(file, snapshot)\n\t\treturn snapshot\n\t}\n\n\t#readFile(file: string, paths?: Map<string, string>): CaptureFileSnapshot | undefined {\n\t\tconst path = this.#path(file, paths)\n\t\tif (!existsSync(path)) return undefined\n\t\tconst stat = statSync(path)\n\t\tif (!stat.isFile())\n\t\t\tthrow new CaptureError(`Expected a physical file: ${file}`, { code: 'CONTAINMENT' })\n\t\treturn {\n\t\t\tfile,\n\t\t\timage: {\n\t\t\t\tdigest: this.#hash(\n\t\t\t\t\tfile.toLowerCase().endsWith('.png') ? readCaptureImage(path) : readFileSync(path),\n\t\t\t\t),\n\t\t\t\tsize: stat.size,\n\t\t\t\tmodified: stat.mtimeMs,\n\t\t\t},\n\t\t\tchanged: stat.ctimeMs,\n\t\t}\n\t}\n\n\t#json(file: string, paths?: Map<string, string>): unknown {\n\t\tconst document: unknown = parseJSON(readFileSync(this.#path(file, paths), 'utf8'))\n\t\tif (!isRecord(document))\n\t\t\tthrow new CaptureError(`Invalid JSON document: ${file}`, { code: 'EVIDENCE' })\n\t\treturn document\n\t}\n\n\t// Expands each pattern list once per pass; the digest sorts its patterns, so sorted lists share a key.\n\t#digest(\n\t\tpatterns: readonly string[],\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tdigests: Map<string, CaptureDigest>,\n\t): CaptureDigest {\n\t\tif (!patterns.every(isCapturePattern))\n\t\t\tthrow new CaptureError('Invalid source attribution pattern', { code: 'HOST' })\n\t\trequireCaptureUnique(patterns, 'source patterns', true)\n\t\tconst key = JSON.stringify(patterns.toSorted())\n\t\tconst known = digests.get(key)\n\t\tif (known !== undefined) return known\n\t\tconst digest = buildCaptureDigest(\n\t\t\tpatterns,\n\t\t\treadCaptureInputs(\n\t\t\t\tthis.#root,\n\t\t\t\tpatterns,\n\t\t\t\tthis.#hash,\n\t\t\t\t(file) => this.#file(file, snapshots)?.image.digest,\n\t\t\t),\n\t\t)\n\t\tdigests.set(key, digest)\n\t\treturn digest\n\t}\n\n\t#images(): readonly string[] {\n\t\tconst pending: CaptureDirectoryResult[] = this.#options.portfolios.map((entry) => ({\n\t\t\tdirectory: entry.directory,\n\t\t\tancestors: [],\n\t\t}))\n\t\tconst files: string[] = []\n\t\tfor (const result of pending) {\n\t\t\tconst directory = result.directory\n\t\t\tconst path = this.#path(directory)\n\t\t\tif (!existsSync(path)) continue\n\t\t\tconst physical = realpathSync(path)\n\t\t\tif (result.ancestors.includes(physical))\n\t\t\t\tthrow new CaptureError('Cyclic portfolio directory alias', { code: 'CONTAINMENT' })\n\t\t\tconst entries = readdirSync(path)\n\t\t\trequireCaptureUnique(entries, 'physical path spellings', true)\n\t\t\tfor (const name of entries) {\n\t\t\t\tconst file = `${directory}/${name}`\n\t\t\t\tconst target = this.#path(file)\n\t\t\t\tif (statSync(target).isDirectory())\n\t\t\t\t\tpending.push({ directory: file, ancestors: [...result.ancestors, physical] })\n\t\t\t\telse if (name.toLowerCase().endsWith('.png')) files.push(file)\n\t\t\t}\n\t\t}\n\t\treturn files.toSorted()\n\t}\n\n\t#snapshot(options: CaptureStageOptions): CaptureSnapshot {\n\t\tconst files = [\n\t\t\t...new Set([\n\t\t\t\t...this.#images(),\n\t\t\t\toptions.report,\n\t\t\t\t...options.projects.map((project) => project.record),\n\t\t\t\tthis.#options.manifest,\n\t\t\t\tthis.#options.registry,\n\t\t\t\tthis.#options.lookups,\n\t\t\t]),\n\t\t]\n\t\tconst snapshots = new Map<string, CaptureFileSnapshot | undefined>()\n\t\tconst digests = new Map<string, CaptureDigest>()\n\t\treturn {\n\t\t\ttime: Date.now(),\n\t\t\tprojects: options.projects.map((project) => {\n\t\t\t\tif (project.inputs.length === 0)\n\t\t\t\t\tthrow new CaptureError('Missing bounded host input population', { code: 'HOST' })\n\t\t\t\treturn { project: project.name, inputs: this.#digest(project.inputs, snapshots, digests) }\n\t\t\t}),\n\t\t\tfiles: files.flatMap((file) => {\n\t\t\t\tconst snapshot = this.#file(file, snapshots)\n\t\t\t\treturn snapshot === undefined ? [] : [snapshot]\n\t\t\t}),\n\t\t}\n\t}\n\n\t#fresh(\n\t\tfile: string,\n\t\tbefore: CaptureSnapshot,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\timage = false,\n\t): CaptureFileSnapshot {\n\t\tconst current = this.#file(file, snapshots)\n\t\tconst previous = before.files.find((entry) => entry.file === file)\n\t\tif (\n\t\t\tcurrent === undefined ||\n\t\t\tcurrent.image.modified < before.time ||\n\t\t\tcurrent.changed < before.time ||\n\t\t\t(previous !== undefined && matchesCaptureFile(previous, current))\n\t\t)\n\t\t\tthrow new CaptureError(`Missing or stale execution output: ${file}`, { code: 'STAGE' })\n\t\tif (image && !matchesCaptureSignature(readCaptureImage(this.#path(file))))\n\t\t\tthrow new CaptureError(`Capture output is not a PNG: ${file}`, { code: 'EVIDENCE' })\n\t\treturn current\n\t}\n\n\t#stable(\n\t\tentry: CaptureDestination,\n\t\tbefore: CaptureDigest,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tdigests: Map<string, CaptureDigest>,\n\t\tstable: Map<string, true>,\n\t): void {\n\t\tconst key = JSON.stringify([\n\t\t\tbefore.digest,\n\t\t\tentry.sources.own.toSorted(),\n\t\t\tentry.sources.shared.toSorted(),\n\t\t\tentry.sources.tests.toSorted(),\n\t\t])\n\t\tif (stable.has(key)) return\n\t\tfor (const patterns of [entry.sources.own, entry.sources.shared, entry.sources.tests]) {\n\t\t\tconst current = this.#digest(patterns, snapshots, digests)\n\t\t\tif (Object.keys(current.files).some((file) => before.files[file] === undefined))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Attribution outside the predeclared host population: ${entry.file}`,\n\t\t\t\t\t{ code: 'STAGE' },\n\t\t\t\t)\n\t\t\tconst matched = this.#match(before, patterns)\n\t\t\tconst previous = Object.fromEntries(\n\t\t\t\tObject.entries(before.files).filter(([file]) => matched.has(file)),\n\t\t\t)\n\t\t\tif (collectCaptureChanges(previous, current.files).length > 0)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Attributed inputs or membership changed during execution: ${entry.file}`,\n\t\t\t\t\t{ code: 'STAGE' },\n\t\t\t\t)\n\t\t\t// Every current file is a member of the predeclared population, so its subsets answer here.\n\t\t\tif (\n\t\t\t\tpatterns.some((pattern) => {\n\t\t\t\t\tconst files = this.#match(before, [pattern])\n\t\t\t\t\treturn !Object.keys(current.files).some((file) => files.has(file))\n\t\t\t\t})\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Declared source pattern has no files: ${entry.file}`, {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t}\n\t\tstable.set(key, true)\n\t}\n\n\t#match(inputs: CaptureDigest, patterns: readonly string[]): ReadonlySet<string> {\n\t\tconst key = computeCaptureMatchKey(inputs, patterns)\n\t\tconst known = this.#matches.get(key)\n\t\tif (known !== undefined) return known\n\t\tconst matched = filterCaptureInputs(inputs, patterns)\n\t\tthis.#matches.set(key, matched)\n\t\treturn matched\n\t}\n\n\t#destination(entry: CaptureDestination, paths?: Map<string, string>): void {\n\t\tconst portfolio = this.#options.portfolios.find(\n\t\t\t(candidate) => candidate.portfolio === entry.portfolio,\n\t\t)\n\t\tif (portfolio === undefined)\n\t\t\tthrow new CaptureError(`Unknown portfolio: ${entry.portfolio}`, { code: 'SELECTION' })\n\t\tconst expected = `${portfolio.directory}/${portfolio.scoped ? `${entry.scope}/` : ''}${entry.state}--${entry.variant}.png`\n\t\tif (entry.file !== expected)\n\t\t\tthrow new CaptureError(`Noncanonical physical destination: ${entry.file}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tthis.#path(entry.file, paths)\n\t}\n\n\t#uniqueRegistry(entries: readonly CaptureDestination[]): void {\n\t\trequireCaptureUnique(entries.map(resolveCaptureKey), 'registry identities', true)\n\t\trequireCaptureUnique(\n\t\t\tentries.map((entry) => entry.file),\n\t\t\t'registry paths',\n\t\t\ttrue,\n\t\t)\n\t}\n\n\t#registry(\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t\tpaths: Map<string, string>,\n\t): CaptureRegistry {\n\t\ttry {\n\t\t\tif (!existsSync(this.#path(this.#options.registry, paths)))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t'Missing accepted registry; run the explicit complete-registry refresh',\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\tconst registry = this.#json(this.#options.registry, paths)\n\t\t\trequireCaptureVersion(registry, 'Registry', this.#options.registry, [\n\t\t\t\tthis.#options.registry,\n\t\t\t\tthis.#options.manifest,\n\t\t\t\tthis.#options.lookups,\n\t\t\t])\n\t\t\tif (\n\t\t\t\t!isCaptureRegistry(registry) ||\n\t\t\t\tregistry.digest !== computeRegistryDigest(registry) ||\n\t\t\t\tregistry.receipts.length === 0\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Invalid accepted registry schema or digest', { code: 'EVIDENCE' })\n\t\t\trequireCaptureUnique(\n\t\t\t\tregistry.receipts.map((receipt) => receipt.variant),\n\t\t\t\t'complete receipt variants',\n\t\t\t\ttrue,\n\t\t\t)\n\t\t\tfor (const receipt of registry.receipts) {\n\t\t\t\tconst report = this.#file(receipt.report.file, snapshots, paths)\n\t\t\t\tif (!receipt.complete || report?.image.digest !== receipt.report.digest)\n\t\t\t\t\tthrow new CaptureError('Registry receipt is incomplete or its report changed', {\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t})\n\t\t\t\tvalidateCaptureReceipt(receipt, readCaptureReport(this.#json(receipt.report.file, paths)))\n\t\t\t\tfor (const path of Object.keys(receipt.inputs)) this.#path(path, paths)\n\t\t\t\trequireCaptureUnique(Object.keys(receipt.inputs), 'receipt input paths', true)\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tregistry.entries.map(describeCaptureDestination),\n\t\t\t\t\tregistry.receipts.flatMap((receipt) => receipt.registry.map(describeCaptureDestination)),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Registry entries differ from complete receipts', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tfor (const entry of registry.entries) this.#destination(entry, paths)\n\t\t\treturn registry\n\t\t} catch (error) {\n\t\t\tthrow resolveCaptureRegistryFault(error)\n\t\t}\n\t}\n\n\t#evidence(snapshots: Map<string, CaptureFileSnapshot | undefined>): CaptureEvidence {\n\t\tconst paths = new Map<string, string>()\n\t\tconst registry = this.#registry(snapshots, paths)\n\t\tconst manifest = existsSync(this.#path(this.#options.manifest, paths))\n\t\t\t? readCaptureManifest(this.#json(this.#options.manifest, paths), this.#options.manifest)\n\t\t\t: undefined\n\t\tif (manifest !== undefined) {\n\t\t\trequireCaptureUnique(Object.keys(manifest.entries), 'manifest keys', true)\n\t\t\tif (manifest.registry.digest !== computeRegistryDigest(manifest.registry))\n\t\t\t\tthrow new CaptureError('Invalid inherited registry digest', { code: 'EVIDENCE' })\n\t\t\tfor (const [key, stamp] of Object.entries(manifest.entries)) {\n\t\t\t\tif (key !== resolveCaptureKey(stamp))\n\t\t\t\t\tthrow new CaptureError('Manifest key differs from stamp identity', { code: 'EVIDENCE' })\n\t\t\t\tif (\n\t\t\t\t\tstamp.shared.digest !==\n\t\t\t\t\t\tbuildCaptureDigest(stamp.shared.patterns, stamp.shared.files).digest ||\n\t\t\t\t\t!matchesCaptureMembers(stamp.shared.patterns, stamp.sources.shared)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError('Invalid inherited shared digest', { code: 'EVIDENCE' })\n\t\t\t\tthis.#path(stamp.file, paths)\n\t\t\t\tfor (const path of [\n\t\t\t\t\t...Object.keys(stamp.own),\n\t\t\t\t\t...Object.keys(stamp.shared.files),\n\t\t\t\t\t...Object.keys(stamp.tests),\n\t\t\t\t])\n\t\t\t\t\tthis.#path(path, paths)\n\t\t\t}\n\t\t}\n\t\tconst separate = existsSync(this.#path(this.#options.lookups, paths))\n\t\t\t? readCaptureLookupJournal(this.#json(this.#options.lookups, paths), this.#options.lookups)\n\t\t\t: undefined\n\t\tconst manifestDigest = this.#file(this.#options.manifest, snapshots, paths)?.image.digest\n\t\tconst current =\n\t\t\tseparate !== undefined && separate.manifest === manifestDigest\n\t\t\t\t? readCaptureLookups(separate, this.#options.lookups)\n\t\t\t\t: []\n\t\tconst lookups = mergeCaptureLookups(manifest?.lookups ?? [], current).filter(\n\t\t\t(entry) => entry.registry === registry.digest,\n\t\t)\n\t\tconst populations = new Map<Readonly<Record<string, string>>, true>()\n\t\tconst references = Map.groupBy(lookups, (entry) => entry.run.file)\n\t\tconst runs = [...references].map(([file, referenced]) => {\n\t\t\tconst snapshot = this.#file(file, snapshots, paths)\n\t\t\tif (\n\t\t\t\tsnapshot === undefined ||\n\t\t\t\treferenced.some((entry) => entry.run.digest !== snapshot.image.digest)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Lookup run record is missing or changed: ${file}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst run = this.#json(file, paths)\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\tfile !==\n\t\t\t\t\t`${this.#options.directory}/runs/${run.request.id}/${run.request.stage}/${run.variant}.json`\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Lookup has no authorized runner record', { code: 'EVIDENCE' })\n\t\t\tconst projects = [...new Set(run.registry.map((entry) => entry.project))]\n\t\t\tif (projects.length > 1)\n\t\t\t\tthrow new CaptureError('Lookup record mixes producing projects', { code: 'EVIDENCE' })\n\t\t\tvalidateCaptureRun(\n\t\t\t\trun,\n\t\t\t\treadCaptureReport(this.#json(this.#reportPath(run.request.args, paths), paths)),\n\t\t\t\tprojects[0] ?? '',\n\t\t\t)\n\t\t\tconst anchor = registry.receipts.find((entry) => entry.variant === run.variant)\n\t\t\tif (\n\t\t\t\tanchor !== undefined &&\n\t\t\t\t(!matchesCaptureMembers(\n\t\t\t\t\tanchor.declarations.map(describeCaptureDeclaration),\n\t\t\t\t\trun.declarations.map(describeCaptureDeclaration),\n\t\t\t\t) ||\n\t\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\t\tanchor.registry.map(describeCaptureDestination),\n\t\t\t\t\t\trun.registry.map(describeCaptureDestination),\n\t\t\t\t\t))\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Lookup declarations disagree with the accepted registry', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tconst declarations = new Map(run.declarations.map((entry) => [entry.case, entry]))\n\t\t\tconst passed = new Set(run.passed)\n\t\t\tfor (const entry of referenced) {\n\t\t\t\tconst declaration = declarations.get(entry.case)\n\t\t\t\tif (\n\t\t\t\t\tdeclaration === undefined ||\n\t\t\t\t\tdeclaration.owner !== entry.owner ||\n\t\t\t\t\trun.variant !== entry.variant ||\n\t\t\t\t\t!passed.has(entry.case) ||\n\t\t\t\t\t!matchesCaptureMembers(declaration.states, entry.states)\n\t\t\t\t)\n\t\t\t\t\tthrow new CaptureError('Lookup differs from its passing declaration', {\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t})\n\t\t\t\tif (!populations.has(entry.inputs)) {\n\t\t\t\t\tfor (const path of Object.keys(entry.inputs)) this.#path(path, paths)\n\t\t\t\t\tpopulations.set(entry.inputs, true)\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const destination of run.registry) this.#destination(destination, paths)\n\t\t\treturn { file: snapshot, run }\n\t\t})\n\t\tconst collections = this.#mergeCollections(\n\t\t\t(manifest?.collections ?? []).filter((entry) => entry.registry === registry.digest),\n\t\t\t(separate?.manifest === manifestDigest ? (separate?.collections ?? []) : []).filter(\n\t\t\t\t(entry) => entry.registry === registry.digest,\n\t\t\t),\n\t\t)\n\t\treturn { registry, ...(manifest === undefined ? {} : { manifest }), lookups, runs, collections }\n\t}\n\n\t#attest(\n\t\trun: CaptureRun,\n\t\tevidence: CaptureEvidence,\n\t\tinputs: Readonly<Record<string, string>>,\n\t\tsnapshots: Map<string, CaptureFileSnapshot | undefined>,\n\t): void {\n\t\tconst receipt = evidence.registry.receipts.find((entry) => entry.variant === run.variant)\n\t\tconst previous =\n\t\t\tevidence.runs.find((entry) => entry.run.variant === run.variant)?.run ??\n\t\t\tthis.#collections(evidence, snapshots).find((entry) => entry.run.variant === run.variant)?.run\n\t\tconst declarations = receipt?.declarations ?? previous?.declarations\n\t\tconst registry = receipt?.registry ?? previous?.registry\n\t\tif (declarations !== undefined && registry !== undefined) {\n\t\t\tif (\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tdeclarations.map(describeCaptureDeclaration),\n\t\t\t\t\trun.declarations.map(describeCaptureDeclaration),\n\t\t\t\t) ||\n\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\tregistry.map(describeCaptureDestination),\n\t\t\t\t\trun.registry.map(describeCaptureDestination),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t'Collected registry declarations changed; run the explicit complete-registry refresh',\n\t\t\t\t\t{ code: 'REGISTRY' },\n\t\t\t\t)\n\t\t} else if (\n\t\t\t!evidence.registry.receipts.some(\n\t\t\t\t(entry) => collectCaptureChanges(entry.inputs, inputs).length === 0,\n\t\t\t)\n\t\t) {\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Unattested producing variant; run the explicit complete-registry refresh before its owner lookup refresh',\n\t\t\t\t{ code: 'REGISTRY', context: { variant: run.variant } },\n\t\t\t)\n\t\t}\n\t}\n\n\t#destinations(evidence: CaptureEvidence): readonly CaptureDestination[] {\n\t\tconst anchored = new Set(evidence.registry.receipts.map((entry) => entry.variant))\n\t\tconst variants = [...new Set(evidence.runs.map((entry) => entry.run.variant))].filter(\n\t\t\t(variant) => !anchored.has(variant),\n\t\t)\n\t\treturn [\n\t\t\t...evidence.registry.entries,\n\t\t\t...variants.flatMap((variant) => {\n\t\t\t\tconst runs = evidence.runs.filter((entry) => entry.run.variant === variant)\n\t\t\t\tconst [first] = runs\n\t\t\t\tif (first === undefined) return []\n\t\t\t\tfor (const entry of runs) {\n\t\t\t\t\tif (\n\t\t\t\t\t\t!matchesCaptureMembers(\n\t\t\t\t\t\t\tfirst.run.registry.map(describeCaptureDestination),\n\t\t\t\t\t\t\tentry.run.registry.map(describeCaptureDestination),\n\t\t\t\t\t\t)\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new CaptureError('Scoped registry attestations disagree', { code: 'EVIDENCE' })\n\t\t\t\t}\n\t\t\t\treturn first.run.registry\n\t\t\t}),\n\t\t]\n\t}\n\n\t#select(\n\t\tentries: readonly CaptureDestination[],\n\t\toptions: CaptureCheckOptions | CaptureLookupOptions,\n\t\tproducers?: ReadonlyMap<string, readonly string[]>,\n\t): readonly CaptureDestination[] {\n\t\tconst selectors = [\n\t\t\t...new Set(\n\t\t\t\tentries.flatMap((entry) => {\n\t\t\t\t\tconst parts = resolveCaptureOwner(entry).split(':')\n\t\t\t\t\treturn parts.map((_part, index) => parts.slice(0, index + 1).join(':'))\n\t\t\t\t}),\n\t\t\t),\n\t\t]\n\t\tconst fault = describeCaptureSelectorFault(options.selector, selectors)\n\t\tif (fault !== undefined) throw new CaptureError(fault, { code: 'USAGE' })\n\t\tif (\n\t\t\toptions.portfolio !== undefined &&\n\t\t\t!this.#options.portfolios.some((entry) => entry.portfolio === options.portfolio)\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown portfolio; ${describeCaptureFault(\n\t\t\t\t\t'selection.portfolio',\n\t\t\t\t\toptions.portfolio,\n\t\t\t\t\t'an authorized portfolio',\n\t\t\t\t\tthis.#options.portfolios.map((entry) => entry.portfolio),\n\t\t\t\t)}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tif (\n\t\t\t!isCaptureSelector(options.selector) ||\n\t\t\t!options.variants.every(isCaptureSegment) ||\n\t\t\t(options.state !== undefined && !isCaptureSegment(options.state)) ||\n\t\t\t(options.case !== undefined && options.case.trim() === '')\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Invalid capture selection; ${describeCaptureFault('selection', options, 'portable variants and state, a nonempty case, and an authorized portfolio; valid values come from the selected registry destinations', ['selector', 'variants', 'state', 'case', 'portfolio'], ['selector', 'variants'], ['selector', 'variants', 'state', 'case', 'portfolio'])}; ${describeCaptureFault(\n\t\t\t\t\t'selection.portfolio',\n\t\t\t\t\toptions.portfolio,\n\t\t\t\t\t'an authorized portfolio when supplied',\n\t\t\t\t\tthis.#options.portfolios.map((entry) => entry.portfolio),\n\t\t\t\t)}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\trequireCaptureUnique(options.variants, 'selected variants', true)\n\t\tconst scoped = entries.filter(\n\t\t\t(entry) =>\n\t\t\t\tmatchesCaptureSelector(resolveCaptureOwner(entry), options.selector) &&\n\t\t\t\t(options.portfolio === undefined || entry.portfolio === options.portfolio),\n\t\t)\n\t\tif (scoped.length === 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Empty selector; ${describeCaptureFault('selector', options.selector, 'a declared selector with destinations in the selected portfolio', ['all', ...selectors])}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'USAGE',\n\t\t\t\t},\n\t\t\t)\n\t\t// An omitted variant list derives from the scoped destinations, so an unknown selector reads as\n\t\t// that before an empty list reads as an invalid one.\n\t\tif (options.variants.length === 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Invalid capture selection; ${describeCaptureFault('selection.variants', options.variants, 'a nonempty selected variant list', [...new Set(scoped.map((entry) => entry.variant))])}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tconst variants = [\n\t\t\t...new Set(\n\t\t\t\tproducers === undefined\n\t\t\t\t\t? entries.map((entry) => entry.variant)\n\t\t\t\t\t: entries.map((entry) => requireCaptureProducer(entry, producers)),\n\t\t\t),\n\t\t]\n\t\tconst unknown = options.variants.find((variant) => !variants.includes(variant))\n\t\t// A caller refuses an undeclared variant before the read, so one outside the attested set lags.\n\t\tif (unknown !== undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown or unattested selected variant; ${describeCaptureFault('selection.variants', unknown, 'an attested registry variant', variants)}`,\n\t\t\t\t{ code: 'REGISTRY', context: { variant: unknown } },\n\t\t\t)\n\t\tconst selected = scoped.filter(\n\t\t\t(entry) =>\n\t\t\t\toptions.variants.includes(\n\t\t\t\t\tproducers === undefined ? entry.variant : requireCaptureProducer(entry, producers),\n\t\t\t\t) &&\n\t\t\t\t(options.state === undefined || entry.state === options.state) &&\n\t\t\t\t(options.case === undefined || entry.case === options.case),\n\t\t)\n\t\tif (selected.length === 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Empty selection or state outside selector/case; ${describeCaptureFault('selection.state', options.state, 'a state in the selected selector/case', [...new Set(scoped.map((entry) => entry.state))])}; ${describeCaptureFault('selection.case', options.case, 'a case in the selected selector', [...new Set(scoped.map((entry) => entry.case))])}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'USAGE',\n\t\t\t\t},\n\t\t\t)\n\t\treturn selected\n\t}\n\n\t#reportPath(args: readonly string[], paths?: Map<string, string>): string {\n\t\tconst outputs = args.filter((argument) => argument.startsWith('--outputFile.json='))\n\t\tif (outputs.length !== 1 || outputs[0] === undefined)\n\t\t\tthrow new CaptureError('Request has no unique JSON reporter path', { code: 'HOST' })\n\t\tconst file: string = normalizeSlashes(\n\t\t\trelative(this.#root, resolve(this.#root, outputs[0].slice('--outputFile.json='.length))),\n\t\t)\n\t\tthis.#path(file, paths)\n\t\treturn file\n\t}\n\n\t#physicalIdentity(file: string, identities: Map<string, string>): string {\n\t\tconst known = identities.get(file)\n\t\tif (known !== undefined) return known\n\t\tconst path = this.#path(file)\n\t\tif (!existsSync(path)) {\n\t\t\tidentities.set(file, path)\n\t\t\treturn path\n\t\t}\n\t\t// Native file identifiers can exceed the exact integer range of a Number.\n\t\tconst stat = statSync(path, { bigint: true })\n\t\tconst identity = stat.ino === 0n ? realpathSync(path) : `${stat.dev}:${stat.ino}`\n\t\tidentities.set(file, identity)\n\t\treturn identity\n\t}\n\n\t#attributable(\n\t\tfile: string,\n\t\tselected: readonly CaptureDestination[],\n\t\tregistry: readonly CaptureDestination[],\n\t\toptions: CaptureCheckOptions,\n\t): boolean {\n\t\tif (\n\t\t\toptions.portfolio !== undefined &&\n\t\t\t!this.#options.portfolios.some(\n\t\t\t\t(entry) => entry.portfolio === options.portfolio && file.startsWith(`${entry.directory}/`),\n\t\t\t)\n\t\t)\n\t\t\treturn false\n\t\tif (registry.some((entry) => entry.file === file)) return false\n\t\tconst name = file.slice(file.lastIndexOf('/') + 1)\n\t\tif (selected.some((entry) => name === `${entry.state}--${entry.variant}.png`)) return true\n\t\tif (options.state !== undefined || options.case !== undefined) return false\n\t\tif (!options.variants.some((variant) => name.endsWith(`--${variant}.png`))) return false\n\t\tif (options.selector === 'all') return true\n\t\treturn selected.some((entry) => {\n\t\t\tconst portfolio = this.#options.portfolios.find(\n\t\t\t\t(candidate) => candidate.portfolio === entry.portfolio,\n\t\t\t)\n\t\t\treturn (\n\t\t\t\tportfolio !== undefined &&\n\t\t\t\toptions.selector === entry.scope &&\n\t\t\t\tfile.startsWith(`${portfolio.directory}/${portfolio.scoped ? `${entry.scope}/` : ''}`)\n\t\t\t)\n\t\t})\n\t}\n\n\t// Runs one Git read in the workspace; a synchronous read of provenance starts no supervised child.\n\t#git(args: readonly string[]): string {\n\t\tconst result = executeSync(\n\t\t\t{ file: 'git', arguments: args },\n\t\t\t{ workspace: this.#root, timeout: 30_000, limit: 64 * 1024 * 1024, strict: false },\n\t\t)\n\t\tif (result.failed || result.truncated)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Git read failed${result.expired ? ' (deadline expired)' : ''}${result.truncated ? ' (output truncated)' : ''}: ${describeCaptureOutput(result.stderr.trim() || String(result.code ?? result.signal))}`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\treturn result.stdout\n\t}\n\n\t#provenance(): { readonly commit: string; readonly dirty: readonly string[] } {\n\t\tconst root = this.#git(['rev-parse', '--show-toplevel']).trim()\n\t\tif (realpathSync(root) !== this.#root)\n\t\t\tthrow new CaptureError('Integrity root differs from the Git workspace root', {\n\t\t\t\tcode: 'HOST',\n\t\t\t})\n\t\tconst commit = this.#git(['rev-parse', 'HEAD']).trim()\n\t\tconst dirty = readCaptureDirty(\n\t\t\tthis.#git(['status', '--porcelain=v1', '-z', '--untracked-files=all']),\n\t\t)\n\t\tif (!/^[a-f0-9]{40,64}$/u.test(commit) || !dirty.every(isCapturePath))\n\t\t\tthrow new CaptureError('Invalid Git provenance', { code: 'EVIDENCE' })\n\t\treturn { commit, dirty }\n\t}\n\n\t#commit(file: string, value: unknown, signal?: AbortSignal): void {\n\t\tconst target = this.#path(file)\n\t\tmkdirSync(dirname(target), { recursive: true })\n\t\tthis.#path(file)\n\t\tconst temporary = `${file}.${randomUUID()}.tmp`\n\t\tconst path = this.#path(temporary)\n\t\ttry {\n\t\t\twriteFileSync(path, `${JSON.stringify(value)}\\n`, { flag: 'wx', flush: true })\n\t\t\tsignal?.throwIfAborted()\n\t\t\tthis.#path(file)\n\t\t\tthis.#path(temporary)\n\t\t\trenameSync(path, target)\n\t\t} finally {\n\t\t\tif (existsSync(path)) rmSync(path)\n\t\t}\n\t}\n}\n","import type { DuplexInterface } from '@orkestrel/process'\nimport type { CaptureRequest } from '@src/core'\nimport type {\n\tCaptureDiscoveryRequest,\n\tCaptureExecutionResult,\n\tCaptureHolder,\n\tCaptureInvocationInterface,\n\tCaptureInvocationOptions,\n\tCaptureOwnership,\n} from './types.js'\nimport { randomUUID } from 'node:crypto'\nimport {\n\tappendFileSync,\n\tlinkSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\twriteFileSync,\n} from 'node:fs'\nimport { resolve } from 'node:path'\nimport { StringDecoder } from 'node:string_decoder'\nimport { attempt, isRecord, parseJSON, preview } from '@orkestrel/contract'\nimport { createDuplex, inspectProcess } from '@orkestrel/process/server'\nimport { createTimeout } from '@orkestrel/timeout'\nimport {\n\tCAPTURE_REQUEST_PREFIX,\n\tCaptureError,\n\tdescribeCaptureError,\n\tisCaptureError,\n} from '@src/core'\nimport {\n\tCAPTURE_FLAG,\n\tCAPTURE_FLAG_VALUE,\n\tCAPTURE_REFUSAL_LIMIT,\n\tCAPTURE_REQUESTS_FLAG,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_SURVIVORS_FILE,\n\tCAPTURE_OWNER_FILE,\n\tCAPTURE_OWNER_TIMEOUT,\n\tCAPTURE_OWNER_BACKOFF,\n} from './constants.js'\nimport {\n\treadCaptureRequestOwner,\n\tsettleCaptureShutdown,\n\tmatchesCaptureTransient,\n} from './helpers.js'\n\n/**\n * Owns one runner invocation's identity, request file, children, and interruption.\n *\n * @remarks\n * The runner creates one for discovery and each changed owner, so the abort controller, session\n * registry, and spawn log belong to an invocation. Interruption derives from the controller's\n * signal. Sessions end the Windows process tree, or signal the POSIX group with SIGTERM and then\n * SIGKILL after a 250 ms grace. A linked timeout ends discovery without interrupting the invocation.\n * Raw stdout is decoded across chunk boundaries and flushed at termination. A writer failure or\n * an observation cutoff refuses the stage rather than accepting incomplete evidence.\n *\n * @example\n * ```ts\n * const invocation = new CaptureInvocation({\n * \tcommand: 'journey',\n * \troot: process.cwd(),\n * \trequests: 'tmp/units',\n * \tstdout: (text) => process.stdout.write(text),\n * \tstderr: (text) => process.stderr.write(text),\n * })\n * invocation.attach()\n * ```\n */\nexport class CaptureInvocation implements CaptureInvocationInterface {\n\treadonly #options: CaptureInvocationOptions\n\treadonly #id = randomUUID()\n\treadonly #controller = new AbortController()\n\treadonly #children = new Set<DuplexInterface>()\n\treadonly #unconfirmed = new Set<number>()\n\treadonly #launches: string[] = []\n\treadonly #interrupt = this.#abort.bind(this)\n\treadonly #request: string\n\treadonly #directory: string\n\treadonly #lock: string\n\t#lease: string | undefined\n\t#termination: Promise<readonly unknown[]> | undefined\n\n\t/**\n\t * Creates the invocation entity for one runner call.\n\t *\n\t * @param options - The command, the workspace, the request directory, and the output writers\n\t */\n\tconstructor(options: CaptureInvocationOptions) {\n\t\tthis.#options = options\n\t\tthis.#request = resolve(\n\t\t\toptions.root,\n\t\t\toptions.requests,\n\t\t\t`${CAPTURE_REQUEST_PREFIX}-${String(process.pid)}.json`,\n\t\t)\n\t\tthis.#directory = resolve(options.root, options.requests, CAPTURE_RUNS_DIRECTORY, this.#id)\n\t\tthis.#lock = resolve(options.root, options.requests, CAPTURE_OWNER_FILE)\n\t}\n\n\tget id(): string {\n\t\treturn this.#id\n\t}\n\n\tget request(): string {\n\t\treturn this.#request\n\t}\n\n\tget directory(): string {\n\t\treturn this.#directory\n\t}\n\n\tget signal(): AbortSignal {\n\t\treturn this.#controller.signal\n\t}\n\n\tget interrupted(): boolean {\n\t\treturn this.#controller.signal.aborted\n\t}\n\n\tattach(): void {\n\t\tprocess.on('SIGINT', this.#interrupt)\n\t\tprocess.on('SIGTERM', this.#interrupt)\n\t}\n\n\tasync release(): Promise<void> {\n\t\tconst failures: unknown[] = []\n\t\tconst kept: string[] = []\n\t\ttry {\n\t\t\tif (this.#termination !== undefined) await this.#termination\n\t\t\tfailures.push(\n\t\t\t\t...(await settleCaptureShutdown(\n\t\t\t\t\t() => this.retract(),\n\t\t\t\t\t[...this.#children].map((child) => () => this.#stop(child)),\n\t\t\t\t)),\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tfailures.push(error)\n\t\t} finally {\n\t\t\tprocess.off('SIGINT', this.#interrupt)\n\t\t\tprocess.off('SIGTERM', this.#interrupt)\n\t\t\tif (this.#lease !== undefined) {\n\t\t\t\tconst removal = attempt(() => {\n\t\t\t\t\tconst deadline = performance.now() + CAPTURE_OWNER_TIMEOUT\n\t\t\t\t\tconst marker = attempt(() => this.#read(deadline))\n\t\t\t\t\tif (!marker.success) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tmarker.error instanceof Error &&\n\t\t\t\t\t\t\t'code' in marker.error &&\n\t\t\t\t\t\t\tmarker.error.code === 'ENOENT'\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\tthrow marker.error\n\t\t\t\t\t}\n\t\t\t\t\tif (this.#owner(marker.value).id !== this.id) return\n\t\t\t\t\tif (this.#unconfirmed.size > 0) {\n\t\t\t\t\t\tkept.push(`ownership marker retained: ${this.#lock}`)\n\t\t\t\t\t\tconst record = attempt(() => this.#record())\n\t\t\t\t\t\tif (record.success) kept.push(`child record: ${record.value}`)\n\t\t\t\t\t\telse failures.push(record.error)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tthis.#remove(deadline)\n\t\t\t\t})\n\t\t\t\tif (removal.success && this.#unconfirmed.size === 0) this.#lease = undefined\n\t\t\t\telse if (!removal.success) failures.push(removal.error)\n\t\t\t}\n\t\t}\n\t\tif (failures.length > 0 || this.#unconfirmed.size > 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture shutdown failed${this.#unconfirmed.size === 0 ? '' : `; child termination was not confirmed for process ${[...this.#unconfirmed].join(', ')}`}${kept.map((entry) => `; ${entry}`).join('')}`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\tcause: new AggregateError(failures),\n\t\t\t\t},\n\t\t\t)\n\t}\n\n\tprepare(): void {\n\t\tconst requests = resolve(this.#options.root, this.#options.requests)\n\t\tattempt(() => mkdirSync(requests, { recursive: true }))\n\t\tthis.#claim()\n\t\tfor (const name of readdirSync(requests)) {\n\t\t\tconst pid = readCaptureRequestOwner(name)\n\t\t\tif (pid === undefined || pid === process.pid) continue\n\t\t\t// A directory under a request file's name survives the nonrecursive removal, as a claim temporary does.\n\t\t\tif (this.#alive(pid) === false)\n\t\t\t\tattempt(() => rmSync(resolve(requests, name), { force: true }))\n\t\t}\n\t}\n\n\tholders(): readonly CaptureHolder[] {\n\t\tconst requests = resolve(this.#options.root, this.#options.requests)\n\t\tconst pids = new Set(\n\t\t\treaddirSync(requests).flatMap((name) => {\n\t\t\t\tconst pid = readCaptureRequestOwner(name)\n\t\t\t\treturn pid === undefined || (pid === process.pid && this.#lease !== undefined) ? [] : [pid]\n\t\t\t}),\n\t\t)\n\t\treturn [...pids].flatMap((pid) => {\n\t\t\tconst alive = this.#alive(pid)\n\t\t\treturn alive === false ? [] : [{ pid, inspected: alive === true }]\n\t\t})\n\t}\n\n\tpublish(request: CaptureRequest | CaptureDiscoveryRequest): void {\n\t\tthis.#claim()\n\t\twriteFileSync(`${this.#request}.tmp`, `${JSON.stringify(request)}\\n`)\n\t\trenameSync(`${this.#request}.tmp`, this.#request)\n\t}\n\n\tretract(): void {\n\t\tif (this.#lease === undefined) return\n\t\tconst results = [\n\t\t\tattempt(() => rmSync(this.#request, { force: true })),\n\t\t\tattempt(() => rmSync(`${this.#request}.tmp`, { force: true })),\n\t\t]\n\t\tconst failures = results.flatMap((result) => (result.success ? [] : [result.error]))\n\t\tif (failures.length > 0)\n\t\t\tthrow new CaptureError('Capture request removal failed', {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcause: new AggregateError(failures),\n\t\t\t})\n\t}\n\n\tlaunched(log: string): boolean {\n\t\treturn this.#launches.includes(log)\n\t}\n\n\tasync spawn(\n\t\targs: readonly string[],\n\t\tlog: string,\n\t\tcapture: boolean,\n\t\tdeadline?: number,\n\t): Promise<CaptureExecutionResult> {\n\t\tthis.signal.throwIfAborted()\n\t\tconst timeout =\n\t\t\tdeadline === undefined ? undefined : createTimeout({ ms: deadline, signal: this.signal })\n\t\t// Keep the armed signal: a later parent abort clears the handle's expiry reading.\n\t\tconst expiry = timeout?.signal\n\t\tconst failure = new AbortController()\n\t\tconst decoder = new StringDecoder('utf8')\n\t\tconst signal = AbortSignal.any([\n\t\t\tthis.signal,\n\t\t\tfailure.signal,\n\t\t\t...(expiry === undefined ? [] : [expiry]),\n\t\t])\n\t\ttry {\n\t\t\tmkdirSync(this.#directory, { recursive: true })\n\t\t\twriteFileSync(log, '')\n\t\t\tconst session = createDuplex({\n\t\t\t\tcommand: {\n\t\t\t\t\tfile: process.execPath,\n\t\t\t\t\targuments: args,\n\t\t\t\t\t// The merge drops every inherited name an override claims by case, the unset flag included.\n\t\t\t\t\tenvironment: {\n\t\t\t\t\t\t[CAPTURE_REQUESTS_FLAG]: resolve(this.#options.root, this.#options.requests),\n\t\t\t\t\t\t[CAPTURE_FLAG]: capture ? CAPTURE_FLAG_VALUE : undefined,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tworkspace: this.#options.root,\n\t\t\t\tgrace: 250,\n\t\t\t\tsignal,\n\t\t\t\ton: {\n\t\t\t\t\tstdout: (bytes) => {\n\t\t\t\t\t\tconst text = decoder.write(Buffer.from(bytes))\n\t\t\t\t\t\tthis.#options.stdout(text)\n\t\t\t\t\t\tappendFileSync(log, text)\n\t\t\t\t\t},\n\t\t\t\t\tstderr: (text) => {\n\t\t\t\t\t\tthis.#options.stderr(text)\n\t\t\t\t\t\tappendFileSync(log, text)\n\t\t\t\t\t},\n\t\t\t\t\terror: (error) =>\n\t\t\t\t\t\tfailure.abort(\n\t\t\t\t\t\t\tnew CaptureError(`Capture child failed: ${describeCaptureError(error)}`, {\n\t\t\t\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t// Session listeners isolate throws; a lost tee must still refuse all evidence.\n\t\t\t\terror: (error) =>\n\t\t\t\t\tfailure.abort(\n\t\t\t\t\t\tnew CaptureError('Capture child output could not be recorded', {\n\t\t\t\t\t\t\tcode: 'STAGE',\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})\n\t\t\tthis.#children.add(session)\n\t\t\tthis.#launches.push(log)\n\t\t\ttry {\n\t\t\t\ttimeout?.start()\n\t\t\t\tthis.#options.stdout(`pid=${String(session.pid)}\\n`)\n\t\t\t\tawait session.end()\n\t\t\t\tconst outcome = await session.exit\n\t\t\t\tconst tail = decoder.end()\n\t\t\t\t// The tail is written outside the session's listener isolation, so its failure joins the same refusal.\n\t\t\t\ttry {\n\t\t\t\t\tif (tail !== '') {\n\t\t\t\t\t\tthis.#options.stdout(tail)\n\t\t\t\t\t\tappendFileSync(log, tail)\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\tfailure.abort(\n\t\t\t\t\t\tnew CaptureError('Capture child output could not be recorded', {\n\t\t\t\t\t\t\tcode: 'STAGE',\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\tfailure.signal.throwIfAborted()\n\t\t\t\tif (!outcome.drained)\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t'Capture child observation was cut off before its output drained',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\t\t},\n\t\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\tcode: outcome.code,\n\t\t\t\t\tsignal: outcome.signal,\n\t\t\t\t\t...(session.pid === undefined ? {} : { pid: session.pid }),\n\t\t\t\t\t...(expiry?.aborted === true ? { expired: true } : {}),\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait this.#stop(session)\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (isCaptureError(error)) throw error\n\t\t\tthrow new CaptureError('Capture child execution failed', { code: 'STAGE', cause: error })\n\t\t} finally {\n\t\t\ttimeout?.clear()\n\t\t}\n\t}\n\n\t#abort(): void {\n\t\tif (this.signal.aborted) return\n\t\tthis.#controller.abort(new CaptureError('Runner interrupted', { code: 'STAGE' }))\n\t\tthis.#termination = settleCaptureShutdown(\n\t\t\t() => this.retract(),\n\t\t\t[...this.#children].map((child) => () => this.#stop(child)),\n\t\t)\n\t}\n\n\tasync #stop(child: DuplexInterface): Promise<boolean> {\n\t\tif (child.pid !== undefined) this.#unconfirmed.add(child.pid)\n\t\tconst confirmed = await (this.#options.terminate === undefined\n\t\t\t? child.stop()\n\t\t\t: this.#options.terminate(child))\n\t\tif (confirmed && child.pid !== undefined) this.#unconfirmed.delete(child.pid)\n\t\tif (confirmed) {\n\t\t\tawait child.destroy()\n\t\t\tthis.#children.delete(child)\n\t\t}\n\t\treturn confirmed\n\t}\n\n\t#read(deadline: number): string {\n\t\tconst result = attempt(() =>\n\t\t\tthis.#options.ownership?.read === undefined\n\t\t\t\t? readFileSync(this.#lock, 'utf8')\n\t\t\t\t: this.#options.ownership.read(this.#lock),\n\t\t)\n\t\tif (result.success) return result.value\n\t\tif (!matchesCaptureTransient(result.error, this.#options.ownership?.platform))\n\t\t\tthrow result.error\n\t\tthis.#backoff(deadline, result.error)\n\t\treturn this.#read(deadline)\n\t}\n\n\t#remove(deadline: number): void {\n\t\tconst result = attempt(() => {\n\t\t\t// Re-read on every retry, including after a failed unlink.\n\t\t\tif (this.#owner(this.#read(deadline)).id !== this.id) return\n\t\t\tif (this.#options.ownership?.remove === undefined) rmSync(this.#lock, { force: true })\n\t\t\telse this.#options.ownership.remove(this.#lock)\n\t\t})\n\t\tif (result.success) return\n\t\tif (result.error instanceof Error && 'code' in result.error && result.error.code === 'ENOENT')\n\t\t\treturn\n\t\tif (!matchesCaptureTransient(result.error, this.#options.ownership?.platform))\n\t\t\tthrow result.error\n\t\tthis.#backoff(deadline, result.error)\n\t\tthis.#remove(deadline)\n\t}\n\n\t#record(retry = true): string {\n\t\tconst file = resolve(this.#directory, CAPTURE_SURVIVORS_FILE)\n\t\tconst text = JSON.stringify({\n\t\t\tpid: process.pid,\n\t\t\tid: this.id,\n\t\t\tcommand: this.#options.command,\n\t\t\tchildren: [...this.#unconfirmed],\n\t\t\tat: new Date().toISOString(),\n\t\t})\n\t\ttry {\n\t\t\tif (this.#options.ownership?.write === undefined) writeFileSync(file, text, { flag: 'wx' })\n\t\t\telse this.#options.ownership.write(file, text)\n\t\t\treturn file\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\terror instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)\n\t\t\tif (code === 'EEXIST') return file\n\t\t\tif (code === 'ENOENT' && retry) {\n\t\t\t\tmkdirSync(this.#directory, { recursive: true })\n\t\t\t\treturn this.#record(false)\n\t\t\t}\n\t\t\tthrow new CaptureError(`Cannot write capture child record (${code}): ${file}`, {\n\t\t\t\tcode: 'STAGE',\n\t\t\t\tcause: error,\n\t\t\t})\n\t\t}\n\t}\n\n\t#write(file: string, text: string): void {\n\t\ttry {\n\t\t\tif (this.#options.ownership?.write === undefined) writeFileSync(file, text, { flag: 'wx' })\n\t\t\telse this.#options.ownership.write(file, text)\n\t\t} catch (error) {\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot write capture ownership temporary (${error instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)}): ${file}`,\n\t\t\t\t{ code: 'STAGE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\t#backoff(deadline: number, error?: unknown): void {\n\t\tconst left = deadline - performance.now()\n\t\tif (left <= 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\terror === undefined\n\t\t\t\t\t? `Capture ownership marker kept changing until the deadline: ${this.#lock}; rerun after serializing capture commands`\n\t\t\t\t\t: `Capture ownership marker is temporarily unavailable (${error instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)}): ${this.#lock}; rerun after serializing capture commands`,\n\t\t\t\t{ code: 'STAGE', ...(error === undefined ? {} : { cause: error }) },\n\t\t\t)\n\t\tAtomics.wait(\n\t\t\tnew Int32Array(new SharedArrayBuffer(4)),\n\t\t\t0,\n\t\t\t0,\n\t\t\tMath.min(CAPTURE_OWNER_BACKOFF, left),\n\t\t)\n\t}\n\n\t#claim(): void {\n\t\tif (this.#lease !== undefined) return\n\t\tconst directory = attempt(() => statSync(resolve(this.#options.root, this.#options.requests)))\n\t\tif (!directory.success || !directory.value.isDirectory())\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture request directory is unavailable: ${resolve(this.#options.root, this.#options.requests)}`,\n\t\t\t\t{ code: 'STAGE', ...(!directory.success ? { cause: directory.error } : {}) },\n\t\t\t)\n\t\tconst requests = resolve(this.#options.root, this.#options.requests)\n\t\tfor (const name of readdirSync(requests)) {\n\t\t\tif (!name.startsWith(`${CAPTURE_OWNER_FILE}.`) || !name.endsWith('.tmp')) continue\n\t\t\tconst [pid] = name.slice(CAPTURE_OWNER_FILE.length + 1).split('.')\n\t\t\tif (\n\t\t\t\tpid !== undefined &&\n\t\t\t\t/^\\d+$/u.test(pid) &&\n\t\t\t\tNumber.isSafeInteger(Number(pid)) &&\n\t\t\t\tNumber(pid) > 0 &&\n\t\t\t\tthis.#alive(Number(pid)) === false\n\t\t\t)\n\t\t\t\tattempt(() => rmSync(resolve(requests, name), { force: true }))\n\t\t}\n\t\tconst temporary = `${this.#lock}.${String(process.pid)}.${this.id}.tmp`\n\t\ttry {\n\t\t\tthis.#write(temporary, JSON.stringify({ pid: process.pid, id: this.id }))\n\t\t\tconst deadline = performance.now() + CAPTURE_OWNER_TIMEOUT\n\t\t\tthis.#acquire(temporary, deadline)\n\t\t} catch (error) {\n\t\t\tif (isCaptureError(error)) throw error\n\t\t\tconst code =\n\t\t\t\terror instanceof Error && 'code' in error ? String(error.code) : describeCaptureError(error)\n\t\t\tconst unsupported = [\n\t\t\t\t'ENOTSUP',\n\t\t\t\t'EOPNOTSUPP',\n\t\t\t\t'ENOSYS',\n\t\t\t\t'EXDEV',\n\t\t\t\t...((this.#options.ownership?.platform ?? process.platform) === 'win32' ? [] : ['EPERM']),\n\t\t\t].includes(code)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot link capture ownership (${code}): ${this.#lock}${unsupported ? '; the store directory must support hard links' : '; inspect the filesystem error and rerun'}`,\n\t\t\t\t{ code: 'STAGE', cause: error },\n\t\t\t)\n\t\t} finally {\n\t\t\t// A leftover names this live pid, so a later claim sweeps it after this process ends.\n\t\t\tattempt(() => rmSync(temporary, { force: true }))\n\t\t}\n\t}\n\n\t#acquire(temporary: string, deadline: number): void {\n\t\tconst opened = attempt(() =>\n\t\t\tthis.#options.ownership?.link === undefined\n\t\t\t\t? linkSync(temporary, this.#lock)\n\t\t\t\t: this.#options.ownership.link(temporary, this.#lock),\n\t\t)\n\t\tif (opened.success) {\n\t\t\tthis.#lease = this.id\n\t\t\treturn\n\t\t}\n\t\tif (matchesCaptureTransient(opened.error, this.#options.ownership?.platform)) {\n\t\t\tthis.#backoff(deadline, opened.error)\n\t\t\treturn this.#acquire(temporary, deadline)\n\t\t}\n\t\tif (\n\t\t\t!(opened.error instanceof Error) ||\n\t\t\t!('code' in opened.error) ||\n\t\t\topened.error.code !== 'EEXIST'\n\t\t)\n\t\t\tthrow opened.error\n\t\tconst marker = attempt(() => this.#read(deadline))\n\t\tif (!marker.success) {\n\t\t\tif (\n\t\t\t\tmarker.error instanceof Error &&\n\t\t\t\t'code' in marker.error &&\n\t\t\t\tmarker.error.code === 'ENOENT'\n\t\t\t) {\n\t\t\t\tthis.#backoff(deadline)\n\t\t\t\treturn this.#acquire(temporary, deadline)\n\t\t\t}\n\t\t\tif (isCaptureError(marker.error)) throw marker.error\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is unreadable: ${this.#lock}; rerun after inspecting the filesystem error`,\n\t\t\t\t{\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\tcause: marker.error,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\t\tconst owner = attempt(() => this.#owner(marker.value))\n\t\tconst alive = owner.success ? this.#alive(owner.value.pid) : undefined\n\t\t// Confirm the content after the liveness probe, or after a yield for malformed content.\n\t\tif (!owner.success) this.#backoff(deadline)\n\t\tconst confirmed = attempt(() => this.#read(deadline))\n\t\tif (!confirmed.success) {\n\t\t\tif (\n\t\t\t\tconfirmed.error instanceof Error &&\n\t\t\t\t'code' in confirmed.error &&\n\t\t\t\tconfirmed.error.code === 'ENOENT'\n\t\t\t) {\n\t\t\t\tthis.#backoff(deadline)\n\t\t\t\treturn this.#acquire(temporary, deadline)\n\t\t\t}\n\t\t\tif (isCaptureError(confirmed.error)) throw confirmed.error\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is unreadable: ${this.#lock}; rerun after inspecting the filesystem error`,\n\t\t\t\t{ code: 'STAGE', cause: confirmed.error },\n\t\t\t)\n\t\t}\n\t\tif (confirmed.value !== marker.value) {\n\t\t\tthis.#backoff(deadline)\n\t\t\treturn this.#acquire(temporary, deadline)\n\t\t}\n\t\tif (!owner.success) throw owner.error\n\t\tthis.#refuse(owner.value, alive)\n\t}\n\n\t#alive(pid: number): boolean | undefined {\n\t\treturn (this.#options.ownership?.alive ?? inspectProcess)(pid)\n\t}\n\n\t#owner(marker: string): CaptureOwnership {\n\t\tif (marker === '')\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is empty; confirm no capture process or surviving child is running and inspect this file: ${this.#lock}; its holder cannot be established`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\tconst owner = attempt(() => parseJSON(marker))\n\t\tif (\n\t\t\t!owner.success ||\n\t\t\t!isRecord(owner.value) ||\n\t\t\ttypeof owner.value.pid !== 'number' ||\n\t\t\t!Number.isSafeInteger(owner.value.pid) ||\n\t\t\towner.value.pid <= 0 ||\n\t\t\ttypeof owner.value.id !== 'string' ||\n\t\t\towner.value.id === ''\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership marker is malformed; expected { pid: positive integer, id: nonempty string }, received ${preview(marker)}; confirm no capture process or surviving child is running and inspect this file: ${this.#lock}`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\treturn {\n\t\t\tpid: owner.value.pid,\n\t\t\tid: owner.value.id,\n\t\t}\n\t}\n\n\t#refuse(holder: CaptureOwnership, alive: boolean | undefined): never {\n\t\tif (alive === false)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership process ${String(holder.pid)} is not running; invocation ${preview(holder.id)}. ${this.#survivors(holder)} Confirm no capture process or surviving child is running and re-read ${this.#lock} to confirm it still names pid ${String(holder.pid)} before you delete this file and rerun`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\tif (alive === undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Capture ownership process ${String(holder.pid)} could not be inspected; invocation ${preview(holder.id)}; serialize capture commands. Confirm no capture process or surviving child is running and re-read ${this.#lock} to confirm it still names pid ${String(holder.pid)} before deleting`,\n\t\t\t\t{ code: 'STAGE' },\n\t\t\t)\n\t\tthrow new CaptureError(\n\t\t\t`Another runner holds this workspace (process ${preview(holder.pid)}); invocation ${preview(holder.id)}; serialize capture commands. If this pid is not a capture run, confirm no capture process or surviving child is running and re-read ${this.#lock} to confirm it still names pid ${String(holder.pid)} before deleting`,\n\t\t\t{ code: 'STAGE' },\n\t\t)\n\t}\n\n\t#survivors(holder: CaptureOwnership): string {\n\t\t// Only an id of the shape this class generates names a directory under the runs directory.\n\t\tif (!/^[\\da-f]{8}-[\\da-f]{4}-4[\\da-f]{3}-[89ab][\\da-f]{3}-[\\da-f]{12}$/u.test(holder.id))\n\t\t\treturn `Invocation ${preview(holder.id)} is not an invocation id; no child record is read.`\n\t\tconst file = resolve(\n\t\t\tthis.#options.root,\n\t\t\tthis.#options.requests,\n\t\t\tCAPTURE_RUNS_DIRECTORY,\n\t\t\tholder.id,\n\t\t\tCAPTURE_SURVIVORS_FILE,\n\t\t)\n\t\ttry {\n\t\t\tconst record: unknown = parseJSON(\n\t\t\t\tthis.#options.ownership?.read === undefined\n\t\t\t\t\t? readFileSync(file, 'utf8')\n\t\t\t\t\t: this.#options.ownership.read(file),\n\t\t\t)\n\t\t\tif (\n\t\t\t\t!isRecord(record) ||\n\t\t\t\trecord.pid !== holder.pid ||\n\t\t\t\trecord.id !== holder.id ||\n\t\t\t\ttypeof record.command !== 'string' ||\n\t\t\t\trecord.command === '' ||\n\t\t\t\ttypeof record.at !== 'string' ||\n\t\t\t\t!Number.isFinite(Date.parse(record.at)) ||\n\t\t\t\t!Array.isArray(record.children) ||\n\t\t\t\t!record.children.every(\n\t\t\t\t\t(pid: unknown) => typeof pid === 'number' && Number.isSafeInteger(pid) && pid > 0,\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn `Child record could not be read (EINVAL): ${file}.`\n\t\t\tconst omitted = record.children.length - CAPTURE_REFUSAL_LIMIT\n\t\t\treturn `Unconfirmed child processes: ${[...record.children.slice(0, CAPTURE_REFUSAL_LIMIT), ...(omitted > 0 ? [`… ${String(omitted)} more`] : [])].join(', ')}; stop them before deleting. Child record: ${file}.`\n\t\t} catch (error) {\n\t\t\tconst code =\n\t\t\t\terror instanceof SyntaxError\n\t\t\t\t\t? 'EINVAL'\n\t\t\t\t\t: error instanceof Error && 'code' in error\n\t\t\t\t\t\t? String(error.code)\n\t\t\t\t\t\t: describeCaptureError(error)\n\t\t\treturn code === 'ENOENT'\n\t\t\t\t? `No child record exists at ${file}.`\n\t\t\t\t: `Child record could not be read (${code}): ${file}.`\n\t\t}\n\t}\n}\n","import type { CaptureDestination, CaptureExpandedManifest } from '@src/core'\nimport type {\n\tCaptureArtifactResult,\n\tCaptureCheckFrame,\n\tCaptureDecodedImage,\n\tCaptureJudgedFrame,\n\tCaptureJudgedRecord,\n\tCaptureProducer,\n\tCaptureProject,\n\tCapturePreflightInterface,\n\tCapturePreflightResult,\n\tCaptureReaderOptions,\n\tCaptureReaderSelection,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { existsSync, readFileSync, realpathSync, rmSync } from 'node:fs'\nimport { isAbsolute, relative, resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\nimport {\n\tarrayOf,\n\tattempt,\n\tisArray,\n\tisFunction,\n\tisRecord,\n\tisString,\n\tparseJSON,\n} from '@orkestrel/contract'\nimport {\n\tCAPTURE_MANIFEST_FILE,\n\tCAPTURE_REGISTRY_FILE,\n\tCaptureError,\n\tdescribeCaptureError,\n\tisCapturePath,\n\tisCaptureError,\n\tisCaptureRun,\n\tmatchesCaptureSelector,\n\treadCaptureArtifact,\n\tresolveCaptureKey,\n\tresolveCaptureOwner,\n} from '@src/core'\nimport {\n\tCAPTURE_DEFAULTS,\n\tCAPTURE_EXIT,\n\tCAPTURE_MINIMUM_IMAGE,\n\tCAPTURE_REPORT_LINES,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_SHEET,\n} from './constants.js'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport {\n\tbuildCaptureIntegrityOptions,\n\tbuildCaptureReaderReport,\n\tcollectCaptureErrors,\n\tscanCaptureFrames,\n\tcomputeCaptureHash,\n\tdecodeCapturePicture,\n\trequireCaptureProjects,\n\tresolveCaptureRelative,\n\trequireCaptureContained,\n\tresolveCaptureExit,\n\treadCaptureImage,\n\treadCaptureManifest,\n\trequireCaptureSelection,\n\tresolveCaptureStandalone,\n\treadCaptureVariants,\n\tshrinkCapturePicture,\n\trequireCaptureArgument,\n} from './helpers.js'\n\n/**\n * Reads the selected population's frames and reports their freshness, mixed observations, and coverage.\n *\n * @remarks\n * A successful preflight is iteration evidence and never assembled-portfolio acceptance. The reader\n * reads the host's wrapper through a `CaptureDiscovery`, the consumer's own Vitest in discovery\n * mode, and reads its projects the way the runner does: it names no portfolio, owner, variant, or\n * path the wrapper does not declare, and it imports neither Vite nor Vitest. It\n * judges each frame by the artifact the frame's own stamp names, never by a variant's latest file.\n * Rules that belong to one product, such as a page-title check or a pixel comparison, live in a\n * host module named by the `checks` option. The reader loads that module through the runtime's own\n * module loader by its file URL, reads its `CAPTURE_CHECKS` export, a list of readers from a frame to\n * its findings, and appends every finding to the report.\n * The wrapper's optional `uniform` owner selectors restrict only mixed observations;\n * absence judges every scope, and an empty list judges none.\n *\n * @example\n * ```ts\n * const preflight = new CapturePreflight({\n * \troot: process.cwd(),\n * \tconfig: `${process.cwd()}/configs/app/vite.journey.config.ts`,\n * \tselection: { selector: 'pages:mail' },\n * \tjourneys: `${process.cwd()}/tmp/journey`,\n * })\n * const exit = await preflight.execute()\n * ```\n */\nexport class CapturePreflight implements CapturePreflightInterface {\n\treadonly #options: CaptureReaderOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds one explicit workspace, wrapper, and selection.\n\t *\n\t * @param options - The host configuration and the exact requested bounds\n\t */\n\tconstructor(options: CaptureReaderOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\t/**\n\t * Reads the authenticated selection, uniform scopes, and the host's declared viewports.\n\t *\n\t * @returns The engine, the selected destinations, the viewports, the uniform scopes, and the primary run directory\n\t * @throws Thrown when the wrapper, the registry, or the selection is invalid.\n\t *\n\t * @example\n\t * ```ts\n\t * const { population } = await preflight.read()\n\t * ```\n\t */\n\tasync read(): Promise<CaptureReaderSelection> {\n\t\tconst { root, config, selection } = this.#options\n\t\tconst invocation = new CaptureInvocation({\n\t\t\tcommand: 'stale',\n\t\t\troot,\n\t\t\trequests: this.#options.requests ?? CAPTURE_DEFAULTS.requests,\n\t\t\tstdout: () => undefined,\n\t\t\tstderr: this.#stderr,\n\t\t})\n\t\tinvocation.attach()\n\t\ttry {\n\t\t\tconst loaded = await this.#load(config, invocation)\n\t\t\trequireCaptureArgument(root, resolve(root, this.#options.journeys), '--journeys')\n\t\t\tif (this.#options.checks !== undefined)\n\t\t\t\trequireCaptureArgument(root, resolve(root, this.#options.checks), '--checks')\n\t\t\tif (!isCapturePath(resolveCaptureRelative(root, config)))\n\t\t\t\tthrow new CaptureError('Reader config must be a contained repository path', {\n\t\t\t\t\tcode: 'USAGE',\n\t\t\t\t})\n\t\t\trequireCaptureSelection(\n\t\t\t\tselection.selector,\n\t\t\t\t[],\n\t\t\t\tloaded.map((entry) => entry.project),\n\t\t\t\t[],\n\t\t\t\tselection.portfolio,\n\t\t\t)\n\t\t\tconst primary = requireCaptureProjects(loaded.map((entry) => entry.project))\n\t\t\tconst standalone = resolveCaptureStandalone(\n\t\t\t\tprimary.standalone,\n\t\t\t\tselection.selector,\n\t\t\t\tselection.portfolio,\n\t\t\t)\n\t\t\tconst options = buildCaptureIntegrityOptions(root, primary, standalone)\n\t\t\trequireCaptureSelection(\n\t\t\t\tselection.selector,\n\t\t\t\tselection.variants ?? [],\n\t\t\t\tloaded.map((entry) => entry.project),\n\t\t\t\treadCaptureVariants(root, resolve(root, options.directory, CAPTURE_REGISTRY_FILE)),\n\t\t\t)\n\t\t\tconst integrity = new CaptureIntegrity(options)\n\t\t\tconst population = await integrity.read(selection)\n\t\t\t// A standalone root's producers belong to another wrapper, so only the primary population is mapped.\n\t\t\tif (\n\t\t\t\tstandalone === undefined &&\n\t\t\t\tpopulation.entries.some(\n\t\t\t\t\t(entry) => !loaded.some((candidate) => candidate.producer.project === entry.project),\n\t\t\t\t)\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Authenticated destination has no actual wrapper project', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\treturn {\n\t\t\t\tintegrity,\n\t\t\t\tpopulation,\n\t\t\t\tvariants: loaded.map((entry) => entry.producer),\n\t\t\t\tdirectory: options.directory,\n\t\t\t\t...(primary.uniform === undefined ? {} : { uniform: primary.uniform }),\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (resolveCaptureExit(error) === 64)\n\t\t\t\trmSync(invocation.directory, { recursive: true, force: true })\n\t\t\tthrow error\n\t\t} finally {\n\t\t\tawait invocation\n\t\t\t\t.release()\n\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t)\n\t\t}\n\t}\n\n\t/**\n\t * Judges every selected frame and returns the mixed observations, freshness, images, and issues.\n\t *\n\t * @returns The preflight result without upgrading any freshness classification\n\t * @throws Thrown when the selection or an artifact cannot be read.\n\t *\n\t * @example\n\t * ```ts\n\t * const result = await preflight.check()\n\t * ```\n\t */\n\tasync check(): Promise<CapturePreflightResult> {\n\t\tconst source = await this.read()\n\t\tconst freshness = await source.integrity.check({\n\t\t\t...this.#options.selection,\n\t\t\tvariants: [...new Set(source.population.entries.map((entry) => entry.variant))],\n\t\t})\n\t\tconst judged = this.#artifacts(source)\n\t\tconst checks = await this.#checks()\n\t\tconst results = judged.map(({ entry, artifact, issues }) => {\n\t\t\tconst result = this.#image(entry)\n\t\t\tconst findings = checks.flatMap((check) => {\n\t\t\t\tconst found: unknown = check({ entry, picture: result.image?.picture, artifact })\n\t\t\t\tif (!arrayOf(isString)(found))\n\t\t\t\t\tthrow new CaptureError('A host check returned something other than a list of findings', {\n\t\t\t\t\t\tcode: 'HOST',\n\t\t\t\t\t})\n\t\t\t\treturn found\n\t\t\t})\n\t\t\treturn {\n\t\t\t\timage:\n\t\t\t\t\tresult.image === undefined\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t...result.image,\n\t\t\t\t\t\t\t\tpicture: { width: result.image.picture.width, height: result.image.picture.height },\n\t\t\t\t\t\t\t\tthumbnail: shrinkCapturePicture(\n\t\t\t\t\t\t\t\t\tresult.image.picture,\n\t\t\t\t\t\t\t\t\tMath.max(1, Math.ceil(result.image.picture.width / CAPTURE_SHEET.cell)),\n\t\t\t\t\t\t\t\t\tCAPTURE_SHEET.limit,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t},\n\t\t\t\tissues: [...issues, ...result.issues, ...findings],\n\t\t\t}\n\t\t})\n\t\tconst images = results.flatMap((result) => (result.image === undefined ? [] : [result.image]))\n\t\tconst result: CapturePreflightResult = {\n\t\t\tselection: source.population,\n\t\t\tvariants: source.variants,\n\t\t\tdirectory: source.directory,\n\t\t\tfreshness,\n\t\t\timages,\n\t\t\tmixed: scanCaptureFrames(\n\t\t\t\timages.filter(\n\t\t\t\t\t({ entry }) =>\n\t\t\t\t\t\tsource.uniform === undefined ||\n\t\t\t\t\t\tsource.uniform.some((scope) =>\n\t\t\t\t\t\t\tmatchesCaptureSelector(resolveCaptureOwner(entry), scope),\n\t\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t\tsource.variants,\n\t\t\t),\n\t\t\tissues: [...new Set(results.flatMap((image) => image.issues))],\n\t\t}\n\t\treturn result\n\t}\n\n\t/**\n\t * Executes the check and prints its report.\n\t *\n\t * @returns Exit 0 for current frames without defects, 1 for any defect, or 64 for refused usage\n\t *\n\t * @example\n\t * ```ts\n\t * const exit = await preflight.execute() // 0\n\t * ```\n\t */\n\tasync execute(): Promise<number> {\n\t\ttry {\n\t\t\tconst result = await this.check()\n\t\t\tthis.#stdout(\n\t\t\t\t`${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify(buildCaptureReaderReport(result))}\\n`,\n\t\t\t)\n\t\t\treturn result.issues.length > 0 ||\n\t\t\t\tresult.freshness.entries.some((entry) => entry.status !== 'current')\n\t\t\t\t? CAPTURE_EXIT.failed\n\t\t\t\t: CAPTURE_EXIT.passed\n\t\t} catch (error) {\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t}\n\t}\n\n\t// Discovers the wrapper through the consumer's own Vitest and keeps each project beside its producing viewport.\n\tasync #load(\n\t\tconfig: string,\n\t\tinvocation: CaptureInvocation,\n\t): Promise<\n\t\tReadonlyArray<{ readonly project: CaptureProject; readonly producer: CaptureProducer }>\n\t> {\n\t\tconst { root, deadline, mode } = this.#options\n\t\t// A discovery child's output is the runner's log, never the reader's report.\n\t\tinvocation.prepare()\n\t\trequireCaptureArgument(root, resolve(root, this.#options.journeys), '--journeys')\n\t\tif (this.#options.checks !== undefined)\n\t\t\trequireCaptureArgument(root, resolve(root, this.#options.checks), '--checks')\n\t\tconst description = await new CaptureDiscovery({\n\t\t\troot,\n\t\t\tconfig,\n\t\t\tinvocation,\n\t\t\t...(mode === undefined ? {} : { mode }),\n\t\t\t...(deadline === undefined ? {} : { deadline }),\n\t\t}).describe()\n\t\treturn description.projects.map(({ project, viewport }) => {\n\t\t\tif (viewport === undefined)\n\t\t\t\tthrow new CaptureError('A reader project declares no viewport geometry', {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t})\n\t\t\treturn { project, producer: { ...viewport, project: project.name } }\n\t\t})\n\t}\n\n\t// Loads the host's check readers; a reader without a checks module has none.\n\tasync #checks(): Promise<ReadonlyArray<(frame: CaptureCheckFrame) => unknown>> {\n\t\tconst { checks, root } = this.#options\n\t\tif (checks === undefined) return []\n\t\tconst loaded: unknown = await this.#import(resolve(root, checks)).catch((error: unknown) => {\n\t\t\tthrow new CaptureError(`Cannot load the checks module: ${checks}`, {\n\t\t\t\tcode: 'HOST',\n\t\t\t\tcause: error,\n\t\t\t})\n\t\t})\n\t\tconst list: unknown = isRecord(loaded) ? loaded.CAPTURE_CHECKS : undefined\n\t\tif (!isArray(list) || !list.every(isFunction))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The checks module exports no CAPTURE_CHECKS list of readers: ${checks}`,\n\t\t\t\t{ code: 'HOST' },\n\t\t\t)\n\t\treturn list\n\t}\n\n\t// Imports a host module by its file URL; the specifier is computed, so a bundler leaves it alone.\n\tasync #import(file: string): Promise<unknown> {\n\t\treturn await import(/* @vite-ignore */ pathToFileURL(file).href)\n\t}\n\n\t// Decodes one selected image, reporting the reason an unreadable or tiny one cannot be judged.\n\t#image(entry: CaptureDestination): {\n\t\treadonly image: CaptureDecodedImage | undefined\n\t\treadonly issues: readonly string[]\n\t} {\n\t\tconst read = attempt(() => {\n\t\t\tconst bytes = readCaptureImage(resolve(this.#options.root, entry.file))\n\t\t\tif (bytes.length < CAPTURE_MINIMUM_IMAGE)\n\t\t\t\tthrow new CaptureError(`Image under 4 KB: ${entry.file}`, { code: 'EVIDENCE' })\n\t\t\tconst image = {\n\t\t\t\tentry,\n\t\t\t\tpicture: decodeCapturePicture(bytes),\n\t\t\t\tdigest: computeCaptureHash(bytes),\n\t\t\t\tsize: bytes.length,\n\t\t\t}\n\t\t\treturn image\n\t\t})\n\t\treturn read.success\n\t\t\t? { image: read.value, issues: [] }\n\t\t\t: {\n\t\t\t\t\timage: undefined,\n\t\t\t\t\tissues: [`Cannot read image ${entry.file}: ${describeCaptureError(read.error)}`],\n\t\t\t\t}\n\t}\n\n\t// Judges each frame by the artifact its own stamp's run record names, then runs the host's checks.\n\t#artifacts(result: CaptureReaderSelection): readonly CaptureJudgedFrame[] {\n\t\tconst stored = this.#manifest(result.directory)\n\t\tconst located = result.population.entries.map((entry) => ({\n\t\t\tentry,\n\t\t\tlocation: attempt(() => this.#locate(entry, stored, result.variants, result.directory)),\n\t\t}))\n\t\tconst paths = new Set(\n\t\t\tlocated.flatMap(({ location }) => (location.success ? [location.value.record] : [])),\n\t\t)\n\t\tconst records = new Map(\n\t\t\t[...paths].map((record) => [record, attempt(() => this.#artifact(record))] as const),\n\t\t)\n\t\tconst judged = located.map(({ entry, location }): CaptureJudgedFrame => {\n\t\t\tif (!location.success)\n\t\t\t\treturn { entry, artifact: undefined, issues: [describeCaptureError(location.error)] }\n\t\t\tconst outcome = records.get(location.value.record)\n\t\t\tif (outcome === undefined)\n\t\t\t\tthrow new CaptureError(`Judged run record was not read: ${location.value.record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (!outcome.success)\n\t\t\t\treturn { entry, artifact: undefined, issues: [describeCaptureError(outcome.error)] }\n\t\t\tconst artifact = outcome.value\n\t\t\tconst lines = readCaptureArtifact(artifact.text)\n\t\t\tconst covered =\n\t\t\t\tartifact.run.passed.includes(location.value.case) &&\n\t\t\t\tartifact.run.entries.some(\n\t\t\t\t\t(emitted) => resolveCaptureKey(emitted) === resolveCaptureKey(entry),\n\t\t\t\t)\n\t\t\treturn {\n\t\t\t\tentry,\n\t\t\t\tartifact,\n\t\t\t\tissues: [\n\t\t\t\t\t...(covered ? [] : [`Judged record does not cover ${entry.file}: ${artifact.record}`]),\n\t\t\t\t\t...(lines.records.includes(artifact.record)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [`Judged journey artifact does not cover its record: ${artifact.file}`]),\n\t\t\t\t\t...(lines.cases.includes(location.value.case)\n\t\t\t\t\t\t? []\n\t\t\t\t\t\t: [`Judged journey artifact does not cover ${location.value.case}: ${artifact.file}`]),\n\t\t\t\t],\n\t\t\t}\n\t\t})\n\t\tconst artifacts = [\n\t\t\t...new Map(\n\t\t\t\tjudged.flatMap(({ artifact }) =>\n\t\t\t\t\tartifact === undefined ? [] : [[artifact.file, artifact] as const],\n\t\t\t\t),\n\t\t\t).values(),\n\t\t]\n\t\tconst errors = artifacts.flatMap((artifact) =>\n\t\t\tcollectCaptureErrors(artifact.file, artifact.text),\n\t\t)\n\t\treturn judged.map((frame) => ({\n\t\t\t...frame,\n\t\t\tissues: [\n\t\t\t\t...frame.issues,\n\t\t\t\t...errors.filter(\n\t\t\t\t\t(error) => frame.artifact !== undefined && error.startsWith(`${frame.artifact.file}:`),\n\t\t\t\t),\n\t\t\t],\n\t\t}))\n\t}\n\n\t// Reads the stamps the engine's check validated; an absent manifest holds no stamps.\n\t#manifest(directory: string): CaptureExpandedManifest | undefined {\n\t\tconst file = resolve(this.#options.root, directory, CAPTURE_MANIFEST_FILE)\n\t\tif (!existsSync(file)) return undefined\n\t\treturn readCaptureManifest(\n\t\t\tparseJSON(readFileSync(file, 'utf8')),\n\t\t\t`${directory}/${CAPTURE_MANIFEST_FILE}`,\n\t\t)\n\t}\n\n\t// Resolves the run record a judged frame's stamp names through its wrapper's producing variant.\n\t#locate(\n\t\tentry: CaptureDestination,\n\t\tstored: CaptureExpandedManifest | undefined,\n\t\tproducers: readonly CaptureProducer[],\n\t\tdirectory: string,\n\t): CaptureJudgedRecord {\n\t\tconst stamp = stored?.entries[resolveCaptureKey(entry)]\n\t\tif (stamp === undefined)\n\t\t\tthrow new CaptureError(`Judged frame has no stamped run record: ${entry.file}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst producer = producers.find((candidate) => candidate.project === entry.project)?.name\n\t\tif (producer === undefined)\n\t\t\tthrow new CaptureError(`No journey artifact mapping for project: ${entry.project}`, {\n\t\t\t\tcode: 'HOST',\n\t\t\t})\n\t\tconst record = `${directory}/${CAPTURE_RUNS_DIRECTORY}/${stamp.identity.id}/${stamp.identity.stage}/${producer}.json`\n\t\tif (!isCapturePath(record))\n\t\t\tthrow new CaptureError(`Invalid judged run record path: ${record}`, { code: 'EVIDENCE' })\n\t\treturn { record, case: stamp.case }\n\t}\n\n\t// Reads a judged record and the artifact it names, refusing changed or unbound artifact bytes.\n\t#artifact(record: string): CaptureArtifactResult {\n\t\tconst { root, journeys } = this.#options\n\t\trequireCaptureContained(root, resolve(root, journeys))\n\t\tconst run = parseJSON(readFileSync(resolve(root, record), 'utf8'))\n\t\tif (!isCaptureRun(run))\n\t\t\tthrow new CaptureError(`Invalid judged run record: ${record}`, { code: 'EVIDENCE' })\n\t\tif (run.artifact === undefined)\n\t\t\tthrow new CaptureError(`Judged record names no journey artifact: ${record}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tconst file = run.artifact.file\n\t\tconst path = resolve(root, file)\n\t\tconst physical = attempt(() => requireCaptureContained(journeys, path))\n\t\tconst contained = relative(journeys, path)\n\t\tif (\n\t\t\tcontained === '' ||\n\t\t\tcontained.startsWith('..') ||\n\t\t\tisAbsolute(contained) ||\n\t\t\t(!physical.success && isCaptureError(physical.error)) ||\n\t\t\t(physical.success && physical.value === realpathSync(journeys))\n\t\t)\n\t\t\tthrow new CaptureError(`Judged journey artifact is outside the journeys directory: ${file}`, {\n\t\t\t\tcode: 'CONTAINMENT',\n\t\t\t})\n\t\tif (!physical.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot read judged journey artifact: ${file}: ${describeCaptureError(physical.error)}`,\n\t\t\t\t{ code: 'EVIDENCE', cause: physical.error },\n\t\t\t)\n\t\tconst bytes = attempt(() => readFileSync(physical.value))\n\t\tif (!bytes.success)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Cannot read judged journey artifact: ${file}: ${describeCaptureError(bytes.error)}`,\n\t\t\t\t{ code: 'EVIDENCE', cause: bytes.error },\n\t\t\t)\n\t\tif (computeCaptureHash(bytes.value) !== run.artifact.digest)\n\t\t\tthrow new CaptureError(`Judged journey artifact differs from its record: ${file}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\treturn { record, run, file, text: bytes.value.toString('utf8') }\n\t}\n}\n","import type { CaptureRequest } from '@src/core'\nimport type {\n\tCaptureExecutionResult,\n\tCaptureInvocationInterface,\n\tCaptureIntegrityOptions,\n\tCaptureProject,\n\tCaptureReceiptInput,\n\tCaptureRegistrarInterface,\n\tCaptureRegistrarOptions,\n\tCaptureRegistryArguments,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { existsSync, readFileSync, renameSync, rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { attempt, parseJSON } from '@orkestrel/contract'\nimport {\n\tCAPTURE_REGISTRY_FILE,\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tdescribeCaptureError,\n\tdescribeCaptureRequest,\n\tisCapturePath,\n\tisCaptureRegistry,\n\tisCaptureRun,\n\treadCaptureReport,\n\tvalidateCaptureRun,\n} from '@src/core'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport {\n\tCAPTURE_EXIT,\n\tCAPTURE_PROGRESS_SUFFIX,\n\tCAPTURE_REGISTRY_LINE,\n\tCAPTURE_REGISTRY_STAGE,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_VITEST_ENTRY,\n} from './constants.js'\nimport {\n\tbuildCaptureArguments,\n\trequireCaptureContained,\n\tdescribeCaptureFault,\n\tdescribeCaptureHolders,\n\tbuildCaptureIntegrityOptions,\n\tbuildCaptureRegistry,\n\tcomputeCaptureHash,\n\treadCaptureInputs,\n\treadCaptureLookupJournal,\n\treadCaptureManifest,\n\tmatchesCaptureVersionRefusal,\n\treadCaptureRegistryArguments,\n\trequireCaptureProjects,\n\tresolveCaptureRelative,\n\twriteCaptureDocument,\n\tresolveCaptureExit,\n} from './helpers.js'\n\n/**\n * Refreshes the accepted registry from one complete capture-free journey stage over the selected variants.\n *\n * @remarks\n * The refresh is the one route that bootstraps or replaces the registry the stage transaction\n * requires, so it cannot stamp through the integrity engine. It reads the wrapper through the same\n * discovery the runner uses, takes the same invocation entity, request file, and Vitest child, and runs\n * every selected producing variant in one stage, one child that receives each variant's project, with\n * the `all` selector and no capture variable. The stage passes no tag filter, so it runs the whole\n * suite, which stands in for the consumer's complete test run. It reads the stage's reporter once and each variant's\n * final record, takes each project's input population before and after, and builds one receipt per\n * variant, all naming the one reporter, through `buildCaptureRegistry`. The registry is written to a\n * candidate beside its target, read back through the integrity engine, and only then renamed into\n * place, so a registry the engine would refuse never replaces a good one. With `--variant`, the\n * existing registry's receipts for the other declared variants are kept. It never widens a scoped\n * run into a refresh and refuses while another runner holds a request file in the request directory.\n * Before any stage, it reads the inherited manifest and lookup journal: it refuses a document of\n * another version with that refusal's own removal and refresh commands alone, and an unsupported\n * schema with the file to inspect and repair.\n *\n * @example\n * ```ts\n * const registrar = new CaptureRegistrar({\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/capture',\n * \targv: [],\n * })\n * const exit = await registrar.execute()\n * ```\n */\nexport class CaptureRegistrar implements CaptureRegistrarInterface {\n\treadonly #options: CaptureRegistrarOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds the workspace, the wrapper default, the request directory, and the command line.\n\t *\n\t * @param options - The workspace, the wrapper default, the request directory, the command line, and optional output writers\n\t */\n\tconstructor(options: CaptureRegistrarOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\tasync execute(): Promise<number> {\n\t\tconst { root, requests, argv, config } = this.#options\n\t\tconst invocation = new CaptureInvocation({\n\t\t\tcommand: 'journey',\n\t\t\troot,\n\t\t\trequests,\n\t\t\tstdout: this.#stdout,\n\t\t\tstderr: this.#stderr,\n\t\t})\n\t\tinvocation.attach()\n\t\ttry {\n\t\t\tinvocation.prepare()\n\t\t\tconst parsed = readCaptureRegistryArguments(argv, root, config)\n\t\t\tconst description = await new CaptureDiscovery({\n\t\t\t\troot,\n\t\t\t\tconfig: parsed.config,\n\t\t\t\tinvocation,\n\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t\t...(this.#options.deadline === undefined ? {} : { deadline: this.#options.deadline }),\n\t\t\t}).describe()\n\t\t\treturn await this.#refresh(\n\t\t\t\tinvocation,\n\t\t\t\tparsed,\n\t\t\t\tdescription.projects.map((entry) => entry.project),\n\t\t\t)\n\t\t} catch (error) {\n\t\t\tif (resolveCaptureExit(error) === 64)\n\t\t\t\trmSync(invocation.directory, { recursive: true, force: true })\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t} finally {\n\t\t\tawait invocation\n\t\t\t\t.release()\n\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t)\n\t\t}\n\t}\n\n\tasync #refresh(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tparsed: CaptureRegistryArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst { root } = this.#options\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst declared = [...new Set(projects.flatMap((project) => project.variants))]\n\t\tfor (const variant of parsed.variants) {\n\t\t\tif (!declared.includes(variant))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Unknown variant; ${describeCaptureFault('--variant', variant, 'a producing variant declared by the wrapper', declared)}`,\n\t\t\t\t\t{ code: 'USAGE', context: { variant } },\n\t\t\t\t)\n\t\t}\n\t\tconst variants = declared.filter(\n\t\t\t(variant) => parsed.variants.length === 0 || parsed.variants.includes(variant),\n\t\t)\n\t\tconst selected = variants.map((variant) => {\n\t\t\tconst project = projects.find((candidate) => candidate.variant === variant)\n\t\t\tif (project === undefined)\n\t\t\t\tthrow new CaptureError(`The wrapper declares no journey project for ${variant}`, {\n\t\t\t\t\tcode: 'HOST',\n\t\t\t\t\tcontext: { variant },\n\t\t\t\t})\n\t\t\treturn project\n\t\t})\n\t\tconst directory = resolveCaptureRelative(root, primary.directory)\n\t\tconst target = `${directory}/${CAPTURE_REGISTRY_FILE}`\n\t\tconst candidate = `${target}.${invocation.id}.candidate`\n\t\t// Validate the physical publication roots before a stage can write a run or a candidate.\n\t\tconst options = buildCaptureIntegrityOptions(root, primary)\n\t\tconst integrity = new CaptureIntegrity({\n\t\t\t...options,\n\t\t\tregistry: candidate,\n\t\t})\n\t\tthis.#inherit(options)\n\t\tconst holders = invocation.holders()\n\t\tif (holders.length > 0)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureHolders(holders, this.#options.requests)}; the registry refresh starts only while no runner is mid-stage`,\n\t\t\t\t{ code: 'STAGE', context: { holders: holders.map((holder) => holder.pid) } },\n\t\t\t)\n\t\t// A receipt this run keeps must still match its reporter bytes, so an altered one refuses before any journey runs.\n\t\tconst retained = parsed.variants.length === 0 ? [] : this.#retain(target, variants, declared)\n\t\tif (retained.length > 0) buildCaptureRegistry(retained)\n\t\tif (invocation.interrupted) return CAPTURE_EXIT.failed\n\t\tconst imports = await this.#stage(invocation, parsed, primary, selected)\n\t\tif (invocation.interrupted) return CAPTURE_EXIT.failed\n\t\tconst registry = buildCaptureRegistry([...retained, ...imports])\n\t\tconst path = resolve(root, candidate)\n\t\trequireCaptureContained(root, path)\n\t\ttry {\n\t\t\twriteCaptureDocument(path, registry, invocation.signal)\n\t\t\t// The engine reads the candidate exactly as it will read the registry, before anything is replaced.\n\t\t\tawait integrity.read({ selector: 'all' })\n\t\t\tinvocation.signal.throwIfAborted()\n\t\t\trequireCaptureContained(root, path)\n\t\t\trequireCaptureContained(root, resolve(root, target))\n\t\t\trenameSync(path, resolve(root, target))\n\t\t} finally {\n\t\t\tif (attempt(() => requireCaptureContained(root, path)).success) rmSync(path, { force: true })\n\t\t}\n\t\tthis.#stdout(\n\t\t\t`${CAPTURE_REGISTRY_LINE} ${JSON.stringify({\n\t\t\t\tfile: target,\n\t\t\t\tdigest: registry.digest,\n\t\t\t\tvariants: registry.receipts.map((receipt) => receipt.variant),\n\t\t\t\trefreshed: variants,\n\t\t\t\tentries: registry.entries.length,\n\t\t\t})}\\n`,\n\t\t)\n\t\treturn CAPTURE_EXIT.passed\n\t}\n\n\t#inherit(options: CaptureIntegrityOptions): void {\n\t\tfor (const file of [options.manifest, options.lookups]) {\n\t\t\tconst path = resolve(options.root, file)\n\t\t\ttry {\n\t\t\t\trequireCaptureContained(options.root, path)\n\t\t\t\tif (!existsSync(path)) continue\n\t\t\t\tconst value: unknown = parseJSON(readFileSync(path, 'utf8'))\n\t\t\t\tif (file === options.manifest) readCaptureManifest(value, file)\n\t\t\t\telse readCaptureLookupJournal(value, file)\n\t\t\t} catch (error) {\n\t\t\t\tif (matchesCaptureVersionRefusal(error)) throw error\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`Cannot refresh the registry with inherited evidence at ${JSON.stringify(file)}: ${describeCaptureError(error)}; inspect and repair this file before retrying`,\n\t\t\t\t\t{ code: 'EVIDENCE', cause: error, context: { file } },\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tasync #stage(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tparsed: CaptureRegistryArguments,\n\t\tprimary: CaptureProject,\n\t\tselected: readonly CaptureProject[],\n\t): Promise<readonly CaptureReceiptInput[]> {\n\t\tconst { root } = this.#options\n\t\tconst stage = CAPTURE_REGISTRY_STAGE\n\t\tconst variants = selected.map((project) => project.variant)\n\t\tconst reportFile = resolve(invocation.directory, `${stage}.json`)\n\t\tconst log = resolve(invocation.directory, `${stage}.log`)\n\t\tconst records = `${resolveCaptureRelative(root, primary.directory)}/${CAPTURE_RUNS_DIRECTORY}/${invocation.id}/${stage}`\n\t\tconst args = buildCaptureArguments({\n\t\t\tentry: resolve(root, CAPTURE_VITEST_ENTRY),\n\t\t\tconfig: parsed.config,\n\t\t\treport: reportFile,\n\t\t\tprogress: resolve(invocation.directory, `${stage}${CAPTURE_PROGRESS_SUFFIX}`),\n\t\t\t...(parsed.bail === undefined ? {} : { bail: parsed.bail }),\n\t\t\tprojects: selected.map((project) => project.name),\n\t\t\tfinal: primary.final,\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t})\n\t\tconst request: CaptureRequest = {\n\t\t\tversion: CAPTURE_VERSION,\n\t\t\tid: invocation.id,\n\t\t\tstage,\n\t\t\tconfig: resolveCaptureRelative(root, parsed.config),\n\t\t\tpid: process.pid,\n\t\t\tcommand: 'journey',\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\tselector: 'all',\n\t\t\tvariants,\n\t\t\targs,\n\t\t}\n\t\tconst snapshots = selected.map((project) => ({\n\t\t\tproject,\n\t\t\tbefore: readCaptureInputs(root, project.inputs),\n\t\t}))\n\t\tconst started = Date.now()\n\t\trmSync(reportFile, { force: true })\n\t\tthis.#stdout(\n\t\t\t`registry ${stage}: ${variants.join(', ')}; all; report=${reportFile}; records=${records}/<variant>.json\\n`,\n\t\t)\n\t\tconst outcome = await this.#run(invocation, request, log)\n\t\tif (invocation.interrupted)\n\t\t\tthrow new CaptureError('Runner interrupted', { code: 'STAGE', context: { stage, variants } })\n\t\tconst subject = `The registry journey for ${variants.join(', ')} in stage ${stage}`\n\t\tif (outcome.code !== 0 || outcome.signal !== null)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${subject} did not exit successfully (${String(outcome.code ?? outcome.signal)})`,\n\t\t\t\t{ code: 'STAGE', context: { stage, variants, code: outcome.code, signal: outcome.signal } },\n\t\t\t)\n\t\tif (!existsSync(reportFile))\n\t\t\tthrow new CaptureError(`${subject} wrote no reporter at ${reportFile}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\tcontext: { stage, variants },\n\t\t\t})\n\t\tconst text = readFileSync(reportFile, 'utf8')\n\t\tconst report = readCaptureReport(parseJSON(text))\n\t\tif (report.start < started || report.end > Date.now())\n\t\t\tthrow new CaptureError('Reporter does not belong to this refresh', { code: 'EVIDENCE' })\n\t\tconst file = resolveCaptureRelative(root, reportFile)\n\t\tconst digest = computeCaptureHash(text)\n\t\treturn snapshots.map(({ project, before }) => {\n\t\t\tconst variant = project.variant\n\t\t\tconst record = `${records}/${variant}.json`\n\t\t\tif (!existsSync(resolve(root, record)))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`The registry journey for ${variant} wrote no final record at ${record}`,\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t\t\tcontext: { variant },\n\t\t\t\t\t},\n\t\t\t\t)\n\t\t\tconst run: unknown = parseJSON(readFileSync(resolve(root, record), 'utf8'))\n\t\t\tif (\n\t\t\t\t!isCaptureRun(run) ||\n\t\t\t\trun.request === undefined ||\n\t\t\t\trun.variant !== variant ||\n\t\t\t\tdescribeCaptureRequest(run.request) !== describeCaptureRequest(request)\n\t\t\t)\n\t\t\t\tthrow new CaptureError(`Invalid or mismatched final record: ${record}`, {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tif (Date.parse(run.time) < started || Date.parse(run.time) > report.end)\n\t\t\t\tthrow new CaptureError('Final record time does not belong to this refresh', {\n\t\t\t\t\tcode: 'EVIDENCE',\n\t\t\t\t})\n\t\t\tvalidateCaptureRun(run, report, project.name)\n\t\t\tif (!run.complete)\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`The registry journey for ${variant} was not a complete run; a refresh imports complete runs only`,\n\t\t\t\t\t{ code: 'EVIDENCE', context: { variant } },\n\t\t\t\t)\n\t\t\tif (JSON.stringify(readCaptureInputs(root, project.inputs)) !== JSON.stringify(before))\n\t\t\t\tthrow new CaptureError('Bounded host inputs or membership changed during the refresh', {\n\t\t\t\t\tcode: 'STAGE',\n\t\t\t\t\tcontext: { variant },\n\t\t\t\t})\n\t\t\treturn {\n\t\t\t\treceipt: {\n\t\t\t\t\tversion: CAPTURE_VERSION,\n\t\t\t\t\tvariant,\n\t\t\t\t\ttime: run.time,\n\t\t\t\t\treport: { file, digest },\n\t\t\t\t\tinputs: before,\n\t\t\t\t\tdeclarations: run.declarations,\n\t\t\t\t\tregistry: run.registry,\n\t\t\t\t\tcomplete: run.complete,\n\t\t\t\t},\n\t\t\t\treport: text,\n\t\t\t\toutcome,\n\t\t\t\tcapped: false,\n\t\t\t}\n\t\t})\n\t}\n\n\tasync #run(\n\t\tinvocation: CaptureInvocationInterface,\n\t\trequest: CaptureRequest,\n\t\tlog: string,\n\t): Promise<CaptureExecutionResult> {\n\t\ttry {\n\t\t\tinvocation.publish(request)\n\t\t\treturn await invocation.spawn(request.args, log, false)\n\t\t} finally {\n\t\t\tinvocation.retract()\n\t\t}\n\t}\n\n\t#retain(\n\t\ttarget: string,\n\t\trefreshed: readonly string[],\n\t\tdeclared: readonly string[],\n\t): readonly CaptureReceiptInput[] {\n\t\tconst { root } = this.#options\n\t\tconst path = resolve(root, target)\n\t\tif (!existsSync(path)) return []\n\t\tconst registry: unknown = parseJSON(readFileSync(path, 'utf8'))\n\t\tif (!isCaptureRegistry(registry))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`The existing registry is invalid and cannot keep the variants this run leaves out; refresh every producing variant to replace it: ${target}`,\n\t\t\t\t{ code: 'EVIDENCE' },\n\t\t\t)\n\t\treturn registry.receipts\n\t\t\t.filter(\n\t\t\t\t(receipt) => declared.includes(receipt.variant) && !refreshed.includes(receipt.variant),\n\t\t\t)\n\t\t\t.map((receipt) => {\n\t\t\t\tif (!isCapturePath(receipt.report.file) || !existsSync(resolve(root, receipt.report.file)))\n\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t`The retained receipt for ${receipt.variant} has no reporter at ${JSON.stringify(receipt.report.file)}; refresh every producing variant`,\n\t\t\t\t\t\t{ code: 'EVIDENCE', context: { variant: receipt.variant } },\n\t\t\t\t\t)\n\t\t\t\treturn {\n\t\t\t\t\treceipt,\n\t\t\t\t\treport: readFileSync(resolve(root, receipt.report.file), 'utf8'),\n\t\t\t\t\toutcome: { code: 0, signal: null },\n\t\t\t\t\tcapped: false,\n\t\t\t\t}\n\t\t\t})\n\t}\n}\n","import type { Result } from '@orkestrel/contract'\nimport type { CapturePortfolioRoot, CaptureRequest } from '@src/core'\nimport type {\n\tCaptureChangePlan,\n\tCaptureIntegrityInterface,\n\tCaptureIntegrityOptions,\n\tCaptureInvocationInterface,\n\tCaptureOutcome,\n\tCaptureOwnerOutcome,\n\tCaptureProject,\n\tCaptureRunnerArguments,\n\tCaptureRunnerInterface,\n\tCaptureRunnerOptions,\n\tCaptureRunPlan,\n\tCaptureStagePlan,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { rmSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { attempt, failure, isFailure, isSuccess, success } from '@orkestrel/contract'\nimport {\n\tCAPTURE_LOOKUPS_FILE,\n\tCAPTURE_MANIFEST_FILE,\n\tCAPTURE_REGISTRY_FILE,\n\tCAPTURE_VERSION,\n\tCaptureError,\n\tdescribeCaptureError,\n\tisCaptureError,\n\tisCapturePath,\n} from '@src/core'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport {\n\tCAPTURE_COMMAND_NAMES,\n\tCAPTURE_EXIT,\n\tCAPTURE_PROGRESS_SUFFIX,\n\tCAPTURE_RECOVERIES,\n\tCAPTURE_RUNS_DIRECTORY,\n\tCAPTURE_STAGES,\n\tCAPTURE_STATUS_RECOVERIES,\n\tCAPTURE_VITEST_ENTRY,\n} from './constants.js'\nimport {\n\tbuildCaptureArguments,\n\tbuildCaptureFilter,\n\tcollectCaptureOwners,\n\tdescribeCaptureSelectorFault,\n\treadCaptureArguments,\n\trenderCaptureCommand,\n\trequireCaptureProjects,\n\tresolveCaptureRelative,\n\tresolveCaptureStages,\n\tresolveCaptureVariants,\n\tresolveCaptureExit,\n\tresolveCaptureStandalone,\n\treadCaptureTitles,\n\tdescribeCaptureMembers,\n\tdescribeCaptureFault,\n\trequireCaptureSelection,\n\treadCaptureVariants,\n\tmatchesCaptureVersionRefusal,\n} from './helpers.js'\n\n/**\n * Drives selected owners through one journey stage or staged frame captures.\n *\n * @remarks\n * The wrapper and the installed Vitest supply the registry and the execution protocol, and the\n * wrapper's provided values supply every name the runner uses: the variants, the first-stage\n * variant, the final case, and the portfolio roots. The runner never loads the wrapper itself: a\n * `CaptureDiscovery` runs the consumer's installed Vitest in discovery mode and reads back the host\n * description the wrapper writes, so the runner imports neither Vite nor Vitest. It creates one\n * discovery invocation per `execute` call and a separate invocation per changed owner, and holds\n * none of that call's state itself.\n *\n * @example\n * ```ts\n * const runner = new CaptureRunner({\n * \tcommand: 'journey',\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/units',\n * \targv: ['pages:mail', '--variant', 'light-390'],\n * })\n * const exit = await runner.execute()\n * ```\n */\nexport class CaptureRunner implements CaptureRunnerInterface {\n\treadonly #options: CaptureRunnerOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds the command, the workspace, and the command line.\n\t *\n\t * @param options - The command, the workspace, the wrapper default, the request directory, and the command line\n\t */\n\tconstructor(options: CaptureRunnerOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\tasync execute(): Promise<number> {\n\t\tconst { command, root, requests, argv, config } = this.#options\n\t\tconst invocation = new CaptureInvocation({\n\t\t\tcommand,\n\t\t\troot,\n\t\t\trequests,\n\t\t\tstdout: this.#stdout,\n\t\t\tstderr: this.#stderr,\n\t\t})\n\t\tinvocation.attach()\n\t\tconst invocations: CaptureInvocationInterface[] = [invocation]\n\t\t// The NEXT commands the outcome's reports record for stdout after the report they follow.\n\t\tconst reports: string[] = []\n\t\tconst argumentsResult = attempt(() => readCaptureArguments(argv, command, root, config))\n\t\tconst described = await this.#describe(invocation, argumentsResult).then(\n\t\t\t(description) => success(description),\n\t\t\t(error: unknown) => failure(error),\n\t\t)\n\t\tconst result = isFailure(described)\n\t\t\t? described\n\t\t\t: await this.#dispatch(\n\t\t\t\t\tinvocation,\n\t\t\t\t\tinvocations,\n\t\t\t\t\treports,\n\t\t\t\t\tdescribed.value.parsed,\n\t\t\t\t\tdescribed.value.projects,\n\t\t\t\t).then(\n\t\t\t\t\t(code) => success(code),\n\t\t\t\t\t(error: unknown) => failure(error),\n\t\t\t\t)\n\t\ttry {\n\t\t\tconst code = isSuccess(result) ? result.value : resolveCaptureExit(result.error)\n\t\t\tif (code === CAPTURE_EXIT.usage)\n\t\t\t\trmSync(invocation.directory, { recursive: true, force: true })\n\t\t\tthis.#conclude(\n\t\t\t\tresult,\n\t\t\t\tinvocations,\n\t\t\t\treports,\n\t\t\t\targumentsResult.success ? argumentsResult.value : undefined,\n\t\t\t\tisSuccess(described) ? described.value.projects : [],\n\t\t\t)\n\t\t\treturn code\n\t\t} finally {\n\t\t\tawait invocation\n\t\t\t\t.release()\n\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t)\n\t\t}\n\t}\n\n\t// Prepares the invocation, then reads the wrapper's projects through the discovery child.\n\tasync #describe(\n\t\tinvocation: CaptureInvocationInterface,\n\t\targumentsResult: Result<CaptureRunnerArguments>,\n\t): Promise<{\n\t\treadonly parsed: CaptureRunnerArguments\n\t\treadonly projects: readonly CaptureProject[]\n\t}> {\n\t\tconst { root } = this.#options\n\t\tinvocation.prepare()\n\t\tif (!argumentsResult.success) throw argumentsResult.error\n\t\tconst parsed = argumentsResult.value\n\t\tconst description = await new CaptureDiscovery({\n\t\t\troot,\n\t\t\tconfig: parsed.config,\n\t\t\tinvocation,\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t...(this.#options.deadline === undefined ? {} : { deadline: this.#options.deadline }),\n\t\t}).describe()\n\t\treturn { parsed, projects: description.projects.map((entry) => entry.project) }\n\t}\n\n\tasync #dispatch(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tinvocations: CaptureInvocationInterface[],\n\t\treports: string[],\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst { command } = this.#options\n\t\tif (parsed.selector !== undefined) {\n\t\t\trequireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio)\n\t\t}\n\t\tif (command !== 'stale' && parsed.variants.length > 0)\n\t\t\tresolveCaptureVariants(parsed.variants, projects)\n\t\t// An unknown or missing owner refuses before --case reads the registry, so it is never a registry condition.\n\t\tif (command !== 'stale' && parsed.changed === undefined)\n\t\t\tthis.#scope(parsed.selector, collectCaptureOwners(projects))\n\t\tif (command !== 'stale' && parsed.case !== undefined) {\n\t\t\tthis.#case(requireCaptureProjects(projects), parsed.case, parsed.selector)\n\t\t}\n\t\tif (command !== 'stale' && parsed.changed !== undefined) {\n\t\t\tawait invocation.release()\n\t\t\tinvocation.attach()\n\t\t\treturn await this.#changed(invocation, invocations, reports, command, parsed, projects)\n\t\t}\n\t\treturn command === 'stale'\n\t\t\t? await this.#check(parsed, projects, reports)\n\t\t\t: await this.#run(invocation, command, parsed, projects, reports)\n\t}\n\n\t// Prints the outcome's NEXT commands once each in first-seen order, a refusal's in the same write.\n\t#conclude(\n\t\tresult: Result<number>,\n\t\tinvocations: readonly CaptureInvocationInterface[],\n\t\treports: readonly string[],\n\t\tparsed: CaptureRunnerArguments | undefined,\n\t\tprojects: readonly CaptureProject[],\n\t): void {\n\t\tconst { command } = this.#options\n\t\t// A refusal with no report line derives its recovery from its condition and any interrupt of the call.\n\t\tconst lines =\n\t\t\treports.length > 0 || isSuccess(result) || parsed === undefined\n\t\t\t\t? reports\n\t\t\t\t: this.#recover(\n\t\t\t\t\t\tresult.error,\n\t\t\t\t\t\tparsed,\n\t\t\t\t\t\tparsed.selector,\n\t\t\t\t\t\tinvocations.some((entry) => entry.interrupted),\n\t\t\t\t\t\tprojects,\n\t\t\t\t\t)\n\t\tconst next = [...new Set(lines)].map((line) => `NEXT ${line}\\n`).join('')\n\t\tif (reports.length > 0 && next !== '') this.#stdout(next)\n\t\tif (isSuccess(result)) return\n\t\tconst ran = Object.values(CAPTURE_STAGES).filter((stage) =>\n\t\t\tinvocations.some((entry) =>\n\t\t\t\tentry.launched(resolve(entry.directory, `${command}-${stage}.log`)),\n\t\t\t),\n\t\t)\n\t\tthis.#stderr(\n\t\t\t`${describeCaptureError(result.error)}\\n${ran.length === 0 ? 'No execution child ran; the command was refused before execution.' : `Execution stopped after stages: ${ran.join(', ')}; no later stage ran.`}\\n${reports.length > 0 ? '' : next}`,\n\t\t)\n\t}\n\n\tasync #changed(\n\t\tdiscovery: CaptureInvocationInterface,\n\t\tinvocations: CaptureInvocationInterface[],\n\t\treports: string[],\n\t\tcommand: CaptureRequest['command'],\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t): Promise<number> {\n\t\tconst { root, requests } = this.#options\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst plan = this.#changes(parsed, primary)\n\t\tfor (const change of plan.changes) this.#stdout(`CHANGE ${JSON.stringify(change)}\\n`)\n\t\tconst commands = plan.owners.map((owner) => renderCaptureCommand(command, parsed, owner, root))\n\t\tconst shared = plan.changes.filter((change) => change.classification === 'shared')\n\t\tconst complete = this.#complete(parsed)\n\t\tfor (const next of commands) this.#stdout(`COMMAND ${next}\\n`)\n\t\tconst variants = resolveCaptureVariants(parsed.variants, projects)\n\t\tif (shared.length > 0) {\n\t\t\tthis.#stderr(\n\t\t\t\t`Shared journey inputs cannot be narrowed because every destination reads them: ${describeCaptureMembers(shared.map((change) => change.path))}\\n`,\n\t\t\t)\n\t\t\tthis.#stdout(\n\t\t\t\t`SUMMARY ${JSON.stringify({ run: [], passed: [], failed: [], notrun: plan.owners, reason: 'shared inputs require an explicit journey selection' })}\\n`,\n\t\t\t)\n\t\t\treports.push(...commands, complete)\n\t\t\treturn CAPTURE_EXIT.usage\n\t\t}\n\t\tif (plan.owners.length === 0) {\n\t\t\tthis.#stdout(\n\t\t\t\t`No journey input changed\\nSUMMARY ${JSON.stringify({ run: [], passed: [], failed: [], notrun: [], reason: 'only outside paths or no changed paths' })}\\n`,\n\t\t\t)\n\t\t\treports.push(complete)\n\t\t\treturn parsed.plan ? CAPTURE_EXIT.passed : CAPTURE_EXIT.failed\n\t\t}\n\t\tconst selectors = collectCaptureOwners(projects)\n\t\tfor (const owner of plan.owners) {\n\t\t\tconst fault = describeCaptureSelectorFault(owner, selectors)\n\t\t\tif (fault !== undefined) throw new CaptureError(fault, { code: 'HOST' })\n\t\t\tif (parsed.case !== undefined) this.#case(primary, parsed.case, owner)\n\t\t\tif (parsed.plan) await this.#resolve(this.#integrity(primary), parsed, owner, variants)\n\t\t}\n\t\tif (parsed.plan) {\n\t\t\tthis.#stdout(\n\t\t\t\t`SUMMARY ${JSON.stringify({ run: [], passed: [], failed: [], notrun: plan.owners, reason: '--plan starts no execution child' })}\\n`,\n\t\t\t)\n\t\t\treports.push(...commands)\n\t\t\treturn CAPTURE_EXIT.passed\n\t\t}\n\t\tconst outcomes: CaptureOwnerOutcome[] = []\n\t\t// The NEXT lines each failed owner's run recorded, in owner order.\n\t\tconst recorded: string[] = []\n\t\tfor (const owner of plan.owners) {\n\t\t\tif (discovery.interrupted) break\n\t\t\tconst invocation = new CaptureInvocation({\n\t\t\t\tcommand,\n\t\t\t\troot,\n\t\t\t\trequests,\n\t\t\t\tstdout: this.#stdout,\n\t\t\t\tstderr: this.#stderr,\n\t\t\t})\n\t\t\tinvocations.push(invocation)\n\t\t\tinvocation.attach()\n\t\t\tconst owned = { ...parsed, selector: owner }\n\t\t\tconst lines: string[] = []\n\t\t\ttry {\n\t\t\t\t// A refusal before execution, an unusable request directory included, fails this owner alone.\n\t\t\t\tconst code = await Promise.resolve()\n\t\t\t\t\t.then(async () => {\n\t\t\t\t\t\tinvocation.prepare()\n\t\t\t\t\t\treturn await this.#run(invocation, command, owned, projects, lines)\n\t\t\t\t\t})\n\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\t// A version refusal holds for every owner, so it ends the changed run.\n\t\t\t\t\t\tif (matchesCaptureVersionRefusal(error)) throw error\n\t\t\t\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\t\t\t\t// A refusal before the owner's stage report recorded no line, so its condition names one.\n\t\t\t\t\t\tif (lines.length === 0)\n\t\t\t\t\t\t\tlines.push(...this.#recover(error, owned, owner, false, projects))\n\t\t\t\t\t\treturn resolveCaptureExit(error)\n\t\t\t\t\t})\n\t\t\t\tif (code !== CAPTURE_EXIT.passed) recorded.push(...lines)\n\t\t\t\toutcomes.push({\n\t\t\t\t\towner,\n\t\t\t\t\tcode,\n\t\t\t\t\tran: Object.values(CAPTURE_STAGES).some((stage) =>\n\t\t\t\t\t\tinvocation.launched(resolve(invocation.directory, `${command}-${stage}.log`)),\n\t\t\t\t\t),\n\t\t\t\t})\n\t\t\t} finally {\n\t\t\t\tawait invocation\n\t\t\t\t\t.release()\n\t\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tif (outcomes.some((outcome) => outcome.code !== CAPTURE_EXIT.passed)) break\n\t\t}\n\t\tconst failed = outcomes.filter((outcome) => outcome.code !== CAPTURE_EXIT.passed)\n\t\tconst notrun = plan.owners.filter(\n\t\t\t(owner) => !outcomes.some((outcome) => outcome.owner === owner && outcome.ran),\n\t\t)\n\t\tthis.#stdout(\n\t\t\t`SUMMARY ${JSON.stringify({\n\t\t\t\trun: outcomes.filter((outcome) => outcome.ran).map((outcome) => outcome.owner),\n\t\t\t\tpassed: outcomes\n\t\t\t\t\t.filter((outcome) => outcome.code === CAPTURE_EXIT.passed)\n\t\t\t\t\t.map((outcome) => outcome.owner),\n\t\t\t\tfailed: failed.map((outcome) => outcome.owner),\n\t\t\t\tnotrun,\n\t\t\t\treason: discovery.interrupted\n\t\t\t\t\t? 'interrupted'\n\t\t\t\t\t: failed.length > 0\n\t\t\t\t\t\t? 'stopped at the first red owner'\n\t\t\t\t\t\t: 'every selected owner passed',\n\t\t\t})}\\n`,\n\t\t)\n\t\treports.push(\n\t\t\t...(failed.length === 0 && notrun.length === 0\n\t\t\t\t? [complete]\n\t\t\t\t: [\n\t\t\t\t\t\t...recorded,\n\t\t\t\t\t\t...notrun.map((owner) => renderCaptureCommand(command, parsed, owner, root)),\n\t\t\t\t\t]),\n\t\t)\n\t\treturn failed.at(0)?.code ?? (discovery.interrupted ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed)\n\t}\n\n\t// Returns the run's selector, or refuses a missing or unknown one as usage.\n\t#scope(selector: string | undefined, selectors: readonly string[]): string {\n\t\tif (selector === undefined) throw new CaptureError(this.#usage(selectors), { code: 'USAGE' })\n\t\tconst fault = describeCaptureSelectorFault(selector, selectors)\n\t\tif (fault !== undefined) throw new CaptureError(fault, { code: 'USAGE', context: { selector } })\n\t\treturn selector\n\t}\n\n\t#case(primary: CaptureProject, name: string, selector?: string): void {\n\t\tconst { root } = this.#options\n\t\tconst titles = readCaptureTitles(\n\t\t\troot,\n\t\t\tresolve(root, primary.directory, CAPTURE_REGISTRY_FILE),\n\t\t\tselector,\n\t\t)\n\t\tif (!Object.hasOwn(titles, name))\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Unknown case; ${describeCaptureFault('--case', name, \"a case in the selected owner's accepted registry reporter collection\", Object.keys(titles))}`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t}\n\n\t#changes(parsed: CaptureRunnerArguments, primary: CaptureProject): CaptureChangePlan {\n\t\ttry {\n\t\t\tif (parsed.changed === undefined)\n\t\t\t\tthrow new CaptureError('Missing value: --changed', { code: 'USAGE' })\n\t\t\treturn this.#integrity(primary).changed(parsed.changed)\n\t\t} catch (error) {\n\t\t\tif (matchesCaptureVersionRefusal(error)) throw error\n\t\t\tthrow new CaptureError(\n\t\t\t\t`${describeCaptureError(error)}\\nNo owner ran; changed selection was refused.`,\n\t\t\t\t{ code: isCaptureError(error) ? error.code : 'EVIDENCE', cause: error },\n\t\t\t)\n\t\t}\n\t}\n\n\tasync #run(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tcommand: CaptureRequest['command'],\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t\treports: string[],\n\t): Promise<number> {\n\t\tconst { root } = this.#options\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst selectors = collectCaptureOwners(projects)\n\t\tconst selector = this.#scope(parsed.selector, selectors)\n\t\tconst variants = resolveCaptureVariants(parsed.variants, projects)\n\t\tconst integrity = this.#integrity(primary)\n\t\tconst selected = await this.#resolve(integrity, parsed, selector, variants)\n\t\tconst plan: CaptureRunPlan = {\n\t\t\tcommand,\n\t\t\tprojects,\n\t\t\tselector,\n\t\t\tfilter: buildCaptureFilter(command, selector, selectors),\n\t\t\t...(selected === undefined ? {} : { case: selected }),\n\t\t\t...(parsed.state === undefined ? {} : { state: parsed.state }),\n\t\t\tfinal: primary.final,\n\t\t\tdirectory: resolveCaptureRelative(root, primary.directory),\n\t\t\tconfig: resolveCaptureRelative(root, parsed.config),\n\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t...(parsed.bail === undefined ? {} : { bail: parsed.bail }),\n\t\t}\n\t\tconst outcomes: CaptureOutcome[] = []\n\t\tconst stages = resolveCaptureStages(variants, primary.first, command)\n\t\tconst completed: CaptureStagePlan[] = []\n\t\tconst result = await this.#stages(\n\t\t\tinvocation,\n\t\t\tintegrity,\n\t\t\tplan,\n\t\t\tstages,\n\t\t\toutcomes,\n\t\t\tcompleted,\n\t\t).then(\n\t\t\t(code) => success(code),\n\t\t\t(error: unknown) => failure(error),\n\t\t)\n\t\tconst ran = stages.filter((stage) =>\n\t\t\tinvocation.launched(resolve(invocation.directory, `${command}-${stage.name}.log`)),\n\t\t)\n\t\tconst notrun = stages.filter((stage) => !ran.includes(stage))\n\t\tconst failed = ran.filter((stage) => !completed.includes(stage))\n\t\tconst passed =\n\t\t\tcompleted.length === stages.length && outcomes.some((outcome) => outcome.count > 0)\n\t\tthis.#stdout(\n\t\t\t`STAGES ${JSON.stringify({\n\t\t\t\tselector,\n\t\t\t\trun: ran.map((stage) => stage.name),\n\t\t\t\tpassed: completed.map((stage) => stage.name),\n\t\t\t\tfailed: failed.map((stage) => stage.name),\n\t\t\t\tnotrun: notrun.map((stage) => stage.name),\n\t\t\t\treason: invocation.interrupted\n\t\t\t\t\t? 'interrupted; no later stage ran'\n\t\t\t\t\t: passed\n\t\t\t\t\t\t? 'selected workload passed'\n\t\t\t\t\t\t: failed.length > 0\n\t\t\t\t\t\t\t? 'stage failed; no later stage ran'\n\t\t\t\t\t\t\t: notrun.length > 0\n\t\t\t\t\t\t\t\t? 'refused before execution'\n\t\t\t\t\t\t\t\t: 'empty selected workload',\n\t\t\t})}\\n`,\n\t\t)\n\t\t// A passing whole-case journey of all is the complete journey; an unfinished stage reruns itself.\n\t\treports.push(\n\t\t\t...(passed\n\t\t\t\t? command === 'journey' && selector === 'all' && parsed.case === undefined\n\t\t\t\t\t? []\n\t\t\t\t\t: [this.#complete(parsed)]\n\t\t\t\t: this.#recover(\n\t\t\t\t\t\tisFailure(result) ? result.error : undefined,\n\t\t\t\t\t\tparsed,\n\t\t\t\t\t\tselector,\n\t\t\t\t\t\tfailed.length > 0 || invocation.interrupted,\n\t\t\t\t\t\tprojects,\n\t\t\t\t\t)),\n\t\t)\n\t\tif (isFailure(result)) throw result.error\n\t\treturn result.value\n\t}\n\n\tasync #stages(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tintegrity: CaptureIntegrityInterface,\n\t\tplan: CaptureRunPlan,\n\t\tstages: readonly CaptureStagePlan[],\n\t\toutcomes: CaptureOutcome[],\n\t\tcompleted: CaptureStagePlan[],\n\t): Promise<number> {\n\t\tfor (const stage of stages) {\n\t\t\tif (invocation.interrupted) return CAPTURE_EXIT.failed\n\t\t\toutcomes.push(...(await this.#stage(invocation, integrity, plan, stage)))\n\t\t\tcompleted.push(stage)\n\t\t}\n\t\tfor (const outcome of outcomes) {\n\t\t\tthis.#stdout(`${outcome.project}: ${String(outcome.count)} owner-bearing passed cases\\n`)\n\t\t}\n\t\tif (outcomes.every((outcome) => outcome.count === 0))\n\t\t\tthrow new CaptureError('Empty selected workload: no requested project held applicable work', {\n\t\t\t\tcode: 'SELECTION',\n\t\t\t})\n\t\treturn CAPTURE_EXIT.passed\n\t}\n\n\tasync #stage(\n\t\tinvocation: CaptureInvocationInterface,\n\t\tintegrity: CaptureIntegrityInterface,\n\t\tplan: CaptureRunPlan,\n\t\tstage: CaptureStagePlan,\n\t): Promise<readonly CaptureOutcome[]> {\n\t\tconst { root } = this.#options\n\t\tconst report = resolve(invocation.directory, `${plan.command}-${stage.name}.json`)\n\t\tconst log = resolve(invocation.directory, `${plan.command}-${stage.name}.log`)\n\t\tconst selected = stage.variants.flatMap((variant) =>\n\t\t\tplan.projects.filter((project) => project.variant === variant),\n\t\t)\n\t\tconst args = buildCaptureArguments({\n\t\t\tentry: resolve(root, CAPTURE_VITEST_ENTRY),\n\t\t\tconfig: resolve(root, plan.config),\n\t\t\treport,\n\t\t\tprogress: resolve(invocation.directory, `${stage.name}${CAPTURE_PROGRESS_SUFFIX}`),\n\t\t\t...(plan.bail === undefined ? {} : { bail: plan.bail }),\n\t\t\tprojects: selected.map((project) => project.name),\n\t\t\tfilter: plan.filter,\n\t\t\t...(plan.mode === undefined ? {} : { mode: plan.mode }),\n\t\t\t...(plan.case === undefined ? {} : { case: plan.case }),\n\t\t\t...(plan.case === undefined\n\t\t\t\t? {}\n\t\t\t\t: {\n\t\t\t\t\t\ttitles: readCaptureTitles(root, resolve(root, plan.directory, CAPTURE_REGISTRY_FILE)),\n\t\t\t\t\t}),\n\t\t\tfinal: plan.final,\n\t\t})\n\t\tconst request: CaptureRequest = {\n\t\t\tversion: CAPTURE_VERSION,\n\t\t\tid: invocation.id,\n\t\t\tstage: stage.name,\n\t\t\tconfig: plan.config,\n\t\t\tpid: process.pid,\n\t\t\tcommand: plan.command,\n\t\t\t...(plan.mode === undefined ? {} : { mode: plan.mode }),\n\t\t\tselector: plan.selector,\n\t\t\t...(plan.case === undefined ? {} : { case: plan.case }),\n\t\t\t...(plan.state === undefined ? {} : { state: plan.state }),\n\t\t\tvariants: stage.variants,\n\t\t\targs,\n\t\t}\n\t\trmSync(report, { force: true })\n\t\ttry {\n\t\t\tinvocation.publish(request)\n\t\t\tthis.#stdout(\n\t\t\t\t`${plan.command} ${stage.name}: ${stage.variants.join(', ')}; ${plan.selector}${plan.case === undefined ? '' : ' (case-scoped)'}; report=${report}; records=${plan.directory}/${CAPTURE_RUNS_DIRECTORY}/${invocation.id}/${stage.name}/<variant>.json\\n`,\n\t\t\t)\n\t\t\tconst result = await integrity.stamp({\n\t\t\t\trequest,\n\t\t\t\treport: resolveCaptureRelative(root, report),\n\t\t\t\tsignal: invocation.signal,\n\t\t\t\tprojects: selected.map((project) => ({\n\t\t\t\t\tname: project.name,\n\t\t\t\t\tvariant: project.variant,\n\t\t\t\t\tinputs: project.inputs,\n\t\t\t\t\trecord: `${resolveCaptureRelative(root, project.directory)}/${CAPTURE_RUNS_DIRECTORY}/${request.id}/${request.stage}/${project.variant}.json`,\n\t\t\t\t})),\n\t\t\t\texecute: () => invocation.spawn(args, log, plan.command === 'capture'),\n\t\t\t})\n\t\t\tthis.#stdout(\n\t\t\t\t`INTEGRITY ${JSON.stringify({\n\t\t\t\t\tcommand: plan.command,\n\t\t\t\t\tstage: stage.name,\n\t\t\t\t\tvariants: stage.variants,\n\t\t\t\t\tstamps: result.entries.length,\n\t\t\t\t\tlookups: result.lookups.length,\n\t\t\t\t\tduration: result.duration,\n\t\t\t\t})}\\n`,\n\t\t\t)\n\t\t\tconst outcomes = result.projects.map((project) => ({\n\t\t\t\tproject: project.project,\n\t\t\t\tvariant: project.variant,\n\t\t\t\tcount: project.passed.length,\n\t\t\t}))\n\t\t\tif (stage.name === CAPTURE_STAGES.first && outcomes.every((outcome) => outcome.count === 0)) {\n\t\t\t\tthis.#stdout(\n\t\t\t\t\t`${stage.variants.join(', ')} is inapplicable; the rest stage carries ${plan.selector} when requested\\n`,\n\t\t\t\t)\n\t\t\t}\n\t\t\treturn outcomes\n\t\t} finally {\n\t\t\tinvocation.retract()\n\t\t}\n\t}\n\n\tasync #resolve(\n\t\tintegrity: CaptureIntegrityInterface,\n\t\tparsed: CaptureRunnerArguments,\n\t\tselector: string,\n\t\tvariants: readonly string[],\n\t): Promise<string | undefined> {\n\t\tif (parsed.state === undefined) return parsed.case\n\t\treturn await integrity\n\t\t\t.lookup({\n\t\t\t\tselector,\n\t\t\t\tvariants,\n\t\t\t\tstate: parsed.state,\n\t\t\t\t...(parsed.case === undefined ? {} : { case: parsed.case }),\n\t\t\t})\n\t\t\t.then((result) => result.case)\n\t}\n\n\t#integrity(\n\t\tprimary: CaptureProject,\n\t\tstandalone?: CapturePortfolioRoot,\n\t): CaptureIntegrityInterface {\n\t\tconst { root } = this.#options\n\t\tconst directory =\n\t\t\tstandalone === undefined\n\t\t\t\t? resolveCaptureRelative(root, primary.directory)\n\t\t\t\t: standalone.directory\n\t\tif (!isCapturePath(directory))\n\t\t\tthrow new CaptureError('The wrapper provides a directory outside the repository', {\n\t\t\t\tcode: 'HOST',\n\t\t\t\tcontext: { directory },\n\t\t\t})\n\t\tconst options: CaptureIntegrityOptions = {\n\t\t\troot,\n\t\t\tdirectory,\n\t\t\tinputs: primary.inputs,\n\t\t\tregistry: `${directory}/${CAPTURE_REGISTRY_FILE}`,\n\t\t\tmanifest: `${directory}/${CAPTURE_MANIFEST_FILE}`,\n\t\t\tlookups: `${directory}/${CAPTURE_LOOKUPS_FILE}`,\n\t\t\tportfolios: standalone === undefined ? primary.portfolios : [standalone],\n\t\t}\n\t\tconst create = this.#options.integrity\n\t\treturn create === undefined ? new CaptureIntegrity(options) : create(options)\n\t}\n\n\tasync #check(\n\t\tparsed: CaptureRunnerArguments,\n\t\tprojects: readonly CaptureProject[],\n\t\treports: string[],\n\t): Promise<number> {\n\t\tconst selector = parsed.selector\n\t\tif (selector === undefined)\n\t\t\tthrow new CaptureError(\n\t\t\t\t`Usage: capture ${CAPTURE_COMMAND_NAMES.stale} <selector> [--variant <output>] [--state <state>] [--case <full name>] [--portfolio <name>]`,\n\t\t\t\t{ code: 'USAGE' },\n\t\t\t)\n\t\tconst primary = requireCaptureProjects(projects)\n\t\tconst standalone = resolveCaptureStandalone(primary.standalone, selector, parsed.portfolio)\n\t\trequireCaptureSelection(\n\t\t\tselector,\n\t\t\tparsed.variants,\n\t\t\tprojects,\n\t\t\treadCaptureVariants(\n\t\t\t\tthis.#options.root,\n\t\t\t\tresolve(\n\t\t\t\t\tthis.#options.root,\n\t\t\t\t\tstandalone?.directory ?? primary.directory,\n\t\t\t\t\tCAPTURE_REGISTRY_FILE,\n\t\t\t\t),\n\t\t\t),\n\t\t)\n\t\t// An omitted variant list reads every output variant of the selected registry destinations,\n\t\t// and refuses a declared producing variant the registry never attested.\n\t\tconst result = await this.#integrity(primary, standalone).check({\n\t\t\tselector,\n\t\t\tdeclared: [...new Set(projects.flatMap((project) => project.variants))],\n\t\t\t...(parsed.variants.length === 0 ? {} : { variants: parsed.variants }),\n\t\t\t...(parsed.case === undefined ? {} : { case: parsed.case }),\n\t\t\t...(parsed.state === undefined ? {} : { state: parsed.state }),\n\t\t\t...(parsed.portfolio === undefined ? {} : { portfolio: parsed.portfolio }),\n\t\t})\n\t\tthis.#stdout(`INTEGRITY ${JSON.stringify({ command: 'stale', ...result })}\\n`)\n\t\t// A frames run over the selector restamps every variant and state, so the line names neither.\n\t\tif (\n\t\t\tstandalone === undefined &&\n\t\t\tresult.entries.some((entry) => CAPTURE_STATUS_RECOVERIES[entry.status] === 'capture')\n\t\t)\n\t\t\treports.push(\n\t\t\t\trenderCaptureCommand(\n\t\t\t\t\t'capture',\n\t\t\t\t\t{\n\t\t\t\t\t\tconfig: parsed.config,\n\t\t\t\t\t\tvariants: [],\n\t\t\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t\t\t\t...(parsed.case === undefined ? {} : { case: parsed.case }),\n\t\t\t\t\t},\n\t\t\t\t\tselector,\n\t\t\t\t\tthis.#options.root,\n\t\t\t\t),\n\t\t\t)\n\t\treturn result.entries.every((entry) => entry.status === 'current')\n\t\t\t? CAPTURE_EXIT.passed\n\t\t\t: CAPTURE_EXIT.failed\n\t}\n\n\t// Returns the commands that clear a refusal's condition, then the run's own when it left work unfinished.\n\t#recover(\n\t\terror: unknown,\n\t\tparsed: CaptureRunnerArguments,\n\t\tselector: string | undefined,\n\t\tunfinished: boolean,\n\t\tprojects: readonly CaptureProject[],\n\t): readonly string[] {\n\t\t// A version refusal names its own recovery, and every command fails until that recovery runs.\n\t\tif (matchesCaptureVersionRefusal(error)) return []\n\t\tconst { command, root } = this.#options\n\t\tconst recovery = isCaptureError(error) ? CAPTURE_RECOVERIES[error.code] : undefined\n\t\t// The registry refresh writes the primary registry alone, so a standalone stale reading has no refresh.\n\t\tconst standalone =\n\t\t\tcommand === 'stale' &&\n\t\t\tselector !== undefined &&\n\t\t\tresolveCaptureStandalone(\n\t\t\t\tprojects.flatMap((project) => project.standalone),\n\t\t\t\tselector,\n\t\t\t\tparsed.portfolio,\n\t\t\t) !== undefined\n\t\treturn [\n\t\t\t...(recovery === 'registry' && !standalone\n\t\t\t\t? [\n\t\t\t\t\t\trenderCaptureCommand(\n\t\t\t\t\t\t\t'registry',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tconfig: parsed.config,\n\t\t\t\t\t\t\t\tvariants: [],\n\t\t\t\t\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t),\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t\t...(recovery === 'journey' && selector !== undefined\n\t\t\t\t? [renderCaptureCommand('journey', parsed, selector, root)]\n\t\t\t\t: []),\n\t\t\t...(unfinished && selector !== undefined\n\t\t\t\t? [renderCaptureCommand(command, parsed, selector, root)]\n\t\t\t\t: []),\n\t\t]\n\t}\n\n\t// Renders the complete journey, which keeps the run's variants, mode, and wrapper.\n\t#complete(parsed: CaptureRunnerArguments): string {\n\t\treturn renderCaptureCommand(\n\t\t\t'journey',\n\t\t\t{\n\t\t\t\tconfig: parsed.config,\n\t\t\t\tvariants: parsed.variants,\n\t\t\t\t...(parsed.mode === undefined ? {} : { mode: parsed.mode }),\n\t\t\t},\n\t\t\t'all',\n\t\t\tthis.#options.root,\n\t\t)\n\t}\n\n\t#usage(selectors: readonly string[]): string {\n\t\tconst { command } = this.#options\n\t\tconst state = command === 'capture' ? ' [--state <name>]' : ''\n\t\treturn `Usage: capture ${CAPTURE_COMMAND_NAMES[command]} <selector> [--variant <name>] [--case <full name>]${state} [--config <file>]\\nOr: capture ${CAPTURE_COMMAND_NAMES[command]} --changed <ref> [--plan] [--variant <name>] [--case <full name>]${state} [--config <file>]\\nSelectors:\\n${describeCaptureMembers(selectors.toSorted())}\\nall (every declared scope; name it explicitly)`\n\t}\n}\n","import type {\n\tCapturePicture,\n\tCapturePreflightResult,\n\tCaptureSheetCell,\n\tCaptureSheetGroup,\n\tCaptureSheetIndex,\n\tCaptureSheetOptions,\n\tCaptureSheetPage,\n\tCaptureSheetRow,\n\tCaptureSheetsInterface,\n\tCaptureWriteHandler,\n} from './types.js'\nimport { existsSync, mkdirSync, realpathSync, writeFileSync } from 'node:fs'\nimport { dirname, relative, resolve } from 'node:path'\nimport { attempt } from '@orkestrel/contract'\nimport { CaptureError, describeCaptureError, isCapturePath, resolveCaptureOwner } from '@src/core'\nimport {\n\tCAPTURE_EXIT,\n\tCAPTURE_REPORT_LINES,\n\tCAPTURE_SHEET,\n\tCAPTURE_SHEET_FILES,\n\tCAPTURE_DEFAULTS,\n} from './constants.js'\nimport { CaptureInvocation } from './CaptureInvocation.js'\nimport { CapturePreflight } from './CapturePreflight.js'\nimport {\n\tbuildCaptureReaderReport,\n\tcomposeCapturePictures,\n\tcomputeCaptureComposite,\n\tencodeCapturePicture,\n\tnormalizeSlashes,\n\tresolveCapturePhysical,\n\tresolveCaptureSheetIdentity,\n\tsplitCapturePages,\n\tsplitCaptureSheets,\n\tresolveCaptureExit,\n\trequireCaptureArgument,\n} from './helpers.js'\n\n/**\n * Composes exactly the authenticated sparse state and output pairs for iteration review.\n *\n * @remarks\n * Sheets remain preflight artifacts, never assembled-portfolio acceptance. The class reads the\n * selection through `CapturePreflight`, so it judges the same population the preflight does and\n * keeps its refusals. It writes the sheets, an index of every cell, and a notes document into a new\n * directory that is contained in the workspace, has an existing parent, and lies outside every\n * selected capture directory. A frame whose image cannot be read shows as a red mark with no source\n * size, and its index cell carries the freshness the engine classified, `missing` for an absent file.\n *\n * @example\n * ```ts\n * const sheets = new CaptureSheets({ reader, output: `${process.cwd()}/tmp/sheets` })\n * const exit = await sheets.execute()\n * ```\n */\nexport class CaptureSheets implements CaptureSheetsInterface {\n\treadonly #options: CaptureSheetOptions\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/**\n\t * Binds a read selection and a new output directory.\n\t *\n\t * @param options - The explicit host, selection, and sheet destination\n\t */\n\tconstructor(options: CaptureSheetOptions) {\n\t\tthis.#options = options\n\t\tthis.#stdout = options.reader.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.reader.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\t/**\n\t * Reads selected physical images, writes complete indexed sheets, and retains all refusals.\n\t *\n\t * @returns Exit 0 for current selected images without preflight defects, 1 for any defect or containment refusal, or 64 for refused usage\n\t *\n\t * @example\n\t * ```ts\n\t * const exit = await sheets.execute() // 0\n\t * ```\n\t */\n\tasync execute(): Promise<number> {\n\t\ttry {\n\t\t\tconst { reader } = this.#options\n\t\t\tconst invocation = new CaptureInvocation({\n\t\t\t\tcommand: 'stale',\n\t\t\t\troot: reader.root,\n\t\t\t\trequests: reader.requests ?? CAPTURE_DEFAULTS.requests,\n\t\t\t\tstdout: this.#stdout,\n\t\t\t\tstderr: this.#stderr,\n\t\t\t})\n\t\t\ttry {\n\t\t\t\tinvocation.prepare()\n\t\t\t\tthis.#output()\n\t\t\t} finally {\n\t\t\t\tawait invocation\n\t\t\t\t\t.release()\n\t\t\t\t\t.catch((error: unknown) =>\n\t\t\t\t\t\tthis.#stderr(`Capture cleanup failed: ${describeCaptureError(error)}\\n`),\n\t\t\t\t\t)\n\t\t\t}\n\t\t\tconst result = await new CapturePreflight(reader).check()\n\t\t\t// Rows are paged, and a row too large for any page refused, from cell sizes before composing.\n\t\t\tconst pages = splitCaptureSheets(\n\t\t\t\tsplitCapturePages(this.#groups(result), CAPTURE_SHEET.pairs).map((pair) => ({\n\t\t\t\t\tpair,\n\t\t\t\t\t...computeCaptureComposite(\n\t\t\t\t\t\tpair.map((group) =>\n\t\t\t\t\t\t\tcomputeCaptureComposite(\n\t\t\t\t\t\t\t\tgroup.cells.map((cell) => cell.picture),\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tCAPTURE_SHEET.gap,\n\t\t\t\t\t),\n\t\t\t\t})),\n\t\t\t\tCAPTURE_SHEET.rows,\n\t\t\t\tCAPTURE_SHEET.gap,\n\t\t\t)\n\t\t\tconst sheets = pages.map((page, index): CaptureSheetPage => {\n\t\t\t\tconst rows = page.map(({ pair }): CaptureSheetRow => {\n\t\t\t\t\tconst groups = pair.map((group): CaptureSheetGroup => ({\n\t\t\t\t\t\t...group,\n\t\t\t\t\t\tpicture: composeCapturePictures(\n\t\t\t\t\t\t\tgroup.cells.map((cell) => cell.picture),\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t),\n\t\t\t\t\t}))\n\t\t\t\t\treturn {\n\t\t\t\t\t\tgroups,\n\t\t\t\t\t\tpicture: composeCapturePictures(\n\t\t\t\t\t\t\tgroups.map((group) => group.picture),\n\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\tCAPTURE_SHEET.gap,\n\t\t\t\t\t\t),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\treturn {\n\t\t\t\t\tfile: `${CAPTURE_SHEET_FILES.prefix}${String(index + 1).padStart(CAPTURE_SHEET_FILES.digits, '0')}.png`,\n\t\t\t\t\trows,\n\t\t\t\t\tpicture: composeCapturePictures(\n\t\t\t\t\t\trows.map((row) => row.picture),\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tCAPTURE_SHEET.gap,\n\t\t\t\t\t),\n\t\t\t\t}\n\t\t\t})\n\t\t\tconst output = this.#output(result)\n\t\t\tmkdirSync(output)\n\t\t\tfor (const sheet of sheets)\n\t\t\t\twriteFileSync(resolve(output, sheet.file), encodeCapturePicture(sheet.picture))\n\t\t\tconst index: CaptureSheetIndex = {\n\t\t\t\t...buildCaptureReaderReport(result),\n\t\t\t\tsheets: sheets.map((sheet) => ({\n\t\t\t\t\tfile: sheet.file,\n\t\t\t\t\twidth: sheet.picture.width,\n\t\t\t\t\theight: sheet.picture.height,\n\t\t\t\t\trows: sheet.rows.map((row) =>\n\t\t\t\t\t\trow.groups.map((group) => ({\n\t\t\t\t\t\t\tidentity: group.identity,\n\t\t\t\t\t\t\tcells: group.cells.map(({ picture, ...cell }) => ({\n\t\t\t\t\t\t\t\t...cell,\n\t\t\t\t\t\t\t\tdisplayed: { width: picture.width, height: picture.height },\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})),\n\t\t\t}\n\t\t\twriteFileSync(\n\t\t\t\tresolve(output, CAPTURE_SHEET_FILES.index),\n\t\t\t\t`${JSON.stringify(index, undefined, 2)}\\n`,\n\t\t\t)\n\t\t\twriteFileSync(\n\t\t\t\tresolve(output, CAPTURE_SHEET_FILES.notes),\n\t\t\t\t`${this.#notes(result, sheets, output).join('\\n')}\\n`,\n\t\t\t)\n\t\t\tthis.#stdout(`${CAPTURE_REPORT_LINES.sheets} ${JSON.stringify(index)}\\n`)\n\t\t\treturn result.issues.length > 0 ||\n\t\t\t\tresult.freshness.entries.some((entry) => entry.status !== 'current')\n\t\t\t\t? CAPTURE_EXIT.failed\n\t\t\t\t: CAPTURE_EXIT.passed\n\t\t} catch (error) {\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t}\n\t}\n\n\t// Refuses an output directory that exists, escapes the workspace, or overlaps a selected capture directory.\n\t#output(result?: CapturePreflightResult): string {\n\t\tconst { root } = this.#options.reader\n\t\tconst output = resolve(this.#options.output)\n\t\tif (result === undefined) requireCaptureArgument(root, output, '--output')\n\t\tconst local = normalizeSlashes(relative(root, output))\n\t\tconst parent = attempt(() =>\n\t\t\tnormalizeSlashes(relative(realpathSync(root), realpathSync(dirname(output)))),\n\t\t)\n\t\tif (\n\t\t\t!isCapturePath(local) ||\n\t\t\t!parent.success ||\n\t\t\t(parent.value !== '' && !isCapturePath(parent.value)) ||\n\t\t\tresult?.selection.entries.some((entry) => {\n\t\t\t\tconst suffix = normalizeSlashes(\n\t\t\t\t\trelative(\n\t\t\t\t\t\tresolveCapturePhysical(resolve(root, dirname(entry.file))),\n\t\t\t\t\t\tresolveCapturePhysical(output),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\t\treturn suffix === '' || isCapturePath(suffix)\n\t\t\t}) ||\n\t\t\texistsSync(output)\n\t\t)\n\t\t\tthrow new CaptureError(\n\t\t\t\t'Contact sheets require a new contained directory outside selected capture directories with an existing parent',\n\t\t\t\t{ code: 'CONTAINMENT' },\n\t\t\t)\n\t\treturn output\n\t}\n\n\t// Gathers the selected destinations by portfolio, owner, and state, each as a row of shrunk cells.\n\t#groups(result: CapturePreflightResult): ReadonlyArray<Omit<CaptureSheetGroup, 'picture'>> {\n\t\tconst identities = [\n\t\t\t...new Set(result.selection.entries.map((entry) => resolveCaptureSheetIdentity(entry))),\n\t\t]\n\t\treturn identities.map((identity): Omit<CaptureSheetGroup, 'picture'> => {\n\t\t\tconst cells = result.selection.entries\n\t\t\t\t.filter((entry) => resolveCaptureSheetIdentity(entry) === identity)\n\t\t\t\t.map((entry): CaptureSheetCell => {\n\t\t\t\t\tconst image = result.images.find((candidate) => candidate.entry.file === entry.file)\n\t\t\t\t\tconst factor =\n\t\t\t\t\t\timage === undefined\n\t\t\t\t\t\t\t? 1\n\t\t\t\t\t\t\t: Math.max(1, Math.ceil(image.picture.width / CAPTURE_SHEET.cell))\n\t\t\t\t\tconst picture: CapturePicture =\n\t\t\t\t\t\timage === undefined\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\twidth: CAPTURE_SHEET.mark.width,\n\t\t\t\t\t\t\t\t\theight: CAPTURE_SHEET.mark.height,\n\t\t\t\t\t\t\t\t\tpixels: Uint8Array.from(\n\t\t\t\t\t\t\t\t\t\t{ length: CAPTURE_SHEET.mark.width * CAPTURE_SHEET.mark.height * 3 },\n\t\t\t\t\t\t\t\t\t\t(_, index) =>\n\t\t\t\t\t\t\t\t\t\t\tindex % 3 === 0 ? CAPTURE_SHEET.mark.present : CAPTURE_SHEET.mark.absent,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: image.thumbnail\n\t\t\t\t\treturn {\n\t\t\t\t\t\tentry,\n\t\t\t\t\t\tpicture,\n\t\t\t\t\t\tsource:\n\t\t\t\t\t\t\timage === undefined\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: { width: image.picture.width, height: image.picture.height, bytes: image.size },\n\t\t\t\t\t\tfactor,\n\t\t\t\t\t\tclipped:\n\t\t\t\t\t\t\timage !== undefined && Math.ceil(image.picture.height / factor) > CAPTURE_SHEET.limit,\n\t\t\t\t\t\tfreshness: result.freshness.entries.find((candidate) => candidate.file === entry.file),\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\treturn { identity, cells }\n\t\t})\n\t}\n\n\t// Writes the notes document: the mixed observations, then each sheet with its cells described.\n\t#notes(\n\t\tresult: CapturePreflightResult,\n\t\tsheets: readonly CaptureSheetPage[],\n\t\toutput: string,\n\t): readonly string[] {\n\t\treturn [\n\t\t\t'# Contact sheets',\n\t\t\t'',\n\t\t\t'Iteration evidence only. Assembled-portfolio acceptance remains withheld.',\n\t\t\t'',\n\t\t\t'## Mixed observations',\n\t\t\t'',\n\t\t\t...(result.mixed.length === 0\n\t\t\t\t? ['No mixed geometry reported for this selection.']\n\t\t\t\t: result.mixed.map((observation) => `- ${observation}`)),\n\t\t\t'',\n\t\t\t...sheets.flatMap((sheet) => [\n\t\t\t\t`## ${sheet.file}`,\n\t\t\t\t'',\n\t\t\t\t``,\n\t\t\t\t'',\n\t\t\t\t...sheet.rows.flatMap((row) =>\n\t\t\t\t\trow.groups.flatMap((group) =>\n\t\t\t\t\t\tgroup.cells.map((cell) => {\n\t\t\t\t\t\t\tconst link = normalizeSlashes(\n\t\t\t\t\t\t\t\trelative(output, resolve(this.#options.reader.root, cell.entry.file)),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tconst source =\n\t\t\t\t\t\t\t\tcell.source === undefined\n\t\t\t\t\t\t\t\t\t? 'unreadable'\n\t\t\t\t\t\t\t\t\t: `${String(cell.source.width)} x ${String(cell.source.height)}`\n\t\t\t\t\t\t\treturn `- ${cell.entry.portfolio} / ${resolveCaptureOwner(cell.entry)} / ${cell.entry.state} / ${cell.entry.variant}: [${cell.entry.file}](${link}); producer ${cell.entry.project}; ${cell.freshness?.status ?? 'missing'}; source ${source}; displayed ${String(cell.picture.width)} x ${String(cell.picture.height)}${cell.clipped ? '; clipped' : ''}`\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]),\n\t\t]\n\t}\n}\n","import type { CaptureCLIInterface, CaptureCLIOptions, CaptureWriteHandler } from './types.js'\nimport { CaptureError, describeCaptureError, isCaptureError } from '@src/core'\nimport { CapturePreflight } from './CapturePreflight.js'\nimport { CaptureRegistrar } from './CaptureRegistrar.js'\nimport { CaptureRunner } from './CaptureRunner.js'\nimport { CaptureSheets } from './CaptureSheets.js'\nimport {\n\tCAPTURE_COMMAND_OPTIONS,\n\tCAPTURE_DEFAULTS,\n\tCAPTURE_EXIT,\n\tCAPTURE_SUBCOMMANDS,\n\tCAPTURE_USAGE,\n} from './constants.js'\nimport {\n\treadCaptureOptions,\n\treadCaptureProgress,\n\treadCaptureReaderArguments,\n\trenderCaptureProgress,\n\tresolveCaptureExit,\n} from './helpers.js'\n\n/**\n * Dispatches capture commands and maps usage and evidence refusals to their exit codes.\n *\n * @remarks\n * The executable's whole behaviour: it reads the subcommand, hands the rest of the command line to\n * the runner, the registry refresh, the preflight, or the contact sheets, or prints the progress of\n * the stage that ran last, and turns a refused usage into exit 64 and any other capture refusal\n * into exit 1, writing the refusal to its error writer. An error that is not a capture refusal\n * propagates.\n *\n * @example\n * ```ts\n * const exit = await new CaptureCLI().execute(['journey', 'pages:mail'])\n * ```\n */\nexport class CaptureCLI implements CaptureCLIInterface {\n\treadonly #root: string\n\treadonly #stdout: CaptureWriteHandler\n\treadonly #stderr: CaptureWriteHandler\n\n\t/** Creates the executable with the working directory and process writers as defaults. */\n\tconstructor(options: CaptureCLIOptions = {}) {\n\t\tthis.#root = options.root ?? process.cwd()\n\t\tthis.#stdout = options.stdout ?? process.stdout.write.bind(process.stdout)\n\t\tthis.#stderr = options.stderr ?? process.stderr.write.bind(process.stderr)\n\t}\n\n\t/**\n\t * Executes one command line and returns its exit code after every child has settled.\n\t *\n\t * @param args - The arguments following the executable name\n\t * @returns 0 for passed work, 1 for failed evidence, or 64 for refused usage\n\t * @example\n\t * ```ts\n\t * await new CaptureCLI().execute([]) // 64, with usage written to stderr\n\t * ```\n\t */\n\tasync execute(args: readonly string[]): Promise<number> {\n\t\ttry {\n\t\t\tconst [name, ...argv] = args\n\t\t\tconst root = this.#root\n\t\t\tif (name === undefined || !CAPTURE_SUBCOMMANDS.includes(name))\n\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t`${name === undefined ? 'No command given' : `Unknown command ${JSON.stringify(name.slice(0, 80))}`}.\\n${CAPTURE_USAGE}`,\n\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t)\n\t\t\tswitch (name) {\n\t\t\t\tcase 'journey':\n\t\t\t\tcase 'frames':\n\t\t\t\tcase 'stale': {\n\t\t\t\t\tconst command = name === 'frames' ? 'capture' : name === 'stale' ? 'stale' : 'journey'\n\t\t\t\t\treturn await new CaptureRunner({\n\t\t\t\t\t\tcommand,\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tconfig: CAPTURE_DEFAULTS.config,\n\t\t\t\t\t\trequests: CAPTURE_DEFAULTS.requests,\n\t\t\t\t\t\targv,\n\t\t\t\t\t\tstdout: this.#stdout,\n\t\t\t\t\t\tstderr: this.#stderr,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t\tcase 'registry': {\n\t\t\t\t\treturn await new CaptureRegistrar({\n\t\t\t\t\t\troot,\n\t\t\t\t\t\tconfig: CAPTURE_DEFAULTS.config,\n\t\t\t\t\t\trequests: CAPTURE_DEFAULTS.requests,\n\t\t\t\t\t\targv,\n\t\t\t\t\t\tstdout: this.#stdout,\n\t\t\t\t\t\tstderr: this.#stderr,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t\tcase 'progress': {\n\t\t\t\t\tconst usage = 'Usage: capture progress'\n\t\t\t\t\tconst { positionals } = readCaptureOptions(argv, CAPTURE_COMMAND_OPTIONS.progress, usage)\n\t\t\t\t\tif (positionals.length > 0)\n\t\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t\t`Unexpected argument ${JSON.stringify(positionals[0]?.slice(0, 80))}: the progress command takes no argument. ${usage}`,\n\t\t\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t\t\t)\n\t\t\t\t\tthis.#stdout(\n\t\t\t\t\t\t`${renderCaptureProgress(readCaptureProgress(root, CAPTURE_DEFAULTS.requests))}\\n`,\n\t\t\t\t\t)\n\t\t\t\t\treturn CAPTURE_EXIT.passed\n\t\t\t\t}\n\t\t\t\tcase 'preflight': {\n\t\t\t\t\tconst { reader } = readCaptureReaderArguments(argv, root, CAPTURE_DEFAULTS, 'preflight')\n\t\t\t\t\treturn await new CapturePreflight({\n\t\t\t\t\t\t...reader,\n\t\t\t\t\t\tstdout: this.#stdout,\n\t\t\t\t\t\tstderr: this.#stderr,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tconst { reader, output } = readCaptureReaderArguments(argv, root, CAPTURE_DEFAULTS)\n\t\t\t\t\tif (output === undefined)\n\t\t\t\t\t\tthrow new CaptureError(\n\t\t\t\t\t\t\t'The sheets command requires --output <new directory>, which must not exist and must sit outside the selected capture directories',\n\t\t\t\t\t\t\t{ code: 'USAGE' },\n\t\t\t\t\t\t)\n\t\t\t\t\treturn await new CaptureSheets({\n\t\t\t\t\t\treader: { ...reader, stdout: this.#stdout, stderr: this.#stderr },\n\t\t\t\t\t\toutput,\n\t\t\t\t\t}).execute()\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tif (!isCaptureError(error)) throw error\n\t\t\tthis.#stderr(`${describeCaptureError(error)}\\n`)\n\t\t\treturn resolveCaptureExit(error)\n\t\t}\n\t}\n}\n","import type {\n\tCaptureCLIInterface,\n\tCaptureCLIOptions,\n\tCaptureDiscoveryInterface,\n\tCaptureDiscoveryRunOptions,\n\tCaptureIntegrityInterface,\n\tCaptureIntegrityOptions,\n\tCapturePreflightInterface,\n\tCaptureReaderOptions,\n\tCaptureRegistrarInterface,\n\tCaptureRegistrarOptions,\n\tCaptureRunnerInterface,\n\tCaptureRunnerOptions,\n\tCaptureSheetOptions,\n\tCaptureSheetsInterface,\n} from './types.js'\nimport { CaptureCLI } from './CaptureCLI.js'\nimport { CaptureDiscovery } from './CaptureDiscovery.js'\nimport { CaptureIntegrity } from './CaptureIntegrity.js'\nimport { CapturePreflight } from './CapturePreflight.js'\nimport { CaptureRegistrar } from './CaptureRegistrar.js'\nimport { CaptureRunner } from './CaptureRunner.js'\nimport { CaptureSheets } from './CaptureSheets.js'\n\n/**\n * Creates the integrity engine bound to an explicit workspace and host portfolio mapping.\n *\n * @param options - The workspace, evidence paths, authorized physical roots, and optional file hash\n * @returns A new engine that stamps stages, reads declarations, checks freshness, and resolves states\n * @throws Thrown when the root is not absolute, a path escapes the root, or a portfolio is invalid.\n *\n * @example\n * ```ts\n * const integrity = createCaptureIntegrity({\n * \troot: process.cwd(),\n * \tdirectory: 'tmp/captures/states',\n * \tinputs: ['src/**'],\n * \tregistry: 'tmp/captures/states/registry.json',\n * \tmanifest: 'tmp/captures/states/manifest.json',\n * \tlookups: 'tmp/captures/states/lookups.json',\n * \tportfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],\n * })\n * ```\n */\nexport function createCaptureIntegrity(\n\toptions: CaptureIntegrityOptions,\n): CaptureIntegrityInterface {\n\treturn new CaptureIntegrity(options)\n}\n\n/**\n * Creates the runner that drives owner-selected journeys for one command line.\n *\n * @param options - The command, the workspace, the wrapper default, the request directory, the command line, and optional output and engine seams\n * @returns A new runner whose `execute` runs the command and returns its exit status\n *\n * @example\n * ```ts\n * const runner = createCaptureRunner({\n * \tcommand: 'journey',\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/units',\n * \targv: ['pages:mail', '--variant', 'light-390'],\n * })\n * const exit = await runner.execute() // 0 when every stage passed\n * ```\n */\nexport function createCaptureRunner(options: CaptureRunnerOptions): CaptureRunnerInterface {\n\treturn new CaptureRunner(options)\n}\n\n/**\n * Creates the preflight that judges the selected frames' freshness, mixed observations, and coverage.\n *\n * @param options - The workspace, the wrapper, the selection, the journey artifact directory, and optional checks module and output seams\n * @returns A new preflight whose `execute` prints its report and returns the exit status\n *\n * @example\n * ```ts\n * const preflight = createCapturePreflight({\n * \troot: process.cwd(),\n * \tconfig: `${process.cwd()}/configs/app/vite.journey.config.ts`,\n * \tselection: { selector: 'pages:mail' },\n * \tjourneys: `${process.cwd()}/tmp/journey`,\n * })\n * const exit = await preflight.execute() // 0 when every selected frame is current and sound\n * ```\n */\nexport function createCapturePreflight(options: CaptureReaderOptions): CapturePreflightInterface {\n\treturn new CapturePreflight(options)\n}\n\n/**\n * Creates the contact-sheet writer for the selected frames.\n *\n * @param options - The reader options that select the frames and the new directory that receives the sheets\n * @returns A new writer whose `execute` writes the sheets and returns the exit status\n *\n * @example\n * ```ts\n * const sheets = createCaptureSheets({ reader, output: `${process.cwd()}/tmp/sheets` })\n * const exit = await sheets.execute() // 0 when every selected frame is current and sound\n * ```\n */\nexport function createCaptureSheets(options: CaptureSheetOptions): CaptureSheetsInterface {\n\treturn new CaptureSheets(options)\n}\n\n/**\n * Creates the discovery that reads a consumer's wrapper through the consumer's own Vitest.\n *\n * @param options - The workspace, the absolute wrapper path, the invocation that owns the child, and the optional mode and deadline\n * @returns A new discovery whose `describe` publishes the request and returns the wrapper's host description\n *\n * @example\n * ```ts\n * const discovery = createCaptureDiscovery({ root: process.cwd(), config, invocation })\n * const { projects } = await discovery.describe()\n * ```\n */\nexport function createCaptureDiscovery(\n\toptions: CaptureDiscoveryRunOptions,\n): CaptureDiscoveryInterface {\n\treturn new CaptureDiscovery(options)\n}\n\n/**\n * Creates the registry refresh that runs each producing variant's complete journey and publishes the registry.\n *\n * @param options - The workspace, the wrapper default, the request directory, the command line, and optional output seams\n * @returns A new refresh whose `execute` publishes `registry.json` and returns the exit status\n *\n * @example\n * ```ts\n * const registrar = createCaptureRegistrar({\n * \troot: process.cwd(),\n * \tconfig: 'configs/app/vite.journey.config.ts',\n * \trequests: 'tmp/capture',\n * \targv: ['--variant', 'light-390'],\n * })\n * const exit = await registrar.execute() // 0 when the registry was published\n * ```\n */\nexport function createCaptureRegistrar(\n\toptions: CaptureRegistrarOptions,\n): CaptureRegistrarInterface {\n\treturn new CaptureRegistrar(options)\n}\n\n/**\n * Creates the executable's command dispatcher over a workspace and injected writers.\n *\n * @param options - The workspace and the report and diagnostic writers; default: the working directory and the process streams\n * @returns A new dispatcher whose `execute` runs one command line and returns its exit code\n *\n * @example\n * ```ts\n * const exit = await createCaptureCLI().execute(['journey', 'pages:mail']) // 0 when the journey passed\n * ```\n */\nexport function createCaptureCLI(options: CaptureCLIOptions = {}): CaptureCLIInterface {\n\treturn new CaptureCLI(options)\n}\n"],"mappings":";;;;;;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