Skip to content

Documentation / @etherfold/core / createSegmentedStream

Function: createSegmentedStream() ​

createSegmentedStream<ABI>(port): ExistingStream<ABI>

Defined in: packages/core/src/stream/segments.ts:165

Segmentation, over a port scoped to one stream's subtree.

The rules live HERE, once, so a second keeper (SQL for a server, OPFS in a browser) supplies five substrate operations and inherits every one of them: one segment per batch and no open tail, the ordinal allocated from the cursor record inside the commit, an empty save that writes only the cursor, a full ordered scan on the way back, one comparison that refuses a write which would leave a HOLE, and one rule for damage -- clear the subtree and let it rebuild.

Nothing here assumes a tail, reads a segment's cursor, or knows what a key looks like.

The damage rule has TWO halves and only ONE of them is here. The damage a port can SHOW is inspected and cleared below. The damage it can only RAISE -- a substrate that is unavailable, which no amount of reading the keys can detect -- RAISES THROUGH, and what to do about it belongs to the caller: a generation treats it as absent and re-indexes, an installer refuses to write (ADR-0068). This keeper used to answer absent for both, which quietly told an installer that an unreadable subtree was an empty one.

Type Parameters ​

ABI ​

ABI extends Abi

Parameters ​

port ​

StreamSegmentPort<ABI>

Returns ​

ExistingStream<ABI>