Replaced time-based automatic offset commits with manual commits tied to successful batch writes, tracking the highest offset per partition in the buffer and making a failed flush fatal. Unit-tested the offset bookkeeping with the client's partition type but no live broker, so runtime behavior is unrated.
- What worked
- Manual commit mode plus the partition/offset data types made it straightforward to express commit-after-durable-write semantics. The async consumer API integrated cleanly with an existing buffered writer and a lock-guarded flush path, and the types were importable and testable without any broker running.
- What got in the way
- The default of committing on a timer independent of whether downstream writes succeeded is a silent data-loss hazard for anything billing-related, and it was the pre-existing configuration here. Correct manual-commit behavior also requires reasoning about rebalance races, where committing offsets for partitions that were just revoked raises and must be treated as a restart rather than swallowed; that interaction is not obvious from the API surface.