From 9f8fcea23d3b85dcd5e24fa15bc8c2a221463c43 Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Tue, 24 Nov 2026 15:16:23 -0500 Subject: [PATCH 1/2] Forged JCL jobs fix an IF result at first evaluation, as IBM does (Part of #8886) The job_flow fact carries each step's enclosing IF constructs (if_chain); the forge emits them and JclConditions.bypassed evaluates each construct once (JCL Reference, IF/THEN/ELSE Example 9). The fixture comparison goes from 2 known differences to 0 (42 of 42 IBM-written answers agree). Co-Authored-By: Claude Sonnet 5.5 --- gitgalaxy/core/fact_channels.py | 7 +- gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py | 8 +- .../cobol_to_java_batch_forge.py | 83 +++++++++++++++++-- .../test_jcl_forged_job_carddemo.py | 7 +- .../test_jcl_forged_job_fixture.py | 76 ++++++++++++----- tests/tools/docs_read_by_tests.txt | 1 + 6 files changed, 148 insertions(+), 34 deletions(-) diff --git a/gitgalaxy/core/fact_channels.py b/gitgalaxy/core/fact_channels.py index 1145f75751..547697b7a8 100644 --- a/gitgalaxy/core/fact_channels.py +++ b/gitgalaxy/core/fact_channels.py @@ -613,6 +613,7 @@ def _file_control_select(cursor, has_table, has_column): line_number INTEGER, disp_normal TEXT, sysout TEXT, + if_chain TEXT, FOREIGN KEY(file_id) REFERENCES file_data(id) ON DELETE CASCADE ) """ @@ -828,6 +829,7 @@ def col(probe, *names): col("sysout", "sysout"), col("restart", "restart", "restart_checkid", "rd", "parm_overrides", "cond_overrides"), col("output_params", "output_params", "output_refs"), + col("if_chain", "if_chain"), ) ) return ( @@ -2221,6 +2223,7 @@ def _transaction_select(_cursor, _has_table, _has_column): ("sysout TEXT",), ("restart TEXT", "restart_checkid TEXT", "rd TEXT", "parm_overrides TEXT", "cond_overrides TEXT"), ("output_params TEXT", "output_refs TEXT"), + ("if_chain TEXT",), # #8886 ), indexes=( "CREATE INDEX IF NOT EXISTS idx_job_flow_file_id ON job_flow_data(file_id);", @@ -2259,6 +2262,7 @@ def _transaction_select(_cursor, _has_table, _has_column): "cond_overrides", "output_params", "output_refs", + "if_chain", ), to_row=lambda j: ( j.get("kind"), @@ -2291,6 +2295,7 @@ def _transaction_select(_cursor, _has_table, _has_column): json.dumps(j["cond_overrides"]) if j.get("cond_overrides") else None, json.dumps(j["output_params"]) if j.get("output_params") else None, json.dumps(j["output_refs"]) if j.get("output_refs") else None, + json.dumps(j["if_chain"]) if j.get("if_chain") else None, # #8886 ), restore_select=_job_flow_select, to_payload=lambda r: { @@ -2316,7 +2321,7 @@ def _transaction_select(_cursor, _has_table, _has_column): }, **{ k: json.loads(r[k]) - for k in ("parm_overrides", "cond_overrides", "output_params", "output_refs") + for k in ("parm_overrides", "cond_overrides", "output_params", "output_refs", "if_chain") if r[k] }, **{k: r[k] for k in ("restart", "restart_checkid", "rd") if r[k]}, diff --git a/gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py b/gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py index 1ff563e9de..2dd8bc012e 100644 --- a/gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py +++ b/gitgalaxy/tools/cobol_to_cobol/galaxy_ir.py @@ -792,6 +792,8 @@ class EngineJobFlow: instream: str | None = None # #4268: an INSTREAM row's SYSIN / SYMNAMES / SORTCNTL / DFSPARM body, as written lrecl: int | None = None # #4268: the record length a DD row states (DCB / LRECL=), None when not stated recfm: str | None = None # #4268: the record format a DD row states (FB / VB / ...), None when not stated + # #8886: a STEP row's enclosing IF constructs, outermost first: [line of the IF, its condition, in its ELSE clause] + if_chain: list | None = None @dataclass @@ -4522,6 +4524,7 @@ def job_steps(self) -> list: "line": r.line, "parm": r.parm, # #3624 "runner_programs": self.runner_runs(r, f.file_path), # #3710 + **({"if_chain": r.if_chain} if r.if_chain else {}), # #8886: presence-keyed } if r.proc: where, inner = self._proc_steps(f, r.proc) @@ -4534,6 +4537,7 @@ def job_steps(self) -> list: "if_cond": s_.if_cond, "parm": s_.parm, "runner_programs": self.runner_runs(s_, where or f.file_path), + **({"if_chain": s_.if_chain} if s_.if_chain else {}), } for s_ in inner ] @@ -6994,9 +6998,10 @@ def load_galaxy_ir(db_path: Path, repo_name: str | None = None) -> GalaxyIR: parm_col = "parm" if _has_column(cur, "job_flow_data", "parm") else "NULL" # #3624 instream_col = "instream" if _has_column(cur, "job_flow_data", "instream") else "NULL" # #4268 dcb_cols = "lrecl, recfm" if _has_column(cur, "job_flow_data", "lrecl") else "NULL, NULL" # #4268 + chain_col = "if_chain" if _has_column(cur, "job_flow_data", "if_chain") else "NULL" # #8886 for row in cur.execute( "SELECT file_id, kind, job_name, step_ordinal, step_name, program, proc_name, cond, if_cond, in_proc, " # noqa: S608 -- normal_col / runner_cols are literals - f"dd_name, dsn, disp, generation, line_number, {normal_col}, {runner_cols}, {parm_col}, {instream_col}, {dcb_cols} FROM job_flow_data " + f"dd_name, dsn, disp, generation, line_number, {normal_col}, {runner_cols}, {parm_col}, {instream_col}, {dcb_cols}, {chain_col} FROM job_flow_data " "WHERE repo_name = ? AND commit_hash = ? ORDER BY file_id, line_number, id", (repo_name, commit_hash), ): @@ -7025,6 +7030,7 @@ def load_galaxy_ir(db_path: Path, repo_name: str | None = None) -> GalaxyIR: instream=row[20], lrecl=int(row[21]) if row[21] else None, recfm=row[22], + if_chain=json.loads(row[23]) if row[23] else None, ) ) # #3455: file definitions. A pre-#3455 database has neither table. diff --git a/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py b/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py index 427346521d..faeb1a8c5b 100644 --- a/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py +++ b/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py @@ -88,6 +88,9 @@ class Step: sort_service: str = "" # #4268: the class of its det translation (a service the step runs), "" until ported sort_java: str = "" # that service's source concat: int = 0 # a SORT whose SORTIN is a concatenation: its datasets (the k-th, k > 1, is the DD `SORTIN`) + if_chain: list[list] = field( + default_factory=list + ) # #8886: [IF line key, condition, in its ELSE clause], outermost first not_ported: str = "" # why the lowered program is not run (the det translation failed or holds holes) lowered_note: str = "" # where its record length came from # #8886: the lowered SORT builds fewer bytes (OUTREC) than its SORTOUT's fixed LRECL: IBM ends it, RC=16 @@ -205,6 +208,7 @@ def _plan(self, j: dict, dds: dict) -> Job: dds.get((j["file"], s["ordinal"], ps["step"] if inner is not None else None), []), self.programs.get(prog or "")) # fmt: skip st.parm = ps.get("parm") + st.if_chain = self._if_chain(s, ps, inner is not None) if prog in COPY: st.refused = self._iebgener_refusal(j["file"], s["ordinal"], st) elif prog in IDCAMS: @@ -619,6 +623,11 @@ def _job_source(self, j: Job) -> str: bean = j.cls[0].lower() + j.cls[1 : -len("Config")] # unique, as the class is java += [" @Bean", f" public Job {bean}({', '.join(params)}) {{", f" return new JobBuilder({_jstr(j.spring)}, jobRepository)", " .listener(steps.abends())"] # fmt: skip + for st in j.steps: + if st.if_chain: # #8886: the IF constructs of the step, by job and step (JclConditions.bypassed) + rows = ", ".join("{" + ", ".join(_jstr(c if isinstance(c, str) else str(c).lower()) for c in r) + "}" + for r in st.if_chain) # fmt: skip + java.append(f" steps.ifChain({_jstr(j.spring)}, {_jstr(st.jcl)}, new String[][] {{{rows}}});") for i, st in enumerate(j.steps): verb = ".start" if i == 0 else ".next" java.append(f" {verb}(new StepBuilder({_jstr(st.name)}, jobRepository)") @@ -697,6 +706,18 @@ def _step_todo(self, st: Step) -> str | None: return f"TODO: {st.jcl} runs the utility {p} through {st.runner} ({st.via}) -- a utility step to port" return f"TODO: {st.jcl} runs the utility {p} (its control statements are in SYSIN) -- a utility step to port" + @staticmethod + def _if_chain(call: dict, ps: dict, in_proc: bool) -> list[list]: + """#8886: the IF constructs a step sits in, outermost first. IBM fixes a construct's result when it is first + evaluated (Example 9), so each carries its IF statement's line as the key; a procedure's own IF is keyed by the + call (each call evaluates its own).""" + chain = [[str(line), expr, bool(in_else)] for line, expr, in_else in call.get("if_chain") or []] + if in_proc: + chain += [ + [f"{call['step']}.{line}", expr, bool(in_else)] for line, expr, in_else in ps.get("if_chain") or [] + ] + return chain + def _tasklet(self, j: Job, st: Step) -> str: consts = f"DDS_{self._const(st.name)}" head = f"{_jstr(st.name)}, {_jstr(st.jcl)}, {_jstr(j.cond)}, {_jstr(st.cond)}, {_jstr(st.if_cond)}" @@ -1313,17 +1334,58 @@ def audit_line(self) -> str: */ public static boolean startsAfterAbend(String jobCond, String cond, String ifCond, Map rcs, Map abends) { - String upper = cond == null ? "" : cond.toUpperCase(Locale.ROOT); boolean inIf = ifCond != null && !ifCond.isBlank(); if (inIf && (!NAMES_ABEND.matcher(ifCond.toUpperCase(Locale.ROOT)).find() || !holds(ifCond, rcs, abends))) { return false; } + return liftsAbendDefault(jobCond, cond, inIf, rcs); + } + + /** + * Whether a step the abend default would bypass starts: EVEN / ONLY or an IF lifts it, and the step's JOB COND + * and COND tests still decide. + */ + private static boolean liftsAbendDefault(String jobCond, String cond, boolean inIf, Map rcs) { + String upper = cond == null ? "" : cond.toUpperCase(Locale.ROOT); if (!(EVEN.matcher(upper).find() || ONLY.matcher(upper).find()) && !inIf) { return false; } return !(jobCond != null && testsHold(jobCond.toUpperCase(Locale.ROOT), rcs)) && !testsHold(upper, rcs); } + /** + * Whether a step is bypassed. `chain` (null: the flat `ifCond`) holds the IF constructs the step sits in, outermost + * first, {line of the IF, its condition, "true" in its ELSE clause}: IBM fixes a construct's result when it is first + * evaluated and does not re-evaluate it for its later steps (JCL Reference, IF/THEN/ELSE Example 9), so `frozen` + * (IF line -> result, kept per job) holds the results. jcl_flow's `_starts` is the engine's twin. + */ + public static boolean bypassed(String jobCond, String cond, String ifCond, String[][] chain, + Map rcs, Map abends, Map frozen) { + if (chain == null || chain.length == 0) { + return !abends.isEmpty() ? !startsAfterAbend(jobCond, cond, ifCond, rcs, abends) + : bypass(jobCond, rcs) || bypass(cond, rcs) || !holds(ifCond, rcs); + } + StringBuilder names = new StringBuilder(); + for (String[] c : chain) { + names.append(c[1]).append(' '); + } + for (String[] c : chain) { + Boolean done = frozen.get(c[0]); + if (done == null) { + if (!abends.isEmpty() && !NAMES_ABEND.matcher(names.toString().toUpperCase(Locale.ROOT)).find()) { + return true; + } + done = holds(c[1], rcs, abends); + frozen.put(c[0], done); + } + if (done == Boolean.parseBoolean(c[2])) { + return true; + } + } + return abends.isEmpty() ? bypass(jobCond, rcs) || bypass(cond, rcs) + : !liftsAbendDefault(jobCond, cond, true, rcs); + } + static boolean compare(int left, String op, int right) { return switch (op) { case "GT", ">" -> left > right; @@ -1500,6 +1562,7 @@ def audit_line(self) -> str: private static final Logger LOG = LoggerFactory.getLogger(JclSteps.class); private final DatasetResolver datasets; private final boolean skipUnimplemented; + private final Map ifChains = new ConcurrentHashMap<>(); //{IDCAMS_IMPORT} private final Map> catalogs = new ConcurrentHashMap<>(); //{/IDCAMS_IMPORT} @@ -1510,6 +1573,11 @@ def audit_line(self) -> str: this.skipUnimplemented = skipUnimplemented; } + /** The IF constructs a step sits in, outermost first: {line of the IF, its condition, "true" in its ELSE clause}. */ + public void ifChain(String job, String jcl, String[][] chain) { + ifChains.put(job + "/" + jcl, chain); + } + /** A step running a program of the estate: its service's runBatch, whose result is RETURN-CODE. */ public Tasklet program(String name, String jcl, String jobCond, String cond, String ifCond, IntSupplier run) { return guarded(jcl, jobCond, cond, ifCond, run); @@ -1727,13 +1795,12 @@ def audit_line(self) -> str: Map rcs = new LinkedHashMap<>((Map) ctx.get("jcl.rc", Map.class, Map.of())); Map abends = new LinkedHashMap<>( (Map) ctx.get("jcl.abend", Map.class, Map.of())); - if (!abends.isEmpty()) { // an earlier step abended: IBM bypasses this one unless EVEN / ONLY / IF ABEND says so - if (!JclConditions.startsAfterAbend(jobCond, cond, ifCond, rcs, abends)) { - contribution.setExitStatus(new ExitStatus("BYPASSED")); - return RepeatStatus.FINISHED; - } - } else if (JclConditions.bypass(jobCond, rcs) || JclConditions.bypass(cond, rcs) - || !JclConditions.holds(ifCond, rcs)) { + Map frozen = new LinkedHashMap<>( + (Map) ctx.get("jcl.if", Map.class, Map.of())); + String[][] chain = ifChains.get(chunk.getStepContext().getJobName() + "/" + jcl); + boolean bypassed = JclConditions.bypassed(jobCond, cond, ifCond, chain, rcs, abends, frozen); + ctx.put("jcl.if", frozen); // an IF construct's result stays fixed for the rest of the job (IBM Example 9) + if (bypassed) { // COND / IF; after an abend IBM bypasses unless EVEN / ONLY / IF ABEND says so contribution.setExitStatus(new ExitStatus("BYPASSED")); return RepeatStatus.FINISHED; } diff --git a/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py b/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py index 79d7d4e243..0d416334ad 100644 --- a/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py +++ b/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py @@ -180,10 +180,9 @@ def _line(key: str, forged: list[dict], given: dict) -> str: def test_the_forge_guard_is_the_one_the_driver_mirrors(): """The driver restates `JclSteps.guarded`'s decision; pin that text so a change to it fails here, not silently.""" guarded = forge_mod._RUNTIME["JclSteps"] - assert ( - "if (JclConditions.bypass(jobCond, rcs) || JclConditions.bypass(cond, rcs)\n" - " || !JclConditions.holds(ifCond, rcs)) {" in guarded - ) + conds = forge_mod._RUNTIME["JclConditions"] + assert "JclConditions.bypassed(" in guarded + assert "bypass(jobCond, rcs) || bypass(cond, rcs) || !holds(ifCond, rcs)" in conds assert "rcs.put(jcl, rc);" in guarded and 'new ExitStatus("BYPASSED")' in guarded diff --git a/tests/cobol_mainframe/test_jcl_forged_job_fixture.py b/tests/cobol_mainframe/test_jcl_forged_job_fixture.py index a2d199ef59..d1cf152b38 100644 --- a/tests/cobol_mainframe/test_jcl_forged_job_fixture.py +++ b/tests/cobol_mainframe/test_jcl_forged_job_fixture.py @@ -9,13 +9,16 @@ writes it), read back, and decided by the forge's own `JclConditions` Java in the order `JclSteps.guarded` uses (the driver and helpers are slice 1's). A step that abends records its completion code and the job goes on as IBM's flush rules say (`JclConditions.startsAfterAbend`: EVEN / ONLY / IF ABEND), so the eighteen abend-flush answers #8821 listed now agree (#8886). -Two differ: an IF result IBM fixes when first evaluated (Example 9). `KNOWN_DIFFERENCES` names each with its reason; the -test fails on a new difference AND on a listed one that no longer reproduces, so the list is the measurement, not an excuse. +An IF result IBM fixes when it is first evaluated (Example 9) is kept per job from the `if_chain` the job_steps fact carries +(`JclConditions.bypassed`, the one decision the generated tasklet and this driver share): all 42 answers agree. If a +difference reappears, `KNOWN_DIFFERENCES` names each with its reason; the test fails on a new difference AND on a listed one +that no longer reproduces, so the list is the measurement, not an excuse. """ from __future__ import annotations import json +import re import shutil import subprocess import sys @@ -33,7 +36,7 @@ SETS = [("FLOW.jcl", "scenarios.json"), ("IFFLOW.jcl", "ifflow_scenarios.json")] # Slice 1's driver splits a step cell on `|`, which an IF expression uses (OR), and has no abend continuation: this -# one splits on U+001F and restates `JclSteps.guarded` with the abends map (the no-abend path is slice 1's decision). +# one splits on U+001F and asks `JclConditions.bypassed`, the decision `JclSteps.guarded` makes. SEP = "\x1f" DRIVER = """package {pkg}; @@ -42,7 +45,8 @@ import java.util.LinkedHashMap; import java.util.Map; -/** Line: key TAB step US jobCond US cond US ifCond US given ... ; given is rc:N, abend:CODE or - (never started). */ +/** Line: key TAB step US jobCond US cond US ifCond US given US chain ... ; given is rc:N, abend:CODE or - (never started); + * chain is the IF constructs, rows split by RS and fields by GS (line, condition, "true" in its ELSE clause). */ public final class Drive { public static void main(String[] a) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in, "UTF-8")); @@ -51,16 +55,21 @@ String[] f = line.split("\\t"); Map rcs = new LinkedHashMap<>(); Map abends = new LinkedHashMap<>(); + Map frozen = new LinkedHashMap<>(); StringBuilder out = new StringBuilder(f[0]); for (int i = 1; i < f.length; i++) { String[] p = f[i].split("\u001f", -1); String name = p[0], jobCond = nul(p[1]), cond = nul(p[2]), ifCond = nul(p[3]), given = p[4]; + String[][] chain = null; + if (!p[5].isEmpty()) { + String[] rows = p[5].split("\u001e", -1); + chain = new String[rows.length][]; + for (int r = 0; r < rows.length; r++) { + chain[r] = rows[r].split("\u001d", -1); + } + } String action; - boolean bypassed = !abends.isEmpty() - ? !JclConditions.startsAfterAbend(jobCond, cond, ifCond, rcs, abends) - : JclConditions.bypass(jobCond, rcs) || JclConditions.bypass(cond, rcs) - || !JclConditions.holds(ifCond, rcs); - if (bypassed) { + if (JclConditions.bypassed(jobCond, cond, ifCond, chain, rcs, abends, frozen)) { action = "bypass"; } else if (given.equals("-")) { action = "run-without-answer"; @@ -86,14 +95,7 @@ needs_javac = pytest.mark.skipif(shutil.which("javac") is None or shutil.which("java") is None, reason="no JDK") -FROZEN = ( - "an IF result is fixed when first evaluated (IBM Example 9: `IF NOT ABEND` stays true when a later step abends); the forge's " - "`holds` re-reads the flag at each step, as the job_steps fact carries no IF chain (`jcl_flow.if_chain` does)" -) -KNOWN_DIFFERENCES = { - ("abn-a2-s0c4", "A3"): FROZEN, # IBM runs A3 (its IF was true before A2 abended); the forge bypasses it - ("abn-a2-s0c4", "A4"): FROZEN, # IBM bypasses A4 (the ELSE of that IF); the forge runs it -} +KNOWN_DIFFERENCES: dict[tuple[str, str], str] = {} def _jobs(member: str) -> dict[str, tuple[dict, list[dict]]]: @@ -115,6 +117,8 @@ def _jobs(member: str) -> dict[str, tuple[dict, list[dict]]]: continue e = {"ordinal": r["step_ordinal"], "step": r["step_name"]} e.update({k: r[k] for k in ("program", "proc", "cond", "if_cond", "line")}) + if r.get("if_chain"): + e["if_chain"] = r["if_chain"] if r["proc"]: e["expands_to"] = [ {"step": s["step_name"], "program": s["program"], "cond": s["cond"], "if_cond": s["if_cond"]} @@ -142,7 +146,18 @@ def _forged() -> dict[str, list[dict]]: forge = slice1.BatchForge( skeletons, {"sections": {"job_steps": {"facts": facts}}}, "com.gitgalaxy", slice1.load_target(None) ) - out[name] = slice1._forged_steps(forge) + steps_out = slice1._forged_steps(forge) + (src,) = forge.sources().values() + (cfg,) = (t for k, t in src.items() if k.endswith("JobConfig")) + chains = { # steps.ifChain(job, step, new String[][] {{line, condition, inElse}, ...}); read back as generated + json.loads(m["step"]): [json.loads("[" + r + "]") for r in re.findall(r"\{(\"[^{}]*)\}", m["rows"])] + for m in re.finditer( + r'steps\.ifChain\("[^"]*", (?P"[^"]*"), new String\[\]\[\] \{(?P.*)\}\);', cfg + ) + } + for st in steps_out: + st["if_chain"] = chains.get(st["name"], []) + out[name] = steps_out return out @@ -178,7 +193,8 @@ def _line(key: str, forged: list[dict], given: dict) -> str: for s in forged: g = given.get(s["name"]) gv = "-" if g is None else f"abend:{g['abend']}" if "abend" in g else f"rc:{g['rc']}" - cells.append(SEP.join([s["name"], s["job_cond"] or "", s["cond"] or "", s["if_cond"] or "", gv])) + chain = "\x1e".join("\x1d".join(c) for c in s["if_chain"]) + cells.append(SEP.join([s["name"], s["job_cond"] or "", s["cond"] or "", s["if_cond"] or "", gv, chain])) return "\t".join([key, *cells]) @@ -201,4 +217,24 @@ def test_the_forged_job_differs_from_the_ibm_written_answers_exactly_where_the_l assert {v for v in got.values()} <= {("run-without-answer", "bypass"), ("bypass", "run")} assert set(got) == set(KNOWN_DIFFERENCES), sorted(set(got) ^ set(KNOWN_DIFFERENCES)) scenarios = {i for i, _ in got} - assert (len(_scenarios()), len(scenarios), len(got)) == (42, 1, 2) + assert (len(_scenarios()), len(scenarios), len(got)) == (42, 0, 0) + + +def test_job_steps_carry_the_if_constructs_a_step_sits_in(tmp_path): + """#8886: IBM fixes an IF result when first evaluated, so a step names the IF statements around it (line, condition, + in ELSE); presence-keyed: a step outside any IF has no `if_chain`. It survives the master DB.""" + sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools")) + from scan_server import scan_to_db + + from gitgalaxy.tools.cobol_to_cobol.galaxy_ir import load_galaxy_ir + + repo = tmp_path / "batch" + (repo / "jcl").mkdir(parents=True) + (repo / "jcl/ABN.jcl").write_text( + "//ABN JOB CLASS=A\n//A1 EXEC PGM=PGMA\n// IF NOT ABEND THEN\n//A2 EXEC PGM=PGMB\n" + "// ELSE\n//A3 EXEC PGM=PGMC\n// ENDIF\n//A4 EXEC PGM=PGMD\n", + encoding="utf-8", + ) + (job,) = load_galaxy_ir(scan_to_db(repo, tmp_path / "scan")).job_steps() + chains = {s["step"]: s.get("if_chain") for s in job["steps"]} + assert chains == {"A1": None, "A2": [[3, "NOT ABEND", False]], "A3": [[3, "NOT ABEND", True]], "A4": None} diff --git a/tests/tools/docs_read_by_tests.txt b/tests/tools/docs_read_by_tests.txt index 592ff978ec..8882616505 100644 --- a/tests/tools/docs_read_by_tests.txt +++ b/tests/tools/docs_read_by_tests.txt @@ -588,6 +588,7 @@ loop.md tests/cobol_mainframe,tests/tools/porting_loop.py mainframe-evidence-policy.md tests/tools/infeasible_outcomes.py,tests/tools/ladder_refresh.py manual_verification.json tests/tools/tri_comparison_chart.py matrix.svg tests/tools/language_sheets.py,tests/tools/test_language_sheets.py +matrix_legacy.svg tests/tools/language_sheets.py,tests/tools/test_language_sheets.py matrix_sparse.svg tests/tools/language_sheets.py,tests/tools/test_language_sheets.py migration_worklist.md gitgalaxy,tests/cobol_mainframe,tests/tools/publish_examples.py mutation.md tests/tools/mutation.py,tests/tools/mutation_crucible.py From 90fd7973545d1591d939dfce66e7f6323b580f6d Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Tue, 24 Nov 2026 16:11:22 -0500 Subject: [PATCH 2/2] Forged JclSteps imports ConcurrentHashMap outside the IDCAMS block; cobolrt API manifest regenerated (Part of #8886) ifChains uses ConcurrentHashMap on every job, but the import sat inside the IDCAMS-only block, so a job with no IDCAMS step failed to compile (compile zopeneditor-sample). JclConditions.bypassed is emitter-used, so the manifest promotes it. Co-Authored-By: Claude Sonnet 5.5 --- docs/language_status/cobolrt_api.json | 12 +++++++----- .../tools/cobol_to_java/cobol_to_java_batch_forge.py | 2 +- .../cobol_mainframe/test_jcl_forged_job_carddemo.py | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/language_status/cobolrt_api.json b/docs/language_status/cobolrt_api.json index 21cd63abbe..ee78dd6821 100644 --- a/docs/language_status/cobolrt_api.json +++ b/docs/language_status/cobolrt_api.json @@ -1,7 +1,7 @@ { "schema": "cobolrt-api/1", "about": ["The cobolrt public API (#4718). Written by tests/tools/cobolrt_api.py generate: edit only a `visibility`, to public or internal; docs/cobolrt_api_contract.md says what they promise.", "`evidence` records who called the item when it was last refreshed, and is never checked: det-port, model-port (committed ports), frozen-overlay (a frozen runtime copy's call to a live class), generated (translator output), emitter (a translator string), emitter-dynamic (a name a computed emission may take), runtime, harness; empty: no caller was found."], - "summary": {"types": 143, "types_public": 112, "members": 1319, "members_public": 863, "members_internal": 456}, + "summary": {"types": 143, "types_public": 112, "members": 1321, "members_public": 864, "members_internal": 457}, "types": [ {"id": "batch.CobolAbend", "kind": "class", "source": "gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py", "variants": ["forge-batch-jobs", "forge-batch-files"], "supers": ["RuntimeException"], "visibility": "public", "evidence": ["det-port", "emitter", "model-port", "signature", "harness", "runtime"], "members": [ {"id": "batch.CobolAbend.(String,String)", "kind": "constructor", "visibility": "internal", "evidence": []}, @@ -56,10 +56,11 @@ {"id": "batch.Dd.status()", "kind": "method", "returns": "String", "visibility": "public", "evidence": ["emitter-dynamic", "harness", "runtime"]} ]}, {"id": "batch.JclConditions", "kind": "class", "source": "gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py", "variants": ["forge-batch-jobs", "forge-batch-files"], "supers": [], "visibility": "public", "evidence": ["emitter", "harness", "runtime"], "members": [ - {"id": "batch.JclConditions.bypass(String,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["emitter", "harness", "runtime"]}, - {"id": "batch.JclConditions.holds(String,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["emitter", "harness", "runtime"]}, - {"id": "batch.JclConditions.holds(String,Map,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["emitter", "harness", "runtime"]}, - {"id": "batch.JclConditions.startsAfterAbend(String,String,String,Map,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["emitter", "harness", "runtime"]} + {"id": "batch.JclConditions.bypass(String,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["harness", "runtime"]}, + {"id": "batch.JclConditions.bypassed(String,String,String,String[][],Map,Map,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["emitter", "harness", "runtime"]}, + {"id": "batch.JclConditions.holds(String,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["harness", "runtime"]}, + {"id": "batch.JclConditions.holds(String,Map,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["harness", "runtime"]}, + {"id": "batch.JclConditions.startsAfterAbend(String,String,String,Map,Map)", "kind": "method", "static": true, "returns": "boolean", "visibility": "public", "evidence": ["runtime"]} ]}, {"id": "batch.JclJobLauncher", "kind": "class", "source": "gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py", "variants": ["forge-batch-jobs"], "supers": [], "visibility": "public", "evidence": ["harness"], "members": [ {"id": "batch.JclJobLauncher.(JobLauncher,List)", "kind": "constructor", "visibility": "internal", "evidence": []}, @@ -75,6 +76,7 @@ {"id": "batch.JclSteps.idcams(String,String,String,String,String,List,String)", "kind": "method", "returns": "Tasklet", "visibility": "internal", "evidence": ["harness"]}, {"id": "batch.JclSteps.idcams(String,String,String,String,String,List,String,String)", "kind": "method", "returns": "Tasklet", "visibility": "internal", "evidence": ["harness", "runtime"]}, {"id": "batch.JclSteps.iefbr14(String,String,String,String,String,List)", "kind": "method", "returns": "Tasklet", "visibility": "public", "evidence": ["harness"]}, + {"id": "batch.JclSteps.ifChain(String,String,String[][])", "kind": "method", "returns": "void", "visibility": "internal", "evidence": []}, {"id": "batch.JclSteps.program(String,String,String,String,String,IntSupplier)", "kind": "method", "returns": "Tasklet", "visibility": "public", "evidence": ["harness"]}, {"id": "batch.JclSteps.utility(String,String,String,String,String,String,String)", "kind": "method", "returns": "Tasklet", "visibility": "public", "evidence": ["harness"]} ]}, diff --git a/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py b/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py index faeb1a8c5b..9a2bdf676b 100644 --- a/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py +++ b/gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py @@ -1531,10 +1531,10 @@ def audit_line(self) -> str: import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; //{IDCAMS_IMPORT} import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; import java.util.function.ToIntFunction; import __BASE__.cobolrt.job.Idcams; //{/IDCAMS_IMPORT} diff --git a/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py b/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py index 0d416334ad..ffd636611b 100644 --- a/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py +++ b/tests/cobol_mainframe/test_jcl_forged_job_carddemo.py @@ -183,6 +183,8 @@ def test_the_forge_guard_is_the_one_the_driver_mirrors(): conds = forge_mod._RUNTIME["JclConditions"] assert "JclConditions.bypassed(" in guarded assert "bypass(jobCond, rcs) || bypass(cond, rcs) || !holds(ifCond, rcs)" in conds + # `ifChains` is used with no IDCAMS step, so its import sits outside the IDCAMS block (zopeneditor-sample compile) + assert guarded.index("import java.util.concurrent.ConcurrentHashMap;") < guarded.index("//{IDCAMS_IMPORT}") assert "rcs.put(jcl, rc);" in guarded and 'new ExitStatus("BYPASSED")' in guarded