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

- 只翻注释/文档字符串:820 增 / 820 删 严格 1:1;剥掉整行注释与行尾注释尾巴后,
  逐文件与 HEAD 比对「代码部分差异 = 0」;裁决/design 编号计数逐项与 HEAD 一致
- 保留可执行 SQL 样例、SQLite 报错原文、pgvector/HNSW/ANN/BLOB 等技术词原文
- 复核:go build 绿 + memory/projectindex/vector 三包测试绿;gofmt 仅剩 2 个既有未格式化文件(改动前即如此,未顺手修)
This commit is contained in:
AskaEth committed 2026-10-04 13:32:54 +08:00
1 parent eb1828ee7a
commit 61cf80d5ee
31 files changed
+820 -820

No files matched your search

+15 -15
View File
@@ -23,7 +23,7 @@ func TestStore_AddGet_正常(t *testing.T) {
s := newTestStore(t)
item := baseItem()
// Add returns the stored item with id and timestamps filled in.
// Add 返回已落库条目,id 与时间戳均已填充。
stored, err := s.Add(ctx, item)
if err != nil {
t.Fatalf("Add: %v", err)
@@ -70,7 +70,7 @@ func TestStore_Add_Defaults_正常(t *testing.T) {
ctx := context.Background()
s := newTestStore(t)
// Empty Scope/Kind/Confidence/DecayWeight normalize to their defaults.
// 空的 Scope/Kind/Confidence/DecayWeight 规范化到其默认值。
stored, err := s.Add(ctx, MemoryItem{
PersonaID: "persona.a",
Content: "我们约定每周日晚上看电影",
@@ -177,7 +177,7 @@ func TestStore_List_正常(t *testing.T) {
ctx := context.Background()
s := newTestStore(t)
// An empty store lists nothing but stays non-nil.
// 空存储列不出任何东西,但仍是非 nil。
if got, err := s.List(ctx); err != nil || got == nil || len(got) != 0 {
t.Fatalf("List() on empty store = %#v, err=%v; want empty non-nil", got, err)
}
@@ -199,7 +199,7 @@ func TestStore_List_正常(t *testing.T) {
if len(got) != 3 {
t.Fatalf("List = %d items, want 3", len(got))
}
// Newest first (created_at DESC).
// 最新的在前(created_at DESC)。
if got[0].Content != "项目记忆" {
t.Errorf("got[0].Content = %q, want the latest added (项目记忆)", got[0].Content)
}
@@ -211,21 +211,21 @@ func TestStore_List_正常(t *testing.T) {
}
}
// TestStore_List_变宽时间戳_排序 is the regression for the variable-width
// timestamp bug: time.RFC3339Nano drops trailing fractional zeros, so the older
// item was once stored as ":05.83" and the newer as ":05.8309789", and the text
// comparison SQLite applies to these columns ranked the older one as newer.
// TestStore_List_变宽时间戳_排序 是变宽时间戳缺陷的回归:
// time.RFC3339Nano 会丢弃末尾小数零,因此较旧的条目
// 曾被存成 ":05.83"、较新的存成 ":05.8309789",而 SQLite 对这些列
// 施加的文本比较把较旧的判成更新的。
func TestStore_List_变宽时间戳_排序(t *testing.T) {
t.Parallel()
ctx := context.Background()
s := newTestStore(t)
sec := time.Date(2026, 9, 7, 3, 20, 5, 0, time.UTC)
older := sec.Add(830 * time.Millisecond) // ":05.83" under RFC3339Nano
newer := older.Add(978900 * time.Nanosecond) // ":05.8309789" under RFC3339Nano
older := sec.Add(830 * time.Millisecond) // RFC3339Nano 下的 ":05.83"
newer := older.Add(978900 * time.Nanosecond) // RFC3339Nano 下的 ":05.8309789"
// The newer item is inserted first, so a rowid-only tiebreak would surface
// the older one: only correctly ordered created_at text yields 较晚 first.
// 较新的条目先插入,因此只按 rowid 打破并列会把较旧的
// 抬到前面:只有正确排序的 created_at 文本才会让较晚的在前。
for _, in := range []struct {
content string
at time.Time
@@ -260,9 +260,9 @@ func TestStore_List_变宽时间戳_排序(t *testing.T) {
}
}
// TestStore_List_同一时间戳_插入序 covers the tie case: the host clock is coarse
// enough that three consecutive Adds can share one timestamp, so ordering must
// fall back to rowid rather than an arbitrary row order.
// TestStore_List_同一时间戳_插入序 覆盖并列情形:宿主时钟
// 精度足够粗,三次连续的 Add 可能共享同一时间戳,因此排序必须
// 回退到 rowid,而不是任意行序。
func TestStore_List_同一时间戳_插入序(t *testing.T) {
t.Parallel()
ctx := context.Background()