@cobol-ts/validation-execution 0.0.0-stage → 0.0.59

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.
Files changed (174) hide show
  1. package/README.md +256 -3
  2. package/dist/index.d.ts +41 -0
  3. package/dist/index.js +59 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/src/compaction.prepare.d.ts +10 -0
  6. package/dist/src/compaction.prepare.js +60 -0
  7. package/dist/src/compaction.prepare.js.map +1 -0
  8. package/dist/src/compaction.project.d.ts +28 -0
  9. package/dist/src/compaction.project.js +81 -0
  10. package/dist/src/compaction.project.js.map +1 -0
  11. package/dist/src/compaction.project.memory.d.ts +12 -0
  12. package/dist/src/compaction.project.memory.js +70 -0
  13. package/dist/src/compaction.project.memory.js.map +1 -0
  14. package/dist/src/compaction.project.spec.d.ts +1 -0
  15. package/dist/src/compaction.project.spec.js +44 -0
  16. package/dist/src/compaction.project.spec.js.map +1 -0
  17. package/dist/src/compaction.project.storage.d.ts +21 -0
  18. package/dist/src/compaction.project.storage.js +3 -0
  19. package/dist/src/compaction.project.storage.js.map +1 -0
  20. package/dist/src/identification.candidate.d.ts +16 -0
  21. package/dist/src/identification.candidate.js +40 -0
  22. package/dist/src/identification.candidate.js.map +1 -0
  23. package/dist/src/identification.context.d.ts +8 -0
  24. package/dist/src/identification.context.js +3 -0
  25. package/dist/src/identification.context.js.map +1 -0
  26. package/dist/src/identification.selection.d.ts +4 -0
  27. package/dist/src/identification.selection.js +3 -0
  28. package/dist/src/identification.selection.js.map +1 -0
  29. package/dist/src/identified.state.publication.d.ts +14 -0
  30. package/dist/src/identified.state.publication.js +3 -0
  31. package/dist/src/identified.state.publication.js.map +1 -0
  32. package/dist/src/identified.state.reader.spec.d.ts +1 -0
  33. package/dist/src/identified.state.reader.spec.js +101 -0
  34. package/dist/src/identified.state.reader.spec.js.map +1 -0
  35. package/dist/src/identified.state.source.d.ts +20 -0
  36. package/dist/src/identified.state.source.js +5 -0
  37. package/dist/src/identified.state.source.js.map +1 -0
  38. package/dist/src/projected.entity.d.ts +8 -0
  39. package/dist/src/projected.entity.js +55 -0
  40. package/dist/src/projected.entity.js.map +1 -0
  41. package/dist/src/validation.candidate.execution.d.ts +6 -0
  42. package/dist/src/validation.candidate.execution.js +31 -0
  43. package/dist/src/validation.candidate.execution.js.map +1 -0
  44. package/dist/src/validation.candidate.failure.d.ts +5 -0
  45. package/dist/src/validation.candidate.failure.js +22 -0
  46. package/dist/src/validation.candidate.failure.js.map +1 -0
  47. package/dist/src/validation.candidate.policy.d.ts +16 -0
  48. package/dist/src/validation.candidate.policy.js +43 -0
  49. package/dist/src/validation.candidate.policy.js.map +1 -0
  50. package/dist/src/validation.candidate.policy.spec.d.ts +1 -0
  51. package/dist/src/validation.candidate.policy.spec.js +32 -0
  52. package/dist/src/validation.candidate.policy.spec.js.map +1 -0
  53. package/dist/src/validation.cursors.d.ts +23 -0
  54. package/dist/src/validation.cursors.js +117 -0
  55. package/dist/src/validation.cursors.js.map +1 -0
  56. package/dist/src/validation.display.d.ts +13 -0
  57. package/dist/src/validation.display.js +45 -0
  58. package/dist/src/validation.display.js.map +1 -0
  59. package/dist/src/validation.display.project.d.ts +4 -0
  60. package/dist/src/validation.display.project.js +20 -0
  61. package/dist/src/validation.display.project.js.map +1 -0
  62. package/dist/src/validation.identification.cutoffs.spec.d.ts +1 -0
  63. package/dist/src/validation.identification.cutoffs.spec.js +124 -0
  64. package/dist/src/validation.identification.cutoffs.spec.js.map +1 -0
  65. package/dist/src/validation.identification.execution.d.ts +11 -0
  66. package/dist/src/validation.identification.execution.js +36 -0
  67. package/dist/src/validation.identification.execution.js.map +1 -0
  68. package/dist/src/validation.identification.inspect.recovered.d.ts +9 -0
  69. package/dist/src/validation.identification.inspect.recovered.js +101 -0
  70. package/dist/src/validation.identification.inspect.recovered.js.map +1 -0
  71. package/dist/src/validation.identification.materialise.d.ts +26 -0
  72. package/dist/src/validation.identification.materialise.js +67 -0
  73. package/dist/src/validation.identification.materialise.js.map +1 -0
  74. package/dist/src/validation.identification.observation.d.ts +15 -0
  75. package/dist/src/validation.identification.observation.js +51 -0
  76. package/dist/src/validation.identification.observation.js.map +1 -0
  77. package/dist/src/validation.identification.observation.spec.d.ts +1 -0
  78. package/dist/src/validation.identification.observation.spec.js +29 -0
  79. package/dist/src/validation.identification.observation.spec.js.map +1 -0
  80. package/dist/src/validation.identification.physical.d.ts +26 -0
  81. package/dist/src/validation.identification.physical.js +79 -0
  82. package/dist/src/validation.identification.physical.js.map +1 -0
  83. package/dist/src/validation.identification.prefix.d.ts +27 -0
  84. package/dist/src/validation.identification.prefix.js +62 -0
  85. package/dist/src/validation.identification.prefix.js.map +1 -0
  86. package/dist/src/validation.identification.prefix.spec.d.ts +1 -0
  87. package/dist/src/validation.identification.prefix.spec.js +76 -0
  88. package/dist/src/validation.identification.prefix.spec.js.map +1 -0
  89. package/dist/src/validation.identification.projection.d.ts +6 -0
  90. package/dist/src/validation.identification.projection.js +21 -0
  91. package/dist/src/validation.identification.projection.js.map +1 -0
  92. package/dist/src/validation.identification.replay.d.ts +18 -0
  93. package/dist/src/validation.identification.replay.js +110 -0
  94. package/dist/src/validation.identification.replay.js.map +1 -0
  95. package/dist/src/validation.identification.satisfaction.d.ts +49 -0
  96. package/dist/src/validation.identification.satisfaction.js +116 -0
  97. package/dist/src/validation.identification.satisfaction.js.map +1 -0
  98. package/dist/src/validation.identification.scope.d.ts +7 -0
  99. package/dist/src/validation.identification.scope.js +60 -0
  100. package/dist/src/validation.identification.scope.js.map +1 -0
  101. package/dist/src/validation.identification.shard.d.ts +23 -0
  102. package/dist/src/validation.identification.shard.js +56 -0
  103. package/dist/src/validation.identification.shard.js.map +1 -0
  104. package/dist/src/validation.identification.strategy.d.ts +6 -0
  105. package/dist/src/validation.identification.strategy.js +26 -0
  106. package/dist/src/validation.identification.strategy.js.map +1 -0
  107. package/dist/src/validation.identification.strategy.spec.d.ts +1 -0
  108. package/dist/src/validation.identification.strategy.spec.js +31 -0
  109. package/dist/src/validation.identification.strategy.spec.js.map +1 -0
  110. package/dist/src/validation.identified.state.d.ts +34 -0
  111. package/dist/src/validation.identified.state.js +90 -0
  112. package/dist/src/validation.identified.state.js.map +1 -0
  113. package/dist/src/validation.investigation.d.ts +32 -0
  114. package/dist/src/validation.investigation.js +57 -0
  115. package/dist/src/validation.investigation.js.map +1 -0
  116. package/dist/src/validation.layouts.d.ts +26 -0
  117. package/dist/src/validation.layouts.js +78 -0
  118. package/dist/src/validation.layouts.js.map +1 -0
  119. package/dist/src/validation.manifest.reader.d.ts +16 -0
  120. package/dist/src/validation.manifest.reader.js +37 -0
  121. package/dist/src/validation.manifest.reader.js.map +1 -0
  122. package/dist/src/validation.observation.d.ts +58 -0
  123. package/dist/src/validation.observation.js +234 -0
  124. package/dist/src/validation.observation.js.map +1 -0
  125. package/dist/src/validation.oracle.dependencies.d.ts +29 -0
  126. package/dist/src/validation.oracle.dependencies.js +108 -0
  127. package/dist/src/validation.oracle.dependencies.js.map +1 -0
  128. package/dist/src/validation.oracle.dependencies.spec.d.ts +1 -0
  129. package/dist/src/validation.oracle.dependencies.spec.js +40 -0
  130. package/dist/src/validation.oracle.dependencies.spec.js.map +1 -0
  131. package/dist/src/validation.project.access.d.ts +23 -0
  132. package/dist/src/validation.project.access.js +13 -0
  133. package/dist/src/validation.project.access.js.map +1 -0
  134. package/dist/src/validation.reader.d.ts +17 -0
  135. package/dist/src/validation.reader.js +181 -0
  136. package/dist/src/validation.reader.js.map +1 -0
  137. package/dist/src/validation.reader.types.d.ts +23 -0
  138. package/dist/src/validation.reader.types.js +3 -0
  139. package/dist/src/validation.reader.types.js.map +1 -0
  140. package/dist/src/validation.recovered.shard.d.ts +8 -0
  141. package/dist/src/validation.recovered.shard.js +3 -0
  142. package/dist/src/validation.recovered.shard.js.map +1 -0
  143. package/dist/src/validation.reference.d.ts +5 -0
  144. package/dist/src/validation.reference.js +3 -0
  145. package/dist/src/validation.reference.js.map +1 -0
  146. package/dist/src/validation.replay.d.ts +27 -0
  147. package/dist/src/validation.replay.js +137 -0
  148. package/dist/src/validation.replay.js.map +1 -0
  149. package/dist/src/validation.report.d.ts +59 -0
  150. package/dist/src/validation.report.js +118 -0
  151. package/dist/src/validation.report.js.map +1 -0
  152. package/dist/src/validation.report.spec.d.ts +1 -0
  153. package/dist/src/validation.report.spec.js +75 -0
  154. package/dist/src/validation.report.spec.js.map +1 -0
  155. package/dist/src/validation.run.d.ts +10 -0
  156. package/dist/src/validation.run.js +20 -0
  157. package/dist/src/validation.run.js.map +1 -0
  158. package/dist/src/validation.run.project.d.ts +5 -0
  159. package/dist/src/validation.run.project.js +57 -0
  160. package/dist/src/validation.run.project.js.map +1 -0
  161. package/dist/src/validation.sequence.d.ts +11 -0
  162. package/dist/src/validation.sequence.js +59 -0
  163. package/dist/src/validation.sequence.js.map +1 -0
  164. package/dist/src/validation.sources.d.ts +11 -0
  165. package/dist/src/validation.sources.js +3 -0
  166. package/dist/src/validation.sources.js.map +1 -0
  167. package/dist/src/validation.sources.spec.d.ts +1 -0
  168. package/dist/src/validation.sources.spec.js +36 -0
  169. package/dist/src/validation.sources.spec.js.map +1 -0
  170. package/dist/src/validation.synchronous.spec.d.ts +1 -0
  171. package/dist/src/validation.synchronous.spec.js +173 -0
  172. package/dist/src/validation.synchronous.spec.js.map +1 -0
  173. package/index.ts +48 -0
  174. package/package.json +79 -3
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareManifestIds = void 0;
4
+ exports.scanValidationShardWith = scanValidationShardWith;
5
+ exports.scanValidationCustomersWith = scanValidationCustomersWith;
6
+ exports.visitValidationIdsWith = visitValidationIdsWith;
7
+ const node_path_1 = require("node:path");
8
+ const file_catalogue_1 = require("@cobol-ts/file-catalogue");
9
+ const composition_definition_1 = require("@cobol-ts/composition-definition");
10
+ const errors_1 = require("@cobol-ts/errors");
11
+ const validation_cursors_1 = require("./validation.cursors");
12
+ const validation_layouts_1 = require("./validation.layouts");
13
+ const validation_sequence_1 = require("./validation.sequence");
14
+ const validation_observation_1 = require("./validation.observation");
15
+ const validation_manifest_reader_1 = require("./validation.manifest.reader");
16
+ var validation_sequence_2 = require("./validation.sequence");
17
+ Object.defineProperty(exports, "compareManifestIds", { enumerable: true, get: function () { return validation_sequence_2.compareManifestIds; } });
18
+ /** Prepared-source entrypoint: configuration acquisition is mandatory. */
19
+ function scanValidationShardWith(configDirectory, sources, readConfig, yaml, visit, select = () => 'read', prepare) {
20
+ return scan(configDirectory, sources, { observation: visit }, select, prepare, readConfig, yaml);
21
+ }
22
+ /** Borrow all selected observations of one customer, in manifest replay order,
23
+ * for one synchronous invocation. Physical leases stay open until it returns.
24
+ * Skipped events are not retained; stop delivers any selected prefix before
25
+ * returning. An incomplete history caused by a read error is never delivered.
26
+ * Neither observations nor their physical leases may escape the visitor. */
27
+ function scanValidationCustomersWith(configDirectory, sources, readConfig, yaml, visit, select = () => 'read', prepare) {
28
+ return scan(configDirectory, sources, { customer: visit }, select, prepare, readConfig, yaml);
29
+ }
30
+ async function readConfiguration(configDirectory, readConfig, yaml) {
31
+ const raw = (0, errors_1.valueOrThrow)(yaml.parse(await readConfig((0, node_path_1.join)(configDirectory, 'files.yaml'))));
32
+ const catalogue = (0, errors_1.valueOrThrow)((0, file_catalogue_1.parseFileCatalogue)(raw));
33
+ const definitions = (0, errors_1.valueOrThrow)((0, composition_definition_1.parseCompositionNames)(raw)).filter(c => c.type === 'relational')
34
+ .map(c => (0, errors_1.valueOrThrow)((0, composition_definition_1.parseCompositionDefinition)(raw, c.name)));
35
+ return { catalogue, definitions };
36
+ }
37
+ async function prepareShard(sources, manifest, inventory, { catalogue, definitions }, prepare) {
38
+ const header = (0, errors_1.valueOrThrow)((0, composition_definition_1.parseValidationManifestHeader)(manifest.columns, catalogue));
39
+ const expected = ['manifest.csv', ...header.files.map(f => f.filename)].sort();
40
+ const actual = [...await sources.names()].sort();
41
+ if (actual.length !== expected.length || actual.some((name, index) => name !== expected[index]))
42
+ throw new Error('Validation shard inventory does not match manifest columns');
43
+ const physical = new Map();
44
+ for (const file of header.files) {
45
+ if (file.logicalName)
46
+ physical.set(file.filename, await sources.configured(file.logicalName, file.filename));
47
+ else {
48
+ if (file.type === 'cobol')
49
+ throw new Error(`Missing catalogue definition for ${file.filename}`);
50
+ inventory.results.set(file.filename, await (0, validation_cursors_1.openText)(sources, file.filename, file.type));
51
+ }
52
+ }
53
+ const layouts = (0, validation_layouts_1.prepareLayouts)(definitions, catalogue, physical);
54
+ for (const layout of layouts)
55
+ for (const { filename } of layout.inputs) {
56
+ if (!inventory.inputs.has(filename))
57
+ inventory.inputs.set(filename, await (0, validation_cursors_1.openInput)(physical.get(filename)));
58
+ }
59
+ for (const filename of physical.keys())
60
+ if (!inventory.inputs.has(filename))
61
+ throw new Error(`Manifest input is not in any composition: ${filename}`);
62
+ // No reference acquisition or graph compilation may interrupt traversal.
63
+ if (prepare)
64
+ for (const layout of layouts)
65
+ layout.referenceData = await prepare(layout.definition, layout.sources);
66
+ const ordinals = new Map(header.files.map((file, i) => [file.filename, i]));
67
+ const scanLayouts = layouts.map(layout => ({ ...layout, inputSlots: layout.inputs.map(input => ({
68
+ ...input, ordinal: ordinals.get(input.filename), cursor: inventory.inputs.get(input.filename)
69
+ })) }));
70
+ const results = [...inventory.results].map(([filename, cursor]) => ({ filename, cursor, ordinal: ordinals.get(filename) }));
71
+ return { reader: (0, validation_manifest_reader_1.compileManifestReader)(manifest, header), results, readObservation: (0, validation_observation_1.createObservationReader)(scanLayouts),
72
+ resolveLayout: (0, validation_layouts_1.createLayoutResolver)(scanLayouts, [...physical.keys()].map(name => ordinals.get(name)), ordinals) };
73
+ }
74
+ function checkCounts(counts, layout, results) {
75
+ for (let i = 0; i < layout.inputSlots.length; i++) {
76
+ const { filename, source, ordinal } = layout.inputSlots[i], count = counts[ordinal];
77
+ (0, validation_sequence_1.checkCount)(filename, count === -1 ? null : count, source.cardinality);
78
+ }
79
+ for (let i = 0; i < results.length; i++) {
80
+ const { filename, ordinal } = results[i], count = counts[ordinal];
81
+ if (count !== -1)
82
+ (0, validation_sequence_1.checkCount)(filename, count, 'one');
83
+ }
84
+ }
85
+ /** The entire traversal is synchronous. Only acquisition and final cleanup may
86
+ * suspend. Never add per-record or per-observation async helpers here. */
87
+ function traverse({ reader, resolveLayout, results, readObservation }, inventory, visitor, select, position) {
88
+ const sequence = (0, validation_sequence_1.createManifestSequence)(), delivery = (0, validation_observation_1.createDelivery)(visitor);
89
+ const { event, counts } = reader;
90
+ try {
91
+ while (reader.next()) {
92
+ position.row++;
93
+ reader.check();
94
+ const layout = resolveLayout(event, counts);
95
+ if (sequence.advance(event, layout))
96
+ delivery.finishCustomer();
97
+ sequence.checkExecution(event);
98
+ checkCounts(counts, layout, results);
99
+ const decision = select(event, layout.keyType);
100
+ if (decision === 'stop') {
101
+ delivery.finishCustomer();
102
+ return;
103
+ }
104
+ if (decision === 'read')
105
+ delivery.accept(readObservation(reader.snapshot(), counts, layout, results));
106
+ else
107
+ (0, validation_observation_1.skipObservation)(counts, layout, results);
108
+ }
109
+ delivery.finishCustomer();
110
+ (0, validation_observation_1.checkTrailingInputs)(inventory.inputs, inventory.results);
111
+ }
112
+ catch (error) {
113
+ try {
114
+ delivery.discard();
115
+ }
116
+ catch (cleanup) {
117
+ throw (0, validation_observation_1.combinedFailure)(error, cleanup);
118
+ }
119
+ throw error;
120
+ }
121
+ }
122
+ async function closeCursors(manifest, inventory) {
123
+ const cursors = [manifest, ...inventory.inputs.values(), ...inventory.results.values()];
124
+ // Defer invocation too, so even a synchronous throw cannot prevent another close.
125
+ const closed = await Promise.allSettled(cursors.map(cursor => Promise.resolve().then(() => cursor.close())));
126
+ const failures = [];
127
+ for (const result of closed)
128
+ if (result.status === 'rejected')
129
+ failures.push(result.reason);
130
+ if (failures.length)
131
+ throw new AggregateError(failures, 'Validation cursor cleanup failed');
132
+ }
133
+ function manifestError(sources, position, error) {
134
+ return new Error(`Validation manifest ${sources.label}/manifest.csv, row ${position.row}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
135
+ }
136
+ async function scan(configDirectory, sources, visitor, select, prepare, readConfig, yaml) {
137
+ const configuration = await readConfiguration(configDirectory, readConfig, yaml);
138
+ const manifest = await (0, validation_cursors_1.openText)(sources, 'manifest.csv', 'csv');
139
+ const inventory = { inputs: new Map(), results: new Map() }, position = { row: 1 };
140
+ try {
141
+ const prepared = await prepareShard(sources, manifest, inventory, configuration, prepare);
142
+ traverse(prepared, inventory, visitor, select, position);
143
+ }
144
+ catch (error) {
145
+ const primary = manifestError(sources, position, error);
146
+ try {
147
+ await closeCursors(manifest, inventory);
148
+ }
149
+ catch (cleanup) {
150
+ throw (0, validation_observation_1.combinedFailure)(primary, cleanup);
151
+ }
152
+ throw primary;
153
+ }
154
+ await closeCursors(manifest, inventory);
155
+ }
156
+ /** Navigation reads only the authenticated manifest. Stop on the page lookahead;
157
+ * distinct IDs are adjacent within a shard, so no set or total is required. */
158
+ async function visitValidationIdsWith(sources, visit) {
159
+ const manifest = await (0, validation_cursors_1.openText)(sources, 'manifest.csv', 'csv');
160
+ let previous;
161
+ try {
162
+ if (manifest.columns?.slice(0, 3).join(',') !== 'customerId,date,periodicity')
163
+ throw new Error('Invalid validation manifest header');
164
+ while (true) {
165
+ const id = manifest.takeFirstColumn();
166
+ if (id === undefined)
167
+ return true;
168
+ if (!id)
169
+ throw new Error('Empty validation customer identity');
170
+ if (id === previous)
171
+ continue;
172
+ previous = id;
173
+ if (!visit(id))
174
+ return false;
175
+ }
176
+ }
177
+ finally {
178
+ await manifest.close();
179
+ }
180
+ }
181
+ //# sourceMappingURL=validation.reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.reader.js","sourceRoot":"","sources":["../../src/validation.reader.ts"],"names":[],"mappings":";;;AAmBA,0DAGC;AAOD,kEAIC;AA2GD,wDAcC;AA1JD,yCAA8B;AAC9B,6DAA2D;AAC3D,6EACuE;AACvE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AAC,OAAO,KAAK,CAAA;QAC9B,CAAC;IACL,CAAC;YAAS,CAAC;QAAA,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAA;IAAA,CAAC;AACtC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { CompositionDefinition, ValidationManifestEvent } from '@cobol-ts/composition-definition';
2
+ import type { CompositeRecord, PreparedSource, ReferenceData } from '@cobol-ts/cursor-composition';
3
+ import type { KeyType } from './validation.layouts';
4
+ /** Called for every prepared layout before any manifest observations are visited. */
5
+ export type ValidationPreparation = (definition: CompositionDefinition, sources: readonly PreparedSource[]) => Promise<ReferenceData | undefined>;
6
+ export interface ValidationObservation {
7
+ readonly event: ValidationManifestEvent;
8
+ readonly composition: string;
9
+ readonly sources: readonly PreparedSource[];
10
+ /** Borrowed for the synchronous observation or customer visitor. Slots and their lease arrays must not escape that invocation; the row handle remains permanently closed. */
11
+ readonly row: CompositeRecord;
12
+ /** Published results keyed by physical filename; CSV cells remain strings. */
13
+ readonly expected: Readonly<Record<string, unknown>>;
14
+ }
15
+ export type ValidationSelection = 'read' | 'skip' | 'stop';
16
+ /** The selector borrows the scan-local event only for this synchronous call.
17
+ * Copy any values needed after it returns. Selected observations have their own event. */
18
+ export type SelectObservation = (event: ValidationManifestEvent, keyType: KeyType) => ValidationSelection;
19
+ export type ValidationVisitor = {
20
+ observation: (observation: ValidationObservation) => void;
21
+ } | {
22
+ customer: (history: readonly ValidationObservation[]) => void;
23
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=validation.reader.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.reader.types.js","sourceRoot":"","sources":["../../src/validation.reader.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import type { CryptoPackager } from '@cobol-ts/crypto-packager';
2
+ import type { ValidationSources } from './validation.sources';
3
+ export interface ShardRecovery extends Pick<CryptoPackager, 'recoverPackageTo'> {
4
+ manifest(id: string): Promise<{
5
+ readonly generation: string;
6
+ }>;
7
+ }
8
+ export type WithRecoveredValidationShard = <T>(id: string, use: (sources: ValidationSources) => Promise<T>) => Promise<T>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=validation.recovered.shard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.recovered.shard.js","sourceRoot":"","sources":["../../src/validation.recovered.shard.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { ProjectPaths } from '@cobol-ts/project-context';
2
+ import type { CompositionFileFactory } from '@cobol-ts/composition-definition';
3
+ /** The replay sees only prepared reference sources, whose lifetime is the
4
+ * enclosing operation. A remote or memory adapter may supply the same factory. */
5
+ export type WithValidationReferences = <T>(paths: ProjectPaths, use: (reference: CompositionFileFactory) => Promise<T>) => Promise<T>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=validation.reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.reference.js","sourceRoot":"","sources":["../../src/validation.reference.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { YamlParser } from '@cobol-ts/yaml';
2
+ import { type CompositionFileFactory } from '@cobol-ts/composition-definition';
3
+ import { type AuthoringGraph, type NamedAccumulatorValues } from '@cobol-ts/cel-graph-runtime';
4
+ import { type IndexedGraphSchema } from '@cobol-ts/cursor-loader-indexed-graph-state';
5
+ import type { TextFiles } from '@cobol-ts/files';
6
+ import type { ProjectPaths } from '@cobol-ts/project-context';
7
+ import type { ValidationObservation, ValidationPreparation } from './validation.reader';
8
+ import { type OracleDependencies } from './validation.oracle.dependencies';
9
+ import { type PublishedComparison } from './validation.report';
10
+ export interface HistoricalSeedSource {
11
+ readonly schema: IndexedGraphSchema;
12
+ read(id: string, schema: IndexedGraphSchema): NamedAccumulatorValues;
13
+ }
14
+ export interface ReplayValues {
15
+ readonly accumulatorIn: Readonly<Record<string, unknown>>;
16
+ readonly accumulatorOut: Readonly<Record<string, unknown>>;
17
+ readonly comparisons?: Readonly<Record<string, readonly PublishedComparison[]>>;
18
+ }
19
+ /** One shared state per customer. Compile each layout once; never retain borrowed rows. */
20
+ export declare function prepareValidationReplayWith(paths: ProjectPaths, files: Pick<TextFiles, 'read' | 'exists'> & {
21
+ readonly yaml: YamlParser;
22
+ }, graphName: string | AuthoringGraph | undefined, openReference: CompositionFileFactory, oracle?: OracleDependencies, historicalSeed?: HistoricalSeedSource): Promise<{
23
+ prepare: ValidationPreparation;
24
+ evaluate: (observation: ValidationObservation, comparePublished?: boolean) => ReplayValues;
25
+ evaluateOutputs: (observation: ValidationObservation) => (name: string) => unknown;
26
+ reset: () => void;
27
+ }>;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareValidationReplayWith = prepareValidationReplayWith;
4
+ const cursor_composition_1 = require("@cobol-ts/cursor-composition");
5
+ const composition_definition_1 = require("@cobol-ts/composition-definition");
6
+ const cel_graph_runtime_1 = require("@cobol-ts/cel-graph-runtime");
7
+ const cursor_loader_indexed_graph_state_1 = require("@cobol-ts/cursor-loader-indexed-graph-state");
8
+ const errors_1 = require("@cobol-ts/errors");
9
+ const project_execution_1 = require("@cobol-ts/project-execution");
10
+ const project_execution_2 = require("@cobol-ts/project-execution");
11
+ const project_execution_3 = require("@cobol-ts/project-execution");
12
+ const validation_oracle_dependencies_1 = require("./validation.oracle.dependencies");
13
+ const validation_candidate_failure_1 = require("./validation.candidate.failure");
14
+ const validation_report_1 = require("./validation.report");
15
+ /** One shared state per customer. Compile each layout once; never retain borrowed rows. */
16
+ async function prepareValidationReplayWith(paths, files, graphName, openReference, oracle, historicalSeed) {
17
+ const authored = typeof graphName === 'object' ? graphName : (0, errors_1.valueOrThrow)(await (0, project_execution_1.loadCelAuthoringGraphWith)(paths, files, files.yaml, graphName));
18
+ const initial = historicalSeed ? (0, errors_1.valueOrThrow)((0, cel_graph_runtime_1.validateInitialAccumulator)(Object.fromEntries(Object.entries((0, errors_1.valueOrThrow)(await (0, project_execution_1.loadInitialAccumulatorWith)(paths, files, files.yaml))).filter(([name]) => !historicalSeed.schema.nodes.some(field => field.name === name))), authored, (0, errors_1.valueOrThrow)((0, cel_graph_runtime_1.canonicaliseCelGraph)(authored)).filter(node => !historicalSeed.schema.nodes.some(field => field.name === node.metadata.name)))) :
19
+ (0, errors_1.valueOrThrow)(await (0, project_execution_2.prepareGraphInitialWith)(paths, files, files.yaml, authored));
20
+ if (oracle?.size) {
21
+ const seed = (0, errors_1.valueOrThrow)(await (0, project_execution_1.loadInitialAccumulatorWith)(paths, files, files.yaml));
22
+ // Native failure placeholders deliberately ignore seeds in ordinary
23
+ // replay. Here they represent observed values, so use any explicit seed.
24
+ for (const [name, type] of oracle)
25
+ if (Object.hasOwn(seed, name))
26
+ initial[name] = (0, validation_oracle_dependencies_1.observedScalar)(name, type, seed[name]);
27
+ }
28
+ const published = oracle ? (0, validation_oracle_dependencies_1.prepareObservedDependencies)(oracle) : undefined;
29
+ const configuration = (0, errors_1.valueOrThrow)(await (0, project_execution_1.loadStateConfigurationWith)(paths, files, files.yaml));
30
+ if (!historicalSeed && (configuration.file !== undefined || !configuration.optional))
31
+ throw new Error('Validation replay currently requires a shared initial accumulator seed without a historical state file');
32
+ const executors = new Map();
33
+ const referenceCache = new Map();
34
+ let state, customer, schemaIdentity;
35
+ function prepareCelGraphForLayout(definition, sources, references) {
36
+ const composed = (0, cursor_composition_1.createComposition)(sources, definition.composition.master, references?.data);
37
+ return (0, errors_1.valueOrThrow)((0, cel_graph_runtime_1.prepareCelGraph)(authored, composed.projection, { ...(0, cursor_composition_1.compositeAccessCompiler)(sources), ...(references ? { referenceTables: references.tables } : {}) }, {}, {}, oracle ? (0, cel_graph_runtime_1.createDirectInputCelPlanner)(node => oracle.has(node.metadata.name)) : undefined));
38
+ }
39
+ const prepare = async (definition, sources) => {
40
+ const ref = definition.composition.referenceData;
41
+ let references;
42
+ if (ref) {
43
+ const key = JSON.stringify(Object.entries(ref).sort(([a], [b]) => a.localeCompare(b)));
44
+ references = referenceCache.get(key);
45
+ if (!references) {
46
+ references = await (0, composition_definition_1.loadReferenceData)(ref, openReference);
47
+ referenceCache.set(key, references);
48
+ }
49
+ }
50
+ const graph = prepareCelGraphForLayout(definition, sources, references);
51
+ const identity = JSON.stringify(graph.schema);
52
+ if (schemaIdentity !== undefined && identity !== schemaIdentity)
53
+ throw new Error('Replay compositions have incompatible accumulator schemas');
54
+ schemaIdentity = identity;
55
+ const execute = oracle ? graph.createExecutor(undefined, undefined, (name, error) => { throw new validation_candidate_failure_1.CandidateExecutionException(name, error); }, (name, index, native) => {
56
+ const ordinal = published.ordinal(name);
57
+ if (ordinal === undefined)
58
+ return native;
59
+ return (_data, _indices, state) => {
60
+ // Prev readers have already seen the previous value; now
61
+ // readers see this update at its normal topological position.
62
+ const value = published.value(ordinal);
63
+ if (value !== undefined)
64
+ return state.update(index, value);
65
+ if (state.values[index] === undefined)
66
+ return state.update(index, null);
67
+ return false;
68
+ };
69
+ }) : graph.createExecutor();
70
+ executors.set(definition.name, { schema: graph.schema, execute, positions: new Map(graph.schema.nodes.map((node, index) => [node.name, index])) });
71
+ return references?.data;
72
+ };
73
+ const variables = { periodicity: '' };
74
+ let outputPositions;
75
+ let outputState;
76
+ function executorFor(observation) {
77
+ const executor = executors.get(observation.composition);
78
+ if (!executor)
79
+ throw new Error(`Replay layout was not prepared: ${observation.composition}`);
80
+ return executor;
81
+ }
82
+ function stateFor(executor, id) {
83
+ if (!state || customer !== id) {
84
+ customer = undefined;
85
+ state ??= (0, cursor_loader_indexed_graph_state_1.createIndexedGraphRecord)(executor.schema.nodes.length);
86
+ (0, project_execution_3.resetIndexedStateFromInitial)(executor.schema, state, initial, historicalSeed?.read(id, executor.schema));
87
+ state.entityKey = id;
88
+ customer = id;
89
+ }
90
+ return state;
91
+ }
92
+ function executeObservation(observation, executor, state) {
93
+ variables.periodicity = observation.event.periodicity;
94
+ try {
95
+ published?.read(observation.expected);
96
+ executor.execute(observation.row, state, variables);
97
+ }
98
+ finally {
99
+ published?.clear();
100
+ }
101
+ }
102
+ function evaluate(observation, comparePublished = false) {
103
+ outputPositions = undefined;
104
+ outputState = undefined;
105
+ const executor = executorFor(observation);
106
+ const state = stateFor(executor, observation.event.customerId);
107
+ const accumulatorIn = (0, project_execution_3.snapshotIndexedState)(executor.schema, state);
108
+ executeObservation(observation, executor, state);
109
+ return { accumulatorIn, accumulatorOut: (0, project_execution_3.snapshotIndexedState)(executor.schema, state),
110
+ ...(comparePublished ? { comparisons: (0, validation_report_1.publishedComparisons)(observation.expected, executor.positions, name => state.values[executor.positions.get(name)]) } : {}) };
111
+ }
112
+ /** Borrowed output lookup, valid only until the next evaluation. Batch validation
113
+ * does not materialise the entire accumulator or projected inputs per event. */
114
+ function evaluateOutputs(observation) {
115
+ outputPositions = undefined;
116
+ outputState = undefined;
117
+ const executor = executorFor(observation);
118
+ const state = stateFor(executor, observation.event.customerId);
119
+ executeObservation(observation, executor, state);
120
+ outputPositions = executor.positions;
121
+ outputState = state;
122
+ return readOutput;
123
+ }
124
+ function readOutput(name) {
125
+ const index = outputPositions?.get(name);
126
+ return index === undefined ? undefined : outputState.values[index];
127
+ }
128
+ function reset() {
129
+ outputPositions = undefined;
130
+ outputState = undefined;
131
+ state = undefined;
132
+ customer = undefined;
133
+ executors.clear();
134
+ }
135
+ return { prepare, evaluate, evaluateOutputs, reset };
136
+ }
137
+ //# sourceMappingURL=validation.replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.replay.js","sourceRoot":"","sources":["../../src/validation.replay.ts"],"names":[],"mappings":";;AA4BA,kEA+GC;AA1ID,qEAAkI;AAClI,6EAA2H;AAC3H,mEAAgN;AAChN,mGAAoI;AACpI,6CAA6C;AAC7C,mEAA6H;AAC7H,mEAAmE;AAC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UAAU,CAAC,CAAA;QAC9D,kBAAkB,CAAC,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;QAChD,eAAe,GAAG,QAAQ,CAAC,SAAS,CAAA;QACpC,WAAW,GAAG,KAAK,CAAA;QACnB,OAAO,UAAU,CAAA;IACrB,CAAC;IACD,SAAS,UAAU,CAAC,IAAY;QAC5B,MAAM,KAAK,GAAG,eAAe,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;QACxC,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACvE,CAAC;IACD,SAAS,KAAK;QACV,eAAe,GAAG,SAAS,CAAA;QAC3B,WAAW,GAAG,SAAS,CAAA;QACvB,KAAK,GAAC,SAAS,CAAA;QACf,QAAQ,GAAC,SAAS,CAAA;QAClB,SAAS,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;IACD,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAC,CAAA;AACtD,CAAC"}
@@ -0,0 +1,59 @@
1
+ import type { ValidationObservation } from './validation.reader';
2
+ export interface ValidationRunOptions {
3
+ readonly characteristic?: string;
4
+ readonly maxCounterexamples?: number;
5
+ readonly graph?: string;
6
+ readonly shard?: string;
7
+ readonly identified?: string;
8
+ }
9
+ type Scalar = string | number | bigint | boolean | null;
10
+ export interface ValidationCounterexample {
11
+ readonly customerId: string;
12
+ readonly date: string;
13
+ readonly periodicity: string;
14
+ readonly composition: string;
15
+ readonly source: string;
16
+ readonly expected: Scalar;
17
+ readonly actual?: Scalar;
18
+ readonly reason: 'different-value' | 'missing-value' | 'non-scalar-value';
19
+ }
20
+ export interface CharacteristicStatistics {
21
+ readonly characteristic: string;
22
+ readonly compared: number;
23
+ readonly matched: number;
24
+ readonly mismatched: number;
25
+ readonly missing: number;
26
+ readonly counterexamples: readonly ValidationCounterexample[];
27
+ }
28
+ export interface ValidationReport {
29
+ readonly status: 'matched' | 'mismatched' | 'incomplete';
30
+ readonly shards: number;
31
+ readonly events: number;
32
+ readonly eventsWithoutResults: number;
33
+ readonly eventsWithoutSelectedCharacteristic: number;
34
+ readonly compared: number;
35
+ readonly matched: number;
36
+ readonly mismatched: number;
37
+ readonly characteristics: readonly CharacteristicStatistics[];
38
+ }
39
+ type ExpectedObservation = Pick<ValidationObservation, 'event' | 'composition' | 'expected'>;
40
+ /** CSV carries text, not JSON types. Only exact canonical scalar text matches;
41
+ * no whitespace trimming, case folding, leading-zero removal or null inference.
42
+ * JSONL compares native scalar types, allowing safe integer number/bigint equality. */
43
+ export declare function matchesPublishedValue(source: string, expected: Scalar, actual: Scalar): boolean;
44
+ /** Diagnostic-only comparisons, computed before lossless JSON conversion. Keep
45
+ * every published source when a characteristic occurs in more than one file. */
46
+ export interface PublishedComparison {
47
+ readonly source: string;
48
+ readonly expected: Scalar;
49
+ readonly status: 'matched' | 'mismatched' | 'unavailable';
50
+ }
51
+ export declare function publishedComparisons(expected: ExpectedObservation['expected'], names: ReadonlyMap<string, number>, read: (name: string) => unknown): Readonly<Record<string, readonly PublishedComparison[]>>;
52
+ export declare function checkValidationRunOptions(options: ValidationRunOptions): number;
53
+ /** Retains one counter and a bounded number of detached scalar counterexamples
54
+ * per characteristic, independent of the number of customers and events. */
55
+ export declare function validationStatistics(characteristics: readonly string[], options?: ValidationRunOptions): {
56
+ observe: (observation: ExpectedObservation, read: (name: string) => unknown) => void;
57
+ report: (shards: number) => ValidationReport;
58
+ };
59
+ export {};
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.matchesPublishedValue = matchesPublishedValue;
4
+ exports.publishedComparisons = publishedComparisons;
5
+ exports.checkValidationRunOptions = checkValidationRunOptions;
6
+ exports.validationStatistics = validationStatistics;
7
+ function isScalar(value) {
8
+ const type = typeof value;
9
+ return value === null || type === 'string' || type === 'number' || type === 'bigint' || type === 'boolean';
10
+ }
11
+ /** CSV carries text, not JSON types. Only exact canonical scalar text matches;
12
+ * no whitespace trimming, case folding, leading-zero removal or null inference.
13
+ * JSONL compares native scalar types, allowing safe integer number/bigint equality. */
14
+ function matchesPublishedValue(source, expected, actual) {
15
+ return matchesScalar(source.endsWith('.csv'), expected, actual);
16
+ }
17
+ function matchesScalar(csv, expected, actual) {
18
+ if (typeof actual === 'number' && (!Number.isFinite(actual) || (Number.isInteger(actual) && !Number.isSafeInteger(actual))))
19
+ return false;
20
+ if (csv)
21
+ return actual !== null && String(actual) === expected;
22
+ if (typeof actual === 'bigint' && typeof expected === 'number')
23
+ return Number.isSafeInteger(expected) && BigInt(expected) === actual;
24
+ return actual === expected;
25
+ }
26
+ function publishedComparisons(expected, names, read) {
27
+ const result = new Map();
28
+ for (const [source, row] of Object.entries(expected)) {
29
+ if (row === null || typeof row !== 'object' || Array.isArray(row))
30
+ continue;
31
+ for (const [name, value] of Object.entries(row)) {
32
+ if (!names.has(name) || !isScalar(value))
33
+ continue;
34
+ const valid = typeof value !== 'number' || (Number.isFinite(value) && (!Number.isInteger(value) || Number.isSafeInteger(value)));
35
+ const actual = read(name);
36
+ const status = !valid ? 'unavailable' : isScalar(actual) && matchesPublishedValue(source, value, actual) ? 'matched' : 'mismatched';
37
+ const entries = result.get(name) ?? [];
38
+ entries.push({ source, expected: value, status });
39
+ result.set(name, entries);
40
+ }
41
+ }
42
+ return Object.fromEntries(result);
43
+ }
44
+ function checkValidationRunOptions(options) {
45
+ const limit = options.maxCounterexamples ?? 5;
46
+ if (!Number.isSafeInteger(limit) || limit < 0 || limit > 100)
47
+ throw new Error('--max-counterexamples must be an integer from 0 to 100');
48
+ if (options.characteristic !== undefined && !options.characteristic.trim())
49
+ throw new Error('Expected a nonempty characteristic name');
50
+ return limit;
51
+ }
52
+ /** Retains one counter and a bounded number of detached scalar counterexamples
53
+ * per characteristic, independent of the number of customers and events. */
54
+ function validationStatistics(characteristics, options = {}) {
55
+ const limit = checkValidationRunOptions(options), statistics = new Map();
56
+ const declared = new Set(characteristics);
57
+ if (options.characteristic !== undefined && !declared.has(options.characteristic))
58
+ throw new Error(`Unknown output characteristic '${options.characteristic}'`);
59
+ for (const characteristic of declared)
60
+ if (options.characteristic === undefined || options.characteristic === characteristic)
61
+ statistics.set(characteristic, { characteristic, compared: 0, matched: 0, mismatched: 0, missing: 0, counterexamples: [] });
62
+ let events = 0, eventsWithoutResults = 0, eventsWithoutSelectedCharacteristic = 0, compared = 0, matched = 0;
63
+ function observe(observation, read) {
64
+ events++;
65
+ let published = false, selected = false;
66
+ // Published JSONL rows may vary in shape. Visit own enumerable keys
67
+ // rather than caching the first row's keys or materialising entry tuples.
68
+ for (const source in observation.expected) {
69
+ if (!Object.hasOwn(observation.expected, source))
70
+ continue;
71
+ const row = observation.expected[source];
72
+ if (row === null || typeof row !== 'object' || Array.isArray(row))
73
+ throw new Error(`Expected a published result object in ${source}`);
74
+ const csv = source.endsWith('.csv');
75
+ const values = row;
76
+ for (const characteristic in values) {
77
+ if (!Object.hasOwn(values, characteristic) || !declared.has(characteristic))
78
+ continue;
79
+ published = true;
80
+ const stats = statistics.get(characteristic);
81
+ if (!stats)
82
+ continue;
83
+ selected = true;
84
+ const expected = values[characteristic];
85
+ if (!isScalar(expected) || (typeof expected === 'number' && (!Number.isFinite(expected) || (Number.isInteger(expected) && !Number.isSafeInteger(expected)))))
86
+ throw new Error(`Unsupported or imprecise published value for ${characteristic} in ${source}`);
87
+ const actual = read(characteristic);
88
+ compared++;
89
+ stats.compared++;
90
+ if (isScalar(actual) && matchesScalar(csv, expected, actual)) {
91
+ matched++;
92
+ stats.matched++;
93
+ continue;
94
+ }
95
+ stats.mismatched++;
96
+ if (actual === undefined)
97
+ stats.missing++;
98
+ if (stats.counterexamples.length < limit) {
99
+ const { customerId, date, periodicity } = observation.event;
100
+ stats.counterexamples.push({ customerId, date: date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3'), periodicity, composition: observation.composition, source, expected,
101
+ ...(isScalar(actual) ? { actual } : {}), reason: actual === undefined ? 'missing-value' : isScalar(actual) ? 'different-value' : 'non-scalar-value' });
102
+ }
103
+ }
104
+ }
105
+ if (!published)
106
+ eventsWithoutResults++;
107
+ if (options.characteristic !== undefined && !selected)
108
+ eventsWithoutSelectedCharacteristic++;
109
+ }
110
+ function report(shards) {
111
+ const mismatched = compared - matched;
112
+ const incomplete = !compared || eventsWithoutResults > 0 || [...statistics.values()].some(c => c.compared === 0);
113
+ return { status: mismatched ? 'mismatched' : incomplete ? 'incomplete' : 'matched', shards, events, eventsWithoutResults, eventsWithoutSelectedCharacteristic, compared, matched, mismatched,
114
+ characteristics: [...statistics.values()].sort((a, b) => a.characteristic < b.characteristic ? -1 : a.characteristic > b.characteristic ? 1 : 0) };
115
+ }
116
+ return { observe, report };
117
+ }
118
+ //# sourceMappingURL=validation.report.js.map