Write pseudocode for a Kafka consumer application.
Asked in the Technical interview (live coding) stage. Implement a deterministic simulation of one consumer partition that polls records in batches, retries failed processing, and commits an offset only after successful processing.
Implement consume_messages(records, committed_offset, batch_size, max_retries). Each record is a dictionary with offset, value, and failures_before_success. Return { "processed": [...], "committed_offset": ... }. Skip records below the committed offset. Stop at the first record that still fails after all retries, without processing later records.
def consume_messages(records, committed_offset, batch_size, max_retries):