| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566 |
- #!/usr/bin/env python3
- """Minimal packager provenance helpers (no packager rewrite).
- Provides:
- - source-closure-relations.json (machine authority = per-file compare)
- - REFERENCE-POINTER.json (compact pointer; raw BRD/PDF stay out of default compact)
- - release_set_id + external release-set JSON (no cyclic ZIP SHA cross-bind)
- """
- from __future__ import annotations
- import hashlib
- import json
- import re
- from datetime import datetime, timezone
- from pathlib import Path
- from typing import Any
- ROOT = Path(__file__).resolve().parents[1]
- # Round-9 door-percent base: locked immutable `dev` tip (not historical jog baseline).
- OLD_BASELINE_DEFAULT = "d4f3df2549efeb1e9227f62d1d71c6179c9f9160"
- BASE_DEV_COMMIT_DEFAULT = OLD_BASELINE_DEFAULT
- ARTIFACT_DEFAULT = "f23d6d4c57959071cd3886ea5503fbe903aee547"
- RELEASE_TASK_SLUG = "door-percent"
- def release_sibling_filename(kind: str, delivery_commit: str) -> str:
- """Canonical sibling names for this task (never altconfig / cross-task slugs)."""
- short = _short(delivery_commit, 8)
- kind_n = kind.strip().casefold()
- if kind_n in {"review-compact", "review", "compact"}:
- return f"prod2u-review-compact-{RELEASE_TASK_SLUG}-{short}.zip"
- if kind_n in {"firmware", "fw"}:
- return f"prod2u-firmware-{RELEASE_TASK_SLUG}-{short}.zip"
- if kind_n in {"review-selftest", "compact-selftest"}:
- return f"prod2u-review-compact-{RELEASE_TASK_SLUG}-{short}.selftest.json"
- if kind_n in {"firmware-selftest", "fw-selftest"}:
- return f"prod2u-firmware-{RELEASE_TASK_SLUG}-{short}.selftest.json"
- if kind_n in {"release-set", "release_set"}:
- return f"prod2u-release-set-{RELEASE_TASK_SLUG}-{short}.json"
- raise ValueError(f"unknown sibling kind: {kind}")
- def assert_no_stale_task_slug(text: str) -> None:
- """Fail when packaging metadata still carries a cross-task stale slug."""
- lowered = text.casefold()
- if "altconfig" in lowered and RELEASE_TASK_SLUG not in lowered:
- raise ValueError(f"stale task slug 'altconfig' in packaging identity: {text}")
- # Standalone raw reference package identity (receipt-backed; ZIP not in default compact).
- REFERENCE_PACKAGE_FILENAME = "prod2u-reference-v1_2-3axis-20260805T171312Z.zip"
- REFERENCE_PACKAGE_SHA256 = (
- "b8a1dd092f453b1b25a4faf4734e8c5a404bfa38752f19fb67cf842d228ec2b1"
- )
- REFERENCE_PACKAGE_SIZE = 4446292
- REFERENCE_CANONICAL_BRD_SHA256 = (
- "269b5bab2f2e1215b9392079a003badc34238ae3cbe8e5094c9a11bba8b84ebb"
- )
- REFERENCE_RECEIPT_REL = "receipts/reference-package-20260805T171312Z.json"
- def _sha256_bytes(data: bytes) -> str:
- return hashlib.sha256(data).hexdigest()
- def _sha256_file(path: Path) -> str:
- digest = hashlib.sha256()
- with path.open("rb") as stream:
- for chunk in iter(lambda: stream.read(1024 * 1024), b""):
- digest.update(chunk)
- return digest.hexdigest()
- def _read_json(path: Path) -> Any:
- return json.loads(path.read_text(encoding="utf-8-sig"))
- def _short(commit: str, n: int = 8) -> str:
- return commit[:n]
- def build_source_closure_relations(
- *,
- old_baseline_commit: str,
- artifact_commit: str,
- delivery_commit: str,
- old_to_artifact_unchanged: bool | None,
- artifact_to_delivery_unchanged: bool | None,
- old_to_artifact_changed_paths: list[str] | None = None,
- artifact_to_delivery_changed_paths: list[str] | None = None,
- comparison_mode: str = "commit_compare",
- ) -> dict[str, Any]:
- """Machine-authoritative dual-edge source-closure relations."""
- old_paths = list(old_to_artifact_changed_paths or [])
- del_paths = list(artifact_to_delivery_changed_paths or [])
- payload = {
- "schema": "prod2u-source-closure-relations-v1",
- "generated_at_utc": datetime.now(timezone.utc).isoformat(),
- "comparison_mode": comparison_mode,
- # Round-9 naming: base_dev → artifact → delivery (never call preview tip final_dev).
- "base_dev_commit": old_baseline_commit,
- "artifact_source_commit": artifact_commit,
- "delivery_commit": delivery_commit,
- "old_baseline_to_artifact": {
- "from_commit": old_baseline_commit,
- "to_commit": artifact_commit,
- "from_short": _short(old_baseline_commit),
- "to_short": _short(artifact_commit),
- "unchanged": old_to_artifact_unchanged,
- "production_changed_paths": old_paths,
- "edge": "base_dev_to_artifact",
- },
- "artifact_to_delivery": {
- "from_commit": artifact_commit,
- "to_commit": delivery_commit,
- "from_short": _short(artifact_commit),
- "to_short": _short(delivery_commit),
- "unchanged": artifact_to_delivery_unchanged,
- "production_changed_paths": del_paths,
- "edge": "artifact_to_delivery",
- },
- # Human-readable aliases (same authority, not a second truth).
- "OLD_TO_NEW_SOURCE_CLOSURE_UNCHANGED": old_to_artifact_unchanged,
- "NEW_ARTIFACT_TO_DELIVERY_SOURCE_CLOSURE_UNCHANGED": artifact_to_delivery_unchanged,
- }
- return payload
- def validate_source_closure_relations(relations: dict[str, Any] | Any) -> dict[str, Any]:
- """Fail-closed consistency checks for dual-edge relations.
- Negatives required by contract:
- - unchanged=false + empty changed_paths + mode=commit_compare → FAIL
- - unchanged=true + non-empty changed_paths → FAIL
- - comparison_mode=commit_compare with unknown booleans → FAIL
- """
- failures: list[str] = []
- if not isinstance(relations, dict):
- return {"status": "fail", "failures": ["relations_not_object"]}
- mode = relations.get("comparison_mode")
- if mode not in {"commit_compare", "snapshot_hash", "comparison_unavailable"}:
- failures.append(f"bad_comparison_mode:{mode}")
- for edge_key in ("old_baseline_to_artifact", "artifact_to_delivery"):
- edge = relations.get(edge_key) or {}
- if not isinstance(edge, dict):
- failures.append(f"{edge_key}_not_object")
- continue
- unchanged = edge.get("unchanged")
- paths = edge.get("production_changed_paths") or []
- if not isinstance(paths, list):
- failures.append(f"{edge_key}_paths_not_list")
- paths = []
- if mode == "commit_compare":
- if unchanged is True and paths:
- failures.append(f"{edge_key}_unchanged_true_with_changed_paths")
- if unchanged is False and not paths:
- failures.append(f"{edge_key}_unchanged_false_empty_paths")
- if unchanged not in (True, False):
- failures.append(f"{edge_key}_unchanged_not_bool_under_commit_compare")
- if mode == "comparison_unavailable":
- if unchanged is not None:
- failures.append(f"{edge_key}_guessed_bool_when_unavailable")
- # Identity presence
- old_edge = relations.get("old_baseline_to_artifact") or {}
- art_edge = relations.get("artifact_to_delivery") or {}
- if not old_edge.get("from_commit") or not old_edge.get("to_commit"):
- failures.append("old_edge_missing_commits")
- if not art_edge.get("from_commit") or not art_edge.get("to_commit"):
- failures.append("art_edge_missing_commits")
- if (
- old_edge.get("to_commit")
- and art_edge.get("from_commit")
- and old_edge.get("to_commit") != art_edge.get("from_commit")
- ):
- failures.append("artifact_identity_mismatch_across_edges")
- return {"status": "fail" if failures else "pass", "failures": failures}
- def load_reference_package_identity(repo_root: Path | None = None) -> dict[str, Any]:
- """Raw reference package identity from canonical receipt (stable; no timestamps)."""
- root = repo_root or ROOT
- receipt_path = root / REFERENCE_RECEIPT_REL
- identity = {
- "filename": REFERENCE_PACKAGE_FILENAME,
- "size": REFERENCE_PACKAGE_SIZE,
- "sha256": REFERENCE_PACKAGE_SHA256,
- "canonical_brd_sha256": REFERENCE_CANONICAL_BRD_SHA256,
- "receipt_path": REFERENCE_RECEIPT_REL,
- }
- if receipt_path.is_file():
- receipt = _read_json(receipt_path)
- zip_sha = receipt.get("zip_sha256")
- zip_bytes = receipt.get("zip_bytes")
- brd_sha = receipt.get("brd_sha256")
- pkg_name = receipt.get("package_name")
- if zip_sha and zip_sha != REFERENCE_PACKAGE_SHA256:
- raise ValueError(
- f"reference receipt zip sha mismatch: {zip_sha} != {REFERENCE_PACKAGE_SHA256}"
- )
- if brd_sha and brd_sha != REFERENCE_CANONICAL_BRD_SHA256:
- raise ValueError(
- f"reference receipt BRD sha mismatch: {brd_sha} != {REFERENCE_CANONICAL_BRD_SHA256}"
- )
- if zip_bytes and int(zip_bytes) != REFERENCE_PACKAGE_SIZE:
- raise ValueError(
- f"reference receipt size mismatch: {zip_bytes} != {REFERENCE_PACKAGE_SIZE}"
- )
- if pkg_name and f"{pkg_name}.zip" != REFERENCE_PACKAGE_FILENAME:
- # Allow receipt package_name without .zip suffix.
- if pkg_name != REFERENCE_PACKAGE_FILENAME.removesuffix(".zip"):
- raise ValueError(f"reference receipt name mismatch: {pkg_name}")
- identity["receipt_status"] = receipt.get("status")
- return identity
- def derived_board_viewer_identity(repo_root: Path | None = None) -> dict[str, Any]:
- """Derived board-viewer evidence identity (separate from raw reference package)."""
- root = repo_root or ROOT
- generated = root / "tools" / "board-viewer" / "generated"
- names = (
- "board-data.json",
- "build-info.json",
- "import-report.json",
- "board-copper.svg",
- "board-silkscreen.svg",
- "board-mask-edge.svg",
- "board-copper-back.svg",
- "board-silkscreen-back.svg",
- "board-mask-edge-back.svg",
- )
- assets: dict[str, str | None] = {}
- for name in names:
- path = generated / name
- assets[name] = _sha256_file(path) if path.is_file() else None
- build_info = _read_json(generated / "build-info.json") if (generated / "build-info.json").is_file() else {}
- input_brd = None
- sources = build_info.get("sources") if isinstance(build_info, dict) else None
- if isinstance(sources, dict):
- brd = sources.get("brd")
- if isinstance(brd, dict):
- input_brd = brd.get("sha256")
- # Stable fingerprint MUST NOT include generated_at or absolute paths.
- parts = {
- "assets": assets,
- "board_viewer_generator_version": build_info.get("generator_version"),
- "input_brd_sha256": input_brd,
- }
- fp = _sha256_bytes(json.dumps(parts, sort_keys=True, separators=(",", ":")).encode("utf-8"))
- return {
- "schema": "prod2u-derived-board-viewer-identity-v1",
- "sha256": fp,
- "parts": parts,
- # Informational only — not mixed into raw reference fingerprint.
- "generated_at_informational": build_info.get("generated_at"),
- }
- def stable_reference_inventory_semantics(inventory: dict[str, Any] | None) -> dict[str, Any]:
- """Extract stable semantic fields only (no generated_at / abs paths / file SHA)."""
- inv = inventory if isinstance(inventory, dict) else {}
- boundaries = inv.get("evidence_boundaries") if isinstance(inv.get("evidence_boundaries"), dict) else {}
- v12 = boundaries.get("v1_2_schematic_pdf") if isinstance(boundaries.get("v1_2_schematic_pdf"), dict) else {}
- return {
- "v1_2_schematic_pdf_status": v12.get("status", "unknown"),
- "historical_schematic_side_evidence": boundaries.get(
- "historical_schematic_side_evidence"
- ),
- }
- def reference_set_fingerprint(repo_root: Path | None = None) -> dict[str, Any]:
- """Stable raw reference-set fingerprint v2 (no generated_at / temp paths / inventory SHA)."""
- root = repo_root or ROOT
- inventory_path = root / "docs" / "REFERENCE-INVENTORY.json"
- raw = load_reference_package_identity(root)
- inventory = _read_json(inventory_path) if inventory_path.is_file() else {}
- schematic_identity = stable_reference_inventory_semantics(
- inventory if isinstance(inventory, dict) else {}
- )
- # Normalized inventory content fingerprint (stable fields only; informational).
- inventory_content_fingerprint = _sha256_bytes(
- json.dumps(schematic_identity, sort_keys=True, separators=(",", ":")).encode(
- "utf-8"
- )
- )
- # Raw fingerprint v2: schema + ZIP identity + BRD + stable schematic semantics.
- # Do NOT mix in inventory file SHA / generated_at / repository_root / abs paths.
- content_parts = {
- "fingerprint_schema": "prod2u-reference-set-fingerprint-v2",
- "reference_package_filename": raw["filename"],
- "reference_package_sha256": raw["sha256"],
- "reference_package_size": raw["size"],
- "canonical_brd_sha256": raw["canonical_brd_sha256"],
- "schematic_identity": schematic_identity,
- }
- fp = _sha256_bytes(
- json.dumps(content_parts, sort_keys=True, separators=(",", ":")).encode("utf-8")
- )
- inventory_file_sha = (
- _sha256_file(inventory_path) if inventory_path.is_file() else None
- )
- return {
- "schema": "prod2u-reference-set-fingerprint-v2",
- "sha256": fp,
- "parts": content_parts,
- "inventory_content_fingerprint": inventory_content_fingerprint,
- # Informational only — must not participate in raw fp / release_set_id.
- "inventory_file_sha256_informational": inventory_file_sha,
- "canonical_brd_path": (
- "reference/original/board/FCB_FPGA_MCU_V1.2_20260717/"
- "FCB_FPGA+MCU_V1.2_20260717.brd"
- ),
- "raw_brd_pdf_dsn_in_default_compact": False,
- }
- def build_reference_pointer(
- *,
- artifact_commit: str,
- delivery_commit: str,
- reference_changed: bool = False,
- reference_reused: bool = True,
- repo_root: Path | None = None,
- summary_only: bool = False,
- ) -> dict[str, Any]:
- """Build REFERENCE-POINTER.json (full for review-compact; summary for firmware)."""
- root = repo_root or ROOT
- raw = load_reference_package_identity(root)
- ref_fp = reference_set_fingerprint(root)
- derived = derived_board_viewer_identity(root)
- pointer = {
- "schema": "prod2u-reference-pointer-v1",
- "generated_at_utc": datetime.now(timezone.utc).isoformat(),
- "reference_changed": bool(reference_changed),
- "reference_reused": bool(reference_reused),
- # Raw reference package identity (NOT inventory filename/hash).
- "filename": raw["filename"],
- "size": raw["size"],
- "sha256": raw["sha256"],
- "content_fingerprint": ref_fp["sha256"],
- "brd_sha256": raw["canonical_brd_sha256"],
- "schematic_identity": ref_fp["parts"].get("schematic_identity"),
- "raw_reference_package": {
- "filename": raw["filename"],
- "size": raw["size"],
- "sha256": raw["sha256"],
- "canonical_brd_sha256": raw["canonical_brd_sha256"],
- "receipt_path": raw.get("receipt_path"),
- },
- "derived_board_viewer": {
- "fingerprint_sha256": derived["sha256"],
- "assets": derived["parts"]["assets"],
- "board_viewer_generator_version": derived["parts"]["board_viewer_generator_version"],
- "input_brd_sha256": derived["parts"]["input_brd_sha256"],
- },
- "artifact_source_commit": artifact_commit,
- "delivery_commit": delivery_commit,
- "raw_brd_pdf_dsn_in_default_compact": False,
- }
- if summary_only:
- return {
- "schema": pointer["schema"],
- "reference_changed": pointer["reference_changed"],
- "reference_reused": pointer["reference_reused"],
- "filename": pointer["filename"],
- "sha256": pointer["sha256"],
- "content_fingerprint": pointer["content_fingerprint"],
- "brd_sha256": pointer["brd_sha256"],
- "artifact_source_commit": artifact_commit,
- "delivery_commit": delivery_commit,
- "raw_brd_pdf_dsn_in_default_compact": False,
- }
- return pointer
- def compute_release_set_id(
- *,
- artifact_commit: str,
- delivery_commit: str,
- bitstream_sha256: str,
- config_fingerprint: str,
- td_run_id: str,
- reference_set_fingerprint_sha256: str,
- base_dev_commit: str = "d4f3df2549efeb1e9227f62d1d71c6179c9f9160",
- td_bound_commit: str | None = None,
- package_stage: str = "final-review",
- hardware_validation: str = "not_run",
- ) -> str:
- """Stable release_set_id — never includes final ZIP SHAs (avoids cyclic bind)."""
- material = {
- "base_dev_commit": base_dev_commit,
- "artifact_source_commit": artifact_commit,
- "td_bound_commit": td_bound_commit or artifact_commit,
- "delivery_commit": delivery_commit,
- "bitstream_sha256": bitstream_sha256,
- "production_polarity_fingerprint": config_fingerprint,
- "td_artifact_run_id": td_run_id,
- "reference_set_fingerprint": reference_set_fingerprint_sha256,
- "package_stage": package_stage,
- "hardware_validation": hardware_validation,
- }
- return _sha256_bytes(
- json.dumps(material, sort_keys=True, separators=(",", ":")).encode("utf-8")
- )
- def sibling_role_stub(
- *,
- role: str,
- expected_filename: str,
- release_set_id: str,
- ) -> dict[str, Any]:
- """In-package sibling pointer: role + expected filename only (no ZIP SHA)."""
- if role not in {"firmware", "review-compact"}:
- raise ValueError(f"unsupported sibling role: {role}")
- return {
- "schema": "prod2u-release-set-sibling-v1",
- "release_set_id": release_set_id,
- "this_role": role,
- "sibling_role": "review-compact" if role == "firmware" else "firmware",
- "sibling_expected_filename": expected_filename,
- "note": "Final ZIP SHAs are recorded only in the external release-set JSON after both packages exist.",
- }
- def build_release_set_document(
- *,
- release_set_id: str,
- artifact_commit: str,
- delivery_commit: str,
- bitstream_sha256: str,
- td_run_id: str,
- config_fingerprint: str,
- reference_set_fingerprint_sha256: str,
- firmware_filename: str,
- firmware_size: int,
- firmware_sha256: str,
- review_compact_filename: str,
- review_compact_size: int,
- review_compact_sha256: str,
- hardware_validation: str = "not_run",
- ) -> dict[str, Any]:
- """External release-set JSON written AFTER both packages exist."""
- for name, sha in (
- (firmware_filename, firmware_sha256),
- (review_compact_filename, review_compact_sha256),
- ):
- if not re.fullmatch(r"[0-9a-f]{64}", sha):
- raise ValueError(f"invalid package sha for {name}")
- return {
- "schema": "prod2u-release-set-v1",
- "generated_at_utc": datetime.now(timezone.utc).isoformat(),
- "release_set_id": release_set_id,
- "hardware_validation": hardware_validation,
- "identity": {
- "artifact_source_commit": artifact_commit,
- "delivery_commit": delivery_commit,
- "bitstream_sha256": bitstream_sha256,
- "td_run_id": td_run_id,
- "config_fingerprint": config_fingerprint,
- "reference_set_fingerprint": reference_set_fingerprint_sha256,
- },
- "packages": {
- "firmware": {
- "role": "firmware",
- "filename": firmware_filename,
- "size": firmware_size,
- "sha256": firmware_sha256,
- },
- "review_compact": {
- "role": "review-compact",
- "filename": review_compact_filename,
- "size": review_compact_size,
- "sha256": review_compact_sha256,
- },
- },
- "cyclic_zip_sha_cross_bind": False,
- }
- def write_release_set_files(
- output_dir: Path,
- document: dict[str, Any],
- ) -> tuple[Path, Path]:
- """Write prod2u-release-set-<delivery8>.json + .sha256 sidecar."""
- delivery8 = _short(document["identity"]["delivery_commit"])
- output_dir = Path(output_dir)
- output_dir.mkdir(parents=True, exist_ok=True)
- json_path = output_dir / f"prod2u-release-set-{delivery8}.json"
- text = json.dumps(document, indent=2, sort_keys=True) + "\n"
- json_path.write_text(text, encoding="utf-8")
- digest = _sha256_bytes(text.encode("utf-8"))
- sha_path = output_dir / f"prod2u-release-set-{delivery8}.json.sha256"
- sha_path.write_text(f"{digest} {json_path.name}\n", encoding="utf-8")
- return json_path, sha_path
- def validate_release_set_selftest(
- document: dict[str, Any],
- *,
- firmware_path: Path | None = None,
- review_compact_path: Path | None = None,
- expected_sibling_filename_in_firmware: str | None = None,
- expected_sibling_filename_in_compact: str | None = None,
- package_sibling_records: dict[str, dict[str, Any]] | None = None,
- ) -> dict[str, Any]:
- """Unit / fresh-extraction / tamper-negative checks for release-set."""
- failures: list[str] = []
- if document.get("schema") != "prod2u-release-set-v1":
- failures.append("bad_schema")
- if document.get("cyclic_zip_sha_cross_bind") is not False:
- failures.append("cyclic_flag_not_false")
- if document.get("hardware_validation") != "not_run":
- failures.append("hardware_not_not_run")
- packages = document.get("packages") or {}
- fw = packages.get("firmware") or {}
- rc = packages.get("review_compact") or {}
- if not fw.get("filename") or not rc.get("filename"):
- failures.append("missing_package_filenames")
- if fw.get("sha256") == rc.get("sha256"):
- failures.append("firmware_and_compact_sha_identical_suspicious")
- if firmware_path is not None:
- if firmware_path.name != fw.get("filename"):
- failures.append("firmware_filename_mismatch")
- if firmware_path.is_file() and _sha256_file(firmware_path) != fw.get("sha256"):
- failures.append("firmware_sha_mismatch")
- if firmware_path.is_file() and firmware_path.stat().st_size != fw.get("size"):
- failures.append("firmware_size_mismatch")
- if review_compact_path is not None:
- if review_compact_path.name != rc.get("filename"):
- failures.append("review_compact_filename_mismatch")
- if review_compact_path.is_file() and _sha256_file(review_compact_path) != rc.get("sha256"):
- failures.append("review_compact_sha_mismatch")
- if package_sibling_records:
- for role, record in package_sibling_records.items():
- if record.get("release_set_id") != document.get("release_set_id"):
- failures.append(f"sibling_release_set_id_mismatch:{role}")
- if "sha256" in record or "zip_sha256" in record:
- failures.append(f"sibling_contains_zip_sha:{role}")
- sib_name = record.get("sibling_expected_filename")
- if role == "firmware" and expected_sibling_filename_in_firmware is not None:
- if sib_name != expected_sibling_filename_in_firmware:
- failures.append("firmware_sibling_filename_mismatch")
- if role == "review-compact" and expected_sibling_filename_in_compact is not None:
- if sib_name != expected_sibling_filename_in_compact:
- failures.append("compact_sibling_filename_mismatch")
- identity = document.get("identity") or {}
- if not identity.get("bitstream_sha256"):
- failures.append("missing_bitstream_identity")
- if not identity.get("reference_set_fingerprint"):
- failures.append("missing_reference_fingerprint")
- return {
- "status": "fail" if failures else "pass",
- "failures": failures,
- "release_set_id": document.get("release_set_id"),
- }
|