You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cobol func_start: free-format source reads data items as paragraphs and misses PROGRAM-ID units (CobolCraft) #4203
bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginelegacy-modernizationCOBOL refractor, dead-code extraction, and JCL forgingpriority: mediumquestionFurther information or community discussion requestedscope:coreBlocks a burned-estate program's next evidence rung, or the 4th-estate one-shot trial
In free-format COBOL (GnuCOBOL -free, *> comments, no sequence area), func_start reads data definitions as paragraphs and misses the program units. The rule's own comments (cobol.py, the CEE3DMP shield) note that "a real structural fix needs file-level fixed/free-format detection"; #2538 and #3197 deferred it.
Repro
CobolCraft (github.com/meyfa/CobolCraft @ e8c420df7a90, MIT), scanned with galaxyscope at main:
LK-POSITION (a LINKAGE item), spanning all 3 programs
src/encoding/decode.cob
13
12
VALUE-BYTES ×9, BYTE-ALPHA, LK-VALUE, LK-SLOT: all data items
Free-format data lines like 01 VALUE-BYTES. match as paragraph headers once the optional sequence-area slot swallows the indent. Meanwhile PROGRAM-ID. X. / END PROGRAM X. units, which carry CobolCraft's structure, aren't counted. Other readings (doc lines, calls/ipc) matched the source in the files checked.
Proposal
Detect the format per file: >>SOURCE FORMAT FREE / >>SOURCE FREE, *> comment density, lines with code in columns 1–6, or code past column 72.
For free-format files, anchor paragraph and section headers to a lone NAME. sentence in the PROCEDURE DIVISION only. Count nested or consecutive PROGRAM-ID units as function boundaries, and never count level-number data lines.
Add CobolCraft-shaped valid and invalid fixtures to the COBOL tests.
Follow-up from PR #4227 (which landed the free-format half): the PROGRAM-ID / END PROGRAM unit-boundary half remains open and needs a design call. It changes func_start counts for every COBOL file, and PROGRAM-IDs are already counted in class_count, so counting them as functions as well makes each program both a class and a function. Decision needed before implementing: (a) keep PROGRAM-ID as class only, (b) also count as func_start, (c) only for multi-program sources. Labelling this question. Also see multi-program issues #4243 and #4245.
Found by estate-crucible v0.2.0 (#4317); planted in squid-protocol/estate-crucible, scored by tests/tools/estate_crucible.py on main (#4337 has the full scorecard). The horror flips to pass when this is fixed.
Neither file has a procedure paragraph or section; each program's PROCEDURE DIVISION runs straight to GOBACK.. So zero units is the correct reading, and no data item is read as a paragraph any more. The free-format data-entry shield (#4227) and the "units only inside the PROCEDURE DIVISION" rule (#4306) both cover this shape.
The column-1 hyphen shape (H-0028) was fixed separately in #4371.
What is left of this issue is the PROGRAM-ID-as-unit half (should a nested or batch-compiled program count as a function boundary?). That is the owner's design question and is untouched here.
Adding programs as units would double-count lines and churn unit counts, keys and goldens across every COBOL estate right before the 4th-estate attempt.
Grouping paragraphs by owning program is tracked separately as a container attribute (follow-up issue).
bugUnintended behavior or logic failure in the enginecore-engineModifications to the central physics and parsing enginelegacy-modernizationCOBOL refractor, dead-code extraction, and JCL forgingpriority: mediumquestionFurther information or community discussion requestedscope:coreBlocks a burned-estate program's next evidence rung, or the 4th-estate one-shot trial
Activity
Bug sweep (COBOL engine): #4204 #4205 #4203 (#4227)
squid-protocol commentedon Oct 3, 2026
Follow-up from PR #4227 (which landed the free-format half): the PROGRAM-ID / END PROGRAM unit-boundary half remains open and needs a design call. It changes
func_startcounts for every COBOL file, and PROGRAM-IDs are already counted inclass_count, so counting them as functions as well makes each program both a class and a function. Decision needed before implementing: (a) keep PROGRAM-ID as class only, (b) also count as func_start, (c) only for multi-program sources. Labelling thisquestion. Also see multi-program issues #4243 and #4245.squid-protocol commentedon Oct 4, 2026
Another shape of this issue (estate-crucible horror H-0028):
>>SOURCE FORMAT FREE, the paragraphLOOKUP-RATE.starting in column 1 is recorded as a unitRATE. Its hyphen sits in column 7, and the fixed-format sequence/indicator slot offunc_startstill applies. This is a new shape of cobol func_start: free-format source reads data items as paragraphs and misses PROGRAM-ID units (CobolCraft) #4203.Found by estate-crucible v0.2.0 (#4317); planted in squid-protocol/estate-crucible, scored by
tests/tools/estate_crucible.pyon main (#4337 has the full scorecard). The horror flips to pass when this is fixed.COBOL func_start: a column-1 free-format paragraph keeps its whole na…
squid-protocol commentedon Oct 5, 2026
The first half (free-format data lines read as paragraph headers) no longer reproduces on main.
I re-scanned the issue's two CobolCraft files at
e8c420df7a90withgalaxyscope --db-onlyon maine514b4d62(after #4227, #4264, #4306 and #4371):src/util/coordinates.cobLK-POSITION, a LINKAGE item)src/encoding/decode.cobVALUE-BYTES×9,BYTE-ALPHA,LK-VALUE,LK-SLOT)Neither file has a procedure paragraph or section; each program's PROCEDURE DIVISION runs straight to
GOBACK.. So zero units is the correct reading, and no data item is read as a paragraph any more. The free-format data-entry shield (#4227) and the "units only inside the PROCEDURE DIVISION" rule (#4306) both cover this shape.The column-1 hyphen shape (H-0028) was fixed separately in #4371.
What is left of this issue is the PROGRAM-ID-as-unit half (should a nested or batch-compiled program count as a function boundary?). That is the owner's design question and is untouched here.
🤖 Generated with Claude Code
squid-protocol commentedon Oct 5, 2026
Closing.
IDMS-CONTROL SECTION/PROTOCOL.(ENVIRONMENT DIVISION) recorded as procedure units #4306 and COBOL func_start: a column-1 free-format paragraph keeps its whole name (part of #4203) #4371, as verified in the comment above.#7170: the #4203 free-format test reads paragraph units; main lines p…
#7170: ruff format the #4203 data-name check
COBOL: the main line is a function_data unit named after its PROGRAM-…