streamEnvelope
A stream-envelope response for a route whose list only grows at its end, such as a log: {"cursor":..,"status":..,("items":[..],)?("dropped":n,)?("state":..)?}.
A poll gets only the entries after its cursor, so a long list isn't sent again each time it grows. The cursor counts entries: total is how many the list ever had, and retained how many of those, the newest, it still holds. From clientCursor, the cursor the client echoed back, the status is:
resetfor an absent, undecodable, or foreign cursor, and for one past the end. appendItems getsfrom = 0andreset = true, and writes what a new client starts with, usually the last entries.unchangedwhen the client has every entry. Items are omitted.deltaotherwise. appendItems gets, asfrom, the index among the retained entries of the first one the client doesn't have, anddroppedsays how many entries the list evicted before the client got them.
appendItems writes the comma-separated JSON array elements (this factory emits the enclosing "items":[...]) and returns the index just past the last retained entry it dealt with: retained when it reached the end, or less when it stopped at a page limit, and then the next poll goes on from there. An entry that a filter left out counts as dealt with.
A non-null state must be a valid JSON value and is appended verbatim as the envelope's state member, with every status.
epoch identifies the list, as in cursorEnvelope: a cursor issued under another epoch is foreign. A list that can be emptied and filled again should take a new epoch when that happens, so a client with a cursor from before gets a reset and replaces what it has.