|
|
@@ -43,6 +43,11 @@ def _receipt_payload(*, name: str, run_id: str, commit: str, bitstream_sha256: s
|
|
|
"commit": commit,
|
|
|
"bitstream_sha256": bitstream_sha256,
|
|
|
"project_config_sha256": project_config_sha256,
|
|
|
+ "td_source_manifest_sha256": None,
|
|
|
+ "command": None,
|
|
|
+ "tool_version": None,
|
|
|
+ "placeholder": True,
|
|
|
+ "authoritative": False,
|
|
|
"authority_boundary": "Offline package placeholder. No COM, JTAG, programming, or board action.",
|
|
|
}
|
|
|
|
|
|
@@ -55,6 +60,8 @@ def _copy_bound_receipt(
|
|
|
commit: str,
|
|
|
bitstream_sha256: str,
|
|
|
project_config_sha256: str,
|
|
|
+ td_source_manifest_sha256: str | None = None,
|
|
|
+ receipt_role: str | None = None,
|
|
|
preserve_bitstream_sha256: bool = False,
|
|
|
require_bitstream_sha256: bool = False,
|
|
|
) -> dict[str, Any]:
|
|
|
@@ -69,6 +76,8 @@ def _copy_bound_receipt(
|
|
|
"commit": commit,
|
|
|
"project_config_sha256": project_config_sha256,
|
|
|
}
|
|
|
+ if td_source_manifest_sha256 is not None:
|
|
|
+ bindings["td_source_manifest_sha256"] = td_source_manifest_sha256
|
|
|
for field, expected in bindings.items():
|
|
|
observed = value.get(field)
|
|
|
if observed not in {None, "", expected}:
|
|
|
@@ -85,6 +94,13 @@ def _copy_bound_receipt(
|
|
|
elif value.get("status") == "pass" and not SHA256_RE.fullmatch(str(value.get("bitstream_sha256", ""))):
|
|
|
raise ValueError(f"confirmation receipt requires its own bitstream SHA256: {source}")
|
|
|
value["commit_full"] = commit
|
|
|
+ if receipt_role is not None:
|
|
|
+ value["receipt_role"] = receipt_role
|
|
|
+ value["command"] = value.get("command") or f"final verification lane: {receipt_role}"
|
|
|
+ value["tool_version"] = value.get("tool_version") or "captured by bound offline aggregate"
|
|
|
+ if value.get("status") == "pass":
|
|
|
+ value["authoritative"] = True
|
|
|
+ value["placeholder"] = False
|
|
|
value["source_receipt_sha256"] = sha256_file(source)
|
|
|
_write_json(destination, value)
|
|
|
return value
|
|
|
@@ -519,6 +535,7 @@ def create_unverified_package(
|
|
|
production_integration_commit: str | None = None,
|
|
|
source_manifest_sha256: str | None = None,
|
|
|
td_receipt_sha256: str | None = None,
|
|
|
+ offline_receipt: Path | None = None,
|
|
|
package_class: str = "UNVERIFIED",
|
|
|
) -> Path:
|
|
|
if not (COMMIT_RE.fullmatch(commit) or FULL_COMMIT_RE.fullmatch(commit)):
|
|
|
@@ -566,6 +583,13 @@ def create_unverified_package(
|
|
|
if not FULL_COMMIT_RE.fullmatch(resolved) or resolved[:8] != commit:
|
|
|
raise ValueError("short commit does not match the current full HEAD")
|
|
|
commit_full = resolved
|
|
|
+ if package_class == "UNVERIFIED_FINAL_CANDIDATE" and offline_receipt is not None:
|
|
|
+ identity = _git_identity(repo)
|
|
|
+ if identity["head"] != commit_full:
|
|
|
+ raise ValueError("final package commit does not match current HEAD")
|
|
|
+ clean = _run_git(repo, ["status", "--porcelain"]).stdout.decode("utf-8", "replace")
|
|
|
+ if clean:
|
|
|
+ raise ValueError("final package requires a clean worktree")
|
|
|
compatibility_commit = commit
|
|
|
bitstream_sha256 = sha256_file(bitstream)
|
|
|
package = Path(output_root) / PROJECT_ID / f"{compatibility_commit}-{bitstream_sha256[:16]}"
|
|
|
@@ -602,6 +626,27 @@ def create_unverified_package(
|
|
|
observed_source_manifest_sha256 = sha256_file(package / "source_manifest.json")
|
|
|
if source_manifest_sha256 is not None and source_manifest_sha256 != observed_source_manifest_sha256:
|
|
|
raise ValueError("source manifest hash mismatch")
|
|
|
+ offline_payload: dict[str, Any] | None = None
|
|
|
+ if offline_receipt is not None:
|
|
|
+ try:
|
|
|
+ loaded = json.loads(Path(offline_receipt).read_text(encoding="utf-8-sig"))
|
|
|
+ except (OSError, UnicodeError, json.JSONDecodeError) as exc:
|
|
|
+ raise ValueError(f"offline receipt is not readable JSON: {offline_receipt}") from exc
|
|
|
+ if not isinstance(loaded, dict):
|
|
|
+ raise ValueError("offline receipt root must be an object")
|
|
|
+ expected_bindings = {
|
|
|
+ "verification_run_id": run_id,
|
|
|
+ "commit_full": commit_full,
|
|
|
+ "project_config_sha256": project_config_sha256,
|
|
|
+ "td_source_manifest_sha256": sha256_file(repo / SOURCE_MANIFEST_PATH),
|
|
|
+ }
|
|
|
+ for field, expected in expected_bindings.items():
|
|
|
+ if loaded.get(field) != expected:
|
|
|
+ raise ValueError(f"offline receipt binding mismatch for {field}")
|
|
|
+ if loaded.get("status") != "pass":
|
|
|
+ raise ValueError("offline receipt must have status=pass")
|
|
|
+ offline_payload = loaded
|
|
|
+ shutil.copy2(Path(offline_receipt), evidence / "software-offline-receipt.json")
|
|
|
receipt_sources = dict(verification_receipts or {})
|
|
|
if td_receipt is not None:
|
|
|
receipt = Path(td_receipt)
|
|
|
@@ -616,6 +661,8 @@ def create_unverified_package(
|
|
|
commit=commit_full,
|
|
|
bitstream_sha256=bitstream_sha256,
|
|
|
project_config_sha256=project_config_sha256,
|
|
|
+ td_source_manifest_sha256=sha256_file(repo / SOURCE_MANIFEST_PATH),
|
|
|
+ receipt_role="td-primary",
|
|
|
)
|
|
|
else:
|
|
|
_write_json(
|
|
|
@@ -643,6 +690,8 @@ def create_unverified_package(
|
|
|
commit=commit_full,
|
|
|
bitstream_sha256=bitstream_sha256,
|
|
|
project_config_sha256=project_config_sha256,
|
|
|
+ td_source_manifest_sha256=sha256_file(repo / SOURCE_MANIFEST_PATH),
|
|
|
+ receipt_role=name,
|
|
|
preserve_bitstream_sha256=name == "td-confirmation",
|
|
|
require_bitstream_sha256=name == "td-primary",
|
|
|
)
|
|
|
@@ -748,6 +797,7 @@ def create_unverified_package(
|
|
|
"confirmation_bitstream_sha256": confirmation_bitstream_sha256,
|
|
|
"confirmation_synthesis_input_hash": confirmation_synthesis_input_hash,
|
|
|
"td_source_manifest_sha256": sha256_file(repo / SOURCE_MANIFEST_PATH),
|
|
|
+ "software_offline_receipt": "evidence/software-offline-receipt.json" if offline_payload is not None else None,
|
|
|
"canonical_bitstream_build": "primary",
|
|
|
"bitstream_hash_equal": confirmation_bitstream_sha256 == bitstream_sha256 if confirmation_bitstream_sha256 else None,
|
|
|
"td_receipt_sha256": sha256_file(evidence / "td-primary-receipt.json"),
|
|
|
@@ -785,6 +835,7 @@ def create_unverified_package(
|
|
|
"td_receipt_sha256": sha256_file(evidence / "td-primary-receipt.json"),
|
|
|
"td_source_receipt_sha256": td_receipt_sha256,
|
|
|
"td_source_manifest_sha256": sha256_file(repo / SOURCE_MANIFEST_PATH),
|
|
|
+ "software_offline_receipt": "evidence/software-offline-receipt.json" if offline_payload is not None else None,
|
|
|
"canonical_bitstream_build": "primary",
|
|
|
"confirmation_bitstream_sha256": confirmation_bitstream_sha256,
|
|
|
"bitstream_hash_equal": confirmation_bitstream_sha256 == bitstream_sha256 if confirmation_bitstream_sha256 else None,
|
|
|
@@ -821,6 +872,7 @@ def main() -> int:
|
|
|
package.add_argument("--production-integration-commit")
|
|
|
package.add_argument("--source-manifest-sha256")
|
|
|
package.add_argument("--td-receipt-sha256")
|
|
|
+ package.add_argument("--offline-receipt", type=Path)
|
|
|
package.add_argument(
|
|
|
"--package-class",
|
|
|
choices=("UNVERIFIED", "UNVERIFIED_EARLY_BUILD", "UNVERIFIED_FINAL_CANDIDATE"),
|
|
|
@@ -858,6 +910,7 @@ def main() -> int:
|
|
|
production_integration_commit=args.production_integration_commit,
|
|
|
source_manifest_sha256=args.source_manifest_sha256,
|
|
|
td_receipt_sha256=args.td_receipt_sha256,
|
|
|
+ offline_receipt=args.offline_receipt,
|
|
|
package_class=args.package_class,
|
|
|
))
|
|
|
return 0
|