feat: add ICDB maintenance and verified CBB backup recovery dialog

This commit is contained in:
阿白叔 committed 2026-10-28 19:43:07 +08:00
1 parent a851e47eca
commit cdb8a6a28b
23 files changed
+1868 -23

No files matched your search

@@ -0,0 +1,55 @@
# 从健康 CBB 来源恢复的增量设计
状态:同名 CBB 完整工程备份恢复弹窗已实现,并通过真实损坏打开失败 → 弹窗恢复 → 同一目标重新打开 PASS/READY 的闭环验证。471 项回归通过;原生跨库重新导入替换闭环仍未验证。
实机记录:`docs/releases/2026-10-28-cbb-backup-dialog-validation.md`。
## 本轮确定的实现范围
采用简单弹窗:目标 CBB、完整备份工程 PRJ、“恢复并校验”和“关闭”。选择的工程名和顶层块必须与目标一致,必须保留完整 Work 数据,不能仅选择单个数据库文件。
后台先保存完整目标库快照及 SHA256 清单,复制来源工程,在另一份目标库副本中恢复来源并通过原生 PCB 打开、集成、保存、关闭及权威 Ready 检查。通过后再次检查来源/目标内容及会话释放状态,保留原 Work 为同级 `Work.before-restore-*`,安装已验证的工程副本,再实际打开目标校验。只有 PASS、GREEN 和已释放的结果视为成功。失败保留回退库、来源快照、旧 Work 和原生日志,不自动覆盖共享数据库回退。
验证副本放在用户目录 `.cbb-restore/<编号>`,记录其实际路径。避开深层日志目录及 MSIX 对 AppData 的长路径重定向;本机短路径原生复核已通过 Ready 检查。目标原生操作保留映射盘/别名,文件快照和 Work 替换使用实际路径。原本已指向目标库的等价相对引用不重写,保留工程字节和日期。
该功能恢复现有条目的工程数据;不删除库条目,不宣称已完成原生跨库重新导入或共享符号库重建。原生导入探测已在新建的隔离库通过“Reusable Blocks / New Reusable Block”从 PRJ 创建 IP101GR,但替换损坏条目和依赖完整性尚未形成完整验证闭环,因此本轮不开放自动先删后导入。
真实验证脚本:`tools/validate_backup_recovery_dialog.py`,分 setup、open-before、restore、compare 四阶段。测试目标移除历史备份并破坏数据库文件头,使用独立健康来源;restore 阶段点击实际主窗口按钮及弹窗“恢复并校验”,使用生产后端。
目标:原生 Repair 无法恢复时,允许选择其他目录或库中的健康 CBB 作为恢复来源,重建目标 CBB 的可用状态,并保留完整回退材料。
## 已确认的原生行为
安装自带 `SDD_HOME/lm/win32/lib/upc_utils.tcl` 提供以下依据:
- `runReuseBlockLoader` 使用 DMS 的 `com.mentor.dms.rbloader.jar` 执行 `copyout`,下载/恢复 CBB。
- `processReuseBlockChunk` 在下载 CBB 和相关 Cell 后调用 `runReuseBlockImporter ... move`,同步 CBB 在共享 iCDB 中的符号。
- `removeReuseBlocks` 经 CleanWGLib 处理 CBB 移除;注释明确说明 Cell 和 iCDB 符号也由原生清理处理。
- `ReuseBlockImporter` 因此不能仅凭名字被当成通用完整 CBB 备份导入程序。任意本地目录/压缩包的完整原生导入方式仍需验证。
## 两种故障分开处理
1. 单个 CBB 的 Work 数据库损坏、目标中心库及共享符号库可用:可验证恢复该 CBB,并通过原生流程重新建立元数据、Cell 和符号关联。
2. `SymbolLibs/__ReusableBlocksSymb` 等共享数据库损坏:在同一损坏目标中删除或导入 CBB 都可能因无法访问共享库失败。应先恢复共享库,或评估建立健康新库并迁移 CBB 及依赖;该迁移路线尚未实测。
不将删除日志、地址文件、锁文件或修改私有数据库会话字段作为恢复方法。
## 建议操作流程
1. 选择健康来源:完整工程/可导入的 CBB 包、来源库或受支持的 DMS 版本。核对 CBB 类型、名称、分区、软件版本、来源时间及符号/Cell/零件依赖;名称相同不证明内容等价。
2. 在来源副本上验证可以打开,保留原始来源不被校验保存修改。
3. 在隔离目标副本中验证原生导入/恢复路径。目标中心库必须可访问,错误类别和数据库路径必须明确。
4. 通过原生流程替换/移除旧条目并恢复健康 CBB,确认 .lmc 元数据、CBB 工程、Cell 和共享符号关联一致。先验证是否支持原生替换;不盲目采用先删后导入,也不假定导入具备原子回退。
5. 实际打开恢复的工程,完成集成、保存、关闭和权威 Verify 状态确认。失败保留原始工程、恢复来源、原生日志和完整备份;不将失败结果改为绿色。
## 对现有按钮的建议升级
维护入口展示原生修复结果;受阻项目可选择“从健康 CBB 恢复”。启动前显示来源与目标、覆盖范围和版本差异;结果区分别报告“原位修复”“从备份恢复”“重新导入恢复”“共享库阻断”和“未确认”。
程序可以负责来源核对、隔离验证、备份、原生操作编排和复核。若本机版本只能使用 GUI 导入,先提供原生窗口及操作指引;没有可靠的原生命令/界面路径之前,不声称支持自动重新导入。
## 后续验证门槛
- 确定一个完整、可打开的来源 CBB,并在独立副本上复现目标报错。
- 记录本机原生本地导入/跨库复制/受支持 DMS 恢复的确切入口、替换策略、冲突提示和日志。
- 对照恢复前后的实际工程打开结果与依赖完整性,包含导入失败、来源版本不匹配、目标共享库不可用的停止行为。
@@ -0,0 +1,24 @@
# ICDB Global Check and Repair Implementation Plan
**Goal:** Provide a separate full-library action that checks each available CBB and invokes the existing evidence-bound iCDB recovery when appropriate.
**Architecture:** Reuse the serial verification queue, including Ready rows, and the existing backup, ownership, native repair and retry safeguards. Confirm the full-library write scope before starting; stop on unconfirmed ownership and retain existing reports and evidence. Shared symbol database repair remains unsupported.
**Tech Stack:** Python 3.12, PySide6, pytest, Windows native Mentor tools.
1. Add UI tests for confirmation, Ready-row inclusion, skipped projects, busy state and cancellation.
2. Add the button and route the full set of eligible rows through the existing queue without changing ordinary Verify behavior.
3. Run focused and full regression tests. On a new isolated project copy, attempt a reproducible native session failure and run the repair; retain evidence and explicitly report whether actual corruption and recovery were demonstrated.
## Button design and acceptance (2026-10-28)
- [x] Put the action in a separate database maintenance panel with the supported scope beside it.
- [x] Confirmation displays the exact library, eligible count, Ready count and missing-project count, and explains that verification saves projects.
- [x] Show item progress and separate checking, backup and native repair phases; allow stopping after the current item.
- [x] Report verified items, native repairs, restored backups requiring review, unconfirmed repairs and unexecuted items separately. Save a JSON maintenance report with original error and repair evidence.
- [x] Detect native restoration from an existing backup without treating it as an automatic repair success or retrying verification. Close only after restoration/diagnostics complete, the native main window is idle and the database address has been released.
- [x] Exercise the actual Qt button on a fresh local library copy using the production reader and verifier, capture screenshots and check source fingerprints afterwards.
- [x] Repeat the real header-corruption/native-repair probe with a 180-second native deadline and verify the restoration-review result and normal process exit.
- [x] Run the full regression suite and record the supported scope and practical limits in a release validation note.
Results: `docs/releases/2026-10-28-icdb-maintenance-button-validation.md`. Actual button run PASS/READY raw=1 on IP101GR; all 21,029 source file hashes unchanged. Real header corruption led to native restoration of an older backup and RESTORED_REVIEW_REQUIRED, without automatic retry. Full regression: 455 passed. Final Windows EXE smoke: clean exit 0.