docs: record native snapshot BOM and recovery acceptance

This commit is contained in:
阿白叔 committed 2026-10-19 11:09:54 +08:00
1 parent 81f34683ea
commit e74ec5bcbd
5 files changed
+322 -17

No files matched your search

@@ -1,5 +1,7 @@
# 器件索引按需采集优化
后续原生宿主完整采集已取得新的同源实测:189.250 秒,见 [原生快照报告](2026-10-19-native-snapshot.md)。下文保留本阶段真实基线。
在上一轮重复步骤修复 `2ad36ba` 基础上继续优化。正式代码提交为 `8fe82c3`,追加防护用例为 `998d78d`。本轮不打包、不发布,不改变逐项保存、磁盘重开和故障恢复协议。
## 本轮修改
@@ -0,0 +1,56 @@
# 原生脚本宿主完整采集优化
同源工程的两条默认 BOM 替换,正式队列从上一轮 **375.688 秒降至 189.250 秒,减少 49.63%**。相对最初 799.50 秒基线,累计减少 76.33%。这是同机、同库、同源样例的单轮对比,不能推广为所有工程的固定加速倍数。本轮未打包、未发布。
正式集成提交:`81f3468`;原生适配模块初版:`2f6060d`;同次快照内 UID 复用:`5b625b0`。机器证据见 [JSON](../testing/evidence/2026-10-19-native-snapshot.json)。
## 改动与边界
安装自带 `wv/samples/viewdraw/scripting/menu.vbs` 描述了 `run <script.vbs>` 命令。本机实测可通过 `ExecuteCommand` 让 CAD 自带宿主在进程内执行完整只读采集,减少逐字段跨进程 COM 调用。它仍使用原来的 COM 对象模型;本轮没有找到或引入独立的无界面替换 CLI。
- 单独新增 `NativeSnapshotReader.vbs`,生成器从当前生产脚本提取白名单内的原有只读函数,不另写一套字段采集。保留属性、样式、位置、几何、引脚及实际归属、连接和上下文检查。
- 每次调用使用独立令牌、结果文件和 CAD GUID,验证工程、图页、完整 U/G 配对、UID 集合、总数与结束帧。未选中器件的完整 U/G 字符串必须与持久化基线完全一致。
- 仅自有私有桌面批次启用。手动模式、旧运行时和缺模块时使用原外部路径。原生命令所需短路径不受支持时,只能在派发前退回原路径;命令发出后,失败或不完整证明会停止当前步骤。
- 采集、保存前检查和磁盘重开检查各自重新读取。原生替换、属性恢复、逐项保存、重开、恢复和私有桌面释放协议保留。
- `worker_runtime.copy_worker_script` 统一处理准备、开始会话、恢复执行步骤和故障恢复这四处运行时复制。自定义脚本没有同级适配模块时保持原字节;重复准备不会累计追加;同路径复制不改源文件。资源清单已加入模块,但没有运行打包。
- 同次快照复用已读 UID,逐引脚实际 owner 读取保留。没有跨替换或重开复用完整页状态。
## 实机默认 BOM 与恢复验收
在新的 `build/native-read-formal-bom-20261019/project/` 副本上创建任务、导出默认模板、填写 RV05/RV14、导入预览并确认后,正式顺序执行两项替换。另把一个新料号填为数值,确认拒绝该行并且不持久化替换计划,再改为文本继续。
| 指标 | 上一轮 | 本轮 |
| --- | --- | --- |
| 两条规则正式队列总耗时 | 375.688 秒 | **189.250 秒** |
| 首项执行器耗时,含自有 CAD 启动 | 230.117 秒 | 121.005 秒 |
| 第二项执行器耗时 | 140.349 秒 | 62.386 秒 |
| 成功保存 / 失败 | 2 / 0 | 2 / 0 |
完整队列总耗时还包含准备、备份、持久化和会话释放,不能直接用两项执行器耗时相加替代。原始阶段计时保留在机器证据中;第二项阶段计数来自最后一次 worker-progress 采样,最终关闭耗时可能未计全,不当成精确的互斥阶段分解。
核对结果:
- RV05 与 RV14 均变为 `4100-CA0000-T0`,Value 分别为 `0R`、`0R/NC`,原 UID 保留。Part Label 拷贝和默认开启的 NC 同步走正式流程。
- 日志确认两项共执行 **6 次**完整原生采集:每项采集、保存前、重开后各一次。
- 第一项原始快照仅排除路径元数据 M 行后,**120 行内容多重集与上一轮完全一致**,没有减少字段。
- 独立层级及扁平 ASCII 导出均核对 **57 个器件、103 个引脚、22 个网络**;55 个未选中器件、全部引脚连接和网络关系不变。完整最终图与上一轮最终结果相等。
- 在已成功的副本队列中注入“已保存、缺少回读证明”状态,正式只读恢复用时 **61.062 秒**,返回 `recovery_saved_verified`。没有再次调用原生替换,关闭工程时不额外保存;恢复前后独立导出的完整图相等。此注入验证不等同于随机杀进程或断电认证。
- 来源 `.prj` 和 `icdb.dat` 哈希不变。执行和恢复的观察均确认主输入桌面未切换,自有 CAD 未抢前台,自有进程退出且私有桌面释放;主桌面文件持续可读。
启动时记录主脚本与 native_helper 的哈希;验收后核对实际执行和恢复使用的合成脚本字节,均精确等于当前主脚本加适配模块,另记录适配模块及组合器哈希。工程、厂商文件和完整现场日志只留在忽略的 build/ 下。
## 定向回归与研究结果
最终相关套件 **239 passed,64.63 秒**;队列、安全、恢复和打包资源合同 **81 passed,43.65 秒,1 deselected**。320 项分属不重叠的文件组。旧的 1000 步模拟性能门槛没有通过,本轮明确排除且不计作成功。
覆盖了旧令牌、错误工程/图页/GUID、截断、重复或丢失 UID、U/G 不一致、数量错误、完整几何变化、取消、原生错误传播、适用条件、派发前路径回退以及派发后禁止回退。完整合成脚本通过 Option Explicit 编译检查。独立只读审查没有 Critical/Important 发现,建议的调用编排及开关边界用例已补齐。
此前接入套件曾为 201 passed / 13 failed:提取式 guard 测试没有带入新增的 QPUseNativeSnapshot,修正测试夹具后重跑取得上述最终结果;失败证据保留。首次宿主探针也失败过:CAD 预定义了三个 Vd 枚举,重复声明引发编译错误对话框。生成器已删除重复声明,后续两轮及同会话连续调用通过。首次探针的自有错误对话框经定向确认后,CAD 正常退出,桌面释放,源哈希不变;其 clean=false 保留为探针异常记录。
纯只读宿主对照:57 个器件的 114 行完整 U/G,与外部读取相等。第二轮原生读取 **0.844 秒**,同会话重复 **0.765 秒**,外部读取 **33.235 秒**;这是局部采集耗时,不能称作整个替换流程快了约 39 倍。
`GetBatchAttributes + GetBatchOats` 的 57 器件对照虽然为 0.446 秒、逐属性为 6.038 秒,但 RV01 的 Part Label 出现单空格与空串差异,且不包含完整样式字段,因此没有用于生产保护。
## 尚待认证
189.250 秒仍高于建议的 180 秒目标。原生采集期间没有逐器件的外部心跳;现有 150 秒 idle 监控、停止文件和安全边界取消继续保留,超大页需要单独验证。复杂层级、多单元/多 gate、PCB Cell Name 映射以及旧 1000 步模拟队列性能门槛仍是缺口,本轮不能据此宣布全面具备发布条件。
@@ -26,40 +26,40 @@ Interfaces:
- QPNativeReadUntouched(SelectedUids): dictionary with total, text, and rows keyed by unselected UID.
- QPParseNativeSnapshot(Text, Token, Project, Sheet, SelectedUids): validates NR1/header, U/G pairs, END/token/count and exact pair identity; returns the dictionary above.
- QPNativeCollect(SelectedUids, Token, Project, Sheet, Guid): freshly queries the owned view and produces the complete frame with existing QPUntouchedComponent.
- QPBuildNativeSnapshotScript(SelectedUids, Token, Project, Sheet, Guid, ResultPath): emits native bootstrap plus an explicit whitelist of original read-only routines; native QPProgress checks cancellation only.
- QPBuildNativeSnapshotScript(Source, SelectedUids, Token, Project, Sheet, Guid, ResultPath, StopToken, Safe): emits native bootstrap plus an explicit whitelist of original read-only routines; native QPProgress checks cancellation only.
- [ ] Write literal frame tests: one zero-pin unselected component, one selected UID, total=2; expected rows["u2"] equals its original U/G pair.
- [x] Write literal frame tests: one zero-pin unselected component, one selected UID, total=2; expected rows["u2"] equals its original U/G pair.
```python
assert parsed_total == 2
assert parsed_uids == ['u2']
```
- [ ] Run tests and observe missing adapter failure. Add negative fixtures for stale token, wrong context, truncation, duplicate UID, wrong G owner, inconsistent U/G, extra selected UID, malformed count and propagated error frame.
- [ ] Implement strict parsing and script generation; collect with the same read functions and no selection/save operations. Exercise generated code using COM-shaped fakes, including cancellation and missing targets.
- [ ] Run the adapter tests and commit after they pass.
- [x] Run tests and observe missing adapter failure. Add negative fixtures for stale token, wrong context, truncation, duplicate UID, wrong G owner, inconsistent U/G, extra selected UID, malformed count and propagated error frame.
- [x] Implement strict parsing and script generation; collect with the same read functions and no selection/save operations. Exercise generated code using COM-shaped fakes, including cancellation and missing targets.
- [x] Run the adapter tests and commit after they pass (`2f6060d`).
## Task 2: Runtime composition and capture/verification integration
Files: modify src/dx_productivity/trial_task_center/quick_run.py, integration/dxdesigner795/QuickPartReplace.vbs, packaging/DxPartReplace.spec and focused runtime tests.
Files: modify src/dx_productivity/trial_task_center/quick_run.py, recovery.py, integration/dxdesigner795/QuickPartReplace.vbs, packaging/DxPartReplace.spec; add worker_runtime.py and focused runtime tests.
Interfaces:
- _copy_worker_script(source: Path, destination: Path): copy source and append its sibling NativeSnapshotReader.vbs when present; preserve custom script compatibility.
- copy_worker_script(source: Path, destination: Path): copy source and append its sibling NativeSnapshotReader.vbs when present; preserve custom script compatibility and same-path no-op.
- QPUseNativeSnapshot(): true only for owned batches with a private-desktop environment and an available adapter function.
- QPVerifyNativeUntouched(Records): compare complete actual rows, total and unselected UID set to existing persisted baselines.
- QPTryNativeVerifyUntouched(Records) and QPCompareNativeUntouched(Records, Actual): compare complete actual rows, total and unselected UID set to existing persisted baselines. Unsupported script paths may fall back only before command dispatch; any failure after dispatch stops the step.
- [ ] Reproduce a prepared default worker missing the adapter and a custom worker that must remain unchanged.
- [ ] Compose all three existing source-copy callsites through _copy_worker_script; include the adapter in the frozen resource specification without building.
- [ ] Route capture and QPVerifyUntouched through native reads only behind QPUseNativeSnapshot. Retain original external loops for other modes and all invalidation calls.
- [ ] Run focused runtime, VBS, execution/recovery and existing accuracy tests. Review any failures before continuing; commit tested integration.
- [x] Reproduce a prepared default worker missing the adapter and a custom worker that must remain unchanged.
- [x] Compose all four existing source-copy callsites (prepare, begin session, resume step and recovery) through copy_worker_script; include the adapter in the frozen resource specification without building.
- [x] Route capture and QPVerifyUntouched through native reads only behind QPUseNativeSnapshot. Retain original external loops for other modes and all invalidation calls.
- [x] Run focused runtime, VBS, execution/recovery and existing accuracy tests. Correct the extracted guard fixture to include QPUseNativeSnapshot; final runs: 239 passed and 81 passed / 1 deselected. Commit tested integration (`81f3468`).
## Task 3: Independent review and real BOM acceptance
Files: add docs/reviews/2026-10-19-native-snapshot.md and sanitized docs/testing/evidence/2026-10-19-native-snapshot.json.
- [ ] Request an independent read-only review of ownership gating, native function whitelist, nonce/context checks, failure propagation and exact full-baseline comparison.
- [ ] Run the established default-template BOM harness on a fresh build/ copy with RV05 and RV14, recording script hashes and timings.
- [ ] Compare initial snapshots with the 120-row previous baseline; independently export hier/flat and verify 55 untouched components, 103 pin connections and 22 nets, plus exact target changes.
- [ ] Exercise read-only recovery on the disposable successful queue because it also calls full verification; confirm no additional replacement/save and safe release.
- [ ] Record failed research probes and remaining release gaps honestly, update plan checkboxes, commit evidence and push. Verify remote HEAD equals local and only feedback/ remains untracked.
- [x] Request an independent read-only review of ownership gating, native function whitelist, nonce/context checks, failure propagation and exact full-baseline comparison. No Critical/Important findings; suggested gating and orchestration cases added.
- [x] Run the established default-template BOM harness on a fresh build/ copy with RV05 and RV14, recording script hashes and timings (189.250 seconds).
- [x] Compare initial snapshots with the 120-row previous baseline; independently export hier/flat and verify 55 untouched components, 103 pin connections and 22 nets, plus exact target changes.
- [x] Exercise read-only recovery on the disposable successful queue because it also calls full verification; confirm no additional replacement/save and safe release (61.062 seconds, exact before/after graph equality).
- [x] Record failed research probes and remaining release gaps honestly, update plan checkboxes, commit evidence and push. Verify remote HEAD equals local and only feedback/ remains untracked.
@@ -12,6 +12,7 @@
- 结果有版本头、令牌、工程、图页和完整结束标记。拒绝旧令牌、截断、重复 UID、U/G 不一致、未选中集合变化、丢失目标和错误总数。
- 目标 UID 只用于排除未选中集合;原生读前后核对目标集合存在。保存前及磁盘重开后均重新执行完整读取。
- 原生错误、命令失败、缺失结果、取消均不得生成成功证明;命令已发出后不静默回退。原生读取不写 CAD、不改选择、不保存。
- 宿主命令使用脚本短路径。路径含宿主不支持的字符时,仅允许在派发命令前退回完整外部读取;原始完整检查仍然执行。
- 原生宿主预定义 Vd 枚举,不重复声明;支持同一 CAD 会话连续调用。
- 取消检查使用当前监控令牌,在原有可安全中止的边界响应;外层监控和自有进程释放仍保留。
- 不打包发布;不触碰 feedback/,实机只用 build/ 下新副本。
@@ -0,0 +1,246 @@
{
"date": "2026-10-19",
"production_code_commit": "81f3468",
"adapter_initial_commit": "2f6060d",
"uid_read_commit": "5b625b0",
"code_hashes": {
"integration/dxdesigner795/QuickPartReplace.vbs": "102be388b4878156c72d40eb0c6bf7bdd2e51295b80560635b482e1e6816babb",
"integration/dxdesigner795/NativeSnapshotReader.vbs": "138fd22d351919b9d25dacf2e1258ebb3d465bca6a8161be919bdac3440ca76c",
"src/dx_productivity/trial_task_center/native_helper.py": "53b5f962de2a84c99b42a78e9b3046239f7bb4c99b8730e8de085893cbd35188",
"src/dx_productivity/trial_task_center/worker_runtime.py": "7b2a0b8365c4b0bb967d6b1d3a3e5fc792d1a5acde24a165159ed40a9cfd040b"
},
"hash_evidence_note": "Main worker and native_helper hashes were recorded at launch. Adapter and composer hashes were recorded after the run; exact original and recovery composed worker bytes match current main + CRLF + adapter.",
"regressions": {
"final-targeted": {
"tests": "239",
"failures": "0",
"errors": "0",
"skipped": "0",
"time": "63.349"
},
"queue-recovery": {
"tests": "81",
"failures": "0",
"errors": "0",
"skipped": "0",
"time": "42.950"
}
},
"excluded_test": "Existing 1000-step simulated performance threshold remains unresolved; intentionally deselected, not counted as passed.",
"formal_bom": {
"verified": true,
"baseline_seconds": 375.688,
"seconds": 189.25,
"time_reduction_percent": 49.62575328464044,
"original_baseline_seconds": 799.5,
"original_baseline_reduction_percent": 76.32895559724828,
"saved_items": 2,
"failed_items": 0,
"source_hashes_unchanged": true,
"snapshot_equivalence": {
"equal_excluding_path_metadata": true,
"baseline_rows": 120,
"optimized_rows": 120,
"native_full_reads": 6
},
"graph_summary": {
"hier": {
"component_count": 57,
"pin_count": 103,
"net_count": 22,
"unchanged_components": 55,
"all_pin_connections_unchanged": true,
"net_graph_unchanged": true
},
"flat": {
"component_count": 57,
"pin_count": 103,
"net_count": 22,
"unchanged_components": 55,
"all_pin_connections_unchanged": true,
"net_graph_unchanged": true
}
},
"previous_result_graph_equivalence": {
"hier": {
"equal": true,
"components": 57,
"pins": 103,
"nets": 22,
"sha256": "32b36adbef100db505ea3d98ca628d50a94c91826d7289d90e473b3f9c864a31"
},
"flat": {
"equal": true,
"components": 57,
"pins": 103,
"nets": 22,
"sha256": "acbb89d93ebd3dc35f7d4b794df943c2ef5d164a0fb0c1626c432d2a0aa5b033"
}
},
"step_timings": [
{
"old_part_number": "4100-CA0000-T7",
"elapsed_seconds": 121.00508039997658,
"worker_stage_seconds": {
"starting": 0.39100000000325963,
"session_startup": 1.0929999999934807,
"check_project": 0.04800000000977889,
"open_project": 16.34300000005169,
"open_sheet": 4.704000000027008,
"session_ready": 0.10899999999674037,
"query_components": 0.06299999996554106,
"find_components": 1.5929999999934807,
"index_pins": 9.157000000064727,
"snapshot_attributes": 0.8900000000139698,
"capture": 0.1559999999590218,
"native_snapshot_read": 6.60899999999674,
"before_native": 0.18800000002374873,
"native_replace": 22.03100000001723,
"restore_preflight": 1.2189999999827705,
"index_components": 1.7509999999892898,
"before_restore_transaction": 2.1869999999762513,
"restore_attribute_fields": 7.953000000037719,
"restore_attributes": 0.0,
"verify_restoration": 1.0149999999557622,
"verify_attribute_fields": 1.140999999945052,
"finished": 1.1410000000032596,
"save_and_close": 3.0929999999934807,
"verify_saved_project": 0.0,
"session_wait": 0.0
}
},
{
"old_part_number": "4100-CA1030-T7",
"elapsed_seconds": 62.38554909999948,
"worker_stage_seconds": {
"check_project": 0.062000000034458935,
"open_sheet": 2.062999999965541,
"query_components": 0.031000000017229468,
"find_components": 0.6879999999655411,
"index_pins": 7.1859999999869615,
"snapshot_attributes": 0.7189999999827705,
"capture": 0.15700000000651926,
"native_snapshot_read": 6.546000000031199,
"before_native": 0.21899999998277053,
"native_replace": 19.78100000001723,
"restore_preflight": 0.7339999999967404,
"index_components": 1.3760000000474975,
"before_restore_transaction": 1.5,
"restore_attribute_fields": 6.907000000006519,
"restore_attributes": 0.015000000013969839,
"verify_restoration": 0.8439999999245629,
"verify_attribute_fields": 1.1880000000237487,
"finished": 1.297000000020489,
"save_and_close": 6.313000000023749,
"verify_saved_project": 0.0,
"open_project": 7.85899999999674,
"session_wait": 0.23399999999674037
},
"worker_stage_source": "Last worker-progress.json sampled before release; final close time may be incomplete."
}
]
},
"recovery": {
"verified": true,
"seconds": 61.06199999997625,
"state": "restored_ok",
"proof": "recovery_saved_verified",
"additional_native_replacement": false,
"closed_without_additional_saving": true,
"native_full_reads": 1,
"graph_equivalence": {
"hier": {
"equal": true,
"components": 57,
"pins": 103,
"nets": 22,
"sha256": "32b36adbef100db505ea3d98ca628d50a94c91826d7289d90e473b3f9c864a31"
},
"flat": {
"equal": true,
"components": 57,
"pins": 103,
"nets": 22,
"sha256": "acbb89d93ebd3dc35f7d4b794df943c2ef5d164a0fb0c1626c432d2a0aa5b033"
}
}
},
"isolation": {
"formal": {
"owned_cad_exit_confirmed": true,
"owned_desktops_released": true,
"input_desktop_unchanged": true,
"owned_cad_became_foreground": false,
"owned_cad_on_input_desktop": false,
"file_read_samples": 843,
"observer_errors": []
},
"recovery": {
"owned_cad_exit_confirmed": true,
"owned_desktops_released": true,
"input_desktop_unchanged": true,
"owned_cad_became_foreground": false,
"owned_cad_on_input_desktop": false,
"file_read_samples": 266,
"observer_errors": []
}
},
"readonly_host_probes": [
{
"native_seconds": 1.172000000020489,
"external_seconds": 46.09299999999348,
"equal_rows": 114,
"component_count": 57
},
{
"native_seconds": 0.8439999999827705,
"native_repeat_seconds": 0.7650000000139698,
"external_seconds": 33.23499999998603,
"equal_rows": 114,
"component_count": 57
}
],
"rejected_bulk_attribute_candidate": {
"enabled_in_production": false,
"equivalent": false,
"bulk_seconds": 0.44640369998523965,
"individual_seconds": 6.037832499889191,
"differences": [
{
"refdes": "RV01",
"bulk_part_label": " ",
"individual_part_label": ""
}
],
"reason": "Space versus empty string semantic mismatch and incomplete full attribute style fields."
},
"initial_failed_host_probe": {
"verified": false,
"reason": "Host predefines VDM_COMP / VDM_COMPPIN / VD_ALL; duplicate declarations opened a script compile error dialog. Generator now omits these declarations.",
"owned_probe_dialog_acknowledged": true,
"owned_cad_exit_code": 0,
"desktop_release_confirmed": true,
"clean_flag": false,
"clean_flag_note": "Probe exception, not cleanup failure; no cleanup errors and desktop confirmation released=true.",
"source_hashes_unchanged": true
},
"test_fixture_correction": "Initial integration run: 201 passed / 13 failed. Extracted VBS guard fixture lacked QPUseNativeSnapshot; corrected fixture and reran the final targeted suite successfully.",
"limitations": [
"One same-source formal run per revision; no general speed guarantee.",
"189.250 seconds remains above the proposed 180-second target.",
"Native read has no per-component external heartbeat; the existing 150-second idle monitor and safe-boundary cancellation remain, so very large pages need separate certification.",
"PCB Cell Name mapping and complex hierarchical/multi-gate cases remain uncertified.",
"1000-step simulated queue performance threshold remains unresolved.",
"No package build or release performed."
],
"raw_evidence_roots": [
"build/native-adapter-20261019",
"build/native-read-formal-bom-20261019",
"build/native-read-ascii-result-20261019",
"build/native-read-ascii-after-recovery-20261019",
"build/native-snapshot-host-20261019",
"build/native-snapshot-host-20261019-v2",
"build/native-snapshot-host-20261019-v3",
"build/bulk-identity-probe-20261019"
]
}