-- Keep a mission's events past the global retention window. -- -- `mission_gc` deletes mission_events older than EVENT_RETENTION_DAYS (7). That -- bound is right for volume — a single busy coding phase adds hundreds of rows -- — and wrong for anything that needs to be re-read later: a Skill-Use -- measurement, a provenance question, an incident review. All three ask about a -- specific mission, so the exemption is per-mission rather than a raised global. -- -- NULL (the default) means the mission obeys the global window, so this changes -- nothing for existing rows. ALTER TABLE missions ADD COLUMN IF NOT EXISTS retain_events_until TIMESTAMPTZ; COMMENT ON COLUMN missions.retain_events_until IS 'While in the future, mission_gc will not reap this mission''s events. Set when a mission is under measurement or investigation.'; -- The sweep joins on this, and the vast majority of rows are NULL. CREATE INDEX IF NOT EXISTS missions_retain_events_idx ON missions (retain_events_until) WHERE retain_events_until IS NOT NULL;