package postgres import ( "context" "github.com/jackc/pgx/v5" ) // ExpireStaging atomically fences replay and returns old terminal sources in bounded batches. func (s *Store) ExpireStaging(ctx context.Context) ([]string, error) { ctx, cancel := context.WithTimeout(ctx, s.timeout) defer cancel() rows, err := s.pool.Query(ctx, `WITH candidates AS ( SELECT a.id FROM attachments a WHERE a.status IN ('ready','failed') AND a.updated_at