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

+7 -7
View File
@@ -5,14 +5,14 @@ import (
"time"
)
// decayFactor computes the decay multiplier for a single item: the stored
// decay_weight scaled by a time-decay that halves every recencyHalfLife days
// (design §2 衰减: 久未使用的记忆降权). A freshly touched item keeps its full
// decay_weight; an item unused for N half-lives is scaled to
// decay_weight * 0.5^N, so it ranks progressively lower unless it stays relevant.
// decayFactor 计算单条条目的衰减乘数:已存的
// decay_weight 乘以每 recencyHalfLife 天减半的时间衰减
// (design §2 衰减: 久未使用的记忆降权)。刚被触碰的条目保留完整的
// decay_weight;N 个半衰期未使用的条目被缩放到
// decay_weight * 0.5^N,因此除非持续相关,其排名会逐步下降。
//
// age is measured from UpdatedAt; a future timestamp (clock skew) is clamped to
// zero, so a just-recorded item is never scored above its base weight.
// age 自 UpdatedAt 起算;未来时间戳(时钟偏移)被夹到
// 零,因此刚记录的条目得分绝不会高于其基础权重。
func (r *Retriever) decayFactor(it MemoryItem, now time.Time) float64 {
age := now.Sub(it.UpdatedAt)
if age < 0 {