feat: 添加可配置场景注册表与规则引擎
- 新增场景基类、配置加载、注册表与原语模块 - 添加 r10_refund_split 规则及场景 JSON Schema - 扩展 scan 引擎与 scenarios API - 新增场景注册表/配置/集成测试 - 更新前端 App、api、labels 支持新场景
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
# yaml-language-server: $schema=./scenario.schema.json
|
||||
# 场景 R10(纯配置示例)· 大额退款拆分规避审批
|
||||
# 演示「B 快捷通道」:新增本场景仅需此 YAML 文件,无需改动任何 Python 代码。
|
||||
# 系统启动时由 app.scenarios.config.load_yaml_scenarios 自动发现、校验并注册。
|
||||
|
||||
code: R10
|
||||
title: 疑似大额退款拆分规避审批
|
||||
risk_domain: 收入
|
||||
label: 退款拆分
|
||||
|
||||
# 复用通用检测原语:金额集中在审批阈值边缘
|
||||
detector: threshold_edge
|
||||
threshold: 0.0 # threshold_edge 命中(评分>0)即生成线索
|
||||
rule_version: rules@r10.v1
|
||||
|
||||
params:
|
||||
amount_field: refund_amount # 数据行中的金额字段
|
||||
threshold: 500000 # 退款审批阈值(50 万)
|
||||
edge_ratio: 0.8 # 边缘下界 = 0.8 * 阈值
|
||||
min_count: 3 # 至少 3 笔集中才判定命中
|
||||
key_field: customer # 主体字段,用于汇总涉及客户
|
||||
|
||||
rationale_template: "{summary};疑似将整笔大额退款拆分至审批阈值以下以规避审批,建议穿透核查关联客户。"
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "AIAudit 配置驱动场景",
|
||||
"description": "配置驱动审计场景(B 快捷通道)的 schema,对应 app.scenarios.config.ScenarioConfig;权威校验以后端 pydantic 为准。",
|
||||
"type": "object",
|
||||
"required": ["code", "title", "risk_domain", "label", "detector"],
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "场景码,全局唯一,如 R10"
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "默认线索标题"
|
||||
},
|
||||
"risk_domain": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "风险域,如 收入/成本"
|
||||
},
|
||||
"label": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "前端展示名"
|
||||
},
|
||||
"detector": {
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
"description": "检测原语名(见 app/scenarios/primitives.py)",
|
||||
"examples": ["threshold_edge", "cliff_drop", "ratio_threshold"]
|
||||
},
|
||||
"params": {
|
||||
"type": "object",
|
||||
"description": "传给检测原语的参数(键随原语而定)"
|
||||
},
|
||||
"threshold": {
|
||||
"type": "number",
|
||||
"description": "评分阈值:草稿 score >= 阈值才生成线索",
|
||||
"default": 0.5
|
||||
},
|
||||
"rationale_template": {
|
||||
"type": "string",
|
||||
"description": "线索理由模板,支持 {summary} 及原语 metrics 中的占位符"
|
||||
},
|
||||
"rule_version": {
|
||||
"type": ["string", "null"],
|
||||
"description": "规则版本,用于线索可追溯"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user