@cobol-ts/cobolts 0.0.16 → 0.0.18
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 +301 -19
- package/dist/src/benchmark.composed.runner.js +1 -1
- package/dist/src/benchmark.composed.runner.js.map +1 -1
- package/dist/src/cli.js +4 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/ai.d.ts +12 -0
- package/dist/src/commands/ai.demo.spec.d.ts +1 -0
- package/dist/src/commands/ai.demo.spec.js +242 -0
- package/dist/src/commands/ai.demo.spec.js.map +1 -0
- package/dist/src/commands/ai.js +125 -0
- package/dist/src/commands/ai.js.map +1 -0
- package/dist/src/commands/ai.spec.d.ts +1 -0
- package/dist/src/commands/ai.spec.js +170 -0
- package/dist/src/commands/ai.spec.js.map +1 -0
- package/dist/src/commands/characteristics.js +70 -20
- package/dist/src/commands/characteristics.js.map +1 -1
- package/dist/src/commands/characteristics.spec.js +157 -24
- package/dist/src/commands/characteristics.spec.js.map +1 -1
- package/dist/src/commands/extract.spec.js +54 -54
- package/dist/src/commands/graph.d.ts +9 -0
- package/dist/src/commands/graph.js +98 -0
- package/dist/src/commands/graph.js.map +1 -0
- package/dist/src/commands/graph.report.d.ts +26 -0
- package/dist/src/commands/graph.report.js +75 -0
- package/dist/src/commands/graph.report.js.map +1 -0
- package/dist/src/commands/graph.spec.d.ts +1 -0
- package/dist/src/commands/graph.spec.js +215 -0
- package/dist/src/commands/graph.spec.js.map +1 -0
- package/dist/src/context.d.ts +3 -0
- package/dist/src/context.js +12 -4
- package/dist/src/context.js.map +1 -1
- package/dist/src/indexed.accumulator.d.ts +2 -2
- package/dist/src/indexed.accumulator.js +6 -1
- package/dist/src/indexed.accumulator.js.map +1 -1
- package/dist/src/indexed.accumulator.spec.js +9 -2
- package/dist/src/indexed.accumulator.spec.js.map +1 -1
- package/package.json +26 -23
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.graphsFromExperiments = graphsFromExperiments;
|
|
4
|
+
exports.addGraph = addGraph;
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const cel_graph_runtime_1 = require("@cobol-ts/cel-graph-runtime");
|
|
7
|
+
const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
|
|
8
|
+
const characteristics_yaml_1 = require("@cobol-ts/characteristics-yaml");
|
|
9
|
+
const graph_report_1 = require("./graph.report");
|
|
10
|
+
function mapping(value, label) {
|
|
11
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
12
|
+
throw new Error(`${label}: expected a YAML mapping`);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function parseYaml(source, filename) {
|
|
16
|
+
const result = yaml_jsyaml_1.jsYamlParser.parse(source);
|
|
17
|
+
if ('errors' in result)
|
|
18
|
+
throw new Error(`${filename}: ${result.errors.join('; ')}`);
|
|
19
|
+
return result.value;
|
|
20
|
+
}
|
|
21
|
+
function authoringGraph(source, name) {
|
|
22
|
+
const parsed = (0, cel_graph_runtime_1.parseAuthoringGraph)(source, yaml_jsyaml_1.jsYamlParser);
|
|
23
|
+
if ('errors' in parsed)
|
|
24
|
+
throw new Error(`${name}: ${parsed.errors.join('; ')}`);
|
|
25
|
+
return parsed.value;
|
|
26
|
+
}
|
|
27
|
+
/** Parse the versioned experiment dossier, but compose only its graphs. All
|
|
28
|
+
* generation, metadata, findings and execution history remain in the dossier. */
|
|
29
|
+
function graphsFromExperiments(document, filename) {
|
|
30
|
+
const root = mapping(document, filename);
|
|
31
|
+
if (root.version !== 1)
|
|
32
|
+
throw new Error(`${filename}: expected experiment document version 1`);
|
|
33
|
+
if (!Array.isArray(root.experiments))
|
|
34
|
+
throw new Error(`${filename}.experiments: expected an array`);
|
|
35
|
+
return root.experiments.map((raw, index) => {
|
|
36
|
+
const location = `${filename}.experiments[${index}]`;
|
|
37
|
+
const entry = mapping(raw, location);
|
|
38
|
+
if (typeof entry.characteristic !== 'string' || !entry.characteristic.trim())
|
|
39
|
+
throw new Error(`${location}.characteristic: expected a nonempty string`);
|
|
40
|
+
const id = entry.characteristic.trim();
|
|
41
|
+
const graph = mapping(entry.graph, `${location}.graph`);
|
|
42
|
+
if (!Object.prototype.hasOwnProperty.call(graph, id))
|
|
43
|
+
throw new Error(`${location}.graph: missing output node '${id}'`);
|
|
44
|
+
return {
|
|
45
|
+
name: `${filename}#${id}`,
|
|
46
|
+
graph: authoringGraph((0, characteristics_yaml_1.stringifyCharacteristicMetadata)(graph, 'yaml'), `${location}.graph`)
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Pure graph composition is in the graph runtime; the CLI only locates inputs,
|
|
51
|
+
* extracts fragments, and serialises the same authoring format as graph.yaml. */
|
|
52
|
+
function addGraph(root, services, options) {
|
|
53
|
+
const graph = root.command('graph').description('Compose graph.yaml authoring graphs from different sources');
|
|
54
|
+
graph.command('build')
|
|
55
|
+
.description('Build graph.yaml authoring nodes from an experiment dossier and optional existing graphs')
|
|
56
|
+
.argument('<experiments>', 'Versioned experiment YAML file (relative to the current directory)')
|
|
57
|
+
.option('--with <filename>', 'Include an existing graph.yaml (repeatable)', (value, previous) => [...previous, value], [])
|
|
58
|
+
.option('--file <filename>', 'Write the assembled graph YAML instead of stdout')
|
|
59
|
+
.option('--report', 'Report included and missing output characteristics to stderr')
|
|
60
|
+
.option('--detailed', 'Include IDs in each report category and node counts by source (implies --report)')
|
|
61
|
+
.action(async (experiments, flags) => {
|
|
62
|
+
const sources = [];
|
|
63
|
+
for (const filename of flags.with) {
|
|
64
|
+
const path = (0, node_path_1.resolve)(filename);
|
|
65
|
+
sources.push({ name: path, graph: authoringGraph(await services.read(path), path) });
|
|
66
|
+
}
|
|
67
|
+
const existing = [...sources];
|
|
68
|
+
const filename = (0, node_path_1.resolve)(experiments);
|
|
69
|
+
const generated = graphsFromExperiments(parseYaml(await services.read(filename), filename), filename);
|
|
70
|
+
sources.push(...generated);
|
|
71
|
+
const merged = (0, cel_graph_runtime_1.composeAuthoringGraphs)(sources);
|
|
72
|
+
if (Object.keys(merged).length === 0)
|
|
73
|
+
throw new Error('Cannot build an empty graph');
|
|
74
|
+
// Verify the assembled authoring graph, not only its individual sources.
|
|
75
|
+
const content = (0, characteristics_yaml_1.stringifyCharacteristicMetadata)(merged, 'yaml');
|
|
76
|
+
const authored = authoringGraph(content, 'Composed graph');
|
|
77
|
+
const canonical = (0, cel_graph_runtime_1.canonicaliseCelGraph)(authored);
|
|
78
|
+
if ('errors' in canonical)
|
|
79
|
+
throw new Error(`Composed graph: ${canonical.errors.join('; ')}`);
|
|
80
|
+
const planned = (0, cel_graph_runtime_1.planCanonicalCelGraph)(canonical.value);
|
|
81
|
+
if ('errors' in planned)
|
|
82
|
+
throw new Error(`Composed graph: ${planned.errors.join('; ')}`);
|
|
83
|
+
let report;
|
|
84
|
+
if (flags.report || flags.detailed) {
|
|
85
|
+
const paths = await services.paths(options());
|
|
86
|
+
const catalogues = await (0, characteristics_yaml_1.loadCharacteristicCatalogues)(paths.directory, services.read, yaml_jsyaml_1.jsYamlParser);
|
|
87
|
+
const overview = (0, graph_report_1.describeGraphBuild)(catalogues.output.list().map(item => item.id), merged, existing, generated, filename);
|
|
88
|
+
report = (0, graph_report_1.formatGraphBuildReport)(overview, flags.detailed);
|
|
89
|
+
}
|
|
90
|
+
if (flags.file === undefined)
|
|
91
|
+
services.output(content.trimEnd());
|
|
92
|
+
else
|
|
93
|
+
await services.write((0, node_path_1.resolve)(flags.file), content);
|
|
94
|
+
if (report !== undefined)
|
|
95
|
+
services.diagnostic(report);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../../src/commands/graph.ts"],"names":[],"mappings":";;AAsCA,sDAkBC;AAID,4BAwC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,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;;YAC3D,MAAM,QAAQ,CAAC,KAAK,CAAC,IAAA,mBAAO,EAAC,KAAK,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;QACvD,IAAI,MAAM,KAAK,SAAS;YAAE,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;AACV,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AuthoringGraph, AuthoringGraphSource } from '@cobol-ts/cel-graph-runtime';
|
|
2
|
+
/** Report over the declared output catalogue, not over arbitrary helper nodes. */
|
|
3
|
+
export interface GraphBuildReport {
|
|
4
|
+
readonly catalogueCount: number;
|
|
5
|
+
readonly experimentCount: number;
|
|
6
|
+
readonly existingGraphCount: number;
|
|
7
|
+
readonly graphNodeCount: number;
|
|
8
|
+
readonly celNodeCount: number;
|
|
9
|
+
readonly aggregateNodeCount: number;
|
|
10
|
+
readonly fromExperiments: readonly string[];
|
|
11
|
+
readonly fromExistingGraphs: readonly string[];
|
|
12
|
+
/** A registered output characteristic for which the assembled graph has no output node. */
|
|
13
|
+
readonly lost: readonly string[];
|
|
14
|
+
/** An experiment whose output characteristic is not in the current output catalogue. */
|
|
15
|
+
readonly uncatalogued: readonly string[];
|
|
16
|
+
readonly contributions: readonly {
|
|
17
|
+
readonly source: string;
|
|
18
|
+
readonly nodes: number;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
/** The composition layer never drops a colliding or invalid node: it fails.
|
|
22
|
+
* 'Lost' therefore means a catalogued output absent from the *resulting* graph,
|
|
23
|
+
* not a node discarded during merging. This distinction matters for partial runs. */
|
|
24
|
+
export declare function describeGraphBuild(catalogueIds: readonly string[], graph: AuthoringGraph, existing: readonly AuthoringGraphSource[], experiments: readonly AuthoringGraphSource[], experimentFilename: string): GraphBuildReport;
|
|
25
|
+
/** A text report is deliberately separate from graph.yaml and sent to diagnostics. */
|
|
26
|
+
export declare function formatGraphBuildReport(report: GraphBuildReport, detailed?: boolean): string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeGraphBuild = describeGraphBuild;
|
|
4
|
+
exports.formatGraphBuildReport = formatGraphBuildReport;
|
|
5
|
+
/** The composition layer never drops a colliding or invalid node: it fails.
|
|
6
|
+
* 'Lost' therefore means a catalogued output absent from the *resulting* graph,
|
|
7
|
+
* not a node discarded during merging. This distinction matters for partial runs. */
|
|
8
|
+
function describeGraphBuild(catalogueIds, graph, existing, experiments, experimentFilename) {
|
|
9
|
+
const provenance = new Map();
|
|
10
|
+
for (const source of existing)
|
|
11
|
+
for (const name of Object.keys(source.graph))
|
|
12
|
+
provenance.set(name, 'existing');
|
|
13
|
+
for (const source of experiments)
|
|
14
|
+
for (const name of Object.keys(source.graph))
|
|
15
|
+
provenance.set(name, 'experiment');
|
|
16
|
+
const fromExperiments = [];
|
|
17
|
+
const fromExistingGraphs = [];
|
|
18
|
+
const lost = [];
|
|
19
|
+
for (const id of [...new Set(catalogueIds)].sort()) {
|
|
20
|
+
if (!Object.prototype.hasOwnProperty.call(graph, id))
|
|
21
|
+
lost.push(id);
|
|
22
|
+
else if (provenance.get(id) === 'experiment')
|
|
23
|
+
fromExperiments.push(id);
|
|
24
|
+
else if (provenance.get(id) === 'existing')
|
|
25
|
+
fromExistingGraphs.push(id);
|
|
26
|
+
else
|
|
27
|
+
throw new Error(`Graph report: no source for output characteristic '${id}'`);
|
|
28
|
+
}
|
|
29
|
+
const catalogueSet = new Set(catalogueIds);
|
|
30
|
+
const uncatalogued = experiments.map(source => source.name.slice(experimentFilename.length + 1))
|
|
31
|
+
.filter(id => !catalogueSet.has(id)).sort();
|
|
32
|
+
const allSources = [...existing, ...experiments];
|
|
33
|
+
return {
|
|
34
|
+
catalogueCount: new Set(catalogueIds).size,
|
|
35
|
+
experimentCount: experiments.length,
|
|
36
|
+
existingGraphCount: existing.length,
|
|
37
|
+
graphNodeCount: Object.keys(graph).length,
|
|
38
|
+
celNodeCount: Object.values(graph).filter(node => node.type === 'cel').length,
|
|
39
|
+
aggregateNodeCount: Object.values(graph).filter(node => node.type === 'aggregate').length,
|
|
40
|
+
fromExperiments, fromExistingGraphs, lost, uncatalogued,
|
|
41
|
+
contributions: allSources.map(source => ({ source: source.name, nodes: Object.keys(source.graph).length }))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** A text report is deliberately separate from graph.yaml and sent to diagnostics. */
|
|
45
|
+
function formatGraphBuildReport(report, detailed = false) {
|
|
46
|
+
const included = report.fromExperiments.length + report.fromExistingGraphs.length;
|
|
47
|
+
const lines = [
|
|
48
|
+
'Graph build report',
|
|
49
|
+
`Sources: ${report.experimentCount} experiment(s), ${report.existingGraphCount} existing graph(s)`,
|
|
50
|
+
`Nodes: ${report.graphNodeCount} (${report.celNodeCount} CEL, ${report.aggregateNodeCount} aggregate)`,
|
|
51
|
+
`Output characteristics: ${report.catalogueCount} catalogued, ${included} included, ${report.lost.length} lost`,
|
|
52
|
+
` From experiments: ${report.fromExperiments.length}`,
|
|
53
|
+
` From existing graphs: ${report.fromExistingGraphs.length}`,
|
|
54
|
+
` Lost (absent from graph): ${report.lost.length}`,
|
|
55
|
+
`Uncatalogued experiments: ${report.uncatalogued.length}`
|
|
56
|
+
];
|
|
57
|
+
if (detailed) {
|
|
58
|
+
const group = (label, ids) => {
|
|
59
|
+
lines.push(`${label} (${ids.length}):`);
|
|
60
|
+
if (ids.length === 0)
|
|
61
|
+
lines.push(' (none)');
|
|
62
|
+
else
|
|
63
|
+
lines.push(...ids.map(id => ` ${id}`));
|
|
64
|
+
};
|
|
65
|
+
group('From experiments', report.fromExperiments);
|
|
66
|
+
group('From existing graphs', report.fromExistingGraphs);
|
|
67
|
+
group('Lost', report.lost);
|
|
68
|
+
group('Uncatalogued experiments', report.uncatalogued);
|
|
69
|
+
lines.push('Source contributions:');
|
|
70
|
+
for (const source of report.contributions)
|
|
71
|
+
lines.push(` ${source.source}: ${source.nodes} node(s)`);
|
|
72
|
+
}
|
|
73
|
+
return lines.join('\n');
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=graph.report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.report.js","sourceRoot":"","sources":["../../../src/commands/graph.report.ts"],"names":[],"mappings":";;AAsBA,gDAiCC;AAGD,wDA2BC;AAlED;;qFAEqF;AACrF,SAAgB,kBAAkB,CAC9B,YAA+B,EAC/B,KAAqB,EACrB,QAAyC,EACzC,WAA4C,EAC5C,kBAA0B;IAE1B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAqC,CAAA;IAC/D,KAAK,MAAM,MAAM,IAAI,QAAQ;QAAE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IAC7G,KAAK,MAAM,MAAM,IAAI,WAAW;QAAE,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;IAClH,MAAM,eAAe,GAAa,EAAE,CAAA;IACpC,MAAM,kBAAkB,GAAa,EAAE,CAAA;IACvC,MAAM,IAAI,GAAa,EAAE,CAAA;IACzB,KAAK,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;aAC9D,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE,CAA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AAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAA;QAChD,CAAC,CAAA;QACD,KAAK,CAAC,kBAAkB,EAAE,MAAM,CAAC,eAAe,CAAC,CAAA;QACjD,KAAK,CAAC,sBAAsB,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACxD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAA;QAC1B,KAAK,CAAC,0BAA0B,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;QACtD,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;QACnC,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,aAAa;YACrC,KAAK,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,UAAU,CAAC,CAAA;IACjE,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_path_1 = require("node:path");
|
|
4
|
+
const cli_1 = require("../cli");
|
|
5
|
+
const yaml_jsyaml_1 = require("@cobol-ts/yaml-jsyaml");
|
|
6
|
+
const input = (0, node_path_1.resolve)('experiments.yaml');
|
|
7
|
+
const manual = (0, node_path_1.resolve)('manual.yaml');
|
|
8
|
+
const output = (0, node_path_1.resolve)('generated-graph.yaml');
|
|
9
|
+
const configDirectory = (0, node_path_1.resolve)('example/.cobolts');
|
|
10
|
+
const config = (0, node_path_1.resolve)(configDirectory, 'characteristics.yaml');
|
|
11
|
+
const inputs = (0, node_path_1.resolve)(configDirectory, 'inputs.yaml');
|
|
12
|
+
const outputs = (0, node_path_1.resolve)(configDirectory, 'outputs.yaml');
|
|
13
|
+
const experiments = `version: 1
|
|
14
|
+
experiments:
|
|
15
|
+
- characteristic: C7030
|
|
16
|
+
metadata:
|
|
17
|
+
description: Overdraft spread
|
|
18
|
+
findings:
|
|
19
|
+
nodeCount: 2
|
|
20
|
+
graph:
|
|
21
|
+
C7030_monthlyBalance:
|
|
22
|
+
type: cel
|
|
23
|
+
cel: input.overdraft.monthEndBalance
|
|
24
|
+
metadata:
|
|
25
|
+
type: number
|
|
26
|
+
rollingWindow:
|
|
27
|
+
periodicity: monthly
|
|
28
|
+
size: 6
|
|
29
|
+
C7030:
|
|
30
|
+
type: aggregate
|
|
31
|
+
window: C7030_monthlyBalance
|
|
32
|
+
operation: min
|
|
33
|
+
history: []
|
|
34
|
+
`;
|
|
35
|
+
const expected = `base:
|
|
36
|
+
type: cel
|
|
37
|
+
cel: input.customers.customerId
|
|
38
|
+
metadata:
|
|
39
|
+
type: number
|
|
40
|
+
C7030_monthlyBalance:
|
|
41
|
+
type: cel
|
|
42
|
+
cel: input.overdraft.monthEndBalance
|
|
43
|
+
metadata:
|
|
44
|
+
type: number
|
|
45
|
+
rollingWindow:
|
|
46
|
+
periodicity: monthly
|
|
47
|
+
size: 6
|
|
48
|
+
C7030:
|
|
49
|
+
type: aggregate
|
|
50
|
+
window: C7030_monthlyBalance
|
|
51
|
+
operation: min
|
|
52
|
+
`;
|
|
53
|
+
function fixture() {
|
|
54
|
+
const lines = [];
|
|
55
|
+
const files = new Map([
|
|
56
|
+
[input, experiments],
|
|
57
|
+
[manual, `base:\n type: cel\n cel: input.customers.customerId\n metadata:\n type: number\n`],
|
|
58
|
+
[config, `files: .\ninput:\n sources:\n demo:\n type: yaml\n file: inputs.yaml\n path: characteristics\noutput:\n sources:\n demo:\n type: yaml\n file: outputs.yaml\n path: characteristics\n`],
|
|
59
|
+
[inputs, `characteristics: {I0010: {description: Test input}}\n`],
|
|
60
|
+
[outputs, `characteristics: {C7030: {description: Generated}, base: {description: Manual}, C9999: {description: Missing}}\n`]
|
|
61
|
+
]);
|
|
62
|
+
const writes = [];
|
|
63
|
+
const diagnostics = [];
|
|
64
|
+
const services = {
|
|
65
|
+
read: async (path) => {
|
|
66
|
+
const content = files.get(path);
|
|
67
|
+
if (content === undefined)
|
|
68
|
+
throw new Error(`Unknown test file: ${path}`);
|
|
69
|
+
return content;
|
|
70
|
+
},
|
|
71
|
+
output: (line) => lines.push(line),
|
|
72
|
+
diagnostic: (line) => diagnostics.push(line),
|
|
73
|
+
paths: async () => ({ directory: configDirectory }),
|
|
74
|
+
write: async (filename, content) => { writes.push({ filename, content }); }
|
|
75
|
+
};
|
|
76
|
+
return { services, lines, files, writes, diagnostics };
|
|
77
|
+
}
|
|
78
|
+
async function invoke(services, ...args) {
|
|
79
|
+
await (0, cli_1.createCoboltsCommand)(services).parseAsync(args, { from: 'user' });
|
|
80
|
+
}
|
|
81
|
+
describe('cobolts graph build', () => {
|
|
82
|
+
it('emits only graph.yaml authoring nodes (never experiment review or history)', async () => {
|
|
83
|
+
const f = fixture();
|
|
84
|
+
await invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml');
|
|
85
|
+
expect(f.lines).toEqual([expected.trimEnd()]);
|
|
86
|
+
expect(f.writes).toEqual([]);
|
|
87
|
+
const parsed = yaml_jsyaml_1.jsYamlParser.parse(f.lines[0]);
|
|
88
|
+
if ('errors' in parsed)
|
|
89
|
+
throw new Error(parsed.errors.join('; '));
|
|
90
|
+
expect(parsed.value).toEqual({
|
|
91
|
+
base: { type: 'cel', cel: 'input.customers.customerId', metadata: { type: 'number' } },
|
|
92
|
+
C7030_monthlyBalance: { type: 'cel', cel: 'input.overdraft.monthEndBalance',
|
|
93
|
+
metadata: { type: 'number', rollingWindow: { periodicity: 'monthly', size: 6 } } },
|
|
94
|
+
C7030: { type: 'aggregate', window: 'C7030_monthlyBalance', operation: 'min' }
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
it('writes exactly the graph, not an experiment dossier', async () => {
|
|
98
|
+
const f = fixture();
|
|
99
|
+
await invoke(f.services, 'graph', 'build', 'experiments.yaml', '--file', 'generated-graph.yaml', '--with', 'manual.yaml');
|
|
100
|
+
expect(f.lines).toEqual([]);
|
|
101
|
+
expect(f.writes).toEqual([{ filename: output, content: expected }]);
|
|
102
|
+
});
|
|
103
|
+
it('refuses node collisions instead of silently overwriting sources', async () => {
|
|
104
|
+
const f = fixture();
|
|
105
|
+
f.files.set(manual, `C7030:\n type: cel\n cel: input.other\n metadata:\n type: number\n`);
|
|
106
|
+
await expect(invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml'))
|
|
107
|
+
.rejects.toThrow(`Graph node 'C7030' is defined by both '${manual}' and '${input}#C7030'`);
|
|
108
|
+
expect(f.lines).toEqual([]);
|
|
109
|
+
expect(f.writes).toEqual([]);
|
|
110
|
+
});
|
|
111
|
+
it('reports source counts, included outputs and lost catalogue outputs without changing graph stdout', async () => {
|
|
112
|
+
const f = fixture();
|
|
113
|
+
await invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml', '--report');
|
|
114
|
+
expect(f.lines).toEqual([expected.trimEnd()]);
|
|
115
|
+
expect(f.writes).toEqual([]);
|
|
116
|
+
expect(f.diagnostics).toEqual([`Graph build report
|
|
117
|
+
Sources: 1 experiment(s), 1 existing graph(s)
|
|
118
|
+
Nodes: 3 (2 CEL, 1 aggregate)
|
|
119
|
+
Output characteristics: 3 catalogued, 2 included, 1 lost
|
|
120
|
+
From experiments: 1
|
|
121
|
+
From existing graphs: 1
|
|
122
|
+
Lost (absent from graph): 1
|
|
123
|
+
Uncatalogued experiments: 0`]);
|
|
124
|
+
});
|
|
125
|
+
it('reports zero loss when all catalogued outputs are present', async () => {
|
|
126
|
+
const f = fixture();
|
|
127
|
+
f.files.set(outputs, `characteristics: {C7030: {description: Generated}, base: {description: Manual}}\n`);
|
|
128
|
+
await invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml', '--report');
|
|
129
|
+
expect(f.diagnostics).toEqual([`Graph build report
|
|
130
|
+
Sources: 1 experiment(s), 1 existing graph(s)
|
|
131
|
+
Nodes: 3 (2 CEL, 1 aggregate)
|
|
132
|
+
Output characteristics: 2 catalogued, 2 included, 0 lost
|
|
133
|
+
From experiments: 1
|
|
134
|
+
From existing graphs: 1
|
|
135
|
+
Lost (absent from graph): 0
|
|
136
|
+
Uncatalogued experiments: 0`]);
|
|
137
|
+
});
|
|
138
|
+
it('--detailed implies --report and names every characteristic camp and contributing source', async () => {
|
|
139
|
+
const f = fixture();
|
|
140
|
+
await invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml', '--file', 'generated-graph.yaml', '--detailed');
|
|
141
|
+
expect(f.lines).toEqual([]);
|
|
142
|
+
expect(f.writes).toEqual([{ filename: output, content: expected }]);
|
|
143
|
+
expect(f.diagnostics).toEqual([`Graph build report
|
|
144
|
+
Sources: 1 experiment(s), 1 existing graph(s)
|
|
145
|
+
Nodes: 3 (2 CEL, 1 aggregate)
|
|
146
|
+
Output characteristics: 3 catalogued, 2 included, 1 lost
|
|
147
|
+
From experiments: 1
|
|
148
|
+
From existing graphs: 1
|
|
149
|
+
Lost (absent from graph): 1
|
|
150
|
+
Uncatalogued experiments: 0
|
|
151
|
+
From experiments (1):
|
|
152
|
+
C7030
|
|
153
|
+
From existing graphs (1):
|
|
154
|
+
base
|
|
155
|
+
Lost (1):
|
|
156
|
+
C9999
|
|
157
|
+
Uncatalogued experiments (0):
|
|
158
|
+
(none)
|
|
159
|
+
Source contributions:
|
|
160
|
+
${manual}: 1 node(s)
|
|
161
|
+
${input}#C7030: 2 node(s)`]);
|
|
162
|
+
});
|
|
163
|
+
it('reports experiments absent from the configured output catalogue instead of treating them as catalogued', async () => {
|
|
164
|
+
const f = fixture();
|
|
165
|
+
f.files.set(outputs, `characteristics: {base: {description: Manual}, C9999: {description: Missing}}\n`);
|
|
166
|
+
await invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml', '--detailed');
|
|
167
|
+
expect(f.diagnostics).toEqual([`Graph build report
|
|
168
|
+
Sources: 1 experiment(s), 1 existing graph(s)
|
|
169
|
+
Nodes: 3 (2 CEL, 1 aggregate)
|
|
170
|
+
Output characteristics: 2 catalogued, 1 included, 1 lost
|
|
171
|
+
From experiments: 0
|
|
172
|
+
From existing graphs: 1
|
|
173
|
+
Lost (absent from graph): 1
|
|
174
|
+
Uncatalogued experiments: 1
|
|
175
|
+
From experiments (0):
|
|
176
|
+
(none)
|
|
177
|
+
From existing graphs (1):
|
|
178
|
+
base
|
|
179
|
+
Lost (1):
|
|
180
|
+
C9999
|
|
181
|
+
Uncatalogued experiments (1):
|
|
182
|
+
C7030
|
|
183
|
+
Source contributions:
|
|
184
|
+
${manual}: 1 node(s)
|
|
185
|
+
${input}#C7030: 2 node(s)`]);
|
|
186
|
+
});
|
|
187
|
+
it('does not print a report when composition fails', async () => {
|
|
188
|
+
const f = fixture();
|
|
189
|
+
f.files.set(manual, `C7030:\n type: cel\n cel: input.other\n metadata:\n type: number\n`);
|
|
190
|
+
await expect(invoke(f.services, 'graph', 'build', 'experiments.yaml', '--with', 'manual.yaml', '--report'))
|
|
191
|
+
.rejects.toThrow(`Graph node 'C7030' is defined by both '${manual}' and '${input}#C7030'`);
|
|
192
|
+
expect(f.lines).toEqual([]);
|
|
193
|
+
expect(f.writes).toEqual([]);
|
|
194
|
+
expect(f.diagnostics).toEqual([]);
|
|
195
|
+
});
|
|
196
|
+
it('rejects a dossier with an unsupported version', async () => {
|
|
197
|
+
const f = fixture();
|
|
198
|
+
f.files.set(input, experiments.replace('version: 1', 'version: 2'));
|
|
199
|
+
await expect(invoke(f.services, 'graph', 'build', 'experiments.yaml'))
|
|
200
|
+
.rejects.toThrow(`${input}: expected experiment document version 1`);
|
|
201
|
+
});
|
|
202
|
+
it('rejects a dossier without its claimed characteristic output node', async () => {
|
|
203
|
+
const f = fixture();
|
|
204
|
+
f.files.set(input, experiments.replace('characteristic: C7030', 'characteristic: C9999'));
|
|
205
|
+
await expect(invoke(f.services, 'graph', 'build', 'experiments.yaml'))
|
|
206
|
+
.rejects.toThrow(`${input}.experiments[0].graph: missing output node 'C9999'`);
|
|
207
|
+
});
|
|
208
|
+
it('rejects a generated graph with missing current-value dependencies', async () => {
|
|
209
|
+
const f = fixture();
|
|
210
|
+
f.files.set(input, `version: 1\nexperiments:\n - characteristic: C7030\n graph:\n C7030:\n type: cel\n cel: now.missing + 1\n metadata:\n type: number\n`);
|
|
211
|
+
await expect(invoke(f.services, 'graph', 'build', 'experiments.yaml'))
|
|
212
|
+
.rejects.toThrow("refers to missing graph node 'missing'");
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
//# sourceMappingURL=graph.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.spec.js","sourceRoot":"","sources":["../../../src/commands/graph.spec.ts"],"names":[],"mappings":";;AAAA,yCAAiC;AACjC,gCAA2C;AAE3C,uDAAkD;AAElD,MAAM,KAAK,GAAG,IAAA,mBAAO,EAAC,kBAAkB,CAAC,CAAA;AACzC,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,aAAa,CAAC,CAAA;AACrC,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,sBAAsB,CAAC,CAAA;AAC9C,MAAM,eAAe,GAAG,IAAA,mBAAO,EAAC,kBAAkB,CAAC,CAAA;AACnD,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,eAAe,EAAE,sBAAsB,CAAC,CAAA;AAC/D,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,eAAe,EAAE,aAAa,CAAC,CAAA;AACtD,MAAM,OAAO,GAAG,IAAA,mBAAO,EAAC,eAAe,EAAE,cAAc,CAAC,CAAA;AAExD,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;CAqBnB,CAAA;AAED,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;CAiBhB,CAAA;AAED,SAAS,OAAO;IACZ,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,MAAM,KAAK,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/context.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CharacteristicCatalogues } from '@cobol-ts/characteristics';
|
|
1
2
|
import { type SpreadsheetExtractConfig, type SpreadsheetExtraction } from '@cobol-ts/spreadsheet';
|
|
2
3
|
import type { ArtefactManifest, FileCatalogue, GenerationPolicy } from '@cobol-ts/file-catalogue';
|
|
3
4
|
import type { CodegenNames, CodegenSelection, GenerationResult } from '@cobol-ts/codegen';
|
|
@@ -65,6 +66,8 @@ export interface CliServices {
|
|
|
65
66
|
readonly write: (filename: string, content: string) => Promise<void>;
|
|
66
67
|
readonly extractSpreadsheet: (config: SpreadsheetExtractConfig) => Promise<SpreadsheetExtraction>;
|
|
67
68
|
readonly read: (filename: string) => Promise<string>;
|
|
69
|
+
/** Optional read-only HTTP adapter, injected for tests or CLI use. */
|
|
70
|
+
readonly serveCharacteristics?: (catalogues: CharacteristicCatalogues, port: number) => Promise<void>;
|
|
68
71
|
readonly paths: (options: CliOptions) => Promise<CliPaths>;
|
|
69
72
|
readonly list: (paths: CliPaths) => Promise<readonly string[]>;
|
|
70
73
|
readonly logicalNames: (paths: CliPaths) => Promise<readonly string[]>;
|
package/dist/src/context.js
CHANGED
|
@@ -91,7 +91,7 @@ function compileIndexedComposedExecutor(paths, authored, initial, stateConfigura
|
|
|
91
91
|
if ('errors' in graph)
|
|
92
92
|
return graph;
|
|
93
93
|
const schema = graph.value.schema;
|
|
94
|
-
const initialValues = (0, indexed_accumulator_1.indexedSeedValues)(initial);
|
|
94
|
+
const initialValues = (0, indexed_accumulator_1.indexedSeedValues)(initial, schema);
|
|
95
95
|
const stateFile = stateConfiguration.file ? (0, node_path_1.resolve)(paths.directory, stateConfiguration.file) : undefined;
|
|
96
96
|
// Accumulator preparation has the same lifetime as the compiled executor.
|
|
97
97
|
// Each run still opens fresh composition and historical-state cursors.
|
|
@@ -244,6 +244,14 @@ exports.nodeCliServices = {
|
|
|
244
244
|
extractSpreadsheet: config => (0, spreadsheet_1.extractSpreadsheet)(spreadsheet_excel_1.excelSpreadsheetReader, config),
|
|
245
245
|
read: filename => files_1.nodeTextFiles.read(filename),
|
|
246
246
|
paths: discoverPaths,
|
|
247
|
+
async serveCharacteristics(catalogues, port) {
|
|
248
|
+
const { createCharacteristicsApp } = await import('@cobol-ts/characteristics-express');
|
|
249
|
+
const server = createCharacteristicsApp(catalogues).listen(port, '127.0.0.1');
|
|
250
|
+
await new Promise((resolve, reject) => {
|
|
251
|
+
server.once('listening', resolve);
|
|
252
|
+
server.once('error', reject);
|
|
253
|
+
});
|
|
254
|
+
},
|
|
247
255
|
async list(paths) {
|
|
248
256
|
const catalogue = (0, errors_1.valueOrThrow)(await (0, file_catalogue_1.readFileCatalogue)(files_1.nodeTextFiles, paths.catalogue, yaml_jsyaml_1.jsYamlParser));
|
|
249
257
|
const result = [paths.catalogue];
|
|
@@ -500,7 +508,7 @@ exports.nodeCliServices = {
|
|
|
500
508
|
const normalizeKey = (0, indexed_accumulator_1.indexedKeyNormalizer)(stateConfiguration.customerIdType, stateConfiguration.customerId);
|
|
501
509
|
await (0, cursor_loader_indexed_graph_state_1.scanIndexedAccumulator)(prepared.composed, {
|
|
502
510
|
schema: historicalGraph.value.schema, optional: stateConfiguration.optional,
|
|
503
|
-
removed: stateConfiguration.removed, customerIdType: stateConfiguration.customerIdType, initial: (0, indexed_accumulator_1.indexedSeedValues)(checked.value),
|
|
511
|
+
removed: stateConfiguration.removed, customerIdType: stateConfiguration.customerIdType, initial: (0, indexed_accumulator_1.indexedSeedValues)(checked.value, historicalGraph.value.schema),
|
|
504
512
|
filename: (0, node_path_1.resolve)(paths.directory, stateConfiguration.file)
|
|
505
513
|
}, row => normalizeKey(row.key), (row, state) => {
|
|
506
514
|
visited++;
|
|
@@ -620,7 +628,7 @@ exports.nodeCliServices = {
|
|
|
620
628
|
const key = (0, indexed_accumulator_1.indexedCustomerKey)(source, stateConfiguration.customerId, stateConfiguration.customerIdType);
|
|
621
629
|
await (0, cursor_loader_indexed_graph_state_1.scanIndexedAccumulator)(source, {
|
|
622
630
|
schema: prepared.value.schema, optional: stateConfiguration.optional,
|
|
623
|
-
removed: stateConfiguration.removed, customerIdType: stateConfiguration.customerIdType, initial: (0, indexed_accumulator_1.indexedSeedValues)(checked.value),
|
|
631
|
+
removed: stateConfiguration.removed, customerIdType: stateConfiguration.customerIdType, initial: (0, indexed_accumulator_1.indexedSeedValues)(checked.value, prepared.value.schema),
|
|
624
632
|
...(stateConfiguration.file ? { filename: (0, node_path_1.resolve)(paths.directory, stateConfiguration.file) } : {})
|
|
625
633
|
}, key, (record, state) => {
|
|
626
634
|
visited++;
|
|
@@ -688,7 +696,7 @@ exports.nodeCliServices = {
|
|
|
688
696
|
let matched = false;
|
|
689
697
|
await (0, cursor_loader_indexed_graph_state_1.scanIndexedAccumulator)(source, {
|
|
690
698
|
schema: historicalGraph.value.schema, optional: stateConfiguration.optional,
|
|
691
|
-
removed: stateConfiguration.removed, customerIdType: stateConfiguration.customerIdType, initial: (0, indexed_accumulator_1.indexedSeedValues)(checked.value),
|
|
699
|
+
removed: stateConfiguration.removed, customerIdType: stateConfiguration.customerIdType, initial: (0, indexed_accumulator_1.indexedSeedValues)(checked.value, historicalGraph.value.schema),
|
|
692
700
|
filename: (0, node_path_1.resolve)(paths.directory, stateConfiguration.file)
|
|
693
701
|
}, key, (record, state) => {
|
|
694
702
|
if ((0, cel_entity_1.selectEntity)(key(record), target) === 'skip')
|