Files
pad/internal
xarmian 7c03beb24e fix(sse): bound the ordering barrier by a count, not by the channel emptying (BUG-2730, codex round 15)
The barrier shipped one commit ago with a comment asserting it could not
starve. That was wrong, and wrong in the way that matters: it waited for
len(ch) == 0, which never happens while a publisher refills faster than
a slow client drains — and the subscriber this whole signal exists for
is precisely a slow one on a busy workspace. The announcement it was
supposed to make could be deferred indefinitely.

The wait is now bounded by the queue depth captured when the gap was
latched, decremented once per event taken off the channel. Once that
many have gone out, every event that predated the hole has been
delivered and anything still queued arrived after it, so the ordering
guarantee is satisfied and the announcement goes. Terminating by
construction, and exact rather than a timeout. The decrement counts
filtered events too — an invisible event occupied a queue slot like any
other.

An honest note on the instrument, because the first one was no good. I
wrote an end-to-end test with a goroutine publishing continuously and it
PASSED against the unbounded version: under most schedulings the channel
does briefly empty, so the scenario is not reliably reproducible through
the handler. The bound is therefore a named predicate,
gapReadyToAnnounce, with the starvation case asserted directly —
latched, budget spent, channel refilled — where it cannot be scheduled
away. The end-to-end test stays for the ordering claim, which it does
discriminate.
2026-08-23 02:09:51 +00:00
..
2026-03-26 01:52:36 +00:00