|
|
@@ -41,6 +41,33 @@ SOURCE_PATHS = (
|
|
|
PROTOCOL_PATH = Path("docs/prod2u-door-temp-protocol.zh-CN.md")
|
|
|
REQUIREMENTS_PATH = Path("projects/prod2u-door-temp/requirements.zh-CN.md")
|
|
|
VERIFICATION_TARGETS_PATH = Path("config/prod2u_p4_verification_targets_v1.json")
|
|
|
+PACKAGE_INFO_SCHEMA = "prod2u-p4-normal-v3-folder-package-info-v3"
|
|
|
+PACKAGE_MANIFEST_SCHEMA = "prod2u-simple-package-manifest-v2"
|
|
|
+RUNTIME_PROFILE = "prod2u-door-temp-115200-v1"
|
|
|
+
|
|
|
+
|
|
|
+def _receipt_payload(*, name: str, run_id: str, commit: str, bitstream_sha256: str) -> dict[str, Any]:
|
|
|
+ return {
|
|
|
+ "schema": f"prod2u-p4-normal-v3-{name}-receipt-v1",
|
|
|
+ "status": "not_run",
|
|
|
+ "verification_run_id": run_id,
|
|
|
+ "commit": commit,
|
|
|
+ "bitstream_sha256": bitstream_sha256,
|
|
|
+ "authority_boundary": "Offline package placeholder. No COM, JTAG, programming, or board action.",
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+def _package_file_hashes(package: Path) -> dict[str, str]:
|
|
|
+ excluded = {
|
|
|
+ "package-info.json",
|
|
|
+ "package_manifest.json",
|
|
|
+ "evidence/package-selftest-result.json",
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ path.relative_to(package).as_posix(): sha256_file(path)
|
|
|
+ for path in sorted(package.rglob("*"))
|
|
|
+ if path.is_file() and path.relative_to(package).as_posix() not in excluded
|
|
|
+ }
|
|
|
|
|
|
|
|
|
def new_run_id() -> str:
|
|
|
@@ -147,8 +174,10 @@ def create_unverified_package(
|
|
|
bitstream_sha256 = sha256_file(bitstream)
|
|
|
package = Path(output_root) / PROJECT_ID / f"{commit}-{bitstream_sha256[:16]}"
|
|
|
package.mkdir(parents=True, exist_ok=True)
|
|
|
- package_bitstream = package / bitstream.name
|
|
|
+ package_bitstream = package / "fw.bit"
|
|
|
package_project = package / "project.json"
|
|
|
+ evidence = package / "evidence"
|
|
|
+ evidence.mkdir(parents=True, exist_ok=True)
|
|
|
shutil.copy2(bitstream, package_bitstream)
|
|
|
shutil.copy2(project, package_project)
|
|
|
repo = _repo_root()
|
|
|
@@ -161,41 +190,117 @@ def create_unverified_package(
|
|
|
if not source.is_file():
|
|
|
raise FileNotFoundError(f"package source is missing: {source}")
|
|
|
shutil.copy2(source, package / name)
|
|
|
- _write_json(package / "source_manifest.json", build_source_manifest(repo))
|
|
|
+ source_manifest = build_source_manifest(repo)
|
|
|
+ _write_json(package / "source_manifest.json", source_manifest)
|
|
|
if td_receipt is not None:
|
|
|
receipt = Path(td_receipt)
|
|
|
if not receipt.is_file():
|
|
|
raise FileNotFoundError(f"TD receipt is missing: {receipt}")
|
|
|
- shutil.copy2(receipt, package / "td_receipt.json")
|
|
|
+ shutil.copy2(receipt, evidence / "td-primary-receipt.json")
|
|
|
+ else:
|
|
|
+ _write_json(
|
|
|
+ evidence / "td-primary-receipt.json",
|
|
|
+ _receipt_payload(name="td-primary", run_id=run_id, commit=commit, bitstream_sha256=bitstream_sha256),
|
|
|
+ )
|
|
|
+ _write_json(
|
|
|
+ evidence / "td-confirmation-receipt.json",
|
|
|
+ _receipt_payload(name="td-confirmation", run_id=run_id, commit=commit, bitstream_sha256=bitstream_sha256),
|
|
|
+ )
|
|
|
+ for name in ("python-unit", "icarus", "verilator", "cocotb", "formal"):
|
|
|
+ _write_json(
|
|
|
+ evidence / f"{name}-receipt.json",
|
|
|
+ _receipt_payload(name=name, run_id=run_id, commit=commit, bitstream_sha256=bitstream_sha256),
|
|
|
+ )
|
|
|
+ _write_json(
|
|
|
+ evidence / "package-selftest-result.json",
|
|
|
+ {
|
|
|
+ "schema": "prod2u-p4-normal-v3-package-selftest-result-v1",
|
|
|
+ "status": "not_run",
|
|
|
+ "verification_run_id": run_id,
|
|
|
+ "commit": commit,
|
|
|
+ "bitstream_sha256": bitstream_sha256,
|
|
|
+ },
|
|
|
+ )
|
|
|
(package / "project_config_sha256.txt").write_text(
|
|
|
sha256_file(package_project) + "\n", encoding="ascii", newline="\n"
|
|
|
)
|
|
|
(package / "bitstream_sha256.txt").write_text(
|
|
|
sha256_file(package_bitstream) + "\n", encoding="ascii", newline="\n"
|
|
|
)
|
|
|
- file_sha256 = {
|
|
|
- path.relative_to(package).as_posix(): sha256_file(path)
|
|
|
- for path in sorted(package.iterdir())
|
|
|
- if path.is_file() and path.name != "package_manifest.json"
|
|
|
+ td_status = "not_run"
|
|
|
+ try:
|
|
|
+ td_value = json.loads((evidence / "td-primary-receipt.json").read_text(encoding="utf-8-sig"))
|
|
|
+ if isinstance(td_value, Mapping) and td_value.get("status") in {"pass", "fail", "blocked", "not_run"}:
|
|
|
+ td_status = str(td_value["status"])
|
|
|
+ except (OSError, UnicodeError, json.JSONDecodeError):
|
|
|
+ td_status = "fail"
|
|
|
+ validation_summary = {
|
|
|
+ "schema": "prod2u-p4-normal-v3-validation-summary-v1",
|
|
|
+ "status": "UNVERIFIED",
|
|
|
+ "delivery_mode": "urgent_single_td",
|
|
|
+ "verification_complete": False,
|
|
|
+ "confirmation_td_present": True,
|
|
|
+ "verification_run_id": run_id,
|
|
|
+ "commit": commit,
|
|
|
+ "bitstream_sha256": bitstream_sha256,
|
|
|
+ "project_config_sha256": sha256_file(package_project),
|
|
|
+ "layers": {
|
|
|
+ "python_unit": {"status": "not_run"},
|
|
|
+ "icarus": {"status": "not_run"},
|
|
|
+ "verilator": {"status": "not_run"},
|
|
|
+ "cocotb": {"status": "not_run"},
|
|
|
+ "formal": {"status": "not_run"},
|
|
|
+ "td_primary": {"status": td_status},
|
|
|
+ "td_confirmation": {"status": "not_run"},
|
|
|
+ "td_confirmation_artifacts": {"status": "not_run"},
|
|
|
+ "td_confirmation_bitstream": {"status": "not_run"},
|
|
|
+ "td_confirmation_synthesis": {"status": "not_run"},
|
|
|
+ "td_confirmation_manifest": {"status": "not_run"},
|
|
|
+ "resource_confirmation": {"status": "not_run"},
|
|
|
+ },
|
|
|
+ "hardware_validation": "not_run",
|
|
|
+ }
|
|
|
+ _write_json(evidence / "validation-summary.json", validation_summary)
|
|
|
+ _write_json(package / "verification_summary.json", validation_summary)
|
|
|
+ package_info = {
|
|
|
+ "schema": PACKAGE_INFO_SCHEMA,
|
|
|
+ "profile": RUNTIME_PROFILE,
|
|
|
+ "project_id": PROJECT_ID,
|
|
|
+ "delivery_mode": "urgent_single_td",
|
|
|
+ "verification_complete": False,
|
|
|
+ "confirmation_td_present": True,
|
|
|
+ "verification_run_id": run_id,
|
|
|
+ "commit": commit,
|
|
|
+ "bitstream": "fw.bit",
|
|
|
+ "bitstream_sha256": bitstream_sha256,
|
|
|
+ "project": "project.json",
|
|
|
+ "project_sha256": sha256_file(package_project),
|
|
|
+ "project_config_sha256": sha256_file(package_project),
|
|
|
+ "source_manifest_sha256": sha256_file(package / "source_manifest.json"),
|
|
|
+ "td_receipt_sha256": sha256_file(evidence / "td-primary-receipt.json"),
|
|
|
+ "confirmation_td_receipt_sha256": sha256_file(evidence / "td-confirmation-receipt.json"),
|
|
|
+ "validation_summary_sha256": sha256_file(evidence / "validation-summary.json"),
|
|
|
+ "package_selftest_result_sha256": sha256_file(evidence / "package-selftest-result.json"),
|
|
|
+ "file_sha256": _package_file_hashes(package),
|
|
|
+ "hardware_validation": "not_run",
|
|
|
}
|
|
|
+ _write_json(package / "package-info.json", package_info)
|
|
|
manifest = {
|
|
|
- "schema": "prod2u-simple-package-manifest-v1",
|
|
|
+ "schema": PACKAGE_MANIFEST_SCHEMA,
|
|
|
"status": "UNVERIFIED",
|
|
|
"run_id": run_id,
|
|
|
"project_id": PROJECT_ID,
|
|
|
"commit": commit,
|
|
|
"created_at": datetime.now(timezone.utc).isoformat(),
|
|
|
- "bitstream": package_bitstream.name,
|
|
|
+ "bitstream": "fw.bit",
|
|
|
"bitstream_sha256": sha256_file(package_bitstream),
|
|
|
"project": "project.json",
|
|
|
"project_sha256": sha256_file(package_project),
|
|
|
- "td_receipt": "td_receipt.json" if td_receipt is not None else None,
|
|
|
- "td_receipt_sha256": (
|
|
|
- sha256_file(package / "td_receipt.json")
|
|
|
- if td_receipt is not None
|
|
|
- else None
|
|
|
- ),
|
|
|
- "file_sha256": file_sha256,
|
|
|
+ "package_info": "package-info.json",
|
|
|
+ "package_info_sha256": sha256_file(package / "package-info.json"),
|
|
|
+ "td_receipt": "evidence/td-primary-receipt.json",
|
|
|
+ "td_receipt_sha256": sha256_file(evidence / "td-primary-receipt.json"),
|
|
|
+ "file_sha256": _package_file_hashes(package),
|
|
|
"hardware_validation": "not_run",
|
|
|
}
|
|
|
_write_json(package / "package_manifest.json", manifest)
|