zhanghongyu_0626 and Cursor
03fce883d4
merge(risk-control-agent): fund convert T+1 on merger base (plan A)
...
Co-authored-by: Cursor <cursoragent@cursor.com >
2026-09-12 17:52:17 +08:00
zhanghongyu_0626
c7fa32ef62
docs(advisor): 顾问线已合入 merger,同步记忆与 E2E 日志
...
- MEMORY/TODO/合并说明:integrate/advisor-agent 已通过 fast-forward 并入 merger(4be27c5)
- ADV-001:补充 4be27c5 与 64c5db7 后端结论仍成立,无需重跑
2026-09-12 17:23:09 +08:00
zhanghongyu_0626
d394686a3b
feat(advisor-agent): Integrate advisor agent functionalities and migration scripts
...
- Merged the `integrate/advisor-agent` branch into the `merger`, enhancing the advisor agent's capabilities with compliance, KYC, and script templates.
- Updated the testing baseline to reflect 926 passed tests, with 65 failures concentrated in the advisor agent's `test_sprint*` cases.
- Introduced new migration scripts for advisor-related database structures, ensuring smooth integration and data management.
- Enhanced documentation to include the new API structure and integration details, providing clarity for future development.
This update significantly advances the advisor agent's functionality while maintaining a structured approach to integration and testing.
2026-09-12 16:37:29 +08:00
zhanghongyu_0626
282f21932c
Merge remote-tracking branch 'xinghuo/advisor-agent' into integrate/advisor-agent
2026-09-12 16:32:48 +08:00
zhanghongyu_0626
973bf1b834
feat(advisor-agent): Integrate advisor agent into merger with new API structure
...
- Merged `xinghuo/advisor-agent` into the `merger` branch, establishing a new API prefix `/api/advisor-agent` to avoid conflicts with existing endpoints.
- Implemented a comprehensive implementation plan detailing the integration steps, including conflict resolution, database migrations, and service adaptations.
- Introduced new files for advisor compliance, script templates, KYC, and market alerts, ensuring a cohesive addition to the existing architecture.
- Updated documentation to reflect the new structure and integration process, enhancing clarity for future development and maintenance.
This integration significantly expands the capabilities of the merger, providing a robust framework for advisor-related functionalities while maintaining compliance and operational integrity.
2026-09-12 15:14:29 +08:00
GaoYiYuan_0626
eac6b61ce4
文档:第 6 步集成测试收官(转换线 AIcoding 六步全流程完成 · 849 绿 / CONVERT_STRESS 7/7 / 真库 9/9 / 紧池 100% 重测)
2026-09-12 14:52:01 +08:00
GaoYiYuan_0626
b411d5a087
T-14/T-17 开口闭环:PRD §2.5.3 修订 + truncate 舍去法接入 + R-12 定稿(用户三项拍板 · 849 绿 / 真库 9/9)
...
① PRD §2.5.3 修订:删「易方达 ETF 场外取整数位」(无证据且有反证,真实整数位载体为场内),改记「2 位主流 + 舍去型真实存在」,版本块加注记
② rounding_mode=truncate 消费接入(用户拍板补做):
- core_ro.get_share_rounding = 位数+模式回退链单点(规则行 → core_product → 默认 2/half_up,mode 白名单读取即校验,get_share_digits 转薄包装)
- calc.product_round/in_qty 加 mode 参数(truncate → ROUND_DOWN)
- 确认段 + 申购折算两处透传;载体 09-seed-org.sql ⑦ 段 PROD-005828(product 层回退,零转换场景引用)
- 测试 +7(842→849):calc 4 + 确认段 2(truncate 34945.53 vs half_up .54 分化 + 回退链遮蔽语义)+ 申购段 1
- 突变:两调用点同拆 mode 透传 → 2 红,还原绿;真库 9/9(seed 新增 ⑫ 载体在位断言)
③ R-12 口径裁定追认定稿:条目回写开发计划(NULL 不参与 A/C 判定 / 同类走一般转换规则)
审核教训留痕:PRD 独立 AI 三轮审查未抓出外部事实断言无出处 —— 联网核实铁律再添例证
文档:开发计划 T-14 开口闭环段 + 基线 849 · 日志新节 · TODO/MEMORY/AGENTS/交接文档开口清零
2026-09-12 14:31:35 +08:00
仝勋敏
68df13c10b
feat: add auth/compliance/kyc/market/template modules, alembic migrations, tests and docs
2026-09-12 14:27:37 +08:00
GaoYiYuan_0626
cde0c226fe
基金转换 T+1 模型:T-15/T-16/T-17 收官(842 绿 / 真库 9/9 / 转换线第 5 步完成)
...
T-15 D28 部分成交专项:
- sqlite +1 终态单幂等 skipped 口径裁定(ConfirmConflict 仅限读后状态才变窗口)
- 真库 confirm +3 组 19 项(E2 占用释放双向 / G2 actual_qty=0 → rejected / H2 撤单后确认)→ 102/102
- CONVERT_STRESS Barrier(2) 窄窗争批:恰 1 confirmed + 1 rejected
- 突变实证防御纵深:④可用量复核 / ⑤plan_lots / 事务内哨兵三道防线拆任一道仍收敛 rejected
T-16 D29 资金流中转:
- _insert_cash_flows 全仓唯一写入点(out/redeem 费前 + in/subscribe 净转入,remark=convert:{gid} 同事务)
- test_confirm_writes_no_cash_flow 反转为恰 2 条 + 金额对账(T-7 登记闭环)
- 真库 apply A2 组 + B 组 0 残留 → 30/30;confirm 反转断言 → 103/103
- FK 坑(core_cash_flow.fk_cf_customer 挡客户删除):5 处清理段补删
T-17 D30 share_class + A/C 互转:
- _validate_products 纯新增拦截分支:两端 share_class 非空且不同才查 allow_ac_convert(任一端=1 两向放行)
- 口径裁定 2 条(R-12 字面偏差,待用户追认):NULL 不参与 A/C 判定 / 同类走一般转换规则
- 联网核实(用户铁律):A/C 互转需管理人开通(摩根 2025-11 公告)= 开关真实载体;持有期重新起算与本仓一致
- 种子 ⑥ 段(双开对/双关对照/同类对照);sqlite +4 → 842 passed / 8 skipped;真库 accept H 组 → 43/43
- 突变:分支失效 → closed 红,还原绿
文档:开发计划 T-15~T-17 DoD 全勾 + 执行记录 · 基线 842 · TODO/MEMORY/AGENTS/交接文档 v4.5 终态(第 5 步收官 → 下一步第 6 步集成测试)
2026-09-12 13:42:49 +08:00
GaoYiYuan_0626
1a615bbbef
基金转换 T+1 模型:T-14 D27 产品舍入真正接入 + 联网核实纠偏(837 绿 / 真库 9/9 / 种子 v1.1 全 2 位)
...
- 接入面 4 处单点收敛:core_ro.get_share_digits(唯一回退链:规则行→core_product.share_digits→PLACES=2)· calc.in_qty 加 digits=PLACES 可选参数 · 确认段(business_type=convert)· 网关申购折算(subscribe);redeem 份额申报无折算无消费方
- 边界裁定:只接落库侧(开发计划 DoD 即边界),响应展示维持 q(D2) 收敛(2 位产品逐字节零漂移);PRD §2.5.2 展示按产品覆盖为登记开口
- 联网核实(用户铁律):主流 2 位 ✅ · 位数按各基金合同配置 ✅ (南方 2012 调整公告)· 舍去 TRUNCATE 型真实存在 ✅ · 货基 2 位 ✅ · 「指数基金份额 4 位」证伪 ❌ (ETF 联接/指数合同全 2 位)→ 11-seed-share-rule.sql v1.1:3 产品 9 行 4→2 + 头注重写为核实出处;「易方达 ETF 场外整数位」无证据有反证(登记开口待拍板)
- 测试 +7(830→837 零回归):calc 层 2 + confirm 段 3(回退链三层各 1 + business_type 干扰行)+ 申购段 2;4 位种子行 = D27 机制验证载体(docstring 钉明)
- 突变验证 2 组(confirm/gateway digits 改固定 2 → 各 2 红,还原零残留);真库 9/9 退出码 0(seed 重灌 42 行全 2 位生效)
- 开口 2 项待用户拍板:① PRD §2.5.3 易方达句修订 ② rounding_mode=truncate 消费接入(真实存在、T-14 范围外)
2026-09-12 12:41:20 +08:00
GaoYiYuan_0626
a7d50386b2
T-13 补修:verify_convert_lots/apply 字面造数日期改真库日历链式回推(用户指出硬编码 · 全仓排查留痕)
2026-09-12 12:09:57 +08:00
GaoYiYuan_0626
5f7ad9180b
文档:T-13 回写 + 全仓进度一致性(开发计划 DoD 6/6 全勾 + 执行记录 · PRD §9 第 18/31 条实测回填 · 交接文档 v4.3)
2026-09-12 11:58:42 +08:00
GaoYiYuan_0626
9ad8a90de1
文档:T-12 回写 + 全仓进度一致性(开发计划 DoD 全勾 + 执行记录)
...
- 开发计划 v2.0 T-12 节:DoD 4/4 全勾 + 执行记录(三改动面 / 联网核实留痕 /
confirm_one 留痕修复 / 真库 56/56 / 突变 4 组 / rebuild_alerts 路径勘误)
- 交接文档 v4.2(T-12 完成块 + 基线 849,.gitignore 内不入库)
- TODO.md / MEMORY.md / AGENTS.md:T-1~T-12 ✅ / T-13~T-17 ⬜ ,基线 849
- 2026-09-12.md 追加 T-12 执行记录(含用户铁律:外部真实业务事实必须联网核实)
2026-09-12 10:55:01 +08:00
GaoYiYuan_0626
b4a61dc306
文档:T-11 回写 + 全仓进度一致性(开发计划 DoD 全勾 + 执行记录 / 交接文档 v4.1 / TODO / MEMORY / AGENTS / 当日日志)
2026-09-12 09:35:13 +08:00
GaoYiYuan_0626
5a784dc185
文档:T-10 回写 + 全仓进度一致性(开发计划 DoD 全勾 + 执行记录)
...
- 开发计划 v2.0:T-10 六项 DoD 全勾(申购落批次 / 哨兵不超扣 / T+2 半开区间
双向 / 金额公式 D26 / 转换后不超扣验收 9 / rebuild 无漂移)+ 新增执行记录
(改法、验证证据 844 passed、真库 89/89、突防验证、3 处断点与口径)
- 交接文档 v4.0(gitignore 不入库,本轮未提交)
- AGENTS.md 入口引用 → T-1~T-10 ✅ / 844 / 89/89 / 下一步 T-11
- docs/memory/TODO.md:T-10 完成条目 + 待办行 T-11~T-17
- docs/memory/MEMORY.md:进度 + 自检第 5/6 问 → 844 / T-1~T-10
2026-09-11 21:24:40 +08:00
zhanghongyu_0626
2b4eaa9725
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.
2026-09-11 20:47:18 +08:00
GaoYiYuan_0626
6ecde37885
文档:convert_fund 退役并入 T-13(用户 2026-09-11 裁定)
...
开发计划 T-13 目标/改法 6/DoD/风险补「convert_fund 退役 + 清理 v1.0 依赖链」;
TODO 待办行补注裁定。本地提交,未推送远程
2026-09-11 20:42:37 +08:00
GaoYiYuan_0626
2277d61568
文档:T-9 回写 + 全仓进度一致性(开发计划 DoD 全勾 + 执行记录 / 交接文档 v3.9 / TODO / 两份 MEMORY / AGENTS.md)
...
开发计划 T-9 新增执行记录(附 2 处口径缺陷细节);各入口进度统一
T-1~T-9 ✅ / 834 passed / 真库 verify_convert_api 88/88 / 下一步 T-10
2026-09-11 20:37:51 +08:00
GaoYiYuan_0626
9f28633e55
文档:T-8 回写 + 全仓进度一致性复核(订正 5 处漏同步)
...
本轮在 T-8 提交(57f16a5)后做文档回写,并对全仓「同一事实的副本」做一致性扫描,
发现并当场订正 5 处漏同步(均属上次改了主状态位、漏改副本):
- AGENTS.md 入口引用(最重要,属项目记忆已强调的「全仓同步入口引用」漏项):
T-1~T-6 ✅ /797 基线/下一步 T-7 → T-1~T-8 ✅ /829 基线/下一步 T-9;
T-6 真库 verify_convert_accept.py 36/36 → 37/37,并并列 83/83、39/39。
- docs/memory/TODO.md:汇总待办行「T-8 ~ T-17(含已完成之引擎时机)」→「T-9 ~ T-17」;
为 v0.x 线引用块加编号歧义提示(其 T-11/T-12 与新线同号且均涉 amount_view,易混)。
- docs/memory/MEMORY.md:自检问答第 6 问进度 T-1~T-7 ✅ /827 → T-1~T-8 ✅ /829。
- 开发计划(T-8 执行期订正,承 57f16a5 代码提交):
就地订正 T-7 执行记录第 2 条「T-8 剩余仅为 rules.amount_view」之误(F-10 明确 T-8 不动去重口径,属 T-11);
新增 T-8「执行记录」5 条差异裁定;DoD 全勾。
不入库但同批完成(交接文档.md 受 .gitignore 忽略):
- 顶部版本 v3.7 → v3.8;§③ 表格行;§B.11 状态块(T-8 完成 + 两处订正);
- 开工纪律行 T-1~T-6 → T-1~T-8;
- §B.11「未落地(T-1 起执行)」立项期清单 → 「已落地」并附实测行号
(01-ddl.sql 272/297/305 行;已进 reset.ps1 与 verify_convert_seed.py 清单),原文折叠留痕。
复核:全量 pytest -q → 829 passed / 10 skipped(16.37s,零失败)。
2026-09-11 19:53:31 +08:00
GaoYiYuan_0626
0e27fec5cb
文档:T-7 确认段落地回写(开发计划 DoD 全勾 + 执行记录 / 交接文档 §B.11 / TODO / 两处 MEMORY)
...
- 开发计划 T-7:DoD 9 项勾选 + 新增「执行记录」小节,逐条留痕 6 处与计划的差异裁定:
① 确认段不做最低持有重判(计划缺口,强制全转属受理段决策,受理单 remark 传承);
② 新增 format/audit/engine_call 三共用模块(后者顺带完成 T-8 的「引擎时机改」);
③ nav.py 未改(确认段直调 core_ro.get_nav_on,取 T−1 路径随 v1.0 convert_fund 一并删);
④ test_convert_integration 改写推迟到 T-9(需端到端真接口);
⑤ 受理单置 confirmed 并入 apply_convert 同事务(防「批次已扣、状态未置」中间态);
⑥ MySQL rowcount=changed rows 陷阱(nav_pending 重试不得复用冲突判定)。
- 交接文档 §B.11:T-6→T-7 完成、基线 797→827、真库 36/36→37/37 与 83/83、
新增 T-7 实施期发现段、下一步 T-8/T-9(并注明 T-8 范围已缩小)。
- docs/memory/TODO.md:进度行 + T-6 真库数 + T-7 条目勾选与详述。
- .workbuddy/memory/MEMORY.md 与 docs/memory/MEMORY.md:进度与关键裁定同步;
当日工作日志补「续 3:T-7 确认段落地」。
2026-09-11 19:37:30 +08:00
GaoYiYuan_0626
f056fcd007
基金转换 T+1 模型:T-1~T-6 落地(DDL/数据层/语义收窄/锁/受理事务)
...
AIcoding 第 5 步 todo 开发(开发计划 v2.0)前半段:
- T-1 3 张新表 DDL(core_convert_request 6 态 ENUM / core_trade_calendar /
core_share_rule)+ 种子 + sqlite 单一事实源同步 + 列清单断言
- T-2/T-2b calc 扩展(product_round/redeem_amount/partial_qty)+ 真实净值实算回填
- T-3 convert_request_repository(6 态 + 条件 UPDATE 守卫)+ core_ro 三读方法
+ share_lot_repository.available_qty_with_inflight(R-3 在途占用推导)
- T-4 convert_repository.sync_mirror 成为 risk_convert_detail 唯一进度镜像写入口
(旧三方法标 Deprecated,T-7 后删)
- T-5 locks.py 锁键构造器 convert_req_lock_key / convert_confirm_lock_key
- T-6 convert_service.accept_convert 受理事务(八步:锁→幂等→校验→受理日顺延
→在途占用校验→落单→镜像+审计→202;不扣份额/不折算/不写流水)
+ tests/test_convert_accept.py(16 用例)
+ scripts/dev/verify_convert_accept.py(真库 36/36 一致)
+ trading_calendar.py 纯函数包(R-5)+ 21 用例
T-6 真库实测暴露并修复:confirm_eta 在日历数据边界抛 ValueError,会让已落库
的受理单在调用方眼里变 500;改为展示性字段容错 + 单测守护。
基线:798 passed / 10 skipped,零回归。
2026-09-11 19:21:15 +08:00
zhanghongyu_0626
793c0307f8
feat(risk): Enhance risk management functionality and access control
...
- Updated `RiskListAccess` and `ThresholdWriteAccess` to enforce access control in the risk repository and threshold repository, ensuring only authorized roles can perform sensitive operations.
- Introduced new methods in `RiskRepository` for counting pending alerts and listing alerts with access checks, improving data security and compliance.
- Enhanced the `chat.py` and `deps.py` files to integrate compliance roles into the risk management matrix, allowing for more granular access control.
- Updated documentation to reflect the new testing baseline of 825 passed tests, indicating improved stability and functionality across the application.
This update significantly strengthens the risk management capabilities, ensuring robust access control and compliance with organizational policies.
2026-09-11 17:07:22 +08:00
GaoYiYuan_0626
3b781f8823
文档:开发计划 §10.6 回写死锁重试后补(43cf2a1)执行记录
2026-09-10 20:32:44 +08:00
GaoYiYuan_0626
c56ea8d50e
基金转换 T-13:全量回归 + 50 并发压测 + 性能实测补录
...
交付:新增 tests/test_convert_concurrency.py(9 条 · CONVERT_STRESS 门禁)+ test_convert_service 同键重试 3 条;app/repository/convert_repository.insert_placeholder 改三步法(R-a)、app/service/convert/convert_service.py 幂等判定 pending→202。
修复 2 处并发缺陷(压测暴露,sqlite 不可见):① 阶段一失败后同键重试永久 503(占位朴素 INSERT 撞 uk_group/uk_idem);② 同键竞态子窗口 A 真·双扣 / B 双扣+503(撞 uk_idem 直穿)。
验证:pytest 736 passed / 10 skipped(+5,跑两遍稳定);CONVERT_STRESS=1 并发 9/9;按 SOP 重灌双库复跑零回归;7 个 convert 真库脚本复跑零回归;突变 4 组全部精准命中。50 并发不超卖(成交 20~25)、紧池退避 40/50=80%(不够用)、松池 100%、跨客户 1213 死锁登记待评估;性能端到端 P50 44.2/max 59.8ms、阶段一 P50 9.8/max 16.7ms(未触阈值、未改实测值)。
文档:PRD v0.9.3(§9 第 18 条实测补录)+ 开发计划 §10(10.1~10.5)+ docs/memory/{TODO,MEMORY,FRAMEWORK,ITERATION,2026-09-10}。
2026-09-10 19:46:08 +08:00
GaoYiYuan_0626
22f2a41192
基金转换 T-12:补偿脚本(详情 + 预警)
...
阶段二失败(或阶段 1.5 引擎失败)后,仅凭 Core 侧数据把「详情 + 预警」两件事补回来
(PRD §7.1 / 架构 §5.4)。
落地(改 3 + 新增 2 脚本 + 测试 2 文件)
- convert_service:新增公开 compensate_convert(group_id, ...) —— 补偿的服务端单点入口
· 锁键 convert:rerun:{gid},与 convert_fund 幂等重试路径同一个键
· 详情侧:非 completed 才补写,复用 _finalize_from_core(不另写第二份阶段二)
· 预警侧:幂等锚点 = 转出端 out_trade_id,复用 find_alerts_by_trade;
命中即 skipped,否则跑 process_convert_event
- risk_repository:has_engine_error_audit 加 decision 参数(默认值不变)
· convert 线阶段 1.5 失败审计用 engine_error,普通交易用 risk_engine_error,不是同一个码
- rebuild_alerts.py:新增 --convert-group(与 location 参数 trade_ids 互斥),薄封装
- 新增 scripts/agent/cleanup_pending_convert.py(架构 §2 与开发计划 §9 指定路径):
超 convert_compensate_sla_hours 的 pending 占位 → status='expired'(标记不硬删,S2)
- 新增 scripts/dev/verify_convert_compensate.py:真库验证脚本(MySQL 8.0.46)
- 测试 +12:test_convert_service +4(补写 / 幂等 / missing / locked)、
test_demo_scripts +8(--convert-group 分派与接线 + cleanup 脚本)
state 四态与 CLI 退出码
- rebuilt(0) / skipped(0 幂等) / missing(1 零写入) / locked(3)
- 退出码 2 保留给 argparse 用法错误,故 locked 取 3
真库专属证据(sqlite 单测给不了的,本任务核心增量)
- status='expired' 在 MySQL ENUM 上被接受(sqlite 该列是 VARCHAR,写什么都收)
- created_at < cutoff 在 DATETIME(3) 上的时间边界正确(超时进候选 / 未超时不进 / 复跑幂等)
- input_summary 是真 JSON 列,而 has_engine_error_audit 用 LIKE 判定:脚本先断言
information_schema 的 DATA_TYPE='json' 再验命中,并反向断言决策码不匹配则不命中
顺带收口(用户指示)
- core_ro.concentration_profile 补 h.qty > 0,与 list_holdings 真正同口径
· ratio 不变(归零行市值为 0),但 rows 不再多出已清仓产品、不虚占截断判定位
· 新用例含跨出口一致性断言;突变验证:去掉 qty > 0 → 精准 1 条红
验证
- pytest -q → 731 passed / 3 skipped(基线 719 加 12,零回归)
- 突变验证 3 组精准命中:去掉幂等锚点(1 红)/ 去掉 status 过滤(2 红)/ 补偿无视锁(1 红)
- 真库 verify_convert_compensate.py 34/34,隔离数据零残留
- 全套 7 个真库脚本复跑零回归:seed 全 PASS / apply 24 / service 35 / engine 31 / lots 20 / tools 14 / compensate 34
2026-09-10 18:59:42 +08:00
GaoYiYuan_0626
a6ac39edd6
基金转换 T-11:工具与 SQL 汇总去重(FR-C15 / R-d)
...
convert 在 core_trade 落两条流水(转出 redeem + 转入 subscribe,共享 convert_group_id),
所有金额聚合读取方必须只计一次,否则同笔转换金额翻倍。
落地(改码 3 处 + 新增 1 脚本 + 测试 3 文件)
- rules.py:_amount_view → 公开 amount_view(提升而非复制别名,全仓唯一金额聚合口径);
docstring 补「跨模块共用」说明
- core_tools.py:query_recent_trades 的 sum_amount 改走 amount_view(FR-C15);
items / total_count 保持全量不变——两条流水是真实的两笔权益变动,读到两条是对的
- core_ro.py:list_holdings 加 h.qty > 0(convert 转出全部份额留下的 qty=0 归零行不是持仓);
sum_trades_on_date 加 convert 去重条件(R-d),组内只计转出端
- 新增 tests/test_core_tools.py(3 条:汇总不翻倍 / 跨口径一致性 / 持仓不返回 qty=0 行)
- tests/test_core_ro_sum.py 追加 1 条 convert 去重用例(既有断言零改动)
- 新增 scripts/dev/verify_convert_tools.py:真库验证脚本(MySQL 8.0.46)
执行期裁定 2 条(已留痕)
- _amount_view 提升为公开而非复制:一个函数两个名字会漂移(自检第 13 问)
- SQL 条件从 IS NULL 扩为 IS NULL OR = '':Python 的 if not gid 把空串当无组,
而 SQL 里 '' IS NULL 恒假。真库实证:只写 IS NULL → 合计数 400000(正确 450000,漏算 50000)。
不加则 RISK-002 漏算,且 sqlite 单测若只造 NULL 数据永远发现不了
- 等价性边界:组内无 redeem 时 SQL 丢整组、amount_view 保留首条;由 R-b 保证不可达
验证
- pytest -q → 718 passed / 3 skipped(基线 714 加 4,零回归)
- 突变验证 3 组均精准命中:去掉去重条件(2 红)/ 去掉 qty>0(1 红)/ 汇总不走 amount_view(2 红)
- 真库 verify_convert_tools.py 14/14,隔离数据零残留
- 复跑受影响真库脚本零回归:T-8 31/31、T-7 35/35、T-10 20/20
2026-09-10 18:40:27 +08:00
GaoYiYuan_0626
5e6fa06d03
基金转换 T-10:普通申赎批次维护(FR-C16)
...
让 core_trade 的普通申赎同步维护 core_share_lot 批次,为 convert 提供权威份额口径。
落地(改码 3 处 + 新增 2 个脚本)
- gateway_repository:新增 insert_share_lots / deduct_share_lots,各自单事务、走 rw 账号;
只落已分配结果、不含分配逻辑,避免出现第二份 FIFO 口径
- share_lot_repository:__init__ 增可选 core_ro 入参,让 trade_gateway 复用同一份 FIFO 选批口径(D18)
- trade_gateway:新增 _nav_as_of / _maintain_lots,在落流水后、规则引擎前调用
· subscribe:取 T 日(含)前最新净值 → qty = amount ÷ 净值(2 位 HALF_UP)→ 建批次(confirmed_at = T)
· redeem:FIFO 扣减;无批次但有持仓 → D8 兜底补建后再扣;两者皆无 → 降级跳过
· 整段 try 包住,任何异常只 warning,绝不阻断交易(R-c(1))
- 新增 scripts/core/rebuild_lots.py:按 core_holding 快照重建批次(L-7),与网关 D8 同调 bootstrap_lots;
默认只补建无批次的持仓行(幂等),--force 才先删后建,--dry-run 只报告
- 新增 scripts/dev/verify_convert_lots.py:真库验证脚本(MySQL 8.0.46)
口径订正(联网查证 4 家管理人业务规则后)
- redeem 的 amount ÷ 净值 折算属本项目简化建模,不是行业标准
- 行业铁律是「金额申购、份额赎回」:投资者以份额申报,登记机构按 T 日净值算金额
(睿远业务规则 §65 / 华泰保兴 §69 / 东方基金 §57 / 国投瑞银 §33;无一家公募支持按金额赎回)
- 派生风险:未知价法下 T 日净值当日不可得(T+1 公告),_nav_as_of 实取 T−1 净值,
故此处算出的份额只是估算值
- 已记入 PRD §10.1 已知差异清单;trade_gateway 注释同步订正
验证
- pytest -q → 714 passed / 3 skipped(基线 697 加 17,零回归)
- R16 test_redeem_accepted_without_alert 零改动通过(由 R-c(1) 降级保住)
- 真库 20/20;T-6 24/24、T-7 35/35 复跑零回归;真库隔离数据零残留
- 突变验证 2 组:切断接线 → 精准 2 条红;关掉 D8 兜底 → 精准 2 条红(含 D18 同源断言)
2026-09-10 18:28:48 +08:00
GaoYiYuan_0626
d0097d6004
基金转换 T-9:API 模型 + 网关分派(HTTP 层 convert 走通)+ 展示位数口径修复
...
一、T-9 本体:HTTP 层 convert 端到端走通
- api/simulate.py:TradeRequest 三型字段分池(subscribe/redeem → product_id+amount;
convert → from/to_product_id + qty + 可选 client_request_id)+ model_validator 分支校验;
未知类型放行给网关抛 400(保住既有 purchase → 400 断言);model_dump(exclude_none=True);
PROCESSING → 202;异常捕获由 except LookupError 收窄为 except NotFoundError
(原写法把 KeyError 这类编程错误静默转成 404,实测掩盖 convert 分支真实诊断)。
- gateway/trade_gateway.py:移除 convert 显式拒绝,新增 _submit_convert 分派
(只做参数映射 + 仓储装配);convert 不写 trade_request 审计(审计归 convert_service)。
- utils/response.py:错误体合入 exc.extra(TOO_MANY_LOTS 的 batch_count/max_lots);
既有 ApiError 无 extra 属性 → 老错误体逐字节不变。
- utils/trace.py + main.py:正则收敛单点定义。执行期发现 trace.py 与 main.py 各有一份
内容完全相同的白名单副本 —— S4 要防的「漂移」其实已经发生,现将常量上移 trace.py
成公开 HEADER_ID_PATTERN(同时解决 main→simulate 反向导入成环)。
二、展示位数口径修复(执行期发现 → 联网核验 → 修复 → 文档订正)
发现:同一逻辑响应两种写法 —— 首次 "53456.95" vs 幂等重放 "53456.9500",数值相等、字符串不等。
根因不是 T-7 写错,是契约缺位:§2.5 只规定「金额/份额 2 位」,净值、费率、申请份额的
回显位数根本没定义 → 实现只能 str(Decimal) 原样出网 → 位数随数据来源漂移。
修复:convert_service 新增 _q(value, unit) + _D2/_D4 规格常量作对外唯一出口 ——
金额/份额 2 位、净值/费率/份额尾差 4 位;响应 + 审计 summary + 异常日志共用该出口;
原 _s() 全部替换。首次路径幂等(除 requested_qty/actual_qty/lot[].qty 由 4 位补齐 2 位外不变)。
依据(2026-09-10 联网核验 7 家管理人公告):金额/份额「四舍五入保留至小数点后两位」;
「申请转换份额精确到小数点后两位」;净值保留 4 位第 5 位四舍五入(中欧/国泰公告由 3 位提高至 4 位);
费率以百分比 2 位表示。已知不统一:易方达 ETF 场外份额取整数位、南方基金取截断 → 取主流口径
并记入 PRD 已知差异(未来接真实 TA 需按基金合同配置化)。
三、文档订正
- PRD → v0.9.2:§2.5 拆 2.5.1 计算精度 / 2.5.2 展示位数(新增按字段分类的规格表 + 外部依据);
§5.3 示例 requested_qty/actual_qty/lot_breakdown[].qty 4 位 → 2 位(原示例与 §2.5
「计算与对外展示按 2 位」自相矛盾,属漏改);字段类型约定补「位数不自由 + 两条路径须逐字节一致」。
- 架构 → v1.0.1:§1 原则 11 补「str() 前必须按 §2.5.2 量化」,无结构变更。
四、验证
- 新增 tests/test_convert_integration.py(8 条真 MySQL 端到端,CNV-TEST-/TRD-TEST- 前缀隔离):
折算与 PRD §5.3 逐项吻合、两条流水同组、持仓与批次如实变动、明细 completed + 审计、
幂等重试不产生第二组、跨主体 400、未知类型 400,以及
「首次与重放逐字段逐字节相等」+「展示位数规格」两条新闸门。
- test_trade_gateway.py +17(11 条错误码映射全表参数化 · 202 · 200 透传 · 不写 trade_request 审计)。
- test_integration_risk.py:R15 处置 —— 端到端已迁入新文件,原槽位改造为
test_invalid_type_400_and_no_new_trade_audit(改用 purchase 触发),保住「校验失败不落审计」不变量。
- pytest -q → 697 passed / 3 skipped(基线 672 +25,零回归)。
- 真库复跑:T-6 24/24 · T-7 35/35 · T-8 31/31;calc_convert_demo.py 15/15。
- 突变验证 4 组:关掉 convert 分派 → 21 条红;关掉错误体 extra 展开 → 精准 1 条;
关掉 client_request_id 正则 → 精准 1 条;关掉 _q() 展示量化 → 2 条红
(assert '50000.0000' == '50000' 直接复现原缺陷)。均已恢复。
2026-09-10 18:00:20 +08:00
GaoYiYuan_0626
7ad1c8204d
基金转换 T-8:规则引擎改造(_amount_view 去重视图 + process_convert_event)
...
一次转换落两条流水(转出 redeem + 转入 subscribe,同 convert_group_id),
金额聚合类规则若两条都算会翻倍报假预警,故按「逐笔 / 聚合」拆成两个视图。
- rules.py:新增 _amount_view —— 同组内只保留 redeem 那条(无 convert_group_id
的交易恒等通过、组内无 redeem 保首条、绝不删行);run_rules 双视图分流:
RISK-001/003/004 用全量 eligible(逐笔判定),RISK-002/005 走金额视图去重。
- alert_service.py:抽出公开 build_trade_event(事件体结构唯一定义),
record_trade_alerts 新增可选 events 参数;缺省 None 退化为单条,
既有调用零改动。新建单落 payload.events 全部,聚合追加只追首条(只认转出端)。
- engine.py:抽 _run 共用实现;process_trade_event 变薄封装(签名与行为不变);
新增 process_convert_event(out_trade, in_trade, ...) 与 _notify_error_hook
(hook 自身异常吞掉,原始异常照常上抛)。
实质影响:阶段 1.5 从「ImportError 静默跳过」变为「真跑」——T-7 部署时
process_convert_event 不存在,T-8 落地后同一笔转换会真实出单 + 写 L3 + 落审计;
T-7 真库脚本复跑仍 35/35,无连带破坏。
验证:新增 tests/test_convert_engine.py(15 用例)+ test_convert_service.py
接线回归 1 条;pytest 672 passed / 3 skipped(基线 656 +16,零回归);
新增 scripts/dev/verify_convert_engine.py 真 MySQL 验证 31/31;
突变验证(关掉去重视图 → 4 条变红)确认用例非假绿。
2026-09-10 17:34:35 +08:00
GaoYiYuan_0626
318cb39a1f
基金转换 T-7:convert_service 八步编排(关键路径 · 幂等前置 + 三阶段)
...
- 新增 app/service/convert/convert_service.py:八步编排(①-④ 校验不落库 / ⑤ 占位 /
⑥ apply_convert / ⑦ 阶段 1.5 引擎不阻断 / ⑧ 回写 + 审计),幂等判定前置到校验之前
以修复同键重试误报 InsufficientShares
- 新增 tests/test_convert_service.py(17 用例)
- 新增 scripts/dev/verify_convert_service.py(真 MySQL 验证 35/35)
- 改 app/repository/convert_repository.py:complete_convert 由纯 UPDATE 改三步法
upsert(无占位直跑也能落完成行,R-a 口径)
- 改 app/repository/core_ro.py:新增 has_convert_trades / list_convert_trades /
list_convert_lot_details 三个只读方法
- 改 app/config/settings.py:新增 6 个 convert 配置项
- 修 tests/test_convert_calc.py:TestPurity 排除编排层 convert_service.py
基线 639 → 656 passed / 3 skipped,零回归
2026-09-10 17:12:01 +08:00
GaoYiYuan_0626
82c9467fb7
基金转换 T-6:apply_convert 阶段一单事务(core 库唯一写入口)
...
新增 app/gateway/convert_core_repository.py:两条流水(redeem/subscribe,
R-b 不使用 ENUM 的 convert)+ N×条件 UPDATE 批次扣减 + 转入新批次
+ 两端 core_holding + N×计费明细,全部收口在 with engine.begin() 单事务。
实现级要点(与开发计划 §6.1 的三处差异,已回写该节执行记录):
- core_holding 改用「基于列当前值的增量 UPDATE」,入参不带持仓快照:
MySQL 的 UPDATE 是当前读,并发两笔自然累加;用快照算绝对值会互相覆盖。
- 数值参数参与算术时写成 (:x + 0.0):实测 sqlite 在 UPDATE 算术表达式中
不把 TEXT 绑定参数转数值(传 '120' 时 c 不变),加 +0.0 后两库一致。
- pnl_pct 拆成独立 UPDATE 重算,避开 MySQL「SET 从左到右」的顺序坑。
验证:pytest 639 passed / 3 skipped(基线 634 +5,零回归);
新增 scripts/dev/verify_convert_apply.py 真 MySQL 验证 24/24 一致,
含真并发两笔首次转入同一产品的终态断言(MySQL RR 的 gap lock 实测留痕)。
2026-09-10 16:26:42 +08:00
GaoYiYuan_0626 and WorkBuddy
4fd2ec05c8
基金转换 T-4+T-5(并行组 A):convert_repository 代理侧 + locks.try_lock 非阻塞抢锁
...
T-4(convert_repository · agent 库 risk_convert_detail):
- 新增 7 方法:insert_placeholder(占位 pending) / complete_convert(回写 completed+折算详情)
/ mark_failed / get_by_group_id / get_by_client_request_id(None 直接返回 None)
/ list_expired_candidates(hours) / mark_expired(S2 标记不硬删)
- 引擎走 agent 库 rw(D20);status 5 值枚举;不与 risk_repository 混职责
- Decimal 折算字段经 _to_bind 转 float 绑定(sqlite 不支持直接绑 Decimal,同 T-3)
T-5(locks.try_lock):
- 单次非阻塞抢锁:抢到返回 _Token(with 进入 True),抢不到立即 _NoLock(进入 False,不等不降级)
- Redis 不可用退回进程内 Lock.acquire(blocking=False);_NoLock.__enter__ 返回 False 避免 with None 报错
- 不改 run_locked(D4:其等 2s 后降级 fn(False),语义相反;3 处调用点零改动)
测试:test_convert_repository.py 6 用例 + test_locks_redis.py +4 用例(既有 6 例零改动)
pytest 全量 634 passed / 3 skipped(基线 624 + 10,零回归)
Co-Authored-By: WorkBuddy <workbuddy@tencent.com >
2026-09-10 15:53:31 +08:00
GaoYiYuan_0626 and WorkBuddy
3244922a55
基金转换 T-3:core_ro 新增 5 个只读方法 + share_lot_repository 读侧
...
- core_ro 新增 get_nav_as_of(D10) / get_redeem_fee_rules / list_share_lots(S1 确定性排序)
/ sum_remain_qty(仅 >0) / get_holding;不动 get_latest_nav 与 list_trades_range 白名单
- 新增 share_lot_repository:core_share_lot 读侧 FIFO 贪心选批 + 汇总,排序复用 core_ro 的 ORDER BY(D18 单一副本)
- 新增 tests/test_share_lot.py 15 用例;pytest 全量 624 passed / 3 skipped(基线 609,零回归)
- 同步开发计划 §5.1 执行记录与交接文档 §B 状态(v1.5 / T-3 ✅ / 基线 624)
Co-Authored-By: WorkBuddy <workbuddy@tencent.com >
2026-09-10 15:42:55 +08:00
GaoYiYuan_0626
497cee289f
docs: 交接文档合并为单一入口 + 全仓指向统一到 交接文档.md §A/§B/§C
...
背景:交接文档的定位是「给 AI 接手用的入口」,此前三份分散(项目根 交接文档.md
+ docs/交接文档-基金转换.md + docs/交接文档-架构改进.md),且 docs/ 两份停留在旧版
(v1.0 / v1.1,不含 T-0~T-2b、609 passed、D20 实施等进度),新会话极易被误导。
改动:
- 三份合并为项目根 交接文档.md v3.0(545 行 = §0 公共层 + §A 风控主线 + §B 基金转换线
+ §C 架构改进线);该文件在 .gitignore:47 内,按用户要求不入库(交接文档只留本地)
- 全仓指向统一到 交接文档.md §A/§B/§C:AGENTS.md(含顶部新增「接手先读交接文档.md」)、
docs/memory/{MEMORY,TODO,FRAMEWORK,ITERATION}、PRD-架构改进与稳定性加固、
开发计划-架构改进、TODO-架构改进、开发计划-基金转换交易
- 两份 docs/交接文档-*.md 加「已废弃(2026-09-10)· 勿读」横幅并指向新入口,
保留作历史留档(不删除)
- 记录事故:对 docs/ 下中文名文件使用 git rm 会静默抹除整个 docs/ 目录(复现 2 次、
退出码 0),已零损失恢复;纪律写入 交接文档.md §0.4 与工作区记忆
无代码改动;pytest 609 passed / 3 skipped。
2026-09-10 15:04:13 +08:00
GaoYiYuan_0626
c5182f1910
feat(convert): 基金转换 T-0/T-0b 门禁 + T-1 数据层 + T-2/T-2b 纯函数与实算回填
...
T-0 / T-0b(门禁 · 2026-09-10)
- T-0:sqlite 与 MySQL 结构对齐 —— core_holding 统一为 qty/cost_amount/as_of/pnl_pct
+ PK + UNIQUE(customer_id, product_id);补 core_product_nav;新增建库自校验
_assert_ddl_aligned()(R-g);test_db.py 增 3 条门禁用例(含反向验证门禁失效)
- T-0b:DB 账号分离(D20)—— 新增 scripts/core/00-grant.sql(三账号逐表授权);
settings.py 增 3 组账号;db.py 改 get_engine(db, role),缓存键改为 (库名, 角色),
账号未配置回退单账号;core_ro→ro / gateway_repository→rw / risk·session_repository→rw;
tests/conftest.py 四处显式 role="admin"(R-e)
T-1(数据层)
- scripts/core/01-ddl.sql:新建 core_fee_rule / core_share_lot / core_convert_lot_detail;
core_trade 加 convert_group_id + idx_convert_group;core_product 加 8 列 + fee_rate 补 COMMENT
- 新增 07-seed-fee-rule.sql(赎回费 5 档 × 14 产品,按 22 号文 §10)/ 08-seed-share-lot.sql
(58 行持仓 → 61 行批次,Σ remain_qty 恒等于 qty)/ 09-seed-org.sql(管理人 + TA +
申购费率 + 最低持有余额,v1.1 按「管理人全产品线」重排)
- reset.ps1 追加 07/08/09;02-mysql-agent专用.sql 追加 risk_convert_detail
- tests/_ddl.py 同步 4 表 + 新增 REQUIRED_CONVERT_TABLES 建库门禁
- 新增 scripts/dev/verify_convert_seed.py(pymysql 等价 reset 流程 + 8 条 DoD 断言,
含断言 ⑧「费率档 ↔ product_type 匹配」,越档即 FAIL)
T-2 / T-2b(纯函数包 + 示例实算回填)
- 新增 app/service/convert/ 7 文件:__init__ / types / calc / fee / nav / lot_bootstrap / errors
(纯函数,不查库、不碰 SQL;所有量化显式 ROUND_HALF_UP;lot_bootstrap 用 zlib.crc32
保证 D18 跨进程同源)
- 新增 tests/test_convert_calc.py 93 用例(12 类:HALF_UP 反向自证 / 分档边界 /
FIFO 含同 confirmed_at 兜底 / 双口径 / 强制全转与强制赎回 / PRD §5.3 全链自证 /
纯函数零 IO 依赖断言)
- 重写 scripts/dev/calc_convert_demo.py:去掉脚本内公式副本,改为调用生产 calc.py,
末尾与 PRD §5.3 逐项比对(不一致即退出码 1),兼作一致性门禁
验证
- pytest 609 passed / 3 skipped(516 → +93,零回归)
- verify_convert_seed.py 8/8 PASS;calc_convert_demo.py 15/15 与 PRD §5.3 一致
文档:PRD v0.9.1(费率分类修正)· 架构 §7 签名回填 / §8.3 错误码注 / §15 T-2 完成 ·
开发计划 §1.5 新增 R-h + §4.2·§4.3 执行记录 · AGENTS.md · docs/memory
2026-09-10 14:45:55 +08:00
zhanghongyu_0626
21ced4d38f
feat(report): Add battery report generation and update course documentation
...
- Introduced `battery_report.json` for local data analysis, excluding it from the database.
- Enhanced `AGENTS.md` to reflect updated test baseline with 795 passed tests.
- Added new metrics for trade flow in `dict_service.py`, improving transaction data analysis.
- Updated regex patterns in `guardrail.py` to better handle numeric extraction and prevent misinterpretation of tokens.
- Expanded course modules with new content on FR-8/9/10 capabilities and L3 role management.
- Improved concurrency handling in transaction processing to ensure accurate alert generation.
This update enhances data analysis capabilities and improves the overall structure and clarity of course materials.
2026-09-10 14:32:25 +08:00
GaoYiYuan_0626
ea9a132a40
docs: 基金转换(convert)设计阶段成果入库
...
此前 AIcoding 第 1~3 步的产出仅存在于本地磁盘、未纳入版本库,本次一次性入库,
补齐「设计可追溯」。本提交为纯文档 + 一个实算脚本,**代码零改动**,接口契约与表结构不变。
入库 6 个文件:
- docs/PRD/PRD-基金转换交易.md(v0.9 · 需求权威:FR-C1~C16 / §4 表结构 / §5 接口 / §9 验收)
- docs/项目框架设计/架构设计-基金转换交易.md(v1.0 · 实现依据:D1~D20 / §5 事务补偿 /
§11.1 DB 账号分离 / §15 任务映射 T-0~T-13 与 §15.1 依赖拓扑)
- docs/项目框架设计/基金转换-审查意见处置表.md(33 条外审处置 + §九 用户拍板记录)
- docs/项目框架设计/评审待办-风控主架构与基金转换.md(评审逐条判定 + 核实证据)
- docs/交接文档-基金转换.md(本线交接入口,读完即可开工)
- scripts/dev/calc_convert_demo.py(PRD §5.3 主示例实算回填脚本——派生值禁手算)
门控:PRD 已定稿并经独立评审闭环(M-7 已满足);架构 v1.0 独立评审 13 条建议 0 悬空。
下一步:AIcoding 第 4 步「产出开发计划」,输入为架构 §15 / §15.1。
2026-09-10 11:29:55 +08:00
zhanghongyu_0626
4b8e11c9bd
feat(threshold): Implement customer loss threshold configuration and notification system
...
- Added `ThresholdRepository` for managing customer loss threshold configurations and notifications.
- Introduced `threshold_service` to handle loss threshold alerts based on customer portfolio performance.
- Enhanced `customer_prompts` to include new intent for querying product net values.
- Updated `customer_service` to integrate new threshold alert functionality into existing workflows.
- Implemented `sanitize_postprocess` for improved compliance handling in customer interactions.
- Enhanced course documentation to reflect updates in advisor training modules and interactive elements.
This update significantly improves the customer experience by providing proactive loss threshold notifications and enhancing the overall service framework.
2026-09-10 10:57:40 +08:00
zhanghongyu_0626
3ad244add0
feat(analyst): Enhance dashboard metrics and customer service interactions
...
- Updated the `dashboard` function in `analyst.py` to include additional metrics for different user roles, improving data visibility for analysts, customers, advisors, and risk officers.
- Introduced a new `prepare_customer_stream` function in `customer_service.py` to facilitate streaming responses for customer interactions, enhancing the chat experience.
- Added new API endpoints in `analyst.ts` for fetching dashboard metrics and managing analyst assets, streamlining data handling and user interactions.
- Updated frontend components to support new dashboard features and asset management, ensuring a cohesive user experience across the application.
This update significantly improves the functionality and usability of the analyst and customer service features, providing users with enhanced tools for data analysis and interaction.
2026-09-09 21:32:59 +08:00
zhanghongyu_0626
bcd6175d4e
feat(analyst): Implement data analysis agent with authentication and query handling
...
- Introduced `analyst_auth_adapter.py` for managing authentication context and access control for the data analysis agent.
- Added new API endpoints in `analyst.py` for chat, dashboard, asset management, and metrics, utilizing the new authentication context.
- Created Pydantic models in `analyst_schemas.py` for request and response structures, ensuring consistent data handling.
- Updated SQL guard logic in `sql_guard.py` to enforce access restrictions based on user roles and contexts.
- Implemented migration scripts for new database tables related to the data analysis agent, enhancing data management capabilities.
- Removed legacy authentication code from `auth.py`, streamlining the authentication process.
This update significantly enhances the data analysis capabilities, providing a robust framework for querying and managing data securely.
2026-09-09 21:02:11 +08:00
zhanghongyu_0626
aa23e1ae1d
Merge branch 'data-analysis-agent-work' into merger
2026-09-09 20:53:59 +08:00
GaoYiYuan_0626
fffb78a11c
docs: 记忆文件同步架构改进交付态(纯文档,零代码)
...
- 架构设计说明书.md:同步桌面终版——§2.1 补 trace 顺序测试守卫、§4.2.1 无 key 告警闭环、
§4.3.4 重写为 Redis 双层锁(TTL 30s/Lua 释放/进程内备)、§5.3/§6.10/§7.1/§7.2/§7.3/§7.4/§9.4
锁与告警状态更新、基线 510
- FRAMEWORK/FLOW/REQUIREMENTS:风控 Tool 四→五(补 query_overdue_alerts)、词表 42→45 口径
- README:risk-m3 tag 注记 + API 契约表改五只读 Tool
- 注:交接文档.md v2.2 同步更新(该文件被 .gitignore 忽略,仅本地)
2026-09-09 20:06:53 +08:00
zhanghongyu_0626
2945108f66
feat(kb): Enhance knowledge base with new collections and search functionality
...
- Added new configuration for knowledge base root directory in `.env.example` and `settings.py`.
- Implemented `find_products` method in `CoreReadOnlyRepository` for fuzzy product search based on user queries.
- Introduced `search_cs_knowledge` function in `rag_service.py` to facilitate semantic search across new `fin_*` collections.
- Updated document parsing to support Markdown and YAML front-matter for knowledge base entries.
- Created multiple new FAQ and policy documents in the `data/kb_collections` directory to enrich the knowledge base.
This update significantly improves the knowledge retrieval capabilities for customer service interactions, ensuring more relevant and accurate responses.
2026-09-09 20:00:06 +08:00
zhanghongyu_0626
b841f68295
feat(visitor): Implement visitor chat functionality and enhance customer service interactions
...
- Added a new visitor chat API endpoint (`/api/chat/visitor`) to allow unauthenticated users to engage in conversations without requiring customer data.
- Introduced a visitor context dependency to manage visitor interactions seamlessly.
- Enhanced the chat API to support explicit session termination and improved response handling for customer service interactions.
- Updated the database configuration to include Redis client support for caching visitor data.
- Added a new customer note repository to persist user notes independently of the L1 profile slots.
This update significantly improves the customer service experience by enabling visitor interactions and ensuring efficient data handling for both registered and unregistered users.
2026-09-09 18:32:00 +08:00
GaoYiYuan_0626
e80f5a1b8c
docs(架构改进): 回写执行状态,纠正测试数为实测 510
...
- TODO-架构改进.md:T-101~T-202 全部勾选;用例数由 hy3 记录的 511 纠正为
实测 510(503 基线 + 6 条锁测试 + 1 条中间件顺序守卫);手工冒烟项保持
未勾选并标注待执行,避免被误读为已验证
- 交接文档-架构改进.md:升 v1.1,新增「当前状态」块(已完成/遗留/改动文件
清单)、§2 状态列、§7.3 勾选、§10 收尾动作;注明《架构设计说明书》存在
两个文件并存(架构设计-风控模块.md 与全量版 架构设计说明书.md),避免改错
- docs/memory/2026-09-09.md:追加 commit 037ce7e 的提交与复核记录
2026-09-09 18:15:08 +08:00
GaoYiYuan_0626
adac28f6f7
架构改进收尾:勾选 TODO T-101~T-202 并追加实施记录
...
- docs/项目框架设计/TODO-架构改进.md:T-101~T-202 逐项勾选,补充实测用例数(510)与文档文件名差异备注
- docs/memory/2026-09-09.md:新增实施记录(改动文件、纪律核查、未做项)
- 实现代码已于 037ce7e 提交,pytest 510 绿,未 push
2026-09-09 18:13:54 +08:00
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
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
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