feat: add confirmed client release with durable consent and server protection

This commit is contained in:
阿白叔 committed 2026-11-05 23:31:36 +08:00
1 parent 282be7be7f
commit 173dee1980
54 files changed
+3909 -14

No files matched your search

@@ -0,0 +1,104 @@
# Issue #2 implementation plan
Approved by user on 2026-11-02. Continue branch codex/temp-issue-2-icdb-recovery,
baseline ec78dd7 (491 tests). Do not merge, publish or close the issue. Preserve
untracked review.diff. Python 3.12, PySide6, Mentor EE7.9.5, private desktop by
default. No force termination of native database owners, deleting locks,
guessing native write interfaces, or editing LMC binary contents.
Each task uses regression tests, focused validation and a separate commit.
Real field lost-session reproduction and Windows 10 validation must be reported
as unverified when unavailable; header corruption is not a substitute.
## Task 1: ICDB failure lifecycle and repair outcomes
Extend the existing owned-empty-PCB close path to wait for its launcher as well.
Cover COM connected without a document, delayed dialogs/addresses/process exit.
Native Repair must report missing healthy backup, native repair failure, database
busy, unknown dialogs and timeout/unreleased distinctly using this run's native
logs and Output. Safely close an idle, conclusively failed native repair tool;
never act on unrecognized prompts or active native operations.
Preserve original error, original evidence and all repair evidence. Record release
state. Repair success in summaries means original native repair succeeded AND
same-project reopening, verification and authoritative GREEN succeeded. Historical
backup restoration remains RESTORED_REVIEW_REQUIRED. A conclusively failed repair
may continue independent CBB items only if all relevant processes and addresses
are released and scope is project-local; shared-library/unknown ownership stops.
Add sanitized replay of issue2 lost-session/open-failure events with asserted target,
stage and invocation order; one automatic repair maximum, no repeated PCB loop.
Maintain VerifyRequest/VerifyResult compatibility. Files primarily failed_session,
pcb_bridge, mentor_adapter, native_repair[_ui], verify_runner, icdb_maintenance and
their tests. Update release evidence. No native live operations without coordinator
agreement (only one native operation at a time). Coordinator builds candidate and
runs frozen tests after review. Field fault sample is not in the attachment (logs
only); do not claim field recovery.
## Task 2: Search, filtering, selection and non-READY maintenance
Implement local name/partition keyword search and filters: all, READY, non-READY,
PENDING, unknown/read errors, missing project. Non-READY includes unconfirmed states
without calling them corrupt. Show visible/READY/error counts; no Mentor rereads on
filtering. Management selection permits READY; verify/maintenance/default backup
recovery exclude READY. Operations target current visible checked rows; hiding a row
clears its checkbox. Provide select visible/clear selection. Maintenance entry,
confirmation, progress and report agree on non-READY target set. Existing verify-all
means visible eligible rows, maintenance defaults visible eligible rows with checked
subset if any. Refresh affected authoritative statuses after operations, retain search
and filter. No premature integration of CRUD; expose selected records for Task4.
Maintain CbbRecord compatibility and explicit status separate from action result.
Tests include mixed READY/PENDING/errors/missing, filtering after state transitions,
selection scope and 381/3000 row responsiveness. Files UI main_window, small focused
filter helper if useful, backup dialog and maintenance report + tests. Avoid unrelated
UI overhaul. Commit and report focused tests plus full suite once.
## Task 3: Scoped primary-file hashes and verified backups
Copy and retain complete backup trees. Restrict SHA256 and semantic before/after
comparison to primary project/design/database/constraint files and required library
dependencies: PRJ/PCB/DXP, icdb.dat, Layout, schematic/logic/symbol assets, CES/config,
target LMC and shared database dependencies. Explicitly exclude runtime logs/temp/
locks/address records, historical backups, PDF/generated output from content hashes;
address files still participate in idle checks. Treat unclassified engineering data
conservatively as primary rather than accidentally excluding it. For central-library
manifest, only target CBB Work/Cert plus active library configuration/shared library
dependency trees; do not hash unrelated CBB projects.
During copy validate tree membership and file size/mtime before/after; primary files
also source/destination SHA256, including locked database stream bytes. Logs changing
after successful snapshot must not invalidate subsequent semantic comparison, while
primary changes/additions/deletions must block install. Manifest is versioned and
contains relative paths, size, hash and scope; progress gives hashed files/bytes/stage.
Keep existing validate-copy -> target conflict check -> retain Work -> install ->
reopen verification. Preserve old backups and evidence on failure. Add tests for logs
only, all primary categories, changed/deleted sources, target concurrency, copied byte
corruption and preserved recovery copies. Files backup_recovery and new focused
manifest helper + tests. Reuse helper in management Task4 without changing old public
Verify contracts. Document explicit rules/compatibility, commit after tests.
## Task 4: Native CBB management and delivery
Integrate add, same-name update, remove in current application. Input complete PRJ/PCB
projects, no Packager/PDF/part replacement/rename/partition move. Add conflicts never
overwrite. Update matches existing name/partition and backs up complete old project
and library recovery snapshot. Remove backs up then uses verified Mentor native
operation; reread confirms absence. Never fake removal by deleting directories.
Add/update reread identity, default auto-verify optional per batch, distinguish upload
failed, uploaded-but-verification-failed, uploaded-and-verified. Preserve source files.
Use isolated native adapter: capability detection by installed version/interface plus
isolated validation. Prefer proven COM/command; verified private desktop controls only
fallback, never foreground input. Unsupported operations disabled with exact reason.
Use cbb-upload-795 as research only, no external runtime dependency. Native API research
comes from coordinator. No fabricated operation parameters. Snapshot/readback result
must correspond to actual library entry and source engineering identity.
Requests/results contain operation, library, CBB, partition, source, auto_verify,
stage/status, safe_to_continue and evidence path. Serialize all writes with existing
verification mutex and a library-level lock compatible with original uploader; apply
coordination to verify/recovery too. Stop when native release uncertain. Persist item
checkpoints and show unfinished tasks on restart, never replay automatically.
Provide safe preview/confirmation for destructive operations; backups outside target.
Test isolated add/conflict/update/remove/reimport, cancellation, timeout/network errors,
partial successes, no-op/lying native response, busy library, restart checkpoints.
Implement capabilities conservatively: if actual native operation cannot be proven,
its UI remains disabled with actionable explanation and validation gap is explicit.
Full Python/compile/diff checks, candidate frozen smoke, Windows11 native scenario;
Windows10 and real field sample explicitly unverified if inaccessible. Coordinator
provides final review and source/frozen deliverables without merging/publishing.
@@ -0,0 +1,12 @@
# 无地址 ICDB 维护与 PCB 版本选择
用户要求按已确认的入口分析修复,并明确允许需要时弹窗让用户选择。沿用临时分支,不恢复应用自动备份,不改原库。
- [x] 无地址记录的明确维护也进入原生 Repair;仅允许唯一数据库与 PCB/PRJ 反向引用绑定,保留全库独占检查。新增回归先失败,集中 250 项通过,独立审查通过。
- [x] 实际应用按钮在无地址 IP101GR 副本完成原生 Repair,随后需要 PCB 版本选择;沿用用户此前确认的手动保存版本,诊断续接已保存关闭并读取 READY。人工续接不算完整自动链路验收。
- [x] 在主应用显示候选时间和手动保存/自动保存/取消按钮。没有 UI 选择入口的调用保持待选择,不自动选版本;每个原生窗口只问一次,等待期间继续观察会话。
- [x] 原生动作仍由私有桌面代理执行,核对修复证明、进程、窗口和候选版本;先选择单选项并复读,再确认 OK;取消或窗口变化不确认恢复。
- [x] 用户选择后沿原校验链路继续,原生保存提示仍由已有监督器处理。最终 READY 保持原有门槛;使用历史 PCB 版本记录“已恢复,版本待核对”,不标记无损修复。
- [x] 测试 UI 取消、手动/自动选择、选择失效、重复弹窗、错 PID/桌面、原生失败和 READY 区分;独立审查、全量回归、冻结实际按钮验证并交付候选。1135 项通过;de952a6 冻结实际按钮达到 PASS/GREEN/READY,历史版本仍标记待核对。
采用独立版本选择控制器与 Qt 对话框,复用原生代理及现有进度信号;不引入前台鼠标或自动重导入。界面只要求选择已有候选版本,不替用户推断应采用哪个版本。
@@ -0,0 +1,36 @@
# Manual Backup Implementation Plan
**Goal:** 按用户最新要求取消应用操作前的自动备份,改为提示手动备份,减少整库复制和重复哈希耗时。
**Architecture:** 管理操作使用只读内容基线、暂存来源、原生身份核对和现有库锁。备份责任转为用户;应用不验证或声称手动备份已存在。恢复操作只创建用于隔离校验的库副本,不再额外复制完整回退库。原生 Repair 自身备份保持原生行为。
**Tech Stack:** Python 3.12 / PySide6 / Mentor EE7.9.5。
用户已明确指定取消自动备份并提示手动备份,本计划直接执行。沿用临时分支,不合并发布、不修改原用户库。保留既有 `review.diff`。
## 范围与检查结果
| 操作 | 旧行为 | 新行为 |
| --- | --- | --- |
| 新增、替换、移除 | 每项完整中心库备份 | 手动备份提示;只读基线、检查点及来源暂存 |
| 普通校验 | 本地 CBB 辅助备份,网络跳过 | 所有路径统一取消应用辅助备份 |
| ICDB Repair | 应用完整工程备份,加原生自身备份 | 取消应用复制,保留独占读取/身份检查及原生自身行为 |
| 从备份恢复 | 整库回退备份再复制验证库;额外来源副本 | 直接复制一次隔离验证库,来源直接暂存到验证工程 |
| 读取/搜索/筛选 | 无备份 | 保持只读 |
验证工程副本和来源暂存是任务输入,不能删除后直接改原始来源。恢复安装中的旧 Work 改名保留是目录交换保护,不复制数据,继续保留。历史证据与备份不清理。独立研究工具的显式备份不属于桌面自动操作。
## Tasks
- [ ] 管理:先增加不复制整库及基线变化阻止写入的回归;移除事务授权对备份目录的依赖,绑定基线清单,保留身份、监督进程、活跃库锁和检查点验证;更新对应测试。
- [ ] 校验/Repair/恢复:先写不调用自动备份、保持独占检查及单一验证库副本的回归;改调用路径和进度说明,测试取消/占用/来源及目标变化继续阻止操作。
- [ ] 界面:将手动备份提示加入管理、校验、维护、恢复执行确认;取消不启动任务,每批一次,不伪称备份已完成。移除自动备份承诺。
- [ ] 验证:集中测试、全量 Python 测试、编译与 diff 检查、独立代码审查;隔离原生移除验证不创建整库备份;新冻结包验证提示和取消反馈。更新验证记录,提交并构建候选。
## Review Focus
- 没有备份目录仍能通过真实管理事务校验;错库、过期锁、来源变化、基线记录篡改仍拒绝。
- 替换移除成功但新增失败必须保留部分失败检查点,明确使用用户手动备份恢复。
- 删除备份调用不能同时删掉数据库独占和取消检查。
- 恢复仍隔离验证,并保留来源/目标变更检查与失败安装回退。
- UI 取消确认无写入;逐项自动校验不重复弹窗;没有目标时不弹无意义提示。
@@ -0,0 +1,32 @@
# 原生 CBB 管理接入续作
沿用用户已批准的工单 #2 管理范围与临时分支。此次用户要求找到并尝试接入库的增删改查原生接口。
不直接修改 LMC 二进制,不采用前台鼠标,不强制结束持有数据库的原生进程;原用户库不参与写入试验。
## 已确认接口
- 查询:LibraryManager.Application.OpenLibrary → Partitions(7) → 名称、分区,核对库身份并正常退出。
- 新增:OnReusableBlocksEditor → 原生 Logical-Physical 页签 → New → 源 PRJ、名称、顶层块,提交原生对话框。字段使用有时限的窗口消息复读,提交后确认成功消息,再关闭重开目录。
- 移除:安装脚本确认的 CleanWGLib/F4/REUSE_BLOCK,必须完整备份且重新读库确认缺失。
- 同名替换:复用经过验证的移除与新增;它不是原子更新,删除后导入失败时保留恢复检查点并停止队列。与仅替换 Work 的“从备份恢复”明确区分。
## 接入步骤
1. 共享原生新增适配层,保留私有桌面、二进制版本、同库租约、监督进程、来源暂存及完整备份的验证。生产能力未通过时只有带隔离库所有权证据的研究入口可写。
2. 原生 ICDB 导入会重写存储。用安装版本锁定的 ASCII、CSV 和 EDIF 原理图导出建立内容指纹,并保留布局及其他工程资产的字节哈希。不能把注册成功或名称相同等同于工程内容一致。
3. 导出仅使用新建的完整工程副本。严格确认退出、有效输出与原生完成标记;仅规范化已经实际证明会变化的报告时间/路径字段。布局、坐标、连接、属性及未知工程文件变化一律阻止接受。
4. 新增后原生程序可能未正确重定位 PCB 配置的 CentralLibrary。仅在本任务注册成功、原生释放和租约持有时修正该已导入工程的库引用,再重新打开核对目录与内容。原始输入工程不改动。
5. 在实际新建隔离库运行新增、同名冲突、不同版本同名替换、备份后移除、从备份重新导入;逐项保存证据,验证源文件未变。随后才提升对应生产能力。
6. 运行相关回归、独立审查、全量测试与冻结包实际管理入口验证。缺少原生证据的能力继续禁用并准确说明原因。
## 已完成的内容指纹取证
`diagnostics/issue2-native-crud-20261103/` 保存真实导出对照:
- ASCII:层次与展开连接、组件、端口和属性,3,531 行;只差生成时间和数据库目录三行报告元数据。
- CSV:14 个表格文件;只差信息表的 System_Date 字段。
- EDIF `-schematic`:约 580 KB,包含坐标、图形、连线、旋转、文本位置及属性;只差根级 status/written/timestamp。
- 139 个主要工程资产一致;其余变化为 ICDB 数据文件、其运行时记录及两处 PCB CentralLibrary 引用。
以上为已验证格式的内容身份合同,不声称任意未知版本、任意外部工具私有元数据都可无差别转换。
导出格式、安装版本、必需文件或引用不符合时拒绝操作。
@@ -0,0 +1,48 @@
# PR #3 comment 249 implementation plan
**Goal:** Make the force-release contract explicit and keep shared native servers out of forced termination; replace the large PR as the merge entry with smaller, ordered review branches.
**Authorization:** The user requested implementation of comment 249. Earlier user decisions retain explicit user-confirmed residual release, manual backups and no release/issue closure before field acceptance. These decisions take precedence over changing Draft status merely to make a merge button available.
**Architecture:** Keep automatic verification and checking cooperative. A separate explicit force action can end supported document clients only after scope, exact process identity, current user SID and Windows session are checked. Native database servers and unknown processes remain observable and cannot be force terminated. Every force request must persist consent intent before any termination and still obtain independent library-release proof afterward.
**Review split:** Preserve #3 as an unmerged umbrella. Create a dependent review chain: (1) read-only owner probing and cooperative queue; (2) native backend, manifests, library coordination and transactions; (3) background checks and application UI integration; (4) residual-session release, its explicit contract, version and documentation. `management_transaction` imports management and lock APIs, and semantic manifests depend on recognized coordination checkpoints; they belong with the backend rather than pretending to be standalone read-only utilities. The existing #5 remains a prerequisite document review, not an automatically merged change.
## Global constraints
- Python/PySide6, Windows and Mentor EE7.9.5 remain the supported implementation stack.
- Never kill native servers or operate production libraries in this development task.
- No automatic Repair, Restore, version choice, issue closure, publishing or PR merge.
- Each split PR states visible behavior, failure safety and rollback.
- Preserve the current user test workspace; work in the PR worktree.
## Task 1: Force-release boundary
Files: `residual_sessions.py`, `ui/residual_release_dialog.py`, `tests/test_residual_sessions.py`, `tests/test_residual_release_dialog.py`.
- [x] Add failing tests: a scoped iCDB server cannot reach `_force_close`; direct force requests against server/unsupported names never obtain a terminate-capable handle; missing consent evidence causes zero termination calls; mixed client/server previews list only supported clients in the confirmation; rejected/reused process identities remain unchanged.
- [x] Define one shared force-eligibility function allowing only recognized document clients with confirmed scope and matching captured executable identity. Enforce it again at dispatch and at the exact handle boundary.
- [x] Persist `consent.json` with target library, exact preview identities and allowed/excluded targets before processing a force request. A write failure returns before native actions.
- [x] Keep excluded servers in the release result and require the existing independent release proof; process exit never means repaired/READY.
- [x] Run focused regressions and the complete suite with an isolated test mutex.
## Task 2: Version and operating contract
Files: `pyproject.toml`, `README.md`, `SOP.md`, `docs/ICDB-MANUAL-REPAIR-AND-UPDATE.md`, `docs/releases/v0.2.4-beta.1.md`.
- [x] Identify the actual tracked SOP before editing; update README, SOP and manual together.
- [x] Set `0.2.4b1` and document the user-confirmed client-only exception to the automatic no-force contract. Explain server handling, evidence, failure states, manual recovery and rollback.
- [x] Keep field ICDB recovery, Win10 and multiuser shared-library acceptance explicitly unverified.
## Task 3: Review branches
- [x] Inventory final files against main and assign each file to the smallest dependency-closed review stage. Keep UI/release hooks unavailable until their backend exists; do not publish branches with broken normal operation.
- [x] Create ordered branches with one concrete feature commit per review unit, no rewriting the existing umbrella history.
- [x] Test each review stage using appropriate unit/full checks; preserve all final regressions and verify the final source tree against the umbrella snapshot.
- [ ] Push branches without force and create draft PRs with explicit base dependencies. Link them from #3 and record the splitting rationale.
## Task 4: Delivery
- [ ] Commit and push the safety fixes and validation record to #3.
- [ ] Verify remote heads, PR descriptions and clean review worktrees. Keep #3 and issues open and do not merge #5.
- [ ] Report PR links, passing tests and remaining field-acceptance limits to the user.