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
@@ -5,17 +5,15 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Wait blocks until every sub-agent named by ids reaches a terminal state (or ctx
|
||||
// is canceled) and returns the merged outcome of exactly those sub-agents, in the
|
||||
// order the ids were given.
|
||||
// Wait 阻塞到 ids 指名的每个子代理都进入终结态(或 ctx 被取消),返回且仅返回这些
|
||||
// 子代理的合并结果,顺序与给定 id 的顺序一致。
|
||||
//
|
||||
// Unlike Join — which covers the whole scheduler — Wait scopes both the wait and
|
||||
// the merge to one caller's batch, so concurrent spawns from different sessions
|
||||
// never wait on, or merge, each other's sub-agents. It is what the spawn tool uses
|
||||
// to collect the results it is about to hand back.
|
||||
// 与覆盖整个调度器的 Join 不同,Wait 把等待与合并都限定在某个调用方自己的批次上,
|
||||
// 因此不同会话的并发派发绝不会互相等待、也不会合并到彼此的子代理。派发工具正是用
|
||||
// 它收集自己即将交回的结果。
|
||||
//
|
||||
// It returns ErrAgentNotFound (wrapped with %w) for an unknown id, and the wrapped
|
||||
// ctx error together with the partial merged outcome when ctx is canceled first.
|
||||
// 未知 id 返回 ErrAgentNotFound(以 %w 包装);ctx 先行取消时返回包装后的 ctx 错误
|
||||
// 与部分合并结果。
|
||||
func (s *Scheduler) Wait(ctx context.Context, ids []string) (*MergedResult, error) {
|
||||
if ctx == nil {
|
||||
ctx = context.Background()
|
||||
@@ -34,8 +32,8 @@ func (s *Scheduler) Wait(ctx context.Context, ids []string) (*MergedResult, erro
|
||||
return mergeSubs(subs), nil
|
||||
}
|
||||
|
||||
// pick resolves ids to their registered sub-agents in the given order. It returns
|
||||
// ErrAgentNotFound wrapped for the first unknown id.
|
||||
// pick 按给定顺序把 ids 解析为已登记的子代理。遇到第一个未知 id 时返回包装后的
|
||||
// ErrAgentNotFound。
|
||||
func (s *Scheduler) pick(ids []string) ([]*SubAgent, error) {
|
||||
subs := make([]*SubAgent, 0, len(ids))
|
||||
s.mu.Lock()
|
||||
@@ -50,8 +48,8 @@ func (s *Scheduler) pick(ids []string) ([]*SubAgent, error) {
|
||||
return subs, nil
|
||||
}
|
||||
|
||||
// merge aggregates every registered sub-agent into a MergedResult. It is called by
|
||||
// Join once all sub-agents are terminal.
|
||||
// merge 把所有已登记的子代理聚合成一个 MergedResult。它由 Join 在全部子代理终结后
|
||||
// 调用。
|
||||
func (s *Scheduler) merge() *MergedResult {
|
||||
s.mu.Lock()
|
||||
subs := make([]*SubAgent, 0, len(s.agents))
|
||||
@@ -62,10 +60,9 @@ func (s *Scheduler) merge() *MergedResult {
|
||||
return mergeSubs(subs)
|
||||
}
|
||||
|
||||
// mergeSubs aggregates the given sub-agents into a MergedResult, counting the
|
||||
// terminal statuses and appending each snapshot in slice order. A sub-agent that
|
||||
// is still running contributes its current snapshot and is counted in neither
|
||||
// Succeeded/Failed/Aborted.
|
||||
// mergeSubs 把给定子代理聚合成一个 MergedResult:统计终结态数量,并按切片顺序追加
|
||||
// 各自的快照。仍在运行的子代理贡献其当前快照,且不计入 Succeeded/Failed/Aborted
|
||||
// 中任何一项。
|
||||
func mergeSubs(subs []*SubAgent) *MergedResult {
|
||||
res := &MergedResult{Total: len(subs), Agents: make([]SubAgentResult, 0, len(subs))}
|
||||
for _, sub := range subs {
|
||||
|
||||
Reference in new issue
Block a user