@orkestrel/capture 0.0.0-stage → 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.
@@ -0,0 +1,3953 @@
1
+ import type { CaptureCollectionReceipt } from '@orkestrel/capture';
2
+ import type { CaptureDeclaration } from '@orkestrel/capture';
3
+ import type { CaptureDestination } from '@orkestrel/capture';
4
+ import type { CaptureDigest } from '@orkestrel/capture';
5
+ import { CaptureError } from '@orkestrel/capture';
6
+ import type { CaptureFreshness } from '@orkestrel/capture';
7
+ import type { CaptureLookup } from '@orkestrel/capture';
8
+ import type { CaptureLookupJournal } from '@orkestrel/capture';
9
+ import type { CaptureReceipt } from '@orkestrel/capture';
10
+ import type { CaptureRegistry } from '@orkestrel/capture';
11
+ import type { CaptureRequest } from '@orkestrel/capture';
12
+ import type { CaptureRun } from '@orkestrel/capture';
13
+ import type { CaptureSelection } from '@orkestrel/capture';
14
+ import type { CaptureStamp } from '@orkestrel/capture';
15
+ import type { CaptureStoredManifest } from '@orkestrel/capture';
16
+ import type { CaptureViewport } from '@orkestrel/capture';
17
+ import type { CaptureWarning } from '@orkestrel/capture';
18
+ import type { parseArgs } from 'node:util';
19
+ import type { ParseArgsOptionsConfig } from 'node:util';
20
+ import type { SessionInterface } from '@orkestrel/process';
21
+
22
+ /**
23
+ * Answers the runner's discovery request from the wrapper, before the wrapper does any other work.
24
+ *
25
+ * @remarks
26
+ * The wrapper calls it once, ahead of anything that sets up a browser, initializes an output
27
+ * directory, or collects a test, and returns `buildCaptureDiscoveryConfig()` when it answered. It
28
+ * reads only the request file its parent process wrote and answers `false` when there is none, or
29
+ * when the file is no discovery request, so an execution child falls through to `readCaptureRequest`.
30
+ * A discovery request is accepted only from its own parent with the exact arguments it recorded, the
31
+ * wrapper path it names, and an identity and challenge that are portable segments. The wrapper
32
+ * describes every project from its own declarations and writes one description, atomically, to the
33
+ * invocation directory; a second answer from another process is refused as a replay, while the same
34
+ * process may answer again if Vitest loads its configuration twice.
35
+ *
36
+ * @param options - The parent id, the process arguments, the request directory, the wrapper path, and the wrapper's `test.projects`
37
+ * @returns True once the description is written; false when the request is no discovery request
38
+ * @throws Thrown as a `HOST` capture error for a discovery request that fails any check or a
39
+ * replayed answer. It does not judge the projects: the runner reads and refuses a malformed one.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const answered = await answerCaptureDiscovery({
44
+ * ppid: process.ppid,
45
+ * argv: process.argv.slice(1),
46
+ * config: 'configs/vite.journey.config.ts',
47
+ * projects,
48
+ * })
49
+ * ```
50
+ */
51
+ export declare function answerCaptureDiscovery(options: CaptureDiscoveryOptions): Promise<boolean>;
52
+
53
+ /**
54
+ * Builds the exact Node argument array that spawns one Vitest stage.
55
+ *
56
+ * @remarks
57
+ * Each value is its own array element, so no shell quoting applies and a case name keeps its
58
+ * spaces and quotes. An exact case adds `-t` with the anchored pattern for that case and the
59
+ * final case, so the final case still writes the run record.
60
+ *
61
+ * @param options - The entry, wrapper, report, projects, tag filter, and optional exact case and mode
62
+ * @returns The arguments after the Node executable
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const args = buildCaptureArguments({
67
+ * entry: '/repo/node_modules/vitest/vitest.mjs',
68
+ * config: '/repo/vite.journey.config.ts',
69
+ * report: '/repo/tmp/units/runs/a/journey-selected.json',
70
+ * projects: ['journey:light-390'],
71
+ * filter: 'owner:pages:mail',
72
+ * final: 'closes the run',
73
+ * })
74
+ * args.includes('--bail=1') // true
75
+ * ```
76
+ */
77
+ export declare function buildCaptureArguments(options: CaptureArgumentsOptions): readonly string[];
78
+
79
+ /**
80
+ * Classifies changed paths through accepted patterns and reduces owners by ancestry.
81
+ *
82
+ * @param paths - Git paths, including removed paths that no longer exist
83
+ * @param entries - The authenticated accepted registry destinations
84
+ * @returns Sorted path classifications and sorted minimal owners; shared patterns take precedence
85
+ * @example
86
+ * ```ts
87
+ * buildCaptureChangePlan(['README.md'], []).changes
88
+ * // [{ path: 'README.md', classification: 'outside', owners: [] }]
89
+ * ```
90
+ */
91
+ export declare function buildCaptureChangePlan(paths: readonly string[], entries: readonly CaptureDestination[]): CaptureChangePlan;
92
+
93
+ /**
94
+ * Computes the digest of both pattern declarations and expanded path and hash membership.
95
+ *
96
+ * @param patterns - The supplied native glob patterns
97
+ * @param files - The expanded file hashes
98
+ * @returns A deterministic digest retaining the original evidence populations
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * buildCaptureDigest(['src/**'], { 'src/a.ts': 'f'.repeat(64) }).patterns // ['src/**']
103
+ * ```
104
+ */
105
+ export declare function buildCaptureDigest(patterns: readonly string[], files: Readonly<Record<string, string>>): CaptureDigest;
106
+
107
+ /**
108
+ * Builds the empty Node configuration a wrapper returns once it has answered a discovery request.
109
+ *
110
+ * @remarks
111
+ * It carries no project, no setup file, and no include pattern, so Vitest collects no test, starts
112
+ * no browser, and initializes no output for a discovery child.
113
+ *
114
+ * @returns A fresh configuration object
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * export default (await answerCaptureDiscovery(options)) ? buildCaptureDiscoveryConfig() : config
119
+ * ```
120
+ */
121
+ export declare function buildCaptureDiscoveryConfig(): {
122
+ readonly test: {
123
+ readonly include: string[];
124
+ readonly passWithNoTests: boolean;
125
+ readonly watch: boolean;
126
+ };
127
+ };
128
+
129
+ /**
130
+ * Builds the tag expression that selects an owner population, and its capture tags for frames.
131
+ *
132
+ * @remarks
133
+ * A journey selects `owner:<selector>`. A capture intersects that with the capture tag the
134
+ * selector names, which is its scope and part: the first two segments. The `all` selector unions
135
+ * every declared scope. Colons stay part of a tag name.
136
+ *
137
+ * @param command - The runner command
138
+ * @param selector - The requested owner path or `all`
139
+ * @param selectors - Every owner path the wrapper declares, without the `owner:` prefix
140
+ * @returns The expression for `--tags-filter`
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * buildCaptureFilter('journey', 'pages:mail', ['pages', 'pages:mail']) // 'owner:pages:mail'
145
+ * buildCaptureFilter('capture', 'pages:mail', ['pages', 'pages:mail']) // 'owner:pages:mail && pages:mail'
146
+ * ```
147
+ */
148
+ export declare function buildCaptureFilter(command: CaptureCommand, selector: string, selectors: readonly string[]): string;
149
+
150
+ /**
151
+ * Derives the integrity engine's options from a wrapper project's host declarations.
152
+ *
153
+ * @remarks
154
+ * Without `standalone` the engine reads the project's primary directory and every portfolio root the
155
+ * project authorizes. With one, the engine reads that root alone, keeping its registry, manifest, and
156
+ * lookups beside its own directory.
157
+ *
158
+ * @param root - The absolute workspace path
159
+ * @param project - The wrapper project whose declarations the engine adopts
160
+ * @param standalone - The standalone root to read through, when a selection names one
161
+ * @returns The options the engine is constructed with
162
+ * @throws Thrown as a `HOST` capture error when the directory leaves the repository.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * buildCaptureIntegrityOptions(root, project).manifest // 'tmp/captures/states/manifest.json'
167
+ * ```
168
+ */
169
+ export declare function buildCaptureIntegrityOptions(root: string, project: CaptureProject, standalone?: CapturePortfolioRoot): CaptureIntegrityOptions;
170
+
171
+ /**
172
+ * Stores each distinct lookup input population once in a manifest-bound journal.
173
+ *
174
+ * @param lookups - The expanded passing case evidence to publish
175
+ * @param collections - The independently authenticated collection receipts
176
+ * @param manifest - The predecessor manifest digest, absent before the first capture
177
+ * @returns The journal with content-addressed input maps and ordered lookup references
178
+ *
179
+ * @example
180
+ * ```ts
181
+ * buildCaptureLookupJournal([], []).inputs // {}
182
+ * ```
183
+ */
184
+ export declare function buildCaptureLookupJournal(lookups: readonly CaptureLookup[], collections: readonly CaptureCollectionReceipt[], manifest?: string): CaptureLookupJournal;
185
+
186
+ /**
187
+ * Imports complete receipts only after their actual exits and exact report bytes validate.
188
+ *
189
+ * @param inputs - Verifier-owned reporter bytes, receipt declarations, and process outcomes
190
+ * @returns The registry document to publish through the verifier's owned evidence path
191
+ * @throws Thrown for caps, signals, unsuccessful exits, altered reports, or incomplete coverage.
192
+ * @remarks This pure importer starts no process and changes no retained receipt or manifest.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * const registry = buildCaptureRegistry([{ receipt, report: text, outcome: { code: 0, signal: null }, capped: false }])
197
+ * registry.digest.length // 64
198
+ * ```
199
+ */
200
+ export declare function buildCaptureRegistry(inputs: readonly CaptureReceiptInput[]): CaptureRegistry;
201
+
202
+ /**
203
+ * Builds the refusal a wrapper raises for a request file it cannot accept as its parent's.
204
+ *
205
+ * @param file - The absolute request path, named in the message
206
+ * @param cause - The underlying failure, when there is one
207
+ * @returns A `HOST` capture error naming the file
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * buildCaptureRequestRefusal('/repo/tmp/units/journey-selection-4242.json').message
212
+ * // 'Invalid journey selection request: /repo/tmp/units/journey-selection-4242.json'
213
+ * ```
214
+ */
215
+ export declare function buildCaptureRequestRefusal(file: string, cause?: unknown): CaptureError;
216
+
217
+ /**
218
+ * Names the executable subcommand each runner command answers to.
219
+ *
220
+ * @remarks
221
+ * The frame-placing command is `capture` in the request protocol and `frames` on the command line,
222
+ * because `capture capture` would stutter. The usage text prints the command-line name.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * CAPTURE_COMMAND_NAMES.capture // 'frames'
227
+ * ```
228
+ */
229
+ export declare const CAPTURE_COMMAND_NAMES: Readonly<{
230
+ readonly journey: 'journey';
231
+ readonly capture: 'frames';
232
+ readonly stale: 'stale';
233
+ }>;
234
+
235
+ /**
236
+ * Defines each command's frozen options for Node's standard argument parser.
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * CAPTURE_COMMAND_OPTIONS.journey.variant.multiple // true
241
+ * ```
242
+ */
243
+ export declare const CAPTURE_COMMAND_OPTIONS: Readonly<{
244
+ readonly journey: Readonly<{
245
+ config: Readonly<{
246
+ type: "string";
247
+ }>;
248
+ variant: Readonly<{
249
+ type: "string";
250
+ multiple: true;
251
+ }>;
252
+ case: Readonly<{
253
+ type: "string";
254
+ }>;
255
+ changed: Readonly<{
256
+ type: "string";
257
+ }>;
258
+ plan: Readonly<{
259
+ type: "boolean";
260
+ }>;
261
+ }>;
262
+ readonly capture: Readonly<{
263
+ config: Readonly<{
264
+ type: "string";
265
+ }>;
266
+ variant: Readonly<{
267
+ type: "string";
268
+ multiple: true;
269
+ }>;
270
+ case: Readonly<{
271
+ type: "string";
272
+ }>;
273
+ state: Readonly<{
274
+ type: "string";
275
+ }>;
276
+ changed: Readonly<{
277
+ type: "string";
278
+ }>;
279
+ plan: Readonly<{
280
+ type: "boolean";
281
+ }>;
282
+ }>;
283
+ readonly stale: Readonly<{
284
+ config: Readonly<{
285
+ type: "string";
286
+ }>;
287
+ variant: Readonly<{
288
+ type: "string";
289
+ multiple: true;
290
+ }>;
291
+ case: Readonly<{
292
+ type: "string";
293
+ }>;
294
+ state: Readonly<{
295
+ type: "string";
296
+ }>;
297
+ portfolio: Readonly<{
298
+ type: "string";
299
+ }>;
300
+ }>;
301
+ readonly preflight: Readonly<{
302
+ variant: Readonly<{
303
+ type: "string";
304
+ multiple: true;
305
+ }>;
306
+ state: Readonly<{
307
+ type: "string";
308
+ }>;
309
+ case: Readonly<{
310
+ type: "string";
311
+ }>;
312
+ portfolio: Readonly<{
313
+ type: "string";
314
+ }>;
315
+ config: Readonly<{
316
+ type: "string";
317
+ }>;
318
+ journeys: Readonly<{
319
+ type: "string";
320
+ }>;
321
+ checks: Readonly<{
322
+ type: "string";
323
+ }>;
324
+ }>;
325
+ readonly sheets: Readonly<{
326
+ variant: Readonly<{
327
+ type: "string";
328
+ multiple: true;
329
+ }>;
330
+ state: Readonly<{
331
+ type: "string";
332
+ }>;
333
+ case: Readonly<{
334
+ type: "string";
335
+ }>;
336
+ portfolio: Readonly<{
337
+ type: "string";
338
+ }>;
339
+ config: Readonly<{
340
+ type: "string";
341
+ }>;
342
+ journeys: Readonly<{
343
+ type: "string";
344
+ }>;
345
+ checks: Readonly<{
346
+ type: "string";
347
+ }>;
348
+ output: Readonly<{
349
+ type: "string";
350
+ }>;
351
+ }>;
352
+ readonly registry: Readonly<{
353
+ variant: Readonly<{
354
+ type: "string";
355
+ multiple: true;
356
+ }>;
357
+ config: Readonly<{
358
+ type: "string";
359
+ }>;
360
+ mode: Readonly<{
361
+ type: "string";
362
+ }>;
363
+ }>;
364
+ }>;
365
+
366
+ /**
367
+ * Holds the repository-relative paths the executable falls back to when the command line names none.
368
+ *
369
+ * @remarks
370
+ * `config` is the journey wrapper a scaffold-born browser application carries, `requests` is the
371
+ * one default directory the runner publishes its request file to, and `journeys` is the directory
372
+ * of journey artifacts the readers read. The runner hands the directory it uses to every child in
373
+ * `CAPTURE_REQUESTS`, and `readCaptureRequest` and `answerCaptureDiscovery` read it from there when
374
+ * the wrapper names none, so a wrapper never repeats this value. `--config` replaces the wrapper
375
+ * and `--journeys` the artifacts.
376
+ *
377
+ * @example
378
+ * ```ts
379
+ * CAPTURE_DEFAULTS.config // 'configs/app/vite.journey.config.ts'
380
+ * ```
381
+ */
382
+ export declare const CAPTURE_DEFAULTS: Readonly<{
383
+ readonly config: 'configs/app/vite.journey.config.ts';
384
+ readonly requests: 'tmp/capture';
385
+ readonly journeys: 'tmp/journey';
386
+ }>;
387
+
388
+ /**
389
+ * Holds the discovery exchange's fixed names and bound.
390
+ *
391
+ * @remarks
392
+ * `phase` is the value that marks a request as a discovery request, `description` is the file the
393
+ * wrapper writes inside the invocation directory, `arguments` are the Vitest arguments that list the
394
+ * configuration's test files without collecting a test, `deadline` is the longest, in milliseconds,
395
+ * the discovery child may run.
396
+ *
397
+ * @example
398
+ * ```ts
399
+ * CAPTURE_DISCOVERY.phase // 'discover'
400
+ * ```
401
+ */
402
+ export declare const CAPTURE_DISCOVERY: Readonly<{
403
+ readonly phase: 'discover';
404
+ readonly description: 'description.json';
405
+ readonly arguments: readonly string[];
406
+ readonly deadline: 60000;
407
+ }>;
408
+
409
+ /**
410
+ * Holds the exit status each runner outcome maps to.
411
+ *
412
+ * @remarks `passed` is every stage green with work run, `failed` is a failed stage or an empty
413
+ * workload, and `usage` is a refused command line or selection.
414
+ *
415
+ * @example
416
+ * ```ts
417
+ * CAPTURE_EXIT.usage // 64
418
+ * ```
419
+ */
420
+ export declare const CAPTURE_EXIT: Readonly<{
421
+ readonly passed: 0;
422
+ readonly failed: 1;
423
+ readonly usage: 64;
424
+ }>;
425
+
426
+ /**
427
+ * Names the environment variable that turns frame capture on for a Vitest child.
428
+ *
429
+ * @example
430
+ * ```ts
431
+ * process.env[CAPTURE_FLAG] = CAPTURE_FLAG_VALUE
432
+ * ```
433
+ */
434
+ export declare const CAPTURE_FLAG = "CAPTURE";
435
+
436
+ /**
437
+ * Holds the one value of the capture variable that turns frame capture on.
438
+ *
439
+ * @example
440
+ * ```ts
441
+ * CAPTURE_FLAG_VALUE // '1'
442
+ * ```
443
+ */
444
+ export declare const CAPTURE_FLAG_VALUE = "1";
445
+
446
+ /**
447
+ * Bounds external diagnostic text while retaining the number of omitted characters.
448
+ * @example
449
+ * ```ts
450
+ * CAPTURE_MESSAGE_LIMIT // 1024
451
+ * ```
452
+ */
453
+ export declare const CAPTURE_MESSAGE_LIMIT = 1024;
454
+
455
+ /**
456
+ * Holds the byte count under which an image is too small to be a real frame.
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * bytes.length < CAPTURE_MINIMUM_IMAGE // true for a blank placeholder
461
+ * ```
462
+ */
463
+ export declare const CAPTURE_MINIMUM_IMAGE = 4000;
464
+
465
+ /** Yields between ownership probes in milliseconds so filesystem contention can settle.
466
+ * @example
467
+ * ```ts
468
+ * CAPTURE_OWNER_BACKOFF // 10
469
+ * ```
470
+ */
471
+ export declare const CAPTURE_OWNER_BACKOFF = 10;
472
+
473
+ /**
474
+ * Names the exclusive workspace invocation marker.
475
+ * @example
476
+ * ```ts
477
+ * CAPTURE_OWNER_FILE // '.capture-owner'
478
+ * ```
479
+ */
480
+ export declare const CAPTURE_OWNER_FILE = ".capture-owner";
481
+
482
+ /**
483
+ * Names the tag prefix that marks a case's owner path and each ancestor of it.
484
+ *
485
+ * @example
486
+ * ```ts
487
+ * `${CAPTURE_OWNER_PREFIX}pages:mail` // 'owner:pages:mail'
488
+ * ```
489
+ */
490
+ export declare const CAPTURE_OWNER_PREFIX = "owner:";
491
+
492
+ /** Bounds a synchronous ownership retry sequence in milliseconds, including host contention.
493
+ * @example
494
+ * ```ts
495
+ * CAPTURE_OWNER_TIMEOUT // 1000
496
+ * ```
497
+ */
498
+ export declare const CAPTURE_OWNER_TIMEOUT = 1000;
499
+
500
+ /**
501
+ * Bounds decoded image memory, row metadata, and PNG input bytes independently of untrusted headers.
502
+ *
503
+ * @remarks The pixel budget admits the fleet's 2880 × 6000 and 1170 × 15000 Chromium full-page
504
+ * frames with 19.5% margin over 17,550,000 pixels. The byte budget adds 20% to the largest RGBA
505
+ * scanlines for deflate overhead, chunk framing, and metadata, before any read or compressed copy.
506
+ * A valid 1 × 1 PNG padded to the derived byte boundary peaked at 171 MiB process RSS.
507
+ * Isolated Windows Node runs on 2026-10-28 measured the fixture peaks noted beside each bound;
508
+ * these measurements are not a universal process RSS ceiling.
509
+ * @example
510
+ * ```ts
511
+ * CAPTURE_PNG_LIMITS.pixels // 20971520
512
+ * ```
513
+ */
514
+ export declare const CAPTURE_PNG_LIMITS: Readonly<{
515
+ readonly pixels: number;
516
+ readonly side: 131072;
517
+ readonly bytes: number;
518
+ }>;
519
+
520
+ /**
521
+ * Caps each refusal population so hostile records cannot flood a terminal or agent context.
522
+ * @example
523
+ * ```ts
524
+ * CAPTURE_REFUSAL_LIMIT // 16
525
+ * ```
526
+ */
527
+ export declare const CAPTURE_REFUSAL_LIMIT = 16;
528
+
529
+ /**
530
+ * Names the first word of the line the registry refresh prints, followed by its JSON summary.
531
+ *
532
+ * @example
533
+ * ```ts
534
+ * `${CAPTURE_REGISTRY_LINE} ${JSON.stringify(summary)}\n`
535
+ * ```
536
+ */
537
+ export declare const CAPTURE_REGISTRY_LINE = "REGISTRY";
538
+
539
+ /**
540
+ * Names the stage each producing variant's complete journey runs in, ahead of the variant's name.
541
+ *
542
+ * @example
543
+ * ```ts
544
+ * `${CAPTURE_REGISTRY_STAGE}-light-390` // 'registry-light-390'
545
+ * ```
546
+ */
547
+ export declare const CAPTURE_REGISTRY_STAGE = "registry";
548
+
549
+ /**
550
+ * Names the first word of the line a reader prints, followed by its JSON report.
551
+ *
552
+ * @example
553
+ * ```ts
554
+ * `${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify(report)}\n`
555
+ * ```
556
+ */
557
+ export declare const CAPTURE_REPORT_LINES: Readonly<{
558
+ readonly preflight: 'READER';
559
+ readonly sheets: 'SHEETS';
560
+ }>;
561
+
562
+ /**
563
+ * Names the environment variable that carries the absolute request directory to a Vitest child.
564
+ *
565
+ * @remarks
566
+ * The runner sets it on every child it spawns, the discovery child included. A wrapper that names no
567
+ * request directory reads it, so the runner and the wrapper agree without a repeated constant.
568
+ *
569
+ * @example
570
+ * ```ts
571
+ * process.env[CAPTURE_REQUESTS_FLAG] // '/repo/tmp/capture' inside a runner's child
572
+ * ```
573
+ */
574
+ export declare const CAPTURE_REQUESTS_FLAG = "CAPTURE_REQUESTS";
575
+
576
+ /**
577
+ * Names the directory beneath a portfolio or request directory that holds one invocation's records.
578
+ *
579
+ * @example
580
+ * ```ts
581
+ * `tmp/captures/states/${CAPTURE_RUNS_DIRECTORY}/a/narrow/light-390.json`
582
+ * ```
583
+ */
584
+ export declare const CAPTURE_RUNS_DIRECTORY = "runs";
585
+
586
+ /**
587
+ * Holds the contact-sheet geometry: how wide a cell shrinks toward, how tall it may grow, the mark
588
+ * that stands in for an unreadable image, the gap between neighbors, and how many cells, rows, and
589
+ * pairs a row and a sheet hold.
590
+ *
591
+ * @example
592
+ * ```ts
593
+ * CAPTURE_SHEET.cell // 320
594
+ * ```
595
+ */
596
+ export declare const CAPTURE_SHEET: Readonly<{
597
+ readonly cell: 320;
598
+ readonly limit: 400;
599
+ readonly mark: Readonly<{
600
+ width: 160;
601
+ height: 20;
602
+ present: 220;
603
+ absent: 20;
604
+ }>;
605
+ readonly gap: 12;
606
+ readonly pairs: 2;
607
+ readonly rows: 4;
608
+ }>;
609
+
610
+ /**
611
+ * Names the contact-sheet files: the sheet prefix and digits, and the two index documents.
612
+ *
613
+ * @example
614
+ * ```ts
615
+ * `${CAPTURE_SHEET_FILES.prefix}001.png` // 'sheet-001.png'
616
+ * ```
617
+ */
618
+ export declare const CAPTURE_SHEET_FILES: Readonly<{
619
+ readonly prefix: 'sheet-';
620
+ readonly digits: 3;
621
+ readonly index: 'index.json';
622
+ readonly notes: 'index.md';
623
+ }>;
624
+
625
+ /**
626
+ * Names the selected journey stage and the narrow and remaining frame stages.
627
+ *
628
+ * @example
629
+ * ```ts
630
+ * CAPTURE_STAGES.first // 'narrow'
631
+ * ```
632
+ */
633
+ export declare const CAPTURE_STAGES: Readonly<{
634
+ readonly selected: 'selected';
635
+ readonly first: 'narrow';
636
+ readonly rest: 'rest';
637
+ }>;
638
+
639
+ /**
640
+ * Names the executable's subcommands in the order its usage text lists them.
641
+ *
642
+ * @remarks
643
+ * `frames` runs the `capture` request command, so `capture capture` never stutters. The other
644
+ * names are their own commands.
645
+ *
646
+ * @example
647
+ * ```ts
648
+ * CAPTURE_SUBCOMMANDS.includes('registry') // true
649
+ * ```
650
+ */
651
+ export declare const CAPTURE_SUBCOMMANDS: readonly string[];
652
+
653
+ /** Names the create-only child record beneath an invocation's run directory.
654
+ * @example
655
+ * ```ts
656
+ * CAPTURE_SURVIVORS_FILE // 'survivors.json'
657
+ * ```
658
+ */
659
+ export declare const CAPTURE_SURVIVORS_FILE = "survivors.json";
660
+
661
+ /**
662
+ * Lists the words a tag name can never be, because a tag filter reads them as operators.
663
+ *
664
+ * @example
665
+ * ```ts
666
+ * CAPTURE_TAG_OPERATORS.includes('and') // true
667
+ * ```
668
+ */
669
+ export declare const CAPTURE_TAG_OPERATORS: readonly string[];
670
+
671
+ /**
672
+ * Holds the usage text the executable prints when it is given no subcommand or an unknown one.
673
+ *
674
+ * @example
675
+ * ```ts
676
+ * CAPTURE_USAGE.split('\n')[0] // 'Usage: capture <command> [arguments]'
677
+ * ```
678
+ */
679
+ export declare const CAPTURE_USAGE: string;
680
+
681
+ /**
682
+ * Names the repository-relative path of the Vitest entry the runner spawns through Node.
683
+ *
684
+ * @example
685
+ * ```ts
686
+ * resolve(root, CAPTURE_VITEST_ENTRY)
687
+ * ```
688
+ */
689
+ export declare const CAPTURE_VITEST_ENTRY = "node_modules/vitest/vitest.mjs";
690
+
691
+ /**
692
+ * Configures the Vitest argument list one stage spawns with.
693
+ *
694
+ * @remarks
695
+ * `entry` is the absolute Vitest entry and `config` the absolute wrapper path. `report` is the
696
+ * absolute JSON reporter path and `projects` the Vitest project labels the stage runs. `filter`
697
+ * is the tag expression. An exact `case` adds the anchored name pattern for that case and the
698
+ * `final` case, so the final case still writes the run record. A `mode` adds Vitest's `--mode`
699
+ * flag, which the registry command forwards so a wrapper can select another registry.
700
+ *
701
+ * @example
702
+ * ```ts
703
+ * const options: CaptureArgumentsOptions = {
704
+ * entry: '/repo/node_modules/vitest/vitest.mjs',
705
+ * config: '/repo/configs/vite.journey.config.ts',
706
+ * report: '/repo/tmp/units/runs/a/journey-selected.json',
707
+ * projects: ['journey:light-390'],
708
+ * filter: 'owner:pages:mail',
709
+ * final: 'closes the run',
710
+ * }
711
+ * ```
712
+ */
713
+ export declare interface CaptureArgumentsOptions {
714
+ readonly entry: string;
715
+ readonly config: string;
716
+ readonly report: string;
717
+ readonly projects: readonly string[];
718
+ readonly filter: string;
719
+ readonly case?: string;
720
+ readonly final: string;
721
+ readonly mode?: string;
722
+ /** Original reporter title segments keyed by its space-joined full name. */
723
+ readonly titles?: Readonly<Record<string, readonly string[]>>;
724
+ }
725
+
726
+ /**
727
+ * Carries a judged run record and the verified text of the journey artifact it names.
728
+ *
729
+ * @example
730
+ * ```ts
731
+ * const result: CaptureArtifactResult = { record, run, file, text }
732
+ * ```
733
+ */
734
+ export declare interface CaptureArtifactResult {
735
+ readonly record: string;
736
+ readonly run: CaptureRun;
737
+ readonly file: string;
738
+ readonly text: string;
739
+ }
740
+
741
+ /**
742
+ * Classifies one changed Git path against accepted source attribution.
743
+ *
744
+ * @remarks Shared and test patterns take precedence over ownership; shared owners name every destination owner.
745
+ * @example
746
+ * ```ts
747
+ * const change: CaptureChange = { path: 'src/mail/view.ts', classification: 'own', owners: ['pages:mail'] }
748
+ * ```
749
+ */
750
+ export declare interface CaptureChange {
751
+ readonly path: string;
752
+ readonly classification: 'own' | 'shared' | 'outside';
753
+ readonly owners: readonly string[];
754
+ }
755
+
756
+ /**
757
+ * Holds changed paths and the stable owner selection reduced by ancestry.
758
+ *
759
+ * @example
760
+ * ```ts
761
+ * const plan: CaptureChangePlan = { changes: [], owners: [] }
762
+ * ```
763
+ */
764
+ export declare interface CaptureChangePlan {
765
+ readonly changes: readonly CaptureChange[];
766
+ readonly owners: readonly string[];
767
+ }
768
+
769
+ /**
770
+ * Carries one judged frame to a host check: its destination, its decoded pixels, and its artifact.
771
+ *
772
+ * @remarks
773
+ * `picture` is `undefined` when the frame's image could not be read, and `artifact` is `undefined`
774
+ * when no verified journey artifact covers the frame. A check that needs either decides what an
775
+ * absent one means; the reader already reports an unreadable image and an uncovered record.
776
+ *
777
+ * @example
778
+ * ```ts
779
+ * const frame: CaptureCheckFrame = { entry, picture, artifact: undefined }
780
+ * ```
781
+ */
782
+ export declare interface CaptureCheckFrame {
783
+ readonly entry: CaptureDestination;
784
+ readonly picture: CapturePicture | undefined;
785
+ readonly artifact: CaptureArtifactResult | undefined;
786
+ }
787
+
788
+ /**
789
+ * Reads one judged frame against a host rule and returns the issues it finds, none when it passes.
790
+ *
791
+ * @example
792
+ * ```ts
793
+ * const check: CaptureCheckHandler = (frame) => (frame.picture.width < 100 ? ['frame is too narrow'] : [])
794
+ * ```
795
+ */
796
+ export declare type CaptureCheckHandler = (frame: CaptureCheckFrame) => readonly string[];
797
+
798
+ /**
799
+ * Selects required output pairs and attributable extras for a freshness reading.
800
+ *
801
+ * @remarks
802
+ * `variants` names output variants, including auxiliary outputs when explicitly selected.
803
+ * `portfolio`, when supplied, restricts the instance's authorized portfolio population. Empty or
804
+ * unknown selectors, variants, portfolios, cases, and states refuse. A scoped reading includes
805
+ * only selected required pairs and attributable extras, and a whole-primary-portfolio reading
806
+ * also reports legacy flat PNGs as orphans.
807
+ *
808
+ * @example
809
+ * ```ts
810
+ * const options: CaptureCheckOptions = { selector: 'pages:mail', variants: ['light-390'] }
811
+ * ```
812
+ */
813
+ export declare interface CaptureCheckOptions extends CaptureSelection {
814
+ readonly variants: readonly string[];
815
+ readonly portfolio?: string;
816
+ }
817
+
818
+ /**
819
+ * Reports the exact judged population, every mismatch reason, and conservative test warnings.
820
+ *
821
+ * @remarks
822
+ * `required` supplies canonical selected paths to preflight and contact-sheet consumers.
823
+ * `entries` includes physical extras and uses duplicate, orphan, missing, unstamped,
824
+ * stale-shared, stale-own, current precedence. Changed test inputs produce warnings and
825
+ * invalidate dependent lookups without changing a frame's pixel classification. `duration` is the
826
+ * measured `performance.now` wall in milliseconds for this selection. The executable derives exit
827
+ * 1 from any noncurrent entry, exit 0 otherwise, and exit 64 from invalid usage or schema.
828
+ * Missing required registry evidence never produces success.
829
+ *
830
+ * @example
831
+ * ```ts
832
+ * const result = await integrity.check({ selector: 'pages:mail' })
833
+ * result.entries.every((entry) => entry.status === 'current')
834
+ * ```
835
+ */
836
+ export declare interface CaptureCheckResult {
837
+ readonly required: readonly CaptureDestination[];
838
+ readonly entries: readonly CaptureFreshness[];
839
+ readonly warnings: readonly CaptureWarning[];
840
+ readonly duration: number;
841
+ }
842
+
843
+ /**
844
+ * Terminates one supervised child and reports whether its exit was confirmed.
845
+ * @example
846
+ * ```ts
847
+ * const terminate: CaptureChildTerminationHandler = (child) => child.stop()
848
+ * ```
849
+ */
850
+ export declare type CaptureChildTerminationHandler = (child: SessionInterface) => Promise<boolean>;
851
+
852
+ /**
853
+ * Dispatches capture commands and maps usage and evidence refusals to their exit codes.
854
+ *
855
+ * @remarks
856
+ * The executable's whole behaviour: it reads the subcommand, hands the rest of the command line to
857
+ * the runner, the registry refresh, the preflight, or the contact sheets, and turns a refused
858
+ * usage into exit 64 and any other capture refusal into exit 1, writing the refusal to its error
859
+ * writer. An error that is not a capture refusal propagates.
860
+ *
861
+ * @example
862
+ * ```ts
863
+ * const exit = await new CaptureCLI().execute(['journey', 'pages:mail'])
864
+ * ```
865
+ */
866
+ export declare class CaptureCLI implements CaptureCLIInterface {
867
+ #private;
868
+ /** Creates the executable with the working directory and process writers as defaults. */
869
+ constructor(options?: CaptureCLIOptions);
870
+ /**
871
+ * Executes one command line and returns its exit code after every child has settled.
872
+ *
873
+ * @param args - The arguments following the executable name
874
+ * @returns 0 for passed work, 1 for failed evidence, or 64 for refused usage
875
+ * @example
876
+ * ```ts
877
+ * await new CaptureCLI().execute([]) // 64, with usage written to stderr
878
+ * ```
879
+ */
880
+ execute(args: readonly string[]): Promise<number>;
881
+ }
882
+
883
+ /**
884
+ * Runs capture command lines through injected output writers.
885
+ *
886
+ * @example
887
+ * ```ts
888
+ * const cli: CaptureCLIInterface = createCaptureCLI()
889
+ * const exit = await cli.execute(['journey', 'pages:mail'])
890
+ * ```
891
+ */
892
+ export declare interface CaptureCLIInterface {
893
+ /** Returns 0 for passed work, 1 for failed evidence, or 64 for refused usage. */
894
+ execute(argv: readonly string[]): Promise<number>;
895
+ }
896
+
897
+ /**
898
+ * Configures the executable's workspace and its report and diagnostic writers.
899
+ *
900
+ * @remarks
901
+ * `root` defaults to the working directory; `stdout` and `stderr` default to the process streams.
902
+ *
903
+ * @example
904
+ * ```ts
905
+ * const options: CaptureCLIOptions = { root: process.cwd(), stdout: (text) => process.stdout.write(text) }
906
+ * ```
907
+ */
908
+ export declare interface CaptureCLIOptions {
909
+ readonly root?: string;
910
+ readonly stdout?: CaptureWriteHandler;
911
+ readonly stderr?: CaptureWriteHandler;
912
+ }
913
+
914
+ /**
915
+ * Carries the authenticated external record beside its collection receipt.
916
+ *
917
+ * @example
918
+ * ```ts
919
+ * const evidence: CaptureCollectionEvidence = { file: snapshot, run, receipt }
920
+ * ```
921
+ */
922
+ export declare interface CaptureCollectionEvidence extends CaptureRunEvidence {
923
+ readonly receipt: CaptureCollectionReceipt;
924
+ }
925
+
926
+ /**
927
+ * Names one command the runner executes: a journey, a frame capture, or a stale reading.
928
+ *
929
+ * @example
930
+ * ```ts
931
+ * const command: CaptureCommand = 'stale'
932
+ * ```
933
+ */
934
+ export declare type CaptureCommand = CaptureRequest['command'] | 'stale';
935
+
936
+ /**
937
+ * Records one selected image's real bytes, geometry, and canonical destination.
938
+ *
939
+ * @example
940
+ * ```ts
941
+ * const result: CaptureDecodedImage = { entry, picture, digest, size: 2048 }
942
+ * ```
943
+ */
944
+ export declare interface CaptureDecodedImage {
945
+ readonly entry: CaptureDestination;
946
+ readonly picture: CapturePicture;
947
+ readonly digest: string;
948
+ readonly size: number;
949
+ }
950
+
951
+ /**
952
+ * Names what a description must echo for the runner to accept it.
953
+ *
954
+ * @remarks
955
+ * `id`, `nonce`, and `config` are the request's own. `parent` is the runner's process id and `pid`
956
+ * the discovery child's, which the runner read from the spawn.
957
+ *
958
+ * @example
959
+ * ```ts
960
+ * const expected: CaptureDescriptionExpectation = {
961
+ * id: 'run-1',
962
+ * nonce: 'a1b2',
963
+ * config: 'configs/vite.journey.config.ts',
964
+ * parent: process.pid,
965
+ * pid: 4343,
966
+ * }
967
+ * ```
968
+ */
969
+ export declare interface CaptureDescriptionExpectation {
970
+ readonly id: string;
971
+ readonly nonce: string;
972
+ readonly config: string;
973
+ readonly parent: number;
974
+ readonly pid: number | undefined;
975
+ }
976
+
977
+ /**
978
+ * Carries one physical-directory ancestry while enumerating logical portfolio paths.
979
+ *
980
+ * @example
981
+ * ```ts
982
+ * const result: CaptureDirectoryResult = { directory: 'tmp/captures/states/pages', ancestors: [] }
983
+ * ```
984
+ */
985
+ export declare interface CaptureDirectoryResult {
986
+ readonly directory: string;
987
+ readonly ancestors: readonly string[];
988
+ }
989
+
990
+ /**
991
+ * Reads a consumer's wrapper by running the consumer's installed Vitest in discovery mode.
992
+ *
993
+ * @remarks
994
+ * The runner never loads the wrapper itself, so it imports neither Vite nor Vitest. It publishes an
995
+ * atomic request with the `discover` phase, spawns the consumer's own Vitest entry through Node as
996
+ * `list --filesOnly --config <wrapper> --configLoader runner`, and reads back the description the
997
+ * wrapper writes when it calls `answerCaptureDiscovery`. The child is bounded by a deadline and
998
+ * recorded by the invocation, so an interrupt ends it with the rest of its tree. The description is
999
+ * accepted only after the child exited zero and every echo in it matches this exchange: the
1000
+ * invocation, the challenge, the wrapper, this process as the wrapper's parent, and the spawned
1001
+ * child as its writer. A wrapper that never answers, answers another exchange, or answers twice
1002
+ * from different processes is refused.
1003
+ *
1004
+ * @example
1005
+ * ```ts
1006
+ * const discovery = new CaptureDiscovery({ root: process.cwd(), config, invocation })
1007
+ * const { projects } = await discovery.describe()
1008
+ * ```
1009
+ */
1010
+ export declare class CaptureDiscovery implements CaptureDiscoveryInterface {
1011
+ #private;
1012
+ /**
1013
+ * Binds the workspace, the wrapper, and the invocation that owns the child.
1014
+ *
1015
+ * @param options - The workspace, the absolute wrapper path, the invocation, and the optional mode and deadline
1016
+ */
1017
+ constructor(options: CaptureDiscoveryRunOptions);
1018
+ describe(): Promise<CaptureHostDescription>;
1019
+ }
1020
+
1021
+ /**
1022
+ * Reads a consumer's wrapper by running its installed Vitest in discovery mode.
1023
+ *
1024
+ * @example
1025
+ * ```ts
1026
+ * const discovery: CaptureDiscoveryInterface = createCaptureDiscovery(options)
1027
+ * ```
1028
+ */
1029
+ export declare interface CaptureDiscoveryInterface {
1030
+ /**
1031
+ * Publishes the discovery request, runs the wrapper's Vitest as a bounded child, and reads back its description.
1032
+ *
1033
+ * @returns The validated host description, accepted only after the exchange and the child's exit both succeeded
1034
+ * @throws Thrown as a `USAGE` capture error for a wrapper outside the workspace, and as a `HOST`
1035
+ * capture error for a missing Vitest, a failed or expired child, and a missing, replayed,
1036
+ * mismatched, or malformed description. Interruption and lost child observation throw `STAGE`.
1037
+ *
1038
+ * @example
1039
+ * ```ts
1040
+ * const { projects } = await discovery.describe()
1041
+ * ```
1042
+ */
1043
+ describe(): Promise<CaptureHostDescription>;
1044
+ }
1045
+
1046
+ /**
1047
+ * Configures how a wrapper answers the runner's discovery request.
1048
+ *
1049
+ * @remarks
1050
+ * `ppid`, `argv`, `directory`, and `config` are the ones `CaptureRequestOptions` names. `projects`
1051
+ * is the wrapper's own `test.projects` list, each entry an inline project, a promise of one, or a
1052
+ * factory, which the answer resolves the way Vitest does.
1053
+ *
1054
+ * @example
1055
+ * ```ts
1056
+ * const options: CaptureDiscoveryOptions = {
1057
+ * ppid: process.ppid,
1058
+ * argv: process.argv.slice(1),
1059
+ * config: 'configs/vite.journey.config.ts',
1060
+ * projects,
1061
+ * }
1062
+ * ```
1063
+ */
1064
+ export declare interface CaptureDiscoveryOptions {
1065
+ readonly ppid: number;
1066
+ readonly argv: readonly string[];
1067
+ readonly directory?: string;
1068
+ readonly config: string;
1069
+ readonly projects: readonly unknown[];
1070
+ }
1071
+
1072
+ /**
1073
+ * Carries the request the runner publishes for the discovery child that reads its wrapper.
1074
+ *
1075
+ * @remarks
1076
+ * `phase` is always `discover`, which is what tells a wrapper this is no execution request. `nonce`
1077
+ * is the challenge the wrapper must echo in its answer, `pid` the runner's process id, `config` the
1078
+ * repository-relative wrapper path, and `args` the exact arguments the discovery child was spawned
1079
+ * with. The file has the name and location of an execution request, so one lease covers both.
1080
+ *
1081
+ * @example
1082
+ * ```ts
1083
+ * const request: CaptureDiscoveryRequest = {
1084
+ * version: 1,
1085
+ * phase: 'discover',
1086
+ * id: 'run-1',
1087
+ * nonce: 'a1b2',
1088
+ * config: 'configs/vite.journey.config.ts',
1089
+ * pid: 4242,
1090
+ * args: ['/repo/node_modules/vitest/vitest.mjs', 'list', '--filesOnly'],
1091
+ * }
1092
+ * ```
1093
+ */
1094
+ export declare interface CaptureDiscoveryRequest {
1095
+ readonly version: 1;
1096
+ readonly phase: 'discover';
1097
+ readonly id: string;
1098
+ readonly nonce: string;
1099
+ readonly config: string;
1100
+ readonly pid: number;
1101
+ readonly args: readonly string[];
1102
+ }
1103
+
1104
+ /**
1105
+ * Configures one discovery: the workspace, the wrapper, the invocation that owns the child, and its bounds.
1106
+ *
1107
+ * @remarks
1108
+ * `root` is the absolute workspace path and `config` the absolute wrapper path. `invocation` owns
1109
+ * the request file, the child, and its interruption. `mode` is Vitest's `--mode` value when the
1110
+ * command forwards one. `deadline` bounds the child in milliseconds; default:
1111
+ * `CAPTURE_DISCOVERY.deadline`.
1112
+ *
1113
+ * @example
1114
+ * ```ts
1115
+ * const options: CaptureDiscoveryRunOptions = { root: process.cwd(), config, invocation }
1116
+ * ```
1117
+ */
1118
+ export declare interface CaptureDiscoveryRunOptions {
1119
+ readonly root: string;
1120
+ readonly config: string;
1121
+ readonly invocation: CaptureInvocationInterface;
1122
+ readonly mode?: string;
1123
+ readonly deadline?: number;
1124
+ }
1125
+
1126
+ /**
1127
+ * Carries accepted registry anchors and separately persisted passing run evidence.
1128
+ *
1129
+ * @example
1130
+ * ```ts
1131
+ * const evidence: CaptureEvidence = { registry, collections: [], lookups: [], runs: [] }
1132
+ * ```
1133
+ */
1134
+ export declare interface CaptureEvidence {
1135
+ readonly registry: CaptureRegistry;
1136
+ readonly collections: readonly CaptureCollectionReceipt[];
1137
+ readonly manifest?: CaptureStoredManifest;
1138
+ readonly lookups: readonly CaptureLookup[];
1139
+ readonly runs: readonly CaptureRunEvidence[];
1140
+ }
1141
+
1142
+ /**
1143
+ * Executes the runner's child after the engine captures its input snapshot.
1144
+ *
1145
+ * @returns The real child close outcome after its output streams close.
1146
+ * @remarks
1147
+ * The runner retains argv, environment, request-file, log, process, and interruption ownership.
1148
+ * This callback starts no alternate runner and is invoked at most once. Throwing, interruption,
1149
+ * a signal, or a nonzero exit prevents any evidence commit.
1150
+ *
1151
+ * @example
1152
+ * ```ts
1153
+ * const execute: CaptureExecutionHandler = async () => ({ code: 0, signal: null })
1154
+ * ```
1155
+ */
1156
+ export declare type CaptureExecutionHandler = () => Promise<CaptureExecutionResult>;
1157
+
1158
+ /**
1159
+ * Carries the supervised child outcome without treating a signal as a successful exit.
1160
+ *
1161
+ * @remarks
1162
+ * The null values mirror the native child outcome. `signal` carries the fleet's signal string.
1163
+ * `pid` is the id of the child the runner spawned, when it spawned one, and `expired` is present
1164
+ * and `true` only when the runner ended
1165
+ * the child because its deadline passed. Observation cutoffs and writer failures throw instead of
1166
+ * returning an outcome that could authorize evidence.
1167
+ *
1168
+ * @example
1169
+ * ```ts
1170
+ * const result: CaptureExecutionResult = { code: 0, signal: null }
1171
+ * ```
1172
+ */
1173
+ export declare interface CaptureExecutionResult {
1174
+ readonly code: number | null;
1175
+ readonly signal: string | null;
1176
+ readonly pid?: number;
1177
+ readonly expired?: boolean;
1178
+ }
1179
+
1180
+ /**
1181
+ * Records one physical file's bytes and native modification readings at a stage boundary.
1182
+ *
1183
+ * @remarks
1184
+ * `file` is repository-relative and `changed` is the native ctime in milliseconds. Missing files
1185
+ * have no row, and duplicate or case-colliding paths refuse before indexing. These readings
1186
+ * accompany execution identity and record validation; they do not independently authorize a
1187
+ * frame stamp.
1188
+ *
1189
+ * @example
1190
+ * ```ts
1191
+ * const snapshot: CaptureFileSnapshot = {
1192
+ * file: 'tmp/captures/states/pages/mail--inbox.png',
1193
+ * image: { digest, size: 2048, modified: 1730000000000 },
1194
+ * changed: 1730000000000,
1195
+ * }
1196
+ * ```
1197
+ */
1198
+ export declare interface CaptureFileSnapshot {
1199
+ readonly file: string;
1200
+ readonly image: CaptureStamp['image'];
1201
+ readonly changed: number;
1202
+ }
1203
+
1204
+ /**
1205
+ * Digests the exact bytes of one file reading and returns the lowercase hexadecimal digest.
1206
+ *
1207
+ * @example
1208
+ * ```ts
1209
+ * const hash: CaptureHashHandler = (bytes) => computeCaptureHash(bytes)
1210
+ * ```
1211
+ */
1212
+ export declare type CaptureHashHandler = (bytes: Uint8Array) => string;
1213
+
1214
+ /**
1215
+ * Carries the description a wrapper writes back to the runner that discovered it.
1216
+ *
1217
+ * @remarks
1218
+ * `id`, `nonce`, and `config` echo the request. `parent` is the runner's process id the wrapper read
1219
+ * as its own parent and `pid` the wrapper process's own id, so the runner can tie the answer to the
1220
+ * child it spawned. `projects` lists one entry per wrapper project in declaration order.
1221
+ *
1222
+ * @example
1223
+ * ```ts
1224
+ * const description: CaptureHostDescription = {
1225
+ * version: 1,
1226
+ * id: 'run-1',
1227
+ * nonce: 'a1b2',
1228
+ * config: 'configs/vite.journey.config.ts',
1229
+ * parent: 4242,
1230
+ * pid: 4343,
1231
+ * projects: [{ project }],
1232
+ * }
1233
+ * ```
1234
+ */
1235
+ export declare interface CaptureHostDescription {
1236
+ readonly version: 1;
1237
+ readonly id: string;
1238
+ readonly nonce: string;
1239
+ readonly config: string;
1240
+ readonly parent: number;
1241
+ readonly pid: number;
1242
+ readonly projects: readonly CaptureHostEntry[];
1243
+ }
1244
+
1245
+ /**
1246
+ * Describes one wrapper project to the runner: its host declarations and, when it has one, its viewport.
1247
+ *
1248
+ * @remarks
1249
+ * The viewport is the geometry of the project's producing variant. A runner command needs none; a
1250
+ * reader refuses a project that declares none.
1251
+ *
1252
+ * @example
1253
+ * ```ts
1254
+ * const entry: CaptureHostEntry = { project, viewport: { name: 'light-390', width: 390, height: 844 } }
1255
+ * ```
1256
+ */
1257
+ export declare interface CaptureHostEntry {
1258
+ readonly project: CaptureProject;
1259
+ readonly viewport?: CaptureViewport;
1260
+ }
1261
+
1262
+ /**
1263
+ * Retains source geometry and a bounded sheet thumbnail after a full frame has been judged.
1264
+ * @example
1265
+ * ```ts
1266
+ * const result: CaptureImageResult = { entry, picture: { width: 2880, height: 6000 }, thumbnail, digest, size: 2048 }
1267
+ * ```
1268
+ */
1269
+ export declare interface CaptureImageResult extends Omit<CaptureDecodedImage, 'picture'> {
1270
+ readonly picture: Pick<CapturePicture, 'width' | 'height'>;
1271
+ readonly thumbnail: CapturePicture;
1272
+ }
1273
+
1274
+ /**
1275
+ * Reads a contained input through an owning operation's file snapshot memo.
1276
+ *
1277
+ * @returns The input digest, or undefined if the file vanished before its snapshot
1278
+ * @example
1279
+ * ```ts
1280
+ * const read: CaptureInputHandler = (file) => snapshots.get(file)?.image.digest
1281
+ * ```
1282
+ */
1283
+ export declare type CaptureInputHandler = (file: string) => string | undefined;
1284
+
1285
+ /**
1286
+ * Validates capture transactions, freshness, and state lookup against real filesystem evidence.
1287
+ *
1288
+ * @remarks
1289
+ * The host supplies every product path, portfolio mapping, and source population; the engine
1290
+ * infers none of them from a name. Construct it through `createCaptureIntegrity`, or directly
1291
+ * with the same options.
1292
+ *
1293
+ * @example
1294
+ * ```ts
1295
+ * const integrity = new CaptureIntegrity({
1296
+ * root: process.cwd(),
1297
+ * directory: 'tmp/captures/states',
1298
+ * inputs: ['src/**'],
1299
+ * registry: 'tmp/captures/states/registry.json',
1300
+ * manifest: 'tmp/captures/states/manifest.json',
1301
+ * lookups: 'tmp/captures/states/lookups.json',
1302
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
1303
+ * })
1304
+ * ```
1305
+ */
1306
+ export declare class CaptureIntegrity implements CaptureIntegrityInterface {
1307
+ #private;
1308
+ /**
1309
+ * Binds the engine to an explicit workspace and host portfolio mapping.
1310
+ *
1311
+ * @param options - The workspace, evidence paths, authorized physical roots, and optional file hash
1312
+ * @throws Thrown when the root is not absolute, a path escapes the root, or a portfolio is invalid.
1313
+ */
1314
+ constructor(options: CaptureIntegrityOptions);
1315
+ /**
1316
+ * Classifies changes since a Git merge-base through the accepted registry.
1317
+ *
1318
+ * @param ref - The Git ref whose merge-base with HEAD bounds tracked changes; HEAD selects uncommitted work
1319
+ * @returns Every tracked or untracked changed path and the reduced owner selection
1320
+ * @throws Thrown when Git refuses the ref or the accepted registry cannot be authenticated.
1321
+ * @example
1322
+ * ```ts
1323
+ * const plan = integrity.changed('HEAD')
1324
+ * ```
1325
+ */
1326
+ changed(ref: string): CaptureChangePlan;
1327
+ /**
1328
+ * Validates an executed stage before atomically publishing its authorized evidence.
1329
+ *
1330
+ * @param options - The exact stage and the runner-owned child execution callback
1331
+ * @returns The committed stage evidence after every selected sibling validates
1332
+ * @throws Thrown when execution, identity, records, reporter results, paths, inputs, registry
1333
+ * evidence, projection, or atomic publication fails. Precommit failures preserve prior
1334
+ * manifest bytes, and journey requests publish no image stamps.
1335
+ *
1336
+ * @example
1337
+ * ```ts
1338
+ * const result = await integrity.stamp(stage)
1339
+ * ```
1340
+ */
1341
+ stamp(options: CaptureStageOptions): Promise<CaptureStageResult>;
1342
+ /**
1343
+ * Reads current full-collection evidence and selects exact declaration destinations.
1344
+ *
1345
+ * @param options - The explicit selection; omitted variants derive from authenticated mappings
1346
+ * @returns The accepted registry identity and exactly selected destinations
1347
+ * @throws Thrown with explicit preparation when declarations lack current authenticated evidence.
1348
+ *
1349
+ * @example
1350
+ * ```ts
1351
+ * const { entries } = await integrity.read({ selector: 'pages:mail' })
1352
+ * ```
1353
+ */
1354
+ read(options: CaptureReadOptions): Promise<CaptureReadResult>;
1355
+ /**
1356
+ * Checks the explicitly selected output population without changing evidence or images.
1357
+ *
1358
+ * @param selection - The selected owners, optional output variants, state, and portfolio, and
1359
+ * the wrapper's declared producing variants. Default variants: every output variant of the
1360
+ * selected registry destinations.
1361
+ * @returns Freshness classifications and warnings for the selected population
1362
+ * @throws Thrown when required evidence, schema, containment, or selection is invalid, or when
1363
+ * variants are omitted and a declared producing variant has no registry evidence.
1364
+ *
1365
+ * @example
1366
+ * ```ts
1367
+ * const result = await integrity.check({ selector: 'pages:mail' })
1368
+ * ```
1369
+ */
1370
+ check(selection: CaptureStaleOptions): Promise<CaptureCheckResult>;
1371
+ /**
1372
+ * Resolves an explicitly requested state through fresh registry and passing case evidence.
1373
+ *
1374
+ * @param options - The original selector, producing variants, state, and optional exact case
1375
+ * @returns The agreed declaring case, output mappings, and validated lookup receipts
1376
+ * @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection;
1377
+ * the message names the explicit refresh command.
1378
+ *
1379
+ * @example
1380
+ * ```ts
1381
+ * const { case: name } = await integrity.lookup({ selector: 'pages:mail', state: 'inbox', variants: ['light-390'] })
1382
+ * ```
1383
+ */
1384
+ lookup(options: CaptureLookupOptions): Promise<CaptureLookupResult>;
1385
+ }
1386
+
1387
+ /**
1388
+ * Creates the integrity engine the runner reads and stamps through, from the options it derives.
1389
+ *
1390
+ * @remarks The default constructs the package's own engine.
1391
+ *
1392
+ * @example
1393
+ * ```ts
1394
+ * const handler: CaptureIntegrityHandler = (options) => createCaptureIntegrity(options)
1395
+ * ```
1396
+ */
1397
+ export declare type CaptureIntegrityHandler = (options: CaptureIntegrityOptions) => CaptureIntegrityInterface;
1398
+
1399
+ /**
1400
+ * Defines the shared stage transaction, freshness reading, and state resolution engine.
1401
+ *
1402
+ * @example
1403
+ * ```ts
1404
+ * const integrity: CaptureIntegrityInterface = createCaptureIntegrity(options)
1405
+ * ```
1406
+ */
1407
+ export declare interface CaptureIntegrityInterface {
1408
+ /**
1409
+ * Classifies changes since a Git merge-base through the accepted registry.
1410
+ *
1411
+ * @param ref - The Git ref whose merge-base with HEAD bounds tracked changes; HEAD selects uncommitted work
1412
+ * @returns Every tracked or untracked changed path and the reduced owner selection
1413
+ * @throws Thrown when Git refuses the ref or the accepted registry cannot be authenticated.
1414
+ * @example
1415
+ * ```ts
1416
+ * const plan = integrity.changed('HEAD')
1417
+ * ```
1418
+ */
1419
+ changed(ref: string): CaptureChangePlan;
1420
+ /**
1421
+ * Reads current full-collection evidence and selects exact declaration destinations.
1422
+ *
1423
+ * @param options - The explicit selection; omitted variants derive from authenticated mappings
1424
+ * @returns The accepted registry identity and exactly selected destinations
1425
+ * @throws Thrown with explicit preparation when declarations lack current authenticated evidence.
1426
+ *
1427
+ * @example
1428
+ * ```ts
1429
+ * const { entries } = await integrity.read({ selector: 'pages:mail' })
1430
+ * ```
1431
+ */
1432
+ read(options: CaptureReadOptions): Promise<CaptureReadResult>;
1433
+ /**
1434
+ * Validates an executed stage before atomically publishing its authorized evidence.
1435
+ *
1436
+ * @param options - The exact stage and the runner-owned child execution callback
1437
+ * @returns The committed stage evidence after every selected sibling validates
1438
+ * @throws Thrown when execution, identity, records, reporter results, paths, inputs, registry
1439
+ * evidence, projection, or atomic publication fails. Precommit failures preserve prior
1440
+ * manifest bytes, and journey requests publish no image stamps.
1441
+ *
1442
+ * @example
1443
+ * ```ts
1444
+ * const result = await integrity.stamp(stage)
1445
+ * ```
1446
+ */
1447
+ stamp(options: CaptureStageOptions): Promise<CaptureStageResult>;
1448
+ /**
1449
+ * Checks the explicitly selected output population without changing evidence or images.
1450
+ *
1451
+ * @param selection - The selected owners, optional output variants, state, and portfolio, and
1452
+ * the wrapper's declared producing variants. Default variants: every output variant of the
1453
+ * selected registry destinations.
1454
+ * @returns Freshness classifications and warnings for the selected population
1455
+ * @throws Thrown when required evidence, schema, containment, or selection is invalid, or when
1456
+ * variants are omitted and a declared producing variant has no registry evidence.
1457
+ *
1458
+ * @example
1459
+ * ```ts
1460
+ * const result = await integrity.check({ selector: 'pages:mail' })
1461
+ * ```
1462
+ */
1463
+ check(selection: CaptureStaleOptions): Promise<CaptureCheckResult>;
1464
+ /**
1465
+ * Resolves an explicitly requested state through fresh registry and passing case evidence.
1466
+ *
1467
+ * @param options - The original selector, producing variants, state, and optional exact case
1468
+ * @returns The agreed declaring case, output mappings, and validated lookup receipts
1469
+ * @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection.
1470
+ *
1471
+ * @example
1472
+ * ```ts
1473
+ * const { case: name } = await integrity.lookup({ selector: 'pages:mail', state: 'inbox', variants: ['light-390'] })
1474
+ * ```
1475
+ */
1476
+ lookup(options: CaptureLookupOptions): Promise<CaptureLookupResult>;
1477
+ }
1478
+
1479
+ /**
1480
+ * Configures the engine's workspace and separate evidence documents.
1481
+ *
1482
+ * @remarks
1483
+ * `root` is the absolute workspace path. Every other path is repository-relative and
1484
+ * slash-separated. `directory` is the primary portfolio root and owns its run records.
1485
+ * `manifest` holds image stamps, `registry` holds the accepted complete-run registry, and
1486
+ * `lookups` holds a lookup journal bound to its predecessor manifest digest. A journey replaces
1487
+ * that journal after retaining unaffected receipts but cannot write the manifest. `portfolios`
1488
+ * authorizes physical image roots and scoped filename layouts the host supplies, including
1489
+ * auxiliary portfolios. `inputs` holds the native patterns for the complete bounded host input
1490
+ * population, including lookup membership. `hash` digests the bytes of every file reading.
1491
+ * Default: `computeCaptureHash`. The engine infers no portfolio, owner, source pattern, or
1492
+ * application path from a product name.
1493
+ *
1494
+ * @example
1495
+ * ```ts
1496
+ * const options: CaptureIntegrityOptions = {
1497
+ * root: process.cwd(),
1498
+ * directory: 'tmp/captures/states',
1499
+ * inputs: ['src/**'],
1500
+ * registry: 'tmp/captures/states/registry.json',
1501
+ * manifest: 'tmp/captures/states/manifest.json',
1502
+ * lookups: 'tmp/captures/states/lookups.json',
1503
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
1504
+ * }
1505
+ * ```
1506
+ */
1507
+ export declare interface CaptureIntegrityOptions {
1508
+ readonly inputs: readonly string[];
1509
+ readonly root: string;
1510
+ readonly directory: string;
1511
+ readonly manifest: string;
1512
+ readonly registry: string;
1513
+ readonly lookups: string;
1514
+ readonly portfolios: readonly CapturePortfolioRoot[];
1515
+ readonly hash?: CaptureHashHandler;
1516
+ }
1517
+
1518
+ /**
1519
+ * Owns one runner invocation's identity, request file, children, and interruption.
1520
+ *
1521
+ * @remarks
1522
+ * The runner creates one for discovery and each changed owner, so the abort controller, session
1523
+ * registry, and spawn log belong to an invocation. Interruption derives from the controller's
1524
+ * signal. Sessions end the Windows process tree, or signal the POSIX group with SIGTERM and then
1525
+ * SIGKILL after a 250 ms grace. A linked timeout ends discovery without interrupting the invocation.
1526
+ * Raw stdout is decoded across chunk boundaries and flushed at termination. A writer failure or
1527
+ * an observation cutoff refuses the stage rather than accepting incomplete evidence.
1528
+ *
1529
+ * @example
1530
+ * ```ts
1531
+ * const invocation = new CaptureInvocation({
1532
+ * command: 'journey',
1533
+ * root: process.cwd(),
1534
+ * requests: 'tmp/units',
1535
+ * stdout: (text) => process.stdout.write(text),
1536
+ * stderr: (text) => process.stderr.write(text),
1537
+ * })
1538
+ * invocation.attach()
1539
+ * ```
1540
+ */
1541
+ export declare class CaptureInvocation implements CaptureInvocationInterface {
1542
+ #private;
1543
+ /**
1544
+ * Creates the invocation entity for one runner call.
1545
+ *
1546
+ * @param options - The command, the workspace, the request directory, and the output writers
1547
+ */
1548
+ constructor(options: CaptureInvocationOptions);
1549
+ get id(): string;
1550
+ get request(): string;
1551
+ get directory(): string;
1552
+ get signal(): AbortSignal;
1553
+ get interrupted(): boolean;
1554
+ attach(): void;
1555
+ release(): Promise<void>;
1556
+ prepare(): void;
1557
+ holders(): readonly number[];
1558
+ publish(request: CaptureRequest | CaptureDiscoveryRequest): void;
1559
+ retract(): void;
1560
+ launched(log: string): boolean;
1561
+ spawn(args: readonly string[], log: string, capture: boolean, deadline?: number): Promise<CaptureExecutionResult>;
1562
+ }
1563
+
1564
+ /**
1565
+ * Owns one runner invocation's identity, request file, children, and interruption.
1566
+ *
1567
+ * @example
1568
+ * ```ts
1569
+ * const invocation: CaptureInvocationInterface = new CaptureInvocation(options)
1570
+ * ```
1571
+ */
1572
+ export declare interface CaptureInvocationInterface {
1573
+ /** Holds the invocation identity, which names its report directory and its request records. */
1574
+ readonly id: string;
1575
+ /** Holds the absolute path of the request file this process names. */
1576
+ readonly request: string;
1577
+ /** Holds the absolute directory that holds this invocation's reports and logs. */
1578
+ readonly directory: string;
1579
+ /** Holds the signal that aborts when the invocation is interrupted. */
1580
+ readonly signal: AbortSignal;
1581
+ /** Holds whether an interrupt has arrived. */
1582
+ readonly interrupted: boolean;
1583
+ /**
1584
+ * Installs the interrupt handler on the process.
1585
+ *
1586
+ * @example
1587
+ * ```ts
1588
+ * invocation.attach()
1589
+ * ```
1590
+ */
1591
+ attach(): void;
1592
+ /**
1593
+ * Releases confirmed ownership and removes interrupt handlers even when shutdown fails.
1594
+ *
1595
+ * @returns Nothing once the children are gone and the handler is removed
1596
+ *
1597
+ * @example
1598
+ * ```ts
1599
+ * await invocation.release()
1600
+ * ```
1601
+ */
1602
+ release(): Promise<void>;
1603
+ /**
1604
+ * Claims invocation ownership, refuses an existing marker, and removes temporary claims and requests from dead processes.
1605
+ *
1606
+ * @remarks A request file under a live process id is never touched, this process's own included.
1607
+ *
1608
+ * @example
1609
+ * ```ts
1610
+ * invocation.prepare()
1611
+ * ```
1612
+ */
1613
+ prepare(): void;
1614
+ /**
1615
+ * Lists the other live processes that hold a request file in the request directory.
1616
+ *
1617
+ * @returns The distinct holder process ids in directory order, excluding this invocation's own lease
1618
+ *
1619
+ * @example
1620
+ * ```ts
1621
+ * invocation.holders() // [] when no other runner is mid-stage
1622
+ * ```
1623
+ */
1624
+ holders(): readonly number[];
1625
+ /**
1626
+ * Writes the stage or discovery request atomically, so no reader sees a partial file.
1627
+ *
1628
+ * @param request - The stage request, or the discovery request that precedes the stages
1629
+ *
1630
+ * @example
1631
+ * ```ts
1632
+ * invocation.publish(request)
1633
+ * ```
1634
+ */
1635
+ publish(request: CaptureRequest | CaptureDiscoveryRequest): void;
1636
+ /**
1637
+ * Removes this process's request file and its temporary sibling.
1638
+ *
1639
+ * @example
1640
+ * ```ts
1641
+ * invocation.retract()
1642
+ * ```
1643
+ */
1644
+ retract(): void;
1645
+ /**
1646
+ * Reports whether a child with this log path has been spawned by this invocation.
1647
+ *
1648
+ * @param log - The absolute log path the spawn was given
1649
+ * @returns True if the spawn began; false otherwise
1650
+ *
1651
+ * @example
1652
+ * ```ts
1653
+ * invocation.launched(log) // false before the spawn
1654
+ * ```
1655
+ */
1656
+ launched(log: string): boolean;
1657
+ /**
1658
+ * Spawns the Vitest child and tees its output to the host streams and the log.
1659
+ *
1660
+ * @param args - The Node argument array, starting with the Vitest entry
1661
+ * @param log - The absolute path of the file that receives the child's output
1662
+ * @param capture - If `true`, sets the capture variable in the child; if `false`, removes it
1663
+ * @param deadline - Milliseconds after which the runner ends the child's process tree; default: unbounded
1664
+ * @returns The drained child outcome, its process id, and whether the deadline ended it
1665
+ * @throws Thrown as a `STAGE` capture error for a pre-aborted invocation, a child observation
1666
+ * cutoff, or a writer, log, or child fault.
1667
+ *
1668
+ * @example
1669
+ * ```ts
1670
+ * const { code } = await invocation.spawn(args, log, true)
1671
+ * ```
1672
+ */
1673
+ spawn(args: readonly string[], log: string, capture: boolean, deadline?: number): Promise<CaptureExecutionResult>;
1674
+ }
1675
+
1676
+ /**
1677
+ * Configures one runner invocation's identity, workspace, and output.
1678
+ *
1679
+ * @remarks
1680
+ * `root` is the absolute workspace path. `requests` is the repository-relative directory that
1681
+ * holds the request file and the invocation's reports and logs. `stdout` and `stderr` receive the
1682
+ * runner's own lines and each child's output.
1683
+ *
1684
+ * @example
1685
+ * ```ts
1686
+ * const options: CaptureInvocationOptions = {
1687
+ * command: 'journey',
1688
+ * root: process.cwd(),
1689
+ * requests: 'tmp/units',
1690
+ * stdout: (text) => process.stdout.write(text),
1691
+ * stderr: (text) => process.stderr.write(text),
1692
+ * }
1693
+ * ```
1694
+ */
1695
+ export declare interface CaptureInvocationOptions {
1696
+ readonly command: CaptureCommand;
1697
+ readonly root: string;
1698
+ readonly requests: string;
1699
+ readonly stdout: CaptureWriteHandler;
1700
+ readonly stderr: CaptureWriteHandler;
1701
+ /** Overrides child termination; false keeps ownership and reports the child's pid. */
1702
+ readonly terminate?: CaptureChildTerminationHandler;
1703
+ /** Supplies host ownership operations; omitted members use the local filesystem and process probe. */
1704
+ readonly ownership?: Partial<CaptureOwnershipHost>;
1705
+ }
1706
+
1707
+ /**
1708
+ * Pairs a judged frame with its verified artifact, when one was read, and its coverage issues.
1709
+ *
1710
+ * @example
1711
+ * ```ts
1712
+ * const frame: CaptureJudgedFrame = { entry, artifact: undefined, issues: [] }
1713
+ * ```
1714
+ */
1715
+ export declare interface CaptureJudgedFrame {
1716
+ readonly entry: CaptureDestination;
1717
+ readonly artifact: CaptureArtifactResult | undefined;
1718
+ readonly issues: readonly string[];
1719
+ }
1720
+
1721
+ /**
1722
+ * Names the run record a judged frame's stamp points at and the case that stamped it.
1723
+ *
1724
+ * @example
1725
+ * ```ts
1726
+ * const judged: CaptureJudgedRecord = { record: 'tmp/captures/states/runs/a/narrow/light-390.json', case: 'mail shows the inbox' }
1727
+ * ```
1728
+ */
1729
+ export declare interface CaptureJudgedRecord {
1730
+ readonly record: string;
1731
+ readonly case: string;
1732
+ }
1733
+
1734
+ /**
1735
+ * Requests a state-to-case resolution before the runner starts any selected project.
1736
+ *
1737
+ * @remarks
1738
+ * `variants` names producing journey variants, retaining the caller's exact selection. Registry
1739
+ * mappings determine output variants, and suffix substitution is forbidden. An explicit `case`
1740
+ * must equal the resolved full declaring name. Missing or stale evidence refuses with the
1741
+ * explicit capture-free owner or exact-case refresh command. Resolving a state starts no
1742
+ * process, repairs no evidence, and widens no selection.
1743
+ *
1744
+ * @example
1745
+ * ```ts
1746
+ * const options: CaptureLookupOptions = { selector: 'pages:mail', state: 'inbox', variants: ['light-390'] }
1747
+ * ```
1748
+ */
1749
+ export declare interface CaptureLookupOptions extends CaptureSelection {
1750
+ readonly state: string;
1751
+ readonly variants: readonly string[];
1752
+ readonly portfolio?: string;
1753
+ }
1754
+
1755
+ /**
1756
+ * Resolves one declaring case and its actual output pairs with their passing evidence.
1757
+ *
1758
+ * @remarks
1759
+ * `case` must agree across applicable requested producing variants, and ambiguity refuses.
1760
+ * `entries` retains each output variant and producing project without replacing the requested
1761
+ * variant list. Inapplicable projects remain in the runner's selected stage. Every entry must
1762
+ * agree with the selector, registry, lookup, and any relevant manifest stamp. An empty
1763
+ * applicable population refuses.
1764
+ *
1765
+ * @example
1766
+ * ```ts
1767
+ * const result = await integrity.lookup(options)
1768
+ * result.case // the declaring case's full name
1769
+ * ```
1770
+ */
1771
+ export declare interface CaptureLookupResult {
1772
+ readonly case: string;
1773
+ readonly entries: readonly CaptureDestination[];
1774
+ readonly lookups: readonly CaptureLookup[];
1775
+ }
1776
+
1777
+ /**
1778
+ * Carries one project's owner-bearing passed work count from a finished stage.
1779
+ *
1780
+ * @example
1781
+ * ```ts
1782
+ * const outcome: CaptureOutcome = { project: 'journey:light-390', variant: 'light-390', count: 3 }
1783
+ * ```
1784
+ */
1785
+ export declare interface CaptureOutcome {
1786
+ readonly project: string;
1787
+ readonly variant: string;
1788
+ readonly count: number;
1789
+ }
1790
+
1791
+ /**
1792
+ * Records one changed owner's exit and whether an execution child started.
1793
+ *
1794
+ * @example
1795
+ * ```ts
1796
+ * const outcome: CaptureOwnerOutcome = { owner: 'pages:mail', code: 0, ran: true }
1797
+ * ```
1798
+ */
1799
+ export declare interface CaptureOwnerOutcome {
1800
+ readonly owner: string;
1801
+ readonly code: number;
1802
+ readonly ran: boolean;
1803
+ }
1804
+
1805
+ /**
1806
+ * Identifies the process and invocation that own a request directory.
1807
+ * @example
1808
+ * ```ts
1809
+ * const owner: CaptureOwnership = { pid: process.pid, id: 'capture-run' }
1810
+ * ```
1811
+ */
1812
+ export declare interface CaptureOwnership {
1813
+ readonly pid: number;
1814
+ readonly id: string;
1815
+ }
1816
+
1817
+ /** Supplies the filesystem and liveness boundary for ownership arbitration.
1818
+ * @example
1819
+ * ```ts
1820
+ * const host: Partial<CaptureOwnershipHost> = { alive: (pid) => readCaptureRunning(pid) }
1821
+ * ```
1822
+ */
1823
+ export declare interface CaptureOwnershipHost {
1824
+ readonly platform: NodeJS.Platform;
1825
+ readonly read: (file: string) => string;
1826
+ /** Writes a temporary claim or survivor record exclusively with flag wx. */
1827
+ readonly write: (file: string, text: string) => void;
1828
+ readonly link: (source: string, target: string) => void;
1829
+ readonly remove: (file: string) => void;
1830
+ readonly alive: (pid: number) => boolean;
1831
+ }
1832
+
1833
+ /**
1834
+ * Carries the typed values and tokens of a strictly parsed capture command line.
1835
+ *
1836
+ * @example
1837
+ * ```ts
1838
+ * const parsed: CaptureParsedArguments<typeof CAPTURE_COMMAND_OPTIONS.journey> = readCaptureOptions(argv, CAPTURE_COMMAND_OPTIONS.journey, usage)
1839
+ * ```
1840
+ */
1841
+ export declare type CaptureParsedArguments<Options extends ParseArgsOptionsConfig> = {
1842
+ readonly [Key in keyof ReturnType<typeof parseArgs<{
1843
+ readonly options: Options;
1844
+ readonly tokens: true;
1845
+ readonly strict: true;
1846
+ readonly allowPositionals: true;
1847
+ }>>]: Readonly<ReturnType<typeof parseArgs<{
1848
+ readonly options: Options;
1849
+ readonly tokens: true;
1850
+ readonly strict: true;
1851
+ readonly allowPositionals: true;
1852
+ }>>[Key]>;
1853
+ };
1854
+
1855
+ /**
1856
+ * Carries a decoded RGB image for the image checks and the contact sheets.
1857
+ *
1858
+ * @example
1859
+ * ```ts
1860
+ * const picture: CapturePicture = { width: 1, height: 1, pixels: Uint8Array.from([255, 255, 255]) }
1861
+ * ```
1862
+ */
1863
+ export declare interface CapturePicture {
1864
+ readonly width: number;
1865
+ readonly height: number;
1866
+ readonly pixels: Uint8Array;
1867
+ }
1868
+
1869
+ /** Bounds a PNG's decoded pixels, side length, and encoded bytes.
1870
+ * @example
1871
+ * ```ts
1872
+ * const limits: CapturePngLimits = { pixels: 100, side: 10, bytes: 492 }
1873
+ * ```
1874
+ */
1875
+ export declare interface CapturePngLimits {
1876
+ readonly pixels: number;
1877
+ readonly side: number;
1878
+ readonly bytes: number;
1879
+ }
1880
+
1881
+ /**
1882
+ * Supplies a host-authorized physical portfolio root without repeating its states or variants.
1883
+ *
1884
+ * @example
1885
+ * ```ts
1886
+ * const root: CapturePortfolioRoot = { portfolio: 'states', directory: 'tmp/captures/states', scoped: true }
1887
+ * ```
1888
+ */
1889
+ export declare interface CapturePortfolioRoot {
1890
+ readonly portfolio: string;
1891
+ readonly directory: string;
1892
+ readonly scoped: boolean;
1893
+ }
1894
+
1895
+ /**
1896
+ * Reads the selected population's frames and reports their freshness, mixed observations, and coverage.
1897
+ *
1898
+ * @remarks
1899
+ * A successful preflight is iteration evidence and never assembled-portfolio acceptance. The reader
1900
+ * reads the host's wrapper through a `CaptureDiscovery`, the consumer's own Vitest in discovery
1901
+ * mode, and reads its projects the way the runner does: it names no portfolio, owner, variant, or
1902
+ * path the wrapper does not declare, and it imports neither Vite nor Vitest. It
1903
+ * judges each frame by the artifact the frame's own stamp names, never by a variant's latest file.
1904
+ * Rules that belong to one product, such as a page-title check or a pixel comparison, live in a
1905
+ * host module named by the `checks` option. The reader loads that module through the runtime's own
1906
+ * module loader by its file URL, reads its `CAPTURE_CHECKS` export, a list of readers from a frame to
1907
+ * its findings, and appends every finding to the report.
1908
+ * The wrapper's optional `uniform` owner selectors restrict only mixed observations;
1909
+ * absence judges every scope, and an empty list judges none.
1910
+ *
1911
+ * @example
1912
+ * ```ts
1913
+ * const preflight = new CapturePreflight({
1914
+ * root: process.cwd(),
1915
+ * config: `${process.cwd()}/configs/app/vite.journey.config.ts`,
1916
+ * selection: { selector: 'pages:mail' },
1917
+ * journeys: `${process.cwd()}/tmp/journey`,
1918
+ * })
1919
+ * const exit = await preflight.execute()
1920
+ * ```
1921
+ */
1922
+ export declare class CapturePreflight implements CapturePreflightInterface {
1923
+ #private;
1924
+ /**
1925
+ * Binds one explicit workspace, wrapper, and selection.
1926
+ *
1927
+ * @param options - The host configuration and the exact requested bounds
1928
+ */
1929
+ constructor(options: CaptureReaderOptions);
1930
+ /**
1931
+ * Reads the authenticated selection, uniform scopes, and the host's declared viewports.
1932
+ *
1933
+ * @returns The engine, the selected destinations, the viewports, the uniform scopes, and the primary run directory
1934
+ * @throws Thrown when the wrapper, the registry, or the selection is invalid.
1935
+ *
1936
+ * @example
1937
+ * ```ts
1938
+ * const { population } = await preflight.read()
1939
+ * ```
1940
+ */
1941
+ read(): Promise<CaptureReaderSelection>;
1942
+ /**
1943
+ * Judges every selected frame and returns the mixed observations, freshness, images, and issues.
1944
+ *
1945
+ * @returns The preflight result without upgrading any freshness classification
1946
+ * @throws Thrown when the selection or an artifact cannot be read.
1947
+ *
1948
+ * @example
1949
+ * ```ts
1950
+ * const result = await preflight.check()
1951
+ * ```
1952
+ */
1953
+ check(): Promise<CapturePreflightResult>;
1954
+ /**
1955
+ * Executes the check and prints its report.
1956
+ *
1957
+ * @returns Exit 0 for current frames without defects, 1 for any defect, or 64 for refused usage
1958
+ *
1959
+ * @example
1960
+ * ```ts
1961
+ * const exit = await preflight.execute() // 0
1962
+ * ```
1963
+ */
1964
+ execute(): Promise<number>;
1965
+ }
1966
+
1967
+ /**
1968
+ * Reads the selected population's frames and reports their freshness, mixed observations, and coverage.
1969
+ *
1970
+ * @example
1971
+ * ```ts
1972
+ * const preflight: CapturePreflightInterface = createCapturePreflight(reader)
1973
+ * ```
1974
+ */
1975
+ export declare interface CapturePreflightInterface {
1976
+ /**
1977
+ * Reads the authenticated selection, uniform scopes, and the host's declared viewports.
1978
+ *
1979
+ * @returns The engine, the selected destinations, the viewports, the uniform scopes, and the primary run directory
1980
+ * @throws Thrown when the wrapper, the registry, or the selection is invalid.
1981
+ *
1982
+ * @example
1983
+ * ```ts
1984
+ * const { population } = await preflight.read()
1985
+ * ```
1986
+ */
1987
+ read(): Promise<CaptureReaderSelection>;
1988
+ /**
1989
+ * Judges every selected frame and returns the mixed observations, freshness, images, and issues.
1990
+ *
1991
+ * @returns The preflight result without upgrading any freshness classification
1992
+ * @throws Thrown when the selection or an artifact cannot be read.
1993
+ *
1994
+ * @example
1995
+ * ```ts
1996
+ * const result = await preflight.check()
1997
+ * ```
1998
+ */
1999
+ check(): Promise<CapturePreflightResult>;
2000
+ /**
2001
+ * Executes the check and prints its report.
2002
+ *
2003
+ * @returns Exit 0 for current frames without defects, 1 for any defect, or 64 for refused usage
2004
+ *
2005
+ * @example
2006
+ * ```ts
2007
+ * const exit = await preflight.execute() // 0
2008
+ * ```
2009
+ */
2010
+ execute(): Promise<number>;
2011
+ }
2012
+
2013
+ /**
2014
+ * Reports selected image checks without upgrading their engine freshness classifications.
2015
+ *
2016
+ * @remarks
2017
+ * `mixed` reports dimension mixtures without inferring intended or actual capture mode.
2018
+ * `directory` names the host's primary run directory, which holds the stamped run records.
2019
+ *
2020
+ * @example
2021
+ * ```ts
2022
+ * const result = await preflight.check()
2023
+ * result.issues // readonly string[]
2024
+ * ```
2025
+ */
2026
+ export declare interface CapturePreflightResult {
2027
+ readonly mixed: readonly string[];
2028
+ readonly variants: readonly CaptureProducer[];
2029
+ readonly directory: string;
2030
+ readonly selection: CaptureReadResult;
2031
+ readonly freshness: CaptureCheckResult;
2032
+ readonly images: readonly CaptureImageResult[];
2033
+ readonly issues: readonly string[];
2034
+ }
2035
+
2036
+ /**
2037
+ * Declares the viewport one wrapper project produces beside the project's own name.
2038
+ *
2039
+ * @remarks
2040
+ * `project` is the Vitest project label, which a destination names as its producer. The geometry
2041
+ * is the viewport the wrapper declares for that project's producing variant, never one derived from
2042
+ * an output name.
2043
+ *
2044
+ * @example
2045
+ * ```ts
2046
+ * const producer: CaptureProducer = { project: 'journey:light-390', name: 'light-390', width: 390, height: 844 }
2047
+ * ```
2048
+ */
2049
+ export declare interface CaptureProducer extends CaptureViewport {
2050
+ readonly project: string;
2051
+ }
2052
+
2053
+ /**
2054
+ * Preserves the wrapper's host declarations, including optional uniform scopes, for consumers.
2055
+ *
2056
+ * @remarks
2057
+ * `name` is the Vitest project label the runner passes to `--project`, `variant` is the one
2058
+ * producing variant that project runs, and `variants` lists every variant the wrapper declares.
2059
+ * `directory` is the absolute primary portfolio root and `record` the run record template.
2060
+ * `inputs` bounds attribution. `final` is the full name of the case that closes a variant's
2061
+ * run, `first` is the variant a frame capture stages alone before the rest, and `portfolios`
2062
+ * authorizes every physical root a selector may reach through the primary registry. `standalone`
2063
+ * lists the roots that keep their own registry, manifest, and lookups beside their directory and
2064
+ * have no stamping route; a selector or `--portfolio` that names one reads through that root
2065
+ * alone. The runner validates uniqueness, tag syntax, references, and containment of every one
2066
+ * of them. `uniform` optionally lists unique valid owner selectors whose frames the preflight
2067
+ * judges for mixed observations. Default: every scope. An empty list judges none. Every project must
2068
+ * agree on the declaration, including its absence; order does not matter. Uniform scopes never
2069
+ * restrict freshness, coverage, or host checks.
2070
+ *
2071
+ * @example
2072
+ * ```ts
2073
+ * const project: CaptureProject = {
2074
+ * name: 'journey:light-390',
2075
+ * variant: 'light-390',
2076
+ * tags: ['owner:pages:mail'],
2077
+ * variants: ['light-390'],
2078
+ * directory: `${process.cwd()}/tmp/captures/states`,
2079
+ * record: 'tmp/captures/states/runs/a/light-390.json',
2080
+ * inputs: ['src/**'],
2081
+ * final: 'showcase journeys places every registered state and writes the variant artifact',
2082
+ * first: 'light-390',
2083
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
2084
+ * standalone: [],
2085
+ * }
2086
+ * ```
2087
+ */
2088
+ export declare interface CaptureProject {
2089
+ readonly name: string;
2090
+ readonly variant: string;
2091
+ readonly tags: readonly string[];
2092
+ readonly variants: readonly string[];
2093
+ readonly directory: string;
2094
+ readonly record: string;
2095
+ readonly inputs: readonly string[];
2096
+ readonly final: string;
2097
+ readonly first: string;
2098
+ readonly uniform?: readonly string[];
2099
+ readonly portfolios: readonly CapturePortfolioRoot[];
2100
+ readonly standalone: readonly CapturePortfolioRoot[];
2101
+ }
2102
+
2103
+ /**
2104
+ * Reports validated project evidence, retaining empty successful selections explicitly.
2105
+ *
2106
+ * @example
2107
+ * ```ts
2108
+ * const result: CaptureProjectResult = {
2109
+ * project: 'journey:light-390',
2110
+ * variant: 'light-390',
2111
+ * record: { file: 'tmp/captures/states/runs/a/narrow/light-390.json', digest },
2112
+ * declarations: [],
2113
+ * passed: [],
2114
+ * }
2115
+ * ```
2116
+ */
2117
+ export declare interface CaptureProjectResult {
2118
+ readonly project: string;
2119
+ readonly variant: string;
2120
+ readonly record: {
2121
+ readonly file: string;
2122
+ readonly digest: string;
2123
+ };
2124
+ readonly declarations: readonly CaptureDeclaration[];
2125
+ readonly passed: readonly string[];
2126
+ }
2127
+
2128
+ /**
2129
+ * Preserves one project's declared patterns and sorted expansion before execution.
2130
+ *
2131
+ * @example
2132
+ * ```ts
2133
+ * const snapshot: CaptureProjectSnapshot = { project: 'journey:light-390', inputs: digest }
2134
+ * ```
2135
+ */
2136
+ export declare interface CaptureProjectSnapshot {
2137
+ readonly project: string;
2138
+ readonly inputs: CaptureDigest;
2139
+ }
2140
+
2141
+ /**
2142
+ * Carries parsed reader arguments and an optional contact-sheet output directory.
2143
+ *
2144
+ * @example
2145
+ * ```ts
2146
+ * const command: CaptureReaderCommand = { reader, output: '/repo/tmp/sheets' }
2147
+ * ```
2148
+ */
2149
+ export declare interface CaptureReaderCommand {
2150
+ readonly reader: CaptureReaderOptions;
2151
+ readonly output?: string;
2152
+ }
2153
+
2154
+ /**
2155
+ * Supplies the wrapper path, the journey artifact directory, and the request directory a reader command line falls back to.
2156
+ *
2157
+ * @remarks
2158
+ * All are repository-relative; the command line's `--config` and `--journeys` replace the first two.
2159
+ * An omitted `requests` is `CAPTURE_DEFAULTS.requests`.
2160
+ *
2161
+ * @example
2162
+ * ```ts
2163
+ * const defaults: CaptureReaderDefaults = { config: 'configs/app/vite.journey.config.ts', journeys: 'tmp/journey' }
2164
+ * ```
2165
+ */
2166
+ export declare interface CaptureReaderDefaults {
2167
+ readonly config: string;
2168
+ readonly journeys: string;
2169
+ readonly requests?: string;
2170
+ }
2171
+
2172
+ /**
2173
+ * Configures a read-only capture consumer using the wrapper's host declarations.
2174
+ *
2175
+ * @remarks
2176
+ * `root` is the absolute workspace and `config` the absolute wrapper path. `selection` bounds the
2177
+ * population, and `journeys` is the absolute directory of journey artifacts. `checks`, when
2178
+ * supplied, is the path of a module, absolute or relative to `root`, that exports the host's
2179
+ * `CAPTURE_CHECKS` list of frame readers. The reader loads it through the runtime's own module
2180
+ * loader by the module's file URL, so a TypeScript module needs a Node that strips types.
2181
+ * `requests` is the repository-relative directory that holds the discovery request; default:
2182
+ * `CAPTURE_DEFAULTS.requests`.
2183
+ * `deadline` bounds the discovery child in milliseconds; default: `CAPTURE_DISCOVERY.deadline`.
2184
+ * `stdout` receives the report line and `stderr` each refusal; default: the process streams.
2185
+ *
2186
+ * @example
2187
+ * ```ts
2188
+ * const reader: CaptureReaderOptions = {
2189
+ * root: process.cwd(),
2190
+ * config: `${process.cwd()}/configs/app/vite.journey.config.ts`,
2191
+ * selection: { selector: 'pages:mail' },
2192
+ * journeys: `${process.cwd()}/tmp/journey`,
2193
+ * checks: 'tests/setupCapture.ts',
2194
+ * }
2195
+ * ```
2196
+ */
2197
+ export declare interface CaptureReaderOptions {
2198
+ readonly root: string;
2199
+ readonly config: string;
2200
+ readonly selection: CaptureReadOptions;
2201
+ readonly journeys: string;
2202
+ readonly checks?: string;
2203
+ readonly requests?: string;
2204
+ readonly deadline?: number;
2205
+ readonly stdout?: CaptureWriteHandler;
2206
+ readonly stderr?: CaptureWriteHandler;
2207
+ }
2208
+
2209
+ /**
2210
+ * Returns a reader's authenticated selection, uniform scopes, and engine for pixel classification.
2211
+ *
2212
+ * @remarks
2213
+ * `directory` is the host's primary run directory, which holds the stamped run records. `uniform`
2214
+ * preserves the wrapper's uniform scopes for mixed observations only. Default: every scope. An
2215
+ * empty list judges none, while the authenticated selection retains every frame for the other checks.
2216
+ *
2217
+ * @example
2218
+ * ```ts
2219
+ * const { population, variants } = await preflight.read()
2220
+ * ```
2221
+ */
2222
+ export declare interface CaptureReaderSelection {
2223
+ readonly integrity: CaptureIntegrityInterface;
2224
+ readonly population: CaptureReadResult;
2225
+ readonly variants: readonly CaptureProducer[];
2226
+ readonly directory: string;
2227
+ readonly uniform?: readonly string[];
2228
+ }
2229
+
2230
+ /**
2231
+ * Selects a declaration population without requiring current images or passing state lookups.
2232
+ *
2233
+ * @remarks
2234
+ * Omitted variants derive from authenticated output mappings, and an explicit empty list
2235
+ * refuses. Every supplied selector, state, case, portfolio, and output variant remains a bound.
2236
+ *
2237
+ * @example
2238
+ * ```ts
2239
+ * const options: CaptureReadOptions = { selector: 'pages:mail', variants: ['light-390'] }
2240
+ * ```
2241
+ */
2242
+ export declare interface CaptureReadOptions extends CaptureSelection {
2243
+ readonly variants?: readonly string[];
2244
+ readonly portfolio?: string;
2245
+ }
2246
+
2247
+ /**
2248
+ * Returns the exact current declaration destinations and their complete-anchor identity.
2249
+ *
2250
+ * @example
2251
+ * ```ts
2252
+ * const { registry, entries } = await integrity.read({ selector: 'pages:mail' })
2253
+ * ```
2254
+ */
2255
+ export declare interface CaptureReadResult {
2256
+ readonly registry: string;
2257
+ readonly entries: readonly CaptureDestination[];
2258
+ }
2259
+
2260
+ /**
2261
+ * Supplies a verifier's actual process outcome and exact reporter bytes for registry import.
2262
+ *
2263
+ * @example
2264
+ * ```ts
2265
+ * const input: CaptureReceiptInput = { receipt, report: text, outcome: { code: 0, signal: null }, capped: false }
2266
+ * ```
2267
+ */
2268
+ export declare interface CaptureReceiptInput {
2269
+ readonly receipt: CaptureReceipt;
2270
+ readonly report: string;
2271
+ readonly outcome: CaptureExecutionResult;
2272
+ readonly capped: boolean;
2273
+ }
2274
+
2275
+ /**
2276
+ * Refreshes the accepted registry from one complete capture-free journey per producing variant.
2277
+ *
2278
+ * @remarks
2279
+ * The refresh is the one route that bootstraps or replaces the registry the stage transaction
2280
+ * requires, so it cannot stamp through the integrity engine. It reads the wrapper through the same
2281
+ * discovery the runner uses, takes the same invocation entity, request file, and Vitest child, and runs
2282
+ * each producing variant as a stage of its own with the `all` selector and no capture variable. It
2283
+ * reads each stage's reporter and final record, takes the project's input population before and
2284
+ * after, and builds the receipts through `buildCaptureRegistry`. The registry is written to a
2285
+ * candidate beside its target, read back through the integrity engine, and only then renamed into
2286
+ * place, so a registry the engine would refuse never replaces a good one. With `--variant`, the
2287
+ * existing registry's receipts for the other declared variants are kept. It never widens a scoped
2288
+ * run into a refresh and refuses while another runner holds a request file in the request directory.
2289
+ * Before any stage, it reads the inherited manifest and lookup journal and refuses an unsupported
2290
+ * schema with the file to inspect and repair.
2291
+ *
2292
+ * @example
2293
+ * ```ts
2294
+ * const registrar = new CaptureRegistrar({
2295
+ * root: process.cwd(),
2296
+ * config: 'configs/app/vite.journey.config.ts',
2297
+ * requests: 'tmp/capture',
2298
+ * argv: [],
2299
+ * })
2300
+ * const exit = await registrar.execute()
2301
+ * ```
2302
+ */
2303
+ export declare class CaptureRegistrar implements CaptureRegistrarInterface {
2304
+ #private;
2305
+ /**
2306
+ * Binds the workspace, the wrapper default, the request directory, and the command line.
2307
+ *
2308
+ * @param options - The workspace, the wrapper default, the request directory, the command line, and optional output writers
2309
+ */
2310
+ constructor(options: CaptureRegistrarOptions);
2311
+ execute(): Promise<number>;
2312
+ }
2313
+
2314
+ /**
2315
+ * Refreshes the accepted registry from one complete capture-free journey per producing variant.
2316
+ *
2317
+ * @example
2318
+ * ```ts
2319
+ * const registrar: CaptureRegistrarInterface = createCaptureRegistrar(options)
2320
+ * const exit = await registrar.execute()
2321
+ * ```
2322
+ */
2323
+ export declare interface CaptureRegistrarInterface {
2324
+ /**
2325
+ * Runs each producing variant's complete journey, imports the receipts, and publishes the registry.
2326
+ *
2327
+ * @returns Exit 0 for a published registry, 1 for a refused, failed, or interrupted refresh, or 64 for refused usage
2328
+ *
2329
+ * @example
2330
+ * ```ts
2331
+ * const exit = await registrar.execute() // 0
2332
+ * ```
2333
+ */
2334
+ execute(): Promise<number>;
2335
+ }
2336
+
2337
+ /**
2338
+ * Configures one registry refresh: its workspace, wrapper default, request directory, and command line.
2339
+ *
2340
+ * @remarks
2341
+ * `root` is the absolute workspace path. `config` is the repository-relative wrapper default, used
2342
+ * when the command line names no `--config`. `requests` is the repository-relative directory that
2343
+ * holds the request file the wrapper reads back. `argv` is the command line after the subcommand.
2344
+ * `stdout` and `stderr` receive the refresh's own lines and each child's output; default: the
2345
+ * process streams. `deadline` bounds the discovery child in milliseconds; default:
2346
+ * `CAPTURE_DISCOVERY.deadline`.
2347
+ *
2348
+ * @example
2349
+ * ```ts
2350
+ * const options: CaptureRegistrarOptions = {
2351
+ * root: process.cwd(),
2352
+ * config: 'configs/app/vite.journey.config.ts',
2353
+ * requests: 'tmp/capture',
2354
+ * argv: ['--variant', 'light-390'],
2355
+ * }
2356
+ * ```
2357
+ */
2358
+ export declare interface CaptureRegistrarOptions {
2359
+ readonly root: string;
2360
+ readonly config: string;
2361
+ readonly requests: string;
2362
+ readonly argv: readonly string[];
2363
+ readonly stdout?: CaptureWriteHandler;
2364
+ readonly stderr?: CaptureWriteHandler;
2365
+ readonly deadline?: number;
2366
+ }
2367
+
2368
+ /**
2369
+ * Carries the parsed registry command line: the wrapper, the variants to refresh, and the mode.
2370
+ *
2371
+ * @remarks `config` is absolute. An empty `variants` list refreshes every declared producing variant.
2372
+ *
2373
+ * @example
2374
+ * ```ts
2375
+ * const parsed: CaptureRegistryArguments = { config: '/repo/configs/vite.journey.config.ts', variants: [] }
2376
+ * ```
2377
+ */
2378
+ export declare interface CaptureRegistryArguments {
2379
+ readonly config: string;
2380
+ readonly variants: readonly string[];
2381
+ readonly mode?: string;
2382
+ }
2383
+
2384
+ /**
2385
+ * Configures how a wrapper reads the runner's request for its own Vitest process.
2386
+ *
2387
+ * @remarks
2388
+ * `ppid` is the wrapper process's parent id, which names the request file the runner wrote.
2389
+ * `argv` is the wrapper process's own arguments after its executable, which the request records
2390
+ * exactly. `directory` is the directory that holds request files, absolute or relative to the
2391
+ * working directory. The runner names the directory it publishes to in the child's environment, so
2392
+ * a wrapper that omits `directory` reads the runner's own and never has to repeat it; a wrapper
2393
+ * that names one declares it, and it must be the runner's. With neither, the directory is
2394
+ * `CAPTURE_DEFAULTS.requests`. `config` is the repository-relative, slash-separated path of the
2395
+ * wrapper the request must name. `owners` lists every owner path the wrapper declares and
2396
+ * `variants` every variant name it declares.
2397
+ *
2398
+ * @example
2399
+ * ```ts
2400
+ * const options: CaptureRequestOptions = {
2401
+ * ppid: process.ppid,
2402
+ * argv: process.argv.slice(1),
2403
+ * config: 'configs/vite.journey.config.ts',
2404
+ * owners: ['pages:mail'],
2405
+ * variants: ['light-390'],
2406
+ * }
2407
+ * ```
2408
+ */
2409
+ export declare interface CaptureRequestOptions {
2410
+ readonly ppid: number;
2411
+ readonly argv: readonly string[];
2412
+ readonly directory?: string;
2413
+ readonly config: string;
2414
+ readonly owners: readonly string[];
2415
+ readonly variants: readonly string[];
2416
+ }
2417
+
2418
+ /**
2419
+ * Removes one invocation's published request during shutdown.
2420
+ *
2421
+ * @example
2422
+ * ```ts
2423
+ * const retract: CaptureRetractionHandler = () => invocation.retract()
2424
+ * ```
2425
+ */
2426
+ export declare type CaptureRetractionHandler = () => void;
2427
+
2428
+ /**
2429
+ * Binds a decoded run record to the physical file whose digest authenticated it.
2430
+ *
2431
+ * @example
2432
+ * ```ts
2433
+ * const evidence: CaptureRunEvidence = { file: snapshot, run }
2434
+ * ```
2435
+ */
2436
+ export declare interface CaptureRunEvidence {
2437
+ readonly file: CaptureFileSnapshot;
2438
+ readonly run: CaptureRun;
2439
+ }
2440
+
2441
+ /**
2442
+ * Drives selected owners through one journey stage or staged frame captures.
2443
+ *
2444
+ * @remarks
2445
+ * The wrapper and the installed Vitest supply the registry and the execution protocol, and the
2446
+ * wrapper's provided values supply every name the runner uses: the variants, the first-stage
2447
+ * variant, the final case, and the portfolio roots. The runner never loads the wrapper itself: a
2448
+ * `CaptureDiscovery` runs the consumer's installed Vitest in discovery mode and reads back the host
2449
+ * description the wrapper writes, so the runner imports neither Vite nor Vitest. It creates one
2450
+ * discovery invocation per `execute` call and a separate invocation per changed owner, and holds
2451
+ * none of that call's state itself.
2452
+ *
2453
+ * @example
2454
+ * ```ts
2455
+ * const runner = new CaptureRunner({
2456
+ * command: 'journey',
2457
+ * root: process.cwd(),
2458
+ * config: 'configs/app/vite.journey.config.ts',
2459
+ * requests: 'tmp/units',
2460
+ * argv: ['pages:mail', '--variant', 'light-390'],
2461
+ * })
2462
+ * const exit = await runner.execute()
2463
+ * ```
2464
+ */
2465
+ export declare class CaptureRunner implements CaptureRunnerInterface {
2466
+ #private;
2467
+ /**
2468
+ * Binds the command, the workspace, and the command line.
2469
+ *
2470
+ * @param options - The command, the workspace, the wrapper default, the request directory, and the command line
2471
+ */
2472
+ constructor(options: CaptureRunnerOptions);
2473
+ execute(): Promise<number>;
2474
+ }
2475
+
2476
+ /**
2477
+ * Carries parsed runner arguments while leaving omitted selectors available to the usage diagnostic.
2478
+ *
2479
+ * @example
2480
+ * ```ts
2481
+ * const parsed: CaptureRunnerArguments = { config: '/repo/configs/vite.journey.config.ts', variants: [] }
2482
+ * ```
2483
+ */
2484
+ export declare interface CaptureRunnerArguments {
2485
+ readonly selector?: string;
2486
+ readonly changed?: string;
2487
+ readonly plan?: boolean;
2488
+ readonly config: string;
2489
+ readonly variants: readonly string[];
2490
+ readonly case?: string;
2491
+ readonly state?: string;
2492
+ readonly portfolio?: string;
2493
+ }
2494
+
2495
+ /**
2496
+ * Drives selected owners through one journey stage or staged frame captures.
2497
+ *
2498
+ * @example
2499
+ * ```ts
2500
+ * const runner: CaptureRunnerInterface = createCaptureRunner(options)
2501
+ * const exit = await runner.execute()
2502
+ * ```
2503
+ */
2504
+ export declare interface CaptureRunnerInterface {
2505
+ /**
2506
+ * Executes the command line without widening its owner or variant selection.
2507
+ *
2508
+ * @returns Exit 0 for passed work, 1 for failure or no work, or 64 for refused usage
2509
+ *
2510
+ * @example
2511
+ * ```ts
2512
+ * const exit = await runner.execute() // 0
2513
+ * ```
2514
+ */
2515
+ execute(): Promise<number>;
2516
+ }
2517
+
2518
+ /**
2519
+ * Configures one runner invocation: its command, its workspace, and the command line it reads.
2520
+ *
2521
+ * @remarks
2522
+ * `root` is the absolute workspace path. `config` is the repository-relative wrapper default,
2523
+ * used when the command line names no `--config`. `requests` is the repository-relative
2524
+ * directory that holds the runner's request file. The runner hands it to every child it spawns in
2525
+ * the `CAPTURE_REQUESTS` variable, so a wrapper that names no directory of its own reads the same
2526
+ * one. `argv` is the command line after the entry name. `stdout` and `stderr` receive the
2527
+ * runner's own lines and each child's output; default: the process streams. `integrity` creates
2528
+ * the engine from the options the runner derives from the wrapper; default: the package's own
2529
+ * engine. `deadline` bounds the discovery child in milliseconds; default:
2530
+ * `CAPTURE_DISCOVERY.deadline`.
2531
+ *
2532
+ * @example
2533
+ * ```ts
2534
+ * const options: CaptureRunnerOptions = {
2535
+ * command: 'journey',
2536
+ * root: process.cwd(),
2537
+ * config: 'configs/app/vite.journey.config.ts',
2538
+ * requests: 'tmp/units',
2539
+ * argv: ['pages:mail', '--variant', 'light-390'],
2540
+ * }
2541
+ * ```
2542
+ */
2543
+ export declare interface CaptureRunnerOptions {
2544
+ readonly command: CaptureCommand;
2545
+ readonly root: string;
2546
+ readonly config: string;
2547
+ readonly requests: string;
2548
+ readonly argv: readonly string[];
2549
+ readonly stdout?: CaptureWriteHandler;
2550
+ readonly stderr?: CaptureWriteHandler;
2551
+ readonly integrity?: CaptureIntegrityHandler;
2552
+ readonly deadline?: number;
2553
+ }
2554
+
2555
+ /**
2556
+ * Carries everything every stage of one invocation shares.
2557
+ *
2558
+ * @remarks
2559
+ * `directory` is the repository-relative primary portfolio root, `config` the repository-relative
2560
+ * wrapper path, and `final` the full name of the case that closes a variant's run. `filter` is
2561
+ * the tag expression. `case` and `state` appear only when the command line named them, and `case`
2562
+ * holds the resolved declaring case once a state selects one. `command` is the request command
2563
+ * every stage records.
2564
+ *
2565
+ * @example
2566
+ * ```ts
2567
+ * const plan: CaptureRunPlan = {
2568
+ * command: 'journey',
2569
+ * projects: [project],
2570
+ * selector: 'pages:mail',
2571
+ * filter: 'owner:pages:mail',
2572
+ * final: 'closes the run',
2573
+ * directory: 'tmp/captures/states',
2574
+ * config: 'configs/vite.journey.config.ts',
2575
+ * }
2576
+ * ```
2577
+ */
2578
+ export declare interface CaptureRunPlan {
2579
+ readonly command: CaptureRequest['command'];
2580
+ readonly projects: readonly CaptureProject[];
2581
+ readonly selector: string;
2582
+ readonly filter: string;
2583
+ readonly case?: string;
2584
+ readonly state?: string;
2585
+ readonly final: string;
2586
+ readonly directory: string;
2587
+ readonly config: string;
2588
+ }
2589
+
2590
+ /**
2591
+ * Holds one contact-sheet cell: a frame's destination, its shrunk picture, and what the sheet reports about it.
2592
+ *
2593
+ * @remarks
2594
+ * `source` is the decoded image's size, `undefined` when the image could not be read, and `factor`
2595
+ * is the whole-number reduction applied. `clipped` is true when the shrunk picture was cut at the
2596
+ * sheet's height limit.
2597
+ *
2598
+ * @example
2599
+ * ```ts
2600
+ * const cell: CaptureSheetCell = { entry, picture, source: undefined, factor: 1, clipped: false, freshness: undefined }
2601
+ * ```
2602
+ */
2603
+ export declare interface CaptureSheetCell {
2604
+ readonly entry: CaptureDestination;
2605
+ readonly picture: CapturePicture;
2606
+ readonly source: {
2607
+ readonly width: number;
2608
+ readonly height: number;
2609
+ readonly bytes: number;
2610
+ } | undefined;
2611
+ readonly factor: number;
2612
+ readonly clipped: boolean;
2613
+ readonly freshness: CaptureFreshness | undefined;
2614
+ }
2615
+
2616
+ /**
2617
+ * Holds the cells of one portfolio, owner, and state side by side as one composite picture.
2618
+ *
2619
+ * @example
2620
+ * ```ts
2621
+ * const group: CaptureSheetGroup = { identity: '["states","pages:mail","mail-screen"]', cells: [], picture }
2622
+ * ```
2623
+ */
2624
+ export declare interface CaptureSheetGroup {
2625
+ readonly identity: string;
2626
+ readonly cells: readonly CaptureSheetCell[];
2627
+ readonly picture: CapturePicture;
2628
+ }
2629
+
2630
+ /**
2631
+ * Carries a contact-sheet output request separately from the population selection.
2632
+ *
2633
+ * @example
2634
+ * ```ts
2635
+ * const options: CaptureSheetOptions = { reader, output: '/repo/tmp/sheets' }
2636
+ * ```
2637
+ */
2638
+ export declare interface CaptureSheetOptions {
2639
+ readonly reader: CaptureReaderOptions;
2640
+ readonly output: string;
2641
+ }
2642
+
2643
+ /**
2644
+ * Holds one written sheet: its file name, the rows it stacks, and the composite picture.
2645
+ *
2646
+ * @example
2647
+ * ```ts
2648
+ * const page: CaptureSheetPage = { file: 'sheet-001.png', rows: [], picture }
2649
+ * ```
2650
+ */
2651
+ export declare interface CaptureSheetPage {
2652
+ readonly file: string;
2653
+ readonly rows: readonly CaptureSheetRow[];
2654
+ readonly picture: CapturePicture;
2655
+ }
2656
+
2657
+ /**
2658
+ * Holds a pair of groups side by side as one composite picture.
2659
+ *
2660
+ * @example
2661
+ * ```ts
2662
+ * const row: CaptureSheetRow = { groups: [], picture }
2663
+ * ```
2664
+ */
2665
+ export declare interface CaptureSheetRow {
2666
+ readonly groups: readonly CaptureSheetGroup[];
2667
+ readonly picture: CapturePicture;
2668
+ }
2669
+
2670
+ /**
2671
+ * Composes exactly the authenticated sparse state and output pairs for iteration review.
2672
+ *
2673
+ * @remarks
2674
+ * Sheets remain preflight artifacts, never assembled-portfolio acceptance. The class reads the
2675
+ * selection through `CapturePreflight`, so it judges the same population the preflight does and
2676
+ * keeps its refusals. It writes the sheets, an index of every cell, and a notes document into a new
2677
+ * directory that is contained in the workspace, has an existing parent, and lies outside every
2678
+ * selected capture directory. A frame whose image cannot be read shows as a red mark and is indexed
2679
+ * as `missing`.
2680
+ *
2681
+ * @example
2682
+ * ```ts
2683
+ * const sheets = new CaptureSheets({ reader, output: `${process.cwd()}/tmp/sheets` })
2684
+ * const exit = await sheets.execute()
2685
+ * ```
2686
+ */
2687
+ export declare class CaptureSheets implements CaptureSheetsInterface {
2688
+ #private;
2689
+ /**
2690
+ * Binds a read selection and a new output directory.
2691
+ *
2692
+ * @param options - The explicit host, selection, and sheet destination
2693
+ */
2694
+ constructor(options: CaptureSheetOptions);
2695
+ /**
2696
+ * Reads selected physical images, writes complete indexed sheets, and retains all refusals.
2697
+ *
2698
+ * @returns Exit 0 for current selected images without preflight defects, 1 for any defect or containment refusal, or 64 for refused usage
2699
+ *
2700
+ * @example
2701
+ * ```ts
2702
+ * const exit = await sheets.execute() // 0
2703
+ * ```
2704
+ */
2705
+ execute(): Promise<number>;
2706
+ }
2707
+
2708
+ /**
2709
+ * Composes exactly the authenticated sparse state and output pairs for iteration review.
2710
+ *
2711
+ * @remarks Sheets remain preflight artifacts, never assembled-portfolio acceptance.
2712
+ *
2713
+ * @example
2714
+ * ```ts
2715
+ * const sheets: CaptureSheetsInterface = createCaptureSheets(options)
2716
+ * ```
2717
+ */
2718
+ export declare interface CaptureSheetsInterface {
2719
+ /**
2720
+ * Reads selected physical images, writes complete indexed sheets, and retains all refusals.
2721
+ *
2722
+ * @returns Exit 0 for current selected images without preflight defects, 1 for any defect or containment refusal, or 64 for refused usage
2723
+ *
2724
+ * @example
2725
+ * ```ts
2726
+ * const exit = await sheets.execute() // 0
2727
+ * ```
2728
+ */
2729
+ execute(): Promise<number>;
2730
+ }
2731
+
2732
+ /**
2733
+ * Holds a stage boundary's input populations and existing output identities.
2734
+ *
2735
+ * @remarks
2736
+ * `time` is epoch milliseconds for comparing physical file timestamps; monotonic operation
2737
+ * durations use `performance.now` separately. Snapshots are engine-owned readings, never a
2738
+ * caller-supplied substitute for taking the pre-execution snapshot.
2739
+ *
2740
+ * @example
2741
+ * ```ts
2742
+ * const snapshot: CaptureSnapshot = { time: Date.now(), projects: [], files: [] }
2743
+ * ```
2744
+ */
2745
+ export declare interface CaptureSnapshot {
2746
+ readonly time: number;
2747
+ readonly projects: readonly CaptureProjectSnapshot[];
2748
+ readonly files: readonly CaptureFileSnapshot[];
2749
+ }
2750
+
2751
+ /**
2752
+ * Binds a stage transaction to its exact request, projects, reporter, and process boundary.
2753
+ *
2754
+ * @remarks
2755
+ * `report` is the invocation-specific repository-relative Vitest JSON reporter path. Before
2756
+ * `execute`, the engine validates paths and snapshots each project's expanded input membership
2757
+ * and bytes, existing image identities, records, and reporter. After successful execution, it
2758
+ * validates every selected record and reporter result, including empty records, before
2759
+ * committing any member. Attributed paths outside a project's initial population refuse, and so
2760
+ * do changed attributed bytes or membership. `signal` propagates runner interruption and is
2761
+ * checked before execution and commit. A capture commits one manifest replacement. A journey
2762
+ * requires empty image entries and publishes passing lookups and full-collection receipts in its
2763
+ * separate journal, leaving manifest bytes unchanged.
2764
+ *
2765
+ * @example
2766
+ * ```ts
2767
+ * const options: CaptureStageOptions = {
2768
+ * request,
2769
+ * projects: [project],
2770
+ * report: 'tmp/captures/states/runs/a/journey-selected.json',
2771
+ * execute: async () => ({ code: 0, signal: null }),
2772
+ * }
2773
+ * ```
2774
+ */
2775
+ export declare interface CaptureStageOptions {
2776
+ readonly request: CaptureRequest;
2777
+ readonly projects: readonly CaptureStageProject[];
2778
+ readonly report: string;
2779
+ readonly execute: CaptureExecutionHandler;
2780
+ readonly signal?: AbortSignal;
2781
+ }
2782
+
2783
+ /**
2784
+ * Names one planned stage and the variants it runs in one Vitest process.
2785
+ *
2786
+ * @example
2787
+ * ```ts
2788
+ * const stage: CaptureStagePlan = { name: 'selected', variants: ['light-390', 'dark-390'] }
2789
+ * ```
2790
+ */
2791
+ export declare interface CaptureStagePlan {
2792
+ readonly name: 'selected' | 'narrow' | 'rest';
2793
+ readonly variants: readonly string[];
2794
+ }
2795
+
2796
+ /**
2797
+ * Supplies one selected project's expected final record and bounded input population.
2798
+ *
2799
+ * @remarks
2800
+ * `name` is the actual Vitest project name and `variant` is its producing variant, which can
2801
+ * differ from a destination's output variant. `record` is the repository-relative path bound to
2802
+ * the active request, never a raw direct-run substitute. `inputs` comes from that project's
2803
+ * wrapper provide and bounds attribution even on a first capture. Every requested variant
2804
+ * requires a project and a final record, including projects whose selected owner population is
2805
+ * inapplicable.
2806
+ *
2807
+ * @example
2808
+ * ```ts
2809
+ * const project: CaptureStageProject = {
2810
+ * name: 'journey:light-390',
2811
+ * variant: 'light-390',
2812
+ * record: 'tmp/captures/states/runs/a/narrow/light-390.json',
2813
+ * inputs: ['src/**'],
2814
+ * }
2815
+ * ```
2816
+ */
2817
+ export declare interface CaptureStageProject {
2818
+ readonly name: string;
2819
+ readonly variant: string;
2820
+ readonly record: string;
2821
+ readonly inputs: readonly string[];
2822
+ }
2823
+
2824
+ /**
2825
+ * Reports the successful stage's committed stamps and validated lookup evidence.
2826
+ *
2827
+ * @remarks
2828
+ * `entries` contains only this stage's image stamps and is empty for a journey. `lookups`
2829
+ * contains this stage's passing case evidence. A partial stage never replaces the last-complete
2830
+ * registry, and refreshed lookups require full collected-declaration equality with that
2831
+ * registry. `duration` is `performance.now` milliseconds spent validating and committing after
2832
+ * child completion, excluding child execution. Failed or interrupted stages reject instead of
2833
+ * returning a partial success result.
2834
+ *
2835
+ * @example
2836
+ * ```ts
2837
+ * const result = await integrity.stamp(options)
2838
+ * result.entries.length // image stamps committed by this stage
2839
+ * ```
2840
+ */
2841
+ export declare interface CaptureStageResult {
2842
+ readonly request: CaptureRequest;
2843
+ readonly projects: readonly CaptureProjectResult[];
2844
+ readonly entries: readonly CaptureStamp[];
2845
+ readonly lookups: readonly CaptureLookup[];
2846
+ readonly duration: number;
2847
+ }
2848
+
2849
+ /**
2850
+ * Selects a freshness population and names the producing variants the host wrapper declares.
2851
+ *
2852
+ * @remarks
2853
+ * `declared` applies only when `variants` is omitted: each declared producing variant needs
2854
+ * full-collection evidence in the registry, so a missing refresh refuses instead of reading as
2855
+ * nothing to check. Auxiliary output variants stay judged through their destinations alone.
2856
+ *
2857
+ * @example
2858
+ * ```ts
2859
+ * const options: CaptureStaleOptions = { selector: 'pages:mail', declared: ['light-390', 'dark-1280'] }
2860
+ * ```
2861
+ */
2862
+ export declare interface CaptureStaleOptions extends CaptureReadOptions {
2863
+ readonly declared?: readonly string[];
2864
+ }
2865
+
2866
+ /**
2867
+ * Begins one independent child termination only after request removal has been attempted.
2868
+ * @example
2869
+ * ```ts
2870
+ * const terminate: CaptureTerminationHandler = () => child.stop()
2871
+ * ```
2872
+ */
2873
+ export declare type CaptureTerminationHandler = () => Promise<boolean>;
2874
+
2875
+ /**
2876
+ * Writes one chunk of runner output to the stream the host chooses.
2877
+ *
2878
+ * @remarks The default writers are `process.stdout` and `process.stderr`.
2879
+ *
2880
+ * @example
2881
+ * ```ts
2882
+ * const write: CaptureWriteHandler = (text) => process.stdout.write(text)
2883
+ * ```
2884
+ */
2885
+ export declare type CaptureWriteHandler = (text: string) => unknown;
2886
+
2887
+ /**
2888
+ * Finds the journey artifact lines that report an uncaught, unhandled, or logged error.
2889
+ *
2890
+ * @param file - The artifact's repository-relative path, which prefixes each finding
2891
+ * @param text - The artifact's text
2892
+ * @returns One finding per matching line
2893
+ *
2894
+ * @example
2895
+ * ```ts
2896
+ * collectCaptureErrors('tmp/journey/light-390.txt', 'ok\nUncaught TypeError') // ['tmp/journey/light-390.txt: Uncaught TypeError']
2897
+ * ```
2898
+ */
2899
+ export declare function collectCaptureErrors(file: string, text: string): readonly string[];
2900
+
2901
+ /**
2902
+ * Groups the selected images whose bytes are identical.
2903
+ *
2904
+ * @param images - The selected images, decoded
2905
+ * @returns One list of files per digest shared by more than one image
2906
+ *
2907
+ * @example
2908
+ * ```ts
2909
+ * collectCaptureIdentical(images) // [['tmp/captures/a.png', 'tmp/captures/b.png']]
2910
+ * ```
2911
+ */
2912
+ export declare function collectCaptureIdentical(images: readonly CaptureImageResult[]): ReadonlyArray<readonly string[]>;
2913
+
2914
+ /**
2915
+ * Composes pictures on the contact-sheet gray background.
2916
+ *
2917
+ * @param pictures - The ordered source cells or rows
2918
+ * @param vertical - If `true`, stacks rows; if `false`, places cells side by side
2919
+ * @param gap - The space between source pictures. Default: 6.
2920
+ * @returns A separately owned composite
2921
+ * @throws Thrown for an empty picture selection.
2922
+ *
2923
+ * @example
2924
+ * ```ts
2925
+ * composeCapturePictures([picture, picture], false).width // picture.width * 2 + 6
2926
+ * ```
2927
+ */
2928
+ export declare function composeCapturePictures(pictures: readonly CapturePicture[], vertical: boolean, gap?: number): CapturePicture;
2929
+
2930
+ /**
2931
+ * Hashes exact source or image bytes with SHA-256.
2932
+ *
2933
+ * @param bytes - The bytes, or the explicitly encoded UTF-8 text
2934
+ * @returns The lowercase hexadecimal digest
2935
+ *
2936
+ * @example
2937
+ * ```ts
2938
+ * computeCaptureHash('') // 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
2939
+ * ```
2940
+ */
2941
+ export declare function computeCaptureHash(bytes: string | Uint8Array): string;
2942
+
2943
+ /**
2944
+ * Computes the registry identity from its authenticated receipts and exact output population.
2945
+ *
2946
+ * @param registry - The registry fields before its digest is attached
2947
+ * @returns The deterministic SHA-256 registry identity
2948
+ *
2949
+ * @example
2950
+ * ```ts
2951
+ * computeRegistryDigest({ version: 1, receipts: [], entries: [] }).length // 64
2952
+ * ```
2953
+ */
2954
+ export declare function computeRegistryDigest(registry: Pick<CaptureRegistry, 'version' | 'receipts' | 'entries'>): string;
2955
+
2956
+ /**
2957
+ * Creates the executable's command dispatcher over a workspace and injected writers.
2958
+ *
2959
+ * @param options - The workspace and the report and diagnostic writers; default: the working directory and the process streams
2960
+ * @returns A new dispatcher whose `execute` runs one command line and returns its exit code
2961
+ *
2962
+ * @example
2963
+ * ```ts
2964
+ * const exit = await createCaptureCLI().execute(['journey', 'pages:mail']) // 0 when the journey passed
2965
+ * ```
2966
+ */
2967
+ export declare function createCaptureCLI(options?: CaptureCLIOptions): CaptureCLIInterface;
2968
+
2969
+ /**
2970
+ * Creates the discovery that reads a consumer's wrapper through the consumer's own Vitest.
2971
+ *
2972
+ * @param options - The workspace, the absolute wrapper path, the invocation that owns the child, and the optional mode and deadline
2973
+ * @returns A new discovery whose `describe` publishes the request and returns the wrapper's host description
2974
+ *
2975
+ * @example
2976
+ * ```ts
2977
+ * const discovery = createCaptureDiscovery({ root: process.cwd(), config, invocation })
2978
+ * const { projects } = await discovery.describe()
2979
+ * ```
2980
+ */
2981
+ export declare function createCaptureDiscovery(options: CaptureDiscoveryRunOptions): CaptureDiscoveryInterface;
2982
+
2983
+ /**
2984
+ * Creates the integrity engine bound to an explicit workspace and host portfolio mapping.
2985
+ *
2986
+ * @param options - The workspace, evidence paths, authorized physical roots, and optional file hash
2987
+ * @returns A new engine that stamps stages, reads declarations, checks freshness, and resolves states
2988
+ * @throws Thrown when the root is not absolute, a path escapes the root, or a portfolio is invalid.
2989
+ *
2990
+ * @example
2991
+ * ```ts
2992
+ * const integrity = createCaptureIntegrity({
2993
+ * root: process.cwd(),
2994
+ * directory: 'tmp/captures/states',
2995
+ * inputs: ['src/**'],
2996
+ * registry: 'tmp/captures/states/registry.json',
2997
+ * manifest: 'tmp/captures/states/manifest.json',
2998
+ * lookups: 'tmp/captures/states/lookups.json',
2999
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
3000
+ * })
3001
+ * ```
3002
+ */
3003
+ export declare function createCaptureIntegrity(options: CaptureIntegrityOptions): CaptureIntegrityInterface;
3004
+
3005
+ /**
3006
+ * Creates the preflight that judges the selected frames' freshness, mixed observations, and coverage.
3007
+ *
3008
+ * @param options - The workspace, the wrapper, the selection, the journey artifact directory, and optional checks module and output seams
3009
+ * @returns A new preflight whose `execute` prints its report and returns the exit status
3010
+ *
3011
+ * @example
3012
+ * ```ts
3013
+ * const preflight = createCapturePreflight({
3014
+ * root: process.cwd(),
3015
+ * config: `${process.cwd()}/configs/app/vite.journey.config.ts`,
3016
+ * selection: { selector: 'pages:mail' },
3017
+ * journeys: `${process.cwd()}/tmp/journey`,
3018
+ * })
3019
+ * const exit = await preflight.execute() // 0 when every selected frame is current and sound
3020
+ * ```
3021
+ */
3022
+ export declare function createCapturePreflight(options: CaptureReaderOptions): CapturePreflightInterface;
3023
+
3024
+ /**
3025
+ * Creates the registry refresh that runs each producing variant's complete journey and publishes the registry.
3026
+ *
3027
+ * @param options - The workspace, the wrapper default, the request directory, the command line, and optional output seams
3028
+ * @returns A new refresh whose `execute` publishes `registry.json` and returns the exit status
3029
+ *
3030
+ * @example
3031
+ * ```ts
3032
+ * const registrar = createCaptureRegistrar({
3033
+ * root: process.cwd(),
3034
+ * config: 'configs/app/vite.journey.config.ts',
3035
+ * requests: 'tmp/capture',
3036
+ * argv: ['--variant', 'light-390'],
3037
+ * })
3038
+ * const exit = await registrar.execute() // 0 when the registry was published
3039
+ * ```
3040
+ */
3041
+ export declare function createCaptureRegistrar(options: CaptureRegistrarOptions): CaptureRegistrarInterface;
3042
+
3043
+ /**
3044
+ * Creates the runner that drives owner-selected journeys for one command line.
3045
+ *
3046
+ * @param options - The command, the workspace, the wrapper default, the request directory, the command line, and optional output and engine seams
3047
+ * @returns A new runner whose `execute` runs the command and returns its exit status
3048
+ *
3049
+ * @example
3050
+ * ```ts
3051
+ * const runner = createCaptureRunner({
3052
+ * command: 'journey',
3053
+ * root: process.cwd(),
3054
+ * config: 'configs/app/vite.journey.config.ts',
3055
+ * requests: 'tmp/units',
3056
+ * argv: ['pages:mail', '--variant', 'light-390'],
3057
+ * })
3058
+ * const exit = await runner.execute() // 0 when every stage passed
3059
+ * ```
3060
+ */
3061
+ export declare function createCaptureRunner(options: CaptureRunnerOptions): CaptureRunnerInterface;
3062
+
3063
+ /**
3064
+ * Creates the contact-sheet writer for the selected frames.
3065
+ *
3066
+ * @param options - The reader options that select the frames and the new directory that receives the sheets
3067
+ * @returns A new writer whose `execute` writes the sheets and returns the exit status
3068
+ *
3069
+ * @example
3070
+ * ```ts
3071
+ * const sheets = createCaptureSheets({ reader, output: `${process.cwd()}/tmp/sheets` })
3072
+ * const exit = await sheets.execute() // 0 when every selected frame is current and sound
3073
+ * ```
3074
+ */
3075
+ export declare function createCaptureSheets(options: CaptureSheetOptions): CaptureSheetsInterface;
3076
+
3077
+ /**
3078
+ * Decodes the eight-bit, non-interlaced PNGs the capture readers consume.
3079
+ *
3080
+ * @remarks
3081
+ * It reads grayscale, grayscale with alpha, RGB, and RGBA, the colour types an encoder writes for a
3082
+ * browser capture. A grayscale sample fills all three channels, and an alpha channel is dropped.
3083
+ * Indexed colour, other bit depths, and interlacing are refused.
3084
+ *
3085
+ * @param bytes - The exact physical image bytes
3086
+ * @returns Image dimensions and RGB pixels
3087
+ * @throws Thrown for unsupported, malformed, or truncated images.
3088
+ *
3089
+ * @example
3090
+ * ```ts
3091
+ * decodeCapturePicture(encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) })).pixels // Uint8Array [1, 2, 3]
3092
+ * ```
3093
+ */
3094
+ export declare function decodeCapturePicture(bytes: Buffer): CapturePicture;
3095
+
3096
+ /**
3097
+ * Describes a refusal with its key path, bounded preview, correction, and member differences.
3098
+ *
3099
+ * @example
3100
+ * ```ts
3101
+ * describeCaptureFault('--variant[0]', 'bad/name', 'a portable segment')
3102
+ * ```
3103
+ */
3104
+ export declare function describeCaptureFault(path: string, value: unknown, expected: string, candidates?: readonly string[], required?: readonly string[], allowed?: readonly string[]): string;
3105
+
3106
+ /**
3107
+ * Describes a bounded member population and the number omitted from its preview.
3108
+ * @example
3109
+ * ```ts
3110
+ * describeCaptureMembers(['wide', 'phone']) // '["wide","phone"]'
3111
+ * ```
3112
+ */
3113
+ export declare function describeCaptureMembers(members: readonly string[]): string;
3114
+
3115
+ /**
3116
+ * Caps external diagnostic text and names the number of omitted characters.
3117
+ * @example
3118
+ * ```ts
3119
+ * describeCaptureOutput('short diagnostic') // 'short diagnostic'
3120
+ * ```
3121
+ */
3122
+ export declare function describeCaptureOutput(output: string): string;
3123
+
3124
+ /**
3125
+ * Describes a project's portfolio roots as comparable lines, primary roots apart from standalone ones.
3126
+ *
3127
+ * @param project - The project whose roots to describe
3128
+ * @returns One line per root, naming its kind, portfolio, directory, and scoping
3129
+ *
3130
+ * @example
3131
+ * ```ts
3132
+ * describeCapturePortfolios({
3133
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
3134
+ * standalone: [],
3135
+ * }) // ['primary states tmp/captures/states true']
3136
+ * ```
3137
+ */
3138
+ export declare function describeCapturePortfolios(project: Pick<CaptureProject, 'portfolios' | 'standalone'>): readonly string[];
3139
+
3140
+ /**
3141
+ * Describes why a selector names nothing the wrapper declares, naming the first unknown segment.
3142
+ *
3143
+ * @remarks
3144
+ * The depth of a segment decides its label: the first segment is a scope and every deeper one an
3145
+ * owner. `all` and every declared owner path, ancestors included, name something.
3146
+ *
3147
+ * @param selector - The requested owner path or `all`
3148
+ * @param selectors - Every owner path the wrapper declares, ancestors included
3149
+ * @returns The refusal text, or `undefined` when the selector names a declared population
3150
+ *
3151
+ * @example
3152
+ * ```ts
3153
+ * describeCaptureSelectorFault('pages:mail', ['pages', 'pages:mail']) // undefined
3154
+ * describeCaptureSelectorFault('pages:none', ['pages', 'pages:mail'])?.includes('selector: received "pages:none"') // true
3155
+ * ```
3156
+ */
3157
+ export declare function describeCaptureSelectorFault(selector: string, selectors: readonly string[]): string | undefined;
3158
+
3159
+ /**
3160
+ * Encodes one checked PNG chunk for contact-sheet output.
3161
+ *
3162
+ * @param name - The four-byte chunk name
3163
+ * @param data - The chunk payload
3164
+ * @returns Header, payload, and checksum bytes
3165
+ *
3166
+ * @example
3167
+ * ```ts
3168
+ * encodeCaptureChunk('IEND', Buffer.alloc(0)).length // 12
3169
+ * ```
3170
+ */
3171
+ export declare function encodeCaptureChunk(name: string, data: Buffer): Buffer;
3172
+
3173
+ /**
3174
+ * Encodes an RGB picture using the contact-sheet writer's native PNG format.
3175
+ *
3176
+ * @param picture - The complete RGB pixel buffer
3177
+ * @param compressed - If `true`, compresses scanlines; if `false`, stores them in the deflate stream. Default: `true`.
3178
+ * @returns A PNG file
3179
+ * @throws Thrown when dimensions and pixel length disagree.
3180
+ *
3181
+ * @example
3182
+ * ```ts
3183
+ * encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) }).subarray(1, 4).toString() // 'PNG'
3184
+ * ```
3185
+ */
3186
+ export declare function encodeCapturePicture(picture: CapturePicture, compressed?: boolean): Buffer;
3187
+
3188
+ /**
3189
+ * Encodes an unsigned 32-bit integer as four big-endian bytes.
3190
+ *
3191
+ * @param value - An integer from 0 through 4294967295
3192
+ * @returns The four bytes, most significant first
3193
+ *
3194
+ * @example
3195
+ * ```ts
3196
+ * encodeCaptureWord(258) // Buffer <00 00 01 02>
3197
+ * ```
3198
+ */
3199
+ export declare function encodeCaptureWord(value: number): Buffer;
3200
+
3201
+ /**
3202
+ * Escapes every regular-expression metacharacter so a case name matches only itself.
3203
+ *
3204
+ * @param text - The literal text
3205
+ * @returns The text with each metacharacter backslash-quoted
3206
+ *
3207
+ * @example
3208
+ * ```ts
3209
+ * escapeCapturePattern('renders (a.b) + c') // 'renders \\(a\\.b\\) \\+ c'
3210
+ * ```
3211
+ */
3212
+ export declare function escapeCapturePattern(text: string): string;
3213
+
3214
+ /**
3215
+ * Inflates a PNG's compressed stream, refusing one that is corrupt or longer than declared.
3216
+ *
3217
+ * @param data - The concatenated data-chunk payloads
3218
+ * @param length - The inflated length the header's dimensions declare
3219
+ * @returns The inflated scanlines
3220
+ * @throws Thrown when the stream is not valid deflate data or inflates past `length`.
3221
+ *
3222
+ * @example
3223
+ * ```ts
3224
+ * inflateCaptureStream(deflateSync(Buffer.from([1, 2, 3])), 3) // Buffer <01 02 03>
3225
+ * ```
3226
+ */
3227
+ export declare function inflateCaptureStream(data: Buffer, length: number): Buffer;
3228
+
3229
+ /**
3230
+ * Compares file content, size, modification time, and change time across two snapshots.
3231
+ *
3232
+ * @example
3233
+ * ```ts
3234
+ * matchesCaptureFile(previous, undefined) // false
3235
+ * ```
3236
+ */
3237
+ export declare function matchesCaptureFile(previous: CaptureFileSnapshot, current: CaptureFileSnapshot | undefined): boolean;
3238
+
3239
+ /**
3240
+ * Checks whether bytes open with the eight-byte PNG signature.
3241
+ *
3242
+ * @param bytes - The leading bytes of a file
3243
+ * @returns True if the first eight bytes equal the signature; false otherwise
3244
+ *
3245
+ * @example
3246
+ * ```ts
3247
+ * matchesCaptureSignature(Uint8Array.from([137, 80, 78, 71, 13, 10, 26, 10])) // true
3248
+ * ```
3249
+ */
3250
+ export declare function matchesCaptureSignature(bytes: Uint8Array): boolean;
3251
+
3252
+ /** Recognizes filesystem contention codes that ownership arbitration can retry.
3253
+ * @param error - The host operation's refusal
3254
+ * @param platform - The host contract; Windows permission errors can reflect handles without delete sharing
3255
+ * @returns Whether the error names temporary ownership contention
3256
+ * @example
3257
+ * ```ts
3258
+ * matchesCaptureTransient(Object.assign(new Error('busy'), { code: 'EBUSY' })) // true
3259
+ * ```
3260
+ */
3261
+ export declare function matchesCaptureTransient(error: unknown, platform?: NodeJS.Platform): boolean;
3262
+
3263
+ /**
3264
+ * Merges unique lookup populations with incoming identities replacing inherited ones.
3265
+ *
3266
+ * @example
3267
+ * ```ts
3268
+ * mergeCaptureLookups([lookup], [lookup]) // [lookup]
3269
+ * ```
3270
+ */
3271
+ export declare function mergeCaptureLookups(previous: readonly CaptureLookup[], lookups: readonly CaptureLookup[]): readonly CaptureLookup[];
3272
+
3273
+ /**
3274
+ * Normalizes a host path to forward slashes.
3275
+ *
3276
+ * @param path - A host path
3277
+ * @returns The same path with every backslash replaced by a slash
3278
+ *
3279
+ * @example
3280
+ * ```ts
3281
+ * normalizeSlashes('tmp\\captures\\a.png') // 'tmp/captures/a.png'
3282
+ * ```
3283
+ */
3284
+ export declare function normalizeSlashes(path: string): string;
3285
+
3286
+ /**
3287
+ * Computes the PNG Paeth predictor used by both image readers.
3288
+ *
3289
+ * @param left - The reconstructed left byte
3290
+ * @param up - The reconstructed byte above
3291
+ * @param corner - The reconstructed upper-left byte
3292
+ * @returns The closest neighbor to the linear estimate
3293
+ *
3294
+ * @example
3295
+ * ```ts
3296
+ * predictCaptureByte(10, 20, 10) // 20
3297
+ * ```
3298
+ */
3299
+ export declare function predictCaptureByte(left: number, up: number, corner: number): number;
3300
+
3301
+ /**
3302
+ * Finds the nearest existing path without following a dangling link.
3303
+ *
3304
+ * @example
3305
+ * ```ts
3306
+ * readCaptureAncestor('/workspace/missing/file') // '/workspace'
3307
+ * ```
3308
+ */
3309
+ export declare function readCaptureAncestor(path: string): string;
3310
+
3311
+ /**
3312
+ * Reads the runner's command line into one selector, its flags, and the resolved wrapper path.
3313
+ *
3314
+ * @remarks
3315
+ * `--state` belongs to `capture` and `stale`, and `--portfolio` to `stale`. Journey and capture
3316
+ * accept `--changed <ref>` instead of a selector, with optional valueless `--plan`. Every other
3317
+ * flag takes one nonempty value, either separated or in equals form, and only `--variant` repeats.
3318
+ * A value beginning with a dash requires equals form. A bare invocation leaves its selector absent
3319
+ * so the caller can print usage with the declared selectors.
3320
+ *
3321
+ * @param argv - The arguments after the entry name
3322
+ * @param command - The runner command the flags belong to
3323
+ * @param root - The absolute workspace path the wrapper path resolves against
3324
+ * @param fallback - The repository-relative wrapper path used when `--config` is absent
3325
+ * @returns The parsed arguments with an absolute wrapper path
3326
+ * @throws Thrown as a `USAGE` capture error for an unknown, repeated, misplaced, or valueless flag, a
3327
+ * second selector, a repeated or invalid variant, an invalid state, or an empty case.
3328
+ *
3329
+ * @example
3330
+ * ```ts
3331
+ * readCaptureArguments(['pages:mail', '--variant', 'light-390'], 'journey', '/repo', 'vite.journey.config.ts')
3332
+ * // { selector: 'pages:mail', config: '/repo/vite.journey.config.ts', variants: ['light-390'] }
3333
+ * ```
3334
+ */
3335
+ export declare function readCaptureArguments(argv: readonly string[], command: CaptureCommand, root: string, fallback: string): CaptureRunnerArguments;
3336
+
3337
+ /**
3338
+ * Reads PNG compressed-data chunks while refusing truncated or corrupt image bytes.
3339
+ *
3340
+ * @param bytes - The complete PNG
3341
+ * @param offset - The next chunk header. Default: 8.
3342
+ * @returns Ordered compressed-data chunks
3343
+ * @throws Thrown for truncated chunks, bad checksums, or a missing closing chunk.
3344
+ *
3345
+ * @example
3346
+ * ```ts
3347
+ * readCaptureChunks(encodeCapturePicture(picture)).length // 1
3348
+ * ```
3349
+ */
3350
+ export declare function readCaptureChunks(bytes: Buffer, offset?: number): readonly Buffer[];
3351
+
3352
+ /**
3353
+ * Accepts the description a wrapper wrote only when it answers this exchange and no other.
3354
+ *
3355
+ * @remarks
3356
+ * Every echo must match: the invocation, the challenge, the wrapper path, the runner as the
3357
+ * wrapper's parent, and the child the runner spawned as the writer. Each project then passes the same
3358
+ * reader the wrapper's own declarations pass through, and the list may not be empty.
3359
+ *
3360
+ * @param value - The parsed description file
3361
+ * @param expected - What the request and the spawn establish
3362
+ * @returns The validated description
3363
+ * @throws Thrown as a `HOST` capture error naming the first echo that differs, a malformed
3364
+ * document, an empty project list, or a malformed project.
3365
+ *
3366
+ * @example
3367
+ * ```ts
3368
+ * const description = readCaptureDescription(parseJSON(text), expected)
3369
+ * ```
3370
+ */
3371
+ export declare function readCaptureDescription(value: unknown, expected: CaptureDescriptionExpectation): CaptureHostDescription;
3372
+
3373
+ /**
3374
+ * Reads one wrapper project, as the description file holds it, into its host declarations and viewport.
3375
+ *
3376
+ * @remarks
3377
+ * The viewport is read when the project declares geometry for its producing variant and is absent
3378
+ * otherwise, because a runner command needs none and only a reader refuses its absence.
3379
+ *
3380
+ * @param value - The resolved project as plain data
3381
+ * @returns The validated project and, when it declares one, its producing viewport
3382
+ * @throws Thrown as a `HOST` capture error when the project is a path or a non-record, or when its
3383
+ * declarations are malformed.
3384
+ *
3385
+ * @example
3386
+ * ```ts
3387
+ * const { project } = readCaptureEntry({ test: { name: 'journey:light-390', provide } })
3388
+ * project.variant // 'light-390'
3389
+ * ```
3390
+ */
3391
+ export declare function readCaptureEntry(value: unknown): CaptureHostEntry;
3392
+
3393
+ /**
3394
+ * Reads an image only after its opened file's size is inside the compressed-byte budget.
3395
+ * @throws Thrown when the file is oversized, unreadable, or changes size during the read.
3396
+ * @example
3397
+ * ```ts
3398
+ * const bytes = readCaptureImage('/workspace/tmp/captures/mail.png')
3399
+ * ```
3400
+ */
3401
+ export declare function readCaptureImage(file: string): Buffer;
3402
+
3403
+ /**
3404
+ * Reads the bounded input population a project declares, as file paths and content hashes.
3405
+ *
3406
+ * @remarks
3407
+ * The expansion is the one the integrity engine takes: the native glob over the patterns, regular
3408
+ * files only, sorted, each path contained in the workspace. A pattern that matches nothing
3409
+ * contributes no file.
3410
+ *
3411
+ * @param root - The absolute workspace path
3412
+ * @param patterns - The project's native input patterns
3413
+ * @param hash - Digests each file's exact bytes. Default: `computeCaptureHash`
3414
+ * @param read - Reads a contained input through the owning operation's snapshot memo, when supplied
3415
+ * @returns The workspace-relative path of every matched file and its digest
3416
+ * @throws Thrown as a `CONTAINMENT` capture error for a matched path the evidence cannot hold, and as
3417
+ * an `EVIDENCE` capture error for a path that matches under two spellings.
3418
+ *
3419
+ * @example
3420
+ * ```ts
3421
+ * readCaptureInputs(process.cwd(), ['src/**']) // { 'src/a.ts': '3f2a…' }
3422
+ * ```
3423
+ */
3424
+ export declare function readCaptureInputs(root: string, patterns: readonly string[], hash?: CaptureHashHandler, read?: CaptureInputHandler): Readonly<Record<string, string>>;
3425
+
3426
+ /**
3427
+ * Resolves journal lookup references after verifying each stored input population's digest.
3428
+ *
3429
+ * @param journal - A structurally validated lookup journal
3430
+ * @returns Every expanded lookup in its stored order, sharing the verified input maps
3431
+ * @throws Thrown when an input digest differs from its map or a lookup names an unknown digest.
3432
+ *
3433
+ * @example
3434
+ * ```ts
3435
+ * readCaptureLookups(buildCaptureLookupJournal([], [])) // []
3436
+ * ```
3437
+ */
3438
+ export declare function readCaptureLookups(journal: CaptureLookupJournal): readonly CaptureLookup[];
3439
+
3440
+ /**
3441
+ * Parses standard option tokens and refuses empty values, terminators, and repeated single options.
3442
+ *
3443
+ * @param argv - The arguments after the subcommand
3444
+ * @param options - The command's frozen Node option definitions
3445
+ * @param usage - The command syntax appended to every parser refusal
3446
+ * @returns Typed values, positionals, and the tokens that supplied them
3447
+ * @example
3448
+ * ```ts
3449
+ * readCaptureOptions(['--case=-draft'], CAPTURE_COMMAND_OPTIONS.journey, 'Usage: capture journey <selector>').values.case // '-draft'
3450
+ * ```
3451
+ */
3452
+ export declare function readCaptureOptions<Options extends ParseArgsOptionsConfig>(argv: readonly string[], options: Options, usage: string): CaptureParsedArguments<Options>;
3453
+
3454
+ /**
3455
+ * Reads the physical portfolio roots a wrapper declares and refuses a malformed or repeated root.
3456
+ *
3457
+ * @param value - The wrapper's declaration, expected to be a list of roots
3458
+ * @param subject - The name of the declaration in a refusal
3459
+ * @returns The validated roots in declaration order
3460
+ * @throws Thrown as a `HOST` capture error when the declaration is not a list or a root is malformed, and
3461
+ * as an `EVIDENCE` capture error when a portfolio name repeats, case-folded.
3462
+ *
3463
+ * @example
3464
+ * ```ts
3465
+ * readCapturePortfolios([{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }], 'portfolios')
3466
+ * ```
3467
+ */
3468
+ export declare function readCapturePortfolios(value: unknown, subject: string): readonly CapturePortfolioRoot[];
3469
+
3470
+ /**
3471
+ * Reads one wrapper project's host declarations from its Vitest test configuration.
3472
+ *
3473
+ * @remarks
3474
+ * The label is the project's `name` or its `label` member. Tags must not contain whitespace or a
3475
+ * tag-filter operator, and a variant must be a portable identity. The project's own `variant` must
3476
+ * be one of the declared `variants`, and so must the `first` stage variant. Portfolio roots and
3477
+ * the final case are required, and standalone roots default to none. `uniform` is an optional
3478
+ * list of unique valid owner selectors for the preflight's frame scan. Default: every scope.
3479
+ * An empty list judges none; the declaration never narrows the other readings.
3480
+ *
3481
+ * @param test - The project's `test` configuration, or any value the wrapper supplied in its place
3482
+ * @returns The validated project declaration
3483
+ * @throws Thrown as a `HOST` capture error when a declaration is missing or malformed.
3484
+ *
3485
+ * @example
3486
+ * ```ts
3487
+ * const project = readCaptureProject({
3488
+ * name: 'journey:light-390',
3489
+ * tags: [{ name: 'owner:pages:mail' }],
3490
+ * provide: {
3491
+ * variant: 'light-390',
3492
+ * variants: [{ name: 'light-390' }],
3493
+ * directory: '/repo/tmp/captures/states',
3494
+ * record: 'tmp/captures/states/runs/a/light-390.json',
3495
+ * inputs: ['src/**'],
3496
+ * final: 'closes the run',
3497
+ * first: 'light-390',
3498
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
3499
+ * },
3500
+ * })
3501
+ * project.variant // 'light-390'
3502
+ * ```
3503
+ */
3504
+ export declare function readCaptureProject(test: unknown): CaptureProject;
3505
+
3506
+ /**
3507
+ * Reads a reader's command line into its selection, its flags, and the resolved paths.
3508
+ *
3509
+ * @remarks
3510
+ * The first argument is the selector and every flag after it takes one nonempty value, separated
3511
+ * or in equals form. Only `--variant` repeats. `--output` belongs to sheets; the preflight option
3512
+ * table refuses it before discovery. The wrapper, the journey artifact directory, and the checks module
3513
+ * resolve against `root`; `defaults` supplies the first two when the command line names neither.
3514
+ *
3515
+ * @param argv - The arguments after the entry name
3516
+ * @param root - The absolute workspace path the paths resolve against
3517
+ * @param defaults - The repository-relative wrapper and journey artifact directory to fall back to
3518
+ * @param command - The reader command whose option table applies. Default: `sheets`
3519
+ * @returns The reader options and the optional contact-sheet directory
3520
+ * @throws Thrown as a `USAGE` capture error for an absent selector, an unknown, repeated, or
3521
+ * valueless flag.
3522
+ *
3523
+ * @example
3524
+ * ```ts
3525
+ * readCaptureReaderArguments(['pages:mail', '--variant', 'light-390'], '/repo', {
3526
+ * config: 'configs/vite.journey.config.ts',
3527
+ * journeys: 'tmp/journey',
3528
+ * }).reader.selection // { selector: 'pages:mail', variants: ['light-390'] }
3529
+ * ```
3530
+ */
3531
+ export declare function readCaptureReaderArguments(argv: readonly string[], root: string, defaults: CaptureReaderDefaults, command?: 'preflight' | 'sheets'): CaptureReaderCommand;
3532
+
3533
+ /**
3534
+ * Reads the registry command line into the wrapper path, the variants to refresh, and the mode.
3535
+ *
3536
+ * @remarks
3537
+ * The command takes no selector: it refreshes every producing variant the wrapper declares, or the
3538
+ * variants named by repeated `--variant` flags. Every flag takes one value, and only `--variant`
3539
+ * repeats. `--mode` is forwarded to the wrapper's Vitest process unread.
3540
+ *
3541
+ * @param argv - The arguments after the subcommand
3542
+ * @param root - The absolute workspace path the wrapper path resolves against
3543
+ * @param fallback - The repository-relative wrapper path used when `--config` is absent
3544
+ * @returns The parsed arguments with an absolute wrapper path
3545
+ * @throws Thrown as a `USAGE` capture error for a positional argument, an unknown, repeated, or
3546
+ * valueless flag, or a repeated or invalid variant.
3547
+ *
3548
+ * @example
3549
+ * ```ts
3550
+ * readCaptureRegistryArguments(['--variant', 'light-390'], '/repo', 'vite.journey.config.ts')
3551
+ * // { config: '/repo/vite.journey.config.ts', variants: ['light-390'] }
3552
+ * ```
3553
+ */
3554
+ export declare function readCaptureRegistryArguments(argv: readonly string[], root: string, fallback: string): CaptureRegistryArguments;
3555
+
3556
+ /**
3557
+ * Reads and validates the request the runner wrote for the wrapper process that is its child.
3558
+ *
3559
+ * @remarks
3560
+ * Only the file named by `ppid` is read, so a request a stopped runner left never reaches a run
3561
+ * that has no runner parent. Every refusal names its cause: a file that does not parse, a record
3562
+ * whose `pid` differs from the parent's, arguments that differ from the process's own, an
3563
+ * unsupported version, an identity that is not a portable segment, a wrapper path that is not
3564
+ * `config`, a state on a command that cannot carry one, and a command, selector, variant list, or
3565
+ * case the wrapper does not declare.
3566
+ *
3567
+ * @param options - The parent id, the process arguments, the request directory, and the wrapper's declarations
3568
+ * @returns The validated request, or `undefined` when the parent wrote none
3569
+ * @throws Thrown as a `HOST` capture error when a request exists and fails any check.
3570
+ *
3571
+ * @example
3572
+ * ```ts
3573
+ * const request = readCaptureRequest({
3574
+ * ppid: process.ppid,
3575
+ * argv: process.argv.slice(1),
3576
+ * directory: '/repo/tmp/units',
3577
+ * config: 'configs/vite.journey.config.ts',
3578
+ * owners: ['pages:mail'],
3579
+ * variants: ['light-390'],
3580
+ * })
3581
+ * request?.selector // 'pages:mail', or undefined when no runner is the parent
3582
+ * ```
3583
+ */
3584
+ export declare function readCaptureRequest(options: CaptureRequestOptions): CaptureRequest | undefined;
3585
+
3586
+ /**
3587
+ * Reads the process id that a request file, or its temporary sibling, names.
3588
+ *
3589
+ * @param name - A file name from the request directory
3590
+ * @returns The positive process id the name carries, or `undefined` for any other name
3591
+ *
3592
+ * @example
3593
+ * ```ts
3594
+ * readCaptureRequestOwner('journey-selection-4242.json') // 4242
3595
+ * readCaptureRequestOwner('journey-selection-4242.json.tmp') // 4242
3596
+ * readCaptureRequestOwner('journey-selection.json') // undefined
3597
+ * ```
3598
+ */
3599
+ export declare function readCaptureRequestOwner(name: string): number | undefined;
3600
+
3601
+ /**
3602
+ * Checks whether a process with this id is running, counting one the caller may not signal.
3603
+ *
3604
+ * @remarks
3605
+ * A zero signal tests existence without sending one. A refusal for permission still proves the
3606
+ * process exists, so only a missing process reads as not running.
3607
+ *
3608
+ * @param pid - The process id
3609
+ * @returns True if the process exists; false otherwise
3610
+ *
3611
+ * @example
3612
+ * ```ts
3613
+ * readCaptureRunning(process.pid) // true
3614
+ * ```
3615
+ */
3616
+ export declare function readCaptureRunning(pid: number): boolean;
3617
+
3618
+ /**
3619
+ * Reads the installed workspace Vitest's exact title separator, refusing unsupported majors.
3620
+ * @example
3621
+ * ```ts
3622
+ * readCaptureSeparator('/workspace/node_modules/vitest/vitest.mjs') // ' ' on Vitest 4
3623
+ * ```
3624
+ */
3625
+ export declare function readCaptureSeparator(entry: string): string;
3626
+
3627
+ /**
3628
+ * Reads original title segments from the accepted registry's authenticated JSON reporter files.
3629
+ * @param root - The repository root that contains the registry and its reporters
3630
+ * @param file - The accepted registry path
3631
+ * @param selector - The optional owner selector that bounds the case candidates
3632
+ * @returns Exact case names mapped to their original title segments within the selected owners
3633
+ * @example
3634
+ * ```ts
3635
+ * const titles = readCaptureTitles('/workspace', '/workspace/tmp/captures/states/registry.json')
3636
+ * ```
3637
+ */
3638
+ export declare function readCaptureTitles(root: string, file: string, selector?: string): Readonly<Record<string, readonly string[]>>;
3639
+
3640
+ /**
3641
+ * Reads output variant candidates without authenticating or accepting registry evidence.
3642
+ * @remarks Missing, unreadable, or malformed registries supply no candidate hints; the integrity engine still authenticates every accepted read.
3643
+ * @example
3644
+ * ```ts
3645
+ * readCaptureVariants('/workspace', '/workspace/tmp/captures/states/registry.json') // [] when absent
3646
+ * ```
3647
+ */
3648
+ export declare function readCaptureVariants(root: string, file: string): readonly string[];
3649
+
3650
+ /**
3651
+ * Reads the viewport a wrapper project's producing variant declares.
3652
+ *
3653
+ * @param test - The project's `test` configuration, or any value the wrapper supplied in its place
3654
+ * @returns The producing variant's name and pixel geometry
3655
+ * @throws Thrown as a `HOST` capture error when the project declares no variant geometry or its
3656
+ * producing variant has none.
3657
+ *
3658
+ * @example
3659
+ * ```ts
3660
+ * readCaptureViewport({
3661
+ * provide: { variant: 'light-390', variants: [{ name: 'light-390', width: 390, height: 844 }] },
3662
+ * }) // { name: 'light-390', width: 390, height: 844 }
3663
+ * ```
3664
+ */
3665
+ export declare function readCaptureViewport(test: unknown): CaptureViewport;
3666
+
3667
+ /**
3668
+ * Renders an exact owner command with the selected variants and filters in host shell syntax.
3669
+ *
3670
+ * @param command - The request command, translated to its executable name, or the registry command
3671
+ * @param parsed - The parsed flags; changed and plan flags are deliberately replaced by the owner
3672
+ * @param selector - The explicit owner or all selector; omitted for a registry refresh
3673
+ * @param root - The workspace that makes the wrapper path relative
3674
+ * @returns The command ready to copy into the host shell
3675
+ * @example
3676
+ * ```ts
3677
+ * renderCaptureCommand('journey', { config: '/repo/journey.ts', variants: [] }, 'pages:mail', '/repo')
3678
+ * // 'capture journey pages:mail --config journey.ts'
3679
+ * ```
3680
+ */
3681
+ export declare function renderCaptureCommand(command: CaptureCommand | 'registry', parsed: CaptureRunnerArguments, selector: string | undefined, root: string): string;
3682
+
3683
+ /** Validates a supplied path argument before work and classifies an outside value as usage.
3684
+ * @param root - The repository root
3685
+ * @param path - The supplied path resolved against the root
3686
+ * @param flag - The command line flag that supplied the path
3687
+ * @returns The contained physical path
3688
+ * @example
3689
+ * ```ts
3690
+ * requireCaptureArgument('/workspace', '/workspace/checks.ts', '--checks')
3691
+ * ```
3692
+ */
3693
+ export declare function requireCaptureArgument(root: string, path: string, flag: string): string;
3694
+
3695
+ /**
3696
+ * Validates a physical destination against a physical root before any read or write.
3697
+ *
3698
+ * @returns The physical destination, including its missing suffix
3699
+ * @throws Thrown when the destination or an existing ancestor escapes the root.
3700
+ * @example
3701
+ * ```ts
3702
+ * requireCaptureContained('/workspace', '/workspace/tmp/new') // '/workspace/tmp/new'
3703
+ * ```
3704
+ */
3705
+ export declare function requireCaptureContained(root: string, path: string): string;
3706
+
3707
+ /**
3708
+ * Refuses compressed image bytes before file reads or chunk-buffer allocation.
3709
+ * @example
3710
+ * ```ts
3711
+ * requireCaptureImageSize(4096) // undefined
3712
+ * ```
3713
+ */
3714
+ export declare function requireCaptureImageSize(size: number): void;
3715
+
3716
+ /**
3717
+ * Refuses a wrapper project set whose members repeat or disagree on a host declaration.
3718
+ *
3719
+ * @remarks
3720
+ * Project labels are unique and so is each project's own variant, case-folded. Every project must
3721
+ * declare the same primary directory, inputs, variants, first-stage variant, final case, and
3722
+ * portfolio roots, because the runner builds one engine for the whole set. Uniform declarations
3723
+ * must also agree as populations, with absence distinct from an empty list.
3724
+ *
3725
+ * @param projects - The wrapper's projects
3726
+ * @returns The first project, whose declarations every other project matches
3727
+ * @throws Thrown as a `HOST` capture error when the set is empty or its members disagree, and as an
3728
+ * `EVIDENCE` capture error when a label or variant repeats.
3729
+ *
3730
+ * @example
3731
+ * ```ts
3732
+ * requireCaptureProjects([project]) // project
3733
+ * ```
3734
+ */
3735
+ export declare function requireCaptureProjects(projects: readonly CaptureProject[]): CaptureProject;
3736
+
3737
+ /**
3738
+ * Refuses unknown command selections from the wrapper before authenticating disk evidence.
3739
+ * @example
3740
+ * ```ts
3741
+ * requireCaptureSelection('all', [], projects) // undefined for declared wrapper projects
3742
+ * ```
3743
+ */
3744
+ export declare function requireCaptureSelection(selector: string, variants: readonly string[], projects: readonly CaptureProject[], outputs?: readonly string[], portfolio?: string): void;
3745
+
3746
+ /**
3747
+ * Maps usage refusals to exit 64 and every other failure to exit 1.
3748
+ *
3749
+ * @example
3750
+ * ```ts
3751
+ * resolveCaptureExit(new CaptureError('Invalid flag', { code: 'USAGE' })) // 64
3752
+ * ```
3753
+ */
3754
+ export declare function resolveCaptureExit(error: unknown): number;
3755
+
3756
+ /**
3757
+ * Resolves an existing path or its nearest existing ancestor to its physical destination.
3758
+ *
3759
+ * @example
3760
+ * ```ts
3761
+ * resolveCapturePhysical('/workspace/alias/new') // '/workspace/target/new'
3762
+ * ```
3763
+ */
3764
+ export declare function resolveCapturePhysical(path: string): string;
3765
+
3766
+ /**
3767
+ * Resolves a path to the slash-separated form the evidence documents store, relative to a root.
3768
+ *
3769
+ * @param root - The absolute workspace path
3770
+ * @param target - The absolute or workspace-relative path
3771
+ * @returns The path relative to the root, with every backslash replaced by a slash
3772
+ *
3773
+ * @example
3774
+ * ```ts
3775
+ * resolveCaptureRelative(process.cwd(), resolve('tmp', 'units')) // 'tmp/units'
3776
+ * ```
3777
+ */
3778
+ export declare function resolveCaptureRelative(root: string, target: string): string;
3779
+
3780
+ /**
3781
+ * Resolves the directory that holds the runner's request files for the process that reads them.
3782
+ *
3783
+ * @remarks
3784
+ * A directory the wrapper names wins. Otherwise the directory the runner handed this child in
3785
+ * `CAPTURE_REQUESTS` applies, and a process the runner did not start reads `CAPTURE_DEFAULTS.requests`
3786
+ * beneath its working directory. The one default therefore lives here and in the executable, and a
3787
+ * consumer never has to repeat it.
3788
+ *
3789
+ * @param directory - The directory the wrapper declares, when it declares one
3790
+ * @returns The absolute directory
3791
+ *
3792
+ * @example
3793
+ * ```ts
3794
+ * resolveCaptureRequests('/repo/tmp/units') // '/repo/tmp/units'
3795
+ * ```
3796
+ */
3797
+ export declare function resolveCaptureRequests(directory?: string): string;
3798
+
3799
+ /**
3800
+ * Names a sheet group by portfolio, owner, and state independently of its output variant.
3801
+ *
3802
+ * @example
3803
+ * ```ts
3804
+ * resolveCaptureSheetIdentity(entry) // '["states","pages:mail","mail-screen"]'
3805
+ * ```
3806
+ */
3807
+ export declare function resolveCaptureSheetIdentity(entry: CaptureDestination): string;
3808
+
3809
+ /**
3810
+ * Plans one selected journey stage or narrow and remaining frame stages.
3811
+ *
3812
+ * @remarks
3813
+ * Journeys run every selected variant together. Frame captures stage the first variant alone and
3814
+ * the remaining variants together. Empty stages are dropped and no unselected variant is added.
3815
+ *
3816
+ * @param variants - The selected variants in declaration order
3817
+ * @param first - The variant the wrapper stages alone first
3818
+ * @param command - The journey or capture command whose stage contract applies
3819
+ * @returns The non-empty stages in run order
3820
+ *
3821
+ * @example
3822
+ * ```ts
3823
+ * resolveCaptureStages(['wide', 'compact'], 'compact', 'capture')
3824
+ * // [{ name: 'narrow', variants: ['compact'] }, { name: 'rest', variants: ['wide'] }]
3825
+ * ```
3826
+ */
3827
+ export declare function resolveCaptureStages(variants: readonly string[], first: string, command: CaptureRequest['command']): readonly CaptureStagePlan[];
3828
+
3829
+ /**
3830
+ * Resolves selected producing variants in declaration order and requires their projects.
3831
+ *
3832
+ * @param selected - Explicit variants, or an empty list for every declared variant
3833
+ * @param projects - The discovered host projects
3834
+ * @returns The declared variants the selection includes
3835
+ * @throws Thrown as USAGE for an unknown variant or HOST for missing variant projects.
3836
+ * @example
3837
+ * ```ts
3838
+ * const variants = resolveCaptureVariants(['light-390'], projects)
3839
+ * // ['light-390'] when the wrapper declares its project
3840
+ * ```
3841
+ */
3842
+ export declare function resolveCaptureVariants(selected: readonly string[], projects: readonly CaptureProject[]): readonly string[];
3843
+
3844
+ /**
3845
+ * Resolves one entry of a wrapper's project list to the project it declares.
3846
+ *
3847
+ * @remarks
3848
+ * A factory entry is called with the serve command and the test mode, as Vitest calls it, and a
3849
+ * promise is awaited. The result is the project as plain data, not yet judged: the runner reads
3850
+ * and validates it, so one reader owns every refusal.
3851
+ *
3852
+ * @param input - The entry as the wrapper declared it: an inline project, a promise of one, or a factory
3853
+ * @returns The resolved project, whatever it holds
3854
+ *
3855
+ * @example
3856
+ * ```ts
3857
+ * const project = await resolveCaptureWrapperProject(wrapper.test.projects[0])
3858
+ * ```
3859
+ */
3860
+ export declare function resolveCaptureWrapperProject(input: unknown): Promise<unknown>;
3861
+
3862
+ /**
3863
+ * Reports a portfolio, owner, and viewport whose frames mix cropped, viewport-sized, and page-sized images.
3864
+ *
3865
+ * @remarks
3866
+ * Only a frame at its own producing variant counts, so an auxiliary output variant never joins its
3867
+ * producer's group. A frame narrower than its viewport reads `crop`, one as tall as the viewport
3868
+ * reads `viewport`, and any other reads `page`. The observation names the mixture without inferring
3869
+ * which framing was intended.
3870
+ *
3871
+ * @param images - The selected images, decoded
3872
+ * @param producers - The wrapper's producing viewports
3873
+ * @returns One observation per group that holds more than one kind
3874
+ *
3875
+ * @example
3876
+ * ```ts
3877
+ * scanCaptureFrames(images, producers) // ['Mixed framing: states/pages:mail@390: page, viewport']
3878
+ * ```
3879
+ */
3880
+ export declare function scanCaptureFrames(images: readonly CaptureImageResult[], producers: readonly CaptureProducer[]): readonly string[];
3881
+
3882
+ /**
3883
+ * Settles independent request removal and child termination without hiding either failure.
3884
+ *
3885
+ * @returns Every removal, termination, or unconfirmed-exit failure
3886
+ * @example
3887
+ * ```ts
3888
+ * await settleCaptureShutdown(() => invocation.retract(), [() => child.stop()]) // []
3889
+ * ```
3890
+ */
3891
+ export declare function settleCaptureShutdown(retract: CaptureRetractionHandler, terminations: readonly CaptureTerminationHandler[]): Promise<readonly unknown[]>;
3892
+
3893
+ /**
3894
+ * Scales a picture with an exact area average and clips its displayed height.
3895
+ *
3896
+ * @param picture - The source RGB picture
3897
+ * @param factor - The integer reduction factor
3898
+ * @param limit - The maximum displayed height
3899
+ * @returns A separately owned scaled picture
3900
+ *
3901
+ * @example
3902
+ * ```ts
3903
+ * shrinkCapturePicture({ width: 2, height: 2, pixels: new Uint8Array(12) }, 2, 8).width // 1
3904
+ * ```
3905
+ */
3906
+ export declare function shrinkCapturePicture(picture: CapturePicture, factor: number, limit: number): CapturePicture;
3907
+
3908
+ /**
3909
+ * Splits a list into consecutive pages with at most the requested size.
3910
+ *
3911
+ * @example
3912
+ * ```ts
3913
+ * splitCapturePages([1, 2, 3], 2) // [[1, 2], [3]]
3914
+ * ```
3915
+ */
3916
+ export declare function splitCapturePages<T>(entries: readonly T[], size: number): ReadonlyArray<readonly T[]>;
3917
+
3918
+ /**
3919
+ * Reconstructs one filtered PNG scanline from its filter byte and the row above.
3920
+ *
3921
+ * @param filter - The scanline's filter type, from 0 through 4
3922
+ * @param line - The filtered bytes of the row, without the filter byte
3923
+ * @param above - The reconstructed row above, or `undefined` for the first row
3924
+ * @param channels - The number of bytes in one pixel
3925
+ * @returns The reconstructed row
3926
+ *
3927
+ * @example
3928
+ * ```ts
3929
+ * unfilterCaptureRow(1, Uint8Array.from([1, 1, 1, 1]), undefined, 1) // Uint8Array [1, 2, 3, 4]
3930
+ * ```
3931
+ */
3932
+ export declare function unfilterCaptureRow(filter: number, line: Uint8Array, above: Uint8Array | undefined, channels: number): Uint8Array;
3933
+
3934
+ /**
3935
+ * Writes one JSON document atomically, so a reader sees the old bytes or the new and never a part.
3936
+ *
3937
+ * @remarks
3938
+ * The document is written to a unique temporary sibling, flushed, and renamed over the target. The
3939
+ * signal is checked after the flush and before the rename, and the temporary file never outlives the
3940
+ * call.
3941
+ *
3942
+ * @param path - The absolute target path, whose directory is created when missing
3943
+ * @param value - The value to serialize
3944
+ * @param signal - Aborts the write before the rename when it fires
3945
+ *
3946
+ * @example
3947
+ * ```ts
3948
+ * writeCaptureDocument('/repo/tmp/captures/states/registry.json', registry)
3949
+ * ```
3950
+ */
3951
+ export declare function writeCaptureDocument(path: string, value: unknown, signal?: AbortSignal): void;
3952
+
3953
+ export { }