mirror of
https://github.com/block/buzz.git
synced 2026-10-31 14:31:02 +00:00
Add the opportunistic prune worker for the local archive DB: it deletes kind-24200 observer-frame scope rows whose archived_at is older than observer_retention_days, cascading orphan GC to both derived indexes, and keeps every other kind forever. Triggers are startup + post-commit, detached from the archive write and collapsed by an in-process single-flight flag plus a >=24h archive_meta.prune_last_success_at gate into at most one scan per day. Candidate scope keys are materialized and fixed per batch transaction; the candidate-scoped GC cascades observer_channel_index (which the whole-scan GC does not cover) and agent_metric_index. The observer-index insert becomes a conditional INSERT ... SELECT so a stale backfill callback cannot resurrect an index row for a pruned event. The prune-candidate SQL constant is colocated with the worker so the EXPLAIN-shape test pins the shipped query. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>