diff --git a/docs/releases/2026-11-03-native-crud.md b/docs/releases/2026-11-03-native-crud.md index c5386b0..e2a9777 100644 --- a/docs/releases/2026-11-03-native-crud.md +++ b/docs/releases/2026-11-03-native-crud.md @@ -1,6 +1,6 @@ # Native CRUD integration and review follow-up -The shared native Add transport uses the proven private-desktop UIA executor, bounded field readback and exact native success message. It closes/reopens the library before comparing exact catalog name/partition and raw engineering identity. Native registration with different engineering bytes returns `success=True`, `identity_matches=False`; missing registration is a native failure. Production Add and Update remain disabled pending independent engineering identity proof. +The shared native Add transport uses the proven private-desktop UIA executor, bounded field readback and exact native success message. It closes/reopens the library before comparing exact catalog name/partition and engineering identity. Missing registration or mismatched native logical/drawing/physical proof cannot become an accepted upload. Production Add/Update are now enabled only with the exact pinned EE7.9.5 core and all three identity exporters, for ASCII target names in the proven DxDesigner / Logical-Physical scope. Every mutation still requires the prepared engine transaction and complete recovery snapshot. The review of 07a9c1e identified that route readiness alone did not authorize existing-library mutation. The follow-up makes public `add()` refuse before reading a source or launching a worker. Research callers must use `add_owned_fixture(..., probe_token=...)` against the fixed library created by the diagnostic workflow and matching probe-owner record. It requires the calling thread's live library lease, checks its lease ID against the checkpoint, owns the management mutex during submission, creates a fresh staged source copy and verified library snapshot, and binds the transaction nonce to target, name, partition, source identity and manifests. @@ -21,3 +21,7 @@ Coordinator-native source/registered capture matched all three exports and prima The coordinator's native engine cycle subsequently passed empty-library creation, Add A, duplicate refusal, same-name replacement by B (with a different verified layout hash), removal with strict absence, and reimport from a complete backup. Every operation reported safe native release and both original source manifests stayed unchanged; evidence is under `diagnostics/issue2-native-crud-20261103/engine-e2e`. Final safety review narrowed the additional iCDB runtime exclusions to known log directories, exact events files and the observed dated GUID log filenames. Unknown `cdbsvr` content remains primary, including unknown events/plog files, and a registered unknown-file change now requires recovery. Export capture binds its analysis copy to the existing library checkpoint before launch. That binding survives retention/restart and cannot be cleared by release or maintenance adoption until recorded processes/child handles have exited, known exporter/server processes are absent, copied addresses are absent and copied database files can be held exclusively. Missing/malformed ownership evidence remains blocked. The final focused safety/engine suite passed 167 tests; no native operations or full-suite run were performed by the implementation agent. Production promotion remains a separate reviewed change. + +After scoped review found both safety issues corrected, the separate capability-promotion change enabled the public prepared engine routes. The basis is the accepted native cycle in `engine-e2e/cycle-result.json` plus the matching integrated three-export/asset identity evidence. That cycle deliberately used `auto_verify=False`: it proves native registration/replacement/removal/reimport and content identity, not the separate default Verify result or frozen UI acceptance. Unsupported exporter versions, flows, partitions or export formats still fail closed. Replacement remains non-atomic Remove+Add with recovery evidence, and arbitrary unexported CES/version equivalence is not claimed. + +The promotion focused suite passed 93 tests, including every required binary mismatch, unsupported flow/partition, engine identity/recovery and UI progress behavior. Native default description is blank; progress reads “正在核对来源工程内容”. Source input and backup Work restoration behavior are unchanged. Full-suite/build and fresh public frozen-UI acceptance remain coordinator-owned. diff --git a/src/cbb_refresh_verify/native_engineering_identity.py b/src/cbb_refresh_verify/native_engineering_identity.py index 4528d28..d7d7f7e 100644 --- a/src/cbb_refresh_verify/native_engineering_identity.py +++ b/src/cbb_refresh_verify/native_engineering_identity.py @@ -17,7 +17,7 @@ from .scoped_manifest import ManifestScope, build_manifest, hash_file POLICY = 'mentor795-native-content-v1' COVERAGE = {'logical_connectivity_and_properties': 'native hierarchy/flat ASCII and CSV', 'physical_design_and_primary_assets': 'raw SHA256', - 'schematic_graphical_geometry': 'native EDIF schematic', 'production_acceptance': False} + 'schematic_graphical_geometry': 'native EDIF schematic', 'production_acceptance': True} EXPORTER_PROOF = { 'icdb2ascii.exe': 'e37c87356eaf57c0b97e4183458bc8c5eb6eb0ac497cc7ad40dcd585d8cd213b', 'icdb2csv.exe': '22059f4a432e8eabf30a5326ebcbd463ed6fa6495af21d7aad5ab5d2f892f255', diff --git a/src/cbb_refresh_verify/native_management.py b/src/cbb_refresh_verify/native_management.py index 9bc581a..70cd864 100644 --- a/src/cbb_refresh_verify/native_management.py +++ b/src/cbb_refresh_verify/native_management.py @@ -21,9 +21,10 @@ from .scoped_manifest import hash_file from .network_path import absolute_preserving_drive _retained_workers = [] -# Promotion requires coordinator-owned native CRUD evidence, in a separate change. -_PRODUCTION_ADD_VALIDATED = False -_PRODUCTION_UPDATE_VALIDATED = False +# Coordinator-owned Create/Add/conflict/update/remove/backup-reimport evidence: +# diagnostics/issue2-native-crud-20261103/engine-e2e/cycle-result.json +_PRODUCTION_ADD_VALIDATED = True +_PRODUCTION_UPDATE_VALIDATED = True _BINARY_PROOF = { 'lm/win32/bin/CleanWGLib.exe': '7808ded326555f1fd5d5c14f68803dbb4f970d624f9ad6e1c7982dc9ed867917', 'lm/win32/bin/LibraryManager.exe': 'a9c4c3d806794dbdc56d2bc4c637a1cf25e87e98644a7d5fd4eb0067ca5845e0', @@ -85,16 +86,22 @@ class NativeManagementAdapter: return { 'remove': Capability(not reason, reason or 'CleanWGLib/F4 route ready.'), 'add': Capability(not reason, reason or 'Library Manager Logical-Physical Add route ready.'), - 'update': Capability(False, 'Update remains remove plus Add while identity readback is gated.'), + 'update': Capability(False, 'Update is composed from Remove and Add; there is no separate native Update call.'), } def capabilities(self): reason = self._binary_capability() + add_reason = reason + if not add_reason: + from .native_engineering_identity import check_exporters + try: check_exporters(self.home) + except (ValueError, OSError, TypeError) as error: add_reason = str(error) return { 'remove': Capability(not reason, reason or '已验证 CleanWGLib/F4;仅 ASCII 名称、Logical-Physical 和 DxDesigner 库。'), - 'add': Capability(not reason and _PRODUCTION_ADD_VALIDATED, '原生新增及工程身份已有隔离证据;完整事务验证通过前生产新增保持禁用。'), - 'update': Capability(not reason and _PRODUCTION_ADD_VALIDATED and _PRODUCTION_UPDATE_VALIDATED, - '同名更新需要原生移除、重新导入及完整端到端隔离验证,目前不可用。'), + 'add': Capability(not add_reason and _PRODUCTION_ADD_VALIDATED, add_reason or + '已验证 EE7.9.5 原生导入及完整工程复读;仅 ASCII 名称、Logical-Physical 和 DxDesigner 库。'), + 'update': Capability(not add_reason and _PRODUCTION_ADD_VALIDATED and _PRODUCTION_UPDATE_VALIDATED, + add_reason or '已验证同名原生替换:完整备份后移除并重新导入,失败时保留恢复证据。'), } def _worker(self, job, evidence): @@ -198,7 +205,7 @@ class NativeManagementAdapter: return NativeOutcome(bool(result.get('success')), bool(result.get('safe_to_continue')), result.get('detail', '')) def preflight(self, request, catalog): - if request.operation in ('remove', 'update'): + if request.operation in ('add', 'remove', 'update'): removal_input(request.name, request.partition) if request.partition != 'Logical-Physical' or catalog.flow != 1: raise ValueError('仅验证了 DxDesigner / Logical-Physical 管理操作。') @@ -656,7 +663,7 @@ def _probe_add_dialog_impl(app, job, desktop, owned_pids, root, *, library=None) win32gui.PostMessage(new_button, win32con.BM_CLICK, 0, 0) dialog = await_window('New Reusable Block') fields = {1217: str(source), 1215: job['name'], 1218: top, - 1216: job.get('description', 'CBB native management validation')} + 1216: job.get('description', '')} for control, value in fields.items(): hwnd = win32gui.GetDlgItem(dialog, control) if not hwnd or win32gui.GetClassName(hwnd) != 'Edit': diff --git a/src/cbb_refresh_verify/ui/management_dialog.py b/src/cbb_refresh_verify/ui/management_dialog.py index 0f9d92e..fc0542c 100644 --- a/src/cbb_refresh_verify/ui/management_dialog.py +++ b/src/cbb_refresh_verify/ui/management_dialog.py @@ -17,6 +17,7 @@ RESULT_LABELS = { 'BLOCKED': '操作被阻止', 'UNSUPPORTED': '当前环境不支持', } STAGE_LABELS = { + 'prepare_identity': '正在核对来源工程内容', 'catalog_before': '正在核对原生目录', 'backup': '正在备份完整中心库', 'stage_source': '正在复制并检查来源工程', 'native_remove': '正在原生移除', 'removed': '原条目已移除', 'native_add': '正在原生上传', 'uploaded': '上传身份已确认', diff --git a/tests/test_management_ui.py b/tests/test_management_ui.py index 9074555..486e603 100644 --- a/tests/test_management_ui.py +++ b/tests/test_management_ui.py @@ -61,6 +61,9 @@ def test_add_dialog_default_auto_verify_and_source_identity_rows(qtbot, tmp_path assert all(r.auto_verify and r.source.suffix == '.prj' for r in requests) dialog.auto_verify.setChecked(False) assert not any(r.auto_verify for r in dialog.requests()) + dialog._progress({'stage': 'prepare_identity', 'block': 'One'}) + assert '正在核对来源工程内容' in dialog.status_label.text() + assert 'prepare_identity' not in dialog.status_label.text() def test_restart_shows_unfinished_without_starting_worker(qtbot, tmp_path): diff --git a/tests/test_native_management.py b/tests/test_native_management.py index eb593ef..824a7b5 100644 --- a/tests/test_native_management.py +++ b/tests/test_native_management.py @@ -177,7 +177,40 @@ def test_add_route_readiness_is_separate_from_conservative_capability_gate(tmp_p adapter = native.NativeManagementAdapter(mentor_home=tmp_path) assert adapter.route_capabilities()['add'].supported assert not adapter.capabilities()['add'].supported - assert '身份' in adapter.capabilities()['add'].reason + assert 'icdb2ascii' in adapter.capabilities()['add'].reason + + +@pytest.mark.parametrize('bad', [None, 'CleanWGLib.exe', 'LibraryManager.exe', 'LMCDLL70.dll', + 'LMCDocAddin70.dll', 'icdb2ascii.exe', 'icdb2csv.exe', 'edifExporter.exe']) +def test_public_crud_requires_pinned_core_and_every_identity_exporter(tmp_path, monkeypatch, bad): + import hashlib + import cbb_refresh_verify.native_management as native + import cbb_refresh_verify.native_engineering_identity as identity + core = {relative: hashlib.sha256(Path(relative).name.encode()).hexdigest() for relative in native._BINARY_PROOF} + exporters = {name: hashlib.sha256(name.encode()).hexdigest() for name in identity.EXPORTER_PROOF} + monkeypatch.setattr(native, '_BINARY_PROOF', core) + monkeypatch.setattr(identity, 'EXPORTER_PROOF', exporters) + for relative in core: + path = tmp_path/relative; path.parent.mkdir(parents=True, exist_ok=True); path.write_bytes(path.name.encode()) + for name in exporters: + path = tmp_path/('wv/win32/bin' if name == 'edifExporter.exe' else 'iCDB/win32/bin')/name + path.parent.mkdir(parents=True, exist_ok=True); path.write_bytes(name.encode()) + if bad: + next(tmp_path.rglob(bad)).write_bytes(b'changed binary') + caps = native.NativeManagementAdapter(mentor_home=tmp_path).capabilities() + assert caps['add'].supported is (bad is None) + assert caps['update'].supported is (bad is None) + if bad in exporters: assert caps['remove'].supported + + +@pytest.mark.parametrize('operation', ['add', 'update', 'remove']) +@pytest.mark.parametrize('flow,partition', [(2, 'Logical-Physical'), (1, 'Unsupported')]) +def test_public_crud_scope_refuses_unproven_flow_or_partition(tmp_path, operation, flow, partition): + from cbb_refresh_verify.management import ManagementRequest, Catalog + from cbb_refresh_verify.native_management import NativeManagementAdapter + request = ManagementRequest(operation, tmp_path/'lib.lmc', 'Block', partition=partition) + with pytest.raises(ValueError): + NativeManagementAdapter(mentor_home=tmp_path).preflight(request, Catalog(request.library, flow, ())) def test_owned_fixture_add_passes_existing_library_and_source_to_worker(tmp_path, monkeypatch):