BobbinExchange
Lazy-bobbin exchange over a Seam.
What it does. Peers share a GSet<BobbinMeta> manifest that is gossiped eagerly via a Quilter, so every peer knows which bobbins (content-addressed byte blobs) exist across the mesh. The actual bytes are fetched on demand: a peer that lacks a bobbin broadcasts a FetchMessage.Request, suspends until a FetchMessage.Response arrives from a peer that holds the bytes, verifies the content hash, caches the bytes in the local Creel, and returns them.
Single-collection. BobbinExchange takes sole ownership of seam.incoming via the internal MuxSeam (ADR-034). Do not collect seam.incoming elsewhere.
Thread-safety. Shared mutable state (the in-flight request map) is guarded by an explicit kotlinx.atomicfu.locks.ReentrantLock. No suspend calls are made inside the locked section. Correct under a multi-threaded dispatcher.
Exception discipline. Best-effort sends use runCatchingCancellable so that kotlinx.coroutines.CancellationException is never swallowed.
Parameters
The Seam over which the manifest is gossiped and fetch messages travel. BobbinExchange takes sole ownership of Seam.incoming via the internal MuxSeam.
The local content-addressed byte store shared with the caller. The exchange populates it on every successful fetch.
Coroutine scope for all background jobs. Required — no default.
Tuning for the internal manifest Quilter. In tests pass a short-cadence config with QuilterConfig.expectVirtualTime = true.
See also
Constructors
Properties
The converged set of BobbinMeta entries known across the mesh — the union of every peer's advertised bobbins. An entry appears here as soon as the manifest GSet delta propagates; the kernel bytes may not yet be cached locally (that is the lazy part).
Functions
Returns the bytes for hash.
Stores bytes as a raw bobbin and advertises BobbinMeta(hash, variantOf = null) on the gossiped manifest so all peers learn the hash immediately.
Stores bytes as a compiled variant and advertises BobbinMeta(hash, [variantOf]) so peers can discover the compiled-for-target version of the source kernel.