docs(comments): 注释中文化 · internal/runtime/model + internal/services/backthink(54 文件,纯替换)
- 只翻注释/文档字符串:`go/scanner` 剥注释后按 token 序列+literal 逐 token 比对,**54/54 文件 SAME**;
改动文件总行数与 HEAD 漂移 = 0(严格 1:1,无合并/拆行)
- 裁决编号与 design 节号逐字保留(03.4.1/03.4.2/03.4.3/14.4.1/14.4.5/07.4.2-4、design/04 §3.1/§3.2 等);
`chat_template_kwargs` / `enable_thinking` / `reasoning_effort` / `thinking:{type}` 字段名与形状说明未动
- 存疑译法(已登记):`persona` 在叙事语境用「角色」、标识符语境保留 `persona`(仓库既有模块本身混用);
`rung`→「级」;`provider` 存在「提供商/提供者」两种落笔(可按需一键统一)
- 复核:build/vet 绿 + 两包测试绿;gofmt 干净;残留英文注释 0 条
- 既有存量(未修,只报告):`model/anthropic_test.go` 612 行 >500;`applyAnthropicEvent` 115 行 >80
This commit is contained in:
1 parent
f5cf117482
commit
3dc1232bc2
54 files changed
+1923
-1923
No files matched your search
@@ -11,10 +11,10 @@ import (
|
||||
|
||||
func TestPusher_AutoRoutesIM(t *testing.T) {
|
||||
t.Parallel()
|
||||
// The owner mandate: a default (auto) push reaches ONE channel over the IM
|
||||
// bridge (the bridge picks her [渠道:...] choice, then her most recent platform,
|
||||
// then the whitelist default) — not the active web client by default.
|
||||
active := &mockActive{n: 2} // a web client is online but is NOT the default target
|
||||
// 主人要求:默认(auto)推送经 IM 桥到达 ONE 个渠道
|
||||
//(桥依次挑她的 [渠道:...] 选择、她最近的平台、
|
||||
// 白名单默认)——默认不是活跃 Web 客户端。
|
||||
active := &mockActive{n: 2} // 有 Web 客户端在线,但它不是默认目标
|
||||
im := &mockIMAdapter{}
|
||||
p := newPusher(active, im, &mockGate{allow: true}, discardLog())
|
||||
|
||||
@@ -58,8 +58,8 @@ func TestPusher_WebHintRoutesActive(t *testing.T) {
|
||||
|
||||
func TestPusher_ConcreteHintRoutesIM_SingleTarget(t *testing.T) {
|
||||
t.Parallel()
|
||||
// A concrete decision channel is honored over the IM bridge, and exactly ONE
|
||||
// target is used (the IM bridge carries it; the active client is not touched).
|
||||
// 具体的决策渠道经 IM 桥被尊重,且只用 ONE 个
|
||||
// 目标(由 IM 桥承载;活跃客户端不被触碰)。
|
||||
active := &mockActive{n: 2}
|
||||
im := &mockIMAdapter{}
|
||||
p := newPusher(active, im, &mockGate{allow: true}, discardLog())
|
||||
@@ -85,8 +85,8 @@ func TestPusher_ConcreteHintRoutesIM_SingleTarget(t *testing.T) {
|
||||
|
||||
func TestPusher_NoIMSink_DegradesToActive(t *testing.T) {
|
||||
t.Parallel()
|
||||
// With no IM sink wired (backthink IM seam absent) the push degrades to the
|
||||
// active web client so the owner is still reached rather than dropped.
|
||||
// 未接线 IM 槽(backthink 的 IM 接缝缺失)时推送降级到
|
||||
// 活跃 Web 客户端,好让主人仍被触达而不是被丢弃。
|
||||
active := &mockActive{n: 1}
|
||||
p := newPusher(active, nil, &mockGate{allow: true}, discardLog())
|
||||
|
||||
@@ -156,8 +156,8 @@ func TestPusher_CancelledContext_Denied(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestPusher_RateLimit exercises the production rateGate over session.RateLimiter:
|
||||
// with a limit of 1 push per window, only the first of three attempts passes.
|
||||
// TestPusher_RateLimit 在 session.RateLimiter 上验证生产 rateGate:
|
||||
// 窗口内 limit 为 1 次推送时,三次尝试中只有第一次通过。
|
||||
func TestPusher_RateLimit(t *testing.T) {
|
||||
t.Parallel()
|
||||
active := &mockActive{n: 1}
|
||||
@@ -181,9 +181,9 @@ func TestPusher_RateLimit(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRateGate_CooldownAfterSuccess verifies the post-push cooldown: after a
|
||||
// successful delivery a further push is refused until the cooldown elapses,
|
||||
// regardless of the configured window counter.
|
||||
// TestRateGate_CooldownAfterSuccess 验证推送后冷却:一次成功
|
||||
// 投递之后,在冷却期结束前再推送会被拒绝,
|
||||
// 与已配置的窗口计数无关。
|
||||
func TestRateGate_CooldownAfterSuccess(t *testing.T) {
|
||||
t.Parallel()
|
||||
t0 := time.Now()
|
||||
@@ -191,7 +191,7 @@ func TestRateGate_CooldownAfterSuccess(t *testing.T) {
|
||||
log: discardLog(),
|
||||
limiter: session.NewRateLimiter(10, time.Hour),
|
||||
cooldown: 30 * time.Minute,
|
||||
kindWindow: 0, // disabled to isolate the cooldown
|
||||
kindWindow: 0, // 置零以单独验证冷却
|
||||
now: func() time.Time { return t0 },
|
||||
lastKind: make(map[PushKind]time.Time),
|
||||
}
|
||||
@@ -208,16 +208,16 @@ func TestRateGate_CooldownAfterSuccess(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRateGate_KindWindowLimitsSameFlavor verifies the per-flavor (问候/提醒/分享/
|
||||
// 关心) limit: the same flavor cannot repeat within the kind window, while a
|
||||
// different flavor and a later same-flavor push (after the window) still pass.
|
||||
// TestRateGate_KindWindowLimitsSameFlavor 验证按风格(问候/提醒/分享/
|
||||
// 关心)限制:同一风格不能在风格窗口内重复,而
|
||||
// 不同风格与更晚的同一风格推送(窗口之后)仍可通过。
|
||||
func TestRateGate_KindWindowLimitsSameFlavor(t *testing.T) {
|
||||
t.Parallel()
|
||||
t0 := time.Now()
|
||||
g := &rateGate{
|
||||
log: discardLog(),
|
||||
limiter: session.NewRateLimiter(10, time.Hour),
|
||||
cooldown: 0, // disabled to isolate the kind window
|
||||
cooldown: 0, // 置零以单独验证风格窗口
|
||||
kindWindow: 2 * time.Hour,
|
||||
now: func() time.Time { return t0 },
|
||||
lastKind: make(map[PushKind]time.Time),
|
||||
@@ -238,10 +238,10 @@ func TestRateGate_KindWindowLimitsSameFlavor(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestPusher_EventBypassesGate verifies an event-driven push skips the PushGate:
|
||||
// with a limit of 1 push per window, three consecutive event pushes are ALL
|
||||
// delivered (owner mandate "该发就发"), each marked Bypassed and each advancing
|
||||
// no cooldown/kind window.
|
||||
// TestPusher_EventBypassesGate 验证事件驱动的推送跳过 PushGate:
|
||||
// 窗口内 limit 为 1 次推送时,连续三次事件推送全部
|
||||
// 被投递(主人要求 "该发就发"),每次都标记 Bypassed,且都不推进
|
||||
// 冷却/风格窗口。
|
||||
func TestPusher_EventBypassesGate(t *testing.T) {
|
||||
t.Parallel()
|
||||
active := &mockActive{n: 1}
|
||||
@@ -266,9 +266,9 @@ func TestPusher_EventBypassesGate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestPusher_HeartbeatStillRateLimited verifies a heartbeat-driven push stays
|
||||
// gate-governed: with a limit of 1 push per window, the first passes and the
|
||||
// second is refused as rate_limited, never Bypassed.
|
||||
// TestPusher_HeartbeatStillRateLimited 验证心跳驱动的推送仍
|
||||
// 受门控管辖:窗口内 limit 为 1 次推送时,第一次通过,
|
||||
// 第二次作为 rate_limited 被拒,绝不是 Bypassed。
|
||||
func TestPusher_HeartbeatStillRateLimited(t *testing.T) {
|
||||
t.Parallel()
|
||||
active := &mockActive{n: 1}
|
||||
@@ -289,9 +289,9 @@ func TestPusher_HeartbeatStillRateLimited(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestPusher_EventBypass_DoesNotAdvanceGate verifies an event-driven push does not
|
||||
// consume the heartbeat limit: after an event push, a following heartbeat push
|
||||
// still gets its own full allowance.
|
||||
// TestPusher_EventBypass_DoesNotAdvanceGate 验证事件驱动的推送不会
|
||||
// 消耗心跳额度:一次事件推送之后,紧随的心跳推送
|
||||
// 仍拿到自己那份完整额度。
|
||||
func TestPusher_EventBypass_DoesNotAdvanceGate(t *testing.T) {
|
||||
t.Parallel()
|
||||
active := &mockActive{n: 1}
|
||||
|
||||
Reference in new issue
Block a user