@agent-wiki/mcp 0.21.7 → 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__/call-boundary-lineage.test.js +410 -7
- package/dist/cobol/__tests__/call-boundary-lineage.test.js.map +1 -1
- package/dist/cobol/__tests__/code-analysis.test.js +2 -0
- package/dist/cobol/__tests__/code-analysis.test.js.map +1 -1
- 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/call-boundary-lineage.d.ts +13 -0
- package/dist/cobol/call-boundary-lineage.d.ts.map +1 -1
- package/dist/cobol/call-boundary-lineage.js +131 -25
- package/dist/cobol/call-boundary-lineage.js.map +1 -1
- package/dist/cobol/extractors.d.ts +36 -0
- package/dist/cobol/extractors.d.ts.map +1 -1
- package/dist/cobol/extractors.js +178 -0
- package/dist/cobol/extractors.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 +89 -14
- package/dist/cobol/field-lineage.js.map +1 -1
- package/dist/cobol/plugin.d.ts.map +1 -1
- package/dist/cobol/plugin.js +5 -0
- package/dist/cobol/plugin.js.map +1 -1
- package/docs/field-lineage-eval.md +234 -0
- package/package.json +1 -1
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Field-lineage eval harness
|
|
2
|
+
|
|
3
|
+
A minimal precision / recall yardstick for the three COBOL field-lineage
|
|
4
|
+
families: shared-copybook reuse (deterministic + inferred), `CALL ... USING`
|
|
5
|
+
boundary pairing, and shared-DB2-table cross-program flow. Lets tier
|
|
6
|
+
threshold changes (Phase C, semantic gates, dynamic-call resolver tweaks,
|
|
7
|
+
DB2 column-pair recall) be evaluated against ground-truth fixtures
|
|
8
|
+
instead of by inspection.
|
|
9
|
+
|
|
10
|
+
## Why
|
|
11
|
+
|
|
12
|
+
Every lineage tier the builder emits — `deterministic`, `inferredHigh`,
|
|
13
|
+
`inferredAmbiguous`, `inferredSemantic`, `callBound`, `db2` — has been
|
|
14
|
+
tuned via spot-check on hand-authored unit fixtures. There's been no
|
|
15
|
+
corpus-level "did this change improve recall without burning precision"
|
|
16
|
+
signal. The harness in `src/cobol/field-lineage-eval.ts` runs the full
|
|
17
|
+
build pipeline against a fixture directory, compares each family's
|
|
18
|
+
emitted entries to a YAML manifest, and reports per-family P/R/F1
|
|
19
|
+
plus the offending false-positive / false-negative keys.
|
|
20
|
+
|
|
21
|
+
## Where things live
|
|
22
|
+
|
|
23
|
+
- `src/cobol/field-lineage-eval.ts` — evaluator + markdown renderer
|
|
24
|
+
- `src/cobol/__tests__/field-lineage-eval.test.ts` — vitest entry point
|
|
25
|
+
- `src/cobol/__tests__/fixtures/eval/basic/` — first fixture corpus
|
|
26
|
+
- `*.cbl` / `*.cpy` — real COBOL sources fed to `parse` →
|
|
27
|
+
`extractModel` → `build*Lineage`
|
|
28
|
+
- `lineage.expected.yaml` — ground-truth manifest
|
|
29
|
+
|
|
30
|
+
## Manifest schema (v1)
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
version: 1
|
|
34
|
+
description: "Optional human-readable summary"
|
|
35
|
+
|
|
36
|
+
# Each family is optional. A family absent (or YAML-null) is *skipped*
|
|
37
|
+
# (not graded). A family present as `[]` is graded strictly — any emitted
|
|
38
|
+
# entry counts as a false positive. Unknown top-level keys are rejected
|
|
39
|
+
# at load time so typo'd family names don't silently degrade to skipped.
|
|
40
|
+
|
|
41
|
+
deterministic:
|
|
42
|
+
- fieldName: CUSTOMER-ID
|
|
43
|
+
copybooks: [CUSTOMER-REC] # logical names, no "copybook:" prefix
|
|
44
|
+
programs: [ORDERA, ORDERB] # program IDs, no "program:" prefix
|
|
45
|
+
# Optional linkage-tier pin. Either ALL deterministic entries pin
|
|
46
|
+
# `linkage`, or NONE do. When pinned, the canonical key includes the
|
|
47
|
+
# tier — a builder regression that emits the right field name under
|
|
48
|
+
# the wrong tier (e.g. plain `deterministic` instead of
|
|
49
|
+
# `deterministic-via-replacing`, losing the `replacing` evidence)
|
|
50
|
+
# lands as FN+FP. Values: `deterministic` | `deterministic-via-replacing`.
|
|
51
|
+
linkage: deterministic
|
|
52
|
+
|
|
53
|
+
inferredHigh:
|
|
54
|
+
- fieldName: CUSTOMER-ID
|
|
55
|
+
copybooks: [CUSTOMER-REC, CLIENT-REC] # pair (exactly two)
|
|
56
|
+
# Optional — pin the qualified paths when a leaf name repeats under
|
|
57
|
+
# different parents. If ANY entry in the family pins qualifiedNames,
|
|
58
|
+
# all entries are graded by qualified path; otherwise grading is by
|
|
59
|
+
# (fieldName, copybooks) only.
|
|
60
|
+
# qualifiedNames: [CUSTOMER-REC.CUSTOMER-ID, CLIENT-REC.CUSTOMER-ID]
|
|
61
|
+
|
|
62
|
+
inferredAmbiguous: []
|
|
63
|
+
inferredSemantic: []
|
|
64
|
+
|
|
65
|
+
callBound:
|
|
66
|
+
- caller: CALLER
|
|
67
|
+
callee: CALLEE
|
|
68
|
+
position: 0 # 0-indexed
|
|
69
|
+
callerField: WS-CUST-ID # leaf name (or use callerQualified for nested)
|
|
70
|
+
calleeField: LK-CUST-ID
|
|
71
|
+
# callerQualified / calleeQualified — pin qualified paths when the
|
|
72
|
+
# CALL boundary involves nested children. Mirrors the inferred-family
|
|
73
|
+
# rule: any qualified pin in the family switches the whole family to
|
|
74
|
+
# qualified-path grading.
|
|
75
|
+
|
|
76
|
+
db2:
|
|
77
|
+
- table: CUSTOMER
|
|
78
|
+
writer: PROG-INS
|
|
79
|
+
reader: PROG-SEL
|
|
80
|
+
# `columnPairs` is opt-in: omitting it grades only the (table, writer,
|
|
81
|
+
# reader) pair and ignores any column pairs the builder emits.
|
|
82
|
+
# Declaring `columnPairs: []` or a non-empty list grades column
|
|
83
|
+
# pairs strictly — emitted column pairs not listed become FPs.
|
|
84
|
+
columnPairs:
|
|
85
|
+
- column: CUST_ID
|
|
86
|
+
writerHostVar: WS-CUST-ID
|
|
87
|
+
readerHostVar: WS-OUT-CUST-ID
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
All identifier comparisons are case-insensitive and order-independent for
|
|
91
|
+
set-valued fields (`copybooks`, `programs`). Each manifest fact maps to
|
|
92
|
+
one canonical key; the actual builder's emission is converted to the same
|
|
93
|
+
key shape, and the two key sets are diffed.
|
|
94
|
+
|
|
95
|
+
### Validation
|
|
96
|
+
|
|
97
|
+
`loadManifest` validates at load time:
|
|
98
|
+
|
|
99
|
+
- `version: 1` (rejects other values — string `"1"` is NOT accepted; quote-strip in your editor).
|
|
100
|
+
- Unknown top-level keys are rejected.
|
|
101
|
+
- Per-family arrays must be arrays of objects with the required fields typed correctly (string for identifier fields, finite number for `position`, exactly-two-element array for inferred `copybooks`).
|
|
102
|
+
- Duplicate canonical keys within a family are rejected (a copy-paste error in the manifest would otherwise silently collapse under `Set` dedup).
|
|
103
|
+
- YAML-null (`deterministic:` with no value) normalizes to "family omitted".
|
|
104
|
+
|
|
105
|
+
A malformed manifest fails with a path-pointing error (`deterministic[2].copybooks must be an array of strings`), not a deep TypeError from inside the grader.
|
|
106
|
+
|
|
107
|
+
## Metrics
|
|
108
|
+
|
|
109
|
+
Per family:
|
|
110
|
+
|
|
111
|
+
- `expected` / `actual` — set sizes after key canonicalization
|
|
112
|
+
- `truePositives` — set intersection
|
|
113
|
+
- `falsePositives` — actual − expected (canonical keys, sorted)
|
|
114
|
+
- `falseNegatives` — expected − actual
|
|
115
|
+
- `precision = TP / (TP + FP)` — 1.0 when no actuals
|
|
116
|
+
- `recall = TP / (TP + FN)` — 1.0 when no expectations
|
|
117
|
+
- `f1 = 2·P·R / (P + R)` — 0 when both P and R are 0
|
|
118
|
+
|
|
119
|
+
A **vacuous** family (manifest `[]` + zero emissions) renders with `—`
|
|
120
|
+
in metric cells rather than 100% so a dashboard reader can tell it apart
|
|
121
|
+
from a family that legitimately scored perfect on real observations.
|
|
122
|
+
|
|
123
|
+
The `overall` block is a **micro-average** across graded families:
|
|
124
|
+
TP, FP, FN are summed across families before computing P/R/F1, so a
|
|
125
|
+
high-volume family (lots of deterministic entries) dominates a
|
|
126
|
+
low-volume one (a handful of CALL-USING pairs). Skipped families and
|
|
127
|
+
vacuous families contribute nothing.
|
|
128
|
+
|
|
129
|
+
## How to run
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx vitest run src/cobol/__tests__/field-lineage-eval.test.ts
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or in test code:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { evaluateFieldLineage, renderEvalReport } from "../field-lineage-eval.js";
|
|
139
|
+
|
|
140
|
+
const report = evaluateFieldLineage(fixtureDir, {
|
|
141
|
+
// Mirrors the production plugin call site — pass site-specific
|
|
142
|
+
// system callees here when the fixture references them.
|
|
143
|
+
// extraSystemCallees: ["MQCONN", "MQDISC"],
|
|
144
|
+
});
|
|
145
|
+
expect(report.overall.precision).toBeCloseTo(1, 10);
|
|
146
|
+
console.log(renderEvalReport(report)); // markdown table + FP/FN lists
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The harness is a pure module — it reads from `fixtureDir` and returns the
|
|
150
|
+
report. No CLI wrapper yet; vitest is the runner.
|
|
151
|
+
|
|
152
|
+
## Adding a fixture
|
|
153
|
+
|
|
154
|
+
1. Create `src/cobol/__tests__/fixtures/eval/<name>/` with one or more
|
|
155
|
+
`.cbl` / `.cpy` files at the top level (subdirectories are ignored).
|
|
156
|
+
2. Write `lineage.expected.yaml` listing every entry you expect the
|
|
157
|
+
builder to emit for the families you want graded. Omit families you
|
|
158
|
+
don't want to grade; declare `[]` for families that should emit
|
|
159
|
+
nothing.
|
|
160
|
+
3. Add a test case that calls `evaluateFieldLineage(fixtureDir)` and
|
|
161
|
+
asserts the precision / recall thresholds you require — `1.0 / 1.0`
|
|
162
|
+
for ground-truthed fixtures, or a corpus-baseline floor for messier
|
|
163
|
+
real-world corpora. Use `.toBeCloseTo(1, 10)` rather than `.toBe(1)`
|
|
164
|
+
so float accumulation in the F1 formula doesn't make the assertion
|
|
165
|
+
brittle on future non-perfect fixtures.
|
|
166
|
+
|
|
167
|
+
When a tier's gates are changed (e.g. the Phase C precision gate at
|
|
168
|
+
`field-lineage.ts:773`, or the inferred-semantic five-gate at the
|
|
169
|
+
matcher), rerun every fixture under `eval/` and confirm metrics move
|
|
170
|
+
in the intended direction before landing the change.
|
|
171
|
+
|
|
172
|
+
## Known limitations
|
|
173
|
+
|
|
174
|
+
- **The production combiner (`combineFieldLineage`) is bypassed.** The
|
|
175
|
+
harness inspects each builder's raw output directly. If a future
|
|
176
|
+
change adds cross-family filtering at combine time, the harness's
|
|
177
|
+
metrics will diverge from what `wiki/cobol/field-lineage.md`
|
|
178
|
+
regeneration produces.
|
|
179
|
+
- **Fixture source discovery is non-recursive.** Only flat `.cbl` /
|
|
180
|
+
`.cpy` files at the fixture-dir top level are picked up.
|
|
181
|
+
Subdirectory layouts (`programs/`, `copybooks/`) are silently
|
|
182
|
+
ignored; reorganize as flat or extend the harness if a fixture
|
|
183
|
+
outgrows it.
|
|
184
|
+
- **Field-lineage diagnostics are not surfaced in the report.** If a
|
|
185
|
+
source file fails to parse cleanly (zero data items, copybook
|
|
186
|
+
truncation, etc.), the affected family lights up as FN with no hint
|
|
187
|
+
that the upstream parse was the cause. Re-run the affected file
|
|
188
|
+
through `code_parse` to inspect diagnostics.
|
|
189
|
+
|
|
190
|
+
## Fixture inventory
|
|
191
|
+
|
|
192
|
+
- `eval/basic/` — deterministic copybook reuse + inferred-high cross-
|
|
193
|
+
copybook + CALL-USING positional pair. The widest-coverage fixture;
|
|
194
|
+
exercises three families.
|
|
195
|
+
- `eval/db2-column-pairs/` — DB2 cross-program flow with column-level
|
|
196
|
+
binding. INSERT INTO T (cols) VALUES (:hv) on the writer + SELECT
|
|
197
|
+
cols INTO :hv FROM T on the reader. Anchors the `:writer-hv → COL
|
|
198
|
+
→ :reader-hv` pairing emitted by `db2-table-lineage.ts:159`. All
|
|
199
|
+
other families declared `[]` to confirm the harness doesn't emit
|
|
200
|
+
anything spurious for them.
|
|
201
|
+
- `eval/replacing/` — `deterministic-via-replacing` cohort (#39
|
|
202
|
+
Phase B). Two consumers share a COPY ... REPLACING clause; the
|
|
203
|
+
manifest pins the post-substitution field names. Anchors against
|
|
204
|
+
a Phase B regression that drops the rename.
|
|
205
|
+
- `eval/replacing-inferred/` — Phase C (REPLACING-aware inferred).
|
|
206
|
+
Two unrelated copybooks consumed only via REPLACING; the matcher
|
|
207
|
+
widens candidate sourcing to include those cohorts but uses the
|
|
208
|
+
ORIGINAL (pre-substitution) field as matching evidence — projection
|
|
209
|
+
is only used to gate out leaves the cohort would have renamed (their
|
|
210
|
+
name has no source-text backing). The fixture verifies both halves:
|
|
211
|
+
COMMON-ID / COMMON-NAME emit as cross-copybook inferred-high pairs
|
|
212
|
+
on their pre-substitution names (recall gain over pre-Phase-C);
|
|
213
|
+
ENTITY-PK (would be laundered from USER-PK + SKU into the same
|
|
214
|
+
target name) is filtered out by the precision gate.
|
|
215
|
+
|
|
216
|
+
A `inferredSemantic` fixture is not yet included — the shape-keyed
|
|
217
|
+
matcher has five conjoined gates (PIC match, USAGE match, level
|
|
218
|
+
match, exact parent path, ≥2 sibling overlap) that interact in
|
|
219
|
+
subtle ways. Building a minimal fixture that exercises ONLY semantic
|
|
220
|
+
without bleeding into the inferred-high tier requires more care than
|
|
221
|
+
the others, and is deferred until there's a concrete tier change
|
|
222
|
+
that needs it as a regression anchor.
|
|
223
|
+
|
|
224
|
+
## Future
|
|
225
|
+
|
|
226
|
+
- A CLI surface (`agent-wiki eval lineage <dir>`) once there are enough
|
|
227
|
+
fixtures to make running the suite outside vitest worthwhile.
|
|
228
|
+
- A baseline-comparison mode that diffs current metrics against a
|
|
229
|
+
committed `baseline.json` and fails if precision regresses — once we
|
|
230
|
+
have stable enough corpora to baseline.
|
|
231
|
+
- A `inferredSemantic` fixture (see note above).
|
|
232
|
+
- Confidence-tier grading on `callBound` (`deterministic` vs `high`) —
|
|
233
|
+
same shape as deterministic-family linkage pinning; deferred until a
|
|
234
|
+
fixture needs the discrimination.
|
package/package.json
CHANGED