@agent-wiki/mcp 0.21.8 → 0.22.1
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/dist/cobol/__tests__/field-lineage-eval.test.d.ts +2 -0
- package/dist/cobol/__tests__/field-lineage-eval.test.d.ts.map +1 -0
- package/dist/cobol/__tests__/field-lineage-eval.test.js +379 -0
- package/dist/cobol/__tests__/field-lineage-eval.test.js.map +1 -0
- package/dist/cobol/__tests__/field-lineage.test.js +144 -0
- package/dist/cobol/__tests__/field-lineage.test.js.map +1 -1
- package/dist/cobol/field-lineage-eval.d.ts +146 -0
- package/dist/cobol/field-lineage-eval.d.ts.map +1 -0
- package/dist/cobol/field-lineage-eval.js +528 -0
- package/dist/cobol/field-lineage-eval.js.map +1 -0
- package/dist/cobol/field-lineage.d.ts.map +1 -1
- package/dist/cobol/field-lineage.js +72 -13
- package/dist/cobol/field-lineage.js.map +1 -1
- package/docs/field-lineage-eval.md +234 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-lineage-eval.test.d.ts","sourceRoot":"","sources":["../../../src/cobol/__tests__/field-lineage-eval.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync, mkdirSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { resolve, join } from "node:path";
|
|
5
|
+
import { evaluateFieldLineage, loadManifest, renderEvalReport, } from "../field-lineage-eval.js";
|
|
6
|
+
const FIXTURE_DIR = resolve(process.cwd(), "src/cobol/__tests__/fixtures/eval/basic");
|
|
7
|
+
function metrics(report, family) {
|
|
8
|
+
const fam = report.families[family];
|
|
9
|
+
if (fam.skipped)
|
|
10
|
+
throw new Error(`Family ${family} unexpectedly skipped`);
|
|
11
|
+
return fam;
|
|
12
|
+
}
|
|
13
|
+
describe("field-lineage eval harness — basic fixture", () => {
|
|
14
|
+
let report;
|
|
15
|
+
beforeAll(() => {
|
|
16
|
+
report = evaluateFieldLineage(FIXTURE_DIR);
|
|
17
|
+
});
|
|
18
|
+
it("perfectly grades the basic fixture (precision = recall = 1.0)", () => {
|
|
19
|
+
expect(report.overall.precision).toBeCloseTo(1, 10);
|
|
20
|
+
expect(report.overall.recall).toBeCloseTo(1, 10);
|
|
21
|
+
expect(report.overall.f1).toBeCloseTo(1, 10);
|
|
22
|
+
});
|
|
23
|
+
it("exercises deterministic, inferredHigh, and callBound families with non-zero TP", () => {
|
|
24
|
+
expect(metrics(report, "deterministic").truePositives).toBeGreaterThan(0);
|
|
25
|
+
expect(metrics(report, "inferredHigh").truePositives).toBeGreaterThan(0);
|
|
26
|
+
expect(metrics(report, "callBound").truePositives).toBeGreaterThan(0);
|
|
27
|
+
});
|
|
28
|
+
it("reports zero false positives and zero false negatives across graded families", () => {
|
|
29
|
+
for (const family of Object.keys(report.families)) {
|
|
30
|
+
const fam = report.families[family];
|
|
31
|
+
if (fam.skipped)
|
|
32
|
+
continue;
|
|
33
|
+
expect(fam.falsePositives, `${family} false positives`).toEqual([]);
|
|
34
|
+
expect(fam.falseNegatives, `${family} false negatives`).toEqual([]);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
it("does not skip any family declared in the manifest", () => {
|
|
38
|
+
for (const family of Object.keys(report.families)) {
|
|
39
|
+
expect(report.families[family].skipped, `${family} should not be skipped`).toBe(false);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
it("renders a markdown report containing the overall scoreline and per-family table", () => {
|
|
43
|
+
const md = renderEvalReport(report);
|
|
44
|
+
expect(md).toContain("Field-lineage eval");
|
|
45
|
+
expect(md).toContain("Overall");
|
|
46
|
+
expect(md).toContain("Deterministic shared copybook");
|
|
47
|
+
expect(md).toContain("Inferred — high confidence");
|
|
48
|
+
expect(md).toContain("CALL ... USING boundary");
|
|
49
|
+
// Perfect run has no per-family FP/FN section.
|
|
50
|
+
expect(md).not.toMatch(/^### .* — high confidence$/m);
|
|
51
|
+
expect(md).not.toContain("**False positives**");
|
|
52
|
+
expect(md).not.toContain("**False negatives**");
|
|
53
|
+
});
|
|
54
|
+
it("renders vacuous (manifest `[]` + zero emissions) families as '—', not 100%", () => {
|
|
55
|
+
const md = renderEvalReport(report);
|
|
56
|
+
// inferredAmbiguous, inferredSemantic, and db2 are declared `[]` in the
|
|
57
|
+
// basic fixture and emit nothing — they must render with a `—` placeholder
|
|
58
|
+
// so a reviewer can tell them apart from a real perfect-graded family.
|
|
59
|
+
const ambiguousRow = md.split("\n").find((line) => line.startsWith("| Inferred — ambiguous |"));
|
|
60
|
+
expect(ambiguousRow, "ambiguous row").toBeDefined();
|
|
61
|
+
expect(ambiguousRow).toContain("| — |");
|
|
62
|
+
expect(ambiguousRow).not.toContain("100.0%");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe("field-lineage eval harness — DB2 column-pair fixture", () => {
|
|
66
|
+
const fixtureDir = resolve(process.cwd(), "src/cobol/__tests__/fixtures/eval/db2-column-pairs");
|
|
67
|
+
let report;
|
|
68
|
+
beforeAll(() => {
|
|
69
|
+
report = evaluateFieldLineage(fixtureDir);
|
|
70
|
+
});
|
|
71
|
+
it("perfectly grades DB2 cross-program column pairs (precision = recall = 1.0)", () => {
|
|
72
|
+
expect(report.overall.precision).toBeCloseTo(1, 10);
|
|
73
|
+
expect(report.overall.recall).toBeCloseTo(1, 10);
|
|
74
|
+
});
|
|
75
|
+
it("emits the table-level pair plus both column-level pairs", () => {
|
|
76
|
+
const fam = report.families.db2;
|
|
77
|
+
if (fam.skipped)
|
|
78
|
+
throw new Error("db2 unexpectedly skipped");
|
|
79
|
+
// 1 pair key + 2 column keys = 3 graded facts.
|
|
80
|
+
expect(fam.expected).toBe(3);
|
|
81
|
+
expect(fam.actual).toBe(3);
|
|
82
|
+
expect(fam.truePositives).toBe(3);
|
|
83
|
+
});
|
|
84
|
+
it("does not light up unrelated families (no copybook reuse, no CALL-USING)", () => {
|
|
85
|
+
const det = report.families.deterministic;
|
|
86
|
+
const cb = report.families.callBound;
|
|
87
|
+
if (det.skipped || cb.skipped)
|
|
88
|
+
throw new Error("graded family unexpectedly skipped");
|
|
89
|
+
expect(det.actual).toBe(0);
|
|
90
|
+
expect(cb.actual).toBe(0);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe("field-lineage eval harness — REPLACING cohort fixture", () => {
|
|
94
|
+
const fixtureDir = resolve(process.cwd(), "src/cobol/__tests__/fixtures/eval/replacing");
|
|
95
|
+
let report;
|
|
96
|
+
beforeAll(() => {
|
|
97
|
+
report = evaluateFieldLineage(fixtureDir);
|
|
98
|
+
});
|
|
99
|
+
it("perfectly grades the REPLACING cohort (precision = recall = 1.0)", () => {
|
|
100
|
+
expect(report.overall.precision).toBeCloseTo(1, 10);
|
|
101
|
+
expect(report.overall.recall).toBeCloseTo(1, 10);
|
|
102
|
+
});
|
|
103
|
+
it("captures the post-substitution field name (CLIENT-ID) and untouched fields (ZIP-CODE) under one cohort", () => {
|
|
104
|
+
const det = report.families.deterministic;
|
|
105
|
+
if (det.skipped)
|
|
106
|
+
throw new Error("deterministic unexpectedly skipped");
|
|
107
|
+
// CUSTOMER-REC + CLIENT-ID + CUSTOMER-ADDRESS + ZIP-CODE = 4 entries.
|
|
108
|
+
expect(det.expected).toBe(4);
|
|
109
|
+
expect(det.actual).toBe(4);
|
|
110
|
+
expect(det.truePositives).toBe(4);
|
|
111
|
+
expect(det.falsePositives).toEqual([]);
|
|
112
|
+
expect(det.falseNegatives).toEqual([]);
|
|
113
|
+
});
|
|
114
|
+
it("anchors against a Phase B regression: a builder that loses the REPLACING rename would surface CUSTOMER-ID as FP and CLIENT-ID as FN", () => {
|
|
115
|
+
// Sanity check against the canonical-key shape — the manifest's CLIENT-ID
|
|
116
|
+
// entry must be matched by the builder's emission of the renamed field,
|
|
117
|
+
// not by an accidental match on the pre-substitution name.
|
|
118
|
+
const det = report.families.deterministic;
|
|
119
|
+
if (det.skipped)
|
|
120
|
+
throw new Error("deterministic unexpectedly skipped");
|
|
121
|
+
expect(det.falsePositives.find((k) => k.startsWith("CUSTOMER-ID|"))).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe("field-lineage eval harness — REPLACING + inferred (Phase C)", () => {
|
|
125
|
+
// Phase C: candidate sourcing for inferred matching widens to include
|
|
126
|
+
// REPLACING cohorts, but matches on the ORIGINAL (pre-substitution)
|
|
127
|
+
// field shape. Projection is used only to gate out leaves whose name
|
|
128
|
+
// was rewritten by REPLACING (no source-text backing for the matched
|
|
129
|
+
// name). The fixture exercises both halves of the gate — see the
|
|
130
|
+
// manifest description for the full setup.
|
|
131
|
+
const fixtureDir = resolve(process.cwd(), "src/cobol/__tests__/fixtures/eval/replacing-inferred");
|
|
132
|
+
let report;
|
|
133
|
+
beforeAll(() => {
|
|
134
|
+
report = evaluateFieldLineage(fixtureDir);
|
|
135
|
+
});
|
|
136
|
+
it("Phase C surfaces COMMON-ID and COMMON-NAME cross-copybook pairs (recall gain over pre-Phase-C)", () => {
|
|
137
|
+
const ih = report.families.inferredHigh;
|
|
138
|
+
if (ih.skipped)
|
|
139
|
+
throw new Error("inferredHigh unexpectedly skipped");
|
|
140
|
+
expect(ih.expected).toBe(2);
|
|
141
|
+
expect(ih.actual).toBe(2);
|
|
142
|
+
expect(ih.truePositives).toBe(2);
|
|
143
|
+
});
|
|
144
|
+
it("precision gate filters the REPLACING-laundered ENTITY-PK pair — both leaves came from substitution on different source names", () => {
|
|
145
|
+
const ih = report.families.inferredHigh;
|
|
146
|
+
if (ih.skipped)
|
|
147
|
+
throw new Error("inferredHigh unexpectedly skipped");
|
|
148
|
+
expect(ih.falsePositives).toEqual([]);
|
|
149
|
+
// Sanity: ENTITY-PK is NOT in the actual emission set. If a future
|
|
150
|
+
// regression dropped the gate, this assertion would fail loudly.
|
|
151
|
+
expect(ih.falseNegatives).toEqual([]);
|
|
152
|
+
});
|
|
153
|
+
it("each REPLACING cohort still emits its full deterministic-via-replacing entry set (8 entries across the two copybooks)", () => {
|
|
154
|
+
const det = report.families.deterministic;
|
|
155
|
+
if (det.skipped)
|
|
156
|
+
throw new Error("deterministic unexpectedly skipped");
|
|
157
|
+
expect(det.expected).toBe(8);
|
|
158
|
+
expect(det.actual).toBe(8);
|
|
159
|
+
expect(det.truePositives).toBe(8);
|
|
160
|
+
});
|
|
161
|
+
it("overall fixture grades 1.0 / 1.0 after Phase C", () => {
|
|
162
|
+
expect(report.overall.precision).toBeCloseTo(1, 10);
|
|
163
|
+
expect(report.overall.recall).toBeCloseTo(1, 10);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
describe("field-lineage eval harness — renderer edge cases", () => {
|
|
167
|
+
it("emits a false-positive section in markdown when actual exceeds expected", () => {
|
|
168
|
+
const report = {
|
|
169
|
+
fixture: "synthetic",
|
|
170
|
+
families: {
|
|
171
|
+
deterministic: {
|
|
172
|
+
skipped: false,
|
|
173
|
+
expected: 1,
|
|
174
|
+
actual: 2,
|
|
175
|
+
truePositives: 1,
|
|
176
|
+
falsePositives: ["EXTRA|cbs=X|pgs=A,B"],
|
|
177
|
+
falseNegatives: [],
|
|
178
|
+
precision: 0.5,
|
|
179
|
+
recall: 1,
|
|
180
|
+
f1: 2 / 3,
|
|
181
|
+
},
|
|
182
|
+
inferredHigh: { skipped: true },
|
|
183
|
+
inferredAmbiguous: { skipped: true },
|
|
184
|
+
inferredSemantic: { skipped: true },
|
|
185
|
+
callBound: { skipped: true },
|
|
186
|
+
db2: { skipped: true },
|
|
187
|
+
},
|
|
188
|
+
overall: { precision: 0.5, recall: 1, f1: 2 / 3 },
|
|
189
|
+
};
|
|
190
|
+
const md = renderEvalReport(report);
|
|
191
|
+
expect(md).toContain("**False positives**");
|
|
192
|
+
expect(md).toContain("EXTRA|cbs=X|pgs=A,B");
|
|
193
|
+
expect(md).not.toContain("**False negatives**");
|
|
194
|
+
});
|
|
195
|
+
it("renders skipped families with '—' across metric cells, not 100%", () => {
|
|
196
|
+
const report = {
|
|
197
|
+
fixture: "skipped-only",
|
|
198
|
+
families: {
|
|
199
|
+
deterministic: { skipped: true },
|
|
200
|
+
inferredHigh: { skipped: true },
|
|
201
|
+
inferredAmbiguous: { skipped: true },
|
|
202
|
+
inferredSemantic: { skipped: true },
|
|
203
|
+
callBound: { skipped: true },
|
|
204
|
+
db2: { skipped: true },
|
|
205
|
+
},
|
|
206
|
+
overall: { precision: 1, recall: 1, f1: 1 },
|
|
207
|
+
};
|
|
208
|
+
const md = renderEvalReport(report);
|
|
209
|
+
// No graded family means no row should mention "100.0%" except the
|
|
210
|
+
// overall scoreline, which is the only line outside the table.
|
|
211
|
+
const rows = md.split("\n").filter((line) => line.startsWith("| ") && !line.startsWith("| Family |") && !line.startsWith("|---"));
|
|
212
|
+
for (const row of rows) {
|
|
213
|
+
expect(row, `skipped row should not show percentages: ${row}`).not.toContain("100.0%");
|
|
214
|
+
expect(row).toContain("_skipped_");
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("field-lineage eval harness — manifest validation", () => {
|
|
219
|
+
let scratchDir;
|
|
220
|
+
const created = [];
|
|
221
|
+
function mkFixture(manifestYaml) {
|
|
222
|
+
const dir = mkdtempSync(join(tmpdir(), "lineage-eval-"));
|
|
223
|
+
created.push(dir);
|
|
224
|
+
// Mirror the basic fixture's COBOL sources so the build pipeline runs;
|
|
225
|
+
// only the manifest varies per test. Single trivial COBOL file is enough
|
|
226
|
+
// since manifest validation runs before any builder call.
|
|
227
|
+
mkdirSync(dir, { recursive: true });
|
|
228
|
+
writeFileSync(join(dir, "STUB.cbl"), ` IDENTIFICATION DIVISION.\n PROGRAM-ID. STUB.\n PROCEDURE DIVISION.\n A. STOP RUN.\n`, "utf-8");
|
|
229
|
+
writeFileSync(join(dir, "lineage.expected.yaml"), manifestYaml, "utf-8");
|
|
230
|
+
return dir;
|
|
231
|
+
}
|
|
232
|
+
afterEach(() => {
|
|
233
|
+
while (created.length > 0) {
|
|
234
|
+
const dir = created.pop();
|
|
235
|
+
rmSync(dir, { recursive: true, force: true });
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
it("rejects YAML-null family values with a clear schema error rather than crashing later", () => {
|
|
239
|
+
scratchDir = mkFixture(`version: 1\ninferredAmbiguous:\n`);
|
|
240
|
+
// YAML-null on a family is normalized to "skipped" — no crash.
|
|
241
|
+
const report = evaluateFieldLineage(scratchDir);
|
|
242
|
+
expect(report.families.inferredAmbiguous.skipped).toBe(true);
|
|
243
|
+
});
|
|
244
|
+
it("rejects non-array family values at load time, not deep in the grader", () => {
|
|
245
|
+
scratchDir = mkFixture(`version: 1\ndeterministic: not-an-array\n`);
|
|
246
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/family 'deterministic' must be an array/);
|
|
247
|
+
});
|
|
248
|
+
it("rejects manifest entries missing required fields with a path-pointing error", () => {
|
|
249
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: CUSTOMER-ID\n programs: [ORDERA, ORDERB]\n`);
|
|
250
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/deterministic\[0\]\.copybooks/);
|
|
251
|
+
});
|
|
252
|
+
it("rejects unknown top-level keys instead of silently skipping a typo'd family", () => {
|
|
253
|
+
scratchDir = mkFixture(`version: 1\ninferredHigj: []\n`);
|
|
254
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/unknown top-level key 'inferredHigj'/);
|
|
255
|
+
});
|
|
256
|
+
it("rejects unsupported manifest versions", () => {
|
|
257
|
+
scratchDir = mkFixture(`version: 2\n`);
|
|
258
|
+
expect(() => loadManifest(join(scratchDir, "lineage.expected.yaml"))).toThrow(/unsupported version 2/);
|
|
259
|
+
});
|
|
260
|
+
it("rejects inferred entries whose copybooks list is not exactly two", () => {
|
|
261
|
+
scratchDir = mkFixture(`version: 1\ninferredHigh:\n - fieldName: CUSTOMER-ID\n copybooks: [A, B, C]\n`);
|
|
262
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/inferredHigh\[0\]\.copybooks must list exactly two/);
|
|
263
|
+
});
|
|
264
|
+
it("rejects callBound entries missing both callerField and callerQualified", () => {
|
|
265
|
+
scratchDir = mkFixture(`version: 1\ncallBound:\n - caller: C\n callee: E\n position: 0\n calleeField: LK\n`);
|
|
266
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/callerField or callerQualified/);
|
|
267
|
+
});
|
|
268
|
+
it("rejects duplicate canonical keys in the manifest (e.g. same deterministic entry twice)", () => {
|
|
269
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: X\n copybooks: [A]\n programs: [P1, P2]\n - fieldName: X\n copybooks: [A]\n programs: [P1, P2]\n`);
|
|
270
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/Duplicate deterministic .* entries/);
|
|
271
|
+
});
|
|
272
|
+
it("rejects empty identifier strings instead of silently producing degenerate canonical keys", () => {
|
|
273
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: ""\n copybooks: [A]\n programs: [P1, P2]\n`);
|
|
274
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/must be a non-empty string/);
|
|
275
|
+
});
|
|
276
|
+
it("rejects empty arrays in deterministic identifier fields", () => {
|
|
277
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: X\n copybooks: []\n programs: [P1, P2]\n`);
|
|
278
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/copybooks must list at least one copybook/);
|
|
279
|
+
});
|
|
280
|
+
it("rejects fewer-than-two programs on a deterministic entry (deterministic emission needs ≥2 consumers)", () => {
|
|
281
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: X\n copybooks: [A]\n programs: [P1]\n`);
|
|
282
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/programs must list at least two programs/);
|
|
283
|
+
});
|
|
284
|
+
it("rejects non-integer callBound position", () => {
|
|
285
|
+
scratchDir = mkFixture(`version: 1\ncallBound:\n - caller: C\n callee: E\n position: 0.5\n callerField: WS\n calleeField: LK\n`);
|
|
286
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/position must be a non-negative integer/);
|
|
287
|
+
});
|
|
288
|
+
it("rejects mixed callerField+callerQualified on the same callBound entry", () => {
|
|
289
|
+
scratchDir = mkFixture(`version: 1\ncallBound:\n - caller: C\n callee: E\n position: 0\n callerField: WS\n callerQualified: WS.X\n calleeField: LK\n`);
|
|
290
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/callerField OR callerQualified, not both/);
|
|
291
|
+
});
|
|
292
|
+
it("rejects asymmetric per-side pinning (callerField + calleeQualified)", () => {
|
|
293
|
+
scratchDir = mkFixture(`version: 1\ncallBound:\n - caller: C\n callee: E\n position: 0\n callerField: WS\n calleeQualified: LK.Y\n`);
|
|
294
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/same pinning mode on both sides/);
|
|
295
|
+
});
|
|
296
|
+
it("rejects mixed-pin inferred family (some entries pin qualifiedNames, others don't)", () => {
|
|
297
|
+
scratchDir = mkFixture(`version: 1\ninferredHigh:\n - fieldName: A\n copybooks: [X, Y]\n qualifiedNames: [X.A, Y.A]\n - fieldName: B\n copybooks: [X, Y]\n`);
|
|
298
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/either ALL entries must pin qualifiedNames, or NONE/);
|
|
299
|
+
});
|
|
300
|
+
it("rejects YAML-null on db2 columnPairs (ambiguous vs `[]` and omitted)", () => {
|
|
301
|
+
scratchDir = mkFixture(`version: 1\ndb2:\n - table: T\n writer: W\n reader: R\n columnPairs:\n`);
|
|
302
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/columnPairs must be an array/);
|
|
303
|
+
});
|
|
304
|
+
it("prefixes per-entry validation errors with the manifest path", () => {
|
|
305
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: 42\n copybooks: [A]\n programs: [P1, P2]\n`);
|
|
306
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/Manifest .*lineage\.expected\.yaml:.*fieldName must be a string/);
|
|
307
|
+
});
|
|
308
|
+
it("rejects invalid deterministic linkage values", () => {
|
|
309
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: X\n copybooks: [A]\n programs: [P1, P2]\n linkage: garbage\n`);
|
|
310
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/linkage must be one of/);
|
|
311
|
+
});
|
|
312
|
+
it("rejects mixed-pin deterministic family (some entries pin linkage, others don't)", () => {
|
|
313
|
+
scratchDir = mkFixture(`version: 1\ndeterministic:\n - fieldName: X\n copybooks: [A]\n programs: [P1, P2]\n linkage: deterministic\n - fieldName: Y\n copybooks: [A]\n programs: [P1, P2]\n`);
|
|
314
|
+
expect(() => evaluateFieldLineage(scratchDir)).toThrow(/either ALL entries must pin linkage, or NONE/);
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
describe("field-lineage eval harness — deterministic linkage-tier grading", () => {
|
|
318
|
+
const basicFixture = resolve(process.cwd(), "src/cobol/__tests__/fixtures/eval/basic");
|
|
319
|
+
const replacingFixture = resolve(process.cwd(), "src/cobol/__tests__/fixtures/eval/replacing");
|
|
320
|
+
it("basic fixture's deterministic family scores 1.0 with tier=deterministic pinned", () => {
|
|
321
|
+
const report = evaluateFieldLineage(basicFixture);
|
|
322
|
+
const det = report.families.deterministic;
|
|
323
|
+
if (det.skipped)
|
|
324
|
+
throw new Error("deterministic unexpectedly skipped");
|
|
325
|
+
expect(det.precision).toBeCloseTo(1, 10);
|
|
326
|
+
expect(det.recall).toBeCloseTo(1, 10);
|
|
327
|
+
});
|
|
328
|
+
it("replacing fixture's deterministic family scores 1.0 with tier=deterministic-via-replacing pinned", () => {
|
|
329
|
+
const report = evaluateFieldLineage(replacingFixture);
|
|
330
|
+
const det = report.families.deterministic;
|
|
331
|
+
if (det.skipped)
|
|
332
|
+
throw new Error("deterministic unexpectedly skipped");
|
|
333
|
+
expect(det.precision).toBeCloseTo(1, 10);
|
|
334
|
+
expect(det.recall).toBeCloseTo(1, 10);
|
|
335
|
+
});
|
|
336
|
+
it("rejects swapped-tier manifest: a basic-style fixture with linkage=deterministic-via-replacing surfaces every entry as FP+FN", () => {
|
|
337
|
+
// Write a clone of the basic fixture but with the WRONG tier pinned —
|
|
338
|
+
// the builder emits `deterministic` (no REPLACING in the sources), so
|
|
339
|
+
// every pinned-as-via-replacing manifest entry should land as FN, and
|
|
340
|
+
// every emitted deterministic entry should land as FP. This is the
|
|
341
|
+
// anchor that proves tier pinning works: the previous tier-agnostic
|
|
342
|
+
// harness would have scored this 1.0/1.0.
|
|
343
|
+
const dir = mkdtempSync(join(tmpdir(), "lineage-eval-tier-"));
|
|
344
|
+
try {
|
|
345
|
+
// Copy basic fixture's COBOL sources verbatim.
|
|
346
|
+
const sources = [
|
|
347
|
+
"CALLEE.cbl",
|
|
348
|
+
"CALLER.cbl",
|
|
349
|
+
"CLIENT-REC.cpy",
|
|
350
|
+
"CLIENTA.cbl",
|
|
351
|
+
"CUSTOMER-REC.cpy",
|
|
352
|
+
"ORDERA.cbl",
|
|
353
|
+
"ORDERB.cbl",
|
|
354
|
+
];
|
|
355
|
+
for (const f of sources) {
|
|
356
|
+
const src = readFileSync(join(basicFixture, f), "utf-8");
|
|
357
|
+
writeFileSync(join(dir, f), src, "utf-8");
|
|
358
|
+
}
|
|
359
|
+
// Wrong-tier manifest: deterministic-via-replacing instead of deterministic.
|
|
360
|
+
writeFileSync(join(dir, "lineage.expected.yaml"), `version: 1\ndeterministic:\n - fieldName: CUSTOMER-REC\n copybooks: [CUSTOMER-REC]\n programs: [ORDERA, ORDERB]\n linkage: deterministic-via-replacing\n - fieldName: CUSTOMER-ID\n copybooks: [CUSTOMER-REC]\n programs: [ORDERA, ORDERB]\n linkage: deterministic-via-replacing\n - fieldName: CUSTOMER-NAME\n copybooks: [CUSTOMER-REC]\n programs: [ORDERA, ORDERB]\n linkage: deterministic-via-replacing\n - fieldName: CUSTOMER-ZIP\n copybooks: [CUSTOMER-REC]\n programs: [ORDERA, ORDERB]\n linkage: deterministic-via-replacing\n`, "utf-8");
|
|
361
|
+
const report = evaluateFieldLineage(dir);
|
|
362
|
+
const det = report.families.deterministic;
|
|
363
|
+
if (det.skipped)
|
|
364
|
+
throw new Error("deterministic unexpectedly skipped");
|
|
365
|
+
// Every expected entry is FN (wrong tier), every actual entry is FP.
|
|
366
|
+
expect(det.truePositives).toBe(0);
|
|
367
|
+
expect(det.falseNegatives.length).toBe(4);
|
|
368
|
+
expect(det.falsePositives.length).toBe(4);
|
|
369
|
+
// The FN keys carry the wrong tier suffix; the FP keys carry the right one.
|
|
370
|
+
expect(det.falseNegatives[0]).toContain("tier=deterministic-via-replacing");
|
|
371
|
+
expect(det.falsePositives[0]).toContain("tier=deterministic");
|
|
372
|
+
expect(det.falsePositives[0]).not.toContain("via-replacing");
|
|
373
|
+
}
|
|
374
|
+
finally {
|
|
375
|
+
rmSync(dir, { recursive: true, force: true });
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
//# sourceMappingURL=field-lineage-eval.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-lineage-eval.test.js","sourceRoot":"","sources":["../../../src/cobol/__tests__/field-lineage-eval.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,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YAC5E,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;YAC9D,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QAC/D,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1113,6 +1113,150 @@ describe("COBOL field lineage", () => {
|
|
|
1113
1113
|
// every other cohort either — lineage is null.
|
|
1114
1114
|
expect(lineage).toBeNull();
|
|
1115
1115
|
});
|
|
1116
|
+
it("Phase C: untouched leaves under a REPLACING cohort participate in cross-copybook inferred matching", () => {
|
|
1117
|
+
// CUSTOMER-REC has an empty cohort with one consumer (ORDERA) plus a
|
|
1118
|
+
// REPLACING cohort with two consumers (PROGA / PROGB), all sharing
|
|
1119
|
+
// the same untouched leaf CUSTOMER-ID (PIC 9(8) — distinct shape from
|
|
1120
|
+
// sharedCopybook so it doesn't tangle with that). LEGACY-PEER has
|
|
1121
|
+
// CUSTOMER-ID with the same shape and a matching sibling
|
|
1122
|
+
// CUSTOMER-ZIP. Pre-Phase-C, the cross-copybook pair would form only
|
|
1123
|
+
// via the empty cohort (one program on the CUSTOMER-REC side); Phase
|
|
1124
|
+
// C unions the REPLACING-cohort consumers into the same candidate
|
|
1125
|
+
// because the original (pre-substitution) leaf identity is the same.
|
|
1126
|
+
const customer = `
|
|
1127
|
+
01 CUSTOMER-REC.
|
|
1128
|
+
05 CUSTOMER-ID PIC 9(8).
|
|
1129
|
+
05 CUSTOMER-ZIP PIC 9(5).
|
|
1130
|
+
`;
|
|
1131
|
+
const legacyPeer = `
|
|
1132
|
+
01 LEGACY-PEER.
|
|
1133
|
+
05 CUSTOMER-ID PIC 9(8).
|
|
1134
|
+
05 CUSTOMER-ZIP PIC 9(5).
|
|
1135
|
+
`;
|
|
1136
|
+
const replacingProgram = (programId) => `
|
|
1137
|
+
IDENTIFICATION DIVISION.
|
|
1138
|
+
PROGRAM-ID. ${programId}.
|
|
1139
|
+
DATA DIVISION.
|
|
1140
|
+
WORKING-STORAGE SECTION.
|
|
1141
|
+
COPY CUSTOMER-REC REPLACING CUSTOMER-ZIP BY ZIP-CODE.
|
|
1142
|
+
PROCEDURE DIVISION.
|
|
1143
|
+
A000-MAIN SECTION.
|
|
1144
|
+
A100-START.
|
|
1145
|
+
STOP RUN.
|
|
1146
|
+
`;
|
|
1147
|
+
const lineage = buildFieldLineage([
|
|
1148
|
+
model(customer, "CUSTOMER-REC.cpy"),
|
|
1149
|
+
model(legacyPeer, "LEGACY-PEER.cpy"),
|
|
1150
|
+
model(program("ORDERA", "CUSTOMER-REC"), "ORDERA.cbl"),
|
|
1151
|
+
model(replacingProgram("PROGA"), "PROGA.cbl"),
|
|
1152
|
+
model(replacingProgram("PROGB"), "PROGB.cbl"),
|
|
1153
|
+
model(program("LEGACYA", "LEGACY-PEER"), "LEGACYA.cbl"),
|
|
1154
|
+
]);
|
|
1155
|
+
expect(lineage).not.toBeNull();
|
|
1156
|
+
const customerId = lineage.inferredHighConfidence.find((e) => e.fieldName === "CUSTOMER-ID");
|
|
1157
|
+
expect(customerId, "CUSTOMER-ID should pair high-confidence across cohorts").toBeDefined();
|
|
1158
|
+
// CUSTOMER-REC side carries programs from BOTH the empty cohort
|
|
1159
|
+
// (ORDERA) and the REPLACING cohort (PROGA, PROGB). Pre-Phase-C this
|
|
1160
|
+
// would have been [ORDERA] only.
|
|
1161
|
+
const customerSide = customerId.left.copybook.id === "copybook:CUSTOMER-REC"
|
|
1162
|
+
? customerId.left
|
|
1163
|
+
: customerId.right;
|
|
1164
|
+
expect(customerSide.programs.map((p) => p.id).sort()).toEqual([
|
|
1165
|
+
"program:ORDERA",
|
|
1166
|
+
"program:PROGA",
|
|
1167
|
+
"program:PROGB",
|
|
1168
|
+
]);
|
|
1169
|
+
});
|
|
1170
|
+
it("Phase C precision gate: a leaf renamed by REPLACING does NOT enter the inferred candidate pool", () => {
|
|
1171
|
+
// Both copybooks rename a distinct source field to the same target
|
|
1172
|
+
// (ENTITY-PK), but share two unrenamed siblings (COMMON-A, COMMON-B).
|
|
1173
|
+
// The unrenamed pair should match (recall gain Phase C delivers).
|
|
1174
|
+
// The renamed-into-the-same-target pair (ENTITY-PK) is laundered
|
|
1175
|
+
// evidence — the precision gate filters it. The companion eval
|
|
1176
|
+
// fixture (eval/replacing-inferred/) covers the full scenario; this
|
|
1177
|
+
// unit test pins the gate behavior at the builder level.
|
|
1178
|
+
const customer = `
|
|
1179
|
+
01 CUSTOMER-REC.
|
|
1180
|
+
05 USER-PK PIC X(8).
|
|
1181
|
+
05 COMMON-A PIC X(10).
|
|
1182
|
+
05 COMMON-B PIC X(10).
|
|
1183
|
+
`;
|
|
1184
|
+
const product = `
|
|
1185
|
+
01 PRODUCT-REC.
|
|
1186
|
+
05 SKU PIC X(8).
|
|
1187
|
+
05 COMMON-A PIC X(10).
|
|
1188
|
+
05 COMMON-B PIC X(10).
|
|
1189
|
+
`;
|
|
1190
|
+
const replacingProgram = (programId, copybook, from) => `
|
|
1191
|
+
IDENTIFICATION DIVISION.
|
|
1192
|
+
PROGRAM-ID. ${programId}.
|
|
1193
|
+
DATA DIVISION.
|
|
1194
|
+
WORKING-STORAGE SECTION.
|
|
1195
|
+
COPY ${copybook} REPLACING ${from} BY ENTITY-PK.
|
|
1196
|
+
PROCEDURE DIVISION.
|
|
1197
|
+
A000-MAIN SECTION.
|
|
1198
|
+
A100-START.
|
|
1199
|
+
STOP RUN.
|
|
1200
|
+
`;
|
|
1201
|
+
const lineage = buildFieldLineage([
|
|
1202
|
+
model(customer, "CUSTOMER-REC.cpy"),
|
|
1203
|
+
model(product, "PRODUCT-REC.cpy"),
|
|
1204
|
+
model(replacingProgram("USRA", "CUSTOMER-REC", "USER-PK"), "USRA.cbl"),
|
|
1205
|
+
model(replacingProgram("USRB", "CUSTOMER-REC", "USER-PK"), "USRB.cbl"),
|
|
1206
|
+
model(replacingProgram("PRDA", "PRODUCT-REC", "SKU"), "PRDA.cbl"),
|
|
1207
|
+
model(replacingProgram("PRDB", "PRODUCT-REC", "SKU"), "PRDB.cbl"),
|
|
1208
|
+
]);
|
|
1209
|
+
// COMMON-A and COMMON-B (untouched on both sides) should both emit —
|
|
1210
|
+
// Phase C's recall gain.
|
|
1211
|
+
const commonA = lineage?.inferredHighConfidence.find((e) => e.fieldName === "COMMON-A");
|
|
1212
|
+
const commonB = lineage?.inferredHighConfidence.find((e) => e.fieldName === "COMMON-B");
|
|
1213
|
+
expect(commonA, "COMMON-A pair should emit under Phase C").toBeDefined();
|
|
1214
|
+
expect(commonB, "COMMON-B pair should emit under Phase C").toBeDefined();
|
|
1215
|
+
// ENTITY-PK must NOT emit — both sides' names came from REPLACING.
|
|
1216
|
+
expect(lineage?.inferredHighConfidence.some((e) => e.fieldName === "ENTITY-PK"), "ENTITY-PK pair must be filtered by the precision gate").not.toBe(true);
|
|
1217
|
+
});
|
|
1218
|
+
it("Phase C precision gate: laundered siblings cannot supply sibling-overlap evidence on their own", () => {
|
|
1219
|
+
// Two copybooks each rename a different source to the same target
|
|
1220
|
+
// (LAUNDERED-NAME), leaving one untouched leaf X with NO other shared
|
|
1221
|
+
// siblings between the copybooks. Pre-refactor Phase C projected
|
|
1222
|
+
// siblings through REPLACING — both X's siblings would have contained
|
|
1223
|
+
// LAUNDERED-NAME, yielding a phantom sibling-overlap match. The
|
|
1224
|
+
// current Phase C uses pre-substitution siblings, so X's siblings
|
|
1225
|
+
// remain distinct (USER-FOO vs PROD-BAR) and the pair is correctly
|
|
1226
|
+
// rejected.
|
|
1227
|
+
const customer = `
|
|
1228
|
+
01 CUSTOMER-REC.
|
|
1229
|
+
05 USER-FOO PIC X(8).
|
|
1230
|
+
05 X-FIELD PIC X(10).
|
|
1231
|
+
`;
|
|
1232
|
+
const product = `
|
|
1233
|
+
01 PRODUCT-REC.
|
|
1234
|
+
05 PROD-BAR PIC X(8).
|
|
1235
|
+
05 X-FIELD PIC X(10).
|
|
1236
|
+
`;
|
|
1237
|
+
const replacingProgram = (programId, copybook, from) => `
|
|
1238
|
+
IDENTIFICATION DIVISION.
|
|
1239
|
+
PROGRAM-ID. ${programId}.
|
|
1240
|
+
DATA DIVISION.
|
|
1241
|
+
WORKING-STORAGE SECTION.
|
|
1242
|
+
COPY ${copybook} REPLACING ${from} BY LAUNDERED-NAME.
|
|
1243
|
+
PROCEDURE DIVISION.
|
|
1244
|
+
A000-MAIN SECTION.
|
|
1245
|
+
A100-START.
|
|
1246
|
+
STOP RUN.
|
|
1247
|
+
`;
|
|
1248
|
+
const lineage = buildFieldLineage([
|
|
1249
|
+
model(customer, "CUSTOMER-REC.cpy"),
|
|
1250
|
+
model(product, "PRODUCT-REC.cpy"),
|
|
1251
|
+
model(replacingProgram("USRA", "CUSTOMER-REC", "USER-FOO"), "USRA.cbl"),
|
|
1252
|
+
model(replacingProgram("USRB", "CUSTOMER-REC", "USER-FOO"), "USRB.cbl"),
|
|
1253
|
+
model(replacingProgram("PRDA", "PRODUCT-REC", "PROD-BAR"), "PRDA.cbl"),
|
|
1254
|
+
model(replacingProgram("PRDB", "PRODUCT-REC", "PROD-BAR"), "PRDB.cbl"),
|
|
1255
|
+
]);
|
|
1256
|
+
// X-FIELD must NOT match — the only would-be shared sibling
|
|
1257
|
+
// (LAUNDERED-NAME) was substitution-laundered into existence.
|
|
1258
|
+
expect(lineage?.inferredHighConfidence.some((e) => e.fieldName === "X-FIELD"), "X-FIELD pair must be rejected when the only shared sibling is laundered").not.toBe(true);
|
|
1259
|
+
});
|
|
1116
1260
|
it("normalizeLoadedFieldLineage backfills summary.deterministic.viaReplacing for pre-#39 JSON", () => {
|
|
1117
1261
|
const pre39 = {
|
|
1118
1262
|
summary: {
|