fix(execution): verify exact identity connections and untouched state

This commit is contained in:
阿白叔 committed 2026-10-19 09:00:04 +08:00
1 parent b646a9a88a
commit 11810eca4c
7 files changed
+673 -133

No files matched your search

@@ -174,6 +174,7 @@ Command.Add "sync_nc","__SYNC_NC__"
__BEFORE__
SnapshotPath=QPJobSnapshotPath(QP_CurrentJobId)
Snapshot="M" & vbTab & QPEncode(QPProjectPath()) & vbTab & "OLD" & vbTab & "NEW" & vbTab & QPEncode(QPSheetIdentity()) & vbTab & "__MODE__" & vbTab & QPEncode("__CUSTOM__") & vbTab & "__SYNC_NC__" & vbCrLf & QPSnapshotComponent(Comp)
Snapshot=Snapshot & "X" & vbTab & "untouched_full_v1" & vbCrLf
QPWriteUtf8 SnapshotPath,Snapshot
Set Attr=Comp.FindAttribute("Part Number"): Attr.Value="NEW"
Set Attr=Comp.FindAttribute("Part Name"): Attr.Value="NEW_NAME"
@@ -215,6 +216,19 @@ Require QP_App.UndoCount=0,"recovery undid prior CAD work"
''')
@pytest.mark.parametrize('change', ['Comp.UID="imposter"', 'Comp.Refdes="R99"'])
def test_restore_rejects_changed_component_identity_before_any_write(tmp_path, change):
run_vbs(tmp_path, 'part_number', '''
On Error Resume Next
QPRestoreAfterOperatorReplace Command,SnapshotPath
Failure=Err.Number
Err.Clear
On Error GoTo 0
Require Failure<>0,"changed component identity was accepted"
Require QP_App.TransactionCount=0,"identity failure must precede CAD writes"
''', after=change)
@pytest.mark.parametrize('mode', ['preserve', 'part_label', 'part_number'])
def test_recovery_repairs_attributes_without_native_replace(tmp_path, mode):
run_vbs(tmp_path, mode, '''