fix(shipping-process-gates): 收口技术重试并补齐运维 UI

跨 Job 累计技术失败次数,耗尽后将 Attempt/Gate 置为 failed_terminal;
收缩旧 action_buttons;healthcheck 增加 Worker 领取探针;恢复卡展示责任方与审计,Admin 诊断改主从布局。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-01 13:54:14 +08:00
1 parent 323928626b
commit cef3d5b26a
15 files changed
+489 -150

No files matched your search

@@ -6,8 +6,8 @@ services/shipping_notice/ui_state.py
process_gate_projection(统一 Gate 用户摘要)。
逻辑:从 ShippingTask DB 字段经状态机解析 checkpoint/checkpoint_kind/action_buttons,
再补充七步流程与可解释 summary(当前待办、暂停原因、下一自动步骤、操作入口、stp_facts);
若存在 ProcessExecution 且当前有 blocking Gate,则清空 action_buttons,
恢复动作仅由 process_gate 驱动(Gate 为唯一业务真相);
若存在 ProcessExecution:阻断时清空 action_buttons;非阻断时仅保留
download_excel / mark_manual_uploaded / refresh(恢复动作仅由 process_gate 驱动);
批次 UI 仅作会话上传集合摘要,不作为履约写操作面。
"""
@@ -555,9 +555,17 @@ def build_task_ui_state(task: ShippingTask) -> dict[str, Any]:
ui = resolve_task_ui_state(task)
action_buttons = _action_buttons_for_task(task)
process_gate = _process_gate_user_summary_for_task(task)
# [STEP] Gate 阻断时旧 action_buttons 不再作为业务恢复真相,避免双卡片/双动作。
if isinstance(process_gate, dict) and process_gate.get('current_blocking_gate'):
action_buttons = []
# [STEP] 存在 ProcessExecution 时恢复动作仅由 process_gate 驱动;
# 仅保留非恢复类 STP 动作(下载 Excel / 人工上传凭据 / 刷新)。
_non_recovery_action_ids = frozenset({'download_excel', 'mark_manual_uploaded', 'refresh'})
if isinstance(process_gate, dict):
if process_gate.get('current_blocking_gate'):
action_buttons = []
else:
action_buttons = [
button for button in action_buttons
if str((button or {}).get('id') or '') in _non_recovery_action_ids
]
steps = build_shipping_workflow_steps(task, ui.checkpoint)
current_index = _derive_current_step_index(task)
current_step = steps[current_index] if 0 <= current_index < len(steps) else None