fix(consumer): Bounded the records delivered from a single fetch response. #552
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.44) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 268 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.335
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #552"
general
weight: 0.35
mcollina
Summary
A single Fetch response can carry far more records than the
highWaterMarkof aMessagesStream. The stream checked the result ofpush()only after deserializing and pushing every record of a response, so with 2,000 small records andhighWaterMark: 16,readableLengthgrew to about 2,000.This change suspends delivery inside a response as soon as
push()returnsfalse, before the next record is deserialized, and resumes it from_read()andresume()before any new fetch is issued. It supersedes #426 with a smaller approach.Changes
#pushRecordsstops at the first record afterpush()returnsfalseand keeps the response by reference, without copying or deserializing anything ahead. The existingrequestedOffsetsmap acts as the cursor: records before the suspension point are skipped as duplicates, batches already delivered are skipped whole, and completed partitions are removed from it.#fetchresumes them in order and fetches again only once the last one completes with room left in the queue. Responses issued before a refresh or a revocation are discarded, andclose()and_destroy()release them.maxFetchescounts a response only once it has been fully delivered, so the stream does not end while records are still retained.Notes
beforeDeserializationhooks still run on the whole response up front.highWaterMarkby up to about two batches.Additional Informations
AI-assisted work. All changes reviewed by a human.