# CBB Refresh Verify Design **Date:** 2026-09-16 **Status:** Approved for planning ## Goal Deliver an independent Windows desktop tool that loads a Mentor central library, lists its uploaded Logical-Physical CBB reusable blocks, invokes the official contents verification command, and produces an auditable result without confusing contents PASS with Library Manager's final green state. ## Scope In scope: - Select and open a `.lmc` central library. - Read and list CBBs from the Reusable Blocks / Logical-Physical partition. - Accept the required `LibSpec` and DMS login configuration paths. - Run `ReuseBlockImporter.exe -chkContents` for a selected CBB. - Display live output, exit code, timeout/stop state, report path, and JSON evidence. - Package and release an onedir executable using the established DxDesigner replacement-tool standard. Out of scope: - Part replacement. - PCB synchronization. - Uploading CBBs to the central library. - Simulating or fabricating DMS connectivity. - Claiming Library Manager's green indicator from a contents-check PASS alone. ## Reuse From DxDesigner Replacement Tool The project will follow the existing replacement tool's conventions instead of reimplementing equivalent infrastructure: - Python 3.12 project metadata and setuptools layout. - PySide6 application bootstrap and an onedir PyInstaller distribution. - `Analysis -> PYZ -> EXE -> COLLECT` packaging structure. - A `packaging` PowerShell build script that resolves the project interpreter, cleans only verified project-local build targets, invokes PyInstaller, and validates the produced executable. - Application data/log root resolution, startup/clean-shutdown logging, exception hook installation, and hidden smoke-test arguments, adapted to the CBB product name. - UI worker/thread patterns for long-running operations and cancellation. The replacement tool's part-replacement domain state machine, project scanner, native replacement scripts, and database schema are not copied because they do not apply to CBB verification. ## Architecture ### Application Bootstrap `cbb_refresh_verify.application` owns command-line parsing, data-root resolution, logging setup, Qt application creation, exception hooks, smoke-test shutdown, and construction of the main window. `__main__.py` calls the absolute package import `cbb_refresh_verify.application.main` so it works both from source and as a frozen PyInstaller script. ### Library Reader `library_reader.py` exposes a Qt-free function that receives a `.lmc` path and returns typed CBB records. On Windows it uses `win32com.client.Dispatch("LibraryManager.Application")`, opens the library, selects partition type 7 (Reusable Blocks), and enumerates Logical-Physical entries. COM failures are returned as structured errors and are visible in the UI; they are never silently converted into an empty list. The reader is isolated behind an interface so fixture data and a fake reader can be used in tests without opening production libraries. ### Verify Runner `verify_runner.py` exposes a Qt-free runner that validates required paths, resolves `ReuseBlockImporter.exe` from the configured Mentor bin or known installation fallback, builds the exact official argument list, and executes it in a cancellable worker process. stdout and stderr are captured separately. The runner writes a text report and JSON evidence containing command, inputs, timestamps, exit code, output, and classified result. Classification rules: - `PASS`: process completed and official success text is present without an error marker. - `FAIL`: process completed with a verification failure or non-zero exit code. - `TIMEOUT`: configured timeout elapsed. - `BLOCKED`: prerequisite such as missing executable, missing DMS configuration, or unavailable environment prevents a meaningful attempt. - `UNKNOWN`: process ended but output cannot be classified safely. No result class is mapped to Library Manager's green indicator. The UI reports that final state separately as `not-read / manual-confirmation-required`. ### UI The main window contains: - central-library path with browse action; - read-only CBB table or combo populated after library load; - required `LibSpec` and DMS login configuration fields; - optional Mentor bin and evidence-directory fields with defaults; - Verify and Stop actions; - status indicator, live output panel, final classification, and evidence/report links. Loading a library and running Verify happen off the GUI thread. Verify is disabled until a library, CBB, LibSpec, and DMS configuration are present. Empty libraries and reader errors are explicit states. ### Evidence and Data Application logs live below the same product-specific data root pattern used by the replacement tool. Each run receives a unique evidence directory or timestamped report, and evidence is never read back as a substitute for live command output. Existing historical screenshots and run JSON files are not inputs to runtime classification. ## Error Handling - Invalid or missing `.lmc`, `LibSpec`, DMS config, or executable: `BLOCKED` with an actionable message. - COM initialization/open/enumeration errors: visible reader error with exception text and no CBB selection. - Process launch errors: `BLOCKED` with resolved executable and working-directory details. - Timeout: terminate the child process, preserve partial output, classify `TIMEOUT`. - User stop: terminate the child process and classify `UNKNOWN` unless the runner has a definitive failure code. - Unexpected exceptions: log full traceback and present a concise UI error. ## Testing and Acceptance Unit tests cover: - CBB record conversion and partition filtering; - COM reader success, empty library, and COM exception paths using fakes; - exact command construction; - PASS/FAIL/UNKNOWN classification from representative output; - missing prerequisite, timeout, stop, and evidence writing. Packaging acceptance requires: 1. The build script exits with code 0. 2. `dist\\CbbRefreshVerify\\CbbRefreshVerify.exe` exists. 3. The frozen executable accepts `--smoke-test --data-root ` and exits 0. 4. Smoke logs contain startup and clean-shutdown events. 5. A fixture `.lmc` can be loaded through the reader test seam without modifying the production central library. Real DMS verification is an environment-dependent acceptance step for the user's work machine. On a machine without DMS, the correct observed result is `BLOCKED` or `UNKNOWN`, never a fabricated PASS. ## Constraints - Windows desktop target. - Python `>=3.12,<3.13`. - Dependencies remain limited to PySide6 and pywin32 plus the existing build/test tools. - No fixed-coordinate UI automation, SendKeys, or production-library writes. - Output is independent from `dxdesigner-part-replacement` and does not modify that project.