@cobol-ts/validation-execution 0.0.0-stage → 0.0.57
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 +256 -3
- package/dist/index.d.ts +41 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/src/compaction.prepare.d.ts +10 -0
- package/dist/src/compaction.prepare.js +60 -0
- package/dist/src/compaction.prepare.js.map +1 -0
- package/dist/src/compaction.project.d.ts +28 -0
- package/dist/src/compaction.project.js +81 -0
- package/dist/src/compaction.project.js.map +1 -0
- package/dist/src/compaction.project.memory.d.ts +12 -0
- package/dist/src/compaction.project.memory.js +70 -0
- package/dist/src/compaction.project.memory.js.map +1 -0
- package/dist/src/compaction.project.spec.d.ts +1 -0
- package/dist/src/compaction.project.spec.js +44 -0
- package/dist/src/compaction.project.spec.js.map +1 -0
- package/dist/src/compaction.project.storage.d.ts +21 -0
- package/dist/src/compaction.project.storage.js +3 -0
- package/dist/src/compaction.project.storage.js.map +1 -0
- package/dist/src/identification.candidate.d.ts +16 -0
- package/dist/src/identification.candidate.js +40 -0
- package/dist/src/identification.candidate.js.map +1 -0
- package/dist/src/identification.context.d.ts +8 -0
- package/dist/src/identification.context.js +3 -0
- package/dist/src/identification.context.js.map +1 -0
- package/dist/src/identification.selection.d.ts +4 -0
- package/dist/src/identification.selection.js +3 -0
- package/dist/src/identification.selection.js.map +1 -0
- package/dist/src/identified.state.publication.d.ts +14 -0
- package/dist/src/identified.state.publication.js +3 -0
- package/dist/src/identified.state.publication.js.map +1 -0
- package/dist/src/identified.state.reader.spec.d.ts +1 -0
- package/dist/src/identified.state.reader.spec.js +101 -0
- package/dist/src/identified.state.reader.spec.js.map +1 -0
- package/dist/src/identified.state.source.d.ts +20 -0
- package/dist/src/identified.state.source.js +5 -0
- package/dist/src/identified.state.source.js.map +1 -0
- package/dist/src/projected.entity.d.ts +8 -0
- package/dist/src/projected.entity.js +55 -0
- package/dist/src/projected.entity.js.map +1 -0
- package/dist/src/validation.candidate.execution.d.ts +6 -0
- package/dist/src/validation.candidate.execution.js +31 -0
- package/dist/src/validation.candidate.execution.js.map +1 -0
- package/dist/src/validation.candidate.failure.d.ts +5 -0
- package/dist/src/validation.candidate.failure.js +22 -0
- package/dist/src/validation.candidate.failure.js.map +1 -0
- package/dist/src/validation.candidate.policy.d.ts +16 -0
- package/dist/src/validation.candidate.policy.js +43 -0
- package/dist/src/validation.candidate.policy.js.map +1 -0
- package/dist/src/validation.candidate.policy.spec.d.ts +1 -0
- package/dist/src/validation.candidate.policy.spec.js +32 -0
- package/dist/src/validation.candidate.policy.spec.js.map +1 -0
- package/dist/src/validation.cursors.d.ts +23 -0
- package/dist/src/validation.cursors.js +117 -0
- package/dist/src/validation.cursors.js.map +1 -0
- package/dist/src/validation.display.d.ts +13 -0
- package/dist/src/validation.display.js +45 -0
- package/dist/src/validation.display.js.map +1 -0
- package/dist/src/validation.display.project.d.ts +4 -0
- package/dist/src/validation.display.project.js +20 -0
- package/dist/src/validation.display.project.js.map +1 -0
- package/dist/src/validation.identification.cutoffs.spec.d.ts +1 -0
- package/dist/src/validation.identification.cutoffs.spec.js +124 -0
- package/dist/src/validation.identification.cutoffs.spec.js.map +1 -0
- package/dist/src/validation.identification.execution.d.ts +11 -0
- package/dist/src/validation.identification.execution.js +36 -0
- package/dist/src/validation.identification.execution.js.map +1 -0
- package/dist/src/validation.identification.inspect.recovered.d.ts +9 -0
- package/dist/src/validation.identification.inspect.recovered.js +101 -0
- package/dist/src/validation.identification.inspect.recovered.js.map +1 -0
- package/dist/src/validation.identification.materialise.d.ts +26 -0
- package/dist/src/validation.identification.materialise.js +67 -0
- package/dist/src/validation.identification.materialise.js.map +1 -0
- package/dist/src/validation.identification.observation.d.ts +15 -0
- package/dist/src/validation.identification.observation.js +51 -0
- package/dist/src/validation.identification.observation.js.map +1 -0
- package/dist/src/validation.identification.observation.spec.d.ts +1 -0
- package/dist/src/validation.identification.observation.spec.js +29 -0
- package/dist/src/validation.identification.observation.spec.js.map +1 -0
- package/dist/src/validation.identification.physical.d.ts +26 -0
- package/dist/src/validation.identification.physical.js +79 -0
- package/dist/src/validation.identification.physical.js.map +1 -0
- package/dist/src/validation.identification.prefix.d.ts +27 -0
- package/dist/src/validation.identification.prefix.js +62 -0
- package/dist/src/validation.identification.prefix.js.map +1 -0
- package/dist/src/validation.identification.prefix.spec.d.ts +1 -0
- package/dist/src/validation.identification.prefix.spec.js +76 -0
- package/dist/src/validation.identification.prefix.spec.js.map +1 -0
- package/dist/src/validation.identification.projection.d.ts +6 -0
- package/dist/src/validation.identification.projection.js +21 -0
- package/dist/src/validation.identification.projection.js.map +1 -0
- package/dist/src/validation.identification.replay.d.ts +18 -0
- package/dist/src/validation.identification.replay.js +110 -0
- package/dist/src/validation.identification.replay.js.map +1 -0
- package/dist/src/validation.identification.satisfaction.d.ts +49 -0
- package/dist/src/validation.identification.satisfaction.js +116 -0
- package/dist/src/validation.identification.satisfaction.js.map +1 -0
- package/dist/src/validation.identification.scope.d.ts +7 -0
- package/dist/src/validation.identification.scope.js +60 -0
- package/dist/src/validation.identification.scope.js.map +1 -0
- package/dist/src/validation.identification.shard.d.ts +23 -0
- package/dist/src/validation.identification.shard.js +56 -0
- package/dist/src/validation.identification.shard.js.map +1 -0
- package/dist/src/validation.identification.strategy.d.ts +6 -0
- package/dist/src/validation.identification.strategy.js +26 -0
- package/dist/src/validation.identification.strategy.js.map +1 -0
- package/dist/src/validation.identification.strategy.spec.d.ts +1 -0
- package/dist/src/validation.identification.strategy.spec.js +31 -0
- package/dist/src/validation.identification.strategy.spec.js.map +1 -0
- package/dist/src/validation.identified.state.d.ts +34 -0
- package/dist/src/validation.identified.state.js +90 -0
- package/dist/src/validation.identified.state.js.map +1 -0
- package/dist/src/validation.investigation.d.ts +32 -0
- package/dist/src/validation.investigation.js +57 -0
- package/dist/src/validation.investigation.js.map +1 -0
- package/dist/src/validation.layouts.d.ts +26 -0
- package/dist/src/validation.layouts.js +78 -0
- package/dist/src/validation.layouts.js.map +1 -0
- package/dist/src/validation.manifest.reader.d.ts +16 -0
- package/dist/src/validation.manifest.reader.js +37 -0
- package/dist/src/validation.manifest.reader.js.map +1 -0
- package/dist/src/validation.observation.d.ts +58 -0
- package/dist/src/validation.observation.js +234 -0
- package/dist/src/validation.observation.js.map +1 -0
- package/dist/src/validation.oracle.dependencies.d.ts +29 -0
- package/dist/src/validation.oracle.dependencies.js +108 -0
- package/dist/src/validation.oracle.dependencies.js.map +1 -0
- package/dist/src/validation.oracle.dependencies.spec.d.ts +1 -0
- package/dist/src/validation.oracle.dependencies.spec.js +40 -0
- package/dist/src/validation.oracle.dependencies.spec.js.map +1 -0
- package/dist/src/validation.project.access.d.ts +23 -0
- package/dist/src/validation.project.access.js +13 -0
- package/dist/src/validation.project.access.js.map +1 -0
- package/dist/src/validation.reader.d.ts +17 -0
- package/dist/src/validation.reader.js +181 -0
- package/dist/src/validation.reader.js.map +1 -0
- package/dist/src/validation.reader.types.d.ts +23 -0
- package/dist/src/validation.reader.types.js +3 -0
- package/dist/src/validation.reader.types.js.map +1 -0
- package/dist/src/validation.recovered.shard.d.ts +8 -0
- package/dist/src/validation.recovered.shard.js +3 -0
- package/dist/src/validation.recovered.shard.js.map +1 -0
- package/dist/src/validation.reference.d.ts +5 -0
- package/dist/src/validation.reference.js +3 -0
- package/dist/src/validation.reference.js.map +1 -0
- package/dist/src/validation.replay.d.ts +27 -0
- package/dist/src/validation.replay.js +137 -0
- package/dist/src/validation.replay.js.map +1 -0
- package/dist/src/validation.report.d.ts +59 -0
- package/dist/src/validation.report.js +118 -0
- package/dist/src/validation.report.js.map +1 -0
- package/dist/src/validation.report.spec.d.ts +1 -0
- package/dist/src/validation.report.spec.js +75 -0
- package/dist/src/validation.report.spec.js.map +1 -0
- package/dist/src/validation.run.d.ts +10 -0
- package/dist/src/validation.run.js +20 -0
- package/dist/src/validation.run.js.map +1 -0
- package/dist/src/validation.run.project.d.ts +5 -0
- package/dist/src/validation.run.project.js +57 -0
- package/dist/src/validation.run.project.js.map +1 -0
- package/dist/src/validation.sequence.d.ts +11 -0
- package/dist/src/validation.sequence.js +59 -0
- package/dist/src/validation.sequence.js.map +1 -0
- package/dist/src/validation.sources.d.ts +11 -0
- package/dist/src/validation.sources.js +3 -0
- package/dist/src/validation.sources.js.map +1 -0
- package/dist/src/validation.sources.spec.d.ts +1 -0
- package/dist/src/validation.sources.spec.js +36 -0
- package/dist/src/validation.sources.spec.js.map +1 -0
- package/dist/src/validation.synchronous.spec.d.ts +1 -0
- package/dist/src/validation.synchronous.spec.js +173 -0
- package/dist/src/validation.synchronous.spec.js.map +1 -0
- package/index.ts +48 -0
- package/package.json +79 -3
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.inspectRecoveredIdentificationWith = inspectRecoveredIdentificationWith;
|
|
4
|
+
const composition_definition_1 = require("@cobol-ts/composition-definition");
|
|
5
|
+
const system_identification_1 = require("@cobol-ts/system-identification");
|
|
6
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
7
|
+
const validation_reader_1 = require("./validation.reader");
|
|
8
|
+
const validation_reader_2 = require("./validation.reader");
|
|
9
|
+
const validation_identification_observation_1 = require("./validation.identification.observation");
|
|
10
|
+
const validation_identification_projection_1 = require("./validation.identification.projection");
|
|
11
|
+
const validation_identification_replay_1 = require("./validation.identification.replay");
|
|
12
|
+
const project_execution_1 = require("@cobol-ts/project-execution");
|
|
13
|
+
const validation_identification_scope_1 = require("./validation.identification.scope");
|
|
14
|
+
const validation_identification_prefix_1 = require("./validation.identification.prefix");
|
|
15
|
+
/** Inspect one entity only. This is the diagnostic path, not the batch hot path. */
|
|
16
|
+
async function inspectRecoveredIdentificationWith(configDirectory, recovered, read, yaml, context, pair, entity, targets, reference, defaults = {}, validateSatisfaction = true) {
|
|
17
|
+
const layouts = context.schemas.map(s => ({ ...s, projection: (0, validation_identification_projection_1.logicalProjection)(s.projection) }));
|
|
18
|
+
const projections = new Map(layouts.map(s => [s.name, s.projection]));
|
|
19
|
+
const start = (0, errors_1.valueOrThrow)((0, system_identification_1.prepareStreamingSystemIdentification)(context.business, pair.evidence, pair.identification, layouts, targets));
|
|
20
|
+
const session = start(), events = [];
|
|
21
|
+
const metadata = (0, errors_1.valueOrThrow)(await (0, composition_definition_1.readCompositionNames)(yaml, configDirectory, 'files.yaml', read)).filter(c => c.type === 'relational');
|
|
22
|
+
const missing = (0, errors_1.valueOrThrow)((0, system_identification_1.discoverIdentificationRequirements)(context.business)).filter(r => !targets.includes(r.name)).map(r => r.name);
|
|
23
|
+
const replay = missing.length ? undefined : (0, validation_identification_replay_1.prepareIdentificationReplay)(context.business, reference);
|
|
24
|
+
// Satisfaction is scoped to published consumers of the selected seeds, not
|
|
25
|
+
// unrelated characteristics or unidentified historical state.
|
|
26
|
+
let fitting, outputs = [];
|
|
27
|
+
let satisfactionError;
|
|
28
|
+
if (validateSatisfaction)
|
|
29
|
+
try {
|
|
30
|
+
const published = context.published ?? [...new Set(context.schemas.flatMap(({ projection }) => Object.keys(projection.output?.type === 'object' ? projection.output.fields : {})))];
|
|
31
|
+
const scope = (0, validation_identification_scope_1.identificationReplayScope)(context.business, targets, published);
|
|
32
|
+
fitting = (0, validation_identification_replay_1.prepareIdentificationReplay)(scope.graph, reference);
|
|
33
|
+
outputs = scope.outputs;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
satisfactionError = String(error);
|
|
37
|
+
}
|
|
38
|
+
const history = [];
|
|
39
|
+
const score = fitting ? (0, validation_identification_prefix_1.prefixSatisfaction)(fitting, outputs, history) : undefined;
|
|
40
|
+
let replayError = missing.length ? `Missing identification targets: ${missing.join(', ')}` : undefined;
|
|
41
|
+
let before = (0, errors_1.valueOrThrow)(session.evidenceValues());
|
|
42
|
+
const inspect = () => {
|
|
43
|
+
const result = session.inspect();
|
|
44
|
+
const input = Object.fromEntries(Object.entries(before).map(([name, ring]) => [name,
|
|
45
|
+
Array.from({ length: ring.count }, (_, i) => ring.values[(ring.excluded + 1 + i) % (ring.size + 1)])]));
|
|
46
|
+
return { input, values: 'value' in result.values ? result.values.value : result.partialValues,
|
|
47
|
+
errors: 'errors' in result.seed ? result.seed.errors : [], seed: 'value' in result.seed ? result.seed.value : undefined };
|
|
48
|
+
};
|
|
49
|
+
let identification;
|
|
50
|
+
await (0, validation_reader_2.scanValidationShardWith)(configDirectory, recovered, read, yaml, item => {
|
|
51
|
+
const projection = projections.get(item.composition);
|
|
52
|
+
if (!projection)
|
|
53
|
+
throw new Error(`Unknown observation composition ${item.composition}`);
|
|
54
|
+
const projected = (0, validation_identification_observation_1.projectIdentificationObservation)(item, projection), observation = projected.observation;
|
|
55
|
+
history.push(projected);
|
|
56
|
+
session.observe(item.composition, observation);
|
|
57
|
+
const after = (0, errors_1.valueOrThrow)(session.evidenceValues()), composition = metadata.find(c => c.name === item.composition);
|
|
58
|
+
const previous = before;
|
|
59
|
+
before = after;
|
|
60
|
+
// Each prefix is inspected before the next observation is gathered.
|
|
61
|
+
identification = inspect();
|
|
62
|
+
events.push({ customerId: entity, date: observation.date, periodicity: observation.periodicity, composition: item.composition,
|
|
63
|
+
colour: composition?.colour, icon: composition?.icon, input: observation, expected: observation.output, accumulatorIn: previous, accumulatorOut: after, identification,
|
|
64
|
+
...(validateSatisfaction ? { satisfaction: satisfactionError ? { status: 'unavailable', error: satisfactionError } : score?.(identification.seed) } : {}) });
|
|
65
|
+
}, (event, keyType) => { const order = (0, validation_reader_1.compareManifestIds)(event.customerId, entity, keyType); return order < 0 ? 'skip' : order > 0 ? 'stop' : 'read'; }, replay || fitting ? async (definition, sources) => {
|
|
66
|
+
if (fitting && !satisfactionError)
|
|
67
|
+
try {
|
|
68
|
+
await fitting.prepare(definition, sources);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
satisfactionError = String(error);
|
|
72
|
+
}
|
|
73
|
+
if (!replay || replayError)
|
|
74
|
+
return undefined;
|
|
75
|
+
try {
|
|
76
|
+
return await replay.prepare(definition, sources);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
replayError = String(error);
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
} : undefined);
|
|
83
|
+
if (!identification)
|
|
84
|
+
throw new Error(`No validation observations for entity ${entity}`);
|
|
85
|
+
let businessEvents;
|
|
86
|
+
if (replay && !replayError && identification.seed !== undefined) {
|
|
87
|
+
try {
|
|
88
|
+
const execute = replay.startInspection({ ...defaults, ...identification.seed });
|
|
89
|
+
businessEvents = history.map((item, index) => {
|
|
90
|
+
const { identification: _investigation, satisfaction: _satisfaction, ...event } = events[index];
|
|
91
|
+
return { ...event, input: item.observation.input, expected: item.expected, ...execute(item) };
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
replayError = String(error);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// The JSON conversion is exclusively a display boundary; computation has already completed with native types.
|
|
99
|
+
return JSON.parse((0, project_execution_1.stringifyCelJson)({ events, businessEvents, replayError, identification }));
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=validation.identification.inspect.recovered.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.identification.inspect.recovered.js","sourceRoot":"","sources":["../../src/validation.identification.inspect.recovered.ts"],"names":[],"mappings":";;AAmBA,gFA+DC;AAjFD,6EAAiG;AACjG,2EAAuH;AACvH,6CAA6C;AAG7C,2DAAsD;AACtD,2DAAkF;AAClF,mGAAgI;AAChI,iGAAwE;AACxE,yFAA8E;AAE9E,mEAA4D;AAC5D,uFAA2E;AAC3E,yFAAqE;AAIrE,oFAAoF;AAC7E,KAAK,UAAU,kCAAkC,CAAC,eAAsB,EAAC,SAA2B,EAAC,IAAsB,EAAC,IAAe,EAAC,OAA6B,EAC5K,IAA4B,EAAC,MAAa,EAAC,OAAyB,EAAC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Ac,CAAC,IAAI,EAAC,CAAC,CAAA;YAC1E,cAAc,GAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAC,KAAK,EAAC,EAAE;gBACrC,MAAM,EAAC,cAAc,EAAE,cAAc,EAAC,YAAY,EAAE,aAAa,EAAC,GAAG,KAAK,EAAC,GAAC,MAAM,CAAC,KAAK,CAAE,CAAA;gBAC1F,OAAO,EAAC,GAAG,KAAK,EAAC,KAAK,EAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAC,QAAQ,EAAC,IAAI,CAAC,QAAQ,EAAC,GAAG,OAAO,CAAC,IAAI,CAAC,EAAC,CAAA;YAC1F,CAAC,CAAC,CAAA;QACN,CAAC;QAAA,OAAM,KAAK,EAAC,CAAC;YAAA,WAAW,GAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAAA,CAAC;IAC5C,CAAC;IACD,8GAA8G;IAC9G,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,oCAAgB,EAAC,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,cAAc,EAAC,CAAC,CAAC,CAAA;AAC3F,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type AccumulatorInitial } from '@cobol-ts/cel-graph-runtime';
|
|
2
|
+
import type { IndexedGraphRecord } from '@cobol-ts/cursor-loader-indexed-graph-state';
|
|
3
|
+
import type { IdentificationContext } from './identification.context';
|
|
4
|
+
import type { IdentificationCandidate } from './identification.candidate';
|
|
5
|
+
import type { IdentificationReplay } from './validation.identification.replay';
|
|
6
|
+
import { type ReadConfiguration } from './validation.reader';
|
|
7
|
+
import type { ValidationSources } from './validation.sources';
|
|
8
|
+
import type { identificationSatisfaction } from './validation.identification.satisfaction';
|
|
9
|
+
/** Preparation is once per project; the output schema contains only historical
|
|
10
|
+
* requirements, never unrelated graph results or derived caches. */
|
|
11
|
+
export declare function prepareIdentificationMaterialisation(context: IdentificationContext, candidate: IdentificationCandidate): {
|
|
12
|
+
start: () => import("@cobol-ts/system-identification").InspectableIdentificationSession;
|
|
13
|
+
schema: import("@cobol-ts/cursor-loader-indexed-graph-state").IndexedGraphSchema;
|
|
14
|
+
graph: import("@cobol-ts/cel-graph-runtime").AuthoringGraph;
|
|
15
|
+
outputs: string[];
|
|
16
|
+
projections: Map<string, Readonly<Record<string, import("@cobol-ts/cursor-loader-types").ProjectionNodeAuthoring>>>;
|
|
17
|
+
record: (id: string, seed: AccumulatorInitial) => IndexedGraphRecord;
|
|
18
|
+
};
|
|
19
|
+
type Prepared = ReturnType<typeof prepareIdentificationMaterialisation>;
|
|
20
|
+
/** One scan, one owned history, one binary row per entity. The caller must
|
|
21
|
+
* discard all written rows if joint satisfaction or scan integrity fails. */
|
|
22
|
+
export declare function materialiseIdentificationShardWith(configDirectory: string, recovered: ValidationSources, read: ReadConfiguration, yaml: import('@cobol-ts/yaml').YamlParser, prepared: Prepared, replay: IdentificationReplay, statistics: ReturnType<typeof identificationSatisfaction>, write: (state: IndexedGraphRecord) => void): Promise<{
|
|
23
|
+
entities: number;
|
|
24
|
+
firstDate: null;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareIdentificationMaterialisation = prepareIdentificationMaterialisation;
|
|
4
|
+
exports.materialiseIdentificationShardWith = materialiseIdentificationShardWith;
|
|
5
|
+
const system_identification_1 = require("@cobol-ts/system-identification");
|
|
6
|
+
const cel_graph_runtime_1 = require("@cobol-ts/cel-graph-runtime");
|
|
7
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
8
|
+
const project_execution_1 = require("@cobol-ts/project-execution");
|
|
9
|
+
const validation_identification_scope_1 = require("./validation.identification.scope");
|
|
10
|
+
const validation_identification_projection_1 = require("./validation.identification.projection");
|
|
11
|
+
const validation_identification_observation_1 = require("./validation.identification.observation");
|
|
12
|
+
const validation_reader_1 = require("./validation.reader");
|
|
13
|
+
const validation_identified_state_1 = require("./validation.identified.state");
|
|
14
|
+
/** Preparation is once per project; the output schema contains only historical
|
|
15
|
+
* requirements, never unrelated graph results or derived caches. */
|
|
16
|
+
function prepareIdentificationMaterialisation(context, candidate) {
|
|
17
|
+
const schemas = context.schemas.map(s => ({ ...s, projection: (0, validation_identification_projection_1.logicalProjection)(s.projection) }));
|
|
18
|
+
const schema = (0, validation_identified_state_1.identifiedSchema)(context.business);
|
|
19
|
+
const names = schema.nodes.map(n => n.name);
|
|
20
|
+
const start = (0, errors_1.valueOrThrow)((0, system_identification_1.prepareStreamingSystemIdentification)(context.business, candidate.evidence, candidate.identification, schemas));
|
|
21
|
+
const { graph, outputs } = (0, validation_identification_scope_1.identificationReplayScope)(context.business, names, context.published ?? []);
|
|
22
|
+
const canonical = (0, errors_1.valueOrThrow)((0, cel_graph_runtime_1.canonicaliseCelGraph)(context.business));
|
|
23
|
+
const projections = new Map(schemas.map(s => [s.name, s.projection]));
|
|
24
|
+
function record(id, seed) {
|
|
25
|
+
if (!/^(?:0|-?[1-9]\d*)$/.test(id))
|
|
26
|
+
throw new Error('Identified state requires integer customer identities');
|
|
27
|
+
const state = (0, project_execution_1.indexedStateFromInitial)(schema, (0, errors_1.valueOrThrow)((0, cel_graph_runtime_1.validateInitialAccumulator)(seed, context.business, canonical)));
|
|
28
|
+
state.customerId = BigInt(id);
|
|
29
|
+
return state;
|
|
30
|
+
}
|
|
31
|
+
return { start, schema, graph, outputs, projections, record };
|
|
32
|
+
}
|
|
33
|
+
/** One scan, one owned history, one binary row per entity. The caller must
|
|
34
|
+
* discard all written rows if joint satisfaction or scan integrity fails. */
|
|
35
|
+
async function materialiseIdentificationShardWith(configDirectory, recovered, read, yaml, prepared, replay, statistics, write) {
|
|
36
|
+
let history = [], entities = 0, firstDate = null;
|
|
37
|
+
function finish() {
|
|
38
|
+
if (!history.length)
|
|
39
|
+
return;
|
|
40
|
+
const session = prepared.start();
|
|
41
|
+
for (const item of history)
|
|
42
|
+
session.observe(item.composition, item.observation);
|
|
43
|
+
const seed = statistics.recordSeed(session.finish());
|
|
44
|
+
if (seed !== undefined) {
|
|
45
|
+
statistics.beginReplay();
|
|
46
|
+
const evaluate = replay.start(seed);
|
|
47
|
+
for (const item of history)
|
|
48
|
+
statistics.observe(item, evaluate(item));
|
|
49
|
+
write(prepared.record(history[0].event.customerId, seed));
|
|
50
|
+
}
|
|
51
|
+
entities++;
|
|
52
|
+
history = [];
|
|
53
|
+
}
|
|
54
|
+
await (0, validation_reader_1.scanValidationShardWith)(configDirectory, recovered, read, yaml, observation => {
|
|
55
|
+
if (history.length && history[0].event.customerId !== observation.event.customerId)
|
|
56
|
+
finish();
|
|
57
|
+
const projection = prepared.projections.get(observation.composition);
|
|
58
|
+
if (!projection)
|
|
59
|
+
throw new Error('Validation composition is absent from identification snapshot');
|
|
60
|
+
history.push((0, validation_identification_observation_1.projectIdentificationObservation)(observation, projection));
|
|
61
|
+
if (firstDate === null || observation.event.date < firstDate)
|
|
62
|
+
firstDate = observation.event.date;
|
|
63
|
+
}, undefined, replay.prepare);
|
|
64
|
+
finish();
|
|
65
|
+
return { entities, firstDate };
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=validation.identification.materialise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.identification.materialise.js","sourceRoot":"","sources":["../../src/validation.identification.materialise.ts"],"names":[],"mappings":";;AAkBA,oFAeC;AAID,gFAyBC;AA9DD,2EAAoF;AACpF,mEAAmH;AAEnH,6CAA6C;AAC7C,mEAAmE;AAGnE,uFAA2E;AAE3E,iGAAwE;AACxE,mGAAgI;AAChI,2DAAkF;AAGlF,+EAA8D;AAE9D;oEACoE;AACpE,SAAgB,oCAAoC,CAAC,OAA6B,EAAC,SAAiC;IAChH,MAAM,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,EAAC,GAAG,CAAC,EA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,IAAI,EAAC,WAAW,CAAA,EAAE;QAC3E,IAAG,OAAO,CAAC,MAAM,IAAE,OAAO,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,UAAU,KAAG,WAAW,CAAC,KAAK,CAAC,UAAU;YAAC,MAAM,EAAE,CAAA;QACvF,MAAM,UAAU,GAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC,CAAA;QAClE,IAAG,CAAC,UAAU;YAAC,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;QAC/F,OAAO,CAAC,IAAI,CAAC,IAAA,wEAAgC,EAAC,WAAW,EAAC,UAAU,CAAC,CAAC,CAAA;QACtE,IAAG,SAAS,KAAG,IAAI,IAAE,WAAW,CAAC,KAAK,CAAC,IAAI,GAAC,SAAS;YAAC,SAAS,GAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAA;IAC1F,CAAC,EAAC,SAAS,EAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC3B,MAAM,EAAE,CAAA;IACR,OAAO,EAAC,QAAQ,EAAC,SAAS,EAAC,CAAA;AAC/B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Observation } from '@cobol-ts/system-identification';
|
|
2
|
+
import type { ProjectionAuthoring } from '@cobol-ts/cursor-loader-types';
|
|
3
|
+
import type { ValidationObservation } from './validation.reader';
|
|
4
|
+
export type IdentificationObservation<T> = Pick<ValidationObservation, 'event' | 'composition' | 'expected'> & {
|
|
5
|
+
readonly observation: T;
|
|
6
|
+
};
|
|
7
|
+
export type ProjectedIdentificationObservation = IdentificationObservation<Observation>;
|
|
8
|
+
/** Snapshot types are the contract for the evidence graph, not inferred from
|
|
9
|
+
* individual CSV values. Do not coerce empty fields or conflicting results. */
|
|
10
|
+
export declare function identificationObservation(observation: ValidationObservation, projection: ProjectionAuthoring): Observation;
|
|
11
|
+
/** Decode published scalars exactly once, independently of physical input access. */
|
|
12
|
+
export declare function identificationMetadata(observation: ValidationObservation, projection: ProjectionAuthoring): Pick<Observation, 'date' | 'periodicity' | 'output'>;
|
|
13
|
+
/** No borrowed row or physical lease escapes the visitor. Published results are
|
|
14
|
+
* detached snapshots from the reader, retained in their original format for comparison. */
|
|
15
|
+
export declare function projectIdentificationObservation(observation: ValidationObservation, projection: ProjectionAuthoring): ProjectedIdentificationObservation;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.identificationObservation = identificationObservation;
|
|
4
|
+
exports.identificationMetadata = identificationMetadata;
|
|
5
|
+
exports.projectIdentificationObservation = projectIdentificationObservation;
|
|
6
|
+
const validation_identification_projection_1 = require("./validation.identification.projection");
|
|
7
|
+
/** Snapshot types are the contract for the evidence graph, not inferred from
|
|
8
|
+
* individual CSV values. Do not coerce empty fields or conflicting results. */
|
|
9
|
+
function identificationObservation(observation, projection) {
|
|
10
|
+
const input = (0, validation_identification_projection_1.ownedProjectedInput)(observation.sources, observation.row);
|
|
11
|
+
const { date, periodicity, output } = identificationMetadata(observation, projection);
|
|
12
|
+
return { date, periodicity, input: input, output };
|
|
13
|
+
}
|
|
14
|
+
/** Decode published scalars exactly once, independently of physical input access. */
|
|
15
|
+
function identificationMetadata(observation, projection) {
|
|
16
|
+
const schema = projection.output;
|
|
17
|
+
if (schema?.type !== 'object')
|
|
18
|
+
throw new Error('Identification requires a published output schema');
|
|
19
|
+
const output = {};
|
|
20
|
+
for (const [filename, raw] of Object.entries(observation.expected)) {
|
|
21
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
22
|
+
throw new Error('Invalid published result row');
|
|
23
|
+
for (const [name, field] of Object.entries(schema.fields)) {
|
|
24
|
+
if (!Object.hasOwn(raw, name))
|
|
25
|
+
continue;
|
|
26
|
+
const incoming = raw[name];
|
|
27
|
+
let value = incoming;
|
|
28
|
+
if (filename.endsWith('.csv') && typeof incoming === 'string' && (field.type === 'integer' || field.type === 'float')) {
|
|
29
|
+
if (!/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/.test(incoming))
|
|
30
|
+
throw new Error(`Invalid published numeric value for ${name}`);
|
|
31
|
+
value = Number(incoming);
|
|
32
|
+
}
|
|
33
|
+
if (value !== null && !(field.type === 'string' && typeof value === 'string') &&
|
|
34
|
+
!(field.type === 'integer' && typeof value === 'number' && Number.isSafeInteger(value)) &&
|
|
35
|
+
!(field.type === 'float' && typeof value === 'number' && Number.isFinite(value)))
|
|
36
|
+
throw new Error(`Invalid published scalar for ${name}`);
|
|
37
|
+
if (Object.hasOwn(output, name) && output[name] !== value)
|
|
38
|
+
throw new Error(`Conflicting published values for ${name}`);
|
|
39
|
+
output[name] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { date: observation.event.date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3'), periodicity: observation.event.periodicity,
|
|
43
|
+
output };
|
|
44
|
+
}
|
|
45
|
+
/** No borrowed row or physical lease escapes the visitor. Published results are
|
|
46
|
+
* detached snapshots from the reader, retained in their original format for comparison. */
|
|
47
|
+
function projectIdentificationObservation(observation, projection) {
|
|
48
|
+
return { event: observation.event, composition: observation.composition, expected: observation.expected,
|
|
49
|
+
observation: identificationObservation(observation, projection) };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=validation.identification.observation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.identification.observation.js","sourceRoot":"","sources":["../../src/validation.identification.observation.ts"],"names":[],"mappings":";;AAUA,8DAIC;AAGD,wDAuBC;AAKD,4EAGC;AA7CD,iGAA0E;AAK1E;+EAC+E;AAC/E,SAAgB,yBAAyB,CAAC,WAAkC,EAAE,UAA+B;IACzG,MAAM,KAAK,GAAG,IAAA,0DAAmB,EAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,CAAA;IACvE,MAAM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AC,CAAA;AACxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const validation_identification_observation_1 = require("./validation.identification.observation");
|
|
4
|
+
const projection = { output: { type: 'object', fields: {
|
|
5
|
+
total: { type: 'integer' }, rate: { type: 'float' }, label: { type: 'string' }
|
|
6
|
+
} } };
|
|
7
|
+
const row = { key: 'A', slots: [], active: true, count: () => 0, entry: () => { throw new Error('No physical inputs'); } };
|
|
8
|
+
function observation(expected, schema = projection) {
|
|
9
|
+
return (0, validation_identification_observation_1.identificationObservation)({ event: { customerId: 'A', date: '20260101', periodicity: 'tick', counts: {} },
|
|
10
|
+
composition: 'layout', sources: [], row, expected }, schema);
|
|
11
|
+
}
|
|
12
|
+
test('identification evidence preserves zero, null, absent fields and numeric CSV conversion', () => {
|
|
13
|
+
expect(observation({ 'oracle.csv': { total: '0', rate: '-1.25e2', label: '007' }, 'oracle.jsonl': { total: 0 } })).toEqual({
|
|
14
|
+
date: '2026-01-01', periodicity: 'tick', input: {}, output: { total: 0, rate: -125, label: '007' }
|
|
15
|
+
});
|
|
16
|
+
expect(observation({ 'oracle.jsonl': { total: null, ignored: 42 } }).output).toEqual({ total: null });
|
|
17
|
+
expect(observation({}).output).toEqual({});
|
|
18
|
+
});
|
|
19
|
+
test('malformed, unsafe and conflicting published values are never identification evidence', () => {
|
|
20
|
+
for (const total of ['', ' 1', 'NaN', '0x10'])
|
|
21
|
+
expect(() => observation({ 'oracle.csv': { total } })).toThrow('Invalid published numeric value for total');
|
|
22
|
+
for (const total of [1.5, Number.MAX_SAFE_INTEGER + 1, '1', false, []])
|
|
23
|
+
expect(() => observation({ 'oracle.jsonl': { total } })).toThrow('Invalid published scalar for total');
|
|
24
|
+
expect(() => observation({ 'oracle.jsonl': { rate: Infinity } })).toThrow('Invalid published scalar for rate');
|
|
25
|
+
expect(() => observation({ 'oracle.csv': { total: '1' }, 'oracle.jsonl': { total: 2 } })).toThrow('Conflicting published values for total');
|
|
26
|
+
expect(() => observation({ 'oracle.jsonl': null })).toThrow('Invalid published result row');
|
|
27
|
+
expect(() => observation({}, {})).toThrow('requires a published output schema');
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=validation.identification.observation.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.identification.observation.spec.js","sourceRoot":"","sources":["../../src/validation.identification.observation.spec.ts"],"names":[],"mappings":";;AAEA,mGAAiF;AAEjF,MAAM,UAAU,GAAwB,EAAC,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE;YACtE,KAAK,EAAE,EAAC,IAAI,EAAE,SAAS,EAAC,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,OAAO,EAAC,EAAE,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC;SAAC,EAAC,EAAC,CAAA;AAC/E,MAAM,GAAG,GAAiC,EAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA,CAAA,CAAC,EAAC,CAAA;AACnJ,SAAS,WAAW,CAAC,QAA2C,EAAE,MAAM,GAAG,UAAU;IACjF,OAAO,IAAA,iEAAyB,EAAC,EAAC,KAAK,EAAE,EAAC,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAC;QACzG,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAC,EAAE,MAAM,CAAC,CAAA;AACnE,CAAC;AAED,IAAI,CAAC,wFAAwF,EAAE,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,OAAO,CAAC,oCAAoC,CAAC,CAAA;IACtG,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAC,cAAc,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAA;IAC1G,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAC,YAAY,EAAE,EAAC,KAAK,EAAE,GAAG,EAAC,EAAE,cAAc,EAAE,EAAC,KAAK,EAAE,CAAC,EAAC,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,wCAAwC,CAAC,CAAA;IACrI,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAC,cAAc,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAA;IACzF,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,oCAAoC,CAAC,CAAA;AACnF,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type CompositeRecord, type PreparedSource } from '@cobol-ts/cursor-composition';
|
|
2
|
+
import { type ScalarAccessCompiler, type ArrayAccessCompiler } from '@cobol-ts/cel-access';
|
|
3
|
+
import { type Observation } from '@cobol-ts/system-identification';
|
|
4
|
+
import type { ProjectionAuthoring } from '@cobol-ts/cursor-loader-types';
|
|
5
|
+
import type { IdentificationContext } from './identification.context';
|
|
6
|
+
import type { IdentificationCandidate } from './identification.candidate';
|
|
7
|
+
import type { ValidationObservation, ValidationPreparation } from './validation.reader';
|
|
8
|
+
import { type IdentificationObservation } from './validation.identification.observation';
|
|
9
|
+
type PhysicalEvidence = {
|
|
10
|
+
readonly periodicity: string;
|
|
11
|
+
readonly metadata: Pick<Observation, 'date' | 'periodicity' | 'output'>;
|
|
12
|
+
readonly row: CompositeRecord;
|
|
13
|
+
};
|
|
14
|
+
export type PhysicalIdentificationObservation = IdentificationObservation<PhysicalEvidence>;
|
|
15
|
+
/** Route the observation namespace at compile time. Input fields use the original
|
|
16
|
+
* physical source accessors; metadata and decoded oracle scalars use the same
|
|
17
|
+
* logical access as inspection. No input objects or arrays are materialised. */
|
|
18
|
+
export declare function physicalEvidenceAccess(sources: readonly PreparedSource[], projection: ProjectionAuthoring): ScalarAccessCompiler<PhysicalEvidence, unknown, readonly number[]> & ArrayAccessCompiler<PhysicalEvidence, unknown, readonly number[]>;
|
|
19
|
+
/** Preflight remains data-independent. The reader binds physical layout plans
|
|
20
|
+
* before delivering the first customer that uses them. */
|
|
21
|
+
export declare function preparePhysicalIdentification(context: IdentificationContext, candidate: IdentificationCandidate, targets: readonly string[]): import("@cobol-ts/errors").ErrorsOr<{
|
|
22
|
+
start: () => import("@cobol-ts/system-identification").InspectableIdentificationSession<PhysicalEvidence>;
|
|
23
|
+
prepare: ValidationPreparation;
|
|
24
|
+
project: (item: ValidationObservation) => PhysicalIdentificationObservation;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.physicalEvidenceAccess = physicalEvidenceAccess;
|
|
4
|
+
exports.preparePhysicalIdentification = preparePhysicalIdentification;
|
|
5
|
+
const cursor_composition_1 = require("@cobol-ts/cursor-composition");
|
|
6
|
+
const cel_access_1 = require("@cobol-ts/cel-access");
|
|
7
|
+
const system_identification_1 = require("@cobol-ts/system-identification");
|
|
8
|
+
const errors_1 = require("@cobol-ts/errors");
|
|
9
|
+
const validation_identification_observation_1 = require("./validation.identification.observation");
|
|
10
|
+
const validation_identification_projection_1 = require("./validation.identification.projection");
|
|
11
|
+
/** Route the observation namespace at compile time. Input fields use the original
|
|
12
|
+
* physical source accessors; metadata and decoded oracle scalars use the same
|
|
13
|
+
* logical access as inspection. No input objects or arrays are materialised. */
|
|
14
|
+
function physicalEvidenceAccess(sources, projection) {
|
|
15
|
+
// Logical evidence allowed an optional source when present. A missing slot
|
|
16
|
+
// throws on read, just as the logical JSON accessor did for a null object.
|
|
17
|
+
const physical = (0, cursor_composition_1.compositeAccessCompiler)(sources.map(source => source.cardinality === 'optional'
|
|
18
|
+
? { ...source, cardinality: 'one' } : source));
|
|
19
|
+
const logical = (0, cel_access_1.jsonAccessCompiler)(projection);
|
|
20
|
+
return {
|
|
21
|
+
compileScalar(path) {
|
|
22
|
+
const declared = logical.compileScalar(path);
|
|
23
|
+
if ('errors' in declared)
|
|
24
|
+
return declared;
|
|
25
|
+
if (path[0] !== 'input') {
|
|
26
|
+
const compiled = declared.value;
|
|
27
|
+
return (0, errors_1.value)({ ...compiled, read: (record, indices) => compiled.read(record.metadata, indices) });
|
|
28
|
+
}
|
|
29
|
+
const resolved = physical.compileScalar(path.slice(1));
|
|
30
|
+
if ('errors' in resolved)
|
|
31
|
+
return resolved;
|
|
32
|
+
const compiled = resolved.value;
|
|
33
|
+
if (compiled.type !== declared.value.type)
|
|
34
|
+
return (0, errors_1.errors)(`Identification: incompatible input type at ${path.join('.')}`);
|
|
35
|
+
// Evidence historically used the logical numeric policy, unlike
|
|
36
|
+
// business replay which preserves physical integerStorage.
|
|
37
|
+
return (0, errors_1.value)({ ...compiled, integerStorage: declared.value.integerStorage,
|
|
38
|
+
read: (record, indices) => compiled.read(record.row, indices) });
|
|
39
|
+
},
|
|
40
|
+
compileArray(path) {
|
|
41
|
+
const declared = logical.compileArray(path);
|
|
42
|
+
if ('errors' in declared)
|
|
43
|
+
return declared;
|
|
44
|
+
if (path[0] !== 'input')
|
|
45
|
+
return (0, errors_1.errors)(`Identification: unsupported metadata array ${path.join('.')}`);
|
|
46
|
+
const resolved = physical.compileArray(path.slice(1));
|
|
47
|
+
if ('errors' in resolved)
|
|
48
|
+
return resolved;
|
|
49
|
+
const compiled = resolved.value;
|
|
50
|
+
return (0, errors_1.value)({ plan: compiled.plan, length: (record, indices) => compiled.length(record.row, indices) });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** Preflight remains data-independent. The reader binds physical layout plans
|
|
55
|
+
* before delivering the first customer that uses them. */
|
|
56
|
+
function preparePhysicalIdentification(context, candidate, targets) {
|
|
57
|
+
const layouts = context.schemas.map(schema => ({ ...schema, projection: (0, validation_identification_projection_1.logicalProjection)(schema.projection) }));
|
|
58
|
+
const projections = new Map(layouts.map(({ name, projection }) => [name, projection]));
|
|
59
|
+
const compiled = (0, system_identification_1.prepareStreamingSystemIdentificationWithAccess)(context.business, candidate.evidence, candidate.identification, layouts, targets);
|
|
60
|
+
if ('errors' in compiled)
|
|
61
|
+
return compiled;
|
|
62
|
+
const { start, prepareLayout } = compiled.value;
|
|
63
|
+
function projectionFor(name) {
|
|
64
|
+
const projection = projections.get(name);
|
|
65
|
+
if (!projection)
|
|
66
|
+
throw new Error('Validation composition is absent from identification snapshot');
|
|
67
|
+
return projection;
|
|
68
|
+
}
|
|
69
|
+
const prepare = async (definition, sources) => {
|
|
70
|
+
(0, errors_1.valueOrThrow)(prepareLayout(definition.name, physicalEvidenceAccess(sources, projectionFor(definition.name))));
|
|
71
|
+
return undefined;
|
|
72
|
+
};
|
|
73
|
+
function project(item) {
|
|
74
|
+
return { event: item.event, composition: item.composition, expected: item.expected,
|
|
75
|
+
observation: { periodicity: item.event.periodicity, metadata: (0, validation_identification_observation_1.identificationMetadata)(item, projectionFor(item.composition)), row: item.row } };
|
|
76
|
+
}
|
|
77
|
+
return (0, errors_1.value)({ start, prepare, project });
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=validation.identification.physical.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.identification.physical.js","sourceRoot":"","sources":["../../src/validation.identification.physical.ts"],"names":[],"mappings":";;AAiBA,wDAmCC;AAID,sEAoBC;AA5ED,qEAA+G;AAC/G,qDAA0I;AAC1I,2EAAgH;AAEhH,6CAA4D;AAI5D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AK,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAA,8DAAsB,EAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAC,EAAC,CAAA;IACnJ,CAAC;IACD,OAAO,IAAA,cAAK,EAAC,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAC,CAAC,CAAA;AAC3C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AccumulatorInitial } from '@cobol-ts/cel-graph-runtime';
|
|
2
|
+
import type { IdentificationReplay } from './validation.identification.replay';
|
|
3
|
+
import type { ProjectedIdentificationObservation } from './validation.identification.observation';
|
|
4
|
+
import type { ValidationObservation } from './validation.reader';
|
|
5
|
+
/** Shared chronological replay. An unchanged seed extends the existing replay;
|
|
6
|
+
* a changed seed starts again. The caller owns the history and selects its cutoff. */
|
|
7
|
+
export declare function prefixReplay<T extends Pick<ValidationObservation, 'event' | 'composition' | 'expected'>>(replay: IdentificationReplay<T>, outputs: readonly string[], history: readonly T[]): {
|
|
8
|
+
reset(): void;
|
|
9
|
+
report(): import("./validation.report").ValidationReport | undefined;
|
|
10
|
+
evaluate(seed: AccumulatorInitial, end?: number): import("./validation.report").ValidationReport;
|
|
11
|
+
};
|
|
12
|
+
/** GUI score at the currently available prefix, with local diagnostic detail. */
|
|
13
|
+
export declare function prefixSatisfaction(replay: IdentificationReplay, outputs: readonly string[], history: readonly ProjectedIdentificationObservation[]): (seed: AccumulatorInitial | undefined) => {
|
|
14
|
+
status: "unavailable";
|
|
15
|
+
error: string;
|
|
16
|
+
matched?: undefined;
|
|
17
|
+
compared?: undefined;
|
|
18
|
+
outputs?: undefined;
|
|
19
|
+
covered?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
status: "matched" | "mismatched" | "incomplete";
|
|
22
|
+
matched: number;
|
|
23
|
+
compared: number;
|
|
24
|
+
outputs: number;
|
|
25
|
+
covered: number;
|
|
26
|
+
error?: undefined;
|
|
27
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prefixReplay = prefixReplay;
|
|
4
|
+
exports.prefixSatisfaction = prefixSatisfaction;
|
|
5
|
+
const validation_report_1 = require("./validation.report");
|
|
6
|
+
/** Seeds contain only scalar values and logical arrays of scalars. Compare
|
|
7
|
+
* their values rather than their object prototypes (which can differ across realms). */
|
|
8
|
+
function sameSeed(previous, current) {
|
|
9
|
+
const entries = Object.entries(previous);
|
|
10
|
+
return entries.length === Object.keys(current).length && entries.every(([name, value]) => {
|
|
11
|
+
if (!Object.hasOwn(current, name))
|
|
12
|
+
return false;
|
|
13
|
+
const next = current[name];
|
|
14
|
+
return Array.isArray(value)
|
|
15
|
+
? Array.isArray(next) && value.length === next.length && value.every((item, i) => Object.is(item, next[i]))
|
|
16
|
+
: Object.is(value, next);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** Keep an owned snapshot even when a caller reuses its seed object or arrays. */
|
|
20
|
+
function snapshotSeed(seed) {
|
|
21
|
+
return Object.fromEntries(Object.entries(seed).map(([name, value]) => [name, Array.isArray(value) ? [...value] : value]));
|
|
22
|
+
}
|
|
23
|
+
/** Shared chronological replay. An unchanged seed extends the existing replay;
|
|
24
|
+
* a changed seed starts again. The caller owns the history and selects its cutoff. */
|
|
25
|
+
function prefixReplay(replay, outputs, history) {
|
|
26
|
+
let active;
|
|
27
|
+
return {
|
|
28
|
+
reset() { active = undefined; },
|
|
29
|
+
report() { return active?.statistics.report(0); },
|
|
30
|
+
evaluate(seed, end = history.length) {
|
|
31
|
+
if (!active || !sameSeed(active.seed, seed) || end < active.next) {
|
|
32
|
+
active = undefined;
|
|
33
|
+
active = { seed: snapshotSeed(seed), evaluate: replay.start(seed), statistics: (0, validation_report_1.validationStatistics)(outputs, { maxCounterexamples: 0 }), next: 0 };
|
|
34
|
+
}
|
|
35
|
+
while (active.next < end) {
|
|
36
|
+
const item = history[active.next++];
|
|
37
|
+
active.statistics.observe(item, active.evaluate(item));
|
|
38
|
+
}
|
|
39
|
+
return active.statistics.report(0);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** GUI score at the currently available prefix, with local diagnostic detail. */
|
|
44
|
+
function prefixSatisfaction(replay, outputs, history) {
|
|
45
|
+
const runner = prefixReplay(replay, outputs, history);
|
|
46
|
+
return (seed) => {
|
|
47
|
+
if (seed === undefined) {
|
|
48
|
+
runner.reset();
|
|
49
|
+
return { status: 'unavailable', error: 'No executable candidate' };
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const { status, matched, compared, characteristics } = runner.evaluate(seed);
|
|
53
|
+
const covered = characteristics.filter(c => c.compared > 0).length;
|
|
54
|
+
return { status, matched, compared, outputs: outputs.length, covered };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
runner.reset();
|
|
58
|
+
return { status: 'unavailable', error: String(error) };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=validation.identification.prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.identification.prefix.js","sourceRoot":"","sources":["../../src/validation.identification.prefix.ts"],"names":[],"mappings":";;AA0BA,oCAiBC;AAGD,gDAUC;AApDD,2DAAwD;AAExD;wFACwF;AACxF,SAAS,QAAQ,CAAC,QAA4B,EAAE,OAA2B;IACvE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACrF,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAA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