refactor(dispatcher): T1.1 退役 graph.go —— 编排引擎收成单一 compose
compose 已默认数天、HITL/多智能体/评测全在其上真实跑过,soak 充分。删掉自研拓扑 解释器这第二套引擎,消灭"双实现 drift"税: - 删 runGraph(graph.go 的自研解释器)+ composeEnabled/EINO_COMPOSE 逃生舱开关 + runConversation(仅 runGraph 用的死代码)。 - executeGraph 直接走 runComposeGraph;compose 编译失败兜底改单轮对话(不再回退 graph.go);清掉仅 runGraph 用的 import(otel attribute/trace/otelx)。 - 保留 board / 各节点执行器(retriever/tool/agent/branch/approval/map/render/aggregate) / 工具函数 —— 它们是 compose 各节点 lambda 复用的,非 graph.go 专属。 - 测试:8 处 runGraph→runComposeGraph;等价测试(对照两引擎)转为 compose 正确性测试; runConversation 的开关测试转为「无 ChatModel 降级 runAgent」。 go test ./... 全绿 + vet 干净;冒烟 简单 agent/分支图 跑通。此后每个编排改动不再两边 对齐,成本减半。DEPTH_ROADMAP T1.1 ✅。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -28,21 +28,15 @@ func echoLLM() *fakeLLM {
|
||||
}
|
||||
}
|
||||
|
||||
func runBoth(t *testing.T, graph string) (interp, comp string) {
|
||||
// runCompose 跑一个图并返回成稿(自研 graph.go 已退役,编排引擎统一为 compose)。
|
||||
func runCompose(t *testing.T, graph string) string {
|
||||
t.Helper()
|
||||
task := &contract.Task{ID: "t_eq", Graph: []byte(graph)}
|
||||
|
||||
o1 := &Orchestrator{pool: echoLLM(), breaker: harness.NewCircuitBreaker(), sink: &fakeSink{}}
|
||||
a1, _, err := o1.runGraph(context.Background(), task, &execTracer{})
|
||||
if err != nil {
|
||||
t.Fatalf("runGraph: %v", err)
|
||||
}
|
||||
o2 := &Orchestrator{pool: echoLLM(), breaker: harness.NewCircuitBreaker(), sink: &fakeSink{}}
|
||||
a2, _, err := o2.runComposeGraph(context.Background(), task, &execTracer{})
|
||||
o := &Orchestrator{pool: echoLLM(), breaker: harness.NewCircuitBreaker(), sink: &fakeSink{}}
|
||||
ans, _, err := o.runComposeGraph(context.Background(), &contract.Task{ID: "t_eq", Graph: []byte(graph)}, &execTracer{})
|
||||
if err != nil {
|
||||
t.Fatalf("runComposeGraph: %v", err)
|
||||
}
|
||||
return a1, a2
|
||||
return ans
|
||||
}
|
||||
|
||||
// rejectWaiter 是恒拒绝的 HITL 审批替身(fail-safe 路径回归用)。
|
||||
@@ -257,8 +251,8 @@ func TestComposeReturnsRefs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestComposeEquivalentLinear 多节点线性图:input→memory→agent→output,两路径成稿应逐字一致。
|
||||
func TestComposeEquivalentLinear(t *testing.T) {
|
||||
// TestComposeLinear 多节点线性图:input→memory→agent→output,compose 应跑通并产出成稿。
|
||||
func TestComposeLinear(t *testing.T) {
|
||||
graph := `{"version":"1","nodes":[
|
||||
{"id":"in","kind":"input","config":{"text":"什么是图编排"}},
|
||||
{"id":"m","kind":"memory","config":{}},
|
||||
@@ -267,14 +261,14 @@ func TestComposeEquivalentLinear(t *testing.T) {
|
||||
],"edges":[
|
||||
{"source":"in","target":"m"},{"source":"m","target":"a"},{"source":"a","target":"out"}
|
||||
]}`
|
||||
interp, comp := runBoth(t, graph)
|
||||
if interp == "" || interp != comp {
|
||||
t.Fatalf("线性图不等价: interp=%q compose=%q", interp, comp)
|
||||
if ans := runCompose(t, graph); !strings.Contains(ans, "ANS:") {
|
||||
t.Fatalf("线性图 compose 应产出成稿,got %q", ans)
|
||||
}
|
||||
}
|
||||
|
||||
// TestComposeEquivalentBranch 分支图:input→branch→(真)A/(假)B,条件恒真应都走 A,两路径一致。
|
||||
func TestComposeEquivalentBranch(t *testing.T) {
|
||||
// TestComposeBranch 分支图:input→branch→(真)A/(假)B,条件恒真走 A,compose 应跑通产出。
|
||||
// 分支真假边的精确选路另由 TestRunGraph_BranchRouting(compose)钉死。
|
||||
func TestComposeBranch(t *testing.T) {
|
||||
graph := `{"version":"1","nodes":[
|
||||
{"id":"in","kind":"input","config":{"text":"hi"}},
|
||||
{"id":"br","kind":"branch","config":{"condition":""}},
|
||||
@@ -285,8 +279,7 @@ func TestComposeEquivalentBranch(t *testing.T) {
|
||||
{"source":"br","target":"a","sourceHandle":"true"},
|
||||
{"source":"br","target":"b","sourceHandle":"false"}
|
||||
]}`
|
||||
interp, comp := runBoth(t, graph)
|
||||
if interp == "" || interp != comp {
|
||||
t.Fatalf("分支图不等价: interp=%q compose=%q", interp, comp)
|
||||
if ans := runCompose(t, graph); !strings.Contains(ans, "ANS:") {
|
||||
t.Fatalf("分支图 compose 应产出成稿,got %q", ans)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user