docs(comments): 注释中文化 · internal/services/channelbridge(纯替换)
- 只翻注释/文档字符串:剥掉注释后代码行逐字节不变(机械校验只剩允许的行尾注释形态) - 术语对齐既有译法(owner→主人、persona→角色、engage→参与度判定、quiet hours→安静时段、backoff→退避) - 复核:go build 绿 + channelbridge 包测试绿;gofmt 干净
This commit is contained in:
1 parent
61cf80d5ee
commit
093f38d986
28 files changed
+1089
-1089
No files matched your search
@@ -43,10 +43,10 @@ func groupOwnerMsg(i int) adapter.UnifiedMessage {
|
||||
return m
|
||||
}
|
||||
|
||||
// TestFlowGate_RateLimitDropsNonOwnerAndAudits verifies the gate is wired into the
|
||||
// ingress (onMessage) and that a rate-limited non-owner message is dropped with the
|
||||
// reason surfaced through the OnRejected audit hook. The dropped path is synchronous
|
||||
// (no worker goroutine is spawned), so the assertion is deterministic.
|
||||
// TestFlowGate_RateLimitDropsNonOwnerAndAudits 验证闸门已接入
|
||||
// 入口(onMessage),且被限流的非主人消息会被丢弃并经
|
||||
// OnRejected 审计钩子暴露原因。丢弃路径是同步的
|
||||
// (不会派生工作 goroutine),因此断言是确定性的。
|
||||
func TestFlowGate_RateLimitDropsNonOwnerAndAudits(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -63,8 +63,8 @@ func TestFlowGate_RateLimitDropsNonOwnerAndAudits(t *testing.T) {
|
||||
ad := &fakeAdapter{name: "kook", cfg: map[string]any{"bot_token": "x", "msgPerMin": 1}}
|
||||
b.Add(ad)
|
||||
|
||||
// First message is admitted (async worker), only auditing the second, which the
|
||||
// total per-minute cap refuses.
|
||||
// 第一条消息被放行(异步工作项),只对第二条入审计,
|
||||
// 它被每分钟总量上限拒绝。
|
||||
b.onMessage(context.Background(), groupSender(0), ad)
|
||||
b.onMessage(context.Background(), groupSender(1), ad)
|
||||
|
||||
@@ -73,9 +73,9 @@ func TestFlowGate_RateLimitDropsNonOwnerAndAudits(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestFlowGate_OwnerPrivateBypassesGate verifies owner messages bypass the flow gate
|
||||
// entirely: even with an aggressive rate limit, an owner message is never dropped as
|
||||
// rate_limited / review_pruned / capped.
|
||||
// TestFlowGate_OwnerPrivateBypassesGate 验证主人消息完全绕过流控
|
||||
// 闸门:即使限流很激进,主人消息也绝不会以
|
||||
// rate_limited / review_pruned / capped 被丢弃。
|
||||
func TestFlowGate_OwnerPrivateBypassesGate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -92,8 +92,8 @@ func TestFlowGate_OwnerPrivateBypassesGate(t *testing.T) {
|
||||
ad := &fakeAdapter{name: "kook", cfg: map[string]any{"bot_token": "x", "groupMsgPerMin": 1, "maxMessages": 1}}
|
||||
b.Add(ad)
|
||||
|
||||
// Three owner messages: if the gate applied, the 2nd and 3rd would be rate
|
||||
// limited / capped and reach OnRejected. Owner bypass leaves the audit empty.
|
||||
// 三条主人消息:若闸门生效,第 2、3 条会被限流
|
||||
// / 触及上限并到达 OnRejected。主人绕过则审计为空。
|
||||
for i := 0; i < 3; i++ {
|
||||
b.onMessage(context.Background(), groupOwnerMsg(i), ad)
|
||||
}
|
||||
@@ -102,9 +102,9 @@ func TestFlowGate_OwnerPrivateBypassesGate(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestFlowGate_GateOptionsDefaults pins the config-to-limit resolution that keeps
|
||||
// old CHANNELS_JSON accounts backward compatible: absent key → off, 0 → protective
|
||||
// default, negative → off, positive → pinned.
|
||||
// TestFlowGate_GateOptionsDefaults 钉住「配置→限制」的解析规则,
|
||||
// 它保证旧的 CHANNELS_JSON 账号向后兼容:键缺失 → 关闭,0 → 保护性
|
||||
// 默认值,负值 → 关闭,正值 → 固定为该值。
|
||||
func TestFlowGate_GateOptionsDefaults(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -139,7 +139,7 @@ func TestFlowGate_GateOptionsDefaults(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// mockLLM is a model.Adapter stub returning a fixed completion.
|
||||
// mockLLM 是返回固定补全的 model.Adapter 桩。
|
||||
type mockLLM struct {
|
||||
content string
|
||||
err error
|
||||
@@ -156,8 +156,8 @@ func (m *mockLLM) ChatStream(_ context.Context, _ model.Request, _ func(model.St
|
||||
return model.Response{}, nil
|
||||
}
|
||||
|
||||
// TestNewLLMReviewer verifies the review model is wrapped into a Reviewer that asks
|
||||
// the LLM which queued messages to keep and filters the returned indices.
|
||||
// TestNewLLMReviewer 验证审查模型被包装成 Reviewer:向
|
||||
// LLM 询问哪些队列消息该保留,并过滤返回的索引。
|
||||
func TestNewLLMReviewer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -173,7 +173,7 @@ func TestNewLLMReviewer(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("review: %v", err)
|
||||
}
|
||||
// Out-of-range index 99 and the duplicate 0 are dropped; keep = [0,1].
|
||||
// 越界索引 99 与重复的 0 被丢弃;保留 = [0,1]。
|
||||
if len(keep) != 2 || keep[0] != 0 || keep[1] != 1 {
|
||||
t.Fatalf("keep = %v, want [0 1]", keep)
|
||||
}
|
||||
@@ -183,8 +183,8 @@ func TestNewLLMReviewer(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewLLMReviewerError verifies a review-model failure is surfaced to the gate,
|
||||
// which then falls back to FIFO eviction rather than fabricating a success.
|
||||
// TestNewLLMReviewerError 验证审查模型失败会暴露给闸门,
|
||||
// 闸门随后回退为 FIFO 淘汰,而不是伪造一个成功。
|
||||
func TestNewLLMReviewerError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in new issue
Block a user