fix(shipping-notice): 调整XFA 身份指纹漂移降级软门禁并放行 datasets 取值

供应商换代重导 XFA 表单必变 template 包指纹,原硬拦截使视觉已唯一
命中的单据永远停在无数据人工复核。

- 身份校验改为状态判定写入 decision.xfa_identity_state
  (matched/incomplete/mismatch),漂移仅记 fallback 码不拦截;
- 放行后按模板既有 bindings 对新包 datasets 取值,仍强制
  validate_xfa_extraction 业务交叉校验兜底;
- 取值/业务校验失败时身份码前置转 Review,复核者可见漂移根因。
This commit is contained in:
hugo committed 2026-10-15 00:31:43 +08:00
1 parent 47ee68ed25
commit 1efb165fd5
1 file changed
+26 -5
@@ -1901,10 +1901,24 @@ def extract(
live_fingerprint = live_fingerprint or signature.get('dataset_structure_fingerprint')
source = selected.get('definition', {}).get('source_contract') if isinstance(selected.get('definition'), dict) else {}
source = source if isinstance(source, dict) else {}
identity_state = 'matched'
if not source.get('template_packet_checksum') or not source.get('dataset_structure_fingerprint'):
return review('xfa_profile_identity_incomplete')
if source.get('template_packet_checksum') != live_template or source.get('dataset_structure_fingerprint') != live_fingerprint:
return review('xfa_profile_identity_mismatch')
identity_state = 'incomplete'
elif (
source.get('template_packet_checksum') != live_template
or source.get('dataset_structure_fingerprint') != live_fingerprint
):
identity_state = 'mismatch'
# [SOFT GATE] XFA 身份指纹漂移不再硬拦截(回归 SNER-20261014-35E35017:供应商
# 换代必变指纹,硬拦截使 XFA 单据永远空转人工)。视觉 Route 已唯一命中,datasets
# 取值后仍有 validate_xfa_extraction 业务交叉校验兜底;漂移降级为决策留痕
# (xfa_identity_state)+ fallback 码,仅当取值/校验失败时与业务原因码一起转 Review。
decision['xfa_identity_state'] = identity_state
if identity_state != 'matched':
decision['fallback_reason_codes'] = [
*(decision.get('fallback_reason_codes') or []),
f'xfa_profile_identity_{identity_state}',
]
table_id = workflow._profile_visual_main_table_id(selected, document.get('layout_snapshot') or {})
if not table_id:
return review('xfa_visual_main_table_missing')
@@ -1947,7 +1961,11 @@ def extract(
# 审计故障不能篡改已冻结的取值/Review 裁决。
pass
if extraction.status != 'parsed' or extraction.reason_codes:
return review(*(list(extraction.reason_codes or []) or ['xfa_required_field_missing']))
codes = list(extraction.reason_codes or []) or ['xfa_required_field_missing']
if identity_state != 'matched':
# 漂移被软门禁放行后取值仍失败:身份码前置,让复核者看到根因。
codes = [f'xfa_profile_identity_{identity_state}', *codes]
return review(*codes)
validation = validate_xfa_extraction(
raw_profile=selected, dataset_analysis=outcome.dataset_analysis, extraction=extraction, pdf_bytes=pdf_bytes,
)
@@ -1960,7 +1978,10 @@ def extract(
'profile_checksum': str(selected.get('checksum') or ''),
}
if not validation.passed:
return review(*(list(validation.reason_codes or []) or ['xfa_business_validation_failed']))
validation_codes = list(validation.reason_codes or []) or ['xfa_business_validation_failed']
if identity_state != 'matched':
validation_codes = [f'xfa_profile_identity_{identity_state}', *validation_codes]
return review(*validation_codes)
table = {
'profile_id': selected.get('profile_id') or selected.get('id'), 'profile_code': str(selected.get('profile_code') or ''),
'profile_version': int(selected.get('version') or 0), 'profile_checksum': str(selected.get('checksum') or ''),