|
|
@@ -26,7 +26,11 @@ if str(TOOLS) not in sys.path:
|
|
|
sys.path.insert(0, str(TOOLS))
|
|
|
|
|
|
from prod2u_p4_normal_v3_build import ( # noqa: E402
|
|
|
+ FULL_COMMIT_RE,
|
|
|
PRODUCTION_RTL_SOURCES,
|
|
|
+ PROJECT_CONFIG_PATH,
|
|
|
+ SHORT_COMMIT_RE,
|
|
|
+ TD_SOURCE_MANIFEST_PATH,
|
|
|
build_synthesis_input_manifest,
|
|
|
)
|
|
|
PROFILE = "prod2u_p4_normal_v3"
|
|
|
@@ -165,6 +169,57 @@ def sha256_file(path: Path) -> str:
|
|
|
return digest.hexdigest()
|
|
|
|
|
|
|
|
|
+def source_identity() -> dict[str, Any]:
|
|
|
+ files = {
|
|
|
+ "project_config_path": ROOT / PROJECT_CONFIG_PATH,
|
|
|
+ "td_source_manifest_path": ROOT / TD_SOURCE_MANIFEST_PATH,
|
|
|
+ }
|
|
|
+ result: dict[str, Any] = {
|
|
|
+ "project_config_path": PROJECT_CONFIG_PATH,
|
|
|
+ "project_config_sha256": None,
|
|
|
+ "td_source_manifest_path": TD_SOURCE_MANIFEST_PATH,
|
|
|
+ "td_source_manifest_sha256": None,
|
|
|
+ }
|
|
|
+ failures: list[str] = []
|
|
|
+ for field, path in files.items():
|
|
|
+ digest_field = field.replace("_path", "_sha256")
|
|
|
+ if not path.is_file():
|
|
|
+ failures.append(f"source_identity_missing:{field}")
|
|
|
+ continue
|
|
|
+ try:
|
|
|
+ result[digest_field] = sha256_file(path)
|
|
|
+ except OSError as exc:
|
|
|
+ failures.append(f"source_identity_unreadable:{field}:{type(exc).__name__}")
|
|
|
+ result["failures"] = failures
|
|
|
+ return result
|
|
|
+
|
|
|
+
|
|
|
+def source_binding_fields(state: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
+ return {
|
|
|
+ "commit": state.get("commit"),
|
|
|
+ "commit_full": state.get("commit_full"),
|
|
|
+ "commit_short": state.get("commit_short"),
|
|
|
+ "project_config_sha256": state.get("project_config_sha256"),
|
|
|
+ "td_source_manifest_sha256": state.get("td_source_manifest_sha256"),
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+def receipt_commit_full(receipt: Mapping[str, Any]) -> str | None:
|
|
|
+ for field in ("commit_full", "commit"):
|
|
|
+ value = receipt.get(field)
|
|
|
+ if isinstance(value, str) and FULL_COMMIT_RE.fullmatch(value):
|
|
|
+ return value
|
|
|
+ return None
|
|
|
+
|
|
|
+
|
|
|
+def receipt_commit_matches(receipt: Mapping[str, Any], expected_commit: str) -> bool:
|
|
|
+ full = receipt_commit_full(receipt)
|
|
|
+ if full is not None:
|
|
|
+ return full == expected_commit
|
|
|
+ short = receipt.get("commit")
|
|
|
+ return isinstance(short, str) and SHORT_COMMIT_RE.fullmatch(short) is not None and short == expected_commit[:8]
|
|
|
+
|
|
|
+
|
|
|
def td_receipt_bitstream_binding_status(receipt: Mapping[str, Any]) -> str:
|
|
|
if receipt.get("status") in {"not_run", "blocked", "running"}:
|
|
|
return "not_run"
|
|
|
@@ -424,11 +479,7 @@ def source_state() -> dict[str, Any]:
|
|
|
commit_result = _git("rev-parse", "HEAD")
|
|
|
status_result = _git("status", "--porcelain", "--untracked-files=all")
|
|
|
full_commit = commit_result.stdout.strip().lower()
|
|
|
- commit = (
|
|
|
- full_commit[:8]
|
|
|
- if re.fullmatch(r"[0-9a-f]{40}", full_commit)
|
|
|
- else full_commit
|
|
|
- )
|
|
|
+ commit = full_commit
|
|
|
changes = []
|
|
|
for line in status_result.stdout.splitlines():
|
|
|
if not line.strip():
|
|
|
@@ -444,9 +495,17 @@ def source_state() -> dict[str, Any]:
|
|
|
failures.append("git_commit_unavailable")
|
|
|
if status_result.returncode != 0:
|
|
|
failures.append("git_status_unavailable")
|
|
|
+ identity = source_identity()
|
|
|
+ failures.extend(identity["failures"])
|
|
|
return {
|
|
|
"status": "pass" if not failures else "fail",
|
|
|
"commit": commit,
|
|
|
+ "commit_full": full_commit if FULL_COMMIT_RE.fullmatch(full_commit) else None,
|
|
|
+ "commit_short": full_commit[:8] if FULL_COMMIT_RE.fullmatch(full_commit) else None,
|
|
|
+ "project_config_path": identity["project_config_path"],
|
|
|
+ "project_config_sha256": identity["project_config_sha256"],
|
|
|
+ "td_source_manifest_path": identity["td_source_manifest_path"],
|
|
|
+ "td_source_manifest_sha256": identity["td_source_manifest_sha256"],
|
|
|
"clean": status_result.returncode == 0 and not changes,
|
|
|
"tracked_changes": changes,
|
|
|
"failures": failures,
|
|
|
@@ -833,6 +892,7 @@ def formal_tool_version_evidence(
|
|
|
executable: str,
|
|
|
version_args: Sequence[str],
|
|
|
env: Mapping[str, str],
|
|
|
+ work_root: Path,
|
|
|
) -> dict[str, Any]:
|
|
|
path = Path(executable).resolve()
|
|
|
failures: list[str] = []
|
|
|
@@ -844,7 +904,7 @@ def formal_tool_version_evidence(
|
|
|
try:
|
|
|
completed = subprocess.run(
|
|
|
[str(path), *version_args],
|
|
|
- cwd=ROOT,
|
|
|
+ cwd=work_root,
|
|
|
env=dict(env),
|
|
|
text=True,
|
|
|
stdout=subprocess.PIPE,
|
|
|
@@ -878,8 +938,8 @@ def formal_toolchain_evidence(
|
|
|
work_root: Path,
|
|
|
) -> dict[str, Any]:
|
|
|
env = formal_tool_env(work_root)
|
|
|
- sby_evidence = formal_tool_version_evidence("sby", sby, ["--version"], env)
|
|
|
- yosys_evidence = formal_tool_version_evidence("yosys", yosys, ["-V"], env)
|
|
|
+ sby_evidence = formal_tool_version_evidence("sby", sby, ["--version"], env, work_root)
|
|
|
+ yosys_evidence = formal_tool_version_evidence("yosys", yosys, ["-V"], env, work_root)
|
|
|
solver_args = {
|
|
|
"yices": ("yices-smt2", ["--version"]),
|
|
|
"boolector": ("boolector", ["--version"]),
|
|
|
@@ -900,7 +960,7 @@ def formal_toolchain_evidence(
|
|
|
"failures": [f"formal_solver_tool_missing:{solver}"],
|
|
|
}
|
|
|
else:
|
|
|
- evidence = formal_tool_version_evidence(solver, executable, args, env)
|
|
|
+ evidence = formal_tool_version_evidence(solver, executable, args, env, work_root)
|
|
|
solver_evidence.append(evidence)
|
|
|
failures.extend(evidence["failures"])
|
|
|
return {
|
|
|
@@ -1228,8 +1288,8 @@ def _run_verilator(work_root: Path) -> dict[str, Any]:
|
|
|
|
|
|
|
|
|
def _run_cocotb(work_root: Path) -> dict[str, Any]:
|
|
|
- python_exe = cocotb_python()
|
|
|
- probe_ok = python_has_cocotb(python_exe)
|
|
|
+ python_exe = cocotb_python(work_root)
|
|
|
+ probe_ok = python_has_cocotb(python_exe, work_root)
|
|
|
missing: list[str] = []
|
|
|
if not probe_ok:
|
|
|
missing.append("python_module:cocotb")
|
|
|
@@ -1254,7 +1314,7 @@ def _run_cocotb(work_root: Path) -> dict[str, Any]:
|
|
|
completed = _run_bounded(
|
|
|
[python_exe, "-B", str(ROOT / target["runner"])],
|
|
|
timeout_name="cocotb",
|
|
|
- cwd=ROOT / "tests" / "cocotb",
|
|
|
+ cwd=target_root,
|
|
|
env=tool_env(
|
|
|
{
|
|
|
"TEMP": str(target_root),
|
|
|
@@ -1297,10 +1357,12 @@ def _run_cocotb(work_root: Path) -> dict[str, Any]:
|
|
|
}
|
|
|
|
|
|
|
|
|
-def python_has_cocotb(python_exe: str | Path) -> bool:
|
|
|
+def python_has_cocotb(python_exe: str | Path, work_root: Path) -> bool:
|
|
|
+ resolved = resolve_work_root(work_root, run=True)
|
|
|
+ assert resolved is not None
|
|
|
completed = subprocess.run(
|
|
|
[str(python_exe), "-B", "-c", "import cocotb"],
|
|
|
- cwd=ROOT,
|
|
|
+ cwd=resolved,
|
|
|
env=tool_env(),
|
|
|
text=True,
|
|
|
stdout=subprocess.PIPE,
|
|
|
@@ -1311,7 +1373,7 @@ def python_has_cocotb(python_exe: str | Path) -> bool:
|
|
|
return completed.returncode == 0
|
|
|
|
|
|
|
|
|
-def cocotb_python() -> str:
|
|
|
+def cocotb_python(work_root: Path) -> str:
|
|
|
candidates: list[Path] = []
|
|
|
configured = os.environ.get("PROD2U_P4_COCOTB_PYTHON", "").strip()
|
|
|
if configured:
|
|
|
@@ -1320,7 +1382,7 @@ def cocotb_python() -> str:
|
|
|
if DEFAULT_VENV_ROOT.is_dir():
|
|
|
candidates.extend(sorted(DEFAULT_VENV_ROOT.glob("*/Scripts/python.exe")))
|
|
|
for candidate in dict.fromkeys(path.expanduser().resolve() for path in candidates):
|
|
|
- if candidate.is_file() and python_has_cocotb(candidate):
|
|
|
+ if candidate.is_file() and python_has_cocotb(candidate, work_root):
|
|
|
return str(candidate)
|
|
|
return str(Path(sys.executable).resolve())
|
|
|
|
|
|
@@ -1773,7 +1835,7 @@ def strict_offline_gate_payload(
|
|
|
"schema": OFFLINE_RECEIPT_SCHEMA,
|
|
|
"status": "fail",
|
|
|
"verification_run_id": run_id,
|
|
|
- "commit": state["commit"],
|
|
|
+ **source_binding_fields(state),
|
|
|
"source_state": state,
|
|
|
"required_layers": ["source_integrity", "unit", "hdl_sim", "formal"],
|
|
|
"layers": {},
|
|
|
@@ -1852,7 +1914,7 @@ def strict_offline_gate_payload(
|
|
|
"generated_at": utc_now(),
|
|
|
"status": "pass" if not failures else "fail",
|
|
|
"verification_run_id": run_id,
|
|
|
- "commit": state["commit"],
|
|
|
+ **source_binding_fields(state),
|
|
|
"source_state": state,
|
|
|
"profile": PROFILE,
|
|
|
"runtime_profile": RUNTIME_PROFILE,
|
|
|
@@ -1916,6 +1978,8 @@ def _copy_active_sources(target: Path) -> None:
|
|
|
"constraints/prod2u_p4_normal_v3.adc",
|
|
|
"constraints/prod2u_p4_normal_v3.sdc",
|
|
|
"td/prod2u_p4_normal_v3.prj",
|
|
|
+ PROJECT_CONFIG_PATH,
|
|
|
+ TD_SOURCE_MANIFEST_PATH,
|
|
|
):
|
|
|
source = ROOT / relative
|
|
|
destination = target / relative
|
|
|
@@ -1953,6 +2017,10 @@ def prepare_td_build_dirs(*, work_root: Path) -> StagedBuild:
|
|
|
"schema": "prod2u-p4-normal-v3-staged-source-manifest-v1",
|
|
|
"status": "pass",
|
|
|
"commit": state["commit"],
|
|
|
+ "commit_full": state["commit_full"],
|
|
|
+ "commit_short": state["commit_short"],
|
|
|
+ "project_config_sha256": state["project_config_sha256"],
|
|
|
+ "td_source_manifest_sha256": state["td_source_manifest_sha256"],
|
|
|
"source_state_clean": state["clean"],
|
|
|
"phases": phases,
|
|
|
"failures": [],
|
|
|
@@ -1985,10 +2053,21 @@ def _staged_synthesis_input_manifest(staged: StagedBuild) -> dict[str, Any]:
|
|
|
else:
|
|
|
path = staged.syn / relative_text
|
|
|
observed[relative_text] = sha256_file(path) if path.is_file() else None
|
|
|
+ manifest_binding = {
|
|
|
+ "inputs": observed,
|
|
|
+ "project_config_path": staged.synthesis_input_manifest.get("project_config_path"),
|
|
|
+ "project_config_sha256": observed.get(PROJECT_CONFIG_PATH),
|
|
|
+ "td_source_manifest_path": staged.synthesis_input_manifest.get("td_source_manifest_path"),
|
|
|
+ "td_source_manifest_sha256": observed.get(TD_SOURCE_MANIFEST_PATH),
|
|
|
+ }
|
|
|
return {
|
|
|
"schema": staged.synthesis_input_manifest.get("schema"),
|
|
|
"inputs": observed,
|
|
|
- "sha256": canonical_sha256(observed),
|
|
|
+ "project_config_path": manifest_binding["project_config_path"],
|
|
|
+ "project_config_sha256": manifest_binding["project_config_sha256"],
|
|
|
+ "td_source_manifest_path": manifest_binding["td_source_manifest_path"],
|
|
|
+ "td_source_manifest_sha256": manifest_binding["td_source_manifest_sha256"],
|
|
|
+ "sha256": canonical_sha256(manifest_binding),
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2054,6 +2133,10 @@ def verify_staged_source_manifest(staged: StagedBuild) -> dict[str, Any]:
|
|
|
"schema": "prod2u-p4-normal-v3-staged-source-manifest-v1",
|
|
|
"status": "pass" if not failures else "fail",
|
|
|
"commit": staged.source_manifest.get("commit"),
|
|
|
+ "commit_full": staged.source_manifest.get("commit_full"),
|
|
|
+ "commit_short": staged.source_manifest.get("commit_short"),
|
|
|
+ "project_config_sha256": staged.source_manifest.get("project_config_sha256"),
|
|
|
+ "td_source_manifest_sha256": staged.source_manifest.get("td_source_manifest_sha256"),
|
|
|
"source_state_clean": staged.source_manifest.get("source_state_clean"),
|
|
|
"phases": verified_phases,
|
|
|
"synthesis_input_manifest": observed_synthesis,
|
|
|
@@ -2747,6 +2830,12 @@ def td_source_states_clean(
|
|
|
source_before.get("clean") is True
|
|
|
and source_after.get("clean") is True
|
|
|
and staged_manifest.get("source_state_clean") is True
|
|
|
+ and source_before.get("project_config_sha256")
|
|
|
+ == source_after.get("project_config_sha256")
|
|
|
+ == staged_manifest.get("project_config_sha256")
|
|
|
+ and source_before.get("td_source_manifest_sha256")
|
|
|
+ == source_after.get("td_source_manifest_sha256")
|
|
|
+ == staged_manifest.get("td_source_manifest_sha256")
|
|
|
)
|
|
|
|
|
|
|
|
|
@@ -2950,7 +3039,7 @@ def td_build_payload(
|
|
|
"status": "pass" if passed else "fail",
|
|
|
"generated_at": generated_at,
|
|
|
"run_id": run_id,
|
|
|
- "commit": staged.source_state["commit"],
|
|
|
+ **source_binding_fields(staged.source_state),
|
|
|
"source_state": dict(staged.source_state),
|
|
|
"repository_state_after": state_after,
|
|
|
"bitstream_sha256": bitstream_sha256,
|
|
|
@@ -3017,15 +3106,19 @@ def td_build_payload(
|
|
|
|
|
|
|
|
|
def _emit(payload: Mapping[str, Any], args: argparse.Namespace, label: str) -> int:
|
|
|
+ emitted = dict(payload)
|
|
|
+ for field, value in source_binding_fields(source_state()).items():
|
|
|
+ if field not in emitted:
|
|
|
+ emitted[field] = value
|
|
|
if getattr(args, "report_file", None):
|
|
|
try:
|
|
|
report_file = resolve_report_file(args.report_file)
|
|
|
except ValueError as exc:
|
|
|
print(json.dumps({"status": "fail", "reason": str(exc)}, indent=2) if getattr(args, "json", False) else f"{label}: fail")
|
|
|
return 1
|
|
|
- write_json_report(payload, report_file)
|
|
|
- print(json.dumps(dict(payload), indent=2) if getattr(args, "json", False) else f"{label}: {payload.get('status', 'unknown')}")
|
|
|
- return 0 if payload.get("status") == "pass" else 1
|
|
|
+ write_json_report(emitted, report_file)
|
|
|
+ print(json.dumps(emitted, indent=2) if getattr(args, "json", False) else f"{label}: {emitted.get('status', 'unknown')}")
|
|
|
+ return 0 if emitted.get("status") == "pass" else 1
|
|
|
|
|
|
|
|
|
def package_required_files(*, confirmation_td_present: bool = True) -> tuple[str, ...]:
|
|
|
@@ -3073,6 +3166,10 @@ def package_selftest_payload(
|
|
|
confirmation_td: Mapping[str, Any] = {}
|
|
|
validation: Mapping[str, Any] = {}
|
|
|
packaged_selftest: Mapping[str, Any] = {}
|
|
|
+ current_state = source_state()
|
|
|
+ expected_commit = receipt_commit_full(current_state) or ""
|
|
|
+ expected_project_config_sha256 = current_state.get("project_config_sha256")
|
|
|
+ expected_td_source_manifest_sha256 = current_state.get("td_source_manifest_sha256")
|
|
|
inputs = (
|
|
|
(info_path, "package_info"),
|
|
|
(primary_td_path, "primary_td"),
|
|
|
@@ -3109,6 +3206,11 @@ def package_selftest_payload(
|
|
|
confirmation_td = loaded_inputs.get("confirmation_td", {})
|
|
|
validation = loaded_inputs.get("validation", {})
|
|
|
packaged_selftest = loaded_inputs.get("packaged_selftest", {})
|
|
|
+ package_commit_full = (
|
|
|
+ info.get("commit_full")
|
|
|
+ if info.get("commit_full")
|
|
|
+ else (primary_td.get("commit_full") if primary_td else None)
|
|
|
+ )
|
|
|
|
|
|
for label, receipt in (
|
|
|
("package_info", info),
|
|
|
@@ -3141,18 +3243,23 @@ def package_selftest_payload(
|
|
|
if verification_complete is not False:
|
|
|
failures.append("urgent_verification_complete_must_be_false")
|
|
|
commit = str(info.get("commit", ""))
|
|
|
- if not re.fullmatch(r"[0-9a-f]{8}", commit):
|
|
|
+ if not (FULL_COMMIT_RE.fullmatch(commit) or SHORT_COMMIT_RE.fullmatch(commit)):
|
|
|
failures.append("package_commit_invalid")
|
|
|
+ info_commit_full = str(info.get("commit_full", ""))
|
|
|
+ if info_commit_full and not FULL_COMMIT_RE.fullmatch(info_commit_full):
|
|
|
+ failures.append("package_commit_full_invalid")
|
|
|
+ if info_commit_full and info_commit_full != expected_commit:
|
|
|
+ failures.append("package_commit_full_mismatch")
|
|
|
if info.get("bitstream_sha256") != digest:
|
|
|
failures.append("package_bitstream_sha256_mismatch")
|
|
|
expected_name = (
|
|
|
f"{commit}-{digest[:16]}"
|
|
|
- if digest is not None and re.fullmatch(r"[0-9a-f]{8}", commit)
|
|
|
+ if digest is not None and (FULL_COMMIT_RE.fullmatch(commit) or SHORT_COMMIT_RE.fullmatch(commit))
|
|
|
else None
|
|
|
)
|
|
|
if expected_name is not None and package.name != expected_name:
|
|
|
failures.append("package_folder_name_mismatch")
|
|
|
- if re.fullmatch(r"[0-9a-f]{8}", commit) and package.parent.name != "prod2u-door-temp":
|
|
|
+ if (FULL_COMMIT_RE.fullmatch(commit) or SHORT_COMMIT_RE.fullmatch(commit)) and package.parent.name != "prod2u-door-temp":
|
|
|
failures.append("package_project_parent_mismatch")
|
|
|
if info.get("td_receipt_sha256") != (
|
|
|
sha256_file(primary_td_path) if primary_td_path.is_file() else None
|
|
|
@@ -3194,6 +3301,13 @@ def package_selftest_payload(
|
|
|
if primary_td:
|
|
|
if primary_td.get("commit") != commit:
|
|
|
failures.append("primary_td_commit_mismatch")
|
|
|
+ if primary_td.get("project_config_sha256") not in {None, expected_project_config_sha256}:
|
|
|
+ failures.append("primary_td_project_config_sha256_mismatch")
|
|
|
+ if primary_td.get("td_source_manifest_sha256") not in {
|
|
|
+ None,
|
|
|
+ expected_td_source_manifest_sha256,
|
|
|
+ }:
|
|
|
+ failures.append("primary_td_td_source_manifest_sha256_mismatch")
|
|
|
if primary_td.get("bitstream_sha256") != digest:
|
|
|
failures.append("primary_td_bitstream_sha256_mismatch")
|
|
|
if info.get("synthesis_input_hash") != primary_td.get("synthesis_input_hash"):
|
|
|
@@ -3201,6 +3315,16 @@ def package_selftest_payload(
|
|
|
if confirmation_td and confirmation_td.get("status") == "pass":
|
|
|
if confirmation_td.get("commit") != commit:
|
|
|
failures.append("confirmation_td_commit_mismatch")
|
|
|
+ if confirmation_td.get("project_config_sha256") not in {
|
|
|
+ None,
|
|
|
+ expected_project_config_sha256,
|
|
|
+ }:
|
|
|
+ failures.append("confirmation_td_project_config_sha256_mismatch")
|
|
|
+ if confirmation_td.get("td_source_manifest_sha256") not in {
|
|
|
+ None,
|
|
|
+ expected_td_source_manifest_sha256,
|
|
|
+ }:
|
|
|
+ failures.append("confirmation_td_td_source_manifest_sha256_mismatch")
|
|
|
if (
|
|
|
confirmation_td.get("bitstream_sha256") not in {None, ""}
|
|
|
and confirmation_td.get("bitstream_sha256") != digest
|
|
|
@@ -3350,6 +3474,12 @@ def package_selftest_payload(
|
|
|
"generated_at": utc_now(),
|
|
|
"verification_run_id": run_id,
|
|
|
"commit": info.get("commit") if info else None,
|
|
|
+ "commit_full": package_commit_full,
|
|
|
+ "commit_short": (
|
|
|
+ package_commit_full[:8]
|
|
|
+ if package_commit_full
|
|
|
+ else (info.get("commit") if info else None)
|
|
|
+ ),
|
|
|
"bitstream_sha256": digest,
|
|
|
"package_dir": str(package),
|
|
|
"delivery_mode": info.get("delivery_mode") if info else None,
|
|
|
@@ -3370,6 +3500,12 @@ def package_selftest_payload(
|
|
|
"confirmation_synthesis_input_hash": (
|
|
|
confirmation_td.get("synthesis_input_hash") if confirmation_td else None
|
|
|
),
|
|
|
+ "project_config_sha256": info.get("project_config_sha256") if info else None,
|
|
|
+ "td_source_manifest_sha256": (
|
|
|
+ info.get("td_source_manifest_sha256")
|
|
|
+ if info
|
|
|
+ else None
|
|
|
+ ) or (primary_td.get("td_source_manifest_sha256") if primary_td else None),
|
|
|
"confirmation_bitstream_sha256": (
|
|
|
confirmation_td.get("bitstream_sha256") if confirmation_td else None
|
|
|
),
|
|
|
@@ -3437,6 +3573,8 @@ def _td_final_failures(
|
|
|
*,
|
|
|
label: str,
|
|
|
expected_commit: str,
|
|
|
+ expected_project_config_sha256: str,
|
|
|
+ expected_td_source_manifest_sha256: str,
|
|
|
) -> list[str]:
|
|
|
failures: list[str] = []
|
|
|
prefix = f"{label}:"
|
|
|
@@ -3444,8 +3582,14 @@ def _td_final_failures(
|
|
|
failures.append(prefix + "schema")
|
|
|
if receipt.get("status") != "pass":
|
|
|
failures.append(prefix + "status")
|
|
|
- if receipt.get("commit") != expected_commit:
|
|
|
+ if not receipt_commit_matches(receipt, expected_commit):
|
|
|
failures.append(prefix + "commit")
|
|
|
+ if receipt.get("commit_full") not in {None, "", expected_commit}:
|
|
|
+ failures.append(prefix + "commit_full")
|
|
|
+ if receipt.get("project_config_sha256") != expected_project_config_sha256:
|
|
|
+ failures.append(prefix + "project_config_sha256")
|
|
|
+ if receipt.get("td_source_manifest_sha256") != expected_td_source_manifest_sha256:
|
|
|
+ failures.append(prefix + "td_source_manifest_sha256")
|
|
|
if not re.fullmatch(
|
|
|
r"[0-9a-f]{32}", str(receipt.get("verification_run_id", ""))
|
|
|
):
|
|
|
@@ -3459,7 +3603,13 @@ def _td_final_failures(
|
|
|
if not re.fullmatch(r"[0-9a-f]{64}", str(receipt.get("synthesis_input_hash", ""))):
|
|
|
failures.append(prefix + "synthesis_input_hash")
|
|
|
source = receipt.get("source_state")
|
|
|
- if not isinstance(source, Mapping) or source.get("clean") is not True or source.get("commit") != expected_commit:
|
|
|
+ if (
|
|
|
+ not isinstance(source, Mapping)
|
|
|
+ or source.get("clean") is not True
|
|
|
+ or not receipt_commit_matches(source, expected_commit)
|
|
|
+ or source.get("project_config_sha256") != expected_project_config_sha256
|
|
|
+ or source.get("td_source_manifest_sha256") != expected_td_source_manifest_sha256
|
|
|
+ ):
|
|
|
failures.append(prefix + "source_state")
|
|
|
for gate_name in (
|
|
|
"source_binding_gate",
|
|
|
@@ -3562,14 +3712,26 @@ def _offline_final_failures(
|
|
|
receipt: Mapping[str, Any],
|
|
|
*,
|
|
|
expected_commit: str,
|
|
|
+ expected_project_config_sha256: str,
|
|
|
+ expected_td_source_manifest_sha256: str,
|
|
|
) -> list[str]:
|
|
|
failures: list[str] = []
|
|
|
if receipt.get("schema") != OFFLINE_RECEIPT_SCHEMA:
|
|
|
failures.append("offline:schema")
|
|
|
- if receipt.get("status") != "pass" or receipt.get("commit") != expected_commit:
|
|
|
+ if receipt.get("status") != "pass" or not receipt_commit_matches(receipt, expected_commit):
|
|
|
failures.append("offline:status_or_commit")
|
|
|
+ if receipt.get("project_config_sha256") != expected_project_config_sha256:
|
|
|
+ failures.append("offline:project_config_sha256")
|
|
|
+ if receipt.get("td_source_manifest_sha256") != expected_td_source_manifest_sha256:
|
|
|
+ failures.append("offline:td_source_manifest_sha256")
|
|
|
source = receipt.get("source_state")
|
|
|
- if not isinstance(source, Mapping) or source.get("clean") is not True:
|
|
|
+ if (
|
|
|
+ not isinstance(source, Mapping)
|
|
|
+ or source.get("clean") is not True
|
|
|
+ or not receipt_commit_matches(source, expected_commit)
|
|
|
+ or source.get("project_config_sha256") != expected_project_config_sha256
|
|
|
+ or source.get("td_source_manifest_sha256") != expected_td_source_manifest_sha256
|
|
|
+ ):
|
|
|
failures.append("offline:source_state")
|
|
|
layers = receipt.get("layers")
|
|
|
required = receipt.get("required_layers")
|
|
|
@@ -3588,6 +3750,8 @@ def _package_final_failures(
|
|
|
receipt: Mapping[str, Any],
|
|
|
*,
|
|
|
expected_commit: str,
|
|
|
+ expected_project_config_sha256: str,
|
|
|
+ expected_td_source_manifest_sha256: str,
|
|
|
expected_bitstream_sha256: str,
|
|
|
expected_primary_td_receipt_sha256: str,
|
|
|
expected_confirmation_td_receipt_sha256: str,
|
|
|
@@ -3596,8 +3760,12 @@ def _package_final_failures(
|
|
|
expected_verification_run_id = receipt.get("verification_run_id")
|
|
|
if receipt.get("schema") != PACKAGE_RECEIPT_SCHEMA:
|
|
|
failures.append("package:schema")
|
|
|
- if receipt.get("status") != "pass" or receipt.get("commit") != expected_commit:
|
|
|
+ if receipt.get("status") != "pass" or receipt_commit_full(receipt) != expected_commit:
|
|
|
failures.append("package:status_or_commit")
|
|
|
+ if receipt.get("project_config_sha256") != expected_project_config_sha256:
|
|
|
+ failures.append("package:project_config_sha256")
|
|
|
+ if receipt.get("td_source_manifest_sha256") != expected_td_source_manifest_sha256:
|
|
|
+ failures.append("package:td_source_manifest_sha256")
|
|
|
if receipt.get("bitstream_sha256") != expected_bitstream_sha256:
|
|
|
failures.append("package:bitstream_sha256")
|
|
|
if not re.fullmatch(
|
|
|
@@ -3655,10 +3823,13 @@ def _package_final_failures(
|
|
|
info.get("schema") != "prod2u-p4-normal-v3-folder-package-info-v3"
|
|
|
or info.get("profile") != RUNTIME_PROFILE
|
|
|
or info.get("verification_run_id") != expected_verification_run_id
|
|
|
- or info.get("commit") != expected_commit
|
|
|
or info.get("bitstream_sha256") != expected_bitstream_sha256
|
|
|
):
|
|
|
failures.append("package:info_binding")
|
|
|
+ if not receipt_commit_matches(info, expected_commit):
|
|
|
+ failures.append("package:info_commit_binding")
|
|
|
+ if info.get("project_config_sha256") != expected_project_config_sha256:
|
|
|
+ failures.append("package:info_project_config_sha256")
|
|
|
if info.get("delivery_mode") != "normal_dual_td":
|
|
|
failures.append("package:info_delivery_mode")
|
|
|
if info.get("verification_complete") is not True:
|
|
|
@@ -3718,20 +3889,27 @@ def _package_final_failures(
|
|
|
|
|
|
if primary_td:
|
|
|
if (
|
|
|
- primary_td.get("commit") != expected_commit
|
|
|
+ not receipt_commit_matches(primary_td, expected_commit)
|
|
|
or primary_td.get("verification_run_id")
|
|
|
!= expected_verification_run_id
|
|
|
or primary_td.get("bitstream_sha256") != expected_bitstream_sha256
|
|
|
+ or primary_td.get("project_config_sha256") != expected_project_config_sha256
|
|
|
+ or primary_td.get("td_source_manifest_sha256")
|
|
|
+ != expected_td_source_manifest_sha256
|
|
|
or info.get("synthesis_input_hash") != primary_td.get("synthesis_input_hash")
|
|
|
):
|
|
|
failures.append("package:primary_td_binding")
|
|
|
if confirmation_td:
|
|
|
if (
|
|
|
- confirmation_td.get("commit") != expected_commit
|
|
|
+ not receipt_commit_matches(confirmation_td, expected_commit)
|
|
|
or confirmation_td.get("verification_run_id")
|
|
|
!= expected_verification_run_id
|
|
|
or confirmation_td.get("bitstream_sha256")
|
|
|
!= expected_bitstream_sha256
|
|
|
+ or confirmation_td.get("project_config_sha256")
|
|
|
+ != expected_project_config_sha256
|
|
|
+ or confirmation_td.get("td_source_manifest_sha256")
|
|
|
+ != expected_td_source_manifest_sha256
|
|
|
or info.get("confirmation_bitstream_sha256")
|
|
|
!= confirmation_td.get("bitstream_sha256")
|
|
|
or info.get("confirmation_synthesis_input_hash")
|
|
|
@@ -3744,7 +3922,7 @@ def _package_final_failures(
|
|
|
!= "prod2u-p4-normal-v3-validation-summary-v1"
|
|
|
or validation.get("verification_run_id")
|
|
|
!= expected_verification_run_id
|
|
|
- or validation.get("commit") != expected_commit
|
|
|
+ or not receipt_commit_matches(validation, expected_commit)
|
|
|
or validation.get("bitstream_sha256") != expected_bitstream_sha256
|
|
|
or validation.get("delivery_mode") != "normal_dual_td"
|
|
|
or validation.get("verification_complete") is not True
|
|
|
@@ -3795,7 +3973,9 @@ def cmd_final_gate(args: argparse.Namespace) -> int:
|
|
|
if (
|
|
|
state.get("status") != "pass"
|
|
|
or state.get("clean") is not True
|
|
|
- or not re.fullmatch(r"[0-9a-f]{8}", str(expected_commit))
|
|
|
+ or not FULL_COMMIT_RE.fullmatch(str(expected_commit))
|
|
|
+ or not re.fullmatch(r"[0-9a-f]{64}", str(state.get("project_config_sha256")))
|
|
|
+ or not re.fullmatch(r"[0-9a-f]{64}", str(state.get("td_source_manifest_sha256")))
|
|
|
):
|
|
|
failures = ["final_source_state_not_clean"]
|
|
|
else:
|
|
|
@@ -3804,6 +3984,8 @@ def cmd_final_gate(args: argparse.Namespace) -> int:
|
|
|
_offline_final_failures(
|
|
|
child_receipts["offline"],
|
|
|
expected_commit=str(expected_commit),
|
|
|
+ expected_project_config_sha256=str(state.get("project_config_sha256")),
|
|
|
+ expected_td_source_manifest_sha256=str(state.get("td_source_manifest_sha256")),
|
|
|
)
|
|
|
)
|
|
|
failures.extend(
|
|
|
@@ -3811,6 +3993,8 @@ def cmd_final_gate(args: argparse.Namespace) -> int:
|
|
|
child_receipts["td"],
|
|
|
label="td",
|
|
|
expected_commit=str(expected_commit),
|
|
|
+ expected_project_config_sha256=str(state.get("project_config_sha256")),
|
|
|
+ expected_td_source_manifest_sha256=str(state.get("td_source_manifest_sha256")),
|
|
|
)
|
|
|
)
|
|
|
failures.extend(
|
|
|
@@ -3818,6 +4002,8 @@ def cmd_final_gate(args: argparse.Namespace) -> int:
|
|
|
child_receipts["td_confirmation"],
|
|
|
label="td_confirmation",
|
|
|
expected_commit=str(expected_commit),
|
|
|
+ expected_project_config_sha256=str(state.get("project_config_sha256")),
|
|
|
+ expected_td_source_manifest_sha256=str(state.get("td_source_manifest_sha256")),
|
|
|
)
|
|
|
)
|
|
|
for name, receipt in child_receipts.items():
|
|
|
@@ -3830,6 +4016,8 @@ def cmd_final_gate(args: argparse.Namespace) -> int:
|
|
|
_package_final_failures(
|
|
|
package,
|
|
|
expected_commit=str(expected_commit),
|
|
|
+ expected_project_config_sha256=str(state.get("project_config_sha256")),
|
|
|
+ expected_td_source_manifest_sha256=str(state.get("td_source_manifest_sha256")),
|
|
|
expected_bitstream_sha256=str(primary.get("bitstream_sha256", "")),
|
|
|
expected_primary_td_receipt_sha256=sha256_file(paths["td"]),
|
|
|
expected_confirmation_td_receipt_sha256=sha256_file(
|
|
|
@@ -3867,6 +4055,10 @@ def cmd_final_gate(args: argparse.Namespace) -> int:
|
|
|
"generated_at": utc_now(),
|
|
|
"verification_run_id": verification_run_id,
|
|
|
"commit": expected_commit,
|
|
|
+ "commit_full": expected_commit,
|
|
|
+ "commit_short": str(expected_commit)[:8],
|
|
|
+ "project_config_sha256": state.get("project_config_sha256"),
|
|
|
+ "td_source_manifest_sha256": state.get("td_source_manifest_sha256"),
|
|
|
"source_state": state,
|
|
|
"child_receipts": {
|
|
|
name: {"path": str(paths[name]), "sha256": sha256_file(paths[name])}
|