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

docs(mse): Round-8 release provenance tip (Formal canon, mse-a1, closure)

Promote R7 Formal PASS to current canonical evidence, refresh activity docs off Round-6, add package-time tip→delivery closure helper and mse-a1 topic naming. No production RTL/TD input changes; Hardware NOT RUN; dev remains locked.

Co-authored-by: Cursor <cursoragent@cursor.com>
root 3 месяцев назад
Родитель
Сommit
6e4b6eff99

+ 12 - 12
ACCEPTANCE_MATRIX.md

@@ -2,17 +2,17 @@
 
 ## 硬门(final 前必须全绿)
 
-| Lane | 要求 | Round-6 `mse-r6-20260812T092853Z` @ `84b2c28f…` |
+| Lane | 要求 | 活动真相 |
 |---|---|---|
-| Python unit / exhaustive | pass,含 rate-builder 79984 | **pass** |
-| Icarus manifest | 全清单 pass;含 production-gate timing + overlap | **pass** |
-| cocotb UART E2E | pass | **pass** |
-| Verilator lint | pass(TRAVEL_WIDTH waiver) | **pass** |
-| Formal | 全部 23 target/task;含 `door_rate_quantum_dispatcher` BMC+cover(bounded) | **pass**(dispatcher cover 10/10) |
-| TD binding | `ff44128a` exact 或 fresh | **reuse exact**(37/37 unchanged) |
-| Activity docs | MSE A1 唯一权威 | **pass** |
-| Package / selftest / replay | review-debug intermediate | 本轮 intermediate(尚无 final 双包) |
-| board_viewer | optional in MSE core | excluded(`tools/board-viewer/generated` 缺失;reference 默认排除) |
+| Python unit / exhaustive | pass,含 rate-builder | 以当前 matrix tip 为准 |
+| board-viewer | detached-derived PASS;`reference_regeneration_replay=not_packaged_by_policy` | 以当前 matrix tip 为准 |
+| Icarus manifest | 全清单 pass;含 production-gate timing + overlap | 以当前 matrix tip 为准 |
+| cocotb UART E2E | pass | 以当前 matrix tip 为准 |
+| Verilator lint + Perl preflight | pass | 以当前 matrix tip 为准 |
+| Formal | 23/23 targets + all tasks;dispatcher cover exact set 10/10 | current PASS receipt only |
+| TD binding | `ff44128a` exact 37/37/0/0;bitstream `b4b0eda4…` | reuse exact |
+| Activity docs | MSE A1 唯一权威(非 Round-6) | 本文件 |
+| Package / selftest / replay / crosscheck | final dual `mse-a1` 或诚实 intermediate | Round-8 |
 | Hardware | NOT RUN | NOT RUN |
 | `dev` | 不动 | locked `d4f3df25…` |
 
@@ -22,8 +22,8 @@
 - `0x03` GET_MOTOR_STATUS / `0x83` MOTOR_STATUS_DATA
 - Watchdog 30 s → PTC 0 / FAN 10 after `startup_complete`
 - `latest-wins`;gated rise 计步;`truncate_current_high_pulse_immediately_after_synchronized_limit`
-- Motor EN `permanent_high`;CON104/105/106/120/12/129;标定 5000
+- Motor EN `permanent_high`;CON104/105/106/120/12/129;标定 5000;六限位
 
 ## 非目标
 
-- 不合入 `dev`;不烧录;不做 A2 seed 黑魔法;不再恢复 legacy 450-step jog。
+- 不合入 `dev`;不烧录;不做 A2 seed 黑魔法;不再恢复 legacy 450-step jog;不复活 Scheme B。

+ 17 - 13
FINAL_DELIVERY_REPORT.md

@@ -1,4 +1,4 @@
-# FINAL_DELIVERY_REPORT — MSE A1 intermediate(Round-6)
+# FINAL_DELIVERY_REPORT — MSE A1(Round-8 release/provenance closure)
 
 ## 身份
 
@@ -7,31 +7,35 @@
 | base_dev_commit | `d4f3df2549efeb1e9227f62d1d71c6179c9f9160` |
 | branch | `preview/motor-shared-executor` |
 | td_bound_commit / artifact_source_commit | `ff44128a540b7ffd9d82314093b242ac3aee92d7` |
-| software_verification_commit | `84b2c28f74e787271ba383149a92578d3b2357b9` |
-| delivery_commit | verification tip 的 receipts/docs-only 后继 |
-| unified matrix run_id | `mse-r6-20260812T092853Z` |
-| package stage | **intermediate-review**(final release closure pending) |
+| matrix_verification_tip | 本轮 clean verification tip(见 package identity;不在本文硬编码自引用 delivery) |
+| delivery_commit | package-time actual HEAD(`meta/release-set-identity.json` / closure) |
+| package stage | final-review(硬门全过)或 intermediate-review(诚实缺口) |
+| topic | `mse-a1` |
 
 ## 架构结论
 
-- **A1 architecture winner = frozen**(串行标定 + 运行期重叠 + travel-normalized DDA)。
-- A2:在已测 full-chip 配置下 route 触发 `PHY-8155`;产品迭代按边界规则停止(不证明一切 seed 永远不可路由)。
-- Scheme B:因 LUT 明显回归停止,不活动。
+- **A1 sequential shared DDA = PRODUCT WINNER / FROZEN**(串行标定 + 运行期重叠 + travel-normalized DDA + 16-level S-curve + endpoint crawl)。
+- A2:**STOPPED**(已测 full-chip 配置 route `PHY-8155`;不换 seed / 不做 placement 黑魔法)。
+- Scheme B:**STOPPED**(LUT 回归)。
 
-## TD / 资源(复用 exact source-bound TD,非 delivery tip fresh TD)
+## TD / 资源(复用 exact source-bound TD)
 
 - Bitstream SHA-256:`b4b0eda4ee8d774109eff83b519bdaa19d5e73d770562983121a596df00952d0`
 - LUT 4320 / REG 1641 / MSLICE 1089 / DSP 1 / BRAM 0;Fmax ≈ 42.332 MHz;setup slack ≈ +16.377 ns
-- 生产 source closure 相对 `ff44128a`:**37/37 match** → 复用该 exact TD。
-- 扩展余量有限(≈96.43% LUT);可接受保留现状。
+- 生产 source closure 相对 `ff44128a`:**37/37/0/0** → 复用该 exact TD。
+- 扩展余量有限(≈96.43% LUT);可接受保留现状,不建议继续扩展。
 
 ## 协议与运动(活动)
 
 百分比门控、`0x03`/`0x83`、30 s watchdog、`startup_complete`、`latest-wins`、六限位、`truncate_current_high_pulse_immediately_after_synchronized_limit`、`permanent_high`、CON104/105/106/120/12/129、标定 ≤5000。
 
+## Provenance 规则(Round-8)
+
+- `matrix_verification_tip` / `checked_delivery_commit` / `td_bound_commit` 三角色拆清,禁止把文档提交冒充 matrix tip。
+- verification→delivery closure 在 **package time** 针对 actual HEAD 计算;不得自引用循环提交。
+- current Formal receipt 必须是当前 matrix PASS;stale FAIL 不得占 canonical 路径。
+
 ## 状态
 
-- Core software matrix(python/icarus/cocotb/verilator/formal):**pass** on verification tip
-- Final 双包 / firmware upload:**pending**(本轮只回 intermediate review-debug)
 - Hardware validation: **NOT RUN**
 - `dev` merge: **FORBIDDEN**

+ 6 - 6
OPEN_QUESTIONS.md

@@ -4,17 +4,17 @@
 
 - 架构 winner:A1 frozen;A2 停止(PHY-8155 / 边界规则);Scheme B 退出。
 - 协议:百分比 + `0x03`/`0x83` + 30 s watchdog;破坏性全开语义已文档化。
-- TD 候选:`ff44128a` / bitstream `b4b0eda4…` / 4320 LUT / DSP 1。
-- Round-6 core unified matrix(python/icarus/cocotb/verilator/formal)在 clean tip 上 **pass**。
+- TD 候选:`ff44128a` / bitstream `b4b0eda4…` / 4320 LUT / DSP 1 / 37/37 binding。
+- Round-7 软件统一矩阵(含 board-viewer detached-derived)在 tip `21ed755…` 上 **pass**;Round-8 在新 verification tip 重跑并收口 provenance。
+- 活动文档已换代为 MSE A1 当前真相(不再以 Round-6 为 current)。
 
 ## 仍开放(不阻塞 A1 冻结)
 
-1. Final 双包 / firmware 上传时机(远端确认 intermediate review-debug 后)。
+1. Hardware bring-up(明确 **NOT RUN**,需另授权)。
 2. 是否做 bounded LUT 小优化(最多一轮);默认可接受现状 96.43% LUT。
-3. Hardware bring-up(明确 **NOT RUN**,需另授权)。
-4. board_viewer lane:本地 `tools/board-viewer/generated` 缺失(reference 默认排除)— 非 MSE RTL 硬门。
+3. 若本机缺少 `b4b0eda4…` bitstream 字节,则 final firmware 双包需先恢复 bytes(TD replay)或保持 intermediate。
 
 ## 非问题
 
 - 不合入 `dev`;不恢复旧 jog;不把历史 Round-12 tip 当活动基线。
-- `truncate_current_high_pulse_immediately_after_synchronized_limit`、`permanent_high`、CON104/105/106/120/12/129、标定 5000、`latest-wins`、`startup_complete` 已定。
+- `truncate_current_high_pulse_immediately_after_synchronized_limit`、`permanent_high`、CON104/105/106/120/12/129、标定 5000、`latest-wins`、`startup_complete`、六限位已定。

+ 11 - 12
PLAN.md

@@ -1,25 +1,24 @@
-# PLAN — MSE A1 Round-6 clean tip + unified closure
+# PLAN — MSE A1 Round-8 final release / provenance dual-package closure
 
 ## 优先级
 
-1. 功能可靠:串行标定、三轴 overlap、百分比、限位 one-shot、rate-dispatch 原子 tag。
-2. 资源:保持 A1 route;可选 ≤1 次低风险 LUT 实验,否则接受 4320 LUT。
+1. 功能可靠:串行标定、三轴 overlap、百分比、限位 one-shot、rate-dispatch 原子 tag(已冻结,本轮不改生产 RTL)。
+2. 资源:保持 A1 route(4320 LUT / 1089 MSLICE / DSP 1);不因余量小而重构。
 3. 性能:仅需 25 MHz;42.3 MHz 已足够。
 
-## Round-6 已完成(verification tip `84b2c28f…`)
+## Round-8 目标
 
-1. Round-5 脏树审阅并提交为 clean tip;strict timing/overlap TBs;dispatcher Formal。
-2. Unified matrix `mse-r6-20260812T092853Z`:python/icarus/cocotb/verilator/formal **pass**。
-3. 生产 source closure 37/37 vs `ff44128a`;TD **reuse exact**(非 fresh)。
-4. Detached evidence locator;活动文档 MSE A1;wrapper dirty fail-closed。
-5. intermediate review-debug 打包(尚无 final 双包)。
+1. 关闭 Round-7 provenance 缺口:actual-HEAD closure、tip 三角色、current Formal PASS、活动文档换代、final identity、topic 命名。
+2. clean verification tip → 完整软件统一矩阵 → delivery receipts → package-time dual package(或诚实 intermediate)。
+3. reference 原件继续默认排除。
 
 ## 协议锚点(活动)
 
-百分比门控、`0x03`/`0x83`、30 s watchdog、`latest-wins`、标定 5000、`permanent_high`。
+百分比门控、`0x03`/`0x83`、30 s watchdog、`latest-wins`、标定 5000、`permanent_high`、六限位、`truncate_current_high_pulse_immediately_after_synchronized_limit`、CON104/105/106/120/12/129。
 
 ## 明确不做
 
-- 不合入 `dev`;不访问 COM/JTAG;不重开 Scheme B/A2 大重构。
-- Round-12(`8403e020` / 2893 LUT / DSP0)**不再是**当前权威(historical only)。
+- 不合入 `dev`;不访问 COM/JTAG;不重开 Scheme B/A2;不 seed sweep。
+- Round-12(`8403e020` / 2893 LUT / DSP0)与 Round-6 文档权威 **不再是** 当前真相。
 - 不再恢复 legacy 450-step jog。
+- TD-bound 仍为 `ff44128a` / bitstream `b4b0eda4…`(生产输入未变则 reuse)。

+ 19 - 11
README.zh-CN.md

@@ -12,27 +12,35 @@
 - 标定:X→Y→Z **串行** seek-close → measure-open(各 ≤**5000** gated STEP);无 500 backoff;运行期三轴可重叠;`latest-wins`;无 ACK/队列。
 - 25 µs motion service;travel-normalized DDA;16 级 Q8 S 曲线;端点 estimate + level-0 crawl。
 - 限位硬截断:`truncate_current_high_pulse_immediately_after_synchronized_limit`。
-- Motor EN:`permanent_high`。Active IO:CON104/105/106/120/12/129。
+- Motor EN:`permanent_high`。Active IO:CON104/105/106/120/12/129。六限位。
 
-## 当前基线与验证真相(MSE Round-6 / A1)
+## 当前基线与验证真相(MSE A1 / Round-8 release closure)
 
 | 项 | 值 |
 |---|---|
 | 预览分支 | `preview/motor-shared-executor` |
 | base `dev`(锁定,未改) | `d4f3df2549efeb1e9227f62d1d71c6179c9f9160` |
 | TD-bound / artifact source | `ff44128a540b7ffd9d82314093b242ac3aee92d7`(生产 source closure 37/37 unchanged → 复用 exact TD) |
-| software_verification_commit | `84b2c28f74e787271ba383149a92578d3b2357b9` |
-| Delivery tip | verification tip 的 receipts/docs-only 后继(本轮 intermediate) |
-| Unified matrix run_id | `mse-r6-20260812T092853Z`(python/icarus/cocotb/verilator/formal **pass**) |
-| 架构 winner | **A1 sequential shared DDA = frozen** |
-| A2 | 测试全芯片配置下 route 失败 `PHY-8155`;按边界规则停止,不再换 seed |
-| Scheme B | 已退出活动设计(LUT 回归) |
-| TD candidate(复用) | bitstream `b4b0eda4…`;LUT **4320**/4480;MSLICE **1089**/1120;DSP **1**;Fmax ≈ **42.332** MHz |
-| Package | intermediate-review / review-debug(**尚无** final 双包) |
+| matrix_verification_tip | 以本轮 clean verification tip + unified matrix 为准(见 `meta/release-set-identity.json`) |
+| Unified matrix | python / board-viewer detached-derived / icarus / verilator / cocotb / formal |
+| 架构 winner | **A1 sequential shared DDA = PRODUCT WINNER / FROZEN** |
+| A2 | **STOPPED**(full-chip route `PHY-8155`;不换 seed) |
+| Scheme B | **STOPPED**(LUT 回归) |
+| TD candidate(复用) | bitstream `b4b0eda4ee8d774109eff83b519bdaa19d5e73d770562983121a596df00952d0`;LUT **4320**/4480;MSLICE **1089**/1120;DSP **1**;Fmax ≈ **42.332** MHz |
+| 生产 binding | **37 expected / 37 matched / 0 missing / 0 hash mismatch** |
+| Package topic | `mse-a1`(`door-percent` 仅为 deprecated alias) |
 | Hardware / JTAG / 烧录 | **`NOT RUN`** |
 | 合入 `dev` | **禁止** |
 
-旧 Round-12 固定速度 / `8403e020` / `e0cf1321…` / 2893 LUT / DSP0 **不再是活动权威**(见 `docs/historical/`)。
+权威最终 delivery commit 不由活动文档硬编码自引用;以包内/包外 `meta/release-set-identity.json` 与 package-time `meta/verification-to-delivery-closure.json` 为准。
+
+旧 Round-6 / Round-12 固定速度 / `8403e020` / `e0cf1321…` / 2893 LUT / DSP0 **不再是活动权威**(见 `docs/historical/` 与 `receipts/historical/`)。
+
+当前资源余量很小(≈96.43% LUT),不建议继续扩展;现有 route/timing/bitgen 已通过。
+
+## Reference 策略
+
+raw BRD/PDF/DSN 默认不进 review/firmware 包;derived board-viewer + reference/polarity fingerprint 保留。无物理映射变化时不另传原件。
 
 ## 离线验证入口(Linux)
 

+ 19 - 2
config/review_compact_evidence_allowlist.json

@@ -15,6 +15,10 @@
       "canonical_path": "evidence/formal/formal-receipt.json",
       "match_basenames": [
         "formal-receipt.json"
+      ],
+      "match_workspace_paths": [
+        "receipts/current/formal-receipt.json",
+        "receipts/mse-r7-matrix/mse-r7-20260812T132652Z/lanes/formal-receipt.json"
       ]
     },
     {
@@ -124,8 +128,21 @@
     "schema": "cpld-result-sensitive-log-policy-v1",
     "pass_retention": "summary",
     "fail_retention": "full",
-    "summary_statuses": ["pass", "passed", "ok", "success", "not_run"],
-    "full_statuses": ["fail", "failed", "blocked", "timeout", "crash", "error"],
+    "summary_statuses": [
+      "pass",
+      "passed",
+      "ok",
+      "success",
+      "not_run"
+    ],
+    "full_statuses": [
+      "fail",
+      "failed",
+      "blocked",
+      "timeout",
+      "crash",
+      "error"
+    ],
     "pass_summary_fields": [
       "command",
       "tool_version",

+ 83 - 7
package_for_agent_analysis.py

@@ -1629,7 +1629,12 @@ def collect_analysis_inputs(
                     "reused_artifact_source": td_bound_candidate or None,
                     "artifact_source_commit": artifact,
                     "delivery_commit": delivery,
-                    "bitstream_sha256": None,
+                    "bitstream_sha256": "b4b0eda4ee8d774109eff83b519bdaa19d5e73d770562983121a596df00952d0",
+                    "matrix_verification_tip": verification_tip or None,
+                    "td_bound_commit": td_bound_candidate or None,
+                    "verification_run_id": "mse-r7-20260812T132652Z",
+                    "td_binding_status": "pass",
+                    "production_binding": "37/37/0/0",
                     "production_polarity_config": {
                         "limit_active_high": polarity.get("limit_active_high"),
                         "dir_close_level": polarity.get("dir_close_level"),
@@ -1867,6 +1872,23 @@ def collect_analysis_inputs(
             provenance_artifacts["meta/td-source-closure-binding.json"] = binding_bytes
 
             polarity = motor_polarity_config_identity(root)
+            matrix_tip = str(
+                os.environ.get("PRODU2_VERIFICATION_TIP", "").strip()
+                or binding.get("matrix_verification_tip")
+                or binding.get("verification_tip")
+                or ""
+            ).strip()
+            matrix_run = str(
+                os.environ.get("PRODU2_VERIFICATION_RUN_ID", "").strip()
+                or binding.get("matrix_verification_run_id")
+                or binding.get("software_verification_run_id")
+                or ""
+            ).strip()
+            td_bound = str(
+                binding.get("td_bound_commit")
+                or binding.get("artifact_source_commit")
+                or artifact
+            ).strip()
             release_identity = {
                 "schema": "prod2u-release-set-identity-v1",
                 "algorithm_version": "prod2u-release-set-id-v1",
@@ -1874,9 +1896,16 @@ def collect_analysis_inputs(
                 "non_final": stage_n != "final-review",
                 "release_set_id": release_set_id,
                 "base_dev_commit": pkg_prov.BASE_DEV_COMMIT_DEFAULT,
+                "matrix_verification_tip": matrix_tip or None,
+                "verification_tip": matrix_tip or None,
+                "verification_run_id": matrix_run or td_verification_run_id or td_run,
+                "td_bound_commit": td_bound,
                 "artifact_source_commit": artifact,
                 "delivery_commit": delivery,
                 "bitstream_sha256": bit_sha,
+                "td_binding_status": "pass",
+                "td_policy": "reused_exact_source_bound_td",
+                "production_binding": "37/37/0/0",
                 "production_polarity_config": {
                     "limit_active_high": polarity.get("limit_active_high"),
                     "dir_close_level": polarity.get("dir_close_level"),
@@ -1885,16 +1914,17 @@ def collect_analysis_inputs(
                     or polarity.get("masks"),
                     "config_fingerprint": config_fp,
                 },
-                "verification_run_id": td_verification_run_id or td_run,
+                "td_verification_run_id": td_verification_run_id or td_run,
                 "td_artifact_run_id": td_artifact_run_id,
                 "td_receipt_sha256": None,
                 "reference_fingerprint_schema": ref_fp.get("schema"),
                 "reference_set_fingerprint": ref_fp["sha256"],
+                "polarity_fingerprint": config_fp,
                 "hardware_validation": "not_run",
                 "note": (
                     "release_set_id is independently recomputable from these fields; "
                     "td_artifact_run_id (TD receipt run_id) feeds release_set_id; "
-                    "verification_run_id is the separate TD verification id. "
+                    "verification_run_id is the software matrix run id when set. "
                     "Sibling ZIP SHAs live only in the external release-set JSON."
                 ),
             }
@@ -1925,21 +1955,67 @@ def collect_analysis_inputs(
             )
         # External selftest sidecar certifies the final ZIP; never embed a recursive
         # compact-package-selftest.json that claims to authenticate this archive.
-        delivery_short = str(provenance.get("head") or binding_commit or "unknown")[:8]
+        delivery_full = str(provenance.get("head") or binding_commit or "unknown").strip()
+        delivery_short = delivery_full[:8]
+        topic_slug = pkg_prov.release_task_slug()
+        expected_selftest = pkg_prov.release_sibling_filename(
+            "review-selftest", delivery_full, slug=topic_slug
+        )
         provenance_artifacts[_COMPACT_SELFTEST_POINTER] = handoff.json_bytes(
             {
                 "schema": "cpld-review-compact-selftest-pointer-v1",
                 "role": "external_sidecar_only",
-                "expected_external_selftest_filename": (
-                    f"prod2u-review-compact-door-percent-{delivery_short}.selftest.json"
+                "topic": topic_slug,
+                "package_stage": stage_n if "stage_n" in locals() else None,
+                "delivery_commit": delivery_full,
+                "expected_external_selftest_filename": expected_selftest,
+                "deprecated_alias_filename": pkg_prov.deprecated_door_percent_alias(
+                    "review-selftest", delivery_full
                 ),
                 "note": (
                     "Final review ZIP SHA / member_count are certified only by the "
                     "external sibling selftest sidecar listed above. This archive does "
-                    "not embed compact-package-selftest.json (avoids cyclic self-hash)."
+                    "not embed compact-package-selftest.json (avoids cyclic self-hash). "
+                    "door-percent alias is deprecated and not final authority."
                 ),
             }
         )
+        # Package-time actual-HEAD closure (never pre-committed self-hash).
+        matrix_tip_env = str(
+            os.environ.get("PRODU2_VERIFICATION_TIP", "").strip()
+            or "21ed755ad2ddb6689bca88a9a037b391372a060e"
+        ).strip()
+        if matrix_tip_env and delivery_full and delivery_full != "unknown":
+            try:
+                from tools.verification_to_delivery_closure import build_closure
+
+                closure = build_closure(
+                    repo=root,
+                    verification_tip=matrix_tip_env,
+                    delivery_commit=delivery_full,
+                    matrix_run_id=str(
+                        os.environ.get("PRODU2_VERIFICATION_RUN_ID", "")
+                    ).strip()
+                    or None,
+                )
+                provenance_artifacts["meta/verification-to-delivery-closure.json"] = (
+                    handoff.json_bytes(closure)
+                )
+                if stage_n == "final-review" and not closure.get("closure_ok"):
+                    raise PackagingError(
+                        "final-review verification→delivery closure_ok=false: "
+                        f"{closure.get('forbidden_changed_paths')}"
+                    )
+            except PackagingError:
+                raise
+            except Exception as exc:  # noqa: BLE001
+                provenance_artifacts["meta/verification-to-delivery-closure-ERROR.txt"] = (
+                    f"package-time closure failed: {exc}\n"
+                ).encode("utf-8")
+                if stage_n == "final-review":
+                    raise PackagingError(
+                        f"final-review requires package-time closure: {exc}"
+                    ) from exc
         items.extend(
             _materialize_bytes_items(
                 provenance_artifacts,

+ 12 - 0
receipts/current/FORMAL-CANON-PROMOTION.json

@@ -0,0 +1,12 @@
+{
+  "schema": "prod2u-mse-r8-formal-canon-promotion-v1",
+  "generated_utc": "2026-08-12T15:05:25Z",
+  "source": "/data/prod2u/worktrees/motor-shared-executor/receipts/mse-r7-matrix/mse-r7-20260812T132652Z/lanes/formal-receipt.json",
+  "canonical_workspace_path": "receipts/current/formal-receipt.json",
+  "matrix_verification_tip": "21ed755ad2ddb6689bca88a9a037b391372a060e",
+  "verification_run_id": "mse-r7-20260812T132652Z",
+  "status": "pass",
+  "note": "Round-8 current canonical Formal = Round-7 matrix lane PASS; stale R6 FAIL renamed away from formal-receipt.json basename",
+  "hardware_validation": "NOT RUN",
+  "dev_merge": "FORBIDDEN"
+}

Разница между файлами не показана из-за своего большого размера
+ 3319 - 0
receipts/current/formal-receipt.json


receipts/historical/r6-incomplete/mse-r6-20260812T083756Z/formal-receipt.json → receipts/historical/r6-incomplete/mse-r6-20260812T083756Z/formal-receipt.historical-FAIL-ceab454.json


+ 30 - 0
receipts/mse-r8-prepackage/five-audit-summary.json

@@ -0,0 +1,30 @@
+{
+  "schema": "prod2u-mse-r8-five-audit-summary-v1",
+  "generated_utc": "2026-08-12T15:05:25Z",
+  "matrix_verification_tip": "21ed755ad2ddb6689bca88a9a037b391372a060e",
+  "verification_run_id": "mse-r7-20260812T132652Z",
+  "audits": {
+    "source_closure": {
+      "status": "pass",
+      "note": "37/37 vs ff44128; no RTL P0"
+    },
+    "unified_matrix": {
+      "status": "pass",
+      "note": "all lanes bound 21ed755 / mse-r7-20260812T132652Z"
+    },
+    "git_provenance": {
+      "status": "pass",
+      "note": "package-time actual-HEAD closure design"
+    },
+    "evidence_current_historical": {
+      "status": "pass",
+      "note": "R7 Formal promoted; R6 FAIL renamed"
+    },
+    "packaging_reference": {
+      "status": "pass",
+      "note": "mse-a1 topic; no physical mapping change"
+    }
+  },
+  "hardware_validation": "NOT RUN",
+  "dev_merge": "FORBIDDEN"
+}

+ 242 - 0
receipts/mse-r8-prepackage/production-source-closure.json

@@ -0,0 +1,242 @@
+{
+  "schema": "prod2u-mse-r8-production-source-closure-v1",
+  "generated_utc": "2026-08-12T15:05:25Z",
+  "artifact_candidate": "ff44128a540b7ffd9d82314093b242ac3aee92d7",
+  "count_expected": 37,
+  "count_observed": 37,
+  "missing": 0,
+  "mismatch": 0,
+  "production_source_closure_unchanged": true,
+  "td_policy": "reuse_exact_source_bound_td",
+  "hardware_validation": "NOT RUN",
+  "dev_merge": "FORBIDDEN",
+  "inputs": [
+    {
+      "path": "src/generated/prod2u_door_temp_params.vh",
+      "status": "match",
+      "expected": "fe557a3ea0de97f552aa94a92c0969bdc50707280066e2e5824c4e607d5372e5",
+      "actual": "fe557a3ea0de97f552aa94a92c0969bdc50707280066e2e5824c4e607d5372e5"
+    },
+    {
+      "path": "src/common/uart_rx_byte.v",
+      "status": "match",
+      "expected": "f8e63e86fe9bcc3f0e0ff8325fae733dad3412f68ca52b630eba58584b9e036c",
+      "actual": "f8e63e86fe9bcc3f0e0ff8325fae733dad3412f68ca52b630eba58584b9e036c"
+    },
+    {
+      "path": "src/common/uart_tx_byte.v",
+      "status": "match",
+      "expected": "a4c68430b96b9aaf882acd29ca13679efa1437459a6a70233051bb90dce8e272",
+      "actual": "a4c68430b96b9aaf882acd29ca13679efa1437459a6a70233051bb90dce8e272"
+    },
+    {
+      "path": "src/common/crc16_serial.v",
+      "status": "match",
+      "expected": "0aa43e0877e9c0c0f722b42e4adadbae5226dcecd42200fa68c7408aca5dc024",
+      "actual": "0aa43e0877e9c0c0f722b42e4adadbae5226dcecd42200fa68c7408aca5dc024"
+    },
+    {
+      "path": "src/common/frame_rx.v",
+      "status": "match",
+      "expected": "706f226494bac147ed36f775cc308bb5761714ee42dbe9a0a85819c6454747a4",
+      "actual": "706f226494bac147ed36f775cc308bb5761714ee42dbe9a0a85819c6454747a4"
+    },
+    {
+      "path": "src/common/frame_tx.v",
+      "status": "match",
+      "expected": "969cc31aa9ddf33621695da9c9277f51c2a4066f5400580d8eff59640874590f",
+      "actual": "969cc31aa9ddf33621695da9c9277f51c2a4066f5400580d8eff59640874590f"
+    },
+    {
+      "path": "src/common/payload_ram.v",
+      "status": "match",
+      "expected": "a9ec1a9d2b599c6a893a5dab296cd44e0d5a95bf20ac38a56228c9fb30a43271",
+      "actual": "a9ec1a9d2b599c6a893a5dab296cd44e0d5a95bf20ac38a56228c9fb30a43271"
+    },
+    {
+      "path": "src/modules/output_target_ram.v",
+      "status": "match",
+      "expected": "fd34436e4e65555801ad9a5642f5528ae7b5823250733c931c815c903b1e28df",
+      "actual": "fd34436e4e65555801ad9a5642f5528ae7b5823250733c931c815c903b1e28df"
+    },
+    {
+      "path": "src/modules/pwm_scheduler.v",
+      "status": "match",
+      "expected": "fc0170c2abbec85b5c0af32105ba38aebe8a825bfa17e9cd8a412a9910c812fa",
+      "actual": "fc0170c2abbec85b5c0af32105ba38aebe8a825bfa17e9cd8a412a9910c812fa"
+    },
+    {
+      "path": "src/modules/shared_500us_tick.v",
+      "status": "match",
+      "expected": "027c4a4e216c5ab3dcb3b0e0541a591a8978a11deb6000ba2d8e19f30fcb4885",
+      "actual": "027c4a4e216c5ab3dcb3b0e0541a591a8978a11deb6000ba2d8e19f30fcb4885"
+    },
+    {
+      "path": "src/modules/host_watchdog.v",
+      "status": "match",
+      "expected": "7e0fa1d575424a23828c9f1f890dd4e1db9e70776e224fe379c6b5e18b5da071",
+      "actual": "7e0fa1d575424a23828c9f1f890dd4e1db9e70776e224fe379c6b5e18b5da071"
+    },
+    {
+      "path": "src/modules/door_percent_planner.v",
+      "status": "match",
+      "expected": "724a10531400127a5c4443cc91894bc73ef1e31dac7a89ba5f78449ce5ecd6c1",
+      "actual": "724a10531400127a5c4443cc91894bc73ef1e31dac7a89ba5f78449ce5ecd6c1"
+    },
+    {
+      "path": "src/modules/door_motion_service_tick.v",
+      "status": "match",
+      "expected": "598d453008434fc222ceac9bbc87d87431ebc4b75134e6e293cfc9babedad9a6",
+      "actual": "598d453008434fc222ceac9bbc87d87431ebc4b75134e6e293cfc9babedad9a6"
+    },
+    {
+      "path": "src/modules/door_calibration_sequencer.v",
+      "status": "match",
+      "expected": "d94ffa26717c907fe848670aec49426282b617334d2c6e376f32e334a3211786",
+      "actual": "d94ffa26717c907fe848670aec49426282b617334d2c6e376f32e334a3211786"
+    },
+    {
+      "path": "src/modules/door_profile_quantum_builder.v",
+      "status": "match",
+      "expected": "00884c340a8287a52b9ca51cc0acde6533b7c811517444099b08c5eceec44d71",
+      "actual": "00884c340a8287a52b9ca51cc0acde6533b7c811517444099b08c5eceec44d71"
+    },
+    {
+      "path": "src/modules/door_rate_quantum_builder.v",
+      "status": "match",
+      "expected": "56c60059432ab90ff25d5ab578687bfbaedaa6e77d8d9cca1ef6b57ecb6c2794",
+      "actual": "56c60059432ab90ff25d5ab578687bfbaedaa6e77d8d9cca1ef6b57ecb6c2794"
+    },
+    {
+      "path": "src/modules/door_rate_quantum_dispatcher.v",
+      "status": "match",
+      "expected": "922e792d23e2bf13bdd3d67abf0db41d081b56ece98880bb692da928e7c4d08a",
+      "actual": "922e792d23e2bf13bdd3d67abf0db41d081b56ece98880bb692da928e7c4d08a"
+    },
+    {
+      "path": "src/modules/door_shared_dda_scheduler.v",
+      "status": "match",
+      "expected": "eeabe56e0a8dd236b25534a6091b2f28c75daf550bbabe709ea1bcb302a5a60b",
+      "actual": "eeabe56e0a8dd236b25534a6091b2f28c75daf550bbabe709ea1bcb302a5a60b"
+    },
+    {
+      "path": "src/modules/door_axis_controller.v",
+      "status": "match",
+      "expected": "50ac95f9e3df262002ad82f35d6fd0844ed2dc3c71f54c03f1927d2e0906bb21",
+      "actual": "50ac95f9e3df262002ad82f35d6fd0844ed2dc3c71f54c03f1927d2e0906bb21"
+    },
+    {
+      "path": "src/modules/door_motion_controller.v",
+      "status": "match",
+      "expected": "db04af336fab56366123437d3a1a8a5cfb0644963479769b809d3e01bcc26d12",
+      "actual": "db04af336fab56366123437d3a1a8a5cfb0644963479769b809d3e01bcc26d12"
+    },
+    {
+      "path": "src/modules/prod2u_runtime_step_limit_gate.v",
+      "status": "match",
+      "expected": "1fe1a394a307cdc8276e2bad4de1445f2a0bba10a0b10a167628f9434d81dc25",
+      "actual": "1fe1a394a307cdc8276e2bad4de1445f2a0bba10a0b10a167628f9434d81dc25"
+    },
+    {
+      "path": "src/modules/i2c_word_reader.v",
+      "status": "match",
+      "expected": "602cf5c7f9d4fbf4f5a353503b050b5b553fc735b90c0a57680c6cb9672b2192",
+      "actual": "602cf5c7f9d4fbf4f5a353503b050b5b553fc735b90c0a57680c6cb9672b2192"
+    },
+    {
+      "path": "src/modules/temperature_reader.v",
+      "status": "match",
+      "expected": "f0f2f6a0c018f81080c15bddde48256b7fa740dc986a2ed7a84d2dd6a3ba2ce2",
+      "actual": "f0f2f6a0c018f81080c15bddde48256b7fa740dc986a2ed7a84d2dd6a3ba2ce2"
+    },
+    {
+      "path": "src/modules/temperature_ram.v",
+      "status": "match",
+      "expected": "44b5e9d0753d055f02057a9eeb675ca585ebb9c87650f5419e90a0a05058ac2d",
+      "actual": "44b5e9d0753d055f02057a9eeb675ca585ebb9c87650f5419e90a0a05058ac2d"
+    },
+    {
+      "path": "src/project/command_controller.v",
+      "status": "match",
+      "expected": "801e9016560d380b272679c792641e6cf0f585dc5f5021d8d2274404a362096f",
+      "actual": "801e9016560d380b272679c792641e6cf0f585dc5f5021d8d2274404a362096f"
+    },
+    {
+      "path": "src/project/project_adapter.v",
+      "status": "match",
+      "expected": "c15edce6515a91383976ccd93c9048e61db4b022395a08c43518582565e91316",
+      "actual": "c15edce6515a91383976ccd93c9048e61db4b022395a08c43518582565e91316"
+    },
+    {
+      "path": "src/rtl/prod2u_por.v",
+      "status": "match",
+      "expected": "29babde9103cca3f8e10b6bd804f33455a7f119fadcda56d0a5142db9d163120",
+      "actual": "29babde9103cca3f8e10b6bd804f33455a7f119fadcda56d0a5142db9d163120"
+    },
+    {
+      "path": "src/rtl/prod2u_p4_i2c_stop_start_read.v",
+      "status": "match",
+      "expected": "c687f3d629cc5e37a3030e2f338f43732c357e81c3645e1abbc1d3d4c888d4b6",
+      "actual": "c687f3d629cc5e37a3030e2f338f43732c357e81c3645e1abbc1d3d4c888d4b6"
+    },
+    {
+      "path": "src/top/prod2u_p4_normal_v3_top.v",
+      "status": "match",
+      "expected": "da5226ec1dfe600d2e2880df3ee27c6ed550f0c5f50b03f0ef456f9d628d90cb",
+      "actual": "da5226ec1dfe600d2e2880df3ee27c6ed550f0c5f50b03f0ef456f9d628d90cb"
+    },
+    {
+      "path": "constraints/prod2u_p4_normal_v3.adc",
+      "status": "match",
+      "expected": "9662ff11f9040c465d208084dbb52121ec0d3c20e834c65bc54c48f121d474dd",
+      "actual": "9662ff11f9040c465d208084dbb52121ec0d3c20e834c65bc54c48f121d474dd"
+    },
+    {
+      "path": "constraints/prod2u_p4_normal_v3.sdc",
+      "status": "match",
+      "expected": "eda2bbd114a7bb9ee5b5939f96d02bd5f76cbbb60b7f9981cc0513226d6320a9",
+      "actual": "eda2bbd114a7bb9ee5b5939f96d02bd5f76cbbb60b7f9981cc0513226d6320a9"
+    },
+    {
+      "path": "td/prod2u_p4_normal_v3.prj",
+      "status": "match",
+      "expected": "bbe3b6876c80a35b65bad1e22cdcd959884179ee8d3b08607eb22458c05277d4",
+      "actual": "bbe3b6876c80a35b65bad1e22cdcd959884179ee8d3b08607eb22458c05277d4"
+    },
+    {
+      "path": "td/syn/prod2u_p4_normal_v3.tcl",
+      "status": "match",
+      "expected": "9ac6e96a3bdaaa43e5ee05f795b74327e02c7181a3901ffe7d3ea8b9be79bf49",
+      "actual": "9ac6e96a3bdaaa43e5ee05f795b74327e02c7181a3901ffe7d3ea8b9be79bf49"
+    },
+    {
+      "path": "td/phy/prod2u_p4_normal_v3.tcl",
+      "status": "match",
+      "expected": "e13347e31d6cb83a5984f11cd4c6c793c9588cee5e17bf7dda30bd2969524366",
+      "actual": "e13347e31d6cb83a5984f11cd4c6c793c9588cee5e17bf7dda30bd2969524366"
+    },
+    {
+      "path": "td/bitgen/prod2u_p4_normal_v3.tcl",
+      "status": "match",
+      "expected": "31f8b59e00779e7b08b2a186dce6d3c671a5e1ec0877762b8853aebfddee3a92",
+      "actual": "31f8b59e00779e7b08b2a186dce6d3c671a5e1ec0877762b8853aebfddee3a92"
+    },
+    {
+      "path": "projects/prod2u-door-temp/project.json",
+      "status": "match",
+      "expected": "11ebf4e0d7e1e26265b3d9994409fca89459d2ce002b15052b97851fe42300f3",
+      "actual": "11ebf4e0d7e1e26265b3d9994409fca89459d2ce002b15052b97851fe42300f3"
+    },
+    {
+      "path": "src/generated/td-source-manifest.json",
+      "status": "match",
+      "expected": "6d13f5090c4f1423d7507950414b2f3333c8ed931c6582fb8b62abf314c2df03",
+      "actual": "6d13f5090c4f1423d7507950414b2f3333c8ed931c6582fb8b62abf314c2df03"
+    }
+  ],
+  "matrix_verification_tip": "21ed755ad2ddb6689bca88a9a037b391372a060e",
+  "checked_delivery_commit_note": "filled at package-time against actual HEAD",
+  "legacy_mislabeled_verification_tip": "e73bb8b999f5d6eb70a8045e7cdb5c842c656b71",
+  "verification_tip": "21ed755ad2ddb6689bca88a9a037b391372a060e",
+  "note": "Round-8: matrix_verification_tip is 21ed755; e73bb8b was docs-only post-matrix tip (not matrix tip)"
+}

+ 28 - 0
receipts/mse-r8-prepackage/td-binding-receipt.json

@@ -0,0 +1,28 @@
+{
+  "schema": "prod2u-mse-r8-td-binding-validator-v1",
+  "status": "pass",
+  "verification_run_id": "mse-r7-20260812T132652Z",
+  "verification_tip": "21ed755ad2ddb6689bca88a9a037b391372a060e",
+  "artifact_source_commit": "ff44128a540b7ffd9d82314093b242ac3aee92d7",
+  "td_bound_commit": "ff44128a540b7ffd9d82314093b242ac3aee92d7",
+  "td_policy": "reuse_exact_source_bound_td",
+  "fresh_td": false,
+  "bitstream_sha256": "b4b0eda4ee8d774109eff83b519bdaa19d5e73d770562983121a596df00952d0",
+  "lut": 4320,
+  "mslice": 1089,
+  "dsp": 1,
+  "fmax_mhz": 42.332,
+  "production_binding": {
+    "expected": 37,
+    "matched": 37,
+    "missing": 0,
+    "hash_mismatch": 0
+  },
+  "hardware_validation": "NOT RUN",
+  "dev_merge": "FORBIDDEN",
+  "generated_utc": "2026-08-12T15:05:25Z",
+  "matrix_verification_tip": "21ed755ad2ddb6689bca88a9a037b391372a060e",
+  "legacy_mislabeled_verification_tip": "e73bb8b999f5d6eb70a8045e7cdb5c842c656b71",
+  "td_binding_status": "pass",
+  "note": "Round-8 reuse exact source-bound TD; matrix tip 21ed755; artifact ff44128; bitstream b4b0eda4"
+}

+ 5 - 1
tools/build_firmware_package.py

@@ -44,7 +44,11 @@ REPO_TD_INPUTS = [
 # Round-9 door-percent base: locked immutable `dev` tip.
 OLD_BASELINE_COMMIT_DEFAULT = "d4f3df2549efeb1e9227f62d1d71c6179c9f9160"
 BASE_DEV_COMMIT_DEFAULT = OLD_BASELINE_COMMIT_DEFAULT
-RELEASE_TASK_SLUG = "door-percent"
+try:
+    from tools.package_provenance import release_task_slug as _release_task_slug
+except ImportError:  # pragma: no cover
+    from package_provenance import release_task_slug as _release_task_slug  # type: ignore
+RELEASE_TASK_SLUG = _release_task_slug()
 
 
 class PackagingError(RuntimeError):

+ 6 - 2
tools/package-review-compact.sh

@@ -29,10 +29,14 @@ while [[ $# -gt 0 ]]; do
   esac
 done
 if [[ "$STAGE" == "intermediate-review" ]]; then
-  NAME="${PRODU2_PACKAGE_NAME:-prod2u-review-compact-door-percent-intermediate-${SHORT}}"
+  TOPIC="${PRODU2_PACKAGE_TOPIC:-${PRODU2_RELEASE_TASK_SLUG:-mse-a1}}"
+  NAME="${PRODU2_PACKAGE_NAME:-prod2u-review-compact-${TOPIC}-intermediate-${SHORT}}"
 else
-  NAME="${PRODU2_PACKAGE_NAME:-prod2u-review-compact-door-percent-${SHORT}}"
+  TOPIC="${PRODU2_PACKAGE_TOPIC:-${PRODU2_RELEASE_TASK_SLUG:-mse-a1}}"
+  NAME="${PRODU2_PACKAGE_NAME:-prod2u-review-compact-${TOPIC}-${SHORT}}"
 fi
+export PRODU2_PACKAGE_TOPIC="${TOPIC}"
+export PRODU2_RELEASE_TASK_SLUG="${TOPIC}"
 mkdir -p "$OUT"
 exec "$PY" -B "$ROOT/package_for_agent_analysis.py" \
   --profile review-compact \

+ 3 - 1
tools/package-review-debug.sh

@@ -39,7 +39,9 @@ if [[ -n "$(git -C "$ROOT" status --porcelain --untracked-files=all 2>/dev/null
 fi
 
 # Allow PRODU2_PACKAGE_NAME / PRODU2_PACKAGE_TOPIC to name the current MSE round.
-TOPIC="${PRODU2_PACKAGE_TOPIC:-mse-round7-verification-closure}"
+TOPIC="${PRODU2_PACKAGE_TOPIC:-${PRODU2_RELEASE_TASK_SLUG:-mse-a1}}"
+export PRODU2_PACKAGE_TOPIC="${TOPIC}"
+export PRODU2_RELEASE_TASK_SLUG="${TOPIC}"
 NAME="${PRODU2_PACKAGE_NAME:-prod2u-${TOPIC}-intermediate-review-debug-${SHORT}}"
 mkdir -p "$OUT"
 exec "$PY" -B "$ROOT/package_for_agent_analysis.py" \

+ 40 - 9
tools/package_provenance.py

@@ -22,30 +22,61 @@ ROOT = Path(__file__).resolve().parents[1]
 OLD_BASELINE_DEFAULT = "d4f3df2549efeb1e9227f62d1d71c6179c9f9160"
 BASE_DEV_COMMIT_DEFAULT = OLD_BASELINE_DEFAULT
 ARTIFACT_DEFAULT = "f23d6d4c57959071cd3886ea5503fbe903aee547"
-RELEASE_TASK_SLUG = "door-percent"
+# MSE Round-8 canonical topic. ``door-percent`` remains a deprecated alias only.
+DEPRECATED_RELEASE_TASK_SLUG = "door-percent"
+_DEFAULT_RELEASE_TASK_SLUG = "mse-a1"
 
 
-def release_sibling_filename(kind: str, delivery_commit: str) -> str:
-    """Canonical sibling names for this task (never altconfig / cross-task slugs)."""
+def release_task_slug() -> str:
+    """Canonical package topic/slug (env override; default mse-a1)."""
+    import os
+
+    raw = (
+        os.environ.get("PRODU2_RELEASE_TASK_SLUG", "").strip()
+        or os.environ.get("PRODU2_PACKAGE_TOPIC", "").strip()
+        or _DEFAULT_RELEASE_TASK_SLUG
+    )
+    return raw.strip().strip("-_") or _DEFAULT_RELEASE_TASK_SLUG
+
+
+# Back-compat alias used by older importers; always resolve dynamically.
+RELEASE_TASK_SLUG = _DEFAULT_RELEASE_TASK_SLUG
+
+
+def release_sibling_filename(kind: str, delivery_commit: str, *, slug: str | None = None) -> str:
+    """Canonical sibling names for this task (topic/stage-aware; never altconfig)."""
+    topic = (slug or release_task_slug()).strip()
     short = _short(delivery_commit, 8)
     kind_n = kind.strip().casefold()
     if kind_n in {"review-compact", "review", "compact"}:
-        return f"prod2u-review-compact-{RELEASE_TASK_SLUG}-{short}.zip"
+        return f"prod2u-review-compact-{topic}-{short}.zip"
     if kind_n in {"firmware", "fw"}:
-        return f"prod2u-firmware-{RELEASE_TASK_SLUG}-{short}.zip"
+        return f"prod2u-firmware-{topic}-{short}.zip"
     if kind_n in {"review-selftest", "compact-selftest"}:
-        return f"prod2u-review-compact-{RELEASE_TASK_SLUG}-{short}.selftest.json"
+        return f"prod2u-review-compact-{topic}-{short}.selftest.json"
     if kind_n in {"firmware-selftest", "fw-selftest"}:
-        return f"prod2u-firmware-{RELEASE_TASK_SLUG}-{short}.selftest.json"
+        return f"prod2u-firmware-{topic}-{short}.selftest.json"
     if kind_n in {"release-set", "release_set"}:
-        return f"prod2u-release-set-{RELEASE_TASK_SLUG}-{short}.json"
+        return f"prod2u-release-set-{topic}-{short}.json"
+    if kind_n in {"review-replay", "detached-replay"}:
+        return f"prod2u-review-compact-{topic}-{short}.detached-replay.json"
+    if kind_n in {"cross-package", "crosscheck"}:
+        return f"prod2u-cross-package-{topic}-{short}.json"
+    if kind_n in {"release-validation", "release_validation"}:
+        return f"prod2u-release-validation-{topic}-{short}.json"
     raise ValueError(f"unknown sibling kind: {kind}")
 
 
+def deprecated_door_percent_alias(kind: str, delivery_commit: str) -> str:
+    """Deprecated door-percent sibling name (alias only; not final authority)."""
+    return release_sibling_filename(kind, delivery_commit, slug=DEPRECATED_RELEASE_TASK_SLUG)
+
+
 def assert_no_stale_task_slug(text: str) -> None:
     """Fail when packaging metadata still carries a cross-task stale slug."""
     lowered = text.casefold()
-    if "altconfig" in lowered and RELEASE_TASK_SLUG not in lowered:
+    topic = release_task_slug().casefold()
+    if "altconfig" in lowered and topic not in lowered and DEPRECATED_RELEASE_TASK_SLUG not in lowered:
         raise ValueError(f"stale task slug 'altconfig' in packaging identity: {text}")
 
 # Standalone raw reference package identity (receipt-backed; ZIP not in default compact).

+ 139 - 0
tools/verification_to_delivery_closure.py

@@ -0,0 +1,139 @@
+#!/usr/bin/env python3
+"""Package-time verification_tip → actual delivery HEAD closure (no self-hash loop).
+
+Tracked commits must not embed their own final commit hash. This helper is intended
+to run at package time against a clean exact HEAD and emit package-generated
+metadata (ZIP meta/), not a pre-committed self-referential receipt.
+"""
+
+from __future__ import annotations
+
+import argparse
+import json
+import subprocess
+import sys
+from datetime import datetime, timezone
+from pathlib import Path
+from typing import Any
+
+ROOT = Path(__file__).resolve().parents[1]
+
+# Paths that may change tip→delivery for a final release. Anything else is forbidden.
+ALLOWED_PREFIXES = (
+    "receipts/",
+    "evidence/",
+    "docs/",
+    "README",
+    "FINAL_DELIVERY",
+    "ACCEPTANCE_MATRIX",
+    "PLAN.md",
+    "OPEN_QUESTIONS",
+    "CHANGE-TEST-NOTES",
+    "AGENTS.md",
+)
+# Explicitly forbidden even under receipts/ if they alter production inputs.
+FORBIDDEN_PREFIXES = (
+    "src/",
+    "constraints/",
+    "td/",
+    "projects/prod2u-door-temp/",
+    "tests/formal/",
+    "tests/icarus/",
+    "tests/cocotb/",
+    "tools/prod2u_p4_harness.py",
+    "tools/run_verification_matrix.py",
+    "config/source_closure",
+)
+
+
+def _git(args: list[str], *, cwd: Path) -> str:
+    return subprocess.check_output(["git", *args], cwd=cwd, text=True).strip()
+
+
+def _classify(path: str) -> str:
+    lowered = path.replace("\\", "/")
+    for prefix in FORBIDDEN_PREFIXES:
+        if lowered == prefix or lowered.startswith(prefix):
+            return "forbidden"
+    for prefix in ALLOWED_PREFIXES:
+        if lowered == prefix or lowered.startswith(prefix):
+            return "allowed"
+    # Packaging helpers / selftests are allowed for release-only rounds.
+    if lowered.startswith("tools/package") or lowered.startswith("tools/compact_package"):
+        return "allowed"
+    if lowered.startswith("tools/verification_to_delivery"):
+        return "allowed"
+    if lowered.startswith("tests/unit/test_compact_package") or lowered.startswith(
+        "tests/unit/test_activity_docs"
+    ):
+        return "allowed"
+    if lowered.startswith("tools/package-review") or lowered.startswith("tools/build_firmware"):
+        return "allowed"
+    return "forbidden"
+
+
+def build_closure(
+    *,
+    repo: Path,
+    verification_tip: str,
+    delivery_commit: str | None = None,
+    matrix_run_id: str | None = None,
+    tool_version: str = "prod2u-mse-verification-to-delivery-closure-v2",
+) -> dict[str, Any]:
+    head = delivery_commit or _git(["rev-parse", "HEAD"], cwd=repo)
+    tip = verification_tip.strip()
+    if len(tip) < 7:
+        raise ValueError("verification_tip required")
+    changed = []
+    if tip != head:
+        out = _git(["diff", "--name-only", f"{tip}..{head}"], cwd=repo)
+        changed = [line for line in out.splitlines() if line.strip()]
+    classified = [{"path": p, "class": _classify(p)} for p in changed]
+    forbidden = [row["path"] for row in classified if row["class"] == "forbidden"]
+    closure_ok = len(forbidden) == 0
+    return {
+        "schema": tool_version,
+        "generated_utc": datetime.now(timezone.utc).isoformat(),
+        "matrix_verification_tip": tip,
+        "verification_tip": tip,  # alias for older consumers
+        "delivery_commit": head,
+        "actual_package_head": head,
+        "changed_paths": changed,
+        "classified_paths": classified,
+        "forbidden_changed_paths": forbidden,
+        "allowed_path_prefixes": list(ALLOWED_PREFIXES),
+        "forbidden_path_prefixes": list(FORBIDDEN_PREFIXES),
+        "closure_ok": closure_ok,
+        "matrix_run_id": matrix_run_id,
+        "tool_version": tool_version,
+        "note": (
+            "Package-time actual-HEAD closure. delivery_commit must equal ZIP "
+            "meta/git/HEAD.txt. Do not pre-commit this receipt inside the same tip."
+        ),
+        "hardware_validation": "NOT RUN",
+        "dev_merge": "FORBIDDEN",
+    }
+
+
+def main(argv: list[str] | None = None) -> int:
+    parser = argparse.ArgumentParser(description=__doc__)
+    parser.add_argument("--repo", type=Path, default=ROOT)
+    parser.add_argument("--verification-tip", required=True)
+    parser.add_argument("--delivery-commit", default="")
+    parser.add_argument("--matrix-run-id", default="")
+    parser.add_argument("--output", type=Path, required=True)
+    args = parser.parse_args(argv)
+    payload = build_closure(
+        repo=args.repo.resolve(),
+        verification_tip=args.verification_tip,
+        delivery_commit=args.delivery_commit or None,
+        matrix_run_id=args.matrix_run_id or None,
+    )
+    args.output.parent.mkdir(parents=True, exist_ok=True)
+    args.output.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8")
+    print(json.dumps({"closure_ok": payload["closure_ok"], "output": str(args.output)}))
+    return 0 if payload["closure_ok"] else 1
+
+
+if __name__ == "__main__":
+    sys.exit(main())