feat: 添加可配置场景注册表与规则引擎

- 新增场景基类、配置加载、注册表与原语模块
- 添加 r10_refund_split 规则及场景 JSON Schema
- 扩展 scan 引擎与 scenarios API
- 新增场景注册表/配置/集成测试
- 更新前端 App、api、labels 支持新场景
This commit is contained in:
selfrelease
2026-06-17 09:57:02 +08:00
parent cbaa2156fc
commit 74e35fed96
20 changed files with 998 additions and 2 deletions
@@ -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": "规则版本,用于线索可追溯"
}
}
}