GaoYiYuan_0626 fe4801bc0a feat: C4 FR-8 持仓集中度预警(RISK-006)
依据《实现方案-风控追加需求v1.1-C4C6.md》§2;不改表结构(alert_type/status
复用 payload 承载,audit_log.event_type 为 VARCHAR 可直接扩)。

1. settings.py + .env.example:一次性加齐风控追加 v1.1 共 11 项配置(C4~C6 共用)。
2. core_ro.concentration_profile(customer_id, limit=500):一次 SQL 取明细
   (LIMIT limit+1 探测截断)+ Python 端按 min_risk_code in (R4,R5) 聚合;
   收口挂账 #1(PRD 字面为 list_holdings,改聚合封装,docstring 注明偏离)。
3. rules.py:RULE_SCORES/RULE_ALERT_TYPES 加 RISK-006=60/pattern;RuleHit 加
   alert_subtype;RiskThresholds 加 concentration_threshold 且 from_settings
   必须补读(评审 P1-2:漏读会让 conftest monkeypatch 失效打穿现有断言);
   新增纯函数 rule_concentration——空仓不触发、截断视同达标(保守告警)、
   阈值边界 79.9% 不触发 / 80% 触发、R4+R5 为 0 不触发。
4. engine.process_trade_event:run_rules 之后、record_trade_alerts 之前并入
   集中度命中(不动 run_rules 签名);命中后 L3 打 high_risk_concentration
   标签 + 写 risk_concentration 审计(金额只落合计与前 5 条摘要)。
5. risk_repository:find_pending_event_alert 改候选 LIMIT 50 + Python 过滤掉
   payload.alert_subtype 含 agent_behavior 的单(评审 P0-1:代理人维度行为链单
   不得充当客户维度事件单的聚合锚点);append_alert_event 加 extra_subtypes
   合并进 payload.alert_subtype(不传时行为与原先一致,向后兼容)。
6. alert_service:subtypes 集合维护(空集不注入 payload,评审 P2-3);
   追加时 alert_type 按「老单规则 ∪ 本批规则」重算(评审 P1-3,修掉既有
   large_amount 单被本批仅 RISK-006(60) 翻转为 pattern 的缺陷);
   _publish_alert 加 notify_role/extra 可选参数(C5/C6 复用)。
7. 对话线:chat_tools.customer_context 加 profile(concentration_ratio/
   r45_value/total_value/holdings_truncated),tool_service.summarize 加
   「高风险持仓占比 X%(仅供参考)」;不新增意图词。
8. 02-redis-keys.md 增补 alert_subtype / escalation_level 附加推送字段。

测试:conftest 加 autouse _disable_concentration_rule(阈值推 1.01 做回归隔离,
现有用例断言零改动);test_risk_rules 加 RISK-006 纯函数 6 例;新建
tests/test_concentration_c4.py 11 例(与 RISK-001 同单聚合、score max=70、
L3 tag、risk_concentration 审计、仅集中度也出单、subtype 合并、P0-1 回归、
alert_type 不翻转、对话线 ratio)。全量 453 绿(436 + 17)。
2026-09-07 19:05:02 +08:00

JinRong · 金融四 Agent 智能管家

四个 Agent(客户财富 / 代理人助手 / 数据分析 / 风控监测)共用统一数据层与合规底座。

文档

目录 内容
docs/memory/MEMORY.md 项目记忆入口(新 Agent 读 §0 交接清单)
docs/PRD/ 风控监测 Agent PRD(v1.1)+ 风控规则表
docs/项目框架设计/ 表设计、技术选型、JWT 手册、开发计划、实现方案
交接文档.md 最新进度速览(本地保留,不入库)

后端结构

app/
├── api/          # 路由:chat、risk、simulate、knowledge、admin + audit_middleware、deps
├── service/      # Agent 编排、风控服务(risk/*)、RAG、记忆、鉴权、输入防护
├── tool/         # Core 只读 Tool、知识库 kb_tools、解析/Embedding/Milvus
├── gateway/      # 模拟交易网关(唯一可写 core_trade)
├── model/        # Pydantic + ORM
├── repository/   # core_ro(Core 只读)、risk_repository、session_repository
├── config/       # settings、database
├── utils/
└── main.py

环境要求

  • Python 3.13+(pytest 依赖装在系统 Python)、MySQL 8.0、Redis 8、Neo4j Desktop、Ollama(bge-m3)
  • Windows 原生部署(见技术选型文档)

快速启动

cp .env.example .env
pip install -r requirements.txt
# 首次:灌 Core 模拟库与同步 — 见 docs/memory/FLOW.md §0
uvicorn app.main:app --reload
python -m pytest   # 406 用例

健康检查:GET http://127.0.0.1:8000/health

前端

React 19 + Vite 7 + Ant Design 5(待 init web/ 目录)。

S
Description
金金融融的
Readme
24 MiB
Languages
Python 84.5%
TypeScript 9%
JavaScript 4.3%
CSS 1.1%
PowerShell 1%