Write a Python function to process and clean a streaming dataset before it hits our inference endpoint at Berkeley Research Group.
Implement clean_stream(records), where records is an iterable of dictionaries with id, text, and features fields. Return a list containing valid records with trimmed, lowercased IDs, trimmed text, and unchanged finite numeric features. Skip malformed records, empty values, invalid features, and duplicate IDs after normalization, keeping the first occurrence.
def clean_stream(records):