Skip to content

COBOL: engine-to-translator fact cross-check as a CI gate (and who owns each fact) #4273

Closed

Description

@squid-protocol

Problem

The engine (regex + fact channels) and the det translator (tree-sitter parse) independently derive layouts, units, PERFORM/GO TO edges, calls, data moves and copybook expansion for every proven program, but nothing compares them. Engine bugs therefore never break a proof (#4242, #4245, #4246, #4203).

Evidence (file:line, origin/main)

  • Translator side: gitgalaxy/tools/cobol_to_java/det/layout.py:123 (parser) and det/stmt.py:65 (parse).
  • Engine side: gitgalaxy/core/mainframe_boundary.py, gitgalaxy/core/data_moves.py, and the cobol language standard.
  • Already known disagreement: COPY REPLACING (engine does not resolve it, translator does: data_moves.py:53-55 vs det/source.py:~130).
  • An agreement-measuring experiment ran on 2026-10-03 (scripts at /tmp/gitgalaxy-scratch/claude/xcheck/); this issue tracks productising it.

Impact on a real estate

Every proven program is a free ground-truth sample for the engine's facts, and today it is unused. Customers get engine facts (call graphs, lineage, layouts) that no test ties to the code that was actually proven.

Acceptance criteria

  • Move the experiment scripts into the repo (tests/tools) with a documented comparison per fact family: layouts/offsets, units, PERFORM/GO TO edges, calls, data moves, copybook expansion
  • Recorded baseline of agreement per family over all proven programs; a CI gate fails on regression below baseline
  • Each disagreement classified (engine bug / translator bug / legitimate difference) and tracked
  • Decision recorded on fact ownership (e.g. translator consumes engine layouts, or engine consumes translator layouts) per family

Out of scope

Fixing the individual engine bugs (#4242, #4245, #4246, #4203).

Found during: 2026-10-03 COBOL engine/translator audit

🤖 Generated with Claude Code

Activity

  1. added
    enhancement
    testing
    legacy-modernization
    priority: high
    on Oct 3, 2026
  2. squid-protocol commented on Oct 3, 2026

    @squid-protocol
    OwnerAuthor

    Experiment result (2026-10-03): engine vs translator on 54 det-ported programs

    Engine origin/main eefa097 (fresh scans of CardDemo, CBSA, GenApp, DBB mortgage) vs the det translator's own parse (det.source, det.layout.parse, det.stmt.parse). Items joined on (file, line, level): 14,714 of 14,714 matched. Scripts and outputs (durable copy): /nvme-data/projects/agent-scratch-2026-10-03/xcheck/ (xcheck.py, summarize.py, classify.py, srcline.py, robust.py, scan_estates.sh). A run takes ~2 s after the scans (~1 min), so it is ready to become the gate.

    Dimension Compared Agree Disagreements
    Item attributes (name/PIC/USAGE/OCCURS/ODO/REDEFINES/VALUE) 14,714 99.8% 137 engine wrong, 20 both defensible
    Elementary offset + size 10,060 99.26% 51 engine wrong (+26 engine-only fields), 23 POINTER (defensible)
    Record size 964 97.3% 15 engine wrong, 11 POINTER
    Units: paragraphs/sections/PROGRAM-ID 861 100% (same start lines) 40 definitional (copybook paragraphs, translator's (MAIN))
    PERFORM / GO TO edges 742 / 76 98% / 100% 13 CALL targets listed as performs; 2 engine wrong; engine keeps 1 of 180 THRU range ends
    CALL / LINK / XCTL / START 120 sites 98.3% sites, 100% targets 2 inside procedure copybooks
    MOVE pairs 4,455 / 4,365 100% of engine rows 90 in procedure copybooks with REPLACING
    Copybooks resolved 260 100%, depth 54/54 none
    EXEC SQL / EXEC CICS 70 / 514 98.6% / 65% engine records no RETURN-without-TRANSID, ASSIGN, ASKTIME, FORMATTIME, SEND TEXT

    Every disagreement checked against the COBOL source was either engine-wrong or definitional. None was translator-wrong.

    Engine bugs found:

    1. A signed VALUE (VALUE +0, VALUE -1) is dropped on 132 items (_VALUE_CLAUSE can't start with a sign), e.g. lgicdb01.cbl:35.
    2. EXEC SQL INCLUDE inside a record is not expanded by record_layout, and nothing reports it. In COTRTLIC the fields after line 304 sit 817 bytes early; the GenApp DFHCOMMAREA size comes back unknown.
    3. Entries that continue a COPYed record are double-counted (COTRN02C:62: 158 vs 100 bytes).
    4. A REDEFINES larger than its target is ignored (COADM02Y 272 vs 407; CORPT00C 1,360 vs 80,000).
    5. A REDEFINES target on the next line is not read (COTRTUPC:115).
    6. REPLACING is not applied (COBOL engine: copybook resolution in the wild (REPLACING-generated names, search-path order, same-named members) #4265), e.g. DELACC.cbl:200.
    7. UPDCUST records no PERFORM edges at all (cause not isolated).
    8. The DEPENDING ON qualifier is dropped.

    POINTER width (engine 4 = z/OS, translator 8 = 64-bit GnuCOBOL oracle) is defensible on both sides and needs a target-platform setting.

    Robustness on 149 unported programs: tree-sitter's DATA DIVISION fails on 25 (long continued literals: 14 NIST plus CBSTM03A:168; *> comments; IDMS; fragments), and the PROCEDURE DIVISION on 6 (SEARCH ALL crashes with "no open EVALUATE"; CBIMPORT and lgtestc1 don't parse). The engine still produced facts on 24/25 and 6/6, but that shows it emits output, not that the output is correct: bug 2 is silent.

    Recommended ownership:

    • Data layout: translator primary, engine checked by this gate. Reconsider once the engine is at 100% here (POINTER aside).
    • Item attributes for analysis: engine primary, after bugs 1, 5 and 8.
    • Units, PROGRAM-ID, call graph, inter-program calls, EXEC SQL, copybook resolution: engine primary, translator as the check.
    • Moves: engine for lineage, translator for meaning.
    • EXEC CICS: translator primary.

    For the translator to consume the engine's layouts:

    • fix bugs 1–6, and report unexpandable members instead of shifting fields silently;
    • record_layout returns every item (groups, REDEFINES overlays, 66/88) with offsets;
    • full typed VALUE lists, plus SIGN, JUSTIFIED, BLANK WHEN ZERO and inherited USAGE;
    • a POINTER-width platform setting;
    • system and BMS copybooks from the same source.

    The (file, line, level) join already maps 100% of items, so an engine→det.layout.Item adapter is feasible, with layout() kept as the check.

  3. squid-protocol commented on Oct 4, 2026

    @squid-protocol
    OwnerAuthor

    Two related explorations filed: #4377, a referee panel rating the engine's COBOL / CICS parsing against independent open-source parsers (Che4z, mapa, Cobrix, ProLeap, Spantree…), and #4378, a bake-off for the det translator's COBOL front end. This gate would be the first, two-parser case of #4377.

  4. squid-protocol commented on Oct 5, 2026

    @squid-protocol
    OwnerAuthor

    Queue note 2026-10-05: next up for an agent once the det/ translator work in flight (#4436 READ LENGTH) lands, to avoid two agents in det/ at once. Context since this was filed: the translator now refuses unmodelled CICS options and swallowed parse errors (#4411), re-wraps continuations (#4412: NIST CCVS85 39 → 143 of 150 parse), and keeps the language-pack grammar (#4378). The estate-crucible gate (#4446) now holds the engine side.

  5. squid-protocol commented on Oct 5, 2026

    @squid-protocol
    OwnerAuthor

    Closing: delivered in PR #4456 (105943d).

  6. added
    scope:infra
    era:2
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementera:2legacy-modernizationpriority: highscope:infratesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions