feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -12,8 +12,10 @@ from types import SimpleNamespace
|
||||
|
||||
from app.services.shipping_notice.candidate_qualification_service import (
|
||||
evaluate_candidate_qualification,
|
||||
resolve_review_case_customer_resolved,
|
||||
)
|
||||
from app.services.shipping_notice.order_build_eligibility_service import assess_auto_build_gates
|
||||
from app.services.shipping_notice.candidate_service import evaluate_candidate_stp_gate
|
||||
|
||||
|
||||
def _eligible_candidate(**overrides):
|
||||
@@ -40,6 +42,14 @@ def _eligible_candidate(**overrides):
|
||||
return SimpleNamespace(**base)
|
||||
|
||||
|
||||
def test_review_case_customer_confirmation_does_not_fall_back_to_another_pdf_in_same_run():
|
||||
"""当前 Case 无确认客户时,同 Run 其他 PDF 的确认结果不得让它通过客户门禁。"""
|
||||
case = SimpleNamespace(run_id=123)
|
||||
|
||||
# 关键断言:没有当前 Candidate/Extraction 的确认记录时必须 fail-closed。
|
||||
assert resolve_review_case_customer_resolved(case=case, candidate=None) is False
|
||||
|
||||
|
||||
def test_profile_unapproved_but_qualified_candidate_is_eligible(monkeypatch):
|
||||
"""模板未批准但 Candidate 合格 → eligible,允许自动建单。"""
|
||||
monkeypatch.setattr(
|
||||
@@ -70,6 +80,37 @@ def test_profile_unapproved_but_qualified_candidate_is_eligible(monkeypatch):
|
||||
assert 'profile_not_auto_freeze_approved' not in result['blocking_reason_codes']
|
||||
|
||||
|
||||
def test_layout_table_review_diagnostic_does_not_block_auto_create(monkeypatch):
|
||||
"""版面表格诊断只影响高亮质量,不得伪装成字段冲突阻断自动建单。"""
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.candidate_qualification_service.extraction_emergency_stop_enabled',
|
||||
lambda: False,
|
||||
)
|
||||
candidate = _eligible_candidate(conflicts_json=[{
|
||||
'field': 'document_layout',
|
||||
'severity': 'blocking',
|
||||
'reason': 'layout_table_needs_review',
|
||||
'document_id': 117,
|
||||
}])
|
||||
|
||||
result = evaluate_candidate_qualification(
|
||||
candidate=candidate,
|
||||
fields_complete=True,
|
||||
customer_resolved=True,
|
||||
schema_auto_create_enabled=True,
|
||||
)
|
||||
|
||||
# 关键断言:诊断仍可保留在 Candidate,但不进入字段冲突建单门禁。
|
||||
assert result['gates']['field_conflicts_resolved'] is True
|
||||
assert result['can_auto_create'] is True
|
||||
assert 'field_conflict' not in result['blocking_reason_codes']
|
||||
|
||||
passed, reason_codes = evaluate_candidate_stp_gate(candidate)
|
||||
# 关键断言:旧 Candidate 仍携带该诊断时,最终 STP 履约校验也不得二次拦截。
|
||||
assert passed is True
|
||||
assert 'blocking_conflict' not in reason_codes
|
||||
|
||||
|
||||
def test_llm_candidate_can_pass_unified_gates(monkeypatch):
|
||||
"""LLM Candidate 具备分类/字段置信度与证据时可通过统一门禁 → eligible。"""
|
||||
monkeypatch.setattr(
|
||||
@@ -284,3 +325,35 @@ def test_assess_auto_build_gates_no_longer_requires_approved_template(monkeypatc
|
||||
assert 'approved_template' not in result['gates']
|
||||
assert result['can_auto_create'] is True
|
||||
assert result['qualification']['status'] == 'eligible'
|
||||
|
||||
|
||||
def test_pdf_preferred_critical_conflict_blocks_auto_create_with_review(monkeypatch):
|
||||
"""
|
||||
PDF 关键冲突须阻断自动建单,并映射为 review_required + 细因码。
|
||||
|
||||
断言:can_auto_create=False;blocking_reason_codes 含 pdf_preferred_critical_conflict。
|
||||
"""
|
||||
monkeypatch.setattr(
|
||||
'app.services.shipping_notice.candidate_qualification_service.extraction_emergency_stop_enabled',
|
||||
lambda: False,
|
||||
)
|
||||
candidate = _eligible_candidate(
|
||||
conflicts_json=[{
|
||||
'field': 'po_number',
|
||||
'severity': 'blocking',
|
||||
'reason': 'pdf_preferred_critical_conflict',
|
||||
'owning_gate_code': 'field_conflict_resolution',
|
||||
}],
|
||||
validation_status='needs_review',
|
||||
)
|
||||
result = evaluate_candidate_qualification(
|
||||
candidate=candidate,
|
||||
fields_complete=True,
|
||||
customer_resolved=True,
|
||||
schema_auto_create_enabled=True,
|
||||
)
|
||||
assert result['can_auto_create'] is False
|
||||
assert 'field_conflicts_resolved' in result['failed_gates']
|
||||
assert 'pdf_preferred_critical_conflict' in result['blocking_reason_codes']
|
||||
assert 'field_conflict' not in result['blocking_reason_codes']
|
||||
assert result['status'] == 'review_required'
|
||||
Reference in new issue
Block a user