Commit Graph
218 Commits
Author SHA1 Message Date
GaoYiYuan_0626 037ce7edca docs(架构改进): 补齐 PRD/开发计划/TODO/交接文档,落地无密钥告警与 Redis 分布式锁
一、流程文档(按 AIcoding 六步落地,供新会话从交接文档开工)
- 新增 docs/PRD/PRD-架构改进与稳定性加固.md:6 条 FR(文档勘误、非缺陷说明、
  无密钥启动告警、审计失败告警、Redis 分布式锁、中间件顺序测试)
- 新增 docs/项目框架设计/改进方案评审-问题清单与对比.md:24 项问题分档 A~G,
  经两轮独立 AI 评审,无阻断级错误
- 新增 docs/项目框架设计/开发计划-架构改进.md:HOW 层设计,含合并前只做低风险
  11 项的批次策略
- 新增 docs/项目框架设计/TODO-架构改进.md:T-101~T-109、T-201~T-202 可勾选项
- 新增 docs/交接文档-架构改进.md:自包含交接入口,hy3 新会话可直接开工
- 新增 docs/项目框架设计/架构设计说明书.md:按模块/分层逐一讲解的全量架构说明

二、代码改动(T-107/108/109、T-201.1、T-201.2)
- app/main.py:启动时 DEEPSEEK_API_KEY 缺失告警,明确告知将走降级回复
- app/utils/authz.py:越权审计失败日志补 trace_id,便于串联全链路
- app/api/audit_middleware.py:审计失败日志补 status/path/request_id
- app/service/risk/redis_gateway.py:新增 acquire_lock(SET NX EX)与
  release_lock(Lua 原子释放,只删自己的锁)
- app/service/risk/locks.py:run_locked 改为双层锁,Redis 为主、进程内锁为备;
  Redis 超时沿用 fn(locked=False) 降级语义,Redis 不可用(含测试 Fake 缺方法的
  AttributeError)安全退回进程内锁,绝不抛异常

三、文档勘误(A1/A2/A3)
- MEMORY.md:文件数 42→45、Tools 4→5
- 02-mysql-agent专用.sql:会话表 5→6
- 架构设计-风控模块.md:同步更正

四、测试
- 新增 tests/test_locks_redis.py:覆盖抢锁成功、占用超时、Redis 故障降级、
  Fake 缺方法降级、只删自己锁、三处调用点 key 前缀
- tests/test_audit_middleware.py:补充告警字段断言
- 全量 pytest 510 passed(原基线 503)
2026-09-09 18:10:03 +08:00
zyi b19a2415f9 feat: 数据分析 Agent 实现(API/服务/表结构元数据/文档/测试)
- 新增 app/api、app/service 数据分析 Agent 全套服务与接口
- schemas.py 重构为 schemas 包(analyst schema)
- 新增 SQL 防注入、guardrail、缓存、字典、LLM 等服务
- 新增 tests 测试套件与 scripts/dev、scripts/setup 脚本
- 补充需求规格、架构说明书、开发清单、表设计等文档
2026-09-09 18:04:45 +08:00
zhanghongyu_0626 ad930c26b1 feat(frontend): Implement initial P0 scaffolding and enhance dashboard features
- Established the P0 scaffolding for the frontend, including login, layout, and routing for four roles.
- Integrated the Customer Wealth Dashboard, Advisor Clients Dashboard, Analyst Market Dashboard, and Risk Alerts Dashboard.
- Updated the API client to support fetching customer and product data, enhancing the overall functionality of the dashboard.
- Added error handling components to improve user experience during data fetching.
- Enhanced charting capabilities using Ant Design Charts for better data visualization.

This update lays the groundwork for further development of the frontend application, ensuring a robust structure for future features and integrations.
2026-09-09 15:50:33 +08:00
zhanghongyu_0626 93cd3a165c Revert "chore(agent): sync updated Cursor User Rules to project agent config"
This reverts commit 8ec7ca5e75.
2026-09-09 11:56:01 +08:00
zhanghongyu_0626andCursor 8ec7ca5e75 chore(agent): sync updated Cursor User Rules to project agent config
Add .cursor/rules/user-rules.mdc so team members get the same User Rules from the repo clone.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 11:53:43 +08:00
zhanghongyu_0626andCursor e9978a4066 chore(agent): add codebase-to-course skill to project agent config
Sync the interactive codebase-to-course skill into .cursor/skills so teammates get it from the repo clone.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-09 11:44:48 +08:00
zhanghongyu_0626 b881893575 feat(chat): Enhance assistant content handling with disclaimer management
- Introduced a new function `_assistant_content_for_persist` to append disclaimers to assistant responses, ensuring consistency in stored content.
- Updated `chat_api` and `chat_stream_api` to utilize the new function for managing assistant replies, improving data integrity.
- Added tests to verify the correct handling of disclaimers in various scenarios, ensuring compliance with expected output.

This update enhances the chat system's reliability by ensuring that disclaimers are consistently applied to assistant responses, improving user experience and data accuracy.
2026-09-09 10:42:24 +08:00
zhanghongyu_0626 cbcac98cdd feat(docs): Update API documentation and add new specifications for market data
- Enhanced AGENTS.md to include new draft specifications for market data in Phase B.
- Updated MEMORY.md with details on the C-05 market data source selection and the new API contract for v0.2.
- Introduced a new document for frontend P0 design specifications, outlining the architecture and features for the initial web application.
- Added a new document for C-05 market data source comparison, detailing the requirements and options for future data integration.
- Updated existing API contracts to reflect the latest changes and ensure consistency across documentation.

This update improves the clarity and comprehensiveness of the API documentation, supporting ongoing development efforts and future integrations.
2026-09-09 10:29:08 +08:00
zhanghongyu_0626 d0da627a5c feat(chat): Update trace ID handling in chat stream API
- Modified `chat_stream_api` to use `new_trace()` instead of an empty string for `trace_id`, enhancing traceability.
- Added tests to verify the correct generation and propagation of `trace_id` in responses, ensuring no empty trace IDs are sent to clients.

This update improves the tracking of chat sessions and ensures compliance with traceability standards.
2026-09-08 21:46:08 +08:00
zhanghongyu_0626 c9cac1cdf9 feat(api): 更新代销平台 API v0.1,增强适当性检查功能
- 在 `risk_suitability_log` 表中新增 `check_source` 枚举值 `platform`,支持代销平台的适当性检查。
- 更新相关 SQL 脚本以适应新的数据结构,确保数据一致性。
- 修改文档以反映 API 的最新状态和测试基线,确保文档与实现保持一致。
- 测试基线更新至 530 passed, 0 skipped,确保系统稳定性。

此更新为代销平台提供了更全面的适当性检查能力,提升了系统的功能性与可维护性。
2026-09-08 21:44:16 +08:00
zhanghongyu_0626 ef56c56435 feat(api): 实现代销平台 API v0.1,包括客户、产品、理财师、合规及员工接口
- 新增多个 API 路由:`/api/customers`, `/api/products`, `/api/advisors`, `/api/compliance`, `/api/staff`,支持客户信息、产品详情、理财师客户列表、合规判定及员工上下文查询。
- 引入平台服务层,封装核心只读操作,支持数据脱敏功能。
- 更新依赖注入,确保各 API 路由的权限控制与数据访问一致性。
- 添加相应的单元测试,确保新接口的功能完整性与稳定性。

此更新为代销平台提供了基础的 REST API 支持,增强了系统的可扩展性与可维护性。
2026-09-08 21:01:07 +08:00
zhanghongyu_0626 f0bce1270b feat(api): 添加代销平台 API 契约文档及相关更新
- 新增《接口契约-代销平台API-v0.1.md》,定义代销平台 REST API 的路由风格、命名规范及端点清单。
- 更新 AGENTS.md,包含代销平台 API 契约的路径信息。
- 修改 ITERATION.md 和 MEMORY.md,反映代销平台 API 的实施进度及相关文档的状态。
- 更新 TODO.md,明确代销平台 API 的实现优先级。

此更新为代销平台 API 的开发提供了清晰的指导,确保各模块间的接口一致性与可维护性。
2026-09-08 20:18:00 +08:00
zhanghongyu_0626 f87e11f104 feat(merge): 完成 AL-09 合并接线,整合风控模块与宿主 Wave 0
- 合并 `risk-control-agent` 分支至 `merger`,实现 JWT 统一与模块 API 恢复。
- 更新 `auth_service` 和 `auth_adapter`,确保对外登录/token 统一。
- 增强 chat 模块,支持会话管理与流式对话(SSE)。
- 测试基线更新至 502 passed, 1 skipped,确保系统稳定性。

此更新标志着风控模块的成功集成,提升了系统的整体功能与可维护性。
2026-09-08 20:00:39 +08:00
zhanghongyu_0626 6d780d45c3 feat(auth): Enhance JWT handling and error management in authentication flow
- Updated the login endpoint to utilize shared JWT issuer/audience settings, improving consistency across modules.
- Introduced error handling for unknown accounts during token issuance, raising an UnauthorizedError when necessary.
- Enhanced traceability by adding trace and request IDs to responses, ensuring better tracking of requests.
- Refactored exception handling in middleware to properly bubble up application-specific errors, preventing them from being swallowed.
- Added new utility functions for generating trace headers to improve debugging capabilities.

This update strengthens the authentication process and enhances error visibility, contributing to a more robust and maintainable codebase.
2026-09-08 19:55:08 +08:00
zhanghongyu_0626 04c12152f6 feat(chat): 重构对话接口与服务,增强会话管理与工具节点支持
- 更新 chat.py,整合四个 Agent 的统一入口,增加输入防护与会话校验逻辑。
- 扩展 agent_service.py,加入工具节点与 LLM 交互,支持意图匹配与合规护栏。
- 改进 memory_service.py,优化会话窗口管理,支持 Redis 与 MySQL 的数据同步。

此更新提升了对话系统的安全性与可扩展性,确保了会话数据的可靠性与合规性。
2026-09-08 19:54:46 +08:00
zhanghongyu_0626andCursor 452b427365 merge: 合并远程 risk-control-agent 到 merger
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 17:56:12 +08:00
zhanghongyu_0626 4685dce518 Update README.md to refine project deliverables and clarify document relationships
- Changed section title from "三份交付物" to "交付物" for clarity.
- Added a new document entry for "04-从需求到公共API开发方法.md" detailing the development methodology from requirements to API.
- Enhanced the explanation of the relationships between documents to better illustrate their interconnections and usage contexts.
2026-09-08 17:47:53 +08:00
GaoYiYuan_0626 2d0e2fa0fe docs: README/AGENTS/MEMORY 同步前端接入面(方案 B+C)与 503 基线 2026-09-08 14:29:33 +08:00
GaoYiYuan_0626 458dbdc7a6 docs: 登记方案 C 交付与遗留项 2026-09-08 14:24:08 +08:00
GaoYiYuan_0626 01ec5fce32 feat(chat): 新增 SSE 流式对话端点 POST /api/chat/stream(方案 C)
契约(OpenAI 兼容 chunk,AI SDK / fetch-event-source 可直接接):
首帧 meta(session_id/trace_id/disclaimer)→ delta → finish_reason=stop → [DONE]。
前端侧:免责声明由首帧下发、前端常驻渲染;落库文本仍按原口径拼尾部。

设计拍板:
1. 新增独立端点,原 POST /api/chat 契约与既有测试零影响;
2. 鉴权/限流/输入防护全部在返回 StreamingResponse 之前完成(SSE 一开就改不了
   状态码),401/403/404/409/429/400 仍是普通 JSON;
3. 整轮一次性落库:中途异常/断连不落消息(Tool 留痕已落可审计),不产生
   半截内容污染历史窗口。

实现:
- agent_service:抽 needs_disclaimer/_degraded_reply/_base_state;新增 stream_chat
  生成器(Tool 节点同步跑完再推 LLM 文本,无 key 走降级整块);
- api/chat:抽 _guard_request(准入→空白→限流→注入拦截)与 _prepare_turn
  (归属+会话解析/创建),同步与流式共用,守卫零偏差;
- session_repository:新增 insert_turn——user+assistant 同事务落库 + 事务内
  取 seq,修掉评审 P0(落库失败会半截落且前端收不到 [DONE] 挂起)与 P1
  (两次写非原子);同步端点一并改用。

测试:新增 9 例(契约/免责/降级/异常不落库/落库失败/鉴权边界/超长/closed/Tool
留痕),全量 pytest 494→503 绿。遗留:无心跳帧(长生成空隙靠反代 timeout 配置),
断连留空会话待清理策略。
2026-09-08 14:23:33 +08:00
GaoYiYuan_0626 af7ba00327 docs: 同步前端接入方案 B 交付与风险经理对话线口径 2026-09-08 14:08:42 +08:00
GaoYiYuan_0626 8328c2403e feat(chat): 新增前端拉侧三端点(会话列表/历史消息/关闭会话)
方案 B:补前端对话页「拉」侧能力(chat 此前只有 POST 发消息):
- GET /api/chat/sessions:本人 + 本 Agent 线会话分页列表(created_at 倒序,total 供分页器)
- GET /api/chat/sessions/{id}/messages:历史消息 seq_no 升序分页(closed 会话仍可读)
- POST /api/chat/sessions/{id}/close:active→closed + closed_at;重复/非 active 409

守卫复用:抽取 _resolve_agent_type / _assert_chat_entry / _guard_session,
POST "" 改为复用同套守卫(行为零回归);risk_manager 在对话线数据面保持
同口径 403(PRD 4A.1 冻结);会话仓储新增 list_sessions / list_messages_page /
close_session(条件更新防并发静默写)。

测试:新增 12 例(分页、越权 403+留痕、404、409、manager 拒绝、limit 钳制、
JWT 通道),路由挂载清单同步;全量 pytest 482→494 绿。独立 AI 评审 P0=0,
P1(close 并发 rowcount 静默 200)已修复。
2026-09-08 14:07:38 +08:00
GaoYiYuan_0626 08e831aaf1 docs: README 重写——面向后续人员的分支导览
- 新增「你是哪种后续人员」分流表:接手开发/合并执行人/需求评审/环境演示各取所读
- 模块交付状态+里程碑表(m1~m4 全量)+模块自治架构定位说明
- 铁律速览(六条红线) / 后端结构注释细化(scripts/tests/data 职责)
- 快速启动更新:测试基线 406→482;演示库重灌两步缺一不可警告;JWT 调用示例(签发+双头);dev debug 头兜底说明
- 核心接口一览表(6 端点×权限矩阵)
- 文档地图补全:合并注意事项/边界标注/需求拆解/业务记忆管理
2026-09-07 20:55:00 +08:00
GaoYiYuan_0626 96dcec931e docs: 合并注意事项手册(给合并执行人) + 文档口径清理
- 新增《合并注意事项-风控模块并入main.md》:面向合并执行人的 AL-09 操作手册——
  基底锁定(本地 main 3995cb4,origin/main 停在 Initial commit 勿用)/20 冲突文件
  指引裁决表/14 个静默并入文件清单(11 代码+3 测试,双套风险与边界防呆)/三处
  硬伤处置(issuer 不统一/STAFF-90001 必保/infer_roles fail-open P1)/合并后
  必测清单(边界测试→中间件顺序→chat 签名→重灌→全量)/演示库重灌提醒
- TODO/MEMORY 口径落账:接口实调验收通过(2026-09-07 AI 代验:三接口契约+三
  鉴权边界 401/403/403 零偏差,前端未 init 口径为后端接口验证);合并 main
  移交合并执行人;模块侧开放项=actor_id 透传评估+前端入口归属拍板;修正
  AL-09 旧口径(9 文件→实测 20 文件);删重复待办行
2026-09-07 20:52:58 +08:00
GaoYiYuan_0626 cfbd056e32 docs: 统一重构档措辞——验收门改为『合并 main 前交付检查点(非分支开发阻塞)』;同步分支已推送远程 + 本地跟踪已建立 + 领先 origin/main 84/落后 0 2026-09-07 20:27:22 +08:00
GaoYiYuan_0626 1d00e53c8e docs: C4~C6 收尾—挂账 #1~#9 逐项核对结论 + risk-m4 tag 落账同步 2026-09-07 20:07:47 +08:00
zhanghongyu_0626 7d854e03ff Add project management documentation for JinRong financial project
- Introduced three key documents:
  - **01-每日会议纪要模板与流程.md**: A template for daily meeting minutes and processes.
  - **02-项目开发计划.md**: A project-level development plan outlining the project timeline, team roles, and dependencies.
  - **03-表设计文档.md**: A readable table design document serving as a dictionary for understanding database structures and relationships.
- Created a README.md to index project management documents and their purposes.
- Enhanced documentation to support a 5-person full-stack novice team in project execution and collaboration.
2026-09-07 20:04:53 +08:00
GaoYiYuan_0626 323d98bdc2 docs: C4~C6 文档落账同步(勾 TODO/MEMORY/交接文档 + 演示 SOP A-12 + 02-redis-keys C6 联动)
- TODO/MEMORY/交接文档:C4/C5/C6 全部标记完成,基线更新为 482 绿(406+30+17+17+12)
- 演示 SOP 补 A-12 代理人行为链走查步骤(debug 头透传 actor + cron 扫描脚本)
- 02-redis-keys.md §2.6 C6 联动清单(代理人维度独立出单线/推送/去重口径)
2026-09-07 19:57:52 +08:00
GaoYiYuan_0626 66ec7eba08 feat: C6 FR-10 代理人行为链 RISK-008
代理人异常行为链识别(RISK-008)落地:
- 新增 agent_behavior_service:三条件证据聚合(A 诱导调仓/B AUTH_403_SCOPE 越权试探/C AUTH_403_NOT_OWNER|NOT_ASSIGNED 越权查询),按代理人维度独立出 pattern 单,payload.actor_id 指向代理人,审计仅 INSERT event_type=agent_behavior_detected。
- risk_repository 新增 list_audit_events / find_agent_behavior_alert / merge_agent_behavior_payload(同日同代理人一张单,证据并集)。
- trade_gateway.submit_trade 补 actor_id 透传(代理人发起交易归属发起人,缺省 SYSTEM);simulate 路由传入 auth.actor_id。
- chat_tools 新增 query_agent_behavior 只读 Tool(agent_id 过滤 + 客户脱敏),tool_service 补意图词与摘要。
- scripts/cron/agent_behavior_scan.py 定时扫描脚本。
- 修复 append_alert_event 序列化缺 default=str(C6 evidence 含 datetime 字段)。
- 单测 12 例(_count_induce 边界 / 三条件 / 出单去重 / payload 归属 / Tool 过滤脱敏)。
全量 pytest 482 passed 0 failed(470 基线 + 12 C6)。
2026-09-07 19:53:39 +08:00
GaoYiYuan_0626 90d0660b44 feat: C5 FR-9 预警处置时效升级(RISK-007,P0)
- 仓储:新增 list_pending_alerts_all / update_alert_escalation(统一读改写 payload,
  升级标记独占写入,status/handler_* 列不碰;_parse_alert 补 created_at/handled_at
  字符串→datetime 解析,兼容 sqlite 原生 DDL)
- escalation_service.scan_and_escalate:扫描判级(普通 4h/24h、AML 1h/4h 短通道)、
  幂等闸门(仅升不降)、先持久化再推送、按 (customer_id,level) 降噪合并一次推送、
  通知链累积(L1 含 risk_manager / L2 含 compliance)、逐单+任务级审计
- scripts/cron/escalation_scan.py:15min 定时扫描壳(sys.path 引导 + new_trace + JSON 摘要)
- 对话线 query_overdue_alerts Tool + 注册表 + 意图词(置于 alert_query 之前)+ summarize 分支
- C5 前置:seed STAFF-31001/31002(risk_manager) + deps 矩阵放行 + chat.py 显式 deny +
  risk.py 台账全量只读分支;JWT 手册 §5.3/§5.4/§6.1 增补 risk_manager
- 测试:conftest 回拨 fixture + test_escalation_service(9) + risk_api/manager(5) +
  chat deny(1) + chat_tools overdue(2);全量 470 绿(453+17)
2026-09-07 19:28:04 +08:00
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
GaoYiYuan_0626 8c226f0c6d chore: 风控Agent模块自治边界标注 + AL-09 合并预处置
背景:远端 main 新提交 3995cb4(09-07 17:20,交接文档漏记)为 Wave 0 鉴权/
chat/防护平行实现,与已完工 T-01/T-02/T-03/T-06 同名不同路径;试合并实测
20 文件冲突(原记 9 个),另有 13 个 main 新增文件不报冲突会静默并入。
拍板:风控 Agent 按独立封装模块自治,与宿主耦合收敛到 4 个接缝。

1. 《风控Agent模块边界与合并接缝标注》入库存档:A~D 四类文件归属表;
   4 接缝(S1 挂载点 main.py / S2 AuthContext / S3 settings / S4 引擎工厂);
   20 冲突文件逐个裁决(core_ro、model/suitability、conftest、02-seed-base
   以模块版为准;chat/main/settings/agent_service 等公共层以 main 为主);
   三处硬伤处置:issuer 不一致改为适配器映射不统一、STAFF-90001 必保、
   main infer_roles 未知 actor 默认 analyst(fail-open)记宿主侧 P1。
2. app/api/auth_adapter.py:S2 接缝适配器预制件(当前未接线,AL-09 接入)。
   鸭子类型读宿主 ctx 故不依赖宿主文件;sub→actor_id、trace_id→contextvar、
   perm_matches 兼容宿主 `前缀:*` 通配;缺主体即 HostAuthAdapterError,
   fail-closed 不静默降级。
3. tests/test_module_boundary.py:边界防呆 4 类断言——模块私有文件存在、
   禁止跨层 import 宿主私有实现(gateway.*/config.database/middleware.*/
   utils.input_guard/model.schemas)、AuthContext 契约完整(actor_id 与
   has_role 多参)、settings 私有字段与 AGENT_TYPES 四值不漂移。
4. tests/test_auth_adapter.py:适配器 11 例(映射/回退/fail-closed/trace 绑定/通配)。

基线:406 → 436 全绿(演示库已按演练 SOP §2 重灌:AML 8 条 / 演示 7 行 / sync 33 rows)。
2026-09-07 18:28:18 +08:00
GaoYiYuan_0626 1ac331b281 docs: 阶段一 AL-01~08 完成落账 + 文档同步——六件套反映换核完成(406 绿基线 425→406/SUIT-001~008 退役改 core_ro.check_suitability C×R 矩阵+JR-AST/FM 契约/risk_suitability_log 21 列/种子 33 客户 14 产品/risk-m1 已补打指向 3c07de6);TODO 进行中改阶段一验收门(唯一卡点=用户目视确认)+AL-09/10/11 待办;ITERATION 追加阶段一完成行;REQUIREMENTS R-02 换核标注;开发计划 M1 改已补打;入库存档《修改报告-对齐main基准.md》(阶段一执行依据)与《实现方案-风控追加需求v1.1-C4C6.md》(阶段二编码依据);吸收上会话遗留同步(分支口径 risk-control-agent/PRD v1.1 冻结标注/T-21 评审闭环/T-03/C1~C3 落账/交接文档指引) 2026-09-07 18:01:16 +08:00
GaoYiYuan_0626 b5fd52ef02 AL-08: 演示库重灌与种子核对对齐 main 基准——prepare_risk_demo.sql 改写 expires_at 口径(演示客户刷新为测评 90 天前/剩余 275 天,CUST-1004 保持过期演示 FM-03,替代 SUIT-008 evaluated_at+365 旧写法);演示 SOP 同步(§2 完成标志 33 客户口径+expires_at 剩余天数,A-1 预期改 SUIT_RISK_MISMATCH,A-2 改 FM-01 SUIT_AGE_CONFIRM 网点确认);网关阻断响应补全 main 契约字段(match_result/mismatch_type/requires_disclosure/needs_branch_confirm/rule_refs)+audit detail 加 block_response_code;集成测试 4 例旧口径断言更新(A-1 trace 一致性断机器码/A-1 audit JSON 断机器码/A-2 重写为 FM-01 语义/settings 退役断言)。SOP §2 脚本化全量重灌双库验证通过(AML 8 条/演示 7 行/sync 33 rows);全量 406 passed 0 failed 0 skipped(集成测试真库走 21 列新表+expires_at 数据恢复执行) 2026-09-07 17:49:39 +08:00
GaoYiYuan_0626 ec11ec42c0 AL-07: test_suitability 按 main 契约重写——七判定路径正反例(not_found 客户/产品两向/FM-03 过期/JR-AST-PRO 专业豁免优先于矩阵 forbidden/JR-AST-012 矩阵 forbidden/矩阵缺行 fail-closed/allowed/矩阵披露与产品 requires_disclosure 两源/FM-01 age70+R5 阻断+69岁与R2 两边界);compute_rule_refs 四类组合(含报告样例 过期+不匹配→['JR-AST-012','FM-03']);build_suitability_log_row 逐字段 21 列映射断言+bool→int 转换;服务集成端到端(21 列落库/check_source r02_trade 与 r02_chat/actor_id/request_ref 透传/兼容字段 rule_id=机器码 映射/NotFound 结构化不抛);MySQL 方言冒烟(真库连通时验 SQL 可执行性,未灌库自动 skip)。可控日期用远未来/远过去 expires_at 种子。全量 395 passed 0 failed;1 skip=集成模块待 AL-08 重灌演示 SQL expires_at 2026-09-07 17:42:55 +08:00
zhanghongyu_0626andCursor ecdf8b5395 Add Docker compose and bootstrap script; ignore override yml only
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 17:42:43 +08:00
GaoYiYuan_0626 38da477be4 AL-06: 对话 Tool 与 API 响应对齐 main 基准——chat_tools.suitability_check 返回体扩展 match_result/mismatch_type/requires_disclosure/needs_branch_confirm/block_response_code/rule_refs(替代 rule_id/reasons/effective_level 展示),check_source='r02_chat',not_found 转结构化 found=False(NotFoundError except 死代码清除);tool_service.summarize suitability 分支按新枚举重写文案(网点当面确认 FM-01/签署风险揭示书/测评过期 FM-03/专业豁免,附 rule_refs 依据);risk_api 断言改 block_response_code。全量 373 passed 0 failed(1 skip=test_suitability 占位待 AL-07)。遗留:chat 链路 risk_suitability_log.actor_id 暂落 SYSTEM(run_tool 统一透传需动 core_tools/kb_tools 冻结 func 契约,发起者留痕已由 agent_tool_call 覆盖) 2026-09-07 17:39:04 +08:00
GaoYiYuan_0626 adf5e8013a AL-05: suitability 服务重构换核对齐 main 基准——判定内核由 SUIT-001~008 纯函数矩阵改为 core_ro.check_suitability(C×R 数据驱动);SuitabilityResult 扩 main 新字段(match_result 五值/mismatch_type 七值/requires_disclosure/needs_branch_confirm/block_response_code/rule_refs)并保留旧字段兼容层(rule_id=机器码别名/effective_level=customer_level/reasons=[reason]);check_core/cap_by_age/match_by_matrix/is_assessment_valid 删除(SUIT-006 被 FM-01 替换,SUIT-008 被 FM-03 expires_at 替换);settings.risk_assessment_valid_days 退役(.env/.env.example 注释);NotFoundError 不再抛(not_found 结构化,main 契约);写库走 build_suitability_log_row + insert_suitability_log 升级 21 列(rule_refs JSON 序列化);check_source 参数化(网关 r02_trade/risk.py manual)+actor_id 透传;网关阻断响应补 block_response_code;model 抽 compute_rule_refs 公共函数防两处漂移;测试配套:_ddl 加矩阵 25 行种子 helper、conftest fixture 灌种子+集成就位校验改 expires_at 口径、trade_gateway/risk_api fixture 补种子与 expires_at、404 两例改 200+blocked 新契约、repository 21 列断言、settings 退役断言、test_suitability 占位 skip 待 AL-07 重写。sqlite 端到端七语义+落库验证通过;剩 4 failed 均为 chat_tools/API 旧展示断言(AL-06 处理) 2026-09-07 17:34:32 +08:00
zhanghongyu_0626 3995cb44d8 Implement authentication and chat functionality with JWT support
- Added `auth.py` for mock login and JWT issuance.
- Introduced `chat.py` for handling chat requests with role-based access control.
- Enhanced `main.py` to include new routers and middleware for tracing.
- Implemented input validation in `input_guard.py` to prevent SQL injection.
- Created repositories for managing agent sessions and audit logs.
- Added exception handling for authorization errors.
- Updated settings to include JWT configuration.
- Introduced tests for authentication and input validation.
2026-09-07 17:20:42 +08:00
GaoYiYuan_0626 c92f0d7020 AL-04: 引入 model/suitability.py 对齐 main 基准——build_suitability_log_row 原样引入(check 结果→risk_suitability_log INSERT 行映射;rule_refs 组合:JR-AST-012 等级不配/FM-03 风评过期/FM-01 网点确认/JR-AST-PRO 专业豁免;CheckSource 四值 Literal) 2026-09-07 17:12:46 +08:00
GaoYiYuan_0626 ba3465a953 AL-03: core_ro.py 融合对齐 main 基准——我方骨架保留(utils/db.get_engine 统一引擎工厂,main 自带 create_engine 工厂不采纳;风控扩展 get_trade_by_id/sum_trades_on_date/list_trades_range/list_active_customers 全保留),吸收 main 四项+1:①get_customer_l0 扩列版(c.*+风评新列+risk_is_expired) ②check_suitability+_suitability_result(C×R 矩阵判定,判定链 not_found→FM-03 过期→JR-AST-PRO 豁免→JR-AST-012 矩阵→披露→FM-01 网点确认) ③list_products_for_customer(C-11) ④list_holdings 合并(limit=500 截断防护+min_subscribe_amount/term_days 新列) ⑤list_trades(差距#13 新查询能力)。移植坑消解:main 三处 CURDATE() SQL 表达式统一改 Python 端 _is_expired 计算(sqlite 测试库兼容),date/datetime/str 统一 _as_date 归一。双方言验收:MySQL 真库(not_found/expired 真跑)+sqlite 七路径可控日期验证通过;pytest 失败面与 AL-02 基线一致(15 failed 均旧契约断言) 2026-09-07 17:11:52 +08:00
GaoYiYuan_0626 e99ec6775a AL-02: risk_suitability_log 重建 21 列对齐 main 基准——底座 SQL 采纳 main 版(product_name/investor_category/match_result 五值/mismatch_type 七值/requires_disclosure/needs_branch_confirm/risk_was_expired/block_response_code/check_source 四值/actor_id/rule_refs JSON + 6 索引);07-说明.md 直接采用 main 版 P0 契约;tests/_ddl.py sqlite 同步(21 列 + core_suitability_rule 新表 + core_customer/core_customer_risk/core_product 扩列,VARCHAR 近似 ENUM 与现有风格一致);修 test_risk_api 位置式 INSERT 补列名。全列 INSERT 验收通过;剩余 15 failed 均为旧契约断言(报告预告作废集,AL-05/06/07 清零) 2026-09-07 17:05:15 +08:00
GaoYiYuan_0626 bb244f43a3 AL-01: Core 库表结构对齐 main 基准——01-ddl 采纳 main 版(新增 core_suitability_rule C×R 矩阵表+FK/core_customer KYC 扩列含 is_hnw/core_customer_risk 七新列含 expires_at+investor_category/core_product 起购金额/期限/揭示书列/core_trade AML 扩列/core_cash_flow flow_subtype);02~06 种子采纳 main 版(33 客户含 CUST-DEMO-A~E/14 产品/矩阵 25 行);保留我方独有 STAFF-90001 风控演示账号;README 种子规模与矩阵口径同步。非交互重灌验证通过(矩阵 25/客户 33/产品 14/风评 33) 2026-09-07 16:57:15 +08:00
zyiandCursor fd9464db0a Append Zhong Zhichao data-analyst work notes to user story doc.
EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 16:06:18 +08:00
GaoYiYuan_0626 eae28bee4e docs: PRD/规则表/开发计划合并需求追加 v1.1 修订 2026-09-07 12:46:59 +08:00
GaoYiYuan_0626 21f63a95ee chore: .gitignore 忽略风控需求追加过程文档 v1.1 2026-09-07 12:42:59 +08:00
GaoYiYuan_0626 9cc2e59bb7 fix: T-21 评审闭环(P1-1 MILVUS_URI 遮蔽)——milvus_service 环境防御顺序重排: settings 先初始化(干净读 .env)→os.environ 归位合法 http 占位(仅替换文件 URI)→import pymilvus; 原顺序下 pydantic 读到被污染 env 会把 .env 的 MILVUS_URI 一并遮蔽(最坏 import 顺序真连接事故); 最坏顺序断言+全量 425 绿+端到端检索通过 2026-09-07 12:24:46 +08:00
zhangyong 5f0f86a007 Merge branch 'main' of http://47.106.207.27:3000/hongzhangyu/XingHuo 2026-09-07 12:15:59 +08:00
zhangyong a9521bcc62 docs(用户手册): 补充11到16条用户咨询需求
新增了包括风险对冲咨询、账户定期体检、税务筹划、财产隔离、定制生活服务以及反共识独立判断在内的6项用户需求条目
2026-09-07 12:15:20 +08:00
GaoYiYuan_0626 8fbbca6bb2 docs: T-21 文档同步——TODO 勾选(完成详情+三坑收口)/MEMORY 交接清单与仓库地图/FLOW milvus_tool 状态改已做; 下一项=前端 React 入口 2026-09-07 12:12:36 +08:00