Initial import of DxDesigner part replacement tool (r21)

This commit is contained in:
阿白叔 committed 2026-09-29 15:42:21 +08:00
commit ffe066cb1e
151 files changed
+58745

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,456 @@
# DxDesigner Part Replacement Trial Task Center Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Deliver a packaged Windows `DxPartReplace.exe` that manages replacement tasks, scans and selects `.prj` projects, edits Part Number mappings, guides one-project-at-a-time native replacement, compares fresh before/after probe evidence, advances verified projects to Completed, and records complete operational and crash logs.
**Architecture:** A PySide6 desktop shell calls a Qt-free service layer. SQLite stores mutable task drafts and project state, append-only JSONL plus rotating text logs preserve diagnostics, and a pure comparison module validates before/after probe profiles. The first release never automates or writes DxDesigner; it waits for operator-created read-only profiles and verifies them before advancing the queue.
**Tech Stack:** Python 3.12, PySide6 6.x, SQLite, pytest 8.x, pytest-qt 4.x, PyInstaller 6.x, JSON/JSONL, PowerShell 5.1-compatible packaging script.
**Spec:** `docs/superpowers/specs/2026-09-04-dxdesigner-part-replacement-trial-task-center-design.md`
## Global Constraints
- Release classification remains `evaluation-only`.
- Operate only on complete disposable project copies.
- Match replacement rules exclusively by `Part Number`; do not impose a material-number regular expression.
- Do not invoke `SendKeys`, UI coordinates, blind delays, automatic save, rewiring, or any DxDesigner design setter.
- Do not bypass the production certification or compatibility-profile gates.
- Task deletion is soft deletion and never deletes engineering files or evidence trees.
- A project reaches `completed` only after a fresh, exact-project before/after comparison has no hard failures.
- Application logging starts before the main window is constructed and captures uncaught main-thread and worker-thread exceptions.
- Preserve all pre-existing dirty-worktree changes outside the files named by a task.
---
### Task 1: Task Records, SQLite CRUD, and Diagnostic Logging
**Files:**
- Create: `src/dx_productivity/trial_task_center/__init__.py`
- Create: `src/dx_productivity/trial_task_center/models.py`
- Create: `src/dx_productivity/trial_task_center/errors.py`
- Create: `src/dx_productivity/trial_task_center/store.py`
- Create: `src/dx_productivity/trial_task_center/logging_setup.py`
- Create: `tests/trial_task_center/test_store.py`
- Create: `tests/trial_task_center/test_logging_setup.py`
**Interfaces:**
- Produces: `TaskStatus`, `ProjectStatus`, `TaskRecord`, `RuleRecord`, `ProjectRecord`, `TaskCenterError`.
- Produces: `TaskStore(path: Path)` with task/rule/project CRUD and transactional state changes.
- Produces: `configure_logging(root: Path) -> LoggingContext`, `install_exception_hooks(context)`, and `append_task_event(...)`.
- Consumes: no Qt and no DxDesigner API.
- [ ] **Step 1: Write failing model and CRUD tests**
Define tests that require these exact public records and methods:
```python
class TaskStatus(str, Enum):
DRAFT = "draft"
READY = "ready"
RUNNING = "running"
PAUSED = "paused"
COMPLETED = "completed"
FAILED = "failed"
DELETED = "deleted"
class ProjectStatus(str, Enum):
PENDING = "pending"
CAPTURING_BEFORE = "capturing_before"
AWAITING_OPERATOR = "awaiting_operator"
CAPTURING_AFTER = "capturing_after"
VERIFYING = "verifying"
COMPLETED = "completed"
FAILED = "failed"
SKIPPED = "skipped"
```
```python
store = TaskStore(tmp_path / "task-center.db")
task = store.create_task("试验任务", note="first")
assert store.get_task(task.task_id).name == "试验任务"
renamed = store.update_task(task.task_id, name="单项目替换", note="updated")
assert renamed.updated_utc > task.updated_utc
store.soft_delete_task(task.task_id)
assert store.list_tasks(TaskStatus.DELETED)[0].task_id == task.task_id
store.restore_task(task.task_id)
```
Add tests for unique nonblank names, running-task deletion rejection, rule add/edit/delete/reorder/enable, project upsert with selection preservation, unavailable rescan records, state transitions, transaction rollback, schema reopening, and crash recovery of `capturing_*`/`verifying` to a paused task plus failed project with an interruption error.
- [ ] **Step 2: Run the focused tests and verify RED**
Run:
```powershell
$env:PYTHONPATH=(Resolve-Path 'src').Path
py -3.12 -m pytest tests/trial_task_center/test_store.py -q
```
Expected: collection/import failure because the package does not exist.
- [ ] **Step 3: Implement immutable records and stable errors**
Use frozen slotted dataclasses. `TaskCenterError` contains `code`, `message`, and a generated `error_id` with the format `DXT-YYYYMMDD-<8 uppercase hex characters>`. Keep user text separate from traceback detail.
- [ ] **Step 4: Implement SQLite schema version 1 and CRUD**
Create `tasks`, `rules`, `projects`, and `metadata` tables with foreign keys enabled, explicit ordered rule positions, canonical unique project paths per task, UTC ISO timestamps, and transaction-scoped writes. Public methods return records rather than SQLite rows. Provide at least:
```python
create_task(name: str, note: str = "") -> TaskRecord
get_task(task_id: str) -> TaskRecord
list_tasks(status: TaskStatus | None = None) -> tuple[TaskRecord, ...]
update_task(task_id: str, *, name: str, note: str) -> TaskRecord
soft_delete_task(task_id: str) -> TaskRecord
restore_task(task_id: str) -> TaskRecord
add_rule(task_id: str, old_part_number: str, new_part_number: str) -> RuleRecord
update_rule(rule_id: str, *, old_part_number: str, new_part_number: str, enabled: bool) -> RuleRecord
delete_rule(rule_id: str) -> None
move_rule(rule_id: str, offset: int) -> tuple[RuleRecord, ...]
list_rules(task_id: str) -> tuple[RuleRecord, ...]
sync_projects(task_id: str, discovery_root: Path, paths: Sequence[Path]) -> tuple[ProjectRecord, ...]
set_project_selected(project_id: str, selected: bool) -> ProjectRecord
set_project_status(project_id: str, status: ProjectStatus, *, error_id: str | None = None, summary: str = "") -> ProjectRecord
list_projects(task_id: str) -> tuple[ProjectRecord, ...]
recover_interrupted_work() -> tuple[str, ...]
```
Validate the complete enabled rule set after each rule mutation by adapting `parse_mapping_bytes`; roll back a mutation that creates a duplicate source, self-map, chain, or cycle.
- [ ] **Step 5: Write logging tests and verify RED**
Tests must assert a 5 MiB rotating UTF-8 application log with five backups, structured task-event keys, flush-before-return, traceback capture, stdout/stderr capture helper behavior, and a thread exception reaching `application.log` with its error ID.
- [ ] **Step 6: Implement logging before UI construction**
`configure_logging` creates paths and handlers without importing Qt. `install_exception_hooks` installs `sys.excepthook` and `threading.excepthook`. `append_task_event` appends canonical one-line JSON using `os.fsync` and keys:
```text
sequence,timestamp_utc,level,task_id,project_id,operation,
state_before,state_after,error_id,message,details
```
- [ ] **Step 7: Run focused tests**
Run:
```powershell
$env:PYTHONPATH=(Resolve-Path 'src').Path
py -3.12 -m pytest tests/trial_task_center/test_store.py tests/trial_task_center/test_logging_setup.py -q
```
Expected: all pass.
- [ ] **Step 8: Commit Task 1**
```powershell
git add src/dx_productivity/trial_task_center tests/trial_task_center/test_store.py tests/trial_task_center/test_logging_setup.py
git commit -m "feat: add trial task storage and diagnostics"
```
---
### Task 2: Project Scanning, Probe Evidence, and Replacement Comparison
**Files:**
- Create: `src/dx_productivity/trial_task_center/scanner.py`
- Create: `src/dx_productivity/trial_task_center/evidence.py`
- Create: `src/dx_productivity/trial_task_center/comparison.py`
- Create: `tests/trial_task_center/test_scanner.py`
- Create: `tests/trial_task_center/test_evidence.py`
- Create: `tests/trial_task_center/test_comparison.py`
- Create: `tests/fixtures/trial_task_center/profile-before.json`
- Create: `tests/fixtures/trial_task_center/profile-after-valid.json`
- Create: `tests/fixtures/trial_task_center/profile-after-invalid.json`
**Interfaces:**
- Consumes: `MappingRule` from `dx_productivity.part_replace.models` and project identity rules from existing input helpers.
- Produces: `scan_projects(root: Path) -> tuple[Path, ...]`.
- Produces: `ProbeStamp`, `CapturedProfile`, `profile_stamp`, and `capture_profile`.
- Produces: `ComparisonIssue`, `ProjectComparison`, `compare_profiles`.
- No Qt, SQLite, or design mutation.
- [ ] **Step 1: Write scanner tests and verify RED**
Tests cover recursive case-insensitive `.prj` discovery, canonical deterministic ordering, duplicate path identities, nonexistent/not-directory roots, inaccessible subtrees as explicit errors, and no filesystem writes.
- [ ] **Step 2: Implement the scanner adapter**
Reuse `discover_projects(root, (".prj",))`. Convert `InputError` into `TaskCenterError` without discarding its stable code. Never select newly discovered projects automatically.
- [ ] **Step 3: Write evidence tests and verify RED**
Require these signatures:
```python
@dataclass(frozen=True, slots=True)
class ProbeStamp:
size: int
modified_ns: int
sha256: str
@dataclass(frozen=True, slots=True)
class CapturedProfile:
source: Path
destination: Path
stamp: ProbeStamp
project_identity: str
data: Mapping[str, object]
def profile_stamp(path: Path) -> ProbeStamp | None: ...
def capture_profile(source: Path, destination: Path, expected_project: Path,
previous: ProbeStamp | None) -> CapturedProfile: ...
```
Tests reject missing, unchanged, corrupt, duplicate-key, wrong-version, and wrong-project profiles. Accept only a profile whose bytes or timestamp changed and whose canonical identity matches. Assert atomic destination publication and exact SHA-256.
- [ ] **Step 4: Implement evidence capture**
Open and hash one stable byte snapshot, parse JSON with duplicate-key rejection, require `format_version == 1`, require `project.identity` string equality after Windows canonicalization, and write the accepted bytes atomically. Do not delete or rename the source menu-probe file.
- [ ] **Step 5: Write comparison tests and verify RED**
Require:
```python
def compare_profiles(
before: Mapping[str, object],
after: Mapping[str, object],
rules: Sequence[MappingRule],
) -> ProjectComparison: ...
```
`ProjectComparison` includes `passed`, matched logical identities per rule, warnings, hard issues, and canonical JSON serialization. Tests cover representative material numbers, no-match warnings, two rules, existing target parts, target mismatch, missing/duplicate logical identity, changed RefDes/hierarchy/unit count/origin/position/rotation/mirror/pins/nets, unrelated changes, and unsupported parameter-presentation capability warnings.
- [ ] **Step 6: Implement strict profile comparison**
Build unique maps by `logical_identity`. Match before Part Numbers with trimmed case-insensitive comparison while preserving exact display strings. For each matched identity, require the after Part Number to match the rule target and compare all trusted protected fields. Compare unrelated components after removing expected Part Number changes. Record `Part Label`, `Value`, and `parameter_probe` differences only as evidence/warnings in this release; never write them.
- [ ] **Step 7: Run Task 2 tests**
```powershell
$env:PYTHONPATH=(Resolve-Path 'src').Path
py -3.12 -m pytest tests/trial_task_center/test_scanner.py tests/trial_task_center/test_evidence.py tests/trial_task_center/test_comparison.py -q
```
Expected: all pass.
- [ ] **Step 8: Commit Task 2**
```powershell
git add src/dx_productivity/trial_task_center tests/trial_task_center tests/fixtures/trial_task_center
git commit -m "feat: compare trial replacement evidence"
```
---
### Task 3: Trial Runner and Application Service
**Files:**
- Create: `src/dx_productivity/trial_task_center/runner.py`
- Create: `src/dx_productivity/trial_task_center/service.py`
- Create: `tests/trial_task_center/test_runner.py`
- Create: `tests/trial_task_center/test_service.py`
**Interfaces:**
- Consumes: Task 1 store/logging and Task 2 scanner/evidence/comparison.
- Produces: `OperatorInstruction`, `RunnerSnapshot`, `TrialRunner`, and `TaskCenterService`.
- Produces synchronous methods designed to be called from a Qt worker; no Qt import.
- [ ] **Step 1: Write runner state-machine tests and verify RED**
Require the exact action methods:
```python
start_task(task_id: str, *, disposable_copy_confirmed: bool) -> RunnerSnapshot
capture_before(task_id: str, project_id: str, probe_path: Path) -> RunnerSnapshot
confirm_native_attempt(task_id: str, project_id: str) -> RunnerSnapshot
capture_after(task_id: str, project_id: str, probe_path: Path) -> RunnerSnapshot
pause_task(task_id: str) -> RunnerSnapshot
resume_task(task_id: str) -> RunnerSnapshot
retry_project(task_id: str, project_id: str) -> RunnerSnapshot
skip_project(task_id: str, project_id: str) -> RunnerSnapshot
snapshot(task_id: str) -> RunnerSnapshot
```
Tests cover start gates, exact first selected project, before capture, operator instructions containing project and every matching old/new rule, after capture, verifying transition, passed project completion, automatic next-project selection, task completion, hard comparison failure, pause-before-next behavior, resume, retry with new attempt evidence paths, skip, and process-restart recovery.
- [ ] **Step 2: Implement the runner**
The runner writes a task event before and after every durable state change. It uses per-attempt evidence directories and never overwrites prior profiles. `confirm_native_attempt` records an operator assertion but cannot mark success. `capture_after` is the only route to comparison and project completion.
- [ ] **Step 3: Write service tests and verify RED**
Test task CRUD delegation, directory scan preserving prior selection, project select-all/clear, rule validation errors, current instruction, log tailing, and opening evidence paths without actually launching Explorer in tests.
- [ ] **Step 4: Implement `TaskCenterService`**
The service is the only interface the UI uses. It converts domain exceptions into `TaskCenterError`, logs every operation, and exposes tuple snapshots safe for worker-to-UI transfer. Inject path opener and clock dependencies for tests.
- [ ] **Step 5: Run Tasks 1-3 tests and existing input/profile tests**
```powershell
$env:PYTHONPATH=(Resolve-Path 'src').Path
py -3.12 -m pytest tests/trial_task_center tests/part_replace/test_inputs.py tests/integration/test_part_replace_probe.py -q
```
Expected: all pass.
- [ ] **Step 6: Commit Task 3**
```powershell
git add src/dx_productivity/trial_task_center/runner.py src/dx_productivity/trial_task_center/service.py tests/trial_task_center
git commit -m "feat: orchestrate trial replacement tasks"
```
---
### Task 4: PySide6 Task Center UI
**Files:**
- Modify: `pyproject.toml`
- Create: `src/dx_productivity/trial_task_center/ui/__init__.py`
- Create: `src/dx_productivity/trial_task_center/ui/styles.py`
- Create: `src/dx_productivity/trial_task_center/ui/workers.py`
- Create: `src/dx_productivity/trial_task_center/ui/task_list.py`
- Create: `src/dx_productivity/trial_task_center/ui/project_table.py`
- Create: `src/dx_productivity/trial_task_center/ui/mapping_table.py`
- Create: `src/dx_productivity/trial_task_center/ui/run_panel.py`
- Create: `src/dx_productivity/trial_task_center/ui/main_window.py`
- Create: `tests/ui/test_trial_task_center_window.py`
- Create: `tests/ui/test_trial_task_center_workflow.py`
**Interfaces:**
- Consumes: `TaskCenterService` only; widgets do not import SQLite, profile JSON, or DxDesigner modules.
- Produces: `TrialTaskCenterWindow(service: TaskCenterService)`.
- All filesystem scans and evidence operations execute through `QThreadPool`; no UI-thread blocking.
- [ ] **Step 1: Add runtime and development dependencies**
Set project dependencies and extras without loosening Python 3.12:
```toml
dependencies = ["PySide6>=6.7,<7"]
dev = [
"pytest>=8,<9", "pytest-cov>=5,<7", "coverage>=7,<8",
"build>=1.2,<2", "pytest-qt>=4.4,<5", "PyInstaller>=6.10,<7"
]
```
Add script:
```toml
dx-part-replace-gui = "dx_productivity.trial_task_center.application:main"
```
- [ ] **Step 2: Write shell and CRUD interaction tests and verify RED**
With `QT_QPA_PLATFORM=offscreen`, assert minimum size 1100x700, Active/Completed/Deleted task filters, task create/edit/delete/restore, native directory-picker injection, scan button busy state, project Select All/Clear, mapping add/edit/delete/reorder, disabled Start gates, and stable object names for UI automation.
- [ ] **Step 3: Implement restrained styles and reusable async workers**
Use semantic colors for canvas, surface, border, primary/secondary text, accent, success, warning, danger, and focus. Use 6 px or smaller control radii, 13 px default text, fixed 30-34 px command heights, native/Qt standard icons where available, and tooltips for icon-only actions. Do not use gradients, decorative cards, animation, or viewport-scaled fonts.
`workers.py` wraps callables in `QRunnable` and emits success/error/finished signals. Every error reaches logging and restores disabled controls.
- [ ] **Step 4: Implement task navigation and workspace tables**
The left pane is a task list, not cards. The main pane uses a directory toolbar, `QTableView` project model, mapping table, operator instruction band, action toolbar, and read-only log dock. Use stable column widths plus stretch for paths so text does not overlap. Completed projects disappear from the Pending filter and remain visible through All/Completed.
- [ ] **Step 5: Implement dialogs and run actions**
Task and rule edits use focused modal dialogs with validation messages. Start requires a disposable-copy confirmation dialog naming the selected project count. Capture Before/After shows the expected menu-probe path and calls the service in a worker. Errors show Chinese summary plus stable error ID and buttons to open log/evidence locations.
- [ ] **Step 6: Run UI tests**
```powershell
$env:PYTHONPATH=(Resolve-Path 'src').Path
$env:QT_QPA_PLATFORM='offscreen'
py -3.12 -m pytest tests/ui/test_trial_task_center_window.py tests/ui/test_trial_task_center_workflow.py -q
```
Expected: all pass without Qt warnings or worker leaks.
- [ ] **Step 7: Capture visual QA screenshots**
Render populated Active and Completed states at 1100x700 and 1440x900 into `.superpowers/visual-qa/trial-task-center/`. Inspect for clipping, overlapping controls, unreadable paths, broken icons, hidden required actions, and one-note color use. Iterate until all four images pass.
- [ ] **Step 8: Commit Task 4**
```powershell
git add pyproject.toml src/dx_productivity/trial_task_center/ui tests/ui
git commit -m "feat: add replacement task center UI"
```
---
### Task 5: Application Bootstrap, PyInstaller EXE, and Trial Guide
**Files:**
- Create: `src/dx_productivity/trial_task_center/application.py`
- Create: `packaging/DxPartReplace.spec`
- Create: `packaging/Build-DxPartReplace.ps1`
- Create: `tests/trial_task_center/test_application.py`
- Create: `tests/packaging/test_dx_part_replace_build.py`
- Create: `docs/user/trial-task-center.md`
**Interfaces:**
- Consumes: logging, store, service, and `TrialTaskCenterWindow`.
- Produces: `main(argv: Sequence[str] | None = None) -> int` and `dist/DxPartReplace/DxPartReplace.exe`.
- Supports `DX_TASK_CENTER_HOME` only as an explicit test/deployment override; default is `%LOCALAPPDATA%\DxProductivity\trial-task-center`.
- [ ] **Step 1: Write bootstrap tests and verify RED**
Tests assert logging is configured before constructing `QApplication`, interrupted work recovery is logged, a second-instance database open remains safe, `--smoke-test` opens and closes through a zero-delay Qt timer, and fatal startup exceptions write a traceback and return a nonzero exit code.
- [ ] **Step 2: Implement application bootstrap**
Parse only `--smoke-test` and `--data-root`. Resolve application paths, configure logging and exception hooks, recover interrupted records, construct store/service/window, and run Qt. Log process version, executable, OS, data root, database, and log paths before window construction.
- [ ] **Step 3: Write the packaging spec and build script**
The spec names the executable `DxPartReplace`, uses windowed mode, collects PySide6 plugins, and bundles no user task database or live evidence. `Build-DxPartReplace.ps1` resolves the repository root, runs focused tests, removes only the explicit repository-local `build\DxPartReplace` and `dist\DxPartReplace` targets after verifying their resolved paths, invokes PyInstaller, and prints the absolute EXE and log locations.
- [ ] **Step 4: Add packaging smoke tests**
Static tests validate spec/script paths and safety guards. The built-artifact smoke test launches:
```powershell
$env:DX_TASK_CENTER_HOME=<temporary absolute directory>
dist\DxPartReplace\DxPartReplace.exe --smoke-test
```
Assert exit code 0, `logs\application.log` exists and contains startup and clean shutdown, and no files are written outside the temporary data root except normal OS/Qt runtime activity.
- [ ] **Step 5: Write the Chinese trial guide**
Document EXE launch, data/log paths, creating one task, scanning/selecting one disposable `.prj`, adding `4300-CA2260-A300`-style mappings, Capture Before, the exact manual DxDesigner Find/Replace Part/Library Wins steps, Capture After, Completed/Failed behavior, retry, and which files to return for diagnosis. State clearly that no automatic `Value`/style write or save occurs.
- [ ] **Step 6: Run the complete test suite**
```powershell
$env:PYTHONPATH=(Resolve-Path 'src').Path
$env:QT_QPA_PLATFORM='offscreen'
py -3.12 -m pytest -q
```
Expected: all tests pass.
- [ ] **Step 7: Build and smoke-test the EXE**
```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File packaging\Build-DxPartReplace.ps1
```
Expected: exit code 0 and a working `dist\DxPartReplace\DxPartReplace.exe`.
- [ ] **Step 8: Perform final review and commit**
Review the full diff against the spec, resolve all blocking findings, then:
```powershell
git add src/dx_productivity/trial_task_center packaging tests docs/user/trial-task-center.md pyproject.toml
git commit -m "build: package replacement trial task center"
```
@@ -0,0 +1,11 @@
# Value options and serial execution implementation
Approved semantics: unchecked preserves the native target Value without creating a missing attribute; checked copies the verified target Part Number into Value. Existing Value display styling is inherited in both modes. Old in-flight queues must not silently adopt a different policy.
Work only in the isolated candidate. Do not commit, rebuild, attach to CAD, or write to the concurrently edited original project.
1. Add failing tests for default-off task settings, SQLite persistence, explicit queue policy, and rejection of a different completed job. Implement models/store/service and quick_run, using a versioned value_mode column and a pinned job argument.
2. Add real VBS routine tests with fake components: preserve content and style, missing Value remains missing, checked content plus style, bad readback, and changed policy on resume. Implement metadata policy binding, restoration and final verification. Native snapshot parsing accepts validated new metadata while retaining read-only legacy parsing.
3. Wire a task-scoped checkbox and confirmation text. Freeze settings once a queue has evidence. Keep one worker/one queue item and require the expected job before writing and on receipt; do not add automatic open/save/close.
4. Add mouse-drag, settings persistence, and checkbox UI tests. Widen splitter handles, make logs collapsible, reduce table minima, persist layout/header state to the task-center data root, and add layout reset.
5. Run targeted tests, then UI/task-center/integration regression suites using external temp paths and no bytecode/cache. Create a unified patch and a baseline hash manifest for review, not an automatic overwrite script. Document remaining real CAD acceptance and concurrent merge boundaries.
@@ -0,0 +1,525 @@
# DxDesigner 7.9.5 Multi-Project Part Replacement Tool
Date: 2026-09-01
## 1. Purpose
Build the part-replacement module of the Dx Productivity suite for
DxDesigner/Expedition Enterprise 7.9.5. The module applies one set of
old-Part-Number to new-Part-Number rules across an explicit list of projects,
uses the native Replace Part workflow to obtain all new part data from the
central library, and verifies every changed project before it can be saved.
This is a true library part replacement. It is not a Part Number property edit,
an attribute annotation workflow, an ASCII design-file rewrite, or automatic
schematic rewiring.
Version 1 is intentionally semi-automatic. The tool prepares each replacement
group and verifies it, while an operator confirms the native Replace Part dialog
once for every project/mapping pair that has matches and confirms each project
once before save.
## 2. Compatibility Baseline
DxDesigner/Expedition Enterprise 7.9.5 is the only supported schematic
integration baseline. Compatibility with newer Siemens releases is not implied.
The module reuses the architecture approved for the Dx Productivity suite:
- one startup-imported `MenuAdd.vbs` entry point;
- all DxDesigner API access inside the internal VBScript host;
- UTF-8 snapshot, command, result, and status files between VBScript and Python;
- Python 3.12 for orchestration, validation, state, and reports;
- user-level path resolution through `DXTOOLS_HOME`;
- ASCII-only VBScript source; and
- preview, backup, stale-state checks, post-change verification, and recovery.
Python must not instantiate or attach to `ViewDraw.Application`. UI-coordinate
automation, `SendKeys`, and blind timing delays are prohibited.
The current repository contains the approved suite design but not an implemented
shared runtime. This module therefore creates only the minimum shared bridge and
run-storage foundations it needs. It does not implement the automatic reference
designator UI or other planned productivity modules.
## 3. Evidence and Route Choice
DxDesigner 7.9.x exposes the native `Edit -> Replace Symbol` workflow with
`Replace part`, a target selected through DxDataBook, and a library-precedence
choice. Community examples also show the automation method
`Block.ChangeComponentPreserveRefdes` and the command-line operation
`ccomp :component_name`.
The public evidence does not establish that either scripted operation is
equivalent to native Replace Part with Library Wins. Users have reported symbol
origin problems and Packager failures with `ChangeComponentPreserveRefdes`, and
a Siemens employee recommended `ccomp` as a manual workaround for that class of
failure. Therefore:
- native Replace Part with Library Wins is the version-1 production write path;
- `ccomp` is a compatibility-probe candidate for a later automation level;
- `ChangeComponentPreserveRefdes` is not a production write path in version 1;
- Databook annotation may help locate parts but is not a replacement mechanism;
and
- exported design files are never edited directly.
Research references:
- <https://community.sw.siemens.com/s/question/0D5Vb00001Tb2wMKAR/how-to-implement-part-replace-by-script-in-dxdesigner>
- <https://community.sw.siemens.com/s/question/0D5Vb00000ojyRYKAY/i-want-to-rearrange-the-selected-symbol-in-its-original-position-while-retaining-the-old-refdes-however-using-the-method-of-blockchangecomponentpreserverefdes-the-package-fails>
No maintained, downloadable open-source tool implementing this full 7.9.5
workflow was found during the design research. A live target-system probe remains
mandatory because community examples do not define a stable automation contract.
## 4. Version-1 Scope
### 4.1 Included
- Import a UTF-8 CSV mapping containing old and new Part Numbers.
- Import an explicit project list and optionally discover candidate projects
beneath a selected root using the extension allowlist in the verified 7.9.5
compatibility profile.
- Inventory every selected project before any project is modified.
- Show a project-by-mapping impact matrix and blocking issues.
- Apply the same enabled mapping set to every enabled project.
- Replace all matching logical components in a multi-project job.
- Support full-project, current-sheet, and selected-component scope for a
single-project job. Multi-project jobs use full-project scope only.
- Obtain the target part, symbol, pins, and library-controlled properties from
the central library through native Replace Part with Library Wins.
- Preserve and verify protected instance state.
- Back up, verify, save, report, resume, and recover at project granularity.
- Produce versioned JSON data plus operator-oriented CSV and static HTML reports.
### 4.2 Excluded
- Automatic rerouting or creation of schematic wires.
- Automatic acceptance of pin-count, pin-number, gate, origin, or pin-coordinate
incompatibility.
- Fully unattended dialog control.
- Direct SQL or file-level mutation of the central library.
- Inferring a target part from description, value, manufacturer, or AI output.
- Replacing a part by independently copying individual properties.
- Automatic correction of Packager, ERC, or netlist errors.
- AI approval of a save operation.
- A full PySide graphical application.
## 5. Inputs and Identity Rules
### 5.1 Replacement Mapping
The input file has exactly these required columns:
```csv
old_part_number,new_part_number
OLD-001,NEW-001
OLD-002,NEW-002
```
Part Number is the unique central-library key supplied by the user. The tool
trims surrounding whitespace, preserves the displayed spelling, and performs
case-insensitive identity comparisons. It rejects:
- blank old or new values;
- duplicate old values, including case-only duplicates;
- a rule whose old and new values are equal;
- chains such as `A -> B` and `B -> C`; and
- cycles such as `A -> B` and `B -> A`.
Rejecting chains and cycles prevents a newly replaced part from becoming input
to a later rule in the same job. Version 1 does not accept component names,
symbol names, attributes, or pin data in the replacement mapping. Those values
come from the project and the central library.
### 5.2 Project List
`projects.txt` contains one absolute project-definition path per line. Paths are
canonicalized without changing their on-disk case. Duplicate paths, missing
paths, nested duplicate discoveries, and unsupported project markers are
reported before inventory.
Root discovery is a convenience that produces a candidate `projects.txt`; it
does not silently add projects to a job. The operator reviews and confirms the
discovered list before inventory.
Each project receives a stable job-local ID derived from its canonical path and
an explicit display name. Reports never rely on a short project name as a unique
identifier.
## 6. Architecture
### 6.1 Batch Controller
The Python batch controller owns immutable job configuration, project queue
state, mapping validation, snapshot comparison, compatibility certifications,
status transitions, and report generation. It communicates only through the
versioned file protocol and never calls DxDesigner COM.
The first release exposes a command-line interface and a PowerShell launcher.
It may use standard file/folder pickers for input selection, but the underlying
job is fully reproducible from mapping, project-list, and job-directory paths.
### 6.2 Internal VBScript Bridge
The bridge runs inside the active DxDesigner 7.9.5 process. It owns:
- active-project identity and dirty-state checks;
- component enumeration and snapshot export;
- logical-component selection;
- the verified route for opening native Replace Part when available;
- monitoring for completion by observing design state rather than window text;
- Undo, save, close, and project-open operations only when separately verified;
and
- result and diagnostic publication back to the job directory.
The bridge never interprets replacement policy. It executes explicit commands
whose expected current state is included in the command file.
### 6.3 Native Replace Part Adapter
For each enabled mapping with matches, the adapter selects every matching
logical component in the approved scope and displays the exact target Part
Number and expected instance count.
If the compatibility probe proves a stable internal route, the bridge opens the
native Replace Part dialog. Otherwise it pauses after selection and instructs
the operator to invoke `Edit -> Replace Symbol`, choose `Replace part`, locate
the exact new Part Number through DxDataBook, and select Library Wins. This
manual-menu fallback is a supported version-1 route.
The tool does not automate target selection inside the dialog. When the dialog
closes, the bridge exports a new snapshot; Python determines whether the correct
target and count were applied.
### 6.4 Project Navigation Adapter
If the probe proves reliable project open/close APIs or commands, the bridge may
advance the queue automatically. Otherwise the baseline route displays the
canonical path of the next project and waits for the operator to open it.
In both routes, processing starts only after the active-project identity exactly
matches the queued project. Automatic project navigation is an optimization,
not a release requirement.
### 6.5 Run Store and Reports
Every batch receives a new run directory under the configured user-local run
root. It contains:
- an immutable copy of the accepted mapping and project list;
- `job.json` with schema version and configuration;
- per-project inventory and before/after snapshots;
- atomic command, result, and status mailboxes;
- backup manifests and content hashes;
- an append-only event log;
- a project-by-mapping impact CSV;
- detailed component and attribute difference CSV/JSON; and
- a static local HTML summary with no executable remote content.
Files use UTF-8 and atomic same-directory publication. VBScript uses
`ADODB.Stream` for encoding and never assumes an ANSI code page.
## 7. Inventory Phase
Inventory is a separate, read-only pass over all enabled projects. No Apply
action is available until every enabled project is inventoried or explicitly
excluded.
For each project, the bridge requires a saved, non-dirty active design and
exports:
- canonical project identity and design hierarchy;
- logical-component identity and every placed unit;
- Part Number and RefDes;
- sheet path, symbol identity, gate/slot identity;
- origin, position, rotation, and mirror state;
- visible and hidden instance attributes;
- pin numbers, pin names, pin positions, and pin-to-net identity; and
- a hashable project-state fingerprint.
The exact API names are supplied by the compatibility profile produced by the
probe. If the bridge cannot obtain unambiguous logical-component identity,
protected placement state, or pin/network state, that component is blocking and
cannot be replaced.
The batch controller then produces the complete impact matrix. Each cell records
the number of logical components and placed units matching a rule. It separately
reports no-match rules, stale or missing Part Numbers, duplicate RefDes values,
multi-unit parts, and data that cannot be verified.
## 8. Compatibility Certification
Automatic eligibility is limited to old/new pairs that have been certified as
interface compatible against the current central-library state.
Because the 7.9.5 public automation interface may not expose complete target
library geometry before placement, the baseline certification route is a trial
replacement in a disposable full project copy:
1. Copy a representative closed project containing the old part.
2. Record its complete pre-change snapshot.
3. Perform one native Replace Part operation with Library Wins.
4. Record the post-change snapshot.
5. Verify the compatibility invariants in Section 10.
6. Run Packager and the available ERC/netlist checks.
7. Store a certification keyed by old Part Number, new Part Number, target
library identity/revision when exposed, and observed interface fingerprint.
If no stable library revision is exposed, the certification records the target
part fingerprint observed during the trial. Every production replacement must
match that fingerprint. A changed fingerprint invalidates the certification and
requires another trial.
An uncertified pair is never silently treated as compatible. The operator may
run the disposable certification flow or exclude the mapping; there is no
"continue anyway" override in version 1.
## 9. Apply Workflow
The production workflow for one project is:
1. Require the project to be saved and closed before backup.
2. Copy the complete project tree to the run backup area and create a file-size
and content-hash manifest.
3. Open or ask the operator to open the queued project.
4. Verify canonical identity and compare the current fingerprint with inventory.
5. Re-inventory and require review if the project is stale.
6. For each enabled mapping with matches, select the exact baseline objects and
show the target Part Number and expected count.
7. Open or ask the operator to open native Replace Part.
8. The operator chooses the exact new Part Number and Library Wins, then confirms
once for the selected group.
9. Export the post-operation snapshot and run immediate verification.
10. Continue only after the mapping is verified.
11. After all mappings pass, present the complete project difference summary.
12. Save only after the operator selects `Save and continue`.
13. Re-open or re-enumerate the saved project, verify the persisted result, and
mark the project complete before advancing the queue.
No individual component requires confirmation. The manual workload is one
native confirmation per project/mapping pair that has at least one match, plus
one project-level save confirmation.
## 10. Verification Rules
### 10.1 Hard Success Conditions
For every replaced logical component:
- the resulting Part Number equals the requested new Part Number;
- the number of matched and replaced logical components is exact;
- RefDes is unchanged;
- sheet and hierarchical ownership are unchanged;
- every placed unit remains present;
- origin, position, rotation, and mirror state are unchanged;
- gate/slot structure and pin-number set are unchanged;
- every pin position is unchanged in schematic coordinates;
- every `RefDes + pin number` resolves to the same net identity; and
- no unrelated logical component changed.
Comparison uses invariant numeric serialization and probe-established coordinate
tolerance. The tolerance accounts only for API serialization precision; it must
not conceal a visible or grid-significant movement.
Any added, removed, renamed, or reconnected pin is a failure. The tool never
creates, deletes, moves, or redraws wires to make a replacement pass.
### 10.2 Library and Attribute Semantics
The target symbol, part definition, pins, and library-controlled properties must
come from native Replace Part with Library Wins. Version 1 does not independently
write those fields.
Protected instance fields include RefDes, hierarchy, placement, rotation,
mirroring, unit assignment, and connectivity. A change to a protected field is
blocking.
All other attribute changes are recorded in the difference report. The live
probe documents how the site's 7.9.5 build and central library treat custom
instance attributes. Conflicting library-controlled attributes follow native
Library Wins behavior; the tool neither reconstructs old values nor overrides
the native result. The operator reviews these non-protected differences at the
project save gate.
### 10.3 Project-Level Checks
After component checks pass, the release workflow requires:
- Packager produces no new error attributable to the replacement;
- ERC produces no new relevant error;
- generated net connectivity is unchanged for protected pins; and
- the saved-project re-read matches the verified in-memory result.
When Packager, ERC, or netlist execution cannot be automated through a verified
7.9.5 route, the tool emits exact pending checks and keeps the project in
`awaiting_external_checks` rather than marking it complete.
## 11. Failure Handling and Recovery
### 11.1 State Machine
Each project moves through these durable states:
- `inventory_pending`
- `inventory_complete`
- `apply_pending`
- `applying`
- `awaiting_save_confirmation`
- `awaiting_external_checks`
- `verified_saved`
- `blocked`
Transitions are append-only events. A status file is a projection of the event
log, not the sole record of progress.
### 11.2 Wrong Target or Verification Failure
If the operator chooses the wrong target or any hard invariant fails, the bridge
stops the current project immediately. It attempts one native Undo only through
the verified route and then compares the complete restored snapshot with the
pre-operation snapshot.
If Undo is unavailable or restoration does not verify exactly, the project must
be closed without saving. The tool then verifies that the on-disk files still
match the pre-apply fingerprint. It does not continue using uncertain in-memory
state.
### 11.3 Backup Restore
Restore is explicit and project-granular. The target project must be closed, the
canonical target path must match the job record, and the backup manifest must
verify before any restore begins. The restore process first preserves the failed
on-disk tree in a recovery location, then copies the verified backup. It never
overwrites an open project or an unrelated directory.
### 11.4 Interruption and Resume
After cancellation, process failure, application crash, or reboot, the
controller resumes only from durable states. `verified_saved` projects are not
reprocessed. A project left in `applying`, `awaiting_save_confirmation`, or an
unknown state is re-inventoried and reconciled against its backup before any
further action.
One blocked project does not prevent the operator from continuing with other
projects. The final report preserves all blocked reasons and never represents a
partially completed batch as fully successful.
## 12. Operator Experience
The command-line flow uses concise numbered prompts and writes richer detail to
the HTML report. At all times it shows:
- current job and project;
- project position in the queue;
- current old and new Part Numbers;
- expected component count;
- whether native-dialog and project-navigation routes are automatic or manual;
- current verification state; and
- the next permitted action.
The target Part Number remains visible while the native dialog is open. Cancel
before a verified save leaves the current project unsaved and records the job as
interrupted.
## 13. AI Review Boundary
The JSON schemas are versioned so a future AI agent or independent review tool
can consume inventory, before/after differences, Packager/ERC results, and
operator decisions.
AI review is advisory. It writes a separate review artifact and cannot alter
the source snapshots, event log, hard verification result, save permission, or
backup. No AI recommendation can approve changed connectivity or an uncertified
part pair.
## 14. Compatibility Probe
Implementation begins with a read-mostly probe on a disposable project. The
probe records the exact 7.9.5 build and establishes one explicit route or the
documented manual fallback for:
- application version and active-project identity;
- full-design logical-component enumeration;
- Part Number, RefDes, hierarchy, unit, symbol, placement, attribute, pin, and
net access;
- selecting an exact set of logical components;
- opening native Replace Part;
- detecting that the dialog operation completed;
- native Undo and save;
- dirty-state detection;
- project open and close; and
- Packager, ERC, and netlist invocation or result capture.
Probe output is a machine-readable compatibility profile plus a human-readable
report. A missing optional automation route selects its manual fallback. Missing
unambiguous identity, snapshot, selection, or post-change verification routes is
a release blocker because those capabilities have no safe fallback.
## 15. Testing Strategy
### 15.1 Python Tests
Unit tests cover:
- UTF-8 CSV parsing and path handling, including spaces and Chinese characters;
- duplicate, equal, chained, and cyclic mappings;
- project discovery confirmation and canonical identity;
- impact-matrix counts;
- immutable snapshots and schema versioning;
- coordinate, attribute, pin, and network comparison;
- certification creation and invalidation;
- stale-state rejection;
- every valid and invalid state transition;
- interruption reconciliation and resume; and
- report generation from complete and partial batches.
### 15.2 Bridge and Integration Tests
VBScript helper tests run under `cscript`. Static tests prohibit direct Python
COM attachment, fixed drive paths, operation-wide error suppression, ANSI file
exchange, `SendKeys`, and write operations before backup and stale-state checks.
A mocked DxDesigner bridge exercises inventory, group selection, correct target,
wrong target, changed RefDes, changed placement, pin-count change, pin-position
change, net change, unrelated-object change, Undo success, Undo failure, save,
crash, and resume.
### 15.3 Live 7.9.5 Acceptance
Release acceptance uses a disposable copy of representative site projects and
at least:
- one compatible single-unit replacement;
- one compatible multi-unit replacement if multi-unit parts are in site scope;
- one different-origin replacement that must be rejected unless coordinates are
demonstrably unchanged;
- one pin-number or pin-count mismatch that must be blocked;
- one deliberately wrong target selection;
- one stale project changed after inventory;
- one successful Undo and one close-without-save recovery;
- a multi-project resume after interruption; and
- Packager, ERC, and netlist comparison on a saved successful project.
The acceptance record captures build number, Windows version, central-library
identity/revision or fingerprint, project fixtures, mappings, route profile,
date, tester, and evidence files. Compatibility is not claimed until every
required item passes with no unresolved blocker.
## 16. Release Criteria
Version 1 is ready for production use only when:
- all automated tests pass;
- the live 7.9.5 probe has produced a valid compatibility profile;
- all required live acceptance cases pass;
- every successful replacement preserves protected instance state and
connectivity;
- Packager, ERC, and netlist checks introduce no relevant regression;
- backup restore has been demonstrated on a disposable project;
- interruption resume has been demonstrated across multiple projects; and
- operator documentation states the exact manual steps for every selected
fallback route.
Until then, generated scripts and reports are evaluation artifacts and must be
used only on disposable project copies.
@@ -0,0 +1,306 @@
# DxDesigner 7.9.5 Automatic Reference Designator Tool
Date: 2026-09-01
## 1. Purpose
Build the first module of a maintainable DxDesigner 7.9.5 productivity suite: automatic reference designator assignment with preview, validation, safe write-back, and recovery.
The tool replaces the legacy workflow that copies selected reference designators to Excel, generates values manually, and pastes them back. Excel is not part of the new annotation workflow.
## 2. Compatibility Baseline
DxDesigner/Expedition Enterprise 7.9.5 is the only supported schematic integration baseline for this phase.
The installation and import flow must remain compatible with the method demonstrated by the supplied legacy tool:
1. The user opens DxDesigner 7.9.5.
2. The user opens `Settings -> Run at Startup`.
3. The user adds one `MenuAdd.vbs` file to the Scripts list.
4. After DxDesigner restarts, one `Dx Productivity` menu appears on the Sheet Menu Bar.
The integration must not require a newer Xpedition add-in framework, a copied DLL from another release, COM re-registration, or a project-format upgrade.
`MenuAdd.vbs` uses only interfaces already demonstrated in the legacy package:
- `Scripting.GetEnvVariable`
- `CommandBars("Sheet Menu Bar").Controls.Add`
- menu control captions and `OnAction`
- the 7.9.5 internal scripting host
The installer sets a user-level `DXTOOLS_HOME` environment variable. `MenuAdd.vbs` resolves every tool path through `Scripting.GetEnvVariable("DXTOOLS_HOME")`; it contains no `D:\NET_CHECK` or other fixed installation path. DxDesigner must be restarted after installation so its script host sees the new environment value.
## 3. Compatibility Probe
The first implementation milestone is a read-only 7.9.5 probe imported through the exact startup-script flow above. It must not change a schematic.
The probe verifies:
- the imported script can add and remove its own menu entries without duplication;
- a menu item can enter the internal VBS bridge and launch the configured Python executable;
- `ActiveView.Query(VDM_COMP, VD_SELECTED)` returns selected components;
- `Application.DesignComponents` enumerates the full design;
- component reference designator, sheet number, X/Y position, attributes, full path, and stable identity are readable;
- the bridge can hold component object references while the Python process is open;
- UTF-8 snapshot and result files can be exchanged through the user-local run directory.
The release menu action uses the first 7.9.5-native route proven by the probe. The permitted routes, in order, are:
1. a named bridge procedure in the imported startup VBS;
2. the 7.9.5 `Run` script action;
3. the proven `Form` action with a minimal 7.9.5 EFM launcher.
No unverified route is shipped. If the first two routes are unavailable, the launcher EFM is created or adapted using the 7.9.5 form format; it is not copied from a newer release.
## 4. Architecture
```text
DxDesigner 7.9.5
-> imported MenuAdd.vbs
-> internal VBS bridge
-> UTF-8 snapshot + in-memory component map
-> Python/PySide6 application
-> validated bridge_id/new_refdes result
-> VBS write-back and full-design verification
```
### 4.1 VBS integration layer
The VBS layer owns every DxDesigner COM/API call. It reads the current design, launches Python, waits for the result, revalidates the snapshot, applies changes, verifies the design, and rolls back on failure.
Python does not attach directly to `ViewDraw.Application`. This avoids 32-bit versus 64-bit COM registration and licensing incompatibilities between DxDesigner 7.9.5 and modern Python.
### 4.2 Python domain layer
The Python domain layer is independent of DxDesigner. It parses snapshots, groups components, computes deterministic annotation plans, validates collisions, and produces an immutable change set.
This layer has no GUI imports and can be exhaustively unit tested with fixtures.
### 4.3 Python UI layer
The desktop UI uses PySide6 and a local style sheet. It implements the approved three-column workbench:
- suite navigation on the left;
- annotation rules in the center;
- live old-to-new preview on the right.
The source remains runnable with the installed Python 3.12 environment. A later packaging step may produce a standalone executable, but packaging does not change the VBS bridge protocol.
## 5. Bridge Protocol
Each run uses a unique directory:
```text
%LOCALAPPDATA%\DxProductivity\runs\<run_id>\
request.json
result.tsv
apply-status.json
```
VBS writes `request.json` as UTF-8 using a deterministic JSON escaping helper. Python writes an ordered `result.tsv` apply schedule with five constrained fields: `sequence`, `bridge_id`, `expected_refdes`, `new_refdes`, and `final_refdes`. Tabs and line breaks are illegal in every result field.
Each sequence number is unique and contiguous from 1. A bridge ID normally appears once. It may appear twice only when a validated reannotation cycle requires a temporary placeholder step followed by the final assignment. VBS verifies `expected_refdes` immediately before every step and verifies `final_refdes` after the complete schedule.
Each snapshot component contains:
- ephemeral `bridge_id` assigned by the current VBS run;
- stable UID when exposed by 7.9.5;
- hierarchical full path as an identity fallback;
- sheet number and current-view membership;
- X and Y schematic coordinates;
- current reference designator;
- symbol-level default reference designator or prefix when available;
- selection state;
- part number and Value for preview;
- lock or protection state when exposed by 7.9.5.
VBS retains an in-memory `bridge_id -> component object` map while Python is open. Result rows never rely on COM enumeration order.
Before write-back, VBS confirms that the active design, component identity, component count in scope, and original reference designators still match the snapshot. A mismatch invalidates the plan and requires a refresh.
## 6. Annotation Behavior
### 6.1 Scope
The UI supports three explicit scopes:
- selected components, which is the default;
- current sheet;
- full design.
If the selected scope is empty, Apply remains disabled. The tool does not silently fall back to another scope.
### 6.2 Processing mode
The default mode fills only unannotated components:
- blank reference designators;
- placeholders matching a leading alphabetic prefix followed by one or more question marks, such as `R?`, `C??`, or `TP?`.
Existing formal reference designators are preserved. A separate, explicit mode reannotates every eligible component in scope.
### 6.3 Prefix resolution
Prefix resolution is deterministic:
1. use the alphabetic prefix in the current placeholder;
2. otherwise use the symbol-level default reference designator/prefix exposed by 7.9.5;
3. otherwise require an explicit prefix in the preview table.
An unresolved prefix is a blocking validation error. Prefix comparison is case-insensitive and output is normalized to uppercase.
### 6.4 Multi-unit components
All symbols that represent the same logical component are grouped by stable component identity. They receive one base reference designator. Symbol units or gates do not consume additional sequence numbers.
If 7.9.5 does not expose a stable UID, the compatibility adapter derives a stable grouping key from the hierarchical component path and validated component metadata. Ambiguous groups are blocked rather than guessed.
### 6.5 Sorting
The default order is:
1. numeric sheet number ascending;
2. schematic Y coordinate from top to bottom;
3. X coordinate from left to right within the same visual row;
4. stable identity as the final deterministic tie-breaker.
Because schematic Y-axis direction is API-dependent, the compatibility adapter normalizes coordinates so larger visual height always sorts first. Components are grouped into visual rows using a default 5 mm tolerance. The user can change the tolerance.
Alternative orders are available for left-to-right column scanning and reverse directions.
### 6.6 Numbering modes
Continuous mode is the default. Each prefix owns an independent sequence beginning at 1 unless the user changes the start value. Numbers already used anywhere outside the target set are skipped.
Page mode uses:
```text
number = numeric_sheet_number * page_step + page_start
```
The defaults are `page_step = 100` and `page_start = 1`, so sheet 3 starts at 301. Each prefix has an independent page sequence. Non-numeric sheet identifiers require an explicit numeric mapping before Apply.
### 6.7 Collision rules
Validation is case-insensitive and covers:
- duplicates inside the proposed change set;
- collisions with components outside the target set;
- illegal or empty prefixes;
- invalid numeric ranges;
- duplicate existing formal reference designators in the source design;
- multiple proposed values for one logical component.
Blocking issues disable Apply. Warnings remain selectable and can locate the affected schematic component.
## 7. Safe Apply and Recovery
Every Apply operation follows this sequence:
1. revalidate the snapshot against the active design;
2. run all collision and format checks again;
3. write a timestamped backup mapping under `%LOCALAPPDATA%\DxProductivity\backups`;
4. apply changes using the in-memory component map;
5. re-enumerate the full design and verify every expected reference designator;
6. write a machine-readable apply status and append an operation-history entry.
Fill-only plans normally write directly because they cannot swap existing formal identifiers.
Full reannotation plans are ordered as a dependency graph. Acyclic moves are applied first. Cycles use the component prefix placeholder, such as `R?`, as a temporary value, then complete the cycle. This uses a placeholder format already accepted by DxDesigner 7.9.5 instead of inventing a new temporary reference-designator syntax.
If any assignment or verification fails, VBS restores every component from the backup mapping and verifies the restoration. A rollback failure is reported prominently with the backup path and the exact remaining mismatch.
The operation-history view exposes Restore Last Annotation. Restore performs the same preflight, backup, apply, and verification sequence; it is not a blind file replay.
## 8. User Interface and Visual Acceptance
The approved mockup is the visual baseline. The release implementation follows these measurable requirements derived from Apple Human Interface Guidelines while remaining a Windows desktop application:
- 13 pt default content text and no essential text below 10 pt;
- approximately 28 by 28 pt default desktop controls and no interactive target below 20 by 20 pt;
- 16 px simplified line icons with consistent weight and optical alignment;
- tooltips and accessible names for icon-only controls;
- one semantic use per status color;
- text contrast of at least 4.5:1 for normal text;
- icons or text in addition to color for every status;
- light, dark, and increased-contrast-compatible palettes;
- complete keyboard navigation with visible focus;
- no clipping or overlap at 100%, 125%, and 150% Windows display scaling;
- a resizable window with a minimum supported content area of 1100 by 700 logical pixels;
- no required command placed only at the bottom edge of the window;
- no automatic, blinking, bouncing, or decorative motion.
Interface icons use a cross-platform icon set with Apple-like semantic consistency. Apple SF Symbols are a design reference only and are not redistributed in the Windows application.
Official design references:
- [Designing for macOS](https://developer.apple.com/design/human-interface-guidelines/designing-for-macos)
- [Layout](https://developer.apple.com/design/human-interface-guidelines/layout)
- [Typography](https://developer.apple.com/design/human-interface-guidelines/typography)
- [Color](https://developer.apple.com/design/human-interface-guidelines/color)
- [Accessibility](https://developer.apple.com/design/human-interface-guidelines/accessibility)
- [Icons](https://developer.apple.com/design/human-interface-guidelines/icons)
## 9. Error Handling
Errors are divided into three levels:
- blocking: Apply is disabled, for example duplicate output or missing prefix;
- warning: the plan remains applicable after review, for example a nonstandard existing designator outside scope;
- informational: no action required, for example a locked component preserved by policy.
The UI shows an icon, short message, affected component count, and location action. Technical details and bridge logs are available in a diagnostics view and retained per run. Normal users do not need to inspect raw JSON, TSV, COM error codes, or Python tracebacks.
If Python is missing or cannot start, the VBS bridge shows a concise message with the configured executable path and exits without changing the design.
## 10. Testing Strategy
### 10.1 Automated domain tests
Tests cover:
- placeholder recognition and prefix normalization;
- continuous and page numbering;
- occupied-number skipping;
- row tolerance and every sort direction;
- numeric and non-numeric sheet identifiers;
- multi-unit grouping;
- duplicate and collision detection;
- deterministic output for equal coordinates;
- reannotation dependency graphs and cycles;
- backup and restore plan generation.
### 10.2 Bridge contract tests
Pure VBS helpers are tested with `cscript` where possible. Tests cover UTF-8, JSON escaping, result parsing, invalid rows, duplicate or noncontiguous sequence numbers, unknown bridge IDs, illegal repeated bridge steps, stale snapshots, and simulated assignment failures.
Python contract tests use captured 7.9.5-compatible fixtures and never require a live DxDesigner instance.
### 10.3 UI tests
Qt tests cover default selections, scope changes, preview filtering, blocking-error behavior, keyboard tab order, light/dark themes, and Apply confirmation for full reannotation.
Screenshots are checked at representative 1100 by 700 and 1440 by 900 window sizes under 100%, 125%, and 150% scaling. Text, controls, and tables must not overlap or clip.
### 10.4 Live 7.9.5 acceptance
The user runs the compatibility probe and a sample-project acceptance checklist on the target DxDesigner 7.9.5 installation. Live acceptance covers startup-script import, menu creation, selected/current/full scopes, coordinate order, write-back, duplicate prevention, rollback, restoration, Chinese installation paths, and paths containing spaces.
No release is marked 7.9.5-compatible solely from mocked COM tests.
## 11. Deliverables for Phase One
- 7.9.5 compatibility probe;
- installer and uninstall instructions using startup-script import;
- `MenuAdd.vbs` and the verified 7.9.5 bridge adapter;
- Python source and dependency metadata;
- automatic reference designator GUI;
- annotation domain tests and bridge contract tests;
- live 7.9.5 acceptance checklist;
- user guide for installation, annotation, preview, Apply, and Restore.
## 12. Non-Goals
This phase does not implement Value/Value1/Part Number editing, attribute visibility, design audits, network navigation, BOM generation, BOM-to-schematic navigation, or Expedition PCB assembly text placement. Those modules reuse the verified bridge and shared application shell in later phase-specific designs.
This phase does not import code or binaries from newer Xpedition releases and does not modify the DxDesigner project format.
@@ -0,0 +1,237 @@
# DxDesigner 7.9.5 Parameter Presentation Transfer Design
## 1. Purpose
This document extends the existing DxDesigner 7.9.5 multi-project part
replacement design. The replacement remains a native `Replace Part` operation
with `Library Wins`, but it now has one controlled post-replacement step:
- copy the new symbol's exact `Part Label` value into the instance `Value`;
- preserve presentation metadata for parameters that existed on the old
instance and have an unambiguous same-name parameter on the new instance;
- never copy an old ordinary parameter value into the new instance.
The material identifier remains the `Part Number` attribute. Values such as
`4300-CA2260-A300` are examples, not a syntax restriction. Identity comparison
trims surrounding whitespace and is case-insensitive, while reports preserve
the original spelling.
This document supersedes only the attribute semantics, snapshot fields, Apply
steps, and verification rules described below. All existing requirements for
backup, native replacement, RefDes, placement, origin, units, pins,
connectivity, unrelated objects, recovery, evidence correlation, and
evaluation-only release status continue to apply.
## 2. Non-Goals
- Rebuilding a symbol or its pins through scripts.
- Copying old ordinary parameter values over new library values.
- Creating parameters that existed only on the old symbol.
- Reconnecting, moving, creating, or deleting wires.
- Using UI coordinates, `SendKeys`, or timing delays.
- Claiming an unsupported 7.9.5 property API without probe and live evidence.
## 3. Parameter Identity
Parameter names are normalized by trimming surrounding whitespace and applying
a case-insensitive comparison. The original name remains in evidence and
reports.
For each component and owner scope:
- one old and one new parameter with the same normalized name form an
unambiguous match;
- an old-only parameter is not recreated and is reported as removed;
- a new-only parameter keeps its new-library value and presentation defaults;
- duplicate normalized names on either side are ambiguous and receive no
automatic presentation transfer.
An ambiguous ordinary parameter creates a warning. An ambiguous `Part Label`
or `Value` prevents the mandatory `Value` operation and is therefore a hard
failure.
## 4. Trusted Pre-Replacement Capture
The bridge must capture and durably publish a complete trusted snapshot before
it selects components or opens native Replace Part. Capture occurs separately
for every matched logical component, every placed unit, and every existing
parameter instance. It may not be reconstructed from post-replacement state.
The controller must correlate this snapshot with the job, project, mapping,
command identifier, active-project identity, expected component count, and
current project fingerprint. If any matched component, unit, parameter value,
or required presentation field cannot be read unambiguously, the bridge stops
before replacement and reports the exact object and field.
Each parameter snapshot contains:
- original and normalized parameter name;
- current value, for reporting and rollback comparison only;
- logical component key and RefDes;
- owner scope and placed-unit identity, when the parameter is unit-owned;
- visible state;
- schematic text origin or position in invariant coordinates;
- rotation or orientation;
- horizontal and vertical justification or the equivalent alignment values;
- color;
- font family or style identifier when exposed;
- text size or height/width fields exposed by the certified route; and
- any additional stable presentation field explicitly named by the
compatibility profile.
The schema distinguishes component/unit placement coordinates from parameter
text coordinates. A parameter coordinate must never substitute for component
origin or component position evidence.
## 5. Apply Sequence
For one mapping group in one project, the bridge performs these ordered steps:
1. Validate the correlated command, active project, saved state, inventory
fingerprint, certification, and expected count.
2. Capture and durably publish the trusted pre-replacement component, unit,
pin, network, ordinary parameter, `Part Label`, and `Value` evidence.
3. Select exactly the logical components identified by the controller.
4. Invoke or request the native `Replace Part` dialog.
5. Require the exact target `Part Number` and `Library Wins`.
6. Observe native completion through the certified route or explicit manual
continuation; no blind delay is allowed.
7. Re-enumerate the replaced objects and verify their target identity.
8. Read the new symbol's exact `Part Label` value.
9. Write that exact value to the instance `Value` and read it back.
10. Transfer presentation metadata for unambiguous same-name parameters.
11. Export the post-transfer snapshot and a field-level transfer result.
12. Let Python run hard verification and produce warnings/differences.
No ordinary parameter value assignment is permitted in step 10. `Library
Wins` remains authoritative for ordinary parameter values.
## 6. Value Rule
`Value` is the only parameter whose value is written by the post-replacement
step.
- Source: the exact new-symbol `Part Label` value.
- Destination: the replaced instance's `Value` parameter.
- Comparison: exact string equality after the write; no case folding or
whitespace normalization changes the stored value.
- Presentation: inherit all certified presentation fields from the old
instance's `Value` when it existed unambiguously.
- Default presentation: when the old instance had no `Value`, retain the new
symbol's default `Value` presentation.
Missing, empty, ambiguous, unreadable, or unwritable `Part Label`; missing,
ambiguous, or unwritable `Value`; a write error; or a read-back mismatch is a
hard failure. The project cannot be saved and the existing verified Undo or
close-without-save recovery path is required.
Failure to copy only a `Value` presentation field is a warning, not a hard
failure, provided the exact `Value` content was written and read back.
## 7. Ordinary Parameter Presentation Transfer
For every unambiguous same-name ordinary parameter, the bridge attempts to
copy each presentation field from the trusted old snapshot to the new
parameter. Values remain those supplied by the new library.
Each failed field produces a `parameter_style_inheritance_failed` warning with
job, project, mapping, logical key, RefDes, unit or owner scope, parameter name,
field name, old presentation value, observed new value, API route, and error.
The warning does not trigger Undo and does not by itself block save.
The reports also distinguish:
- `parameter_removed_by_new_symbol`;
- `parameter_added_by_new_symbol`;
- `parameter_value_changed_by_library`;
- `parameter_name_ambiguous`; and
- successfully inherited presentation fields.
## 8. Verification and Recovery
Hard verification still requires the exact target `Part Number`, component
count, RefDes, hierarchy, unit set, component origin and position, rotation,
mirror state, pin-number set, pin coordinates, pin-to-net identity, and no
unrelated component changes.
It additionally requires:
- one nonempty, unambiguous new `Part Label` per replaced instance;
- exact `Value == Part Label` after the write and in the persisted reread; and
- no ordinary parameter value assignment performed by the transfer adapter.
Presentation warnings remain visible at the project save gate and in CSV, JSON,
and HTML reports. They do not override a hard verification result.
If any hard condition fails, Undo must be verified against the complete trusted
pre-replacement snapshot, including component/unit geometry, connectivity,
parameter values, and parameter presentation. If exact Undo cannot be proven,
the project must be closed without saving or restored from the verified backup.
## 9. Compatibility Profile
The read-mostly probe records the actual 7.9.5 routes and types for:
- enumerating parameter instances and their owner scope;
- reading `Part Label` and `Value`;
- writing and reading back `Value`;
- reading and writing each supported presentation field; and
- distinguishing component placement coordinates from parameter text
coordinates.
Production Apply is blocked unless the `Part Label` read route and `Value`
write/read-back routes are live-certified. An unavailable ordinary
presentation field disables only that field's automatic transfer and produces
an explicit warning/capability result.
The profile promotion evidence must identify the exact DxDesigner 7.9.5 build,
central-library identity or fingerprint, disposable fixture, mapping, route,
field type, observed before/after values, tester, date, and evidence hashes.
## 10. Protocol and Modules
The snapshot protocol advances to format version 3. Version 3 adds structured
parameter instances and presentation metadata. Version 1 lacks independent
component origin evidence and remains unsafe. Version 2 lacks parameter
presentation evidence and cannot authorize the new Apply workflow. Existing
version 1 or 2 jobs must be rejected with a stable re-inventory-required error;
they are never silently upgraded.
Responsibilities remain separated:
- Python domain/protocol modules define immutable parameter and presentation
evidence.
- A dedicated Python parameter-transfer policy module matches names, classifies
differences, and verifies results without accessing DxDesigner.
- A dedicated ASCII-only VBScript parameter-transfer adapter performs the
certified `Part Label`, `Value`, and presentation operations.
- The bridge coordinates selection, native replacement, adapter invocation,
and evidence publication, but does not decide warning or save policy.
- Controller/operator modules consume correlated results and preserve the
existing save and recovery gates.
## 11. Tests and Acceptance
Automated tests cover:
- representative material numbers such as `4300-CA2260-A300` without imposing
a fixed syntax;
- capture before selection or dialog invocation;
- multiple logical components, units, and parameter coordinate sets;
- case-insensitive trimmed name matching and ambiguous duplicates;
- old-only, new-only, hidden, and visible parameters;
- ordinary values remaining from the new library;
- each presentation field copied independently;
- field-level warning behavior and report contents;
- exact `Part Label -> Value` write/read-back;
- missing/empty/ambiguous fields and forced write failure causing Undo;
- persisted `Value` verification after save;
- exact Undo restoration of values and presentation; and
- real `cscript` execution through a fake object host without source-text-only
claims.
Live 7.9.5 acceptance uses disposable projects and records screenshots or
machine evidence for parameter positions, colors, sizes, orientation,
visibility, ordinary new-library values, exact `Value`, Undo, save, and
persisted reread. Until every required route and case passes, the package
remains evaluation-only.
@@ -0,0 +1,340 @@
# DxDesigner Part Replacement Trial Task Center Design
## 1. Purpose
Build a Windows desktop EXE that makes the current DxDesigner 7.9.5
replacement investigation usable on one disposable project first, while using
the same task, project, mapping, status, and evidence model needed for later
multi-project execution.
The application is a trial task center. It manages work, collects before/after
probe evidence, guides the operator through the native DxDesigner replacement,
verifies the observed result, advances successful projects to Completed, and
records every application and task error. It does not claim that the
uncertified production replacement path is ready.
## 2. Release Boundary
The first release is `evaluation-only` and may be used only with complete,
disposable project copies.
It does not:
- automate DxDesigner controls with window coordinates, `SendKeys`, or delays;
- bypass the existing production certification or compatibility-profile gates;
- save, reconnect, move, add, or delete schematic objects;
- write `Value` or parameter presentation fields;
- delete source projects when a task is deleted; or
- present a manually confirmed replacement as machine-verified success.
The operator still performs native `Replace Part` with `Library Wins` in
DxDesigner. The EXE makes that process repeatable, correlated, reviewable, and
ready for later replacement-adapter integration.
## 3. Technology and Packaging
- Python 3.12.
- PySide6 for the native Windows UI.
- SQLite from the Python standard library for mutable task drafts and status.
- Existing `dx_productivity.part_replace` discovery, validation, identity, and
verification helpers where their contracts fit the trial flow.
- Existing ASCII-only DxDesigner 7.9.5 menu probe for live evidence.
- Python logging plus append-only JSON Lines task events.
- PyInstaller `onedir` output containing `DxPartReplace.exe` and its runtime
files. A single-file build is deferred until the installed-machine behavior
is proven.
The executable must not require a separate Python installation. The DxDesigner
menu integration remains a separately installed site integration because it is
loaded by DxDesigner itself.
## 4. Storage
Mutable task-center data lives outside engineering projects:
```text
%LOCALAPPDATA%\DxProductivity\trial-task-center\
task-center.db
logs\application.log
tasks\<task-id>\
task.json
events.jsonl
logs\task.log
evidence\
<project-id>\before-profile.json
<project-id>\after-profile.json
<project-id>\comparison.json
```
`task-center.db` uses schema version 1 and stores tasks, mapping rules, scanned
projects, project selection, project state, timestamps, and the last error
identifier. All database writes use transactions. Evidence JSON is written
atomically and referenced by SHA-256 from `events.jsonl`.
Task deletion is a soft delete recorded by `deleted_at`. It hides the task from
the normal task list but keeps logs and evidence. A future retention tool may
purge archived records; the MVP never recursively deletes task or project
directories.
## 5. Domain Records
### Task
- immutable UUID task ID;
- editable unique nonblank name;
- optional note;
- selected discovery root;
- status: `draft`, `ready`, `running`, `paused`, `completed`, `failed`, or
`deleted`;
- created, updated, started, and completed UTC timestamps; and
- last error ID and summary.
The application supports task create, read/list, rename/edit, soft delete, and
restore. A running task cannot be deleted; it must be paused first.
### Mapping Rule
- immutable rule UUID;
- task ID;
- ordered position;
- old `Part Number`;
- new `Part Number`; and
- enabled flag.
Rules support create, read, edit, delete, and reorder. Validation reuses the
existing mapping semantics: trim surrounding whitespace, compare identities
case-insensitively, reject blanks, self-maps, duplicate sources, chains, and
cycles. Material numbers such as `4300-CA2260-A300` remain ordinary strings and
are not constrained by a format regular expression.
### Project
- stable project ID derived from the canonical project-definition path;
- task ID, display name, path, and discovery root;
- selected flag;
- state: `pending`, `capturing_before`, `awaiting_operator`,
`capturing_after`, `verifying`, `completed`, `failed`, or `skipped`;
- retry count; and
- last error ID and summary.
Rescanning updates candidates without silently selecting new projects or
removing prior evidence. Missing projects are visibly marked unavailable.
## 6. User Interface
The application opens directly into the task center, not a landing page.
### Task List
The left navigation contains Active, Completed, and Deleted views. It supports
create, rename/edit, open, soft delete, and restore. Active-task rows show a
compact progress count and the last updated time.
### Task Workspace
The main workspace contains:
- a directory path field and native directory picker;
- Scan and Rescan commands;
- a project table with selection checkboxes, Select All, Clear Selection,
project name, canonical path, state, last result, and retry command;
- an editable mapping table with Add, Edit, Delete, and reorder commands;
- Start, Pause, Resume, and Open Evidence Folder commands;
- a current-operator-action band containing the exact project, old/new part
number, expected count when known, and the next DxDesigner instruction; and
- a docked log view showing timestamp, level, project, operation, and message.
The UI remains work-focused: dense tables, restrained color, no decorative
cards, no nested cards, and no required control below the fold. Completed
projects leave the active queue immediately and remain accessible through the
Completed filter.
## 7. Trial Execution Flow
### 7.1 Validation
Start is enabled only when the task has at least one enabled valid mapping and
one selected available `.prj` project. The operator must confirm that every
selected project is a complete disposable copy. The confirmation is recorded
with timestamp and task ID; it does not waive any verification rule.
Only one project is active at a time. Remaining selected projects stay queued.
Pause prevents the next project from starting but does not interrupt a probe or
verification that is already being committed.
### 7.2 Before Capture
For the active project, the EXE records the current menu-probe file hash and
timestamp, then instructs the operator to:
1. open the exact project in DxDesigner 7.9.5;
2. save any unrelated edits;
3. run `Dx Productivity -> Part replacement probe`; and
4. return to the EXE and choose Capture Result.
The EXE accepts the profile only when it is newer or byte-different from the
recorded predecessor, parses as the expected profile version, and its canonical
`project.identity` exactly matches the selected project. It atomically copies
the bytes into task evidence before advancing.
The before profile is searched exclusively by the `Part Number` attribute. For
each enabled rule it records all matching logical identities and counts. A rule
with no matches is reported and skipped for that project; ambiguous or
unreadable identity/parameter evidence fails the project before replacement.
### 7.3 Native Replacement
The project moves to `awaiting_operator`. The UI shows one mapping at a time and
the exact identities/count found in the trusted before profile. The operator
uses DxDesigner Find, selects those components, invokes native Replace Part,
chooses the requested new part, and selects `Library Wins`.
The EXE does not click the dialog, infer completion from elapsed time, or alter
the schematic. The operator confirms only that the native action was attempted;
this confirmation is not success evidence.
After all matching rules have been attempted, the EXE instructs the operator to
run the read-only menu probe again and capture the result.
### 7.4 Verification
The after profile must pass the same freshness, schema, and project-identity
checks. For every logical identity matched before replacement:
- the after `Part Number` must equal the rule's new value using the normal
trimmed, case-insensitive identity comparison;
- no matched logical identity may disappear or become ambiguous;
- RefDes, hierarchy, placed-unit count, component origin/position, rotation,
mirror state, pin numbers, pin coordinates, and pin-to-net identity must be
unchanged wherever the probe supplied trusted evidence; and
- unrelated logical components must retain their observed identity and
protected fields.
The comparison records `Part Label`, `Value`, and parameter-presentation
capability differences but does not write them in this release. Missing or
unsupported presentation fields produce explicit capability warnings. A target
part mismatch or protected-invariant change is a failed project.
Only a machine comparison with no hard failures moves the project to
`completed`. The runner then automatically selects the next pending project.
When every selected project is completed or skipped, the task moves to
`completed`; any failed project keeps the task in `failed` until it is retried,
skipped explicitly, or removed from selection while paused.
## 8. Logging and Diagnostics
Logging starts before the main window is constructed.
### Application Log
`application.log` is UTF-8, rotated at 5 MiB, and keeps five backups. It records:
- process start, version, executable path, OS, and storage paths;
- database migration and recovery;
- UI command start/completion;
- scan roots and candidate counts;
- task/project/rule IDs and state transitions;
- probe source/destination hashes and validation outcomes;
- subprocess command, exit code, stdout, and stderr when a subprocess is used;
- handled exceptions with stable error IDs; and
- uncaught main-thread, worker-thread, Qt callback, and shutdown exceptions with
complete Python tracebacks.
### Task Evidence Log
Every meaningful task action appends one canonical JSON object to
`events.jsonl` containing sequence, UTC timestamp, level, task ID, project ID,
operation, state before/after, error ID, message, and structured details. The
append is flushed before the UI reports completion.
The visible error dialog contains a concise Chinese explanation, the stable
error ID, and actions to open the task log or evidence folder. Raw tracebacks
remain in logs rather than being shown as the primary UI message.
## 9. Failure and Recovery
- A scan failure leaves the previous project list intact and records the error.
- A database transaction failure does not update in-memory UI state as if it
succeeded.
- An invalid or stale probe file is rejected without consuming it.
- A crash during execution is reconstructed from SQLite state and append-only
events on the next start. `capturing_*` and `verifying` projects become
paused with an interruption error; the operator chooses retry.
- Retrying creates a new attempt number and never overwrites prior evidence.
- A failed comparison never marks a project completed and never automatically
saves or modifies the source project.
## 10. Module Boundaries
```text
src/dx_productivity/trial_task_center/
models.py immutable task/project/rule records and enums
store.py SQLite schema, transactions, CRUD, and recovery
scanner.py directory discovery adapter
evidence.py probe freshness, identity, hashing, and atomic copies
comparison.py before/after rule and invariant comparison
runner.py one-project-at-a-time state machine
logging_setup.py rotating logs, JSONL events, and exception hooks
application.py application bootstrap and resource paths
ui/
main_window.py task navigation and workspace shell
task_list.py task filters and CRUD actions
project_table.py scan results, selection, states, and retry
mapping_table.py mapping CRUD and validation display
run_panel.py operator instruction and live log surfaces
```
The UI depends on service interfaces, not SQLite or profile JSON directly.
Comparison code has no Qt imports and is testable with fixture profiles. The
runner changes task/project state only through the store transaction API.
## 11. Tests
Automated tests cover:
- task, mapping, and project CRUD plus soft-delete/restore;
- mapping validation, including representative material numbers;
- recursive `.prj` scanning, deterministic ordering, rescan, duplicates,
missing paths, and selection preservation;
- application and per-task logs, rotation configuration, exception hooks, and
subprocess stdout/stderr capture;
- probe freshness, exact project identity, atomic evidence copies, SHA-256, and
rejection of stale/corrupt/wrong-project profiles;
- before-match extraction, no-match handling, exact logical-identity
correlation, target replacement, unrelated-object checks, and every protected
invariant;
- runner pause, resume, retry, crash recovery, automatic next-project advance,
and completed-task transition;
- PySide6 task/mapping/project CRUD interactions and disabled/enabled run gates;
- responsive worker execution without blocking the Qt UI thread;
- visual screenshots at 1100x700 and 1440x900 logical pixels with no clipped or
overlapping text; and
- a PyInstaller smoke test that starts the built EXE with an isolated temporary
application-data root, opens the main window, writes a startup log, and exits
cleanly.
No mock or automated test is accepted as proof that a DxDesigner 7.9.5 live
route works. Live acceptance requires one complete disposable project copy, a
before profile, a native replacement, an after profile, the comparison file,
and the corresponding logs.
## 12. MVP Acceptance
The first executable is acceptable for user testing when it can:
1. start without a separate Python installation and write its startup log;
2. create, edit, list, soft-delete, and restore tasks;
3. scan a selected directory, select one or more `.prj` projects, and preserve
the selection after rescan;
4. create, edit, reorder, enable, and delete mapping rules;
5. capture and correlate fresh before/after profiles for one selected project;
6. guide the operator through the native replacement without UI automation;
7. compare the selected project's before/after evidence and move it to
Completed only when hard verification passes;
8. retain failed projects with a visible error ID and retry action;
9. automatically advance to the next selected project; and
10. preserve complete application, task-event, evidence, and crash logs.
Parameter-style restoration and exact `Part Label -> Value` writes are the next
phase. The trial task center records the evidence needed to implement and
certify them without redesigning task storage or the UI.