docs(详细设计): 新增风险预警设计

This commit is contained in:
2026-06-03 21:08:15 +08:00
parent 0e49eea683
commit 2876a1b028
9 changed files with 1055 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
# 风险预警编排Skill 设计
## 1. Skill 定位
`风险预警编排Skill` 是第五步工作流的总入口 Skill负责组织前序报告汇总、风险规则加载、风险项生成、风险归并、准入判定、整改建议生成和风险报告输出。
英文实现标识建议使用 `RiskWarningOrchestrateSkill`
## 2. 输入
```python
@dataclass
class RiskWarningOrchestrateInput:
batch_id: int
scenario_id: str = "registration_risk_report"
risk_rule_id: str = "ivd_registration_risk_v1"
include_reports: list[str] = field(default_factory=list)
enable_llm_summary: bool = True
```
## 3. 输出
```python
@dataclass
class RiskWarningOrchestrateOutput:
report_type: str
batch_id: int
summary: dict
risk_items: list[dict]
manual_review_items: list[dict]
suggestions: list[dict]
audit_id: int | None = None
```
## 4. 依赖 Skill
1. `前序报告汇总Skill`
2. `风险规则加载Skill`
3. `风险项生成Skill`
4. `风险归并Skill`
5. `准入判定Skill`
6. `整改建议生成Skill`
7. `风险报告生成Skill`
## 5. 核心方法
### 5.1 `run(input) -> RiskWarningOrchestrateOutput`
主入口方法。
### 5.2 `load_execution_context(input) -> RiskEvaluationContext`
加载批次、场景和前序报告上下文。
### 5.3 `merge_results(risks, admission, suggestions) -> dict`
合并风险、准入和建议。
## 6. 技术实现
使用技术:
1. Tool Registry
2. dataclass/Pydantic
3. Django ORM
4. Audit 服务
建议注册名:
```python
tool_registry.register(
name="risk_warning_orchestrate",
handler=RiskWarningOrchestrateSkill().run,
)
```
## 7. 异常处理
1. 前序报告缺失:输出业务提示。
2. 风险规则缺失:任务失败。
3. LLM 不可用:使用模板摘要。
4. 审计写入失败:报告返回并记录系统警告。
## 8. 测试要点
1. 能串联所有依赖 Skill。
2. 高风险导致不通过。
3. 前序报告缺失时提示清晰。
4. 输出报告 schema 稳定。