Repository navigation
Fix #3998: no-scan refractor lineage reads SELECT with the engine's reader - #3999
Merged
Merged
Conversation
The refractor without --scan mapped files with cobol_dag_architect's own _SELECT regex over a literal-blanked view: `ASSIGN TO "x"` read the DD as `TO`, `SELECT OPTIONAL f` took OPTIONAL as the file, and Japanese / full-width file names never matched, so lineage differed from --scan. The SELECT half of mainframe_boundary._cobol_datasets (what --scan's dataset_data lineage uses) is split out as _select_assigns and exposed as cobol_select_assigns; extract_lineage now builds its file_map from it over a literal-keeping code view. Engine output is unchanged. Also logs the opensourcecobol4j fresh-estate defects (#3955, #3956, #3991, #3992, #3957, #3958) and this one in field_testing.json as D029-D035, lets field_testing.py place a defect found on an unkeyed estate by after_round like a review find, and regenerates the field-testing report and fact_channel_confidence.json. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01EC8FWfn3aPmsUPnRgKNVup
Contributor
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.
Fixes #3998
Problem
Without
--scan, the refractor gets a program's file lineage (analysis.lineage.inputs/outputs) fromcobol_dag_architect.extract_lineage. That function had its own SELECT regex,_SELECT, which it ran over a view with literal contents blanked. So:ASSIGN TO "./IN-FILE"readTOas the DD, because(?:TO\s+)?backtracked onto the blanked literal.SELECT OPTIONAL ftookOPTIONALas the file name.[A-Z0-9\-].With
--scan, lineage comes from the engine'sdataset_data, which gets all three right. So the same program got different lineage depending on the path. The issue's reproduction gaveinputs: ['TO'], outputs: []without--scanandinputs: ['./IN-FILE', 'CUSTDD'], outputs: ['OUTDD']with it.Approach: reuse the engine's reader
The
--scanlineage doesn't come fromcore/file_control.py. It comes frommainframe_boundary._cobol_datasets, through its_SELECT_ASSIGN+_ASSIGN_DEVICE_PREFIX→dataset_data→engine_sourcing.engine_lineage.file_control.pyfeedsfile_control_data, which records organization and keys and isn't part of lineage. So the reader to share is_cobol_datasets's SELECT half:mainframe_boundary.py: the SELECT loop of_cobol_datasetsmoves unchanged into_select_assigns(sentences)._cobol_datasetsbuilds its records from it, with the same keys in the same order. A new public helper,cobol_select_assigns(code_stream) -> {internal: dd_name}, exposes the mapping. Engine output doesn't change (it's a pure extraction).cobol_dag_architect.py:_SELECTis deleted.file_map = cobol_select_assigns(code_view(text, blank_literals=False)).code_viewgets ablank_literalsflag so the ASSIGN literal survives. Comment and debug lines, the sequence area and cols 73+ are still dropped, and there's a test that a commented-out SELECT is still ignored. The OPEN walk, dead-paragraph masking and dynamic-CALL detection are unchanged and still run on the literal-blanked view.Why reuse the reader instead of fixing the regex: one reader can't drift.
OPTIONAL, literal targets, the COBOL word class (national, full-width digits and hyphens from #3955/#3991/#3995) and the device-prefix rules all come from the reader--scanalready uses. It's a pure function over a string, so the no-scan path doesn't need a scan or a DB.Behaviour changes on the no-scan path. All of them are parity with
--scan:UT-S-/UR-S-are still stripped.DA-S-,UT-,UR-,DA-are now stripped as well, the way the engine does it.Tests
tests/cobol_mainframe/test_noscan_select_lineage.py:cobol_select_assignsfor each form: ASSIGN TO literal (both quote styles), ASSIGN literal with no TO, plain, ASSIGN with no TO, OPTIONAL, a Japanese name, a full-width-digit name,UT-S-andUR-S-, and a multi-line SELECT. Also checks that TO/OPTIONAL are never read as names and that the first SELECT of a name wins.extract_lineageon a program that has every form, across INPUT/OUTPUT/I-O/EXTEND, and a test that a commented SELECT is still ignored.cobol-refractoron the same estate without and then with--scan, and asserts thatanalysis.lineageis identical and correct.cobol_dag_architect.pyreverted to origin/main, the lineage test and the parity test fail (they showTO). The unit tests need the new helper.tests/cobol_mainframe+tests/tools_recorders: 1359 passed, 32 skipped. Thetests/core_enginefiles that importmainframe_boundary: 325 passed.field_testing.py check: valid, report up to date.ruff_audit --ci,mypy_audit --ci,dead_key_audit --ci: no new findings.tool_regex_redos --ci: 0 offenders (no new regex).ruff formatwas run on the touched files only.Corpus output
java_target_matrix.py --same-as origin/main --only defaulton CardDemo, CBSA, GenApp, zopeneditor, zECS and DSF:--scanpath: the diff is only the field-testing status changes described below, in Javadoc comments, skeleton / port-ticket JSON and markdown, plus those files'sha256/bytes/tokensmetadata. I checked that every changed.javaline is a comment line: 48 files in CardDemo, 58 in CBSA, 57 in GenApp, 3 in zopeneditor, 9 in zECS, 419 in DSF. No code line changes, so CI's compile will rebuild but has nothing new to compile.extract_lineageover all 123 lineage-bearing COBOL programs in those six corpora is identical to main.ground_truth_ledger.py check: ledger clean.crucible_check.py: full_precision PASS, zero_dependency PASS (the engine change is a pure extraction).TOor an empty set with the real target (for example./TEST-FILE,./INPUT.TXT,./テスト_ファイル). No program loses a non-TOvalue.Field-testing log: opensourcecobol4j fresh-estate defects (D029-D035)
tests/cobol_mainframe/field_testing.jsonnow logs the defects the opensourcecobol4j fresh estate (#3806) exposed, plus this one. opensourcecobol4j isn't added toestates: it's GPL, unkeyed and kept outside the repo, and a public estate has to be a keyed corpus. So each entry has"estate": null, "after_round": 6.fields: [], so each has the closest honest field and severityattribute, and its summary says why. Generated REST controller does not compile when a file is ASSIGNed to a literal path ("./TEST-FILE" -> @RequestBody ./testFileDTO) #3957 getsfile control(the ASSIGN clause whose literal became a Java identifier). Target config: data.code_page silently accepts non-EBCDIC pages (shift_jis -> katakana 'sign characters'); a PC-COBOL (ASCII / Shift_JIS) estate cannot be declared #3958 getsrecord fields(the zoned-decimal fields its sign characters decode).found_by: "review"(found while fixing Generated REST controller references an undefined <File>DTO for a batch program without JCL: jp-compat still does not compile after #3957 #3992, not by the scan). It has nofixed_bybecause this PR's number didn't exist when it was written; it cites issue Refractor without --scan: cobol_dag_architect reads ASSIGN TO "x" as DD 'TO', misses SELECT OPTIONAL and non-ASCII file names (lineage differs from --scan) #3998.tests/tools/field_testing.py: before, only afound_by: "review"defect could name no estate; a null estate with any otherfound_byfailed validation as an unknown estate. A defect withestate: nullis now placed byafter_roundthe same way (off_ledger()), and its round cell readsunkeyed estate, after 6. There's a new test intest_field_testing.py.This resets the clean fresh-round counts for every field an engine defect names. Only engine defects reset them; forge defects only add to the forge column.
fact_channel_confidence.jsonanddocs/language_status/cics_field_testing.mdwere regenerated. Changed rows:record fieldslosingfield-testedis why the--scan-path Java comments and skeleton JSON sayopeninstead offield-testedfor record layouts.🤖 Generated with Claude Code