fix(memory): R6 容量壓力真的會清,而且不清承諾與今天的紀錄(v0.0.7 同批)
實際踩到的 bug:短期記憶連睡兩次都停在 70 筆、111 組候選,`prune-short-term` 每次都回報 ok 卻一筆都沒清掉。 原因:`pruneShortTerm()` 只有兩道——超過 14 天、超過硬上限 240 筆。但提示固化的門檻 (`CONSOLIDATE_THRESHOLD`)是 40 筆,中間那 200 筆沒有任何機制會動它。R6 在 `candidates` 裡被列為「依顯著度清出空間」,但那個清除動作**從來沒有實作**。 修法:加一道軟上限(`SHORT_TERM_SOFT_CAP`=120),超過就從顯著度最低、最舊的開始裁。 兩個保護,因為「沒經過判斷就把今天清掉」是這裡最不能犯的錯: - 顯著度 ≥ 80 或 `intent=commit`(承諾與界線都在這一層)→ 一則都不清 - 24 小時內的新紀錄 → 一則都不清(還沒機會被固化) 順帶:`pruneShortTermDetail()` 回傳清了幾筆、為什麼清、保護了幾筆,`sleep` 的 `run()` 會把細節帶進回報——**不做無聲的裁切**。 測試:302 項全過(新增 5 項:軟上限會清、承諾不清、今天的不清、清的是顯著度最低的、 回報帶細節)。文件同步:README 的 R6 與目錄樹、persona-memory 的 R6。 版本:與 PR #10 同一批未合併的改動,維持 0.0.7。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-3
@@ -483,8 +483,9 @@ commands.sleep = async ({ flags }) => {
|
||||
const steps = [];
|
||||
const run = async (step, fn) => {
|
||||
try {
|
||||
await fn();
|
||||
steps.push({ step, ok: true });
|
||||
const detail = await fn();
|
||||
// 有細節就帶回去(例如裁掉幾筆短期記憶)——不做無聲的裁切
|
||||
steps.push(detail && typeof detail === "object" ? { step, ok: true, detail } : { step, ok: true });
|
||||
} catch (err) {
|
||||
// 一步壞掉不放棄整個睡眠:記下來繼續走,最後在報告裡說明。
|
||||
steps.push({ step, ok: false, error: String(err.message || err).slice(0, 300) });
|
||||
@@ -501,7 +502,8 @@ commands.sleep = async ({ flags }) => {
|
||||
for (const name of seen) pl.stampContact(slug, name);
|
||||
pl.renderRelations(slug);
|
||||
});
|
||||
await run("prune-short-term", () => pl.pruneShortTerm(slug));
|
||||
// 不做無聲的裁切:清掉幾筆、為什麼清、保護了幾筆,都要寫進回報
|
||||
await run("prune-short-term", () => pl.pruneShortTermDetail(slug));
|
||||
await run("archive-threads", () => pl.archiveStaleThreads(slug));
|
||||
await run("emotion-decay", () => {
|
||||
const state = pl.decayEmotionBy(pl.loadEmotion(slug), pl.SLEEP_DECAY_MINUTES);
|
||||
|
||||
Reference in New Issue
Block a user