66//! @ai-context: 单文件 ≤300 行约束(AGENTS.md §3)下按域拆至 types_*.rs,本文件只保留
77//! `#[path]` 子模块声明 + `pub use` 再导出 ⇒ crate::types::X 对全仓引用面零改动。
88
9- use serde:: { Deserialize , Serialize } ;
10-
119#[ path = "types_session.rs" ]
1210mod types_session;
1311#[ path = "types_knowledge.rs" ]
@@ -18,138 +16,12 @@ mod types_note;
1816mod types_ocr;
1917#[ path = "types_extract.rs" ]
2018mod types_extract;
19+ #[ path = "types_decision.rs" ]
20+ mod types_decision;
2121
2222pub use types_session:: * ;
2323pub use types_knowledge:: * ;
2424pub use types_note:: * ;
2525pub use types_ocr:: * ;
2626pub use types_extract:: * ;
27-
28- /// 决策/应用记录(v0.13.3 REQ-208;一表两面,kind 区分)。
29- ///
30- /// @ai-context: 对应 knowledge_decisions 表——decision=思辨面(决策),application=学习面
31- /// (记一次使用);一表两面不双表。used_refs 为 JSON 文本(存储态,原样保存,
32- /// 结构契约由知识纯函数 validate_decision_input 校验;解析辅助见 UsedRefs)。
33- /// decided_at 为决策/应用时刻(Unix 秒,数据层填充)。
34- /// @ai-context: M1 类型供 M2 command 层接入用(机制先行);接入后移除本 allow。
35- #[ allow( dead_code) ]
36- #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
37- #[ serde( rename_all = "camelCase" ) ]
38- pub struct KnowledgeDecision {
39- pub id : i64 ,
40- /// decision / application
41- pub kind : String ,
42- /// 所属体系(None=未挂体系,仅体系级应用允许)
43- pub system_id : Option < i64 > ,
44- /// 关联问题树节点(None=未挂节点)
45- pub question_id : Option < i64 > ,
46- /// 引用 JSON 文本(存储态;引用必填,command 层拒绝空)
47- pub used_refs : String ,
48- /// 决策内容/应用动作(必填)
49- pub content : String ,
50- /// 预期结果(四行法;None=未填)
51- pub expectation : Option < String > ,
52- /// 实际结果(四行法;None=未填)
53- pub actual : Option < String > ,
54- /// 反思(四行法:如果重来改变什么;None=未填)
55- pub reflection : Option < String > ,
56- /// 决策/应用时刻(Unix 秒,数据层填充)
57- pub decided_at : i64 ,
58- pub created_at : i64 ,
59- }
60-
61- /// 新建决策/应用记录入参(id/decided_at/created_at 由数据层填充;kind 由调用方传入)。
62- /// @ai-context: M1 类型供 M2 command 层接入用(机制先行);接入后移除本 allow。
63- #[ allow( dead_code) ]
64- #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
65- #[ serde( rename_all = "camelCase" ) ]
66- pub struct NewKnowledgeDecision {
67- /// decision / application(调用方传入;command 层白名单校验)
68- pub kind : String ,
69- #[ serde( default ) ]
70- pub system_id : Option < i64 > ,
71- #[ serde( default ) ]
72- pub question_id : Option < i64 > ,
73- /// 引用 JSON 文本(必填非空——command 层经 validate_decision_input 校验)
74- pub used_refs : String ,
75- /// 决策内容/应用动作(必填)
76- pub content : String ,
77- #[ serde( default ) ]
78- pub expectation : Option < String > ,
79- #[ serde( default ) ]
80- pub actual : Option < String > ,
81- #[ serde( default ) ]
82- pub reflection : Option < String > ,
83- }
84-
85- /// used_refs JSON 结构的解析辅助(仅作解析;DB 仍存原始 JSON 文本)。
86- ///
87- /// @ai-context: 一表包全引用——体系实体(node/concept/model)+四类证据引用
88- /// (group/card/note/fragment,即四类 LinkTarget)。serde camelCase;
89- /// 结构契约(键白名单/正整数/非空)由 validate_decision_input(知识纯函数)校验,
90- /// 本结构仅供 command 层读取 used_refs 时反序列化。
91- /// @ai-context: M1 类型供 M2 command 层接入用(机制先行);接入后移除本 allow。
92- #[ allow( dead_code) ]
93- #[ derive( Debug , Clone , Default , Serialize , Deserialize , PartialEq ) ]
94- #[ serde( rename_all = "camelCase" ) ]
95- pub struct UsedRefs {
96- #[ serde( default ) ]
97- pub node_ids : Vec < i64 > ,
98- #[ serde( default ) ]
99- pub concept_ids : Vec < i64 > ,
100- #[ serde( default ) ]
101- pub model_ids : Vec < i64 > ,
102- #[ serde( default ) ]
103- pub group_id : Option < i64 > ,
104- #[ serde( default ) ]
105- pub card_id : Option < i64 > ,
106- #[ serde( default ) ]
107- pub note_id : Option < i64 > ,
108- #[ serde( default ) ]
109- pub fragment_id : Option < i64 > ,
110- }
111-
112- // ────────────────────────────────────────────────────────────
113- // v0.13.8 画布:节点位置与视口契约
114- //
115- // @ai-context: 画布=手动画布非自动图(REQ-029 P3 维持)——节点位置由用户拖拽决定,
116- // 首次打开时以辐射布局初始化(BFS 算法),算法只在首次生效。
117- // 坐标口径:React Flow 左上角(node.position 语义),与 DB 存储一致。
118- // ────────────────────────────────────────────────────────────
119-
120- /// 画布节点位置(batch_initialize_canvas_positions 入参;x/y 为左上角坐标)。
121- ///
122- /// @ai-context: 三表 id 空间独立(nodes/concepts/models),但本入参仅服务
123- /// knowledge_nodes(概念/模型无画布列,属浮动参照——每次打开重排)。
124- #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
125- #[ serde( rename_all = "camelCase" ) ]
126- pub struct CanvasNodePosition {
127- pub node_id : i64 ,
128- pub x : f64 ,
129- pub y : f64 ,
130- }
131-
132- /// 画布视口(get_canvas_viewport 返回;save_canvas_viewport 存储态)。
133- ///
134- /// @ai-context: 切回画布时经 setViewport 恢复;zoom 必须 >0(错误缩放直接拒绝,
135- /// 防损坏值放大/缩小到不可见)。
136- #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
137- #[ serde( rename_all = "camelCase" ) ]
138- pub struct CanvasViewport {
139- pub viewport_x : f64 ,
140- pub viewport_y : f64 ,
141- pub zoom : f64 ,
142- }
143-
144- /// 画布偏好(v0.14.1:连线样式/箭头/布局算法;按体系持久化)。
145- ///
146- /// @ai-context: 枚举白名单在命令层校验(EDGE_STYLES/LAYOUT_ALGORITHMS——前后端同
147- /// 口径,未知值拒绝入库);states 行可能不存在(首开)→ 前端回落默认值
148- /// (smoothstep + radial,与迁移 DEFAULT 一致)。
149- #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
150- #[ serde( rename_all = "camelCase" ) ]
151- pub struct CanvasPrefs {
152- pub edge_style : String ,
153- pub edge_arrows : bool ,
154- pub layout_algorithm : String ,
155- }
27+ pub use types_decision:: * ;
0 commit comments