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
@@ -41,7 +41,7 @@ func TestParseProactive_NoPushMarker(t *testing.T) {
|
||||
|
||||
func TestParseProactive_ChannelColonWidth(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Tolerate a full-width colon and trailing spaces, and uppercase channel value.
|
||||
// 容忍全角冒号与尾随空格,以及大写渠道值。
|
||||
conclusion := "[我决定:push] [渠道:WEB] 晚上早点睡"
|
||||
msg, hint, push := parseProactive(conclusion)
|
||||
if !push {
|
||||
@@ -104,11 +104,11 @@ func TestParseProactive_MalformedFailsSafe(t *testing.T) {
|
||||
|
||||
func TestParseProactive_MarkerWithoutBody(t *testing.T) {
|
||||
t.Parallel()
|
||||
// A lone push marker with no body must not push an empty message (fail safe).
|
||||
// 单独一个 push 标记、正文为空时绝不能推出空消息(失败安全)。
|
||||
if _, _, push := parseProactive("[我决定:push]"); push {
|
||||
t.Fatalf("push = true for a marker with no body, want false")
|
||||
}
|
||||
// A push marker whose body says "nothing" is contradictory → fail safe.
|
||||
// push 标记的正文写着「无」是自相矛盾的 → 失败安全。
|
||||
if _, _, push := parseProactive("[我决定:push]\n无"); push {
|
||||
t.Fatalf("push = true for a push marker with nothing body, want false")
|
||||
}
|
||||
@@ -131,8 +131,8 @@ func TestThink_ParsesStructuredDecision_EndToEnd(t *testing.T) {
|
||||
|
||||
b.think(context.Background(), heartbeatTrigger())
|
||||
|
||||
// The channel hint "kook" routes to the IM bridge (a specific platform), not the
|
||||
// active client.
|
||||
// 渠道提示 "kook" 路由到 IM 桥(一个具体平台),而不是
|
||||
// 活跃客户端。
|
||||
if active.calls != 0 {
|
||||
t.Fatalf("active calls = %d, want 0 (specific platform routes to IM)", active.calls)
|
||||
}
|
||||
@@ -172,8 +172,8 @@ func TestThink_ParsesStructuredDecision_EndToEnd(t *testing.T) {
|
||||
|
||||
func TestThink_NoMarkerDefaultRoute_IM(t *testing.T) {
|
||||
t.Parallel()
|
||||
// No channel marker → auto → a single IM channel (the bridge picks her choice /
|
||||
// her recent platform / the whitelist default), NOT the active web client.
|
||||
// 无渠道标记 → auto → 单个 IM 渠道(由桥挑出她的选择 /
|
||||
// 她最近的平台 / 白名单默认),而不是活跃 Web 客户端。
|
||||
conclusion := "[我决定:push]\n洗衣机洗好了,衣服可以收了"
|
||||
thinker := &mockThinker{text: conclusion}
|
||||
active := &mockActive{n: 2}
|
||||
@@ -241,8 +241,8 @@ func TestThink_ConcludedNoPush_NotPushed(t *testing.T) {
|
||||
|
||||
func TestThink_DoNotDisturbBlocksPush(t *testing.T) {
|
||||
t.Parallel()
|
||||
// She wants to push, but the user is asleep → the hard safety gate refuses,
|
||||
// regardless of her decision.
|
||||
// 她想推送,但用户正在睡觉 → 硬安全门拒绝,
|
||||
// 与她的决策无关。
|
||||
conclusion := "[我决定:push]\n想跟你说晚安"
|
||||
thinker := &mockThinker{text: conclusion}
|
||||
b, _ := newBackthink(t, Config{}, Deps{
|
||||
@@ -292,9 +292,9 @@ func TestBuildProactiveMessage_SpecificPlatform(t *testing.T) {
|
||||
|
||||
func TestPusher_SpecificPlatform_NoIM_FallsBackToActive(t *testing.T) {
|
||||
t.Parallel()
|
||||
// When a specific platform is requested but no IM sink is wired, the pusher
|
||||
// falls back to the default route so the owner still receives the message, and
|
||||
// records the requested hint.
|
||||
// 请求了具体平台但未接线 IM 槽时,推送器
|
||||
// 降级到默认路由,好让主人仍能收到消息,并
|
||||
// 记录下请求的提示。
|
||||
active := &mockActive{n: 1}
|
||||
p := newPusher(active, nil, &mockGate{allow: true}, discardLog())
|
||||
res := p.Push(context.Background(), PushRequest{
|
||||
@@ -309,9 +309,9 @@ func TestPusher_SpecificPlatform_NoIM_FallsBackToActive(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestStripInternalMarkers_CleanBody verifies the internal decision/channel
|
||||
// markers are removed from a proactive body in every shape a model may emit
|
||||
// (bracketed, full-width, bare), so a marker can never reach the user-facing text.
|
||||
// TestStripInternalMarkers_CleanBody 验证内部决策/渠道
|
||||
// 标记在模型可能发出的每种形状下(带括号、全角、裸写)
|
||||
// 都被从主动正文中移除,因此标记永远无法到达面向用户的文本。
|
||||
func TestStripInternalMarkers_CleanBody(t *testing.T) {
|
||||
t.Parallel()
|
||||
cases := []struct {
|
||||
@@ -336,9 +336,9 @@ func TestStripInternalMarkers_CleanBody(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestThink_BareMarkersStrippedFromBody is the regression for the KOOK leak: a
|
||||
// conclusion carrying bare (bracket-less) "我决定:push"/"渠道:..." markers must
|
||||
// still deliver a clean warm body, never the structured decision text.
|
||||
// TestThink_BareMarkersStrippedFromBody 是 KOOK 泄漏的回归用例:
|
||||
// 携带裸写(无括号)"我决定:push"/"渠道:..." 标记的结论仍须
|
||||
// 投递干净的温暖正文,绝不是结构化的决策文本。
|
||||
func TestThink_BareMarkersStrippedFromBody(t *testing.T) {
|
||||
t.Parallel()
|
||||
conclusion := "我决定:push\n渠道:kook\n记得喝水哦"
|
||||
|
||||
Reference in new issue
Block a user