Record REV004 regression and fallback-reduction evidence

The evidence captures the new regression scripts, formal-first query
narrowing, and the fresh verification trail used to support the next
round of fallback removal.

Constraint: Evidence must match commands and outcomes actually executed in backend worktree
Rejected: Fold this into an older summary doc | would hide the stepwise proof for fallback reduction
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep appending fresh verification evidence here until the remaining legacy fallback is either removed or explicitly retained
Tested: Evidence cross-checked against backend worktree commands, regression logs, and targeted test outputs
Not-tested: No doc export/render pipeline executed
This commit is contained in:
tangweijie 2026-04-20 15:02:24 +08:00
parent 24761c5df3
commit 1b6fda9c4d

View File

@ -0,0 +1,171 @@
# REV004 自动化回归脚本 + legacy fallback 缩减2026-04-17
## 本轮目标
1. 为 REV004 建立可重复执行的自动化回归脚本入口。
2. 继续缩小 accountProcess 对 legacy fallback 的直接依赖面。
## 后端代码变更
### 1. 新增回归脚本目录
后端新增:`script/rev004-regression/`
- `env.sh`
- `01_prepare_env.sh`
- `02_unit_regression.sh`
- `03_live_db_smoke.sh`
- `04_summary.sh`
- `run_all.sh`
说明:
- unit 回归默认覆盖:`AccountingAdjustQueryServiceImplTest``AccountingAdjustProcessServiceImplTest``AccountingAdjustActionServiceImplTest``ChargeServiceAccountingAdjustTest``PrestorageFormalizationServiceTest`
- live DB smoke 默认覆盖:
- `Rev004AccountProcessLiveDbReadinessTest`
- `Rev004AccountProcessCanaryQueryIntegrationTest`
- `prestoragePage_shouldReturnSuccessEnvelope`
- `prestorageSubmit_shouldChangeBalanceAndWriteOperatLog`
- `prestorageRevoke_shouldRestoreBalanceAndWriteRevokeLog`
- `prestorageSubmit_thenProcessAndAttachmentsShouldExposeReturnedAdjustmentNo`
### 2. 缩减 legacy fallback 使用面
#### `AccountingAdjustProcessServiceImpl`
- `getProcess(...)`:调整为
- prestorage formal 优先
- unified snapshot 次优先
- synthetic snapshot 仅在 unified 缺失时兜底
- `getAttachments(...)`:调整为
- prestorage formal 优先
- unified snapshot 次优先
- synthetic snapshot 仅在 unified 缺失时兜底
#### `AccountingAdjustQueryServiceImpl`
- page 聚合时,先汇总 formal adjustmentNo 集合
- legacy request log 转换出的 request record 若 adjustmentNo 已被 formal 记录覆盖,则不再进入 merged 集合
- 保留 legacy log 的审计/兜底职责,但不再重复参与 formal 已覆盖对象的主结果聚合
## 新增/更新测试
### 单测补强
- `AccountingAdjustProcessServiceImplTest`
- `getProcess_shouldPreferUnifiedSnapshotOverSyntheticFallback`
- `getAttachments_shouldPreferUnifiedSnapshotOverSyntheticFallback`
- `AccountingAdjustQueryServiceImplTest`
- `getAccountingAdjustPage_shouldSkipLegacyRequestRecordWhenFormalRecordExists`
## 验证结果
### 1. unit 回归
执行:
```bash
script/rev004-regression/02_unit_regression.sh
```
结果:
- `Tests run: 68, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`
### 2. live DB smoke
执行:
```bash
script/rev004-regression/03_live_db_smoke.sh
```
结果:
- `Tests run: 5, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`
### 3. 一键入口
执行:
```bash
script/rev004-regression/run_all.sh
```
结果:
- unit + live DB smoke 均通过
- 日志目录:
- `.omx/logs/rev004-regression/20260417T110151Z`
## 当前边界
- 当前 live DB smoke 默认仍以 prestorage 稳定链路为主,用来验证真实数据库 + Spring + MockMvc + formal/legacy 协同路径。
- writtenoff / price diff / redink / bad debt 在本轮主要由 targeted unit regression 覆盖;后续可继续补到 live DB fixture。
- `Rev004AccountProcessCanaryQueryIntegrationTest` 中仍有其它更大范围场景未纳入默认 smoke 入口,本轮没有把它们全部收进默认脚本,以避免把未收敛场景误当作回归主入口。
## 结论
本轮已完成:
- REV004 自动化回归脚本首版落地
- 一键执行入口可用
- process / attachments 的 legacy fallback 优先级继续收口
- page 聚合中的 duplicate legacy request 参与面继续缩小
## 追加收口(继续删 fallback
### Query 层进一步收口
- `AccountingAdjustQueryServiceImpl#getAccountingAdjustPage(...)`
- `loadLatestActionMap(...)` 改为只对 legacy request records 构建 action overlay
- formal 记录即使 chargeId 下存在 legacy approval log也不再被 legacy 审批轨迹回填覆盖主状态
### 新增回归测试
- `getAccountingAdjustPage_shouldNotLetLegacyApprovalOverrideFormalRecord`
- 验证formal 已存在时legacy approval log 不再覆盖 formal 的 `approvalStatus/resultStatus/writeBackStatus/message/actionAmount`
### 本次追加验证
执行:
```bash
mvn -pl sw-business/sw-business-server -Dtest=AccountingAdjustQueryServiceImplTest,AccountingAdjustProcessServiceImplTest test
```
结果:
- `Tests run: 32, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`
### 统计口径锁定
新增测试:
- `getAccountingAdjustStat_shouldIgnoreLegacyApprovalForFormalRecord`
验证:
- formal record 已存在时legacy approval/action 不再把统计口径从 `PENDING_APPROVAL` 误改成 `APPROVED`
- `totalActionAmount` 仍取 formal 金额
执行:
```bash
mvn -pl sw-business/sw-business-server -Dtest=AccountingAdjustQueryServiceImplTest test
```
结果:
- `Tests run: 13, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`
再次执行:
```bash
script/rev004-regression/run_all.sh
```
结果:
- unit`Tests run: 69, Failures: 0, Errors: 0, Skipped: 0`
- live smoke`Tests run: 5, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`
### 日志查询口径锁定
新增测试:
- `getAccountingAdjustLogs_shouldReturnSyntheticFormalLogWhenLegacyLogsMissing`
验证:
- formal 对象即使没有 legacy operat_log也能通过 `getAccountingAdjustLogs` 返回一条 synthetic formal log
- 前端日志页不再被 legacy log 是否存在所卡死
执行:
```bash
mvn -pl sw-business/sw-business-server -Dtest=AccountingAdjustQueryServiceImplTest test
```
结果:
- `Tests run: 14, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`
### action-only 日志补齐
新增测试:
- `getAccountingAdjustLogs_shouldPrependSyntheticFormalLogWhenOnlyActionLogExists`
验证:
- formal 对象若只有 legacy action log、没有 legacy request log
- 日志列表会自动在前面补一条 synthetic formal log再保留 legacy action log
- 前端日志时间线可同时看到 formal 主记录和 legacy 审批动作
执行:
```bash
mvn -pl sw-business/sw-business-server -Dtest=AccountingAdjustQueryServiceImplTest test
```
结果:
- `Tests run: 15, Failures: 0, Errors: 0, Skipped: 0`
- `BUILD SUCCESS`