scripts/verify_iip0044_foundry_v1_3_biologics.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0044_foundry_v1_3_biologics.py · SHA-256: 1d6c53a0817f6254…
dec123_canonical = json.dumps(dec123_entry, sort_keys=True, ensure_ascii=False, separators=(",", ":"))
require_cond(protocol_path.is_file(), f"Missing companion protocol doc: {protocol_path.name}")
protocol_text = protocol_path.read_text(encoding="utf-8")
require_cond("IIP-0044" in protocol_text and "DEC-123" in protocol_text, "Companion protocol missing IIP-0044/DEC-123 headers")
# Dynamic side-contract-bound Islet-GUARD eligibility verification & Gate 30-SHIELD-SPR fail-first self-tests
guard_arm_tests = run_islet_guard_arm_restriction_tests(side_contract=side_contract)
shield_spr_tests = run_gate30_shield_spr_decision_table_self_tests()
audit_parity = verify_stage0_tier1_audit_parity(summary, side_contract, dt_obj, protocol_text)
# Cross-verify sequence-derived unmodified average molecular weights directly against side_contract (R15 0039-M1!)
sc_shield_c1 = side_contract["programs_registered"]["Islet_SHIELD"]["component_1"]
sc_shield_c2 = side_contract["programs_registered"]["Islet_SHIELD"]["component_2"]
qf09_mw = leads_check["sequences"]["IsletSHIELD_QF09_pI2"]
t006_mw = leads_check["sequences"]["IsletSHIELD_Comp2_T006"]
require_cond(
abs(float(sc_shield_c1["unmodified_average_mw_kda_exact"]) - qf09_mw["unmodified_average_mw_kda"]) <= 1e-6
and abs(float(sc_shield_c1["mw_kda"]) - qf09_mw["unmodified_average_mw_kda_2dp"]) <= 1e-6,
f"IsletSHIELD_QF09_pI2 side_contract MW mismatch vs sequence-derived elemental mass: "
f"sc=({sc_shield_c1['unmodified_average_mw_kda_exact']}, {sc_shield_c1['mw_kda']}) vs "
f"derived=({qf09_mw['unmodified_average_mw_kda']}, {qf09_mw['unmodified_average_mw_kda_2dp']})",
)
require_cond(
abs(float(sc_shield_c2["unmodified_average_mw_kda_exact"]) - t006_mw["unmodified_average_mw_kda"]) <= 1e-6
and abs(float(sc_shield_c2["mw_kda"]) - t006_mw["unmodified_average_mw_kda_2dp"]) <= 1e-6,
f"IsletSHIELD_Comp2_T006 side_contract MW mismatch vs sequence-derived elemental mass: "
f"sc=({sc_shield_c2['unmodified_average_mw_kda_exact']}, {sc_shield_c2['mw_kda']}) vs "
f"derived=({t006_mw['unmodified_average_mw_kda']}, {t006_mw['unmodified_average_mw_kda_2dp']})",
)
# Cross-verify the 2 locally deposited FASTA byte sizes & digests against the embedded 71-file manifest
t1_map = {e["relpath"]: e for e in summary["source_cleanroom_bundle"]["tier1_source_manifest_71_files"]}
require_cond(
t1_map["fasta/openislet_cleanroom_v1_3_all_leads.fasta"]["bytes"] == leads_check["bytes"]
and t1_map["fasta/openislet_cleanroom_v1_3_all_leads.fasta"]["sha256"] == leads_check["sha256"],
"Deposited all_leads FASTA bytes/SHA-256 mismatch vs embedded 71-file manifest",
)
require_cond(
t1_map["fasta/IsletSHIELD_Comp2_comparators.fasta"]["bytes"] == comp2_check["bytes"]
and t1_map["fasta/IsletSHIELD_Comp2_comparators.fasta"]["sha256"] == comp2_check["sha256"],
"Deposited comp2_comparators FASTA bytes/SHA-256 mismatch vs embedded 71-file manifest",
)
# Pin SHA-256 digests of every checked non-FASTA input in the receipt (B6!)
checked_inputs_sha256: dict[str, dict[str, Any]] = {
"verifier_script": {"filename": SCRIPT_PATH.name, "sha256": sha256_file(SCRIPT_PATH), "bytes": SCRIPT_PATH.stat().st_size},
"side_contract": {"filename": side_contract_path.name, "sha256": sha256_file(side_contract_path), "bytes": side_contract_path.stat().st_size},
"tier1_summary": {"filename": summary_path.name, "sha256": sha256_file(summary_path), "bytes": summary_path.stat().st_size},
"protocol_doc": {"filename": protocol_path.name, "sha256": sha256_file(protocol_path), "bytes": protocol_path.stat().st_size},
"dec123_canonical_json": {"key": "foundry_v1_3_cleanroom_biologics_registration_iip_0044", "sha256": sha256_bytes(dec123_canonical.encode("utf-8")), "bytes": len(dec123_canonical.encode("utf-8"))},
}
# 3. Gate 30-TOS-QUARANTINE & public hygiene scan across ALL IIP-0044 files, DEC-123, tests, and aligned IIP-0042 files (B5!)
hygiene_results: dict[str, dict[str, int]] = {}
def _scan_file(label: str, path: Path, *, is_summary: bool = False, is_md: bool = False) -> None:
raw = path.read_text(encoding="utf-8")
if is_summary:
raw = strip_verified_tier2_exclusion_manifest(raw, label)
elif is_md:
raw = mask_canonical_layer2_disclaimer_only(raw)
hygiene_results[label] = require_tos_quarantine_clean(raw, label)
_scan_file(SCRIPT_PATH.name, SCRIPT_PATH)
_scan_file(fasta_leads_path.name, fasta_leads_path)
_scan_file(fasta_comp2_path.name, fasta_comp2_path)
_scan_file(side_contract_path.name, side_contract_path)
_scan_file(summary_path.name, summary_path, is_summary=True)
_scan_file(protocol_path.name, protocol_path, is_md=True)
# Scan DEC-123 in BOTH installed AND staging modes!
hygiene_results["DEC-123::stage0_decision_tree_v1.json"] = require_tos_quarantine_clean(
dec123_canonical, "DEC-123::stage0_decision_tree_v1.json"
)
if installed_check and test39_path is not None:
require_cond(test39_path.is_file(), f"Missing IIP-0044 test suite in repo: {test39_path.name}")
_scan_file(test39_path.name, test39_path)
checked_inputs_sha256["iip0044_test_suite"] = {
"filename": test39_path.name,
"sha256": sha256_file(test39_path),
"bytes": test39_path.stat().st_size,
}
if not installed_check:
pmid_rec_p = SCRIPT_DIR / "iip0044_pmid_and_bundle_verification_receipt.json"
if pmid_rec_p.is_file():
_scan_file(pmid_rec_p.name, pmid_rec_p)
for optional_p in (
SCRIPT_DIR.parent / "BRIEF.md",
SCRIPT_DIR.parent / "confirmation-carbon-2026-11-28.md",
SCRIPT_DIR.parents[2] / "candidate-proposals" / "CAND-035-foundry-v1-3-cleanroom-biologics-iip0044-carbon.md",
):
if optional_p.is_file():
_scan_file(optional_p.name, optional_p, is_md=(optional_p.suffix == ".md"))
# 4. Zero-LIMS-Touch invariance & INDEPENDENT IIP-0042 alignment audit (B2 + B5!)
lims_invariance: dict[str, Any]
iip0042_alignment: dict[str, Any]
alignment_self_tests = run_iip0042_alignment_self_tests()
if repo_root is not None:
lims_invariance = verify_zero_lims_touch_invariance(repo_root)
sc37_path = repo_root / "data" / "protocols" / "iip0042_portfolio_and_trackb_side_contract_v0.8.0.json"
doc37_path = repo_root / "docs" / "GATE-30-PORTFOLIO-AND-TRACKB-CONTINGENCY-PROTOCOL.md"
if not (sc37_path.is_file() and doc37_path.is_file()):
raise FileNotFoundError("Missing IIP-0042 side contract or GATE-30 protocol in OpenIslet repo")
# Include aligned IIP-0042 surfaces in Gate 30-TOS-QUARANTINE scan AND input SHA-256 pins!
_scan_file(sc37_path.name, sc37_path)
_scan_file(doc37_path.name, doc37_path, is_md=True)
checked_inputs_sha256["iip0042_side_contract"] = {
"filename": sc37_path.name,
"sha256": sha256_file(sc37_path),
"bytes": sc37_path.stat().st_size,
}
checked_inputs_sha256["iip0042_protocol_doc"] = {
"filename": doc37_path.name,
"sha256": sha256_file(doc37_path),
"bytes": doc37_path.stat().st_size,
}
iip0042_eval = evaluate_iip0042_alignment(
sc37_path.read_text(encoding="utf-8"),
doc37_path.read_text(encoding="utf-8"),
)
if installed_check:
require_cond(
iip0042_eval["aligned"] is True,
f"IIP-0042 independent alignment check FAILED in --installed-check mode; unresolved gaps: {iip0042_eval['gaps']}",
)
iip0042_alignment = {
"mode": "INSTALLED_STRICT_INDEPENDENT_ENFORCED",
"aligned": True,
"independent_surface_enforcement": True,
"checks": iip0042_eval["checks"],
"gaps": [],
"self_tests": alignment_self_tests,
}
else:
iip0042_alignment = {
"mode": "STAGING_PRE_S5_READONLY_AUDIT",
"pre_s5_repo_currently_aligned": iip0042_eval["aligned"],
"pre_s5_alignment_gaps_to_apply_at_s5": iip0042_eval["gaps"],
"pre_s5_checks": iip0042_eval["checks"],
"self_tests": alignment_self_tests,
}
else:
lims_invariance = {
"status": "SKIPPED_NO_REPO_ROOT_PROVIDED_IN_STAGING",
"all_zero_lims_touch_invariants_passed": None,
}
iip0042_alignment = {
"mode": "STAGING_SELF_TEST_ONLY_NO_REPO_ROOT",
"self_tests": alignment_self_tests,
}
hygiene_neg_tests = run_tos_quarantine_negative_self_tests()
receipt = {
"schema_version": "iip0044_foundry_v1_3_biologics_verification_receipt_v0.8.2",
"contribution_id": "IIP-0044",
"decision_id": "DEC-123",
"candidate_id": "CAND-035",
"investigation_id": "EXP-032",
"generated_date": GENERATED_DATE,
"verification_mode": mode_label,
"overall_status": "INSTALLED_CHECK_PASSED" if installed_check else "STAGING_VERIFICATION_PASSED",
"live_odds_credit_pp": 0.0,
"zero_wetlab_contract_import": True,
"zero_assert_runtime": True,
"portable_receipt_no_interpreter_version_coupling": True,
"local_vs_upstream_verification_scope": {
"locally_verified_in_public_snapshot": [
"Deposited CC-BY-4.0 FASTAs on disk (12 sequences, exact byte sizes, exact SHA-256, motif/developability recomputation, sequence-derived IUPAC elemental average molecular weights [IsletSHIELD_QF09_pI2 6.76672 / 6.77 kDa; IsletSHIELD_Comp2_T006 6.49247 / 6.49 kDa] reconciled directly against side contract, UniProt P07204[363..480] M406L diff)",
"Pinned IIP-0044 side-contract enforcement across all three validate_islet_guard_eligibility call modes (None -> frozen in-code policy; Path -> raw file SHA-256 + canonical JSON SHA-256 + policy parity; dict -> canonical JSON SHA-256 + policy parity), plus local JSON, companion protocol, DEC-123 canonical JSON, test suite, aligned IIP-0042 file digests, and 0-byte frozen LIMS & Playbook §4.1.20 invariance",
"Internal consistency of embedded 71+5 manifest (strict positive integer byte sizes, valid SPDX labels, and deterministic 76-line SHA256SUMS.txt reconstruction aa3b25f4...)",
"Locally recomputed verdicts from structured deposited measurements for 6/10 Comp1 gates (Protenix iPTM, peptide share, DQ2.5/DQ8-trans seed convergence, off-target ceiling, celiac threshold FAIL derived from disclosed cel_glutenin_L1=0.823 > 0.25 [5/6 full-panel pass count upstream-reported], 10 ns MD), 11/11 Comp2 gates (including 14 unique off-target peptides, OpenFold3 min/max shifts, model-specific heterodimer thresholds OpenFold3 <= 0.25 & Boltz-2 MIT <= 0.20, and 10 ns MD), and GUARD 10 ns MD RMSD verdict (5.487 A > 3.0 A; 0.94-1.02 A 1DX5 geometry and 0 Ca2+ setup upstream-reported), explicitly distinguishing the 4/10 Comp1 gates and GUARD bimodal audit tagged UPSTREAM_REPORTED_PROVENANCE_ONLY",