重构: Coordinator 接入 agentic loop + audit 拆分(approval/record)

- audit/approval.rs: 审批门控(风险分类+自动执行+挂起审批)

- audit/record.rs: 审计记录写入+历史查询

- coordinator.rs: 移除 deprecated,正式作为 P0 骨架可用

- run_agentic_loop: plan_execution_enabled 时 Coordinator 分解意图→记录 Plan

- audit/mod.rs 从 ~500 行精简至 ~200 行(编排层)
This commit is contained in:
2026-07-01 14:29:34 +08:00
parent a9ee9b1f74
commit fa410e6843
11 changed files with 1234 additions and 523 deletions

View File

@@ -2,10 +2,10 @@
//!
//! 第五批从 audit/mod.rs 抽离,行为零变更:
//! - `risk_str` / `risk_from_str`finalize / restore 通过 `super::` 引用pub(crate))。
//! - `truncate_chars`mod.rs 的 list_tool_executions DTO 装配用pub(super))。
//! - `truncate_chars`mod.rs 的 process_tool_calls DTO 装配用 + record.rs 审计面板 IPC 用pub(crate))。
//!
//! re-export 维持原路径透明:`super::risk_str` / `super::risk_from_str` / `super::truncate_chars`
//! 在 audit/mod.rs 内通过 `use` 引入后裸名可用,外部子模块的 `super::risk_*` 引用不变。
//! 在 audit/mod.rs 内通过 `pub(crate) use` 引入后裸名可用,外部子模块的 `super::risk_*` 引用不变。
use df_ai::ai_tools::RiskLevel;
@@ -18,7 +18,7 @@ pub(crate) fn risk_str(r: RiskLevel) -> &'static str {
}
}
/// 审计记录字符串 → RiskLevel启动重建 pending_approvals 用,未知串返回 None 跳过)
/// 审计记录字符串 → RiskLevel启动重建 pending_approvals 用未知串返回 None 跳过)
pub(crate) fn risk_from_str(s: &str) -> Option<RiskLevel> {
match s {
"low" => Some(RiskLevel::Low),
@@ -28,8 +28,8 @@ pub(crate) fn risk_from_str(s: &str) -> Option<RiskLevel> {
}
}
/// 截断字符串到 max 字符(按 char_indices 边界切,避免切坏中文/emoji)
pub(super) fn truncate_chars(s: &str, max: usize) -> String {
/// 截断字符串到 max 字符按 char_indices 边界切避免切坏中文/emoji
pub(crate) fn truncate_chars(s: &str, max: usize) -> String {
if s.chars().count() <= max {
return s.to_string();
}