Planetarium cue recording loses the final observation when closing
Level 3 · node · Reliability · Upstream and downstream buffer drain order in a multistage stream
Scenario
A fictional planetarium receives light observations in chunks, sums consecutive pairs, compresses equal consecutive sums into run records, and stores them in fixed-capacity pages. Completed pages are produced normally during collection, but sessions with a lone final observation lose data in their closing result. Trace the public recorder, pipeline coordinator, and buffer-draining contract of each stage together.
Requirements
createRecorder(pageSize) exposes write(samples) and close(). samples is an array of small nonnegative integers and pageSize is a positive integer. Sum consecutive pairs regardless of chunk boundaries, treating a lone final value as one sum by itself. Compress equal consecutive sums into one {sum,count} record and group records into pages of pageSize records. close() returns all completed pages in order, preserving the final partial page. Empty input returns an empty array. Preserve the public interface and the streaming behavior of each stage.
Acceptance criteria
- An even number of observations produces the same pages regardless of chunk boundaries.
- A lone final observation equal to the previous sum is included in that run record.
- A lone final observation with a different sum is preserved as a separate record with correct page boundaries.
- Empty input and a single observation are handled correctly.