优化: 立项回滚级联删 + df-ideas 死代码清理

- T-09: idea.rs:149 立项失败回滚 delete→purge_with_descendants(防孤儿子记录)
- T-12: capture.rs 删 CaptureInput/IdeaCapture 死代码,保留 Idea/IdeaScores 共享实体
- T-10: 无改动(normalize_path 已含 canonicalize,判定已解决)
This commit is contained in:
2026-06-14 15:19:41 +08:00
parent 4aa689e110
commit 89da9fad9a
2 changed files with 2 additions and 55 deletions

View File

@@ -1,26 +1,9 @@
//! 想法捕获 — 快速记录与管理
//! 想法实体与评分类型 — 供 scoring/adversarial/promotion 共享
use serde::{Deserialize, Serialize};
use df_core::types::{IdeaId, Priority};
/// 捕获一个新想法的输入
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CaptureInput {
/// 标题
pub title: String,
/// 详细描述
pub description: String,
/// 优先级
#[serde(default)]
pub priority: Priority,
/// 标签
#[serde(default)]
pub tags: Vec<String>,
/// 来源(如 "用户输入"、"AI 生成"、"会议记录"
pub source: Option<String>,
}
/// 想法实体
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Idea {
@@ -60,39 +43,3 @@ pub struct IdeaScores {
/// 综合评分 (加权平均)
pub overall: f64,
}
/// 想法捕获器
pub struct IdeaCapture;
impl IdeaCapture {
/// 捕获一个新想法
///
/// TODO: 接入存储层持久化
pub fn capture(input: CaptureInput) -> Idea {
let now = chrono::Utc::now();
Idea {
id: df_core::types::new_id(),
title: input.title,
description: input.description,
status: df_core::types::IdeaStatus::Draft,
priority: input.priority,
scores: None,
tags: input.tags,
source: input.source,
related_ids: Vec::new(),
created_at: now,
updated_at: now,
}
}
/// 快速捕获(仅标题)
pub fn quick_capture(title: String) -> Idea {
Self::capture(CaptureInput {
title,
description: String::new(),
priority: Priority::default(),
tags: Vec::new(),
source: None,
})
}
}

View File

@@ -146,7 +146,7 @@ pub async fn promote_idea(
if let Err(e) = state.ideas.update_full(&updated).await {
// 回写失败:补偿删除已建项目,避免悬空项目(idea.promoted_to 仍空,可重试立项)
tracing::error!("想法 {id} 回写失败,补偿删除已建项目 {project_id}: {e}");
if let Err(del_err) = state.projects.delete(&project_id).await {
if let Err(del_err) = state.projects.purge_with_descendants(&project_id).await {
tracing::error!("补偿删除项目 {project_id} 也失败(需人工清理): {del_err}");
}
return Err(format!("想法立项回写失败(已回滚项目创建): {}", e));