Skip to content

feat(memory): always-on daily personal-memory retention schedule#79

Merged
ersinkoc merged 1 commit into
mainfrom
feat/memory-retention-default-schedule
Jun 5, 2026
Merged

feat(memory): always-on daily personal-memory retention schedule#79
ersinkoc merged 1 commit into
mainfrom
feat/memory-retention-default-schedule

Conversation

@ersinkoc
Copy link
Copy Markdown
Collaborator

@ersinkoc ersinkoc commented Jun 5, 2026

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 daily setInterval (mirroring the ClawManager retention pattern) that runs MemoryService.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_consolidate triggers stay opt-in (privacy-first).

Cadence (the key correctness detail)

  • cleanup is an idempotent DELETE (only removes entries with importance < 0.1 AND older than 90d AND not accessed in 90d) → runs on boot AND daily, so short-lived / frequently-restarted processes still get bounded storage.
  • decay is a compounding UPDATE 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×).
  • Timer is unref()'d so it never holds the process open (matches ClawManager).

Wired into server.ts startup (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.
  • ✅ 9/9 pass, suite type-check clean
  • pnpm --filter @ownpilot/gateway typecheck clean
  • ✅ ESLint clean on changed files

🤖 Generated with Claude Code

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>
@ersinkoc ersinkoc merged commit 3e9c869 into main Jun 5, 2026
2 checks passed
@ersinkoc ersinkoc deleted the feat/memory-retention-default-schedule branch June 5, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant