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

+14 -14
View File
@@ -9,8 +9,8 @@ import (
"git.yeij.top/AskaEth/Cyrene_v2/internal/db"
)
// newTestDB opens an isolated in-memory SQLite DB for tests that must inspect
// the raw stored timestamp text.
// newTestDB 为需要查看原始落库时间戳文本的测试打开一个隔离的
// 内存 SQLite 库。
func newTestDB(t *testing.T) *sql.DB {
t.Helper()
ctx := context.Background()
@@ -22,8 +22,8 @@ func newTestDB(t *testing.T) *sql.DB {
return d
}
// insertLegacyItemSQL writes a memory_items row with caller-supplied raw
// timestamps, standing in for a row persisted before the fixed-width layout.
// insertLegacyItemSQL 用调用方给定的原始时间戳写入一行 memory_items,
// 代表定宽布局之前持久化的行。
const insertLegacyItemSQL = `INSERT INTO memory_items
(id, persona_id, role_id, project_id, scope, kind, content, tags, confidence,
source_conversation, created_at, updated_at, decay_weight)
@@ -58,16 +58,16 @@ func TestFormatTime_定宽_正常(t *testing.T) {
func TestFormatTime_非UTC_正常(t *testing.T) {
t.Parallel()
zone := time.FixedZone("UTC+8", 8*60*60)
// 11:20:05.830+08:00 is 03:20:05.830Z, so the stored text is UTC.
// 11:20:05.830+08:00 即 03:20:05.830Z,因此落库文本是 UTC。
at := time.Date(2026, 9, 7, 11, 20, 5, 830000000, zone)
if got, want := formatTime(at), "2026-09-07T03:20:05.830000000Z"; got != want {
t.Errorf("formatTime = %q, want %q", got, want)
}
}
// TestNewStore_归一化历史时间戳_正常 writes a legacy variable-width row directly,
// re-opens the store to trigger normalization, and checks both the repaired text
// and its idempotence on a further open.
// TestNewStore_归一化历史时间戳_正常 直接写入一行旧的变宽数据,
// 重新打开存储触发规范化,并检查修复后的文本
// 以及再次打开时的幂等性。
func TestNewStore_归一化历史时间戳_正常(t *testing.T) {
t.Parallel()
ctx := context.Background()
@@ -77,8 +77,8 @@ func TestNewStore_归一化历史时间戳_正常(t *testing.T) {
t.Fatalf("NewStore: %v", err)
}
// RFC3339Nano drops the trailing fractional zeros, so this legacy value is
// only 23 bytes wide and loses the text-ordering guarantee.
// RFC3339Nano 丢弃末尾小数零,因此这个遗留值
// 只有 23 字节宽,失去了文本排序保证。
const legacy = "2026-09-07T03:20:05.83Z"
if _, err := d.ExecContext(ctx, insertLegacyItemSQL, "legacy", legacy, legacy); err != nil {
t.Fatalf("insert legacy row: %v", err)
@@ -106,8 +106,8 @@ func TestNewStore_归一化历史时间戳_正常(t *testing.T) {
t.Errorf("timestamps = %v/%v, want %v", got.CreatedAt, got.UpdatedAt, wantTime)
}
// A further open must be a no-op: the length condition selects nothing once
// the row is fixed width.
// 再次打开必须是空操作:行变为定宽后,
// 长度条件不会选中任何东西。
if _, err := NewStore(ctx, d, testLogger()); err != nil {
t.Fatalf("NewStore (second pass): %v", err)
}
@@ -121,8 +121,8 @@ func TestNewStore_归一化历史时间戳_正常(t *testing.T) {
}
}
// TestNewStore_无法解析的时间戳_跳过 pins the "leave it alone" rule: one bad legacy
// value must not keep the store from opening, and must not be rewritten.
// TestNewStore_无法解析的时间戳_跳过 钉住「原样保留」规则:一个坏的
// 遗留值既不该妨碍存储打开,也不该被重写。
func TestNewStore_无法解析的时间戳_跳过(t *testing.T) {
t.Parallel()
ctx := context.Background()