Skip to content

feat(#3120): refraction pipeline reads the engine master DB (opt-in IR source + explained differential) - #3207

Merged
squid-protocol merged 2 commits into
mainfrom
feat/3120-refraction-galaxy-ir
Sep 19, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feat/3120-refraction-galaxy-ir

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Part of #3120 (Phase 1 of #3122). This does not close #3120: the differential it asked for shows the DB can't yet replace the dead-code x-ray or dataset lineage.

What changes

  • gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py (new): reads a <repo>_galaxy_master.db read-only, using the latest snapshot. It exposes per-file PROGRAM-IDs (class_data), units (function_data), resolved COPY/INCLUDE edges (edge_data), subsystem hit counts, and a mainframe-language inventory. scan_to_db() runs galaxyscope --db-only and returns the DB path.
  • cobol-refractor --galaxy-db PATH | --scan: with either flag, the program list, PROGRAM-ID, COPY dependencies and paragraph inventory come from the engine.
    • Each IR dump gains metadata.ir_source, analysis.copy_dependencies and analysis.engine_units.
    • The audit report gains [5] ENGINE INVENTORY: every mainframe-family language, with non-COBOL units shown as detected, not yet migratable and hlasm as wrap-or-retire.
    • A DB that doesn't describe the target is refused before any output is written.
  • Unchanged on purpose: dead code, DD lineage, data items and CICS/DB2 flags stay on the forge tools. usage_status is carried as data and never fed to dead-code masking.
  • cobol-to-java: no code change. It inherits the new IR fields (docstring note only).

The differential (#3120's "transition risk" requirement)

tests/tools/refraction_differential.py compares the old parsers with the DB, field by field. docs/refraction_engine_differential.md attributes every delta on IBM/zopeneditor-sample and cicsdev/cics-banking-sample-application-cbsa to a cause, checked against source. Headlines:

datum outcome
PROGRAM-ID, program list agree 36/36; the DB separates programs from copybooks, including procedure copybooks
COPY edges the DB wins, but both are incomplete. The old resolver finds 0 real copybooks (same directory only; the 29 it "resolves" on CBSA are .cbl programs). The engine drops ambiguous targets (#3199)
dead paragraphs not replaceable. Old: 100% of zopeneditor's "dead" are END-IF./GOBACK.. DB: usage_status flags entry points (000-MAIN, PREMIERE SECTION), is case-sensitive, and lets X-EXIT count as a reference (#3198)
dataset lineage, DD names, CALLs stated absence in the DB (#3200, #3201). The old DAG architect has never reported an output (#3204)
CICS/DB2 forge booleans correct 36/36, forge counts wrong (#3205); the DB hit columns can't give a clean flag

Filed from this run: engine #3197–#3202, forge #3203–#3206.

Verification

  • pytest tests/cobol_mainframe: 54 passed. That includes the new test_galaxy_ir.py, which is backed by a real galaxyscope scan of a program + copybook + JCL fixture. Also run as plain pytest from an unrelated directory (CI invocation style).
  • End to end on CBSA:
    • main's controller vs this branch without a flag: IR dumps and report identical, compared order-insensitively. The dumps serialise Python sets, whose order already varies run to run.
    • With --galaxy-db: the JCL and schemas are byte-identical, and the IR differs only by the three added fields.
    • cobol-to-java generates from both DB-mode clean rooms with zero failures.
  • --scan end to end on zopeneditor: the inventory reproduces the issue's counts (cobol 70 / jcl 25 / rexx 4 / hlasm 1; pli 8 vs the issue's 7).
  • tests/tools/audit_check.py: ruff / mypy / dead-key / ast-accuracy all clear. Two new ruff findings got justified noqas: S608 on the constant column list, and S603 on the sys.executable subprocess.
  • No parsing rules changed, so no golden-master bless is owed.

🤖 Generated with Claude Code

…R source + differential)

cobol-refractor gains --galaxy-db PATH / --scan. The program list,
PROGRAM-ID, COPY edges and paragraph inventory come from the engine's
<repo>_galaxy_master.db via the new gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py.
The IR gains metadata.ir_source, analysis.copy_dependencies and
analysis.engine_units, and the audit report gains a mainframe-language
inventory.

Dead code, dataset lineage, data items and CICS/DB2 flags stay on the
forge tools. The differential shows the DB does not carry them yet:
- edge_data has COPY/INCLUDE edges only
- usage_status is a by-name test that flags entry points

tests/tools/refraction_differential.py runs the old parsers against the
DB. docs/refraction_engine_differential.md explains every delta on
zopeneditor-sample and CBSA. Engine and forge defects are filed as
#3197-#3206.

Without the flag, output is identical to main. With it, the generated
JCL and schemas are byte-identical on CBSA.

Part of #3120.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@squid-protocol squid-protocol added enhancement New feature, sensor, or structural signature legacy-modernization COBOL refractor, dead-code extraction, and JCL forging labels Sep 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

…slashes)

full-suite-matrix (windows-latest) failed 4 test_galaxy_ir tests: the
engine records OS-native file_path separators, so 'src\PAYROLL.cbl'
never matched a POSIX lookup. Normalize on load; the new test rewrites a
DB copy to backslashes so this is covered on every OS (verified it fails
without the fix).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@squid-protocol
squid-protocol merged commit e6e8d7b into main Sep 19, 2026
29 checks passed
@squid-protocol
squid-protocol deleted the feat/3120-refraction-galaxy-ir branch September 19, 2026 15:06
squid-protocol added a commit that referenced this pull request Sep 20, 2026
`full-suite-gate.yml` triggered on `pull_request: types: [labeled]` and a `v*`
tag only. That cut the queue from 23-65 minutes of identical per-label runs, but
it also means the matrix runs once, against the SHA that carried the label: a
commit pushed afterwards never goes through it. #3207's Windows fix merged that
way.

Adds `workflow_dispatch` with a `full_matrix` boolean. A plain manual run gets
the same trimmed grid a label gives (four Pythons on ubuntu, floor+ceiling on
Windows and macOS); `-f full_matrix=true` gets the untrimmed 12-way grid a tag
gets. `github.event_name` already selected the grid, so the matrix job needed
one extra condition, not a new branch.

Keeping the re-run manual is the point: the issue's alternative, also firing on
`synchronize` for an already-labelled PR, hands back the queue cost the
label-only rule bought.

Documented in CLAUDE.md as its own section, with the `gh workflow run` and
`gh run list` invocations, and the cobol-modernization skill's gotcha updated to
point at it instead of "remove and re-add a label".

Closes #3209.

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, sensor, or structural signature legacy-modernization COBOL refractor, dead-code extraction, and JCL forging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refraction pipeline: consume the engine's master DB instead of re-parsing COBOL

1 participant