description: Dependency & topology mapping — call graphs, data lineage, batch flows, rendered as navigable diagrams
Build a dependency and topology map of legacy/$1 and render it visually.
The assessment gave us domains. Now go one level deeper: how do the pieces connect? This is the map an engineer needs before touching anything.
Write a one-off analysis script (Python or shell — your choice) that parses
the source under legacy/$1 and extracts the four datasets below. Cover
the parse targets that are real for the stack you're looking at — these are
the ones LLMs reliably miss:
CALL '...' and EXEC CICS LINK/XCTL PROGRAM(...). Most
PROGRAM(...) targets are data-names, not literals — resolve them
against working-storage VALUE clauses and any menu/route copybooks
before declaring an edge unresolvable.require/import.SELECT ... ASSIGN TO <ddname> joined with JCL DD
statements (this is the only way to attribute file I/O to a program).EXEC CICS READ/WRITE/REWRITE/DELETE/STARTBR/READNEXT/
READPREV ... FILE(...) joined with DEFINE FILE in the CSD.EXEC SQL ... END-EXEC table references — not JCL DD; DB2 access
is via plan/package binds.SEND MAP/RECEIVE MAP ↔ map source under bms/ and copybooks
under cpy-bms/ (or wherever the maps live).EXEC PGM= steps and CICS DEFINE TRANSACTION ... PROGRAM(...)
from the CSD — without the CSD, every online program looks unreachable.
Web: HTTP routes. CLI: argv parsing.For COBOL fixed-format, slice columns 8-72 and skip * indicator lines
(column 7) before regex matching, or you'll match sequence numbers and
commented-out code.
Save the script as analysis/$1/extract_topology.py (or .sh) so it can be
re-run and audited. Have it write a machine-readable
analysis/$1/topology.json and print a human summary. Run it; show the
summary (cap at ~200 lines for very large estates).
From the extracted data, generate three Mermaid diagrams and write them
to analysis/$1/TOPOLOGY.html as a self-contained page that renders in any
browser.
The HTML page must use: dark #1e1e1e background, #d4d4d4 text,
#cc785c for <h2>/accents, system-ui font, all CSS inline (no
external stylesheets). Load Mermaid from a CDN in <head>:
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true, theme: 'dark' });
</script>
Each diagram goes in a <pre class="mermaid">...</pre> block. Do not
wrap diagrams in markdown ` fences inside the HTML.
graph TD — Module call graph. Cluster by domain (use subgraph).
Highlight entry points in a distinct style. Cap at ~40 nodes — if larger,
show domain-level with one expanded domain.
graph LR — Data lineage. Programs → data stores.
Mark read vs write edges.
flowchart TD — Critical path. Trace ONE end-to-end business flow
(e.g., "monthly billing run" or "process payment") through every program
and data store it touches, in execution order. If production telemetry is
available (see /modernize-assess Step 4), annotate each step with its
p50/p99 wall-clock.
Also export the three diagrams as standalone .mmd files for re-use:
analysis/$1/call-graph.mmd, analysis/$1/data-lineage.mmd,
analysis/$1/critical-path.mmd.
Below each <pre class="mermaid"> block in TOPOLOGY.html, add a <ul>
with 3-5 architect observations: tight coupling clusters, single
points of failure, candidates for service extraction, data stores
touched by too many writers.
Tell the user to open analysis/$1/TOPOLOGY.html in a browser.