refactor(shipping-notice): 重构货代发货通知状态管理,移除废弃的process_status字段
统一货代发货通知的业务阶段为四个标准阶段:接收解析、订单复核、发货准备、上传完成 设置 ui_state 为前端唯一状态数据源,不再依赖 process_status 驱动业务流程 删除 shipping_notices 表的废弃 process_status 列及对应复合索引,新增数据库迁移脚本 替换全栈代码中所有对 process_status 的引用为生命周期、上传状态等领域字段 更新相关文档、测试用例与前端展示逻辑适配新的状态管理规则
This commit is contained in:
1 parent
6684e7181a
commit
5ef8329bd8
178 files changed
+5091
-1734
No files matched your search
@@ -2,9 +2,9 @@
|
||||
services/shipping_notice/tool_response.py
|
||||
|
||||
用途:统一构建发货通知 Tool 的 JSON 响应结构。
|
||||
依赖:state_machine 中的 checkpoint/human_options/action_buttons 解析能力;ShippingProcessExecution。
|
||||
依赖:state_machine 中的 checkpoint/human_options 解析能力;ShippingProcessExecution。
|
||||
逻辑:由 task_workflow、inventory_workflow、fulfillment_workflow 等 workflow 调用本文件,把状态机信息整理成一致的 Tool 响应;
|
||||
已绑定 ProcessExecution 的任务不再下发旧 action_buttons / next_required_action(恢复仅由 Gate 驱动)。
|
||||
已绑定 ProcessExecution 的任务不再下发旧动作字段(恢复仅由 Gate 驱动)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -85,37 +85,30 @@ def tool_response(
|
||||
"""
|
||||
构建发货通知 Tool 标准 JSON 响应。
|
||||
|
||||
核心逻辑:未显式传 checkpoint 时从 task DB 状态推导 checkpoint/human_options/action_buttons;
|
||||
核心逻辑:未显式传 checkpoint 时从 task DB 状态推导 checkpoint/human_options;
|
||||
显式 checkpoint 优先(如 parse_ok、task_exists)。
|
||||
若任务已有 ProcessExecution:不再填充 action_buttons / next_required_action,避免与 Gate 双真相。
|
||||
若任务已有 ProcessExecution:不再填充旧动作字段,避免与 Gate 双真相。
|
||||
|
||||
Args:
|
||||
stop_agent_turn: True 时要求 Agent 本回合停止,等待用户操作。
|
||||
forbidden_next_tools: 禁止 Agent 同轮调用的 Tool 名称列表。
|
||||
extra: 需要保留在顶层的兼容字段,例如 batch_no。
|
||||
"""
|
||||
from app.services.shipping_notice.state_machine import (
|
||||
action_buttons_for_checkpoint,
|
||||
build_action_buttons,
|
||||
resolve_task_ui_state,
|
||||
)
|
||||
from app.services.shipping_notice.state_machine import resolve_task_ui_state
|
||||
|
||||
if task is not None and not task_id:
|
||||
task_id = task.task_no
|
||||
|
||||
gate_owns_recovery = _task_has_process_execution(task)
|
||||
# action_buttons 是历史调用参数,仅为兼容调用方签名;绝不进入对外响应。
|
||||
del action_buttons
|
||||
resolved_checkpoint = checkpoint
|
||||
resolved_human_options = human_options
|
||||
resolved_action_buttons = action_buttons
|
||||
|
||||
if checkpoint is None and task is not None:
|
||||
ui = resolve_task_ui_state(task)
|
||||
resolved_checkpoint = ui.checkpoint
|
||||
if human_options is None:
|
||||
resolved_human_options = ui.human_options
|
||||
# [STEP] Gate 绑定任务:忽略状态机推导的旧动作按钮。
|
||||
if not gate_owns_recovery and action_buttons is None and ui.action_buttons:
|
||||
resolved_action_buttons = ui.action_buttons
|
||||
|
||||
payload: dict[str, Any] = {
|
||||
"status": status,
|
||||
@@ -127,17 +120,7 @@ def tool_response(
|
||||
if resolved_human_options is not None:
|
||||
payload["human_options"] = resolved_human_options
|
||||
|
||||
# [STEP] ProcessExecution 存在时业务调用清零旧动作字段(含调用方显式传入)。
|
||||
if gate_owns_recovery:
|
||||
payload["action_buttons"] = []
|
||||
elif resolved_action_buttons is not None:
|
||||
payload["action_buttons"] = resolved_action_buttons
|
||||
elif resolved_human_options is not None:
|
||||
payload["action_buttons"] = build_action_buttons(resolved_human_options)
|
||||
elif resolved_checkpoint:
|
||||
buttons = action_buttons_for_checkpoint(resolved_checkpoint)
|
||||
if buttons:
|
||||
payload["action_buttons"] = buttons
|
||||
# [STEP] 业务按钮统一由 ui_state.actions 返回;Tool 响应不再生成旧 action_buttons。
|
||||
if resolved_checkpoint:
|
||||
payload["checkpoint"] = resolved_checkpoint
|
||||
if next_required_action and not gate_owns_recovery:
|
||||
@@ -148,8 +131,7 @@ def tool_response(
|
||||
payload["stop_agent_turn"] = True
|
||||
if extra:
|
||||
payload.update(extra)
|
||||
# [STEP] extra 不得绕过 Gate 绑定任务的旧动作清零。
|
||||
# [STEP] extra 不得绕过 Gate 绑定任务的旧 next_required_action 约束。
|
||||
if gate_owns_recovery:
|
||||
payload["action_buttons"] = []
|
||||
payload.pop("next_required_action", None)
|
||||
return payload
|
||||
Reference in new issue
Block a user