Files
dxdesigner-part-replacement/docs/superpowers/plans/v1.1.0-task-1-report.md

4.0 KiB

V1.1.0 Task 1 Backend Report

Task 1 implements single-project persistence, target inventory/plans, Excel interchange, target-aware queue preparation, native selector checks, and recovery bindings.

APIs for UI and scheduler

  • TaskCenterService.create_project_tasks(root: Path, selected_paths: tuple[Path, ...] | None = None) -> tuple[TaskRecord, ...]: scans a directory and creates one task per selected .prj; each task owns exactly one project. Active unfinished paths are deduplicated. Completed tasks may be recreated with a readable suffix.
  • TaskCenterService.scan_project_directory(root: Path) -> tuple[Path, ...]: read-only directory scan.
  • TaskCenterService.collect_target_inventory(task_id: str, old_part_numbers: tuple[str, ...] | None = None) -> tuple[TargetPlanRow, ...]: runs existing owned-project discovery in read mode and records stable ComponentTarget baselines. No save is requested from the CAD process.
  • TaskCenterService.target_plan(task_id: str) -> tuple[TargetPlanRow, ...] and replace_target_plan(task_id, rows): read/edit the plan. store.record_target_inventory(task_id, targets) is the trusted initial baseline operation. A plan edit cannot alter project/schematic/sheet/UID/RefDes/old-part/old-Value identity.
  • TaskCenterService.preview_target_plan(task_id, path) validates an Excel workbook without writing; import_target_plan(task_id, path) validates then commits atomically; export_target_plan(task_id, path) writes explicit columns.
  • TaskCenterService.for_project_task(task_id) -> TaskCenterService: returns a facade whose queue evidence root is storage/tasks/<task_id>/quick-run; the facade shares the store and logging context. Parent quick-run entry points delegate automatically for bound single-project tasks.
  • TaskCenterService.move_project_task(task_id, offset) changes group ordering while the group is idle.
  • ComponentTarget(project_path, schematic_name, sheet_number, uid, refdes, old_part_number, old_value) is immutable identity. TargetPlanRow(target, enabled=False, new_part_number='', custom_value_enabled=False, custom_value='', sync_nc=True) contains editable fields. NC defaults to enabled.

Execution behavior

TaskRecord.target_plan_mode is set when inventory is recorded, including an explicitly empty inventory. Execution compiles only enabled target rows into TargetRule groups. An empty or all-disabled target plan raises enabled_rule_required; it never falls back to old-part full matching. Mixing target and full-match rules is rejected. Target queue rows carry target_scope=targets and encoded UID/RefDes/old-Value selectors.

The VBS helper validates selectors against the active project/sheet before capture and native replacement. Python native checks do the same and compare the unselected component baseline (UID, RefDes, Part Number, Value, Part Name, Part Label) before and after mutation. Recovery binds the selector set and snapshot hash to the transaction evidence. Native CAD operations remain uncalled by tests.

Validation

Commands run from the worktree:

PYTHONPATH=src python -m pytest tests/v1_1 -q
36 passed in 5.06s

PYTHONPATH=src python -m pytest tests/integration/test_quick_part_replace_contract.py tests/trial_task_center/test_recovery.py tests/trial_task_center/test_value_options.py -q
45 passed in 7.57s

The V1.1 suite covers transaction rollback/reopen, schema 5 to 6 migration, project deduplication and recreation, target subset isolation, empty target safety, forged identity rejection, Excel roundtrip/atomic validation, per-task evidence roots, native selector checks, unselected-change detection, and purge cleanup.

Limits

Component inventory depends on the existing QuickPartReplace.vbs read-only discovery route and therefore requires a Windows DxDesigner installation for live collection. The test suite uses injected inventory rows and never performs production CAD writes. The native helper cannot prove arbitrary attributes that are not included in the recorded baseline; it checks the documented identity/value fields above.