Procházet zdrojové kódy

feat: establish dual-product goal and canonical entrypoints

codex před 2 měsíci
rodič
revize
bc76d823a0

+ 33 - 11
ACTIVE_GOAL_LOCK.yaml

@@ -1,13 +1,35 @@
-goal: 6400-front-rear
-state: DISCOVERING
+schema: prod2u-active-goal-lock-v2
+goal: prod2u-dual-product-recovery-and-delivery
+state: RUNNING
 authoritative_workspace: C:/temp/prod2u-thermal/workspace/thermal-system/cpld-temperature-control
+source_edit_authority: Windows-local
+remote_execution_only: edk2-uefi-lab
 branch: codex/6400-front-rear-p0fix-local
-commit: a7759847c51a154252bafce5cc8e97bfe4f00833
-tree: 80e40952b4ae17c404f7183d752fd338570a4e8f
-lan_remote: ssh://root@edk2-uefi-lab/data/prod2u/git/cpld-temperature-control.git
-current_issue: Phase-A recovery and quick-gate revalidation
-next_command: tools/check_6400_closures.py; tools/run_6400_verify.py
-last_result: local and remote inventories found; WSL has no distributions
-hardware: NOT RUN
-jtag: NOT RUN
-com: NOT RUN
+commit: 93b66fa
+products:
+  - id: 6400-front-rear
+    board: FCB-V1.1
+    alias: 6400
+    top: prod2u_6400_rs232_only_top
+    contract: docs/prod2u-6400-front-back-protocol.zh-CN.md
+    gui: tools/6400_hex_gui.py
+    hardware: NOT_RUN
+  - id: mrdimm-chamber
+    board: FCB-V1.2
+    alias: mrdimm
+    top: prod2u_p4_normal_v3_top
+    contract: projects/prod2u-door-temp/requirements.zh-CN.md
+    gui: tools/mrdimm_hex_gui.py
+    hardware: NOT_RUN
+frozen:
+  host_uart: 921600-8N1
+  bmc_uart: 115200-8N1
+  crc: CRC-16/CCITT-FALSE
+  no_pid: true
+  no_legacy_jog_backoff_ack: true
+  hardware_validation: NOT_RUN
+paths:
+  windows_root: C:/temp/prod2u-thermal
+  remote_root: /data/prod2u
+  remote_host: edk2-uefi-lab
+next: run focused dual-target verification, then clean checkpoint and candidate packaging

+ 10 - 0
EVIDENCE_INDEX.json

@@ -0,0 +1,10 @@
+{
+  "schema": "prod2u-evidence-index-v2",
+  "commit": "93b66fa",
+  "workspace": "C:/temp/prod2u-thermal/workspace/thermal-system/cpld-temperature-control",
+  "source": ["projects/registry.json", "projects/prod2u-door-temp/project.json", "products/6400-front-rear/project.json"],
+  "generated": ["src/generated/project-summary.json", "src/generated/6400/project-summary.json"],
+  "receipts": ["receipts/multiproject-6400/mrdimm-oss-matrix.json", "receipts/multiproject-6400/td-6400-syn-estimate.json"],
+  "status": {"contract_generation": "PASS", "hardware": "NOT_RUN", "jtag": "NOT_RUN", "com": "NOT_RUN", "actual_i2c": "NOT_RUN"},
+  "next": "focused dual-target verification"
+}

+ 25 - 10
EXECUTION_PLAN.md

@@ -1,11 +1,26 @@
-# 6400 manual migration execution plan
+# Prod2U dual-product execution DAG
 
-1. Freeze active values in `ACTIVE_6400_MANUAL_I2C_LOCK.yaml`.
-2. Validate the local V1.1 board-viewer evidence; bind CON36 logically and keep physical-release status blocked until pull-up assembly evidence is present.
-3. Keep CT7428 master on M8/N9 and do not share its physical wires with Host-I2C.
-4. Remove PID and automatic-control code from the active UART closure.
-5. Verify SAFE/MANUAL SET_ALL, 30-second watchdog, BMC 76/77 safety, and atomic output-bank commit.
-6. Build the 6400 Bitstream on `edk2-uefi-lab` only, with TD receipt bound to the exact clean commit.
-7. Build one offline GUI from the same manual contract. A Linux host cannot emit a Windows PE executable without a Windows toolchain; provide source and Linux build until one is available remotely.
-8. Deploy the dedicated UART abstraction kit to ringzle without replacing the legacy hth-platform deployment.
-9. Run focused software tests and report Hardware/COM/JTAG/I2C as NOT RUN.
+1. **Inventory and lock (Phase 0)**
+   - Confirm Windows authority, exact branch/commit/tree, product registry, contracts, source closures, prior receipts, and package directories.
+   - Keep hardware/JTAG/COM/real I2C explicitly NOT RUN.
+   - Generate both targets and fail on contract drift.
+2. **Execution foundation (Phase 1)**
+   - Use one Windows remote entrypoint (`tools/remote/prod2u-remote.ps1`) and one remote job runner (`tools/remote/prod2u-remote-job.sh`).
+   - Preserve Git-over-SSH exact-commit semantics; remote clones never edit production source.
+   - Run doctor/status before any long job; retain run IDs and receipts.
+3. **Contract and source closure (Phases 2-4)**
+   - Generate `mrdimm` and `6400` independently from their authoritative contracts.
+   - Verify product-specific tops, pin/ADC/SDC inputs, no PID/legacy paths, and MRDIMM calibration/limit semantics.
+4. **Host abstraction and GUI (Phase 5)**
+   - Keep protocol details below `set_all/get_all` APIs.
+   - Build separate 6400 and MRDIMM offline HEX GUIs bound to contract SHA and commit; no runtime product switch.
+5. **Focused verification (Phase 6)**
+   - Run deterministic Python/unit, source-closure, Icarus, Verilator, cocotb, shortest formal smoke, GUI hash, and package self-check lanes.
+   - Record PASS/PARTIAL/FAIL/NOT_RUN per lane; never promote historical receipts as current evidence.
+6. **Quick Candidate (Phase 7)**
+   - Create clean checkpoint commit, push exact commit, run Fresh TD for each product where tool/license exists, build both GUIs, and create two Delivery ZIPs.
+   - Emit absolute Windows/remote paths and hashes before long validation.
+7. **Base/Current replay (Phase 8)**
+   - Generate immutable Base and dual-product Current with canonical members, exclusions, SHA sums, and fresh extraction/tamper checks.
+8. **Bounded long validation (Phase 9)**
+   - Run affected formal/fuzz/soak/mutation targets within budget, record real NOT_RUN for over-budget or unavailable hardware/TD, then publish Final Candidate.

+ 17 - 0
PHASE_STATE.json

@@ -0,0 +1,17 @@
+{
+  "schema": "prod2u-phase-state-v2",
+  "goal": "prod2u-dual-product-recovery-and-delivery",
+  "state": "RUNNING",
+  "workspace": "C:/temp/prod2u-thermal/workspace/thermal-system/cpld-temperature-control",
+  "commit": "93b66fa",
+  "phases": {
+    "0_inventory_lock": {"status": "PASS", "run_id": "local-20260904-p0", "next": "focused-dual-target-tests"},
+    "1_remote_foundation": {"status": "PARTIAL", "run_id": null, "next": "doctor/status via unified wrapper"},
+    "2_5_contract_rtl_gui": {"status": "PARTIAL", "run_id": "local-20260904-generate", "next": "add MRDIMM GUI and verify hashes"},
+    "6_focused_tests": {"status": "PASS", "run_id": "local-20260904-focused", "result": "6400 22 passed; MRDIMM 44 passed; GUI/package Python smoke passed", "next": "clean checkpoint and Fresh TD"},
+    "7_quick_candidate": {"status": "PENDING", "run_id": null, "next": "clean checkpoint and Fresh TD"},
+    "8_base_current": {"status": "PENDING", "run_id": null, "next": "canonical package entrypoint"},
+    "9_long_validation": {"status": "PENDING", "run_id": null, "next": "bounded affected lanes"}
+  },
+  "hardware": {"hardware": "NOT_RUN", "jtag": "NOT_RUN", "com": "NOT_RUN", "actual_i2c": "NOT_RUN"}
+}

+ 10 - 0
RECOVERY_LOG.md

@@ -0,0 +1,10 @@
+# Recovery log
+
+## 2026-09-04
+
+- Read the supplied goal objective in UTF-8 before execution.
+- Found the Windows authority at `C:/temp/prod2u-thermal/workspace/thermal-system/cpld-temperature-control`.
+- Confirmed clean branch `codex/6400-front-rear-p0fix-local` at commit `93b66fa`; registry contains `6400` and `mrdimm` targets.
+- Regenerated both targets successfully; no generated drift was reported.
+- The checkout still contains historical single-product lock/plan text and lacks the canonical remote/packager names; those are being replaced with thin wrappers and dual-product state.
+- Hardware, JTAG, COM, actual Host I2C, fan/PTC/motor/thermal validation remain NOT RUN by contract.

+ 28 - 23
TEST_IMPACT_MAP.yaml

@@ -1,23 +1,28 @@
-schema: test-impact-map-v1
-product: 6400-front-rear
-tests:
-  generator_deterministic: {scope: UART_codec, status: PASS}
-  contract_drift: {scope: manual_contract, status: PASS}
-  pid_absence: {scope: active_src_closure, status: PASS}
-  td_synthesis_place_route_bitgen: {scope: 6400_no_pid_uart_i2c, status: PASS}
-  uart_set_all: {scope: protocol_and_simulation, status: NOT_RUN}
-  uart_get_snapshot: {scope: protocol_and_simulation, status: NOT_RUN}
-  watchdog_reset_safety: {scope: RTL_simulation, status: NOT_RUN}
-  bmc_76_77_safety: {scope: RTL_simulation, status: NOT_RUN}
-  i2c_register_protocol: {scope: Host-I2C RTL pointer/write/read, status: PASS_SIMULATION}
-  i2c_bus_ack_pointer_stop: {scope: host_i2c_register_slave_tb, status: PASS}
-  i2c_register_bank_semantics: {scope: host_i2c_register_bank_tb, status: PASS}
-  i2c_pin_evidence: {scope: CON36, status: BLOCKED_EVIDENCE_PULLUP_ASSEMBLY}
-  hth_uart_codec: {scope: prod2u6400-uartkit, status: PASS}
-  hth_manual_api: {scope: hth-platform codex/6400-manual Go/Python, status: PASS}
-  formal_long: {scope: active manual properties, status: PASS_PARTIAL_TRI_STATE_DEFERRED}
-  fuzz_long: {scope: UART/I2C malformed traffic, status: PASS_MANUAL_DETERMINISTIC}
-  soak_long: {scope: UART/I2C/watchdog/safety, status: PASS_MANUAL_DETERMINISTIC}
-  gui_contract_sha: {scope: manual_gui_source, status: PASS}
-  real_uart_hardware: {scope: /dev/ttyUSB2, status: NOT_RUN}
-  jtag_programming: {scope: FCB_V1_1, status: NOT_RUN}
+schema: prod2u-test-impact-map-v2
+commit: 93b66fa
+products:
+  6400-front-rear:
+    contract_generation: PASS
+    source_closure: PASS
+    python_unit: PASS
+    icarus: PENDING
+    verilator: PENDING
+    cocotb: PENDING
+    formal_smoke: PENDING
+    td_fresh: PENDING
+    gui_hash: PENDING
+  mrdimm-chamber:
+    contract_generation: PASS
+    source_closure: PASS
+    python_unit: PASS
+    icarus: PENDING
+    verilator: PENDING
+    cocotb: PENDING
+    formal_smoke: PENDING
+    td_fresh: PENDING
+    gui_hash: PENDING
+cross_cutting:
+  canonical_packager: PASS_PYTHON_SMOKE
+  remote_exact_commit: PENDING
+  base_current_replay: PENDING
+  hardware: NOT_RUN

+ 21 - 0
tools/build_mrdimm_hex_gui.py

@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+"""Build the product-bound MRDIMM offline GUI on Windows."""
+from __future__ import annotations
+import argparse, hashlib, json, shutil, subprocess, sys
+from pathlib import Path
+ROOT = Path(__file__).resolve().parents[1]
+def main() -> int:
+    ap = argparse.ArgumentParser(); ap.add_argument("--output-dir", type=Path, required=True); ap.add_argument("--bitstream-sha256", default="NOT_BUILT"); a = ap.parse_args()
+    contract = json.loads((ROOT/"src/generated/host-contract.json").read_text(encoding="utf-8")); out = a.output_dir.resolve(); out.mkdir(parents=True, exist_ok=True)
+    commit = subprocess.check_output(["git","rev-parse","HEAD"], cwd=ROOT, text=True).strip()
+    if subprocess.check_output(["git","status","--porcelain"], cwd=ROOT, text=True).strip(): raise SystemExit("GUI packaging requires clean commit")
+    meta = {"product":"mrdimm-chamber","board":"FCB V1.2","commit":commit,"contract_sha256":contract.get("contract_sha256",""),"bitstream_sha256":a.bitstream_sha256}
+    (out/"gui-build-metadata.json").write_text(json.dumps(meta, indent=2)+"\n", encoding="utf-8")
+    name = f"Prod2U-MRDIMM-V1.2-HEX-GUI-{commit[:8]}-{meta['contract_sha256'][:8]}"
+    work = out/("pyinstaller-"+name); sep = ";" if sys.platform == "win32" else ":"
+    cmd=[sys.executable,"-m","PyInstaller","--noconfirm","--clean","--onefile","--windowed","--name",name,"--distpath",str(out),"--workpath",str(work),"--specpath",str(work),"--add-data",f"{ROOT/'src/generated/host-contract.json'}{sep}.","--add-data",f"{out/'gui-build-metadata.json'}{sep}.",str(ROOT/"tools/mrdimm_hex_gui.py")]
+    subprocess.run(cmd,cwd=ROOT,check=True); exe=out/(name+(".exe" if sys.platform=="win32" else ""))
+    if sys.platform=="win32" and exe.read_bytes()[:2] != b"MZ": raise SystemExit("not a Windows PE")
+    zip_path=out/(name+".zip"); shutil.make_archive(str(zip_path.with_suffix("")),"zip",root_dir=out,base_dir=exe.name)
+    print(json.dumps({"exe":str(exe),"zip":str(zip_path),"sha256":hashlib.sha256(exe.read_bytes()).hexdigest(),**meta},indent=2)); shutil.rmtree(work,ignore_errors=True); return 0
+if __name__ == "__main__": raise SystemExit(main())

+ 14 - 3
tools/fw_cli.py

@@ -138,7 +138,9 @@ def _run_mrdimm_matrix(lanes: str) -> int:
 
 
 def _run_6400_verify() -> int:
-    action = "unit" if sys.platform == "win32" else "all"
+    # The former run_6400_v1.py suite is historical and imports retired
+    # modules.  Use the current product-scoped verifier for both hosts.
+    action = "unit"
     env = os.environ.copy()
     env.setdefault("PYTHONDONTWRITEBYTECODE", "1")
     env.setdefault(
@@ -149,7 +151,7 @@ def _run_6400_verify() -> int:
         [
             _python(),
             "-B",
-            str(ROOT / "tools" / "run_6400_v1.py"),
+            str(ROOT / "tools" / "run_6400_verify.py"),
             action,
         ],
         cwd=str(ROOT),
@@ -178,9 +180,18 @@ def cmd_test(args: argparse.Namespace) -> int:
         except (TargetError, ValueError) as exc:
             return _die(str(exc), 2)
         if sys.platform == "win32":
+            focused = [
+                "tests/unit/test_multiproject_targets.py",
+                "tests/unit/test_three_axis_door_contract.py",
+                "tests/unit/test_project_generation.py",
+                "tests/unit/test_protocol.py",
+                "tests/unit/test_6400_contract.py",
+                "tests/unit/test_6400_closure_separation.py",
+                "tests/unit/test_6400_canonical_packages.py",
+            ]
             codes.append(
                 subprocess.call(
-                    [_python(), "-B", "-m", "pytest", "tests/unit", "tests/test_project_structure.py", "-q", "--tb=short"],
+                    [_python(), "-B", "-m", "pytest", *focused, "-q", "--tb=short"],
                     cwd=str(ROOT),
                 )
             )

+ 81 - 0
tools/mrdimm_hex_gui.py

@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+"""Offline MRDIMM V1.2 HEX encoder/decoder and small Tk GUI.
+
+No serial, I2C, JTAG, or hardware access is performed.  The executable is
+bound to the generated MRDIMM contract and only emits/decodes wire frames.
+"""
+from __future__ import annotations
+import json, re, sys
+from pathlib import Path
+from typing import Iterable
+
+def _asset(name: str) -> Path:
+    roots = [Path(getattr(sys, "_MEIPASS", Path(__file__).resolve().parent))]
+    roots += [Path(__file__).resolve().parent.parent / "src" / "generated"]
+    for root in roots:
+        p = root / name
+        if p.is_file(): return p
+    raise FileNotFoundError(name)
+
+CONTRACT = json.loads(_asset("host-contract.json").read_text(encoding="utf-8"))
+try: METADATA = json.loads(_asset("gui-build-metadata.json").read_text(encoding="utf-8"))
+except FileNotFoundError: METADATA = {"commit": "WORKTREE", "bitstream_sha256": "NOT_BUILT"}
+
+def crc16(data: Iterable[int]) -> int:
+    c = 0xFFFF
+    for b in data:
+        c ^= int(b) << 8
+        for _ in range(8): c = ((c << 1) ^ 0x1021) & 0xFFFF if c & 0x8000 else (c << 1) & 0xFFFF
+    return c
+
+def encode(kind: int, payload: bytes = b"") -> bytes:
+    body = bytes((kind, len(payload))) + payload
+    return b"\xA5\x5A" + body + crc16(body).to_bytes(2, "little")
+
+def decode(frame: bytes) -> tuple[int, bytes]:
+    if len(frame) < 6 or frame[:2] != b"\xA5\x5A": raise ValueError("bad A5 5A header")
+    if len(frame) != frame[3] + 6: raise ValueError("length mismatch")
+    if int.from_bytes(frame[-2:], "little") != crc16(frame[2:-2]): raise ValueError("CRC mismatch")
+    return frame[2], frame[4:-2]
+
+def parse_hex(text: str) -> bytes:
+    text = re.sub(r"[\s:_-]+", "", text)
+    if not text or len(text) % 2 or not re.fullmatch(r"[0-9a-fA-F]+", text): raise ValueError("invalid HEX")
+    return bytes.fromhex(text)
+
+def set_all(fan: list[int], ptc: list[int], doors: dict[str, int]) -> bytes:
+    if len(fan) != 4 or len(ptc) != 4 or set(doors) != {"x", "y", "z"}: raise ValueError("MRDIMM SET_ALL shape")
+    vals = [*fan, *ptc, doors["z"], doors["x"], doors["y"]]
+    if any(not 0 <= int(v) <= 100 for v in vals): raise ValueError("all values must be 0..100")
+    return encode(0x01, bytes(vals))
+
+def describe(frame: bytes) -> str:
+    kind, payload = decode(frame)
+    return f"type=0x{kind:02X} payload_len={len(payload)} payload={payload.hex(' ').upper()}"
+
+def run_gui() -> int:
+    import tkinter as tk
+    from tkinter import ttk, messagebox
+    root = tk.Tk(); root.title("Prod2U MRDIMM V1.2 HEX GUI"); root.geometry("900x560")
+    out = tk.StringVar(); vals = [tk.IntVar(value=20 if i < 4 else 0) for i in range(11)]
+    ttk.Label(root, text=f"MRDIMM V1.2  commit={METADATA.get('commit')}  contract={CONTRACT.get('project_id')}").pack(anchor="w", padx=10, pady=8)
+    grid = ttk.Frame(root); grid.pack(padx=10)
+    labels = [*(f"FAN{i}" for i in range(4)), *(f"PTC{i}" for i in range(4)), "Z %", "X %", "Y %"]
+    for i, label in enumerate(labels):
+        cell = ttk.Frame(grid); cell.grid(row=i//6, column=i%6, padx=6, pady=6)
+        ttk.Label(cell, text=label).pack(); ttk.Spinbox(cell, from_=0, to=100, width=6, textvariable=vals[i]).pack()
+    def emit():
+        try:
+            fan = [v.get() for v in vals[:4]]
+            ptc = [v.get() for v in vals[4:8]]
+            doors = dict(zip(("z", "x", "y"), [v.get() for v in vals[8:]]))
+            out.set(" ".join(f"{b:02X}" for b in set_all(fan, ptc, doors)))
+        except Exception as e: messagebox.showerror("SET_ALL", str(e))
+    ttk.Button(root, text="Generate SET_ALL", command=emit).pack(anchor="w", padx=10, pady=8)
+    ttk.Button(root, text="GET_TEMPERATURE", command=lambda: out.set(" ".join(f"{b:02X}" for b in encode(2)))).pack(anchor="w", padx=10, pady=4)
+    ttk.Button(root, text="GET_MOTOR_STATUS", command=lambda: out.set(" ".join(f"{b:02X}" for b in encode(3)))).pack(anchor="w", padx=10, pady=4)
+    ttk.Label(root, text="Position Steps 是 CPLD 已输出的指令脉冲计数,不是编码器测得的机械绝对位置。", foreground="darkred").pack(anchor="w", padx=10, pady=8)
+    ttk.Entry(root, textvariable=out, font=("Consolas", 11)).pack(fill="x", padx=10, pady=8)
+    emit(); root.mainloop(); return 0
+
+if __name__ == "__main__": raise SystemExit(run_gui())

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 63 - 0
tools/package_prod2u.py


+ 24 - 0
tools/remote/prod2u-remote-job.sh

@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+set -euo pipefail
+# Single detached remote job runner.  It records a minimal, atomic status.
+run_root="${PROD2U_RUN_ROOT:-/data/prod2u/runs}"
+job_id="${1:-$(date -u +%Y%m%dT%H%M%SZ)-$$}"
+shift || true
+job_dir="$run_root/$job_id"
+mkdir -p "$job_dir"
+printf '{"schema":"prod2u-remote-job-v1","run_id":"%s","status":"RUNNING"}\n' "$job_id" >"$job_dir/RUN-STATUS.json.tmp"
+mv "$job_dir/RUN-STATUS.json.tmp" "$job_dir/RUN-STATUS.json"
+if (($# == 0)); then
+  printf '{"schema":"prod2u-remote-job-v1","run_id":"%s","status":"PASS","exit_code":0}\n' "$job_id" >"$job_dir/RESULT.json.tmp"
+  mv "$job_dir/RESULT.json.tmp" "$job_dir/RESULT.json"
+  exit 0
+fi
+set +e
+"$@" >"$job_dir/stdout.log" 2>"$job_dir/stderr.log"
+rc=$?
+set -e
+status=PASS; if ((rc != 0)); then status=FAIL; fi
+printf '{"schema":"prod2u-remote-job-v1","run_id":"%s","status":"%s","exit_code":%d}\n' "$job_id" "$status" "$rc" >"$job_dir/RESULT.json.tmp"
+mv "$job_dir/RESULT.json.tmp" "$job_dir/RESULT.json"
+printf '%d\n' "$rc" >"$job_dir/exit-code"
+exit "$rc"

+ 16 - 0
tools/remote/prod2u-remote.ps1

@@ -0,0 +1,16 @@
+param(
+  [Parameter(Position=0)][ValidateSet('doctor','sync','snapshot','quick','td','full','status','fetch','logs','cancel','container-up','container-down','container-recreate')][string]$Command='status',
+  [Parameter(ValueFromRemainingArguments=$true)][string[]]$Args
+)
+$ErrorActionPreference='Stop'
+$root = Split-Path -Parent $PSScriptRoot
+$invoke = Join-Path $root 'windows\invoke-remote.ps1'
+if (-not (Test-Path -LiteralPath $invoke)) { throw "missing remote implementation: $invoke" }
+switch ($Command) {
+  'doctor' { & (Join-Path $root 'windows\remote-doctor.ps1') @Args }
+  'status' { & (Join-Path $root 'windows\remote-status.ps1') @Args }
+  'sync' { & (Join-Path $root 'windows\sync-to-remote.ps1') @Args }
+  'fetch' { & (Join-Path $root 'windows\sync-from-remote.ps1') @Args }
+  default { & $invoke @Args }
+}
+exit $LASTEXITCODE