@agent-wiki/mcp 0.17.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/.claude-plugin/plugin.json +7 -0
  2. package/README.md +171 -0
  3. package/architecture.svg +58 -0
  4. package/dist/atlassian.d.ts +63 -0
  5. package/dist/atlassian.d.ts.map +1 -0
  6. package/dist/atlassian.js +596 -0
  7. package/dist/atlassian.js.map +1 -0
  8. package/dist/cli.d.ts +11 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +391 -0
  11. package/dist/cli.js.map +1 -0
  12. package/dist/cobol/__tests__/call-boundary-lineage.test.d.ts +2 -0
  13. package/dist/cobol/__tests__/call-boundary-lineage.test.d.ts.map +1 -0
  14. package/dist/cobol/__tests__/call-boundary-lineage.test.js +505 -0
  15. package/dist/cobol/__tests__/call-boundary-lineage.test.js.map +1 -0
  16. package/dist/cobol/__tests__/code-analysis.test.d.ts +2 -0
  17. package/dist/cobol/__tests__/code-analysis.test.d.ts.map +1 -0
  18. package/dist/cobol/__tests__/code-analysis.test.js +465 -0
  19. package/dist/cobol/__tests__/code-analysis.test.js.map +1 -0
  20. package/dist/cobol/__tests__/db2-table-lineage.test.d.ts +2 -0
  21. package/dist/cobol/__tests__/db2-table-lineage.test.d.ts.map +1 -0
  22. package/dist/cobol/__tests__/db2-table-lineage.test.js +182 -0
  23. package/dist/cobol/__tests__/db2-table-lineage.test.js.map +1 -0
  24. package/dist/cobol/__tests__/evidence-mapping.test.d.ts +2 -0
  25. package/dist/cobol/__tests__/evidence-mapping.test.d.ts.map +1 -0
  26. package/dist/cobol/__tests__/evidence-mapping.test.js +49 -0
  27. package/dist/cobol/__tests__/evidence-mapping.test.js.map +1 -0
  28. package/dist/cobol/__tests__/extractors.test.d.ts +2 -0
  29. package/dist/cobol/__tests__/extractors.test.d.ts.map +1 -0
  30. package/dist/cobol/__tests__/extractors.test.js +189 -0
  31. package/dist/cobol/__tests__/extractors.test.js.map +1 -0
  32. package/dist/cobol/__tests__/field-lineage.test.d.ts +2 -0
  33. package/dist/cobol/__tests__/field-lineage.test.d.ts.map +1 -0
  34. package/dist/cobol/__tests__/field-lineage.test.js +329 -0
  35. package/dist/cobol/__tests__/field-lineage.test.js.map +1 -0
  36. package/dist/cobol/__tests__/graph.test.d.ts +2 -0
  37. package/dist/cobol/__tests__/graph.test.d.ts.map +1 -0
  38. package/dist/cobol/__tests__/graph.test.js +456 -0
  39. package/dist/cobol/__tests__/graph.test.js.map +1 -0
  40. package/dist/cobol/__tests__/integration.test.d.ts +2 -0
  41. package/dist/cobol/__tests__/integration.test.d.ts.map +1 -0
  42. package/dist/cobol/__tests__/integration.test.js +971 -0
  43. package/dist/cobol/__tests__/integration.test.js.map +1 -0
  44. package/dist/cobol/__tests__/lexer.test.d.ts +2 -0
  45. package/dist/cobol/__tests__/lexer.test.d.ts.map +1 -0
  46. package/dist/cobol/__tests__/lexer.test.js +111 -0
  47. package/dist/cobol/__tests__/lexer.test.js.map +1 -0
  48. package/dist/cobol/__tests__/parser.test.d.ts +2 -0
  49. package/dist/cobol/__tests__/parser.test.d.ts.map +1 -0
  50. package/dist/cobol/__tests__/parser.test.js +180 -0
  51. package/dist/cobol/__tests__/parser.test.js.map +1 -0
  52. package/dist/cobol/__tests__/variable-tracer.test.d.ts +2 -0
  53. package/dist/cobol/__tests__/variable-tracer.test.d.ts.map +1 -0
  54. package/dist/cobol/__tests__/variable-tracer.test.js +256 -0
  55. package/dist/cobol/__tests__/variable-tracer.test.js.map +1 -0
  56. package/dist/cobol/__tests__/wiki-gen.test.d.ts +2 -0
  57. package/dist/cobol/__tests__/wiki-gen.test.d.ts.map +1 -0
  58. package/dist/cobol/__tests__/wiki-gen.test.js +76 -0
  59. package/dist/cobol/__tests__/wiki-gen.test.js.map +1 -0
  60. package/dist/cobol/call-boundary-lineage.d.ts +49 -0
  61. package/dist/cobol/call-boundary-lineage.d.ts.map +1 -0
  62. package/dist/cobol/call-boundary-lineage.js +159 -0
  63. package/dist/cobol/call-boundary-lineage.js.map +1 -0
  64. package/dist/cobol/db2-table-lineage.d.ts +45 -0
  65. package/dist/cobol/db2-table-lineage.d.ts.map +1 -0
  66. package/dist/cobol/db2-table-lineage.js +127 -0
  67. package/dist/cobol/db2-table-lineage.js.map +1 -0
  68. package/dist/cobol/evidence-mapping.d.ts +31 -0
  69. package/dist/cobol/evidence-mapping.d.ts.map +1 -0
  70. package/dist/cobol/evidence-mapping.js +27 -0
  71. package/dist/cobol/evidence-mapping.js.map +1 -0
  72. package/dist/cobol/extractors.d.ts +88 -0
  73. package/dist/cobol/extractors.d.ts.map +1 -0
  74. package/dist/cobol/extractors.js +297 -0
  75. package/dist/cobol/extractors.js.map +1 -0
  76. package/dist/cobol/field-lineage.d.ts +101 -0
  77. package/dist/cobol/field-lineage.d.ts.map +1 -0
  78. package/dist/cobol/field-lineage.js +603 -0
  79. package/dist/cobol/field-lineage.js.map +1 -0
  80. package/dist/cobol/graph.d.ts +182 -0
  81. package/dist/cobol/graph.d.ts.map +1 -0
  82. package/dist/cobol/graph.js +453 -0
  83. package/dist/cobol/graph.js.map +1 -0
  84. package/dist/cobol/lexer.d.ts +15 -0
  85. package/dist/cobol/lexer.d.ts.map +1 -0
  86. package/dist/cobol/lexer.js +251 -0
  87. package/dist/cobol/lexer.js.map +1 -0
  88. package/dist/cobol/parser.d.ts +13 -0
  89. package/dist/cobol/parser.d.ts.map +1 -0
  90. package/dist/cobol/parser.js +584 -0
  91. package/dist/cobol/parser.js.map +1 -0
  92. package/dist/cobol/plugin.d.ts +23 -0
  93. package/dist/cobol/plugin.d.ts.map +1 -0
  94. package/dist/cobol/plugin.js +507 -0
  95. package/dist/cobol/plugin.js.map +1 -0
  96. package/dist/cobol/types.d.ts +73 -0
  97. package/dist/cobol/types.d.ts.map +1 -0
  98. package/dist/cobol/types.js +9 -0
  99. package/dist/cobol/types.js.map +1 -0
  100. package/dist/cobol/variable-tracer.d.ts +31 -0
  101. package/dist/cobol/variable-tracer.d.ts.map +1 -0
  102. package/dist/cobol/variable-tracer.js +361 -0
  103. package/dist/cobol/variable-tracer.js.map +1 -0
  104. package/dist/cobol/wiki-gen.d.ts +18 -0
  105. package/dist/cobol/wiki-gen.d.ts.map +1 -0
  106. package/dist/cobol/wiki-gen.js +222 -0
  107. package/dist/cobol/wiki-gen.js.map +1 -0
  108. package/dist/code-analysis.d.ts +160 -0
  109. package/dist/code-analysis.d.ts.map +1 -0
  110. package/dist/code-analysis.js +53 -0
  111. package/dist/code-analysis.js.map +1 -0
  112. package/dist/evidence-search.d.ts +43 -0
  113. package/dist/evidence-search.d.ts.map +1 -0
  114. package/dist/evidence-search.js +112 -0
  115. package/dist/evidence-search.js.map +1 -0
  116. package/dist/evidence-search.test.d.ts +2 -0
  117. package/dist/evidence-search.test.d.ts.map +1 -0
  118. package/dist/evidence-search.test.js +98 -0
  119. package/dist/evidence-search.test.js.map +1 -0
  120. package/dist/evidence.d.ts +32 -0
  121. package/dist/evidence.d.ts.map +1 -0
  122. package/dist/evidence.js +16 -0
  123. package/dist/evidence.js.map +1 -0
  124. package/dist/evidence.test.d.ts +2 -0
  125. package/dist/evidence.test.d.ts.map +1 -0
  126. package/dist/evidence.test.js +51 -0
  127. package/dist/evidence.test.js.map +1 -0
  128. package/dist/extraction.d.ts +40 -0
  129. package/dist/extraction.d.ts.map +1 -0
  130. package/dist/extraction.js +283 -0
  131. package/dist/extraction.js.map +1 -0
  132. package/dist/extraction.test.d.ts +5 -0
  133. package/dist/extraction.test.d.ts.map +1 -0
  134. package/dist/extraction.test.js +137 -0
  135. package/dist/extraction.test.js.map +1 -0
  136. package/dist/index.d.ts +38 -0
  137. package/dist/index.d.ts.map +1 -0
  138. package/dist/index.js +35 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/queue.d.ts +52 -0
  141. package/dist/queue.d.ts.map +1 -0
  142. package/dist/queue.js +139 -0
  143. package/dist/queue.js.map +1 -0
  144. package/dist/queue.test.d.ts +2 -0
  145. package/dist/queue.test.d.ts.map +1 -0
  146. package/dist/queue.test.js +161 -0
  147. package/dist/queue.test.js.map +1 -0
  148. package/dist/search.d.ts +163 -0
  149. package/dist/search.d.ts.map +1 -0
  150. package/dist/search.js +653 -0
  151. package/dist/search.js.map +1 -0
  152. package/dist/search.test.d.ts +6 -0
  153. package/dist/search.test.d.ts.map +1 -0
  154. package/dist/search.test.js +551 -0
  155. package/dist/search.test.js.map +1 -0
  156. package/dist/server.d.ts +33 -0
  157. package/dist/server.d.ts.map +1 -0
  158. package/dist/server.js +2530 -0
  159. package/dist/server.js.map +1 -0
  160. package/dist/server.test.d.ts +8 -0
  161. package/dist/server.test.d.ts.map +1 -0
  162. package/dist/server.test.js +2397 -0
  163. package/dist/server.test.js.map +1 -0
  164. package/dist/version.d.ts +2 -0
  165. package/dist/version.d.ts.map +1 -0
  166. package/dist/version.js +5 -0
  167. package/dist/version.js.map +1 -0
  168. package/dist/wiki.d.ts +496 -0
  169. package/dist/wiki.d.ts.map +1 -0
  170. package/dist/wiki.js +2677 -0
  171. package/dist/wiki.js.map +1 -0
  172. package/dist/wiki.test.d.ts +8 -0
  173. package/dist/wiki.test.d.ts.map +1 -0
  174. package/dist/wiki.test.js +1881 -0
  175. package/dist/wiki.test.js.map +1 -0
  176. package/docs/code-analysis-plugins.md +169 -0
  177. package/docs/configuration.md +135 -0
  178. package/docs/diagrams/cobol-analysis-flow.png +0 -0
  179. package/docs/diagrams/cobol-analysis-flow.svg +156 -0
  180. package/docs/evidence-envelope.md +176 -0
  181. package/docs/graph-1.gif +0 -0
  182. package/docs/legacy-code-knowledge-compiler-prd.md +511 -0
  183. package/docs/product-direction.md +120 -0
  184. package/docs/request-optimization.md +201 -0
  185. package/docs/search.md +266 -0
  186. package/docs/tools.md +269 -0
  187. package/graph-viewer/dist/cli.d.ts +3 -0
  188. package/graph-viewer/dist/cli.d.ts.map +1 -0
  189. package/graph-viewer/dist/cli.js +97 -0
  190. package/graph-viewer/dist/cli.js.map +1 -0
  191. package/graph-viewer/dist/graph.d.ts +14 -0
  192. package/graph-viewer/dist/graph.d.ts.map +1 -0
  193. package/graph-viewer/dist/graph.js +96 -0
  194. package/graph-viewer/dist/graph.js.map +1 -0
  195. package/graph-viewer/dist/index.d.ts +6 -0
  196. package/graph-viewer/dist/index.d.ts.map +1 -0
  197. package/graph-viewer/dist/index.js +4 -0
  198. package/graph-viewer/dist/index.js.map +1 -0
  199. package/graph-viewer/dist/parse.d.ts +10 -0
  200. package/graph-viewer/dist/parse.d.ts.map +1 -0
  201. package/graph-viewer/dist/parse.js +62 -0
  202. package/graph-viewer/dist/parse.js.map +1 -0
  203. package/graph-viewer/dist/server.d.ts +15 -0
  204. package/graph-viewer/dist/server.d.ts.map +1 -0
  205. package/graph-viewer/dist/server.js +168 -0
  206. package/graph-viewer/dist/server.js.map +1 -0
  207. package/graph-viewer/dist/types.d.ts +48 -0
  208. package/graph-viewer/dist/types.d.ts.map +1 -0
  209. package/graph-viewer/dist/types.js +2 -0
  210. package/graph-viewer/dist/types.js.map +1 -0
  211. package/graph-viewer/public/app.js +525 -0
  212. package/graph-viewer/public/index.html +68 -0
  213. package/graph-viewer/public/style.css +68 -0
  214. package/package.json +73 -0
  215. package/skills/aceclaw/SKILL.md +173 -0
  216. package/skills/agent-wiki/SKILL.md +184 -0
  217. package/skills/agent-wiki/references/tools-reference.md +368 -0
@@ -0,0 +1,971 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdtempSync, rmSync, readFileSync, existsSync } from "fs";
3
+ import { join, resolve } from "path";
4
+ import { tmpdir } from "os";
5
+ import { Wiki } from "../../wiki.js";
6
+ import { handleTool } from "../../server.js";
7
+ const FIXTURES = resolve(process.cwd(), "src/cobol/__tests__/fixtures");
8
+ describe("COBOL MCP tools integration", () => {
9
+ let wiki;
10
+ let tmp;
11
+ beforeEach(() => {
12
+ tmp = mkdtempSync(join(tmpdir(), "cobol-test-"));
13
+ wiki = Wiki.init(tmp);
14
+ });
15
+ afterEach(() => {
16
+ rmSync(tmp, { recursive: true, force: true });
17
+ });
18
+ it("code_parse succeeds end-to-end with a .cbl file", async () => {
19
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
20
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
21
+ const result = await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
22
+ expect(typeof result).toBe("string");
23
+ const parsed = JSON.parse(result);
24
+ expect(parsed.summary.unitName).toBe("PAYROLL");
25
+ expect(parsed.artifacts.length).toBe(5); // ast, normalized, summary, model, knowledge-graph
26
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/PAYROLL.model.json");
27
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/knowledge-graph.json");
28
+ expect(parsed.wikiPages).toContain("cobol/programs/payroll.md");
29
+ expect(parsed.wikiPages).toContain("cobol/system-map.md");
30
+ // Verify wiki page was actually written to disk
31
+ const wikiPage = join(tmp, "wiki", "cobol", "programs", "payroll.md");
32
+ expect(existsSync(wikiPage)).toBe(true);
33
+ const pageContent = readFileSync(wikiPage, "utf-8");
34
+ expect(pageContent).toContain("PAYROLL");
35
+ // Verify normalized model artifact exists
36
+ const normalized = join(tmp, "raw", "parsed", "cobol", "PAYROLL.normalized.json");
37
+ expect(existsSync(normalized)).toBe(true);
38
+ const normalizedContent = JSON.parse(readFileSync(normalized, "utf-8"));
39
+ expect(normalizedContent.units).toBeDefined();
40
+ expect(normalizedContent.units[0].language).toBe("COBOL");
41
+ });
42
+ it("code_parse with trace_variable returns variable references", async () => {
43
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
44
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
45
+ const result = await handleTool(wiki, "code_parse", {
46
+ path: "PAYROLL.cbl",
47
+ trace_variable: "WS-TOTAL-SALARY",
48
+ });
49
+ const parsed = JSON.parse(result);
50
+ expect(parsed.variableTrace).toBeDefined();
51
+ expect(parsed.variableTrace.length).toBeGreaterThan(0);
52
+ });
53
+ it("code_trace_variable succeeds end-to-end", async () => {
54
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
55
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
56
+ const result = await handleTool(wiki, "code_trace_variable", {
57
+ path: "PAYROLL.cbl",
58
+ variable: "EMP-SALARY",
59
+ });
60
+ const parsed = JSON.parse(result);
61
+ expect(parsed.variable).toBe("EMP-SALARY");
62
+ expect(parsed.references.length).toBeGreaterThan(0);
63
+ });
64
+ it("code_query procedure_flow returns section and paragraph PERFORM flow", async () => {
65
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
66
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
67
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
68
+ const result = await handleTool(wiki, "code_query", {
69
+ query_type: "procedure_flow",
70
+ path: "PAYROLL.cbl",
71
+ procedure: "A100-INIT",
72
+ });
73
+ const parsed = JSON.parse(result);
74
+ expect(parsed.query.type).toBe("procedure_flow");
75
+ expect(parsed.summary.performRelations).toBeGreaterThanOrEqual(3);
76
+ expect(parsed.sectionCalls.some((entry) => entry.fromSection === "A000-MAIN" && entry.toSection === "B000-PROCESS")).toBe(true);
77
+ expect(parsed.flowByDepth.length).toBeGreaterThanOrEqual(1);
78
+ expect(parsed.flowByDepth[0].nodes.some((node) => node.name === "B000-PROCESS")).toBe(true);
79
+ expect(parsed.flowByDepth[0].nodes.some((node) => node.name === "C000-FINALIZE")).toBe(true);
80
+ });
81
+ it("code_query procedure_flow supports section-focused traversal", async () => {
82
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
83
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
84
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
85
+ const result = await handleTool(wiki, "code_query", {
86
+ query_type: "procedure_flow",
87
+ path: "PAYROLL.cbl",
88
+ procedure: "A000-MAIN",
89
+ procedure_kind: "section",
90
+ });
91
+ const parsed = JSON.parse(result);
92
+ expect(parsed.focus.name).toBe("A000-MAIN");
93
+ expect(parsed.focus.kind).toBe("section");
94
+ expect(parsed.flowByDepth.length).toBeGreaterThanOrEqual(1);
95
+ expect(parsed.flowByDepth[0].nodes.some((node) => node.name === "B000-PROCESS")).toBe(true);
96
+ expect(parsed.flowByDepth[0].nodes.some((node) => node.name === "C000-FINALIZE")).toBe(true);
97
+ const processNode = parsed.flowByDepth[0].nodes.find((node) => node.name === "B000-PROCESS");
98
+ expect(processNode.via.some((edge) => edge.viaParagraph === "A100-INIT")).toBe(true);
99
+ });
100
+ it("code_impact reports affected programs for a resolved copybook", async () => {
101
+ const invoiceSrc = readFileSync(join(FIXTURES, "INVOICE.cbl"), "utf-8");
102
+ const dateUtilsSrc = readFileSync(join(FIXTURES, "DATE-UTILS.cpy"), "utf-8");
103
+ wiki.rawAdd("INVOICE.cbl", { content: invoiceSrc });
104
+ wiki.rawAdd("DATE-UTILS.cpy", { content: dateUtilsSrc });
105
+ await handleTool(wiki, "code_parse", { path: "INVOICE.cbl" });
106
+ await handleTool(wiki, "code_parse", { path: "DATE-UTILS.cpy" });
107
+ const result = await handleTool(wiki, "code_impact", {
108
+ node_id: "DATE-UTILS",
109
+ kind: "copybook",
110
+ });
111
+ const parsed = JSON.parse(result);
112
+ expect(parsed.source.node_id).toBe("copybook:DATE-UTILS");
113
+ expect(parsed.source.resolved).toBe(true);
114
+ expect(parsed.summary.affectedNodes).toBeGreaterThanOrEqual(1);
115
+ expect(parsed.impactedByDepth).toHaveLength(1);
116
+ expect(parsed.impactedByDepth[0].depth).toBe(1);
117
+ expect(parsed.impactedByDepth[0].nodes.some((n) => n.node_id === "program:INVOICE")).toBe(true);
118
+ const invoice = parsed.impactedByDepth[0].nodes.find((n) => n.node_id === "program:INVOICE");
119
+ expect(invoice.resolved).toBe(true);
120
+ expect(invoice.via.some((e) => e.relationship === "COPIES" && e.to === "copybook:DATE-UTILS")).toBe(true);
121
+ });
122
+ it("code_impact works for unresolved source nodes and marks downstream warnings", async () => {
123
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
124
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
125
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
126
+ const result = await handleTool(wiki, "code_impact", {
127
+ node_id: "program:CALC-TAX",
128
+ });
129
+ const parsed = JSON.parse(result);
130
+ expect(parsed.source.node_id).toBe("program:CALC-TAX");
131
+ expect(parsed.source.resolved).toBe(false);
132
+ expect(parsed.impactedByDepth).toHaveLength(1);
133
+ const level1 = parsed.impactedByDepth[0];
134
+ expect(level1.nodes.some((n) => n.node_id === "program:PAYROLL")).toBe(true);
135
+ const payroll = level1.nodes.find((n) => n.node_id === "program:PAYROLL");
136
+ expect(payroll.via.some((e) => e.relationship === "CALLS" && e.to === "program:CALC-TAX")).toBe(true);
137
+ expect(parsed.diagnostics.some((d) => d.message.includes("program:CALC-TAX"))).toBe(true);
138
+ });
139
+ it("code_parse persists field-lineage artifacts and wiki summary when copybooks are shared", async () => {
140
+ const copybook = `
141
+ 01 CUSTOMER-REC.
142
+ 05 CUSTOMER-ID PIC X(10).
143
+ 05 CUSTOMER-ADDRESS.
144
+ 10 ZIP-CODE PIC 9(5).
145
+ `;
146
+ const orderA = `
147
+ IDENTIFICATION DIVISION.
148
+ PROGRAM-ID. ORDERA.
149
+ DATA DIVISION.
150
+ WORKING-STORAGE SECTION.
151
+ COPY CUSTOMER-REC.
152
+ PROCEDURE DIVISION.
153
+ A000-MAIN SECTION.
154
+ A100-START.
155
+ STOP RUN.
156
+ `;
157
+ const orderB = `
158
+ IDENTIFICATION DIVISION.
159
+ PROGRAM-ID. ORDERB.
160
+ DATA DIVISION.
161
+ WORKING-STORAGE SECTION.
162
+ COPY CUSTOMER-REC.
163
+ PROCEDURE DIVISION.
164
+ A000-MAIN SECTION.
165
+ A100-START.
166
+ STOP RUN.
167
+ `;
168
+ wiki.rawAdd("ORDERA.cbl", { content: orderA });
169
+ wiki.rawAdd("ORDERB.cbl", { content: orderB });
170
+ wiki.rawAdd("CUSTOMER-REC.cpy", { content: copybook });
171
+ await handleTool(wiki, "code_parse", { path: "ORDERA.cbl" });
172
+ await handleTool(wiki, "code_parse", { path: "ORDERB.cbl" });
173
+ const result = await handleTool(wiki, "code_parse", { path: "CUSTOMER-REC.cpy" });
174
+ const parsed = JSON.parse(result);
175
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/field-lineage.json");
176
+ expect(parsed.wikiPages).toContain("cobol/field-lineage.md");
177
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
178
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
179
+ expect(existsSync(lineagePath)).toBe(true);
180
+ expect(existsSync(pagePath)).toBe(true);
181
+ const lineage = JSON.parse(readFileSync(lineagePath, "utf-8"));
182
+ expect(lineage.summary.deterministic.fields).toBeGreaterThan(0);
183
+ expect(lineage.deterministic.some((entry) => entry.fieldName === "ZIP-CODE")).toBe(true);
184
+ const page = readFileSync(pagePath, "utf-8");
185
+ expect(page).toContain("CUSTOMER-REC");
186
+ // No CALL USING in this fixture, so the call-boundary section should be absent.
187
+ expect(page).not.toContain("Call Boundary Field Lineage");
188
+ expect(page).not.toContain("Call sites with USING args");
189
+ });
190
+ it("code_query field_lineage returns deterministic matches for a shared copybook field", async () => {
191
+ const copybook = `
192
+ 01 CUSTOMER-REC.
193
+ 05 CUSTOMER-ID PIC X(10).
194
+ `;
195
+ const orderA = `
196
+ IDENTIFICATION DIVISION.
197
+ PROGRAM-ID. ORDERA.
198
+ DATA DIVISION.
199
+ WORKING-STORAGE SECTION.
200
+ COPY CUSTOMER-REC.
201
+ PROCEDURE DIVISION.
202
+ A000-MAIN SECTION.
203
+ A100-START.
204
+ STOP RUN.
205
+ `;
206
+ const orderB = `
207
+ IDENTIFICATION DIVISION.
208
+ PROGRAM-ID. ORDERB.
209
+ DATA DIVISION.
210
+ WORKING-STORAGE SECTION.
211
+ COPY CUSTOMER-REC.
212
+ PROCEDURE DIVISION.
213
+ A000-MAIN SECTION.
214
+ A100-START.
215
+ STOP RUN.
216
+ `;
217
+ wiki.rawAdd("ORDERA.cbl", { content: orderA });
218
+ wiki.rawAdd("ORDERB.cbl", { content: orderB });
219
+ wiki.rawAdd("CUSTOMER-REC.cpy", { content: copybook });
220
+ await handleTool(wiki, "code_parse", { path: "ORDERA.cbl" });
221
+ await handleTool(wiki, "code_parse", { path: "ORDERB.cbl" });
222
+ await handleTool(wiki, "code_parse", { path: "CUSTOMER-REC.cpy" });
223
+ const result = await handleTool(wiki, "code_query", {
224
+ query_type: "field_lineage",
225
+ field_name: "CUSTOMER-ID",
226
+ copybook: "CUSTOMER-REC",
227
+ });
228
+ const parsed = JSON.parse(result);
229
+ expect(parsed.query.type).toBe("field_lineage");
230
+ expect(parsed.summary.deterministicMatches).toBeGreaterThan(0);
231
+ expect(parsed.deterministic).toHaveLength(1);
232
+ expect(parsed.deterministic[0].fieldName).toBe("CUSTOMER-ID");
233
+ expect(parsed.deterministic[0].programs.map((program) => program.id)).toEqual([
234
+ "program:ORDERA",
235
+ "program:ORDERB",
236
+ ]);
237
+ });
238
+ it("code_parse persists inferred field-lineage artifacts for cross-copybook matches", async () => {
239
+ const customerA = `
240
+ 01 CUSTOMER-REC.
241
+ 05 CUSTOMER-ID PIC X(10).
242
+ 05 CUSTOMER-NAME PIC X(30).
243
+ `;
244
+ const customerB = `
245
+ 01 CLIENT-REC.
246
+ 05 CUSTOMER-ID PIC X(10).
247
+ 05 CUSTOMER-NAME PIC X(30).
248
+ `;
249
+ const billingA = `
250
+ IDENTIFICATION DIVISION.
251
+ PROGRAM-ID. BILLINGA.
252
+ DATA DIVISION.
253
+ WORKING-STORAGE SECTION.
254
+ COPY CUSTOMER-A.
255
+ PROCEDURE DIVISION.
256
+ MAIN.
257
+ STOP RUN.
258
+ `;
259
+ const billingB = `
260
+ IDENTIFICATION DIVISION.
261
+ PROGRAM-ID. BILLINGB.
262
+ DATA DIVISION.
263
+ WORKING-STORAGE SECTION.
264
+ COPY CUSTOMER-B.
265
+ PROCEDURE DIVISION.
266
+ MAIN.
267
+ STOP RUN.
268
+ `;
269
+ wiki.rawAdd("CUSTOMER-A.cpy", { content: customerA });
270
+ wiki.rawAdd("CUSTOMER-B.cpy", { content: customerB });
271
+ wiki.rawAdd("BILLINGA.cbl", { content: billingA });
272
+ wiki.rawAdd("BILLINGB.cbl", { content: billingB });
273
+ await handleTool(wiki, "code_parse", { path: "BILLINGA.cbl" });
274
+ await handleTool(wiki, "code_parse", { path: "BILLINGB.cbl" });
275
+ await handleTool(wiki, "code_parse", { path: "CUSTOMER-A.cpy" });
276
+ const result = await handleTool(wiki, "code_parse", { path: "CUSTOMER-B.cpy" });
277
+ const parsed = JSON.parse(result);
278
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/field-lineage.json");
279
+ expect(parsed.wikiPages).toContain("cobol/field-lineage.md");
280
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
281
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
282
+ const lineage = JSON.parse(readFileSync(lineagePath, "utf-8"));
283
+ expect(lineage.summary.deterministic.fields).toBe(0);
284
+ expect(lineage.summary.inferred.highConfidence).toBeGreaterThan(0);
285
+ expect(lineage.summary.inferred.copybooks).toBe(2);
286
+ expect(lineage.summary.inferred.programs).toBe(2);
287
+ expect(lineage.inferredHighConfidence.some((entry) => entry.fieldName === "CUSTOMER-ID")).toBe(true);
288
+ expect(readFileSync(pagePath, "utf-8")).toContain("Inferred Cross-Copybook Candidates");
289
+ });
290
+ it("code_parse persists call-boundary lineage in field-lineage.json and renders the wiki section", async () => {
291
+ const caller = `
292
+ IDENTIFICATION DIVISION.
293
+ PROGRAM-ID. CALLER.
294
+ DATA DIVISION.
295
+ WORKING-STORAGE SECTION.
296
+ 01 WS-CUSTOMER-REC.
297
+ 05 WS-CUST-ID PIC X(10).
298
+ 05 WS-CUST-NAME PIC X(30).
299
+ PROCEDURE DIVISION.
300
+ A000-MAIN SECTION.
301
+ A100-START.
302
+ CALL "CALLEE" USING WS-CUSTOMER-REC.
303
+ STOP RUN.
304
+ `;
305
+ const callee = `
306
+ IDENTIFICATION DIVISION.
307
+ PROGRAM-ID. CALLEE.
308
+ DATA DIVISION.
309
+ LINKAGE SECTION.
310
+ 01 LK-CUSTOMER-REC.
311
+ 05 LK-CUST-ID PIC X(10).
312
+ 05 LK-CUST-NAME PIC X(30).
313
+ PROCEDURE DIVISION USING LK-CUSTOMER-REC.
314
+ A000-MAIN SECTION.
315
+ A100-START.
316
+ GOBACK.
317
+ `;
318
+ wiki.rawAdd("CALLER.cbl", { content: caller });
319
+ wiki.rawAdd("CALLEE.cbl", { content: callee });
320
+ await handleTool(wiki, "code_parse", { path: "CALLER.cbl" });
321
+ const result = await handleTool(wiki, "code_parse", { path: "CALLEE.cbl" });
322
+ const parsed = JSON.parse(result);
323
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/field-lineage.json");
324
+ expect(parsed.wikiPages).toContain("cobol/field-lineage.md");
325
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
326
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
327
+ const lineage = JSON.parse(readFileSync(lineagePath, "utf-8"));
328
+ expect(lineage.callBoundLineage).toBeTruthy();
329
+ expect(lineage.callBoundLineage.summary.callSites).toBe(1);
330
+ const fieldNames = lineage.callBoundLineage.entries.map((e) => e.caller.fieldName);
331
+ expect(fieldNames).toContain("WS-CUSTOMER-REC");
332
+ expect(fieldNames).toContain("WS-CUST-ID");
333
+ const page = readFileSync(pagePath, "utf-8");
334
+ expect(page).toContain("Call Boundary Field Lineage");
335
+ expect(page).toContain("CALLER → CALLEE");
336
+ expect(page).toContain("WS-CUSTOMER-REC.WS-CUST-ID");
337
+ expect(page).toContain("LK-CUSTOMER-REC.LK-CUST-ID");
338
+ // Overview surfaces call-bound coverage so users see the page has data
339
+ // even when there's no shared-copybook lineage.
340
+ expect(page).toContain("Call sites with USING args");
341
+ expect(page).toContain("Call-bound field pairs");
342
+ // Per-group summary draws the eye to the high-confidence tier when present;
343
+ // here all names align so the summary should report all-deterministic.
344
+ expect(page).toMatch(/\d+ pair\(s\), all deterministic/);
345
+ // No copybook lineage in this fixture, so the copybook sections should
346
+ // be omitted entirely (not rendered with "no data" placeholders).
347
+ expect(page).not.toContain("Copybook Usage");
348
+ expect(page).not.toContain("Shared Copybook-Backed Fields");
349
+ expect(page).not.toContain("Inferred Cross-Copybook Candidates");
350
+ });
351
+ it("code_parse persists DB2 cross-program lineage in field-lineage.json and renders the wiki section", async () => {
352
+ const writer = `
353
+ IDENTIFICATION DIVISION.
354
+ PROGRAM-ID. WRITER.
355
+ DATA DIVISION.
356
+ WORKING-STORAGE SECTION.
357
+ 01 WS-NAME PIC X(30).
358
+ PROCEDURE DIVISION.
359
+ A000-MAIN SECTION.
360
+ A100-START.
361
+ EXEC SQL INSERT INTO CUSTOMERS (NAME)
362
+ VALUES (:WS-NAME) END-EXEC.
363
+ STOP RUN.
364
+ `;
365
+ const reader = `
366
+ IDENTIFICATION DIVISION.
367
+ PROGRAM-ID. READER.
368
+ DATA DIVISION.
369
+ WORKING-STORAGE SECTION.
370
+ 01 WS-NAME PIC X(30).
371
+ PROCEDURE DIVISION.
372
+ A000-MAIN SECTION.
373
+ A100-START.
374
+ EXEC SQL SELECT NAME INTO :WS-NAME
375
+ FROM CUSTOMERS END-EXEC.
376
+ STOP RUN.
377
+ `;
378
+ wiki.rawAdd("WRITER.cbl", { content: writer });
379
+ wiki.rawAdd("READER.cbl", { content: reader });
380
+ await handleTool(wiki, "code_parse", { path: "WRITER.cbl" });
381
+ const result = await handleTool(wiki, "code_parse", { path: "READER.cbl" });
382
+ const parsed = JSON.parse(result);
383
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/field-lineage.json");
384
+ expect(parsed.wikiPages).toContain("cobol/field-lineage.md");
385
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
386
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
387
+ const lineage = JSON.parse(readFileSync(lineagePath, "utf-8"));
388
+ expect(lineage.db2Lineage).toBeTruthy();
389
+ expect(lineage.db2Lineage.summary.sharedTables).toBe(1);
390
+ expect(lineage.db2Lineage.entries).toHaveLength(1);
391
+ const entry = lineage.db2Lineage.entries[0];
392
+ expect(entry.table).toBe("CUSTOMERS");
393
+ expect(entry.writer.programId).toBe("program:WRITER");
394
+ expect(entry.writer.operations).toEqual(["INSERT"]);
395
+ expect(entry.reader.programId).toBe("program:READER");
396
+ expect(entry.reader.operations).toEqual(["SELECT"]);
397
+ const page = readFileSync(pagePath, "utf-8");
398
+ expect(page).toContain("DB2 Table Lineage");
399
+ expect(page).toContain("CUSTOMERS");
400
+ expect(page).toContain("Shared DB2 tables");
401
+ expect(page).toContain("DB2 cross-program pairs");
402
+ });
403
+ it("code_parse persists DB2 references into model artifacts and wiki summaries", async () => {
404
+ const source = readFileSync(join(FIXTURES, "CUSTOMER-DB2.cbl"), "utf-8");
405
+ wiki.rawAdd("CUSTOMER-DB2.cbl", { content: source });
406
+ const result = await handleTool(wiki, "code_parse", { path: "CUSTOMER-DB2.cbl" });
407
+ const parsed = JSON.parse(result);
408
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/CUSTOMER-DB2.model.json");
409
+ expect(parsed.wikiPages).toContain("cobol/programs/customerdb.md");
410
+ const modelPath = join(tmp, "raw", "parsed", "cobol", "CUSTOMER-DB2.model.json");
411
+ const pagePath = join(tmp, "wiki", "cobol", "programs", "customerdb.md");
412
+ const modelJson = JSON.parse(readFileSync(modelPath, "utf-8"));
413
+ expect(modelJson.db2References).toHaveLength(3);
414
+ expect(modelJson.db2References[0].tables).toEqual(["CUSTOMER-TABLE"]);
415
+ expect(readFileSync(pagePath, "utf-8")).toContain("### DB2");
416
+ expect(readFileSync(pagePath, "utf-8")).toContain("CUSTOMER-TABLE");
417
+ });
418
+ it("code_parse persists CICS references into model artifacts and wiki summaries", async () => {
419
+ const source = readFileSync(join(FIXTURES, "ONLINE-CICS.cbl"), "utf-8");
420
+ wiki.rawAdd("ONLINE-CICS.cbl", { content: source });
421
+ const result = await handleTool(wiki, "code_parse", { path: "ONLINE-CICS.cbl" });
422
+ const parsed = JSON.parse(result);
423
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/ONLINE-CICS.model.json");
424
+ expect(parsed.wikiPages).toContain("cobol/programs/onlinesvc.md");
425
+ const modelPath = join(tmp, "raw", "parsed", "cobol", "ONLINE-CICS.model.json");
426
+ const pagePath = join(tmp, "wiki", "cobol", "programs", "onlinesvc.md");
427
+ const modelJson = JSON.parse(readFileSync(modelPath, "utf-8"));
428
+ expect(modelJson.cicsReferences).toHaveLength(1);
429
+ expect(modelJson.cicsReferences[0]).toMatchObject({
430
+ command: "LINK",
431
+ program: "CUSTSRV",
432
+ transaction: "C001",
433
+ map: "CUSTMAP",
434
+ });
435
+ expect(readFileSync(pagePath, "utf-8")).toContain("### CICS");
436
+ expect(readFileSync(pagePath, "utf-8")).toContain("CUSTSRV");
437
+ });
438
+ it("code_parse succeeds with a .cpy copybook", async () => {
439
+ const source = readFileSync(join(FIXTURES, "DATE-UTILS.cpy"), "utf-8");
440
+ wiki.rawAdd("DATE-UTILS.cpy", { content: source });
441
+ const result = await handleTool(wiki, "code_parse", { path: "DATE-UTILS.cpy" });
442
+ const parsed = JSON.parse(result);
443
+ expect(parsed.summary.symbolCount).toBeGreaterThan(0);
444
+ expect(parsed.wikiPages).toContain("cobol/copybooks/date-utils.md");
445
+ });
446
+ it("code_parse generates knowledge graph with correct node identities", async () => {
447
+ // Parse two programs + one copybook to verify cross-file graph
448
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
449
+ const invoiceSrc = readFileSync(join(FIXTURES, "INVOICE.cbl"), "utf-8");
450
+ const dateUtilsSrc = readFileSync(join(FIXTURES, "DATE-UTILS.cpy"), "utf-8");
451
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
452
+ wiki.rawAdd("INVOICE.cbl", { content: invoiceSrc });
453
+ wiki.rawAdd("DATE-UTILS.cpy", { content: dateUtilsSrc });
454
+ // Parse all three — graph is rebuilt on each call
455
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
456
+ await handleTool(wiki, "code_parse", { path: "INVOICE.cbl" });
457
+ const result = await handleTool(wiki, "code_parse", { path: "DATE-UTILS.cpy" });
458
+ const parsed = JSON.parse(result);
459
+ // Graph summary present in output
460
+ expect(parsed.knowledgeGraph).toBeDefined();
461
+ expect(parsed.knowledgeGraph.nodes).toBeGreaterThan(0);
462
+ expect(parsed.knowledgeGraph.edges).toBeGreaterThan(0);
463
+ // Read the persisted graph JSON
464
+ const graphPath = join(tmp, "raw", "parsed", "cobol", "knowledge-graph.json");
465
+ expect(existsSync(graphPath)).toBe(true);
466
+ const graph = JSON.parse(readFileSync(graphPath, "utf-8"));
467
+ // Verify canonical IDs: namespaced, no extensions
468
+ const nodeIds = graph.nodes.map((n) => n.id);
469
+ expect(nodeIds).toContain("program:PAYROLL");
470
+ expect(nodeIds).toContain("program:INVOICE");
471
+ expect(nodeIds).toContain("copybook:DATE-UTILS");
472
+ // DATE-UTILS should be resolved (source-backed) — no .cpy in ID
473
+ const dateUtils = graph.nodes.find((n) => n.id === "copybook:DATE-UTILS");
474
+ expect(dateUtils.resolved).toBe(true);
475
+ // CALC-TOTAL is referenced but never parsed — should be unresolved
476
+ const calcTotal = graph.nodes.find((n) => n.id === "program:CALC-TOTAL");
477
+ expect(calcTotal).toBeDefined();
478
+ expect(calcTotal.resolved).toBe(false);
479
+ // EMPLOYEE-FILE dataset should be resolved (FD-backed)
480
+ const empFile = graph.nodes.find((n) => n.id === "dataset:EMPLOYEE-FILE");
481
+ expect(empFile).toBeDefined();
482
+ expect(empFile.resolved).toBe(true);
483
+ // Diagnostics should flag unresolved nodes
484
+ expect(graph.diagnostics.length).toBeGreaterThan(0);
485
+ const unresolvedDiags = graph.diagnostics.filter((d) => d.message.includes("Unresolved"));
486
+ expect(unresolvedDiags.length).toBeGreaterThan(0);
487
+ // System map wiki page should exist
488
+ const systemMap = join(tmp, "wiki", "cobol", "system-map.md");
489
+ expect(existsSync(systemMap)).toBe(true);
490
+ const mapContent = readFileSync(systemMap, "utf-8");
491
+ expect(mapContent).toContain("COBOL System Map");
492
+ expect(mapContent).toContain("PAYROLL");
493
+ expect(mapContent).toContain("unresolved");
494
+ });
495
+ it("rejects unsupported file types", async () => {
496
+ await expect(handleTool(wiki, "code_parse", { path: "readme.md" }))
497
+ .rejects.toThrow(/Unsupported file type/);
498
+ });
499
+ it("code_impact fails clearly when no compiled graph exists", async () => {
500
+ await expect(handleTool(wiki, "code_impact", { node_id: "program:PAYROLL" }))
501
+ .rejects.toThrow(/Compiled knowledge graph not found/);
502
+ });
503
+ it("code_impact does not include diagnostics for prefix-overlapping node ids", async () => {
504
+ wiki.rawAddParsedArtifact("parsed/cobol/knowledge-graph.json", JSON.stringify({
505
+ nodes: [
506
+ { id: "program:PAY", kind: "Program", resolved: true, sourceFile: "PAY.cbl" },
507
+ { id: "program:PAYROLL", kind: "Program", resolved: true, sourceFile: "PAYROLL.cbl" },
508
+ ],
509
+ edges: [],
510
+ diagnostics: [
511
+ {
512
+ severity: "warning",
513
+ message: 'Unresolved Program "program:PAYROLL" — referenced by [program:INVOICE] but never parsed from source',
514
+ sourceFile: "INVOICE.cbl",
515
+ line: 15,
516
+ },
517
+ ],
518
+ }, null, 2));
519
+ const result = await handleTool(wiki, "code_impact", { node_id: "program:PAY" });
520
+ const parsed = JSON.parse(result);
521
+ expect(parsed.source.node_id).toBe("program:PAY");
522
+ expect(parsed.diagnostics).toEqual([]);
523
+ });
524
+ it("code_impact keeps diagnostics for dataset ids with dots and underscores", async () => {
525
+ wiki.rawAddParsedArtifact("parsed/cobol/knowledge-graph.json", JSON.stringify({
526
+ nodes: [
527
+ { id: "dataset:HLQ.PROD_TRANS.FILE", kind: "Dataset", resolved: true, sourceFile: "JOB001.jcl" },
528
+ ],
529
+ edges: [],
530
+ diagnostics: [
531
+ {
532
+ severity: "warning",
533
+ message: 'Unresolved Dataset "dataset:HLQ.PROD_TRANS.FILE" — referenced by [program:PAYROLL] but never parsed from source',
534
+ sourceFile: "PAYROLL.cbl",
535
+ line: 27,
536
+ },
537
+ ],
538
+ }, null, 2));
539
+ const result = await handleTool(wiki, "code_impact", { node_id: "dataset:HLQ.PROD_TRANS.FILE" });
540
+ const parsed = JSON.parse(result);
541
+ expect(parsed.source.node_id).toBe("dataset:HLQ.PROD_TRANS.FILE");
542
+ expect(parsed.diagnostics).toHaveLength(1);
543
+ expect(parsed.diagnostics[0].message).toContain("dataset:HLQ.PROD_TRANS.FILE");
544
+ });
545
+ it("code_parse and code_impact work for nested source paths", async () => {
546
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
547
+ wiki.rawAdd("nested/PAYROLL.cbl", { content: source });
548
+ const parseResult = await handleTool(wiki, "code_parse", { path: "nested/PAYROLL.cbl" });
549
+ const parseParsed = JSON.parse(parseResult);
550
+ expect(parseParsed.knowledgeGraph).toBeDefined();
551
+ expect(parseParsed.knowledgeGraph.nodes).toBeGreaterThan(0);
552
+ const impactResult = await handleTool(wiki, "code_impact", { node_id: "program:CALC-TAX" });
553
+ const impactParsed = JSON.parse(impactResult);
554
+ expect(impactParsed.impactedByDepth[0].nodes.some((n) => n.node_id === "program:PAYROLL")).toBe(true);
555
+ });
556
+ it("code_parse and code_query procedure_flow work for nested source paths", async () => {
557
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
558
+ wiki.rawAdd("nested/PAYROLL.cbl", { content: source });
559
+ await handleTool(wiki, "code_parse", { path: "nested/PAYROLL.cbl" });
560
+ const result = await handleTool(wiki, "code_query", {
561
+ query_type: "procedure_flow",
562
+ path: "nested/PAYROLL.cbl",
563
+ procedure: "A100-INIT",
564
+ });
565
+ const parsed = JSON.parse(result);
566
+ expect(parsed.query.path).toBe("nested/PAYROLL.cbl");
567
+ expect(parsed.flowByDepth[0].nodes.some((node) => node.name === "B000-PROCESS")).toBe(true);
568
+ });
569
+ it("wiki_rebuild emits deterministic call-graph source order for nested models", async () => {
570
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
571
+ const invoiceSrc = readFileSync(join(FIXTURES, "INVOICE.cbl"), "utf-8");
572
+ wiki.rawAdd("nested/PAYROLL.cbl", { content: payrollSrc });
573
+ wiki.rawAdd("INVOICE.cbl", { content: invoiceSrc });
574
+ await handleTool(wiki, "code_parse", { path: "nested/PAYROLL.cbl" }, { skipGraphRebuild: true });
575
+ await handleTool(wiki, "code_parse", { path: "INVOICE.cbl" }, { skipGraphRebuild: true });
576
+ await handleTool(wiki, "wiki_rebuild", {});
577
+ const callGraph = readFileSync(join(tmp, "wiki", "cobol", "call-graph.md"), "utf-8");
578
+ const invoiceIdx = callGraph.indexOf(" - raw/INVOICE.cbl");
579
+ const nestedIdx = callGraph.indexOf(" - raw/nested/PAYROLL.cbl");
580
+ expect(invoiceIdx).toBeGreaterThan(-1);
581
+ expect(nestedIdx).toBeGreaterThan(-1);
582
+ expect(invoiceIdx).toBeLessThan(nestedIdx);
583
+ });
584
+ it("parsed artifacts pass lint integrity checks (no missing-meta)", async () => {
585
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
586
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
587
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
588
+ const verifyResults = wiki.rawVerify();
589
+ const missingMeta = verifyResults.filter((r) => r.status === "missing-meta");
590
+ expect(missingMeta).toEqual([]);
591
+ });
592
+ describe("deferred graph rebuild (O(N) batch path)", () => {
593
+ it("skipGraphRebuild prevents knowledge-graph.json and system-map.md generation", async () => {
594
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
595
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
596
+ // Parse with graph rebuild skipped
597
+ const result = await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" }, { skipGraphRebuild: true });
598
+ const parsed = JSON.parse(result);
599
+ // Core parse artifacts still written
600
+ expect(parsed.artifacts).toContain("raw/parsed/cobol/PAYROLL.model.json");
601
+ expect(existsSync(join(tmp, "raw", "parsed", "cobol", "PAYROLL.model.json"))).toBe(true);
602
+ // Graph artifacts NOT written
603
+ expect(parsed.artifacts).not.toContain("raw/parsed/cobol/knowledge-graph.json");
604
+ expect(parsed.knowledgeGraph).toBeUndefined();
605
+ expect(existsSync(join(tmp, "raw", "parsed", "cobol", "knowledge-graph.json"))).toBe(false);
606
+ expect(parsed.wikiPages).not.toContain("cobol/system-map.md");
607
+ });
608
+ it("batch code_parse defers graph rebuild to end — single rebuild for N files", async () => {
609
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
610
+ const invoiceSrc = readFileSync(join(FIXTURES, "INVOICE.cbl"), "utf-8");
611
+ const dateUtilsSrc = readFileSync(join(FIXTURES, "DATE-UTILS.cpy"), "utf-8");
612
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
613
+ wiki.rawAdd("INVOICE.cbl", { content: invoiceSrc });
614
+ wiki.rawAdd("DATE-UTILS.cpy", { content: dateUtilsSrc });
615
+ // Batch parse all three — graph rebuild deferred to end
616
+ const result = await handleTool(wiki, "batch", {
617
+ operations: [
618
+ { tool: "code_parse", args: { path: "PAYROLL.cbl" } },
619
+ { tool: "code_parse", args: { path: "INVOICE.cbl" } },
620
+ { tool: "code_parse", args: { path: "DATE-UTILS.cpy" } },
621
+ ],
622
+ });
623
+ const batch = JSON.parse(result);
624
+ // All 3 parses succeeded
625
+ expect(batch.count).toBe(3);
626
+ for (const r of batch.results) {
627
+ expect(r.error).toBeUndefined();
628
+ }
629
+ // Per-parse results should NOT include graph artifacts (deferred)
630
+ for (const r of batch.results) {
631
+ expect(r.result.knowledgeGraph).toBeUndefined();
632
+ expect(r.result.artifacts).not.toContain("raw/parsed/cobol/knowledge-graph.json");
633
+ }
634
+ // But the deferred rebuild at end of batch should have produced the graph
635
+ const graphPath = join(tmp, "raw", "parsed", "cobol", "knowledge-graph.json");
636
+ expect(existsSync(graphPath)).toBe(true);
637
+ const graph = JSON.parse(readFileSync(graphPath, "utf-8"));
638
+ // Graph contains all 3 parsed files
639
+ const nodeIds = graph.nodes.map((n) => n.id);
640
+ expect(nodeIds).toContain("program:PAYROLL");
641
+ expect(nodeIds).toContain("program:INVOICE");
642
+ expect(nodeIds).toContain("copybook:DATE-UTILS");
643
+ // System map wiki page exists
644
+ const systemMap = join(tmp, "wiki", "cobol", "system-map.md");
645
+ expect(existsSync(systemMap)).toBe(true);
646
+ });
647
+ it("batch code_parse followed by code_impact sees freshly rebuilt graph", async () => {
648
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
649
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
650
+ const result = await handleTool(wiki, "batch", {
651
+ operations: [
652
+ { tool: "code_parse", args: { path: "PAYROLL.cbl" } },
653
+ { tool: "code_impact", args: { node_id: "program:CALC-TAX" } },
654
+ ],
655
+ });
656
+ const batch = JSON.parse(result);
657
+ expect(batch.count).toBe(2);
658
+ expect(batch.results[0].error).toBeUndefined();
659
+ expect(batch.results[1].error).toBeUndefined();
660
+ expect(batch.results[1].result.source.node_id).toBe("program:CALC-TAX");
661
+ expect(batch.results[1].result.impactedByDepth).toHaveLength(1);
662
+ expect(batch.results[1].result.impactedByDepth[0].nodes.some((n) => n.node_id === "program:PAYROLL")).toBe(true);
663
+ const graphPath = join(tmp, "raw", "parsed", "cobol", "knowledge-graph.json");
664
+ expect(existsSync(graphPath)).toBe(true);
665
+ });
666
+ it("batch code_parse followed by code_query field_lineage sees freshly rebuilt derived artifacts", async () => {
667
+ const copybook = `
668
+ 01 CUSTOMER-REC.
669
+ 05 CUSTOMER-ID PIC X(10).
670
+ `;
671
+ const orderA = `
672
+ IDENTIFICATION DIVISION.
673
+ PROGRAM-ID. ORDERA.
674
+ DATA DIVISION.
675
+ WORKING-STORAGE SECTION.
676
+ COPY CUSTOMER-REC.
677
+ PROCEDURE DIVISION.
678
+ MAIN.
679
+ STOP RUN.
680
+ `;
681
+ const orderB = `
682
+ IDENTIFICATION DIVISION.
683
+ PROGRAM-ID. ORDERB.
684
+ DATA DIVISION.
685
+ WORKING-STORAGE SECTION.
686
+ COPY CUSTOMER-REC.
687
+ PROCEDURE DIVISION.
688
+ MAIN.
689
+ STOP RUN.
690
+ `;
691
+ wiki.rawAdd("ORDERA.cbl", { content: orderA });
692
+ wiki.rawAdd("ORDERB.cbl", { content: orderB });
693
+ wiki.rawAdd("CUSTOMER-REC.cpy", { content: copybook });
694
+ const result = await handleTool(wiki, "batch", {
695
+ operations: [
696
+ { tool: "code_parse", args: { path: "ORDERA.cbl" } },
697
+ { tool: "code_parse", args: { path: "ORDERB.cbl" } },
698
+ { tool: "code_parse", args: { path: "CUSTOMER-REC.cpy" } },
699
+ { tool: "code_query", args: { query_type: "field_lineage", field_name: "CUSTOMER-ID" } },
700
+ ],
701
+ });
702
+ const batch = JSON.parse(result);
703
+ expect(batch.results[3].error).toBeUndefined();
704
+ expect(batch.results[3].result.summary.deterministicMatches).toBeGreaterThan(0);
705
+ expect(batch.results[3].result.deterministic[0].fieldName).toBe("CUSTOMER-ID");
706
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
707
+ expect(existsSync(lineagePath)).toBe(true);
708
+ });
709
+ it("wiki_rebuild regenerates knowledge graph from existing parsed artifacts", async () => {
710
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
711
+ const invoiceSrc = readFileSync(join(FIXTURES, "INVOICE.cbl"), "utf-8");
712
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
713
+ wiki.rawAdd("INVOICE.cbl", { content: invoiceSrc });
714
+ // Parse both with graph rebuild skipped
715
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" }, { skipGraphRebuild: true });
716
+ await handleTool(wiki, "code_parse", { path: "INVOICE.cbl" }, { skipGraphRebuild: true });
717
+ // No graph yet
718
+ const graphPath = join(tmp, "raw", "parsed", "cobol", "knowledge-graph.json");
719
+ expect(existsSync(graphPath)).toBe(false);
720
+ // Explicit wiki_rebuild triggers graph generation
721
+ const rebuildResult = await handleTool(wiki, "wiki_rebuild", {});
722
+ const rebuildParsed = JSON.parse(rebuildResult);
723
+ expect(rebuildParsed.ok).toBe(true);
724
+ expect(rebuildParsed.message).toContain("Knowledge graph");
725
+ // Graph now exists with both programs
726
+ expect(existsSync(graphPath)).toBe(true);
727
+ const graph = JSON.parse(readFileSync(graphPath, "utf-8"));
728
+ const nodeIds = graph.nodes.map((n) => n.id);
729
+ expect(nodeIds).toContain("program:PAYROLL");
730
+ expect(nodeIds).toContain("program:INVOICE");
731
+ });
732
+ it("wiki_rebuild regenerates field-lineage artifacts from existing parsed models", async () => {
733
+ const copybook = `
734
+ 01 CUSTOMER-REC.
735
+ 05 CUSTOMER-ID PIC X(10).
736
+ `;
737
+ const orderA = `
738
+ IDENTIFICATION DIVISION.
739
+ PROGRAM-ID. ORDERA.
740
+ DATA DIVISION.
741
+ WORKING-STORAGE SECTION.
742
+ COPY CUSTOMER-REC.
743
+ PROCEDURE DIVISION.
744
+ A000-MAIN SECTION.
745
+ A100-START.
746
+ STOP RUN.
747
+ `;
748
+ const orderB = `
749
+ IDENTIFICATION DIVISION.
750
+ PROGRAM-ID. ORDERB.
751
+ DATA DIVISION.
752
+ WORKING-STORAGE SECTION.
753
+ COPY CUSTOMER-REC.
754
+ PROCEDURE DIVISION.
755
+ A000-MAIN SECTION.
756
+ A100-START.
757
+ STOP RUN.
758
+ `;
759
+ wiki.rawAdd("ORDERA.cbl", { content: orderA });
760
+ wiki.rawAdd("ORDERB.cbl", { content: orderB });
761
+ wiki.rawAdd("CUSTOMER-REC.cpy", { content: copybook });
762
+ await handleTool(wiki, "code_parse", { path: "ORDERA.cbl" }, { skipGraphRebuild: true });
763
+ await handleTool(wiki, "code_parse", { path: "ORDERB.cbl" }, { skipGraphRebuild: true });
764
+ await handleTool(wiki, "code_parse", { path: "CUSTOMER-REC.cpy" }, { skipGraphRebuild: true });
765
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
766
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
767
+ expect(existsSync(lineagePath)).toBe(false);
768
+ expect(existsSync(pagePath)).toBe(false);
769
+ await handleTool(wiki, "wiki_rebuild", {});
770
+ expect(existsSync(lineagePath)).toBe(true);
771
+ expect(existsSync(pagePath)).toBe(true);
772
+ const lineage = JSON.parse(readFileSync(lineagePath, "utf-8"));
773
+ expect(lineage.summary.deterministic.fields).toBeGreaterThan(0);
774
+ });
775
+ it("wiki_rebuild removes stale field-lineage outputs when lineage no longer exists", async () => {
776
+ const copybook = `
777
+ 01 CUSTOMER-REC.
778
+ 05 CUSTOMER-ID PIC X(10).
779
+ `;
780
+ const orderA = `
781
+ IDENTIFICATION DIVISION.
782
+ PROGRAM-ID. ORDERA.
783
+ DATA DIVISION.
784
+ WORKING-STORAGE SECTION.
785
+ COPY CUSTOMER-REC.
786
+ PROCEDURE DIVISION.
787
+ A000-MAIN SECTION.
788
+ A100-START.
789
+ STOP RUN.
790
+ `;
791
+ const orderB = `
792
+ IDENTIFICATION DIVISION.
793
+ PROGRAM-ID. ORDERB.
794
+ DATA DIVISION.
795
+ WORKING-STORAGE SECTION.
796
+ COPY CUSTOMER-REC.
797
+ PROCEDURE DIVISION.
798
+ A000-MAIN SECTION.
799
+ A100-START.
800
+ STOP RUN.
801
+ `;
802
+ wiki.rawAdd("ORDERA.cbl", { content: orderA });
803
+ wiki.rawAdd("ORDERB.cbl", { content: orderB });
804
+ wiki.rawAdd("CUSTOMER-REC.cpy", { content: copybook });
805
+ await handleTool(wiki, "code_parse", { path: "ORDERA.cbl" }, { skipGraphRebuild: true });
806
+ await handleTool(wiki, "code_parse", { path: "ORDERB.cbl" }, { skipGraphRebuild: true });
807
+ await handleTool(wiki, "code_parse", { path: "CUSTOMER-REC.cpy" }, { skipGraphRebuild: true });
808
+ await handleTool(wiki, "wiki_rebuild", {});
809
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
810
+ const lineageMetaPath = `${lineagePath}.meta.yaml`;
811
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
812
+ expect(existsSync(lineagePath)).toBe(true);
813
+ expect(existsSync(pagePath)).toBe(true);
814
+ rmSync(join(tmp, "raw", "parsed", "cobol", "ORDERB.model.json"), { force: true });
815
+ rmSync(join(tmp, "raw", "parsed", "cobol", "ORDERB.model.json.meta.yaml"), { force: true });
816
+ await handleTool(wiki, "wiki_rebuild", {});
817
+ expect(existsSync(lineagePath)).toBe(false);
818
+ expect(existsSync(lineageMetaPath)).toBe(false);
819
+ expect(existsSync(pagePath)).toBe(false);
820
+ });
821
+ it("wiki_rebuild removes stale field-lineage outputs when parsed model directory disappears", async () => {
822
+ const copybook = `
823
+ 01 CUSTOMER-REC.
824
+ 05 CUSTOMER-ID PIC X(10).
825
+ `;
826
+ const orderA = `
827
+ IDENTIFICATION DIVISION.
828
+ PROGRAM-ID. ORDERA.
829
+ DATA DIVISION.
830
+ WORKING-STORAGE SECTION.
831
+ COPY CUSTOMER-REC.
832
+ PROCEDURE DIVISION.
833
+ A000-MAIN SECTION.
834
+ A100-START.
835
+ STOP RUN.
836
+ `;
837
+ const orderB = `
838
+ IDENTIFICATION DIVISION.
839
+ PROGRAM-ID. ORDERB.
840
+ DATA DIVISION.
841
+ WORKING-STORAGE SECTION.
842
+ COPY CUSTOMER-REC.
843
+ PROCEDURE DIVISION.
844
+ A000-MAIN SECTION.
845
+ A100-START.
846
+ STOP RUN.
847
+ `;
848
+ wiki.rawAdd("ORDERA.cbl", { content: orderA });
849
+ wiki.rawAdd("ORDERB.cbl", { content: orderB });
850
+ wiki.rawAdd("CUSTOMER-REC.cpy", { content: copybook });
851
+ await handleTool(wiki, "code_parse", { path: "ORDERA.cbl" }, { skipGraphRebuild: true });
852
+ await handleTool(wiki, "code_parse", { path: "ORDERB.cbl" }, { skipGraphRebuild: true });
853
+ await handleTool(wiki, "code_parse", { path: "CUSTOMER-REC.cpy" }, { skipGraphRebuild: true });
854
+ await handleTool(wiki, "wiki_rebuild", {});
855
+ const lineagePath = join(tmp, "raw", "parsed", "cobol", "field-lineage.json");
856
+ const lineageMetaPath = `${lineagePath}.meta.yaml`;
857
+ const pagePath = join(tmp, "wiki", "cobol", "field-lineage.md");
858
+ expect(existsSync(lineagePath)).toBe(true);
859
+ expect(existsSync(pagePath)).toBe(true);
860
+ rmSync(join(tmp, "raw", "parsed", "cobol"), { recursive: true, force: true });
861
+ await handleTool(wiki, "wiki_rebuild", {});
862
+ expect(existsSync(lineagePath)).toBe(false);
863
+ expect(existsSync(lineageMetaPath)).toBe(false);
864
+ expect(existsSync(pagePath)).toBe(false);
865
+ });
866
+ it("wiki_rebuild includes graph pages in index.md and timeline.md", async () => {
867
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
868
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
869
+ // Parse with graph rebuild skipped — no graph pages yet
870
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" }, { skipGraphRebuild: true });
871
+ expect(existsSync(join(tmp, "wiki", "cobol", "system-map.md"))).toBe(false);
872
+ expect(existsSync(join(tmp, "wiki", "cobol", "call-graph.md"))).toBe(false);
873
+ // Single wiki_rebuild should generate graph pages AND include them in index/timeline
874
+ await handleTool(wiki, "wiki_rebuild", {});
875
+ // Graph pages exist
876
+ expect(existsSync(join(tmp, "wiki", "cobol", "system-map.md"))).toBe(true);
877
+ expect(existsSync(join(tmp, "wiki", "cobol", "call-graph.md"))).toBe(true);
878
+ // Graph pages are under cobol/, so they appear in the topic sub-index
879
+ const cobolIndex = readFileSync(join(tmp, "wiki", "cobol", "index.md"), "utf-8");
880
+ expect(cobolIndex).toContain("system-map");
881
+ expect(cobolIndex).toContain("call-graph");
882
+ // Top-level index should reference the cobol topic
883
+ const index = readFileSync(join(tmp, "wiki", "index.md"), "utf-8");
884
+ expect(index).toContain("cobol");
885
+ // Timeline includes the freshly generated graph pages
886
+ const timeline = readFileSync(join(tmp, "wiki", "timeline.md"), "utf-8");
887
+ expect(timeline).toContain("COBOL System Map");
888
+ expect(timeline).toContain("COBOL Call Graph");
889
+ });
890
+ it("batch code_parse rebuilds timeline with graph pages", async () => {
891
+ const payrollSrc = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
892
+ wiki.rawAdd("PAYROLL.cbl", { content: payrollSrc });
893
+ // Batch with a single code_parse — deferred graph rebuild should trigger timeline
894
+ const batchOps = [{ tool: "code_parse", args: { path: "PAYROLL.cbl" } }];
895
+ await handleTool(wiki, "batch", { operations: batchOps });
896
+ // Graph pages exist
897
+ expect(existsSync(join(tmp, "wiki", "cobol", "system-map.md"))).toBe(true);
898
+ expect(existsSync(join(tmp, "wiki", "cobol", "call-graph.md"))).toBe(true);
899
+ // Index includes graph pages
900
+ const index = readFileSync(join(tmp, "wiki", "index.md"), "utf-8");
901
+ expect(index).toContain("cobol");
902
+ // Timeline includes graph pages — this is the regression test
903
+ const timeline = readFileSync(join(tmp, "wiki", "timeline.md"), "utf-8");
904
+ expect(timeline).toContain("COBOL System Map");
905
+ expect(timeline).toContain("COBOL Call Graph");
906
+ });
907
+ });
908
+ describe("dataflow_edges", () => {
909
+ it("returns flat edge list for a parsed program", async () => {
910
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
911
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
912
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
913
+ const result = await handleTool(wiki, "code_query", {
914
+ query_type: "dataflow_edges",
915
+ path: "PAYROLL.cbl",
916
+ });
917
+ const parsed = JSON.parse(result);
918
+ expect(parsed.total).toBeGreaterThan(0);
919
+ const addEdge = parsed.edges.find((e) => e.from === "EMP-SALARY" && e.to === "WS-TOTAL-SALARY" && e.via === "ADD");
920
+ expect(addEdge).toBeDefined();
921
+ });
922
+ it("filters by from field", async () => {
923
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
924
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
925
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
926
+ const result = await handleTool(wiki, "code_query", {
927
+ query_type: "dataflow_edges",
928
+ path: "PAYROLL.cbl",
929
+ from: "EMP-SALARY",
930
+ });
931
+ const parsed = JSON.parse(result);
932
+ expect(parsed.edges.every((e) => e.from === "EMP-SALARY")).toBe(true);
933
+ });
934
+ it("transitive downstream: EMP-SALARY reaches WS-AVG-SALARY via WS-TOTAL-SALARY", async () => {
935
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
936
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
937
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
938
+ const result = await handleTool(wiki, "code_query", {
939
+ query_type: "dataflow_edges",
940
+ path: "PAYROLL.cbl",
941
+ field: "EMP-SALARY",
942
+ transitive: true,
943
+ direction: "downstream",
944
+ });
945
+ const parsed = JSON.parse(result);
946
+ expect(parsed.transitive).toBe(true);
947
+ expect(parsed.field).toBe("EMP-SALARY");
948
+ expect(parsed.direction).toBe("downstream");
949
+ const allFields = parsed.levels.flatMap((l) => l.fields);
950
+ expect(allFields).toContain("WS-TOTAL-SALARY");
951
+ expect(allFields).toContain("WS-AVG-SALARY");
952
+ });
953
+ it("transitive upstream: WS-AVG-SALARY traces back to EMP-SALARY", async () => {
954
+ const source = readFileSync(join(FIXTURES, "PAYROLL.cbl"), "utf-8");
955
+ wiki.rawAdd("PAYROLL.cbl", { content: source });
956
+ await handleTool(wiki, "code_parse", { path: "PAYROLL.cbl" });
957
+ const result = await handleTool(wiki, "code_query", {
958
+ query_type: "dataflow_edges",
959
+ path: "PAYROLL.cbl",
960
+ field: "WS-AVG-SALARY",
961
+ transitive: true,
962
+ direction: "upstream",
963
+ });
964
+ const parsed = JSON.parse(result);
965
+ const allFields = parsed.levels.flatMap((l) => l.fields);
966
+ expect(allFields).toContain("WS-TOTAL-SALARY");
967
+ expect(allFields).toContain("EMP-SALARY");
968
+ });
969
+ });
970
+ });
971
+ //# sourceMappingURL=integration.test.js.map