parser.add_argument( "--fail-on-conflict-gt-3sigma", action="store_true", help="Fail closed if any observed endpoint has z_conflict > 3.0", ) args = parser.parse_args() if args.input_json and args.dry_run_calibration: raise ValueError("Cannot specify both --input-json and --dry-run-calibration/--synthetic-dry-run simultaneously.") if not args.input_json and not args.dry_run_calibration: raise ValueError("Must specify either --input-json or --dry-run-calibration (--synthetic-dry-run).") prior_report = None prior_path = None prior_raw = None if args.prior_posterior_json: prior_path = _validate_safe_cli_path(args.prior_posterior_json, "prior_posterior_json") prior_report, prior_raw = _read_safe_json_file(prior_path) if args.input_json: in_path = _validate_safe_cli_path(args.input_json, "input_json") payload, _input_raw = _read_safe_json_file(in_path) is_dry = False else: payload = { "batch_id": "DRY-RUN-CALIBRATION-001", "obs_stage7_yield_ratio": 0.982, "obs_stage7_yield_se": 0.018, "obs_cd47_fold": 7.95, "obs_cd47_fold_se": 0.35, "obs_serpinb9_log10_kass": 6.21, "obs_serpinb9_log10_kass_se": 0.09, "obs_icasp9_log10_kill": 4.48, "obs_icasp9_log10_kill_se": 0.11, } is_dry = True expected_snapshots = {} if not args.no_write: out_path = _validate_safe_cli_path(args.output, "output") targets = [out_path] + ([LEGACY_ALIAS_PATH.resolve()] if out_path == DEFAULT_OUT.resolve() else []) for target in targets: # Preserve the exact state actually used for an in-place update, # including a race occurring between the input and output reads. expected_snapshots[target] = prior_raw if target == prior_path else _existing_json_bytes(target) report = run_calibration( payload, is_dry_run=is_dry, prior_posterior_report=prior_report, fail_on_conflict_gt_3sigma=args.fail_on_conflict_gt_3sigma, ) if args.no_write: print(f"[Wet-Lab Ingestor v0.8.0] Verified in-memory (--no-write, mode={report['calibration_mode']})") return _publish_calibration_report(out_path, report, expected_snapshots, force_overwrite_empirical=args.force_overwrite_empirical) print(f"[Wet-Lab Ingestor v0.8.0] Wrote {out_path} (mode={report['calibration_mode']})") if __name__ == "__main__": main()