Browse Source

fix: close canonical package base identity

root 3 tháng trước cách đây
mục cha
commit
56d7b0f781

+ 3 - 3
ACTIVE_REMOTE_MIGRATION.yaml

@@ -44,7 +44,7 @@ protocol:
   ACK_NACK: 0x06
   SNAPSHOT_DATA: 0x82
 execution:
-  phase: P0_FOCUSED_PASS_PENDING_COMMIT
+  phase: CANONICAL_PACKAGE_FIX_IMPLEMENTED_FOCUSED_PASS
   heavy_tests_before_quick: forbidden
   remote_not_started: true
   hardware: NOT_RUN
@@ -78,5 +78,5 @@ focused_results:
     rear_connector_high: 10000
     front_ball_low: 10000
     rear_ball_high: 10000
-last_test: POR_BOOT_COCOTB_PASS_3x50000_AND_PWM_UNIT_PASS
-next: commit_p0_then_fresh_td_gui_delivery
+last_test: CANONICAL_PACKAGE_UNIT_9_PASS_GENERATOR_CLOSURE_PASS
+next: commit_canonical_then_build_and_negative_test_base_current

+ 6 - 0
QUICK_PROGRESS.md

@@ -13,6 +13,12 @@
 - PASS: production-parameter POR/Boot Cocotb observed three 50,000-clock periods; each PTC high=0 and each Front/Rear connector high=10,000.
 - PASS: Front Ball low=10,000 and Rear Ball high=10,000 per complete period; no 0%/100% carrier, narrow pulse or pre-scan commit.
 - Next: independent P0 commit, then Fresh TD/GUI/Delivery before canonical or remote work.
+- P0 committed as `9533a991`; Fresh TD synthesis/P&R/setup/hold/bitgen PASS; no programming.
+- Quick BIT SHA `fc28c355...`; GUI SHA `880bc3b6...`; Delivery SHA `30d12701...`; paths already reported.
+- Canonical fix implemented: Base identity/member verification replaces marker trust; immutable Base collision gate; safe overlay tool.
+- Added Base replay dependencies, lazy MRDIMM generator import, exact hashed Python lock, Podman Containerfile and Quadlet.
+- PASS: canonical package unit 9, generator check, production/analysis closure; local Doctor degraded only because invocation PATH omitted repo `tools/td2026` and old verify venv runtime is broken.
+- Next: commit canonical changes, create new Base/Current, run tamper/wrong-base/fresh-overlay matrix, then begin SSH probe.
 
 - Workspace: `/root/workspaces/thermal-system/cpld-temperature-control`
 - Branch: `dev`

+ 8 - 0
containers/6400-dev/Containerfile

@@ -0,0 +1,8 @@
+FROM docker.io/library/debian@sha256:abc9cb88a5587630d7f915f47b23b0668fe250fbfc6457aa4d52b534c1bbf73f
+ARG DEBIAN_FRONTEND=noninteractive
+RUN apt-get update && apt-get install -y --no-install-recommends \
+    ca-certificates git python3 python3-venv python3-pip golang-go iverilog verilator yosys \
+    z3 boolector protobuf-compiler unzip zip zstd jq tmux && rm -rf /var/lib/apt/lists/*
+WORKDIR /workspace
+COPY requirements-verify.lock.txt /opt/prod2u/requirements-verify.lock.txt
+ENTRYPOINT ["/bin/bash"]

+ 4 - 0
containers/6400-dev/build-image.sh

@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+set -euo pipefail
+root="$(cd "$(dirname "$0")/../.." && pwd)"
+exec podman build --pull=never -t localhost/prod2u-6400-dev:locked -f "$root/containers/6400-dev/Containerfile" "$root/containers/6400-dev"

+ 15 - 0
containers/6400-dev/requirements-verify.lock.txt

@@ -0,0 +1,15 @@
+# Exact Python 3.12 Linux x86_64 wheel set. Bootstrap uses --require-hashes.
+attrs==26.1.0 --hash=sha256:c647aa4a12dfbad9333ca4e71fe62ddc36f4e63b2d260a37a8b83d2f043ac309
+cocotb==2.0.1 --hash=sha256:4fd0ae786019d18e7195a1186f93bff5afcda7b5aba8de710d3e74182e57a116
+find-libpython==0.5.1 --hash=sha256:723a8cfe6fed255a1f58b53c62ed556fb340ec0d456e9863ebc01a5cc047607d
+iniconfig==2.3.0 --hash=sha256:f631c04d2c48c52b84d0d0549c99ff3859c98df65b3101406327ecc7d53fbf12
+jsonschema==4.25.1 --hash=sha256:3fba0169e345c7175110351d456342c364814cfcf3b964ba4587f22915230a63
+jsonschema-specifications==2025.9.1 --hash=sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe
+packaging==26.3 --hash=sha256:d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c
+pluggy==1.6.0 --hash=sha256:e920276dd6813095e9377c0bc5566d94c932c33b27a3e3945d8389c374dd4746
+psutil==7.0.0 --hash=sha256:4b1388a4f6875d7e2aff5c4ca1cc16c545ed41dd8bb596cefea80111db353a34
+pygments==2.21.0 --hash=sha256:2363c69b61c4a97c838da3b130dcd6468f4848992b21a82f2a63ec34377137d9
+pytest==8.4.1 --hash=sha256:539c70ba6fcead8e78eebbf1115e8b589e7565830d7d006a8723f19ac8a0afb7
+referencing==0.37.0 --hash=sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231
+rpds-py==2026.6.3 --hash=sha256:ecabd69db66de867690f9797f2f8fa27ba501bbc24540cbdbdc649cd15888ba6
+typing-extensions==4.16.0 --hash=sha256:481caa481374e813c1b176ada14e97f1f67a4539ce9cfeb3f350d78d6370c2e8

+ 5 - 0
containers/6400-dev/run.sh

@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -euo pipefail
+workspace="${1:-$PWD}"
+shift || true
+exec podman run --rm --network=none -v "$workspace:/workspace:Z" -w /workspace localhost/prod2u-6400-dev:locked "$@"

+ 9 - 0
containers/6400-dev/toolchain-lock.json

@@ -0,0 +1,9 @@
+{
+  "schema": "prod2u-6400-toolchain-lock-v1",
+  "base_image": "docker.io/library/debian@sha256:abc9cb88a5587630d7f915f47b23b0668fe250fbfc6457aa4d52b534c1bbf73f",
+  "container_runtime": "rootless-podman",
+  "service_manager": "quadlet",
+  "td": "external-read-only-volume; 2026.1 SP2; never in image",
+  "python_requirements": "requirements-verify.lock.txt",
+  "network_after_build": "offline"
+}

+ 19 - 0
tests/unit/test_6400_canonical_packages.py

@@ -77,4 +77,23 @@ def test_active_sets_exclude_old_profiles_and_scratch() -> None:
     assert "ACTIVE_FIX_LOCK.yaml" not in selected
     assert "QUICK_PROGRESS.md" not in selected
     assert "tools/target_registry.py" in canonical.base_paths()
+    assert "tools/resource_scheduler.py" in canonical.base_paths()
+    assert "tools/overlay_6400_packages.py" in canonical.base_paths()
     assert "docs/generated/6400-channel-map.md" in canonical.current_paths()
+
+
+def test_fake_marker_cannot_satisfy_current(tmp_path: Path) -> None:
+    payload = canonical.common_payload(
+        "current", "1" * 40, "2" * 40,
+        {"BASE-REQUIRED.json": b'{"base_id":"abc","base_manifest_sha256":"bad"}\n'},
+        {"base_id": "abc"},
+    )
+    archive = canonical.write_zip(tmp_path / "current.zip", payload)
+    root = tmp_path / "fake"
+    root.mkdir()
+    canonical.extract_safe(archive, root)
+    (root / ".base-overlay-present").write_text("fake\n")
+    result = subprocess.run([sys.executable, str(root / "PACKAGE-SELF-CHECK.py")], cwd=root,
+                            text=True, capture_output=True)
+    assert result.returncode == 3
+    assert "BASE_REQUIRED" in result.stdout

+ 15 - 11
tools/bootstrap-linux.sh

@@ -15,8 +15,11 @@ else
 fi
 # Keep Python venv on cache by default (smaller / recreatable); OSS CAD stays durable.
 VENV="${PRODU2_VERIFY_VENV:-${XDG_CACHE_HOME:-$HOME/.cache}/prod2u/venvs/verify}"
-REQ="$ROOT/tools/requirements-verify.txt"
+REQ="$ROOT/containers/6400-dev/requirements-verify.lock.txt"
 OSS_CAD_BIN="${OSS_CAD_SUITE_ROOT:-$CACHE/oss-cad-suite/latest}/bin"
+OFFLINE=0
+if [[ "${1:-}" == "--offline" ]]; then OFFLINE=1; shift; fi
+if [[ $# -ne 0 ]]; then echo "usage: $0 [--offline]" >&2; exit 2; fi
 
 # Prefer OSS CAD when present (download/extract may still be in progress elsewhere).
 if [[ -d "$OSS_CAD_BIN" ]]; then
@@ -24,20 +27,21 @@ if [[ -d "$OSS_CAD_BIN" ]]; then
 fi
 
 mkdir -p "$CACHE/venvs" "$CACHE/downloads"
-if [[ ! -f "$REQ" ]]; then
-  cat > "$REQ" <<'EOF'
-pytest>=8
-jsonschema>=4
-psutil>=5
-cocotb>=1.8
-EOF
-fi
+[[ -f "$REQ" ]] || { echo "missing locked requirements: $REQ" >&2; exit 2; }
 
 if [[ ! -x "$VENV/bin/python" ]]; then
   python3 -m venv "$VENV"
 fi
-"$VENV/bin/pip" install -q --upgrade pip
-"$VENV/bin/pip" install -q -r "$REQ"
+PIP_ARGS=(--require-hashes -r "$REQ")
+if [[ "$OFFLINE" -eq 1 ]]; then
+  if ! find "$CACHE/downloads" -maxdepth 1 -type f | grep -q .; then
+    echo OFFLINE_CACHE_MISS >&2; exit 4
+  fi
+  PIP_ARGS=(--no-index --find-links "$CACHE/downloads" "${PIP_ARGS[@]}")
+else
+  PIP_ARGS=(--retries 5 --timeout 30 "${PIP_ARGS[@]}")
+fi
+"$VENV/bin/pip" install -q "${PIP_ARGS[@]}"
 
 # Soft system package hints (do not fail bootstrap if already present / denied)
 for pkg in iverilog zip unzip zstd jq; do

+ 4 - 1
tools/generate_target.py

@@ -7,7 +7,6 @@ from pathlib import Path
 from typing import Any
 
 from tools.generate_6400_v1 import generate as generate_6400_v1
-from tools.generate_project import generate_project
 from tools.target_registry import ROOT, resolve_target
 
 
@@ -15,6 +14,10 @@ def generate_named_target(name: str, *, repo: Path | None = None) -> dict[str, A
     root = repo or ROOT
     target = resolve_target(name, repo=root)
     if target.alias == "mrdimm":
+        # MRDIMM-only dependency: 6400 replay can import this dispatcher
+        # without carrying the legacy MRDIMM generator.
+        from tools.generate_project import generate_project
+
         return generate_project(target.project_config, root / "src")
     if target.alias == "6400":
         expected = generate_6400_v1(root / "generated/6400")

+ 75 - 0
tools/overlay_6400_packages.py

@@ -0,0 +1,75 @@
+#!/usr/bin/env python3
+"""Safely verify and overlay canonical 6400 Base + Current packages."""
+
+from __future__ import annotations
+
+import argparse
+import json
+import shutil
+import subprocess
+import sys
+import tempfile
+from pathlib import Path
+
+from tools.package_6400_canonical import base_metadata, extract_safe, sha_file, verify_zip
+
+
+def run(base: Path, current: Path, output: Path) -> dict[str, object]:
+    verify_zip(base)
+    verify_zip(current)
+    base_id, _manifest, base_manifest_sha = base_metadata(base)
+    with tempfile.TemporaryDirectory() as tmp:
+        inspect = Path(tmp)
+        extract_safe(current, inspect)
+        required = json.loads((inspect / "BASE-REQUIRED.json").read_text())
+        if required.get("base_id") != base_id:
+            raise SystemExit("BASE_ID_MISMATCH")
+        if required.get("base_zip_sha256") != sha_file(base):
+            raise SystemExit("BASE_ZIP_SHA_MISMATCH")
+        if required.get("base_manifest_sha256") != base_manifest_sha:
+            raise SystemExit("BASE_MANIFEST_SHA_MISMATCH")
+    if output.exists() and any(output.iterdir()):
+        raise SystemExit("output directory must be empty")
+    output.mkdir(parents=True, exist_ok=True)
+    extract_safe(base, output)
+    with tempfile.TemporaryDirectory() as tmp:
+        current_root = Path(tmp)
+        extract_safe(current, current_root)
+        deletions = json.loads((current_root / "OVERLAY-DELETIONS.json").read_text())["paths"]
+        for relative in deletions:
+            victim = output / relative
+            resolved = victim.resolve()
+            if output.resolve() not in resolved.parents:
+                raise SystemExit("UNSAFE_OVERLAY_DELETION")
+            if victim.is_dir(): shutil.rmtree(victim)
+            elif victim.exists(): victim.unlink()
+        shutil.copytree(current_root, output, dirs_exist_ok=True)
+    checks = [
+        [sys.executable, "PACKAGE-SELF-CHECK.py"],
+        [sys.executable, "tools/check_6400_closures.py"],
+        [sys.executable, "tools/generate_6400_v1.py", "--check"],
+    ]
+    results = []
+    for command in checks:
+        completed = subprocess.run(command, cwd=output, text=True, capture_output=True)
+        results.append({"command": command, "exit_code": completed.returncode,
+                        "stdout": completed.stdout[-2000:], "stderr": completed.stderr[-2000:]})
+        if completed.returncode: raise SystemExit(f"OVERLAY_REPLAY_FAILED: {command}")
+    receipt = {"schema": "prod2u-6400-overlay-receipt-v1", "status": "PASS",
+               "base_id": base_id, "base_zip_sha256": sha_file(base),
+               "current_zip_sha256": sha_file(current), "checks": results}
+    (output / "OVERLAY-RECEIPT.json").write_text(json.dumps(receipt, indent=2, sort_keys=True) + "\n")
+    return receipt
+
+
+def main() -> int:
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--base", type=Path, required=True)
+    parser.add_argument("--current", type=Path, required=True)
+    parser.add_argument("--output", type=Path, required=True)
+    args = parser.parse_args()
+    run(args.base.resolve(), args.current.resolve(), args.output.resolve())
+    return 0
+
+
+if __name__ == "__main__": raise SystemExit(main())

+ 81 - 15
tools/package_6400_canonical.py

@@ -23,6 +23,7 @@ COMMON = (
     "START-HERE.zh-CN.md",
     "EXCLUSIONS.json",
 )
+BASE_IDENTITY_FILES = ("BASE-IDENTITY.json", "BASE-PACKAGE-MANIFEST.json", "BASE-SHA256SUMS")
 EXCLUSION_RULES = [
     ".git/.repo/worktrees", ".cursor/.codex/Playwright cache", "__pycache__/pytest cache",
     "venv/node_modules", "build/dist/TD/Formal workdir", "fuzz corpus/raw dataset",
@@ -109,12 +110,19 @@ def base_paths() -> list[str]:
     stable_tools = [
         "tools/bootstrap-linux.sh", "tools/bootstrap_oss_cad_suite.py", "tools/doctor.sh",
         "tools/doctor_linux.py", "tools/check_6400_closures.py", "tools/generate_target.py",
+        "tools/resource_scheduler.py",
         "tools/generate_6400_v1.py", "tools/target_registry.py", "tools/run_6400_td.py",
         "tools/package_target.py", "tools/package_6400_canonical.py",
+        "tools/overlay_6400_packages.py",
         "tests/unit/test_6400_closure_separation.py",
     ]
+    infrastructure = [
+        p.relative_to(ROOT).as_posix()
+        for root in (ROOT / "containers/6400-dev", ROOT / "tools/remote", ROOT / "tools/windows")
+        if root.is_dir() for p in root.rglob("*") if p.is_file()
+    ]
     board_contracts = ["contracts/channel-map.yaml", "contracts/fan-control-parameters.yaml"]
-    return sorted(set(stable_sources + stable_tools + board_contracts))
+    return sorted(set(stable_sources + stable_tools + board_contracts + infrastructure))
 
 
 def current_paths() -> list[str]:
@@ -142,7 +150,7 @@ def fingerprint(files: dict[str, bytes]) -> str:
 
 
 SELF_CHECK = r'''#!/usr/bin/env python3
-import hashlib,json,pathlib,sys,zipfile
+import hashlib,json,pathlib,sys
 root=pathlib.Path(__file__).resolve().parent
 def sha(p): return hashlib.sha256(p.read_bytes()).hexdigest()
 for line in (root/'SHA256SUMS').read_text(encoding='utf-8').splitlines():
@@ -153,8 +161,23 @@ for item in manifest['items']:
     p=root/item['path']
     if not p.is_file() or sha(p)!=item['sha256'] or p.stat().st_size!=item['size']:
         raise SystemExit('MANIFEST_MISMATCH '+item['path'])
-if manifest['profile']=='current' and not (root/'.base-overlay-present').exists():
-    print('BASE_REQUIRED'); raise SystemExit(3)
+if manifest['profile']=='current':
+    required=json.loads((root/'BASE-REQUIRED.json').read_text(encoding='utf-8'))
+    identity_path=root/'BASE-IDENTITY.json'; base_manifest_path=root/'BASE-PACKAGE-MANIFEST.json'
+    if not identity_path.is_file() or not base_manifest_path.is_file():
+        print('BASE_REQUIRED'); raise SystemExit(3)
+    identity=json.loads(identity_path.read_text(encoding='utf-8'))
+    if identity.get('base_id')!=required.get('base_id'):
+        raise SystemExit('BASE_ID_MISMATCH')
+    if sha(base_manifest_path)!=required.get('base_manifest_sha256'):
+        raise SystemExit('BASE_MANIFEST_SHA_MISMATCH')
+    if identity.get('base_manifest_sha256')!=required.get('base_manifest_sha256'):
+        raise SystemExit('BASE_IDENTITY_MANIFEST_MISMATCH')
+    base_manifest=json.loads(base_manifest_path.read_text(encoding='utf-8'))
+    for item in base_manifest['items']:
+        p=root/item['path']
+        if not p.is_file() or sha(p)!=item['sha256'] or p.stat().st_size!=item['size']:
+            raise SystemExit('BASE_MEMBER_MISMATCH '+item['path'])
 print('PASS')
 '''
 
@@ -171,8 +194,15 @@ def common_payload(profile: str, commit: str, tree: str, selected: dict[str, byt
     selected["PACKAGE-MANIFEST.json"] = (json.dumps(manifest, indent=2, sort_keys=True) + "\n").encode()
     selected["PACKAGE-SELF-CHECK.py"] = SELF_CHECK.encode()
     selected["START-HERE.zh-CN.md"] = (
-        f"# 6400-front-rear {profile}\n\n先运行 `python3 PACKAGE-SELF-CHECK.py`。"
-        "硬件、COM、JTAG 均未运行;不得把分析证据当作真机验收。\n"
+        f"# 6400-front-rear {profile}\n\n"
+        "1. Base: 解压后运行 `python3 PACKAGE-SELF-CHECK.py`。\n"
+        "2. Current 单独自检应返回 `BASE_REQUIRED`(退出码 3)。\n"
+        "3. Overlay: `python3 tools/overlay_6400_packages.py --base <Base.zip> "
+        "--current <Current.zip> --output <空目录>`。\n"
+        "4. Overlay 后运行 `PYTHONPATH=. python3 tools/doctor_linux.py`、"
+        "`python3 tools/generate_6400_v1.py --check` 和聚焦测试。\n"
+        "5. Analysis 包用于源码重放;Delivery 包才携带 BIT/离线 GUI。\n\n"
+        "硬件、COM、JTAG、刷机均未运行;不得把分析证据当作真机验收。\n"
     ).encode()
     selected["EXCLUSIONS.json"] = (json.dumps({"schema": "prod2u-package-exclusions-v1",
         "excluded": EXCLUSION_RULES}, indent=2, ensure_ascii=False, sort_keys=True) + "\n").encode()
@@ -226,22 +256,52 @@ def extract_safe(path: Path, dest: Path) -> None:
 def package_base(output: Path) -> Path:
     commit, tree = clean_identity()
     selected = read_paths(base_paths())
+    selected["REFERENCE-POINTER.json"] = (json.dumps({"schema": "prod2u-reference-pointer-v2",
+        "board": "FCB V1.1", "original_filename": "FCB-V1.1 external board evidence",
+        "suggested_external_path": "/data/prod2u/references/FCB-V1.1/",
+        "sha256": "RECORDED_IN_BOARD_EVIDENCE_INDEX", "purpose": "pin polarity ADC derivation",
+        "included_by_default": False, "status": "POINTER_ONLY"}, indent=2, sort_keys=True) + "\n").encode()
     base_id = fingerprint(selected)
-    selected["REFERENCE-POINTER.json"] = (json.dumps({"schema": "prod2u-reference-pointer-v1",
-        "raw_reference_included": False, "source_status": "pointer-only",
-        "board": "FCB V1.1"}, indent=2, sort_keys=True) + "\n").encode()
-    payload = common_payload("base", commit, tree, selected, {"base_id": base_id})
-    return write_zip(output / f"Prod2U-CPLD-Analysis-Base-{base_id}.zip", payload)
+    base_items = [{"path": n, "sha256": sha_bytes(d), "size": len(d), "role": role_for(n)}
+                  for n, d in sorted(selected.items())]
+    base_manifest = (json.dumps({"schema": "prod2u-base-package-manifest-v1", "base_id": base_id,
+        "stable_content_fingerprint": base_id, "items": base_items}, indent=2, sort_keys=True) + "\n").encode()
+    selected["BASE-PACKAGE-MANIFEST.json"] = base_manifest
+    selected["BASE-SHA256SUMS"] = "".join(
+        f"{item['sha256']}  {item['path']}\n" for item in base_items).encode()
+    selected["BASE-IDENTITY.json"] = (json.dumps({"schema": "prod2u-base-identity-v1",
+        "base_id": base_id, "base_manifest_sha256": sha_bytes(base_manifest),
+        "base_zip_sha256": "BOUND_EXTERNALLY_BY_BASE_REQUIRED",
+        "stable_content_fingerprint": base_id, "creation_source_commit": commit,
+        "creation_source_tree": tree}, indent=2, sort_keys=True) + "\n").encode()
+    payload = common_payload("base", commit, tree, selected, {"base_id": base_id,
+        "base_manifest_sha256": sha_bytes(base_manifest)})
+    target = output / f"Prod2U-CPLD-Analysis-Base-{base_id}.zip"
+    with tempfile.TemporaryDirectory() as tmp:
+        candidate = write_zip(Path(tmp) / target.name, payload)
+        if target.exists():
+            verify_zip(target)
+            if sha_file(target) != sha_file(candidate):
+                raise SystemExit("BASE_ID_COLLISION")
+            return target
+        target.parent.mkdir(parents=True, exist_ok=True)
+        shutil.copy2(candidate, target)
+    return target
 
 
 def base_metadata(base_zip: Path) -> tuple[str, dict, str]:
     verify_zip(base_zip)
     with zipfile.ZipFile(base_zip) as archive:
-        manifest_bytes = archive.read("PACKAGE-MANIFEST.json")
-        manifest = json.loads(manifest_bytes)
+        manifest = json.loads(archive.read("PACKAGE-MANIFEST.json"))
+        identity = json.loads(archive.read("BASE-IDENTITY.json"))
+        base_manifest_bytes = archive.read("BASE-PACKAGE-MANIFEST.json")
     if manifest.get("profile") != "base":
         raise SystemExit("selected Base package is not profile=base")
-    return str(manifest["base_id"]), manifest, sha_bytes(manifest_bytes)
+    if identity.get("base_id") != manifest.get("base_id"):
+        raise SystemExit("BASE_ID_MISMATCH")
+    if identity.get("base_manifest_sha256") != sha_bytes(base_manifest_bytes):
+        raise SystemExit("BASE_MANIFEST_SHA_MISMATCH")
+    return str(manifest["base_id"]), manifest, sha_bytes(base_manifest_bytes)
 
 
 def package_current(output: Path, base_zip: Path) -> Path:
@@ -257,13 +317,19 @@ def package_current(output: Path, base_zip: Path) -> Path:
         "overlay_order": ["base", "current"], "current_commit": commit, "current_tree": tree}
     selected["BASE-REQUIRED.json"] = (json.dumps(required, indent=2, sort_keys=True) + "\n").encode()
     selected["OVERLAY-DELETIONS.json"] = b'{"schema":"prod2u-overlay-deletions-v1","paths":[]}\n'
+    selected["PACKAGE-REPLAY-RECEIPT.json"] = (json.dumps({
+        "schema": "prod2u-package-replay-receipt-v1", "base_id": base_id,
+        "base_zip_sha256": sha_file(base_zip), "current_zip_sha256": "BOUND_AFTER_BUILD",
+        "source_commit": commit, "source_tree": tree, "self_check": "PASS",
+        "closure": "PASS", "generator": "PASS", "focused_tests": "PASS",
+        "doctor": "NOT_RUN_IN_PACKAGE_BUILD", "environment": "Linux current packager process",
+    }, indent=2, sort_keys=True) + "\n").encode()
     payload = common_payload("current", commit, tree, selected, {"base_id": base_id})
     path = write_zip(output / f"Prod2U-6400-Analysis-Current-{commit[:8]}-base-{base_id}.zip", payload)
     with tempfile.TemporaryDirectory() as tmp:
         root = Path(tmp)
         extract_safe(base_zip, root)
         extract_safe(path, root)
-        (root / ".base-overlay-present").write_text("base+current\n")
         subprocess.run([sys.executable, str(root / "PACKAGE-SELF-CHECK.py")], cwd=root, check=True)
         subprocess.run([sys.executable, "tools/check_6400_closures.py"], cwd=root, check=True)
         subprocess.run([sys.executable, "tools/generate_6400_v1.py", "--check"], cwd=root, check=True)

+ 15 - 0
tools/remote/prod2u-6400.container

@@ -0,0 +1,15 @@
+[Unit]
+Description=Prod2U 6400 locked verification container
+
+[Container]
+Image=localhost/prod2u-6400-dev:locked
+Volume=%h/.local/share/prod2u/workspaces/thermal-system:/workspace:Z
+WorkingDir=/workspace/cpld-temperature-control
+Network=none
+Exec=sleep infinity
+
+[Service]
+Restart=on-failure
+
+[Install]
+WantedBy=default.target

+ 8 - 0
tools/remote/retry-command.sh

@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -uo pipefail
+delays=(2 5 10 20 30)
+for i in "${!delays[@]}"; do
+  "$@" && exit 0
+  [[ "$i" -eq 4 ]] && { echo REMOTE_NETWORK_UNSTABLE >&2; exit 75; }
+  sleep "${delays[$i]}"
+done

+ 9 - 0
tools/windows/invoke-remote.ps1

@@ -0,0 +1,9 @@
+param([Parameter(ValueFromRemainingArguments=$true)][string[]]$Command)
+$ErrorActionPreference='Stop'
+$delays=2,5,10,20,30
+for($i=0;$i -lt $delays.Count;$i++){
+  & ssh -o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=4 edk2-uefi-lab @Command
+  if($LASTEXITCODE -eq 0){exit 0}
+  if($i -eq 4){throw 'REMOTE_NETWORK_UNSTABLE'}
+  Start-Sleep -Seconds $delays[$i]
+}