#!/usr/bin/env python3 """Job #1528 prior-art probes: Halberstam-Richert 1974 Theorem 2.2 (upper-bound combinatorial sieve, dimension kappa, conditions (Omega_1), (Omega_2(kappa)), (R)). Every reply is saved raw under work/job1528/replies/ and sha256'd. Records channel, URL, status and a compact summary only; no credential is ever sent or printed. """ import hashlib import json import os import sys import urllib.error import urllib.parse import urllib.request OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "job1528", "replies") os.makedirs(OUT, exist_ok=True) UA = "solveathome-department-research/1.0 (prior-art probe; contact: department)" TIMEOUT = 25 PROBES = [ # ---- owning-convention names for the object ------------------------------- ("openalex-flt-fundamental-lemma", "https://api.openalex.org/works?per-page=25&filter=" + urllib.parse.quote('fulltext.search:"fundamental lemma of sieve theory"')), ("openalex-flt-thm22-hr", "https://api.openalex.org/works?per-page=25&filter=" + urllib.parse.quote('fulltext.search:"Halberstam and Richert" "Theorem 2.2"')), ("arxiv-fundamental-lemma", "http://export.arxiv.org/api/query?max_results=25&search_query=" + urllib.parse.quote('all:"fundamental lemma of sieve theory"')), ("arxiv-upper-bound-sieve-kappa", "http://export.arxiv.org/api/query?max_results=25&search_query=" + urllib.parse.quote('all:"upper bound sieve" AND all:"sieve dimension"')), ("crossref-brun-upper-bound-sieve", "https://api.crossref.org/works?rows=15&query.bibliographic=" + urllib.parse.quote("fundamental lemma of sieve theory Brun upper bound sieve dimension kappa")), ("s2-fundamental-lemma", "https://api.semanticscholar.org/graph/v1/paper/search?limit=10&fields=" + urllib.parse.quote("title,year,venue,externalIds,citationCount") + "&query=" + urllib.parse.quote("fundamental lemma of sieve theory")), # ---- HR 1974 itself in bibliographic channels ----------------------------- ("openalex-hr-1974", "https://api.openalex.org/works?per-page=10&filter=" + urllib.parse.quote('title.search:"Sieve Methods"') + "&search=" + urllib.parse.quote("Halberstam Richert")), ("crossref-hr-1974", "https://api.crossref.org/works?rows=10&query.bibliographic=" + urllib.parse.quote("Halberstam Richert Sieve Methods 1974 Academic Press L.M.S. Monographs")), # ---- the consumer: Kalmynin-Konyagin arXiv:2302.00459 --------------------- ("openalex-kk2302", "https://api.openalex.org/works?per-page=5&filter=" + urllib.parse.quote('doi:10.48550/arxiv.2302.00459')), ("openaire-kk-title", "https://api.openaire.eu/search/publications?format=json&size=5&title=" + urllib.parse.quote("Polynomial Jacobsthal function")), ] summary = {"version": "job1528/1", "utc": "2026-09-16", "probes": []} for name, url in PROBES: rec = {"name": name, "url": url, "status": None, "bytes": None, "sha256": None, "note": None, "count": None} req = urllib.request.Request(url, headers={"User-Agent": UA, "Accept": "application/json"}) try: with urllib.request.urlopen(req, timeout=TIMEOUT) as r: body = r.read() rec["status"] = r.status except urllib.error.HTTPError as e: body = e.read() rec["status"] = e.code rec["note"] = "http error" except Exception as e: # noqa: BLE001 rec["status"] = None rec["note"] = type(e).__name__ + ": " + str(e)[:160] body = b"" if body: p = os.path.join(OUT, name + ".raw") with open(p, "wb") as f: f.write(body) rec["bytes"] = len(body) rec["sha256"] = hashlib.sha256(body).hexdigest() try: d = json.loads(body) if "results" in d and isinstance(d["results"], list): rec["count"] = len(d["results"]) rec["titles"] = [(w.get("title") or "")[:110] + " | " + str(w.get("publication_year")) for w in d["results"][:8]] elif "feed" in d: ents = d["feed"].get("entry", []) rec["count"] = len(ents) rec["titles"] = [(e.get("title", "") or "").replace("\n", " ")[:110] for e in ents[:8]] elif "message" in d and isinstance(d["message"], dict): its = d["message"].get("items", []) rec["count"] = len(its) rec["titles"] = [((i.get("title") or [""])[0])[:110] for i in its[:8]] elif "data" in d: rec["count"] = len(d["data"]) rec["titles"] = [((x.get("title") or "")[:110]) for x in d["data"][:8]] except Exception: # noqa: BLE001 rec["note"] = (rec["note"] or "") + " (non-JSON reply saved raw)" summary["probes"].append(rec) print(json.dumps({k: v for k, v in rec.items() if k != "titles"})) for t in rec.get("titles", [])[:6]: print(" -", t) sp = os.path.join(os.path.dirname(OUT), "job1528-search.json") with open(sp, "w") as f: json.dump(summary, f, indent=1) print("saved", sp)