fix(retention): page through all expired records, remove 10k cap (#102) - #165
Merged
Conversation
6 tasks
RetentionEngine.find_expired() called trail.query(end=cutoff, limit=10000), silently dropping every expired record past the 10,000th. A retention run on a large trail would report success while leaving thousands of records that should have been purged — a compliance gap for EU AI Act Art. 12 archival requirements. The fix pages with trail.query(end=cutoff, limit=batch, offset=offset) until a short page signals the end of results. _QUERY_BATCH_SIZE is a class attribute (not a hardcoded literal) so tests can set it to 2 and exercise the multi-batch path without needing 10k rows. Closes #102
rajfirke
force-pushed
the
fix/102-retention-pagination
branch
from
September 3, 2026 18:27
faa3ea4 to
d6d39cb
Compare
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 does this PR do?
RetentionEngine.find_expired()calledtrail.query(end=cutoff, limit=10000)— a single fixed-size query. Any trail with more than 10,000 expired records would silently drop the remainder:preview()under-counted, andexecute()left those records undeleted while reporting success. For a compliance retention engine enforcing EU AI Act Art. 12 archival requirements, this is unacceptable.Fix: Page through the full result set using
offset:_QUERY_BATCH_SIZE = 10000is a class attribute instead of a hardcoded literal so tests can shrink it to 2 and exercise the multi-batch path without inserting 10k rows.Two new regression tests verify that
find_expired()andexecute()correctly handle a trail whose expired record count exceeds one batch.Checklist
ruff check src/ tests/passesruff format --check src/ tests/passesmypy src/provena/passespytestpasses with no failuresRelated Issues
Closes #102