%%{init: {"flowchart": {"wrappingWidth": 680}}}%%
flowchart TB
%% 依据:lpt-be RecallAiService#bounded/semanticExpression、RecallReferenceLoader#snapshot/units、
%% ReviewRecallStore#load、RecallDtos.RecallAiParams;lpt-ai recall.ts#validateRecallParams。
%% 资料是创建回忆时冻结的 ReferenceSnapshot,不在每次请求时重新取数。
classDef src fill:#ffe1e1,stroke:#c0392b,stroke-width:3.5px,color:#7b1414
classDef api fill:#e8f0fe,stroke:#1a56b0,stroke-width:1.2px,color:#111
classDef take fill:#e7f6ea,stroke:#2e8b57,stroke-width:1.2px,color:#14532d
classDef use fill:#f3f0fb,stroke:#6b4fa0,stroke-width:1.2px,color:#3b2a63
classDef origin fill:#fff3cd,stroke:#b8860b,stroke-dasharray:4 3,color:#664d03
classDef note fill:#f7f7f7,stroke:#999,stroke-dasharray:4 3,color:#333
classDef warn fill:#ffe1e1,stroke:#c0392b,stroke-width:2.2px,color:#7b1414
S["「源」review_recalls.document_json
detail.expression、detail.scope;
reference.sources/units/limitations 在创建回忆时冻结"]:::origin
S --> EX["「用」semanticExpression()
剥离颜色等展示字段"]:::use
S --> U["「取」reference.units
过滤 text != null 且 status=AVAILABLE;
PRIMARY 优先 → sourceId → start 排序"]:::take
EX --> P["「用」RecallAiParams
schemaVersion=1、promptVersion=recall-v1、
scope、expression、hintForm、units、limits、limitations"]:::use
U --> P
P --> CAP["「取」整份接受或拒绝
超过 40 单元 / 12000 字 / 200 KiB → INPUT_TOO_LARGE"]:::take
CAP --> MSG["「源」user 消息
JSON.stringify({ type, ...params })"]:::origin
MSG --> N["「说明」unitId=sourceId:start;start/end 是 source 全文的 UTF-16 半开绝对偏移;
导图预算 1000 节点 / 32000 字 / 深度 32;
limits 固定 3 / 5 / 12;HINT 取用户选的形式,CHECK 为 null"]:::note