Files
group_xinghuo_jinrong/docs/memory/REQUIREMENTS.md
T
zhanghongyu_0626 aea97a243c feat(analyst): Introduce interpret functionality and enhance chat API
- Added `interpret` flag to `AnalystChatRequest` for optional immediate interpretation of queries.
- Implemented new `POST /api/analyst/interpret` endpoint for on-demand data interpretation based on the latest query snapshot.
- Updated `AnalystAgent` to handle interpretation logic, including error handling and response formatting.
- Enhanced `AnalystQueryPage` to include a button for triggering interpretations, improving user interaction.
- Updated frontend API calls to support the new interpret functionality, ensuring seamless integration with existing workflows.

This update significantly enhances the analytical capabilities of the application, allowing users to request interpretations of their queries directly.
2026-09-11 12:15:18 +08:00

69 lines
6.5 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.
# 需求拆解(对照开发)
> 来源:`docs/需求拆解/业务场景优先级清单.md`(P0)
> 合规:`docs/需求拆解/Agent风险与合规约束汇总.md`
> 数据:`docs/需求拆解/数据交互矩阵.md`
------
## 本轮范围
- **目的:** 四 Agent 服务四类人群,统一数据层 + 合规底座,可对话闭环。
- **明确不做:** 自动交易、营销推荐、Agent 互调 LLM、自动冻户、Streamlit、P3 平台能力。
------
**合并状态(2026-09-08):** AL-09 接线完成(`merger` 分支)——宿主 Wave 0 与风控模块共存;JWT/login 统一;chat/risk 走模块鉴权;502 pytest 绿。
## Wave 0 · 共用底座
| ID | 需求 | 验收对照 | 状态 | TODO |
| --- | --- | --- | --- | --- |
| F-01 | JWT + RBAC + 数据归属 | 越权 403 + audit;JWT 手册 §13 | **已完成(T-01,2026-09-07)**:auth_service 验签/吊销 + deps 工厂(Bearer 全环境 + dev debug 头兜底)+ X-Agent-Type 准入矩阵 + 归属断言(B6 已有);越权 403 + audit + input_guard_log 双写 | ~~T-01~~ |
| F-02 | 全量审计留痕 | trace_id 可还原 | **已完成(T-02,2026-09-07)**:http_access 审计中间件 + X-Trace-Id/X-Request-Id 双贯通 + 4xx/500 统一错误体;业务判定审计 B6 已接 | ~~T-02~~ |
| F-03 | 输入防护 | input_guard_log | **完成(2026-09-07,T-03)**:prompt_injection(词表 42 条纯函数检测,命中即拒)/ oversize(4000,Pydantic 硬顶 20000)/ rate_limit(Redis 固定窗口 actor 级 30 次/分 fail-open);chat 链路 blocked 全留痕,fail-fast 不建会话 | — |
| F-04 | Core 只读层 | 不改 Core 账;Repository 只 SELECT | **已完成(T-04,2026-09-07)**:core_ro(含风控扩展)经 app/tool/core_tools.py 三只读 Tool 接入 chat(L0/持仓/流水);Tool 层归属校验(A-01 语义:customer 本人/advisor assigned/risk_officer 全量)+ agent_tool_call 全留痕;Core 侧仍仅 SELECT | ~~T-04~~ |
| R0-DB | MySQL 共用 11 表 + Redis | 01-mysql-共用底座.sql | SQL 已定;本机已灌库(B9b 走查验证) | T-05(本机已完成) |
| R0-CORE | Core 模拟 + 同步 | reset.ps1 + sync 脚本 | **脚本已落地** | T-05 |
**F-01 部分完成说明:** B6 已落地 `app/api/deps.py`(AuthContext Pydantic + `get_auth_context()` 工厂,dev 从 `X-Debug-Role`/`X-Debug-Actor` 头构造;T-01 就绪后仅替换工厂内部为 JWT 解析)。
**F-04 完成说明(T-04,2026-09-07):** `app/repository/core_ro.py`(含风控扩展)仅 SELECT 不变;对话接入经 `app/tool/core_tools.py`(query_customer_profile / query_holdings / query_recent_trades,TOOL_REGISTRY 白名单)+ `app/service/tool_service.py`(run_tool:归属校验→执行→agent_tool_call 落库);agent_service 图为 START→tool→llm→guard,customer_id 由会话注入不接受 LLM 生成。风控四 Tool 归 C1 复用同一 runner。
## Wave 1 · 内部 Agent P0
| ID | 需求 | 验收对照 | 状态 | TODO |
| --- | --- | --- | --- | --- |
| D-01~D-04 | 分析:客户/产品/预警查数 + SQL 留痕 | analytics_query_log | **已实现(S3+D-09 子集 · 2026-09-11)**:问数默认 `interpret=false`(仅表/SQL)· **`POST /api/analyst/interpret` 按需解读(看图说话)** · sql_guard/guardrail · self 域尾注 | ~~T-10~~ |
| A-01~A-05 | 代理人:画像/规则/草稿/流程/合规巡检 | 非归属 403;草稿不外发 | 未做 | T-20 |
## Wave 2 · 风控 P0
> 详细需求见 **`docs/PRD/PRD-风控监测Agent.md`(v1.0 冻结 + v1.1 追加 FR-8/9/10)**;范围含 R-04(P1 顺手做)、R-05 仅预留 L3 接口。
| ID | 需求 | 验收对照 | 状态 | TODO |
| --- | --- | --- | --- | --- |
| R-01 | 大额预警 | risk_alert pending_review | **已实现**(B1~B6,A-1/A-2 用例绿) | ~~T-30~~ |
| R-02 | 适当性阻断请求 | 唯一阻断场景 | **已实现**(~~SUIT-001~008~~ **阶段一换核**:main 的 core_ro.check_suitability C×R 矩阵 + match_result 五值/JR-AST-012/FM-01/FM-03/JR-AST-PRO 契约 + check API 带鉴权 + 网关阻断;risk_suitability_log 21 列落库;MySQL 手工 SQL 对照挂账 B9b) | ~~T-31~~ |
| R-03 | AML 命中通知 | 不自动冻户 | **已实现**(aml_service + scan API + L3 联动;对话线随 C1~C3 完成,A-6 验收通过) | ~~T-32~~ |
| R-04 | 频繁/试探模式预警 | 聚合出单 + 去重 | **已实现**(B1 规则 + B2 聚合去重) | ~~T-30~~ |
| R-05 | L3 画像写入 | 最小写入(最高档合并) | **已实现**(profile_l3 防降级;`risk_score` 一期保持 NULL 归评分模型首写) | ~~T-30~~ |
| FR-8 | 客户资产配置集中度预警(RISK-006) | A-10:R4+R5 占比 ≥ 阈值出单(并入事件类聚合);对话线只读展示 | **已实现**(C4 `fe4801b`,2026-09-07) | ~~C4~~ |
| FR-9 | 预警单处置时效监控与自动升级(RISK-007) | A-11:超时分级升级(payload 承载不改 status)+ 幂等 + 降噪 | **已实现**(C5 `90d0660` + escalation_scan 脚本,2026-09-07) | ~~C5~~ |
| FR-10 | 代理人异常行为链识别(RISK-008) | A-12:条件 A/B/C 触发 + 代理人维度出单(payload.actor_id)+ 明细仅 officer/manager 可见 | **已实现**(C6 `66ec7eb` + agent_behavior_scan 脚本,2026-09-07) | ~~C6~~ |
## Wave 3 · 客户 P0
| ID | 需求 | 验收对照 | 状态 | TODO |
| --- | --- | --- | --- | --- |
| C-01 | 持仓查询 | Core 只读 fact_text · 无买卖指导 | **已实现** · `holding_query` | ~~T-40~~ |
| C-02 | 产品规则咨询 | fin_product RAG + 免责 | **已实现** · Wave1~2 | — |
| C-03 | 政策/FAQ | fin_policy / fin_faq RAG | **已实现** · Wave1~2 | — |
| C-04 | 亏损阈值提醒 | `customer_threshold_config` + 持仓查询追加提醒 | **已实现(2026-09-10)** · `threshold_service` | ~~T-40~~ |
| C-05 | 产品净值 | Core 最新净值快照;禁止实时盘口 | **已实现(2026-09-10)** · `nav_query`;「实时净值」reject · **无 Chat 历史走势曲线**;统计趋势见问数 self 域(合并说明 §9.6) | ~~T-40~~ |
| C-07 | 风评查询 / 重测引导 | Core L0;重测引导 App/网点 | **部分已实现** · 无 Agent 内问卷 | T-41 |
| C-08 | 配置目标 | L1 槽 `allocation_target` | **部分已实现** · 无偏离检测/调仓 | T-41 |
| C-11 | 适当性匹配说明 | 非营销推荐;联动 R-02 | **部分已实现** · 「我能买什么」→ suitability;「推荐稳赚」仍 reject | T-42 |
**Wave 3 未做:** 主动 push/cron 阈值通知 · Phase B 行情 sync · GraphRAG 式推荐 · 自动调仓。