Skip to content

fix(streaming): require terminal event in validate_events - #9

Merged
fufuchiu merged 2 commits into
fufuchiu:mainfrom
yuna-morio:fix-validate-events-terminal
Sep 10, 2026
Merged

fufuchiu merged 2 commits into
fufuchiu:mainfrom
yuna-morio:fix-validate-events-terminal

Conversation

@yuna-morio

Copy link
Copy Markdown
Contributor

The docstring for validate_events in src/speechloom/streaming.py promises to "require contiguous sequence IDs and a single final terminal event", but the implementation silently accepted:

  1. Empty event lists - the for loop never executes, so [] passes without error.
  2. Sequences without a terminal event - a list like [StreamEvent(0, "text", "hello")] passes even though it lacks a done or cancelled event at the end.

This adds two explicit checks:

  • if not values rejects empty lists.
  • if values[-1].kind not in ("done", "cancelled") rejects sequences that do not end with a terminal event.

A new test file tests/test_validate_events_terminal.py covers both cases plus the valid done and cancelled terminal paths.

The docstring promises 'a single final terminal event' but the function
accepted empty lists and sequences ending with non-terminal events. Add
explicit checks for both cases.
@fufuchiu
fufuchiu merged commit b81a446 into fufuchiu:main Sep 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants