TencentDB-Agent-Memory icon indicating copy to clipboard operation
TencentDB-Agent-Memory copied to clipboard

[Bug] capture.l0l1RetentionDays=1 never cleans: cutoff sanity check rejects every run

Open indexGin opened this issue 3 weeks ago • 0 comments

OpenClaw Version | OpenClaw 版本

N/A — self-hosted plugin

Plugin Version | 插件版本

feat/server_team @ 8a47837 (MemoryCore 1.0.2-beta.1)

Operating System | 操作系统

Linux (platform-independent)

Describe the bug | 问题描述

capture.l0l1RetentionDays = 1 never cleans anything, even with capture.allowAggressiveCleanup = true (the documented combination for 1–2 day retention, see MemoryCore/SKILL.md).

LocalMemoryCleaner.runOnce() computes the retention cutoff as local midnight of today - (retentionDays - 1) days, i.e. today 00:00 when retentionDays = 1. computeCutoffMsByLocalDay() then requires the gap between "now" and the cutoff to be at least 24 hours:

// Sanity check: gap between now and cutoff must be at least 24h
const MIN_GAP_MS = 24 * 60 * 60 * 1000;
if (nowMs - cutoffMs < MIN_GAP_MS) {
  throw new Error(`cutoff sanity failed: gap ... < 24h, ... possible clock skew`);
}

For a one-day window that gap is just the elapsed part of the current day, so it is always below 24h. Every scheduled run throws, logs an error, and returns before scanning or deleting any shard. The configuration is accepted by parseConfig() and documented as supported, but cleanup is silently disabled at runtime.

To Reproduce | 复现步骤

  1. Configure:
    { "capture": { "l0l1RetentionDays": 1, "allowAggressiveCleanup": true, "cleanTime": "03:00" } }
    
  2. Under the data dir, create conversations/2026-11-08.jsonl and conversations/2026-11-09.jsonl.
  3. On 2026-11-09 at any time before midnight, trigger the cleaner (LocalMemoryCleaner.runOnce() or wait for cleanTime).
  4. 2026-11-08.jsonl is still present and the run logs: [memory-tdai][cleaner] cutoff sanity failed: gap 43200000ms < 24h, retentionDays=1, possible clock skew

Expected behavior | 预期行为

With retentionDays = 1, shards older than today are removed and today's shard is kept. The clock-skew sanity check should scale with the configured window instead of hard-coding a 24h minimum.

Error Logs / Screenshots | 报错日志/截图

[memory-tdai][cleaner] cutoff sanity failed: gap 43200000ms < 24h, retentionDays=1, possible clock skew

Additional context | 补充信息

retentionDays >= 2 is unaffected: the cutoff is at least one day in the past, so the existing 24h check still holds.

indexGin avatar Nov 09 '26 13:11 indexGin