@orkestrel/capture 0.0.4 → 0.0.5
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 +10 -8
- package/dist/src/core/index.cjs +2 -1
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +2 -0
- package/dist/src/core/index.d.ts +2 -0
- package/dist/src/core/index.js +2 -1
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +44 -22
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +32 -10
- package/dist/src/server/index.d.ts +32 -10
- package/dist/src/server/index.js +44 -22
- package/dist/src/server/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/validators.ts","../../../src/core/helpers.ts"],"sourcesContent":["/**\n * Lists the condition axes a capture failure carries, in the order the executable reports them.\n *\n * @remarks\n * `USAGE` is a refused command line and exits 64; every other condition exits 1. `SELECTION`\n * names a selector, variant, case, state, or portfolio the host does not declare. `HOST` names a\n * wrapper, configuration, or declaration fault. `STAGE` names a runner stage that did not\n * complete. `EVIDENCE` names a record, report, registry, or manifest that fails its protocol.\n * `CONTAINMENT` names a path that leaves the authorized roots.\n *\n * @example\n * ```ts\n * CAPTURE_ERROR_CODES.includes('USAGE') // true\n * ```\n */\nexport const CAPTURE_ERROR_CODES = Object.freeze([\n\t'USAGE',\n\t'SELECTION',\n\t'HOST',\n\t'STAGE',\n\t'EVIDENCE',\n\t'CONTAINMENT',\n] as const)\n\n/**\n * Keys the global brand a capture error carries, so a duplicate installation recognizes it.\n *\n * @remarks\n * The key follows the package-and-class form, `Symbol.for('<package>.<ClassName>')`. The brand is\n * a recognition marker and never proof that the class's constructor ran.\n *\n * @example\n * ```ts\n * CAPTURE_ERROR_BRAND === Symbol.for('@orkestrel/capture.CaptureError') // true\n * ```\n */\nexport const CAPTURE_ERROR_BRAND = Symbol.for('@orkestrel/capture.CaptureError')\n\n/**\n * Lists the non-current freshness classifications from highest precedence to lowest.\n *\n * @remarks\n * `resolveCaptureStatus` reads this order to choose a frame's primary classification while the\n * reading keeps every finding separately. A frame with none of these is current.\n *\n * @example\n * ```ts\n * CAPTURE_STATUS_PRECEDENCE[0] // 'duplicate'\n * ```\n */\nexport const CAPTURE_STATUS_PRECEDENCE = Object.freeze([\n\t'duplicate',\n\t'orphan',\n\t'missing',\n\t'unstamped',\n\t'stale-shared',\n\t'stale-own',\n] as const)\n\n/**\n * Names the file prefix of a runner request, completed by the runner's process id and `.json`.\n *\n * @example\n * ```ts\n * `${CAPTURE_REQUEST_PREFIX}-${process.pid}.json` // 'journey-selection-4242.json'\n * ```\n */\nexport const CAPTURE_REQUEST_PREFIX = 'journey-selection'\n\n/**\n * Holds the protocol version every request, record, receipt, registry, and manifest declares.\n *\n * @example\n * ```ts\n * CAPTURE_VERSION // 1\n * ```\n */\nexport const CAPTURE_VERSION = 1\n\n/**\n * Holds the eight bytes every PNG file opens with.\n *\n * @example\n * ```ts\n * CAPTURE_PNG_SIGNATURE.map((byte) => byte.toString(16)).join('') // '89504e470d0a1a0a'\n * ```\n */\nexport const CAPTURE_PNG_SIGNATURE = Object.freeze([137, 80, 78, 71, 13, 10, 26, 10] as const)\n\n/**\n * Names the default accepted complete-run registry file inside a portfolio directory.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_REGISTRY_FILE}` // 'tmp/captures/states/registry.json'\n * ```\n */\nexport const CAPTURE_REGISTRY_FILE = 'registry.json'\n\n/**\n * Names the default image-stamp manifest file inside a portfolio directory.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_MANIFEST_FILE}` // 'tmp/captures/states/manifest.json'\n * ```\n */\nexport const CAPTURE_MANIFEST_FILE = 'manifest.json'\n\n/**\n * Names the default lookup journal file inside a portfolio directory.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_LOOKUPS_FILE}` // 'tmp/captures/states/lookups.json'\n * ```\n */\nexport const CAPTURE_LOOKUPS_FILE = 'lookups.json'\n","import type { CaptureErrorCode, CaptureErrorContext, CaptureErrorOptions } from './types.js'\nimport { holds, INTRINSICS, isError, isFunction, isObject } from '@orkestrel/contract'\nimport { CAPTURE_ERROR_BRAND, CAPTURE_ERROR_CODES } from './constants.js'\n\n/**\n * Reports one capture failure under a stable condition axis.\n *\n * @remarks\n * Every refusal the engine, the runner, and the readers raise arrives as one of these, so the\n * executable branches on `code` rather than on message text: `USAGE` exits 64 and every other\n * condition exits 1. Narrow a caught value with `isCaptureError` before reading `code`.\n *\n * @example\n * ```ts\n * const error = new CaptureError('Unknown variant: phone', {\n * \tcode: 'SELECTION',\n * \tcontext: { variant: 'phone' },\n * })\n * error.code // 'SELECTION'\n * error.context?.variant // 'phone'\n * ```\n */\nexport class CaptureError extends Error {\n\toverride readonly name = 'CaptureError'\n\treadonly code: CaptureErrorCode\n\treadonly context: CaptureErrorContext | undefined\n\n\t/**\n\t * Creates one classified capture failure.\n\t *\n\t * @param message - Human-readable description of what failed\n\t * @param options - The condition, optional structured context, and optional cause\n\t */\n\tconstructor(message: string, options: CaptureErrorOptions) {\n\t\tsuper(message, 'cause' in options ? { cause: options.cause } : undefined)\n\t\t// A transparent proxy forwards its target's identity and fails the guard's comparison.\n\t\tObject.defineProperty(this, CAPTURE_ERROR_BRAND, { value: this })\n\t\tthis.code = options.code\n\t\tthis.context = options.context\n\t}\n}\n\n/**\n * Checks whether an unknown value is a capture error.\n *\n * @remarks\n * Recognition requires a native `Error` whose prototype is not `Error.prototype`, an own brand\n * property holding the tested value itself, a declared condition code, and an object, callable, or absent\n * context. It recognizes an error from another installed copy of this package, and refuses a\n * look-alike with the same code and no brand, a proxy over a branded error, and a plain object\n * that only carries the brand.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `CaptureError`; false otherwise\n *\n * @example\n * ```ts\n * isCaptureError(new CaptureError('Empty selection', { code: 'USAGE' })) // true\n * isCaptureError(new Error('Empty selection')) // false\n * ```\n */\nexport function isCaptureError(value: unknown): value is CaptureError {\n\treturn holds(() => {\n\t\tif (!isError(value) || INTRINSICS.prototype(value) === INTRINSICS.error.prototype) return false\n\t\tif (INTRINSICS.describe(value, CAPTURE_ERROR_BRAND)?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tconst context: unknown = INTRINSICS.reflect.read(value, 'context')\n\t\treturn (\n\t\t\tCAPTURE_ERROR_CODES.some((declared) => declared === code) &&\n\t\t\t(context === undefined || isObject(context) || isFunction(context))\n\t\t)\n\t})\n}\n","import type {\n\tCaptureArtifact,\n\tCaptureBox,\n\tCaptureCollectionReceipt,\n\tCaptureDeclaration,\n\tCaptureDestination,\n\tCaptureDigest,\n\tCaptureEntry,\n\tCaptureIdentity,\n\tCaptureLookup,\n\tCaptureLookupJournal,\n\tCaptureManifest,\n\tCaptureReceipt,\n\tCaptureRegistry,\n\tCaptureRequest,\n\tCaptureRun,\n\tCaptureSources,\n\tCaptureStamp,\n\tCaptureStoredManifest,\n\tCaptureViewport,\n} from './types.js'\nimport { arrayOf, holds, isFiniteNumber, isObject, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Checks whether a serialized path stays within the portable relative-path vocabulary.\n *\n * @param value - The serialized file or directory path\n * @returns True if every segment is portable and relative; false otherwise\n *\n * @example\n * ```ts\n * isCapturePath('tmp/captures/states/pages/mail--inbox.png') // true\n * isCapturePath('../escape.png') // false\n * ```\n */\nexport function isCapturePath(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.length > 0 &&\n\t\t[...value].every((character) => character.charCodeAt(0) > 0x1f) &&\n\t\tvalue\n\t\t\t.split('/')\n\t\t\t.every(\n\t\t\t\t(segment) =>\n\t\t\t\t\tsegment !== '' &&\n\t\t\t\t\tsegment !== '.' &&\n\t\t\t\t\tsegment !== '..' &&\n\t\t\t\t\t!/[<>:\"\\\\|?*]/u.test(segment) &&\n\t\t\t\t\t!/[. ]$/u.test(segment) &&\n\t\t\t\t\t!/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\\.|$)/iu.test(segment),\n\t\t\t)\n\t)\n}\n\n/**\n * Checks whether a native glob declaration uses relative portable path segments.\n *\n * @param value - A source attribution pattern\n * @returns True if the pattern has no path traversal or host-specific spelling; false otherwise\n *\n * @example\n * ```ts\n * isCapturePattern('src/**') // true\n * isCapturePattern('src\\\\**') // false\n * ```\n */\nexport function isCapturePattern(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.length > 0 &&\n\t\t[...value].every((character) => character.charCodeAt(0) > 0x1f) &&\n\t\tvalue\n\t\t\t.split('/')\n\t\t\t.every(\n\t\t\t\t(segment) =>\n\t\t\t\t\tsegment !== '' &&\n\t\t\t\t\tsegment !== '.' &&\n\t\t\t\t\tsegment !== '..' &&\n\t\t\t\t\t!/[<>:\"\\\\|]/u.test(segment) &&\n\t\t\t\t\t!/[. ]$/u.test(segment) &&\n\t\t\t\t\t!/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\\.|$)/iu.test(segment),\n\t\t\t)\n\t)\n}\n\n/**\n * Checks whether a protocol identity can occupy one portable path segment.\n *\n * @param value - The identity segment\n * @returns True if the segment is safe and nonempty; false otherwise\n *\n * @example\n * ```ts\n * isCaptureSegment('light-390') // true\n * isCaptureSegment('light 390') // false\n * ```\n */\nexport function isCaptureSegment(value: unknown): value is string {\n\treturn isCapturePath(value) && /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/u.test(value)\n}\n\n/**\n * Checks whether an owner selector uses canonical colon-separated segments.\n *\n * @param value - The owner selector\n * @returns True if every owner segment is canonical; false otherwise\n *\n * @example\n * ```ts\n * isCaptureSelector('pages:mail') // true\n * isCaptureSelector('pages::mail') // false\n * ```\n */\nexport function isCaptureSelector(value: unknown): value is string {\n\treturn typeof value === 'string' && value.split(':').every(isCaptureSegment)\n}\n\n/**\n * Checks whether a value is a SHA-256 hexadecimal digest.\n *\n * @param value - The digest\n * @returns True if the digest has the expected hexadecimal width; false otherwise\n *\n * @example\n * ```ts\n * isCaptureHash('a'.repeat(64)) // true\n * isCaptureHash('abc') // false\n * ```\n */\nexport function isCaptureHash(value: unknown): value is string {\n\treturn typeof value === 'string' && /^[a-f0-9]{64}$/u.test(value)\n}\n\n/**\n * Checks whether a file-hash map has portable keys and valid digests.\n *\n * @param value - The hash map\n * @returns True if every key and digest is valid and no two keys differ only by case; false otherwise\n *\n * @example\n * ```ts\n * isCaptureHashes({ 'src/index.ts': 'a'.repeat(64) }) // true\n * isCaptureHashes({ 'src/index.ts': 'x' }) // false\n * ```\n */\nexport function isCaptureHashes(value: unknown): value is Readonly<Record<string, string>> {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tObject.entries(value).every(\n\t\t\t\t([file, digest]) => isCapturePath(file) && isCaptureHash(digest),\n\t\t\t) &&\n\t\t\tnew Set(Object.keys(value).map((file) => file.toLowerCase())).size ===\n\t\t\t\tObject.keys(value).length,\n\t)\n}\n\n/**\n * Checks whether source attribution separates own, shared, and behavioral patterns.\n *\n * @param value - The attribution\n * @returns True if every declared pattern is valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureSources({ own: ['src/mail/**'], shared: [], tests: [] }) // true\n * isCaptureSources({ own: ['../x'], shared: [], tests: [] }) // false\n * ```\n */\nexport function isCaptureSources(value: unknown): value is CaptureSources {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tarrayOf(isCapturePattern)(value.own) &&\n\t\t\tarrayOf(isCapturePattern)(value.shared) &&\n\t\t\tarrayOf(isCapturePattern)(value.tests),\n\t)\n}\n\n/**\n * Checks whether an execution identity carries its required authorization fields.\n *\n * @param value - The identity\n * @returns True if the identity is valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureIdentity({ id: 'run-1', stage: 'selected', pid: 4242, config: 'configs/journey.ts' }) // true\n * isCaptureIdentity({ id: 'run-1', stage: 'selected', pid: 0, config: 'configs/journey.ts' }) // false\n * ```\n */\nexport function isCaptureIdentity(value: unknown): value is CaptureIdentity {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureSegment(value.id) &&\n\t\t\tisCaptureSegment(value.stage) &&\n\t\t\ttypeof value.pid === 'number' &&\n\t\t\tNumber.isSafeInteger(value.pid) &&\n\t\t\tvalue.pid > 0 &&\n\t\t\tisCapturePath(value.config),\n\t)\n}\n\n/**\n * Checks whether a request has the supported version and complete execution identity.\n *\n * @param value - The transported request\n * @returns True if every request field has its protocol shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureRequest(JSON.parse(text)) // true for a well-formed runner request\n * isCaptureRequest({ version: 2 }) // false\n * ```\n */\nexport function isCaptureRequest(value: unknown): value is CaptureRequest {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureIdentity(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\t(value.command === 'journey' || value.command === 'capture') &&\n\t\t\tisCaptureSelector(value.selector) &&\n\t\t\tarrayOf(isCaptureSegment)(value.variants) &&\n\t\t\tvalue.variants.length > 0 &&\n\t\t\tarrayOf(isString)(value.args) &&\n\t\t\t(value.case === undefined || (typeof value.case === 'string' && value.case.trim() !== '')) &&\n\t\t\t(value.state === undefined || (value.command === 'capture' && isCaptureSegment(value.state))),\n\t)\n}\n\n/**\n * Checks whether a collected declaration preserves its full owner and state population.\n *\n * @param value - The declaration\n * @returns True if the declaration has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureDeclaration({\n * \tcase: 'mail shows the inbox',\n * \towner: 'pages:mail',\n * \tvariant: 'light-390',\n * \teligible: true,\n * \tstates: ['inbox'],\n * }) // true\n * ```\n */\nexport function isCaptureDeclaration(value: unknown): value is CaptureDeclaration {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\ttypeof value.case === 'string' &&\n\t\t\tvalue.case.trim() !== '' &&\n\t\t\tisCaptureSelector(value.owner) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.eligible === 'boolean' &&\n\t\t\tarrayOf(isCaptureSegment)(value.states),\n\t)\n}\n\n/**\n * Checks whether a destination supplies canonical identity and source attribution fields.\n *\n * @param value - The destination\n * @returns True if the destination has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureDestination(JSON.parse(text)) // true for a registry destination row\n * isCaptureDestination({}) // false\n * ```\n */\nexport function isCaptureDestination(value: unknown): value is CaptureDestination {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureSegment(value.portfolio) &&\n\t\t\tisCaptureSegment(value.state) &&\n\t\t\tisCaptureSegment(value.scope) &&\n\t\t\tisCaptureSegment(value.part) &&\n\t\t\t(value.section === undefined || isCaptureSegment(value.section)) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.project === 'string' &&\n\t\t\tvalue.project !== '' &&\n\t\t\tisCapturePath(value.file) &&\n\t\t\ttypeof value.case === 'string' &&\n\t\t\tvalue.case.trim() !== '' &&\n\t\t\tisCaptureSources(value.sources),\n\t)\n}\n\n/**\n * Checks whether an emitted entry includes a finite nonnegative case duration.\n *\n * @param value - The emitted entry\n * @returns True if the entry is valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureEntry({ ...destination, duration: 812 }) // true\n * isCaptureEntry({ ...destination, duration: -1 }) // false\n * ```\n */\nexport function isCaptureEntry(value: unknown): value is CaptureEntry {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureDestination(value) &&\n\t\t\tisFiniteNumber(value.duration) &&\n\t\t\tvalue.duration >= 0,\n\t)\n}\n\n/**\n * Checks whether a record names its journey artifact by portable path and SHA-256 digest.\n *\n * @param value - The decoded artifact reference\n * @returns True if the reference has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureArtifact({ file: 'tmp/runs/a/light-390.txt', digest: 'a'.repeat(64) }) // true\n * isCaptureArtifact({ file: '/abs.txt', digest: 'a'.repeat(64) }) // false\n * ```\n */\nexport function isCaptureArtifact(value: unknown): value is CaptureArtifact {\n\treturn holds(() => isRecord(value) && isCapturePath(value.file) && isCaptureHash(value.digest))\n}\n\n/**\n * Checks whether a final record preserves declarations, observations, and output separately.\n *\n * @param value - The decoded run record\n * @returns True if the record has the supported protocol shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureRun(JSON.parse(text)) // true for a final run record\n * isCaptureRun(null) // false\n * ```\n */\nexport function isCaptureRun(value: unknown): value is CaptureRun {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.time === 'string' &&\n\t\t\tNumber.isFinite(Date.parse(value.time)) &&\n\t\t\ttypeof value.complete === 'boolean' &&\n\t\t\ttypeof value.reference === 'boolean' &&\n\t\t\tarrayOf(isCaptureDeclaration)(value.declarations) &&\n\t\t\tarrayOf(isCaptureDestination)(value.registry) &&\n\t\t\tarrayOf(isString)(value.passed) &&\n\t\t\tarrayOf(isCaptureSegment)(value.observed) &&\n\t\t\tarrayOf(isCaptureEntry)(value.entries) &&\n\t\t\t(value.artifact === undefined || isCaptureArtifact(value.artifact)) &&\n\t\t\t((value.identity === undefined && value.request === undefined) ||\n\t\t\t\t(isCaptureIdentity(value.identity) && isCaptureRequest(value.request))),\n\t)\n}\n\n/**\n * Checks whether a shared-source digest retains both patterns and expanded file hashes.\n *\n * @param value - The digest reading\n * @returns True if the digest reading has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureDigest({ patterns: ['src/**'], files: {}, digest: 'a'.repeat(64) }) // true\n * isCaptureDigest({ patterns: [], files: {} }) // false\n * ```\n */\nexport function isCaptureDigest(value: unknown): value is CaptureDigest {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tarrayOf(isCapturePattern)(value.patterns) &&\n\t\t\tisCaptureHashes(value.files) &&\n\t\t\tisCaptureHash(value.digest),\n\t)\n}\n\n/**\n * Checks whether a complete-run receipt binds the report, inputs, and declaration registry.\n *\n * @param value - The receipt\n * @returns True if the receipt has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureReceipt(JSON.parse(text)) // true for a complete-run receipt\n * isCaptureReceipt({}) // false\n * ```\n */\nexport function isCaptureReceipt(value: unknown): value is CaptureReceipt {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.time === 'string' &&\n\t\t\tNumber.isFinite(Date.parse(value.time)) &&\n\t\t\tisRecord(value.report) &&\n\t\t\tisCapturePath(value.report.file) &&\n\t\t\tisCaptureHash(value.report.digest) &&\n\t\t\tisCaptureHashes(value.inputs) &&\n\t\t\tarrayOf(isCaptureDeclaration)(value.declarations) &&\n\t\t\tarrayOf(isCaptureDestination)(value.registry) &&\n\t\t\ttypeof value.complete === 'boolean',\n\t)\n}\n\n/**\n * Checks whether a registry document retains its receipts and required output pairs.\n *\n * @param value - The registry document\n * @returns True if the registry has the supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureRegistry(JSON.parse(text)) // true for a published registry.json\n * isCaptureRegistry([]) // false\n * ```\n */\nexport function isCaptureRegistry(value: unknown): value is CaptureRegistry {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tarrayOf(isCaptureReceipt)(value.receipts) &&\n\t\t\tarrayOf(isCaptureDestination)(value.entries) &&\n\t\t\tisCaptureHash(value.digest),\n\t)\n}\n\n/**\n * Checks whether a lookup binds a passing case to its full run record and input hashes.\n *\n * @param value - The lookup receipt\n * @returns True if the receipt has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureLookup(JSON.parse(text)) // true for a lookup row\n * isCaptureLookup(undefined) // false\n * ```\n */\nexport function isCaptureLookup(value: unknown): value is CaptureLookup {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureHash(value.registry) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.case === 'string' &&\n\t\t\tvalue.case.trim() !== '' &&\n\t\t\tisCaptureSelector(value.owner) &&\n\t\t\tarrayOf(isCaptureSegment)(value.states) &&\n\t\t\tisCaptureHashes(value.inputs) &&\n\t\t\tisRecord(value.run) &&\n\t\t\tisCapturePath(value.run.file) &&\n\t\t\tisCaptureHash(value.run.digest),\n\t)\n}\n\n/**\n * Checks the separate lookup journal and its optional predecessor manifest digest.\n *\n * @param value - The decoded journal\n * @returns True if the journal has its supported shape; false otherwise\n * @remarks Input-map digests and reference existence are verified when the journal is read.\n *\n * @example\n * ```ts\n * isCaptureLookupJournal({ version: 1, inputs: {}, lookups: [] }) // true\n * isCaptureLookupJournal({ version: 2, inputs: {}, lookups: [] }) // false\n * ```\n */\nexport function isCaptureLookupJournal(value: unknown): value is CaptureLookupJournal {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\t(value.collections === undefined || arrayOf(isCaptureCollection)(value.collections)) &&\n\t\t\tvalue.version === 1 &&\n\t\t\t(value.manifest === undefined || isCaptureHash(value.manifest)) &&\n\t\t\tisRecord(value.inputs) &&\n\t\t\tObject.entries(value.inputs).every(\n\t\t\t\t([digest, inputs]) => isCaptureHash(digest) && isCaptureHashes(inputs),\n\t\t\t) &&\n\t\t\tarrayOf(\n\t\t\t\t(entry) =>\n\t\t\t\t\tisRecord(entry) &&\n\t\t\t\t\tisCaptureHash(entry.inputs) &&\n\t\t\t\t\tisCaptureLookup({ ...entry, inputs: {} }),\n\t\t\t)(value.lookups),\n\t)\n}\n\n/**\n * Checks whether a stamp binds an emitted image to source and execution provenance.\n *\n * @param value - The stamp\n * @returns True if the stamp has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureStamp(manifest.entries['pages/mail--inbox.png']) // true for a stamped frame\n * isCaptureStamp({}) // false\n * ```\n */\nexport function isCaptureStamp(value: unknown): value is CaptureStamp {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureEntry(value) &&\n\t\t\tisCaptureIdentity(value.identity) &&\n\t\t\ttypeof value.time === 'string' &&\n\t\t\tNumber.isFinite(Date.parse(value.time)) &&\n\t\t\ttypeof value.commit === 'string' &&\n\t\t\t/^[a-f0-9]{40,64}$/u.test(value.commit) &&\n\t\t\tarrayOf(isCapturePath)(value.dirty) &&\n\t\t\tisCaptureHashes(value.own) &&\n\t\t\tisCaptureDigest(value.shared) &&\n\t\t\tisCaptureHashes(value.tests) &&\n\t\t\tisCaptureHash(value.registry) &&\n\t\t\tisRecord(value.image) &&\n\t\t\tisCaptureHash(value.image.digest) &&\n\t\t\tisFiniteNumber(value.image.size) &&\n\t\t\tNumber.isSafeInteger(value.image.size) &&\n\t\t\tvalue.image.size > 0 &&\n\t\t\tisFiniteNumber(value.image.modified) &&\n\t\t\tvalue.image.modified >= 0,\n\t)\n}\n\n/**\n * Checks whether an inherited manifest has the supported schema without discarding malformed rows.\n *\n * @param value - The manifest\n * @returns True if every inherited member validates; false otherwise\n *\n * @example\n * ```ts\n * isCaptureManifest(JSON.parse(text)) // true for a published manifest.json\n * isCaptureManifest('manifest') // false\n * ```\n */\nexport function isCaptureManifest(value: unknown): value is CaptureManifest {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tisCaptureRegistry(value.registry) &&\n\t\t\tisRecord(value.entries) &&\n\t\t\tObject.entries(value.entries).every(\n\t\t\t\t([key, stamp]) => isCapturePath(key) && isCaptureStamp(stamp),\n\t\t\t) &&\n\t\t\tarrayOf(isCaptureLookup)(value.lookups),\n\t)\n}\n\n/**\n * Checks whether collection evidence pins complete input membership and both external artifacts.\n *\n * @param value - The collection receipt\n * @returns True if every field has the supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureCollection(manifest.collections?.[0]) // true for a collection receipt\n * isCaptureCollection({}) // false\n * ```\n */\nexport function isCaptureCollection(value: unknown): value is CaptureCollectionReceipt {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureHash(value.registry) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.project === 'string' &&\n\t\t\tvalue.project.trim() !== '' &&\n\t\t\tisCaptureDigest(value.inputs) &&\n\t\t\tisRecord(value.run) &&\n\t\t\tisCapturePath(value.run.file) &&\n\t\t\tisCaptureHash(value.run.digest) &&\n\t\t\tisRecord(value.report) &&\n\t\t\tisCapturePath(value.report.file) &&\n\t\t\tisCaptureHash(value.report.digest),\n\t)\n}\n\n/**\n * Checks optional collection metadata without upgrading historical image evidence.\n *\n * @param value - The inherited image transaction\n * @returns True if its existing manifest and any collection receipts are valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureStoredManifest(JSON.parse(text)) // true for a manifest with or without collections\n * isCaptureStoredManifest(null) // false\n * ```\n */\nexport function isCaptureStoredManifest(value: unknown): value is CaptureStoredManifest {\n\treturn holds(\n\t\t() =>\n\t\t\tisCaptureManifest(value) &&\n\t\t\tisRecord(value) &&\n\t\t\t(value.collections === undefined || arrayOf(isCaptureCollection)(value.collections)),\n\t)\n}\n\n/**\n * Checks the host's declared viewport without deriving geometry from an output name.\n *\n * @param value - The published viewport data\n * @returns True if the named viewport has usable dimensions; false otherwise\n *\n * @example\n * ```ts\n * isCaptureGeometry({ name: 'light-390', width: 390, height: 844 }) // true\n * isCaptureGeometry({ name: 'light-390', width: 0, height: 844 }) // false\n * ```\n */\nexport function isCaptureGeometry(value: unknown): value is CaptureViewport {\n\treturn holds(\n\t\t() =>\n\t\t\tisObject(value) &&\n\t\t\t'name' in value &&\n\t\t\tisCaptureSegment(value.name) &&\n\t\t\t'width' in value &&\n\t\t\tisFiniteNumber(value.width) &&\n\t\t\tvalue.width > 0 &&\n\t\t\t'height' in value &&\n\t\t\tisFiniteNumber(value.height) &&\n\t\t\tvalue.height > 0,\n\t)\n}\n\n/**\n * Checks a journey artifact's recorded sampling box.\n *\n * @param value - The recorded viewport box\n * @returns True if its coordinates and dimensions are finite; false otherwise\n *\n * @example\n * ```ts\n * isCaptureBox({ x: 0, y: 64, width: 390, height: 780 }) // true\n * isCaptureBox({ x: 0, y: 64, width: 0, height: 780 }) // false\n * ```\n */\nexport function isCaptureBox(value: unknown): value is CaptureBox {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisFiniteNumber(value.x) &&\n\t\t\tisFiniteNumber(value.y) &&\n\t\t\tisFiniteNumber(value.width) &&\n\t\t\tvalue.width > 0 &&\n\t\t\tisFiniteNumber(value.height) &&\n\t\t\tvalue.height > 0,\n\t)\n}\n","import type {\n\tCaptureAssertion,\n\tCaptureDeclaration,\n\tCaptureDestination,\n\tCaptureLookup,\n\tCaptureReceipt,\n\tCaptureReport,\n\tCaptureRequest,\n\tCaptureRun,\n\tCaptureStatus,\n} from './types.js'\nimport { arrayOf, isError, isFiniteNumber, isRecord, isString } from '@orkestrel/contract'\nimport { CAPTURE_STATUS_PRECEDENCE } from './constants.js'\nimport { CaptureError } from './errors.js'\nimport { isCaptureDeclaration } from './validators.js'\n\n/**\n * Describes a caught failure as one reportable line.\n *\n * @param error - The caught value, which need not be an `Error`\n * @returns The error's message, or the value's string form\n *\n * @example\n * ```ts\n * describeCaptureError(new Error('Unknown variant: phone')) // 'Unknown variant: phone'\n * describeCaptureError('refused') // 'refused'\n * ```\n */\nexport function describeCaptureError(error: unknown): string {\n\treturn isError(error) ? error.message : String(error)\n}\n\n/**\n * Finds repeated identities before a keyed collection could discard them.\n *\n * @param values - The identity population\n * @param folded - If `true`, compares case-folded keys; if `false`, compares exact identities. Default: `false`\n * @returns Every member whose comparison key appears more than once\n *\n * @example\n * ```ts\n * collectCaptureDuplicates(['a', 'b', 'a']) // ['a', 'a']\n * collectCaptureDuplicates(['Pages', 'pages'], true) // ['Pages', 'pages']\n * ```\n */\nexport function collectCaptureDuplicates(\n\tvalues: readonly string[],\n\tfolded = false,\n): readonly string[] {\n\tconst keys = values.map((value) => (folded ? value.toLowerCase() : value))\n\treturn values.filter(\n\t\t(_value, index) => keys.indexOf(keys[index] ?? '') !== keys.lastIndexOf(keys[index] ?? ''),\n\t)\n}\n\n/**\n * Refuses duplicate declarations or portable storage-key collisions before indexing.\n *\n * @param values - The complete identity population\n * @param label - The diagnostic subject\n * @param folded - If `true`, refuses case-colliding keys; if `false`, requires exact uniqueness. Default: `false`\n * @throws Thrown as an `EVIDENCE` capture error when an identity repeats.\n *\n * @example\n * ```ts\n * requireCaptureUnique(['mail', 'files'], 'owners') // returns\n * requireCaptureUnique(['mail', 'mail'], 'owners') // throws 'Duplicate owners: mail, mail'\n * ```\n */\nexport function requireCaptureUnique(\n\tvalues: readonly string[],\n\tlabel: string,\n\tfolded = false,\n): void {\n\tconst duplicates = collectCaptureDuplicates(values, folded)\n\tif (duplicates.length > 0)\n\t\tthrow new CaptureError(`Duplicate ${label}: ${duplicates.join(', ')}`, {\n\t\t\tcode: 'EVIDENCE',\n\t\t\tcontext: { label, duplicates },\n\t\t})\n}\n\n/**\n * Compares complete populations without erasing duplicates.\n *\n * @param left - The first population\n * @param right - The second population\n * @returns True if the sorted populations are equal; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureMembers(['b', 'a'], ['a', 'b']) // true\n * matchesCaptureMembers(['a', 'a'], ['a']) // false\n * ```\n */\nexport function matchesCaptureMembers(left: readonly string[], right: readonly string[]): boolean {\n\tconst ordered = right.toSorted()\n\treturn (\n\t\tleft.length === right.length &&\n\t\tleft.toSorted().every((entry, index) => entry === ordered[index])\n\t)\n}\n\n/**\n * Compares an owner with an explicit selector at colon boundaries.\n *\n * @param owner - The canonical owner\n * @param selector - The requested owner or the `all` selector\n * @returns True if the owner belongs to the selection; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureSelector('pages:mail', 'pages') // true\n * matchesCaptureSelector('pages:mailbox', 'pages:mail') // false\n * ```\n */\nexport function matchesCaptureSelector(owner: string, selector: string): boolean {\n\treturn selector === 'all' || owner === selector || owner.startsWith(`${selector}:`)\n}\n\n/**\n * Builds the canonical owner from a destination's registry identity.\n *\n * @param entry - The destination\n * @returns The scope, part, and optional section selector\n *\n * @example\n * ```ts\n * resolveCaptureOwner({ ...destination, scope: 'pages', part: 'mail' }) // 'pages:mail'\n * ```\n */\nexport function resolveCaptureOwner(entry: CaptureDestination): string {\n\treturn [entry.scope, entry.part, ...(entry.section === undefined ? [] : [entry.section])].join(\n\t\t':',\n\t)\n}\n\n/**\n * Builds a manifest identity independently of the physical image path.\n *\n * @param entry - The registry destination\n * @returns The scope-qualified state and output-variant key\n *\n * @example\n * ```ts\n * resolveCaptureKey({ ...destination, scope: 'pages', state: 'inbox', variant: 'light-390' })\n * // 'pages/inbox--light-390.png'\n * ```\n */\nexport function resolveCaptureKey(entry: CaptureDestination): string {\n\treturn `${entry.scope}/${entry.state}--${entry.variant}.png`\n}\n\n/**\n * Serializes a destination's identity and attribution in a deterministic field order.\n *\n * @param entry - The destination\n * @returns The comparison representation, excluding image and duration readings\n *\n * @example\n * ```ts\n * describeCaptureDestination(destination) === describeCaptureDestination({ ...destination })\n * // true\n * ```\n */\nexport function describeCaptureDestination(entry: CaptureDestination): string {\n\treturn JSON.stringify([\n\t\tentry.portfolio,\n\t\tentry.state,\n\t\tentry.scope,\n\t\tentry.part,\n\t\tentry.section,\n\t\tentry.variant,\n\t\tentry.project,\n\t\tentry.file,\n\t\tentry.case,\n\t\tentry.sources.own.toSorted(),\n\t\tentry.sources.shared.toSorted(),\n\t\tentry.sources.tests.toSorted(),\n\t])\n}\n\n/**\n * Serializes only the registry's execution and output identity, independent of input revisions.\n *\n * @param entry - The destination or inherited stamp\n * @returns The identity used for relevant manifest agreement during state resolution\n *\n * @example\n * ```ts\n * describeCaptureIdentity(destination) === describeCaptureIdentity({\n * \t...destination,\n * \tsources: { own: [], shared: [], tests: [] },\n * })\n * // true\n * ```\n */\nexport function describeCaptureIdentity(entry: CaptureDestination): string {\n\treturn JSON.stringify([\n\t\tentry.portfolio,\n\t\tentry.state,\n\t\tentry.scope,\n\t\tentry.part,\n\t\tentry.section,\n\t\tentry.variant,\n\t\tentry.project,\n\t\tentry.file,\n\t\tentry.case,\n\t])\n}\n\n/**\n * Serializes a complete behavioral declaration without dropping eligibility or states.\n *\n * @param entry - The collected declaration\n * @returns The deterministic comparison representation\n *\n * @example\n * ```ts\n * describeCaptureDeclaration({ ...declaration, states: ['b', 'a'] }) ===\n * \tdescribeCaptureDeclaration({ ...declaration, states: ['a', 'b'] })\n * // true\n * ```\n */\nexport function describeCaptureDeclaration(entry: CaptureDeclaration): string {\n\treturn JSON.stringify([\n\t\tentry.case,\n\t\tentry.owner,\n\t\tentry.variant,\n\t\tentry.eligible,\n\t\tentry.states.toSorted(),\n\t])\n}\n\n/**\n * Serializes every request field, retaining the exact argv order.\n *\n * @param request - The transported request\n * @returns The exact request comparison representation\n *\n * @example\n * ```ts\n * describeCaptureRequest(request) === describeCaptureRequest({ ...request, args: [] })\n * // false when the request carried argv\n * ```\n */\nexport function describeCaptureRequest(request: CaptureRequest): string {\n\treturn JSON.stringify([\n\t\trequest.version,\n\t\trequest.id,\n\t\trequest.stage,\n\t\trequest.pid,\n\t\trequest.config,\n\t\trequest.command,\n\t\trequest.selector,\n\t\trequest.case,\n\t\trequest.state,\n\t\trequest.variants,\n\t\trequest.args,\n\t])\n}\n\n/**\n * Names every changed, added, or removed file in hash populations.\n *\n * @param previous - The retained file hashes\n * @param current - The observed file hashes\n * @returns The sorted changed membership\n *\n * @example\n * ```ts\n * collectCaptureChanges({ 'a.ts': 'x', 'b.ts': 'y' }, { 'a.ts': 'x', 'b.ts': 'z', 'c.ts': 'w' })\n * // ['b.ts', 'c.ts']\n * ```\n */\nexport function collectCaptureChanges(\n\tprevious: Readonly<Record<string, string>>,\n\tcurrent: Readonly<Record<string, string>>,\n): readonly string[] {\n\treturn [...new Set([...Object.keys(previous), ...Object.keys(current)])]\n\t\t.filter((file) => previous[file] !== current[file])\n\t\t.toSorted()\n}\n\n/**\n * Builds the stable case identity used to merge separate lookup receipts.\n *\n * @param lookup - The lookup identity\n * @returns The producing variant and full case key\n *\n * @example\n * ```ts\n * resolveLookupKey({ variant: 'light-390', case: 'mail shows the inbox' })\n * // '[\"light-390\",\"mail shows the inbox\"]'\n * ```\n */\nexport function resolveLookupKey(lookup: Pick<CaptureLookup, 'variant' | 'case'>): string {\n\treturn JSON.stringify([lookup.variant, lookup.case])\n}\n\n/**\n * Reads successful Vitest JSON output and validates every owner-bearing assertion.\n *\n * @param value - The parsed external reporter document\n * @returns A validated projection of the fields used by integrity\n * @throws Thrown as an `EVIDENCE` capture error for failed reporters, malformed assertions, or duplicate case identities.\n *\n * @example\n * ```ts\n * const report = readCaptureReport(parseJSON(text))\n * report.assertions.map((assertion) => assertion.case)\n * ```\n */\nexport function readCaptureReport(value: unknown): CaptureReport {\n\tif (\n\t\t!isRecord(value) ||\n\t\tvalue.success !== true ||\n\t\tvalue.numFailedTests !== 0 ||\n\t\tvalue.numFailedTestSuites !== 0 ||\n\t\t!isFiniteNumber(value.startTime) ||\n\t\t!arrayOf(isRecord)(value.testResults) ||\n\t\tvalue.testResults.length === 0\n\t)\n\t\tthrow new CaptureError('Invalid or unsuccessful Vitest JSON report', { code: 'EVIDENCE' })\n\tconst files = value.testResults.map((file) => {\n\t\tif (\n\t\t\tfile.status !== 'passed' ||\n\t\t\t!isFiniteNumber(file.startTime) ||\n\t\t\t!isFiniteNumber(file.endTime) ||\n\t\t\tfile.endTime < file.startTime ||\n\t\t\t!arrayOf(isRecord)(file.assertionResults)\n\t\t)\n\t\t\tthrow new CaptureError('Invalid Vitest file report', { code: 'EVIDENCE' })\n\t\treturn { start: file.startTime, end: file.endTime, assertions: file.assertionResults }\n\t})\n\tconst assertions: readonly CaptureAssertion[] = files.flatMap((file) =>\n\t\tfile.assertions.flatMap((assertion) => {\n\t\t\tif (!isRecord(assertion.meta))\n\t\t\t\tthrow new CaptureError('Invalid Vitest assertion metadata', { code: 'EVIDENCE' })\n\t\t\tif (assertion.meta.owner === undefined) return []\n\t\t\tconst declaration = {\n\t\t\t\tcase: assertion.fullName,\n\t\t\t\towner: assertion.meta.owner,\n\t\t\t\tvariant: assertion.meta.variant,\n\t\t\t\teligible: assertion.meta.eligible === undefined ? true : assertion.meta.eligible,\n\t\t\t\tstates: assertion.meta.states === undefined ? [] : assertion.meta.states,\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!isCaptureDeclaration(declaration) ||\n\t\t\t\t!isString(assertion.status) ||\n\t\t\t\t(assertion.duration !== undefined &&\n\t\t\t\t\tassertion.duration !== null &&\n\t\t\t\t\t(!isFiniteNumber(assertion.duration) || assertion.duration < 0))\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Invalid owner-bearing Vitest assertion', { code: 'EVIDENCE' })\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\t...declaration,\n\t\t\t\t\tstatus: assertion.status,\n\t\t\t\t\t...(typeof assertion.duration === 'number' ? { duration: assertion.duration } : {}),\n\t\t\t\t},\n\t\t\t]\n\t\t}),\n\t)\n\trequireCaptureUnique(assertions.map(resolveLookupKey), 'reporter case identities')\n\treturn {\n\t\tstart: Math.min(value.startTime, ...files.map((file) => file.start)),\n\t\tend: Math.max(...files.map((file) => file.end)),\n\t\tassertions,\n\t}\n}\n\n/**\n * Validates declaration, reporter, observation, completeness, and output-projection agreement.\n *\n * @param run - The final record\n * @param report - The validated external reporter\n * @param project - The actual producing project name\n * @throws Thrown as an `EVIDENCE` capture error when a record differs from the actual selected results or declarations.\n *\n * @example\n * ```ts\n * validateCaptureRun(run, readCaptureReport(parseJSON(text)), 'journey:light-390')\n * ```\n */\nexport function validateCaptureRun(run: CaptureRun, report: CaptureReport, project: string): void {\n\tconst assertions = report.assertions.filter((entry) => entry.variant === run.variant)\n\trequireCaptureUnique(\n\t\trun.declarations.map((entry) => entry.case),\n\t\t'declaring cases',\n\t)\n\trequireCaptureUnique(\n\t\trun.declarations.flatMap((entry) => entry.states),\n\t\t'declared states',\n\t\ttrue,\n\t)\n\trequireCaptureUnique(run.registry.map(resolveCaptureKey), 'registry identities', true)\n\trequireCaptureUnique(\n\t\trun.registry.map((entry) => entry.file),\n\t\t'registry paths',\n\t\ttrue,\n\t)\n\trequireCaptureUnique(run.entries.map(resolveCaptureKey), 'emitted identities', true)\n\trequireCaptureUnique(run.passed, 'passed cases')\n\trequireCaptureUnique(run.observed, 'observed states', true)\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.declarations.map(describeCaptureDeclaration),\n\t\t\tassertions.map(describeCaptureDeclaration),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Run declarations differ from full reporter declarations', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst eligible = run.declarations.filter((entry) => entry.eligible)\n\tconst passed = assertions.filter((entry) => entry.eligible && entry.status === 'passed')\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.passed,\n\t\t\tpassed.map((entry) => entry.case),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Run passed cases differ from reporter results', { code: 'EVIDENCE' })\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.observed,\n\t\t\tpassed.flatMap((entry) => entry.states),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Run observations differ from full passed declarations', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tif (run.complete !== (eligible.length > 0 && eligible.length === passed.length))\n\t\tthrow new CaptureError('Run completeness differs from eligible results', { code: 'EVIDENCE' })\n\tfor (const declaration of eligible) {\n\t\tconst destinations = run.registry.filter((entry) => entry.case === declaration.case)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tdestinations.map((entry) => entry.state),\n\t\t\t\tdeclaration.states,\n\t\t\t) ||\n\t\t\tdestinations.some(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry.project !== project ||\n\t\t\t\t\t!matchesCaptureSelector(resolveCaptureOwner(entry), declaration.owner),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError(`Registry differs from eligible declaration: ${declaration.case}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n\tif (\n\t\trun.registry.some((entry) => !eligible.some((declaration) => declaration.case === entry.case))\n\t)\n\t\tthrow new CaptureError('Registry contains an ineligible or undeclared case', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst reference = run.registry.filter((entry) => entry.section === entry.state)\n\tif (\n\t\trun.reference !==\n\t\t(reference.length > 0 && reference.every((entry) => run.passed.includes(entry.case)))\n\t)\n\t\tthrow new CaptureError('Reference completeness differs from declaring section results', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst request = run.request\n\tif (request !== undefined) {\n\t\tif (\n\t\t\trun.identity === undefined ||\n\t\t\trun.identity.id !== request.id ||\n\t\t\trun.identity.stage !== request.stage ||\n\t\t\trun.identity.pid !== request.pid ||\n\t\t\trun.identity.config !== request.config ||\n\t\t\t!request.variants.includes(run.variant)\n\t\t)\n\t\t\tthrow new CaptureError('Run identity differs from its request', { code: 'EVIDENCE' })\n\t\tconst selected = eligible.filter(\n\t\t\t(entry) =>\n\t\t\t\tmatchesCaptureSelector(entry.owner, request.selector) &&\n\t\t\t\t(request.case === undefined || entry.case === request.case) &&\n\t\t\t\t(request.command === 'journey' || entry.states.length > 0),\n\t\t)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tselected.map((entry) => entry.case),\n\t\t\t\trun.passed,\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Selected full case names differ from passed results', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tif (\n\t\t\trequest.state !== undefined &&\n\t\t\tselected.some((entry) => !entry.states.includes(request.state ?? ''))\n\t\t)\n\t\t\tthrow new CaptureError('Requested state differs from its selected declaring case', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n\tconst expected =\n\t\trequest?.command === 'journey' || (request === undefined && run.entries.length === 0)\n\t\t\t? []\n\t\t\t: run.registry.filter(\n\t\t\t\t\t(entry) =>\n\t\t\t\t\t\trun.passed.includes(entry.case) &&\n\t\t\t\t\t\t(request?.state === undefined || entry.state === request.state),\n\t\t\t\t)\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.entries.map(describeCaptureDestination),\n\t\t\texpected.map(describeCaptureDestination),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Emitted entries differ from exact requested projection', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tfor (const entry of run.entries) {\n\t\tif (passed.find((assertion) => assertion.case === entry.case)?.duration !== entry.duration)\n\t\t\tthrow new CaptureError(`Emitted duration differs from its producing case: ${entry.case}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n}\n\n/**\n * Chooses the primary classification while retaining all findings separately.\n *\n * @param statuses - Every classification justified by the reading\n * @returns The highest-precedence classification, or `current` when none applies\n *\n * @example\n * ```ts\n * resolveCaptureStatus(['stale-own', 'missing']) // 'missing'\n * resolveCaptureStatus([]) // 'current'\n * ```\n */\nexport function resolveCaptureStatus(statuses: readonly CaptureStatus[]): CaptureStatus {\n\treturn CAPTURE_STATUS_PRECEDENCE.find((status) => statuses.includes(status)) ?? 'current'\n}\n\n/**\n * Reads Git's NUL-delimited porcelain paths without treating spaces or quoted names as separators.\n *\n * @param output - The exact `status --porcelain=v1 -z` output\n * @returns Dirty repository-relative paths, including both sides of renames, sorted without repeats\n * @throws Thrown as an `EVIDENCE` capture error when a rename or copy record has no original path.\n *\n * @example\n * ```ts\n * readCaptureDirty(' M src/a.ts\\0R src/b.ts\\0src/c.ts\\0') // ['src/a.ts', 'src/b.ts', 'src/c.ts']\n * ```\n */\nexport function readCaptureDirty(output: string): readonly string[] {\n\t// A rename or copy record is followed by its original path as a bare record, so whether a record\n\t// is an original depends on the record before it, and the result carries that in its accumulator.\n\tconst result = output\n\t\t.split('\\0')\n\t\t.filter((record) => record !== '')\n\t\t.reduce<{ readonly paths: readonly string[]; readonly pending: boolean }>(\n\t\t\t(state, record) =>\n\t\t\t\tstate.pending\n\t\t\t\t\t? { paths: [...state.paths, record], pending: false }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tpaths: [...state.paths, record.slice(3)],\n\t\t\t\t\t\t\tpending: /[RC]/u.test(record.slice(0, 2)),\n\t\t\t\t\t\t},\n\t\t\t{ paths: [], pending: false },\n\t\t)\n\tif (result.pending)\n\t\tthrow new CaptureError('Incomplete Git rename provenance', { code: 'EVIDENCE' })\n\treturn [...new Set(result.paths)].toSorted()\n}\n\n/**\n * Validates a complete receipt against full reporter declarations and eligible output coverage.\n *\n * @param receipt - The retained complete-run receipt\n * @param report - The authenticated reporter projection\n * @throws Thrown as an `EVIDENCE` capture error when the receipt omits, invents, or changes a collected declaration or output.\n *\n * @example\n * ```ts\n * validateCaptureReceipt(receipt, readCaptureReport(parseJSON(text)))\n * ```\n */\nexport function validateCaptureReceipt(receipt: CaptureReceipt, report: CaptureReport): void {\n\tconst assertions = report.assertions.filter((entry) => entry.variant === receipt.variant)\n\tif (\n\t\t!receipt.complete ||\n\t\t!matchesCaptureMembers(\n\t\t\tassertions.map(describeCaptureDeclaration),\n\t\t\treceipt.declarations.map(describeCaptureDeclaration),\n\t\t) ||\n\t\t!assertions.some((entry) => entry.eligible) ||\n\t\tassertions.some((entry) => entry.eligible && entry.status !== 'passed')\n\t)\n\t\tthrow new CaptureError('Registry receipt does not prove complete eligible behavior', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst eligible = receipt.declarations.filter((entry) => entry.eligible)\n\tfor (const declaration of eligible) {\n\t\trequireCaptureUnique(declaration.states, 'states within a declaration', true)\n\t\tconst entries = receipt.registry.filter((entry) => entry.case === declaration.case)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tentries.map((entry) => entry.state),\n\t\t\t\tdeclaration.states,\n\t\t\t) ||\n\t\t\tentries.some(\n\t\t\t\t(entry) => !matchesCaptureSelector(resolveCaptureOwner(entry), declaration.owner),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Registry receipt destination coverage differs from declarations', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n\tif (\n\t\treceipt.registry.some(\n\t\t\t(entry) => !eligible.some((declaration) => declaration.case === entry.case),\n\t\t) ||\n\t\tnew Set(receipt.registry.map((entry) => entry.project)).size > 1\n\t)\n\t\tthrow new CaptureError(\n\t\t\t'Registry receipt contains an undeclared output or mixes producing projects',\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,IAAa,sBAAsB,OAAO,OAAO;CAChD;CACA;CACA;CACA;CACA;CACA;AACD,CAAU;;;;;;;;;;;;;AAcV,IAAa,sBAAsB,OAAO,IAAI,iCAAiC;;;;;;;;;;;;;AAc/E,IAAa,4BAA4B,OAAO,OAAO;CACtD;CACA;CACA;CACA;CACA;CACA;AACD,CAAU;;;;;;;;;AAUV,IAAa,yBAAyB;;;;;;;;;AAUtC,IAAa,kBAAkB;;;;;;;;;AAU/B,IAAa,wBAAwB,OAAO,OAAO;CAAC;CAAK;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;AAAE,CAAU;;;;;;;;;AAU7F,IAAa,wBAAwB;;;;;;;;;AAUrC,IAAa,wBAAwB;;;;;;;;;AAUrC,IAAa,uBAAuB;;;;;;;;;;;;;;;;;;;;AC/FpC,IAAa,eAAb,cAAkC,MAAM;CACvC,OAAyB;CACzB;CACA;;;;;;;CAQA,YAAY,SAAiB,SAA8B;EAC1D,MAAM,SAAS,WAAW,UAAU,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAA,CAAS;EAExE,OAAO,eAAe,MAAM,qBAAqB,EA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aAAa,IAAI,0BAA0B,CACpD,KACA,CAAC,WAAW,MAAM,UAAU,MAAM,QAAQ,KAC1C,WAAW,MAAM,UAAU,MAAM,YAAY,MAAM,WAAW,QAAQ,GAEtE,MAAM,IAAI,aAAa,8DAA8D,EACpF,MAAM,WACP,CAAC;CACF,MAAM,WAAW,QAAQ,aAAa,QAAQ,UAAU,MAAM,QAAQ;CACtE,KAAK,MAAM,eAAe,UAAU;EACnC,qBAAqB,YAAY,QAAQ,+BAA+B,IAAI;EAC5E,MAAM,UAAU,QAAQ,SAAS,QAAQ,UAAU,MAAM,SAAS,YAAY,IAAI;EAClF,IACC,CAAC,sBACA,QAAQ,KAAK,UAAU,MAAM,KAAK,GAClC,YAAY,MACb,KACA,QAAQ,MACN,UAAU,CAAC,uBAAuB,oBAAoB,KAAK,GAAG,YAAY,KAAK,CACjF,GAEA,MAAM,IAAI,aAAa,mEAAmE,EACzF,MAAM,WACP,CAAC;CACH;CACA,IACC,QAAQ,SAAS,MACf,UAAU,CAAC,SAAS,MAAM,gBAAgB,YAAY,SAAS,MAAM,IAAI,CAC3E,KACA,IAAI,IAAI,QAAQ,SAAS,KAAK,UAAU,MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,GAE/D,MAAM,IAAI,aACT,8EACA,EAAE,MAAM,WAAW,CACpB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/core/constants.ts","../../../src/core/errors.ts","../../../src/core/validators.ts","../../../src/core/helpers.ts"],"sourcesContent":["/**\n * Lists the condition axes a capture failure carries, in the order the executable reports them.\n *\n * @remarks\n * `USAGE` is a refused command line and exits 64; every other condition exits 1. `SELECTION`\n * names a selector, variant, case, state, or portfolio the host does not declare. `HOST` names a\n * wrapper, configuration, or declaration fault. `STAGE` names a runner stage that did not\n * complete. `EVIDENCE` names a record, report, registry, or manifest that fails its protocol.\n * `CONTAINMENT` names a path that leaves the authorized roots.\n *\n * @example\n * ```ts\n * CAPTURE_ERROR_CODES.includes('USAGE') // true\n * ```\n */\nexport const CAPTURE_ERROR_CODES = Object.freeze([\n\t'USAGE',\n\t'SELECTION',\n\t'HOST',\n\t'STAGE',\n\t'EVIDENCE',\n\t'CONTAINMENT',\n] as const)\n\n/**\n * Keys the global brand a capture error carries, so a duplicate installation recognizes it.\n *\n * @remarks\n * The key follows the package-and-class form, `Symbol.for('<package>.<ClassName>')`. The brand is\n * a recognition marker and never proof that the class's constructor ran.\n *\n * @example\n * ```ts\n * CAPTURE_ERROR_BRAND === Symbol.for('@orkestrel/capture.CaptureError') // true\n * ```\n */\nexport const CAPTURE_ERROR_BRAND = Symbol.for('@orkestrel/capture.CaptureError')\n\n/**\n * Lists the non-current freshness classifications from highest precedence to lowest.\n *\n * @remarks\n * `resolveCaptureStatus` reads this order to choose a frame's primary classification while the\n * reading keeps every finding separately. A frame with none of these is current.\n *\n * @example\n * ```ts\n * CAPTURE_STATUS_PRECEDENCE[0] // 'duplicate'\n * ```\n */\nexport const CAPTURE_STATUS_PRECEDENCE = Object.freeze([\n\t'duplicate',\n\t'orphan',\n\t'missing',\n\t'unstamped',\n\t'stale-shared',\n\t'stale-own',\n] as const)\n\n/**\n * Names the file prefix of a runner request, completed by the runner's process id and `.json`.\n *\n * @example\n * ```ts\n * `${CAPTURE_REQUEST_PREFIX}-${process.pid}.json` // 'journey-selection-4242.json'\n * ```\n */\nexport const CAPTURE_REQUEST_PREFIX = 'journey-selection'\n\n/**\n * Holds the protocol version every request, record, receipt, registry, and manifest declares.\n *\n * @example\n * ```ts\n * CAPTURE_VERSION // 1\n * ```\n */\nexport const CAPTURE_VERSION = 1\n\n/**\n * Holds the eight bytes every PNG file opens with.\n *\n * @example\n * ```ts\n * CAPTURE_PNG_SIGNATURE.map((byte) => byte.toString(16)).join('') // '89504e470d0a1a0a'\n * ```\n */\nexport const CAPTURE_PNG_SIGNATURE = Object.freeze([137, 80, 78, 71, 13, 10, 26, 10] as const)\n\n/**\n * Names the default accepted complete-run registry file inside a portfolio directory.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_REGISTRY_FILE}` // 'tmp/captures/states/registry.json'\n * ```\n */\nexport const CAPTURE_REGISTRY_FILE = 'registry.json'\n\n/**\n * Names the default image-stamp manifest file inside a portfolio directory.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_MANIFEST_FILE}` // 'tmp/captures/states/manifest.json'\n * ```\n */\nexport const CAPTURE_MANIFEST_FILE = 'manifest.json'\n\n/**\n * Names the default lookup journal file inside a portfolio directory.\n *\n * @example\n * ```ts\n * `tmp/captures/states/${CAPTURE_LOOKUPS_FILE}` // 'tmp/captures/states/lookups.json'\n * ```\n */\nexport const CAPTURE_LOOKUPS_FILE = 'lookups.json'\n","import type { CaptureErrorCode, CaptureErrorContext, CaptureErrorOptions } from './types.js'\nimport { holds, INTRINSICS, isError, isFunction, isObject } from '@orkestrel/contract'\nimport { CAPTURE_ERROR_BRAND, CAPTURE_ERROR_CODES } from './constants.js'\n\n/**\n * Reports one capture failure under a stable condition axis.\n *\n * @remarks\n * Every refusal the engine, the runner, and the readers raise arrives as one of these, so the\n * executable branches on `code` rather than on message text: `USAGE` exits 64 and every other\n * condition exits 1. Narrow a caught value with `isCaptureError` before reading `code`.\n *\n * @example\n * ```ts\n * const error = new CaptureError('Unknown variant: phone', {\n * \tcode: 'SELECTION',\n * \tcontext: { variant: 'phone' },\n * })\n * error.code // 'SELECTION'\n * error.context?.variant // 'phone'\n * ```\n */\nexport class CaptureError extends Error {\n\toverride readonly name = 'CaptureError'\n\treadonly code: CaptureErrorCode\n\treadonly context: CaptureErrorContext | undefined\n\n\t/**\n\t * Creates one classified capture failure.\n\t *\n\t * @param message - Human-readable description of what failed\n\t * @param options - The condition, optional structured context, and optional cause\n\t */\n\tconstructor(message: string, options: CaptureErrorOptions) {\n\t\tsuper(message, 'cause' in options ? { cause: options.cause } : undefined)\n\t\t// A transparent proxy forwards its target's identity and fails the guard's comparison.\n\t\tObject.defineProperty(this, CAPTURE_ERROR_BRAND, { value: this })\n\t\tthis.code = options.code\n\t\tthis.context = options.context\n\t}\n}\n\n/**\n * Checks whether an unknown value is a capture error.\n *\n * @remarks\n * Recognition requires a native `Error` whose prototype is not `Error.prototype`, an own brand\n * property holding the tested value itself, a declared condition code, and an object, callable, or absent\n * context. It recognizes an error from another installed copy of this package, and refuses a\n * look-alike with the same code and no brand, a proxy over a branded error, and a plain object\n * that only carries the brand.\n *\n * @param value - The value to inspect\n * @returns True if the value is a `CaptureError`; false otherwise\n *\n * @example\n * ```ts\n * isCaptureError(new CaptureError('Empty selection', { code: 'USAGE' })) // true\n * isCaptureError(new Error('Empty selection')) // false\n * ```\n */\nexport function isCaptureError(value: unknown): value is CaptureError {\n\treturn holds(() => {\n\t\tif (!isError(value) || INTRINSICS.prototype(value) === INTRINSICS.error.prototype) return false\n\t\tif (INTRINSICS.describe(value, CAPTURE_ERROR_BRAND)?.value !== value) return false\n\t\tconst code: unknown = INTRINSICS.reflect.read(value, 'code')\n\t\tconst context: unknown = INTRINSICS.reflect.read(value, 'context')\n\t\treturn (\n\t\t\tCAPTURE_ERROR_CODES.some((declared) => declared === code) &&\n\t\t\t(context === undefined || isObject(context) || isFunction(context))\n\t\t)\n\t})\n}\n","import type {\n\tCaptureArtifact,\n\tCaptureBox,\n\tCaptureCollectionReceipt,\n\tCaptureDeclaration,\n\tCaptureDestination,\n\tCaptureDigest,\n\tCaptureEntry,\n\tCaptureIdentity,\n\tCaptureLookup,\n\tCaptureLookupJournal,\n\tCaptureManifest,\n\tCaptureReceipt,\n\tCaptureRegistry,\n\tCaptureRequest,\n\tCaptureRun,\n\tCaptureSources,\n\tCaptureStamp,\n\tCaptureStoredManifest,\n\tCaptureViewport,\n} from './types.js'\nimport { arrayOf, holds, isFiniteNumber, isObject, isRecord, isString } from '@orkestrel/contract'\n\n/**\n * Checks whether a serialized path stays within the portable relative-path vocabulary.\n *\n * @param value - The serialized file or directory path\n * @returns True if every segment is portable and relative; false otherwise\n *\n * @example\n * ```ts\n * isCapturePath('tmp/captures/states/pages/mail--inbox.png') // true\n * isCapturePath('../escape.png') // false\n * ```\n */\nexport function isCapturePath(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.length > 0 &&\n\t\t[...value].every((character) => character.charCodeAt(0) > 0x1f) &&\n\t\tvalue\n\t\t\t.split('/')\n\t\t\t.every(\n\t\t\t\t(segment) =>\n\t\t\t\t\tsegment !== '' &&\n\t\t\t\t\tsegment !== '.' &&\n\t\t\t\t\tsegment !== '..' &&\n\t\t\t\t\t!/[<>:\"\\\\|?*]/u.test(segment) &&\n\t\t\t\t\t!/[. ]$/u.test(segment) &&\n\t\t\t\t\t!/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\\.|$)/iu.test(segment),\n\t\t\t)\n\t)\n}\n\n/**\n * Checks whether a native glob declaration uses relative portable path segments.\n *\n * @param value - A source attribution pattern\n * @returns True if the pattern has no path traversal or host-specific spelling; false otherwise\n *\n * @example\n * ```ts\n * isCapturePattern('src/**') // true\n * isCapturePattern('src\\\\**') // false\n * ```\n */\nexport function isCapturePattern(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.length > 0 &&\n\t\t[...value].every((character) => character.charCodeAt(0) > 0x1f) &&\n\t\tvalue\n\t\t\t.split('/')\n\t\t\t.every(\n\t\t\t\t(segment) =>\n\t\t\t\t\tsegment !== '' &&\n\t\t\t\t\tsegment !== '.' &&\n\t\t\t\t\tsegment !== '..' &&\n\t\t\t\t\t!/[<>:\"\\\\|]/u.test(segment) &&\n\t\t\t\t\t!/[. ]$/u.test(segment) &&\n\t\t\t\t\t!/^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³])(?:\\.|$)/iu.test(segment),\n\t\t\t)\n\t)\n}\n\n/**\n * Checks whether a protocol identity can occupy one portable path segment.\n *\n * @param value - The identity segment\n * @returns True if the segment is safe and nonempty; false otherwise\n *\n * @example\n * ```ts\n * isCaptureSegment('light-390') // true\n * isCaptureSegment('light 390') // false\n * ```\n */\nexport function isCaptureSegment(value: unknown): value is string {\n\treturn isCapturePath(value) && /^[a-zA-Z0-9][a-zA-Z0-9_-]*$/u.test(value)\n}\n\n/**\n * Checks whether an owner selector uses canonical colon-separated segments.\n *\n * @param value - The owner selector\n * @returns True if every owner segment is canonical; false otherwise\n *\n * @example\n * ```ts\n * isCaptureSelector('pages:mail') // true\n * isCaptureSelector('pages::mail') // false\n * ```\n */\nexport function isCaptureSelector(value: unknown): value is string {\n\treturn typeof value === 'string' && value.split(':').every(isCaptureSegment)\n}\n\n/**\n * Checks whether a value is a SHA-256 hexadecimal digest.\n *\n * @param value - The digest\n * @returns True if the digest has the expected hexadecimal width; false otherwise\n *\n * @example\n * ```ts\n * isCaptureHash('a'.repeat(64)) // true\n * isCaptureHash('abc') // false\n * ```\n */\nexport function isCaptureHash(value: unknown): value is string {\n\treturn typeof value === 'string' && /^[a-f0-9]{64}$/u.test(value)\n}\n\n/**\n * Checks whether a file-hash map has portable keys and valid digests.\n *\n * @param value - The hash map\n * @returns True if every key and digest is valid and no two keys differ only by case; false otherwise\n *\n * @example\n * ```ts\n * isCaptureHashes({ 'src/index.ts': 'a'.repeat(64) }) // true\n * isCaptureHashes({ 'src/index.ts': 'x' }) // false\n * ```\n */\nexport function isCaptureHashes(value: unknown): value is Readonly<Record<string, string>> {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tObject.entries(value).every(\n\t\t\t\t([file, digest]) => isCapturePath(file) && isCaptureHash(digest),\n\t\t\t) &&\n\t\t\tnew Set(Object.keys(value).map((file) => file.toLowerCase())).size ===\n\t\t\t\tObject.keys(value).length,\n\t)\n}\n\n/**\n * Checks whether source attribution separates own, shared, and behavioral patterns.\n *\n * @param value - The attribution\n * @returns True if every declared pattern is valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureSources({ own: ['src/mail/**'], shared: [], tests: [] }) // true\n * isCaptureSources({ own: ['../x'], shared: [], tests: [] }) // false\n * ```\n */\nexport function isCaptureSources(value: unknown): value is CaptureSources {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tarrayOf(isCapturePattern)(value.own) &&\n\t\t\tarrayOf(isCapturePattern)(value.shared) &&\n\t\t\tarrayOf(isCapturePattern)(value.tests),\n\t)\n}\n\n/**\n * Checks whether an execution identity carries its required authorization fields.\n *\n * @param value - The identity\n * @returns True if the identity is valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureIdentity({ id: 'run-1', stage: 'selected', pid: 4242, config: 'configs/journey.ts' }) // true\n * isCaptureIdentity({ id: 'run-1', stage: 'selected', pid: 0, config: 'configs/journey.ts' }) // false\n * ```\n */\nexport function isCaptureIdentity(value: unknown): value is CaptureIdentity {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureSegment(value.id) &&\n\t\t\tisCaptureSegment(value.stage) &&\n\t\t\ttypeof value.pid === 'number' &&\n\t\t\tNumber.isSafeInteger(value.pid) &&\n\t\t\tvalue.pid > 0 &&\n\t\t\tisCapturePath(value.config),\n\t)\n}\n\n/**\n * Checks whether a request has the supported version and complete execution identity.\n *\n * @param value - The transported request\n * @returns True if every request field has its protocol shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureRequest(JSON.parse(text)) // true for a well-formed runner request\n * isCaptureRequest({ version: 2 }) // false\n * ```\n */\nexport function isCaptureRequest(value: unknown): value is CaptureRequest {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureIdentity(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\t(value.command === 'journey' || value.command === 'capture') &&\n\t\t\t(value.mode === undefined || (typeof value.mode === 'string' && value.mode.trim() !== '')) &&\n\t\t\tisCaptureSelector(value.selector) &&\n\t\t\tarrayOf(isCaptureSegment)(value.variants) &&\n\t\t\tvalue.variants.length > 0 &&\n\t\t\tarrayOf(isString)(value.args) &&\n\t\t\t(value.case === undefined || (typeof value.case === 'string' && value.case.trim() !== '')) &&\n\t\t\t(value.state === undefined || (value.command === 'capture' && isCaptureSegment(value.state))),\n\t)\n}\n\n/**\n * Checks whether a collected declaration preserves its full owner and state population.\n *\n * @param value - The declaration\n * @returns True if the declaration has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureDeclaration({\n * \tcase: 'mail shows the inbox',\n * \towner: 'pages:mail',\n * \tvariant: 'light-390',\n * \teligible: true,\n * \tstates: ['inbox'],\n * }) // true\n * ```\n */\nexport function isCaptureDeclaration(value: unknown): value is CaptureDeclaration {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\ttypeof value.case === 'string' &&\n\t\t\tvalue.case.trim() !== '' &&\n\t\t\tisCaptureSelector(value.owner) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.eligible === 'boolean' &&\n\t\t\tarrayOf(isCaptureSegment)(value.states),\n\t)\n}\n\n/**\n * Checks whether a destination supplies canonical identity and source attribution fields.\n *\n * @param value - The destination\n * @returns True if the destination has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureDestination(JSON.parse(text)) // true for a registry destination row\n * isCaptureDestination({}) // false\n * ```\n */\nexport function isCaptureDestination(value: unknown): value is CaptureDestination {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureSegment(value.portfolio) &&\n\t\t\tisCaptureSegment(value.state) &&\n\t\t\tisCaptureSegment(value.scope) &&\n\t\t\tisCaptureSegment(value.part) &&\n\t\t\t(value.section === undefined || isCaptureSegment(value.section)) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.project === 'string' &&\n\t\t\tvalue.project !== '' &&\n\t\t\tisCapturePath(value.file) &&\n\t\t\ttypeof value.case === 'string' &&\n\t\t\tvalue.case.trim() !== '' &&\n\t\t\tisCaptureSources(value.sources),\n\t)\n}\n\n/**\n * Checks whether an emitted entry includes a finite nonnegative case duration.\n *\n * @param value - The emitted entry\n * @returns True if the entry is valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureEntry({ ...destination, duration: 812 }) // true\n * isCaptureEntry({ ...destination, duration: -1 }) // false\n * ```\n */\nexport function isCaptureEntry(value: unknown): value is CaptureEntry {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureDestination(value) &&\n\t\t\tisFiniteNumber(value.duration) &&\n\t\t\tvalue.duration >= 0,\n\t)\n}\n\n/**\n * Checks whether a record names its journey artifact by portable path and SHA-256 digest.\n *\n * @param value - The decoded artifact reference\n * @returns True if the reference has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureArtifact({ file: 'tmp/runs/a/light-390.txt', digest: 'a'.repeat(64) }) // true\n * isCaptureArtifact({ file: '/abs.txt', digest: 'a'.repeat(64) }) // false\n * ```\n */\nexport function isCaptureArtifact(value: unknown): value is CaptureArtifact {\n\treturn holds(() => isRecord(value) && isCapturePath(value.file) && isCaptureHash(value.digest))\n}\n\n/**\n * Checks whether a final record preserves declarations, observations, and output separately.\n *\n * @param value - The decoded run record\n * @returns True if the record has the supported protocol shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureRun(JSON.parse(text)) // true for a final run record\n * isCaptureRun(null) // false\n * ```\n */\nexport function isCaptureRun(value: unknown): value is CaptureRun {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.time === 'string' &&\n\t\t\tNumber.isFinite(Date.parse(value.time)) &&\n\t\t\ttypeof value.complete === 'boolean' &&\n\t\t\ttypeof value.reference === 'boolean' &&\n\t\t\tarrayOf(isCaptureDeclaration)(value.declarations) &&\n\t\t\tarrayOf(isCaptureDestination)(value.registry) &&\n\t\t\tarrayOf(isString)(value.passed) &&\n\t\t\tarrayOf(isCaptureSegment)(value.observed) &&\n\t\t\tarrayOf(isCaptureEntry)(value.entries) &&\n\t\t\t(value.artifact === undefined || isCaptureArtifact(value.artifact)) &&\n\t\t\t((value.identity === undefined && value.request === undefined) ||\n\t\t\t\t(isCaptureIdentity(value.identity) && isCaptureRequest(value.request))),\n\t)\n}\n\n/**\n * Checks whether a shared-source digest retains both patterns and expanded file hashes.\n *\n * @param value - The digest reading\n * @returns True if the digest reading has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureDigest({ patterns: ['src/**'], files: {}, digest: 'a'.repeat(64) }) // true\n * isCaptureDigest({ patterns: [], files: {} }) // false\n * ```\n */\nexport function isCaptureDigest(value: unknown): value is CaptureDigest {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tarrayOf(isCapturePattern)(value.patterns) &&\n\t\t\tisCaptureHashes(value.files) &&\n\t\t\tisCaptureHash(value.digest),\n\t)\n}\n\n/**\n * Checks whether a complete-run receipt binds the report, inputs, and declaration registry.\n *\n * @param value - The receipt\n * @returns True if the receipt has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureReceipt(JSON.parse(text)) // true for a complete-run receipt\n * isCaptureReceipt({}) // false\n * ```\n */\nexport function isCaptureReceipt(value: unknown): value is CaptureReceipt {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.time === 'string' &&\n\t\t\tNumber.isFinite(Date.parse(value.time)) &&\n\t\t\tisRecord(value.report) &&\n\t\t\tisCapturePath(value.report.file) &&\n\t\t\tisCaptureHash(value.report.digest) &&\n\t\t\tisCaptureHashes(value.inputs) &&\n\t\t\tarrayOf(isCaptureDeclaration)(value.declarations) &&\n\t\t\tarrayOf(isCaptureDestination)(value.registry) &&\n\t\t\ttypeof value.complete === 'boolean',\n\t)\n}\n\n/**\n * Checks whether a registry document retains its receipts and required output pairs.\n *\n * @param value - The registry document\n * @returns True if the registry has the supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureRegistry(JSON.parse(text)) // true for a published registry.json\n * isCaptureRegistry([]) // false\n * ```\n */\nexport function isCaptureRegistry(value: unknown): value is CaptureRegistry {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tarrayOf(isCaptureReceipt)(value.receipts) &&\n\t\t\tarrayOf(isCaptureDestination)(value.entries) &&\n\t\t\tisCaptureHash(value.digest),\n\t)\n}\n\n/**\n * Checks whether a lookup binds a passing case to its full run record and input hashes.\n *\n * @param value - The lookup receipt\n * @returns True if the receipt has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureLookup(JSON.parse(text)) // true for a lookup row\n * isCaptureLookup(undefined) // false\n * ```\n */\nexport function isCaptureLookup(value: unknown): value is CaptureLookup {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureHash(value.registry) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.case === 'string' &&\n\t\t\tvalue.case.trim() !== '' &&\n\t\t\tisCaptureSelector(value.owner) &&\n\t\t\tarrayOf(isCaptureSegment)(value.states) &&\n\t\t\tisCaptureHashes(value.inputs) &&\n\t\t\tisRecord(value.run) &&\n\t\t\tisCapturePath(value.run.file) &&\n\t\t\tisCaptureHash(value.run.digest),\n\t)\n}\n\n/**\n * Checks the separate lookup journal and its optional predecessor manifest digest.\n *\n * @param value - The decoded journal\n * @returns True if the journal has its supported shape; false otherwise\n * @remarks Input-map digests and reference existence are verified when the journal is read.\n *\n * @example\n * ```ts\n * isCaptureLookupJournal({ version: 1, inputs: {}, lookups: [] }) // true\n * isCaptureLookupJournal({ version: 2, inputs: {}, lookups: [] }) // false\n * ```\n */\nexport function isCaptureLookupJournal(value: unknown): value is CaptureLookupJournal {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\t(value.collections === undefined || arrayOf(isCaptureCollection)(value.collections)) &&\n\t\t\tvalue.version === 1 &&\n\t\t\t(value.manifest === undefined || isCaptureHash(value.manifest)) &&\n\t\t\tisRecord(value.inputs) &&\n\t\t\tObject.entries(value.inputs).every(\n\t\t\t\t([digest, inputs]) => isCaptureHash(digest) && isCaptureHashes(inputs),\n\t\t\t) &&\n\t\t\tarrayOf(\n\t\t\t\t(entry) =>\n\t\t\t\t\tisRecord(entry) &&\n\t\t\t\t\tisCaptureHash(entry.inputs) &&\n\t\t\t\t\tisCaptureLookup({ ...entry, inputs: {} }),\n\t\t\t)(value.lookups),\n\t)\n}\n\n/**\n * Checks whether a stamp binds an emitted image to source and execution provenance.\n *\n * @param value - The stamp\n * @returns True if the stamp has its supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureStamp(manifest.entries['pages/mail--inbox.png']) // true for a stamped frame\n * isCaptureStamp({}) // false\n * ```\n */\nexport function isCaptureStamp(value: unknown): value is CaptureStamp {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureEntry(value) &&\n\t\t\tisCaptureIdentity(value.identity) &&\n\t\t\ttypeof value.time === 'string' &&\n\t\t\tNumber.isFinite(Date.parse(value.time)) &&\n\t\t\ttypeof value.commit === 'string' &&\n\t\t\t/^[a-f0-9]{40,64}$/u.test(value.commit) &&\n\t\t\tarrayOf(isCapturePath)(value.dirty) &&\n\t\t\tisCaptureHashes(value.own) &&\n\t\t\tisCaptureDigest(value.shared) &&\n\t\t\tisCaptureHashes(value.tests) &&\n\t\t\tisCaptureHash(value.registry) &&\n\t\t\tisRecord(value.image) &&\n\t\t\tisCaptureHash(value.image.digest) &&\n\t\t\tisFiniteNumber(value.image.size) &&\n\t\t\tNumber.isSafeInteger(value.image.size) &&\n\t\t\tvalue.image.size > 0 &&\n\t\t\tisFiniteNumber(value.image.modified) &&\n\t\t\tvalue.image.modified >= 0,\n\t)\n}\n\n/**\n * Checks whether an inherited manifest has the supported schema without discarding malformed rows.\n *\n * @param value - The manifest\n * @returns True if every inherited member validates; false otherwise\n *\n * @example\n * ```ts\n * isCaptureManifest(JSON.parse(text)) // true for a published manifest.json\n * isCaptureManifest('manifest') // false\n * ```\n */\nexport function isCaptureManifest(value: unknown): value is CaptureManifest {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tvalue.version === 1 &&\n\t\t\tisCaptureRegistry(value.registry) &&\n\t\t\tisRecord(value.entries) &&\n\t\t\tObject.entries(value.entries).every(\n\t\t\t\t([key, stamp]) => isCapturePath(key) && isCaptureStamp(stamp),\n\t\t\t) &&\n\t\t\tarrayOf(isCaptureLookup)(value.lookups),\n\t)\n}\n\n/**\n * Checks whether collection evidence pins complete input membership and both external artifacts.\n *\n * @param value - The collection receipt\n * @returns True if every field has the supported shape; false otherwise\n *\n * @example\n * ```ts\n * isCaptureCollection(manifest.collections?.[0]) // true for a collection receipt\n * isCaptureCollection({}) // false\n * ```\n */\nexport function isCaptureCollection(value: unknown): value is CaptureCollectionReceipt {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisCaptureHash(value.registry) &&\n\t\t\tisCaptureSegment(value.variant) &&\n\t\t\ttypeof value.project === 'string' &&\n\t\t\tvalue.project.trim() !== '' &&\n\t\t\tisCaptureDigest(value.inputs) &&\n\t\t\tisRecord(value.run) &&\n\t\t\tisCapturePath(value.run.file) &&\n\t\t\tisCaptureHash(value.run.digest) &&\n\t\t\tisRecord(value.report) &&\n\t\t\tisCapturePath(value.report.file) &&\n\t\t\tisCaptureHash(value.report.digest),\n\t)\n}\n\n/**\n * Checks optional collection metadata without upgrading historical image evidence.\n *\n * @param value - The inherited image transaction\n * @returns True if its existing manifest and any collection receipts are valid; false otherwise\n *\n * @example\n * ```ts\n * isCaptureStoredManifest(JSON.parse(text)) // true for a manifest with or without collections\n * isCaptureStoredManifest(null) // false\n * ```\n */\nexport function isCaptureStoredManifest(value: unknown): value is CaptureStoredManifest {\n\treturn holds(\n\t\t() =>\n\t\t\tisCaptureManifest(value) &&\n\t\t\tisRecord(value) &&\n\t\t\t(value.collections === undefined || arrayOf(isCaptureCollection)(value.collections)),\n\t)\n}\n\n/**\n * Checks the host's declared viewport without deriving geometry from an output name.\n *\n * @param value - The published viewport data\n * @returns True if the named viewport has usable dimensions; false otherwise\n *\n * @example\n * ```ts\n * isCaptureGeometry({ name: 'light-390', width: 390, height: 844 }) // true\n * isCaptureGeometry({ name: 'light-390', width: 0, height: 844 }) // false\n * ```\n */\nexport function isCaptureGeometry(value: unknown): value is CaptureViewport {\n\treturn holds(\n\t\t() =>\n\t\t\tisObject(value) &&\n\t\t\t'name' in value &&\n\t\t\tisCaptureSegment(value.name) &&\n\t\t\t'width' in value &&\n\t\t\tisFiniteNumber(value.width) &&\n\t\t\tvalue.width > 0 &&\n\t\t\t'height' in value &&\n\t\t\tisFiniteNumber(value.height) &&\n\t\t\tvalue.height > 0,\n\t)\n}\n\n/**\n * Checks a journey artifact's recorded sampling box.\n *\n * @param value - The recorded viewport box\n * @returns True if its coordinates and dimensions are finite; false otherwise\n *\n * @example\n * ```ts\n * isCaptureBox({ x: 0, y: 64, width: 390, height: 780 }) // true\n * isCaptureBox({ x: 0, y: 64, width: 0, height: 780 }) // false\n * ```\n */\nexport function isCaptureBox(value: unknown): value is CaptureBox {\n\treturn holds(\n\t\t() =>\n\t\t\tisRecord(value) &&\n\t\t\tisFiniteNumber(value.x) &&\n\t\t\tisFiniteNumber(value.y) &&\n\t\t\tisFiniteNumber(value.width) &&\n\t\t\tvalue.width > 0 &&\n\t\t\tisFiniteNumber(value.height) &&\n\t\t\tvalue.height > 0,\n\t)\n}\n","import type {\n\tCaptureAssertion,\n\tCaptureDeclaration,\n\tCaptureDestination,\n\tCaptureLookup,\n\tCaptureReceipt,\n\tCaptureReport,\n\tCaptureRequest,\n\tCaptureRun,\n\tCaptureStatus,\n} from './types.js'\nimport { arrayOf, isError, isFiniteNumber, isRecord, isString } from '@orkestrel/contract'\nimport { CAPTURE_STATUS_PRECEDENCE } from './constants.js'\nimport { CaptureError } from './errors.js'\nimport { isCaptureDeclaration } from './validators.js'\n\n/**\n * Describes a caught failure as one reportable line.\n *\n * @param error - The caught value, which need not be an `Error`\n * @returns The error's message, or the value's string form\n *\n * @example\n * ```ts\n * describeCaptureError(new Error('Unknown variant: phone')) // 'Unknown variant: phone'\n * describeCaptureError('refused') // 'refused'\n * ```\n */\nexport function describeCaptureError(error: unknown): string {\n\treturn isError(error) ? error.message : String(error)\n}\n\n/**\n * Finds repeated identities before a keyed collection could discard them.\n *\n * @param values - The identity population\n * @param folded - If `true`, compares case-folded keys; if `false`, compares exact identities. Default: `false`\n * @returns Every member whose comparison key appears more than once\n *\n * @example\n * ```ts\n * collectCaptureDuplicates(['a', 'b', 'a']) // ['a', 'a']\n * collectCaptureDuplicates(['Pages', 'pages'], true) // ['Pages', 'pages']\n * ```\n */\nexport function collectCaptureDuplicates(\n\tvalues: readonly string[],\n\tfolded = false,\n): readonly string[] {\n\tconst keys = values.map((value) => (folded ? value.toLowerCase() : value))\n\treturn values.filter(\n\t\t(_value, index) => keys.indexOf(keys[index] ?? '') !== keys.lastIndexOf(keys[index] ?? ''),\n\t)\n}\n\n/**\n * Refuses duplicate declarations or portable storage-key collisions before indexing.\n *\n * @param values - The complete identity population\n * @param label - The diagnostic subject\n * @param folded - If `true`, refuses case-colliding keys; if `false`, requires exact uniqueness. Default: `false`\n * @throws Thrown as an `EVIDENCE` capture error when an identity repeats.\n *\n * @example\n * ```ts\n * requireCaptureUnique(['mail', 'files'], 'owners') // returns\n * requireCaptureUnique(['mail', 'mail'], 'owners') // throws 'Duplicate owners: mail, mail'\n * ```\n */\nexport function requireCaptureUnique(\n\tvalues: readonly string[],\n\tlabel: string,\n\tfolded = false,\n): void {\n\tconst duplicates = collectCaptureDuplicates(values, folded)\n\tif (duplicates.length > 0)\n\t\tthrow new CaptureError(`Duplicate ${label}: ${duplicates.join(', ')}`, {\n\t\t\tcode: 'EVIDENCE',\n\t\t\tcontext: { label, duplicates },\n\t\t})\n}\n\n/**\n * Compares complete populations without erasing duplicates.\n *\n * @param left - The first population\n * @param right - The second population\n * @returns True if the sorted populations are equal; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureMembers(['b', 'a'], ['a', 'b']) // true\n * matchesCaptureMembers(['a', 'a'], ['a']) // false\n * ```\n */\nexport function matchesCaptureMembers(left: readonly string[], right: readonly string[]): boolean {\n\tconst ordered = right.toSorted()\n\treturn (\n\t\tleft.length === right.length &&\n\t\tleft.toSorted().every((entry, index) => entry === ordered[index])\n\t)\n}\n\n/**\n * Compares an owner with an explicit selector at colon boundaries.\n *\n * @param owner - The canonical owner\n * @param selector - The requested owner or the `all` selector\n * @returns True if the owner belongs to the selection; false otherwise\n *\n * @example\n * ```ts\n * matchesCaptureSelector('pages:mail', 'pages') // true\n * matchesCaptureSelector('pages:mailbox', 'pages:mail') // false\n * ```\n */\nexport function matchesCaptureSelector(owner: string, selector: string): boolean {\n\treturn selector === 'all' || owner === selector || owner.startsWith(`${selector}:`)\n}\n\n/**\n * Builds the canonical owner from a destination's registry identity.\n *\n * @param entry - The destination\n * @returns The scope, part, and optional section selector\n *\n * @example\n * ```ts\n * resolveCaptureOwner({ ...destination, scope: 'pages', part: 'mail' }) // 'pages:mail'\n * ```\n */\nexport function resolveCaptureOwner(entry: CaptureDestination): string {\n\treturn [entry.scope, entry.part, ...(entry.section === undefined ? [] : [entry.section])].join(\n\t\t':',\n\t)\n}\n\n/**\n * Builds a manifest identity independently of the physical image path.\n *\n * @param entry - The registry destination\n * @returns The scope-qualified state and output-variant key\n *\n * @example\n * ```ts\n * resolveCaptureKey({ ...destination, scope: 'pages', state: 'inbox', variant: 'light-390' })\n * // 'pages/inbox--light-390.png'\n * ```\n */\nexport function resolveCaptureKey(entry: CaptureDestination): string {\n\treturn `${entry.scope}/${entry.state}--${entry.variant}.png`\n}\n\n/**\n * Serializes a destination's identity and attribution in a deterministic field order.\n *\n * @param entry - The destination\n * @returns The comparison representation, excluding image and duration readings\n *\n * @example\n * ```ts\n * describeCaptureDestination(destination) === describeCaptureDestination({ ...destination })\n * // true\n * ```\n */\nexport function describeCaptureDestination(entry: CaptureDestination): string {\n\treturn JSON.stringify([\n\t\tentry.portfolio,\n\t\tentry.state,\n\t\tentry.scope,\n\t\tentry.part,\n\t\tentry.section,\n\t\tentry.variant,\n\t\tentry.project,\n\t\tentry.file,\n\t\tentry.case,\n\t\tentry.sources.own.toSorted(),\n\t\tentry.sources.shared.toSorted(),\n\t\tentry.sources.tests.toSorted(),\n\t])\n}\n\n/**\n * Serializes only the registry's execution and output identity, independent of input revisions.\n *\n * @param entry - The destination or inherited stamp\n * @returns The identity used for relevant manifest agreement during state resolution\n *\n * @example\n * ```ts\n * describeCaptureIdentity(destination) === describeCaptureIdentity({\n * \t...destination,\n * \tsources: { own: [], shared: [], tests: [] },\n * })\n * // true\n * ```\n */\nexport function describeCaptureIdentity(entry: CaptureDestination): string {\n\treturn JSON.stringify([\n\t\tentry.portfolio,\n\t\tentry.state,\n\t\tentry.scope,\n\t\tentry.part,\n\t\tentry.section,\n\t\tentry.variant,\n\t\tentry.project,\n\t\tentry.file,\n\t\tentry.case,\n\t])\n}\n\n/**\n * Serializes a complete behavioral declaration without dropping eligibility or states.\n *\n * @param entry - The collected declaration\n * @returns The deterministic comparison representation\n *\n * @example\n * ```ts\n * describeCaptureDeclaration({ ...declaration, states: ['b', 'a'] }) ===\n * \tdescribeCaptureDeclaration({ ...declaration, states: ['a', 'b'] })\n * // true\n * ```\n */\nexport function describeCaptureDeclaration(entry: CaptureDeclaration): string {\n\treturn JSON.stringify([\n\t\tentry.case,\n\t\tentry.owner,\n\t\tentry.variant,\n\t\tentry.eligible,\n\t\tentry.states.toSorted(),\n\t])\n}\n\n/**\n * Serializes every request field, retaining the exact argv order.\n *\n * @param request - The transported request\n * @returns The exact request comparison representation\n *\n * @example\n * ```ts\n * describeCaptureRequest(request) === describeCaptureRequest({ ...request, args: [] })\n * // false when the request carried argv\n * ```\n */\nexport function describeCaptureRequest(request: CaptureRequest): string {\n\treturn JSON.stringify([\n\t\trequest.version,\n\t\trequest.id,\n\t\trequest.stage,\n\t\trequest.pid,\n\t\trequest.config,\n\t\trequest.command,\n\t\trequest.mode,\n\t\trequest.selector,\n\t\trequest.case,\n\t\trequest.state,\n\t\trequest.variants,\n\t\trequest.args,\n\t])\n}\n\n/**\n * Names every changed, added, or removed file in hash populations.\n *\n * @param previous - The retained file hashes\n * @param current - The observed file hashes\n * @returns The sorted changed membership\n *\n * @example\n * ```ts\n * collectCaptureChanges({ 'a.ts': 'x', 'b.ts': 'y' }, { 'a.ts': 'x', 'b.ts': 'z', 'c.ts': 'w' })\n * // ['b.ts', 'c.ts']\n * ```\n */\nexport function collectCaptureChanges(\n\tprevious: Readonly<Record<string, string>>,\n\tcurrent: Readonly<Record<string, string>>,\n): readonly string[] {\n\treturn [...new Set([...Object.keys(previous), ...Object.keys(current)])]\n\t\t.filter((file) => previous[file] !== current[file])\n\t\t.toSorted()\n}\n\n/**\n * Builds the stable case identity used to merge separate lookup receipts.\n *\n * @param lookup - The lookup identity\n * @returns The producing variant and full case key\n *\n * @example\n * ```ts\n * resolveLookupKey({ variant: 'light-390', case: 'mail shows the inbox' })\n * // '[\"light-390\",\"mail shows the inbox\"]'\n * ```\n */\nexport function resolveLookupKey(lookup: Pick<CaptureLookup, 'variant' | 'case'>): string {\n\treturn JSON.stringify([lookup.variant, lookup.case])\n}\n\n/**\n * Reads successful Vitest JSON output and validates every owner-bearing assertion.\n *\n * @param value - The parsed external reporter document\n * @returns A validated projection of the fields used by integrity\n * @throws Thrown as an `EVIDENCE` capture error for failed reporters, malformed assertions, or duplicate case identities.\n *\n * @example\n * ```ts\n * const report = readCaptureReport(parseJSON(text))\n * report.assertions.map((assertion) => assertion.case)\n * ```\n */\nexport function readCaptureReport(value: unknown): CaptureReport {\n\tif (\n\t\t!isRecord(value) ||\n\t\tvalue.success !== true ||\n\t\tvalue.numFailedTests !== 0 ||\n\t\tvalue.numFailedTestSuites !== 0 ||\n\t\t!isFiniteNumber(value.startTime) ||\n\t\t!arrayOf(isRecord)(value.testResults) ||\n\t\tvalue.testResults.length === 0\n\t)\n\t\tthrow new CaptureError('Invalid or unsuccessful Vitest JSON report', { code: 'EVIDENCE' })\n\tconst files = value.testResults.map((file) => {\n\t\tif (\n\t\t\tfile.status !== 'passed' ||\n\t\t\t!isFiniteNumber(file.startTime) ||\n\t\t\t!isFiniteNumber(file.endTime) ||\n\t\t\tfile.endTime < file.startTime ||\n\t\t\t!arrayOf(isRecord)(file.assertionResults)\n\t\t)\n\t\t\tthrow new CaptureError('Invalid Vitest file report', { code: 'EVIDENCE' })\n\t\treturn { start: file.startTime, end: file.endTime, assertions: file.assertionResults }\n\t})\n\tconst assertions: readonly CaptureAssertion[] = files.flatMap((file) =>\n\t\tfile.assertions.flatMap((assertion) => {\n\t\t\tif (!isRecord(assertion.meta))\n\t\t\t\tthrow new CaptureError('Invalid Vitest assertion metadata', { code: 'EVIDENCE' })\n\t\t\tif (assertion.meta.owner === undefined) return []\n\t\t\tconst declaration = {\n\t\t\t\tcase: assertion.fullName,\n\t\t\t\towner: assertion.meta.owner,\n\t\t\t\tvariant: assertion.meta.variant,\n\t\t\t\teligible: assertion.meta.eligible === undefined ? true : assertion.meta.eligible,\n\t\t\t\tstates: assertion.meta.states === undefined ? [] : assertion.meta.states,\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!isCaptureDeclaration(declaration) ||\n\t\t\t\t!isString(assertion.status) ||\n\t\t\t\t(assertion.duration !== undefined &&\n\t\t\t\t\tassertion.duration !== null &&\n\t\t\t\t\t(!isFiniteNumber(assertion.duration) || assertion.duration < 0))\n\t\t\t)\n\t\t\t\tthrow new CaptureError('Invalid owner-bearing Vitest assertion', { code: 'EVIDENCE' })\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\t...declaration,\n\t\t\t\t\tstatus: assertion.status,\n\t\t\t\t\t...(typeof assertion.duration === 'number' ? { duration: assertion.duration } : {}),\n\t\t\t\t},\n\t\t\t]\n\t\t}),\n\t)\n\trequireCaptureUnique(assertions.map(resolveLookupKey), 'reporter case identities')\n\treturn {\n\t\tstart: Math.min(value.startTime, ...files.map((file) => file.start)),\n\t\tend: Math.max(...files.map((file) => file.end)),\n\t\tassertions,\n\t}\n}\n\n/**\n * Validates declaration, reporter, observation, completeness, and output-projection agreement.\n *\n * @param run - The final record\n * @param report - The validated external reporter\n * @param project - The actual producing project name\n * @throws Thrown as an `EVIDENCE` capture error when a record differs from the actual selected results or declarations.\n *\n * @example\n * ```ts\n * validateCaptureRun(run, readCaptureReport(parseJSON(text)), 'journey:light-390')\n * ```\n */\nexport function validateCaptureRun(run: CaptureRun, report: CaptureReport, project: string): void {\n\tconst assertions = report.assertions.filter((entry) => entry.variant === run.variant)\n\trequireCaptureUnique(\n\t\trun.declarations.map((entry) => entry.case),\n\t\t'declaring cases',\n\t)\n\trequireCaptureUnique(\n\t\trun.declarations.flatMap((entry) => entry.states),\n\t\t'declared states',\n\t\ttrue,\n\t)\n\trequireCaptureUnique(run.registry.map(resolveCaptureKey), 'registry identities', true)\n\trequireCaptureUnique(\n\t\trun.registry.map((entry) => entry.file),\n\t\t'registry paths',\n\t\ttrue,\n\t)\n\trequireCaptureUnique(run.entries.map(resolveCaptureKey), 'emitted identities', true)\n\trequireCaptureUnique(run.passed, 'passed cases')\n\trequireCaptureUnique(run.observed, 'observed states', true)\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.declarations.map(describeCaptureDeclaration),\n\t\t\tassertions.map(describeCaptureDeclaration),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Run declarations differ from full reporter declarations', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst eligible = run.declarations.filter((entry) => entry.eligible)\n\tconst passed = assertions.filter((entry) => entry.eligible && entry.status === 'passed')\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.passed,\n\t\t\tpassed.map((entry) => entry.case),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Run passed cases differ from reporter results', { code: 'EVIDENCE' })\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.observed,\n\t\t\tpassed.flatMap((entry) => entry.states),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Run observations differ from full passed declarations', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tif (run.complete !== (eligible.length > 0 && eligible.length === passed.length))\n\t\tthrow new CaptureError('Run completeness differs from eligible results', { code: 'EVIDENCE' })\n\tfor (const declaration of eligible) {\n\t\tconst destinations = run.registry.filter((entry) => entry.case === declaration.case)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tdestinations.map((entry) => entry.state),\n\t\t\t\tdeclaration.states,\n\t\t\t) ||\n\t\t\tdestinations.some(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry.project !== project ||\n\t\t\t\t\t!matchesCaptureSelector(resolveCaptureOwner(entry), declaration.owner),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError(`Registry differs from eligible declaration: ${declaration.case}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n\tif (\n\t\trun.registry.some((entry) => !eligible.some((declaration) => declaration.case === entry.case))\n\t)\n\t\tthrow new CaptureError('Registry contains an ineligible or undeclared case', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst reference = run.registry.filter((entry) => entry.section === entry.state)\n\tif (\n\t\trun.reference !==\n\t\t(reference.length > 0 && reference.every((entry) => run.passed.includes(entry.case)))\n\t)\n\t\tthrow new CaptureError('Reference completeness differs from declaring section results', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst request = run.request\n\tif (request !== undefined) {\n\t\tif (\n\t\t\trun.identity === undefined ||\n\t\t\trun.identity.id !== request.id ||\n\t\t\trun.identity.stage !== request.stage ||\n\t\t\trun.identity.pid !== request.pid ||\n\t\t\trun.identity.config !== request.config ||\n\t\t\t!request.variants.includes(run.variant)\n\t\t)\n\t\t\tthrow new CaptureError('Run identity differs from its request', { code: 'EVIDENCE' })\n\t\tconst selected = eligible.filter(\n\t\t\t(entry) =>\n\t\t\t\tmatchesCaptureSelector(entry.owner, request.selector) &&\n\t\t\t\t(request.case === undefined || entry.case === request.case) &&\n\t\t\t\t(request.command === 'journey' || entry.states.length > 0),\n\t\t)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tselected.map((entry) => entry.case),\n\t\t\t\trun.passed,\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Selected full case names differ from passed results', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t\tif (\n\t\t\trequest.state !== undefined &&\n\t\t\tselected.some((entry) => !entry.states.includes(request.state ?? ''))\n\t\t)\n\t\t\tthrow new CaptureError('Requested state differs from its selected declaring case', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n\tconst expected =\n\t\trequest?.command === 'journey' || (request === undefined && run.entries.length === 0)\n\t\t\t? []\n\t\t\t: run.registry.filter(\n\t\t\t\t\t(entry) =>\n\t\t\t\t\t\trun.passed.includes(entry.case) &&\n\t\t\t\t\t\t(request?.state === undefined || entry.state === request.state),\n\t\t\t\t)\n\tif (\n\t\t!matchesCaptureMembers(\n\t\t\trun.entries.map(describeCaptureDestination),\n\t\t\texpected.map(describeCaptureDestination),\n\t\t)\n\t)\n\t\tthrow new CaptureError('Emitted entries differ from exact requested projection', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tfor (const entry of run.entries) {\n\t\tif (passed.find((assertion) => assertion.case === entry.case)?.duration !== entry.duration)\n\t\t\tthrow new CaptureError(`Emitted duration differs from its producing case: ${entry.case}`, {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n}\n\n/**\n * Chooses the primary classification while retaining all findings separately.\n *\n * @param statuses - Every classification justified by the reading\n * @returns The highest-precedence classification, or `current` when none applies\n *\n * @example\n * ```ts\n * resolveCaptureStatus(['stale-own', 'missing']) // 'missing'\n * resolveCaptureStatus([]) // 'current'\n * ```\n */\nexport function resolveCaptureStatus(statuses: readonly CaptureStatus[]): CaptureStatus {\n\treturn CAPTURE_STATUS_PRECEDENCE.find((status) => statuses.includes(status)) ?? 'current'\n}\n\n/**\n * Reads Git's NUL-delimited porcelain paths without treating spaces or quoted names as separators.\n *\n * @param output - The exact `status --porcelain=v1 -z` output\n * @returns Dirty repository-relative paths, including both sides of renames, sorted without repeats\n * @throws Thrown as an `EVIDENCE` capture error when a rename or copy record has no original path.\n *\n * @example\n * ```ts\n * readCaptureDirty(' M src/a.ts\\0R src/b.ts\\0src/c.ts\\0') // ['src/a.ts', 'src/b.ts', 'src/c.ts']\n * ```\n */\nexport function readCaptureDirty(output: string): readonly string[] {\n\t// A rename or copy record is followed by its original path as a bare record, so whether a record\n\t// is an original depends on the record before it, and the result carries that in its accumulator.\n\tconst result = output\n\t\t.split('\\0')\n\t\t.filter((record) => record !== '')\n\t\t.reduce<{ readonly paths: readonly string[]; readonly pending: boolean }>(\n\t\t\t(state, record) =>\n\t\t\t\tstate.pending\n\t\t\t\t\t? { paths: [...state.paths, record], pending: false }\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tpaths: [...state.paths, record.slice(3)],\n\t\t\t\t\t\t\tpending: /[RC]/u.test(record.slice(0, 2)),\n\t\t\t\t\t\t},\n\t\t\t{ paths: [], pending: false },\n\t\t)\n\tif (result.pending)\n\t\tthrow new CaptureError('Incomplete Git rename provenance', { code: 'EVIDENCE' })\n\treturn [...new Set(result.paths)].toSorted()\n}\n\n/**\n * Validates a complete receipt against full reporter declarations and eligible output coverage.\n *\n * @param receipt - The retained complete-run receipt\n * @param report - The authenticated reporter projection\n * @throws Thrown as an `EVIDENCE` capture error when the receipt omits, invents, or changes a collected declaration or output.\n *\n * @example\n * ```ts\n * validateCaptureReceipt(receipt, readCaptureReport(parseJSON(text)))\n * ```\n */\nexport function validateCaptureReceipt(receipt: CaptureReceipt, report: CaptureReport): void {\n\tconst assertions = report.assertions.filter((entry) => entry.variant === receipt.variant)\n\tif (\n\t\t!receipt.complete ||\n\t\t!matchesCaptureMembers(\n\t\t\tassertions.map(describeCaptureDeclaration),\n\t\t\treceipt.declarations.map(describeCaptureDeclaration),\n\t\t) ||\n\t\t!assertions.some((entry) => entry.eligible) ||\n\t\tassertions.some((entry) => entry.eligible && entry.status !== 'passed')\n\t)\n\t\tthrow new CaptureError('Registry receipt does not prove complete eligible behavior', {\n\t\t\tcode: 'EVIDENCE',\n\t\t})\n\tconst eligible = receipt.declarations.filter((entry) => entry.eligible)\n\tfor (const declaration of eligible) {\n\t\trequireCaptureUnique(declaration.states, 'states within a declaration', true)\n\t\tconst entries = receipt.registry.filter((entry) => entry.case === declaration.case)\n\t\tif (\n\t\t\t!matchesCaptureMembers(\n\t\t\t\tentries.map((entry) => entry.state),\n\t\t\t\tdeclaration.states,\n\t\t\t) ||\n\t\t\tentries.some(\n\t\t\t\t(entry) => !matchesCaptureSelector(resolveCaptureOwner(entry), declaration.owner),\n\t\t\t)\n\t\t)\n\t\t\tthrow new CaptureError('Registry receipt destination coverage differs from declarations', {\n\t\t\t\tcode: 'EVIDENCE',\n\t\t\t})\n\t}\n\tif (\n\t\treceipt.registry.some(\n\t\t\t(entry) => !eligible.some((declaration) => declaration.case === entry.case),\n\t\t) ||\n\t\tnew Set(receipt.registry.map((entry) => entry.project)).size > 1\n\t)\n\t\tthrow new CaptureError(\n\t\t\t'Registry receipt contains an undeclared output or mixes producing projects',\n\t\t\t{ code: 'EVIDENCE' },\n\t\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAeA,IAAa,sBAAsB,OAAO,OAAO;CAChD;CACA;CACA;CACA;CACA;CACA;AACD,CAAU;;;;;;;;;;;;;AAcV,IAAa,sBAAsB,OAAO,IAAI,iCAAiC;;;;;;;;;;;;;AAc/E,IAAa,4BAA4B,OAAO,OAAO;CACtD;CACA;CACA;CACA;CACA;CACA;AACD,CAAU;;;;;;;;;AAUV,IAAa,yBAAyB;;;;;;;;;AAUtC,IAAa,kBAAkB;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MAAM,OAAO,CAAC,CAAC,CAAC,OAAO,GAE/D,MAAM,IAAI,aACT,8EACA,EAAE,MAAM,WAAW,CACpB;AACF"}
|
|
@@ -98,7 +98,8 @@ var CAPTURE_COMMAND_OPTIONS = Object.freeze({
|
|
|
98
98
|
}),
|
|
99
99
|
case: Object.freeze({ type: "string" }),
|
|
100
100
|
changed: Object.freeze({ type: "string" }),
|
|
101
|
-
plan: Object.freeze({ type: "boolean" })
|
|
101
|
+
plan: Object.freeze({ type: "boolean" }),
|
|
102
|
+
mode: Object.freeze({ type: "string" })
|
|
102
103
|
}),
|
|
103
104
|
capture: Object.freeze({
|
|
104
105
|
config: Object.freeze({ type: "string" }),
|
|
@@ -109,7 +110,8 @@ var CAPTURE_COMMAND_OPTIONS = Object.freeze({
|
|
|
109
110
|
case: Object.freeze({ type: "string" }),
|
|
110
111
|
state: Object.freeze({ type: "string" }),
|
|
111
112
|
changed: Object.freeze({ type: "string" }),
|
|
112
|
-
plan: Object.freeze({ type: "boolean" })
|
|
113
|
+
plan: Object.freeze({ type: "boolean" }),
|
|
114
|
+
mode: Object.freeze({ type: "string" })
|
|
113
115
|
}),
|
|
114
116
|
stale: Object.freeze({
|
|
115
117
|
config: Object.freeze({ type: "string" }),
|
|
@@ -119,7 +121,8 @@ var CAPTURE_COMMAND_OPTIONS = Object.freeze({
|
|
|
119
121
|
}),
|
|
120
122
|
case: Object.freeze({ type: "string" }),
|
|
121
123
|
state: Object.freeze({ type: "string" }),
|
|
122
|
-
portfolio: Object.freeze({ type: "string" })
|
|
124
|
+
portfolio: Object.freeze({ type: "string" }),
|
|
125
|
+
mode: Object.freeze({ type: "string" })
|
|
123
126
|
}),
|
|
124
127
|
preflight: Object.freeze({
|
|
125
128
|
variant: Object.freeze({
|
|
@@ -131,7 +134,8 @@ var CAPTURE_COMMAND_OPTIONS = Object.freeze({
|
|
|
131
134
|
portfolio: Object.freeze({ type: "string" }),
|
|
132
135
|
config: Object.freeze({ type: "string" }),
|
|
133
136
|
journeys: Object.freeze({ type: "string" }),
|
|
134
|
-
checks: Object.freeze({ type: "string" })
|
|
137
|
+
checks: Object.freeze({ type: "string" }),
|
|
138
|
+
mode: Object.freeze({ type: "string" })
|
|
135
139
|
}),
|
|
136
140
|
sheets: Object.freeze({
|
|
137
141
|
variant: Object.freeze({
|
|
@@ -144,6 +148,7 @@ var CAPTURE_COMMAND_OPTIONS = Object.freeze({
|
|
|
144
148
|
config: Object.freeze({ type: "string" }),
|
|
145
149
|
journeys: Object.freeze({ type: "string" }),
|
|
146
150
|
checks: Object.freeze({ type: "string" }),
|
|
151
|
+
mode: Object.freeze({ type: "string" }),
|
|
147
152
|
output: Object.freeze({ type: "string" })
|
|
148
153
|
}),
|
|
149
154
|
registry: Object.freeze({
|
|
@@ -414,13 +419,13 @@ var CAPTURE_DISCOVERY = Object.freeze({
|
|
|
414
419
|
var CAPTURE_USAGE = [
|
|
415
420
|
"Usage: capture <command> [arguments]",
|
|
416
421
|
"Commands:",
|
|
417
|
-
" journey <selector> [--variant <name>]... [--case <full name>] [--config <file>]",
|
|
418
|
-
" journey --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--config <file>]",
|
|
419
|
-
" frames <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--config <file>]",
|
|
420
|
-
" frames --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--state <name>] [--config <file>]",
|
|
421
|
-
" stale <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--portfolio <name>] [--config <file>]",
|
|
422
|
-
" preflight <selector> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--config <file>] [--journeys <directory>] [--checks <module>]",
|
|
423
|
-
" sheets <selector> --output <new directory> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--config <file>] [--journeys <directory>] [--checks <module>]",
|
|
422
|
+
" journey <selector> [--variant <name>]... [--case <full name>] [--mode <name>] [--config <file>]",
|
|
423
|
+
" journey --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--mode <name>] [--config <file>]",
|
|
424
|
+
" frames <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--mode <name>] [--config <file>]",
|
|
425
|
+
" frames --changed <ref> [--plan] [--variant <name>]... [--case <full name>] [--state <name>] [--mode <name>] [--config <file>]",
|
|
426
|
+
" stale <selector> [--variant <name>]... [--case <full name>] [--state <name>] [--portfolio <name>] [--mode <name>] [--config <file>]",
|
|
427
|
+
" preflight <selector> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--mode <name>] [--config <file>] [--journeys <directory>] [--checks <module>]",
|
|
428
|
+
" sheets <selector> --output <new directory> [--variant <name>]... [--state <name>] [--case <full name>] [--portfolio <name>] [--mode <name>] [--config <file>] [--journeys <directory>] [--checks <module>]",
|
|
424
429
|
" registry [--variant <name>]... [--mode <name>] [--config <file>]",
|
|
425
430
|
"--changed takes one Git ref; HEAD selects uncommitted work. It cannot accompany a selector.",
|
|
426
431
|
"--plan requires --changed and prints paths and commands after read-only discovery; no execution child starts.",
|
|
@@ -496,6 +501,7 @@ function renderCaptureCommand(command, parsed, selector, root) {
|
|
|
496
501
|
command === "registry" ? command : CAPTURE_COMMAND_NAMES[command],
|
|
497
502
|
...selector === void 0 ? [] : [selector],
|
|
498
503
|
...parsed.variants.flatMap((variant) => ["--variant", variant]),
|
|
504
|
+
...parsed.mode === void 0 ? [] : ["--mode", parsed.mode],
|
|
499
505
|
...parsed.case === void 0 ? [] : parsed.case.startsWith("-") ? [`--case=${parsed.case}`] : ["--case", parsed.case],
|
|
500
506
|
...parsed.state === void 0 ? [] : ["--state", parsed.state],
|
|
501
507
|
...config.startsWith("-") ? [`--config=${config}`] : ["--config", config]
|
|
@@ -1373,7 +1379,7 @@ function buildCaptureArguments(options) {
|
|
|
1373
1379
|
"run",
|
|
1374
1380
|
"--config",
|
|
1375
1381
|
options.config,
|
|
1376
|
-
...options.mode === void 0 ? [] : ["--mode", options.mode],
|
|
1382
|
+
...options.mode === void 0 ? [] : options.mode.startsWith("-") ? [`--mode=${options.mode}`] : ["--mode", options.mode],
|
|
1377
1383
|
"--configLoader",
|
|
1378
1384
|
"runner",
|
|
1379
1385
|
"--no-cache",
|
|
@@ -1511,6 +1517,7 @@ function readCaptureArguments(argv, command, root, fallback) {
|
|
|
1511
1517
|
const state = "state" in values && typeof values.state === "string" ? values.state : void 0;
|
|
1512
1518
|
if (state !== void 0 && !(0, _src_core.isCaptureSegment)(state)) throw new _src_core.CaptureError(`Invalid state identity; ${describeCaptureFault("--state", state, "a portable nonempty state identity; valid values come from the selected case's state declarations")}`, { code: "USAGE" });
|
|
1513
1519
|
const name = values.case;
|
|
1520
|
+
const mode = values.mode;
|
|
1514
1521
|
if (name !== void 0 && name.trim() === "") throw new _src_core.CaptureError("Empty case name", { code: "USAGE" });
|
|
1515
1522
|
const portfolio = "portfolio" in values && typeof values.portfolio === "string" ? values.portfolio : void 0;
|
|
1516
1523
|
const selector = positional.at(0);
|
|
@@ -1523,6 +1530,7 @@ function readCaptureArguments(argv, command, root, fallback) {
|
|
|
1523
1530
|
...changed === void 0 ? {} : { changed },
|
|
1524
1531
|
...plan ? { plan: true } : {},
|
|
1525
1532
|
config: (0, node_path.resolve)(root, values.config ?? fallback),
|
|
1533
|
+
...mode === void 0 ? {} : { mode },
|
|
1526
1534
|
variants,
|
|
1527
1535
|
...name === void 0 ? {} : { case: name },
|
|
1528
1536
|
...state === void 0 ? {} : { state },
|
|
@@ -1783,6 +1791,7 @@ function readCaptureRequest(options) {
|
|
|
1783
1791
|
if (parsed.version !== 1) throw new _src_core.CaptureError("Journey selection request has invalid version", { code: "HOST" });
|
|
1784
1792
|
if (!(0, _src_core.isCaptureSegment)(parsed.id) || !(0, _src_core.isCaptureSegment)(parsed.stage)) throw new _src_core.CaptureError("Journey selection request has invalid identity", { code: "HOST" });
|
|
1785
1793
|
if (parsed.config !== options.config) throw new _src_core.CaptureError("Journey selection request has invalid config", { code: "HOST" });
|
|
1794
|
+
if (parsed.mode !== void 0 && (typeof parsed.mode !== "string" || parsed.mode.trim() === "")) throw new _src_core.CaptureError("Journey selection request has invalid mode", { code: "HOST" });
|
|
1786
1795
|
const command = parsed.command === "journey" || parsed.command === "capture" ? parsed.command : void 0;
|
|
1787
1796
|
if (parsed.state !== void 0 && (typeof parsed.state !== "string" || parsed.state.trim() === "" || command !== "capture")) throw new _src_core.CaptureError("Journey selection request has invalid state", { code: "HOST" });
|
|
1788
1797
|
const selector = typeof parsed.selector === "string" ? parsed.selector : void 0;
|
|
@@ -1795,6 +1804,7 @@ function readCaptureRequest(options) {
|
|
|
1795
1804
|
config: options.config,
|
|
1796
1805
|
pid: options.ppid,
|
|
1797
1806
|
command,
|
|
1807
|
+
...typeof parsed.mode === "string" ? { mode: parsed.mode } : {},
|
|
1798
1808
|
selector,
|
|
1799
1809
|
...typeof parsed.case === "string" ? { case: parsed.case } : {},
|
|
1800
1810
|
variants,
|
|
@@ -1808,7 +1818,7 @@ function readCaptureRequest(options) {
|
|
|
1808
1818
|
* @remarks
|
|
1809
1819
|
* The first argument is the selector and every flag after it takes one nonempty value, separated
|
|
1810
1820
|
* or in equals form. Only `--variant` repeats. `--output` belongs to sheets; the preflight option
|
|
1811
|
-
* table refuses it before discovery. The wrapper, the journey artifact directory, and the checks module
|
|
1821
|
+
* table refuses it before discovery. `--mode` selects the wrapper's Vitest mode. The wrapper, the journey artifact directory, and the checks module
|
|
1812
1822
|
* resolve against `root`; `defaults` supplies the first two when the command line names neither.
|
|
1813
1823
|
*
|
|
1814
1824
|
* @param argv - The arguments after the entry name
|
|
@@ -1838,10 +1848,12 @@ function readCaptureReaderArguments(argv, root, defaults, command = "sheets") {
|
|
|
1838
1848
|
const portfolio = values.portfolio;
|
|
1839
1849
|
const checks = values.checks;
|
|
1840
1850
|
const output = "output" in values && typeof values.output === "string" ? values.output : void 0;
|
|
1851
|
+
const mode = values.mode;
|
|
1841
1852
|
return {
|
|
1842
1853
|
reader: {
|
|
1843
1854
|
root: (0, node_path.resolve)(root),
|
|
1844
1855
|
config: (0, node_path.resolve)(root, values.config ?? defaults.config),
|
|
1856
|
+
...mode === void 0 ? {} : { mode },
|
|
1845
1857
|
journeys: (0, node_path.resolve)(root, values.journeys ?? defaults.journeys),
|
|
1846
1858
|
selection: {
|
|
1847
1859
|
selector,
|
|
@@ -2003,8 +2015,8 @@ function readCaptureRunning(pid) {
|
|
|
2003
2015
|
* Resolves one entry of a wrapper's project list to the project it declares.
|
|
2004
2016
|
*
|
|
2005
2017
|
* @remarks
|
|
2006
|
-
* A factory entry is called with the serve command and the
|
|
2007
|
-
* promise is awaited. The result is the project as plain data
|
|
2018
|
+
* A factory entry is called with the serve command and the requested mode, or the default test
|
|
2019
|
+
* mode, as Vitest calls it, and a promise is awaited. The result is the project as plain data: the runner reads
|
|
2008
2020
|
* and validates it, so one reader owns every refusal.
|
|
2009
2021
|
*
|
|
2010
2022
|
* @param input - The entry as the wrapper declared it: an inline project, a promise of one, or a factory
|
|
@@ -2015,10 +2027,10 @@ function readCaptureRunning(pid) {
|
|
|
2015
2027
|
* const project = await resolveCaptureWrapperProject(wrapper.test.projects[0])
|
|
2016
2028
|
* ```
|
|
2017
2029
|
*/
|
|
2018
|
-
async function resolveCaptureWrapperProject(input) {
|
|
2030
|
+
async function resolveCaptureWrapperProject(input, mode = "test") {
|
|
2019
2031
|
return (0, _orkestrel_contract.isFunction)(input) ? await input({
|
|
2020
2032
|
command: "serve",
|
|
2021
|
-
mode
|
|
2033
|
+
mode
|
|
2022
2034
|
}) : await input;
|
|
2023
2035
|
}
|
|
2024
2036
|
/**
|
|
@@ -2181,13 +2193,15 @@ async function answerCaptureDiscovery(options) {
|
|
|
2181
2193
|
if (parsed.version !== _src_core.CAPTURE_VERSION) throw new _src_core.CaptureError("Discovery request has invalid version", { code: "HOST" });
|
|
2182
2194
|
if (!(0, _src_core.isCaptureSegment)(parsed.id) || !(0, _src_core.isCaptureSegment)(parsed.nonce)) throw new _src_core.CaptureError("Discovery request has invalid identity", { code: "HOST" });
|
|
2183
2195
|
if (parsed.config !== options.config) throw new _src_core.CaptureError("Discovery request has invalid config", { code: "HOST" });
|
|
2196
|
+
if (parsed.mode !== void 0 && (typeof parsed.mode !== "string" || parsed.mode.trim() === "")) throw new _src_core.CaptureError("Discovery request has invalid mode", { code: "HOST" });
|
|
2184
2197
|
const answer = (0, node_path.resolve)(directory, CAPTURE_RUNS_DIRECTORY, parsed.id, CAPTURE_DISCOVERY.description);
|
|
2185
2198
|
const prior = (0, node_fs.existsSync)(answer) ? (0, _orkestrel_contract.parseJSON)((0, node_fs.readFileSync)(answer, "utf8")) : void 0;
|
|
2186
2199
|
if (prior !== void 0 && !((0, _orkestrel_contract.isRecord)(prior) && prior.pid === process.pid)) throw new _src_core.CaptureError(`Discovery was already answered for this request: ${file}`, {
|
|
2187
2200
|
code: "HOST",
|
|
2188
2201
|
context: { file }
|
|
2189
2202
|
});
|
|
2190
|
-
const
|
|
2203
|
+
const mode = typeof parsed.mode === "string" ? parsed.mode : void 0;
|
|
2204
|
+
const projects = await Promise.all(options.projects.map((input) => resolveCaptureWrapperProject(input, mode)));
|
|
2191
2205
|
writeCaptureDocument(answer, {
|
|
2192
2206
|
version: _src_core.CAPTURE_VERSION,
|
|
2193
2207
|
id: parsed.id,
|
|
@@ -2347,7 +2361,7 @@ var CaptureDiscovery = class {
|
|
|
2347
2361
|
...CAPTURE_DISCOVERY.arguments,
|
|
2348
2362
|
"--config",
|
|
2349
2363
|
(0, node_path.resolve)(root, config),
|
|
2350
|
-
...mode === void 0 ? [] : ["--mode", mode],
|
|
2364
|
+
...mode === void 0 ? [] : mode.startsWith("-") ? [`--mode=${mode}`] : ["--mode", mode],
|
|
2351
2365
|
"--configLoader",
|
|
2352
2366
|
"runner"
|
|
2353
2367
|
];
|
|
@@ -2357,6 +2371,7 @@ var CaptureDiscovery = class {
|
|
|
2357
2371
|
id: invocation.id,
|
|
2358
2372
|
nonce,
|
|
2359
2373
|
config: relative,
|
|
2374
|
+
...mode === void 0 ? {} : { mode },
|
|
2360
2375
|
pid: process.pid,
|
|
2361
2376
|
args
|
|
2362
2377
|
};
|
|
@@ -3909,7 +3924,7 @@ var CapturePreflight = class {
|
|
|
3909
3924
|
}
|
|
3910
3925
|
}
|
|
3911
3926
|
async #load(config, invocation) {
|
|
3912
|
-
const { root, deadline } = this.#options;
|
|
3927
|
+
const { root, deadline, mode } = this.#options;
|
|
3913
3928
|
invocation.prepare();
|
|
3914
3929
|
requireCaptureArgument(root, (0, node_path.resolve)(root, this.#options.journeys), "--journeys");
|
|
3915
3930
|
if (this.#options.checks !== void 0) requireCaptureArgument(root, (0, node_path.resolve)(root, this.#options.checks), "--checks");
|
|
@@ -3917,6 +3932,7 @@ var CapturePreflight = class {
|
|
|
3917
3932
|
root,
|
|
3918
3933
|
config,
|
|
3919
3934
|
invocation,
|
|
3935
|
+
...mode === void 0 ? {} : { mode },
|
|
3920
3936
|
...deadline === void 0 ? {} : { deadline }
|
|
3921
3937
|
}).describe()).projects.map(({ project, viewport }) => {
|
|
3922
3938
|
if (viewport === void 0) throw new _src_core.CaptureError("A reader project declares no viewport geometry", { code: "HOST" });
|
|
@@ -4229,6 +4245,7 @@ var CaptureRegistrar = class {
|
|
|
4229
4245
|
config: resolveCaptureRelative(root, parsed.config),
|
|
4230
4246
|
pid: process.pid,
|
|
4231
4247
|
command: "journey",
|
|
4248
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
4232
4249
|
selector: "all",
|
|
4233
4250
|
variants: [variant],
|
|
4234
4251
|
args
|
|
@@ -4381,6 +4398,7 @@ var CaptureRunner = class {
|
|
|
4381
4398
|
root,
|
|
4382
4399
|
config: parsed.config,
|
|
4383
4400
|
invocation,
|
|
4401
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
4384
4402
|
...this.#options.deadline === void 0 ? {} : { deadline: this.#options.deadline }
|
|
4385
4403
|
}).describe()).projects.map((entry) => entry.project);
|
|
4386
4404
|
if (parsed.selector !== void 0) requireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio);
|
|
@@ -4422,7 +4440,8 @@ var CaptureRunner = class {
|
|
|
4422
4440
|
const shared = plan.changes.filter((change) => change.classification === "shared");
|
|
4423
4441
|
const complete = renderCaptureCommand("journey", {
|
|
4424
4442
|
config: parsed.config,
|
|
4425
|
-
variants: parsed.variants
|
|
4443
|
+
variants: parsed.variants,
|
|
4444
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
4426
4445
|
}, "all", root);
|
|
4427
4446
|
for (const next of commands) this.#stdout(`COMMAND ${next}\n`);
|
|
4428
4447
|
const variants = resolveCaptureVariants(parsed.variants, projects);
|
|
@@ -4556,7 +4575,8 @@ var CaptureRunner = class {
|
|
|
4556
4575
|
...parsed.state === void 0 ? {} : { state: parsed.state },
|
|
4557
4576
|
final: primary.final,
|
|
4558
4577
|
directory: resolveCaptureRelative(root, primary.directory),
|
|
4559
|
-
config: resolveCaptureRelative(root, parsed.config)
|
|
4578
|
+
config: resolveCaptureRelative(root, parsed.config),
|
|
4579
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
4560
4580
|
};
|
|
4561
4581
|
const outcomes = [];
|
|
4562
4582
|
const stages = resolveCaptureStages(variants, primary.first, command);
|
|
@@ -4600,6 +4620,7 @@ var CaptureRunner = class {
|
|
|
4600
4620
|
report,
|
|
4601
4621
|
projects: selected.map((project) => project.name),
|
|
4602
4622
|
filter: plan.filter,
|
|
4623
|
+
...plan.mode === void 0 ? {} : { mode: plan.mode },
|
|
4603
4624
|
...plan.case === void 0 ? {} : { case: plan.case },
|
|
4604
4625
|
...plan.case === void 0 ? {} : { titles: readCaptureTitles(root, (0, node_path.resolve)(root, plan.directory, _src_core.CAPTURE_REGISTRY_FILE)) },
|
|
4605
4626
|
final: plan.final
|
|
@@ -4611,6 +4632,7 @@ var CaptureRunner = class {
|
|
|
4611
4632
|
config: plan.config,
|
|
4612
4633
|
pid: process.pid,
|
|
4613
4634
|
command: plan.command,
|
|
4635
|
+
...plan.mode === void 0 ? {} : { mode: plan.mode },
|
|
4614
4636
|
selector: plan.selector,
|
|
4615
4637
|
...plan.case === void 0 ? {} : { case: plan.case },
|
|
4616
4638
|
...plan.state === void 0 ? {} : { state: plan.state },
|