新增: 知识图谱Phase2事件流(父⑥) — project_events统一事件流+埋点+timeline
父⑥ Phase 2(对标设计 §2.4): - V30 迁移:project_events 追加型审计表(id/project_id/event_type/entity_type/entity_id/from_state/to_state/context_json/source/conversation_id/created_at)+ 双索引(project,time / entity) - ProjectEventRecord + ProjectEventRepo(insert 追加型/get_by_project/get_by_entity/list_recent) - 事件埋点(best-effort,hook/after,失败 warn 不阻断主操作): - task.rs emit_event 辅助 + create_task/advance_task/move_task_queue 埋点 - idea.rs promote_idea 埋点(idea_promoted,project_id=新项目) - project.rs create/delete 埋点 - 注:idea_created 暂不埋点(idea 无 project_id,待 Inbox 项目落地,NOT NULL+FK 约束) - get_project_timeline IPC(events 模块)+ lib.rs 注册 + AI 工具(基线 +N) - source 语义:IPC 标 human,AI 工具路径标 ai 注:workflow 脚本中文变量名 const 致验证 agent 未跑,主控独立 cargo check EXIT 0 + grep 落地齐全核验。
This commit is contained in:
@@ -146,6 +146,41 @@ pub struct TaskLinkRecord {
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
/// 项目事件流记录(project_events 表,知识图谱 Phase 2 V30,追加型审计表)。
|
||||
///
|
||||
/// 一张表承载跨实体(idea/task/workflow/knowledge/module/service/project)的全部事件,
|
||||
/// 是 AI 精准检索项目事件流的基础(回答"上周做了什么 / 这个任务为何 blocked / 决策何时做出")。
|
||||
/// 对标设计 docs/02-架构设计/专项设计/项目知识图谱与任务队列系统-2026-06-26.md §2.4。
|
||||
///
|
||||
/// **追加型审计**(对标 KnowledgeEventRecord / IdeaEvaluationRecord):只 INSERT 不 UPDATE/
|
||||
/// DELETE,历史不改可追溯。无 updated_at 字段,无通用 update/delete 路径。
|
||||
///
|
||||
/// - `project_id`:所属项目(FK projects.id)。
|
||||
/// - `event_type`:事件类型白名单(idea_created/task_advanced/decision_made 等,应用层校验)。
|
||||
/// - `entity_type` / `entity_id`:事件指向的实体(可空——纯决策日志等无明确实体)。entity_type
|
||||
/// 白名单应用层校验(idea/project/task/workflow/knowledge/module/service)。
|
||||
/// - `from_state` / `to_state`:状态变化前后(仅状态变化类事件有值;created/referenced 类为 None)。
|
||||
/// - `context_json`:事件附加上下文(JSON 字符串,因 event_type 而异)。
|
||||
/// - `source`:ai / human / system(AI Working 溯源——区分 AI 自主操作还是人操作)。
|
||||
/// - `conversation_id`:触发事件的对应对话(AI Working 溯源链:事件→对话→决策,可空)。
|
||||
///
|
||||
/// **与 knowledge_events 关系**(设计 D9):knowledge_events 保持不变(知识库专属),knowledge
|
||||
/// 相关事件同时写入两者,双写在埋点层(commands/IPC hook)实现。
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ProjectEventRecord {
|
||||
pub id: String,
|
||||
pub project_id: String,
|
||||
pub event_type: String,
|
||||
pub entity_type: Option<String>,
|
||||
pub entity_id: Option<String>,
|
||||
pub from_state: Option<String>,
|
||||
pub to_state: Option<String>,
|
||||
pub context_json: Option<String>,
|
||||
pub source: Option<String>,
|
||||
pub conversation_id: Option<String>,
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
/// 分支记录
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BranchRecord {
|
||||
|
||||
Reference in New Issue
Block a user