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
@@ -5,14 +5,14 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// dayAt returns a mid-afternoon time in UTC (outside the quiet-hours window).
|
||||
// dayAt 返回 UTC 的午后时间(在安静时段窗口之外)。
|
||||
func dayAt() time.Time { return time.Date(2026, 9, 6, 14, 0, 0, 0, time.UTC) }
|
||||
|
||||
// nightAt returns a 02:00 time in UTC (inside the default 23-7 quiet window).
|
||||
// nightAt 返回 UTC 的 02:00(在默认 23-7 安静窗口之内)。
|
||||
func nightAt() time.Time { return time.Date(2026, 9, 6, 2, 0, 0, 0, time.UTC) }
|
||||
|
||||
// testBackthink builds a Backthink with a normalized empty Config so Decide uses
|
||||
// the default quiet-hours window (23:00-07:00).
|
||||
// testBackthink 用归一化的空 Config 构建 Backthink,因此 Decide 使用
|
||||
// 默认安静时段窗口(23:00-07:00)。
|
||||
func testBackthink() *Backthink {
|
||||
return &Backthink{cfg: normalize(Config{})}
|
||||
}
|
||||
@@ -144,8 +144,8 @@ func TestInQuietHours(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestClassifyPush verifies the proactive message body maps to the intended flavor
|
||||
// (问候/提醒/分享/关心) so the frequency gate can limit each flavor separately.
|
||||
// TestClassifyPush 验证主动消息正文映射到预期的风格
|
||||
// (问候/提醒/分享/关心),使频率门能分别限制每种风格。
|
||||
func TestClassifyPush(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
@@ -168,16 +168,16 @@ func TestClassifyPush(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestDecide_ActivityGate verifies the activity-aware soft gate: a fresh
|
||||
// conversation holds trivia (unless critical), a long-idle owner is only woken by
|
||||
// an important event — except a heartbeat pass, which is never held by a
|
||||
// long-silent gap (裁决 07.4.3) — and the in-between band does not over-suppress.
|
||||
// TestDecide_ActivityGate 验证活动感知软门:刚开始的
|
||||
// 对话会扣下琐碎内容(critical 除外),长期静默的主人只会被
|
||||
// 重要事件唤醒——但心跳轮除外,它永远不会被长期
|
||||
// 静默的间隔拦下(裁决 07.4.3)——而中间地带不会过度抑制。
|
||||
func TestDecide_ActivityGate(t *testing.T) {
|
||||
t.Parallel()
|
||||
b := testBackthink()
|
||||
|
||||
// Just chatted (within RecentChatCooldown=10min): a normal daytime push is
|
||||
// held unless the event is safety-critical.
|
||||
// 刚聊过(在 RecentChatCooldown=10min 内):白天普通推送
|
||||
// 会被扣下,除非该事件是安全关键。
|
||||
fresh := DecisionInput{
|
||||
Import: ImportanceNormal,
|
||||
At: dayAt(),
|
||||
@@ -194,8 +194,8 @@ func TestDecide_ActivityGate(t *testing.T) {
|
||||
t.Fatalf("critical event should push even in a fresh conversation, got %+v", got)
|
||||
}
|
||||
|
||||
// Away a long while (> longIdleThreshold): only an important event is worth
|
||||
// it — but a heartbeat pass still goes through (裁决 07.4.3 长期静默段不拦心跳).
|
||||
// 离开很久(> longIdleThreshold):只有重要事件值得
|
||||
// 唤醒——但心跳轮仍会通过(裁决 07.4.3 长期静默段不拦心跳)。
|
||||
idle := DecisionInput{
|
||||
Import: ImportanceNormal,
|
||||
At: dayAt(),
|
||||
@@ -217,7 +217,7 @@ func TestDecide_ActivityGate(t *testing.T) {
|
||||
t.Fatalf("long idle heartbeat should still push (07.4.3), got %+v", got)
|
||||
}
|
||||
|
||||
// Middling activity (30 min ago) is not over-suppressed.
|
||||
// 中等活动(30 分钟前)不会被过度抑制。
|
||||
middle := DecisionInput{
|
||||
Import: ImportanceNormal,
|
||||
At: dayAt(),
|
||||
|
||||
Reference in new issue
Block a user