docs(comments): 注释中文化 · internal/runtime/history(15 文件,纯替换)
- 只翻注释/文档字符串:剥离注释后代码行逐字节不变(机械校验只剩 4 条行尾注释的翻译,代码前缀全等) - 交叉引用(design/16 §4.6、D4/B3、0010 迁移文件名)逐字保留 - 保留未译技术词:DDL/rowid/LIKE/LEFT JOIN/DTO/rune/WS/actor 及全部标识符与表名 - 顺带副作用:store.go、session_persona_test.go 由注释文字改变而变得 gofmt 干净(未运行 gofmt -w)
This commit is contained in:
1 parent
b0fbb8bc0d
commit
09fba77f87
15 files changed
+430
-516
No files matched your search
@@ -6,8 +6,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// personaOf returns the stored role binding of a session, failing the test when the
|
||||
// session is absent from the list.
|
||||
// personaOf 返回某个会话已存储的角色绑定,会话不在列表中时使测试失败。
|
||||
func personaOf(t *testing.T, st *Store, id string) string {
|
||||
t.Helper()
|
||||
sessions, err := st.ListSessions(context.Background())
|
||||
@@ -23,11 +22,10 @@ func personaOf(t *testing.T, st *Store, id string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// TestSessionPersonaRoundTrip is design/22 acceptance 1: the session-level role is
|
||||
// the single source of truth, so a value written through SetSessionPersona must come
|
||||
// back from both the direct read and the list projection (the DTO the client gets),
|
||||
// and the main session — which always exists — starts out unbound ('' = inherit the
|
||||
// global default). An explicit "" clears the binding back to that same state.
|
||||
// TestSessionPersonaRoundTrip 是 design/22 验收 1:会话级角色是唯一事实来源,
|
||||
// 因此通过 SetSessionPersona 写入的值必须能从直接读取与列表投影(客户端拿到的
|
||||
// DTO)两条路径读回,而始终存在的主会话初始为未绑定(空 = 继承全局默认)。
|
||||
// 显式空串会把绑定清回同一状态。
|
||||
func TestSessionPersonaRoundTrip(t *testing.T) {
|
||||
t.Parallel()
|
||||
st := newStore(t)
|
||||
@@ -52,8 +50,7 @@ func TestSessionPersonaRoundTrip(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// An explicit empty value is the documented "unbind" (follow the default again),
|
||||
// not a no-op.
|
||||
// 显式空值是文档化的「解绑」(重新跟随默认),不是空操作。
|
||||
if err := st.SetSessionPersona(ctx, MainSessionID, ""); err != nil {
|
||||
t.Fatalf("SetSessionPersona(\"\"): %v", err)
|
||||
}
|
||||
@@ -62,9 +59,9 @@ func TestSessionPersonaRoundTrip(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSessionPersonaUnknownSession covers the error contract: binding or reading the
|
||||
// role of a session that does not exist reports ErrSessionNotFound (so the HTTP layer
|
||||
// answers 404) instead of silently creating/looking up nothing.
|
||||
// TestSessionPersonaUnknownSession 覆盖错误契约:绑定或读取一个不存在的会话的
|
||||
// 角色会报 ErrSessionNotFound(因此 HTTP 层回答 404),而不是悄悄创建/查不到
|
||||
// 任何东西。
|
||||
func TestSessionPersonaUnknownSession(t *testing.T) {
|
||||
t.Parallel()
|
||||
st := newStore(t)
|
||||
@@ -78,10 +75,9 @@ func TestSessionPersonaUnknownSession(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestNewSubSessionForBindsPersona locks the create path: a sub session created with a
|
||||
// role carries it from its first read (no extra PATCH needed), and the plain
|
||||
// NewSubSession still creates an unbound session — the pre-multi-character contract,
|
||||
// which every existing caller relies on.
|
||||
// TestNewSubSessionForBindsPersona 锁定创建路径:带角色创建的子会话从第一次读取
|
||||
// 起就携带它(无需额外 PATCH),而朴素的 NewSubSession 仍创建未绑定会话 —— 即
|
||||
// 多角色之前的契约,每个既有调用方都依赖它。
|
||||
func TestNewSubSessionForBindsPersona(t *testing.T) {
|
||||
t.Parallel()
|
||||
st := newStore(t)
|
||||
@@ -104,11 +100,10 @@ func TestNewSubSessionForBindsPersona(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestMessagePersonaPersisted proves design/22 §7-5's storage half: a session may
|
||||
// switch roles while keeping its context, so every message records the role that
|
||||
// SPOKE it. The column survives the write/read round trip through the same scanner
|
||||
// the REST/WS DTOs use, and messages written without a role stay '' (= the default
|
||||
// role), which is what keeps pre-upgrade history readable.
|
||||
// TestMessagePersonaPersisted 证明 design/22 §7-5 的存储一半:一个会话可以在保留
|
||||
// 上下文的同时切换角色,因此每条消息都记录说出它的那个角色。该列通过 REST/WS
|
||||
// DTO 使用的同一个扫描器活过写入/读取往返,而未指定角色写入的消息保持为空
|
||||
// (= 默认角色),这正是升级前历史仍可读的原因。
|
||||
func TestMessagePersonaPersisted(t *testing.T) {
|
||||
t.Parallel()
|
||||
st := newStore(t)
|
||||
@@ -139,8 +134,8 @@ func TestMessagePersonaPersisted(t *testing.T) {
|
||||
t.Fatalf("unattributed message persona_id = %q, want ''", got)
|
||||
}
|
||||
|
||||
// The persona column must also survive Recent (the WS replay path) and
|
||||
// AppendFull (the orchestrator's realtime-sync path).
|
||||
// persona 列还必须活过 Recent(WS 回放路径)与 AppendFull(编排器的实时
|
||||
// 同步路径)。
|
||||
recent, err := st.Recent(ctx, MainSessionID, 10)
|
||||
if err != nil {
|
||||
t.Fatalf("recent: %v", err)
|
||||
|
||||
Reference in new issue
Block a user