@orkestrel/capture 0.0.1 → 0.0.2
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 +3 -0
- package/dist/src/core/index.cjs +2 -2
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +1 -1
- package/dist/src/core/index.d.ts +1 -1
- package/dist/src/core/index.js +3 -3
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +35 -31
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +26 -24
- package/dist/src/server/index.d.ts +26 -24
- package/dist/src/server/index.js +35 -31
- package/dist/src/server/index.js.map +1 -1
- package/package.json +14 -14
|
@@ -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, isRecord } 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// The brand holds the error itself, so a transparent proxy over a branded error forwards its\n\t\t// target's identity and fails the comparison in `isCaptureError`.\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 a record 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 || isRecord(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;EAGxE,OAAO,eAAe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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\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;CAA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1131
|
function shrinkCapturePicture(picture, factor, limit) {
|
|
1132
1132
|
const width = Math.max(1, Math.ceil(picture.width / factor));
|
|
1133
1133
|
const height = Math.min(Math.max(1, Math.ceil(picture.height / factor)), limit);
|
|
1134
|
-
const
|
|
1135
|
-
const sums = new Float64Array(width * 3);
|
|
1136
|
-
for (let y = 0; y < height; y += 1) {
|
|
1137
|
-
sums.fill(0);
|
|
1138
|
-
const rows = Math.min(factor, picture.height - y * factor);
|
|
1139
|
-
for (let row = 0; row < rows; row += 1) {
|
|
1140
|
-
let source = (y * factor + row) * picture.width * 3;
|
|
1141
|
-
for (let x = 0; x < width; x += 1) {
|
|
1142
|
-
const columns = Math.min(factor, picture.width - x * factor);
|
|
1143
|
-
let red = 0;
|
|
1144
|
-
let green = 0;
|
|
1145
|
-
let blue = 0;
|
|
1146
|
-
for (let column = 0; column < columns; column += 1) {
|
|
1147
|
-
red += picture.pixels[source] ?? 0;
|
|
1148
|
-
green += picture.pixels[source + 1] ?? 0;
|
|
1149
|
-
blue += picture.pixels[source + 2] ?? 0;
|
|
1150
|
-
source += 3;
|
|
1151
|
-
}
|
|
1152
|
-
const target = x * 3;
|
|
1153
|
-
sums[target] = (sums[target] ?? 0) + red;
|
|
1154
|
-
sums[target + 1] = (sums[target + 1] ?? 0) + green;
|
|
1155
|
-
sums[target + 2] = (sums[target + 2] ?? 0) + blue;
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
for (let x = 0; x < width; x += 1) {
|
|
1159
|
-
const count = rows * Math.min(factor, picture.width - x * factor);
|
|
1160
|
-
for (let channel = 0; channel < 3; channel += 1) pixels[(y * width + x) * 3 + channel] = Math.round((sums[x * 3 + channel] ?? 0) / count);
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1134
|
+
const span = Array.from({ length: Math.ceil(Math.min(factor, Math.max(picture.width, picture.height))) }, (_, index) => index);
|
|
1163
1135
|
return {
|
|
1164
1136
|
width,
|
|
1165
1137
|
height,
|
|
1166
|
-
pixels
|
|
1138
|
+
pixels: Uint8Array.from({ length: width * height * 3 }, (_, index) => {
|
|
1139
|
+
const channel = index % 3;
|
|
1140
|
+
const x = Math.floor(index / 3) % width;
|
|
1141
|
+
const y = Math.floor(index / 3 / width);
|
|
1142
|
+
const rows = Math.min(factor, picture.height - y * factor);
|
|
1143
|
+
const columns = Math.min(factor, picture.width - x * factor);
|
|
1144
|
+
const sum = span.reduce((total, row) => {
|
|
1145
|
+
if (row >= rows) return total;
|
|
1146
|
+
const start = (y * factor + row) * picture.width * 3 + x * Math.ceil(factor) * 3 + channel;
|
|
1147
|
+
return span.reduce((block, column) => column >= columns ? block : block + (picture.pixels[start + column * 3] ?? 0), total);
|
|
1148
|
+
}, 0);
|
|
1149
|
+
return Math.round(sum / (rows * columns));
|
|
1150
|
+
})
|
|
1167
1151
|
};
|
|
1168
1152
|
}
|
|
1169
1153
|
/**
|
|
@@ -4085,6 +4069,8 @@ var CapturePreflight = class {
|
|
|
4085
4069
|
* place, so a registry the engine would refuse never replaces a good one. With `--variant`, the
|
|
4086
4070
|
* existing registry's receipts for the other declared variants are kept. It never widens a scoped
|
|
4087
4071
|
* run into a refresh and refuses while another runner holds a request file in the request directory.
|
|
4072
|
+
* Before any stage, it reads the inherited manifest and lookup journal and refuses an unsupported
|
|
4073
|
+
* schema with the file to inspect and repair.
|
|
4088
4074
|
*
|
|
4089
4075
|
* @example
|
|
4090
4076
|
* ```ts
|
|
@@ -4158,10 +4144,12 @@ var CaptureRegistrar = class {
|
|
|
4158
4144
|
});
|
|
4159
4145
|
const target = `${resolveCaptureRelative(root, primary.directory)}/${_src_core.CAPTURE_REGISTRY_FILE}`;
|
|
4160
4146
|
const candidate = `${target}.${invocation.id}.candidate`;
|
|
4147
|
+
const options = buildCaptureIntegrityOptions(root, primary);
|
|
4161
4148
|
const integrity = new CaptureIntegrity({
|
|
4162
|
-
...
|
|
4149
|
+
...options,
|
|
4163
4150
|
registry: candidate
|
|
4164
4151
|
});
|
|
4152
|
+
this.#inherit(options);
|
|
4165
4153
|
const holders = invocation.holders();
|
|
4166
4154
|
if (holders.length > 0) throw new _src_core.CaptureError(`Another runner holds this workspace (process ${holders.join(", ")}); the registry refresh starts only while no runner is mid-stage`, {
|
|
4167
4155
|
code: "STAGE",
|
|
@@ -4197,6 +4185,22 @@ var CaptureRegistrar = class {
|
|
|
4197
4185
|
})}\n`);
|
|
4198
4186
|
return CAPTURE_EXIT.passed;
|
|
4199
4187
|
}
|
|
4188
|
+
#inherit(options) {
|
|
4189
|
+
for (const [file, guard] of [[options.manifest, _src_core.isCaptureStoredManifest], [options.lookups, _src_core.isCaptureLookupJournal]]) {
|
|
4190
|
+
const path = (0, node_path.resolve)(options.root, file);
|
|
4191
|
+
try {
|
|
4192
|
+
requireCaptureContained(options.root, path);
|
|
4193
|
+
if (!(0, node_fs.existsSync)(path)) continue;
|
|
4194
|
+
if (!guard((0, _orkestrel_contract.parseJSON)((0, node_fs.readFileSync)(path, "utf8")))) throw new _src_core.CaptureError("Invalid inherited evidence schema", { code: "EVIDENCE" });
|
|
4195
|
+
} catch (error) {
|
|
4196
|
+
throw new _src_core.CaptureError(`Cannot refresh the registry with inherited evidence at ${JSON.stringify(file)}: ${(0, _src_core.describeCaptureError)(error)}; inspect and repair this file before retrying`, {
|
|
4197
|
+
code: "EVIDENCE",
|
|
4198
|
+
cause: error,
|
|
4199
|
+
context: { file }
|
|
4200
|
+
});
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
}
|
|
4200
4204
|
async #stage(invocation, parsed, projects, primary, variant) {
|
|
4201
4205
|
const { root } = this.#options;
|
|
4202
4206
|
const project = projects.find((candidate) => candidate.variant === variant);
|