@@ -104,6 +104,21 @@ def _fixture_snapshot(lock_payload: dict[str, object]) -> dict[str, object]:
104104 }
105105
106106
107+ def _fixture_manifest (run_id : str , artifact_name : str , lock_bytes : bytes , snapshot_bytes : bytes ) -> dict [str , object ]:
108+ return {
109+ "bundle_version" : BUNDLE_VERSION ,
110+ "artifact_name" : artifact_name ,
111+ "source_run_id" : run_id ,
112+ "source_attempt" : 1 ,
113+ "lock_version" : LOCK_VERSION ,
114+ "snapshot_version" : SNAPSHOT_VERSION ,
115+ "files" : [
116+ {"name" : "input_snapshot.json" , "sha256" : _sha256 (snapshot_bytes )},
117+ {"name" : "period_lock.json" , "sha256" : _sha256 (lock_bytes )},
118+ ],
119+ }
120+
121+
107122def _assert_empty_output_dir (output_dir : Path ) -> None :
108123 if output_dir .is_symlink () or not output_dir .is_dir ():
109124 raise ValueError ("period_lock_output_dir_invalid" )
@@ -126,18 +141,7 @@ def build_bundle(output_dir: Path, run_id: str, artifact_name: str | None = None
126141 lock_bytes = serialize_period_lock (lock )
127142 snapshot = _fixture_snapshot (lock_payload )
128143 snapshot_bytes = _canonical_json (snapshot , "period_lock_snapshot_invalid" )
129- manifest = {
130- "bundle_version" : BUNDLE_VERSION ,
131- "artifact_name" : expected_name ,
132- "source_run_id" : run_id ,
133- "source_attempt" : 1 ,
134- "lock_version" : LOCK_VERSION ,
135- "snapshot_version" : SNAPSHOT_VERSION ,
136- "files" : [
137- {"name" : "input_snapshot.json" , "sha256" : _sha256 (snapshot_bytes )},
138- {"name" : "period_lock.json" , "sha256" : _sha256 (lock_bytes )},
139- ],
140- }
144+ manifest = _fixture_manifest (run_id , expected_name , lock_bytes , snapshot_bytes )
141145 manifest_bytes = _canonical_json (manifest , "period_lock_manifest_invalid" )
142146 payloads = {
143147 "period_lock.json" : lock_bytes ,
@@ -189,6 +193,12 @@ def verify_bundle(output_dir: Path, expected_run_id: str, expected_artifact: str
189193 expected_snapshot = _fixture_snapshot (_fixture_lock_payload (expected_run_id ))
190194 if snapshot != expected_snapshot :
191195 raise ValueError ("period_lock_snapshot_mismatch" )
196+ expected_manifest_bytes = _canonical_json (
197+ _fixture_manifest (expected_run_id , expected_artifact , payloads ["period_lock.json" ], payloads ["input_snapshot.json" ]),
198+ "period_lock_manifest_invalid" ,
199+ )
200+ if payloads ["bundle_manifest.json" ] != expected_manifest_bytes :
201+ raise ValueError ("period_lock_manifest_mismatch" )
192202 manifest = _parse_canonical_json (payloads ["bundle_manifest.json" ], "period_lock_manifest_invalid" )
193203 if set (manifest ) != {"bundle_version" , "artifact_name" , "source_run_id" , "source_attempt" , "lock_version" , "snapshot_version" , "files" }:
194204 raise ValueError ("period_lock_manifest_invalid" )
0 commit comments