docs: annotate Foundry source and deployment lifecycle in Chinese [skip ci]
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// AI 执行计划的纯规划器:解析真实端点、选择传播范围、冻结静态内容并按依赖拓扑排序。
|
||||
package platform
|
||||
|
||||
import (
|
||||
@@ -7,6 +8,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// canvasAIStaticInput 保存不由本轮生成的输入内容及其逻辑边身份,后续编辑不会改变已经冻结的输入。
|
||||
type canvasAIStaticInput struct {
|
||||
EdgeID string `json:"logical_edge_id"`
|
||||
BoardID string `json:"board_id"`
|
||||
@@ -14,6 +16,8 @@ type canvasAIStaticInput struct {
|
||||
Kind string `json:"kind"`
|
||||
Content map[string]any `json:"content"`
|
||||
}
|
||||
|
||||
// canvasAIStepPlan 固定来源、配置、内容指纹与依赖;canonical 根/incarnation 由准入阶段另行绑定。
|
||||
type canvasAIStepPlan struct {
|
||||
CanonicalRoot string `json:"canonical_root,omitempty"`
|
||||
TargetIncarnation int64 `json:"target_incarnation,omitempty"`
|
||||
@@ -30,19 +34,25 @@ type canvasAIStepPlan struct {
|
||||
Status string `json:"status"`
|
||||
Dependencies []string `json:"dependencies"`
|
||||
}
|
||||
|
||||
// canvasAIEdgePlan 的 ID 由拥有者画布/边 ID 组成,端点是解析后的真实步骤复合 ID。
|
||||
type canvasAIEdgePlan struct {
|
||||
ID string `json:"logical_edge_id"`
|
||||
Source string `json:"source_step_id"`
|
||||
Target string `json:"target_step_id"`
|
||||
}
|
||||
|
||||
// canvasAIPlan 是可持久化的确定执行输入,Versions 标明规划时读取的所有快照版本。
|
||||
type canvasAIPlan struct {
|
||||
Steps []canvasAIStepPlan `json:"steps"`
|
||||
Edges []canvasAIEdgePlan `json:"edges"`
|
||||
Versions map[string]int64 `json:"frozen_versions"`
|
||||
}
|
||||
|
||||
// canvasNodeKey 在旧画布局部 ID 域内组合唯一键,canonical 元素仍保留原计划来源作为步骤身份。
|
||||
func canvasNodeKey(board, node string) string { return board + "/" + node }
|
||||
|
||||
// buildCanvasAIPlan 只操作传入快照,不访问数据库;最多选择 64 步,拓扑最长路径不得超过 32。
|
||||
func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string, propagate bool) (canvasAIPlan, error) {
|
||||
plan := canvasAIPlan{Steps: []canvasAIStepPlan{}, Edges: []canvasAIEdgePlan{}, Versions: map[string]int64{}}
|
||||
data := map[string]map[string]any{}
|
||||
@@ -53,6 +63,7 @@ func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string,
|
||||
}
|
||||
}
|
||||
var resolve func(string, string, string, string, int) (string, error)
|
||||
// frame 的连接必须经方向匹配端口下钻到真实节点,图标等不可执行节点不能成为输入/目标。
|
||||
resolve = func(board, node, handle, direction string, depth int) (string, error) {
|
||||
if depth > 8 {
|
||||
return "", errors.New("graph_limit_exceeded")
|
||||
@@ -119,6 +130,7 @@ func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string,
|
||||
for key := range outgoing {
|
||||
sort.Slice(outgoing[key], func(i, j int) bool { return outgoing[key][i].ID < outgoing[key][j].ID })
|
||||
}
|
||||
// 根由显式请求执行;下游未启用 AI 或没有模型则记录 skipped 并停止从该节点继续传播。
|
||||
selected := map[string]bool{}
|
||||
skipped := map[string]bool{}
|
||||
queue := []string{root}
|
||||
@@ -149,6 +161,7 @@ func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string,
|
||||
}
|
||||
}
|
||||
// Kahn's algorithm waits for every participating predecessor at a diamond.
|
||||
// Kahn 入度等待所有参与前驱,菱形汇合只能在两支都处理完后出队,不能按首次访问就执行。
|
||||
indegree := map[string]int{}
|
||||
incoming := map[string][]string{}
|
||||
depths := map[string]int{}
|
||||
@@ -177,6 +190,7 @@ func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string,
|
||||
content := canvasFrozenContent(d)
|
||||
static := []canvasAIStaticInput{}
|
||||
sort.Slice(allIncoming[id], func(i, j int) bool { return allIncoming[id][i].ID < allIncoming[id][j].ID })
|
||||
// 本轮将生成的有效前驱作为动态依赖,其余入边内容冻结为静态输入,包括传播关闭时的前驱。
|
||||
for _, edge := range allIncoming[id] {
|
||||
if propagate && selected[edge.Source] && !skipped[edge.Source] {
|
||||
continue
|
||||
@@ -209,6 +223,7 @@ func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string,
|
||||
}
|
||||
}
|
||||
}
|
||||
// 有入度永远无法归零的已选节点表示执行环,拒绝整个计划而不是执行可排序前缀。
|
||||
if len(plan.Steps) != len(selected) {
|
||||
return plan, errors.New("execution_cycle")
|
||||
}
|
||||
@@ -216,6 +231,7 @@ func buildCanvasAIPlan(snapshots map[string]canvasSnapshot, board, node string,
|
||||
return plan, nil
|
||||
}
|
||||
|
||||
// canvasFrozenContent 只捕获语义输入:图片为引用身份,文本为正文,不含位置和纯展示样式。
|
||||
func canvasFrozenContent(data map[string]any) map[string]any {
|
||||
if canvasChoice(data["kind"], "image", "plain-image") {
|
||||
return map[string]any{"src": data["src"], "assetId": data["assetId"]}
|
||||
|
||||
Reference in New Issue
Block a user