feat(native): add correlated read-only snapshot adapter

This commit is contained in:
阿白叔 committed 2026-10-19 10:54:25 +08:00
1 parent 5b625b076e
commit 2f6060dfe3
4 files changed
+440

No files matched your search

@@ -0,0 +1,65 @@
# Native Readonly Snapshot Implementation Plan
> **For agentic workers:** Execute this plan inline with existing user authorization; use independent requesting-code-review for the final boundaries. Steps use checkbox syntax for tracking.
**Goal:** Speed up complete unselected-state acquisition without removing any save/reopen verification.
**Architecture:** A separate VBScript adapter builds a native-host script from the existing read-only production routines. Python combines the adapter with the main worker at preparation time. Correlated, complete U/G frames are checked before capture or verification consumes them.
**Tech Stack:** Python 3.12, VBScript, installed DxDesigner 7.9.5 script host, existing private desktop supervisor.
**Spec:** ../specs/2026-10-19-native-readonly-snapshot.md
## Global Constraints
- Only owned private-desktop batches use the adapter; manual/legacy paths retain external COM.
- Keep original full fields, live pin owners, context checks, save/reopen and recovery boundaries.
- Native error or incomplete proof fails closed after dispatch; no CAD writes from the reader.
- Do not package/release, modify feedback/, or run real CAD on source projects.
## Task 1: Correlated read frame and native script adapter
Files: create integration/dxdesigner795/NativeSnapshotReader.vbs and tests/v1_1/test_native_snapshot_reader.py.
Interfaces:
- QPNativeReadUntouched(SelectedUids): dictionary with total, text, and rows keyed by unselected UID.
- QPParseNativeSnapshot(Text, Token, Project, Sheet, SelectedUids): validates NR1/header, U/G pairs, END/token/count and exact pair identity; returns the dictionary above.
- QPNativeCollect(SelectedUids, Token, Project, Sheet, Guid): freshly queries the owned view and produces the complete frame with existing QPUntouchedComponent.
- QPBuildNativeSnapshotScript(SelectedUids, Token, Project, Sheet, Guid, ResultPath): emits native bootstrap plus an explicit whitelist of original read-only routines; native QPProgress checks cancellation only.
- [ ] Write literal frame tests: one zero-pin unselected component, one selected UID, total=2; expected rows["u2"] equals its original U/G pair.
```python
assert parsed_total == 2
assert parsed_uids == ['u2']
```
- [ ] Run tests and observe missing adapter failure. Add negative fixtures for stale token, wrong context, truncation, duplicate UID, wrong G owner, inconsistent U/G, extra selected UID, malformed count and propagated error frame.
- [ ] Implement strict parsing and script generation; collect with the same read functions and no selection/save operations. Exercise generated code using COM-shaped fakes, including cancellation and missing targets.
- [ ] Run the adapter tests and commit after they pass.
## Task 2: Runtime composition and capture/verification integration
Files: modify src/dx_productivity/trial_task_center/quick_run.py, integration/dxdesigner795/QuickPartReplace.vbs, packaging/DxPartReplace.spec and focused runtime tests.
Interfaces:
- _copy_worker_script(source: Path, destination: Path): copy source and append its sibling NativeSnapshotReader.vbs when present; preserve custom script compatibility.
- QPUseNativeSnapshot(): true only for owned batches with a private-desktop environment and an available adapter function.
- QPVerifyNativeUntouched(Records): compare complete actual rows, total and unselected UID set to existing persisted baselines.
- [ ] Reproduce a prepared default worker missing the adapter and a custom worker that must remain unchanged.
- [ ] Compose all three existing source-copy callsites through _copy_worker_script; include the adapter in the frozen resource specification without building.
- [ ] Route capture and QPVerifyUntouched through native reads only behind QPUseNativeSnapshot. Retain original external loops for other modes and all invalidation calls.
- [ ] Run focused runtime, VBS, execution/recovery and existing accuracy tests. Review any failures before continuing; commit tested integration.
## Task 3: Independent review and real BOM acceptance
Files: add docs/reviews/2026-10-19-native-snapshot.md and sanitized docs/testing/evidence/2026-10-19-native-snapshot.json.
- [ ] Request an independent read-only review of ownership gating, native function whitelist, nonce/context checks, failure propagation and exact full-baseline comparison.
- [ ] Run the established default-template BOM harness on a fresh build/ copy with RV05 and RV14, recording script hashes and timings.
- [ ] Compare initial snapshots with the 120-row previous baseline; independently export hier/flat and verify 55 untouched components, 103 pin connections and 22 nets, plus exact target changes.
- [ ] Exercise read-only recovery on the disposable successful queue because it also calls full verification; confirm no additional replacement/save and safe release.
- [ ] Record failed research probes and remaining release gaps honestly, update plan checkboxes, commit evidence and push. Verify remote HEAD equals local and only feedback/ remains untracked.