feat(shipping-process-gates): 落地全门禁中断恢复并消除双真相

纳入 Execution/Gate/Attempt 模型与迁移、Worker/API/前端恢复卡片与 Admin 诊断,
Gate 阻断时清零旧 action_buttons,异常摘要统一脱敏,并为运维筛选与 Attempt Diff 补齐入口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-01 13:08:32 +08:00
1 parent b352c281d5
commit 323928626b
92 files changed
+11930 -458

No files matched your search

@@ -5,11 +5,11 @@ backend/app/services/shipping_notice/audit_service.py
写入 Workflow 软引用与哈希链字段。
依赖:ShippingAuditEvent、progress_audit_contract、audit_snapshot_service(在 append 内导入以避免环)、
SQLAlchemy 会话。
逻辑:Run、Task、Workflow Item、库存和 Chatflow 服务调用本模块写入状态与决策事实;
逻辑:Run、Task、Workflow Item、库存、门禁 Attempt 和 Chatflow 服务调用本模块写入状态与决策事实;
写入前投影白名单快照 → 计算 diff → 解析同聚合 previous_event_hash → 计算 event_hash;
本服务不提交事务,由调用方保证业务与审计原子性。支持 operation_id、白名单前后快照、
证据引用、Workflow 软引用(非 session_item)、属主;货代全业务审计事件永久保留
(retention_expires_at=None),清理 Job 仅处理历史遗留的到期行。IP / User-Agent 仅持久化哈希。
证据引用、Workflow 软引用(非 session_item)、属主;actor_type 含 worker(门禁 Job);
货代全业务审计事件永久保留(retention_expires_at=None),清理 Job 仅处理历史遗留到期行。
"""
from __future__ import annotations
@@ -245,7 +245,8 @@ def append_shipping_audit_event(
resolve_previous_event_hash,
)
allowed_actor_types = {'user', 'system', 'rpa', 'chatflow', 'admin'}
# worker:门禁 Attempt / Job 租约路径的执行主体(Phase 4+)。
allowed_actor_types = {'user', 'system', 'rpa', 'chatflow', 'admin', 'worker'}
if actor_type not in allowed_actor_types:
raise ValidationError('Invalid shipping audit actor type', code='SHIPPING_NOTICE.AUDIT_ACTOR_INVALID')
if result is not None and result not in {'success', 'failure', 'rejected', 'ignored'}: