Files
syops/docs/superpowers/plans/2026-10-17-freight-rpa-upload-action-fix.md
T
hugoandCursor 39fe3c05f2 feat(freight-rpa): 库存/收料改名在手/入站,报表归属RPA,类名统一FreightRpa
把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与
枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa
持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀,
上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-19 10:46:06 +08:00

79 lines
3.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Freight RPA upload action 纠偏 Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** 把批次 R 误写的 upload trigger action `outbound_upload` 改回与心跳能力一致的 `freight_upload`,消除「出站 outbound」与「履约上传 upload」混名。
**Architecture:** upload 是与 onhand/inbound/outbound **同级独立域**。trigger schema 保持 `freight_rpa.upload.v1`;action 与心跳能力串 `FREIGHT_UPLOAD_CAPABILITY = "freight_upload"` 对齐。不做 `freight_rpa_upload`(见下方裁决)。
**Tech Stack:** Python / Flask;Worker 侧 `onhand_rpa_worker._handle_upload_trigger` 当前不校验 action 字面量,但仍须双侧契约文档一致。
**Ruling(2026-10-17):** 否决把 `freight_upload` 改成 `freight_rpa_upload`。理由:心跳能力、lifecycle stage、gate `freight_upload_rpa` 已广泛使用 `freight_upload`;`freight_rpa_*` 是包/表/env 命名空间,action 用短动词与 `onhand_export`/`inbound_export` 同形。改成 `freight_rpa_upload` 会制造第三套词根且波及 shipping_notice 生命周期契约,超出本纠偏。
**Spec 权威:** `docs/superpowers/specs/2026-10-16-freight-rpa-decouple-and-rename-design.md`(upload action 对齐 freight_upload)+ `docs/features/freight-rpa/GLOSSARY.md` Upload 条。
---
## File map
| File | Responsibility |
| --- | --- |
| `backend/app/services/freight_rpa/upload/trigger_io.py` | 常量 + 写入 action |
| `backend/tests/services/freight_rpa/**`(若已有 upload 契约测)或新建最小单测 | 断言 action/schema |
| `docs/features/freight-rpa/GLOSSARY.md` / cutover-runbook / batch-R 勘误 | 已就地写明;本计划只确认代码落地 |
---
### Task 1: upload action → `freight_upload`
**Files:**
- Modify: `backend/app/services/freight_rpa/upload/trigger_io.py`
- Modify or create: focused test under `backend/tests/services/freight_rpa/`(优先改既有;无则新建 `test_upload_trigger_contract.py`)
- [ ] **Step 1: 写失败测试**
断言 `ACTION_*`(或写入 trigger 后读出的 `action`)等于 `"freight_upload"`,`schema_version` 等于 `"freight_rpa.upload.v1"`。禁止再出现 `outbound_upload` / `shipment_upload`。
- [ ] **Step 2: 跑测确认失败**
```bash
cd backend && python -m pytest tests/services/freight_rpa/ -k upload -q
```
Expected: 失败(当前常量仍是 outbound_upload)或新增测未发现常量。
- [ ] **Step 3: 改常量与注释**
- 将 `ACTION_OUTBOUND_UPLOAD = "outbound_upload"` 改为 `ACTION_FREIGHT_UPLOAD = "freight_upload"`
- 更新所有引用
- 文件头 docstring:说明 action 对齐心跳 `freight_upload`;upload 独立域,禁止 outbound_* / shipment_* 作为 upload action
- 禁止引入 `freight_rpa_upload`
- [ ] **Step 4: 跑测通过**
```bash
cd backend && python -m pytest tests/services/freight_rpa/ -k upload -q
```
另跑:
```bash
rg -n "outbound_upload|ACTION_OUTBOUND_UPLOAD" backend/app scripts/freight_rpa
```
Expected: 代码命中清零(文档勘误「勿用 outbound_upload」可保留)。
- [ ] **Step 5: 暂存,不提交**
`git add` 相关文件;**不要 commit**(等用户批准)。
---
## Global Constraints
- 不改 lifecycle / gate / i18n 里的 `freight_upload` 业务词(它们本来就对)
- 不改 `shipment_*` 履约出货命名
- 不改 `freight_rpa/outbound/` 调拨出站骨架
- 不做双路由/兼容层
- 三层注释规范(文件头 + 函数)随改同步