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)
This commit is contained in:
@@ -56,6 +56,12 @@ INSERT INTO core_staff (staff_id, display_name, staff_type, roles) VALUES
|
||||
INSERT INTO core_staff (staff_id, display_name, staff_type, roles) VALUES
|
||||
('STAFF-90001', '风控演示账号', 'risk_officer', '["risk_officer", "risk_demo"]');
|
||||
|
||||
-- 2 风控经理(C5 前置 · PRD 4A.1:risk_manager 可看台账全量,无处置权)
|
||||
-- staff_type 仍为 risk_officer(同岗位序列),roles 标 risk_manager 用于权限区分
|
||||
INSERT INTO core_staff (staff_id, display_name, staff_type, roles) VALUES
|
||||
('STAFF-31001', '风控经理甲', 'risk_officer', '["risk_manager"]'),
|
||||
('STAFF-31002', '风控经理乙', 'risk_officer', '["risk_manager"]');
|
||||
|
||||
-- ========== 产品 14 只(含起购/期限 · C-11) ==========
|
||||
INSERT INTO core_product (
|
||||
product_id, product_name, product_type, min_risk_code,
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
"""RISK-007 处置时效升级扫描(建议 15min 周期;RISK_ESCALATION_SCAN_MINUTES 可配)。
|
||||
|
||||
初期独立脚本 + 系统 cron;内嵌 lifespan 归 M4 评估(开发计划挂账 #2)。
|
||||
结构对齐 scripts/demo/rebuild_alerts.py:sys.path 引导 → new_trace → 扫描 → 打印
|
||||
JSON 摘要(供 cron 日志 / 演示走查)。审计写库失败由 service 内降级留底,不阻塞
|
||||
下次扫描(红线 5 口径)。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# ① sys.path 引导项目根(rebuild_alerts 先例)
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from app.service.risk.escalation_service import scan_and_escalate # noqa: E402
|
||||
from app.utils.trace import new_trace # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
# ② 显式生成 trace(无 HTTP 上下文,service 内 current_trace 复用)
|
||||
new_trace()
|
||||
# ③ 扫描 → 打印 JSON 摘要
|
||||
summary = scan_and_escalate()
|
||||
print(json.dumps(summary, ensure_ascii=False, default=str, indent=2))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user