#!/usr/bin/env python3 # -*- coding: utf-8 -*- """budget_scale.py — job #2743: budget-scaled exact-recovery test of the PRODUCING instrument. The instrument under test is `check-2043.py` (the one whose state the route's n = 25 record is built from, served with the sibling run bf2-fd7c93e9fdc79517 and retrievable from return #1098's evidence). It is imported **read-only by path** and never edited: the point of this job is the instrument's own strength at a real budget, not a repaired version of it. What is scaled: its calibration ladder gave every level **18 s**. This driver gives one level 20-30x that slot and records `covered / holes_best / seconds`, plus the state it ends on, so exact recovery gets a measured cost curve instead of a single data point. Method (nothing new is invented): `climb_fixed_R(n, R, seconds, seed, warm)` straight out of the producer module, warm-started from that level's OWN plateau state as recorded in its served output (`check-2043.out.json`, `levels.calibration[].residues`) — so the test asks "what does 20-30x the slot buy on the state it already had?", not "can a fresh random start do better?". Two runs of the same configuration are not expected to be identical (time-boxed, randomized) and are quoted as protocols; the ARTIFACT is the state, and the state is checked independently by this run's own scanners (`cover90scan.py`, `window.py`) and, when a window is covered, by `runcheck.py`, which shares no code with either search. stdout is the artifact; progress goes to stderr (the file-note lesson from return #1360). """ import argparse import importlib.util import json import os import sys import time PRODUCER_DEFAULT = os.path.join( ".solveathome", "twin-primes", "runs", "bf2-fd7c93e9fdc79517", "evidence", "1098", "check-2043.py") def load_producer(path): spec = importlib.util.spec_from_file_location("check2043_ro", path) mod = importlib.util.module_from_spec(spec) spec.loader.exec_module(mod) # read-only: the file is never written to return mod def main(): ap = argparse.ArgumentParser() ap.add_argument("--producer", default=PRODUCER_DEFAULT) ap.add_argument("--n", type=int, required=True, help="level: number of primes") ap.add_argument("--R", type=int, required=True, help="pre-registered target (published term)") ap.add_argument("--seconds", type=float, default=450.0) ap.add_argument("--seed", type=int, required=True) ap.add_argument("--warm-file", help="JSON with the level's own plateau residues") ap.add_argument("--out", required=True) a = ap.parse_args() prod = load_producer(a.producer) if len(prod.PRIMES) < a.n: raise SystemExit("producer module has only %d primes" % len(prod.PRIMES)) warm = None if a.warm_file: d = json.load(open(a.warm_file, encoding="utf-8")) warm = d.get("best_residues") or d.get("residues") or d if len(warm) != a.n: raise SystemExit("warm state has %d residues, level is %d" % (len(warm), a.n)) t0 = time.time() res = prod.climb_fixed_R(a.n, a.R, a.seconds, a.seed, warm=warm, log=None) elapsed = time.time() - t0 out = { "tool": "budget_scale/1", "instrument": "check-2043.py (imported read-only) climb_fixed_R", "producer_path": a.producer, "n": a.n, "R": a.R, "seconds_requested": a.seconds, "seconds_elapsed": round(elapsed, 1), "seed": a.seed, "warm_start": bool(warm), "holes_best": res["holes_best"], "covered": bool(res["covered"]), "window_start_in_buffer": res["start"], "steps": res["steps"], "restarts": res["restarts"], "trajectory": res["trajectory"], "residues": res["residues"], "producer_best_run": res["best_run"], "producer_best_run_start": res["best_run_start"], "producer_best_run_state": res["best_run_state"], } os.makedirs(os.path.dirname(a.out) or ".", exist_ok=True) json.dump(out, open(a.out, "w", encoding="utf-8"), indent=1) # artifact to stdout, progress to stderr print(json.dumps({k: out[k] for k in ("n", "R", "seconds_requested", "seed", "holes_best", "covered", "steps", "producer_best_run")}, indent=1)) print(json.dumps({"progress": "budget_scale", "n": a.n, "seconds_elapsed": out["seconds_elapsed"], "steps": out["steps"]}), file=sys.stderr) return 0 if __name__ == "__main__": sys.exit(main())