feat(nav): Implement historical NAV tracking and enhance product API
- Added `list_nav_history` method in `CoreReadOnlyRepository` to retrieve historical NAV data for products over a specified number of days. - Introduced `get_nav_history` endpoint in `product_service` to return historical NAV sequences, improving product data accessibility. - Updated `products.py` to include new API endpoint for fetching NAV history, ensuring compliance with access control. - Enhanced `ready.py` to include a health check for the new functionality, ensuring system readiness. - Updated documentation to reflect the new testing baseline of 833 passed tests, indicating improved stability and functionality across the application. This update significantly enhances the product API by providing access to historical NAV data, improving user insights into product performance.
This commit is contained in:
+12
-12
@@ -9,7 +9,7 @@
|
||||
|
||||
**项目是什么:** 金融四 Agent(客户财富 / 代理人 / 数据分析 / 风控)共用数据层与合规底座;**不**互调 LLM,跨 Agent 走 L1/L2/L3 画像与预警表。
|
||||
|
||||
**当前进度:** 需求与表设计已定 · **风控 TEST-RISK-001(含 F12)** · **827 pytest** · **22 Vitest** · **Redis @ 6380** · **`merger` 未 commit**
|
||||
**当前进度:** 需求与表设计已定 · **风控 TEST-RISK-001(含 F12)** · **833 pytest** · **22 Vitest** · **Redis @ 6380** · **`merger` 未 commit** · **⚠️ 代理人 Agent 未完整接入**(顾问 Chat 骨架在,T-20/A 线未做,答辩勿作主 Demo)
|
||||
|
||||
**工作分支:** 团队开发在 **`merger`**;历史 `risk-control-agent` 交付冻结。
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
| `app/gateway/` | **宿主 Wave 0(并存)** | jwt_service / auth_deps / rbac / ownership;模块 API 走 `deps.py`,禁止模块 import gateway |
|
||||
| `app/api/risk.py` `simulate.py` `deps.py` | **已实现** | 风控 4 API + 模拟网关 · **compliance/service_risk 矩阵(F2/F3)** · 台账 **`stats` 待审计数(F7)** |
|
||||
| `app/api/chat.py` `audit_middleware.py` | **已实现** | POST /api/chat · **POST /api/chat/stream(customer 分流 → prepare_customer_stream)** · visitor · sessions 三端点 |
|
||||
| `app/api/customers.py` `products.py` `advisors.py` `staff.py` `compliance.py` | **已实现(v0.1)** | 代销平台 REST;`get_platform_auth_context`(无 X-Agent-Type);Service 层 `app/service/platform/` |
|
||||
| `app/api/customers.py` `products.py` `advisors.py` `staff.py` `compliance.py` | **已实现(v0.1 + 行情历史)** | 代销平台 REST;`get_platform_auth_context`;**`GET /api/products/{id}/nav/history`**(RBAC · compliance 拒) |
|
||||
| `app/api/analyst.py` `analyst_auth_adapter.py` | **已实现(S3+D-06+D-09 子集 + N-03/N-07)** | 问数 `POST /api/analyst/chat`(默认 `interpret=false`)· **`POST /api/analyst/interpret`** · **`GET /query/{trace_id}/sample`** · **`POST /escalate`** · dashboard/assets/metrics |
|
||||
| `app/api/ready.py` | **已实现(2026-09-11)** | `GET /api/ready`:Redis + 关键路由自检;前端 `DevReadyBanner` |
|
||||
| `app/service/analyst_agent.py` `template_service.py` `cache_service.py` | **已实现(S3+D-06)** | NL2SQL 编排 · guardrail · **结果缓存(表世代键)+ 写侧 bump**(`analyst_cache_invalidate`)· **模板填参**(published `analytics_query_template`) |
|
||||
@@ -37,7 +37,7 @@
|
||||
| `app/service/tool_service.py` `app/tool/core_tools.py` `service/risk/chat_tools.py` | **已实现(T-04/C1)** | 对话 Tool 编排(统一注册表 get_registered_tool:core+risk / 归属校验 / agent_tool_call 落库)+ Core RO 三只读 Tool(L0/持仓/流水)+ C1 风控四只读 Tool(alert_query/customer_context/suitability_check/aml_lookup,RISK_TOOL_REGISTRY) |
|
||||
| `app/repository/session_repository.py` | **已实现(T-06/T-04 + 前端接入 B/C)** | agent_session / agent_message / agent_tool_call 读写;**方案 B 增 `list_sessions`(分页+total)/ `list_messages_page`(seq 升序分页,勿与 LLM 窗口的 `list_messages` 混用)/ `close_session`(条件更新防并发)**;**方案 C 增 `insert_turn`(user+assistant 同事务落库 + 事务内取 seq,修评审 P0/P1)** |
|
||||
| `app/gateway/` | **已实现** | 模拟交易网关(仅 gateway_repository 可 INSERT core_trade,B5) |
|
||||
| `app/repository/core_ro.py` | **已实现** | Core 只读 SELECT(含风控扩展 sum_trades_on_date / list_trades_range / list_active_customers);**阶段一吸收 main:check_suitability(C×R 矩阵判定,CURDATE() 改 Python 端 `_is_expired`)/ list_products_for_customer / list_holdings 合并(limit=500+新列)/ list_trades / get_customer_l0 扩列版** |
|
||||
| `app/repository/core_ro.py` | **已实现** | Core 只读 SELECT(含风控扩展 sum_trades_on_date / list_trades_range / list_active_customers);**`list_nav_history(product_id, days)`** · check_suitability / list_products_for_customer / list_holdings / list_trades / get_customer_l0 |
|
||||
| `app/repository/risk_repository.py` | **已实现** | risk_alert / … · **`list_alerts` 须 `RiskListAccess`(F1)** · **`status=handled` 聚合筛选** · `count_pending_stats` |
|
||||
| `app/repository/repo_access.py` | **已实现(2026-09-11)** | `RiskListAccess` / `ThresholdWriteAccess` 仓储调用凭证 |
|
||||
| `app/repository/threshold_repository.py` | **已实现** | 阈值配置 · **`upsert_portfolio` 须 `ThresholdWriteAccess`** |
|
||||
@@ -47,11 +47,11 @@
|
||||
| `app/service/customer_service.py` `visitor_service.py` | **已实现(S2 + Wave3 + 问候快路由)** | 客服 14 节点 · **C-04 阈值** · **C-05 nav_query** · **C-11 匹配说明** · **「你好」等问候关键词 → chit_chat;LLM 失败闲聊降级 `CHITCHAT_DEGRADED_TEXT`** · 游客 9 节点;共用 `sanitize_postprocess`(1B);RAG **fin_* 三库** |
|
||||
| `app/service/threshold_service.py` | **已实现(C-04)** | L1 `threshold_pref_summary` → `customer_threshold_config`;持仓查询加权盈亏 vs 阈值 → `customer_notify_log` |
|
||||
| `app/utils/sanitize_postprocess.py` | **已实现(1B 共用)** | 数据查询 intent(含 nav_query)违禁 → 回退 fact_text;RAG/闲聊 → COMPLIANCE_REJECT;均不自动 transfer |
|
||||
| `scripts/core/*.sql` + `reset.ps1` | **已实现** | Core 模拟库 DDL + 种子 |
|
||||
| `scripts/core/*.sql` + `reset.ps1` | **已实现** | Core 模拟库 DDL + 种子 · **`07-seed-nav-history.sql`(14 产品 ×364 日)** · 再生 `seed_nav_history.py --export-sql` |
|
||||
| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | **`prepare_all.ps1`** · **`push_threshold_alerts.py`** · **`seed_analyst.ps1`** · **`sandbox_risk_test.py`** · `run_query_battery.py`(**不入库**) |
|
||||
| `scripts/sync/*.py` | **已实现** | 归属同步 + Neo4j 全图 |
|
||||
| `tests/` | **已实现** | **827 用例** 1 skipped |
|
||||
| `docs/答辩/` | **答辩提纲 + Demo SOP** | `答辩知识点清单.md` · **`DEMO-SOP-问数.md`**(套餐 ①)· spec `docs/superpowers/specs/2026-09-11-defense-stable-package.md` |
|
||||
| `tests/` | **已实现** | **833 用例** 1 skipped |
|
||||
| `docs/答辩/` | **答辩提纲 + Demo SOP** | `答辩知识点清单.md` · **`DEMO-SOP-答辩全流程.md`** · `DEMO-SOP-问数.md` · spec `docs/superpowers/specs/2026-09-11-defense-stable-package.md` |
|
||||
| `docs/course/` | **交互课程集** | 导览中心 + 总览 **8 模块** + 问数 **5 模块**(D-06)+ 风控深潜 **7 模块** · 与答辩清单同步 |
|
||||
| `docs/PRD/PRD-风控监测Agent.md` | **已冻结(v1.1)** | 风控 PRD v1.0 + v1.1 追加 FR-8/9/10(§4A)+ 规则表附录 |
|
||||
| `docs/项目框架设计/实现方案-风控追加需求v1.1-C4C6.md` | **已定稿** | C4~C6 编码依据(经独立 AI 评审修订闭环);分支/进度速览另见项目根 `交接文档.md` |
|
||||
@@ -62,21 +62,21 @@
|
||||
| `docs/项目框架设计/接口契约-代销平台API-v0.2-行情扩展草案.md` | **草案(2026-09-09)** | `nav-snapshot` · `sync_market_nav` · 前端产品行情 Phase B |
|
||||
| `docs/项目框架设计/表设计/` | 已定 | Agent 共用 11 表 + agent 专用 SQL |
|
||||
| `docs/项目框架设计/Core模拟底座/` | 已定 | 无真实 Core 时的 L0 方案 |
|
||||
| `web/` | **P0 Demo 齐备 + E2E/Chat 缺陷已修(2026-09-10)** | 四角色 Dashboard/Chat · **`ChatPanel` 流式续聊 `session_id` + 刷新恢复** · 会话侧栏分页 · 固定面板高度 · 清单见 `docs/整体测试/前端整体测试交接.md` |
|
||||
| `web/` | **P0 Demo 齐备 + 行情详情(2026-09-11)** | 四角色 Dashboard/Chat · **`/app/market/:productId` 近一年净值曲线** · ChatPanel 流式 · 清单见 `docs/整体测试/前端整体测试交接.md` |
|
||||
|
||||
**本地 bootstrap(首次):** 完整步骤与前置说明见 `FLOW.md` §0(权威),速览:
|
||||
|
||||
```text
|
||||
1. cp .env.example .env → 填 MYSQL_PASSWORD、NEO4J_PASSWORD、DEEPSEEK_API_KEY
|
||||
2. pip install -r requirements.txt
|
||||
3. .\scripts\core\reset.ps1 # 建 jinrong_core 模拟库 + 种子
|
||||
3. .\scripts\core\reset.ps1 # 建 jinrong_core(含 07 净值历史 ~365 日/产品)
|
||||
4. mysql … < 01-mysql-共用底座.sql # jinrong_agent 共用 11 表
|
||||
mysql … < 02-mysql-agent专用.sql # 风控四表 + risk_aml_list
|
||||
5. mysql … < scripts/agent/seed-aml-list.sql # AML 名单(Windows 乱码:`python scripts/dev/fix_utf8_seed.py`)
|
||||
(风控演示:`.\scripts\demo\prepare_all.ps1` 或 `prepare_risk_demo.sql` · PRD §10.2)
|
||||
6. python scripts/sync/sync_advisor_rel.py && python scripts/sync/sync_neo4j.py
|
||||
7. `docker compose up -d redis`(或 `.\scripts\dev\start-redis.ps1`)→ **REDIS_URL=redis://127.0.0.1:6380/0**(Docker Redis 7;避开本机 Windows Redis 占 6379)
|
||||
8. uvicorn … · python -m pytest(**827 绿**);问数答辩:`docs/答辩/DEMO-SOP-问数.md` · 种子 **`scripts/dev/seed_analyst.ps1`**
|
||||
8. uvicorn … · python -m pytest(**833 绿**);问数答辩:`docs/答辩/DEMO-SOP-问数.md` · 种子 **`scripts/dev/seed_analyst.ps1`**
|
||||
```
|
||||
|
||||
**AL-09 合并后架构(一句话):** 宿主 `gateway/` + 模块 `deps.py` **双栈并存**;对外登录/token **统一**;chat/risk 均走模块鉴权;接缝 S2 用 `auth_adapter`。
|
||||
@@ -175,7 +175,7 @@ audit_log 等审计表(只 INSERT)
|
||||
| **C-07** | 风评查询走 Core;**「重新测评/重做风评」** → 引导 App/网点(Agent 内不做问卷) | `customer_prompts._RISK_KW` |
|
||||
| **C-08** | 仅 L1 槽位 `investment.allocation_target`(13 槽);**无自动偏离检测/调仓** | `profile_slots.py` |
|
||||
| **问数 vs 分析对话** | 问数页 + **`/interpret`** · **N-03 抽样溯源** · **N-07 escalate/失败转人工** · 分析对话 URL **重定向问数** | spec `2026-09-11-query-interpret-split-design.md` |
|
||||
| **客户「趋势/走势」** | **客户 Chat**:仅 **C-05 最新净值快照** + 持仓/流水;**走势预测/实时盘口 reject**;**无 Chat 内净值历史曲线 Tool** · **统计类趋势**(近 N 日笔数、结构描述)→ **问数** `POST /api/analyst/chat` · **`self` 域**(拍板 `数据分析Agent-合并说明.md` §9.6 · 尾注「AI 分析有风险」)· **D-12 看板钻取未做** | 问数 ≠ 客户助手 · Phase B 行情 sync 未做 |
|
||||
| **客户「趋势/走势」** | **客户 Chat**:仅 **C-05 最新净值快照** + 持仓/流水;**走势预测/实时盘口 reject** · **平台「产品行情」**:列表 + **`GET nav/history` 详情折线**(customer/advisor/analyst/风控可读;compliance 无菜单/API 403)· **无 Chat 内历史曲线 Tool** · 统计类趋势 → **问数** `self` 域 · **D-12 看板钻取未做** | Phase B 外部 sync 未做 |
|
||||
| **L0 优先** | 抽槽与 L0 撞车**永远听 L0**;L1 只 enrich 措辞 | `profile_slots` D7 |
|
||||
|
||||
------
|
||||
@@ -190,7 +190,7 @@ Core 模拟:scripts/core/reset.ps1 · 文档 docs/项目框架设计/Core模
|
||||
依赖:requirements.txt(LangGraph + langchain-core/openai + FastAPI + SQLAlchemy)
|
||||
启动:uvicorn app.main:app --reload → GET /health · **GET /api/ready**(环境自检)
|
||||
Redis:`docker compose up -d redis` · `REDIS_URL=redis://127.0.0.1:6380/0` · `scripts/dev/start-redis.ps1`
|
||||
测试:python -m pytest(**827 绿**;集成需本机 MySQL + AML + 风控演示数据)
|
||||
测试:python -m pytest(**833 绿**;集成需本机 MySQL + AML + 风控演示数据)
|
||||
风控沙盘:`python scripts/dev/sandbox_risk_test.py`(TEST-RISK-001)
|
||||
前端:cd web && npm run dev · npm run build/test/lint(**22** Vitest)· 四角色 Demo 见 `docs/frontend/FRONTEND-HANDOFF.md` §8
|
||||
问数模板:mysql … < scripts/agent/seed-analyst-query-templates.sql
|
||||
@@ -242,6 +242,6 @@ RBAC 联调账号:scripts/dev/rbac-seed-reference.md
|
||||
2. 改动属于 api / service / tool / repository 哪一层?
|
||||
3. 是否需 customer_id 归属与 JWT RBAC?
|
||||
4. Core 是模拟库只读还是 agent 库读写?
|
||||
5. 如何验证?(`python -m pytest` **827 绿** · Redis **6380** · `/api/ready` · 问数 Demo 见 `docs/答辩/DEMO-SOP-问数.md`)
|
||||
5. 如何验证?(`python -m pytest` **833 绿** · Redis **6380** · `/api/ready` · 行情详情 `/app/market/PROD-000001` · 问数 Demo 见 `docs/答辩/DEMO-SOP-问数.md`)
|
||||
|
||||
大任务:FRAMEWORK/FLOW 与实现状态不符时先更新 memory 再编码(用户确认跳过除外)。
|
||||
|
||||
Reference in New Issue
Block a user