Files
DEMO-AGENT/docs/详细设计/skill/一致性核查编排Skill.md

104 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 一致性核查编排Skill 设计
## 1. Skill 定位
`一致性核查编排Skill` 是第四步工作流的总入口 Skill负责组织审核范围确认、强一致规则加载、字段分组、完全一致比对、混档风险识别、字段池状态回写和报告生成。
英文实现标识建议使用 `ConsistencyReviewOrchestrateSkill`
## 2. 输入
```python
@dataclass
class ConsistencyReviewOrchestrateInput:
batch_id: int
scenario_id: str = "registration_consistency_review"
selected_document_ids: list[int] = field(default_factory=list)
field_rule_id: str = "ivd_strict_consistency_v1"
target_field_keys: list[str] = field(default_factory=list)
strict_mode: bool = True
```
## 3. 输出
```python
@dataclass
class ConsistencyReviewOrchestrateOutput:
report_type: str
batch_id: int
summary: dict
consistent_fields: list[dict]
conflict_fields: list[dict]
manual_review_fields: list[dict]
mixed_package_warnings: list[dict]
audit_id: int | None = None
```
## 4. 依赖 Skill
1. `审核范围确认Skill`
2. `强一致规则加载Skill`
3. `字段分组Skill`
4. `字段完全一致比对Skill`
5. `混档风险识别Skill`
6. `一致性报告生成Skill`
## 5. 核心方法
### 5.1 `run(input) -> ConsistencyReviewOrchestrateOutput`
主入口方法。
执行顺序:
1. 读取统一字段池。
2. 调用 `审核范围确认Skill`
3. 调用 `强一致规则加载Skill`
4. 调用 `字段分组Skill`
5. 调用 `字段完全一致比对Skill`
6. 调用 `混档风险识别Skill`
7. 回写字段池冲突状态。
8. 调用 `一致性报告生成Skill`
9. 写入审计。
### 5.2 `load_field_pool(batch_id) -> list[FieldPoolItem]`
读取字段池主表和候选值。
### 5.3 `update_field_pool_status(compare_results) -> FieldPoolUpdateResult`
回写一致、冲突、待复核状态。
## 6. 技术实现
使用技术:
1. Django ORM
2. Tool Registry
3. dataclass/Pydantic
4. Audit 服务
建议注册名:
```python
tool_registry.register(
name="consistency_review_orchestrate",
handler=ConsistencyReviewOrchestrateSkill().run,
)
```
## 7. 异常处理
1. 字段池不存在:任务失败并提示先执行字段抽取。
2. 审核范围为空:返回业务错误。
3. 规则缺失:任务失败并写审计。
4. 字段池回写失败:报告仍生成,但标记系统警告。
## 8. 测试要点
1. 能按顺序调用依赖 Skill。
2. 字段池缺失时返回清晰错误。
3. 冲突结果能回写字段池。
4. 输出报告 schema 稳定。