refactor(shipping-notice): 进度信号统一为 15 阶 stage 契约码并透传阻断原因

- 后端进度写入 step_key 全量切换为 15 阶契约 stage 码
- 投影层清除 CheckPoint stepN_* 遗留别名与子串/前缀启发式,阶段信号按契约码精确匹配
- 建单前 Case 摘要透传草稿首要阻断原因
- 前端标签/归一化/处理卡片同步契约码,阻断原因按 i18n 优先展示
- 修复正式下游回看时 activeCase 刻意为空导致队列定位与接收解析上下文静默跳过
- 同步更新投影/门禁/工作台/RPA 流程测试
This commit is contained in:
hugo committed 2026-09-17 15:54:53 +08:00
1 parent d1adbe5ec5
commit 18af972d20
34 files changed
+903 -111

No files matched your search

@@ -36,21 +36,39 @@ def test_fifteen_processing_stages_all_map_to_a_lifecycle_stage():
)
def test_legacy_step_key_stage_maps_to_fulfillment_prep():
"""OT.stage 若残留 step5_match_inventory,生命周期必须进通知准备而非接收解析。"""
def test_stage_mapping_rejects_checkpoint_legacy_keys():
"""CheckPoint stepN_* 遗留键已全部清除:阶段映射只认 15 阶契约码。
历史缺陷:step_key 被写进 OT.stage,靠投影别名兜底;现写路径只产出契约码
(set_task_step_progress 校验 + 存量迁移清洗),别名不得再存在。
"""
legacy_keys = [
'step1_notice_submit',
'step2_parse_confirm',
'step3_inventory_prepare',
'step5_match_inventory',
'step6_generate_file',
'step7_upload_freight',
]
for key in legacy_keys:
assert key not in LIFECYCLE_STAGE_BY_PROCESSING_STAGE, (
f"CheckPoint 遗留键 {key!r} 不得再进入阶段映射"
)
for stage_code in LIFECYCLE_STAGE_BY_PROCESSING_STAGE:
assert not str(stage_code).startswith('step'), (
f"阶段映射出现非契约键 {stage_code!r}"
)
# 契约码本身仍能正常映射:库存匹配属通知准备,processing_stage 权威生效。
from app.services.shipping_notice.lifecycle_projection import project_lifecycle
result = project_lifecycle(
current_gate={'gate_code': 'task_creation', 'status': 'invalidated'},
blocking_reason={'code': 'gate_invalidated'},
has_candidate_context=True,
processing_stage='step5_match_inventory',
processing_stage='inventory_matching',
)
# processing_stage 权威高于错误的 task_creation 门禁。
assert result['lifecycle_stage'] == 'fulfillment_prep'
assert result['lifecycle_authority'] == 'processing_stage'
current = next(e for e in result['lifecycle_entries'] if e['state'] == 'current')
assert current['code'] == 'fulfillment_prep'
def test_fifteen_stages_inventory_source_before_review():