qa_signoff_id=qa_signoff_id, expected_dossier_sha256=expected_dossier_sha256, expected_qa_signoff_sha256=expected_qa_signoff_sha256, expected_canonical_manifest_sha256=eff_exp_msha, release_scope=release_scope, governed_store_root=governed_store_root, canonical_manifest_path=canonical_manifest_path, openislet_root=openislet_root, ) return rec def _add_wave6_physical_receipt_cli_args_v2_round8(parser: argparse.ArgumentParser) -> None: parser.add_argument( "--issue-physical-receipt", action="store_true", help="Resolve separately governed Gate 0V physical dossier, QA sign-off, and QA issuer registry stores on disk and issue a single-key receipt on PASS.", ) parser.add_argument("--governed-store-root", type=Path, default=None, help="Separately governed on-disk Gate 0V store directory") parser.add_argument("--canonical-manifest", type=Path, default=None, help="Governed wave6_canonical_arm_manifest.json path on disk (hashed strictly from bytes)") parser.add_argument("--lookup-request-json", type=Path, default=None, help="Optional JSON file containing caller lookup anchors only") parser.add_argument("--arm-id", type=str, default=None, help="Wave-6 arm ID lookup anchor") parser.add_argument("--lot-id", type=str, default=None, help="Lot ID lookup anchor") parser.add_argument("--bank-id", type=str, default=None, help="Bank / MCB ID lookup anchor") parser.add_argument("--product-id", type=str, default=None, help="Canonical product_variant_id lookup anchor") parser.add_argument("--construct-manifest-sha256", type=str, default=None, help="Construct manifest SHA-256 lookup anchor") parser.add_argument("--dossier-id", type=str, default=None, help="Governed physical dossier ID lookup anchor") parser.add_argument("--qa-signoff-id", type=str, default=None, help="Governed independent QA sign-off ID lookup anchor") parser.add_argument("--expected-dossier-sha256", type=str, default=None, help="Optional expected physical dossier archive SHA-256") parser.add_argument("--expected-qa-signoff-sha256", type=str, default=None, help="Optional expected QA sign-off archive SHA-256") parser.add_argument("--expected-canonical-manifest-sha256", type=str, default=None, help="Optional caller assertion anchor checked against governed manifest bytes") parser.add_argument("--release-scope", type=str, default=None, help="Optional caller requested release scope (CLINICAL_LOT_RELEASE or BANK_QUALIFICATION_ONLY)") parser.add_argument("--issued-receipt-out", type=Path, default=None, help="Optional path to also write the emitted receipt JSON") def _run_wave6_physical_receipt_cli_v2_round8(args: argparse.Namespace, *, openislet_root: Path) -> int: lookup_req: Any = None if args.lookup_request_json is not None: loaded_req, req_err = _safe_load_governed_json_v2_round8(args.lookup_request_json) if req_err is not None: _tctx_cli, _ = _load_and_verify_owner_trust_config_v2_round9(_resolve_openislet_root(openislet_root)) rec = _finalize_gate0v_cli_receipt( _make_fail_closed_gate0v_custody_receipt_v2_round7( decision="FAIL_MALFORMED_ARCHIVED_MEASUREMENT", authority_scope="REJECTED_MALFORMED_ARCHIVED_MEASUREMENT", evidence_tier="UNAUTHENTICATED_FAIL", record_prefix="G0V-MALFORMED-FAIL", product_id=_safe_str_v2_round8(args.product_id), lot_id=_safe_str_v2_round8(args.lot_id), bank_id=_safe_str_v2_round8(args.bank_id), bank_origin="", manifest_sha="", construct_manifest_sha256=_safe_str_v2_round8(args.construct_manifest_sha256), dossier_id=_safe_str_v2_round8(args.dossier_id) or None, qa_signoff_id=_safe_str_v2_round8(args.qa_signoff_id) or None, custody_failure_reasons=[f"LOOKUP_REQUEST_JSON_LOAD_ERROR:{req_err}"], ), is_synthetic_plumbing=_is_synthetic_plumbing_installation_v2_round13(_tctx_cli), ) serialized = json.dumps(rec, indent=2, sort_keys=True, ensure_ascii=False, allow_nan=False) if args.issued_receipt_out is not None: args.issued_receipt_out.parent.mkdir(parents=True, exist_ok=True) args.issued_receipt_out.write_text(serialized + "\n", encoding="utf-8") print(serialized) return 3 lookup_req = loaded_req rec, rc = issue_gate0v_physical_receipt_from_governed_root( lookup_req, arm_id=args.arm_id, lot_id=args.lot_id, bank_id=args.bank_id, product_id=args.product_id, construct_manifest_sha256=args.construct_manifest_sha256, dossier_id=args.dossier_id, qa_signoff_id=args.qa_signoff_id, expected_dossier_sha256=args.expected_dossier_sha256, expected_qa_signoff_sha256=args.expected_qa_signoff_sha256, expected_canonical_manifest_sha256=args.expected_canonical_manifest_sha256, release_scope=args.release_scope, governed_store_root=args.governed_store_root, canonical_manifest_path=args.canonical_manifest, openislet_root=openislet_root, ) serialized = json.dumps(rec, indent=2, sort_keys=True, ensure_ascii=False, allow_nan=False) if args.issued_receipt_out is not None: args.issued_receipt_out.parent.mkdir(parents=True, exist_ok=True) args.issued_receipt_out.write_text(serialized + "\n", encoding="utf-8") print(serialized) return rc def main() -> int: parser = argparse.ArgumentParser( description="EXP-031 Round-02 Executable Dual-Evaluator Composite Release Wrapper (legacy wetlab_contract.py AND whole-graft Gate 0V)" ) parser.add_argument("--repo-root", type=Path, default=None, help="Path to OpenIslet science repository (read-only)") parser.add_argument("--lot-json", type=Path, default=None, help="Composite measured-lot JSON bundle to evaluate") parser.add_argument( "--trusted-qualification-store", type=Path, default=None, help=( "Independent external trusted qualification store (registry JSON or directory) required for " "LOT_RELEASE_SURROGATE and AUTOLOGOUS_D1B_PROCESS_QUAL; deployment prerequisite: independent " "QA operator administration and write-restricted storage control." ), ) parser.add_argument( "--nw08-ocr-json", type=Path, default=None, help=( "Optional lot-bound measured-OCR NW-08 record JSON file. In coupled composite release mode, " "MUST bind cryptographically to the current composite lot (`lot_id`, `mcb_id`, canonical " "`product_variant_id`, lot-declared `nw08_route_id`, current `lot_payload_sha256`, " "`measurement_record_id`, `measurement_evidence_sha256`, UTC `measurement_timestamp_utc`, " "and canonical `ocr_record_sha256`, plus external `--trusted-qualification-store` " "`nw08_ocr_records` verification when active) before gating composite release on live 3D FVM " "dispatch_and_solve_nw08_measured_ocr (PASS -> exit 0, FAIL -> exit 3, unbound/stale/mismatched/" "ambiguous JSON -> structured HOLD exit 2). Standalone unbound diagnostic CLI: " "scripts/verify_iip0043_wholegraft_gate0v_and_calibration.py --dispatch-nw08-ocr ." ), ) parser.add_argument("--self-test", action="store_true", help="Run differential unit test suite against live read-only wetlab_contract.py") parser.add_argument("--out", type=Path, default=DEFAULT_RECEIPT_PATH, help="Output receipt JSON path for --self-test") _add_wave6_physical_receipt_cli_args_v2_round8(parser) args = parser.parse_args() openislet_root = _resolve_openislet_root(args.repo_root) if getattr(args, "issue_physical_receipt", False): return _run_wave6_physical_receipt_cli_v2_round8(args, openislet_root=openislet_root) if args.lot_json is not None: wc_path = openislet_root / "scripts" / "wetlab_contract.py" v38_path = _resolve_gate0v_verifier_path() try: leg_fn = _load_module("openislet_wetlab_contract_ro", wc_path).evaluate_stage0_decision_tree if wc_path.is_file() else None except Exception: leg_fn = None try: g0v_fn = _get_v38_module().evaluate_wholegraft_gate0v_and_stress_ap1903 if v38_path.is_file() else None except Exception: g0v_fn = None res, rc = evaluate_composite_lot_file( args.lot_json, legacy_evaluator=leg_fn, gate0v_evaluator=g0v_fn, trusted_qualification_store=args.trusted_qualification_store, openislet_root=openislet_root, nw08_ocr_json_path=args.nw08_ocr_json, ) print(json.dumps(res, indent=2, sort_keys=True, allow_nan=False)) return rc # Default or --self-test: execute differential suite & write receipt receipt = run_differential_self_test(openislet_root) args.out.parent.mkdir(parents=True, exist_ok=True) args.out.write_text(json.dumps(receipt, indent=2) + "\n", encoding="utf-8") print( f"Composite release self-test | passed={receipt['passed_cases']}/{receipt['total_cases']} | " f"legacy_wetlab_untouched={receipt['legacy_wetlab_contract_zero_byte_untouched']} | " f"all_passed={receipt['all_passed']}" ) return 0 if receipt["all_passed"] else 1 if __name__ == "__main__": raise SystemExit(main())