Repository navigation
COBOL: the main line is a function_data unit named after its PROGRAM-ID (#7170) - #7172
Conversation
…ID (#7170) A program's main line (PROCEDURE DIVISION code before its first paragraph) was a calls-only __global_context__ bucket (#4302): edges only, no size, complexity or signals, and dropped entirely when it called nothing. A program that does its work before its first paragraph (or has none) was invisible to every per-function view; 17 crucible COBOL files with no paragraphs were classified Declarative / Non-Code. detector: the main line is measured like a paragraph (from its header, loc the physical span, args from the header's USING list), named after the nearest PROGRAM-ID, def_shape 'main_line', in the population with its own impact, kept without edges, exempt from the orphan/duplicate verdict. No PROGRAM-ID: the old calls-only bucket. DECLARATIVES opening the division is not a main line. call_resolver: a main line is a caller, never a definition (CALL 'PROG' does not land on it), so call resolution is unchanged. galaxy_ir: main lines stay out of the paragraph inventory (translator, forges). cobol_answer_key / estate_crucible: read the main-line row as the main line, with its extent; older DBs keep the synthetic_unit_data path. Ledger: 18 mismatches fixed, 0 introduced (CardDemo unit extents 871 -> 881/881, zECS 216 -> 221/221, DSF 155 -> 158). Estate crucible 61/63 -> 61/63, none moved. Goldens: function-level channels move on COBOL files only; non-COBOL files move only in scan-wide channels (topological coordinates, PageRank). Closes #7170 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Field check on unkeyed code: the agentic-COBOL repos that found this bug (
|
|
No description provided. |
|
CodeQL |
|
PR #7172 @ 852ebc3: 1 failed check(s) == Analyze (python) (failure) -- real |
…ine is a function (#7170) summary.functions 167 -> 168; gridwalker.cob functions 0 -> 1 (its main line, now a function_data unit). fps-cob, agentic-cobol-doom-cc and mood are unchanged (their programs open with a paragraph). Checked locally first with doom_rosetta_check.py on the four COBOL-bearing ports: the same two differences CI's shard 2 reported, nothing else. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
DOOM-rosetta shard 2 was this PR's intended change: |
|
CI shepherd: the head of this PR (3a5557b) is not the one a maintainer labelled |
|
No description provided. |
|
PR #7172 @ 3a5557b: 4 failed check(s) == db2 ${{ matrix.shard }} (cancelled) -- infra == det (failure) -- real == shard ${{ matrix.shard }} (cancelled) -- infra == shard ${{ matrix.shard }} (${{ matrix.loc }} LOC) (cancelled) -- infra |
|
No description provided. |
|
No description provided. |
|
No description provided. |
…inned; docs_read_by_tests refreshed
full-suite part 1/2 failed test_free_format_data_entries_are_not_units[sibling_programs]: its
CobolCraft sibling programs have no paragraphs and now (correctly) carry main lines named after
their PROGRAM-IDs. _units() lists paragraph and section units, as the test means ('no unit is a
data item'), and a new test pins FACING-GETRELATIVE L11-16 and DECODE-INT L32-34 with no LK-*
data name among the units. docs_read_by_tests.txt gains the new test's MAINLN.cbl / NOPARAS.cbl.
Full local run of tests/core_engine, extraction, cobol_mainframe, tools, estate_crucible: 27,008
passed, the only failure the stale list fixed here.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # tests/golden_master_audit/12_scan_output_snapshots/gpu_json.json # tests/golden_master_zero_dep_audit/12_scan_output_snapshots/gpu_json.json
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
CI shepherd: the head of this PR (7a08950) is not the one a maintainer labelled |
|
No description provided. |
|
PR #7172 @ 7a08950: 9 failed check(s) == crucible (failure) -- real == db2 ${{ matrix.shard }} (cancelled) -- infra == det (failure) -- real == full-suite (failure) -- real == full-suite part ${{ matrix.group }}/${{ needs.shard-plan.outputs.splits }} (cancelled) -- infra == measure (shard ${{ matrix.shard }}/${{ matrix.total }}) (cancelled) -- infra == shard ${{ matrix.shard }} (cancelled) -- infra == store the suite's durations (cancelled) -- infra == suite time budget (#5166) (cancelled) -- infra |
|
No description provided. |
…Fixes #7374) (#7377) #7172 made the COBOL main line a non-synthetic function_data unit named (procedure division). engine_adapter put it in `units` too, though the key and the translator name only paragraphs and sections there: 19 NEW engine-only units disagreements. The same change gave the engine the main-line extent, so the 19 ledgered unit_extents disagreements (and the engine-main-line-no-extent cause) no longer reproduce. Co-authored-by: Claude Sonnet 5.5 <[email protected]>
…y guards The duplicate/orphan guard now skips both the entry unit a PROCEDURE DIVISION falls into (#7206) and the program's main line (#7170). The main-line test now expects the main line as its own never-orphan unit; the first paragraph is still flagged. Goldens take main's side here and are re-blessed in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What was broken
A COBOL program's main line, the procedure-division code before its first paragraph, had no
function_datarow. #4302 made it a calls-only__global_context__bucket insynthetic_unit_data. That bucket holds only edges: no size, complexity or signals. It was also dropped entirely when the main line called nothing. As a result, a program that does its work before its first paragraph, or has no paragraphs at all, was invisible to every per-function view: hotspots, distributions, archetypes,sfsfingerprints.Example: in
acherm/agentic-chessengine-cobol-codex, 45% of the procedure code sits in main lines.src/eval.cobhas 328 coding lines and 0 functions. In the crucible, 17 COBOL files with no paragraphs were classified Declarative / Non-Code.Fix
Engine (
gitgalaxy/core/detector.py,_cobol_procedure_entry_units):PROGRAM-ID(quoted names too) and getsdef_shape = "main_line".PROCEDURE DIVISIONheader,locis the physical span, and its args are the header'sUSINGlist.DECLARATIVES.opening the division is not a main line.Other readers kept consistent:
core/call_resolver.py: amain_lineunit is a caller, never a definition.CALL 'PROG'andPERFORM PROGdo not land on it, so call resolution is unchanged; only the caller's identity moves from the synthetic bucket to the new row.tools/cobol_to_cobol/galaxy_ir.py: main lines stay out of the paragraph inventory, so the det-port translator and the forges see the same units as before. Older DBs withoutdef_shapestill load.tests/tools/cobol_answer_key.pyandtests/tools/estate_crucible.py: they read the main-line row as the program's main line, with its extent. A main line the key does not list is not a phantom paragraph. Older DBs keep thesynthetic_unit_datapath.function_population.py's docstring, and thefact_ownership.mdstatus row ("main line has no extent").Before -> after
Repro, two files:
mainln.cob(a 9-line main line with a loop and an IF, thenSHOW-IT):SHOW-IT;MAINLNL7–15 with branch count 3, callingSHOW-IT, not dead.noparas.cob(no paragraphs):NOPARASL3–8.Regression tests:
tests/extraction/languages/test_cobol_procedure_entry_4302.py(13 tests, rewritten from the COBOL engine: statements between PROCEDURE DIVISION and the first paragraph belong to no unit, so the program's main-line PERFORM/CALL edges are never recorded #4302 file):tests/cobol_mainframe/test_cobol_main_line_7170.py(3 tests, one real scan):test_cobol_answer_key.py,test_estate_crucible_scorer.pyandtest_referee_che4z_lsp.py(174 passed), andtest_galaxy_ir.py(78 passed).Golden masters (vs
8468edeb1f74), both legs identicalBlessed through
bugfix_kit.py bless: 32 fixtures, 300 scanned files moved (cobol 138).Function-level channels move on COBOL files only:
Every one is the new main-line unit and its weight entering the file's statistics.
Non-COBOL files move only in scan-wide channels: Topological Coordinates X/Y/Z and PageRank, which are normalised over the whole scan, so added COBOL mass shifts them everywhere.
I checked every changed leaf of both legs by language. The only non-COBOL-labelled changes outside those channels are two repo-wide rollups:
scope --expect coboltherefore reports non-COBOL movement. All of it is these scan-wide channels.Ground-truth ledger
18 mismatches fixed, 0 introduced;
ledger checkpasses.Estate-crucible
61/63 horrors passing → 61/63. 0 horrors moved.
Audits
mypy, ruff and dead-key
--ciall pass, and the changed test files pass (16).Draft, per the owner's hold on the DOOM/COBOL study work. This fix unblocks the agentic-COBOL structural comparison.
Closes #7170
🤖 Generated with Claude Code