Skip to content

Crate vyrn md

Amp edited this page Nov 18, 2026 · 1 revision

vyrn-md

crates/vyrn-md · layer 7 of spec 11 §1.4 · split: publisher threads pinned (11 §1.3) · binaries vyrn-md and vyrn-dropcopy

Purpose

Market data and drop copy from a replica's replay events. On main the crate turns a stream of replayed events for one book into MBO packets. The output is a pure function of the stream, so the A and B observers emit identical bytes. The crate also ships a reference subscriber that applies the merge rule and rebuilds the replica's book after every step. It was merged in PR #40.

Spec sections it implements

  • 10 §7.3 (packet framing, flush rules, heartbeats)
  • 10 §7.4 (MBO lane channels, the step channel, the merge rule)
  • 10 §7.5 (16-byte record layouts)
  • Not yet: 10 §8 (drop copy)

Main public types

Type Role
ReplayStream (trait), Event, EventKind, BookOp The input seam that the observer replica will implement
MboEncoder, PacketSink, StreamError Event stream → MBO packets; rejects streams that break ordering rules 1–2
Header, Packet, Channel, Feed, PacketError 32-byte header, up to 88 records per packet
Record, RecordError, Side, DeleteCause, AttestKind, BookStatus The 16-byte record codec
MboSubscriber, SubError Reference reader, implementing the 10 §7.4 merge rule
Book, Order, BookError The book that the subscriber rebuilds
NO_WATERMARK "No watermark yet" for interval 0 (a labeled spec gap)

Status on main (a9f0d61)

Implemented (partial)

  • The MBO encoder, the record codec and the reference subscriber are implemented. Feed defines codes for MBO-C, MBP-10, TOB, TRADES and STATS, but only MBO has an encoder.
  • Drop copy is not implemented. src/dropcopy.rs is one line, //! Drop copy (10).
  • Both binaries are stubs: src/bin/vyrn-md.rs and src/bin/vyrn-dropcopy.rs are fn main() {}.
  • The crate doc lists five spec gaps. Gap 2: "A quiet lane channel advances its watermark only by heartbeat (MD_HEARTBEAT_MS = 1), which can hold steps for up to 1 ms, against MD_LAG_P99_NS = 5_000. [Likely] Not solved here."
  • Tests: 14 #[test]. tests/mbo.rs has 12, and tests/vectors.rs has 2, which use tests/mbo_vectors.txt and tests/record_vectors.txt.

Depends on

Crates
Code (Cargo.toml) vyrn-types, vyrn-nic (vyrn-nic is declared, but no source file uses it)
11 §1.4 vyrn-replica
11 §1.3 binaries vyrn-md: vyrn-md, vyrn-replica (replay core), vyrn-nic; vyrn-dropcopy: vyrn-md::dropcopy, vyrn-replica

Missing: vyrn-replica. Cargo.toml says it "returns when its replay core lands; until then the replica implements ReplayStream (src/stream.rs) and nothing here links it."

Links

Clone this wiki locally