Skip to content

COBOL: the main line (PROCEDURE DIVISION code before the first paragraph) has no function_data row, so its size, complexity and calls are missing from every per-function view #7170

Closed

Description

@squid-protocol

What happens. A COBOL program's main line is the procedure-division code before its first paragraph. It gets no row in function_data. The file's coding_loc counts that code, but no function does. So its LOC, complexity, fan-out, archetype and signals are missing from every per-function view: hotspots, distributions, archetype mix, sfs fingerprints and call-graph shape.

#4302 (closed 2026-10-04) records the main line's PERFORM/CALL edges. It did not give the main line a unit row, and the ground-truth ledger still attributes CardDemo's unit-extent gap (871/881) to "main line in no unit".

Evidence. Engine 6c7c6c1bc, scanning acherm/agentic-chessengine-cobol-codex @ 58f68b2289fd05738c1af02fed23a37da9741c35 (MIT):

file file coding_loc function rows LOC in functions answer-key main line
src/eval.cob 328 0 0 lines 59–385
src/board.cob 23 0 0 lines 13–28
src/perft.cob 55 0 0 lines 37–64
src/fen.cob 224 4 92 lines 42–167

Across the repo, tests/tools/cobol_answer_key.py (draft + add-extents) puts 906 of 2,008 procedure lines (45%) in main lines of 9 of its 11 programs. The scorer reports unit extents P 57/57 · R 57/68 · 875 code lines outside any unit. In other repos it varies widely: 39% in acherm/agentic-cobol-pygame, 5% in acherm/agentic-cobol-compress, and 0% in programs that open with a named paragraph. Per-function statistics therefore compare different fractions of each codebase, and a whole program with no paragraphs (eval.cob) is invisible to them.

Expected. One unit per main line, with a stable name (for example the PROGRAM-ID, or a reserved marker for the main line, as other languages' top-level slices get), from the first procedure statement to the line before the first paragraph header. It should carry complexity, LOC, signals and the main-line call edges #4302 already records. The answer key's main_line extents give the target.

Scope to check in the fix

  • Every COBOL path that writes function_data. Check what the existing __global_context__ convention means for COBOL, and keep downstream readers that drop synthetic slices consistent with it (sfs drops __global_context__, so the main line likely needs a distinct, non-synthetic name).
  • Nested programs and multiple PROCEDURE DIVISIONs in one file.
  • Programs whose main line is empty: no row, unchanged.
  • Procedure code that lives in COPYed copybooks.
  • Fixed and free format.
  • Ledger: the CardDemo unit-extents row should rise from 871/881 by the main-line share. That needs a golden and ledger re-bless.

Found by the agentic-COBOL structural comparison (DOOM study follow-up). That comparison is on hold until this is fixed, because main-line share differs sharply between the systems compared.

Activity

  1. added
    bug
    core-engine
    on Oct 30, 2026
  2. added a commit that references this issue on Nov 1, 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

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions