feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛
闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。 同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d2b3d74def
commit
84a881b554
195 files changed
+20269
-3463
No files matched your search
@@ -0,0 +1,64 @@
|
||||
"""
|
||||
backend/tests/performance/test_shipping_xfa_visual_mapping_load.py
|
||||
|
||||
用途:阶段 8 统一视觉映射建议/转换负载冒烟(合成数据,软阈值,非 flaky)。
|
||||
依赖:order_profile_unified_migration、time。
|
||||
逻辑:批量转换合成 XFA definition;断言在本地冒烟预算内完成。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
from app.services.shipping_notice.order_profile_unified_migration import (
|
||||
convert_xfa_definition_to_unified_bindings,
|
||||
)
|
||||
|
||||
|
||||
def _synthetic_xfa_definition(*, field_count: int = 40) -> dict:
|
||||
"""生成含多 Header/Line 映射的合成 XFA definition。"""
|
||||
headers = []
|
||||
lines = []
|
||||
for index in range(field_count // 2):
|
||||
headers.append({
|
||||
'mapping_id': f'map-h-{index}',
|
||||
'field_id': f'fld-h-{index}',
|
||||
'field_code': f'header_field_{index}',
|
||||
'data_path': f'/data/HEADER/F{index}',
|
||||
'path_id': f'path-h-{index}',
|
||||
'value_type': 'string',
|
||||
})
|
||||
lines.append({
|
||||
'mapping_id': f'map-l-{index}',
|
||||
'field_id': f'fld-l-{index}',
|
||||
'field_code': f'line_field_{index}',
|
||||
'data_path': f'/data/ITEMS/DATA/C{index}',
|
||||
'path_id': f'path-l-{index}',
|
||||
'value_type': 'string',
|
||||
})
|
||||
return {
|
||||
'template_mode': 'xfa_dataset',
|
||||
'source_contract': {
|
||||
'template_packet_checksum': 'sha256:' + ('a' * 64),
|
||||
'dataset_structure_fingerprint': 'sha256:' + ('b' * 64),
|
||||
'dataset_root_path': '/data',
|
||||
'authoritative_line_collection_path': '/data/ITEMS/DATA',
|
||||
'mirror_collection_paths': [],
|
||||
},
|
||||
'header_mappings': headers,
|
||||
'line_mapping': {'row_path': '/data/ITEMS/DATA', 'fields': lines},
|
||||
'bindings': [],
|
||||
'split_rules': [],
|
||||
}
|
||||
|
||||
|
||||
def test_visual_mapping_conversion_under_soft_latency_budget():
|
||||
"""40 字段统一转换应在软阈值(2s)内完成;失败才视为回归。"""
|
||||
definition = _synthetic_xfa_definition(field_count=40)
|
||||
started = time.perf_counter()
|
||||
after, stats = convert_xfa_definition_to_unified_bindings(definition, widgets=[])
|
||||
elapsed = time.perf_counter() - started
|
||||
assert stats['binding_count'] == 40
|
||||
assert len(after['bindings']) == 40
|
||||
# 软阈值:本地合成转换远快于 2s;避免偶发 GC 抖动用宽松上限。
|
||||
assert elapsed < 2.0
|
||||
Reference in new issue
Block a user