Skip to content

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

Closed

Description

@squid-protocol

Found while fixing #3992 (PR #3994), and left out of that PR. It affects the refractor without --scan. There, cobol_dag_architect supplies the program's file lineage (analysis.lineage.inputs/outputs) from its own SELECT reader, not the engine's.

Defect

_SELECT in gitgalaxy/tools/cobol_to_cobol/cobol_dag_architect.py:36:

_SELECT = re.compile(rf"{_V}SELECT\s+([A-Z0-9\-]+)\s+ASSIGN\s+(?:TO\s+)?([A-Z0-9@#$\-]+)")

The engine's own reader (core/file_control.py, used with --scan) and, since #3994, analyze_cobol_intent's files_requested get all three right. So the same program gets different lineage depending on whether --scan is passed.

Minimal reproduction (origin/main 71d33c5)

mkdir -p estate
cat > estate/ASGTO.cbl <<'COB'
       IDENTIFICATION DIVISION.
       PROGRAM-ID. ASGTO.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT IN-FILE ASSIGN TO "./IN-FILE"
                  ORGANIZATION LINE SEQUENTIAL.
           SELECT OPTIONAL OUT-FILE ASSIGN TO OUTDD.
           SELECT 顧客ファイル ASSIGN TO CUSTDD.
       DATA DIVISION.
       FILE SECTION.
       FD IN-FILE.
       01 IN-REC PIC X(10).
       FD OUT-FILE.
       01 OUT-REC PIC X(10).
       FD 顧客ファイル.
       01 顧客レコード PIC X(10).
       PROCEDURE DIVISION.
           OPEN INPUT IN-FILE 顧客ファイル OUTPUT OUT-FILE.
           READ IN-FILE.
           WRITE OUT-REC FROM IN-REC.
           CLOSE IN-FILE OUT-FILE 顧客ファイル.
           STOP RUN.
COB
python -c "import sys; sys.argv=['r','estate']; from gitgalaxy.cobol_refractor_controller import main; main()"
python -c "import json,glob; print(json.load(open(glob.glob('estate_gitgalaxy_clean_*/04_ir_state_dumps/*_ir.json')[0]))['analysis']['lineage'])"

Actual (no --scan): inputs: ['TO'], outputs: []
With --scan: inputs: ['./IN-FILE', 'CUSTDD'], outputs: ['OUTDD'] (expected)

Expected

Both paths give the same lineage. The cleanest fix is probably for the no-scan path to use the engine's SELECT reader (core/file_control.py) rather than keep a second regex. Otherwise _SELECT has to read the ASSIGN target before literals are blanked, accept OPTIONAL, never take TO as a name, and use the COBOL word class (national, Japanese, full-width). A test should check that --scan and no-scan lineage agree on these SELECT forms.

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Sep 29, 2026
    716ac4f
  2. added
    scope:frontierMapped, not yet built: eras/commands/regions the burned estates don't use (Gap Atlas)
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:frontierMapped, not yet built: eras/commands/regions the burned estates don't use (Gap Atlas)

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions