Repository navigation
feat(memory): an end user's retention sweep deletes what is older than their retention_days (PRD-274 Wave 3) - #1488
Merged
Merged
Conversation
…n their retention_days (PRD-274 Wave 3) services/end_user_retention.sweep_end_user_retention, for every end user with retention_days and no erase started: - their facts made before the cutoff (DurableMemoryStore.prune_older_than, read in pages straight from the store, so retired facts go too); - their messages sent before it, in their own conversations, and then each of their conversations left empty that was itself opened before it. Running it twice deletes nothing more; one end user that fails is logged and counted, and the rest are swept. Nothing schedules it yet (the next PR). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Dave Arthur <davidarthur@hotmail.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
Contributor
Pre-merge checks:
|
10 of 14 tasks
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.
What and why
PRD-274 §5.5 says retention is set per end user, and #1479's consent record carries
retention_days: "Days their memories are kept; none: until erased". Until now nothing enforced it. This is the first of two stacked PRs:Nothing calls the sweep until PR 2, so this PR changes no behaviour on its own.
services/end_user_retention.sweep_end_user_retentiondeletes, for every end user withretention_daysand no erase started:DurableMemoryStore.prune_older_than(namespace, cutoff)reads their one namespace in pages straight from Qdrant and deletes the old points by id._scroll's decorators) leaves an old fact behind, retired ones included.created_athas only a keyword index, so the age is checked in Python, as the archival job does. A fact with no readablecreated_atis kept.chats.end_user_id, feat(chat): a server key's chat turn for one of its end users (PRD-274 Wave 3) #1486).Its behaviour:
MEMORY_SESSION_TTL_SECONDS.For Gerard to confirm (PR 2 records it as PRD-274 decision 22): retention covers their conversations as well as their facts.
retention_dayssays "memories", but their messages are their own words too.How it was verified
tests/test_afp_w3_end_user_retention.py(3 tests; real database, with a stand-in durable store for the sweep and a stand-in Qdrant client for the prune):Z-suffixed, and keeps a recent one, an undated one and an unreadable one, all within the one namespace.Without the change, the test file can't import the new module.
Every test file touching the durable store, end users or retention passes: 32 files, 489 tests.
The code shape check has no errors,
lint-importsis clean, and ruff is clean.Tests added or updated, and they fail without this change
CI green (a lane marked non-required counts too)
Both editions considered: local (
AUTH_EDITION=local) and hosted (the same code; with no durable store configured the prune deletes nothing)UI change: screenshots below (none)
AI assistance
Checklist (AGENTS.md)
git commit -s)orchestrator/config.py; no hardcoded valuesV2copies)create_all-built database, head pins moved (none)orchestrator/reports/route-manifest.json(none)🤖 Generated with Claude Code