3434)
3535
3636RELEASE_HANDOFF_MANIFEST_NAME = "RELEASE_HANDOFF_MANIFEST.json"
37- HANDOFF_FOR_PF_NAME = "handoff_for_pf.json"
37+ HANDOFF_TO_PF_NAME = "handoff_to_pf.json"
38+ HANDOFF_FOR_PF_NAME = HANDOFF_TO_PF_NAME # deprecated alias
3839RELEASE_FIXTURE_MANIFEST_NAME = "RELEASE_FIXTURE_MANIFEST.json"
3940LEGACY_MANIFEST_NAME = "manifest.json"
4041
@@ -196,16 +197,19 @@ def build_handoff_manifest(
196197 return manifest
197198
198199
199- def build_handoff_for_pf (run_dir : Path ) -> dict [str , Any ]:
200- certified = _load_json (run_dir / "science_claim_bundle.certified.json" )
201- _ , certificate_id , trace_hash = certified_bundle_ids (certified )
202- return {
203- "schema_version" : "v0" ,
204- "certified_bundle" : "science_claim_bundle.certified.json" ,
205- "expected_certificate_id" : certificate_id ,
206- "expected_trace_hash" : trace_hash ,
207- "expected_bundle_id" : certified ["bundle_id" ],
208- }
200+ def build_handoff_for_pf (
201+ run_dir : Path ,
202+ * ,
203+ source_commit : str | None = None ,
204+ ) -> dict [str , Any ]:
205+ """Build HandoffManifest.v0 for PF signing (legacy name retained for callers)."""
206+ from labtrust_gym .pcs .handoff_manifest import build_bundle_to_verifier_handoff
207+
208+ return build_bundle_to_verifier_handoff (
209+ run_dir / "science_claim_bundle.certified.json" ,
210+ release_mode = True ,
211+ source_commit = source_commit ,
212+ )
209213
210214
211215def build_release_fixture_manifest (
@@ -248,7 +252,7 @@ def write_run_manifests(
248252 generator : str ,
249253 handoff_id : str | None = None ,
250254) -> tuple [dict [str , Any ], dict [str , Any ], dict [str , Any ]]:
251- """Write RELEASE_HANDOFF_MANIFEST, handoff_for_pf , and RELEASE_FIXTURE_MANIFEST into run_dir."""
255+ """Write RELEASE_HANDOFF_MANIFEST, HandoffManifest.v0 , and RELEASE_FIXTURE_MANIFEST into run_dir."""
252256 for name in HANDOFF_ARTIFACTS :
253257 if not (run_dir / name ).is_file ():
254258 raise FileNotFoundError (f"release-run missing handoff artifact: { name } " )
@@ -258,7 +262,7 @@ def write_run_manifests(
258262 handoff_manifest = build_handoff_manifest (
259263 run_dir , commits , generator = generator , handoff_id = handoff_id
260264 )
261- handoff_pf = build_handoff_for_pf (run_dir )
265+ handoff_pf = build_handoff_for_pf (run_dir , source_commit = commits [ "labtrust_gym_commit" ] )
262266 fixture_manifest = build_release_fixture_manifest (
263267 run_dir , commits , handoff_manifest , generator = generator
264268 )
@@ -309,16 +313,30 @@ def validate_handoff_directory(handoff_root: Path) -> None:
309313 path = handoff_root / name
310314 if file_content_digest (path ) != expected_digest :
311315 raise ValueError (f"handoff digest mismatch for { name } " )
312- pf_guard = handoff_root / HANDOFF_FOR_PF_NAME
313- if not pf_guard .is_file ():
314- raise FileNotFoundError (f"handoff missing: { HANDOFF_FOR_PF_NAME } " )
315- pf_doc = _load_json (pf_guard )
316- certified = _load_json (handoff_root / pf_doc ["certified_bundle" ])
316+ from labtrust_gym .pcs .handoff_manifest import assert_handoff_manifest_valid
317+
318+ handoff_path = handoff_root / HANDOFF_TO_PF_NAME
319+ if not handoff_path .is_file ():
320+ raise FileNotFoundError (f"handoff missing: { HANDOFF_TO_PF_NAME } " )
321+ legacy_guard = handoff_root / "handoff_for_pf.json"
322+ if legacy_guard .is_file () and legacy_guard != handoff_path :
323+ raise ValueError (
324+ "handoff/ must not contain legacy handoff_for_pf.json; use handoff_to_pf.json"
325+ )
326+ pf_doc = _load_json (handoff_path )
327+ assert_handoff_manifest_valid (pf_doc )
328+ certified_name = "science_claim_bundle.certified.json"
329+ certified = _load_json (handoff_root / certified_name )
317330 _ , cert_id , trace_hash = certified_bundle_ids (certified )
318- if pf_doc ["expected_certificate_id" ] != cert_id :
319- raise ValueError ("handoff_for_pf.expected_certificate_id mismatch" )
320- if pf_doc ["expected_trace_hash" ] != trace_hash :
321- raise ValueError ("handoff_for_pf.expected_trace_hash mismatch" )
331+ inv = pf_doc .get ("invariants" ) or {}
332+ if inv .get ("certificate_id" ) != cert_id :
333+ raise ValueError ("handoff_to_pf invariants.certificate_id mismatch" )
334+ if inv .get ("trace_hash" ) != trace_hash :
335+ raise ValueError ("handoff_to_pf invariants.trace_hash mismatch" )
336+ entry = (pf_doc .get ("input_artifacts" ) or {}).get (certified_name ) or {}
337+ on_disk = file_content_digest (handoff_root / certified_name )
338+ if entry .get ("sha256" ) != on_disk :
339+ raise ValueError ("handoff_to_pf input_artifacts certified bundle sha256 mismatch" )
322340
323341
324342def promote_release_run_atomic (
0 commit comments