# LSFX Mock Server 异常账户后端验证记录

## 1. 验证命令

按实施过程实际执行了以下命令：

```bash
cd lsfx-mock-server
python3 -m pytest tests/test_file_service.py::test_fetch_inner_flow_should_attach_abnormal_account_rule_plan -v
python3 -m pytest tests/test_statement_service.py -k "sudden_account_closure or dormant_account_large_activation" -v
python3 -m pytest tests/test_statement_service.py::test_generate_statements_should_follow_abnormal_account_rule_plan_from_file_record -v
python3 -m pytest tests/test_file_service.py tests/test_statement_service.py -v
python3 -m pytest tests/ -v
```

README 补充后按计划追加执行：

```bash
cd lsfx-mock-server
python3 -m pytest tests/test_statement_service.py -v
```

合并到 `dev` 后补充执行：

```bash
python3 -m pytest lsfx-mock-server/tests/test_statement_service.py::test_get_bank_statement_should_preserve_abnormal_account_mask_no -v
python3 -m pytest lsfx-mock-server/tests/test_file_service.py lsfx-mock-server/tests/test_statement_service.py -v
python3 main.py --rule-hit-mode all
```

启动服务后，使用标准库 `urllib` 调用了以下两个接口做运行态核验：

```text
POST /watson/api/project/getJZFileOrZjrcuFile
POST /watson/api/project/getBSByLogId
```

## 2. 验证结果摘要

- `tests/test_file_service.py::test_fetch_inner_flow_should_attach_abnormal_account_rule_plan`：通过
- `tests/test_statement_service.py -k "sudden_account_closure or dormant_account_large_activation"`：通过
- `tests/test_statement_service.py::test_generate_statements_should_follow_abnormal_account_rule_plan_from_file_record`：通过
- `python3 -m pytest tests/test_file_service.py tests/test_statement_service.py -v`：`43 passed`
- `python3 -m pytest tests/ -v`：`84 passed`
- `python3 -m pytest tests/test_statement_service.py -v`：`26 passed`
- `python3 -m pytest lsfx-mock-server/tests/test_statement_service.py::test_get_bank_statement_should_preserve_abnormal_account_mask_no -v`：通过
- `python3 -m pytest lsfx-mock-server/tests/test_file_service.py lsfx-mock-server/tests/test_statement_service.py -v`：`44 passed`

运行态 HTTP 验证结果：

- `logId=16724`
- 返回流水总数：`200`
- `SUDDEN_ACCOUNT_CLOSURE` 命中样本：`3` 条
- `DORMANT_ACCOUNT_LARGE_ACTIVATION` 命中样本：`3` 条
- 销户规则账号：`6222006485425901`
  日期：`2026-02-18`、`2026-03-07`、`2026-03-18`
  结论：全部落在销户日前 30 天窗口内
- 休眠激活规则账号：`6222004693652802`
  日期：`2025-07-01`、`2025-07-10`、`2025-07-19`
  累计金额：`560000.0`
  单笔最大金额：`260000.0`
  结论：满足开户满 6 个月后激活、累计金额阈值和单笔最大金额阈值

## 3. 过程说明

- 回归期间发现 `all` 模式安全噪声测试未同步清空新增的异常账户规则维度，导致异常账户样本被计入噪声断言
- 已通过补齐测试夹具方式修正，随后重新执行聚焦回归和全量回归，结果均通过
- 合并到 `dev` 后的 HTTP 验证又发现 `getBSByLogId` 返回前会覆盖异常账户样本账号，已通过新增回归用例与最小实现修正

## 4. 进程清理

本轮验证过程中临时启动了 `lsfx-mock-server` 的 `python3 main.py --rule-hit-mode all` 进程，验证完成后已主动停止，无残留端口占用。
