docs: define explicit target cell selection and verification plan

This commit is contained in:
阿白叔 committed 2026-10-19 14:29:36 +08:00
1 parent 5ad0c66732
commit 8723076cb6
2 files changed
+104

No files matched your search

@@ -0,0 +1,65 @@
# Target Cell Selection Implementation Plan
> **For agentic workers:** Use superpowers:subagent-driven-development in this session; user has approved explicit rule selection and blocking when missing. Do not ask for repeated approval.
**Goal:** Bind explicit, authoritative target Cell selection to rules and verified execution.
**Architecture:** An isolated read-only library catalog supplies rule choices. Persist a target_cell string through batch defaults and per-target plans. The queue, native transaction, restore and saved readback all bind that selection; existing C/A/U/G protections remain complete.
**Tech Stack:** Python 3.12, SQLite, PySide6, installed EE 7.9.5 COM, VBScript.
**Spec:** ../specs/2026-10-19-target-cell-selection.md
## Global Constraints
- Preserve the default 11-column BOM; no inferred Cell choice.
- Keep current branch codex/bom-import-state and preserve feedback/.
- No packaging/release, no source-project/library writes, no user desktop CAD control.
- Real execution only in build/ disposable copies with owned desktops.
- Libraries must have complete PDB/Cell dependencies; failed/rebuilding copies fail closed.
## Task 1: Complete and commit native selected capture separately (root)
Files: NativeSnapshotReader.vbs, QuickPartReplace.vbs, test_native_selected_capture.py.
- [x] Reuse original QPSnapshotComponent within one correlated NR2 capture; NR1 verify stays unchanged.
- [x] Reject incomplete/foreign/duplicate selected C/A and scope drift; compare focused tests and independent review.
- [ ] Complete same-source legal BOM baseline/native runs and field/graph equivalence; commit evidence separately.
## Task 2: Rule and target-plan persistence/UI (cell_rules agent)
Files: models.py, store.py, store_schema.py, service.py rule methods, batch_rules.py, target_plan.py, BOM merge code, ui/dialogs.py, ui/main_window.py, ui/mapping_table.py, relevant tests.
Interfaces: target_cell: str = ''; service.target_cell_choices(task_id, new_part_number) -> tuple[str,...] delegates cell_catalog.read_project_cell_choices; RuleRecord and target plan compilation preserve target_cell. Root owns quick_run.py, recovery.py, native_helper.py and VBS.
- [ ] Write meaningful red tests for migration, batch propagation, BOM-preserved selection, selected target compilation, PN change invalidation and UI stale choices.
- [ ] Implement field, editing dropdown/load action and async current-PN binding; preserve existing dialog.values() tuple for callers if practical.
- [ ] Add cheap service.validate_target_cells(task_id) for GUI preflight, before CAD startup. Missing target_cell is actionable and cannot start execution from UI.
- [ ] Run scoped tests, self-review and commit only owned files. Root will review and integrate.
## Task 3: Isolated authoritative catalog (cell_catalog agent)
Files: new cell_catalog.py, new cell_catalog_worker.py if needed, application.py hidden CLI dispatch, catalog tests. Do not edit service/UI/quick_run/native_helper/VBS.
Interfaces are exactly the spec's CellChoice, CellCatalog and read functions. Cache/evidence root supplied by caller. Helpers launch using the frozen EXE hidden action or source -m module; every process is owned by PrivateDesktop.
- [ ] Reproduce incomplete dependency/old fingerprint/duplicate target behavior with fakes; test failures are explicit.
- [ ] Implement complete shadow copy with metadata preservation, source proof, exact numeric COM enumeration and all cleanup.
- [ ] Use installed IMGCLMPart.AssociatedCells; no raw DLL ABI guessing. Reuse probe findings; do not operate on originals.
- [ ] Run focused tests and a tiny read-only owned-library probe if needed; commit only owned files.
## Task 4: Transport and native Cell proof (root)
Files: quick_run.py, recovery.py, native_helper.py, QuickPartReplace.vbs, execution tests.
- [ ] Add target_cell queue option and separate L snapshot row; mismatch/changes cannot resume old work.
- [ ] Verify current catalog and selected value before mutation; bind catalog/choice in native evidence.
- [ ] Write selected Cell instance within existing restore transaction; validate full targets, untouched baseline, save/reopen and saved recovery.
- [ ] Red/green tests for missing/invalid/changed choice, no broad writes and restoration failure.
## Task 5: Integrated review and real acceptance (root + independent reviewer)
- [ ] Review each task against spec and quality; resolve important findings.
- [ ] Run appropriate combined regressions, final GUI interaction and representative BOM/cross-cell copy execution.
- [ ] Record actual timings, known research failures, mapping/graph/desktop proofs and limits; update docs.
- [ ] Commit and push; verify remote HEAD and only feedback/ untracked. No release.
@@ -0,0 +1,39 @@
# 料号规则的显式目标封装
用户已选择:在料号规则里选择目标封装,未选择时阻止执行。保留一工程一任务、同批规则共享及默认 11 列 BOM,不修改 BOM 模板。
## 数据及界面
- RuleRecord 与目标计划行增加 target_cell: str,默认空;数据库兼容旧数据。旧规则不会自动猜一个封装。
- 规则编辑器增加目标封装下拉及读取按钮,候选异步读取、明确加载/失败/就绪状态。新料号变化时清空旧选择;过时的读取结果不能覆盖当前料号。空选择可保存草稿,正式执行必须有合法选择。
- target_cell 存原生 Cell Name,保持大小写。候选来自目标料号的真实关联,不从 Part Name 字符串推断。跨分区同名封装不能无声合并;若目前无法唯一确定则阻断。
- 同批传播、BOM 导入、按位号执行规则编译都保留选择;BOM 原有列不变。新料号被修改而无同一映射默认值时清空旧选择。
## 权威来源
本机 LibraryManager.tlb 公开 IMGCLMPart.AssociatedCells。读取必须在自有私有桌面和库副本中执行;原库不启动编辑、不被重写。
读取副本必须含 LMC、配套 cfg/prp、PDB 和 CellDB 依赖,保持原时间戳,核对复制前后指纹。缺少物理 CellDB 时 AssociatedCells 会静默返回空,不能将不完整副本的空集合视为权威。自动迁移/重建分区对话框、超时或缺依赖均失败,不点确认后猜结果。
接口模块 cell_catalog.py:
- CellChoice(partition: str, name: str)。
- CellCatalog(library_path: Path, part_partition: str, part_number: str, cells: tuple[CellChoice,...], source_fingerprint: str, evidence_path: Path)。
- read_library_cell_catalog(library_path: Path, part_number: str, evidence_root: Path, *, partition: str | None = None) -> CellCatalog。
- read_project_cell_choices(project_paths: tuple[Path,...], part_number: str, evidence_root: Path) -> tuple[str,...]:不同工程库的候选取交集;无法核验、无交集或同名跨分区歧义均报错。
缓存必须按源内容指纹、料号、分区绑定;执行时重新核对源,不能仅用名称缓存。读取工作通过隐藏入口 --cell-catalog-worker 分发,冻结与源码同一代码路径,不依赖外部 Python 安装。
## 执行及恢复
- 队列记录 target_cell,并纳入队列一致性检查;快照新增独立 L 行,不改变原 M 行已有字段顺序。新任务缺选择必须在原生替换提交前停止。
- 原生 helper 从实际活动工程的 CentralLibraryPath 读取当前库关联,验证选择属于目标料号允许集合,记录完整候选、指纹及显式选择,绑定 snapshot hash/工程/图页/目标 UID。
- 仅修改已确认目标组件的 Cell Name 实例值;不清空原实例后依赖继承。不修改未选中器件,不修改原库。遵守现有恢复事务、失败关闭未保存、保存前及重开后核验,校验有效 Cell Name 等于所选值。
- saved 恢复必须核对同一封装选择及磁盘值;任何未认证的新恢复路径都不能产生成功证明。旧队列不能无声套用新的封装选择。
- 多候选不得按第一个或按名称近似自动选择。单候选也在规则中显示明确选择,空草稿阻止正式执行。
## 验证范围
字段持久化/升级、同批传播、BOM 保留、异步过时结果、未选/非法选择阻断、候选变化、事务绑定、保存重开及恢复反例。真实合法样例使用两个源料号替换为 4100-CA1020-T7,目标 RESC1005N_0402;已确认跨封装样例单独证明未选或不合法选择在写入前阻断。只有目标封装实际选择且写入/回读通过,才认证跨封装。
不打包、不发布、不修改 feedback/,实机仅 build/ 新副本。源文件哈希、私有进程和桌面释放作为证据。100% 不作为跨工程无条件承诺。