src/Client/ResultChunkAssembler.php:32 assembles whatever chunks are currently present for a result id after sorting by sequence number. It does not require that a terminal chunk with more === false has arrived, it does not validate that sequence numbers are contiguous from zero, and push() silently overwrites duplicate sequence numbers. A client can therefore get a truncated or corrupted assembled result without any exception when a chunk is missing, duplicated with different data, or assembled too early.
This is risky because the README describes result chunks as part of an ordered stream that should survive reconnects gap-free, and the helper is the public client-side abstraction intended to make that stream usable. The current integration coverage only exercises the happy path in tests/Integration/JobLifecycleTest.php:237.
Fix prompt: Make ResultChunkAssembler track completion and validate integrity before returning bytes. assemble() should fail if the result id is unknown, no terminal chunk has arrived, the sequence range is not contiguous from zero through the terminal sequence, or a duplicate sequence arrives with conflicting payload metadata. Add PHPUnit tests for early assembly, missing middle chunks, duplicate conflicting chunks, out-of-order delivery, and valid base64 chunks.
src/Client/ResultChunkAssembler.php:32assembles whatever chunks are currently present for a result id after sorting by sequence number. It does not require that a terminal chunk withmore === falsehas arrived, it does not validate that sequence numbers are contiguous from zero, andpush()silently overwrites duplicate sequence numbers. A client can therefore get a truncated or corrupted assembled result without any exception when a chunk is missing, duplicated with different data, or assembled too early.This is risky because the README describes result chunks as part of an ordered stream that should survive reconnects gap-free, and the helper is the public client-side abstraction intended to make that stream usable. The current integration coverage only exercises the happy path in
tests/Integration/JobLifecycleTest.php:237.Fix prompt: Make
ResultChunkAssemblertrack completion and validate integrity before returning bytes.assemble()should fail if the result id is unknown, no terminal chunk has arrived, the sequence range is not contiguous from zero through the terminal sequence, or a duplicate sequence arrives with conflicting payload metadata. Add PHPUnit tests for early assembly, missing middle chunks, duplicate conflicting chunks, out-of-order delivery, and valid base64 chunks.