binlog-inspect

ROADMAP

Based on the conclusions of three independent expert reviews dated 2026-11-05 (binlog protocol correctness / Rust engineering quality / documentation & UX). Every item includes acceptance criteria; the “Contract” section is the unified API specification for the parallel implementations, and implementations must conform to it.

Status markers use done for implemented and verified work, partial for a delivered subset, and backlog for deferred work. W1–W3 are the original batches, W4 is the 2026-11-06 re-review, and W5 is the 2026-11-07 source and roadmap review. Historical findings below describe the code at the time of review. The current status and the W5 section record subsequent fixes.

R. Correctness Fixes (P0/P1)

C. CLI Reliability and Safety (P1)

F. Performance (P1)

L. Library Quality (P1)

D. Documentation and Engineering (P1)

W2. Feature Extensions (Second Batch)

P. Pending and Deferred

W5-2. Second W5 Batch (2026-11-09, round-2 expert review)

From the 2026-11-09 two-expert re-review (engineering + documentation; the engineering reviewer empirically reproduced the R48 amplification: a 221-byte aliased jsonb decodes to 8,388,607 nodes, and ~331 wire bytes demand ~275 GB before the depth cap ever fires — a fail-closed violation).

W5. Source Review and Delivery Scope (2026-11-07)

Contract: API Specification for the First Parallel Implementation Batch

Historical batch-1 specification, kept verbatim for provenance. The code has since evolved beyond it (R26 added ranges/GTID fields to EventFilter, R33 added PartialUpdateRows.after, EventType derives ValueEnum only under the cli feature); consult the rustdoc for the current signatures.

Implementations must match the signatures below (both parallel implementers take this as authoritative; report contract defects in the final report instead of unilaterally deviating):

// —— src/event.rs ——
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, ValueEnum)]
#[serde(rename_all = "snake_case")]
pub enum EventType {
    FormatDescription, TableMap, WriteRows, UpdateRows, DeleteRows,
    PartialUpdateRows, Query, Xid, Gtid, AnonymousGtid, PreviousGtids,
    Rotate, Stop, RowsQuery, Incident, Intvar, Rand, UserVar,
    BeginLoadQuery, ExecuteLoadQuery, Heartbeat, Ignorable,
    TransactionContext, ViewChange, XaPrepare, TransactionPayload, Unknown,
}
impl EventType {
    pub fn as_str(self) -> &'static str;      // snake_case, identical to the old JSON strings
    pub fn from_raw(code: u8) -> Self;        // see the mapping below
}

Raw-code mapping (from_raw): 2 Query, 3 Stop, 4 Rotate, 5 Intvar, 13 Rand, 14 UserVar, 15 FormatDescription, 16 Xid, 17 BeginLoadQuery, 18 ExecuteLoadQuery, 19 TableMap, 26 Incident, 27 Heartbeat, 28 Ignorable, 29 RowsQuery, 30 WriteRows, 31 UpdateRows, 32 DeleteRows, 33 Gtid, 34 AnonymousGtid, 35 PreviousGtids, 36 TransactionContext, 37 ViewChange, 38 XaPrepare, 39 PartialUpdateRows, 40 TransactionPayload, 41 Heartbeat, 42 Gtid; everything else (including MariaDB 160+) is Unknown.

// —— ParsedEvent (JSON field names unchanged; event_type serializes as a snake_case string) ——
pub struct ParsedEvent {
    pub offset: u64, pub timestamp: u32, pub event_type: EventType,
    pub event_type_code: u8, pub server_id: u32, pub event_size: u32,
    pub log_pos: u32, pub payload: EventPayload,
}

// —— EventPayload (existing variant fields unchanged; additions/adjustments below) ——
pub enum EventPayload {
    FormatDescription { server_version: String },          // R4: NUL truncation
    TableMap { table_id: u64, database: String, table: String, column_count: u64 },
    Rows { table_id: u64, database: String, table: String, changes: Vec<RowChange> },
    PartialUpdateRows { table_id: u64, database: String, table: String,
                        before: Vec<Option<RowImage>> },    // R6: after diff not decoded
    Unresolved { table_id: u64 },
    Query { database: String, sql: String },
    Xid { xid: u64 },
    Gtid { gtid: String, tag: Option<String> },            // R2/R3: uuid[:tag]:gno; anonymous="ANONYMOUS"
    PreviousGtids { gtid_set: String },                     // R20: mysqlbinlog-style set string
    Rotate { next_file: String, position: u64 },
    Stop,                                                   // R20
    RowsQuery { sql: String },                              // R20
    Incident { incident_type: String, message: String },    // R20
    Intvar { var_type: String, value: u64 },                // R20
    Unknown { raw_len: usize },
}
// —— src/filter.rs ——
pub struct EventFilter {
    pub kinds: HashSet<EventType>,
    pub tables: HashSet<(String, String)>,   // R16; the CLI splits db.table at parse time
}

// —— src/formatter.rs ——
#[derive(Debug, thiserror::Error)]
pub enum FormatterError {
    #[error(transparent)] Json(#[from] serde_json::Error),
    #[error(transparent)] Io(#[from] std::io::Error),
}
pub trait Formatter {
    fn header(&self) -> Option<&'static str> { None }
    fn format(&mut self, event: &ParsedEvent, out: &mut dyn Write)
        -> Result<bool, FormatterError>;     // Ok(false) = no output for this event
}

// —— src/parser.rs ——
pub const MAX_EVENT_SIZE: u32 = 64 * 1024 * 1024;
pub struct BinlogParser<R: Read = std::fs::File> { /* ... */ }
impl BinlogParser<std::fs::File> {
    pub fn open(path: impl AsRef<Path>) -> Result<Self, ParserError>;   // includes magic validation
}
impl<R: Read> BinlogParser<R> {
    pub fn from_reader(reader: R) -> Result<Self, ParserError>;         // R12
    pub fn with_max_event_size(self, cap: u32) -> Self;                 // R21
    pub fn events(&mut self) -> impl Iterator<Item = Result<ParsedEvent, ParserError>> + '_;
}

CLI behavior specification: --events values are all EventType snake_case names, except transaction_payload, which is rejected with “compressed transaction payload events will be supported in a later version; they are currently rejected at the framing layer”; a --table value must be split at the first . into (database, table) with both parts non-empty, otherwise it errors; exit-code 0/1/2/3 semantics per R9; the file argument - reads stdin; the text format keeps {ts} {event_type} server={id} pos={log_pos} {payload_json}.

W6. Third Review Round and Delivery Scope (2026-11-13)

From the 2026-11-13 round-3 expert review (binlog protocol correctness + Rust engineering quality). Round-3 follow-ups already delivered in 652cc6a: the hostile-NEWDECIMAL fuzz crash input kept as a regression corpus seed with the fuzz/README known-findings section corrected, the README install sections noting that 0.5.0 is in-tree and unpublished, the merged 0.5.0 CHANGELOG heading, and the apply_pair clone moved behind the gap check.

Release Record

W7. Fourth Review Round and Delivery Scope (2026-11-15)

From the 2026-11-15 round-4 expert review (binlog protocol + engineering). Round-3 findings A1–A4 (walk-defer contract, comment rot, repo hygiene, stale pointers) and the R46b/R38/R47b backlog decisions below.