Skip to content

Fix #4264: fixed / free COBOL reference format, per file and per directive - #4290

Merged
squid-protocol merged 5 commits into
mainfrom
fix/4264-source-format
Oct 4, 2026
Merged

squid-protocol merged 5 commits into
mainfrom
fix/4264-source-format

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Resolves #4264.

What was broken

  • No fixed/free detection, no >>SOURCE FORMAT handling. cobol.py:137 said outright that column-73 blanking was "unsafe without fixed/free-format detection".
  • Identification-area text reached the readers. In fixed format, columns 73-80 are an identification area the compiler ignores (NIST CCVS NC1314.2 on every line), but every COBOL rule and reader saw it. On the crucible's NIST CCVS85 set:
    • about 2,500 phantom data-flow operands (MOVE "." -> NC1314);
    • a CONTENT:IC2244 operand in CALL USING;
    • 198 dataset bindings whose DD name was the tag (DB1044 instead of the XXXXX055 on the next line).
  • Free-format lines were cut. The cobol func_start: Area-B continuation lines ending in a period become paragraphs (follow-up to #2538's deferred fixed/free-format anchor) #3197 sentence scan cut every line at column 72, so a free-format statement whose period sits past column 72 never ended its sentence.

Changes

  • gitgalaxy/core/cobol_source_format.py (new):
    • line_formats gives each line fixed / free / variable: the file's detected format, switched from the line after each directive. Directives handled: >>SOURCE [FORMAT] [IS] FREE|FIXED|VARIABLE, >>FORMAT …, and Micro Focus $SET SOURCEFORMAT"FREE" / (FIXED) / '…'.
    • blank_identification_area blanks columns 73+ of fixed lines only, keeping offsets and lengths.
    • Detection is a documented vote. Free evidence: *> or program text in cols 1-6, a word crossing col 72/73, text past col 80. Fixed evidence: a six-digit sequence area, a col-7 indicator, a lone token in cols 73-80. Fixed is the default.
  • Prism: the COBOL code stream has the identification area of fixed lines blanked before any rule or reader runs; free and variable lines keep their text past column 72. Detection reads the raw segment, comments included.
  • Detector: _cobol_sentence_start_offsets cuts at column 72 only on fixed lines.
  • db2_declare_table._blank_sequence_fields (COBOL): leaves free lines alone, with no cols 1-6 or 73+ blanking. It is shared by the data-move, CALL USING, file-control, MQ, SQL and UOW readers.
  • mainframe_boundary SELECT reader (dataset bindings, cobol_select_assigns): blanks sequence fields, as file_control already did. The tag had been hiding a real defect. With ASSIGN TO at a line's end, the next line's 003400 sequence area made the regex fall back to capturing TO. It now reads the real name.
  • cobol.py: the cols 73-80 note is updated to point at this layer. Comment only; no rule regex changed, so this does not touch Fix #4242: record a quoted PROGRAM-ID (PROGRAM-ID. 'EPSCSMRD'.) #4285's class_start edit.

What moved, and why

Golden masters: 1,054 differences per mode across 147 files. I scoped all of them from a golden_store export --rev HEAD + deep_compare, not from the truncated crucible_check view.

  • 140 NIST CCVS85 files:
    • Data Moves / Record Layout / File Control / Dataset Bindings / Call Sites lose identification-area tokens, and dataset bindings gain their real XXXXXnnn names (198 changes, none to TO or blank);
    • the architectural-profile coordinates follow.
  • Completeness:
    • data flows: total 29,608 → 27,143, unresolved operands 3,702 → 1,160, ratio 87.5% → 95.7%;
    • program calls resolved 301 → 358: e.g. IC101A's CALL "IC102A" now resolves to IC1024.2.cbl, adding an import edge;
    • batch entry 287 → 265: 22 subprograms are now reached by a CALL;
    • score 61.4% → 64.4%.
  • carddemo COCRDUPC.cbl: line 1530 holds only 340000 in cols 73-80. It is no longer a code line (coding LOC −1). Doc LOC +1 is the existing accounting (raw non-blank lines minus code), not new comment text.
  • cics-genapp (2 files), ada/alire (2 files), other carddemo files: composition-fit z-scores only. That's the cluster centroids re-solving.
  • Global: LOC −1, network macro metrics, the LLM brief and the GPU / graph digests follow from the above.

Verification

  • New tests/core_engine/test_cobol_source_format_4264.py (15 tests): directive forms, including negatives (a literal, a comment); detection of fixed, free and the default; fixed blanking with lengths kept; a free line longer than 72 columns kept, by Prism and by _blank_sequence_fields; mixed-with-directive switching; and a free sentence ending past column 72 still ends, so the paragraph after it is found.
  • With every mainframe corpus fetched, tests/cobol_mainframe + tests/cics_crucible + COBOL extraction (strict included) + tests/core_engine + test_golden_store.py: 3,883 passed, 432 skipped. Run with PYTHONPATH set to the worktree: a shared venv otherwise gives spawned pool workers another checkout's code.
  • Pinned-corpus completeness pins and the full-corpus refraction differential are unchanged. The ground-truth ledger is clean.
  • crucible_check.py --update --yes: both fixtures re-blessed, scoped as above.
  • ruff / mypy / dead-key / ast-accuracy audits: all clear. Format clean.
  • Field testing: defect D043, found_by: review (like D035), fields data moves, CALL USING, DD names; report regenerated. D041 / D042 are taken by Fix #4242: record a quoted PROGRAM-ID (PROGRAM-ID. 'EPSCSMRD'.) #4285 / Fix #4246: an unnamed data description entry is an implicit FILLER #4284, so whichever merges later rebases that file.

Not done

🤖 Generated with Claude Code

squid-protocol and others added 2 commits October 3, 2026 18:01
…ctive

Columns 73-80 of a fixed-format line are an identification area the compiler
ignores, and no COBOL reader knew fixed from free format: NIST CCVS tags
(`NC1314.2`) leaked into data moves, CALL USING operands and DD names, while a
free-format line past column 72 was cut by the sentence scan.

- gitgalaxy/core/cobol_source_format.py: per-file detection (documented vote:
  `*>` / code in cols 1-6 / a word crossing col 72 vs a numbered sequence
  area, a col-7 indicator, a lone cols 73-80 tag; fixed by default) and
  `>>SOURCE [FORMAT] [IS] FREE|FIXED|VARIABLE`, `>>FORMAT`, Micro Focus
  `$SET SOURCEFORMAT` switching from the line after the directive.
- Prism blanks the identification area of fixed lines only (offsets kept),
  for every COBOL rule and reader; free / variable lines keep their text.
- The #3197 sentence scan cuts at column 72 only on fixed lines;
  _blank_sequence_fields leaves free lines alone.
- The SELECT reader (dataset bindings) blanks sequence fields as file_control
  does: with the tag gone, `ASSIGN TO` / name-on-next-line read `TO`.
- cobol.py's cols 73-80 note resolved (comment only; no rule changed).
- Golden masters re-blessed (147 files, 140 of them NIST CCVS85; scoped in
  full); field-testing defect D043 (review).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
# Conflicts:
#	docs/language_status/cics_field_testing.md
#	tests/cobol_mainframe/field_testing.json
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol marked this pull request as draft October 4, 2026 12:04
squid-protocol and others added 3 commits October 4, 2026 08:59
Both sides re-blessed the golden masters (this branch on v1.6.0, main
on v1.7.0 via #4259), so the conflicted snapshots were regenerated
from the merged code in both CI legs (full-precision, zero-dependency)
rather than hand-merged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
field_testing.json merged by entry (main's #4243 defect kept; this
branch's defect renumbered where its ID collided), then
cics_field_testing.md and fact_channel_confidence.json regenerated
with `tests/tools/field_testing.py report --write` rather than
hand-merged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Golden masters regenerated in both legs (full-precision, zero-dependency)
against language-crucible v1.7.0 on the merged engine; field-testing report
and fact_channel_confidence.json regenerated with field_testing.py report --write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FNWHcUSn5p7eMxFTsB5rFo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

COBOL engine: >>SOURCE FORMAT directives and per-file fixed/free detection with column-72 handling

1 participant