diff --git a/docs/superpowers/plans/2026-10-14-v1.1.0-project-tasks.md b/docs/superpowers/plans/2026-10-14-v1.1.0-project-tasks.md new file mode 100644 index 0000000..f13dec5 --- /dev/null +++ b/docs/superpowers/plans/2026-10-14-v1.1.0-project-tasks.md @@ -0,0 +1,60 @@ +# V1.1.0 Project Tasks Implementation Plan + +> **For agentic workers:** Use superpowers:subagent-driven-development task-by-task. Steps use checkbox syntax. + +**Goal:** Iterate the existing replacement application with single-project tasks, editable per-component plans, optional Excel imports and serial task execution. + +**Architecture:** Reuse the existing desktop service/store and native replacement helper. Add focused plan/inventory/queue modules with stable target identities and transactional persistence. Keep historic jobs and an explicit legacy test entry point. + +**Tech Stack:** Python 3.12, SQLite, PySide6, ASCII VBScript; openpyxl for XLSX files. + +**Spec:** docs/superpowers/specs/2026-10-14-v1.1.0-project-tasks-design.md + +## Global Constraints + +- Version 1.1.0; retain existing task view and direct editing. +- Each directory-created task owns exactly one .prj; historical tasks are preserved. +- Explicit empty targets never mean all matches. +- UID + schematic + sheet + expected RefDes + old Part Number identify targets. +- Default NC synchronization remains on and is editable in UI/import; independent /NC only. +- Existing Replace Part + Library Wins, backup and saved readback remain required. +- No production CAD writes for interface research or tests. +- Default tests are fast behavior tests; historic regressions are explicit and preserved. + +--- + +## Task 1: Persistence, inventory, plans and target execution + +Files: models.py, store.py, service.py, quick_run.py, recovery.py, QuickPartReplace.vbs; create target_plan.py, inventory.py, spreadsheet_plan.py and project_tasks.py as focused modules; tests/v1_1/test_project_tasks.py, test_target_plan.py, test_inventory.py, test_spreadsheet_plan.py, test_target_execution.py. + +Interfaces consumed: TaskStore transaction(), create_task(), sync_projects(); QuickRunPreparer and existing sheet discovery. Produced: directory task creation, task inventory, target plan edit/import/export APIs and versioned target-aware queue preparation. Define exact signatures in the implementation report for UI/task queue integration. + +- [ ] Write failing behavior tests for two .prj files creating two single-project tasks, duplicate scanning not duplicating active tasks, same names differentiated by relative path; run these tests and observe missing APIs. +- [ ] Implement transaction-backed group/order/project binding and migrations; maintain legacy constructor defaults. Test transaction rollback and reopen. +- [ ] Write failing tests using injected inventory rows for same old part on R1/R2/R3: selecting R1/R3 yields only those UIDs; R2 stays excluded; missing target errors, empty target errors, conflicting imports and equal/chain/cycle rules error. +- [ ] Implement component inventory read mode on existing discovery route, collecting effective Value and all stable identifiers without pin/attribute full snapshots; do not save while scanning. +- [ ] Implement target rule grouping and target-aware command/snapshot/recovery freeze validation in both Python and VBS. Run isolated VBS contract tests and native_helper mocks; tests must prove selectors survive recovery and stale targets do not become no_match. +- [ ] Add openpyxl reader/writer using explicit columns and literal values; parse whole workbook, validate identity and duplicates, then commit atomically. Test roundtrip editing new part, Value and NC plus forged UID and duplicate row rejection. +- [ ] Run V1.1 behavior tests and relevant existing inputs/value/recovery tests; commit this task only after covering tests pass and report API signatures and validation limits. + +## Task 2: Cross-task scheduler and existing UI integration + +Files: task_queue.py; ui/main_window.py, task_list.py, mapping_table.py; tests/v1_1/test_task_queue.py, test_project_task_ui.py. + +Consumed APIs: Task 1 report; existing service.execute_quick_run_queue/quick_run_progress and safe pause. Produced APIs: fixed ordered task queue runner and UI directory wizard/inventory target table/Excel optional entry points. + +- [ ] Write failing scheduler test with fake runner logging starts/ends: A completes before B starts; pause leaves B unstarted; uncertain A prevents B; safe ordinary A failure allows B and summary records both. +- [ ] Implement scheduler with per-task evidence paths and fixed IDs/plan fingerprints; reject same-project concurrent tasks, preserve active task evidence on resume. +- [ ] Add directory scanner/create dialog to existing New action with project checkboxes and async scan; existing edit/name notes and historical view survive. Show counts and execution order, support ordering and group start/pause. +- [ ] Add Collect Targets action and editable target table: per row enabled/new part/custom Value/NC controls; preserve existing rule dialog/full-match path. Excel import/export optional actions use same plan validation; blank typed target lists rejected rather than matching all. +- [ ] Verify Qt widgets with offscreen smoke interactions and scheduler failure/lock tests. Commit after tests pass. + +## Task 3: Test entry points, version and deliverable verification + +Files: pyproject.toml, version.py, packaging/Build-DxPartReplace.ps1, docs/user/v1.1.0-project-tasks.md, tests/conftest.py or tests/legacy/conftest.py, tools/test_v1_1.ps1 and tools/test_legacy.ps1. + +- [ ] Default testpaths becomes tests/v1_1. Keep existing directories reachable with explicit paths; scripts set local src PYTHONPATH to prevent unrelated installed dx_productivity package collisions. +- [ ] Version pyproject and desktop to 1.1.0. Add openpyxl dependency and ensure packaging discovers it; update build QA commands to run V1.1 and meaningful safety regressions rather than reintroducing full slow suite implicitly. +- [ ] Document new task/inventory/Excel/NC workflows, previous data migration and real CAD validation limits; include native research report. +- [ ] Run default behavior suite, selected safety/Qt/VBS tests, compileall and build/frozen smoke if toolchain available. Review diff for selector fallback, evidence overwrites, migration loss and UI async locks; fix findings. +- [ ] Bring verified commits into the main workspace without rewriting user work; supply V1.1.0 ZIP/EXE if build succeeds and distinguish code test results from live CAD acceptance. diff --git a/docs/superpowers/plans/v1.1.0-task-1-brief.md b/docs/superpowers/plans/v1.1.0-task-1-brief.md new file mode 100644 index 0000000..b14b97c --- /dev/null +++ b/docs/superpowers/plans/v1.1.0-task-1-brief.md @@ -0,0 +1,39 @@ +# V1.1.0 Project Tasks Implementation Plan + +> **For agentic workers:** Use superpowers:subagent-driven-development task-by-task. Steps use checkbox syntax. + +**Goal:** Iterate the existing replacement application with single-project tasks, editable per-component plans, optional Excel imports and serial task execution. + +**Architecture:** Reuse the existing desktop service/store and native replacement helper. Add focused plan/inventory/queue modules with stable target identities and transactional persistence. Keep historic jobs and an explicit legacy test entry point. + +**Tech Stack:** Python 3.12, SQLite, PySide6, ASCII VBScript; openpyxl for XLSX files. + +**Spec:** docs/superpowers/specs/2026-10-14-v1.1.0-project-tasks-design.md + +## Global Constraints + +- Version 1.1.0; retain existing task view and direct editing. +- Each directory-created task owns exactly one .prj; historical tasks are preserved. +- Explicit empty targets never mean all matches. +- UID + schematic + sheet + expected RefDes + old Part Number identify targets. +- Default NC synchronization remains on and is editable in UI/import; independent /NC only. +- Existing Replace Part + Library Wins, backup and saved readback remain required. +- No production CAD writes for interface research or tests. +- Default tests are fast behavior tests; historic regressions are explicit and preserved. + +--- + +## Task 1: Persistence, inventory, plans and target execution + +Files: models.py, store.py, service.py, quick_run.py, recovery.py, QuickPartReplace.vbs; create target_plan.py, inventory.py, spreadsheet_plan.py and project_tasks.py as focused modules; tests/v1_1/test_project_tasks.py, test_target_plan.py, test_inventory.py, test_spreadsheet_plan.py, test_target_execution.py. + +Interfaces consumed: TaskStore transaction(), create_task(), sync_projects(); QuickRunPreparer and existing sheet discovery. Produced: directory task creation, task inventory, target plan edit/import/export APIs and versioned target-aware queue preparation. Define exact signatures in the implementation report for UI/task queue integration. + +- [ ] Write failing behavior tests for two .prj files creating two single-project tasks, duplicate scanning not duplicating active tasks, same names differentiated by relative path; run these tests and observe missing APIs. +- [ ] Implement transaction-backed group/order/project binding and migrations; maintain legacy constructor defaults. Test transaction rollback and reopen. +- [ ] Write failing tests using injected inventory rows for same old part on R1/R2/R3: selecting R1/R3 yields only those UIDs; R2 stays excluded; missing target errors, empty target errors, conflicting imports and equal/chain/cycle rules error. +- [ ] Implement component inventory read mode on existing discovery route, collecting effective Value and all stable identifiers without pin/attribute full snapshots; do not save while scanning. +- [ ] Implement target rule grouping and target-aware command/snapshot/recovery freeze validation in both Python and VBS. Run isolated VBS contract tests and native_helper mocks; tests must prove selectors survive recovery and stale targets do not become no_match. +- [ ] Add openpyxl reader/writer using explicit columns and literal values; parse whole workbook, validate identity and duplicates, then commit atomically. Test roundtrip editing new part, Value and NC plus forged UID and duplicate row rejection. +- [ ] Run V1.1 behavior tests and relevant existing inputs/value/recovery tests; commit this task only after covering tests pass and report API signatures and validation limits. + diff --git a/docs/superpowers/specs/2026-10-14-v1.1.0-project-tasks-design.md b/docs/superpowers/specs/2026-10-14-v1.1.0-project-tasks-design.md new file mode 100644 index 0000000..c502223 --- /dev/null +++ b/docs/superpowers/specs/2026-10-14-v1.1.0-project-tasks-design.md @@ -0,0 +1,31 @@ +# DxPartReplace V1.1.0 单工程任务与位号计划 + +已获用户授权开始迭代;本设计记录当前对话决定,不新增审批步骤。 + +## 产品流程 + +保留现有任务列表与规则编辑体验。新建入口支持选择目录、扫描 .prj、勾选工程、一次创建多个任务;每个新任务绑定且只绑定一个工程。同名工程使用相对路径区分。任务组只是目录创建与排序的组织单位。历史多工程任务保留,不能在迁移中重写执行证据。 + +用户在任务内填写旧料号、新料号,点击采集位号。使用已有只读图页发现链路读取真实器件的图页、UID、RefDes、Part Number、有效 Value。采集不调用替换、不保存。图页不同、层级不同或同名位号不能只靠 RefDes 合并。采集只读进程必须有界结束并关闭其拥有的工程。 + +用户可在原界面直接编辑/选择目标位号,不必导出。Excel 导入是可选入口;可导出同样的计划用于 Excel 编辑,但不会要求导出后才能执行。一行代表一个真实器件,保留工程、原理图、图页、UID、位号、旧料号、旧 Value,用户可编辑启用、新料号、自定义 Value、NC 同步。基线身份列不可重新解释;导入必须完整校验后原子提交,不得部分写入。 + +## 规则与执行 + +规则支持明确的全匹配范围与显式目标范围。旧规则迁移为全匹配;新目标规则使用已采集的 UID 与图页/位号作为预期状态。空目标集合不能退化为全匹配。同一旧料号允许不同位号子集和不同目标料号;重叠目标、全匹配与目标子集混用、链式/循环映射拒绝。一个目标可写独立自定义 Value;按图页/旧料号/新料号/Value/NC 策略编译分组再执行。 + +NC 保留现有可选语义并补齐任务视图编辑及 Excel 导入,默认开启;仅独立 /NC 段识别,禁止重复追加,写入和保存后回读均检验。保留模式的真实含义沿用现有原生库 Value 语义,不凭名为 preserve 推断会恢复旧文字。自定义模式明确写入用户给出的新值。 + +保持已有原生 Replace Part + Library Wins 写入路径与备份/连接/位置/保存回读/不确定保护。Python 计划携带 UID 清单,VBScript 在选取前校验 UID、RefDes、源料号、图页;目标缺失/状态变化必须失败而不是 no_match。未选器件的变化必须检测。目标绑定加入命令、快照、恢复与输入冻结校验。 + +跨任务执行采用已确认的任务 ID 顺序并固定计划。一个任务完成收尾/关闭后才进入下一个;普通失败在工程已安全关闭时可继续,未确定结果、恢复保护、关闭失败停止。各任务持有独立队列、备份、日志,不能用共享目录覆盖上一任务的未完成状态。规则、选择和任务操作在活动执行期间锁定,暂停在安全项边界。 + +## 结构与迁移 + +添加聚焦的 project_tasks、target_plan、inventory、spreadsheet_plan、task_queue 模块;复用 TaskStore/TaskCenterService 与 Qt 视图;不得复制旧多工程控制器或实现另一套 CAD 写入引擎。数据库使用事务迁移,新增字段有兼容默认值。版本从 1.1.0 起,EXE 标题、构建清单、依赖版本同步。 + +原生接口调研代理独立只读:检查当地官方类型库与帮助、已有探针以及公开资料,报告已证实能力/待验证能力;不对当前 CAD 会话或生产工程发起写操作。实验接口不自动成为默认后端。 + +## 验证 + +重建测试入口:默认只运行 V1.1.0 的行为级快速核心测试和必要的现有安全回归。旧测试保留为显式 legacy 回归入口,不删掉证据、不把过长模拟睡眠放入默认测试。无需 CAD、真实 COM 或网络即可测试导入原子性、目标隔离、顺序、重启/暂停、NC 和协议绑定。VBS 契约验证、Qt 交互和冻结 EXE 冒烟单独报告。现场原生替换与单元测试结论必须区分。