SigningLog retention/pruning — the usage-cap log grows unbounded #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
#28 (PR #34) added
SigningLog— a durable, append-only row per allowed consequential signing (sign_event/encrypt/decrypt) — as the source of truth usage caps count against. It has no retention/pruning, so on a busy key it grows without bound.Why it's deferred from #28
Caps only ever count signings within the trailing
windowSecondsof a rule, so the only rows that can ever matter are those newer than the longest active window across all policies. Everything older is dead weight (kept only for incidental audit value). #28 shipped the enforcement; pruning is orthogonal and can land separately without changing behavior.Proposed work
SigningLogrows older thanmax(windowSeconds across all PolicyRule) + margin(and a hard floor, e.g. keep ≥ 24h regardless). AsetIntervalin the daemon, or opportunistic prune on write (probabilistic, to avoid a delete per sign).windowSeconds = NULL): those count all-time, so a key with any lifetime-capped rule must not have its log pruned for that(method, kind). Either exclude keyUsers/methods covered by a lifetime cap from pruning, or keep an aggregate counter for lifetime caps specifically.@@index([keyUserId, method, createdAt])), so acreatedAt < cutoffdelete is cheap.Notes
SigningLoggrowth is bounded only by traffic. For current low-volume bunkers that's fine; revisit before any high-throughput signer.Requestephemeral-row auto-delete pattern (authorize.ts:79,setTimeoutdelete) is a precedent for opportunistic cleanup, though a batched reaper is better here.