docs(comments): 注释中文化 · internal/runtime/orchestration(29 文件,纯替换)
- 只翻注释/文档字符串:剥离注释后代码行逐字节不变(机械校验只剩允许的行尾注释形态) - 裁决编号与 design 节号(02.4.3 / 11.4.2 / design/05 §9 等)逐字保留 - 复核:go build 绿;orchestration 及其子包(audit/comm)测试绿;gofmt 干净
This commit is contained in:
1 parent
fe90f64a56
commit
eb1828ee7a
29 files changed
+751
-949
No files matched your search
@@ -17,11 +17,10 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/trace"
|
||||
)
|
||||
|
||||
// TestSubagentBranchFoldsIntoParentGraph is the end-to-end wiring test for the
|
||||
// branch visualization: a real loop driven by the scheduler under a parent
|
||||
// session must appear in that session's graph as a subagent lane root whose inner
|
||||
// llm/tool steps hang off it, must not start a round (so the frontend's single
|
||||
// flowGraph is never replaced), and must not open a graph under its own id.
|
||||
// TestSubagentBranchFoldsIntoParentGraph 是分支可视化的端到端接线测试:由调度器在父会话
|
||||
// 之下驱动的真实循环,必须作为子代理泳道根出现在该会话的图里、其内部 llm/tool 步骤挂在
|
||||
// 它下面;必须不开启新一轮(否则前端唯一的 flowGraph 会被替换);也必须不以其自身 id
|
||||
// 另开一张图。
|
||||
func TestSubagentBranchFoldsIntoParentGraph(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := &graphCapture{}
|
||||
@@ -64,8 +63,7 @@ func TestSubagentBranchFoldsIntoParentGraph(t *testing.T) {
|
||||
if subNode.Kind != "subagent" || subNode.Status != trace.FlowStatusDone {
|
||||
t.Fatalf("subagent node = %+v, want kind subagent / status done", subNode)
|
||||
}
|
||||
// The branch's steps chain inside its own lane: llm (asks for the tool), tool,
|
||||
// llm (answers).
|
||||
// 该分支的步骤在自己的泳道内成链:llm(请求工具)、tool、llm(作答)。
|
||||
chain := flowLaneChain(t, g, subNode)
|
||||
if len(chain) != 3 || chain[0].Kind != "llm" || chain[1].Kind != "tool" || chain[2].Kind != "llm" {
|
||||
t.Fatalf("lane chain = %s, want llm>tool>llm", chainKinds(chain))
|
||||
@@ -75,7 +73,7 @@ func TestSubagentBranchFoldsIntoParentGraph(t *testing.T) {
|
||||
t.Fatalf("input node label = %q, want the parent round's seed text", in.Label)
|
||||
}
|
||||
|
||||
// Node logs: every executed step must carry a real event, and nothing else.
|
||||
// 节点日志:每个已执行的步骤都必须带一条真实事件,且不带别的。
|
||||
llmEvent := flowLogEvent(t, llmNode, loop.EventLLMDone)
|
||||
if got := fmt.Sprint(llmEvent.Props["model"]); got != "mock-1" {
|
||||
t.Fatalf("llm log model = %q, want mock-1 (props: %+v)", got, llmEvent.Props)
|
||||
@@ -97,7 +95,7 @@ func TestSubagentBranchFoldsIntoParentGraph(t *testing.T) {
|
||||
t.Fatalf("tool log args_keys = %q, want the argument names", got)
|
||||
}
|
||||
|
||||
// Red line: no credential from the tool call or its result may be published.
|
||||
// 红线:工具调用或其结果中的任何凭据都不得被发布。
|
||||
blob, merr := json.Marshal(g)
|
||||
if merr != nil {
|
||||
t.Fatalf("marshal graph: %v", merr)
|
||||
@@ -113,10 +111,9 @@ func TestSubagentBranchFoldsIntoParentGraph(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSpawnParallelBranchesStaySeparate asserts two sub-agents running at the same
|
||||
// time land in two disjoint swimlanes of the parent graph: each lane has its own
|
||||
// llm→tool chain and nothing in one lane is reachable from the other (design/19 §2
|
||||
// 泳道, the cross-linking failure the lane cursor exists to prevent).
|
||||
// TestSpawnParallelBranchesStaySeparate 断言同时运行的两个子代理落在父图的两条互不相交
|
||||
// 的泳道里:每条泳道有自己的 llm→tool 链,且一条泳道里没有任何东西可从另一条到达
|
||||
// (design/19 §2 泳道,也就是泳道游标存在的意义——防交叉链接失效)。
|
||||
func TestSpawnParallelBranchesStaySeparate(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := &graphCapture{}
|
||||
@@ -169,17 +166,15 @@ func TestSpawnParallelBranchesStaySeparate(t *testing.T) {
|
||||
t.Fatalf("node %s is reachable from both lanes (cross-linked edges: %+v)", id, g.Edges)
|
||||
}
|
||||
}
|
||||
// The trunk cursor must still be the parent's seed, not the last branch node.
|
||||
// 主干游标必须仍是父轮的种子,而不是最后那个分支节点。
|
||||
if !hasFlowEdge(g, "input", nodeA.ID) || !hasFlowEdge(g, "input", nodeB.ID) {
|
||||
t.Fatalf("edges = %+v, want both branch roots hanging off the parent's input node", g.Edges)
|
||||
}
|
||||
}
|
||||
|
||||
// TestSubagentRunDoesNotStreamToFrontSession asserts a sub-agent's inner stream is
|
||||
// muted: the loop still drives the model (its llm step appears in the parent's flow
|
||||
// lane), but no delta reaches the caller's OnStream, so a background sub-agent's
|
||||
// monologue never leaks into the front conversation (design/05 §8, design/04 §2
|
||||
// 不污染前台).
|
||||
// TestSubagentRunDoesNotStreamToFrontSession 断言子代理的内部流被静音:循环仍驱动模型
|
||||
// (其 llm 步骤出现在父图的泳道里),但没有任何增量抵达调用方的 OnStream,因此后台子代理
|
||||
// 的独白绝不会泄漏进前台对话(design/05 §8, design/04 §2 不污染前台)。
|
||||
func TestSubagentRunDoesNotStreamToFrontSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := &graphCapture{}
|
||||
@@ -228,7 +223,7 @@ func TestSubagentRunDoesNotStreamToFrontSession(t *testing.T) {
|
||||
if len(got) != 0 {
|
||||
t.Fatalf("sub-agent pushed %d stream events into the front session: %+v", len(got), got)
|
||||
}
|
||||
// The work is still visible where it belongs: as a lane of the parent's graph.
|
||||
// 该工作仍在它该在的地方可见:作为父图的一条泳道。
|
||||
g := capture.graph(t, parentSession)
|
||||
subNode := flowSubagentNode(t, g, sub.ID)
|
||||
if chain := flowLaneChain(t, g, subNode); len(chain) == 0 {
|
||||
@@ -236,9 +231,8 @@ func TestSubagentRunDoesNotStreamToFrontSession(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSpawnWithoutParentSessionStaysOutOfEveryGraph asserts the flow attribution is
|
||||
// opt-in: a spawn with no ParentSession publishes no graph at all, so an
|
||||
// unattributed background agent can never surface as a stray lane.
|
||||
// TestSpawnWithoutParentSessionStaysOutOfEveryGraph 断言流图归属是选择性的:未带
|
||||
// ParentSession 的派发根本不发布任何图,因此未归属的后台 agent 绝不会作为游离泳道浮现。
|
||||
func TestSpawnWithoutParentSessionStaysOutOfEveryGraph(t *testing.T) {
|
||||
t.Parallel()
|
||||
capture := &graphCapture{}
|
||||
|
||||
Reference in new issue
Block a user