Skip to main content

Module stream

Module stream 

Source
Expand description

Streaming / Infinity mode: ordered frames that reassemble into exactly the canonical image.

A stream is a sequence of self-delimiting frames:

Begin  { format version, flags, dialect }
Batch  { section id, bytes }        (one or more per section, in order)
End    { content hash, total size }

followed, for incremental updates, by any number of

Delta  { operations }               (applied to the reassembled module)
End    { new content hash }

Reassembly is byte-exact: a stream produced from a module yields the same bytes and the same Blake3 content hash as crate::encode::encode of that module, because each batch carries a slice of the canonical section image. Deltas are semantic (root, node content, bindings, annotations, provenance) and are re-canonicalized after application, so an incremental update also lands on the identical whole-module encoding.

Every frame carries its own length and a truncated Blake3 checksum, so corruption is detected at the frame boundary instead of surfacing as a confusing parse error later.

Structs§

Frame
One stream frame.
StreamDecoder
Streaming decoder state.
StreamEncoder
Stream encoder facade: prepares frames for a module and for deltas.
StreamedModule
A reassembled stream generation.

Enums§

DeltaOp
A semantic delta operation.
FrameKind
Frame kinds.

Constants§

DEFAULT_CHUNK
Default batch chunk size (bytes of section payload per frame).
FRAME_HEADER_SIZE
Fixed frame header size.
MAX_FRAME_PAYLOAD
Largest frame payload this reader accepts.
STREAM_VERSION
Stream frame magic is AINS; version 1.

Functions§

aligned_section_len
Convenience: number of bytes a generation occupies after padding.
apply_delta
Apply delta operations to a module, returning the updated module.
decode_stream
Reassemble a whole byte stream into a module.
delta_annotations
Test helper: annotations that a delta touched.
delta_hash
Apply a list of delta operations and return the re-encoded hash.
encode_stream
Encode a module into stream frames.
encode_stream_with
Encode a module into stream frames with explicit encoder options.
frame_checksum
Truncated Blake3 checksum of a frame payload.