feat(threshold): Implement customer loss threshold configuration and notification system
- Added `ThresholdRepository` for managing customer loss threshold configurations and notifications. - Introduced `threshold_service` to handle loss threshold alerts based on customer portfolio performance. - Enhanced `customer_prompts` to include new intent for querying product net values. - Updated `customer_service` to integrate new threshold alert functionality into existing workflows. - Implemented `sanitize_postprocess` for improved compliance handling in customer interactions. - Enhanced course documentation to reflect updates in advisor training modules and interactive elements. This update significantly improves the customer experience by providing proactive loss threshold notifications and enhancing the overall service framework.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# 手工验收清单 · TEST-2026-09-10-CS-001
|
||||
|
||||
## 前置
|
||||
|
||||
- [ ] `merger` 分支最新代码
|
||||
- [ ] Core:`.\scripts\core\reset.ps1`(CUST-9527 持仓 3 只)
|
||||
- [ ] Agent 表已建(`01-mysql-共用底座.sql`)
|
||||
- [ ] Redis Docker 6380 · `.env` `REDIS_URL=redis://127.0.0.1:6380/0`
|
||||
- [ ] R1 演示:`python scripts/dev/run_sql_file.py scripts/agent/seed-customer-profile-l1-r1-demo.sql` + `DEL profile:l1:CUST-9527`
|
||||
|
||||
## 1B · 数据查询 sanitize 不误转人工
|
||||
|
||||
| # | 步骤 | 期望 | 结果 |
|
||||
| --- | --- | --- | --- |
|
||||
| 1 | 登录 CUST-9527,问「我的持仓怎么样」 | 回复含 Core 真数(如 3 只产品) | ☐ |
|
||||
| 2 | 同上,观察 `transfer_to_human` | **false**(无橙色转人工 Tag) | ☐ |
|
||||
| 3 | 问「推荐稳赚基金」 | reject 静态拒答,transfer **false** | ☐ |
|
||||
| 4 | 输入「转人工」 | transfer **true** | ☐ |
|
||||
|
||||
## R1 · 偏好 Top-K 注入
|
||||
|
||||
| # | 步骤 | 期望 | 结果 |
|
||||
| --- | --- | --- | --- |
|
||||
| 5 | 灌 R1 种子后闲聊/RAG 一轮 | prompt 侧画像含「货币基金、债券基金」等 Top-3 | ☐ |
|
||||
| 6 | 确认不含「指数基金」 | 2020 条目超 TTL=90d 被过滤 | ☐ |
|
||||
|
||||
## 自动化(CI 等价)
|
||||
|
||||
```powershell
|
||||
python -m pytest tests/test_wave3_customer_service.py tests/test_wave3_profile_service.py -q
|
||||
python -m pytest -q
|
||||
```
|
||||
@@ -0,0 +1,28 @@
|
||||
# 测试包 · 客服 1B / 画像 R1(2026-09-10)
|
||||
|
||||
| 项 | 值 |
|
||||
| --- | --- |
|
||||
| 测试记录编号 | `TEST-2026-09-10-CS-001` |
|
||||
| 模块 | 客户财富 Agent(CS Wave 3) |
|
||||
| 模块负责人 | zhangyong |
|
||||
| 修改人 | Andrew |
|
||||
| 关联拍板 | 1B · R1 · L0 优先 · C-04~C-11(部分) |
|
||||
|
||||
## 文件
|
||||
|
||||
| 文件 | 说明 |
|
||||
| --- | --- |
|
||||
| [TEST-LOG-2026-09-10-CS-001.md](./TEST-LOG-2026-09-10-CS-001.md) | 企业级测试日志(缺陷发现 → 修复 → 回归) |
|
||||
| [MANUAL-CHECKLIST.md](./MANUAL-CHECKLIST.md) | 手工验收步骤(含数据灌入) |
|
||||
|
||||
## 数据灌入(可选 · R1 手工验 Top-K)
|
||||
|
||||
```powershell
|
||||
# Agent 库 L1 演示数据(CUST-9527 · 含 items_meta)
|
||||
python scripts/dev/run_sql_file.py scripts/agent/seed-customer-profile-l1-r1-demo.sql
|
||||
|
||||
# 清 Redis 热缓存(6380)
|
||||
redis-cli -p 6380 DEL profile:l1:CUST-9527
|
||||
```
|
||||
|
||||
**1B 持仓 sanitize** 不依赖 L1 种子,仅需 Core 库 CUST-9527 持仓(`scripts/core/reset.ps1` 已有)。
|
||||
@@ -0,0 +1,170 @@
|
||||
# 企业级测试日志 · TEST-2026-09-10-CS-001
|
||||
|
||||
> 客户财富 Agent · sanitize 分治(1B)+ L1 偏好 Top-K(R1)+ Wave3 能力(C-04/C-05/C-11 等)
|
||||
|
||||
---
|
||||
|
||||
## 1. 文档元数据
|
||||
|
||||
| 字段 | 值 |
|
||||
| --- | --- |
|
||||
| **测试记录编号** | TEST-2026-09-10-CS-001 |
|
||||
| **缺陷/变更标题** | 1B/R1 合规拍板 + Wave3 数据查询扩展 + keyword 优先级 |
|
||||
| **文档版本** | v1.1 |
|
||||
| **创建日期** | 2026-09-10 |
|
||||
| **最后更新** | 2026-09-10 |
|
||||
| **关联分支** | `merger` |
|
||||
| **关联拍板 ID** | 1B · R1 · L0 优先 · C-04 · C-05 · C-11 · C-07 · C-08 |
|
||||
| **关联 TODO / 需求** | MEMORY §3 · REQUIREMENTS Wave3 · TODO 客服 Wave3 批次 |
|
||||
| **风险等级** | MEDIUM(合规体验 + 意图路由回归) |
|
||||
| **缺陷类型** | 逻辑缺陷 ×3(sanitize 分治 · 画像注入 · keyword 优先级)+ 能力增量 ×5 |
|
||||
| **发现阶段** | 代码走读 + 课程缺口 + pytest 回归 |
|
||||
| **修复阶段** | TDD 单测 + 全量 pytest 786 绿 |
|
||||
|
||||
---
|
||||
|
||||
## 2. 组织与责任
|
||||
|
||||
| 字段 | 值 |
|
||||
| --- | --- |
|
||||
| **所属系统** | JinRong 金融四 Agent 智能管家 |
|
||||
| **所属模块** | 客户财富 Agent(CS Wave 3) |
|
||||
| **子模块 / 服务** | `customer_service` · `visitor_service` · `profile_service` · `threshold_service` · `sanitize_postprocess` |
|
||||
| **模块负责人** | zhangyong |
|
||||
| **发现人** | Andrew |
|
||||
| **修改人** | Andrew |
|
||||
| **测试执行人** | Andrew |
|
||||
| **评审人** | (待模块负责人确认) |
|
||||
| **发布建议** | 可合并 `merger`;C-04 无 push/cron 为已知缺口 |
|
||||
|
||||
---
|
||||
|
||||
## 3. 环境与基线
|
||||
|
||||
| 字段 | 值 |
|
||||
| --- | --- |
|
||||
| **测试环境** | development · 本机 Windows |
|
||||
| **Python** | 3.13 · pytest 8.4.2 |
|
||||
| **数据库** | MySQL `jinrong_agent` + `jinrong_core`(模拟库) |
|
||||
| **Redis** | Docker 6380 · RESP2(R1 手工项可 skip) |
|
||||
| **修复前测试基线** | 774 passed |
|
||||
| **中间基线(1B/R1)** | 776 passed, 1 skipped |
|
||||
| **修复后测试基线** | **786 passed**, 1 skipped |
|
||||
| **前端** | 未在本轮执行 Vitest |
|
||||
|
||||
---
|
||||
|
||||
## 4. 缺陷与变更描述
|
||||
|
||||
### 4.1 缺陷 A · 1B — 数据查询 sanitize 误转人工
|
||||
|
||||
| 字段 | 内容 |
|
||||
| --- | --- |
|
||||
| **缺陷编号** | DEF-CS-2026-09-10-001 |
|
||||
| **严重等级** | P2 |
|
||||
| **修复方案** | 抽到 `app/utils/sanitize_postprocess.py` · `finalize_sanitized_reply`;customer + visitor 共用 |
|
||||
| **变更文件** | `sanitize_postprocess.py` · `customer_service.py` · `visitor_service.py` · `test_sanitize_postprocess.py` |
|
||||
|
||||
### 4.2 缺陷 B · R1 — L1 偏好全量平铺注入
|
||||
|
||||
| 字段 | 内容 |
|
||||
| --- | --- |
|
||||
| **缺陷编号** | DEF-CS-2026-09-10-002 |
|
||||
| **严重等级** | P3 |
|
||||
| **修复方案** | `items_meta` + Top-K/TTL · `settings.profile_preference_*` |
|
||||
| **变更文件** | `profile_service.py` · `settings.py` · `test_wave3_profile_service.py` |
|
||||
|
||||
### 4.3 缺陷 C · keyword_route — save_note 抢数据查询
|
||||
|
||||
| 字段 | 内容 |
|
||||
| --- | --- |
|
||||
| **缺陷编号** | DEF-CS-2026-09-10-003 |
|
||||
| **严重等级** | P2 |
|
||||
| **复现** | 「帮我记住最近的流水」误命中 `save_note` 而非 `transaction_query` |
|
||||
| **根因** | save_note 关键词块排在数据查询之前 |
|
||||
| **修复** | 顺序:数据查询(trade/risk/suitability/holding)→ save_note → eligible/nav |
|
||||
| **变更文件** | `customer_prompts.py` · `test_wave5_notes.py` |
|
||||
|
||||
### 4.4 能力增量 · Wave3(非缺陷)
|
||||
|
||||
| ID | 能力 | 落点 | 单测 |
|
||||
| --- | --- | --- | --- |
|
||||
| C-04 | 阈值摘要 → config;持仓达线 inline 提醒 | `threshold_service.py` · `core_ro_tool.query_holdings` | `test_threshold_service.py` |
|
||||
| C-05 | nav_query · Core 最新净值;实时净值 reject | `core_ro_tool.query_product_nav` | `test_wave2_prompts.py` · `test_wave3_customer_service.py` |
|
||||
| C-11 | 「我能买什么」→ suitability_check | `customer_prompts._ELIGIBLE_PRODUCTS_KW` | `test_wave2_prompts.py` |
|
||||
| C-07 | 重新测评关键词 → 引导网点 | `customer_prompts._RISK_KW` | `test_wave2_prompts.py` |
|
||||
| C-08 | L1 槽 `investment.allocation_target`(13 槽) | `profile_slots.py` | `test_wave2_profile_slots.py` |
|
||||
|
||||
---
|
||||
|
||||
## 5. 变更清单
|
||||
|
||||
| 类型 | 路径 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| 代码 | `app/utils/sanitize_postprocess.py` | 1B 共用分治 |
|
||||
| 代码 | `app/service/threshold_service.py` | C-04 新建 |
|
||||
| 代码 | `app/service/visitor_service.py` | 对齐 1B |
|
||||
| 代码 | `app/tool/core_ro_tool.py` | nav + 阈值 alert |
|
||||
| 代码 | `app/service/customer_prompts.py` | Wave3 意图 + keyword 顺序 |
|
||||
| 代码 | `app/config/profile_slots.py` | C-08 第 13 槽 |
|
||||
| 单测 | `tests/test_threshold_service.py` 等 | +10 例量级 |
|
||||
| 记忆 | MEMORY / REQUIREMENTS / FLOW / TODO / FRAMEWORK / ITERATION | 786 基线 · Wave3 状态 |
|
||||
| 课程 | `modules/04~07` · `build_all.py` | 1B 路径 · Wave3 模块 7 |
|
||||
| 种子 | `scripts/agent/seed-customer-profile-l1-r1-demo.sql` | R1 手工验 |
|
||||
|
||||
---
|
||||
|
||||
## 6. 测试执行记录
|
||||
|
||||
| 序号 | 类型 | 用例 / 命令 | 执行时间 | 执行人 | 结果 | 证据 |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| 1 | 单元 | 1B/R1 原 5 项 | 2026-09-10 | Andrew | **PASS** | 见 v1.0 |
|
||||
| 2 | 单元 | `test_threshold_service.py` | 2026-09-10 | Andrew | **PASS** | C-04 解析/alert |
|
||||
| 3 | 单元 | `test_sanitize_postprocess.py` | 2026-09-10 | Andrew | **PASS** | nav_query 在 DATA_QUERY |
|
||||
| 4 | 单元 | `test_keyword_route_save_note_priority` | 2026-09-10 | Andrew | **PASS** | 修顺序后绿 |
|
||||
| 5 | 模块 | `test_wave2_prompts` · `test_wave3_customer_service` | 2026-09-10 | Andrew | **PASS** | nav/eligible/13 intent |
|
||||
| 6 | 全量回归 | `python -m pytest -q` | 2026-09-10 | Andrew | **PASS** | **786 passed, 1 skipped** |
|
||||
| 7 | 手工 · R1 | 种子 + render_profile_context | 2026-09-10 | Andrew | **PASS(脚本)** | Top-3 正确 |
|
||||
| 8 | Redis DEL | `profile:l1:CUST-9527` | 2026-09-10 | Andrew | **跳过** | 6380 未起时可后补 |
|
||||
|
||||
---
|
||||
|
||||
## 7. 数据准备与重灌结论
|
||||
|
||||
| 数据集 | 是否需重灌 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| Core | 否 | CUST-9527 持仓/风评/净值在 reset.ps1 |
|
||||
| Agent L1 种子 | 建议(R1 手工) | `seed-customer-profile-l1-r1-demo.sql` |
|
||||
| `customer_threshold_config` | 可选 | 口述「亏10%提醒我」后自动 upsert |
|
||||
| Redis 热缓存 | 灌 SQL 后清 | `DEL profile:l1:CUST-9527` |
|
||||
|
||||
---
|
||||
|
||||
## 8. 结论与剩余风险
|
||||
|
||||
| 字段 | 结论 |
|
||||
| --- | --- |
|
||||
| **需求是否覆盖** | C-01~05 已实现;C-07/08/11 部分实现(见 REQUIREMENTS) |
|
||||
| **旧功能是否破坏** | 否 · 786 pytest 全绿 |
|
||||
| **剩余风险** | ① C-04 无 push/cron;② C-05 非实时、Phase B 未做;③ C-08 无偏离检测;④ 手工 uvicorn 走查待补 |
|
||||
| **建议人工再验** | CUST-9527:持仓+阈值 · nav_query · 「我能买什么」· 「实时净值」reject · save_note 与流水优先级 |
|
||||
| **是否可发布** | 后端可合并 |
|
||||
|
||||
---
|
||||
|
||||
## 9. 签核(可选)
|
||||
|
||||
| 角色 | 姓名 | 日期 | 意见 |
|
||||
| --- | --- | --- | --- |
|
||||
| 模块负责人 | zhangyong | | ☐ 通过 ☐ 待改 |
|
||||
| 修改人 | Andrew | 2026-09-10 | 自测通过 |
|
||||
| 测试 | Andrew | 2026-09-10 | 786 自动化 PASS |
|
||||
|
||||
---
|
||||
|
||||
## 10. 修订历史
|
||||
|
||||
| 版本 | 日期 | 作者 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| v1.0 | 2026-09-10 | Andrew | 1B/R1 初稿 |
|
||||
| v1.1 | 2026-09-10 | Andrew | Wave3 批次 · keyword 缺陷 · 786 基线 · 课程模块 7 |
|
||||
@@ -1,34 +1,51 @@
|
||||
# 测试日志模板
|
||||
|
||||
复制为 `YYYYMMDD-短任务名.md` 后填写。
|
||||
复制为 `YYYYMMDD-短任务名/` 目录,内含 `TEST-LOG-*.md`(企业级字段见 `2026-09-10-customer-1b-r1/TEST-LOG-2026-09-10-CS-001.md` 范例)。
|
||||
|
||||
```markdown
|
||||
# 测试日志:<任务名>
|
||||
|
||||
- 日期:
|
||||
- 关联 TODO:
|
||||
- 风险等级:LOW / MEDIUM / HIGH
|
||||
## 1. 文档元数据
|
||||
| 测试记录编号 | |
|
||||
| 缺陷/变更标题 | |
|
||||
| 文档版本 | v1.0 |
|
||||
| 创建日期 | |
|
||||
| 关联分支 | merger |
|
||||
| 关联拍板/TODO | |
|
||||
| 风险等级 | LOW / MEDIUM / HIGH |
|
||||
| 缺陷类型 | |
|
||||
| 发现阶段 | |
|
||||
|
||||
## 改了什么
|
||||
## 2. 组织与责任
|
||||
| 所属模块 | |
|
||||
| 模块负责人 | |
|
||||
| 发现人 | |
|
||||
| 修改人 | |
|
||||
| 测试执行人 | |
|
||||
| 评审人 | |
|
||||
|
||||
- 文件:
|
||||
- 行为变化:
|
||||
## 3. 缺陷描述(可多条)
|
||||
| 缺陷编号 | |
|
||||
| 严重等级 | P1/P2/P3 |
|
||||
| 复现步骤 | |
|
||||
| 期望 / 实际 | |
|
||||
| 根因 | |
|
||||
| 修复方案 | |
|
||||
|
||||
## 已执行
|
||||
## 4. 变更清单
|
||||
| 类型 | 路径 | 说明 |
|
||||
|
||||
| 类型 | 命令或步骤 | 结果 |
|
||||
| --- | --- | --- |
|
||||
| 手工 / 单测 / 集成 | | PASS / FAIL / 未执行 |
|
||||
## 5. 测试执行记录
|
||||
| 序号 | 类型 | 用例/命令 | 执行人 | 结果 | 证据 |
|
||||
|
||||
## 未执行
|
||||
## 6. 数据准备
|
||||
| 数据集 | 是否重灌 | 操作 |
|
||||
|
||||
- 项:
|
||||
- 原因:
|
||||
## 7. 结论
|
||||
| 需求覆盖 | |
|
||||
| 回归 | |
|
||||
| 剩余风险 | |
|
||||
| 建议人工再验 | |
|
||||
|
||||
## 结论
|
||||
|
||||
- 需求是否覆盖:
|
||||
- 旧功能是否破坏:
|
||||
- 剩余风险:
|
||||
- 建议人工再验:
|
||||
## 8. 签核 / 修订历史
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user