docs(runtime): internal/runtime/loop 44 个文件注释改中文(逐行 1:1,代码零字节改动)

主人 2026-10-03 拍板「注释一律中文」;本模块按长期分批协议(一个模块一次派工)执行。
注释行数 1329 → 1329 逐行 1:1(含中文 33 → 1304);行尾注释 5 条一并译。
校验:机械校验(非注释改动行)= 空;独立 Go AST 程序(剥注释复渲)证明 44/44 文件代码全等;
全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
gofmt:capacity_loop_test.go / flow.go 改动前即未格式化,按铁律保留原样未动。
This commit is contained in:
AskaEth committed 2026-10-03 22:28:21 +08:00
1 parent 355f81d04a
commit 91e8d7a029
44 files changed
+1315 -1315

No files matched your search

+11 -11
View File
@@ -2,23 +2,23 @@ package loop
import "context"
// muteKey is the context key for the "suppress UI broadcast" flag. When set,
// a Run performs its work as usual but does NOT push stream/thinking/capacity
// events to the UI channel (OnStream / OnCapacity). This is used by internal
// autonomous passes (e.g. background reflection) whose intermediate reasoning
// must not leak into the user-facing chat stream. The loop itself is unchanged;
// only the outward event emission is muted.
// muteKey 是「抑制 UI 广播」标志的 context key。置位时,
// Run 照常完成工作,但不把 stream/thinking/capacity 事件
// 推给 UI 通道(OnStream / OnCapacity)。内部自主流程
// (如后台反思)使用它,这些流程的中间推理
// 不得泄露进面向用户的聊天流。循环本身不变,
// 只是对外的广播被静音。
type muteKey struct{}
// WithMutedBroadcast returns a context whose loop Run suppresses UI stream and
// capacity broadcast, while still returning the final result to the caller.
// WithMutedBroadcast 返回一个 context,其 loop Run 抑制 UI 流式
// 与 capacity 广播,但仍把最终结果返回给调用方。
func WithMutedBroadcast(ctx context.Context) context.Context {
return context.WithValue(ctx, muteKey{}, true)
}
// isMutedBroadcast reports whether the Run driving ctx should suppress UI
// broadcast. An unset flag (the common case) returns false so normal chat
// streaming is untouched.
// isMutedBroadcast 报告驱动 ctx 的 Run 是否应抑制 UI
// 广播。标志未置位(常见情况)返回 false,因此正常聊天
// 流式不受影响。
func isMutedBroadcast(ctx context.Context) bool {
v, _ := ctx.Value(muteKey{}).(bool)
return v