@orkestrel/capture 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/dist/src/core/index.cjs +75 -22
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +124 -51
- package/dist/src/core/index.d.ts +124 -51
- package/dist/src/core/index.js +73 -22
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +1012 -316
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +523 -22
- package/dist/src/server/index.d.ts +523 -22
- package/dist/src/server/index.js +991 -319
- package/dist/src/server/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -13,6 +13,51 @@ let node_string_decoder = require("node:string_decoder");
|
|
|
13
13
|
let _orkestrel_timeout = require("@orkestrel/timeout");
|
|
14
14
|
// src/server/constants.ts
|
|
15
15
|
/**
|
|
16
|
+
* Names the command that clears each refusal condition, or none where no command clears it.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* `registry` is the complete-registry refresh, and `journey` is the selected owner's journey, which
|
|
20
|
+
* refreshes its state lookups. A runner prints the command on stdout after the report line it
|
|
21
|
+
* follows, ahead of the refusal on stderr, and on stderr after the refusal when no report line
|
|
22
|
+
* precedes it; a condition with no command prints none.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* CAPTURE_RECOVERIES.REGISTRY // 'registry'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
var CAPTURE_RECOVERIES = Object.freeze({
|
|
30
|
+
USAGE: void 0,
|
|
31
|
+
SELECTION: void 0,
|
|
32
|
+
HOST: void 0,
|
|
33
|
+
STAGE: void 0,
|
|
34
|
+
EVIDENCE: void 0,
|
|
35
|
+
REGISTRY: "registry",
|
|
36
|
+
LOOKUP: "journey",
|
|
37
|
+
CONTAINMENT: void 0
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Names the command that clears each freshness classification, or none where no command clears it.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* `capture` is a frames run over the read selection. A `duplicate` or an `orphan` names a registry
|
|
44
|
+
* or a file that no frames run changes, and a `current` frame needs nothing.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* CAPTURE_STATUS_RECOVERIES['stale-own'] // 'capture'
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
var CAPTURE_STATUS_RECOVERIES = Object.freeze({
|
|
52
|
+
current: void 0,
|
|
53
|
+
duplicate: void 0,
|
|
54
|
+
orphan: void 0,
|
|
55
|
+
missing: "capture",
|
|
56
|
+
unstamped: "capture",
|
|
57
|
+
"stale-shared": "capture",
|
|
58
|
+
"stale-own": "capture"
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
16
61
|
* Names the executable subcommand each runner command answers to.
|
|
17
62
|
*
|
|
18
63
|
* @remarks
|
|
@@ -529,8 +574,13 @@ function buildCaptureChangePlan(paths, entries) {
|
|
|
529
574
|
/**
|
|
530
575
|
* Renders an exact owner command with the selected variants and filters in host shell syntax.
|
|
531
576
|
*
|
|
577
|
+
* @remarks
|
|
578
|
+
* A flag is rendered only when the rendered command's `CAPTURE_COMMAND_OPTIONS` entry declares it,
|
|
579
|
+
* so a journey drops `--state`, a registry refresh drops `--case`, and only `stale` keeps
|
|
580
|
+
* `--portfolio`. `--changed` and `--plan` are never rendered.
|
|
581
|
+
*
|
|
532
582
|
* @param command - The request command, translated to its executable name, or the registry command
|
|
533
|
-
* @param parsed - The parsed flags, a `false` bail rendered as `--no-bail
|
|
583
|
+
* @param parsed - The parsed flags, a `false` bail rendered as `--no-bail`; changed and plan flags are deliberately replaced by the owner
|
|
534
584
|
* @param selector - The explicit owner or all selector; omitted for a registry refresh
|
|
535
585
|
* @param root - The workspace that makes the wrapper path relative
|
|
536
586
|
* @returns The command ready to copy into the host shell
|
|
@@ -542,15 +592,17 @@ function buildCaptureChangePlan(paths, entries) {
|
|
|
542
592
|
*/
|
|
543
593
|
function renderCaptureCommand(command, parsed, selector, root) {
|
|
544
594
|
const config = resolveCaptureRelative(root, parsed.config);
|
|
595
|
+
const options = CAPTURE_COMMAND_OPTIONS[command];
|
|
545
596
|
return [
|
|
546
597
|
"capture",
|
|
547
598
|
command === "registry" ? command : CAPTURE_COMMAND_NAMES[command],
|
|
548
599
|
...selector === void 0 ? [] : [selector],
|
|
549
|
-
...parsed.variants.flatMap((variant) => ["--variant", variant]),
|
|
550
|
-
...parsed.mode === void 0 ? [] : ["--mode", parsed.mode],
|
|
551
|
-
...parsed.case === void 0 ? [] : parsed.case.startsWith("-") ? [`--case=${parsed.case}`] : ["--case", parsed.case],
|
|
552
|
-
...parsed.state === void 0 ? [] : ["--state", parsed.state],
|
|
553
|
-
...parsed.
|
|
600
|
+
...Object.hasOwn(options, "variant") ? parsed.variants.flatMap((variant) => ["--variant", variant]) : [],
|
|
601
|
+
...parsed.mode === void 0 || !Object.hasOwn(options, "mode") ? [] : ["--mode", parsed.mode],
|
|
602
|
+
...parsed.case === void 0 || !Object.hasOwn(options, "case") ? [] : parsed.case.startsWith("-") ? [`--case=${parsed.case}`] : ["--case", parsed.case],
|
|
603
|
+
...parsed.state === void 0 || !Object.hasOwn(options, "state") ? [] : ["--state", parsed.state],
|
|
604
|
+
...parsed.portfolio === void 0 || !Object.hasOwn(options, "portfolio") ? [] : ["--portfolio", parsed.portfolio],
|
|
605
|
+
...parsed.bail === false && Object.hasOwn(options, "bail") ? ["--no-bail"] : [],
|
|
554
606
|
...config.startsWith("-") ? [`--config=${config}`] : ["--config", config]
|
|
555
607
|
].map((argument) => /^[\w./:-]+$/u.test(argument) ? argument : process.platform === "win32" ? `'${argument.replaceAll("'", "''")}'` : `'${argument.replaceAll("'", "'\\''")}'`).join(" ");
|
|
556
608
|
}
|
|
@@ -830,55 +882,341 @@ function filterCaptureInputs(inputs, patterns) {
|
|
|
830
882
|
*
|
|
831
883
|
* @example
|
|
832
884
|
* ```ts
|
|
833
|
-
* buildCaptureLookupJournal([], []).
|
|
885
|
+
* buildCaptureLookupJournal([], []).populations // {}
|
|
834
886
|
* ```
|
|
835
887
|
*/
|
|
836
888
|
function buildCaptureLookupJournal(lookups, collections, manifest) {
|
|
837
|
-
const
|
|
838
|
-
const references = lookups.map((lookup) => {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
return {
|
|
843
|
-
...lookup,
|
|
844
|
-
inputs: population.digest
|
|
845
|
-
};
|
|
846
|
-
});
|
|
889
|
+
const memo = /* @__PURE__ */ new Map();
|
|
890
|
+
const references = lookups.map((lookup) => ({
|
|
891
|
+
...lookup,
|
|
892
|
+
inputs: computeCaptureTableKey(lookup.inputs, memo)
|
|
893
|
+
}));
|
|
847
894
|
return {
|
|
848
895
|
version: _src_core.CAPTURE_VERSION,
|
|
849
896
|
...manifest === void 0 ? {} : { manifest },
|
|
850
|
-
|
|
897
|
+
populations: buildCaptureTable(memo),
|
|
851
898
|
lookups: references,
|
|
852
899
|
collections
|
|
853
900
|
};
|
|
854
901
|
}
|
|
855
902
|
/**
|
|
903
|
+
* Admits a decoded lookup journal, checking its declared version before its schema.
|
|
904
|
+
*
|
|
905
|
+
* @param value - The decoded journal file
|
|
906
|
+
* @param file - The journal path each refusal names
|
|
907
|
+
* @returns The journal, whose table digests `readCaptureLookups` verifies
|
|
908
|
+
* @throws Thrown with the removal and the refresh commands when the journal declares another
|
|
909
|
+
* protocol version, and thrown naming the file when its schema is invalid.
|
|
910
|
+
*
|
|
911
|
+
* @example
|
|
912
|
+
* ```ts
|
|
913
|
+
* readCaptureLookupJournal(JSON.parse(text), 'tmp/captures/states/lookups.json').lookups.length
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
function readCaptureLookupJournal(value, file) {
|
|
917
|
+
requireCaptureVersion(value, "Lookup journal", file, [file]);
|
|
918
|
+
if (!(0, _src_core.isCaptureLookupJournal)(value)) throw new _src_core.CaptureError(`Invalid lookup journal schema: ${file}`, {
|
|
919
|
+
code: "EVIDENCE",
|
|
920
|
+
context: { file }
|
|
921
|
+
});
|
|
922
|
+
return value;
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
856
925
|
* Resolves journal lookup references after verifying each stored input population's digest.
|
|
857
926
|
*
|
|
858
927
|
* @param journal - A structurally validated lookup journal
|
|
928
|
+
* @param file - The journal path each refusal names
|
|
859
929
|
* @returns Every expanded lookup in its stored order, sharing the verified input maps
|
|
860
|
-
* @throws Thrown when
|
|
930
|
+
* @throws Thrown when a population does not hash to its key or a lookup names an unknown key.
|
|
861
931
|
*
|
|
862
932
|
* @example
|
|
863
933
|
* ```ts
|
|
864
|
-
* readCaptureLookups(buildCaptureLookupJournal([], [])) // []
|
|
934
|
+
* readCaptureLookups(buildCaptureLookupJournal([], []), 'tmp/captures/states/lookups.json') // []
|
|
865
935
|
* ```
|
|
866
936
|
*/
|
|
867
|
-
function readCaptureLookups(journal) {
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
937
|
+
function readCaptureLookups(journal, file) {
|
|
938
|
+
const subject = `Lookup journal at ${file}`;
|
|
939
|
+
const populations = readCaptureTable(journal.populations, subject);
|
|
940
|
+
return journal.lookups.map((lookup) => ({
|
|
941
|
+
...lookup,
|
|
942
|
+
inputs: requireCaptureTableEntry(populations, lookup.inputs, subject, "inputs")
|
|
871
943
|
}));
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Computes the table key of a file map, the digest from `buildCaptureDigest([], files)`, once per map.
|
|
947
|
+
*
|
|
948
|
+
* @remarks
|
|
949
|
+
* The memo belongs to one document build: it holds each map by identity beside its ordered,
|
|
950
|
+
* digested population, so equal maps from different objects share one key.
|
|
951
|
+
*
|
|
952
|
+
* @param files - The path-to-hash map a document stores once
|
|
953
|
+
* @param memo - The build's memo from each map to its ordered, digested population
|
|
954
|
+
* @returns The digest that names the map in the document's population table
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```ts
|
|
958
|
+
* const memo = new Map()
|
|
959
|
+
* computeCaptureTableKey({ 'src/a.ts': 'f'.repeat(64) }, memo).length // 64
|
|
960
|
+
* ```
|
|
961
|
+
*/
|
|
962
|
+
function computeCaptureTableKey(files, memo) {
|
|
963
|
+
const known = memo.get(files);
|
|
964
|
+
if (known !== void 0) return known.digest;
|
|
965
|
+
const population = buildCaptureDigest([], files);
|
|
966
|
+
memo.set(files, population);
|
|
967
|
+
return population.digest;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Builds a document's population table from the memo its table keys were computed through.
|
|
971
|
+
*
|
|
972
|
+
* @param memo - The memo `computeCaptureTableKey` filled for one document build
|
|
973
|
+
* @returns Each distinct ordered map under its digest, in the order the build first met it
|
|
974
|
+
*
|
|
975
|
+
* @example
|
|
976
|
+
* ```ts
|
|
977
|
+
* const memo = new Map()
|
|
978
|
+
* const key = computeCaptureTableKey({ 'src/a.ts': 'f'.repeat(64) }, memo)
|
|
979
|
+
* buildCaptureTable(memo)[key] // { 'src/a.ts': 'ffff…' }
|
|
980
|
+
* ```
|
|
981
|
+
*/
|
|
982
|
+
function buildCaptureTable(memo) {
|
|
983
|
+
return Object.fromEntries([...memo.values()].map((population) => [population.digest, population.files]));
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Reads a document's population table after verifying that each map hashes to the key it is stored under.
|
|
987
|
+
*
|
|
988
|
+
* @param table - The stored table from each digest to its path-to-hash map
|
|
989
|
+
* @param subject - The document and its path, which open the refusal message
|
|
990
|
+
* @returns Each verified map by its digest
|
|
991
|
+
* @throws Thrown when a stored map does not hash to its key.
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* ```ts
|
|
995
|
+
* readCaptureTable({}, 'Manifest at tmp/captures/states/manifest.json').size // 0
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
function readCaptureTable(table, subject) {
|
|
999
|
+
return new Map(Object.entries(table).map(([digest, files]) => {
|
|
1000
|
+
if (buildCaptureDigest([], files).digest !== digest) throw new _src_core.CaptureError(`${subject} stores a population that does not hash to its key: ${digest}`, { code: "EVIDENCE" });
|
|
1001
|
+
return [digest, files];
|
|
1002
|
+
}));
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Returns the verified map a table key names, refusing a key the table does not hold.
|
|
1006
|
+
*
|
|
1007
|
+
* @param table - The verified table `readCaptureTable` returns
|
|
1008
|
+
* @param key - The digest a stored member names
|
|
1009
|
+
* @param subject - The document and its path, which open the refusal message
|
|
1010
|
+
* @param field - The referencing field the refusal message names
|
|
1011
|
+
* @returns The file map stored under the key
|
|
1012
|
+
* @throws Thrown when the table holds no map under the key.
|
|
1013
|
+
*
|
|
1014
|
+
* @example
|
|
1015
|
+
* ```ts
|
|
1016
|
+
* requireCaptureTableEntry(new Map([[key, files]]), key, 'Manifest at manifest.json', 'inputs') === files // true
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
function requireCaptureTableEntry(table, key, subject, field) {
|
|
1020
|
+
const files = table.get(key);
|
|
1021
|
+
if (files === void 0) throw new _src_core.CaptureError(`${subject} names an unknown ${field} digest: ${key}`, { code: "EVIDENCE" });
|
|
1022
|
+
return files;
|
|
1023
|
+
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Stores each distinct file map of an expanded manifest once, in a table keyed by the map's digest.
|
|
1026
|
+
*
|
|
1027
|
+
* @param manifest - The expanded manifest the engine publishes
|
|
1028
|
+
* @returns The document whose stamps, lookups, and collections name their maps by table key
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const document = buildCaptureManifestDocument(manifest)
|
|
1033
|
+
* Object.keys(document.populations) // one digest per distinct shared or input map
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
function buildCaptureManifestDocument(manifest) {
|
|
1037
|
+
const memo = /* @__PURE__ */ new Map();
|
|
1038
|
+
const entries = Object.fromEntries(Object.entries(manifest.entries).map(([key, stamp]) => [key, {
|
|
1039
|
+
...stamp,
|
|
1040
|
+
shared: {
|
|
1041
|
+
...stamp.shared,
|
|
1042
|
+
files: computeCaptureTableKey(stamp.shared.files, memo)
|
|
1043
|
+
}
|
|
1044
|
+
}]));
|
|
1045
|
+
const lookups = manifest.lookups.map((lookup) => ({
|
|
1046
|
+
...lookup,
|
|
1047
|
+
inputs: computeCaptureTableKey(lookup.inputs, memo)
|
|
1048
|
+
}));
|
|
1049
|
+
const collections = manifest.collections?.map((receipt) => ({
|
|
1050
|
+
...receipt,
|
|
1051
|
+
inputs: {
|
|
1052
|
+
...receipt.inputs,
|
|
1053
|
+
files: computeCaptureTableKey(receipt.inputs.files, memo)
|
|
1054
|
+
}
|
|
1055
|
+
}));
|
|
1056
|
+
return {
|
|
1057
|
+
version: manifest.version,
|
|
1058
|
+
populations: buildCaptureTable(memo),
|
|
1059
|
+
registry: manifest.registry,
|
|
1060
|
+
entries,
|
|
1061
|
+
lookups,
|
|
1062
|
+
...collections === void 0 ? {} : { collections }
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
/**
|
|
1066
|
+
* Admits a stored manifest and expands every table reference into the file map it names.
|
|
1067
|
+
*
|
|
1068
|
+
* @param value - The decoded manifest file
|
|
1069
|
+
* @param file - The manifest path each refusal names
|
|
1070
|
+
* @returns The expanded manifest, whose references to one key share one verified map
|
|
1071
|
+
* @throws Thrown with the removal and the refresh commands when the document declares another
|
|
1072
|
+
* protocol version, and thrown when its schema is invalid, a table map does not hash to its key,
|
|
1073
|
+
* or a reference names no table key.
|
|
1074
|
+
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```ts
|
|
1077
|
+
* const manifest = readCaptureManifest(JSON.parse(text), 'tmp/captures/states/manifest.json')
|
|
1078
|
+
* manifest.lookups[0]?.inputs // the expanded input map
|
|
1079
|
+
* ```
|
|
1080
|
+
*/
|
|
1081
|
+
function readCaptureManifest(value, file) {
|
|
1082
|
+
requireCaptureVersion(value, "Manifest", file, [file, "its lookup journal"]);
|
|
1083
|
+
if (!(0, _src_core.isCaptureManifestDocument)(value)) throw new _src_core.CaptureError(`Invalid inherited manifest schema: ${file}`, { code: "EVIDENCE" });
|
|
1084
|
+
const subject = `Manifest at ${file}`;
|
|
1085
|
+
const table = readCaptureTable(value.populations, subject);
|
|
1086
|
+
return {
|
|
1087
|
+
version: value.version,
|
|
1088
|
+
registry: value.registry,
|
|
1089
|
+
entries: Object.fromEntries(Object.entries(value.entries).map(([key, stamp]) => [key, {
|
|
1090
|
+
...stamp,
|
|
1091
|
+
shared: {
|
|
1092
|
+
...stamp.shared,
|
|
1093
|
+
files: requireCaptureTableEntry(table, stamp.shared.files, subject, "shared.files")
|
|
1094
|
+
}
|
|
1095
|
+
}])),
|
|
1096
|
+
lookups: value.lookups.map((lookup) => ({
|
|
876
1097
|
...lookup,
|
|
877
|
-
inputs
|
|
878
|
-
}
|
|
1098
|
+
inputs: requireCaptureTableEntry(table, lookup.inputs, subject, "inputs")
|
|
1099
|
+
})),
|
|
1100
|
+
...value.collections === void 0 ? {} : { collections: value.collections.map((receipt) => ({
|
|
1101
|
+
...receipt,
|
|
1102
|
+
inputs: {
|
|
1103
|
+
...receipt.inputs,
|
|
1104
|
+
files: requireCaptureTableEntry(table, receipt.inputs.files, subject, "inputs.files")
|
|
1105
|
+
}
|
|
1106
|
+
})) }
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Refuses a document that declares a numeric version other than `CAPTURE_VERSION`, naming what to remove and the refresh commands.
|
|
1111
|
+
*
|
|
1112
|
+
* @remarks
|
|
1113
|
+
* A document with no numeric version passes, so the schema check that follows names that fault.
|
|
1114
|
+
* No document of another version is converted.
|
|
1115
|
+
*
|
|
1116
|
+
* @param value - The decoded document
|
|
1117
|
+
* @param subject - The document kind that opens the refusal, such as `Registry`
|
|
1118
|
+
* @param file - The document path the refusal names
|
|
1119
|
+
* @param removal - The paths, or the phrases naming them, to remove before the refresh
|
|
1120
|
+
* @throws Thrown as an `EVIDENCE` capture error whose context carries `file` and `version` when the
|
|
1121
|
+
* document declares another numeric version.
|
|
1122
|
+
*
|
|
1123
|
+
* @example
|
|
1124
|
+
* ```ts
|
|
1125
|
+
* requireCaptureVersion({ version: 1 }, 'Registry', 'registry.json', ['registry.json'])
|
|
1126
|
+
* // throws: Registry version 1 at registry.json is not version 2, … Remove registry.json, then refresh explicitly with: capture registry, then capture frames all
|
|
1127
|
+
* ```
|
|
1128
|
+
*/
|
|
1129
|
+
function requireCaptureVersion(value, subject, file, removal) {
|
|
1130
|
+
const version = (0, _orkestrel_contract.isRecord)(value) ? value.version : void 0;
|
|
1131
|
+
if (typeof version === "number" && version !== _src_core.CAPTURE_VERSION) throw new _src_core.CaptureError(`${subject} version ${String(version)} at ${file} is not version ${String(_src_core.CAPTURE_VERSION)}, and no other version is converted. Remove ${new Intl.ListFormat("en", { type: "conjunction" }).format(removal)}, then refresh explicitly with: capture registry, then capture frames all`, {
|
|
1132
|
+
code: "EVIDENCE",
|
|
1133
|
+
context: {
|
|
1134
|
+
file,
|
|
1135
|
+
version
|
|
1136
|
+
}
|
|
879
1137
|
});
|
|
880
1138
|
}
|
|
881
1139
|
/**
|
|
1140
|
+
* Checks whether an error is the refusal `requireCaptureVersion` throws for another document version.
|
|
1141
|
+
*
|
|
1142
|
+
* @remarks
|
|
1143
|
+
* A caller that adds its own recovery to a refusal passes this one through unchanged, because it
|
|
1144
|
+
* already names the removal and the refresh.
|
|
1145
|
+
*
|
|
1146
|
+
* @param error - The caught value
|
|
1147
|
+
* @returns True if it is an `EVIDENCE` capture error whose context carries a file and a numeric version; false otherwise
|
|
1148
|
+
*
|
|
1149
|
+
* @example
|
|
1150
|
+
* ```ts
|
|
1151
|
+
* matchesCaptureVersionRefusal(captureError(() => requireCaptureVersion({ version: 1 }, 'Registry', file, [file]))) // true
|
|
1152
|
+
* matchesCaptureVersionRefusal(new Error('Invalid')) // false
|
|
1153
|
+
* ```
|
|
1154
|
+
*/
|
|
1155
|
+
function matchesCaptureVersionRefusal(error) {
|
|
1156
|
+
return (0, _src_core.isCaptureError)(error) && error.code === "EVIDENCE" && typeof error.context?.file === "string" && typeof error.context.version === "number";
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Classifies a failure raised while reading the accepted registry as the registry condition.
|
|
1160
|
+
*
|
|
1161
|
+
* @remarks
|
|
1162
|
+
* The complete-registry refresh clears every such failure but a document of another version, whose
|
|
1163
|
+
* refusal names its own removal and refresh.
|
|
1164
|
+
*
|
|
1165
|
+
* @param error - The value a registry read threw
|
|
1166
|
+
* @returns A `REGISTRY` capture error with the same message and the original as its cause, for a
|
|
1167
|
+
* value that is not a capture error or is an `EVIDENCE` capture error other than a version refusal;
|
|
1168
|
+
* otherwise the value itself
|
|
1169
|
+
*
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```ts
|
|
1172
|
+
* resolveCaptureRegistryFault(new CaptureError('Invalid accepted registry schema or digest', { code: 'EVIDENCE' })) // a REGISTRY capture error
|
|
1173
|
+
* resolveCaptureRegistryFault(new CaptureError('Unknown portfolio: x', { code: 'SELECTION' })) // the same error
|
|
1174
|
+
* ```
|
|
1175
|
+
*/
|
|
1176
|
+
function resolveCaptureRegistryFault(error) {
|
|
1177
|
+
return (0, _src_core.isCaptureError)(error) && (error.code !== "EVIDENCE" || matchesCaptureVersionRefusal(error)) ? error : new _src_core.CaptureError((0, _src_core.describeCaptureError)(error), {
|
|
1178
|
+
code: "REGISTRY",
|
|
1179
|
+
cause: error
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Collects the variants that produce each destination across the registry receipts and the lookup runs.
|
|
1184
|
+
*
|
|
1185
|
+
* @param evidence - The accepted registry and the authenticated lookup runs
|
|
1186
|
+
* @returns Each destination description mapped to its distinct producing variants, in first-seen order
|
|
1187
|
+
*
|
|
1188
|
+
* @example
|
|
1189
|
+
* ```ts
|
|
1190
|
+
* collectCaptureProducers({ registry, runs: [] }).get(describeCaptureDestination(destination)) // ['light-390']
|
|
1191
|
+
* ```
|
|
1192
|
+
*/
|
|
1193
|
+
function collectCaptureProducers(evidence) {
|
|
1194
|
+
const sources = [...evidence.registry.receipts, ...evidence.runs.map((entry) => entry.run)];
|
|
1195
|
+
const attributions = Map.groupBy(sources.flatMap((source) => source.registry.map((entry) => ({
|
|
1196
|
+
description: (0, _src_core.describeCaptureDestination)(entry),
|
|
1197
|
+
variant: source.variant
|
|
1198
|
+
}))), (entry) => entry.description);
|
|
1199
|
+
return new Map([...attributions].map(([description, entries]) => [description, [...new Set(entries.map((entry) => entry.variant))]]));
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Returns the one variant that produces a destination, refusing a destination with none or several.
|
|
1203
|
+
*
|
|
1204
|
+
* @param destination - The destination whose producer is read
|
|
1205
|
+
* @param producers - The map `collectCaptureProducers` returns
|
|
1206
|
+
* @returns The destination's unique producing variant
|
|
1207
|
+
* @throws Thrown as an `EVIDENCE` capture error when no variant or more than one produces the destination.
|
|
1208
|
+
*
|
|
1209
|
+
* @example
|
|
1210
|
+
* ```ts
|
|
1211
|
+
* requireCaptureProducer(destination, collectCaptureProducers({ registry, runs: [] })) // 'light-390'
|
|
1212
|
+
* ```
|
|
1213
|
+
*/
|
|
1214
|
+
function requireCaptureProducer(destination, producers) {
|
|
1215
|
+
const variants = producers.get((0, _src_core.describeCaptureDestination)(destination)) ?? [];
|
|
1216
|
+
if (variants.length !== 1 || variants[0] === void 0) throw new _src_core.CaptureError("Destination has no unique producing variant", { code: "EVIDENCE" });
|
|
1217
|
+
return variants[0];
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
882
1220
|
* Computes the registry identity from its authenticated receipts and exact output population.
|
|
883
1221
|
*
|
|
884
1222
|
* @param registry - The registry fields before its digest is attached
|
|
@@ -886,7 +1224,7 @@ function readCaptureLookups(journal) {
|
|
|
886
1224
|
*
|
|
887
1225
|
* @example
|
|
888
1226
|
* ```ts
|
|
889
|
-
* computeRegistryDigest({ version:
|
|
1227
|
+
* computeRegistryDigest({ version: 2, receipts: [], entries: [] }).length // 64
|
|
890
1228
|
* ```
|
|
891
1229
|
*/
|
|
892
1230
|
function computeRegistryDigest(registry) {
|
|
@@ -970,12 +1308,10 @@ function matchesCaptureSignature(bytes) {
|
|
|
970
1308
|
*/
|
|
971
1309
|
function predictCaptureByte(left, up, corner) {
|
|
972
1310
|
const estimate = left + up - corner;
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
];
|
|
978
|
-
return (distances[0] ?? 0) <= (distances[1] ?? 0) && (distances[0] ?? 0) <= (distances[2] ?? 0) ? left : (distances[1] ?? 0) <= (distances[2] ?? 0) ? up : corner;
|
|
1311
|
+
const west = Math.abs(estimate - left);
|
|
1312
|
+
const north = Math.abs(estimate - up);
|
|
1313
|
+
const diagonal = Math.abs(estimate - corner);
|
|
1314
|
+
return west <= north && west <= diagonal ? left : north <= diagonal ? up : corner;
|
|
979
1315
|
}
|
|
980
1316
|
/**
|
|
981
1317
|
* Reads PNG compressed-data chunks while refusing truncated or corrupt image bytes.
|
|
@@ -983,7 +1319,10 @@ function predictCaptureByte(left, up, corner) {
|
|
|
983
1319
|
* @param bytes - The complete PNG
|
|
984
1320
|
* @param offset - The next chunk header. Default: 8.
|
|
985
1321
|
* @returns Ordered compressed-data chunks
|
|
986
|
-
* @throws Thrown for
|
|
1322
|
+
* @throws Thrown for bytes over the file budget; a truncated chunk, which a file with no closing
|
|
1323
|
+
* chunk also meets; a bad checksum; a closing chunk that is not empty and last; an IHDR chunk
|
|
1324
|
+
* anywhere but offset 8; a critical chunk other than IHDR, PLTE, IDAT, and IEND; or IDAT chunks
|
|
1325
|
+
* that are not consecutive.
|
|
987
1326
|
*
|
|
988
1327
|
* @example
|
|
989
1328
|
* ```ts
|
|
@@ -992,23 +1331,89 @@ function predictCaptureByte(left, up, corner) {
|
|
|
992
1331
|
*/
|
|
993
1332
|
function readCaptureChunks(bytes, offset = 8) {
|
|
994
1333
|
requireCaptureImageSize(bytes.length);
|
|
995
|
-
const positions =
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
1334
|
+
const positions = scanCaptureChunks(bytes, offset, Infinity);
|
|
1335
|
+
const types = positions.map((position) => bytes.readUInt32BE(position + 4));
|
|
1336
|
+
const header = Buffer.from("IHDR", "latin1").readUInt32BE(0);
|
|
1337
|
+
const palette = Buffer.from("PLTE", "latin1").readUInt32BE(0);
|
|
1338
|
+
const data = Buffer.from("IDAT", "latin1").readUInt32BE(0);
|
|
1339
|
+
const end = Buffer.from("IEND", "latin1").readUInt32BE(0);
|
|
1340
|
+
const last = positions.at(-1);
|
|
1341
|
+
if (last === void 0 || types.at(-1) !== end) throw new _src_core.CaptureError(`Missing capture PNG closing chunk: ${last === void 0 ? `no chunk follows offset ${(0, _orkestrel_contract.preview)(offset)}` : `the last chunk is ${(0, _orkestrel_contract.preview)(bytes.toString("latin1", last + 4, last + 8))} at offset ${String(last)}`}; expected an empty IEND chunk that ends the file`, { code: "EVIDENCE" });
|
|
1342
|
+
const first = types.indexOf(data);
|
|
1343
|
+
const final = types.lastIndexOf(data);
|
|
1344
|
+
const placed = positions.find((position, index) => types[index] === header && position !== 8);
|
|
1345
|
+
if (placed !== void 0) throw new _src_core.CaptureError(`Invalid capture PNG chunk order: ${describeCaptureChunk(bytes, placed)}; expected one IHDR chunk, at offset 8`, { code: "EVIDENCE" });
|
|
1346
|
+
const unknown = positions.find((position, index) => ((bytes[position + 4] ?? 0) & 32) === 0 && ![
|
|
1347
|
+
header,
|
|
1348
|
+
palette,
|
|
1349
|
+
data,
|
|
1350
|
+
end
|
|
1351
|
+
].includes(types[index] ?? 0));
|
|
1352
|
+
if (unknown !== void 0) throw new _src_core.CaptureError(`Unsupported capture PNG chunk: critical ${describeCaptureChunk(bytes, unknown)}; expected a critical chunk to be IHDR, PLTE, IDAT, or IEND`, { code: "EVIDENCE" });
|
|
1353
|
+
const gap = types.findIndex((type, index) => index > first && index < final && type !== data);
|
|
1354
|
+
const resume = gap === -1 ? -1 : types.indexOf(data, gap);
|
|
1355
|
+
const resumed = positions[resume];
|
|
1356
|
+
const before = positions[resume - 1];
|
|
1357
|
+
if (resumed !== void 0 && before !== void 0) throw new _src_core.CaptureError(`Invalid capture PNG chunk order: ${describeCaptureChunk(bytes, resumed)} follows ${(0, _orkestrel_contract.preview)(bytes.toString("latin1", before + 4, before + 8))} at offset ${String(before)}; expected every IDAT chunk in one consecutive run`, { code: "EVIDENCE" });
|
|
1358
|
+
return positions.flatMap((position, index) => {
|
|
999
1359
|
const length = bytes.readUInt32BE(position);
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1360
|
+
return types[index] === data && length > 0 ? [bytes.subarray(position + 8, position + 8 + length)] : [];
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Walks a PNG's checked chunks from one header and returns each header's offset, up to the closing chunk.
|
|
1365
|
+
*
|
|
1366
|
+
* @remarks
|
|
1367
|
+
* The walk reads at most `count` chunks, and never more than the bytes can hold, so an infinite or
|
|
1368
|
+
* very large count ends at the closing chunk or at a refusal. Each level halves the count, so the
|
|
1369
|
+
* call depth grows with the logarithm of the chunks the bytes can hold.
|
|
1370
|
+
*
|
|
1371
|
+
* @param bytes - The complete PNG
|
|
1372
|
+
* @param position - The offset of the first chunk header to read
|
|
1373
|
+
* @param count - The most chunks to read
|
|
1374
|
+
* @returns The offset of each chunk header read, in order
|
|
1375
|
+
* @throws Thrown for a truncated chunk, a bad checksum, or a closing chunk that is not empty and last.
|
|
1376
|
+
*
|
|
1377
|
+
* @example
|
|
1378
|
+
* ```ts
|
|
1379
|
+
* scanCaptureChunks(encodeCapturePicture({ width: 1, height: 1, pixels: Uint8Array.from([1, 2, 3]) }), 8, Infinity) // [8, 33, 57]
|
|
1380
|
+
* ```
|
|
1381
|
+
*/
|
|
1382
|
+
function scanCaptureChunks(bytes, position, count) {
|
|
1383
|
+
const limit = Math.min(count, Math.floor(bytes.length / 12) + 1);
|
|
1384
|
+
if (limit >= 2) {
|
|
1385
|
+
const half = Math.ceil(limit / 2);
|
|
1386
|
+
const head = scanCaptureChunks(bytes, position, half);
|
|
1387
|
+
const last = head.at(-1);
|
|
1388
|
+
if (last === void 0 || bytes.toString("latin1", last + 4, last + 8) === "IEND") return head;
|
|
1389
|
+
return [...head, ...scanCaptureChunks(bytes, last + 12 + bytes.readUInt32BE(last), limit - half)];
|
|
1010
1390
|
}
|
|
1011
|
-
|
|
1391
|
+
if (!(limit >= 1)) return [];
|
|
1392
|
+
if (!Number.isSafeInteger(position) || position < 8 || position + 12 > bytes.length) throw new _src_core.CaptureError(`Truncated capture PNG: no 12-byte chunk frame fits at offset ${(0, _orkestrel_contract.preview)(position)} in ${String(bytes.length)} bytes; expected a whole offset from 8 with 12 bytes after it`, { code: "EVIDENCE" });
|
|
1393
|
+
const end = position + 12 + bytes.readUInt32BE(position);
|
|
1394
|
+
if (end > bytes.length) throw new _src_core.CaptureError(`Truncated capture PNG chunk: ${describeCaptureChunk(bytes, position)} ends at byte ${String(end)}; expected it to end within the file's ${String(bytes.length)} bytes`, { code: "EVIDENCE" });
|
|
1395
|
+
const stored = bytes.readUInt32BE(end - 4);
|
|
1396
|
+
const computed = (0, node_zlib.crc32)(bytes.subarray(position + 4, end - 4)) >>> 0;
|
|
1397
|
+
if (computed !== stored) throw new _src_core.CaptureError(`Capture PNG checksum differs: ${describeCaptureChunk(bytes, position)} stores ${stored.toString(16).padStart(8, "0")}; expected ${computed.toString(16).padStart(8, "0")}`, { code: "EVIDENCE" });
|
|
1398
|
+
if (bytes.toString("latin1", position + 4, position + 8) === "IEND" && (end !== position + 12 || end !== bytes.length)) throw new _src_core.CaptureError(`Invalid capture PNG closing chunk: ${describeCaptureChunk(bytes, position)} ends at byte ${String(end)} of ${String(bytes.length)}; expected an empty IEND chunk that ends the file`, { code: "EVIDENCE" });
|
|
1399
|
+
return [position];
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Describes the PNG chunk whose header sits at an offset by its type, offset, and length.
|
|
1403
|
+
*
|
|
1404
|
+
* @remarks The type is untrusted file bytes, so it is JSON-encoded and length-capped.
|
|
1405
|
+
*
|
|
1406
|
+
* @param bytes - The complete PNG
|
|
1407
|
+
* @param position - The offset of the chunk header, with its 8 header bytes inside `bytes`
|
|
1408
|
+
* @returns The chunk's description for a refusal
|
|
1409
|
+
*
|
|
1410
|
+
* @example
|
|
1411
|
+
* ```ts
|
|
1412
|
+
* describeCaptureChunk(encodeCapturePicture(picture), 8) // '"IHDR" at offset 8 with length 13'
|
|
1413
|
+
* ```
|
|
1414
|
+
*/
|
|
1415
|
+
function describeCaptureChunk(bytes, position) {
|
|
1416
|
+
return `${(0, _orkestrel_contract.preview)(bytes.toString("latin1", position + 4, position + 8))} at offset ${String(position)} with length ${String(bytes.readUInt32BE(position))}`;
|
|
1012
1417
|
}
|
|
1013
1418
|
/**
|
|
1014
1419
|
* Reads an image only after its opened file's size is inside the compressed-byte budget.
|
|
@@ -1038,7 +1443,7 @@ function readCaptureImage(file) {
|
|
|
1038
1443
|
* ```
|
|
1039
1444
|
*/
|
|
1040
1445
|
function requireCaptureImageSize(size) {
|
|
1041
|
-
if (!Number.isSafeInteger(size) || size < 0 || size > CAPTURE_PNG_LIMITS.bytes) throw new _src_core.CaptureError(
|
|
1446
|
+
if (!Number.isSafeInteger(size) || size < 0 || size > CAPTURE_PNG_LIMITS.bytes) throw new _src_core.CaptureError(`Capture PNG size is outside the file budget: ${(0, _orkestrel_contract.preview)(size)} bytes; expected a whole number of bytes from 0 to ${String(CAPTURE_PNG_LIMITS.bytes)}`, { code: "EVIDENCE" });
|
|
1042
1447
|
}
|
|
1043
1448
|
/**
|
|
1044
1449
|
* Reconstructs one filtered PNG scanline from its filter byte and the row above.
|
|
@@ -1056,19 +1461,19 @@ function requireCaptureImageSize(size) {
|
|
|
1056
1461
|
*/
|
|
1057
1462
|
function unfilterCaptureRow(filter, line, above, channels) {
|
|
1058
1463
|
const bytes = new Uint8Array(line.length);
|
|
1059
|
-
for (const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}
|
|
1464
|
+
if (filter === 1) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + (index >= channels ? bytes[index - channels] ?? 0 : 0) & 255;
|
|
1465
|
+
else if (filter === 2) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + (above?.[index] ?? 0) & 255;
|
|
1466
|
+
else if (filter === 3) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + ((index >= channels ? bytes[index - channels] ?? 0 : 0) + (above?.[index] ?? 0) >> 1) & 255;
|
|
1467
|
+
else if (filter === 4) for (const index of line.keys()) bytes[index] = (line[index] ?? 0) + predictCaptureByte(index >= channels ? bytes[index - channels] ?? 0 : 0, above?.[index] ?? 0, index >= channels ? above?.[index - channels] ?? 0 : 0) & 255;
|
|
1468
|
+
else bytes.set(line);
|
|
1065
1469
|
return bytes;
|
|
1066
1470
|
}
|
|
1067
1471
|
/**
|
|
1068
1472
|
* Inflates a PNG's compressed stream, refusing one that is corrupt or longer than declared.
|
|
1069
1473
|
*
|
|
1070
1474
|
* @param data - The concatenated data-chunk payloads
|
|
1071
|
-
* @param length - The inflated length the header's dimensions declare
|
|
1475
|
+
* @param length - The inflated length the header's dimensions declare, a whole number from 1 to
|
|
1476
|
+
* `Number.MAX_SAFE_INTEGER`; any other value gives an unspecified result that might throw
|
|
1072
1477
|
* @returns The inflated scanlines
|
|
1073
1478
|
* @throws Thrown when the stream is not valid deflate data or inflates past `length`.
|
|
1074
1479
|
*
|
|
@@ -1081,7 +1486,7 @@ function inflateCaptureStream(data, length) {
|
|
|
1081
1486
|
try {
|
|
1082
1487
|
return (0, node_zlib.inflateSync)(data, { maxOutputLength: length });
|
|
1083
1488
|
} catch (error) {
|
|
1084
|
-
throw new _src_core.CaptureError(
|
|
1489
|
+
throw new _src_core.CaptureError(`Capture PNG stream is corrupt or longer than declared: ${(0, _orkestrel_contract.preview)((0, _orkestrel_contract.isError)(error) ? error.message : error)} in ${String(data.length)} compressed bytes; expected a zlib stream that inflates to at most ${(0, _orkestrel_contract.preview)(length)} bytes`, {
|
|
1085
1490
|
code: "EVIDENCE",
|
|
1086
1491
|
cause: error
|
|
1087
1492
|
});
|
|
@@ -1106,24 +1511,27 @@ function inflateCaptureStream(data, length) {
|
|
|
1106
1511
|
*/
|
|
1107
1512
|
function decodeCapturePicture(bytes) {
|
|
1108
1513
|
requireCaptureImageSize(bytes.length);
|
|
1109
|
-
if (bytes.length < 33 || !matchesCaptureSignature(bytes) || bytes.toString("latin1", 12, 16) !== "IHDR" || bytes.readUInt32BE(8) !== 13) throw new _src_core.CaptureError(
|
|
1514
|
+
if (bytes.length < 33 || !matchesCaptureSignature(bytes) || bytes.toString("latin1", 12, 16) !== "IHDR" || bytes.readUInt32BE(8) !== 13) throw new _src_core.CaptureError(`Invalid capture PNG header: ${bytes.length < 33 ? `the file is ${String(bytes.length)} bytes` : !matchesCaptureSignature(bytes) ? `the signature is ${bytes.toString("hex", 0, 8)}` : `the first chunk is ${(0, _orkestrel_contract.preview)(bytes.toString("latin1", 12, 16))} with length ${String(bytes.readUInt32BE(8))}`}; expected at least 33 bytes that open with the signature ${Buffer.from(_src_core.CAPTURE_PNG_SIGNATURE).toString("hex")} and an IHDR chunk with length 13`, { code: "EVIDENCE" });
|
|
1515
|
+
scanCaptureChunks(bytes, 8, 1);
|
|
1110
1516
|
const width = bytes.readUInt32BE(16);
|
|
1111
1517
|
const height = bytes.readUInt32BE(20);
|
|
1112
1518
|
const channels = bytes[25] === 6 ? 4 : bytes[25] === 2 ? 3 : bytes[25] === 4 ? 2 : bytes[25] === 0 ? 1 : 0;
|
|
1113
1519
|
const gray = bytes[25] === 0 || bytes[25] === 4;
|
|
1114
|
-
if (
|
|
1520
|
+
if (channels === 0 || bytes[24] !== 8 || bytes[26] !== 0 || bytes[27] !== 0 || bytes[28] !== 0) throw new _src_core.CaptureError(`Unsupported capture PNG encoding: bit depth ${String(bytes[24])}, colour type ${String(bytes[25])}, compression ${String(bytes[26])}, filter ${String(bytes[27])}, interlace ${String(bytes[28])}; expected bit depth 8, colour type 0, 2, 4, or 6, compression 0, filter 0, and interlace 0`, { code: "EVIDENCE" });
|
|
1521
|
+
const size = `${String(width)} × ${String(height)}`;
|
|
1522
|
+
if (width === 0 || height === 0) throw new _src_core.CaptureError(`Invalid capture PNG dimensions: ${size}; expected a width and a height of at least 1`, { code: "EVIDENCE" });
|
|
1115
1523
|
const stride = width * channels;
|
|
1116
1524
|
const length = (stride + 1) * height;
|
|
1117
|
-
if (!Number.isSafeInteger(length)) throw new _src_core.CaptureError(
|
|
1118
|
-
if (width * height > CAPTURE_PNG_LIMITS.pixels) throw new _src_core.CaptureError(
|
|
1119
|
-
if (width > CAPTURE_PNG_LIMITS.side || height > CAPTURE_PNG_LIMITS.side) throw new _src_core.CaptureError(
|
|
1525
|
+
if (!Number.isSafeInteger(length)) throw new _src_core.CaptureError(`Invalid capture PNG dimensions: ${size} at ${String(channels)} bytes per pixel; expected scanlines of at most ${String(Number.MAX_SAFE_INTEGER)} bytes in all`, { code: "EVIDENCE" });
|
|
1526
|
+
if (width * height > CAPTURE_PNG_LIMITS.pixels) throw new _src_core.CaptureError(`Capture PNG exceeds the pixel budget: ${size} is ${String(width * height)} pixels; expected at most ${String(CAPTURE_PNG_LIMITS.pixels)} pixels`, { code: "EVIDENCE" });
|
|
1527
|
+
if (width > CAPTURE_PNG_LIMITS.side || height > CAPTURE_PNG_LIMITS.side) throw new _src_core.CaptureError(`Capture PNG exceeds the dimension budget: ${size}; expected at most ${String(CAPTURE_PNG_LIMITS.side)} pixels per side`, { code: "EVIDENCE" });
|
|
1120
1528
|
const chunks = readCaptureChunks(bytes);
|
|
1121
1529
|
const raw = inflateCaptureStream(chunks.length === 1 && chunks[0] !== void 0 ? chunks[0] : Buffer.concat(chunks), length);
|
|
1122
|
-
if (raw.length !== length) throw new _src_core.CaptureError(
|
|
1530
|
+
if (raw.length !== length) throw new _src_core.CaptureError(`Capture PNG scanline length differs: the stream inflates to ${String(raw.length)} bytes; expected ${String(length)} bytes for ${size} at ${String(channels)} bytes per pixel and one filter byte per row`, { code: "EVIDENCE" });
|
|
1123
1531
|
const rows = new Uint8Array(stride * height);
|
|
1124
1532
|
for (const row of new Array(height).keys()) {
|
|
1125
1533
|
const filter = raw[row * (stride + 1)];
|
|
1126
|
-
if (filter === void 0 || filter > 4) throw new _src_core.CaptureError(
|
|
1534
|
+
if (filter === void 0 || filter > 4) throw new _src_core.CaptureError(`Unsupported capture PNG filter: type ${String(filter)} on row ${String(row)}; expected a type from 0 to 4`, { code: "EVIDENCE" });
|
|
1127
1535
|
const line = raw.subarray(row * (stride + 1) + 1, (row + 1) * (stride + 1));
|
|
1128
1536
|
rows.set(filter === 0 ? line : unfilterCaptureRow(filter, line, row === 0 ? void 0 : rows.subarray((row - 1) * stride, row * stride), channels), row * stride);
|
|
1129
1537
|
}
|
|
@@ -1193,7 +1601,8 @@ function encodeCaptureChunk(name, data) {
|
|
|
1193
1601
|
* @param picture - The complete RGB pixel buffer
|
|
1194
1602
|
* @param compressed - If `true`, compresses scanlines; if `false`, stores them in the deflate stream. Default: `true`.
|
|
1195
1603
|
* @returns A PNG file
|
|
1196
|
-
* @throws Thrown when
|
|
1604
|
+
* @throws Thrown when a dimension is not a whole number of at least 1, or when the pixel length is
|
|
1605
|
+
* not `width * height * 3`.
|
|
1197
1606
|
*
|
|
1198
1607
|
* @example
|
|
1199
1608
|
* ```ts
|
|
@@ -1222,11 +1631,78 @@ function encodeCapturePicture(picture, compressed = true) {
|
|
|
1222
1631
|
]);
|
|
1223
1632
|
}
|
|
1224
1633
|
/**
|
|
1634
|
+
* Sums a run of samples three bytes apart, one channel of consecutive RGB pixels.
|
|
1635
|
+
*
|
|
1636
|
+
* @remarks
|
|
1637
|
+
* The caller bounds the run: the call reads one sample per column, inside the bytes or not, so a
|
|
1638
|
+
* count that is not above 0 sums nothing and a fractional count reads its ceiling. Each sample reads
|
|
1639
|
+
* `pixels[index] ?? 0` at the index the call computes, so an index outside the bytes, a fractional
|
|
1640
|
+
* index, or a `NaN` index reads 0. For whole-number arguments, the sum equals the direct sum of
|
|
1641
|
+
* those samples where every number the call computes from its arguments is a safe integer, each
|
|
1642
|
+
* sample index among them.
|
|
1643
|
+
*
|
|
1644
|
+
* @param pixels - The source RGB bytes
|
|
1645
|
+
* @param start - The index of the first sample
|
|
1646
|
+
* @param columns - The number of samples to sum
|
|
1647
|
+
* @returns The sum, reading an index outside the bytes or a fractional index as 0
|
|
1648
|
+
* @throws Thrown as an `EVIDENCE` capture error when `columns` is `Infinity`.
|
|
1649
|
+
*
|
|
1650
|
+
* @example
|
|
1651
|
+
* ```ts
|
|
1652
|
+
* sumCaptureRow(Uint8Array.from([1, 0, 0, 2, 0, 0, 3]), 0, 3) // 6
|
|
1653
|
+
* ```
|
|
1654
|
+
*/
|
|
1655
|
+
function sumCaptureRow(pixels, start, columns) {
|
|
1656
|
+
if (columns > 8) {
|
|
1657
|
+
if (columns === Infinity) throw new _src_core.CaptureError("Capture sum columns must be a finite sample count, not Infinity", { code: "EVIDENCE" });
|
|
1658
|
+
const half = Math.ceil(columns / 2);
|
|
1659
|
+
return sumCaptureRow(pixels, start, half) + sumCaptureRow(pixels, start + half * 3, columns - half);
|
|
1660
|
+
}
|
|
1661
|
+
return (columns > 0 ? pixels[start] ?? 0 : 0) + (columns > 1 ? pixels[start + 3] ?? 0 : 0) + (columns > 2 ? pixels[start + 6] ?? 0 : 0) + (columns > 3 ? pixels[start + 9] ?? 0 : 0) + (columns > 4 ? pixels[start + 12] ?? 0 : 0) + (columns > 5 ? pixels[start + 15] ?? 0 : 0) + (columns > 6 ? pixels[start + 18] ?? 0 : 0) + (columns > 7 ? pixels[start + 21] ?? 0 : 0);
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Sums one channel of a picture over a block of source rows.
|
|
1665
|
+
*
|
|
1666
|
+
* @remarks
|
|
1667
|
+
* Source row `top + row` starts its block at `(top + row) * picture.width * 3 + left`, and each row
|
|
1668
|
+
* contributes `columns` samples through `sumCaptureRow`. The caller bounds the block: the call reads
|
|
1669
|
+
* `rows × columns` samples, inside the bytes or not, so a row count that is not above 0 sums nothing
|
|
1670
|
+
* and a fractional row count reads its ceiling. For whole-number arguments, the sum equals the
|
|
1671
|
+
* direct sum of those samples where every number the call computes from its arguments is a safe
|
|
1672
|
+
* integer, each row number, each intermediate sum and product of a row start, and each sample index
|
|
1673
|
+
* among them.
|
|
1674
|
+
*
|
|
1675
|
+
* @param picture - The source RGB picture
|
|
1676
|
+
* @param top - The block's first source row
|
|
1677
|
+
* @param left - The byte offset of the block's first sample inside a row, its channel included
|
|
1678
|
+
* @param row - The first row to sum, counted from `top`
|
|
1679
|
+
* @param rows - The number of rows to sum
|
|
1680
|
+
* @param columns - The number of samples to sum in each row
|
|
1681
|
+
* @returns The block's sum
|
|
1682
|
+
* @throws Thrown as an `EVIDENCE` capture error when `rows` is `Infinity`, or when `columns` is
|
|
1683
|
+
* `Infinity` and the block reads a row.
|
|
1684
|
+
*
|
|
1685
|
+
* @example
|
|
1686
|
+
* ```ts
|
|
1687
|
+
* sumCaptureBlock({ width: 2, height: 2, pixels: Uint8Array.from([1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0]) }, 0, 0, 0, 2, 2) // 10
|
|
1688
|
+
* ```
|
|
1689
|
+
*/
|
|
1690
|
+
function sumCaptureBlock(picture, top, left, row, rows, columns) {
|
|
1691
|
+
if (rows > 2) {
|
|
1692
|
+
if (rows === Infinity) throw new _src_core.CaptureError("Capture sum rows must be a finite row count, not Infinity", { code: "EVIDENCE" });
|
|
1693
|
+
const half = Math.ceil(rows / 2);
|
|
1694
|
+
return sumCaptureBlock(picture, top, left, row, half, columns) + sumCaptureBlock(picture, top, left, row + half, rows - half, columns);
|
|
1695
|
+
}
|
|
1696
|
+
return (rows > 0 ? sumCaptureRow(picture.pixels, (top + row) * picture.width * 3 + left, columns) : 0) + (rows > 1 ? sumCaptureRow(picture.pixels, (top + (row + 1)) * picture.width * 3 + left, columns) : 0);
|
|
1697
|
+
}
|
|
1698
|
+
/**
|
|
1225
1699
|
* Scales a picture with an exact area average and clips its displayed height.
|
|
1226
1700
|
*
|
|
1227
1701
|
* @param picture - The source RGB picture
|
|
1228
|
-
* @param factor - The
|
|
1229
|
-
*
|
|
1702
|
+
* @param factor - The reduction factor, a whole number of at least 1; any other value gives an
|
|
1703
|
+
* unspecified result that might throw
|
|
1704
|
+
* @param limit - The maximum displayed height, a whole number of at least 1; any other value gives
|
|
1705
|
+
* an unspecified result that might throw
|
|
1230
1706
|
* @returns A separately owned scaled picture
|
|
1231
1707
|
*
|
|
1232
1708
|
* @example
|
|
@@ -1237,7 +1713,7 @@ function encodeCapturePicture(picture, compressed = true) {
|
|
|
1237
1713
|
function shrinkCapturePicture(picture, factor, limit) {
|
|
1238
1714
|
const width = Math.max(1, Math.ceil(picture.width / factor));
|
|
1239
1715
|
const height = Math.min(Math.max(1, Math.ceil(picture.height / factor)), limit);
|
|
1240
|
-
const
|
|
1716
|
+
const reach = Array.from({ length: Math.ceil(Math.min(factor, Math.max(picture.width, picture.height))) }).length;
|
|
1241
1717
|
const pixels = new Uint8Array(Math.min(Math.max(Math.trunc(width * height * 3) || 0, 0), Number.MAX_SAFE_INTEGER));
|
|
1242
1718
|
const offsets = Array.from({ length: Math.min(width * 3, pixels.length) }, (_, offset) => offset);
|
|
1243
1719
|
const lines = pixels.length === 0 ? 0 : Math.ceil(pixels.length / (width * 3));
|
|
@@ -1246,15 +1722,9 @@ function shrinkCapturePicture(picture, factor, limit) {
|
|
|
1246
1722
|
for (const offset of offsets) {
|
|
1247
1723
|
const index = y * width * 3 + offset;
|
|
1248
1724
|
if (index >= pixels.length) break;
|
|
1249
|
-
const channel = offset % 3;
|
|
1250
1725
|
const x = Math.floor(offset / 3);
|
|
1251
1726
|
const columns = Math.min(factor, picture.width - x * factor);
|
|
1252
|
-
|
|
1253
|
-
if (row >= rows) return total;
|
|
1254
|
-
const start = (y * factor + row) * picture.width * 3 + x * Math.ceil(factor) * 3 + channel;
|
|
1255
|
-
return span.reduce((block, column) => column >= columns ? block : block + (picture.pixels[start + column * 3] ?? 0), total);
|
|
1256
|
-
}, 0);
|
|
1257
|
-
pixels[index] = Math.round(sum / (rows * columns));
|
|
1727
|
+
pixels[index] = Math.round(sumCaptureBlock(picture, y * factor, x * Math.ceil(factor) * 3 + offset % 3, 0, rows > 0 ? Math.min(reach, Math.ceil(rows)) : 0, columns > 0 ? Math.min(reach, Math.ceil(columns)) : 0) / (rows * columns));
|
|
1258
1728
|
}
|
|
1259
1729
|
}
|
|
1260
1730
|
return {
|
|
@@ -1284,16 +1754,19 @@ function composeCapturePictures(pictures, vertical, gap = 6) {
|
|
|
1284
1754
|
if (pictures.length === 0) throw new _src_core.CaptureError("Empty contact-sheet picture selection", { code: "USAGE" });
|
|
1285
1755
|
const { side, pixels: budget } = CAPTURE_PNG_LIMITS;
|
|
1286
1756
|
const faults = [...pictures.flatMap((picture, position) => ["width", "height"].flatMap((axis) => Number.isSafeInteger(picture[axis]) && picture[axis] >= 0 && picture[axis] <= side ? [] : [`pictures[${String(position)}].${axis} is ${(0, _orkestrel_contract.preview)(picture[axis])}`])), ...Number.isSafeInteger(gap) && gap >= 0 && gap <= side ? [] : [`gap is ${(0, _orkestrel_contract.preview)(gap)}`]];
|
|
1287
|
-
const width
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1757
|
+
const { width, height } = computeCaptureComposite(pictures, vertical, gap);
|
|
1758
|
+
if (faults.length > 0 || !matchesCaptureLimits({
|
|
1759
|
+
width,
|
|
1760
|
+
height
|
|
1761
|
+
})) throw new _src_core.CaptureError(`Contact-sheet geometry is out of range: ${faults.length === 0 ? `composite is ${String(width)} × ${String(height)}` : [...faults.slice(0, 16), ...faults.length > 16 ? [`… ${String(faults.length - 16)} more`] : []].join("; ")}; expected whole numbers from 0 to ${String(side)} for every width, height, and gap, and a composite of at most ${String(side)} per side and ${String(budget)} pixels`, { code: "EVIDENCE" });
|
|
1762
|
+
const ends = [];
|
|
1763
|
+
for (const picture of pictures) ends.push((ends.at(-1) ?? 0) + (vertical ? picture.height : picture.width) + gap);
|
|
1292
1764
|
const spans = pictures.map((picture, position) => ({
|
|
1293
1765
|
picture,
|
|
1294
|
-
start:
|
|
1295
|
-
end: Math.min(
|
|
1296
|
-
}));
|
|
1766
|
+
start: ends[position - 1] ?? 0,
|
|
1767
|
+
end: Math.min(ends[position] ?? 0, vertical ? height : width)
|
|
1768
|
+
})).filter((span) => span.end > span.start);
|
|
1769
|
+
const pixels = new Uint8Array(width * height * 3);
|
|
1297
1770
|
if (vertical) {
|
|
1298
1771
|
for (const { picture, start, end } of spans) for (const row of new Array(Math.max(0, end - start)).keys()) {
|
|
1299
1772
|
const copied = row < picture.height ? picture.width : 0;
|
|
@@ -1320,6 +1793,87 @@ function composeCapturePictures(pictures, vertical, gap = 6) {
|
|
|
1320
1793
|
};
|
|
1321
1794
|
}
|
|
1322
1795
|
/**
|
|
1796
|
+
* Computes the width and height of the composite that `composeCapturePictures` builds from
|
|
1797
|
+
* pictures of these sizes.
|
|
1798
|
+
*
|
|
1799
|
+
* @param pictures - The ordered source sizes
|
|
1800
|
+
* @param vertical - If `true`, stacks them; if `false`, places them side by side
|
|
1801
|
+
* @param gap - The space between source pictures. Default: 6.
|
|
1802
|
+
* @returns The composite's width and height, each 0 for no pictures
|
|
1803
|
+
*
|
|
1804
|
+
* @example
|
|
1805
|
+
* ```ts
|
|
1806
|
+
* computeCaptureComposite([{ width: 4, height: 2 }, { width: 3, height: 5 }], false) // { width: 13, height: 5 }
|
|
1807
|
+
* ```
|
|
1808
|
+
*/
|
|
1809
|
+
function computeCaptureComposite(pictures, vertical, gap = 6) {
|
|
1810
|
+
const span = gap * Math.max(0, pictures.length - 1);
|
|
1811
|
+
return vertical ? {
|
|
1812
|
+
width: pictures.reduce((widest, entry) => Math.max(widest, entry.width), 0),
|
|
1813
|
+
height: pictures.reduce((sum, entry) => sum + entry.height, 0) + span
|
|
1814
|
+
} : {
|
|
1815
|
+
width: pictures.reduce((sum, entry) => sum + entry.width, 0) + span,
|
|
1816
|
+
height: pictures.reduce((tallest, entry) => Math.max(tallest, entry.height), 0)
|
|
1817
|
+
};
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Checks whether a picture size fits `CAPTURE_PNG_LIMITS`, per side and in pixels.
|
|
1821
|
+
*
|
|
1822
|
+
* @param picture - The size to check
|
|
1823
|
+
* @returns True if neither side passes `CAPTURE_PNG_LIMITS.side` and the area does not pass
|
|
1824
|
+
* `CAPTURE_PNG_LIMITS.pixels`; false otherwise
|
|
1825
|
+
*
|
|
1826
|
+
* @example
|
|
1827
|
+
* ```ts
|
|
1828
|
+
* matchesCaptureLimits({ width: 13040, height: 1636 }) // false
|
|
1829
|
+
* ```
|
|
1830
|
+
*/
|
|
1831
|
+
function matchesCaptureLimits(picture) {
|
|
1832
|
+
const { side, pixels } = CAPTURE_PNG_LIMITS;
|
|
1833
|
+
return picture.width <= side && picture.height <= side && picture.width * picture.height <= pixels;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* Splits contact-sheet rows into consecutive pages of at most `size` rows whose stacked composite
|
|
1837
|
+
* fits `CAPTURE_PNG_LIMITS`.
|
|
1838
|
+
*
|
|
1839
|
+
* @remarks
|
|
1840
|
+
* A page takes each next row while it holds fewer than `size` rows and the stacked composite,
|
|
1841
|
+
* with `gap` between rows, still fits; otherwise the row opens the next page.
|
|
1842
|
+
*
|
|
1843
|
+
* @param rows - The ordered rows, each with its composite width and height
|
|
1844
|
+
* @param size - The most rows a page holds, a whole number of at least 1; any other value gives an
|
|
1845
|
+
* unspecified result that might throw
|
|
1846
|
+
* @param gap - The space between stacked rows
|
|
1847
|
+
* @returns The pages, in order
|
|
1848
|
+
* @throws Thrown with the `USAGE` condition when one row alone does not fit `CAPTURE_PNG_LIMITS`,
|
|
1849
|
+
* naming its composite, the limits, and the narrower `--variant` selection that recovers.
|
|
1850
|
+
*
|
|
1851
|
+
* @example
|
|
1852
|
+
* ```ts
|
|
1853
|
+
* splitCaptureSheets([{ width: 13040, height: 400 }, { width: 13040, height: 400 }], 4, 12).length // 1
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
function splitCaptureSheets(rows, size, gap) {
|
|
1857
|
+
const wide = rows.find((row) => !matchesCaptureLimits(row));
|
|
1858
|
+
if (wide !== void 0) throw new _src_core.CaptureError(`Contact-sheet row is out of range: composite is ${String(wide.width)} × ${String(wide.height)}; expected at most ${String(CAPTURE_PNG_LIMITS.side)} per side and ${String(CAPTURE_PNG_LIMITS.pixels)} pixels; select fewer variants with --variant`, { code: "USAGE" });
|
|
1859
|
+
const marks = [];
|
|
1860
|
+
for (const [index, row] of rows.entries()) {
|
|
1861
|
+
const last = marks.at(-1);
|
|
1862
|
+
const joined = last === void 0 ? void 0 : {
|
|
1863
|
+
first: last.first,
|
|
1864
|
+
width: Math.max(last.width, row.width),
|
|
1865
|
+
height: last.height + gap + row.height
|
|
1866
|
+
};
|
|
1867
|
+
marks.push(joined !== void 0 && index - joined.first < size && matchesCaptureLimits(joined) ? joined : {
|
|
1868
|
+
first: index,
|
|
1869
|
+
width: row.width,
|
|
1870
|
+
height: row.height
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
const starts = marks.flatMap((mark, index) => mark.first === index ? [index] : []);
|
|
1874
|
+
return starts.map((first, page) => rows.slice(first, starts[page + 1] ?? rows.length));
|
|
1875
|
+
}
|
|
1876
|
+
/**
|
|
1323
1877
|
* Reads the process id that a request file, or its temporary sibling, names.
|
|
1324
1878
|
*
|
|
1325
1879
|
* @param name - A file name from the request directory
|
|
@@ -1470,6 +2024,19 @@ function resolveCaptureVariants(selected, projects) {
|
|
|
1470
2024
|
return variants;
|
|
1471
2025
|
}
|
|
1472
2026
|
/**
|
|
2027
|
+
* Collects the owner selectors the projects' owner tags declare, once each, in tag order.
|
|
2028
|
+
*
|
|
2029
|
+
* @param projects - The discovered host projects
|
|
2030
|
+
* @returns Each tagged owner selector, ancestors included where the wrapper tags them
|
|
2031
|
+
* @example
|
|
2032
|
+
* ```ts
|
|
2033
|
+
* collectCaptureOwners(projects) // ['pages', 'pages:mail'] for owner:pages and owner:pages:mail tags
|
|
2034
|
+
* ```
|
|
2035
|
+
*/
|
|
2036
|
+
function collectCaptureOwners(projects) {
|
|
2037
|
+
return [...new Set(projects.flatMap((project) => project.tags))].filter((tag) => tag.startsWith(_src_core.CAPTURE_OWNER_PREFIX)).map((tag) => tag.slice(_src_core.CAPTURE_OWNER_PREFIX.length));
|
|
2038
|
+
}
|
|
2039
|
+
/**
|
|
1473
2040
|
* Refuses unknown command selections from the wrapper before authenticating disk evidence.
|
|
1474
2041
|
* @example
|
|
1475
2042
|
* ```ts
|
|
@@ -1477,7 +2044,7 @@ function resolveCaptureVariants(selected, projects) {
|
|
|
1477
2044
|
* ```
|
|
1478
2045
|
*/
|
|
1479
2046
|
function requireCaptureSelection(selector, variants, projects, outputs = [], portfolio) {
|
|
1480
|
-
const fault = describeCaptureSelectorFault(selector, [...new Set(projects.flatMap((project) => [...project
|
|
2047
|
+
const fault = describeCaptureSelectorFault(selector, [...new Set(projects.flatMap((project) => [...collectCaptureOwners([project]), ...project.standalone.map((entry) => entry.portfolio)]))]);
|
|
1481
2048
|
if (fault !== void 0) throw new _src_core.CaptureError(fault, { code: "USAGE" });
|
|
1482
2049
|
const portfolios = [...new Set(projects.flatMap((project) => [...project.portfolios, ...project.standalone].map((entry) => entry.portfolio)))];
|
|
1483
2050
|
if (portfolio !== void 0 && !portfolios.includes(portfolio)) throw new _src_core.CaptureError(describeCaptureFault("--portfolio", portfolio, "a portfolio declared by the wrapper", portfolios), { code: "USAGE" });
|
|
@@ -1485,6 +2052,27 @@ function requireCaptureSelection(selector, variants, projects, outputs = [], por
|
|
|
1485
2052
|
for (const variant of variants) if (!declared.includes(variant)) throw new _src_core.CaptureError(describeCaptureFault("--variant", variant, "a variant declared by the wrapper or registry output population", declared), { code: "USAGE" });
|
|
1486
2053
|
}
|
|
1487
2054
|
/**
|
|
2055
|
+
* Picks the standalone portfolio root a selection names by its selector or its portfolio.
|
|
2056
|
+
*
|
|
2057
|
+
* @remarks
|
|
2058
|
+
* A standalone root has no stamping route and no registry refresh, so a selection reads it only
|
|
2059
|
+
* when it names the root's portfolio. Every other selection reads the primary directory.
|
|
2060
|
+
*
|
|
2061
|
+
* @param roots - The wrapper's standalone roots
|
|
2062
|
+
* @param selector - The selected owner selector
|
|
2063
|
+
* @param portfolio - The selected portfolio, when the selection names one
|
|
2064
|
+
* @returns The named standalone root, or `undefined` for a primary selection
|
|
2065
|
+
* @example
|
|
2066
|
+
* ```ts
|
|
2067
|
+
* const vue = { portfolio: 'vue', directory: 'tmp/captures/vue', scoped: false }
|
|
2068
|
+
* resolveCaptureStandalone([vue], 'vue:home') // vue
|
|
2069
|
+
* resolveCaptureStandalone([vue], 'pages:mail') // undefined
|
|
2070
|
+
* ```
|
|
2071
|
+
*/
|
|
2072
|
+
function resolveCaptureStandalone(roots, selector, portfolio) {
|
|
2073
|
+
return roots.find((root) => portfolio === root.portfolio || selector === root.portfolio || selector.startsWith(`${root.portfolio}:`));
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
1488
2076
|
* Reads output variant candidates without authenticating or accepting registry evidence.
|
|
1489
2077
|
* @remarks Missing, unreadable, or malformed registries supply no candidate hints; the integrity engine still authenticates every accepted read.
|
|
1490
2078
|
* @example
|
|
@@ -1567,33 +2155,46 @@ function readCaptureSeparator(entry) {
|
|
|
1567
2155
|
* @param file - The accepted registry path
|
|
1568
2156
|
* @param selector - The optional owner selector that bounds the case candidates
|
|
1569
2157
|
* @returns Exact case names mapped to their original title segments within the selected owners
|
|
2158
|
+
* @throws Thrown with the removal of the registry and the manifest and lookup journal beside it,
|
|
2159
|
+
* and the refresh commands, when the registry declares another protocol version; thrown as a
|
|
2160
|
+
* `REGISTRY` capture error when the registry or a reporter it names is absent, unreadable, or fails
|
|
2161
|
+
* authentication.
|
|
1570
2162
|
* @example
|
|
1571
2163
|
* ```ts
|
|
1572
2164
|
* const titles = readCaptureTitles('/workspace', '/workspace/tmp/captures/states/registry.json')
|
|
1573
2165
|
* ```
|
|
1574
2166
|
*/
|
|
1575
2167
|
function readCaptureTitles(root, file, selector) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
return
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
2168
|
+
try {
|
|
2169
|
+
const path = requireCaptureContained(root, file);
|
|
2170
|
+
const loaded = (0, _orkestrel_contract.attempt)(() => (0, node_fs.readFileSync)(path, "utf8"));
|
|
2171
|
+
if (!loaded.success) throw new _src_core.CaptureError(`Missing accepted registry; run the explicit complete-registry refresh: capture registry. Registry path: ${file}`, {
|
|
2172
|
+
code: "EVIDENCE",
|
|
2173
|
+
cause: loaded.error
|
|
2174
|
+
});
|
|
2175
|
+
const registry = (0, _orkestrel_contract.parseJSON)(loaded.value);
|
|
2176
|
+
requireCaptureVersion(registry, "Registry", file, [
|
|
2177
|
+
file,
|
|
2178
|
+
(0, node_path.resolve)((0, node_path.dirname)(file), _src_core.CAPTURE_MANIFEST_FILE),
|
|
2179
|
+
(0, node_path.resolve)((0, node_path.dirname)(file), _src_core.CAPTURE_LOOKUPS_FILE)
|
|
2180
|
+
]);
|
|
2181
|
+
if (!(0, _src_core.isCaptureRegistry)(registry)) throw new _src_core.CaptureError("Invalid accepted registry for case titles", { code: "EVIDENCE" });
|
|
2182
|
+
return Object.fromEntries(registry.receipts.flatMap((receipt) => {
|
|
2183
|
+
const text = (0, node_fs.readFileSync)(requireCaptureContained(root, (0, node_path.resolve)(root, receipt.report.file)), "utf8");
|
|
2184
|
+
if (computeCaptureHash(text) !== receipt.report.digest) throw new _src_core.CaptureError("Registry reporter digest differs for case titles", { code: "EVIDENCE" });
|
|
2185
|
+
const report = (0, _orkestrel_contract.parseJSON)(text);
|
|
2186
|
+
if (!(0, _orkestrel_contract.isRecord)(report) || !(0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isRecord)(report.testResults)) throw new _src_core.CaptureError("Invalid registry reporter for case titles", { code: "EVIDENCE" });
|
|
2187
|
+
const selected = selector === void 0 ? void 0 : new Set((0, _src_core.readCaptureReport)(report).assertions.filter((entry) => (0, _src_core.matchesCaptureSelector)(entry.owner, selector)).map((entry) => entry.case));
|
|
2188
|
+
return report.testResults.flatMap((result) => !(0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isRecord)(result.assertionResults) ? [] : result.assertionResults.flatMap((assertion) => {
|
|
2189
|
+
if (!(0, _orkestrel_contract.isString)(assertion.fullName) || !(0, _orkestrel_contract.isString)(assertion.title) || !(0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)(assertion.ancestorTitles)) return [];
|
|
2190
|
+
const titles = [...assertion.ancestorTitles, assertion.title];
|
|
2191
|
+
if (titles.join(" ") !== assertion.fullName) throw new _src_core.CaptureError("Registry reporter title segments differ from its case", { code: "EVIDENCE" });
|
|
2192
|
+
return selected === void 0 || selected.has(assertion.fullName) ? [[assertion.fullName, titles]] : [];
|
|
2193
|
+
}));
|
|
1595
2194
|
}));
|
|
1596
|
-
})
|
|
2195
|
+
} catch (error) {
|
|
2196
|
+
throw resolveCaptureRegistryFault(error);
|
|
2197
|
+
}
|
|
1597
2198
|
}
|
|
1598
2199
|
/**
|
|
1599
2200
|
* Parses standard option tokens and refuses empty values, terminators, and repeated single options.
|
|
@@ -1947,7 +2548,7 @@ function readCaptureRequest(options) {
|
|
|
1947
2548
|
code: "HOST",
|
|
1948
2549
|
context: { file }
|
|
1949
2550
|
});
|
|
1950
|
-
if (parsed.version !==
|
|
2551
|
+
if (parsed.version !== _src_core.CAPTURE_VERSION) throw new _src_core.CaptureError("Journey selection request has invalid version", { code: "HOST" });
|
|
1951
2552
|
if (!(0, _src_core.isCaptureSegment)(parsed.id) || !(0, _src_core.isCaptureSegment)(parsed.stage)) throw new _src_core.CaptureError("Journey selection request has invalid identity", { code: "HOST" });
|
|
1952
2553
|
if (parsed.config !== options.config) throw new _src_core.CaptureError("Journey selection request has invalid config", { code: "HOST" });
|
|
1953
2554
|
if (parsed.mode !== void 0 && (typeof parsed.mode !== "string" || parsed.mode.trim() === "")) throw new _src_core.CaptureError("Journey selection request has invalid mode", { code: "HOST" });
|
|
@@ -1957,7 +2558,7 @@ function readCaptureRequest(options) {
|
|
|
1957
2558
|
const variants = (0, _orkestrel_contract.arrayOf)(_orkestrel_contract.isString)(parsed.variants) ? parsed.variants : void 0;
|
|
1958
2559
|
if (command === void 0 || selector === void 0 || selector.trim() === "" || selector !== "all" && !options.owners.some((owner) => (0, _src_core.matchesCaptureSelector)(owner, selector)) || variants === void 0 || variants.length === 0 || new Set(variants).size !== variants.length || variants.some((variant) => !options.variants.includes(variant)) || parsed.case !== void 0 && (typeof parsed.case !== "string" || parsed.case.trim() === "")) throw new _src_core.CaptureError("Journey selection request has invalid command, selector, variants, or case", { code: "HOST" });
|
|
1959
2560
|
return {
|
|
1960
|
-
version:
|
|
2561
|
+
version: _src_core.CAPTURE_VERSION,
|
|
1961
2562
|
id: parsed.id,
|
|
1962
2563
|
stage: parsed.stage,
|
|
1963
2564
|
config: options.config,
|
|
@@ -2130,7 +2731,34 @@ function scanCaptureFrames(images, producers) {
|
|
|
2130
2731
|
* ```
|
|
2131
2732
|
*/
|
|
2132
2733
|
function collectCaptureIdentical(images) {
|
|
2133
|
-
return [...
|
|
2734
|
+
return [...Map.groupBy(images, (image) => image.digest).values()].filter((group) => group.length > 1).map((group) => group.map((image) => image.entry.file));
|
|
2735
|
+
}
|
|
2736
|
+
/**
|
|
2737
|
+
* Builds the report a preflight prints and a contact-sheet index carries from one preflight result.
|
|
2738
|
+
*
|
|
2739
|
+
* @param result - The judged selection
|
|
2740
|
+
* @returns The selection, freshness, mixed observations, issues, identical groups, image sizes, and `acceptance: false`
|
|
2741
|
+
*
|
|
2742
|
+
* @example
|
|
2743
|
+
* ```ts
|
|
2744
|
+
* buildCaptureReaderReport(await preflight.check()).acceptance // false
|
|
2745
|
+
* ```
|
|
2746
|
+
*/
|
|
2747
|
+
function buildCaptureReaderReport(result) {
|
|
2748
|
+
return {
|
|
2749
|
+
selection: result.selection,
|
|
2750
|
+
freshness: result.freshness,
|
|
2751
|
+
mixed: result.mixed,
|
|
2752
|
+
issues: result.issues,
|
|
2753
|
+
identical: collectCaptureIdentical(result.images),
|
|
2754
|
+
sizes: result.images.map(({ entry, picture, size }) => ({
|
|
2755
|
+
file: entry.file,
|
|
2756
|
+
width: picture.width,
|
|
2757
|
+
height: picture.height,
|
|
2758
|
+
bytes: size
|
|
2759
|
+
})),
|
|
2760
|
+
acceptance: false
|
|
2761
|
+
};
|
|
2134
2762
|
}
|
|
2135
2763
|
/**
|
|
2136
2764
|
* Finds the journey artifact lines that report an uncaught, unhandled, or logged error.
|
|
@@ -2266,7 +2894,7 @@ function readCaptureDescription(value, expected) {
|
|
|
2266
2894
|
"pid",
|
|
2267
2895
|
"projects"
|
|
2268
2896
|
];
|
|
2269
|
-
if (!(0, _orkestrel_contract.isRecord)(value) || value.version !== _src_core.CAPTURE_VERSION || !(0, _orkestrel_contract.isArray)(value.projects) || keys.some((key) => value[key] === void 0) || Object.keys(value).some((key) => !keys.includes(key))) throw new _src_core.CaptureError(`The host description is malformed; ${describeCaptureFault("description", value,
|
|
2897
|
+
if (!(0, _orkestrel_contract.isRecord)(value) || value.version !== _src_core.CAPTURE_VERSION || !(0, _orkestrel_contract.isArray)(value.projects) || keys.some((key) => value[key] === void 0) || Object.keys(value).some((key) => !keys.includes(key))) throw new _src_core.CaptureError(`The host description is malformed; ${describeCaptureFault("description", value, `{ version: ${String(_src_core.CAPTURE_VERSION)}, id: invocation id, nonce: challenge, config: wrapper path, parent: parent pid, pid: discovery child pid, projects: project[] }`, keys, keys)}`, { code: "HOST" });
|
|
2270
2898
|
if (value.id !== expected.id) throw new _src_core.CaptureError(`The host description answers another invocation; ${describeCaptureFault("description.id", value.id, "the active invocation id", [expected.id])}`, { code: "HOST" });
|
|
2271
2899
|
if (value.nonce !== expected.nonce) throw new _src_core.CaptureError(`The host description answers another challenge (a replay); ${describeCaptureFault("description.nonce", value.nonce, "the active discovery challenge", [expected.nonce])}`, { code: "HOST" });
|
|
2272
2900
|
if (value.config !== expected.config) throw new _src_core.CaptureError(`The host description names another wrapper; ${describeCaptureFault("description.config", value.config, "the requested wrapper path", [expected.config])}`, { code: "HOST" });
|
|
@@ -3096,15 +3724,15 @@ var CaptureIntegrity = class {
|
|
|
3096
3724
|
if (request.command === "capture" && stamps.length > 0) {
|
|
3097
3725
|
const inherited = Object.entries(evidence.manifest?.entries ?? {});
|
|
3098
3726
|
const replaced = new Set(stamps.map(_src_core.resolveCaptureKey));
|
|
3099
|
-
const
|
|
3727
|
+
const document = buildCaptureManifestDocument({
|
|
3100
3728
|
collections,
|
|
3101
3729
|
version: _src_core.CAPTURE_VERSION,
|
|
3102
3730
|
registry: evidence.registry,
|
|
3103
3731
|
entries: Object.fromEntries([...inherited.filter(([key]) => !replaced.has(key)), ...stamps.map((stamp) => [(0, _src_core.resolveCaptureKey)(stamp), stamp])]),
|
|
3104
3732
|
lookups: merged
|
|
3105
|
-
};
|
|
3106
|
-
if (!(0, _src_core.
|
|
3107
|
-
this.#commit(this.#options.manifest,
|
|
3733
|
+
});
|
|
3734
|
+
if (!(0, _src_core.isCaptureManifestDocument)(document)) throw new _src_core.CaptureError("Invalid next manifest", { code: "EVIDENCE" });
|
|
3735
|
+
this.#commit(this.#options.manifest, document, options.signal);
|
|
3108
3736
|
} else if (request.command === "journey" && collected.length > 0) {
|
|
3109
3737
|
const manifest = before.files.find((file) => file.file === this.#options.manifest)?.image.digest;
|
|
3110
3738
|
this.#commit(this.#options.lookups, buildCaptureLookupJournal(merged, collections, manifest), options.signal);
|
|
@@ -3148,12 +3776,13 @@ var CaptureIntegrity = class {
|
|
|
3148
3776
|
const destinations = this.#destinations(populated);
|
|
3149
3777
|
this.#uniqueRegistry(destinations);
|
|
3150
3778
|
const variants = this.#variants(destinations, options);
|
|
3151
|
-
const entries = this.#select(
|
|
3779
|
+
const entries = this.#select(destinations, {
|
|
3152
3780
|
...options,
|
|
3153
3781
|
variants
|
|
3154
|
-
}
|
|
3782
|
+
});
|
|
3155
3783
|
const inputs = this.#digest(this.#options.inputs, snapshots, digests);
|
|
3156
|
-
|
|
3784
|
+
const producers = collectCaptureProducers(populated);
|
|
3785
|
+
for (const variant of new Set(entries.map((entry) => requireCaptureProducer(entry, producers)))) {
|
|
3157
3786
|
const anchor = evidence.registry.receipts.find((receipt) => receipt.variant === variant);
|
|
3158
3787
|
if (anchor !== void 0 && (0, _src_core.collectCaptureChanges)(anchor.inputs, inputs.files).length === 0) continue;
|
|
3159
3788
|
if (!collections.some((entry) => entry.run.variant === variant && entry.receipt.inputs.digest === inputs.digest)) throw new _src_core.CaptureError(`No current full-collection evidence for producing variant: ${variant}`, {
|
|
@@ -3167,6 +3796,7 @@ var CaptureIntegrity = class {
|
|
|
3167
3796
|
entries
|
|
3168
3797
|
};
|
|
3169
3798
|
} catch (error) {
|
|
3799
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
3170
3800
|
throw new _src_core.CaptureError(`${(0, _src_core.describeCaptureError)(error)}. Prepare the explicit complete-registry refresh, or an explicit capture-free owner/case run whose full collection equals that anchor for each affected producing variant; this read starts no process.`, {
|
|
3171
3801
|
code: (0, _src_core.isCaptureError)(error) ? error.code : "EVIDENCE",
|
|
3172
3802
|
cause: error
|
|
@@ -3197,7 +3827,7 @@ var CaptureIntegrity = class {
|
|
|
3197
3827
|
const attested = /* @__PURE__ */ new Set([...evidence.registry.receipts.map((receipt) => receipt.variant), ...evidence.runs.map(({ run }) => run.variant)]);
|
|
3198
3828
|
const unattested = selection.variants === void 0 ? (selection.declared ?? []).filter((variant) => !attested.has(variant)) : [];
|
|
3199
3829
|
if (unattested.length > 0) throw new _src_core.CaptureError(`Unattested declared variant: ${unattested.join(", ")}`, {
|
|
3200
|
-
code: "
|
|
3830
|
+
code: "REGISTRY",
|
|
3201
3831
|
context: { variants: unattested }
|
|
3202
3832
|
});
|
|
3203
3833
|
const registry = this.#destinations(evidence);
|
|
@@ -3205,7 +3835,7 @@ var CaptureIntegrity = class {
|
|
|
3205
3835
|
...selection,
|
|
3206
3836
|
variants: this.#variants(registry, selection)
|
|
3207
3837
|
};
|
|
3208
|
-
const required = this.#select(
|
|
3838
|
+
const required = this.#select(registry, options);
|
|
3209
3839
|
const disk = this.#images();
|
|
3210
3840
|
const identities = /* @__PURE__ */ new Map();
|
|
3211
3841
|
const physical = Map.groupBy(disk, (file) => this.#physicalIdentity(file, identities));
|
|
@@ -3295,8 +3925,9 @@ var CaptureIntegrity = class {
|
|
|
3295
3925
|
*
|
|
3296
3926
|
* @param options - The original selector, producing variants, state, and optional exact case
|
|
3297
3927
|
* @returns The agreed declaring case, output mappings, and validated lookup receipts
|
|
3298
|
-
* @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection;
|
|
3299
|
-
* the
|
|
3928
|
+
* @throws Thrown when evidence is missing, stale, ambiguous, or disagrees with the selection; a
|
|
3929
|
+
* refusal of the requested state names the owner's journey refresh, and a fault in the evidence
|
|
3930
|
+
* read keeps its own message.
|
|
3300
3931
|
*
|
|
3301
3932
|
* @example
|
|
3302
3933
|
* ```ts
|
|
@@ -3308,7 +3939,7 @@ var CaptureIntegrity = class {
|
|
|
3308
3939
|
const snapshots = /* @__PURE__ */ new Map();
|
|
3309
3940
|
const digests = /* @__PURE__ */ new Map();
|
|
3310
3941
|
const evidence = this.#evidence(snapshots);
|
|
3311
|
-
const entries = this.#select(
|
|
3942
|
+
const entries = this.#select(this.#destinations(evidence), options, collectCaptureProducers(evidence));
|
|
3312
3943
|
this.#uniqueRegistry(entries);
|
|
3313
3944
|
const cases = [...new Set(entries.map((entry) => entry.case))];
|
|
3314
3945
|
const [name] = cases;
|
|
@@ -3319,15 +3950,17 @@ var CaptureIntegrity = class {
|
|
|
3319
3950
|
lookups: entries.map((entry) => {
|
|
3320
3951
|
const run = evidence.runs.find((record) => record.run.registry.some((destination) => (0, _src_core.describeCaptureDestination)(destination) === (0, _src_core.describeCaptureDestination)(entry)));
|
|
3321
3952
|
const lookup = evidence.lookups.find((candidate) => candidate.case === entry.case && candidate.variant === run?.run.variant && candidate.states.includes(options.state));
|
|
3322
|
-
if (lookup === void 0 || lookup.registry !== evidence.registry.digest || !(0, _src_core.matchesCaptureSelector)(lookup.owner, options.selector) || (0, _src_core.collectCaptureChanges)(lookup.inputs, this.#digest(this.#options.inputs, snapshots, digests).files).length > 0) throw new _src_core.CaptureError(`Missing or stale state lookup: ${entry.state} in ${entry.project}`, { code: "
|
|
3953
|
+
if (lookup === void 0 || lookup.registry !== evidence.registry.digest || !(0, _src_core.matchesCaptureSelector)(lookup.owner, options.selector) || (0, _src_core.collectCaptureChanges)(lookup.inputs, this.#digest(this.#options.inputs, snapshots, digests).files).length > 0) throw new _src_core.CaptureError(`Missing or stale state lookup: ${entry.state} in ${entry.project}`, { code: "LOOKUP" });
|
|
3323
3954
|
const stamp = evidence.manifest?.entries[(0, _src_core.resolveCaptureKey)(entry)];
|
|
3324
3955
|
if (stamp !== void 0 && (0, _src_core.describeCaptureIdentity)(stamp) !== (0, _src_core.describeCaptureIdentity)(entry)) throw new _src_core.CaptureError("State lookup disagrees with the manifest identity", { code: "EVIDENCE" });
|
|
3325
3956
|
return lookup;
|
|
3326
3957
|
})
|
|
3327
3958
|
};
|
|
3328
3959
|
} catch (error) {
|
|
3329
|
-
|
|
3330
|
-
|
|
3960
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
3961
|
+
const code = (0, _src_core.isCaptureError)(error) ? error.code : "EVIDENCE";
|
|
3962
|
+
throw new _src_core.CaptureError(code === "LOOKUP" || code === "USAGE" || code === "SELECTION" ? `${(0, _src_core.describeCaptureError)(error)}. Refresh explicitly with: capture journey ${options.selector}${options.variants.map((variant) => ` --variant ${variant}`).join("")}${options.case === void 0 ? "" : ` --case ${JSON.stringify(options.case)}`}. Registry declaration changes require the complete-registry refresh: capture registry.` : (0, _src_core.describeCaptureError)(error), {
|
|
3963
|
+
code,
|
|
3331
3964
|
cause: error
|
|
3332
3965
|
});
|
|
3333
3966
|
}
|
|
@@ -3540,26 +4173,34 @@ var CaptureIntegrity = class {
|
|
|
3540
4173
|
(0, _src_core.requireCaptureUnique)(entries.map((entry) => entry.file), "registry paths", true);
|
|
3541
4174
|
}
|
|
3542
4175
|
#registry(snapshots, paths) {
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
(0, _src_core.requireCaptureUnique)(
|
|
4176
|
+
try {
|
|
4177
|
+
if (!(0, node_fs.existsSync)(this.#path(this.#options.registry, paths))) throw new _src_core.CaptureError("Missing accepted registry; run the explicit complete-registry refresh", { code: "EVIDENCE" });
|
|
4178
|
+
const registry = this.#json(this.#options.registry, paths);
|
|
4179
|
+
requireCaptureVersion(registry, "Registry", this.#options.registry, [
|
|
4180
|
+
this.#options.registry,
|
|
4181
|
+
this.#options.manifest,
|
|
4182
|
+
this.#options.lookups
|
|
4183
|
+
]);
|
|
4184
|
+
if (!(0, _src_core.isCaptureRegistry)(registry) || registry.digest !== computeRegistryDigest(registry) || registry.receipts.length === 0) throw new _src_core.CaptureError("Invalid accepted registry schema or digest", { code: "EVIDENCE" });
|
|
4185
|
+
(0, _src_core.requireCaptureUnique)(registry.receipts.map((receipt) => receipt.variant), "complete receipt variants", true);
|
|
4186
|
+
for (const receipt of registry.receipts) {
|
|
4187
|
+
const report = this.#file(receipt.report.file, snapshots, paths);
|
|
4188
|
+
if (!receipt.complete || report?.image.digest !== receipt.report.digest) throw new _src_core.CaptureError("Registry receipt is incomplete or its report changed", { code: "EVIDENCE" });
|
|
4189
|
+
(0, _src_core.validateCaptureReceipt)(receipt, (0, _src_core.readCaptureReport)(this.#json(receipt.report.file, paths)));
|
|
4190
|
+
for (const path of Object.keys(receipt.inputs)) this.#path(path, paths);
|
|
4191
|
+
(0, _src_core.requireCaptureUnique)(Object.keys(receipt.inputs), "receipt input paths", true);
|
|
4192
|
+
}
|
|
4193
|
+
if (!(0, _src_core.matchesCaptureMembers)(registry.entries.map(_src_core.describeCaptureDestination), registry.receipts.flatMap((receipt) => receipt.registry.map(_src_core.describeCaptureDestination)))) throw new _src_core.CaptureError("Registry entries differ from complete receipts", { code: "EVIDENCE" });
|
|
4194
|
+
for (const entry of registry.entries) this.#destination(entry, paths);
|
|
4195
|
+
return registry;
|
|
4196
|
+
} catch (error) {
|
|
4197
|
+
throw resolveCaptureRegistryFault(error);
|
|
3553
4198
|
}
|
|
3554
|
-
if (!(0, _src_core.matchesCaptureMembers)(registry.entries.map(_src_core.describeCaptureDestination), registry.receipts.flatMap((receipt) => receipt.registry.map(_src_core.describeCaptureDestination)))) throw new _src_core.CaptureError("Registry entries differ from complete receipts", { code: "EVIDENCE" });
|
|
3555
|
-
for (const entry of registry.entries) this.#destination(entry, paths);
|
|
3556
|
-
return registry;
|
|
3557
4199
|
}
|
|
3558
4200
|
#evidence(snapshots) {
|
|
3559
4201
|
const paths = /* @__PURE__ */ new Map();
|
|
3560
4202
|
const registry = this.#registry(snapshots, paths);
|
|
3561
|
-
const manifest = (0, node_fs.existsSync)(this.#path(this.#options.manifest, paths)) ? this.#json(this.#options.manifest, paths) : void 0;
|
|
3562
|
-
if (manifest !== void 0 && !(0, _src_core.isCaptureStoredManifest)(manifest)) throw new _src_core.CaptureError("Invalid inherited manifest schema", { code: "EVIDENCE" });
|
|
4203
|
+
const manifest = (0, node_fs.existsSync)(this.#path(this.#options.manifest, paths)) ? readCaptureManifest(this.#json(this.#options.manifest, paths), this.#options.manifest) : void 0;
|
|
3563
4204
|
if (manifest !== void 0) {
|
|
3564
4205
|
(0, _src_core.requireCaptureUnique)(Object.keys(manifest.entries), "manifest keys", true);
|
|
3565
4206
|
if (manifest.registry.digest !== computeRegistryDigest(manifest.registry)) throw new _src_core.CaptureError("Invalid inherited registry digest", { code: "EVIDENCE" });
|
|
@@ -3574,10 +4215,9 @@ var CaptureIntegrity = class {
|
|
|
3574
4215
|
]) this.#path(path, paths);
|
|
3575
4216
|
}
|
|
3576
4217
|
}
|
|
3577
|
-
const separate = (0, node_fs.existsSync)(this.#path(this.#options.lookups, paths)) ? this.#json(this.#options.lookups, paths) : void 0;
|
|
3578
|
-
if (separate !== void 0 && !(0, _src_core.isCaptureLookupJournal)(separate)) throw new _src_core.CaptureError("Invalid separate lookup schema", { code: "EVIDENCE" });
|
|
4218
|
+
const separate = (0, node_fs.existsSync)(this.#path(this.#options.lookups, paths)) ? readCaptureLookupJournal(this.#json(this.#options.lookups, paths), this.#options.lookups) : void 0;
|
|
3579
4219
|
const manifestDigest = this.#file(this.#options.manifest, snapshots, paths)?.image.digest;
|
|
3580
|
-
const current = separate !== void 0 && separate.manifest === manifestDigest ? readCaptureLookups(separate) : [];
|
|
4220
|
+
const current = separate !== void 0 && separate.manifest === manifestDigest ? readCaptureLookups(separate, this.#options.lookups) : [];
|
|
3581
4221
|
const lookups = mergeCaptureLookups(manifest?.lookups ?? [], current).filter((entry) => entry.registry === registry.digest);
|
|
3582
4222
|
const populations = /* @__PURE__ */ new Map();
|
|
3583
4223
|
const runs = [...Map.groupBy(lookups, (entry) => entry.run.file)].map(([file, referenced]) => {
|
|
@@ -3621,9 +4261,9 @@ var CaptureIntegrity = class {
|
|
|
3621
4261
|
const declarations = receipt?.declarations ?? previous?.declarations;
|
|
3622
4262
|
const registry = receipt?.registry ?? previous?.registry;
|
|
3623
4263
|
if (declarations !== void 0 && registry !== void 0) {
|
|
3624
|
-
if (!(0, _src_core.matchesCaptureMembers)(declarations.map(_src_core.describeCaptureDeclaration), run.declarations.map(_src_core.describeCaptureDeclaration)) || !(0, _src_core.matchesCaptureMembers)(registry.map(_src_core.describeCaptureDestination), run.registry.map(_src_core.describeCaptureDestination))) throw new _src_core.CaptureError("Collected registry declarations changed; run the explicit complete-registry refresh", { code: "
|
|
4264
|
+
if (!(0, _src_core.matchesCaptureMembers)(declarations.map(_src_core.describeCaptureDeclaration), run.declarations.map(_src_core.describeCaptureDeclaration)) || !(0, _src_core.matchesCaptureMembers)(registry.map(_src_core.describeCaptureDestination), run.registry.map(_src_core.describeCaptureDestination))) throw new _src_core.CaptureError("Collected registry declarations changed; run the explicit complete-registry refresh", { code: "REGISTRY" });
|
|
3625
4265
|
} else if (!evidence.registry.receipts.some((entry) => (0, _src_core.collectCaptureChanges)(entry.inputs, inputs).length === 0)) throw new _src_core.CaptureError("Unattested producing variant; run the explicit complete-registry refresh before its owner lookup refresh", {
|
|
3626
|
-
code: "
|
|
4266
|
+
code: "REGISTRY",
|
|
3627
4267
|
context: { variant: run.variant }
|
|
3628
4268
|
});
|
|
3629
4269
|
}
|
|
@@ -3638,7 +4278,7 @@ var CaptureIntegrity = class {
|
|
|
3638
4278
|
return first.run.registry;
|
|
3639
4279
|
})];
|
|
3640
4280
|
}
|
|
3641
|
-
#select(
|
|
4281
|
+
#select(entries, options, producers) {
|
|
3642
4282
|
const selectors = [...new Set(entries.flatMap((entry) => {
|
|
3643
4283
|
const parts = (0, _src_core.resolveCaptureOwner)(entry).split(":");
|
|
3644
4284
|
return parts.map((_part, index) => parts.slice(0, index + 1).join(":"));
|
|
@@ -3663,19 +4303,16 @@ var CaptureIntegrity = class {
|
|
|
3663
4303
|
const scoped = entries.filter((entry) => (0, _src_core.matchesCaptureSelector)((0, _src_core.resolveCaptureOwner)(entry), options.selector) && (options.portfolio === void 0 || entry.portfolio === options.portfolio));
|
|
3664
4304
|
if (scoped.length === 0) throw new _src_core.CaptureError(`Empty selector; ${describeCaptureFault("selector", options.selector, "a declared selector with destinations in the selected portfolio", ["all", ...selectors])}`, { code: "USAGE" });
|
|
3665
4305
|
if (options.variants.length === 0) throw new _src_core.CaptureError(`Invalid capture selection; ${describeCaptureFault("selection.variants", options.variants, "a nonempty selected variant list", [...new Set(scoped.map((entry) => entry.variant))])}`, { code: "USAGE" });
|
|
3666
|
-
const variants = [...new Set(
|
|
4306
|
+
const variants = [...new Set(producers === void 0 ? entries.map((entry) => entry.variant) : entries.map((entry) => requireCaptureProducer(entry, producers)))];
|
|
3667
4307
|
const unknown = options.variants.find((variant) => !variants.includes(variant));
|
|
3668
|
-
if (unknown !== void 0) throw new _src_core.CaptureError(`Unknown or unattested selected variant; ${describeCaptureFault("selection.variants", unknown, "an attested registry variant", variants)}`, {
|
|
3669
|
-
|
|
4308
|
+
if (unknown !== void 0) throw new _src_core.CaptureError(`Unknown or unattested selected variant; ${describeCaptureFault("selection.variants", unknown, "an attested registry variant", variants)}`, {
|
|
4309
|
+
code: "REGISTRY",
|
|
4310
|
+
context: { variant: unknown }
|
|
4311
|
+
});
|
|
4312
|
+
const selected = scoped.filter((entry) => options.variants.includes(producers === void 0 ? entry.variant : requireCaptureProducer(entry, producers)) && (options.state === void 0 || entry.state === options.state) && (options.case === void 0 || entry.case === options.case));
|
|
3670
4313
|
if (selected.length === 0) throw new _src_core.CaptureError(`Empty selection or state outside selector/case; ${describeCaptureFault("selection.state", options.state, "a state in the selected selector/case", [...new Set(scoped.map((entry) => entry.state))])}; ${describeCaptureFault("selection.case", options.case, "a case in the selected selector", [...new Set(scoped.map((entry) => entry.case))])}`, { code: "USAGE" });
|
|
3671
4314
|
return selected;
|
|
3672
4315
|
}
|
|
3673
|
-
#producer(destination, evidence) {
|
|
3674
|
-
const sources = [...evidence.registry.receipts, ...evidence.runs.map((entry) => entry.run)];
|
|
3675
|
-
const variants = [...new Set(sources.filter((source) => source.registry.some((entry) => (0, _src_core.describeCaptureDestination)(entry) === (0, _src_core.describeCaptureDestination)(destination))).map((source) => source.variant))];
|
|
3676
|
-
if (variants.length !== 1 || variants[0] === void 0) throw new _src_core.CaptureError("Destination has no unique producing variant", { code: "EVIDENCE" });
|
|
3677
|
-
return variants[0];
|
|
3678
|
-
}
|
|
3679
4316
|
#reportPath(args, paths) {
|
|
3680
4317
|
const outputs = args.filter((argument) => argument.startsWith("--outputFile.json="));
|
|
3681
4318
|
if (outputs.length !== 1 || outputs[0] === void 0) throw new _src_core.CaptureError("Request has no unique JSON reporter path", { code: "HOST" });
|
|
@@ -4255,7 +4892,7 @@ var CapturePreflight = class {
|
|
|
4255
4892
|
if (!(0, _src_core.isCapturePath)(resolveCaptureRelative(root, config))) throw new _src_core.CaptureError("Reader config must be a contained repository path", { code: "USAGE" });
|
|
4256
4893
|
requireCaptureSelection(selection.selector, [], loaded.map((entry) => entry.project), [], selection.portfolio);
|
|
4257
4894
|
const primary = requireCaptureProjects(loaded.map((entry) => entry.project));
|
|
4258
|
-
const standalone = primary.standalone
|
|
4895
|
+
const standalone = resolveCaptureStandalone(primary.standalone, selection.selector, selection.portfolio);
|
|
4259
4896
|
const options = buildCaptureIntegrityOptions(root, primary, standalone);
|
|
4260
4897
|
requireCaptureSelection(selection.selector, selection.variants ?? [], loaded.map((entry) => entry.project), readCaptureVariants(root, (0, node_path.resolve)(root, options.directory, _src_core.CAPTURE_REGISTRY_FILE)));
|
|
4261
4898
|
const integrity = new CaptureIntegrity(options);
|
|
@@ -4348,22 +4985,8 @@ var CapturePreflight = class {
|
|
|
4348
4985
|
async execute() {
|
|
4349
4986
|
try {
|
|
4350
4987
|
const result = await this.check();
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
selection: result.selection,
|
|
4354
|
-
freshness: result.freshness,
|
|
4355
|
-
mixed: result.mixed,
|
|
4356
|
-
issues,
|
|
4357
|
-
identical: collectCaptureIdentical(result.images),
|
|
4358
|
-
sizes: result.images.map(({ entry, picture, size }) => ({
|
|
4359
|
-
file: entry.file,
|
|
4360
|
-
width: picture.width,
|
|
4361
|
-
height: picture.height,
|
|
4362
|
-
bytes: size
|
|
4363
|
-
})),
|
|
4364
|
-
acceptance: false
|
|
4365
|
-
})}\n`);
|
|
4366
|
-
return issues.length > 0 || result.freshness.entries.some((entry) => entry.status !== "current") ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed;
|
|
4988
|
+
this.#stdout(`${CAPTURE_REPORT_LINES.preflight} ${JSON.stringify(buildCaptureReaderReport(result))}\n`);
|
|
4989
|
+
return result.issues.length > 0 || result.freshness.entries.some((entry) => entry.status !== "current") ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed;
|
|
4367
4990
|
} catch (error) {
|
|
4368
4991
|
this.#stderr(`${(0, _src_core.describeCaptureError)(error)}\n`);
|
|
4369
4992
|
return resolveCaptureExit(error);
|
|
@@ -4471,9 +5094,7 @@ var CapturePreflight = class {
|
|
|
4471
5094
|
#manifest(directory) {
|
|
4472
5095
|
const file = (0, node_path.resolve)(this.#options.root, directory, _src_core.CAPTURE_MANIFEST_FILE);
|
|
4473
5096
|
if (!(0, node_fs.existsSync)(file)) return void 0;
|
|
4474
|
-
|
|
4475
|
-
if (!(0, _src_core.isCaptureStoredManifest)(manifest)) throw new _src_core.CaptureError("Invalid stamped manifest schema", { code: "EVIDENCE" });
|
|
4476
|
-
return manifest;
|
|
5097
|
+
return readCaptureManifest((0, _orkestrel_contract.parseJSON)((0, node_fs.readFileSync)(file, "utf8")), `${directory}/${_src_core.CAPTURE_MANIFEST_FILE}`);
|
|
4477
5098
|
}
|
|
4478
5099
|
#locate(entry, stored, producers, directory) {
|
|
4479
5100
|
const stamp = stored?.entries[(0, _src_core.resolveCaptureKey)(entry)];
|
|
@@ -4533,7 +5154,8 @@ var CapturePreflight = class {
|
|
|
4533
5154
|
* place, so a registry the engine would refuse never replaces a good one. With `--variant`, the
|
|
4534
5155
|
* existing registry's receipts for the other declared variants are kept. It never widens a scoped
|
|
4535
5156
|
* run into a refresh and refuses while another runner holds a request file in the request directory.
|
|
4536
|
-
* Before any stage, it reads the inherited manifest and lookup journal
|
|
5157
|
+
* Before any stage, it reads the inherited manifest and lookup journal: it refuses a document of
|
|
5158
|
+
* another version with that refusal's own removal and refresh commands alone, and an unsupported
|
|
4537
5159
|
* schema with the file to inspect and repair.
|
|
4538
5160
|
*
|
|
4539
5161
|
* @example
|
|
@@ -4651,13 +5273,16 @@ var CaptureRegistrar = class {
|
|
|
4651
5273
|
return CAPTURE_EXIT.passed;
|
|
4652
5274
|
}
|
|
4653
5275
|
#inherit(options) {
|
|
4654
|
-
for (const
|
|
5276
|
+
for (const file of [options.manifest, options.lookups]) {
|
|
4655
5277
|
const path = (0, node_path.resolve)(options.root, file);
|
|
4656
5278
|
try {
|
|
4657
5279
|
requireCaptureContained(options.root, path);
|
|
4658
5280
|
if (!(0, node_fs.existsSync)(path)) continue;
|
|
4659
|
-
|
|
5281
|
+
const value = (0, _orkestrel_contract.parseJSON)((0, node_fs.readFileSync)(path, "utf8"));
|
|
5282
|
+
if (file === options.manifest) readCaptureManifest(value, file);
|
|
5283
|
+
else readCaptureLookupJournal(value, file);
|
|
4660
5284
|
} catch (error) {
|
|
5285
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
4661
5286
|
throw new _src_core.CaptureError(`Cannot refresh the registry with inherited evidence at ${JSON.stringify(file)}: ${(0, _src_core.describeCaptureError)(error)}; inspect and repair this file before retrying`, {
|
|
4662
5287
|
code: "EVIDENCE",
|
|
4663
5288
|
cause: error,
|
|
@@ -4684,7 +5309,7 @@ var CaptureRegistrar = class {
|
|
|
4684
5309
|
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
4685
5310
|
});
|
|
4686
5311
|
const request = {
|
|
4687
|
-
version:
|
|
5312
|
+
version: _src_core.CAPTURE_VERSION,
|
|
4688
5313
|
id: invocation.id,
|
|
4689
5314
|
stage,
|
|
4690
5315
|
config: resolveCaptureRelative(root, parsed.config),
|
|
@@ -4851,60 +5476,69 @@ var CaptureRunner = class {
|
|
|
4851
5476
|
stderr: this.#stderr
|
|
4852
5477
|
});
|
|
4853
5478
|
invocation.attach();
|
|
5479
|
+
const invocations = [invocation];
|
|
5480
|
+
const reports = [];
|
|
4854
5481
|
const argumentsResult = (0, _orkestrel_contract.attempt)(() => readCaptureArguments(argv, command, root, config));
|
|
5482
|
+
const described = await this.#describe(invocation, argumentsResult).then((description) => (0, _orkestrel_contract.success)(description), (error) => (0, _orkestrel_contract.failure)(error));
|
|
5483
|
+
const result = (0, _orkestrel_contract.isFailure)(described) ? described : await this.#dispatch(invocation, invocations, reports, described.value.parsed, described.value.projects).then((code) => (0, _orkestrel_contract.success)(code), (error) => (0, _orkestrel_contract.failure)(error));
|
|
4855
5484
|
try {
|
|
4856
|
-
|
|
4857
|
-
if (
|
|
4858
|
-
const parsed = argumentsResult.value;
|
|
4859
|
-
const projects = (await new CaptureDiscovery({
|
|
4860
|
-
root,
|
|
4861
|
-
config: parsed.config,
|
|
4862
|
-
invocation,
|
|
4863
|
-
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
4864
|
-
...this.#options.deadline === void 0 ? {} : { deadline: this.#options.deadline }
|
|
4865
|
-
}).describe()).projects.map((entry) => entry.project);
|
|
4866
|
-
if (parsed.selector !== void 0) requireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio);
|
|
4867
|
-
if (command !== "stale" && parsed.variants.length > 0) resolveCaptureVariants(parsed.variants, projects);
|
|
4868
|
-
if (command !== "stale" && parsed.case !== void 0) this.#case(requireCaptureProjects(projects), parsed.case, parsed.selector);
|
|
4869
|
-
if (command !== "stale" && parsed.changed !== void 0) {
|
|
4870
|
-
await invocation.release();
|
|
4871
|
-
invocation.attach();
|
|
4872
|
-
const code = await this.#changed(invocation, command, parsed, projects);
|
|
4873
|
-
if (code === 64) (0, node_fs.rmSync)(invocation.directory, {
|
|
4874
|
-
recursive: true,
|
|
4875
|
-
force: true
|
|
4876
|
-
});
|
|
4877
|
-
return code;
|
|
4878
|
-
}
|
|
4879
|
-
return command === "stale" ? await this.#check(parsed, projects) : await this.#run(invocation, command, parsed, projects);
|
|
4880
|
-
} catch (error) {
|
|
4881
|
-
if (resolveCaptureExit(error) === 64) (0, node_fs.rmSync)(invocation.directory, {
|
|
5485
|
+
const code = (0, _orkestrel_contract.isSuccess)(result) ? result.value : resolveCaptureExit(result.error);
|
|
5486
|
+
if (code === CAPTURE_EXIT.usage) (0, node_fs.rmSync)(invocation.directory, {
|
|
4882
5487
|
recursive: true,
|
|
4883
5488
|
force: true
|
|
4884
5489
|
});
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
config: argumentsResult.success ? argumentsResult.value.config : (0, node_path.resolve)(root, config),
|
|
4888
|
-
variants: []
|
|
4889
|
-
}, "all", root);
|
|
4890
|
-
this.#stderr(`${(0, _src_core.describeCaptureError)(error)}\n${ran.length === 0 ? "No execution child ran; the command was refused before execution." : `Execution stopped after stages: ${ran.join(", ")}; no later stage ran.`}\nNEXT ${next}\n`);
|
|
4891
|
-
return resolveCaptureExit(error);
|
|
5490
|
+
this.#conclude(result, invocations, reports, argumentsResult.success ? argumentsResult.value : void 0, (0, _orkestrel_contract.isSuccess)(described) ? described.value.projects : []);
|
|
5491
|
+
return code;
|
|
4892
5492
|
} finally {
|
|
4893
5493
|
await invocation.release().catch((error) => this.#stderr(`Capture cleanup failed: ${(0, _src_core.describeCaptureError)(error)}\n`));
|
|
4894
5494
|
}
|
|
4895
5495
|
}
|
|
4896
|
-
async #
|
|
5496
|
+
async #describe(invocation, argumentsResult) {
|
|
5497
|
+
const { root } = this.#options;
|
|
5498
|
+
invocation.prepare();
|
|
5499
|
+
if (!argumentsResult.success) throw argumentsResult.error;
|
|
5500
|
+
const parsed = argumentsResult.value;
|
|
5501
|
+
return {
|
|
5502
|
+
parsed,
|
|
5503
|
+
projects: (await new CaptureDiscovery({
|
|
5504
|
+
root,
|
|
5505
|
+
config: parsed.config,
|
|
5506
|
+
invocation,
|
|
5507
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
5508
|
+
...this.#options.deadline === void 0 ? {} : { deadline: this.#options.deadline }
|
|
5509
|
+
}).describe()).projects.map((entry) => entry.project)
|
|
5510
|
+
};
|
|
5511
|
+
}
|
|
5512
|
+
async #dispatch(invocation, invocations, reports, parsed, projects) {
|
|
5513
|
+
const { command } = this.#options;
|
|
5514
|
+
if (parsed.selector !== void 0) requireCaptureSelection(parsed.selector, [], projects, [], parsed.portfolio);
|
|
5515
|
+
if (command !== "stale" && parsed.variants.length > 0) resolveCaptureVariants(parsed.variants, projects);
|
|
5516
|
+
if (command !== "stale" && parsed.changed === void 0) this.#scope(parsed.selector, collectCaptureOwners(projects));
|
|
5517
|
+
if (command !== "stale" && parsed.case !== void 0) this.#case(requireCaptureProjects(projects), parsed.case, parsed.selector);
|
|
5518
|
+
if (command !== "stale" && parsed.changed !== void 0) {
|
|
5519
|
+
await invocation.release();
|
|
5520
|
+
invocation.attach();
|
|
5521
|
+
return await this.#changed(invocation, invocations, reports, command, parsed, projects);
|
|
5522
|
+
}
|
|
5523
|
+
return command === "stale" ? await this.#check(parsed, projects, reports) : await this.#run(invocation, command, parsed, projects, reports);
|
|
5524
|
+
}
|
|
5525
|
+
#conclude(result, invocations, reports, parsed, projects) {
|
|
5526
|
+
const { command } = this.#options;
|
|
5527
|
+
const lines = reports.length > 0 || (0, _orkestrel_contract.isSuccess)(result) || parsed === void 0 ? reports : this.#recover(result.error, parsed, parsed.selector, invocations.some((entry) => entry.interrupted), projects);
|
|
5528
|
+
const next = [...new Set(lines)].map((line) => `NEXT ${line}\n`).join("");
|
|
5529
|
+
if (reports.length > 0 && next !== "") this.#stdout(next);
|
|
5530
|
+
if ((0, _orkestrel_contract.isSuccess)(result)) return;
|
|
5531
|
+
const ran = Object.values(CAPTURE_STAGES).filter((stage) => invocations.some((entry) => entry.launched((0, node_path.resolve)(entry.directory, `${command}-${stage}.log`))));
|
|
5532
|
+
this.#stderr(`${(0, _src_core.describeCaptureError)(result.error)}\n${ran.length === 0 ? "No execution child ran; the command was refused before execution." : `Execution stopped after stages: ${ran.join(", ")}; no later stage ran.`}\n${reports.length > 0 ? "" : next}`);
|
|
5533
|
+
}
|
|
5534
|
+
async #changed(discovery, invocations, reports, command, parsed, projects) {
|
|
4897
5535
|
const { root, requests } = this.#options;
|
|
4898
5536
|
const primary = requireCaptureProjects(projects);
|
|
4899
5537
|
const plan = this.#changes(parsed, primary);
|
|
4900
5538
|
for (const change of plan.changes) this.#stdout(`CHANGE ${JSON.stringify(change)}\n`);
|
|
4901
5539
|
const commands = plan.owners.map((owner) => renderCaptureCommand(command, parsed, owner, root));
|
|
4902
5540
|
const shared = plan.changes.filter((change) => change.classification === "shared");
|
|
4903
|
-
const complete =
|
|
4904
|
-
config: parsed.config,
|
|
4905
|
-
variants: parsed.variants,
|
|
4906
|
-
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
4907
|
-
}, "all", root);
|
|
5541
|
+
const complete = this.#complete(parsed);
|
|
4908
5542
|
for (const next of commands) this.#stdout(`COMMAND ${next}\n`);
|
|
4909
5543
|
const variants = resolveCaptureVariants(parsed.variants, projects);
|
|
4910
5544
|
if (shared.length > 0) {
|
|
@@ -4916,7 +5550,7 @@ var CaptureRunner = class {
|
|
|
4916
5550
|
notrun: plan.owners,
|
|
4917
5551
|
reason: "shared inputs require an explicit journey selection"
|
|
4918
5552
|
})}\n`);
|
|
4919
|
-
|
|
5553
|
+
reports.push(...commands, complete);
|
|
4920
5554
|
return CAPTURE_EXIT.usage;
|
|
4921
5555
|
}
|
|
4922
5556
|
if (plan.owners.length === 0) {
|
|
@@ -4926,10 +5560,11 @@ var CaptureRunner = class {
|
|
|
4926
5560
|
failed: [],
|
|
4927
5561
|
notrun: [],
|
|
4928
5562
|
reason: "only outside paths or no changed paths"
|
|
4929
|
-
})}\
|
|
5563
|
+
})}\n`);
|
|
5564
|
+
reports.push(complete);
|
|
4930
5565
|
return parsed.plan ? CAPTURE_EXIT.passed : CAPTURE_EXIT.failed;
|
|
4931
5566
|
}
|
|
4932
|
-
const selectors =
|
|
5567
|
+
const selectors = collectCaptureOwners(projects);
|
|
4933
5568
|
for (const owner of plan.owners) {
|
|
4934
5569
|
const fault = describeCaptureSelectorFault(owner, selectors);
|
|
4935
5570
|
if (fault !== void 0) throw new _src_core.CaptureError(fault, { code: "HOST" });
|
|
@@ -4944,10 +5579,11 @@ var CaptureRunner = class {
|
|
|
4944
5579
|
notrun: plan.owners,
|
|
4945
5580
|
reason: "--plan starts no execution child"
|
|
4946
5581
|
})}\n`);
|
|
4947
|
-
|
|
5582
|
+
reports.push(...commands);
|
|
4948
5583
|
return CAPTURE_EXIT.passed;
|
|
4949
5584
|
}
|
|
4950
5585
|
const outcomes = [];
|
|
5586
|
+
const recorded = [];
|
|
4951
5587
|
for (const owner of plan.owners) {
|
|
4952
5588
|
if (discovery.interrupted) break;
|
|
4953
5589
|
const invocation = new CaptureInvocation({
|
|
@@ -4957,16 +5593,24 @@ var CaptureRunner = class {
|
|
|
4957
5593
|
stdout: this.#stdout,
|
|
4958
5594
|
stderr: this.#stderr
|
|
4959
5595
|
});
|
|
5596
|
+
invocations.push(invocation);
|
|
4960
5597
|
invocation.attach();
|
|
5598
|
+
const owned = {
|
|
5599
|
+
...parsed,
|
|
5600
|
+
selector: owner
|
|
5601
|
+
};
|
|
5602
|
+
const lines = [];
|
|
4961
5603
|
try {
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
5604
|
+
const code = await Promise.resolve().then(async () => {
|
|
5605
|
+
invocation.prepare();
|
|
5606
|
+
return await this.#run(invocation, command, owned, projects, lines);
|
|
5607
|
+
}).catch((error) => {
|
|
5608
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
4967
5609
|
this.#stderr(`${(0, _src_core.describeCaptureError)(error)}\n`);
|
|
5610
|
+
if (lines.length === 0) lines.push(...this.#recover(error, owned, owner, false, projects));
|
|
4968
5611
|
return resolveCaptureExit(error);
|
|
4969
5612
|
});
|
|
5613
|
+
if (code !== CAPTURE_EXIT.passed) recorded.push(...lines);
|
|
4970
5614
|
outcomes.push({
|
|
4971
5615
|
owner,
|
|
4972
5616
|
code,
|
|
@@ -4986,10 +5630,18 @@ var CaptureRunner = class {
|
|
|
4986
5630
|
notrun,
|
|
4987
5631
|
reason: discovery.interrupted ? "interrupted" : failed.length > 0 ? "stopped at the first red owner" : "every selected owner passed"
|
|
4988
5632
|
})}\n`);
|
|
4989
|
-
|
|
4990
|
-
if (failed.length === 0 && notrun.length === 0) this.#stdout(`NEXT ${complete}\n`);
|
|
5633
|
+
reports.push(...failed.length === 0 && notrun.length === 0 ? [complete] : [...recorded, ...notrun.map((owner) => renderCaptureCommand(command, parsed, owner, root))]);
|
|
4991
5634
|
return failed.at(0)?.code ?? (discovery.interrupted ? CAPTURE_EXIT.failed : CAPTURE_EXIT.passed);
|
|
4992
5635
|
}
|
|
5636
|
+
#scope(selector, selectors) {
|
|
5637
|
+
if (selector === void 0) throw new _src_core.CaptureError(this.#usage(selectors), { code: "USAGE" });
|
|
5638
|
+
const fault = describeCaptureSelectorFault(selector, selectors);
|
|
5639
|
+
if (fault !== void 0) throw new _src_core.CaptureError(fault, {
|
|
5640
|
+
code: "USAGE",
|
|
5641
|
+
context: { selector }
|
|
5642
|
+
});
|
|
5643
|
+
return selector;
|
|
5644
|
+
}
|
|
4993
5645
|
#case(primary, name, selector) {
|
|
4994
5646
|
const { root } = this.#options;
|
|
4995
5647
|
const titles = readCaptureTitles(root, (0, node_path.resolve)(root, primary.directory, _src_core.CAPTURE_REGISTRY_FILE), selector);
|
|
@@ -5000,31 +5652,18 @@ var CaptureRunner = class {
|
|
|
5000
5652
|
if (parsed.changed === void 0) throw new _src_core.CaptureError("Missing value: --changed", { code: "USAGE" });
|
|
5001
5653
|
return this.#integrity(primary).changed(parsed.changed);
|
|
5002
5654
|
} catch (error) {
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
variants: []
|
|
5006
|
-
}, "all", this.#options.root);
|
|
5007
|
-
const registry = renderCaptureCommand("registry", {
|
|
5008
|
-
config: parsed.config,
|
|
5009
|
-
variants: []
|
|
5010
|
-
}, void 0, this.#options.root);
|
|
5011
|
-
throw new _src_core.CaptureError(`${(0, _src_core.describeCaptureError)(error)}\nNo owner ran; changed selection was refused.\n${(0, _src_core.isCaptureError)(error) && error.code === "EVIDENCE" ? `NEXT ${registry}\n` : ""}NEXT ${command}`, {
|
|
5655
|
+
if (matchesCaptureVersionRefusal(error)) throw error;
|
|
5656
|
+
throw new _src_core.CaptureError(`${(0, _src_core.describeCaptureError)(error)}\nNo owner ran; changed selection was refused.`, {
|
|
5012
5657
|
code: (0, _src_core.isCaptureError)(error) ? error.code : "EVIDENCE",
|
|
5013
5658
|
cause: error
|
|
5014
5659
|
});
|
|
5015
5660
|
}
|
|
5016
5661
|
}
|
|
5017
|
-
async #run(invocation, command, parsed, projects) {
|
|
5662
|
+
async #run(invocation, command, parsed, projects, reports) {
|
|
5018
5663
|
const { root } = this.#options;
|
|
5019
5664
|
const primary = requireCaptureProjects(projects);
|
|
5020
|
-
const selectors =
|
|
5021
|
-
const selector = parsed.selector;
|
|
5022
|
-
if (selector === void 0) throw new _src_core.CaptureError(this.#usage(selectors), { code: "USAGE" });
|
|
5023
|
-
const fault = describeCaptureSelectorFault(selector, selectors);
|
|
5024
|
-
if (fault !== void 0) throw new _src_core.CaptureError(fault, {
|
|
5025
|
-
code: "USAGE",
|
|
5026
|
-
context: { selector }
|
|
5027
|
-
});
|
|
5665
|
+
const selectors = collectCaptureOwners(projects);
|
|
5666
|
+
const selector = this.#scope(parsed.selector, selectors);
|
|
5028
5667
|
const variants = resolveCaptureVariants(parsed.variants, projects);
|
|
5029
5668
|
const integrity = this.#integrity(primary);
|
|
5030
5669
|
const selected = await this.#resolve(integrity, parsed, selector, variants);
|
|
@@ -5044,33 +5683,32 @@ var CaptureRunner = class {
|
|
|
5044
5683
|
const outcomes = [];
|
|
5045
5684
|
const stages = resolveCaptureStages(variants, primary.first, command);
|
|
5046
5685
|
const completed = [];
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
this.#stdout(`NEXT ${renderCaptureCommand(passed ? "journey" : command, passed ? {
|
|
5070
|
-
config: parsed.config,
|
|
5071
|
-
variants: []
|
|
5072
|
-
} : parsed, passed ? "all" : selector, root)}\n`);
|
|
5686
|
+
const result = await this.#stages(invocation, integrity, plan, stages, outcomes, completed).then((code) => (0, _orkestrel_contract.success)(code), (error) => (0, _orkestrel_contract.failure)(error));
|
|
5687
|
+
const ran = stages.filter((stage) => invocation.launched((0, node_path.resolve)(invocation.directory, `${command}-${stage.name}.log`)));
|
|
5688
|
+
const notrun = stages.filter((stage) => !ran.includes(stage));
|
|
5689
|
+
const failed = ran.filter((stage) => !completed.includes(stage));
|
|
5690
|
+
const passed = completed.length === stages.length && outcomes.some((outcome) => outcome.count > 0);
|
|
5691
|
+
this.#stdout(`STAGES ${JSON.stringify({
|
|
5692
|
+
selector,
|
|
5693
|
+
run: ran.map((stage) => stage.name),
|
|
5694
|
+
passed: completed.map((stage) => stage.name),
|
|
5695
|
+
failed: failed.map((stage) => stage.name),
|
|
5696
|
+
notrun: notrun.map((stage) => stage.name),
|
|
5697
|
+
reason: invocation.interrupted ? "interrupted; no later stage ran" : passed ? "selected workload passed" : failed.length > 0 ? "stage failed; no later stage ran" : notrun.length > 0 ? "refused before execution" : "empty selected workload"
|
|
5698
|
+
})}\n`);
|
|
5699
|
+
reports.push(...passed ? command === "journey" && selector === "all" && parsed.case === void 0 ? [] : [this.#complete(parsed)] : this.#recover((0, _orkestrel_contract.isFailure)(result) ? result.error : void 0, parsed, selector, failed.length > 0 || invocation.interrupted, projects));
|
|
5700
|
+
if ((0, _orkestrel_contract.isFailure)(result)) throw result.error;
|
|
5701
|
+
return result.value;
|
|
5702
|
+
}
|
|
5703
|
+
async #stages(invocation, integrity, plan, stages, outcomes, completed) {
|
|
5704
|
+
for (const stage of stages) {
|
|
5705
|
+
if (invocation.interrupted) return CAPTURE_EXIT.failed;
|
|
5706
|
+
outcomes.push(...await this.#stage(invocation, integrity, plan, stage));
|
|
5707
|
+
completed.push(stage);
|
|
5073
5708
|
}
|
|
5709
|
+
for (const outcome of outcomes) this.#stdout(`${outcome.project}: ${String(outcome.count)} owner-bearing passed cases\n`);
|
|
5710
|
+
if (outcomes.every((outcome) => outcome.count === 0)) throw new _src_core.CaptureError("Empty selected workload: no requested project held applicable work", { code: "SELECTION" });
|
|
5711
|
+
return CAPTURE_EXIT.passed;
|
|
5074
5712
|
}
|
|
5075
5713
|
async #stage(invocation, integrity, plan, stage) {
|
|
5076
5714
|
const { root } = this.#options;
|
|
@@ -5091,7 +5729,7 @@ var CaptureRunner = class {
|
|
|
5091
5729
|
final: plan.final
|
|
5092
5730
|
});
|
|
5093
5731
|
const request = {
|
|
5094
|
-
version:
|
|
5732
|
+
version: _src_core.CAPTURE_VERSION,
|
|
5095
5733
|
id: invocation.id,
|
|
5096
5734
|
stage: stage.name,
|
|
5097
5735
|
config: plan.config,
|
|
@@ -5167,11 +5805,11 @@ var CaptureRunner = class {
|
|
|
5167
5805
|
const create = this.#options.integrity;
|
|
5168
5806
|
return create === void 0 ? new CaptureIntegrity(options) : create(options);
|
|
5169
5807
|
}
|
|
5170
|
-
async #check(parsed, projects) {
|
|
5808
|
+
async #check(parsed, projects, reports) {
|
|
5171
5809
|
const selector = parsed.selector;
|
|
5172
5810
|
if (selector === void 0) throw new _src_core.CaptureError(`Usage: capture ${CAPTURE_COMMAND_NAMES.stale} <selector> [--variant <output>] [--state <state>] [--case <full name>] [--portfolio <name>]`, { code: "USAGE" });
|
|
5173
5811
|
const primary = requireCaptureProjects(projects);
|
|
5174
|
-
const standalone = primary.standalone
|
|
5812
|
+
const standalone = resolveCaptureStandalone(primary.standalone, selector, parsed.portfolio);
|
|
5175
5813
|
requireCaptureSelection(selector, parsed.variants, projects, readCaptureVariants(this.#options.root, (0, node_path.resolve)(this.#options.root, standalone?.directory ?? primary.directory, _src_core.CAPTURE_REGISTRY_FILE)));
|
|
5176
5814
|
const result = await this.#integrity(primary, standalone).check({
|
|
5177
5815
|
selector,
|
|
@@ -5185,8 +5823,36 @@ var CaptureRunner = class {
|
|
|
5185
5823
|
command: "stale",
|
|
5186
5824
|
...result
|
|
5187
5825
|
})}\n`);
|
|
5826
|
+
if (standalone === void 0 && result.entries.some((entry) => CAPTURE_STATUS_RECOVERIES[entry.status] === "capture")) reports.push(renderCaptureCommand("capture", {
|
|
5827
|
+
config: parsed.config,
|
|
5828
|
+
variants: [],
|
|
5829
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode },
|
|
5830
|
+
...parsed.case === void 0 ? {} : { case: parsed.case }
|
|
5831
|
+
}, selector, this.#options.root));
|
|
5188
5832
|
return result.entries.every((entry) => entry.status === "current") ? CAPTURE_EXIT.passed : CAPTURE_EXIT.failed;
|
|
5189
5833
|
}
|
|
5834
|
+
#recover(error, parsed, selector, unfinished, projects) {
|
|
5835
|
+
if (matchesCaptureVersionRefusal(error)) return [];
|
|
5836
|
+
const { command, root } = this.#options;
|
|
5837
|
+
const recovery = (0, _src_core.isCaptureError)(error) ? CAPTURE_RECOVERIES[error.code] : void 0;
|
|
5838
|
+
const standalone = command === "stale" && selector !== void 0 && resolveCaptureStandalone(projects.flatMap((project) => project.standalone), selector, parsed.portfolio) !== void 0;
|
|
5839
|
+
return [
|
|
5840
|
+
...recovery === "registry" && !standalone ? [renderCaptureCommand("registry", {
|
|
5841
|
+
config: parsed.config,
|
|
5842
|
+
variants: [],
|
|
5843
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
5844
|
+
}, void 0, root)] : [],
|
|
5845
|
+
...recovery === "journey" && selector !== void 0 ? [renderCaptureCommand("journey", parsed, selector, root)] : [],
|
|
5846
|
+
...unfinished && selector !== void 0 ? [renderCaptureCommand(command, parsed, selector, root)] : []
|
|
5847
|
+
];
|
|
5848
|
+
}
|
|
5849
|
+
#complete(parsed) {
|
|
5850
|
+
return renderCaptureCommand("journey", {
|
|
5851
|
+
config: parsed.config,
|
|
5852
|
+
variants: parsed.variants,
|
|
5853
|
+
...parsed.mode === void 0 ? {} : { mode: parsed.mode }
|
|
5854
|
+
}, "all", this.#options.root);
|
|
5855
|
+
}
|
|
5190
5856
|
#usage(selectors) {
|
|
5191
5857
|
const { command } = this.#options;
|
|
5192
5858
|
const state = command === "capture" ? " [--state <name>]" : "";
|
|
@@ -5202,8 +5868,8 @@ var CaptureRunner = class {
|
|
|
5202
5868
|
* selection through `CapturePreflight`, so it judges the same population the preflight does and
|
|
5203
5869
|
* keeps its refusals. It writes the sheets, an index of every cell, and a notes document into a new
|
|
5204
5870
|
* directory that is contained in the workspace, has an existing parent, and lies outside every
|
|
5205
|
-
* selected capture directory. A frame whose image cannot be read shows as a red mark
|
|
5206
|
-
*
|
|
5871
|
+
* selected capture directory. A frame whose image cannot be read shows as a red mark with no source
|
|
5872
|
+
* size, and its index cell carries the freshness the engine classified, `missing` for an absent file.
|
|
5207
5873
|
*
|
|
5208
5874
|
* @example
|
|
5209
5875
|
* ```ts
|
|
@@ -5252,23 +5918,31 @@ var CaptureSheets = class {
|
|
|
5252
5918
|
await invocation.release().catch((error) => this.#stderr(`Capture cleanup failed: ${(0, _src_core.describeCaptureError)(error)}\n`));
|
|
5253
5919
|
}
|
|
5254
5920
|
const result = await new CapturePreflight(reader).check();
|
|
5255
|
-
const sheets =
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
})), CAPTURE_SHEET.rows).map((page, index) =>
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5921
|
+
const sheets = splitCaptureSheets(splitCapturePages(this.#groups(result), CAPTURE_SHEET.pairs).map((pair) => ({
|
|
5922
|
+
pair,
|
|
5923
|
+
...computeCaptureComposite(pair.map((group) => computeCaptureComposite(group.cells.map((cell) => cell.picture), false)), false, CAPTURE_SHEET.gap)
|
|
5924
|
+
})), CAPTURE_SHEET.rows, CAPTURE_SHEET.gap).map((page, index) => {
|
|
5925
|
+
const rows = page.map(({ pair }) => {
|
|
5926
|
+
const groups = pair.map((group) => ({
|
|
5927
|
+
...group,
|
|
5928
|
+
picture: composeCapturePictures(group.cells.map((cell) => cell.picture), false)
|
|
5929
|
+
}));
|
|
5930
|
+
return {
|
|
5931
|
+
groups,
|
|
5932
|
+
picture: composeCapturePictures(groups.map((group) => group.picture), false, CAPTURE_SHEET.gap)
|
|
5933
|
+
};
|
|
5934
|
+
});
|
|
5935
|
+
return {
|
|
5936
|
+
file: `${CAPTURE_SHEET_FILES.prefix}${String(index + 1).padStart(CAPTURE_SHEET_FILES.digits, "0")}.png`,
|
|
5937
|
+
rows,
|
|
5938
|
+
picture: composeCapturePictures(rows.map((row) => row.picture), true, CAPTURE_SHEET.gap)
|
|
5939
|
+
};
|
|
5940
|
+
});
|
|
5263
5941
|
const output = this.#output(result);
|
|
5264
5942
|
(0, node_fs.mkdirSync)(output);
|
|
5265
5943
|
for (const sheet of sheets) (0, node_fs.writeFileSync)((0, node_path.resolve)(output, sheet.file), encodeCapturePicture(sheet.picture));
|
|
5266
5944
|
const index = {
|
|
5267
|
-
|
|
5268
|
-
freshness: result.freshness,
|
|
5269
|
-
mixed: result.mixed,
|
|
5270
|
-
issues: result.issues,
|
|
5271
|
-
acceptance: false,
|
|
5945
|
+
...buildCaptureReaderReport(result),
|
|
5272
5946
|
sheets: sheets.map((sheet) => ({
|
|
5273
5947
|
file: sheet.file,
|
|
5274
5948
|
width: sheet.picture.width,
|
|
@@ -5308,30 +5982,28 @@ var CaptureSheets = class {
|
|
|
5308
5982
|
}
|
|
5309
5983
|
#groups(result) {
|
|
5310
5984
|
return [...new Set(result.selection.entries.map((entry) => resolveCaptureSheetIdentity(entry)))].map((identity) => {
|
|
5311
|
-
const cells = result.selection.entries.filter((entry) => resolveCaptureSheetIdentity(entry) === identity).map((entry) => {
|
|
5312
|
-
const image = result.images.find((candidate) => candidate.entry.file === entry.file);
|
|
5313
|
-
const factor = image === void 0 ? 1 : Math.max(1, Math.ceil(image.picture.width / CAPTURE_SHEET.cell));
|
|
5314
|
-
return {
|
|
5315
|
-
entry,
|
|
5316
|
-
picture: image === void 0 ? {
|
|
5317
|
-
width: CAPTURE_SHEET.mark.width,
|
|
5318
|
-
height: CAPTURE_SHEET.mark.height,
|
|
5319
|
-
pixels: Uint8Array.from({ length: CAPTURE_SHEET.mark.width * CAPTURE_SHEET.mark.height * 3 }, (_, index) => index % 3 === 0 ? CAPTURE_SHEET.mark.present : CAPTURE_SHEET.mark.absent)
|
|
5320
|
-
} : image.thumbnail,
|
|
5321
|
-
source: image === void 0 ? void 0 : {
|
|
5322
|
-
width: image.picture.width,
|
|
5323
|
-
height: image.picture.height,
|
|
5324
|
-
bytes: image.size
|
|
5325
|
-
},
|
|
5326
|
-
factor,
|
|
5327
|
-
clipped: image !== void 0 && Math.ceil(image.picture.height / factor) > CAPTURE_SHEET.limit,
|
|
5328
|
-
freshness: result.freshness.entries.find((candidate) => candidate.file === entry.file)
|
|
5329
|
-
};
|
|
5330
|
-
});
|
|
5331
5985
|
return {
|
|
5332
5986
|
identity,
|
|
5333
|
-
cells
|
|
5334
|
-
|
|
5987
|
+
cells: result.selection.entries.filter((entry) => resolveCaptureSheetIdentity(entry) === identity).map((entry) => {
|
|
5988
|
+
const image = result.images.find((candidate) => candidate.entry.file === entry.file);
|
|
5989
|
+
const factor = image === void 0 ? 1 : Math.max(1, Math.ceil(image.picture.width / CAPTURE_SHEET.cell));
|
|
5990
|
+
return {
|
|
5991
|
+
entry,
|
|
5992
|
+
picture: image === void 0 ? {
|
|
5993
|
+
width: CAPTURE_SHEET.mark.width,
|
|
5994
|
+
height: CAPTURE_SHEET.mark.height,
|
|
5995
|
+
pixels: Uint8Array.from({ length: CAPTURE_SHEET.mark.width * CAPTURE_SHEET.mark.height * 3 }, (_, index) => index % 3 === 0 ? CAPTURE_SHEET.mark.present : CAPTURE_SHEET.mark.absent)
|
|
5996
|
+
} : image.thumbnail,
|
|
5997
|
+
source: image === void 0 ? void 0 : {
|
|
5998
|
+
width: image.picture.width,
|
|
5999
|
+
height: image.picture.height,
|
|
6000
|
+
bytes: image.size
|
|
6001
|
+
},
|
|
6002
|
+
factor,
|
|
6003
|
+
clipped: image !== void 0 && Math.ceil(image.picture.height / factor) > CAPTURE_SHEET.limit,
|
|
6004
|
+
freshness: result.freshness.entries.find((candidate) => candidate.file === entry.file)
|
|
6005
|
+
};
|
|
6006
|
+
})
|
|
5335
6007
|
};
|
|
5336
6008
|
});
|
|
5337
6009
|
}
|
|
@@ -5600,6 +6272,7 @@ exports.CAPTURE_OWNER_TIMEOUT = CAPTURE_OWNER_TIMEOUT;
|
|
|
5600
6272
|
exports.CAPTURE_PID_LIMIT = CAPTURE_PID_LIMIT;
|
|
5601
6273
|
exports.CAPTURE_PNG_LIMITS = CAPTURE_PNG_LIMITS;
|
|
5602
6274
|
exports.CAPTURE_PROGRESS_SUFFIX = CAPTURE_PROGRESS_SUFFIX;
|
|
6275
|
+
exports.CAPTURE_RECOVERIES = CAPTURE_RECOVERIES;
|
|
5603
6276
|
exports.CAPTURE_REFUSAL_LIMIT = CAPTURE_REFUSAL_LIMIT;
|
|
5604
6277
|
exports.CAPTURE_REGISTRY_LINE = CAPTURE_REGISTRY_LINE;
|
|
5605
6278
|
exports.CAPTURE_REGISTRY_STAGE = CAPTURE_REGISTRY_STAGE;
|
|
@@ -5609,6 +6282,7 @@ exports.CAPTURE_RUNS_DIRECTORY = CAPTURE_RUNS_DIRECTORY;
|
|
|
5609
6282
|
exports.CAPTURE_SHEET = CAPTURE_SHEET;
|
|
5610
6283
|
exports.CAPTURE_SHEET_FILES = CAPTURE_SHEET_FILES;
|
|
5611
6284
|
exports.CAPTURE_STAGES = CAPTURE_STAGES;
|
|
6285
|
+
exports.CAPTURE_STATUS_RECOVERIES = CAPTURE_STATUS_RECOVERIES;
|
|
5612
6286
|
exports.CAPTURE_SUBCOMMANDS = CAPTURE_SUBCOMMANDS;
|
|
5613
6287
|
exports.CAPTURE_SURVIVORS_FILE = CAPTURE_SURVIVORS_FILE;
|
|
5614
6288
|
exports.CAPTURE_TAG_OPERATORS = CAPTURE_TAG_OPERATORS;
|
|
@@ -5631,15 +6305,22 @@ exports.buildCaptureDiscoveryConfig = buildCaptureDiscoveryConfig;
|
|
|
5631
6305
|
exports.buildCaptureFilter = buildCaptureFilter;
|
|
5632
6306
|
exports.buildCaptureIntegrityOptions = buildCaptureIntegrityOptions;
|
|
5633
6307
|
exports.buildCaptureLookupJournal = buildCaptureLookupJournal;
|
|
6308
|
+
exports.buildCaptureManifestDocument = buildCaptureManifestDocument;
|
|
5634
6309
|
exports.buildCaptureOverride = buildCaptureOverride;
|
|
6310
|
+
exports.buildCaptureReaderReport = buildCaptureReaderReport;
|
|
5635
6311
|
exports.buildCaptureRegistry = buildCaptureRegistry;
|
|
5636
6312
|
exports.buildCaptureRequestRefusal = buildCaptureRequestRefusal;
|
|
6313
|
+
exports.buildCaptureTable = buildCaptureTable;
|
|
5637
6314
|
exports.buildCaptureWrapper = buildCaptureWrapper;
|
|
5638
6315
|
exports.collectCaptureErrors = collectCaptureErrors;
|
|
5639
6316
|
exports.collectCaptureIdentical = collectCaptureIdentical;
|
|
6317
|
+
exports.collectCaptureOwners = collectCaptureOwners;
|
|
6318
|
+
exports.collectCaptureProducers = collectCaptureProducers;
|
|
5640
6319
|
exports.composeCapturePictures = composeCapturePictures;
|
|
6320
|
+
exports.computeCaptureComposite = computeCaptureComposite;
|
|
5641
6321
|
exports.computeCaptureHash = computeCaptureHash;
|
|
5642
6322
|
exports.computeCaptureMatchKey = computeCaptureMatchKey;
|
|
6323
|
+
exports.computeCaptureTableKey = computeCaptureTableKey;
|
|
5643
6324
|
exports.computeRegistryDigest = computeRegistryDigest;
|
|
5644
6325
|
exports.createCaptureCLI = createCaptureCLI;
|
|
5645
6326
|
exports.createCaptureDiscovery = createCaptureDiscovery;
|
|
@@ -5649,6 +6330,7 @@ exports.createCaptureRegistrar = createCaptureRegistrar;
|
|
|
5649
6330
|
exports.createCaptureRunner = createCaptureRunner;
|
|
5650
6331
|
exports.createCaptureSheets = createCaptureSheets;
|
|
5651
6332
|
exports.decodeCapturePicture = decodeCapturePicture;
|
|
6333
|
+
exports.describeCaptureChunk = describeCaptureChunk;
|
|
5652
6334
|
exports.describeCaptureFault = describeCaptureFault;
|
|
5653
6335
|
exports.describeCaptureHolders = describeCaptureHolders;
|
|
5654
6336
|
exports.describeCaptureMembers = describeCaptureMembers;
|
|
@@ -5662,8 +6344,10 @@ exports.escapeCapturePattern = escapeCapturePattern;
|
|
|
5662
6344
|
exports.filterCaptureInputs = filterCaptureInputs;
|
|
5663
6345
|
exports.inflateCaptureStream = inflateCaptureStream;
|
|
5664
6346
|
exports.matchesCaptureFile = matchesCaptureFile;
|
|
6347
|
+
exports.matchesCaptureLimits = matchesCaptureLimits;
|
|
5665
6348
|
exports.matchesCaptureSignature = matchesCaptureSignature;
|
|
5666
6349
|
exports.matchesCaptureTransient = matchesCaptureTransient;
|
|
6350
|
+
exports.matchesCaptureVersionRefusal = matchesCaptureVersionRefusal;
|
|
5667
6351
|
exports.mergeCaptureLookups = mergeCaptureLookups;
|
|
5668
6352
|
exports.normalizeSlashes = normalizeSlashes;
|
|
5669
6353
|
exports.predictCaptureByte = predictCaptureByte;
|
|
@@ -5676,7 +6360,9 @@ exports.readCaptureFrames = readCaptureFrames;
|
|
|
5676
6360
|
exports.readCaptureImage = readCaptureImage;
|
|
5677
6361
|
exports.readCaptureInputs = readCaptureInputs;
|
|
5678
6362
|
exports.readCaptureListing = readCaptureListing;
|
|
6363
|
+
exports.readCaptureLookupJournal = readCaptureLookupJournal;
|
|
5679
6364
|
exports.readCaptureLookups = readCaptureLookups;
|
|
6365
|
+
exports.readCaptureManifest = readCaptureManifest;
|
|
5680
6366
|
exports.readCaptureOptions = readCaptureOptions;
|
|
5681
6367
|
exports.readCapturePortfolios = readCapturePortfolios;
|
|
5682
6368
|
exports.readCaptureProgress = readCaptureProgress;
|
|
@@ -5686,6 +6372,7 @@ exports.readCaptureRegistryArguments = readCaptureRegistryArguments;
|
|
|
5686
6372
|
exports.readCaptureRequest = readCaptureRequest;
|
|
5687
6373
|
exports.readCaptureRequestOwner = readCaptureRequestOwner;
|
|
5688
6374
|
exports.readCaptureSeparator = readCaptureSeparator;
|
|
6375
|
+
exports.readCaptureTable = readCaptureTable;
|
|
5689
6376
|
exports.readCaptureTitles = readCaptureTitles;
|
|
5690
6377
|
exports.readCaptureVariants = readCaptureVariants;
|
|
5691
6378
|
exports.readCaptureViewport = readCaptureViewport;
|
|
@@ -5694,20 +6381,29 @@ exports.renderCaptureProgress = renderCaptureProgress;
|
|
|
5694
6381
|
exports.requireCaptureArgument = requireCaptureArgument;
|
|
5695
6382
|
exports.requireCaptureContained = requireCaptureContained;
|
|
5696
6383
|
exports.requireCaptureImageSize = requireCaptureImageSize;
|
|
6384
|
+
exports.requireCaptureProducer = requireCaptureProducer;
|
|
5697
6385
|
exports.requireCaptureProjects = requireCaptureProjects;
|
|
5698
6386
|
exports.requireCaptureSelection = requireCaptureSelection;
|
|
6387
|
+
exports.requireCaptureTableEntry = requireCaptureTableEntry;
|
|
6388
|
+
exports.requireCaptureVersion = requireCaptureVersion;
|
|
5699
6389
|
exports.resolveCaptureExit = resolveCaptureExit;
|
|
5700
6390
|
exports.resolveCapturePhysical = resolveCapturePhysical;
|
|
6391
|
+
exports.resolveCaptureRegistryFault = resolveCaptureRegistryFault;
|
|
5701
6392
|
exports.resolveCaptureRelative = resolveCaptureRelative;
|
|
5702
6393
|
exports.resolveCaptureRequests = resolveCaptureRequests;
|
|
5703
6394
|
exports.resolveCaptureSheetIdentity = resolveCaptureSheetIdentity;
|
|
5704
6395
|
exports.resolveCaptureStages = resolveCaptureStages;
|
|
6396
|
+
exports.resolveCaptureStandalone = resolveCaptureStandalone;
|
|
5705
6397
|
exports.resolveCaptureVariants = resolveCaptureVariants;
|
|
5706
6398
|
exports.resolveCaptureWrapperProject = resolveCaptureWrapperProject;
|
|
6399
|
+
exports.scanCaptureChunks = scanCaptureChunks;
|
|
5707
6400
|
exports.scanCaptureFrames = scanCaptureFrames;
|
|
5708
6401
|
exports.settleCaptureShutdown = settleCaptureShutdown;
|
|
5709
6402
|
exports.shrinkCapturePicture = shrinkCapturePicture;
|
|
5710
6403
|
exports.splitCapturePages = splitCapturePages;
|
|
6404
|
+
exports.splitCaptureSheets = splitCaptureSheets;
|
|
6405
|
+
exports.sumCaptureBlock = sumCaptureBlock;
|
|
6406
|
+
exports.sumCaptureRow = sumCaptureRow;
|
|
5711
6407
|
exports.unfilterCaptureRow = unfilterCaptureRow;
|
|
5712
6408
|
exports.writeCaptureDocument = writeCaptureDocument;
|
|
5713
6409
|
|