OpenIslet

scripts/verify_iip0033_bilayer_and_resp1.py

Deterministic Stage-0 Physics, Multi-Mesh 3D FVM & Respirometry Verifier (IIP-0033 / DEC-112)

script Release v0.8.0 gen-eb955f8266035aba 78 KB · 7 sections

Use this file in any AI chat (paste-only or attachment-capable):

Download as text (.txt) Download section (.txt)

Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0033_bilayer_and_resp1.py · SHA-256: 45f1396930f3a6af…

    assert computed_delta_pp == 0.0
    return {
        "live_locked_pct": round(100.0 * lck, 6),
        "live_modular_pct": round(100.0 * mod, 6),
        "live_shared_ceiling_pct": round(100.0 * ceil, 6),
        "evaluated_stacks_checked": len(combos_post),
        "pre_iip0033_studies_count": len(studies_pre),
        "post_iip0033_studies_count": len(studies_all),
        "mutated_stacks_vs_pre_iip0033": mutated_vs_pre,
        "mutated_stacks_vs_committed_pareto": mutated_vs_committed,
        "max_abs_composite_score_delta": round(max_abs_score_delta, 12),
        "max_abs_committed_rounded_delta": round(max_abs_committed_delta, 12),
        "iip0033_live_headline_delta_pp": computed_delta_pp,
    }


def build_verification_artifact(*, fast: bool = False) -> Dict[str, Any]:
    meshes = [(40, 28, 32, 78)] if fast else [(40, 28, 32, 78), (60, 42, 48, 78), (80, 56, 64, 78)]
    return {
        "schema_version": "openislet_iip0033_bilayer_respirometry_verification_v0.8.0",
        "contribution_id": "IIP-0033",
        "decision_id": "DEC-112",
        "mesh_schedule": [list(m) for m in meshes],
        "respirometry_contract": verify_respirometry_contract(),
        "type7_finite_sample_cubic_mean_bounds": verify_type7_finite_sample_cubic_mean_bounds(),
        "fixed_pitch_bilayer_and_holds": verify_fixed_pitch_bilayer_and_holds(meshes),
        "gy028_cylindrical_trap_anchors": verify_cylindrical_traps(),
        "oq016_live_baseline_parity": verify_live_oq016_baseline(),
        "overall_status": "ALL_IIP0033_PHYSICS_AND_RESPIROMETRY_ASSERTIONS_PASSED",
    }


def main() -> None:
    parser = argparse.ArgumentParser(description="Deterministic IIP-0033 3-mesh bilayer, respirometry & GY-028 verifier.")
    parser.add_argument("--write", action="store_true", help=f"Write verified artifact to {DEFAULT_OUT_PATH}")
    parser.add_argument("--check", action="store_true", help=f"Verify exact match against {DEFAULT_OUT_PATH}")
    parser.add_argument("--fast", action="store_true", help="Run single nx=40 mesh only (smoke check)")
    parser.add_argument("--out", type=Path, default=DEFAULT_OUT_PATH, help="Output JSON path")
    args = parser.parse_args()

    payload = build_verification_artifact(fast=args.fast)
    serialized = json.dumps(payload, indent=2, ensure_ascii=False, allow_nan=False) + "\n"
    digest = hashlib.sha256(serialized.encode("utf-8")).hexdigest()

    if args.write:
        args.out.parent.mkdir(parents=True, exist_ok=True)
        args.out.write_text(serialized, encoding="utf-8")
        print(f"Wrote {args.out} (SHA-256: {digest}) — ALL ASSERTIONS PASSED.")
    elif args.check:
        if not args.out.is_file():
            raise SystemExit(f"Missing verification artifact: {args.out}")
        existing = args.out.read_text(encoding="utf-8")
        if existing != serialized:
            raise SystemExit(f"Artifact drift detected vs {args.out} (computed SHA-256: {digest})")
        print(f"Verified exact match against {args.out} (SHA-256: {digest}) — PASS.")
    else:
        print(f"IIP-0033 deterministic replay passed (SHA-256: {digest}; meshes={payload['mesh_schedule']}).")


if __name__ == "__main__":
    main()