docs(pricing): 计划 Task 5 补设计文档 §5.2 修正步 + Self-Review 记录范围外死代码删除裁决

This commit is contained in:
2026-09-01 15:10:32 +08:00
parent 7ff9743acc
commit a52d66cd88
@@ -669,6 +669,7 @@ git commit --only service/pricing/charge_calc.go service/pricing/charge_calc_tes
**Files:**
- Modify: `docs/superpowers/specs/2026-08-28-pricing-enum-design.md`9 处精确替换)
- Modify: `docs/superpowers/specs/2026-09-01-pricing-media-price-design.md`(§5.2 代码块语法修正)
- 无 Go 代码改动
**Interfaces:**
@@ -744,17 +745,34 @@ git commit --only service/pricing/charge_calc.go service/pricing/charge_calc_tes
`ChargeUsage.MediaType` §5.3 225 行保留不动——上报入参字段。)
- [ ] **Step 10: 全量编译 + 全量测试**
- [ ] **Step 10: 设计文档 §5.2 代码块语法修正**
Run: `cd /c/App/GolandProjects/shop-user-trade && go build ./... && go test ./service/pricing/ ./model/dto/pricing/ -count=1`
Expected: PASS
`docs/superpowers/specs/2026-09-01-pricing-media-price-design.md` §5.2 的 mediaPrices 校验代码块中,`ModelMediaSet``map[string]struct{}``!pricingConsts.ModelMediaSet[mt]` 无法编译。将该判断改为 `_, ok` 成员判定(与实现一致;实现已将校验提取为共享 `validateMediaPrices` helper):
- [ ] **Step 11: 提交**
```go
if len(r.Rules[i].MediaPrices) > 0 {
for mt, mp := range r.Rules[i].MediaPrices {
if _, ok := pricingConsts.ModelMediaSet[mt]; !ok {
return nil, errors.New("model 费率 mediaPrices 键须为 text/audio/video/image")
}
if mp == nil {
return nil, errors.New("model 费率 mediaPrices 值须配置 price")
}
}
}
```
- [ ] **Step 11: 全量编译 + 全量测试**
Run: `cd /c/App/GolandProjects/shop-user-trade && go build ./... && GF_GCFG_PATH="C:/App/GolandProjects/shop-user-trade" go test ./service/pricing/ ./model/dto/pricing/ -count=1`
Expected: PASSservice/pricing 25 用例全绿;GF_GCFG_PATH 规避 common/consul init panic
- [ ] **Step 12: 提交**
```bash
git add docs/superpowers/specs/2026-08-28-pricing-enum-design.md
git add docs/superpowers/specs/2026-08-28-pricing-enum-design.md docs/superpowers/specs/2026-09-01-pricing-media-price-design.md
git status --short
git commit --only docs/superpowers/specs/2026-08-28-pricing-enum-design.md -m "docs(pricing): 枚举设计 §4.2/§5.2/§8 同步 mediaPrices v0.4"
git commit --only docs/superpowers/specs/2026-08-28-pricing-enum-design.md docs/superpowers/specs/2026-09-01-pricing-media-price-design.md -m "docs(pricing): 枚举设计 §4.2/§5.2/§8 同步 mediaPrices v0.4 + 设计文档 §5.2 语法修正"
```
---
@@ -766,3 +784,4 @@ git commit --only docs/superpowers/specs/2026-08-28-pricing-enum-design.md -m "d
- **类型一致性**`ModelMediaSet`Task1 定义)Task3 消费;`modelRule.MediaPrices`Task1Task3/4 消费;`pickModelPrice`/`validateMediaPrices` 签名在定义与调用处一致;`modelMatch` 无 MediaType 贯穿全部测试构造。
- **测试互不依赖**:Task 3/4 测试追加到同一 `charge_calc_test.go`Task 4 全量跑含 Task 2/3 用例(25 个 = Task2 6 + Task3 5 + Task4 媒体价 6 + 回归 8),顺序无关。
- **回归裁决**Task 2 审查发现旧 charge_calc_test.goHEAD 存在 10 测试)被覆盖删除,用户裁决「维持删除,Task 4 补回归」——Task 4 已加 8 个回归测试(阶梯算费/无匹配/cache-hit/M3 负值钳制/P2 base 不匹配/P1 nil-price×2/单位多路径),fixture 去 mediaTypeper_period/分派路径未恢复(设计不改动),记 ledger minor。
- **范围外死代码删除(最终审查裁决)**:Task 1 顺带删除了共享 `calculator` 接口的 `mode()` 方法(6 个计算器实现)与 `ChargeUsage.ItemCount` 字段。最终整分支审查(opus)核实为**死代码**——`.mode(` 全模块零调用(分派走显式 workflowCalculators/modelCalculators/businessCalculators maps + getCalculator),`ItemCount` 零 Go 引用(仅 charge_dto.go:33 doc 注释提及)。计划 §11「不改动 ChargeUsage 字段 / workflow-business 计算器」文本与之冲突,用户裁决「保留删除 + 记录确认」。