fix: preserve review diagnostics and fallback readback

This commit is contained in:
阿白叔 committed 2026-10-31 11:18:30 +08:00
1 parent e5e628de4a
commit 24b655cae1
4 files changed
+29 -4

No files matched your search

@@ -31,4 +31,11 @@
- GBK 输出回退断言通过:`'中文'.encode('gbk')` 正确还原。
- 冻结 EXE smoke 通过;最新源码与包内 VBS SHA256 一致。
## 非阻断建议采纳情况
- 收尾记录写失败改为 best-effort,保留原始 `application_shutdown_failed`,不让二次磁盘错误覆盖主因。
- Python fallback 完整回读新增回归;VBS 捕获/恢复链路已有生产脚本加 COM 替身端到端覆盖。
- 恢复预检缺失字段错误现在包含字段名和 fallback UID,便于现场诊断。
- 引脚 owner 的二次身份校验保留:它是连接归属的安全证明,去掉虽然可能减少 COM 调用,但会降低错误 pin 被混入连接签名的可检测性;待真实大工程基准后再评估。
仍需 Windows 10、真实 DxDesigner 7.9.5 无 UID 工程、中央库/许可证/COM 注册、网络共享和企业策略现场验收。
@@ -2068,8 +2068,9 @@ Sub QPRestorePreflight(ByRef Comp, ByRef ComponentRecord, _
Set Record = Attributes.Item(CStr(Index))
If CStr(Record("uid")) = CStr(ComponentRecord("uid")) Then
For Each Field In Array("x", "y", "color", "font", "size", "orientation", "visible")
If Len(CStr(Record(Field))) = 0 Then Err.Raise vbObjectError + 836, _
"QuickPartReplace.Snapshot", "attribute display state unavailable; no restoration writes allowed"
If Len(CStr(Record(Field))) = 0 Then Err.Raise vbObjectError + 836, _
"QuickPartReplace.Snapshot", "attribute display state unavailable field=" & CStr(Field) & _
"; uid=" & CStr(ComponentRecord("uid")) & "; no restoration writes allowed"
Next
End If
Next
@@ -264,13 +264,20 @@ def _finish_response(root, journal, response, context):
if related:
raise resource_pending_error(journal['operation'], result, error, primary)
resource_path = internal_path(Path(root) / 'batch-resources' / journal['batch_id'] / 'session.json')
def preserve_shutdown_failure(detail):
try:
write_record(Path(root) / 'batch-resources' / journal['batch_id'] / 'supervisor.json', journal)
except OSError as record_error:
context.logger.error('supervisor_shutdown_record_failed batch_id=%s error=%s',
journal['batch_id'], record_error)
journal['shutdown_record_error'] = str(record_error)
try:
resource = json.loads(resource_path.read_text(encoding='utf-8'))
except FileNotFoundError:
resource = {}
except (OSError, ValueError, TypeError) as failure:
journal.update(state='blocked', shutdown_record_error=str(failure))
write_record(Path(root) / 'batch-resources' / journal['batch_id'] / 'supervisor.json', journal)
preserve_shutdown_failure(failure)
raise application_shutdown_error(result, error, primary) from failure
shutdown = resource.get('cad_shutdown') if isinstance(resource, dict) else None
if shutdown is None and isinstance(resource, dict):
@@ -279,7 +286,7 @@ def _finish_response(root, journal, response, context):
or not isinstance(shutdown.get('cleanup_errors', ()), (list, tuple))
or any(not isinstance(item, dict) for item in shutdown.get('cleanup_errors', ()))):
journal.update(state='blocked', shutdown_record_error='invalid shutdown record shape')
write_record(Path(root) / 'batch-resources' / journal['batch_id'] / 'supervisor.json', journal)
preserve_shutdown_failure('invalid shutdown record shape')
raise application_shutdown_error(result, error, primary)
if (shutdown.get('orderly_shutdown') is False or shutdown.get('forced_termination')
or shutdown.get('diagnostic_errors')
@@ -1,4 +1,5 @@
from collections import Counter
from pathlib import Path
from types import SimpleNamespace
import pytest
@@ -83,6 +84,15 @@ def test_missing_uid_matches_flow_into_pin_promotion(monkeypatch, count):
assert [pin['uid'] for pin in promoted] == matches
def test_missing_uid_fallback_survives_complete_readback():
target = Component('', 'R1', **{'Part Number': 'NEW', 'Part Name': 'TARGET', 'Part Label': 'LABEL'})
snapshot = Path('fallback-readback.tsv')
metadata = ['M', 'project', 'OLD', 'NEW', 'sheet', 'part_label', '', '1']
assert native.verify_replacement_readback(snapshot, [target], metadata,
[['C', '@REFDES|R1', 'R1']], {'@REFDES|R1'}, {}, True,
['lib', 'NEW', 'symbol', 'gate', 'TARGET', 'LABEL'], ['@REFDES|R1']) == ['@REFDES|R1']
def test_preselection_context_does_not_query_an_unused_selection(monkeypatch):
target = Component('u1', 'R1', **{'Part Number': 'OLD', 'Value': 'V0'})
target._oleobj_ = target