Semantic catalog from COBOL sources¶
Crate oliviadb-enterprise/crates/oliviadb-agent (catalog, cobol), binary oliviadb-catalog. Field-level
meaning for the replica's segments, from static analysis of the COBOL programs and
copybooks that use them; served to agents through the layer-1 view
(agent-data.md).
What it builds¶
For each segment a program reads or changes through DL/I:
- Binding. A
CALL 'CBLTDLI'(alsoAIBTDLI,CEETDLI; a leading parameter count is recognised) whose last SSA names the segment binds it to the I/O area's layout: the area's subordinate items, moved by the area's offset in its record and by a reference modification (AREA (5:)), with the copybook the record comes from. Function and SSA values are found by data flow: the last literal moved or strung into the item earlier in the same paragraph or section, else literals moved to it anywhere, else its VALUE (also through a subordinate item over the SSA's first 8 bytes). - Types. PICTURE and USAGE give the encoding: zoned decimal (DISPLAY numeric), packed decimal (COMP-3), binary (COMP, COMP-4, COMP-5, BINARY) with scale and sign, characters; floating point and pointers as bytes. Sizes as the Enterprise COBOL Language Reference ("PICTURE clause", "USAGE clause") gives them; OCCURS tables become numbered fields (up to 50 occurrences).
- Meanings. 88-level condition names give value labels; a derived field
FIELD:meaningshows the condition name of the value (searchable: "closed account" finds accounts whose status is the value ofACCT-CLOSED). - REDEFINES discriminators. For each variant group, the conditions under which
programs use a variant's fields (IF with comparisons or 88-level names, EVALUATE
subject/WHEN) vote for a discriminator field and its values; a value claimed by two
variants drops both rules. A variant's fields are shown only where its rule holds.
SemanticCatalog::checkruns the rules over the replica's data: for each occurrence a rule selects, whether the variant's numeric fields hold valid values. - Usage. Which programs read (GU, GN, GNP, hold forms) and change (ISRT, REPL, DLET)
each segment:
read_by/written_byin the catalog.
ReplicaSource::with_layouts(catalog.layouts()) puts it in service: the catalog
(CATALOG, CUSTDB, CATALOG/CUSTDB/ACCT paths) shows copybook names, types,
descriptions, labels, conditions and programs; values are decoded with scale and sign;
data_recall also searches the catalog entries the agent may see. Masks of an agent PSB
hide bytes, not names: a masked field's REDEFINES aliases and every overlapping field
are redacted too, and a masked field's labels leave the catalog.
Parsing¶
OliviaDB does not contain a COBOL parser. It expands COPY members itself (reference format,
REPLACING of words and pseudo-text) and sends the program text to a parse service, a
separate process given by OLIVIADB_COBOL_PARSER (a command line), which answers with a
concrete syntax tree as JSON (protocol in src/cobol/cst.rs). OliviaDB is tested with a
service that runs the ANTLR4 grammar of the Eclipse Che4z COBOL language support
(EPL-2.0); the service is not part of OliviaDB and is not distributed with it.
OLIVIADB_COBOL_PARSER="java -jar /path/to/parse-service.jar serve" \
oliviadb-catalog --cobol src/cobol --copy src/copy --dbd src/dbd
Evidence¶
tests/catalog.rs(runs when a parse service is available; skipped otherwise): two programs and two copybooks written for the test: calls, functions, segments, reference modification, offsets and encodings, 88-level labels, discriminators from an 88-level name and from EVALUATE, the check against loaded data, the catalog and values through an agent view, masks across REDEFINES.
Open¶
- EXEC DLI commands, PL/I and assembler programs are not analysed; PCBs are not mapped to the PSB (the segment name decides the database; a name in several databases is noted and skipped).
- Calls without an SSA (unqualified GN) and SSAs built at run time from data are noted, not bound.
- Discriminators: equality tests only (no ranges, NOT, or compound conditions), within one record; nested OCCURS keep the innermost table only.
- The catalog is not versioned bitemporally yet (one current version, built on demand); descriptions are generated from the analysis (no language model drafts).