fix(shipping-notice): 修复流程门禁审计与库存匹配同步

This commit is contained in:
hugo committed 2026-09-14 18:37:17 +08:00
1 parent fbca0b485c
commit 9745bb78a7
14 files changed
+832 -154

No files matched your search

@@ -2946,6 +2946,14 @@ pytest tests/test_shipping_notice_state_machine.py tests/test_shipping_notice_ui
- **旧五门禁**:内部仍评估 `can_auto_create`,但禁止 `auto_build_gate_*` 平行用户阻断;用户可见最多一条「自动建单策略尚未放行」。
- **投影**:`process_gate_projection` 分离用户安全投影与管理员诊断投影;`ui_state` / Workflow 提示优先消费统一 Gate 摘要。
### Process Gate 锁顺序(2026-09-14)
- **顺序**:`Task → Job(任务级 SHIPPING_PROCESS_GATE) → Execution → Gate(sequence_no ASC) → Attempt → 叶子(Attempt 绑定 Job / RecoveryPlan)`。
- **硬规则**:同一事务既改 Attempt 又改 Gate/Execution 时,必须 `FOR UPDATE` **Execution → Gate → Attempt**;禁止只锁 Attempt 后无锁 UPDATE Gate/Execution。
- **入口**:`mark_attempt_running` / `complete_gate_attempt` / `recover_stale_gate_attempts` 经 `_lock_execution_gate_attempt`;Worker `claim` 领取前不得单独先锁 Attempt。
- **心跳**:仅锁 Attempt 并立即 commit,不碰 Gate/Execution。
- **审计**:SAVEPOINT + 门禁 `strict=False`;审计失败不得回滚 Gate 业务结果。
### STP 阶段 3:自动建单与复核工作台(2026-07-30)
- 抽取收尾 `maybe_stp_auto_create_for_run`:无人工改脏且资格 ready 时幂等自动建单并 `auto_progress`。