Przeglądaj źródła

fix(prod2u): finalize P0 truth, limit coverage, durable OSS CAD paths

Align door-byte 00 and delivery-commit identity docs/tests, strengthen
top runtime-limit TB plus formal gate equivalence, and keep OSS CAD on
persistent /data/prod2u for container rebuild survival.

Co-authored-by: Cursor <cursoragent@cursor.com>
root 3 miesięcy temu
rodzic
commit
c7e5a562b2

+ 129 - 0
.cursor/skills/chatgpt-56pro-auto-loop/SKILL.md

@@ -0,0 +1,129 @@
+---
+name: chatgpt-56pro-auto-loop
+description: >-
+  Prompt-relay loop with ChatGPT 5.6 Sol Pro via Edge Playwright: after each
+  local task, auto-upload results, wait for Pro, treat Pro's next prompt as the
+  new requirements, and repeat until Pro has no remaining changes. Always ask
+  about packager and reference. Use when the user wants dual-model auto
+  iteration without ferrying messages.
+---
+
+# ChatGPT 5.6 Pro 提示词接力自动环
+
+用户不当传话筒。模式不是“偶尔咨询”,而是:
+
+1. 用户先与 ChatGPT 会话,拿到**初始提示词**(可加工后交给本地 Agent)
+2. 本地主 Agent(Grok 4.5)按该提示词执行第一轮任务
+3. 任务结束后,**自动**把本轮结果包发给固定会话里的 GPT-5.6 Sol Pro
+4. 等待 Pro 审完并给出下一轮**超长多阶段详设/提示词**
+5. 将该提示词**直接当作下一轮需求/任务**继续执行(不必等用户搬运)
+6. 循环,直到某次 Pro 明确表示没什么要改 / 符合预期 / 可以停
+
+产品合同仍以根目录 `AGENTS.md` 与 `projects/prod2u-door-temp/` 为准。不新建 ChatGPT 插件、ledger 或固定顾问平台。
+
+## 环路示意
+
+```
+用户加工后的初始提示词
+        ↓
+Grok 执行一轮(Pro 详设允许并行则并行;撞车时现场微调)
+        ↓
+打分析包(源码 + 调试/分析记录 + 必要证据;默认无 reference)
+  + 短清单:改了什么 / 测了什么
+        ↓
+Playwright → 固定 ChatGPT 会话(Sol + Pro)
+  开放式审包 + 元提示期望 + 必问打包/reference
+        ↓
+抽取:结论 + 下一轮提示词/详设 → 落盘 .chatgpt-handoff/
+        ↓
+    Pro 还有意见? ──是──→ 下一轮提示词 = 本轮唯一任务合同 → 回到执行
+        │
+        否
+        ↓
+停止顾问环;汇总给用户;commit/push 仅在用户明确要求时做
+```
+
+## 给 Pro 的元提示期望(每轮回访应传达或贴入)
+
+你(GPT-5.6 Sol Pro)是本任务主导方,不只给几条修改意见。每一轮(含首次)主动完成并写清:
+
+1. **需求**:确认要做什么、不做什么、验收长什么样  
+2. **分析**:对照源码、调试/分析记录、证据,指出偏差与缺口(自然语言即可)  
+3. **架构**:模块划分、数据/控制路径、与 UART/PWM/门轴/限位/启动等边界  
+4. **逻辑**:简单粗暴、有效可靠;不为罕见/过度安全边界堆复杂机制  
+5. **详设**:一大段、多阶段自然语言详设(阶段顺序、目标、改哪些面、怎么测、怎么打包回传),让本地 **Grok 4.5** 能直接当任务合同执行
+
+本地 Agent 负责执行,可并行、可自修小问题并兜底;**需求—分析—架构—逻辑—详设的主体是你**。下一轮内容应可直接提示词接力,不必经用户翻译。沟通保持自然语言,不要强制 JSON/固定 schema/结构化 I/O。
+
+**实现优先级(详设必须遵守,本地照做):**
+
+1. **最高**:功能正确;逻辑简单粗暴;行为确定可靠。先做成能用、可综合的版本。  
+2. **其次**:功能正确后优化 **LUT / Slice(及 Packed Slice)**。其他 FPGA 资源不必省;若多用 BRAM/FF/IO/其他资源能换更低 LUT/Slice,可以优先考虑。  
+3. **最次**:性能(吞吐、延迟等)。不为性能复杂化设计。
+
+并行设备/功能不要求同步触发,只要某一时刻可有多个设备同时使能即可。
+
+**回传与打包默认:**
+
+- 本地回传:简短分析 +「改了什么 / 测了什么」短清单(非 JSON)+ 证据包  
+- 默认分析包主料:**源码 + 调试/分析记录及必要绑定证据**  
+- **PDF/BRD 等 reference 不进默认包,按需再要**,避免重复上传  
+- 打包宁多勿漏,只剔除对分析绝对无用的;脚本可维护 reference 卷但不默认打进每轮  
+- 若要改打包脚本或 reference 策略,明确写进下一轮提示词  
+
+不人为收窄与任务相关的改动面;并行拆分由你详设决定,本地撞车时再微调。
+
+## 每轮发给 Pro 时必须包含
+
+开放式主问(不要预填 P0/P1/P2),并带上上方元提示期望的要点:
+
+- 标明:我是 Cursor 侧 **Grok 4.5 High** 主 Agent  
+- 请你继续主导需求、分析、架构、逻辑、详设;用一大段多阶段自然语言给出下一轮完整提示词(我将原样作为任务合同)  
+- 请审本轮结果包:是否完全符合预期?还要改什么?  
+- 提醒实现优先级:功能简单可靠 → LUT/Slice → 性能最次;其他资源可换 LUT/Slice  
+- **必问**:打包脚本要不要改?reference(BRD/PDF/原件)是否仍不进默认分析包、要否按需另传?若要改,写入下一轮提示词  
+- 非严重边界/工具链/路径/测试夹具问题我会自修重跑  
+- Hardware 保持 NOT RUN(除非用户另行授权)  
+
+可附客观身份哈希、包 SHA、用户硬约束(只留本地 `dev`、普通 push 等)。
+
+## 接到 Pro 回复后怎么做
+
+1. 落盘完整答复与提示词原文到 `.chatgpt-handoff/`  
+2. 更新 `LOOP-STATE.md`(轮次、包哈希、是否继续、下一提示词路径)  
+3. 若 Pro 给出下一轮提示词:**该文件/文本即为下一轮唯一任务合同**,立即执行,不要缩成摘要后丢掉细节  
+4. 若 Pro 只有少量修改说明:把“还要改什么 + 打包/reference 决定”整理成可执行任务合同后继续  
+5. 若 Pro 明确“不用改了 / 符合预期 / 无进一步意见”:停止循环,向用户汇报,等待是否 commit/push  
+
+## Playwright 操作要点
+
+- 默认会话(可被用户覆盖):  
+  `https://chatgpt.com/g/g-p-6a16aa59456c8191a9df2af8ba070da8/c/6a7312ac-2364-83e8-abb3-e3575bef6b1f`
+- 模型:GPT-5.6 Sol + Pro  
+- 单标签复用;禁循环新开页;禁点历史 Download 下错旧文件  
+- 上传用已验证 Windows 路径:  
+  `C:\Users\Administrator\Agentworkspace\.playwright-upload-cache\<包名>.zip`  
+  经 `browser_run_code_unsafe` 对 composer `drop`(长对话可先藏历史 turn)  
+- 勿用 Linux `/root/...` 路径直接丢给 Edge  
+- reference:按当轮 Pro 意见;未要求则默认不传  
+- Pro 可能很慢:本地等待,勿因超时放弃环路  
+
+## 本地执行与回传
+
+- 按 Pro 当轮详设执行;优先级:功能简单可靠 → 再抠 LUT/Slice(其他资源可换)→ 最后性能  
+- 可按详设并行;执行期撞文件/worktree 问题时现场微调即可  
+- 回传:自然语言短分析 +「改了什么/测了什么」清单 + 分析包(默认无 reference)  
+- `/loop` 只监视本地长任务是否完成,不用于定时问 Pro  
+- `/run-everything`、`/in-cloud` 默认不用  
+- 不 force-push;不擅自 Hardware;不擅自 commit/push  
+
+## 落盘
+
+`.chatgpt-handoff/`:
+
+- `LOOP-STATE.md` — 轮次与是否继续  
+- `round-N/upload.zip` + `.sha256`  
+- `round-N/PROMPT-to-pro.txt`  
+- `round-N/REPLY-from-pro.md`  
+- `round-N/NEXT-TASK-PROMPT.md` — **下一轮直接执行的任务合同**  
+- `round-N/CHANGE-TEST-NOTES.md` — 本轮「改了什么/测了什么」短清单(可选独立文件)  

+ 2 - 0
.gitignore

@@ -75,3 +75,5 @@ reference/original/schematics/8000高温罩电气图V2.0.pdf
 /td_*.log
 /td_*.logw
 /td_20260804_*.log*
+.playwright-upload-cache/
+.chatgpt-handoff/

+ 4 - 4
ACCEPTANCE_MATRIX.md

@@ -10,7 +10,7 @@
 |---|---|---:|
 | Project configuration | `project.json`:4 FAN + 4 chamber PTC→8 PWM + Z/X/Y doors;UART/I2C/motor/watchdog/六限位 | pass(源合同) |
 | Schema | 配置节闭合;`stop_semantics` enum = truncate | pass(源合同) |
-| Protocol model | CRC;duty 0..100;**SET_ALL 11 字节**;旧 14 字节拒绝;三轴 `00=stop`;无电磁铁 | pass(源合同) |
+| Protocol model | CRC;duty 0..100;**SET_ALL 11 字节**;旧 14 字节拒绝;三轴 `00`=不启动新 jog(busy 忽略,非急停);无电磁铁 | pass(源合同) |
 | Motors / EN | 450 step jog @ 1000;X/Y/Z 可重叠;EN `permanent_high` @ CON120.2/C11 | pass(源合同) |
 | Limits / hard truncate | 六限位;`runtime_use=true`;`truncate_current_high_pulse_immediately_after_synchronized_limit` | pass(源合同) |
 | Startup one-shot | 5000 close / 500 backoff @ 1000;`startup_done` 后运行期仍硬截断(非惰性) | pass(源合同) |
@@ -20,9 +20,9 @@
 
 | Area | Bound evidence | Status |
 |---|---|---:|
-| Python / contract | tip `0de9f93…` / 后续 SOURCE-CLOSURE-UNCHANGED tip(内容 tip `03ab80b63d00…`;`dev` merge `503fa89a38c6…` 同树) | pass |
-| Formal / Icarus / cocotb / Verilator | `closure-matrix-final-20260806T023046Z-807dc3` @ `19d588bc…`(SOURCE-CLOSURE-UNCHANGED vs `0de9f93…`) | pass |
-| Full matrix @ FINAL_COMMIT | 软件矩阵 `closure-matrix-final-20260806T023046Z-807dc3` + TD `closure-td-20260806T022723Z-63cb51`;FINAL-DEV 内容 tip `03ab80b63d0056ba41a02a844fcee379fb8beb03` | pass(硬件除外) |
+| Python / contract | ARTIFACT-SOURCE `0de9f93…`;DELIVERY-COMMIT 见包内 meta(SOURCE-CLOSURE-UNCHANGED 以本轮 binding 为准) | pass |
+| Formal / Icarus / cocotb / Verilator | 以本轮 offline matrix receipt 为准(SOURCE-CLOSURE-UNCHANGED vs `0de9f93…`) | pass |
+| Full matrix @ ARTIFACT-SOURCE | 软件矩阵 + TD receipts 绑定本轮 run;DELIVERY-COMMIT 见包内 `FINAL-DEV-COMMIT.txt` / `meta/git/HEAD.txt` | pass(硬件除外) |
 | TD + bitstream | Linux `td2026` Release_2026.1_SP2 Build `6.2.2.200067` @ **`0de9f93988344e3c11931482902196b02ac7a713`**;bit SHA-256 `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c` | pass |
 | 历史旁路 bit(非 tip) | `45f548ab…` built @ `bb515af` | historical only — **不是** current |
 | Package / replay | firmware + compact + reference 三卷绑定最终 tip | 打包阶段 |

+ 2 - 1
AGENTS.md

@@ -43,7 +43,7 @@ Current authority is limited to the above contract files, this `AGENTS.md`, and
 - UART: 25 MHz, 115200 8N1, 217 clocks/bit, A5 5A framing, CRC-16/CCITT-FALSE.
 - Supported frame types: `0x01 SET_ALL`, `0x02 GET_TEMPERATURE`, `0x82 TEMPERATURE_DATA`.
 - SET_ALL payload: 4 FAN + 4 chamber PTC (each duplicated to 2 physical PTC PWM) + Z/X/Y door bytes (11 bytes total).
-- Door byte `00`: motor axes = stop (no new jog). `01` open / `02` close.
+- Door byte `00`: no new jog; while busy, ignore (does not stop or override running motion). `01` open / `02` close.
 - PTC active high; FAN active low at FPGA output.
 - PWM ~20 Hz.
 - Watchdog 10 s -> PTC 0, FAN 20.
@@ -70,6 +70,7 @@ Current authority is limited to the above contract files, this `AGENTS.md`, and
 - Prefer thin `tools/*.sh` entrypoints that call Python modules; do not use Windows PowerShell / `.ps1` as the production path.
 - Container-local package installs (apt/pip/npm) are allowed when reconstructing the toolchain; do not modify the host outside the container.
 - Temporary/run state uses Linux XDG paths (`$XDG_CACHE_HOME`, `$XDG_STATE_HOME`, `$XDG_RUNTIME_DIR`, `$TMPDIR`), never Windows `C:\...` or Downloads as authority.
+- Durable toolchains (OSS CAD Suite archive + extract, Anlogic TD) must live on persistent volumes such as `/data/prod2u/` (or `OSS_CAD_SUITE_ROOT` / `PRODU2_TOOLCHAIN_BASE`), not overlay `~/.cache` which disappears on container rebuild.
 - TD command is `td2026` (Anlogic TD 2026.1 SP2 Linux). Do not call `td603`, Windows `td_commands_prompt.exe`, or hard-code `C:\Anlogic\...`.
 - Keep TD `LD_LIBRARY_PATH` / vendor Qt vars confined to the TD subprocess; they break apt and other tools if exported globally.
 - Final acceptance evidence must be produced by the current Linux run; historical Windows receipts are historical only.

+ 3 - 4
FINAL_DELIVERY_REPORT.md

@@ -18,9 +18,8 @@
 |---|---|
 | 合同对齐基线 tip | `cdf9f76b22d75f1c2bc1e7ff99a49d2897a8dcb7`(Lane 合并起点) |
 | ARTIFACT-SOURCE-COMMIT(TD / 位流源闭包) | `0de9f93988344e3c11931482902196b02ac7a713` |
-| FINAL-DEV-COMMIT / 内容 tip(三卷包) | `03ab80b63d0056ba41a02a844fcee379fb8beb03` |
-| `dev` merge HEAD(同树) | `503fa89a38c642ddeb8b159ce096415cca64d115`(`^{tree}` 与 `03ab80b…` 相同;其后仅文档戳记) |
-| FINAL_COMMIT / ARTIFACT-SOURCE-COMMIT(位流源闭包) | `0de9f93988344e3c11931482902196b02ac7a713`(SOURCE-CLOSURE-UNCHANGED through docs tip) |
+| DELIVERY-COMMIT | 见 firmware 包 `FINAL-DEV-COMMIT.txt` / review-compact `meta/git/HEAD.txt`(活动文档不硬编码未产生的 tip) |
+| FINAL_COMMIT / ARTIFACT-SOURCE-COMMIT(位流源闭包) | `0de9f93988344e3c11931482902196b02ac7a713`(SOURCE-CLOSURE-UNCHANGED 以本轮 binding 为准) |
 | SET_ALL payload | **11 字节**(Z/X/Y) |
 | stop_semantics | `truncate_current_high_pulse_immediately_after_synchronized_limit` |
 | Full matrix | TD RUN_ID `closure-td-20260806T022723Z-63cb51`;软件矩阵 `closure-matrix-final-20260806T023046Z-807dc3` @ `19d588bc783c1df61e8750653fdd0b0c3eee43bf`(SOURCE-CLOSURE-UNCHANGED vs 位流 tip) |
@@ -33,7 +32,7 @@
 
 ## 风门与限位摘要
 
-- 三轴门字节 `00` = stop(无新 jog);`01` open;`02` close。
+- 三轴门字节 `00` = 不启动新 jog(busy 时不停止、不覆盖当前动作);`01` open;`02` close。
 - 六限位运行期与 startup 均硬截断;runtime limits are **not** inert。
 - EN:FPGA 恒 1(`permanent_high`)。
 

+ 1 - 1
OPEN_QUESTIONS.md

@@ -6,7 +6,7 @@ No user product-contract decision currently blocks the **11-byte SET_ALL + three
 
 - **Hardware validation: `NOT RUN`** — COM/JTAG/programming not authorized.
 - **FINAL_COMMIT / tip TD / bitstream SHA-256**: bound — ARTIFACT-SOURCE-COMMIT `0de9f93988344e3c11931482902196b02ac7a713`; Bitstream SHA-256 `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c`; td2026 Release_2026.1_SP2 Build `6.2.2.200067`; RUN_ID `closure-td-20260806T022723Z-63cb51`.
-- **FINAL-DEV / 内容 tip**: `03ab80b63d0056ba41a02a844fcee379fb8beb03`;`dev` merge HEAD `503fa89a38c642ddeb8b159ce096415cca64d115` 同树;其后文档戳记 SOURCE-CLOSURE-UNCHANGED。Hardware **`NOT RUN`**.
+- **DELIVERY-COMMIT**: 见 firmware 包 `FINAL-DEV-COMMIT.txt` / review-compact `meta/git/HEAD.txt`(活动文档不硬编码未产生的 tip)。SOURCE-CLOSURE-UNCHANGED 以本轮 binding 为准。Hardware **`NOT RUN`**.
 - Prior bypass firmware bitstream `45f548ab…` was built at `bb515af`, **not** tip — not active closure evidence.
 - Contract/source baseline for lanes merge start: `cdf9f76b22d75f1c2bc1e7ff99a49d2897a8dcb7`.
 - Active contract: X/Y/Z, six limits, 450/5000/500, EN `permanent_high`, hard truncate `truncate_current_high_pulse_immediately_after_synchronized_limit`. Runtime limits are **not** inert.

+ 1 - 1
PLAN.md

@@ -2,7 +2,7 @@
 
 - Contract truth: X/Y/Z, six limits, 450/5000/500, EN `permanent_high`, hard truncate `truncate_current_high_pulse_immediately_after_synchronized_limit`
 - ARTIFACT-SOURCE-COMMIT / tip TD: `0de9f93988344e3c11931482902196b02ac7a713`
-- FINAL-DEV / 内容 tip(三卷包): `03ab80b63d0056ba41a02a844fcee379fb8beb03`(`dev` merge `503fa89a38c642ddeb8b159ce096415cca64d115` 同树;SOURCE-CLOSURE-UNCHANGED)
+- DELIVERY-COMMIT: 见 firmware 包 `FINAL-DEV-COMMIT.txt` / review-compact `meta/git/HEAD.txt`(SOURCE-CLOSURE-UNCHANGED 以本轮 binding 为准)
 - Bitstream SHA-256: `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c`
 - td2026: Release_2026.1_SP2 Build `6.2.2.200067` (RUN_ID `closure-td-20260806T022723Z-63cb51`)
 - Historical bypass bit `45f548ab…` @ `bb515af` — **not** tip

+ 6 - 5
README.zh-CN.md

@@ -18,9 +18,9 @@ PTC/FAN 占空为十进制 0..100。PWM ≈20 Hz。PTC active-high;FAN 在 FPG
 
 | 字节 | 轴 | `00` | `01` | `02` |
 |---|---|---|---|---|
-| 偏移 8 | Z | stop(无新 jog) | open DIR=0 | close DIR=1 |
-| 偏移 9 | X | stop(无新 jog) | open DIR=0 | close DIR=1 |
-| 偏移 10 | Y | stop(无新 jog) | open DIR=0 | close DIR=1 |
+| 偏移 8 | Z | 不启动新 jog(busy 忽略,不停止/不覆盖当前动作) | open DIR=0 | close DIR=1 |
+| 偏移 9 | X | 不启动新 jog(busy 忽略,不停止/不覆盖当前动作) | open DIR=0 | close DIR=1 |
+| 偏移 10 | Y | 不启动新 jog(busy 忽略,不停止/不覆盖当前动作) | open DIR=0 | close DIR=1 |
 
 普通 jog:**450** 步 @ 1000 step/s;X/Y/Z 可并行。电机 EN:CON120.2 / C11,FPGA `permanent_high`(板级 NPN 反相后座端永久使能)。详细合同见 [`docs/prod2u-door-temp-protocol.zh-CN.md`](docs/prod2u-door-temp-protocol.zh-CN.md) 与 `projects/prod2u-door-temp/project.json`。
 
@@ -47,8 +47,9 @@ PTC/FAN 占空为十进制 0..100。PWM ≈20 Hz。PTC active-high;FAN 在 FPG
 |---|---|
 | 合同 / 源码基线 tip | `cdf9f76b22d75f1c2bc1e7ff99a49d2897a8dcb7`(Lane 合并起点) |
 | ARTIFACT-SOURCE-COMMIT / FINAL_COMMIT(TD 源闭包) | `0de9f93988344e3c11931482902196b02ac7a713` |
-| FINAL-DEV / 内容 tip(三卷包) | `03ab80b63d0056ba41a02a844fcee379fb8beb03`(`dev` merge `503fa89a38c642ddeb8b159ce096415cca64d115` 同树;SOURCE-CLOSURE-UNCHANGED) |
-| Bitstream SHA-256 | `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c` |
+| DELIVERY-COMMIT | 见 firmware 包 `FINAL-DEV-COMMIT.txt` / review-compact `meta/git/HEAD.txt`(不在活动文档硬编码未产生的 tip) |
+| Bitstream SHA-256 | `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c`(若生产输入相对 ARTIFACT-SOURCE 变化则以本轮 TD 新产物为准) |
+| SOURCE-CLOSURE-UNCHANGED | 以本轮 `meta/td/td-source-closure-binding.json` 与逐文件 source closure map 为准 |
 | td2026 | Release_2026.1_SP2 Build `6.2.2.200067`;RUN_ID `closure-td-20260806T022723Z-63cb51` |
 | 历史旁路 firmware bit | `45f548ab…` 构建于 `bb515af`,**不是** tip / 当前闭包证据 |
 | Hardware / JTAG / 烧录 | **`not_run`**(未授权) |

+ 2 - 2
docs/HARDWARE_BRINGUP_NOTES.zh-CN.md

@@ -24,7 +24,7 @@ run_id: `3axis-20260805T171312Z`
 | 4 | FAN/PTC PWM | SET_ALL 单腔 0/50/100 | ~20 Hz;同腔两路 PTC 一致 |
 | 5 | 普通 jog | byte8/9/10 = Z/X/Y;`01`/`02` | 450 STEP 上升沿 @ 1000 step/s |
 | 6 | 运行期限位硬停 | jog 中拨对应方向限位 | 当前高脉冲结束后无新上升沿 |
-| 7 | `00` stop | busy 时或空闲发 `00` | 无新 jog;busy 忽略新 start |
+| 7 | `00` 不启动新 jog | busy 时或空闲发 `00` | busy 忽略;不停止/不覆盖当前动作 |
 | 8 | 看门狗 | 停发 SET_ALL ≥10 s | PTC→0,FAN→20 |
 
 ## 2. 期望行为摘要
@@ -39,7 +39,7 @@ run_id: `3axis-20260805T171312Z`
 
 ### 2.2 普通 jog(startup_done 后)
 
-- SET_ALL:`door_z`@8、`door_x`@9、`door_y`@10;`01` 开 / `02` 关 / `00` stop。
+- SET_ALL:`door_z`@8、`door_x`@9、`door_y`@10;`01` 开 / `02` 关 / `00` 不启动新 jog(busy 时不停止、不覆盖)。
 - 固定 **450** STEP @ 1000 step/s。
 - 运行期:开方向看 HS、关方向看 LS;每时钟硬停。
 

+ 4 - 3
docs/HARDWARE_TEST_ORDER_WAVEFORMS.zh-CN.md

@@ -1,8 +1,9 @@
 # Prod2U V1.2 硬件测试顺序与期望波形(三轴活动版)
 
-前提:比特流与 active ADC 绑定 tip TD `0de9f93988344e3c11931482902196b02ac7a713`;  
+前提:比特流与 active ADC 绑定 ARTIFACT-SOURCE-COMMIT `0de9f93988344e3c11931482902196b02ac7a713`;  
 Bitstream SHA-256 `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c`(td2026 Release_2026.1_SP2 Build `6.2.2.200067`)。  
-历史旁路 bit `45f548ab…` @ `bb515af` **不是** tip。  
+DELIVERY-COMMIT 见 firmware 包 / `meta/git/HEAD.txt`。SOURCE-CLOSURE-UNCHANGED 以本轮 binding 为准。  
+历史旁路 bit `45f548ab…` @ `bb515af` **不是** tip。 Hardware **`NOT RUN`**。  
 本文件 **不是** 已执行硬件回执;物理 COM/JTAG 未授权前状态为 `not_run`。
 
 旧二轴+电磁铁探点(CON68/CON34/CON138–141、solenoid)已归档:  
@@ -66,7 +67,7 @@ LIMIT (active-high):   ____________/‾‾‾‾‾‾  → truncate high immedi
 
 ### 2.4 普通 jog(startup_done 后)
 
-- `01` DIR=0 开门;`02` DIR=1 关门;`00` = stop(无新 jog)。
+- `01` DIR=0 开门;`02` DIR=1 关门;`00` = 不启动新 jog(busy 时不停止、不覆盖当前动作)。
 - 非零命令:最多 **450** 个 STEP 上升沿 @ 1000 step/s。
 - 运行期目标限位有效:**硬截断**(非 inert)。
 

+ 1 - 1
docs/TD_USAGE.zh-CN.md

@@ -7,7 +7,7 @@
 | 项 | 状态 |
 |---|---|
 | ARTIFACT-SOURCE-COMMIT / FINAL_COMMIT / tip TD | `0de9f93988344e3c11931482902196b02ac7a713` |
-| FINAL-DEV / 内容 tip(三卷包) | `03ab80b63d0056ba41a02a844fcee379fb8beb03`(`dev` merge `503fa89a38c642ddeb8b159ce096415cca64d115` 同树;SOURCE-CLOSURE-UNCHANGED) |
+| DELIVERY-COMMIT | 见 firmware 包 `FINAL-DEV-COMMIT.txt` / review-compact `meta/git/HEAD.txt`(SOURCE-CLOSURE-UNCHANGED 以本轮 binding 为准) |
 | Bitstream SHA-256 | `54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c` |
 | td2026 | Release_2026.1_SP2 Build `6.2.2.200067` |
 | TD RUN_ID | `closure-td-20260806T022723Z-63cb51` |

+ 4 - 1
package_for_agent_analysis.py

@@ -1113,7 +1113,10 @@ def collect_analysis_inputs(
             commit=binding_commit,
             require_bitstream=require_bitstream_binding,
         )
-        provenance_artifacts["meta/td-source-closure-binding.json"] = handoff.json_bytes(binding)
+        binding_bytes = handoff.json_bytes(binding)
+        # Canonical path meta/td/...; keep legacy flat alias for older consumers.
+        provenance_artifacts["meta/td/td-source-closure-binding.json"] = binding_bytes
+        provenance_artifacts["meta/td-source-closure-binding.json"] = binding_bytes
         purpose = handoff.package_purpose_text(profile, package_name=package_name)
         provenance_artifacts["meta/PACKAGE-PURPOSE.txt"] = purpose.encode("utf-8")
         items.extend(

+ 1 - 1
projects/prod2u-door-temp/requirements.zh-CN.md

@@ -32,7 +32,7 @@ CRC 为 CRC-16/CCITT-FALSE。正式类型只有 `0x01`、`0x02` 和 `0x82`。
 
 ## 风门与马达
 
-- 三轴编码均为 `00/01/02`:`00` = **stop**(无新 jog);`01` 开门 DIR=0;`02` 关门 DIR=1。
+- 三轴编码均为 `00/01/02`:`00` = 不启动新 jog(轴已 busy 时忽略该字节,不停止、不覆盖当前动作);`01` 开门 DIR=0;`02` 关门 DIR=1。
 - 普通 jog:450 步、1000 step/s,X/Y/Z 可并行。
 - 电机 EN:CON120.2 → C11,板级 NPN 反相;FPGA 恒 1(`permanent_high`),座端 EN 永久有效。
 - 步进/方向球位:X CON104.2/3 → C12/B12;Y CON105.2/3 → L12/J11;Z CON106.2/3 → L14/K14。

+ 129 - 4
tests/sim/prod2u_p4_normal_v3_top_runtime_limit_tb.v

@@ -30,8 +30,16 @@ module prod2u_p4_normal_v3_top_runtime_limit_tb;
     reg fast_tick;
 
     integer host_x_steps;
+    integer host_y_steps;
+    integer host_z_steps;
+    integer post_limit_rise;
     reg prev_x_step;
+    reg prev_y_step;
+    reg prev_z_step;
     reg startup_done_seen = 1'b0;
+    reg count_y_steps = 1'b0;
+    reg count_z_steps = 1'b0;
+    reg watch_x_rises = 1'b0;
 
     always #1 sys_clk = ~sys_clk;
 
@@ -66,8 +74,17 @@ module prod2u_p4_normal_v3_top_runtime_limit_tb;
 
     always @(posedge sys_clk) begin
         prev_x_step <= x_step;
-        if (startup_done_seen && !prev_x_step && x_step)
+        prev_y_step <= y_step;
+        prev_z_step <= z_step;
+        if (startup_done_seen && !prev_x_step && x_step) begin
             host_x_steps <= host_x_steps + 1;
+            if (watch_x_rises)
+                post_limit_rise <= post_limit_rise + 1;
+        end
+        if (startup_done_seen && count_y_steps && !prev_y_step && y_step)
+            host_y_steps <= host_y_steps + 1;
+        if (startup_done_seen && count_z_steps && !prev_z_step && z_step)
+            host_z_steps <= host_z_steps + 1;
     end
 
     task wait_for_startup_done;
@@ -136,6 +153,7 @@ module prod2u_p4_normal_v3_top_runtime_limit_tb;
             $fatal(1, "runtime LS stop failed to truncate X before 450, got %0d", host_x_steps);
         if (host_x_steps < 1)
             $fatal(1, "X never stepped before runtime LS stop");
+        $display("PASS_SECTION_X_LS steps=%0d", host_x_steps);
 
         // Wrong-side HS while closing must not stop X.
         host_x_steps = 0;
@@ -151,6 +169,7 @@ module prod2u_p4_normal_v3_top_runtime_limit_tb;
         release_host_motor();
         if (host_x_steps !== HOST_STEPS)
             $fatal(1, "expected full 450 with wrong-side HS held, got %0d", host_x_steps);
+        $display("PASS_SECTION_WRONG_HS steps=%0d", host_x_steps);
 
         // Host open on X (DIR=0): assert HS mid-move -> truncate before 450.
         host_x_steps = 0;
@@ -168,26 +187,132 @@ module prod2u_p4_normal_v3_top_runtime_limit_tb;
         release_host_motor();
         if (host_x_steps >= HOST_STEPS)
             $fatal(1, "runtime HS stop failed to truncate X before 450, got %0d", host_x_steps);
+        $display("PASS_SECTION_X_HS steps=%0d", host_x_steps);
+
+        // Target limit already high before start -> zero external rising edges.
+        host_x_steps = 0;
+        prev_x_step = 1'b0;
+        x_limit_ls = 1'b1;
+        x_limit_hs = 1'b0;
+        drain_limit_sync();
+        start_host_motor(3'b001, 3'b001);
+        // Engine may finish immediately or ignore start when target limit already high.
+        repeat (400) @(posedge sys_clk);
+        if (dut.u_motor_engine.busy) begin
+            force dut.watchdog_timeout_event = 1'b1;
+            @(posedge sys_clk);
+            force dut.watchdog_timeout_event = 1'b0;
+            repeat (20) @(posedge sys_clk);
+        end
+        if (dut.u_motor_engine.busy)
+            $fatal(1, "pre-asserted LS left X engine busy");
+        release_host_motor();
+        if (host_x_steps !== 0)
+            $fatal(1, "pre-asserted LS should yield zero X rising edges, got %0d", host_x_steps);
+        $display("PASS_SECTION_PREASSERTED steps=%0d", host_x_steps);
+
+        // Y truncate on LS while Z continues to full 450 (axis independence).
+        host_y_steps = 0;
+        host_z_steps = 0;
+        prev_y_step = 1'b0;
+        prev_z_step = 1'b0;
+        count_y_steps = 1'b1;
+        count_z_steps = 1'b1;
+        x_limit_ls = 1'b0;
+        y_limit_ls = 1'b0;
+        z_limit_ls = 1'b0;
+        y_limit_hs = 1'b0;
+        z_limit_hs = 1'b0;
+        drain_limit_sync();
+        start_host_motor(3'b110, 3'b110);
+        begin : wait_y_steps
+            integer guard;
+            guard = 0;
+            while (host_y_steps < 5) begin
+                @(posedge sys_clk);
+                guard = guard + 1;
+                if (guard > 200000)
+                    $fatal(1, "timeout waiting for Y steps before LS truncate");
+            end
+        end
+        y_limit_ls = 1'b1;
+        drain_limit_sync();
+        if (y_step !== 1'b0)
+            $fatal(1, "runtime LS truncate failed on Y");
+        begin : wait_z_continue
+            integer z_before;
+            integer guard;
+            z_before = host_z_steps;
+            guard = 0;
+            while (host_z_steps < z_before + 8) begin
+                @(posedge sys_clk);
+                guard = guard + 1;
+                if (guard > 200000)
+                    $fatal(1, "Z did not continue after Y LS truncate");
+            end
+        end
+        // Abort remaining Z motion instead of waiting for full 450 (wall-time).
+        @(negedge sys_clk);
+        force dut.watchdog_timeout_event = 1'b1;
+        @(posedge sys_clk);
+        @(negedge sys_clk);
+        force dut.watchdog_timeout_event = 1'b0;
+        release_host_motor();
+        count_y_steps = 1'b0;
+        count_z_steps = 1'b0;
+        if (host_y_steps >= HOST_STEPS)
+            $fatal(1, "Y not truncated before 450, got %0d", host_y_steps);
+        $display("PASS_SECTION_YZ_INDEP y=%0d z=%0d", host_y_steps, host_z_steps);
 
-        // Watchdog abort: external STEP low; EN remains permanent_high.
+        // After synced target limit, no new X rising edges.
         host_x_steps = 0;
+        post_limit_rise = 0;
         prev_x_step = 1'b0;
         x_limit_ls = 1'b0;
         x_limit_hs = 1'b0;
+        y_limit_ls = 1'b0;
         drain_limit_sync();
         start_host_motor(3'b001, 3'b001);
+        while (host_x_steps < 4) @(posedge sys_clk);
+        x_limit_ls = 1'b1;
+        drain_limit_sync();
+        watch_x_rises = 1'b1;
+        repeat (200) @(posedge sys_clk);
+        watch_x_rises = 1'b0;
+        if (post_limit_rise !== 0)
+            $fatal(1, "new X rising edges after synced LS: %0d", post_limit_rise);
+        force dut.watchdog_timeout_event = 1'b1;
+        @(posedge sys_clk);
+        force dut.watchdog_timeout_event = 1'b0;
+        release_host_motor();
+        $display("PASS_SECTION_NO_RISE post=%0d", post_limit_rise);
+
+        // Watchdog abort: all external STEP low; EN remains permanent_high.
+        host_x_steps = 0;
+        host_y_steps = 0;
+        host_z_steps = 0;
+        prev_x_step = 1'b0;
+        count_y_steps = 1'b1;
+        count_z_steps = 1'b1;
+        x_limit_ls = 1'b0;
+        y_limit_ls = 1'b0;
+        z_limit_ls = 1'b0;
+        drain_limit_sync();
+        start_host_motor(3'b111, 3'b111);
         while (host_x_steps < 3) @(posedge sys_clk);
         @(negedge sys_clk);
         force dut.watchdog_timeout_event = 1'b1;
         @(posedge sys_clk);
         #1;
-        if (x_step !== 1'b0)
-            $fatal(1, "watchdog abort left x_step high");
+        if (x_step !== 1'b0 || y_step !== 1'b0 || z_step !== 1'b0)
+            $fatal(1, "watchdog abort left STEP high xyz=%b%b%b", x_step, y_step, z_step);
         if (motor_en_n !== 1'b1)
             $fatal(1, "motor_en_n dropped after watchdog (expected permanent_high)");
         @(negedge sys_clk);
         force dut.watchdog_timeout_event = 1'b0;
         release_host_motor();
+        count_y_steps = 1'b0;
+        count_z_steps = 1'b0;
 
         if (!dut.startup_done)
             $fatal(1, "startup_done was not sticky through runtime limit stops");

+ 41 - 12
tests/unit/test_activity_docs_truth.py

@@ -2,8 +2,8 @@
 """Fail-closed consistency gates for active status docs vs current 3-axis truth.
 
 Activity docs must assert X/Y/Z, six limits, 450/5000/500, permanent EN, hard
-truncate, and bound tip-TD/bitstream identity. Stale 2-axis/solenoid IO,
-runtime-limit-inert policy, and old bit/commit-as-current claims must not reappear.
+truncate, ARTIFACT-SOURCE / bitstream identity, and door-byte 00 semantics.
+Delivery commit is package-meta authority — not a hardcoded tip in tracked docs.
 """
 
 from __future__ import annotations
@@ -19,10 +19,6 @@ ROOT = Path(__file__).resolve().parents[2]
 
 ARTIFACT_SOURCE_COMMIT = "0de9f93988344e3c11931482902196b02ac7a713"
 ARTIFACT_SOURCE_SHORT = "0de9f939"
-FINAL_DEV_CONTENT_TIP = "03ab80b63d0056ba41a02a844fcee379fb8beb03"
-FINAL_DEV_CONTENT_TIP_SHORT = "03ab80b63d00"
-DEV_MERGE_HEAD = "503fa89a38c642ddeb8b159ce096415cca64d115"
-DEV_MERGE_HEAD_SHORT = "503fa89a38c6"
 BITSTREAM_SHA256 = (
     "54ce967da4dce40d7cbb6821eb1e8d7d95b3bdda27a7edf30cbcad7131cb667c"
 )
@@ -34,6 +30,11 @@ PRIOR_BIT_COMMIT = "bb515af"
 BASELINE_TIP_SHORT = "cdf9f76"
 STALE_FINAL_DEV_SHORT = "98fdf610"
 PENDING_MARKER = "pending final tip TD"
+# Historical content tip / merge that must not be re-asserted as current delivery tip.
+STALE_HARDCODED_DELIVERY_TIPS = (
+    "03ab80b63d0056ba41a02a844fcee379fb8beb03",
+    "503fa89a38c642ddeb8b159ce096415cca64d115",
+)
 
 ACTIVITY_DOCS = (
     "README.zh-CN.md",
@@ -56,8 +57,6 @@ PER_DOC_MARKERS = (
 # Must appear somewhere in the activity-doc corpus.
 CORPUS_REQUIRED = (
     ARTIFACT_SOURCE_COMMIT,
-    FINAL_DEV_CONTENT_TIP,
-    DEV_MERGE_HEAD,
     BITSTREAM_SHA256,
     TD_TOOL_BUILD,
     TRUNCATE_SEMANTICS,
@@ -75,8 +74,16 @@ CORPUS_REQUIRED = (
     PRIOR_BIT_SHORT,
     PRIOR_BIT_COMMIT,
     "ARTIFACT-SOURCE-COMMIT",
-    "FINAL-DEV",
+    "DELIVERY-COMMIT",
     "SOURCE-CLOSURE-UNCHANGED",
+    "meta/git/HEAD.txt",
+)
+
+# Door-byte 00 must not be bare "stop" without busy/no-override semantics.
+BARE_00_STOP = re.compile(
+    r"(?i)(?:`?00`?\s*=\s*`?stop`?|三轴\s*`?00\s*=\s*stop`?|"
+    r"`00`\s*=\s*\*\*stop\*\*|"
+    r"stop(无新 jog))"
 )
 
 # Superseded identifiers / policies that must not be presented as current tip truth.
@@ -145,7 +152,7 @@ STALE_AS_CURRENT = (
     ),
     (
         re.compile(
-            r"(?i)(?:FINAL-DEV(?:-COMMIT)?|文档 tip|内容 tip)\s*[|::=]*\s*`?"
+            r"(?i)(?:FINAL-DEV(?:-COMMIT)?|文档 tip|内容 tip|DELIVERY-COMMIT)\s*[|::=]*\s*`?"
             + STALE_FINAL_DEV_SHORT
         ),
         "stale FINAL-DEV 98fdf610 presented as current tip",
@@ -191,12 +198,35 @@ class ActivityDocsTruthTests(unittest.TestCase):
             corpus,
             r"(?i)45f548ab[^\n]{0,80}bb515af|bb515af[^\n]{0,80}45f548ab",
         )
-        # Active mapping must include 3-axis connectors somewhere.
         self.assertRegex(corpus, r"CON104")
         self.assertRegex(corpus, r"CON105")
         self.assertRegex(corpus, r"CON106")
         self.assertRegex(corpus, r"CON120")
         self.assertRegex(corpus, r"CON129")
+        # Door 00 canonical semantics somewhere in corpus.
+        self.assertRegex(
+            corpus,
+            r"(?i)(?:不启动新 jog|no new jog).{0,40}(?:busy|不停止|不覆盖)",
+        )
+
+    def test_activity_docs_reject_hardcoded_delivery_tip(self) -> None:
+        for rel in ACTIVITY_DOCS:
+            text = _read(rel)
+            for tip in STALE_HARDCODED_DELIVERY_TIPS:
+                self.assertNotIn(
+                    tip,
+                    text,
+                    f"{rel} hardcodes delivery tip {tip}; use package meta instead",
+                )
+
+    def test_activity_docs_reject_bare_00_stop(self) -> None:
+        for rel in ACTIVITY_DOCS:
+            text = _read(rel)
+            match = BARE_00_STOP.search(text)
+            if match is not None:
+                self.fail(
+                    f"{rel}: bare 00=stop without busy/no-override semantics: {match.group(0)!r}"
+                )
 
     def test_activity_docs_reject_stale_current_claims(self) -> None:
         for rel in ACTIVITY_DOCS:
@@ -219,7 +249,6 @@ class ActivityDocsTruthTests(unittest.TestCase):
             for token in obsolete:
                 if token.lower() not in text.lower() and token not in text:
                     continue
-                # Allow token only in sentences/lines that negate active use.
                 for line in text.splitlines():
                     if token.lower() not in line.lower() and token not in line:
                         continue

+ 7 - 2
tests/unit/test_bootstrap_oss_cad_suite.py

@@ -43,9 +43,14 @@ def run_powershell(command: str) -> subprocess.CompletedProcess[str]:
 
 class BootstrapOssCadSuiteTests(unittest.TestCase):
     def test_default_paths_use_path_home_not_administration_literal(self) -> None:
+        allowed_roots = {str(Path.home()), "/data/prod2u"}
         for path in [bootstrap.DEFAULT_ROOT, bootstrap.DEFAULT_DOWNLOAD_DIR, bootstrap.DEFAULT_COCOTB_VENV]:
-            self.assertIn(str(Path.home()), str(path))
-            self.assertNotIn(r"C:\Users\Administration", str(path))
+            text = str(path)
+            self.assertTrue(
+                any(text.startswith(root) or root in text for root in allowed_roots),
+                f"unexpected toolchain path {text}",
+            )
+            self.assertNotIn(r"C:\Users\Administration", text)
         self.assertEqual(
             bootstrap.DEFAULT_COCOTB_VENV.name,
             "prod2u-p4-actuator-trace-cocotb-venv",

+ 10 - 0
tests/unit/test_compact_package_selftest.py

@@ -64,6 +64,10 @@ class CompactPackageSelftestUnitTests(unittest.TestCase):
             package_dir.mkdir()
             zip_path = package_dir / "demo.zip"
             with zipfile.ZipFile(zip_path, "w") as archive:
+                archive.writestr(
+                    "CPLD/meta/td/td-source-closure-binding.json",
+                    json.dumps({"schema": "cpld-td-source-closure-binding-v1", "status": "hook_ready"}),
+                )
                 archive.writestr(
                     "CPLD/meta/td-source-closure-binding.json",
                     json.dumps({"schema": "cpld-td-source-closure-binding-v1", "status": "hook_ready"}),
@@ -74,11 +78,17 @@ class CompactPackageSelftestUnitTests(unittest.TestCase):
                     b"cdf9f76b22d75f1c2bc1e7ff99a49d2897a8dcb7\n",
                 )
                 archive.writestr("CPLD/meta/git/tree-manifest.json", b"{}\n")
+                archive.writestr(
+                    "CPLD/meta/git/source-file-sha256.json",
+                    b'{"schema":"cpld-review-git-file-sha256-v1","files":{}}\n',
+                )
                 archive.writestr(
                     "CPLD/meta/git/sanitized-snapshot-status.json",
                     b'{"status":"pass","requested":false}\n',
                 )
                 archive.writestr("CPLD/evidence/.keep", b"\n")
+            (package_dir / "EXCLUSIONS.txt").write_text("none\n", encoding="utf-8")
+            (package_dir / "START-HERE.zh-CN.md").write_text("# start\n", encoding="utf-8")
 
             files = [
                 {

+ 79 - 0
tests/unit/test_top_step_gate_matches_formal.py

@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+"""Structure-equivalence: formal STEP gate must match real top pin gate."""
+
+from __future__ import annotations
+
+import re
+import unittest
+from pathlib import Path
+
+ROOT = Path(__file__).resolve().parents[2]
+TOP = ROOT / "src/top/prod2u_p4_normal_v3_top.v"
+FORMAL = ROOT / "tests/formal/runtime_limit_hard_stop_formal.v"
+
+
+def _normalize_gate_expr(expr: str) -> str:
+    text = re.sub(r"\s+", "", expr)
+    # Formal uses limit_*_sync[i]; top uses x/y/z_limit_*_sync1.
+    text = text.replace("x_limit_ls_sync1", "limit_ls_sync[0]")
+    text = text.replace("x_limit_hs_sync1", "limit_hs_sync[0]")
+    text = text.replace("y_limit_ls_sync1", "limit_ls_sync[1]")
+    text = text.replace("y_limit_hs_sync1", "limit_hs_sync[1]")
+    text = text.replace("z_limit_ls_sync1", "limit_ls_sync[2]")
+    text = text.replace("z_limit_hs_sync1", "limit_hs_sync[2]")
+    text = text.replace("engine_step[0]", "engine_step")
+    text = text.replace("engine_dir[0]", "engine_dir")
+    text = text.replace("engine_step[1]", "engine_step")
+    text = text.replace("engine_dir[1]", "engine_dir")
+    text = text.replace("engine_step[2]", "engine_step")
+    text = text.replace("engine_dir[2]", "engine_dir")
+    text = text.replace("limit_ls_sync[0]", "LS")
+    text = text.replace("limit_hs_sync[0]", "HS")
+    text = text.replace("limit_ls_sync[1]", "LS")
+    text = text.replace("limit_hs_sync[1]", "HS")
+    text = text.replace("limit_ls_sync[2]", "LS")
+    text = text.replace("limit_hs_sync[2]", "HS")
+    return text
+
+
+def _extract_top_gates(text: str) -> dict[str, str]:
+    pattern = re.compile(
+        r"assign\s+([xyz])_step\s*=\s*([^;]+);",
+        re.MULTILINE,
+    )
+    return {m.group(1): _normalize_gate_expr(m.group(2)) for m in pattern.finditer(text)}
+
+
+def _extract_formal_gates(text: str) -> dict[str, str]:
+    pattern = re.compile(
+        r"assign\s+gated_step\[(\d)\]\s*=\s*([^;]+);",
+        re.MULTILINE,
+    )
+    axis = {"0": "x", "1": "y", "2": "z"}
+    return {
+        axis[m.group(1)]: _normalize_gate_expr(m.group(2))
+        for m in pattern.finditer(text)
+    }
+
+
+class TopStepGateMatchesFormalTests(unittest.TestCase):
+    def test_formal_gate_matches_top_structure(self) -> None:
+        top = TOP.read_text(encoding="utf-8")
+        formal = FORMAL.read_text(encoding="utf-8")
+        top_gates = _extract_top_gates(top)
+        formal_gates = _extract_formal_gates(formal)
+        self.assertEqual(set(top_gates), {"x", "y", "z"})
+        self.assertEqual(set(formal_gates), {"x", "y", "z"})
+        for axis in ("x", "y", "z"):
+            self.assertEqual(
+                top_gates[axis],
+                formal_gates[axis],
+                f"axis {axis}: top={top_gates[axis]!r} formal={formal_gates[axis]!r}",
+            )
+        # Canonical shape: engine_step & ~(engine_dir ? LS : HS)
+        for axis, expr in top_gates.items():
+            self.assertIn("engine_step&~(engine_dir?LS:HS)", expr, axis)
+
+
+if __name__ == "__main__":
+    unittest.main()

+ 9 - 2
tools/bootstrap-linux.sh

@@ -6,8 +6,15 @@ unset LD_LIBRARY_PATH LD_PRELOAD QT_PLUGIN_PATH || true
 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 
 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
-CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
-VENV="$CACHE/venvs/verify"
+if [[ -n "${PRODU2_TOOLCHAIN_BASE:-}" ]]; then
+  CACHE="$PRODU2_TOOLCHAIN_BASE"
+elif [[ -d /data/prod2u || ( -d /data && -w /data ) ]]; then
+  CACHE="/data/prod2u"
+else
+  CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
+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"
 OSS_CAD_BIN="${OSS_CAD_SUITE_ROOT:-$CACHE/oss-cad-suite/latest}/bin"
 

+ 7 - 0
tools/bootstrap_oss_cad_suite.py

@@ -23,6 +23,13 @@ from typing import Any
 
 def _default_toolchain_base() -> Path:
     if sys.platform.startswith("linux"):
+        override = os.environ.get("PRODU2_TOOLCHAIN_BASE", "").strip()
+        if override:
+            return Path(override)
+        # Durable volume survives container rebuild; overlay ~/.cache does not.
+        persistent = Path("/data/prod2u")
+        if persistent.is_dir() or os.access("/data", os.W_OK):
+            return persistent
         return Path.home() / ".cache" / "prod2u"
     return Path.home() / "CodexToolchains" / "CPLD"
 

+ 20 - 1
tools/compact_package_selftest.py

@@ -206,13 +206,32 @@ def run_compact_package_selftest(
 
     binding_status = "missing"
     if any(
-        _normalize_member(name).endswith("meta/td-source-closure-binding.json")
+        _normalize_member(name).endswith("meta/td/td-source-closure-binding.json")
+        or _normalize_member(name).endswith("meta/td-source-closure-binding.json")
         for name in members
     ):
         binding_status = "present"
     else:
         failures.append("missing_td_source_closure_binding")
 
+    required_meta_suffixes = (
+        "meta/git/HEAD.txt",
+        "meta/git/tree-manifest.json",
+    )
+    for suffix in required_meta_suffixes:
+        if not any(_normalize_member(name).endswith(suffix) for name in members):
+            failures.append(f"missing_{suffix.replace('/', '_')}")
+    if not any(
+        _normalize_member(name).endswith("meta/git/source-file-sha256.json")
+        or _normalize_member(name).endswith("meta/git/file-sha256.json")
+        for name in members
+    ):
+        failures.append("missing_meta_git_source_file_sha256")
+    if not (package_dir / "EXCLUSIONS.txt").is_file() and not (package_dir / "EXCLUSIONS.json").is_file():
+        failures.append("missing_exclusions_sidecar")
+    if not (package_dir / "START-HERE.zh-CN.md").is_file():
+        failures.append("missing_start_here_sidecar")
+
     replay_report: dict[str, Any] | None = None
     # Hash/path/forbidden failures still allow attempting replay only when ZIP is usable.
     if zip_path is not None and not any(

+ 8 - 2
tools/doctor.sh

@@ -2,13 +2,19 @@
 set -euo pipefail
 unset LD_LIBRARY_PATH LD_PRELOAD QT_PLUGIN_PATH || true
 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
+if [[ -n "${PRODU2_TOOLCHAIN_BASE:-}" ]]; then
+  CACHE="$PRODU2_TOOLCHAIN_BASE"
+elif [[ -d /data/prod2u || ( -d /data && -w /data ) ]]; then
+  CACHE="/data/prod2u"
+else
+  CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
+fi
 OSS_CAD_BIN="${OSS_CAD_SUITE_ROOT:-$CACHE/oss-cad-suite/latest}/bin"
 if [[ -d "$OSS_CAD_BIN" ]]; then
   export PATH="$OSS_CAD_BIN:$PATH"
 fi
 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
-VENV="${PRODU2_VERIFY_VENV:-$CACHE/venvs/verify}"
+VENV="${PRODU2_VERIFY_VENV:-${XDG_CACHE_HOME:-$HOME/.cache}/prod2u/venvs/verify}"
 if [[ -x "$VENV/bin/python" ]]; then
   exec "$VENV/bin/python" "$ROOT/tools/doctor_linux.py" "$@"
 fi

+ 6 - 0
tools/doctor_linux.py

@@ -26,6 +26,12 @@ if str(ROOT) not in sys.path:
 
 
 def _cache_root() -> Path:
+    override = os.environ.get("PRODU2_TOOLCHAIN_BASE", "").strip()
+    if override:
+        return Path(override)
+    persistent = Path("/data/prod2u")
+    if persistent.is_dir() or os.access("/data", os.W_OK):
+        return persistent
     return Path(os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache"))) / "prod2u"
 
 

+ 16 - 3
tools/download_oss_cad_linux.sh

@@ -7,9 +7,16 @@ unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY all_proxy no_proxy
 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH:-}"
 
 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
-CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
-DOWNLOAD_DIR="$CACHE/downloads"
-INSTALL_ROOT="$CACHE/oss-cad-suite/latest"
+# Prefer durable /data over overlay ~/.cache (container rebuild wipes overlay).
+if [[ -n "${PRODU2_TOOLCHAIN_BASE:-}" ]]; then
+  TOOLCHAIN_BASE="$PRODU2_TOOLCHAIN_BASE"
+elif [[ -d /data && -w /data ]]; then
+  TOOLCHAIN_BASE="/data/prod2u"
+else
+  TOOLCHAIN_BASE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
+fi
+DOWNLOAD_DIR="${OSS_CAD_DOWNLOAD_DIR:-$TOOLCHAIN_BASE/downloads}"
+INSTALL_ROOT="${OSS_CAD_SUITE_ROOT:-$TOOLCHAIN_BASE/oss-cad-suite/latest}"
 LOG="$DOWNLOAD_DIR/oss-cad-download.log"
 
 DEFAULT_URL="${OSS_CAD_DOWNLOAD_URL:-https://github.com/YosysHQ/oss-cad-suite-build/releases/download/2026-08-04/oss-cad-suite-linux-x64-20260804.tgz}"
@@ -35,12 +42,18 @@ Native curl resume download for OSS CAD Suite Linux x64.
   expected size: $EXPECTED_SIZE bytes
 
 Environment:
+  PRODU2_TOOLCHAIN_BASE     durable base (default: /data/prod2u when writable)
+  OSS_CAD_SUITE_ROOT        extract/install root (default: \$TOOLCHAIN_BASE/oss-cad-suite/latest)
+  OSS_CAD_DOWNLOAD_DIR      archive download dir (default: \$TOOLCHAIN_BASE/downloads)
   OSS_CAD_DOWNLOAD_URL      override download URL
   OSS_CAD_ARCHIVE           final .tgz path (default: \$DOWNLOAD_DIR/<basename>)
   OSS_CAD_EXPECTED_SIZE     byte size check (default: $EXPECTED_SIZE)
   OSS_CAD_EXPECTED_SHA256   sha256 check after download
                             (default: f9c8f52d7333341a1dcad3dc19b0ce229f1b30c5a30cdc8befcc6dd5c8ee2cbd)
   OSS_CAD_SKIP_EXTRACT=1    download only, do not extract
+
+Note: do not store the OSS CAD archive/extract under overlay ~/.cache; container
+rebuilds wipe that path. Use /data/prod2u (same durable volume as Anlogic TD).
 EOF
 }
 

+ 4 - 1
tools/package_agent_handoff.py

@@ -1886,13 +1886,16 @@ def collect_review_git_provenance(
             "files": tree_rows,
         }
     )
-    artifacts[f"{meta_prefix}/file-sha256.json"] = json_bytes(
+    file_sha_payload = json_bytes(
         {
             "schema": "cpld-review-git-file-sha256-v1",
             "head": head,
             "files": file_hashes,
         }
     )
+    # Canonical name per finalize layout; keep legacy alias for older consumers.
+    artifacts[f"{meta_prefix}/source-file-sha256.json"] = file_sha_payload
+    artifacts[f"{meta_prefix}/file-sha256.json"] = file_sha_payload
 
     if include_sanitized_git_snapshot:
         snap_temp = temp_root if temp_root is not None else Path(

+ 14 - 1
tools/prod2u_p4_harness.py

@@ -43,10 +43,23 @@ TD_EXE = Path(
     or (_TD_FROM_PATH if _TD_FROM_PATH else "")
     or (_TD_HOME / "bin" / "td")
 )
+def _default_prod2u_toolchain_base() -> Path:
+    override = (
+        os.environ.get("PRODU2_TOOLCHAIN_BASE", "").strip()
+        or os.environ.get("PROD2U_P4_TOOLCHAIN_ROOT", "").strip()
+    )
+    if override:
+        return Path(override)
+    persistent = Path("/data/prod2u")
+    if persistent.is_dir() or os.access("/data", os.W_OK):
+        return persistent
+    return Path.home() / ".cache" / "prod2u"
+
+
 DEFAULT_TOOLCHAIN_ROOT = Path(
     os.environ.get(
         "OSS_CAD_SUITE_ROOT",
-        str(Path.home() / ".cache" / "prod2u" / "oss-cad-suite" / "latest"),
+        str(_default_prod2u_toolchain_base() / "oss-cad-suite" / "latest"),
     )
 )
 DEFAULT_VENV_ROOT = Path(

+ 7 - 1
tools/run_verification_matrix.py

@@ -69,7 +69,13 @@ def _write_json(path: Path, payload: dict[str, Any]) -> None:
 
 
 def _prefer_oss_cad_on_path() -> None:
-    cache = Path(os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache"))) / "prod2u"
+    override = os.environ.get("PRODU2_TOOLCHAIN_BASE", "").strip()
+    if override:
+        cache = Path(override)
+    elif Path("/data/prod2u").is_dir() or os.access("/data", os.W_OK):
+        cache = Path("/data/prod2u")
+    else:
+        cache = Path(os.environ.get("XDG_CACHE_HOME", str(Path.home() / ".cache"))) / "prod2u"
     root = Path(os.environ.get("OSS_CAD_SUITE_ROOT", str(cache / "oss-cad-suite" / "latest")))
     oss_bin = root / "bin"
     if not oss_bin.is_dir():

+ 14 - 3
tools/toolchain_probe.py

@@ -27,9 +27,20 @@ TD_EXE = Path(
 # Legacy Windows CLI name; on Linux td2026 wraps the same binary.
 TD_CLI = TD_EXE
 GIT_EXE = Path(shutil.which("git") or "git")
-DEFAULT_TOOLCHAIN_BASE = Path(
-    os.environ.get("PROD2U_P4_TOOLCHAIN_ROOT", str(Path.home() / ".cache" / "prod2u"))
-)
+def _default_toolchain_base() -> Path:
+    override = (
+        os.environ.get("PRODU2_TOOLCHAIN_BASE", "").strip()
+        or os.environ.get("PROD2U_P4_TOOLCHAIN_ROOT", "").strip()
+    )
+    if override:
+        return Path(override)
+    persistent = Path("/data/prod2u")
+    if persistent.is_dir() or os.access("/data", os.W_OK):
+        return persistent
+    return Path.home() / ".cache" / "prod2u"
+
+
+DEFAULT_TOOLCHAIN_BASE = _default_toolchain_base()
 DEFAULT_OSS_CAD_SUITE_ROOT = Path(
     os.environ.get("OSS_CAD_SUITE_ROOT", str(DEFAULT_TOOLCHAIN_BASE / "oss-cad-suite" / "latest"))
 )

+ 7 - 1
tools/verify.sh

@@ -8,7 +8,13 @@ unset LD_LIBRARY_PATH LD_PRELOAD QT_PLUGIN_PATH || true
 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
 
 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
-CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
+if [[ -n "${PRODU2_TOOLCHAIN_BASE:-}" ]]; then
+  CACHE="$PRODU2_TOOLCHAIN_BASE"
+elif [[ -d /data/prod2u || ( -d /data && -w /data ) ]]; then
+  CACHE="/data/prod2u"
+else
+  CACHE="${XDG_CACHE_HOME:-$HOME/.cache}/prod2u"
+fi
 OSS_CAD_BIN="${OSS_CAD_SUITE_ROOT:-$CACHE/oss-cad-suite/latest}/bin"
 if [[ -d "$OSS_CAD_BIN" ]]; then
   export PATH="$OSS_CAD_BIN:$PATH"