feat(memory): always-on daily personal-memory retention schedule#79
Merged
Conversation
Personal-memory decay and cleanup previously ran only via manual REST calls or user-enabled triggers — there was no default daily enforcement, unlike the Claw runtime which already trims its own tables daily. Add services/memory/retention.ts: a daily setInterval (mirroring the ClawManager retention pattern) that runs MemoryService.decayMemories + cleanupMemories for the default owner. Pure hygiene — no LLM, no conversation extraction, no semantic consolidation — so it runs by default while the LLM-driven memory_extract / memory_consolidate triggers stay opt-in. Cadence split: cleanup (idempotent DELETE of importance<0.1, >90d old, unaccessed 90d) runs on boot AND daily; the compounding decay step (importance *= 0.9) runs ONLY on the daily tick, so it stays independent of restart frequency. Timer is unref()'d so it never holds the process open. Wired into server.ts startup (after Autonomy Engine) and shutdown. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Personal-memory decay and cleanup previously ran only via manual REST calls or user-enabled triggers — there was no default daily enforcement, unlike the Claw runtime which already trims its own tables daily. This closes that asymmetry.
Adds
packages/gateway/src/services/memory/retention.ts: a dailysetInterval(mirroring theClawManagerretention pattern) that runsMemoryService.decayMemories()+cleanupMemories()for the default owner.It's pure hygiene — no LLM, no conversation extraction, no semantic consolidation — so it runs by default, while the LLM-driven
memory_extract/memory_consolidatetriggers stay opt-in (privacy-first).Cadence (the key correctness detail)
cleanupis an idempotentDELETE(only removes entries withimportance < 0.1AND older than 90d AND not accessed in 90d) → runs on boot AND daily, so short-lived / frequently-restarted processes still get bounded storage.decayis a compoundingUPDATE importance = importance * 0.9→ runs only on the daily interval tick, never on the boot pass. This bounds decay to once per 24h of continuous uptime and keeps it independent of restart frequency (a dev process restarting 20×/day must not decay a memory 20×).unref()'d so it never holds the process open (matchesClawManager).Wired into
server.tsstartup (after the Autonomy Engine) and shutdown (stopMemoryRetention()before the memory-service reset).Test plan
services/memory/retention.test.ts— 9 tests: default vs{decay:false}pass, error isolation (decay throw still cleans; cleanup throw never propagates), boot-pass cleanup-only, daily-tick full pass, start idempotency, stop idempotency/teardown.pnpm --filter @ownpilot/gateway typecheckclean🤖 Generated with Claude Code