#!/usr/bin/env python3 """Job #4224 (route 87 step check, first look): is the step still open? Read-only, stdlib only, no network and no simulation. Reads eight local files by their served/declared names in the current directory and prints one deterministic JSON object. Decisive questions, each a claim below: C1 #1122's served instrument stops at H_SUB = 0.48 on the LOW family (its own line 70), so the step's question -- is the R failure a TOP-edge artefact -- has no measurement on the record. C2 #1863, the previous step check, runs no simulation (its docstring says so and its input is #1122's served output by sha), so it is a forecast, not an answer. C3 Route 87's record shows nothing after #1863: state, last_return_id, events, jobs. C4 #1864 is route 72's own step check and says nothing about route 87's grid. C5 The next_step this run submits is the issued step, copied exactly (parsed-JSON equality and byte equality of the canonical dumps). A1 control: a MUTATED next_step (0.48 -> 0.50 in the question) must be detected as different. A2 control: a MUTATED H_SUB literal must be detected as not equal to [0.30 ... 0.48]. """ import hashlib import json import re import sys try: sys.stdout.reconfigure(encoding="utf-8", errors="replace") except Exception: # noqa: BLE001 pass FILES = ("check-2083.py", "edge4221.py", "edge4221.out.json", "route87.json", "r1863.json", "r1864.json", "step-4224.json", "research-4224.json") SHA = { "check-2083.py": "5931777bfeff34814d46b5e561b21e4b397674cbc1c0816cf45b372c3ce44fa2", "edge4221.py": "90243cced63fadf7d0ff844aafa604811ebabdb103fa15d11ee1a6faa23b1ebb", "edge4221.out.json": "3e87fecae5f27e7154c2e377bb9820edec61bbcf2feb9e532b258ff3b8377dbb", } H_SUB = [0.30, 0.33, 0.36, 0.39, 0.42, 0.45, 0.48] CHECK_2083_OUT_SHA = "67a4f8c7fbb5309be70cf4cc89772deb19d9b8625c3d511e7d9a399a90dfcfac" def load(name): with open(name, "rb") as fh: return fh.read() def canon(o): return json.dumps(o, sort_keys=True, ensure_ascii=False).encode("utf-8") def h_sub_literal(src): m = re.search(r"^H_SUB\s*=\s*(\[[^\]]*\])", src, re.M) return json.loads(m.group(1)) if m else None def body(path): """api-get.py wraps the response: {"code":200,"path":...,"body":""}.""" j = json.loads(load(path).decode("utf-8")) return json.loads(j["body"]) if isinstance(j.get("body"), str) else j def main(): claims, controls, shas = [], [], {} for name in FILES: blob = load(name) shas[name] = hashlib.sha256(blob).hexdigest() # C1 src = load("check-2083.py").decode("utf-8") lit = h_sub_literal(src) c1 = (shas["check-2083.py"] == SHA["check-2083.py"] and lit == H_SUB and lit[-1] == 0.48 and re.search(r"widened downward", src) is not None) claims.append({"id": "C1", "ok": bool(c1), "detail": "check-2083.py sha matches; H_SUB literal = %s (top %s); its own comment " "records the grid was widened DOWNWARD, so the top edge is untouched" % (lit, lit[-1] if lit else None)}) # A2 control: a mutated literal must fail the same test mutated = "[0.30, 0.33, 0.36, 0.39, 0.42, 0.45, 0.50]" controls.append({"name": "H_SUB top 0.48 -> 0.50", "detected": json.loads(mutated) != lit, "note": "same test applied to the mutated literal"}) # C2 e = load("edge4221.py").decode("utf-8") # First draft used `"H_SUB" not in e.replace("H_SUB grid", "")` as the "runs no generator" test; # the file names H_SUB in a COMMENT (the grid it hard-codes), so the substring was the wrong # instrument. The honest tests are: it declares no simulation and imports/uses no simulation # library, and it pins its input by sha. Both first-draft defects (this and the string/int id # comparison in C3) were caught by the checker's own run and fixed before serving. c2 = (shas["edge4221.py"] == SHA["edge4221.py"] and "no simulation" in e and "numpy" not in e and CHECK_2083_OUT_SHA in e) claims.append({"id": "C2", "ok": bool(c2), "detail": "edge4221.py sha matches; docstring says 'read-only, stdlib only, no " "simulation'; it pins #1122's check-2083.out.json by sha %s and only " "positions/extrapolates that output" % CHECK_2083_OUT_SHA[:12]}) # C3 route = body("route87.json") # ids come back as STRINGS on this route (`"return_id": "1863"`), so compare as integers. ev_returns = [x.get("return_id") for x in (route.get("events") or [])] jobs = {str(x.get("id")): (x.get("status"), x.get("research_stage")) for x in (route.get("jobs") or [])} newest = [int(r) for r in ev_returns if r] c3 = (route.get("state") == "active" and int(route.get("last_return_id")) == 1863 and newest and max(newest) == 1863 and jobs.get("2095") == ("expired", "pursue") and jobs.get("4221") == ("returned", "first_look") and jobs.get("4224") == ("assigned", "first_look") and "2083" in jobs) claims.append({"id": "C3", "ok": bool(c3), "detail": "route 87 rev %s state %s last_return_id %s; newest event return %s; jobs " "after 2083 = %s" % (route.get("revision"), route.get("state"), route.get("last_return_id"), max(newest) if newest else None, {k: jobs[k] for k in ("2095", "4221", "4224") if k in jobs})}) # C4 r1864 = body("r1864.json") r1863 = body("r1863.json") st = json.loads(load("step-4224.json").decode("utf-8")) r124 = json.loads(load("research-4224.json").decode("utf-8")) c4 = ((r1864.get("research") or {}).get("route_id") == 72 and (r1864.get("research") or {}).get("next_step", {}).get("question") != st["question"] and "H_SUB" not in json.dumps(r1864.get("research") or {})) claims.append({"id": "C4", "ok": bool(c4), "detail": "#1864 is route %s and its next_step question is a different one; no H_SUB " "anywhere in its research block" % (r1864.get("research") or {}).get("route_id")}) # C5 -- the copy, exactly same_parsed = r124["next_step"] == st same_bytes = canon(r124["next_step"]) == canon(st) c5 = same_parsed and same_bytes and r124["route_id"] == 87 and r124["outcome"] == "promising" claims.append({"id": "C5", "ok": bool(c5), "detail": "submitted next_step equals the issued step (parsed and canonical bytes); " "step sha256 %s" % hashlib.sha256(canon(st)).hexdigest()}) mut = dict(st) mut["question"] = st["question"].replace("0.48", "0.50") controls.append({"name": "next_step question 0.48 -> 0.50", "detected": canon(mut) != canon(st), "note": "the same equality test applied to a mutated copy"}) # context, not a claim: #1863 said the same thing ctx = {"r1863_outcome": (r1863.get("research") or {}).get("outcome"), "r1863_files": [f.get("name") for f in (r1863.get("files") or [])], "r1863_step_question_equals_issued": (r1863.get("research") or {}).get("next_step", {}).get("question") == st["question"]} out = {"tool": "verify-4224/1", "all_ok": all(c["ok"] for c in claims), "claims": claims, "controls": controls, "context": ctx, "inputs": shas, "step_canon_sha256": hashlib.sha256(canon(st)).hexdigest(), "next_step_canon_sha256": hashlib.sha256(canon(r124["next_step"])).hexdigest()} print(json.dumps(out, indent=1, sort_keys=True)) return 0 if out["all_ok"] else 1 if __name__ == "__main__": sys.exit(main())