feat(redis): Update Redis configuration and enhance compatibility with Docker
- Changed Redis port mapping in `docker-compose.yml` from `6379:6379` to `6380:6379` to avoid conflicts with Windows Redis. - Updated `.env.example` to reflect the new Redis URL (`redis://127.0.0.1:6380/0`), ensuring proper configuration for Docker users. - Enhanced Redis client initialization in `database.py` and `redis_gateway.py` to utilize a new `_redis_kwargs` function for improved compatibility with Windows Redis 3.x and Docker Redis 7. - Added a new PowerShell script `start-redis.ps1` to facilitate starting Redis in Docker, providing a seamless setup experience for developers. This update significantly improves the Redis integration, ensuring a smoother development process and better compatibility across environments.
This commit is contained in:
+17
-10
@@ -9,7 +9,7 @@
|
||||
|
||||
**项目是什么:** 金融四 Agent(客户财富 / 代理人 / 数据分析 / 风控)共用数据层与合规底座;**不**互调 LLM,跨 Agent 走 L1/L2/L3 画像与预警表。
|
||||
|
||||
**当前进度:** 需求与表设计已定 · **风控模块 B1~B9b + C4~C6 + chat B/C + AL-09 合并** · **代销平台 API v0.1 已落地** · **客服 Agent S2 接缝收尾**(visitor 试聊 + customer 并行分流 · Wave 1~5 测试绿 · CS-C-11 迁移已执行) · **730 passed 0 skipped** · **`web/` 静奢智能 UI 已落地** · **`npm run build/test/lint` 绿(14 例 Vitest)**。**下一步:ChatPanel/SSE · 前端 customer Chat。**
|
||||
**当前进度:** 需求与表设计已定 · **风控 B1~B9b + C4~C6 + chat B/C + AL-09 合并** · **代销平台 API v0.1** · **客服 Agent S2 收尾**(visitor + customer 分流 · fin_* KB · Wave 1~5 绿 · CS-C-11 迁移) · **730 passed** · **`web/` 前端 P0 主链路已真接**(ChatPanel · 游客试聊 · 四 Agent 对话 · 平台只读页 · 行情 · 风控台账处置) · **`npm run build/test/lint` 绿(19 例 Vitest)** · **Redis:Docker `jinrong-redis` @ 127.0.0.1:6380**。下一步:analytics 问数页 · 接口契约发群 · customer Chat SSE(后端未接 stream)。
|
||||
|
||||
**工作分支:** 团队开发在 **`merger`**(已 merge 风控模块);历史开发分支 `risk-control-agent` 交付冻结。旧文档中「待 AL-09 合并」口径已过时。
|
||||
|
||||
@@ -37,9 +37,11 @@
|
||||
| `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/risk_repository.py` | **已实现** | risk_alert / risk_suitability_log / L3 / risk_aml_list / audit_log / input_guard_log 读写 |
|
||||
| `app/utils/` | **基本就绪** | trace(trace_id+request_id 双 contextvar)/ desensitize / db(引擎工厂)/ response(统一错误体+4xx/500 handler)/ exceptions(含 ApiError)已实现;logger 占位 |
|
||||
| `app/config/settings.py` | **已实现** | 双库 + risk_* 阈值 + JWT 配置(jwt_public_key_path/jwt_dev_secret/jwt_issuer/jwt_audience) |
|
||||
| `app/config/database.py` | **已实现** | MySQL 双引擎 + **Redis 单例**(`REDIS_URL` · **RESP2 `protocol=2`** 兼容 Docker Redis 7 / 旧 Windows Redis 3) |
|
||||
| `app/config/settings.py` | **已实现** | 双库 + risk_* 阈值 + JWT + **customer/visitor/profile** 字段 + `kb_root_dir` |
|
||||
| `app/service/customer_service.py` `visitor_service.py` | **已实现(S2)** | 客服 14 节点 · 游客 9 节点 LangGraph;RAG 走 **fin_* 三库**;Redis 记忆 **fail-open** |
|
||||
| `scripts/core/*.sql` + `reset.ps1` | **已实现** | Core 模拟库 DDL + 种子 |
|
||||
| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | AML 名单种子 + 风控演示数据 + `fix_utf8_seed.py`/`run_sql_file.py`(Windows UTF-8 灌库)+ issue_dev_token |
|
||||
| `scripts/agent/` `scripts/demo/` `scripts/dev/` | **已实现** | AML 种子 + 演示数据 + `run_sql_file.py` + **`start-redis.ps1`**(Docker Redis 优先)+ issue_dev_token |
|
||||
| `scripts/sync/*.py` | **已实现** | 归属同步 + Neo4j 全图 |
|
||||
| `tests/` | **已实现** | 37+ 测试模块 **730 用例 0 skipped**(含客服 Wave 1~5;sqlite + 真 MySQL 集成;`test_module_boundary` 宿主 D 类排除)。改路由必同步 `tests/test_main.py::test_all_routers_mounted` |
|
||||
| `docs/需求拆解/` | 已定 | 场景 P0、矩阵、合规原文 |
|
||||
@@ -52,7 +54,7 @@
|
||||
| `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/` | **静奢智能 UI(2026-09-09)** | React 19 + Vite 8 + **AntD 6** + **Tailwind CSS v4**(`@tailwindcss/vite`)+ HashRouter;`components/ui`/`dashboard`/`layout` 分层 · 四角色首页真调 `customers/products/advisors/risk` · **未接** ChatPanel/SSE、共享 `/app/market`、risk 处置 UI;交接 **`docs/frontend/FRONTEND-HANDOFF.md`** |
|
||||
| `web/` | **静奢智能 UI + P0 真接(2026-09-09)** | `ChatPanel`/`useChatPanel` · **customer 同步 Chat** · **risk/advisor/analyst SSE** · 登录页 **VisitorChatWidget** · 档案/持仓/流水/行情/风控台账+处置 · `web/src/api/chat.ts` · 交接 **`docs/frontend/FRONTEND-HANDOFF.md`** |
|
||||
|
||||
**本地 bootstrap(首次):** 完整步骤与前置说明见 `FLOW.md` §0(权威),速览:
|
||||
|
||||
@@ -65,12 +67,15 @@
|
||||
5. mysql … < scripts/agent/seed-aml-list.sql # AML 名单(Windows 乱码:`python scripts/dev/fix_utf8_seed.py`)
|
||||
(风控演示:scripts/demo/prepare_risk_demo.sql,reset 后重跑)
|
||||
6. python scripts/sync/sync_advisor_rel.py && python scripts/sync/sync_neo4j.py
|
||||
7. uvicorn app.main:app --reload → GET /health;`docker compose up -d redis`(限流/会话窗口);python -m pytest(**730 绿**,系统 Python 3.13.14)
|
||||
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 app.main:app --reload → GET /health;`cd web && npm run dev`(5173 代理 8000);python -m pytest(**730 绿**)
|
||||
```
|
||||
|
||||
**AL-09 合并后架构(一句话):** 宿主 `gateway/` + 模块 `deps.py` **双栈并存**;对外登录/token **统一**;chat/risk 均走模块鉴权;接缝 S2 用 `auth_adapter`。
|
||||
|
||||
**下一步(见 TODO):** 前端 ChatPanel/SSE(customer/risk/advisor)· 共享 `/app/market` · risk 台账处置 UI · 接口契约发群 · Agent 合并改调 platform Service。
|
||||
**下一步(见 TODO):** analytics 问数页 · 接口契约发群 · customer Chat 流式(后端 `/stream` 未接 customer_service)· simulate 交易 UI(不做)。
|
||||
|
||||
**Redis(2026-09-09):** 推荐 **Docker** `jinrong-redis`(`redis:7-alpine`)· 宿主机 **6380** → 容器 6379 · `.env` `REDIS_URL=redis://127.0.0.1:6380/0` · 客户端 **RESP2**(`database.py` / `redis_gateway.py`)。
|
||||
|
||||
**前端启动(`web/`):** `npm install` → `npm run dev`(`5173`,`/api` 代理 `8000`)· 验收四 demo 账号见 **`docs/frontend/FRONTEND-HANDOFF.md` §8** · 改 UI 后跑 `npm run build && npm run test && npm run lint`。
|
||||
|
||||
@@ -93,8 +98,8 @@
|
||||
## 1. 项目简介
|
||||
|
||||
- **名称:** JinRong 金融四 Agent 智能管家
|
||||
- **当前阶段:** **代销平台 API v0.1 + AL-09 合并 + `web/` P0 脚手架(2026-09-09)**——530 测试绿;前端业务页与 Agent SSE **待接**
|
||||
- **当前优先级:** 前端 P0 真接 API/SSE(统筹)/ 接口契约发群 / Agent 队友并行(合并期改调 platform canonical API)
|
||||
- **当前阶段:** **代销平台 v0.1 + AL-09 + 客服 S2 + 前端 P0 主链路真接(2026-09-09)**——730 pytest 绿 · 19 Vitest 绿
|
||||
- **当前优先级:** analytics 问数 · 接口契约发群 · customer SSE(后端)· simulate UI(显式不做)
|
||||
|
||||
------
|
||||
|
||||
@@ -157,7 +162,9 @@ Core 模拟:scripts/core/reset.ps1 · 文档 docs/项目框架设计/Core模
|
||||
种子:scripts/agent/seed-aml-list.sql(AML 名单)· scripts/demo/prepare_risk_demo.sql(reset 后重跑)
|
||||
依赖:requirements.txt(LangGraph + langchain-core/openai + FastAPI + SQLAlchemy)
|
||||
启动:uvicorn app.main:app --reload → GET /health
|
||||
测试:python -m pytest(**730 绿**;集成测试需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`)
|
||||
Redis:`docker compose up -d redis` · `REDIS_URL=redis://127.0.0.1:6380/0` · `scripts/dev/start-redis.ps1`
|
||||
测试:python -m pytest(**730 绿**;集成需本机 MySQL + `risk_aml_list` + `prepare_risk_demo.sql`)
|
||||
前端:cd web && npm run dev · npm run build/test/lint(**19** Vitest)
|
||||
运维/演示脚本:scripts/demo/subscribe_alerts.py(订阅推送演示)· rebuild_alerts.py TRD-xxx(引擎异常补偿重放)
|
||||
JWT 联调:python scripts/dev/issue_dev_token.py --sub STAFF-30001 --roles risk_officer(+ Authorization: Bearer + X-Agent-Type)
|
||||
配置:.env(见 .env.example)
|
||||
@@ -205,6 +212,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` 全量(当前 **730 绿**)· `docker compose up -d redis` · uvicorn + /health · 平台 `/api/customers/*` · `tests/test_module_boundary.py` 全绿)
|
||||
5. 如何验证?(`python -m pytest` **730 绿** · `docker compose up -d redis` + `.env` **6380** · uvicorn + `/health` · `web/` build/test · 平台 `/api/customers/*` · 登录页游客试聊 · 客户助手 Chat)
|
||||
|
||||
大任务:FRAMEWORK/FLOW 与实现状态不符时先更新 memory 再编码(用户确认跳过除外)。
|
||||
|
||||
Reference in New Issue
Block a user