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:
1 parent
355f81d04a
commit
91e8d7a029
44 files changed
+1315
-1315
No files matched your search
@@ -6,24 +6,24 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/runtime/capacity"
|
||||
)
|
||||
|
||||
// capStateKey is the context key for the per-Run capacity-state accumulator.
|
||||
// capStateKey 是每 Run capacity 状态累加器的 context key。
|
||||
type capStateKey struct{}
|
||||
|
||||
// capStateAccum holds the mutable capacity state for one Run so the state
|
||||
// progresses across a multi-step tool loop (quiet→awake→full) without leaking
|
||||
// between concurrent runs. It lives on the context seeded at the top of Run.
|
||||
// capStateAccum 持有一个 Run 的可变 capacity 状态,使该状态
|
||||
// 能跨多步工具循环演进(quiet→awake→full),且不在并发 run 之间
|
||||
// 泄漏。它挂在 Run 顶部播种的 context 上。
|
||||
type capStateAccum struct {
|
||||
state capacity.State
|
||||
}
|
||||
|
||||
// withCapState returns a context carrying acc.
|
||||
// withCapState 返回携带 acc 的 context。
|
||||
func withCapState(ctx context.Context, acc *capStateAccum) context.Context {
|
||||
return context.WithValue(ctx, capStateKey{}, acc)
|
||||
}
|
||||
|
||||
// capState returns the accumulator on ctx, or a fresh quiet one when none is
|
||||
// seeded (a defensive fallback for a caller that invokes toolSchemas outside
|
||||
// Run, where the state is not meant to persist).
|
||||
// capState 返回 ctx 上的累加器;未播种时返回一个全新的 quiet
|
||||
// 累加器(为在 Run 之外调用 toolSchemas 的调用方提供的防御性兜底,
|
||||
// 此处状态本就不应持久化)。
|
||||
func capState(ctx context.Context) *capStateAccum {
|
||||
if acc, ok := ctx.Value(capStateKey{}).(*capStateAccum); ok {
|
||||
return acc
|
||||
|
||||
Reference in new issue
Block a user