docs(comments): 注释中文化 · internal/services/channelbridge(纯替换)
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- 只翻注释/文档字符串:剥掉注释后代码行逐字节不变(机械校验只剩允许的行尾注释形态)
- 术语对齐既有译法(owner→主人、persona→角色、engage→参与度判定、quiet hours→安静时段、backoff→退避)
- 复核:go build 绿 + channelbridge 包测试绿;gofmt 干净
This commit is contained in:
AskaEth committed 2026-10-04 13:33:06 +08:00
1 parent 61cf80d5ee
commit 093f38d986
28 files changed
+1089 -1089

No files matched your search

+20 -20
View File
@@ -6,22 +6,22 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
)
// This file builds the conversation-origin context injected as a SYSTEM message so
// the model can see which platform and conversation a message came from, WITHOUT
// polluting the user's free-text channel (design/16 §4.6.1). Origin is metadata, so
// it is carried as a system context line and the per-message sender is carried as the
// structured model.Message.SenderName field — never as a natural-language tag
// concatenated into the user text, which would be both ambiguous and a prompt-injection
// surface (a malicious member could forge tags that look like system markup).
// 本文件构建会话来源上下文,以 SYSTEM 消息注入,
// 让模型能看到消息来自哪个平台、哪个会话,同时不污染
// 用户的自由文本通道(design/16 §4.6.1)。来源属于元数据,因此
// 它由一行系统上下文承载,而每条消息的发送者由
// 结构化的 model.Message.SenderName 字段承载——绝不做成
// 拼进用户文本的自然语言标签,那样既含糊,又构成提示词注入
// 面(恶意群成员可以伪造看似系统标记的标签)。
//
// Identity and permission are still decided structurally by the session/actor layer
// (a project red line); this line only decorates the context and tells the model to
// trust structure over anything in the message body.
// 身份与权限仍由会话/actor 层结构化判定
// (项目红线);这一行只装饰上下文,并告知模型
// 要相信结构,而非消息正文里的任何内容。
// originSystemText returns a system context line describing the conversation origin
// (platform + group/private) and the identity-trust rule, or "" for a pure Web main
// session message (left undecorated to avoid noise). The conversation is constant for
// a session, so the line is injected once per turn, not once per message.
// originSystemText 返回描述会话来源的系统上下文行
// (平台 + 群聊/私聊)与身份信任规则;纯 Web 主会话消息返回 ""
// (不加装饰以免噪声)。会话在一次会话内是恒定的,
// 因此该行每轮注入一次,而不是每条消息注入一次。
func originSystemText(msg adapter.UnifiedMessage, actor adapter.Actor) string {
platform := msg.Platform
if platform == "" || platform == "web" {
@@ -34,9 +34,9 @@ func originSystemText(msg adapter.UnifiedMessage, actor adapter.Actor) string {
)
}
// originConvo names the conversation in the origin line: a group becomes
// "群「名称」" (or "群#<id>"), and a private chat becomes "私聊". The owner's private
// chat is left "私聊" without a name (the owner is never labeled, design/16 §4.6).
// originConvo 在来源行里为会话命名:群聊成为
// "群「名称」"(或 "群#<id>"),私聊则成为 "私聊"。主人的私聊
// 保持 "私聊" 不带名称(主人从不被标注,design/16 §4.6)。
func originConvo(msg adapter.UnifiedMessage, actor adapter.Actor) string {
if msg.IsGroup() {
return groupLabel(msg)
@@ -44,9 +44,9 @@ func originConvo(msg adapter.UnifiedMessage, actor adapter.Actor) string {
return "私聊"
}
// groupLabel builds the "群「名称」" / "群#<id>" label for a group conversation. A named
// group carries its display name; an unnamed one falls back to the group id and then
// the channel id (a GROUP-BROADCAST channel is identified by its channel id).
// groupLabel 为群聊构建 "群「名称」" / "群#<id>" 标签。有名称的
// 群带显示名称;无名称的依次回退到群 id、再到
// 渠道 id(GROUP-BROADCAST 渠道以其渠道 id 标识)。
func groupLabel(msg adapter.UnifiedMessage) string {
if msg.GroupName != "" {
return "群「" + msg.GroupName + "」"