修复: status→enum + type alias(SMELL-P1-6)
This commit is contained in:
@@ -142,6 +142,7 @@ mod idea_source_test_helpers {
|
||||
use df_storage::crud::IdeaRepo;
|
||||
use df_storage::db::Database;
|
||||
use df_storage::models::IdeaRecord;
|
||||
use df_types::types::IdeaStatus;
|
||||
|
||||
/// 建内存 DB(已跑 migrations,含 ideas 表)+ 插一条 IdeaRecord fixture,返回 db 句柄。
|
||||
///
|
||||
@@ -155,7 +156,7 @@ mod idea_source_test_helpers {
|
||||
id: id.to_string(),
|
||||
title: format!("fixture-{}", id),
|
||||
description: String::new(),
|
||||
status: "draft".to_string(),
|
||||
status: IdeaStatus::Draft,
|
||||
priority: 1,
|
||||
score: None,
|
||||
tags: None,
|
||||
|
||||
@@ -88,7 +88,7 @@ impl MentionResolver for ProjectResolver {
|
||||
ref_id: id.clone(),
|
||||
})?;
|
||||
// status: String → ProjectStatus(未知字符串按 Planning 兜底,不阻断注入)
|
||||
let status = ProjectStatus::from_db_str(&record.status).unwrap_or(ProjectStatus::Planning);
|
||||
let status = ProjectStatus::from_db_str(record.status.as_str()).unwrap_or(ProjectStatus::Planning);
|
||||
// path 脱敏:None(未绑定)保持 None;Some 则按 locality 脱敏包 newtype
|
||||
let path = record
|
||||
.path
|
||||
@@ -113,7 +113,7 @@ impl MentionResolver for ProjectResolver {
|
||||
}).await {
|
||||
if !tasks.is_empty() {
|
||||
let mut task_lines: Vec<String> = tasks.iter().map(|t| {
|
||||
format!(" - {} ({})", t.title, t.status)
|
||||
format!(" - {} ({})", t.title, t.status.as_str())
|
||||
}).collect();
|
||||
task_lines.insert(0, format!("进行中任务({}):", tasks.len()));
|
||||
lines.push(task_lines.join("\n"));
|
||||
@@ -126,9 +126,9 @@ impl MentionResolver for ProjectResolver {
|
||||
..Default::default()
|
||||
}).await {
|
||||
let related: Vec<_> = ideas.iter()
|
||||
.filter(|i| i.status == "pending_review")
|
||||
.filter(|i| i.status.as_str() == "pending_review")
|
||||
.take(3)
|
||||
.map(|i| format!(" - {} ({})", i.title, i.status))
|
||||
.map(|i| format!(" - {} ({})", i.title, i.status.as_str()))
|
||||
.collect();
|
||||
if !related.is_empty() {
|
||||
let mut idea_lines = vec![format!("待评估灵感({}):", related.len())];
|
||||
@@ -189,7 +189,7 @@ impl MentionResolver for TaskResolver {
|
||||
kind: "task".to_string(),
|
||||
ref_id: id.clone(),
|
||||
})?;
|
||||
let status = TaskStatus::from_db_str(&task.status).unwrap_or(TaskStatus::Todo);
|
||||
let status = TaskStatus::from_db_str(task.status.as_str()).unwrap_or(TaskStatus::Todo);
|
||||
// join project_name:project_id 取 ProjectRecord.name;失败/无对应 None(非错误)
|
||||
let project_name = {
|
||||
let project_repo = ProjectRepo::new(&self.db);
|
||||
@@ -253,7 +253,7 @@ impl MentionResolver for IdeaResolver {
|
||||
kind: "idea".to_string(),
|
||||
ref_id: id.clone(),
|
||||
})?;
|
||||
let status = IdeaStatus::from_db_str(&record.status).unwrap_or(IdeaStatus::Draft);
|
||||
let status = IdeaStatus::from_db_str(record.status.as_str()).unwrap_or(IdeaStatus::Draft);
|
||||
Ok(Augmentation::Idea {
|
||||
id: record.id,
|
||||
title: record.title,
|
||||
|
||||
@@ -162,7 +162,7 @@ pub(crate) async fn build_system_prompt_with_excluded(
|
||||
if excluded_project_ids.iter().any(|id| id == &p.id) {
|
||||
continue;
|
||||
}
|
||||
prompt.push_str(&format!("- {} ({}): {}\n", p.name, p.status, p.description));
|
||||
prompt.push_str(&format!("- {} ({}): {}\n", p.name, p.status.as_str(), p.description));
|
||||
if let Some(ref dir) = p.path {
|
||||
prompt.push_str(&format!(" 目录: {}\n", dir));
|
||||
}
|
||||
@@ -181,7 +181,7 @@ pub(crate) async fn build_system_prompt_with_excluded(
|
||||
if excluded_task_ids.iter().any(|id| id == &tk.id) {
|
||||
continue;
|
||||
}
|
||||
prompt.push_str(&format!("- {} ({}): {}\n", tk.title, tk.status, tk.description));
|
||||
prompt.push_str(&format!("- {} ({}): {}\n", tk.title, tk.status.as_str(), tk.description));
|
||||
}
|
||||
// 机制层注明语(中/英):仅最近 20 条,全量/按项目查询走 list_tasks
|
||||
prompt.push_str(&tasks_listed_note(lang));
|
||||
|
||||
@@ -11,7 +11,7 @@ use df_execute::shell::{execute, ShellRequest};
|
||||
use df_storage::db::Database;
|
||||
use df_storage::models::{ProjectRecord, ProjectServiceRecord, TaskRecord, IdeaRecord};
|
||||
|
||||
use df_types::types::new_id;
|
||||
use df_types::types::{new_id, IdeaStatus, ProjectStatus, TaskStatus};
|
||||
|
||||
use crate::commands::now_millis;
|
||||
use crate::state::AllowedDirs;
|
||||
@@ -573,7 +573,7 @@ fn register_project_tools(registry: &mut AiToolRegistry, db: &Arc<Database>) {
|
||||
let repo = df_storage::crud::ProjectRepo::new(&db);
|
||||
let record = ProjectRecord {
|
||||
id: new_id(), name: name.to_string(), description: description.to_string(),
|
||||
status: "planning".to_string(), idea_id: None,
|
||||
status: ProjectStatus::Planning, idea_id: None,
|
||||
path: None, stack: None,
|
||||
created_at: now_millis(), updated_at: now_millis(),
|
||||
};
|
||||
@@ -683,7 +683,7 @@ fn register_task_tools(registry: &mut AiToolRegistry, db: &Arc<Database>) {
|
||||
};
|
||||
// 按状态过滤(可选):todo/in_progress/in_review/testing/blocked/done/cancelled
|
||||
if let Some(status) = args.get("status").and_then(|v| v.as_str()) {
|
||||
tasks.retain(|t| t.status == status);
|
||||
tasks.retain(|t| t.status.as_str() == status);
|
||||
}
|
||||
let total = tasks.len();
|
||||
let offset = args["offset"].as_u64().unwrap_or(0) as usize;
|
||||
@@ -767,7 +767,7 @@ fn register_task_tools(registry: &mut AiToolRegistry, db: &Arc<Database>) {
|
||||
id: new_id(), project_id: project_id.to_string(), title: title.to_string(),
|
||||
description: args["description"].as_str().unwrap_or("").to_string(),
|
||||
// priority 默认 2(medium):与 commands::task::default_priority 一致,新任务默认中优先级(非 high)
|
||||
status: "todo".to_string(), priority: args["priority"].as_i64().unwrap_or(2) as i32,
|
||||
status: TaskStatus::Todo, priority: args["priority"].as_i64().unwrap_or(2) as i32,
|
||||
branch_name: None, assignee: None, workflow_def_id: None, base_branch: None,
|
||||
review_rounds: 0,
|
||||
output_json: None,
|
||||
@@ -1032,13 +1032,13 @@ fn register_task_graph_tools(registry: &mut AiToolRegistry, db: &Arc<Database>)
|
||||
"backlog" => "todo".to_string(),
|
||||
"active" => {
|
||||
if ACTIVE_OK_STATUSES.contains(¤t.status.as_str()) {
|
||||
current.status.clone()
|
||||
current.status.as_str().to_string()
|
||||
} else {
|
||||
"in_progress".to_string()
|
||||
}
|
||||
}
|
||||
"todo" => "todo".to_string(),
|
||||
"decision" => current.status.clone(),
|
||||
"decision" => current.status.as_str().to_string(),
|
||||
_ => unreachable!("queue 白名单已收口"),
|
||||
};
|
||||
|
||||
@@ -1047,7 +1047,7 @@ fn register_task_graph_tools(registry: &mut AiToolRegistry, db: &Arc<Database>)
|
||||
repo.update_field(id, "queue", &new_queue).await?;
|
||||
}
|
||||
// 写 status(专用 set_status_for_aggregation 绕过 status 收口,合法非状态机路径)
|
||||
if current.status != new_status {
|
||||
if current.status.as_str() != new_status {
|
||||
repo.set_status_for_aggregation(id, &new_status).await?;
|
||||
}
|
||||
|
||||
@@ -1354,7 +1354,7 @@ fn register_idea_tools(registry: &mut AiToolRegistry, db: &Arc<Database>) {
|
||||
id: new_id(), title: title.to_string(),
|
||||
description: args["description"].as_str().unwrap_or("").to_string(),
|
||||
// priority 默认 1:灵感默认普通优先级(与 commands::idea::default_priority 及 tasks 表 SQL DEFAULT 1 对齐)
|
||||
status: "draft".to_string(), priority: args["priority"].as_i64().unwrap_or(1) as i32,
|
||||
status: IdeaStatus::Draft, priority: args["priority"].as_i64().unwrap_or(1) as i32,
|
||||
score: None, tags: args["tags"].as_str().map(|s| s.to_string()),
|
||||
source: args["source"].as_str().map(|s| s.to_string()),
|
||||
promoted_to: None, ai_analysis: None, scores: None,
|
||||
|
||||
Reference in New Issue
Block a user