Repository navigation
Conversation
skhaz
approved these changes
Nov 17, 2026
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.
Token usage records are never deleted, so
token_usageandtoken_usage_cache_writesgrow without bound. This adds a declared retention policy, a bounded prune and a retention owner. Rollups are out of scope, and the module adds no scheduler of its own.wippy.usage:policydeclaresmeta.retention.token_usage(default"90d", 1d to 3650d) andbatch_token_usage(default 500, at most 500). An invalid or missing value fails closed with a non-retryableINVALIDerror, and nothing is deleted. Override the entry to change the window.token_usage_repo.prune(cutoff, limit)deletes at mostlimitrecords stamped at or before the cutoff, oldest first, throughidx_token_usage_timestamp. It reports whether more expired records remain and the timestamp of the oldest remaining record. It deletes thetoken_usage_cache_writesrows of the batch in the same transaction. TheON DELETE CASCADEfires on PostgreSQL, but SQLite enforces it only on databases withforeign_keys: true, and that option is off by default.wippy.usage:retentioncarriesmeta.type: kickside.retention.owner. Hosts that discover owners of that type call it on their own retention schedule. With no such host, nothing calls it. It returns{success, deleted, needs_continue, deadline_ms}.deadline_msis the time the oldest remaining record expires, and the field is absent while expired records remain. The owner runs assystem:wippy.usage.retention. Its two declared policies grantdb.geton thetarget_dbvalue, injected by the requirement, andregistry.geton the requirement and the policy. These two grants are enough when the caller's scope has no grants at all.Validation on Wippy v0.3.65a: 25 usage tests pass on SQLite and on PostgreSQL 17 with
TZ=America/New_York. That includes 10 new retention cases: default and override, invalid policies, boundary, cache writes, batch continuation, oldest timestamp, argument checks, owner protocol, and an owner call from a scope with no grants. Before the change, the suite failed to load becausewippy.usage:retention_policywas not found. With the explicit child delete removed, the SQLite cache-write cases fail (expected 0, got 2). With the declared policies removed, the no-grant owner case fails. Usage lint reports no issues, and the module manifest check passes.