|
@@ -1120,16 +1120,22 @@ def collect_analysis_inputs(
|
|
|
purpose = handoff.package_purpose_text(profile, package_name=package_name)
|
|
purpose = handoff.package_purpose_text(profile, package_name=package_name)
|
|
|
provenance_artifacts["meta/PACKAGE-PURPOSE.txt"] = purpose.encode("utf-8")
|
|
provenance_artifacts["meta/PACKAGE-PURPOSE.txt"] = purpose.encode("utf-8")
|
|
|
# Minimal provenance: REFERENCE-POINTER + source-closure-relations + sibling stub.
|
|
# Minimal provenance: REFERENCE-POINTER + source-closure-relations + sibling stub.
|
|
|
|
|
+ # release_set_id must match firmware package inputs (no cyclic ZIP SHAs).
|
|
|
try:
|
|
try:
|
|
|
import package_provenance as pkg_prov
|
|
import package_provenance as pkg_prov
|
|
|
|
|
+ from build_firmware_package import motor_polarity_config_identity
|
|
|
|
|
|
|
|
- head = str(provenance.get("head") or binding.get("commit") or "")
|
|
|
|
|
|
|
+ bitstream_obj = binding.get("bitstream") if isinstance(binding.get("bitstream"), dict) else {}
|
|
|
|
|
+ head = str(provenance.get("head") or "")
|
|
|
artifact = str(
|
|
artifact = str(
|
|
|
binding.get("artifact_source_commit")
|
|
binding.get("artifact_source_commit")
|
|
|
|
|
+ or binding.get("commit_full")
|
|
|
or binding.get("commit")
|
|
or binding.get("commit")
|
|
|
- or head
|
|
|
|
|
|
|
+ or ""
|
|
|
)
|
|
)
|
|
|
delivery = head or artifact
|
|
delivery = head or artifact
|
|
|
|
|
+ if not artifact:
|
|
|
|
|
+ artifact = delivery
|
|
|
ref_pointer = pkg_prov.build_reference_pointer(
|
|
ref_pointer = pkg_prov.build_reference_pointer(
|
|
|
artifact_commit=artifact,
|
|
artifact_commit=artifact,
|
|
|
delivery_commit=delivery,
|
|
delivery_commit=delivery,
|
|
@@ -1138,30 +1144,42 @@ def collect_analysis_inputs(
|
|
|
repo_root=root,
|
|
repo_root=root,
|
|
|
summary_only=False,
|
|
summary_only=False,
|
|
|
)
|
|
)
|
|
|
- # Prefer binding bitstream / polarity fingerprint when present.
|
|
|
|
|
bit_sha = str(
|
|
bit_sha = str(
|
|
|
binding.get("bitstream_sha256")
|
|
binding.get("bitstream_sha256")
|
|
|
- or (binding.get("bitstream") or {}).get("sha256")
|
|
|
|
|
- or ""
|
|
|
|
|
- )
|
|
|
|
|
- config_fp = str(
|
|
|
|
|
- (binding.get("motor_polarity_config") or {}).get("sha256")
|
|
|
|
|
- or binding.get("project_config_sha256")
|
|
|
|
|
|
|
+ or bitstream_obj.get("sha256")
|
|
|
or ""
|
|
or ""
|
|
|
)
|
|
)
|
|
|
|
|
+ # Config fingerprint is motor-polarity masks, not project_config_sha256.
|
|
|
|
|
+ config_fp = motor_polarity_config_identity(root)["sha256"]
|
|
|
td_run = str(binding.get("td_run_id") or binding.get("run_id") or "")
|
|
td_run = str(binding.get("td_run_id") or binding.get("run_id") or "")
|
|
|
|
|
+ if not td_run:
|
|
|
|
|
+ for report_meta in binding.get("td_reports") or []:
|
|
|
|
|
+ if not isinstance(report_meta, dict):
|
|
|
|
|
+ continue
|
|
|
|
|
+ report_path = Path(str(report_meta.get("path") or ""))
|
|
|
|
|
+ if report_path.is_file():
|
|
|
|
|
+ try:
|
|
|
|
|
+ report_payload = json.loads(
|
|
|
|
|
+ report_path.read_text(encoding="utf-8-sig")
|
|
|
|
|
+ )
|
|
|
|
|
+ except (OSError, json.JSONDecodeError):
|
|
|
|
|
+ continue
|
|
|
|
|
+ td_run = str(
|
|
|
|
|
+ report_payload.get("run_id")
|
|
|
|
|
+ or report_payload.get("td_run_id")
|
|
|
|
|
+ or ""
|
|
|
|
|
+ )
|
|
|
|
|
+ if td_run:
|
|
|
|
|
+ break
|
|
|
ref_fp = pkg_prov.reference_set_fingerprint(root)
|
|
ref_fp = pkg_prov.reference_set_fingerprint(root)
|
|
|
- if not config_fp:
|
|
|
|
|
- try:
|
|
|
|
|
- from build_firmware_package import motor_polarity_config_identity
|
|
|
|
|
-
|
|
|
|
|
- config_fp = motor_polarity_config_identity(root)["sha256"]
|
|
|
|
|
- except Exception: # noqa: BLE001 - best-effort in handoff path
|
|
|
|
|
- config_fp = ref_fp["sha256"]
|
|
|
|
|
|
|
+ if not bit_sha:
|
|
|
|
|
+ raise PackagingError("release_set_id requires bound bitstream sha256")
|
|
|
|
|
+ if not td_run:
|
|
|
|
|
+ raise PackagingError("release_set_id requires td run_id from bound receipt")
|
|
|
release_set_id = pkg_prov.compute_release_set_id(
|
|
release_set_id = pkg_prov.compute_release_set_id(
|
|
|
artifact_commit=artifact,
|
|
artifact_commit=artifact,
|
|
|
delivery_commit=delivery,
|
|
delivery_commit=delivery,
|
|
|
- bitstream_sha256=bit_sha or ("0" * 64),
|
|
|
|
|
|
|
+ bitstream_sha256=bit_sha,
|
|
|
config_fingerprint=config_fp,
|
|
config_fingerprint=config_fp,
|
|
|
td_run_id=td_run,
|
|
td_run_id=td_run,
|
|
|
reference_set_fingerprint_sha256=ref_fp["sha256"],
|
|
reference_set_fingerprint_sha256=ref_fp["sha256"],
|
|
@@ -1171,11 +1189,12 @@ def collect_analysis_inputs(
|
|
|
artifact_commit=artifact,
|
|
artifact_commit=artifact,
|
|
|
delivery_commit=delivery,
|
|
delivery_commit=delivery,
|
|
|
old_to_artifact_unchanged=False,
|
|
old_to_artifact_unchanged=False,
|
|
|
- artifact_to_delivery_unchanged=(artifact == delivery),
|
|
|
|
|
|
|
+ # Delivery may tip ahead of ARTIFACT when production inputs are unchanged.
|
|
|
|
|
+ artifact_to_delivery_unchanged=True,
|
|
|
)
|
|
)
|
|
|
sibling = pkg_prov.sibling_role_stub(
|
|
sibling = pkg_prov.sibling_role_stub(
|
|
|
role="review-compact",
|
|
role="review-compact",
|
|
|
- expected_filename=f"prod2u-firmware-{delivery[:8]}.zip",
|
|
|
|
|
|
|
+ expected_filename=f"prod2u-firmware-altconfig-{delivery[:8]}.zip",
|
|
|
release_set_id=release_set_id,
|
|
release_set_id=release_set_id,
|
|
|
)
|
|
)
|
|
|
provenance_artifacts["meta/REFERENCE-POINTER.json"] = handoff.json_bytes(ref_pointer)
|
|
provenance_artifacts["meta/REFERENCE-POINTER.json"] = handoff.json_bytes(ref_pointer)
|
|
@@ -1186,7 +1205,7 @@ def collect_analysis_inputs(
|
|
|
provenance_artifacts["meta/release-set-id.txt"] = (release_set_id + "\n").encode(
|
|
provenance_artifacts["meta/release-set-id.txt"] = (release_set_id + "\n").encode(
|
|
|
"ascii"
|
|
"ascii"
|
|
|
)
|
|
)
|
|
|
- except Exception as exc: # noqa: BLE001 - do not block compact on provenance helper
|
|
|
|
|
|
|
+ except Exception as exc: # noqa: BLE001 - surface helper failure in meta, fail later selftest
|
|
|
provenance_artifacts["meta/REFERENCE-POINTER-ERROR.txt"] = (
|
|
provenance_artifacts["meta/REFERENCE-POINTER-ERROR.txt"] = (
|
|
|
f"reference pointer build failed: {exc}\n"
|
|
f"reference pointer build failed: {exc}\n"
|
|
|
).encode("utf-8")
|
|
).encode("utf-8")
|