@orkestrel/capture 0.0.8 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,83 @@
1
+ /**
2
+ * Builds the required output pair of each state an eligible owner-bearing case declares.
3
+ *
4
+ * @param cases - Every collected case, including cases a runner filter excluded
5
+ * @param rules - The host's part and source resolvers
6
+ * @param options - The producing project and the portfolio mapping of each state
7
+ * @returns One destination per declared state, in case and state order
8
+ * @throws Thrown as a `HOST` capture error when a state has no single mapping or resolves outside its case's owner or the scope, part, and optional section form.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * buildCaptureDestinations(cases, rules, { project: 'journey:light-390', portfolios })[0]?.file
13
+ * // 'tmp/captures/states/pages/inbox--light-390.png'
14
+ * ```
15
+ */
16
+ export declare function buildCaptureDestinations(cases: readonly CaptureCase[], rules: CaptureRules, options: CaptureDestinationOptions): readonly CaptureDestination[];
17
+
18
+ /**
19
+ * Builds a run record from collected cases, the run's destinations, and its observed and emitted states.
20
+ *
21
+ * @param options - The cases, registry, observed states, emitted state-to-path pairs, and execution context
22
+ * @returns The final record, without the journey artifact the caller binds after rendering it
23
+ * @throws Thrown as a `HOST` capture error for an owner-bearing case with no variant, and as an `EVIDENCE` capture error for an emitted state with no destination, a path other than its destination's file, or a producing case with no measured duration.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const run = buildCaptureRun({ cases, registry, observed, emitted, variant: 'light-390', time })
28
+ * validateCaptureRun(run, readCaptureReport(parseJSON(text)), 'journey:light-390')
29
+ * ```
30
+ */
31
+ export declare function buildCaptureRun(options: CaptureRunOptions): CaptureRun;
32
+
33
+ /**
34
+ * Builds the owner and capture tags a wrapper declares for its owner population.
35
+ *
36
+ * @param owners - Every canonical owner path the host declares
37
+ * @returns The unique `owner:` tag of each owner and ancestor, and each owner's scope and part tags
38
+ * @throws Thrown as a `HOST` capture error naming each owner that is not a canonical selector.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * buildCaptureTags(['pages:mail'])
43
+ * // ['owner:pages', 'owner:pages:mail', 'pages', 'pages:mail']
44
+ * ```
45
+ */
46
+ export declare function buildCaptureTags(owners: readonly string[]): readonly string[];
47
+
48
+ /**
49
+ * Builds the Vitest test options of one capture case from its declaration.
50
+ *
51
+ * @param input - The case's owner, states, producing variant, and harness values
52
+ * @param rules - The host's owners and part resolver
53
+ * @returns The derived tags, the capture metadata, and the optional timeout
54
+ * @throws Thrown as a `HOST` capture error for an undeclared owner or tag, tags beside an owner, capture tags with no states, or a state whose part is undeclared or outside the owner.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * buildCaptureTest({ owner: 'pages:mail', states: ['inbox'], variant: 'light-390' }, rules).tags
59
+ * // ['owner:pages', 'owner:pages:mail', 'pages', 'pages:mail']
60
+ * ```
61
+ */
62
+ export declare function buildCaptureTest(input: CaptureTestInput, rules: CaptureRules): CaptureTestOptions;
63
+
64
+ /**
65
+ * Names the journey artifact line prefixes that bind a run record and each case that ran.
66
+ *
67
+ * @remarks
68
+ * The preflight reader requires the line `record=<record path>` and one `case-ran=<full name>`
69
+ * line for each stamping case.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * `${CAPTURE_ARTIFACT_PREFIXES.case}mail opens the inbox` // 'case-ran=mail opens the inbox'
74
+ * ```
75
+ */
76
+ export declare const CAPTURE_ARTIFACT_PREFIXES: Readonly<{
77
+ readonly record: 'record=';
78
+ readonly case: 'case-ran=';
79
+ }>;
80
+
1
81
  /**
2
82
  * Keys the global brand a capture error carries, so a duplicate installation recognizes it.
3
83
  *
@@ -19,7 +99,9 @@ export declare const CAPTURE_ERROR_BRAND: unique symbol;
19
99
  * `USAGE` is a refused command line and exits 64; every other condition exits 1. `SELECTION`
20
100
  * names a selector, variant, case, state, or portfolio the host does not declare. `HOST` names a
21
101
  * wrapper, configuration, or declaration fault. `STAGE` names a runner stage that did not
22
- * complete. `EVIDENCE` names a record, report, registry, or manifest that fails its protocol.
102
+ * complete. `EVIDENCE` names a record, report, journal, or manifest that fails its protocol, and a
103
+ * document of another version. `REGISTRY` names an accepted registry that is absent, fails
104
+ * authentication, or lags the declarations. `LOOKUP` names a state lookup that is absent or stale.
23
105
  * `CONTAINMENT` names a path that leaves the authorized roots.
24
106
  *
25
107
  * @example
@@ -27,7 +109,7 @@ export declare const CAPTURE_ERROR_BRAND: unique symbol;
27
109
  * CAPTURE_ERROR_CODES.includes('USAGE') // true
28
110
  * ```
29
111
  */
30
- export declare const CAPTURE_ERROR_CODES: readonly ["USAGE", "SELECTION", "HOST", "STAGE", "EVIDENCE", "CONTAINMENT"];
112
+ export declare const CAPTURE_ERROR_CODES: readonly ["USAGE", "SELECTION", "HOST", "STAGE", "EVIDENCE", "REGISTRY", "LOOKUP", "CONTAINMENT"];
31
113
 
32
114
  /**
33
115
  * Names the default lookup journal file inside a portfolio directory.
@@ -49,6 +131,16 @@ export declare const CAPTURE_LOOKUPS_FILE = "lookups.json";
49
131
  */
50
132
  export declare const CAPTURE_MANIFEST_FILE = "manifest.json";
51
133
 
134
+ /**
135
+ * Names the tag prefix that marks a case's owner path and each ancestor of it.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * `${CAPTURE_OWNER_PREFIX}pages:mail` // 'owner:pages:mail'
140
+ * ```
141
+ */
142
+ export declare const CAPTURE_OWNER_PREFIX = "owner:";
143
+
52
144
  /**
53
145
  * Holds the eight bytes every PNG file opens with.
54
146
  *
@@ -98,10 +190,10 @@ export declare const CAPTURE_STATUS_PRECEDENCE: readonly ["duplicate", "orphan",
98
190
  *
99
191
  * @example
100
192
  * ```ts
101
- * CAPTURE_VERSION // 1
193
+ * CAPTURE_VERSION // 2
102
194
  * ```
103
195
  */
104
- export declare const CAPTURE_VERSION = 1;
196
+ export declare const CAPTURE_VERSION = 2;
105
197
 
106
198
  /**
107
199
  * Names the journey artifact a final case wrote and the SHA-256 of its bytes.
@@ -116,6 +208,22 @@ export declare interface CaptureArtifact {
116
208
  readonly digest: string;
117
209
  }
118
210
 
211
+ /**
212
+ * Carries the run records a journey artifact binds and the cases it shows ran.
213
+ *
214
+ * @example
215
+ * ```ts
216
+ * const lines: CaptureArtifactLines = {
217
+ * records: ['tmp/captures/states/runs/run-1/selected/light-390.json'],
218
+ * cases: ['mail opens the inbox'],
219
+ * }
220
+ * ```
221
+ */
222
+ export declare interface CaptureArtifactLines {
223
+ readonly records: readonly string[];
224
+ readonly cases: readonly string[];
225
+ }
226
+
119
227
  /**
120
228
  * Carries the owner-bearing projection of a Vitest JSON assertion.
121
229
  *
@@ -152,6 +260,28 @@ export declare interface CaptureBox {
152
260
  readonly height: number;
153
261
  }
154
262
 
263
+ /**
264
+ * Carries one collected case, including a case a runner filter excluded.
265
+ *
266
+ * @example
267
+ * ```ts
268
+ * const entry: CaptureCase = {
269
+ * name: 'mail opens the inbox',
270
+ * mode: 'run',
271
+ * tags: ['owner:pages', 'owner:pages:mail', 'pages', 'pages:mail'],
272
+ * meta: { owner: 'pages:mail', states: ['inbox'], variant: 'light-390' },
273
+ * result: { state: 'pass', duration: 812 },
274
+ * }
275
+ * ```
276
+ */
277
+ export declare interface CaptureCase {
278
+ readonly name: string;
279
+ readonly mode: string;
280
+ readonly tags: readonly string[];
281
+ readonly meta: CaptureMeta;
282
+ readonly result?: CaptureTaskResult;
283
+ }
284
+
155
285
  /**
156
286
  * Binds a successful full collection to the unchanged complete anchor and exact evidence bytes.
157
287
  *
@@ -226,6 +356,19 @@ export declare interface CaptureDestination {
226
356
  readonly sources: CaptureSources;
227
357
  }
228
358
 
359
+ /**
360
+ * Configures the producing project and the portfolio mappings of a destination build.
361
+ *
362
+ * @example
363
+ * ```ts
364
+ * const options: CaptureDestinationOptions = { project: 'journey:light-390', portfolios: [mapping] }
365
+ * ```
366
+ */
367
+ export declare interface CaptureDestinationOptions {
368
+ readonly project: string;
369
+ readonly portfolios: readonly CaptureMapping[];
370
+ }
371
+
229
372
  /**
230
373
  * Records declared patterns, expanded file hashes, and their combined digest.
231
374
  *
@@ -241,6 +384,20 @@ export declare interface CaptureDigest {
241
384
  readonly digest: string;
242
385
  }
243
386
 
387
+ /**
388
+ * Names a digest's file map by the key a document's population table stores it under.
389
+ *
390
+ * @example
391
+ * ```ts
392
+ * const shared: CaptureDigestReference = { patterns: ['src/core/**'], files: key, digest }
393
+ * ```
394
+ */
395
+ export declare interface CaptureDigestReference {
396
+ readonly patterns: readonly string[];
397
+ readonly files: string;
398
+ readonly digest: string;
399
+ }
400
+
244
401
  /**
245
402
  * Records an emitted destination and its producing case duration.
246
403
  *
@@ -319,6 +476,21 @@ export declare interface CaptureErrorOptions {
319
476
  readonly cause?: unknown;
320
477
  }
321
478
 
479
+ /**
480
+ * Extends the image manifest with independently authenticated collection evidence.
481
+ *
482
+ * @remarks Absence means no collection attestation; historical lookups supply none implicitly.
483
+ *
484
+ * @example
485
+ * ```ts
486
+ * const manifest = readCaptureManifest(JSON.parse(text), file)
487
+ * manifest.collections // readonly receipts or undefined
488
+ * ```
489
+ */
490
+ export declare interface CaptureExpandedManifest extends CaptureManifest {
491
+ readonly collections?: readonly CaptureCollectionReceipt[];
492
+ }
493
+
322
494
  /**
323
495
  * Reports a frame's freshness classification and every supporting reason.
324
496
  *
@@ -388,20 +560,20 @@ export declare interface CaptureLookup {
388
560
  *
389
561
  * @remarks
390
562
  * A successful capture merges the journal and changes the manifest digest, retiring this journal
391
- * logically without a second filesystem mutation in the capture transaction. The `inputs` table
392
- * stores each distinct path-to-hash map under its digest; every lookup names that digest in its
393
- * `inputs` field. Expanded lookup results and image manifests retain their input maps.
563
+ * logically without a second filesystem mutation in the capture transaction. The `populations`
564
+ * table stores each distinct path-to-hash map under its digest; every lookup names that digest in
565
+ * its `inputs` field.
394
566
  *
395
567
  * @example
396
568
  * ```ts
397
- * const journal: CaptureLookupJournal = { version: 1, inputs: {}, lookups: [] }
569
+ * const journal: CaptureLookupJournal = { version: 2, populations: {}, lookups: [] }
398
570
  * ```
399
571
  */
400
572
  export declare interface CaptureLookupJournal {
401
573
  readonly collections?: readonly CaptureCollectionReceipt[];
402
- readonly version: 1;
574
+ readonly version: typeof CAPTURE_VERSION;
403
575
  readonly manifest?: string;
404
- readonly inputs: Readonly<Record<string, Readonly<Record<string, string>>>>;
576
+ readonly populations: Readonly<Record<string, Readonly<Record<string, string>>>>;
405
577
  readonly lookups: ReadonlyArray<Omit<CaptureLookup, 'inputs'> & {
406
578
  readonly inputs: string;
407
579
  }>;
@@ -412,17 +584,149 @@ export declare interface CaptureLookupJournal {
412
584
  *
413
585
  * @example
414
586
  * ```ts
415
- * const manifest: unknown = JSON.parse(text)
416
- * if (isCaptureManifest(manifest)) Object.keys(manifest.entries) // stamped image keys
587
+ * const manifest: CaptureManifest = readCaptureManifest(JSON.parse(text), file)
588
+ * Object.keys(manifest.entries) // stamped image keys
417
589
  * ```
418
590
  */
419
591
  export declare interface CaptureManifest {
420
- readonly version: number;
592
+ readonly version: typeof CAPTURE_VERSION;
421
593
  readonly registry: CaptureRegistry;
422
594
  readonly entries: Readonly<Record<string, CaptureStamp>>;
423
595
  readonly lookups: readonly CaptureLookup[];
424
596
  }
425
597
 
598
+ /**
599
+ * Stores a manifest with each distinct file map once, in a table keyed by the map's digest.
600
+ *
601
+ * @remarks
602
+ * Each `populations` key is the digest from `buildCaptureDigest([], files)` over the path-to-hash
603
+ * map it stores. Each stamp's `shared.files`, each lookup's `inputs`, and each collection receipt's
604
+ * `inputs.files` names a key in that table. The expanded `CaptureExpandedManifest` carries every
605
+ * map in place.
606
+ *
607
+ * @example
608
+ * ```ts
609
+ * const document: unknown = JSON.parse(text)
610
+ * if (isCaptureManifestDocument(document)) Object.keys(document.populations) // distinct map digests
611
+ * ```
612
+ */
613
+ export declare interface CaptureManifestDocument {
614
+ readonly version: typeof CAPTURE_VERSION;
615
+ readonly populations: Readonly<Record<string, Readonly<Record<string, string>>>>;
616
+ readonly registry: CaptureRegistry;
617
+ readonly entries: Readonly<Record<string, Omit<CaptureStamp, 'shared'> & {
618
+ readonly shared: CaptureDigestReference;
619
+ }>>;
620
+ readonly lookups: CaptureLookupJournal['lookups'];
621
+ readonly collections?: ReadonlyArray<Omit<CaptureCollectionReceipt, 'inputs'> & {
622
+ readonly inputs: CaptureDigestReference;
623
+ }>;
624
+ }
625
+
626
+ /**
627
+ * Maps the states one portfolio writes to its output variant and physical root.
628
+ *
629
+ * @example
630
+ * ```ts
631
+ * const mapping: CaptureMapping = {
632
+ * portfolio: 'states',
633
+ * directory: 'tmp/captures/states',
634
+ * scoped: true,
635
+ * variant: 'light-390',
636
+ * states: ['inbox'],
637
+ * }
638
+ * ```
639
+ */
640
+ export declare interface CaptureMapping extends CapturePortfolioRoot {
641
+ readonly variant: string;
642
+ readonly states: readonly string[];
643
+ }
644
+
645
+ /**
646
+ * Declares the capture metadata a journey case carries in Vitest's task metadata.
647
+ *
648
+ * @remarks
649
+ * Extend Vitest's `TaskMeta` with it in the workspace's own module declaration, so a case's
650
+ * `meta` option and every collected task carry these fields.
651
+ *
652
+ * @example
653
+ * ```ts
654
+ * const meta: CaptureMeta = { owner: 'pages:mail', states: ['inbox'], variant: 'light-390' }
655
+ * ```
656
+ */
657
+ export declare interface CaptureMeta {
658
+ readonly owner?: string;
659
+ readonly states?: readonly string[];
660
+ readonly variant?: string;
661
+ readonly eligible?: boolean;
662
+ }
663
+
664
+ /**
665
+ * Resolves a declared state to the canonical owner path of the part that renders it.
666
+ *
667
+ * @remarks Throw for a state the host does not declare.
668
+ *
669
+ * @example
670
+ * ```ts
671
+ * const part: CapturePartHandler = (state) => (state.startsWith('inbox') ? 'pages:mail' : 'pages:board')
672
+ * ```
673
+ */
674
+ export declare type CapturePartHandler = (state: string) => string;
675
+
676
+ /**
677
+ * Supplies a host-authorized physical portfolio root without repeating its states or variants.
678
+ *
679
+ * @example
680
+ * ```ts
681
+ * const root: CapturePortfolioRoot = { portfolio: 'states', directory: 'tmp/captures/states', scoped: true }
682
+ * ```
683
+ */
684
+ export declare interface CapturePortfolioRoot {
685
+ readonly portfolio: string;
686
+ readonly directory: string;
687
+ readonly scoped: boolean;
688
+ }
689
+
690
+ /**
691
+ * Declares the values a journey wrapper provides to each project, which the runner and the suite read.
692
+ *
693
+ * @remarks
694
+ * Extend Vitest's `ProvidedContext` with it in the workspace's own module declaration. `request` is
695
+ * present only when a runner is the parent, and `capture` reports whether frames are written.
696
+ * `sources` holds the shared and test source patterns the suite attributes to every destination.
697
+ *
698
+ * @example
699
+ * ```ts
700
+ * const provided: CaptureProvided = {
701
+ * variant: 'light-390',
702
+ * variants: [{ name: 'light-390', width: 390, height: 844 }],
703
+ * directory: 'tmp/captures/states',
704
+ * record: 'tmp/captures/states/runs/run-1/selected/light-390.json',
705
+ * inputs: ['src/**'],
706
+ * sources: { shared: ['src/core/**'], tests: ['tests/**'] },
707
+ * final: 'closes the run',
708
+ * first: 'light-390',
709
+ * portfolios: [{ portfolio: 'states', directory: 'tmp/captures/states', scoped: true }],
710
+ * capture: false,
711
+ * }
712
+ * ```
713
+ */
714
+ export declare interface CaptureProvided {
715
+ readonly variant: string;
716
+ readonly variants: readonly CaptureViewport[];
717
+ readonly directory: string;
718
+ readonly record: string;
719
+ readonly inputs: readonly string[];
720
+ readonly sources: Pick<CaptureSources, 'shared' | 'tests'>;
721
+ readonly final: string;
722
+ readonly first: string;
723
+ readonly uniform?: readonly string[];
724
+ readonly portfolios: readonly CapturePortfolioRoot[];
725
+ readonly standalone?: readonly CapturePortfolioRoot[];
726
+ readonly capture: boolean;
727
+ readonly request?: CaptureRequest;
728
+ }
729
+
426
730
  /**
427
731
  * Binds a complete registry reading to its report and input hashes.
428
732
  *
@@ -433,7 +737,7 @@ export declare interface CaptureManifest {
433
737
  * ```
434
738
  */
435
739
  export declare interface CaptureReceipt {
436
- readonly version: number;
740
+ readonly version: typeof CAPTURE_VERSION;
437
741
  readonly variant: string;
438
742
  readonly time: string;
439
743
  readonly report: {
@@ -456,7 +760,7 @@ export declare interface CaptureReceipt {
456
760
  * ```
457
761
  */
458
762
  export declare interface CaptureRegistry {
459
- readonly version: number;
763
+ readonly version: typeof CAPTURE_VERSION;
460
764
  readonly receipts: readonly CaptureReceipt[];
461
765
  readonly entries: readonly CaptureDestination[];
462
766
  readonly digest: string;
@@ -492,13 +796,31 @@ export declare interface CaptureReport {
492
796
  * ```
493
797
  */
494
798
  export declare interface CaptureRequest extends CaptureSelection, CaptureIdentity {
495
- readonly version: 1;
799
+ readonly version: typeof CAPTURE_VERSION;
496
800
  readonly command: 'journey' | 'capture';
497
801
  readonly mode?: string;
498
802
  readonly variants: readonly string[];
499
803
  readonly args: readonly string[];
500
804
  }
501
805
 
806
+ /**
807
+ * Supplies the host's owner population and its part and source resolvers.
808
+ *
809
+ * @remarks
810
+ * `owners` lists every canonical owner path the host declares. `part` and `sources` carry the
811
+ * product rules the package never infers.
812
+ *
813
+ * @example
814
+ * ```ts
815
+ * const rules: CaptureRules = { owners: ['pages:mail'], part: () => 'pages:mail', sources }
816
+ * ```
817
+ */
818
+ export declare interface CaptureRules {
819
+ readonly owners: readonly string[];
820
+ readonly part: CapturePartHandler;
821
+ readonly sources: CaptureSourcesHandler;
822
+ }
823
+
502
824
  /**
503
825
  * Records collected declarations, successful observations, and emitted output separately.
504
826
  *
@@ -509,7 +831,7 @@ export declare interface CaptureRequest extends CaptureSelection, CaptureIdentit
509
831
  * ```
510
832
  */
511
833
  export declare interface CaptureRun {
512
- readonly version: number;
834
+ readonly version: typeof CAPTURE_VERSION;
513
835
  readonly identity?: CaptureIdentity;
514
836
  readonly request?: CaptureRequest;
515
837
  readonly variant: string;
@@ -524,6 +846,36 @@ export declare interface CaptureRun {
524
846
  readonly entries: readonly CaptureEntry[];
525
847
  }
526
848
 
849
+ /**
850
+ * Supplies the collected cases, the destinations, and the observed and emitted states of one run record.
851
+ *
852
+ * @remarks
853
+ * `observed` lists every state the run placed, whether or not it wrote a frame. `emitted` pairs
854
+ * each written state with the path its portfolio wrote. `time` is an ISO 8601 timestamp, and
855
+ * `request` is the runner request the wrapper provided.
856
+ *
857
+ * @example
858
+ * ```ts
859
+ * const options: CaptureRunOptions = {
860
+ * cases,
861
+ * registry,
862
+ * observed: ['inbox'],
863
+ * emitted: [['inbox', 'tmp/captures/states/pages/inbox--light-390.png']],
864
+ * variant: 'light-390',
865
+ * time: '2026-11-15T09:00:00.000Z',
866
+ * }
867
+ * ```
868
+ */
869
+ export declare interface CaptureRunOptions {
870
+ readonly cases: readonly CaptureCase[];
871
+ readonly registry: readonly CaptureDestination[];
872
+ readonly observed: readonly string[];
873
+ readonly emitted: ReadonlyArray<readonly [state: string, path: string]>;
874
+ readonly variant: string;
875
+ readonly time: string;
876
+ readonly request?: CaptureRequest;
877
+ }
878
+
527
879
  /**
528
880
  * Carries the selection fields a request and a parking check read.
529
881
  *
@@ -552,6 +904,18 @@ export declare interface CaptureSources {
552
904
  readonly tests: readonly string[];
553
905
  }
554
906
 
907
+ /**
908
+ * Resolves a canonical owner path to its own, shared, and behavioral source attribution.
909
+ *
910
+ * @remarks Throw for an owner the host does not attribute.
911
+ *
912
+ * @example
913
+ * ```ts
914
+ * const sources: CaptureSourcesHandler = (owner) => ({ own: [`src/${owner.split(':')[1]}/**`], shared: [], tests: [] })
915
+ * ```
916
+ */
917
+ export declare type CaptureSourcesHandler = (owner: string) => CaptureSources;
918
+
555
919
  /**
556
920
  * Stamps one emitted frame with execution, source, image, and registry provenance.
557
921
  *
@@ -588,18 +952,79 @@ export declare interface CaptureStamp extends CaptureEntry {
588
952
  export declare type CaptureStatus = 'current' | (typeof CAPTURE_STATUS_PRECEDENCE)[number];
589
953
 
590
954
  /**
591
- * Extends the image manifest with independently authenticated collection evidence.
955
+ * Mirrors the members of a Vitest file, suite, or test task that case collection reads.
592
956
  *
593
- * @remarks Absence means no collection attestation; historical lookups supply none implicitly.
957
+ * @remarks
958
+ * A Vitest `RunnerTask` satisfies it when the workspace's `TaskMeta` extends `CaptureMeta`. A task with
959
+ * `filepath` is a file, and a task with `tasks` is a file or a suite.
594
960
  *
595
961
  * @example
596
962
  * ```ts
597
- * const manifest: unknown = JSON.parse(text)
598
- * if (isCaptureStoredManifest(manifest)) manifest.collections // readonly receipts or undefined
963
+ * const task: CaptureTask = { name: 'opens the inbox', mode: 'run', meta: { owner: 'pages:mail' } }
599
964
  * ```
600
965
  */
601
- export declare interface CaptureStoredManifest extends CaptureManifest {
602
- readonly collections?: readonly CaptureCollectionReceipt[];
966
+ export declare interface CaptureTask {
967
+ readonly name: string;
968
+ readonly mode: string;
969
+ readonly tags?: readonly string[];
970
+ readonly meta: CaptureMeta;
971
+ readonly result?: CaptureTaskResult;
972
+ readonly filepath?: string;
973
+ readonly tasks?: readonly CaptureTask[];
974
+ }
975
+
976
+ /**
977
+ * Mirrors the members of Vitest's `TaskResult` that a run record reads.
978
+ *
979
+ * @example
980
+ * ```ts
981
+ * const result: CaptureTaskResult = { state: 'pass', duration: 812 }
982
+ * ```
983
+ */
984
+ export declare interface CaptureTaskResult {
985
+ readonly state: string;
986
+ readonly duration?: number;
987
+ }
988
+
989
+ /**
990
+ * Supplies one case's owner, states, producing variant, and harness registration values.
991
+ *
992
+ * @remarks
993
+ * An owner-bearing case derives its tags from its owner and states; a case without an owner, such
994
+ * as the final case, names its tags.
995
+ *
996
+ * @example
997
+ * ```ts
998
+ * const input: CaptureTestInput = { owner: 'pages:mail', states: ['inbox'], variant: 'light-390' }
999
+ * ```
1000
+ */
1001
+ export declare interface CaptureTestInput {
1002
+ readonly owner?: string;
1003
+ readonly states?: readonly string[];
1004
+ readonly variant: string;
1005
+ readonly eligible?: boolean;
1006
+ readonly timeout?: number;
1007
+ readonly tags?: readonly string[];
1008
+ }
1009
+
1010
+ /**
1011
+ * Carries the Vitest test options a capture case registers with.
1012
+ *
1013
+ * @remarks
1014
+ * `tags` is a mutable array because Vitest's `TestOptions` declares its `tags` member that way.
1015
+ *
1016
+ * @example
1017
+ * ```ts
1018
+ * const options: CaptureTestOptions = {
1019
+ * tags: ['owner:pages', 'owner:pages:mail', 'pages', 'pages:mail'],
1020
+ * meta: { owner: 'pages:mail', states: ['inbox'], variant: 'light-390' },
1021
+ * }
1022
+ * ```
1023
+ */
1024
+ export declare interface CaptureTestOptions {
1025
+ readonly tags: string[];
1026
+ readonly meta: CaptureMeta;
1027
+ readonly timeout?: number;
603
1028
  }
604
1029
 
605
1030
  /**
@@ -629,6 +1054,34 @@ export declare interface CaptureWarning {
629
1054
  readonly cases: readonly string[];
630
1055
  }
631
1056
 
1057
+ /**
1058
+ * Expands an owner path into its prefixes, from its scope through the owner itself.
1059
+ *
1060
+ * @param owner - A canonical owner path
1061
+ * @returns Each colon-bounded prefix, shortest first
1062
+ *
1063
+ * @example
1064
+ * ```ts
1065
+ * collectCaptureAncestors('pages:mail:inbox') // ['pages', 'pages:mail', 'pages:mail:inbox']
1066
+ * ```
1067
+ */
1068
+ export declare function collectCaptureAncestors(owner: string): readonly string[];
1069
+
1070
+ /**
1071
+ * Collects every leaf case under a task, keeping cases a runner filter excluded and their results.
1072
+ *
1073
+ * @param task - A Vitest file, suite, or test task
1074
+ * @param ancestors - The titles of the suites that enclose the task, excluding the file name. Default: none
1075
+ * @returns Each case with its suite titles and own title joined by spaces, as the Vitest JSON reporter names it
1076
+ *
1077
+ * @example
1078
+ * ```ts
1079
+ * collectCaptureCases({ name: 'mail', mode: 'run', meta: {}, tasks: [inbox] })[0]?.name
1080
+ * // 'mail opens the inbox'
1081
+ * ```
1082
+ */
1083
+ export declare function collectCaptureCases(task: CaptureTask, ancestors?: readonly string[]): readonly CaptureCase[];
1084
+
632
1085
  /**
633
1086
  * Names every changed, added, or removed file in hash populations.
634
1087
  *
@@ -822,6 +1275,20 @@ export declare function isCaptureDestination(value: unknown): value is CaptureDe
822
1275
  */
823
1276
  export declare function isCaptureDigest(value: unknown): value is CaptureDigest;
824
1277
 
1278
+ /**
1279
+ * Checks whether a digest names its file map by a table key beside its patterns and combined digest.
1280
+ *
1281
+ * @param value - The stored digest reference
1282
+ * @returns True if the patterns are valid and both digests are SHA-256 hexadecimal; false otherwise
1283
+ *
1284
+ * @example
1285
+ * ```ts
1286
+ * isCaptureDigestReference({ patterns: ['src/**'], files: 'a'.repeat(64), digest: 'b'.repeat(64) }) // true
1287
+ * isCaptureDigestReference({ patterns: ['src/**'], files: {}, digest: 'b'.repeat(64) }) // false
1288
+ * ```
1289
+ */
1290
+ export declare function isCaptureDigestReference(value: unknown): value is CaptureDigestReference;
1291
+
825
1292
  /**
826
1293
  * Checks whether an emitted entry includes a finite nonnegative case duration.
827
1294
  *
@@ -857,6 +1324,20 @@ export declare function isCaptureEntry(value: unknown): value is CaptureEntry;
857
1324
  */
858
1325
  export declare function isCaptureError(value: unknown): value is CaptureError;
859
1326
 
1327
+ /**
1328
+ * Checks whether an expanded manifest and its optional collection receipts have the supported schema.
1329
+ *
1330
+ * @param value - The expanded manifest
1331
+ * @returns True if the manifest and any collection receipts are valid; false otherwise
1332
+ *
1333
+ * @example
1334
+ * ```ts
1335
+ * isCaptureExpandedManifest(readCaptureManifest(JSON.parse(text), file)) // true with or without collections
1336
+ * isCaptureExpandedManifest(null) // false
1337
+ * ```
1338
+ */
1339
+ export declare function isCaptureExpandedManifest(value: unknown): value is CaptureExpandedManifest;
1340
+
860
1341
  /**
861
1342
  * Checks the host's declared viewport without deriving geometry from an output name.
862
1343
  *
@@ -936,26 +1417,41 @@ export declare function isCaptureLookup(value: unknown): value is CaptureLookup;
936
1417
  *
937
1418
  * @example
938
1419
  * ```ts
939
- * isCaptureLookupJournal({ version: 1, inputs: {}, lookups: [] }) // true
940
- * isCaptureLookupJournal({ version: 2, inputs: {}, lookups: [] }) // false
1420
+ * isCaptureLookupJournal({ version: 2, populations: {}, lookups: [] }) // true
1421
+ * isCaptureLookupJournal({ version: 1, populations: {}, lookups: [] }) // false
941
1422
  * ```
942
1423
  */
943
1424
  export declare function isCaptureLookupJournal(value: unknown): value is CaptureLookupJournal;
944
1425
 
945
1426
  /**
946
- * Checks whether an inherited manifest has the supported schema without discarding malformed rows.
1427
+ * Checks whether an expanded manifest has the supported schema without discarding malformed rows.
947
1428
  *
948
1429
  * @param value - The manifest
949
1430
  * @returns True if every inherited member validates; false otherwise
950
1431
  *
951
1432
  * @example
952
1433
  * ```ts
953
- * isCaptureManifest(JSON.parse(text)) // true for a published manifest.json
1434
+ * isCaptureManifest(readCaptureManifest(JSON.parse(text), file)) // true for an expanded manifest.json
954
1435
  * isCaptureManifest('manifest') // false
955
1436
  * ```
956
1437
  */
957
1438
  export declare function isCaptureManifest(value: unknown): value is CaptureManifest;
958
1439
 
1440
+ /**
1441
+ * Checks whether a stored manifest holds its population table and every member that names a table key.
1442
+ *
1443
+ * @param value - The decoded manifest file
1444
+ * @returns True if the version, table, registry, stamps, lookups, and collections are valid; false otherwise
1445
+ * @remarks Table digests and reference existence are verified when the document is read.
1446
+ *
1447
+ * @example
1448
+ * ```ts
1449
+ * isCaptureManifestDocument(JSON.parse(text)) // true for a written manifest.json
1450
+ * isCaptureManifestDocument({ version: 1, populations: {}, entries: {}, lookups: [] }) // false
1451
+ * ```
1452
+ */
1453
+ export declare function isCaptureManifestDocument(value: unknown): value is CaptureManifestDocument;
1454
+
959
1455
  /**
960
1456
  * Checks whether a serialized path stays within the portable relative-path vocabulary.
961
1457
  *
@@ -1021,7 +1517,7 @@ export declare function isCaptureRegistry(value: unknown): value is CaptureRegis
1021
1517
  * @example
1022
1518
  * ```ts
1023
1519
  * isCaptureRequest(JSON.parse(text)) // true for a well-formed runner request
1024
- * isCaptureRequest({ version: 2 }) // false
1520
+ * isCaptureRequest({ version: 1 }) // false
1025
1521
  * ```
1026
1522
  */
1027
1523
  export declare function isCaptureRequest(value: unknown): value is CaptureRequest;
@@ -1096,20 +1592,6 @@ export declare function isCaptureSources(value: unknown): value is CaptureSource
1096
1592
  */
1097
1593
  export declare function isCaptureStamp(value: unknown): value is CaptureStamp;
1098
1594
 
1099
- /**
1100
- * Checks optional collection metadata without upgrading historical image evidence.
1101
- *
1102
- * @param value - The inherited image transaction
1103
- * @returns True if its existing manifest and any collection receipts are valid; false otherwise
1104
- *
1105
- * @example
1106
- * ```ts
1107
- * isCaptureStoredManifest(JSON.parse(text)) // true for a manifest with or without collections
1108
- * isCaptureStoredManifest(null) // false
1109
- * ```
1110
- */
1111
- export declare function isCaptureStoredManifest(value: unknown): value is CaptureStoredManifest;
1112
-
1113
1595
  /**
1114
1596
  * Compares complete populations without erasing duplicates.
1115
1597
  *
@@ -1140,6 +1622,20 @@ export declare function matchesCaptureMembers(left: readonly string[], right: re
1140
1622
  */
1141
1623
  export declare function matchesCaptureSelector(owner: string, selector: string): boolean;
1142
1624
 
1625
+ /**
1626
+ * Reads the record bindings and the ran cases from a journey artifact's text.
1627
+ *
1628
+ * @param text - The artifact text, with LF or CRLF line endings
1629
+ * @returns The path of each `record=` line and the full name of each `case-ran=` line, in text order
1630
+ *
1631
+ * @example
1632
+ * ```ts
1633
+ * readCaptureArtifact('# light-390\r\nrecord=tmp/run.json\r\ncase-ran=mail opens the inbox\r\n')
1634
+ * // { records: ['tmp/run.json'], cases: ['mail opens the inbox'] }
1635
+ * ```
1636
+ */
1637
+ export declare function readCaptureArtifact(text: string): CaptureArtifactLines;
1638
+
1143
1639
  /**
1144
1640
  * Reads Git's NUL-delimited porcelain paths without treating spaces or quoted names as separators.
1145
1641
  *
@@ -1169,6 +1665,39 @@ export declare function readCaptureDirty(output: string): readonly string[];
1169
1665
  */
1170
1666
  export declare function readCaptureReport(value: unknown): CaptureReport;
1171
1667
 
1668
+ /**
1669
+ * Renders the journey artifact lines that bind a run record and each case that passed in it.
1670
+ *
1671
+ * @param record - The run record's portable path
1672
+ * @param run - The run whose passed cases the artifact names
1673
+ * @returns The `record=` line, then one `case-ran=` line per passed case, without line endings
1674
+ * @throws Thrown as an `EVIDENCE` capture error for a record path that is not portable or a case name that holds a line break.
1675
+ *
1676
+ * @example
1677
+ * ```ts
1678
+ * renderCaptureArtifact('tmp/captures/states/runs/run-1/selected/light-390.json', {
1679
+ * passed: ['mail opens the inbox'],
1680
+ * })
1681
+ * // ['record=tmp/captures/states/runs/run-1/selected/light-390.json', 'case-ran=mail opens the inbox']
1682
+ * ```
1683
+ */
1684
+ export declare function renderCaptureArtifact(record: string, run: Pick<CaptureRun, 'passed'>): readonly string[];
1685
+
1686
+ /**
1687
+ * Refuses a selection whose cases place states owned outside the selected owner.
1688
+ *
1689
+ * @param cases - Every collected case, including cases a runner filter excluded
1690
+ * @param rules - The host's owners and part resolver
1691
+ * @param selection - The runner's selection, absent when no runner is the parent
1692
+ * @throws Thrown as a `SELECTION` capture error for an undeclared selector, and as a `HOST` capture error naming each case that places a selected state from outside the selected owner.
1693
+ *
1694
+ * @example
1695
+ * ```ts
1696
+ * requireCaptureCases(cases, rules, { selector: 'pages:mail' }) // returns when no case is parked
1697
+ * ```
1698
+ */
1699
+ export declare function requireCaptureCases(cases: readonly CaptureCase[], rules: CaptureRules, selection?: CaptureSelection): void;
1700
+
1172
1701
  /**
1173
1702
  * Refuses duplicate declarations or portable storage-key collisions before indexing.
1174
1703
  *