Skip to content

Fix #4243: the forge reads a multi-program source per program - #4291

Merged
squid-protocol merged 2 commits into
mainfrom
fix/4243-multi-program-forge
Oct 4, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
fix/4243-multi-program-forge

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Resolves #4243.

What was broken

cobol_graveyard_finder (the refraction forge's unit and dead-code reader) took everything after the first PROCEDURE DIVISION as one program. DBB epscsmrd.cbl has eleven batch-compiled siblings and two nested programs, and each one opens with MAINLINE SECTION. Read that way:

  • the later programs' AUTHOR / INSTALLATION / LINKAGE / WORKING-STORAGE headers became units of the first program;
  • thirteen MAINLINEs collapsed into one name;
  • reachability crossed program boundaries.

Against the key's draft entry (#4206 models the file as siblings with PROG:NAME units), the forge scored 973 mismatches: units 236 fp / 251 fn, dead 237 / 6, non-trivial dead 237 / 6. This is the "about 1,000" in the answer-key README.

Changes

  • split_programs (graveyard finder). A program starts at each IDENTIFICATION DIVISION. in Area A and ends at its END PROGRAM; a header met while a program is open starts a nested one. Each program keeps only its own lines, so a nested program's lines are cut out of its parent, and copybooks are inlined per program. A one-program source, or a free-format one, takes the old code path unchanged.

  • x_ray_dead_code / old_paragraphs compute units and reachability per program. A later program's units are named PROG:NAME (keyed_unit), the same as the key, so forge and key score pair for pair.

  • The reader gaps the key's draft already fixed on this file (answer key: model multi-program sources (sibling programs / END PROGRAM) #4206), ported to the forge (they are what made its dead verdicts wrong here):

    • GO TO targets are read one name at a time after the verb (_GO_TO_TARGET). The old match consumed a run of names that also spans the following statements, so it swallowed the later GO TO X000000CC … X00000174 DEPENDING ON, and 169 EPSCSMRI targets read as dead. Reading token by token also keeps the pattern out of the ReDoS gate; a lookahead version, even bounded, was flagged.
    • A plain GO TO after a GO TO … DEPENDING ON in the same sentence ends the unit.
    • XML PARSE … PROCESSING PROCEDURE A THRU B reaches A..B like a PERFORM.
    • END-XML / END-JSON / END-INVOKE close an ON EXCEPTION phrase.
  • refraction_differential:

    • engine units and usage_status units are placed in their program by start line (_program_placer, innermost program wins, read with the key's program_spans);
    • the classifier context (own_units, unit_kind, reached) is per program;
    • key verdicts use keyed_units / keyed_dead.

    The key's bare_units / bare_dead (grading the forge on bare names) are removed: nothing reads a file as one program any more.

  • Docs: the answer-key README and epscsmrd.cbl's excluded_programs note no longer describe the one-program reading. The file stays excluded until it is censused.

  • Field testing: D043 (forge, units / dead, DBB round, found by the fix(answer-key): model multi-program sources (sibling / nested programs) (#4206) #4226 census); report regenerated.

Numbers

  • epscsmrd.cbl against a locally drafted key entry (not committed; scratch harness calling draft_program + score), forge side: units 269/269, 0 fp / 0 fn; dead 6/6, 0 / 0. On origin/main it was 973 mismatches.
  • Refraction snapshot, DBB full corpus: re-blessed. Only epscsmrd.cbl moved: its IR dump now lists the six EPSCSMRI headers the key and the engine call dead, instead of 238 cross-program "dead" names, and the audit summary goes from 238 to 7 unreachable blocks. No other corpus snapshot moved.
  • Full-corpus refraction differential: with Fix #4242: record a quoted PROGRAM-ID (PROGRAM-ID. 'EPSCSMRD'.) #4285 cherry-picked locally on top of this branch, epscsmrd.cbl's 7 paragraph/old and 231 usage_status_not_reachability deltas are gone. What remains is 26 schema_column/db. Those are not multi-program: they are the first program's own items, and cobol_schema_forge._LEVEL_ENTRY accepts only two-digit level numbers (01, [1-4][0-9]), so this generated wrapper's 1 / 2 / 3 levels are skipped. They are the same names as the file's forge_flat_schema record deltas. That's a separate follow-up, not done here.

Merge order (with #4285)

Verification

  • tests/cobol_mainframe + tests/cics_crucible with every pinned corpus fetched: 1389 passed, 427 skipped.
  • New tests:
    • test_cobol_graveyard_finder.py: the multi-program split and per-program dead set; one-program and free-format reading unchanged; the GO TO run; DEPENDING then GO TO; XML PARSE / END-XML. The five reader and split tests fail on main's code.
    • test_cobol_answer_key.py: forge old_paragraphs and dead verdicts equal the key's keyed units and dead set on the multi-program fixture.
    • test_refraction_differential.py: engine unit placement.
  • Ground-truth ledger: clean. refraction_differential.py --ci: no new unexplained. ReDoS tool-regex gate: passes.
  • ruff / mypy / dead-key / ast-accuracy audits: all clear. No engine parsing code changed, so no crucible run.

Not done

🤖 Generated with Claude Code

cobol_graveyard_finder read a source holding several programs as one: DBB
epscsmrd.cbl (eleven batch-compiled siblings, two nested, each opening with
MAINLINE SECTION) gave the later programs' AUTHOR / INSTALLATION / LINKAGE
headers as units of the first, one MAINLINE for thirteen, and reachability
across programs -- 973 forge unit / dead mismatches against the key's draft.

- split_programs: a program per IDENTIFICATION DIVISION in Area A, ending at
  its END PROGRAM; a header met while one is open nests in it. Each program's
  own lines (a nested program's cut out), copybooks inlined per program.
  A one-program or free-format source takes the old path unchanged.
- x_ray_dead_code / old_paragraphs: units and reachability per program, a
  later program's named PROG:NAME as the key does (#4206).
- The same reader gaps the key's draft fixed on this file (#4206): GO TO
  targets read one name at a time after the verb (a consuming run swallowed
  the later GO TO ... DEPENDING ON), a plain GO TO after a DEPENDING ON ends
  the unit, XML PARSE PROCESSING PROCEDURE A THRU B is reached like a PERFORM,
  END-XML / END-JSON / END-INVOKE close ON EXCEPTION.
- refraction_differential places engine units per program (PROG:NAME), its
  classifier context is per program, and key verdicts use keyed names; the
  key's bare_units / bare_dead (one-program grading) are gone.
- epscsmrd.cbl against its draft: forge units 269/269, dead 6/6 (from 18
  matched units and 0 dead). DBB full refraction snapshot re-blessed: the
  file's IR dump now names the six EPSCSMRI headers. Field-testing D043.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@squid-protocol
squid-protocol force-pushed the fix/4243-multi-program-forge branch from af70009 to cd4104c Compare October 3, 2026 22:27
@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
squid-protocol marked this pull request as ready for review October 4, 2026 12:29
@squid-protocol
squid-protocol merged commit fec04a0 into main Oct 4, 2026
39 checks passed
@squid-protocol
squid-protocol deleted the fix/4243-multi-program-forge branch October 4, 2026 12:32
squid-protocol added a commit that referenced this pull request Oct 4, 2026
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]>
squid-protocol added a commit that referenced this pull request Oct 4, 2026
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]>
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 forge/differential reads a multi-program source as one program, blocking EPSCSMRD onboarding

1 participant