Skip to content

Refractor: consume fact channels (datasets, records, calls) from EngineFile instead of forge re-parsing #3348

Closed

Description

@squid-protocol

Follow-up from roadmap #3249. Part of epic #3122.

Problem

The fact channels store data, compare it and report it, but the refactor pipeline does not read them. On main, cobol_refractor_controller.process_payload reads only program_ids, copy_deps and units from EngineFile. Everything else still comes from the forge's own parsers of the raw file:

IR field today's source (forge) channel already in the master DB
analysis.lineage (DD inputs/outputs) extract_lineage(work_path, ...) dataset_data → EngineFile.datasets (#3201)
generation.schemas (record layouts) forge_schemas(...) record_data → EngineFile.records (#3246, PL/I #3250)
call targets / transaction routing forge readers call_site_data / transaction_data → EngineFile.calls (#3200, #3211)

The galaxy_ir.py SCOPE comment already says the DB "carries almost everything the forge parsers derive". The refractor never switched over, so these channels today feed only the differential, the answer key, the audit JSON and the LLM brief.

The new #3249 channels (BMS map fields, DB2 DECLARE TABLE/DCLGEN, JCL PROC/SET resolution) have the same gap: they are stored but not used.

Scope

  • When engine_file is present, source lineage, schemas and the call/transaction data from EngineFile instead of the forge readers. Keep the forge path as the fallback when there is no engine DB, and record which source was used (ir_source, per field).
  • Map EngineFile.records (a flat item tree with children) to the shape forge_schemas produces. The known lossy difference is forge_flat_schema (see the differential), and any intentional divergence needs an explanation.
  • Once the Roadmap: Named System Facts — extend the fact-channel pattern to remaining forge-owned relations #3249 channels land, use them too: BMS field layouts for screen schemas, DB2 table shapes for SQL binding schemas, and resolved JCL DSNs for lineage.
  • Out of scope: reachability-based dead code stays on the forge. It is deliberately not a fact channel (docs/unreferenced_by_name_contract.md), and usage_status must not be used for dead-code masking.

Acceptance

Activity

  1. added
    priority: high
    legacy-modernization
    on Sep 23, 2026
  2. squid-protocol commented on Sep 23, 2026

    @squid-protocol
    OwnerAuthor

    Ground-truth evidence for this issue, from the new ledger (#3415, cause forge_flat_schema).

    The forge's flat cobol_schema_forge reader misses 44 record fields that the engine's record_data carries. It gets 1814/1851 on CBSA and 156/163 on zopeneditor; the engine gets 1851/1851 and 163/163. The misses fall into these shapes:

    • Level-01 elementary items, for example ACTUAL-BALANCE-DISPLAY PIC +9(10).99 in BNK1CAC/CRA/DAC/TFN/UAC, and NUMERIC-AMOUNT-DISPLAY in DBCRFUN/XFRFUN.
    • REDEFINES items, for example ACCOUNT-KY2-BYTES REDEFINES ACCOUNT-KY2, WS-POINTER-BYTES/-NUMBER REDEFINES WS-POINTER, and RDATE-NUMERIC.
    • Items under a REDEFINES group, for example CRECUST WS-CHILD-DATA-BIRTH-MONTH/-YEAR.
    • zopeneditor multiroot/sam/SAM1.cbl lines with an R2 change marker in the sequence area (cols 1–6), for example RPT-CRUNCH-*, NUM-PRE-CUSTOMERS, CUST-CNT-NAME.

    Once the refractor sources schemas from EngineFile.records, these 44 ledger entries stop reproducing. ground_truth_ledger.py check will then flag them, and update ratchets them out. That is a measurable acceptance check for this issue. The record key section is still draft (records_validated: false), so these numbers show the forge agreeing with the key's own reader, which is weaker evidence than agreement with signed-off truth.

  3. squid-protocol commented on Sep 23, 2026

    @squid-protocol
    OwnerAuthor

    CardDemo adds 341 more forge_flat_schema misses: the forge's flat reader gets 1498/1839 record fields, and the engine's record_data gets 1839/1839. Across the three corpora that's 385 ledger entries for this issue to ratchet out. (The CardDemo answer key lands alongside #3415. Its record section is a draft, like the others.)

  4. squid-protocol commented on Sep 24, 2026

    @squid-protocol
    OwnerAuthor

    #3437 fixes the forge's own record reader. cobol_schema_forge now reads whole data entries, and record fields are 3,853/3,853 exact on all three pinned corpora. That clears all 385 forge_flat_schema ledger entries, plus a latent PIC 9(n). → DECIMAL type bug. This issue's main goal is still open: have the refractor source lineage, schemas and calls from EngineFile when a DB is present. Now that both readers agree with the key, that change can be checked field by field. One thing worth revisiting at the same time is the forge's 'one table named after the last 01 group' schema model.

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

    legacy-modernizationpriority: high

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions