def _require(cond: bool, msg: str) -> None: if not cond: raise RuntimeError(msg) def _require_bool(val: Any, name: str) -> bool: if not isinstance(val, bool): raise TypeError(f"{name} must be strict bool, got {type(val).__name__}: {val!r}") return val def sha256_bytes(data: bytes) -> str: return hashlib.sha256(data).hexdigest() def sha256_str(text: str) -> str: return sha256_bytes(text.encode("utf-8")) def load_strict_json_text(raw: str, label: str) -> Any: def _reject_dup(pairs: list[tuple[str, Any]]) -> dict[str, Any]: out: dict[str, Any] = {} for k, v in pairs: if k in out: raise ValueError(f"Duplicate JSON key {k!r} in {label}") out[k] = v return out def _reject_const(token: str) -> Any: raise ValueError(f"Non-finite JSON token {token!r} in {label}") return json.loads(raw, object_pairs_hook=_reject_dup, parse_constant=_reject_const) # ============================================================================= # 1. PUBLIC HYGIENE SCANNER (GATE 30-TOS-QUARANTINE ALIGNED) # ============================================================================= _HOME_MAC = "/" + "Users" + "/" _HOME_LINUX = "/" + "home" + "/" _HOME_WIN_ESC = r"[A-Za-z]:\\" + "Users" + r"\\" _RE_LOCAL_HOME_PATH = re.compile( r"(? dict[str, int]: scrubbed_urls = re.sub(r"https?://[^\s<>()\[\]\"'`]+", " ", text) return { "home_path_hits": len(_RE_LOCAL_HOME_PATH.findall(scrubbed_urls)), "currency_hits": len(_RE_CURRENCY.findall(text)), "vendor_token_hits": len(_RE_VENDOR.findall(text)), "coordinate_row_hits": len(_RE_COORDINATE_ROW.findall(text)), } def assert_public_hygiene_clean(text: str, label: str) -> dict[str, int]: counts = scan_public_hygiene_text(text) if any(v > 0 for v in counts.values()): raise RuntimeError(f"Public hygiene violation in {label}: {counts}") return counts def run_hygiene_negative_probes() -> dict[str, bool]: probes = [ ("mac_home_path", "bad " + _HOME_MAC + "alice/secret.json", "home_path_hits"), ("linux_home_path", "bad " + _HOME_LINUX + "bob/file.txt", "home_path_hits"), ("usd_currency", "cost $" + "50000 estimate", "currency_hits"), ("vendor_token", "model " + _VENDOR_TOKENS[0] + " score", "vendor_token_hits"), ("coord_row", "AT" + "OM 1 N ALA A 1 1.000 2.000 3.000", "coordinate_row_hits"), ] out: dict[str, bool] = {} for pname, ptext, key in probes: c = scan_public_hygiene_text(ptext) _require(c[key] > 0, f"Hygiene negative probe {pname} failed to trigger {key}: {c}") out[pname] = True url_ok = scan_public_hygiene_text("https://www.ncbi.nlm.nih.gov/" + "home/about/policies/") _require(url_ok["home_path_hits"] == 0, f"URL control false-triggered: {url_ok}") out["url_positive_control"] = True return out # ============================================================================= # 2. EMBEDDED RCSB CC0-1.0 COORDINATE SUBSET (7P6S, 7P6T, 1PT6, 1QC5, ALL 10 2M32 MODELS) # Plain float triples from public CC0-1.0 PDB depositions; zero PDB row strings. # ============================================================================= EMBEDDED_RCSB_CC0_CRYSTAL_SUBSET_SHA256 = "9b48627e1995baeb9ab2813341f24a569601d215ce90199a9822cbba675ea520" EMBEDDED_RCSB_CC0_CRYSTAL_SUBSET_JSON = r"""{ "source_rcsb_cc0_sha256": {"7P6S":"97054f64f25e0329ac1ad50eb0dbb2678e8a229d1131c97882b79b81eb573ae6","7P6T":"bf4529c4c3721878b515ce8724fdba20a50d36585d879dfbd630fda41fb1e77c","1PT6":"d94733c194cf9b793274838517b7c7e67f3581b1e7db48d6e99848f73a7d6989","1QC5":"b4bfec14a8b6201ad65eb0dc706cee29704273637b2fe5cf743329e5f53940c2","2M32":"2ba0231fb278470994910f0b503d838d947e521a5ebd2bc89984a3675d7129d5"}, "gp2_7p6s": {"ss_sg":{"48":[9.414,-9.246,16.575],"59":[8.485,-10.991,17.076],"63":[13.982,-13.506,3.853],"85":[6.849,10.687,-3.266],"107":[23.766,9.904,-7.36],"113":[15.296,5.201,-10.851],"138":[22.461,8.711,0.547],"145":[25.08,11.312,-6.691],"146":[22.166,10.599,1.231],"157":[14.348,-12.692,2.012],"172":[5.948,12.352,-2.428],"177":[15.781,5.028,-8.891]},"deposited_nag_sites_linked_asn":{"201":65,"202":122},"deposited_nag_atoms":{"201":[[3.09,-9.003,7.335],[2.259,-9.505,8.512],[1.282,-8.426,8.968],[2.015,-7.121,9.245],[2.849,-6.718,8.035],[3.702,-5.498,8.288],[1.933,-11.944,8.534],[1.07,-13.08,8.067],[1.544,-10.72,8.156],[0.615,-8.871,10.144],[1.079,-6.086,9.526],[3.746,-7.785,7.694],[4.531,-5.203,7.173],[2.935,-12.127,9.218]],"202":[[27.592,6.289,1.226],[28.717,5.367,1.693],[29.968,6.193,1.999],[30.337,7.075,0.814],[29.14,7.886,0.328],[29.413,8.6,-0.976],[28.15,3.267,2.839],[27.751,2.639,4.136],[28.322,4.595,2.861],[31.052,5.319,2.298],[31.358,7.99,1.203],[28.02,7.021,0.087],[29.77,7.688,-2.007],[28.302,2.608,1.816]]},"asn_sequon_atoms":{"65":[[6.741,-12.635,4.003],[5.628,-11.713,4.184],[6.009,-10.338,3.654],[6.334,-9.42,4.426],[5.193,-11.644,5.649],[4.058,-10.681,5.86],[3.164,-10.574,5.02],[4.088,-9.972,6.978]],"88":[[3.582,6.261,-0.196],[2.636,5.369,0.464],[3.241,4.039,0.887],[2.527,3.21,1.458],[1.436,5.102,-0.447],[0.531,6.303,-0.578],[0.123,6.668,-1.678],[0.222,6.928,0.545]],"122":[[22.776,3.509,-0.106],[24.096,3.959,0.352],[24.693,2.91,1.289],[24.934,3.143,2.473],[23.908,5.308,1.04],[25.21,5.979,1.488],[25.165,6.813,2.392],[26.348,5.649,0.864]],"134":[[20.303,-2.635,8.737],[19.779,-1.281,8.614],[20.722,-0.44,7.761],[21.943,-0.47,7.953],[19.558,-0.641,9.985],[20.839,-0.452,10.752],[21.808,-1.18,10.546],[20.863,0.547,11.63]]},"ep_atoms":{"49":[[5.464,-6.838,15.711],[4.389,-5.875,15.76],[4.759,-4.628,16.541],[5.836,-4.5,17.127]],"50":[[3.82,-3.69,16.553],[4.084,-2.375,17.116],[4.461,-2.497,18.588],[3.724,-3.125,19.362],[2.839,-1.497,16.974]],"51":[[5.587,-1.921,19.015],[5.912,-1.928,20.446],[4.801,-1.288,21.262],[4.088,-0.397,20.794],[7.202,-1.101,20.522],[7.815,-1.247,19.174],[6.663,-1.307,18.212]],"52":[[4.656,-1.761,22.498],[3.65,-1.228,23.393],[2.231,-1.637,23.087],[1.301,-1.074,23.671]],"53":[[2.028,-2.596,22.192],[0.708,-3.077,21.828],[0.642,-4.584,22.033],[1.679,-5.25,22.15],[0.392,-2.76,20.359],[1.118,-3.656,19.506],[0.765,-1.319,20.025]],"54":[[-0.564,-5.156,22.094],[-0.684,-6.61,22.271],[-0.178,-7.426,21.093],[-0.214,-8.659,21.163],[-2.195,-6.82,22.473],[-2.716,-5.494,22.908],[-1.87,-4.48,22.196]],"55":[[0.279,-6.792,20.015],[0.907,-7.5,18.909],[2.426,-7.414,18.95],[3.088,-7.921,18.04],[0.401,-6.952,17.57],[-0.857,-7.635,17.044],[-1.959,-7.727,18.084],[-2.314,-6.68,18.666],[-2.476,-8.843,18.314]],"56":[[2.992,-6.791,19.987],[4.431,-6.563,20.027],[5.222,-7.862,20.045],[6.398,-7.867,19.666],[4.785,-5.717,21.25]],"57":[[4.611,-8.96,20.48],[5.281,-10.25,20.493],[5.077,-11.032,19.205],[5.673,-12.102,19.049],[4.76,-11.093,21.66],[3.366,-11.598,21.456],[2.273,-10.762,21.394],[2.89,-12.854,21.283],[1.181,-11.481,21.203],[1.528,-12.754,21.132]],"70":[[6.265,-5.727,-9.437],[6.811,-5.965,-10.77],[6.517,-4.686,-11.546],[5.497,-4.578,-12.232],[6.167,-7.193,-11.412],[6.782,-7.547,-12.753],[7.525,-6.722,-13.321],[6.527,-8.67,-13.241]],"72":[[8.52,-2.323,-13.967],[9.71,-1.983,-14.761],[10.019,-0.499,-14.79],[11.181,-0.13,-15.007],[9.366,-2.525,-16.156],[8.424,-3.664,-15.886],[7.621,-3.256,-14.677]],"76":[[16.593,2.115,-13.101],[17.524,3.234,-13.142],[17.807,3.694,-14.566],[18.319,4.803,-14.758],[18.853,2.834,-12.49],[19.372,1.665,-13.142],[18.672,2.544,-11.008]],"77":[[17.505,2.87,-15.564],[17.719,3.237,-16.955],[16.492,3.86,-17.609],[16.592,4.336,-18.744],[18.154,2.008,-17.76],[19.524,1.491,-17.371],[20.642,2.27,-18.03],[20.824,2.142,-19.261],[21.331,3.02,-17.313]],"78":[[15.351,3.876,-16.927],[14.116,4.39,-17.499],[14.053,5.898,-17.294],[14.008,6.368,-16.153],[12.907,3.746,-16.83],[11.607,4.399,-17.243],[11.456,4.816,-18.386],[10.673,4.515,-16.309]],"79":[[14.018,6.65,-18.394],[13.944,8.105,-18.344],[12.556,8.65,-18.666],[12.399,9.868,-18.805],[14.969,8.71,-19.306],[14.678,8.35,-20.648]],"80":[[11.545,7.796,-18.772],[10.225,8.223,-19.205],[9.237,8.213,-18.042],[9.609,8.021,-16.877],[9.738,7.327,-20.349]],"81":[[7.969,8.431,-18.366],[6.882,8.266,-17.417],[6.564,9.537,-16.658],[7.412,10.403,-16.442]],"82":[[5.303,9.648,-16.248],[4.886,10.741,-15.381],[5.436,10.491,-13.984],[5.105,9.481,-13.353],[3.363,10.824,-15.344],[2.933,11.948,-14.595]],"96":[[10.675,-7.533,-8.58],[10.921,-8.519,-9.622],[10.618,-7.894,-10.979],[10.031,-6.814,-11.078],[10.101,-9.816,-9.415],[10.453,-10.468,-8.073],[8.601,-9.538,-9.502]],"97":[[11.044,-8.579,-12.031],[10.683,-8.201,-13.382],[11.799,-7.501,-14.13],[12.959,-7.454,-13.711]],"98":[[11.412,-6.932,-15.273],[12.382,-6.364,-16.201],[13.123,-5.168,-15.621],[14.232,-4.865,-16.073],[11.674,-5.954,-17.496],[11.051,-7.111,-18.267],[11.983,-8.301,-18.39],[13.144,-8.106,-18.809],[11.559,-9.431,-18.064]],"109":[[21.1,8.82,-11.896],[20.875,10.129,-12.496],[19.458,10.612,-12.204],[18.518,9.821,-12.097],[21.087,10.052,-14.006],[21.081,11.407,-14.69],[22.068,12.377,-14.065],[21.704,13.193,-13.215],[23.326,12.292,-14.483]],"127":[[24.481,-10.702,2.774],[24.453,-12.09,2.347],[23.444,-12.869,3.189],[23.088,-12.476,4.302],[25.846,-12.706,2.501]],"128":[[22.992,-13.996,2.643],[22.053,-14.846,3.364],[22.702,-15.36,4.642],[23.778,-15.966,4.603],[21.623,-16.008,2.475],[20.647,-16.999,3.107],[19.363,-16.314,3.541],[20.334,-18.128,2.145]],"129":[[22.056,-15.095,5.773],[22.6,-15.383,7.083],[22.995,-14.154,7.87],[23.228,-14.263,9.082]],"142":[[19.685,18.049,-7.301],[20.412,19.317,-7.227],[21.902,19.109,-6.968],[22.48,19.683,-6.043],[19.807,20.222,-6.153],[20.104,21.588,-6.405]],"143":[[22.526,18.271,-7.792],[23.963,18.079,-7.71],[24.442,17.365,-6.466],[25.635,17.422,-6.145]],"144":[[23.545,16.674,-5.765],[23.819,16.124,-4.44],[23.229,14.722,-4.428],[22.004,14.567,-4.432],[23.175,17.011,-3.373],[23.458,16.551,-1.957],[23.729,15.377,-1.706],[23.365,17.481,-1.012]],"158":[[16.339,-16.996,1.616],[16.499,-18.275,0.915],[15.862,-18.212,-0.461],[14.747,-17.714,-0.628],[15.78,-19.273,1.828],[15.84,-18.665,3.179],[15.737,-17.176,2.951]],"159":[[16.581,-18.715,-1.456],[16.151,-18.629,-2.832],[16.822,-17.539,-3.636],[16.495,-17.374,-4.817]],"160":[[17.747,-16.792,-3.037],[18.545,-15.85,-3.789],[17.901,-14.515,-4.079],[18.194,-13.916,-5.116]],"171":[[10.297,13.079,1.013],[9.847,14.169,0.153],[9.223,13.517,-1.075],[9.248,12.293,-1.227],[11.035,15.081,-0.175],[10.698,16.416,-0.763],[10.784,16.774,-2.072],[10.211,17.568,-0.061],[10.388,18.082,-2.232],[10.039,18.591,-1.01],[9.917,17.836,1.279],[9.568,19.86,-0.668],[9.453,19.101,1.62],[9.288,20.094,0.649]]},"ep_bfacs":{"49":26.402,"50":27.686,"51":27.51,"52":23.145,"53":23.437,"54":24.481,"55":35.288,"56":23.196,"57":24.489,"70":17.78,"72":17.026,"76":14.47,"77":24.251,"78":16.784,"79":20.327,"80":29.99,"81":46.985,"82":42.16,"96":12.926,"97":15.95,"98":30.902,"109":19.828,"127":11.566,"128":10.842,"129":13.415,"142":16.82,"143":15.265,"144":11.58,"158":12.339,"159":13.295,"160":14.65,"171":11.63}},