Repository navigation
Forge: copybook resolver reads every copy shape (#3414); schema reader reads whole entries (#3348) - #3437
Merged
Conversation
…r reads whole entries (#3348) cobol_graveyard_finder (#3414): COPY_PATTERN now matches - COPY with its period on a later line, including after a sequence field (CardDemo `COPY 'CSSTRPFY'` / ` .`, `COPY CSUTLDPY` / ` .`); - REPLACING spanning lines (CSSETATY); - COPY ... IN|OF <library> (zopeneditor SAM1LIB); - EXEC SQL INCLUDE, on one line or split (CBSA's DB2 members, CardDemo's CSDB2R*). `.dcl` DCLGEN members are copybooks. Named groups plus copy_member(); resolve_copybooks and the answer-key scorer's forge view both use them. The scorer's view now trims cols 73-80 as resolve_copybooks does. cobol_schema_forge (#3348): data_entries() reads per data description ENTRY, not per line. So a PIC on the next line, a PIC after REDEFINES or OCCURS, and edited pictures (`+9(10).99`, `ZZZ,ZZ9`) are seen. The cols 1-6 sequence area and zopeneditor's `R2` markers are blanked, sequence-only lines no longer swallow the next entry, and literals are blanked. It also fixes a latent type bug: the PIC used to include the entry's terminating period, so every `PIC 9(n).` was typed DECIMAL(n, 0) instead of an integer. Ground-truth ledger: -419 forge entries (385 record fields -> 3,853/3,853 exact on all three corpora; 34 copybook paths -> exact). +32 deliberate `forge_units_include_copied_paragraphs`: the forge reads the compiled program, so a procedure-division copybook's paragraphs are units of the program that copies them, which dead-code analysis needs; the key lists source-file paragraphs. Refraction snapshots re-blessed: added schema columns, DTO/entity fields and IR entries for the recovered fields; integer types for PIC 9(n). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g
Contributor
…ecords-3414-3348 # Conflicts: # tests/cobol_mainframe/ground_truth_ledger.json # tests/cobol_mainframe/refraction_snapshot/full/aws-mainframe-modernization-carddemo/clean/04_ir_state_dumps/COACTUPC_ir.json.snap # tests/cobol_mainframe/refraction_snapshot/full/aws-mainframe-modernization-carddemo/clean/04_ir_state_dumps/COTRTLIC_ir.json.snap # tests/cobol_mainframe/refraction_snapshot/full/aws-mainframe-modernization-carddemo/clean/04_ir_state_dumps/COTRTUPC_ir.json.snap # tests/cobol_mainframe/refraction_snapshot/full/aws-mainframe-modernization-carddemo/java/java_migration_audit.txt.snap # tests/cobol_mainframe/test_cobol_graveyard_finder.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3414. Refs #3348: this fixes the forge's own record reader. Switching the refractor onto
EngineFile.recordsis #3348's larger scope and is left for that issue.Together with #3436, this leaves the forge exact against the fully censused answer keys on every field the ledger scores. The ledger keeps only two causes, both deliberate.
#3414:
COPY_PATTERNreads every copy shape (cobol_graveyard_finder)Hand-verified misses, now all resolved (34 → 0):
COPY 'CSSTRPFY'/.,COPY CSUTLDPY/.,206400 COPY 'CSSTRPFY'/206500 ..COPY … IN|OF <library>: zopeneditor SAM1LIB.EXEC SQL INCLUDE, one line or split: CBSA's DB2 members, CardDemo's CSDB2R*..dclDCLGEN members as copybooks.The pattern now uses named groups plus
copy_member().resolve_copybooksand the answer-key scorer's forge view both use them, and the scorer's view now trims cols 73–80 exactly asresolve_copybooksdoes.#3348:
cobol_schema_forgereads whole data entriesThe new
data_entries()works per data description entry (a sentence), not per line. Record fields go from 3,468 to 3,853 of 3,853: exact on zopeneditor, CBSA and CardDemo, with no false fields. Shapes the line reader lost:01 ACTUAL-BALANCE-DISPLAY PIC +9(10).99. The PIC class lacked+ , $ / * Z B.ACCOUNT-KY2-BYTES REDEFINES ACCOUNT-KY2 PIC X(16).07 WS-CUSTOMER-RANGE-BOTTOM/PIC ….R2change markers; a line holding only its sequence number no longer swallows the next entry.Latent type bug fixed in passing: the old PIC capture included the entry's terminating period, so
PIC 9(4).read as9(4).and every numeric item ending a line was typedDECIMAL(n, 0). It's now typed as an integer (SMALLINT/INTEGER/BIGINT), and the generated Java fields follow.Ground truth
forge_flat_schemaand 34forge_copybook_resolution, both causes now gone.forge_units_include_copied_paragraphs(owned by Forge copybook fallback: follow EXEC SQL INCLUDE and COPY … IN <library> #3414). The forge reads the compiled program, so a procedure-division copybook's paragraphs (CSSTRPFYYYYY-STORE-PFKEY, CSUTLDPYEDIT-DATE-*, CSDB2RPY9998-PRIMING-QUERY) are units of the program that copies them. Dead-code analysis needs that. The key lists paragraphs from the program's own source file. These surfaced once the period-on-next-line COPY started resolving.Refraction snapshots (re-blessed: excerpts plus full zopeneditor, CBSA and CardDemo)
I read the
checkdiff first. What moved:Added columns, DTO/entity fields and IR entries for the recovered fields. Every removed column line is re-added in the same file; they're trailing-comma moves.
Integer types for
PIC 9(n)., as above.Two entity renames, which follow the forge's existing "table named after the last 01 group" rule:
Cbact01cWsReissueDate→Cbact01cWsAcctReissueDate:WS-REISSUE-DATE … REDEFINES … PIC X(10)is elementary, and the old reader mistook it for a group;…RptStatsDetail→…RptStatsCustDetail: the real last group sits onR2lines the old reader skipped.That naming rule predates this PR and is crude; it's worth revisiting under Refractor: consume fact channels (datasets, records, calls) from EngineFile instead of forge re-parsing #3348.
Test plan
COPY_PATTERNshape cases plus a.dclresolution test; a whole-entry schema test covering 7 shapes (edited PIC, REDEFINES, next-line PIC, sequence field,R2, sequence-only line, literal with a period)test_tool_regex_redos: the new patterns are linearpytest tests/: 11,097 passed;ground_truth_ledger.py checkcleanMerge note: #3436 also touches
ground_truth_ledger.jsonandcobol_graveyard_finder.py, in different regions. Whichever merges second needsground_truth_ledger.py updateafter merging main.🤖 Generated with Claude Code
https://claude.ai/code/session_017ZsVaAkb86P5r5JXDC2Y9g