Просмотр исходного кода

docs(protocol,release): maintain docs/CPLD_通讯协议v2.0.md (v3.2.0) and auto-bundle/deploy on every release

Prod2U Recovery 6 дней назад
Родитель
Сommit
d52af1f8ce

+ 3 - 3
AGENTS.md

@@ -38,11 +38,11 @@
 ## 4. Verification, Packaging & Tool Recovery Guardrails
 
 - **TD Fit Gate**: Invoke `./tools/td2026` (`/data/prod2u/toolchain/TD_Release_2026.1_SP2_NL`, license valid to `2027-09-30`; NEVER use expired `/data/anlogic/...`). LUT, Slice subtypes, BRAM/ERAM, DSP, and IO must sit strictly below physical device limits (e.g. LUT < 4480) AND pass 25 MHz setup/hold with a generated `.bit`. Never disable axes or fake fit; never bypass vendor license checks.
-- **Remote Services & Delivery**: Board viewer on `http://192.168.2.25:8765/` (`board-viewer.service`, `/srv/board-viewer`); privileged thermal test platform `prod2u-thermal-test-backend` on `root@192.168.2.25:8766` (`tools/thermal_test_server.py`); Windows EXE & release delivery target `administrator@192.168.2.24` (`C:\Prod2U_Releases\`).
-- **Tool/Network Bounds**: Reuse `remote_job.py` / `remote_transfer.py` in background; network retry max 5; formal run 600s max killing full process group on timeout. Packaging maintains `tools/package_prod2u.py` & `tools/package_unified_analysis.py` (deterministic POSIX paths, explicit checksums).
+- **Remote Services & Delivery**: Board viewer on `http://192.168.2.25:8765/` (`board-viewer.service`, `/srv/board-viewer`); privileged thermal test platform `prod2u-thermal-test-backend` on `root@192.168.2.25:8766` (`tools/thermal_test_server.py`); Windows EXE, source/debug packages & maintained protocol doc (`docs/CPLD_通讯协议v2.0.md`) delivery target `administrator@192.168.2.24` (`C:\Prod2U_Releases\`).
+- **Tool/Network Bounds**: Reuse `remote_job.py` / `remote_transfer.py` in background; network retry max 5; formal run 600s max killing full process group on timeout. Packaging maintains `tools/package_prod2u.py` & `tools/package_unified_analysis.py` (deterministic POSIX paths, explicit checksums; auto-bundles `docs/CPLD_通讯协议v2.0.md` on every release — keep it updated on every iteration).
 
 ## 5. Reference Docs (Read On Demand)
 
-- Current release & wiring: `README.zh-CN.md`, `docs/releases/v3.2.0.md`, `docs/releases/v3.1.0.md`, `docs/evidence/6400-v2-electrical-alignment.md`
+- Current release, protocol & wiring: `README.zh-CN.md`, `docs/CPLD_通讯协议v2.0.md`, `docs/releases/v3.2.0.md`, `docs/releases/v3.1.0.md`, `docs/evidence/6400-v2-electrical-alignment.md`
 - Detailed legacy specs & recovery notes: `docs/operating-rules-2026-09-recovery.md`
 - Protocol & scope guides: `docs/prod2u-dual-product-protocol.zh-CN.md`, `docs/pwm-scope.md`, `docs/TD_USAGE.zh-CN.md`

+ 1 - 1
README.zh-CN.md

@@ -2,7 +2,7 @@
 
 当前生产发布分支是 **`dev`**。本轮同时维护 **6400 V2.0(`6400-v2`)**、**MRDIMM V1.2(`mrdimm`)** 与 **6400 V1.1(`6400`)**:最高优先级是逻辑简单直接、高复用串行、稳定可靠,其次压低 LUT / Slice(自由使用 BRAM/FF/IO 换取更低 LUT),不堆复杂或过度安全边界。
 
-先读 [3.2.0 发布说明与资源对比](docs/releases/v3.2.0.md) 与 [6400 V2.0 完整电气对齐表](docs/evidence/6400-v2-electrical-alignment.md)。
+先读 [CPLD 通讯协议 v2.0(持续维护最新版)](docs/CPLD_通讯协议v2.0.md)、[3.2.0 发布说明与资源对比](docs/releases/v3.2.0.md) 与 [6400 V2.0 完整电气对齐表](docs/evidence/6400-v2-electrical-alignment.md)。
 
 ## 当前入口与协议(v3.2.0)
 

Разница между файлами не показана из-за своего большого размера
+ 654 - 0
docs/CPLD_通讯协议v2.0.md


+ 19 - 0
tests/unit/test_release_analysis_bundle.py

@@ -167,3 +167,22 @@ def test_explicit_hardware_survives_source_restore_without_entering_debug(releas
     with pytest.raises(ValueError, match="conflicting hardware file"):
         bundle.main(conflict_argv)
     assert not list(rejected_out.glob("*.zip"))
+
+
+def test_protocol_doc_bundled_at_release_root_and_in_archives(release):
+    proto = release["repo"] / "docs/CPLD_通讯协议v2.0.md"
+    proto.write_text("# Synthetic protocol doc\n", encoding="utf-8")
+    subprocess.run(["git", "add", str(proto.relative_to(release["repo"]))], cwd=release["repo"], check=True)
+    subprocess.run(["git", "commit", "-m", "add protocol doc"], cwd=release["repo"], check=True, capture_output=True)
+    assert bundle.main(release["argv"]) == 0
+    out = release["out"]
+    expected_bytes = proto.read_bytes()
+    assert (out / "CPLD_通讯协议v2.0.md").read_bytes() == expected_bytes
+    run_meta = json.loads((out / "RUN.json").read_text(encoding="utf-8"))
+    assert run_meta["protocol_doc"]["file"] == "CPLD_通讯协议v2.0.md"
+    assert run_meta["protocol_doc"]["sha256"] == sha(expected_bytes)
+    delivery = {item["path"]: item for item in json.loads((out / "DELIVERY-SHA256.json").read_text(encoding="utf-8"))}
+    assert delivery["CPLD_通讯协议v2.0.md"]["sha256"] == sha(expected_bytes)
+    for row in json.loads((out / "PACKAGE-RESULTS.json").read_text(encoding="utf-8")):
+        files = read_archive(out / row["file"])["files"]
+        assert files["CPLD_通讯协议v2.0.md"] == expected_bytes

+ 4 - 3
tools/deploy_to_delivery_pc.py

@@ -33,12 +33,13 @@ def main(argv=None) -> int:
         with log.open("a") as stream:
             subprocess.run(command, stdout=stream, stderr=subprocess.STDOUT, check=True)
 
-    destination = args.destination.rstrip("/")
+    destination = args.destination.rstrip("/\\")
+    scp_destination = destination.replace("\\", "/")
     run(["ssh", "-o", "ConnectTimeout=10", args.host,
          ps("$ErrorActionPreference='Stop'; $p=" + quote(destination)
             + "; if (Test-Path $p) {throw 'Use a new release directory'}; New-Item -ItemType Directory -Path $p | Out-Null")])
     for child in sorted(source.iterdir()):
-        run(["scp", "-r", str(child), args.host + ":" + destination + "/"])
+        run(["scp", "-r", str(child), args.host + ":" + scp_destination + "/"])
     verify = r'''
 $ErrorActionPreference='Stop'
 $root=ROOT_VALUE
@@ -57,7 +58,7 @@ $result | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $root 'D
 Write-Output ('DELIVERY_SHA256_PASS '+$verified.Count)
 '''.replace("ROOT_VALUE", quote(destination))
     run(["ssh", "-o", "ConnectTimeout=10", args.host, ps(verify)])
-    run(["scp", args.host + ":" + destination + "/DELIVERY-RECEIPT.json", str(receipt)])
+    run(["scp", args.host + ":" + scp_destination + "/DELIVERY-RECEIPT.json", str(receipt)])
     result = json.loads(receipt.read_text(encoding="utf-8-sig"))
     if result.get("status") != "PASS":
         raise ValueError("remote delivery verification failed")

+ 23 - 0
tools/package_unified_analysis.py

@@ -21,6 +21,7 @@ if str(ROOT) not in sys.path:
 from tools.package_archive import encode, finalize, read_archive, write_archive
 
 PRODUCTS = {"6400-v2", "mrdimm-chamber"}
+DEFAULT_PROTOCOL_DOC = Path("docs/CPLD_通讯协议v2.0.md")
 
 
 def digest(data: bytes) -> str:
@@ -113,6 +114,8 @@ def main(argv=None) -> int:
     parser.add_argument("--review-dir", type=Path, required=True)
     parser.add_argument("--related-repo", action="append", default=[], metavar="NAME=PATH")
     parser.add_argument("--hardware-file", action="append", type=Path, default=[])
+    parser.add_argument("--protocol-doc", type=Path, default=None,
+                        help="Maintained protocol document to bundle at release root and inside archives (defaults to docs/CPLD_通讯协议v2.0.md if present)")
     parser.add_argument("--hardware-status", type=Path, required=True,
                         help="actual connection/programming/test result JSON, including NOT_RUN when unavailable")
     args = parser.parse_args(argv)
@@ -198,9 +201,27 @@ def main(argv=None) -> int:
             raise ValueError("conflicting hardware file: " + key)
         hardware[key] = data
     start = (ROOT / f"docs/releases/v{version}.md").read_bytes()
+    protocol_doc_path = args.protocol_doc.resolve() if args.protocol_doc is not None else (ROOT / DEFAULT_PROTOCOL_DOC)
+    protocol_doc_bytes = None
+    if protocol_doc_path.is_file():
+        protocol_doc_bytes = protocol_doc_path.read_bytes()
+        try:
+            proto_rel = protocol_doc_path.relative_to(ROOT.resolve()).as_posix()
+        except ValueError:
+            proto_rel = protocol_doc_path.name
+        run["protocol_doc"] = {
+            "file": protocol_doc_path.name,
+            "source_path": proto_rel,
+            "sha256": digest(protocol_doc_bytes),
+            "size_bytes": len(protocol_doc_bytes),
+        }
+    elif args.protocol_doc is not None:
+        parser.error("missing --protocol-doc: " + str(protocol_doc_path))
     common = {"START-HERE.zh-CN.md": start, "RUN.json": encode(run),
         "EXCLUSIONS.json": encode({"excluded": ["working untracked user files except explicit --hardware-file inputs", "tool databases and vvp/vcd/fst intermediates", "ignored caches", "Git local config (including remote credentials)"],
                                     "source_scope": "All Git-tracked working files; explicit hardware originals included with repository-relative paths preserved; committed history in history/*.bundle"})}
+    if protocol_doc_bytes is not None:
+        common[protocol_doc_path.name] = protocol_doc_bytes
     tag = f"v{version}-{identity['commit'][:8]}"
     results = [
         package(out / f"Prod2U-Source-{tag}.zip", {**sources, **hardware, **common}, {"kind": "source", "version": version}),
@@ -214,6 +235,8 @@ def main(argv=None) -> int:
         target.parent.mkdir(parents=True, exist_ok=True)
         target.write_bytes(data)
     (out / "START-HERE.zh-CN.md").write_bytes(start)
+    if protocol_doc_bytes is not None:
+        (out / protocol_doc_path.name).write_bytes(protocol_doc_bytes)
     (out / "RUN.json").write_bytes(encode(run))
     (out / "PACKAGE-RESULTS.json").write_bytes(encode(results))
     inventory = [{"path": p.relative_to(out).as_posix(), "sha256": digest(p.read_bytes()), "size_bytes": p.stat().st_size}