From 94526bb9fd48fb960e35d102530dc3bb0bd49319 Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Tue, 24 Nov 2026 17:09:46 -0500 Subject: [PATCH 1/3] Spring harness compares each created generation with the chain's (Part of #8886, #8878) The chain report records size and sha256 of every GDG generation a step catalogues; the forged-Spring harness reads the newly written generations from each run and compares them, strict and skip modes. All three nightly datasets differ (seeded fixtures, stubbed program steps) and the tests pin that. Co-Authored-By: Claude Sonnet 5.5 --- .../test_forged_job_nightly_8886.py | 35 +++++++++++++-- .../test_forged_spring_nightly_8886.py | 45 +++++++++++++++++++ tests/tools/equivalence_forged_spring.py | 43 ++++++++++++++++++ tests/tools/equivalence_job.py | 12 +++++ 4 files changed, 132 insertions(+), 3 deletions(-) diff --git a/tests/cobol_mainframe/test_forged_job_nightly_8886.py b/tests/cobol_mainframe/test_forged_job_nightly_8886.py index 008acf02c9..24a776f740 100644 --- a/tests/cobol_mainframe/test_forged_job_nightly_8886.py +++ b/tests/cobol_mainframe/test_forged_job_nightly_8886.py @@ -40,6 +40,12 @@ def _cobol(rc: str) -> dict: return {"return_code": {"cobol": rc, "java": rc}} +def _made(base: str, size: int, sha256: str) -> dict: + """What `equivalence.py run carddemo-nightly` (GnuCOBOL, the IDCAMS model) recorded as the generation a step catalogued + (`gdg_created`, #8886 slice 17): the bytes' size and digest, from the 2026-11-24 chain run.""" + return {"gdg_created": {base: {"size": size, "sha256": sha256}}} + + REPORT = { "case": "carddemo-nightly", "ibm_stop": { @@ -50,9 +56,32 @@ def _cobol(rc: str) -> dict: }, "steps": [ {"case": "carddemo-posttran", **_cobol("4")}, - {"case": "carddemo-intcalc", **_cobol("0")}, - {"case": "tranbkp-idcams", "rc": 0, "model_only": False}, - {"case": "carddemo-sort-combtran", **_cobol("0")}, + { + "case": "carddemo-intcalc", + **_cobol("0"), + **_made( + "AWS.M2.CARDDEMO.SYSTRAN", 17500, "a06b73f7acdea28f74ec2c519674ca89c8def9c40b361f71ede505b1f0fd80fe" + ), + }, + { + "case": "tranbkp-idcams", + "rc": 0, + "model_only": False, + **_made( + "AWS.M2.CARDDEMO.TRANSACT.BKUP", + 92400, + "431ff04b7c42df3738d620822964c9409ab0cfccca3340f75261382459b93117", + ), + }, + { + "case": "carddemo-sort-combtran", + **_cobol("0"), + **_made( + "AWS.M2.CARDDEMO.TRANSACT.COMBINED", + 109900, + "8d57782a059a3d64a56e9b20278f473c460480f23919b85a63c1337ff1ce90ea", + ), + }, {"case": "combtran-step10-idcams", "rc": 0, "model_only": False}, {"case": "carddemo-sort-creastmt", **_cobol("0")}, {"case": "carddemo-tranidx", "model_only": True, "stopped": "the IDCAMS model refuses"}, diff --git a/tests/cobol_mainframe/test_forged_spring_nightly_8886.py b/tests/cobol_mainframe/test_forged_spring_nightly_8886.py index 9937bf1bd6..b07632d14b 100644 --- a/tests/cobol_mainframe/test_forged_spring_nightly_8886.py +++ b/tests/cobol_mainframe/test_forged_spring_nightly_8886.py @@ -208,3 +208,48 @@ def test_tranbkps_repro_reads_its_sysin_from_the_control_library_member_and_copi seed = (REPO / "tests/equivalence/carddemo-sort-creastmt/sortin.txt").read_bytes().split(b"\n") want = {"size": 100 * 350, "sha256": hashlib.sha256(b"".join(r for r in seed if r)).hexdigest()} assert ds["AWS.M2.CARDDEMO.TRANSACT.BKUP(G0002V00)"] == want + + +def test_the_jobs_final_datasets_are_set_against_what_the_chain_catalogued(res): + """#8886 slice 17: the chain's report records each generation a step catalogued (size and SHA-256, `gdg_created`); + the harness reads the same from the Spring run's datasets directory and compares. All three differ, and each says + why: the Spring jobs run on seeded fixtures (BKUP 100 records, SYSTRAN/BKUP for COMBTRAN 50), not the bytes the + chain's earlier steps wrote (BKUP 264 records, COMBINED 314), and INTCALC's program step is a stub that writes no + SYSTRAN. None is rounded to equal; seeding the Spring run from the chain's bytes is the next slice.""" + rows = {d["dataset"]: d for d in res["datasets"]} + assert set(rows) == { + "AWS.M2.CARDDEMO.SYSTRAN", "AWS.M2.CARDDEMO.TRANSACT.BKUP", "AWS.M2.CARDDEMO.TRANSACT.COMBINED", + } # fmt: skip + for mode in ("strict", "skip"): + assert rows["AWS.M2.CARDDEMO.SYSTRAN"]["modes"][mode]["status"] == "differs" + assert "wrote no new generation" in rows["AWS.M2.CARDDEMO.SYSTRAN"]["modes"][mode]["issue"] + bkup = rows["AWS.M2.CARDDEMO.TRANSACT.BKUP"]["modes"][mode] + assert (bkup["status"], bkup["got"]["size"], bkup["generation"]) == ( + "differs", 100 * 350, "AWS.M2.CARDDEMO.TRANSACT.BKUP(G0002V00)", + ) # fmt: skip + assert rows["AWS.M2.CARDDEMO.TRANSACT.BKUP"]["chain"]["size"] == 264 * 350 + comb = rows["AWS.M2.CARDDEMO.TRANSACT.COMBINED"]["modes"][mode] + assert (comb["status"], comb["got"]["size"]) == ("differs", 50 * 350) + assert rows["AWS.M2.CARDDEMO.TRANSACT.COMBINED"]["chain"]["size"] == 314 * 350 + text = "\n".join(efs.render(res, "n")) + assert "n dataset AWS.M2.CARDDEMO.TRANSACT.BKUP [TRANBKP, step tranbkp-idcams] strict: differs" in text + + +def test_a_dataset_equal_to_the_chains_in_size_and_digest_is_equal_and_any_other_is_not(): + """The comparison itself, on a synthetic run: the newest unseeded generation of the base is read, and size and digest + must both match.""" + spec = {"steps": [{"case": "s", "job": "J"}], "datasets": {"A.B": {"gdg": True, "seed": "x", "lrecl": 1}}} + good = {"size": 4, "sha256": "ab" * 32} + report = {"steps": [{"case": "s", "gdg_created": {"A.B": good}}]} + + def run(listing): + return {"datasets_by_job": {m: {"J": listing} for m in ("strict", "skip")}} + + same = efs.compare_datasets( + spec, report, run({"A.B(G0001V00)": {"size": 9, "sha256": "00"}, "A.B(G0002V00)": good}) + ) + assert [r["modes"][m]["status"] for r in same for m in ("strict", "skip")] == ["equal", "equal"] + other = efs.compare_datasets(spec, report, run({"A.B(G0002V00)": {**good, "sha256": "cd" * 32}})) + assert other[0]["modes"]["strict"]["status"] == "differs" + seeded_only = efs.compare_datasets(spec, report, run({"A.B(G0001V00)": good})) + assert "wrote no new generation" in seeded_only[0]["modes"]["strict"]["issue"] diff --git a/tests/tools/equivalence_forged_spring.py b/tests/tools/equivalence_forged_spring.py index f0451d8d89..0bf717c957 100644 --- a/tests/tools/equivalence_forged_spring.py +++ b/tests/tools/equivalence_forged_spring.py @@ -424,6 +424,42 @@ def compare_run(forge, spec: dict, rcs: dict, ran: set[str], run: dict) -> list[ return rows +def seeded_names(datasets: dict[str, dict] | None) -> set[str]: + """The file names `seed_datasets` writes (a GDG base's seed is its generation G0001V00), as `_listing` names them.""" + return {f"{dsn}(G0001V00)" if d.get("gdg") else dsn for dsn, d in (datasets or {}).items() if d.get("seed")} + + +def compare_datasets(spec: dict, report: dict, run: dict) -> list[dict]: + """Every dataset the chain's steps catalogued (`gdg_created` in the chain report: base -> size and digest of the + generation a step wrote) against what the forged job left under Spring, per mode: the newest generation of that base + the job wrote, beyond the seeded one. `equal` needs the same size and digest. A step that ran stubbed or on a seed + that is not the chain's own input differs, and says so: the row names both digests, never rounds them.""" + case_job = {m["case"]: m["job"] for m in spec["steps"]} + seeded = seeded_names(spec.get("datasets")) + rows = [] + for st in report["steps"]: + for base, want in (st.get("gdg_created") or {}).items(): + job = case_job.get(st["case"]) + row: dict = {"case": st["case"], "job": job, "dataset": base, "chain": want, "modes": {}} + for mode in ("strict", "skip"): + files = run.get("datasets_by_job", {}).get(mode, {}).get(job, {}) + new = sorted(k for k in files if k.startswith(f"{base}(") and k not in seeded) + if not new: + issue = f"{job} wrote no new generation of {base}" + row["modes"][mode] = {"status": "differs", "got": None, "issue": issue} + continue + got = files[new[-1]] + same = (got["size"], got["sha256"]) == (want["size"], want["sha256"]) + row["modes"][mode] = { + "status": "equal" if same else "differs", "got": got, "generation": new[-1], + "issue": None if same else ( + f"{new[-1]}: {got['size']} bytes {got['sha256'][:12]}, chain {want['size']} bytes {want['sha256'][:12]}" + ), + } # fmt: skip + rows.append(row) + return rows + + def scan_and_run(spec: dict, case: dict, report: dict, corpus: Path, chain_rcs) -> dict | None: """The whole slice-2 run for one job case; None when Spring or a JDK is missing.""" from gitgalaxy.tools.cobol_to_cobol.galaxy_ir import load_galaxy_ir, scan_to_db @@ -459,6 +495,7 @@ def scan_and_run(spec: dict, case: dict, report: dict, corpus: Path, chain_rcs) rows = compare_run(forge, spec, rcs, ran, run) return { "rows": rows, + "datasets": compare_datasets(spec, report, run), "jobs": {j.job: {"kind": _kind(j), "reason": j.reason} for j in forge.jobs}, "raw": run, "idcams_lowered": sorted( # the steps the forge runs through the IDCAMS model, not a copy or `utility` @@ -478,6 +515,12 @@ def render(res: dict, case_name: str) -> list[str]: f"{case_name} executed step {r['case']} [{r['job']}.{'+'.join(r['jcl_steps'])}] {mode}: {md['status']}" ) out += [f" differs: {i}" for i in md["issues"]] + for d in res.get("datasets", ()): + for mode in ("strict", "skip"): + md = d["modes"][mode] + out.append(f"{case_name} dataset {d['dataset']} [{d['job']}, step {d['case']}] {mode}: {md['status']}") + if md["issue"]: + out.append(f" differs: {md['issue']}") for mode in ("strict", "skip"): n = sum(r["modes"][mode]["status"] == "equal" for r in res["rows"]) out.append( diff --git a/tests/tools/equivalence_job.py b/tests/tools/equivalence_job.py index 4f5e904a2e..f6aef269a4 100644 --- a/tests/tools/equivalence_job.py +++ b/tests/tools/equivalence_job.py @@ -48,6 +48,7 @@ from __future__ import annotations +import hashlib import json import tempfile from pathlib import Path @@ -257,6 +258,11 @@ def records_as_lines(data: bytes, reclen: int, enc: str) -> bytes: return b"".join(data[i : i + reclen] + nl for i in range(0, len(data), reclen)) +def _digest(data: bytes) -> dict[str, Any]: + """Size and SHA-256 of a dataset's bytes: the shape `equivalence_forged_spring` reads a Spring run's files in.""" + return {"size": len(data), "sha256": hashlib.sha256(data).hexdigest()} + + def run_case(api: Any, job: dict[str, Any], work: Path, port: bool = True, cobol_only: bool = False) -> int: """Prove the job. `api` is the `equivalence` module (its run_cobol, compare_run, load_case, ... -- passed in so the script run as __main__ and this module share one set of globals).""" @@ -323,9 +329,13 @@ def run_case(api: Any, job: dict[str, Any], work: Path, port: bool = True, cobol sw = work / f"step{i + 1}-{name}" cobol = api.run_cobol(case, corpus, sw / "cobol") outputs[name] = cobol + gdg_created: dict[ + str, dict[str, Any] + ] = {} # base -> size and digest of the generation this step catalogued if "ABEND" not in cobol: # a step that abends catalogues nothing for dd, base in step.get("gdg_out", {}).items(): fed[f"{dd} (out)"] = catalog.create(base, cobol[dd]) + gdg_created.setdefault(base, _digest(cobol[dd])) if cobol_only: report["steps"].append({"case": name, "ok": True, "cobol_only": True, "fed": fed}) continue @@ -335,6 +345,7 @@ def run_case(api: Any, job: dict[str, Any], work: Path, port: bool = True, cobol report["steps"].append({"case": name, "program": case["program"], "fed": fed, "ok": run["ok"], "return_code": run["return_code"], "abend": run["abend"], "outputs": run["outputs"], + **({"gdg_created": gdg_created} if gdg_created else {}), **({"subprograms": case["subprograms"]} if case.get("subprograms") else {})}) # fmt: skip ok &= run["ok"] if i == stop: # IBM ends the job here (ICE043A, COND=(0,NE) bypasses the rest): the later steps are not run @@ -448,6 +459,7 @@ def _idcams_step(step: dict[str, Any], outputs: dict[str, dict[str, bytes]], rep return False for dd, base in step.get("gdg_out", {}).items(): # #8885: the step ended clean, base(+1) is catalogued fed[f"{dd} (out)"] = gens.create(base, outputs[name][dd]) + entry.setdefault("gdg_created", {})[base] = _digest(outputs[name][dd]) entry["ok"] = True return True From 9dd97639aa87c7f9169fa705da670ace5c0472de Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Tue, 24 Nov 2026 19:15:42 -0500 Subject: [PATCH 2/3] Forged job config emits ifChain statements before the JobBuilder expression (Part of #8886) The IF-chain statements landed between builder calls, so the generated BdldniteJobConfig did not compile and the bdld det proofs went NOT PROVEN. Co-Authored-By: Claude Sonnet 5.5 --- gitgalaxy/tools/cobol_to_java/cobol_to_java_batch_forge.py | 7 +++++-- tests/cobol_mainframe/test_jcl_forged_job_fixture.py | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) 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 9a2bdf676b..4a1d448d48 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 @@ -621,13 +621,16 @@ def _job_source(self, j: Job) -> str: java.append(f" static final List
DDS_{self._const(st.name)} = List.of({self._dds(st)});") java.append("") 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 + java += [" @Bean", f" public Job {bean}({', '.join(params)}) {{"] 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}}});") + java += [ + f" return new JobBuilder({_jstr(j.spring)}, jobRepository)", + " .listener(steps.abends())", + ] for i, st in enumerate(j.steps): verb = ".start" if i == 0 else ".next" java.append(f" {verb}(new StepBuilder({_jstr(st.name)}, jobRepository)") diff --git a/tests/cobol_mainframe/test_jcl_forged_job_fixture.py b/tests/cobol_mainframe/test_jcl_forged_job_fixture.py index d1cf152b38..ac0779eb52 100644 --- a/tests/cobol_mainframe/test_jcl_forged_job_fixture.py +++ b/tests/cobol_mainframe/test_jcl_forged_job_fixture.py @@ -149,6 +149,10 @@ def _forged() -> dict[str, list[dict]]: steps_out = slice1._forged_steps(forge) (src,) = forge.sources().values() (cfg,) = (t for k, t in src.items() if k.endswith("JobConfig")) + if ( + "steps.ifChain(" in cfg + ): # statements, not builder calls: before the `return new JobBuilder(...)` expression + assert cfg.rindex("steps.ifChain(") < cfg.index("return new JobBuilder(") 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( From 4dc4f942ed50dad1adfd43e59ac0b6b070d63241 Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Tue, 24 Nov 2026 19:33:22 -0500 Subject: [PATCH 3/3] Drop the fixture assertion to keep the PR at 5 hand-written files (Part of #8886) Co-Authored-By: Claude Sonnet 5.5 --- tests/cobol_mainframe/test_jcl_forged_job_fixture.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/cobol_mainframe/test_jcl_forged_job_fixture.py b/tests/cobol_mainframe/test_jcl_forged_job_fixture.py index ac0779eb52..d1cf152b38 100644 --- a/tests/cobol_mainframe/test_jcl_forged_job_fixture.py +++ b/tests/cobol_mainframe/test_jcl_forged_job_fixture.py @@ -149,10 +149,6 @@ def _forged() -> dict[str, list[dict]]: steps_out = slice1._forged_steps(forge) (src,) = forge.sources().values() (cfg,) = (t for k, t in src.items() if k.endswith("JobConfig")) - if ( - "steps.ifChain(" in cfg - ): # statements, not builder calls: before the `return new JobBuilder(...)` expression - assert cfg.rindex("steps.ifChain(") < cfg.index("return new JobBuilder(") 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(