#!/usr/bin/env python3 """gen_q#274 run 47 -- assert that THE CELL THIS PAYLOAD JUST RAN carries the J_elite/value split. WHY THIS EXISTS. Run 46's four decomposition payloads asserted their deliverable with D=$(ls -t .../td274smoke/*JSPLIT*.diag.json | head -1); if [ -n "$D" ]; then ... LANDED which is a glob over a SHARED directory and is not anchored to the cell the payload ran. cfg(a) writes no separate .diag.json at all -- its diagnostics are inline in the cell JSON -- so on both cfg(a) slots the glob matched the cfg(b) diag that had landed in the same directory ~40 seconds earlier, and the payload printed "DIAG LANDED" naming ANOTHER CELL'S artefact and exited 0. A success assertion that another cell's file can satisfy is not an assertion, and it would have reported a lost deliverable as a landed one. WHAT IT CHECKS. Given the exact path of the cell JSON this payload wrote, the split keys must be present EITHER inline (cfg(a): planner.scorer.{last_backend_stats,backend_stats_mean}) OR in that cell's OWN .diag.json sibling (cfg(b): J_elite_rsum_last / J_elite_termq_last). Nothing else in the directory is looked at. Exit 0 = landed, 1 = did not. """ import json, os, sys if len(sys.argv) != 2: sys.stderr.write("usage: assert_split_landed.py \n"); sys.exit(2) cell = sys.argv[1] if not os.path.exists(cell): print("[assert_split] NO CELL JSON at %s" % cell); sys.exit(1) try: d = json.load(open(cell)) except Exception as e: print("[assert_split] CELL JSON UNREADABLE %s: %s" % (cell, e)); sys.exit(1) sc = (d.get("planner") or {}).get("scorer") or {} inline = [k for k in ("last_backend_stats", "backend_stats_mean") if sc.get(k)] have_inline = all( (sc.get(k) or {}).get("value_termq_mean") is not None for k in inline) and len(inline) == 2 sib = cell[:-5] + ".diag.json" if cell.endswith(".json") else cell + ".diag.json" have_diag = False if os.path.exists(sib): try: j = json.load(open(sib)) have_diag = j.get("J_elite_rsum_last") is not None and j.get("J_elite_termq_last") is not None except Exception: have_diag = False if have_inline: print("[assert_split] OK inline split in %s (calls=%s)" % (cell, (sc.get("backend_stats_mean") or {}).get("calls"))) sys.exit(0) if have_diag: print("[assert_split] OK split in this cell's OWN diag %s" % sib) sys.exit(0) print("[assert_split] MISSING the split. cell=%s inline_keys=%s diag_exists=%s" % (cell, inline, os.path.exists(sib))) sys.exit(1)