Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/synapse/patches/ad084967f2286f90 # synapse A component of the AienOS ecosystem. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/synapse#78 (code only) closed derived `ad084967f2286f90` #78 Imported from GitHub aien-dev/synapse#78 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `e863c87b581ddd0d33183667d6d4842d2de1f4fe` · Head `78f5b39488d84c58432fb9f5de988a55bba0d986` ### Apply it ``` git checkout -b patch-ad084967f2286f90 e863c87b581ddd0d33183667d6d4842d2de1f4fe curl -fsSL https://interplane.io/drakestapleton/synapse/patches/ad084967f2286f90.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/synapse 78 78f5b39488d84c58432fb9f5de988a55bba0d986 ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"synapse","number":78,"url":"https://github.com/aien-dev/synapse/pull/78","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:18Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/.crumb b/.crumb index cbb4924..f234f97 100644 --- a/.crumb +++ b/.crumb @@ -39,6 +39,10 @@ { "name": "synapse-coord", "role": "Shared agent coordination plane (claims, presence, whispers) byte-compatible with the crumb.c RFC-0002 store; never history, evidence, or authority (ADR 0004)" + }, + { + "name": "synapse-wire", + "role": "Binary wire frames with a fuzzed decoder, have-want chunk negotiation, and stream transports (ADR 0003 step G1)" } ], "invariants": [], @@ -55,7 +59,8 @@ "synapse-radicle": "crates/synapse-radicle", "synapse-bench": "crates/synapse-bench", "synapse-crumb": "crates/synapse-crumb", - "synapse-coord": "crates/synapse-coord" + "synapse-coord": "crates/synapse-coord", + "synapse-wire": "crates/synapse-wire" }, "migrated_from": { "dialect": "D3 (schema: \"crumb/v1\", ADR 0004)", diff --git a/Cargo.lock b/Cargo.lock index 29fb32d..8fb6001 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -415,6 +415,7 @@ dependencies = [ "synapse-git", "synapse-radicle", "synapse-store", + "synapse-wire", ] [[package]] @@ -500,6 +501,17 @@ dependencies = [ "synapse-core", ] +[[package]] +name = "synapse-wire" +version = "0.1.0" +dependencies = [ + "ed25519-dalek", + "serde_json", + "synapse-auth", + "synapse-core", + "synapse-store", +] + [[package]] name = "typenum" version = "1.20.1" diff --git a/Cargo.toml b/Cargo.toml index e9e7f69..40750e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ members = [ "crates/synapse-crumb", "crates/synapse-coord", "crates/synapse-evidence", + "crates/synapse-wire", ] [workspace.package] @@ -43,6 +44,7 @@ synapse-evidence = { path = "crates/synapse-evidence" } synapse-git = { path = "crates/synapse-git" } synapse-radicle = { path = "crates/synapse-radicle" } synapse-store = { path = "crates/synapse-store" } +synapse-wire = { path = "crates/synapse-wire" } zeroize = "1.9" [profile.release] diff --git a/crates/synapse-bench/Cargo.toml b/crates/synapse-bench/Cargo.toml index 7a2f28c..59e4eba 100644 --- a/crates/synapse-bench/Cargo.toml +++ b/crates/synapse-bench/Cargo.toml @@ -22,6 +22,7 @@ synapse-core.workspace = true synapse-git.workspace = true synapse-radicle.workspace = true synapse-store.workspace = true +synapse-wire.workspace = true [dev-dependencies] # ADR 0004 D5 combined Crumb-Synapse qualification (tests/crumb_synapse_qualification.rs). diff --git a/crates/synapse-bench/src/bin/wire-transport.rs b/crates/synapse-bench/src/bin/wire-transport.rs new file mode 100644 index 0000000..b1b41a6 --- /dev/null +++ b/crates/synapse-bench/src/bin/wire-transport.rs @@ -0,0 +1,370 @@ +//! G1 transport measurement: seconds and joules per accepted change across the wire +//! transport (Unix socket, binary frames, have-want negotiation), against the ADR 0003 +//! section 6 bound for one durable change (`docs/PHASE5_GROUP_COMMIT.md` section 5). +//! +//! ```text +//! wire-transport --out DIR [--changes N] [--reps R] [--idle-s S] [--store-root DIR] +//! ``` +//! +//! Three arms per repetition, order rotated, each on a fresh store directory with +//! `GROUP_COMMIT_DEFAULT` and one agent submitting one change at a time: +//! * `wire`: client and server threads joined by a Unix socket; per change Have, Want, +//! Chunk (only the blobs the server lacks), Submit, Accepted after durable commit. +//! * `direct_auth`: the same chain authorisation and store admission in process, no +//! transport (isolates framing and socket cost). +//! * `direct`: store admission only (no chain check). +//! +//! Every change upserts one new 3,967-byte blob (the Gate 4 median new content per change) +//! and one blob shared by every change (sent once, then skipped by negotiation). +//! Envelopes and requests are signed before timing starts. `spec.json` is written before +//! the first change; `result.json` holds every per-change latency in nanoseconds. + +use serde_json::json; +use std::os::unix::net::UnixStream; +use std::path::{Path, PathBuf}; +use std::process::ExitCode; +use std::sync::Arc; +use std::time::{Duration, Instant}; +use synapse_auth::{BoundaryKind, Capability, ChainedRequest, PolicyEnforcer}; +use synapse_bench::energy::{idle_window, EnergyReading, EnergyWindow}; +use synapse_core::{BlobDigest, ChangesetEnvelope, WalSeq}; +use synapse_store::{FsyncPolicy, RecoveryPolicy, SharedStore, StoreLimits}; +use synapse_wire::session::submit_request; +use synapse_wire::testkit::{envelope, repo, server, ChainFixture, FIXTURE_NOW_MS}; +use synapse_wire::{WireClient, WireLimits}; + +/// Bound inputs, `docs/PHASE5_GROUP_COMMIT.md` section 5 (W1 floor, one agent). +const FLUSH_FLOOR_S: f64 = 0.805e-3; +const SEQ_WRITE_S_PER_GIB: f64 = 0.138; +const FLOOR_BYTES_PER_CHANGE: f64 = 11_500.0; +const IDLE_W_FLOOR: f64 = 22.731; +const ESSENTIAL_CPU_J: f64 = 0.2766e-3; +/// Gate 4 median new content per change, bytes. +const NEW_BLOB_BYTES: usize = 3_967; + +struct Change { + env: ChangesetEnvelope, + req: ChainedRequest, + blobs: Vec<(BlobDigest, Vec)>, +} + +fn blob(seed: u64, len: usize) -> Vec { + let mut x = seed.wrapping_mul(0x9E37_79B9_7F4A_7C15) | 1; + (0..len) + .map(|_| { + x ^= x << 13; + x ^= x >> 7; + x ^= x << 17; + (x >> 24) as u8 + }) + .collect() +} + +fn build_changes(fx: &ChainFixture, rep: usize, n: usize, shared: &[u8]) -> Vec { + (0..n) + .map(|i| { + let new = blob((rep as u64) << 32 | i as u64, NEW_BLOB_BYTES); + let path = format!("src/r{rep}/c{i:05}.rs"); + let shared_path = format!("src/r{rep}/shared{i:05}.rs"); + let (env, blobs) = envelope( + &fx.agent, + &format!("wire-{rep}-{i}"), + &[(&path, new), (&shared_path, shared.to_vec())], + &[], + 1_000 + i as u64, + ); + let mut nonce = [0u8; 32]; + nonce[..8].copy_from_slice(&(rep as u64).to_le_bytes()); + nonce[8..16].copy_from_slice(&(i as u64).to_le_bytes()); + let req = submit_request(&fx.agent, fx.chain.clone(), &env, nonce, 1_000 + i as u64) + .expect("request"); + Change { env, req, blobs } + }) + .collect() +} + +fn open(dir: &Path) -> Arc { + let _ = std::fs::remove_dir_all(dir); + std::fs::create_dir_all(dir).expect("store dir"); + Arc::new( + SharedStore::open( + dir, + FsyncPolicy::GROUP_COMMIT_DEFAULT, + RecoveryPolicy::StrictFailClosed, + StoreLimits::default(), + ) + .expect("open store"), + ) +} + +/// Per repetition: seconds per change, package joules per change, above-idle joules. +type RepFigures = (f64, Option, f64); + +struct ArmRun { + latencies_ns: Vec, + elapsed_s: f64, + energy: EnergyReading, + wire_bytes_sent: u64, + wire_bytes_received: u64, + chunks_sent: u64, + chunk_bytes_sent: u64, +} + +fn run_wire(fx: &ChainFixture, dir: &Path, changes: &[Change]) -> ArmRun { + let store = open(dir); + let srv = server(fx, store.clone()); + let (a, b) = UnixStream::pair().expect("socket pair"); + let s = srv.clone(); + let t = std::thread::spawn(move || s.serve(b)); + let mut client = WireClient::connect(a, WireLimits::default()).expect("connect"); + let (s0, r0) = client.bytes(); + let mut lat = Vec::with_capacity(changes.len()); + let (mut chunks, mut chunk_bytes) = (0u64, 0u64); + let w = EnergyWindow::start(); + let start = Instant::now(); + for c in changes { + let t0 = Instant::now(); + let rep = client.submit(&c.req, &c.blobs).expect("accepted"); + lat.push(t0.elapsed().as_nanos() as u64); + assert!(!rep.accepted.duplicate); + chunks += rep.wanted as u64; + chunk_bytes += rep.chunk_bytes_sent; + } + let elapsed_s = start.elapsed().as_secs_f64(); + let energy = w.finish(); + let (s1, r1) = client.bytes(); + drop(client); + t.join().expect("server thread").expect("server"); + ArmRun { + latencies_ns: lat, + elapsed_s, + energy, + wire_bytes_sent: s1 - s0, + wire_bytes_received: r1 - r0, + chunks_sent: chunks, + chunk_bytes_sent: chunk_bytes, + } +} + +fn run_direct(fx: &ChainFixture, dir: &Path, changes: &[Change], auth: bool) -> ArmRun { + let store = open(dir); + let mut enforcer: PolicyEnforcer = fx.enforcer(); + let mut lat = Vec::with_capacity(changes.len()); + let w = EnergyWindow::start(); + let start = Instant::now(); + for c in changes { + let t0 = Instant::now(); + if auth { + let seq = WalSeq(store.read().committed_seq().0 + 1); + enforcer + .authorize_chain( + BoundaryKind::Api, + "wire_submit", + &repo(), + Capability::Propose, + &c.req, + seq, + FIXTURE_NOW_MS, + ) + .expect("authorized"); + } + store.submit(c.env.clone(), &c.blobs).expect("committed"); + lat.push(t0.elapsed().as_nanos() as u64); + } + let elapsed_s = start.elapsed().as_secs_f64(); + let energy = w.finish(); + ArmRun { + latencies_ns: lat, + elapsed_s, + energy, + wire_bytes_sent: 0, + wire_bytes_received: 0, + chunks_sent: 0, + chunk_bytes_sent: 0, + } +} + +fn nearest_rank(sorted: &[u64], q: f64) -> u64 { + let rank = (q * sorted.len() as f64).ceil() as usize; + sorted[rank.clamp(1, sorted.len()) - 1] +} + +fn median(v: &mut [f64]) -> f64 { + v.sort_by(|a, b| a.total_cmp(b)); + v[v.len() / 2] +} + +fn git_rev() -> String { + std::process::Command::new("git") + .args(["rev-parse", "HEAD"]) + .output() + .ok() + .filter(|o| o.status.success()) + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) + .unwrap_or_else(|| "unknown".into()) +} + +fn usage() -> ExitCode { + eprintln!( + "usage: wire-transport --out DIR [--changes N] [--reps R] [--idle-s S] [--store-root DIR]" + ); + ExitCode::from(2) +} + +fn main() -> ExitCode { + let args: Vec = std::env::args().skip(1).collect(); + let (mut out, mut changes_n, mut reps, mut idle_s) = (None, 2000usize, 3usize, 30u64); + let mut store_root = PathBuf::from("target/wire-transport-stores"); + let mut i = 0; + while i < args.len() { + let Some(v) = args.get(i + 1) else { + return usage(); + }; + match args[i].as_str() { + "--out" => out = Some(PathBuf::from(v)), + "--changes" => match v.parse() { + Ok(n) => changes_n = n, + Err(_) => return usage(), + }, + "--reps" => match v.parse() { + Ok(n) => reps = n, + Err(_) => return usage(), + }, + "--idle-s" => match v.parse() { + Ok(n) => idle_s = n, + Err(_) => return usage(), + }, + "--store-root" => store_root = PathBuf::from(v), + _ => return usage(), + } + i += 2; + } + let Some(out) = out else { return usage() }; + if changes_n == 0 || reps == 0 { + return usage(); + } + std::fs::create_dir_all(&out).expect("out dir"); + std::fs::create_dir_all(&store_root).expect("store root"); + let t_floor = + FLUSH_FLOOR_S + FLOOR_BYTES_PER_CHANGE * SEQ_WRITE_S_PER_GIB / (1u64 << 30) as f64; + let e_floor = IDLE_W_FLOOR * t_floor + ESSENTIAL_CPU_J; + let arms = ["wire", "direct_auth", "direct"]; + let spec = json!({ + "tool": "wire-transport", + "step": "G1", + "git_rev": git_rev(), + "changes_per_arm": changes_n, + "reps": reps, + "arms": arms, + "order": "rotated per repetition", + "agents": 1, + "fsync_policy": "GROUP_COMMIT_DEFAULT", + "chain_depth": 2, + "per_change": {"new_blob_bytes": NEW_BLOB_BYTES, "shared_blob_bytes": NEW_BLOB_BYTES, "paths": 2}, + "transport": "std::os::unix::net::UnixStream pair, client and server threads in one process", + "store_root": store_root.display().to_string(), + "idle_window_s": idle_s, + "bound": { + "source": "docs/PHASE5_GROUP_COMMIT.md section 5 (ADR 0003 section 6 durable latency for one change)", + "t_floor_s": t_floor, + "t_floor_formula": "0.805 ms + 11500 B x 0.138 s/GiB", + "e_floor_j": e_floor, + "e_floor_formula": "22.731 W x t_floor + 0.2766 mJ", + "fraction": "floor / measured (1.0 = at the floor)", + }, + "energy_sensor": "aien_spbm hwmon: SoC package only, uncalibrated; NVMe UNMEASURED", + "declared_before_run": true, + }); + std::fs::write( + out.join("spec.json"), + serde_json::to_string_pretty(&spec).expect("json") + "\n", + ) + .expect("write spec"); + eprintln!("spec written; idle window {idle_s} s"); + let idle = idle_window(Duration::from_secs(idle_s)); + + let fx = ChainFixture::new(2, None); + let shared = blob(0xFEED, NEW_BLOB_BYTES); + let mut runs: Vec = Vec::new(); + let mut per_arm: std::collections::BTreeMap<&str, Vec> = Default::default(); + for rep in 0..reps { + for k in 0..arms.len() { + let arm = arms[(k + rep) % arms.len()]; + let changes = build_changes(&fx, rep, changes_n, &shared); + let dir = store_root.join(format!("{arm}-{rep}")); + let r = match arm { + "wire" => run_wire(&fx, &dir, &changes), + "direct_auth" => run_direct(&fx, &dir, &changes, true), + _ => run_direct(&fx, &dir, &changes, false), + }; + let _ = std::fs::remove_dir_all(&dir); + let mut s = r.latencies_ns.clone(); + s.sort_unstable(); + let n = s.len() as f64; + let s_per_change = r.elapsed_s / n; + let j_per_change = r.energy.pkg_j.map(|j| j / n); + let above_idle = r.energy.pkg_above_idle_j(&idle).map(|j| j / n); + per_arm.entry(arm).or_default().push(( + s_per_change, + j_per_change, + above_idle.unwrap_or(f64::NAN), + )); + eprintln!( + "rep {rep} {arm}: {:.3} ms/change, p50 {:.3} ms, {:?} J/change", + s_per_change * 1e3, + nearest_rank(&s, 0.5) as f64 / 1e6, + j_per_change + ); + runs.push(json!({ + "rep": rep, + "arm": arm, + "changes": s.len(), + "elapsed_s": r.elapsed_s, + "s_per_change": s_per_change, + "p50_s": nearest_rank(&s, 0.50) as f64 / 1e9, + "p99_s": nearest_rank(&s, 0.99) as f64 / 1e9, + "max_s": s[s.len() - 1] as f64 / 1e9, + "pkg_j_per_change": j_per_change, + "pkg_above_idle_j_per_change": above_idle, + "wire_bytes_sent_per_change": r.wire_bytes_sent as f64 / n, + "wire_bytes_received_per_change": r.wire_bytes_received as f64 / n, + "chunks_sent": r.chunks_sent, + "chunk_bytes_sent": r.chunk_bytes_sent, + "energy": r.energy, + "latencies_ns": r.latencies_ns, + })); + } + } + let mut summary = serde_json::Map::new(); + for (arm, v) in &per_arm { + let mut s: Vec = v.iter().map(|x| x.0).collect(); + let mut j: Vec = v.iter().filter_map(|x| x.1).collect(); + let mut a: Vec = v.iter().map(|x| x.2).filter(|x| x.is_finite()).collect(); + let s_med = median(&mut s); + let j_med = (!j.is_empty()).then(|| median(&mut j)); + summary.insert( + arm.to_string(), + json!({ + "s_per_change_median": s_med, + "s_per_change_reps": v.iter().map(|x| x.0).collect::>(), + "fraction_of_time_floor": t_floor / s_med, + "pkg_j_per_change_median": j_med, + "fraction_of_energy_floor": j_med.map(|j| e_floor / j), + "pkg_above_idle_j_per_change_median": (!a.is_empty()).then(|| median(&mut a)), + }), + ); + } + let result = json!({ + "spec": spec, + "idle": idle, + "summary": summary, + "runs": runs, + }); + std::fs::write( + out.join("result.json"), + serde_json::to_string_pretty(&result).expect("json") + "\n", + ) + .expect("write result"); + eprintln!("{}", serde_json::to_string_pretty(&summary).expect("json")); + ExitCode::SUCCESS +} diff --git a/crates/synapse-core/src/lib.rs b/crates/synapse-core/src/lib.rs index cf66bc0..c96bf3e 100644 --- a/crates/synapse-core/src/lib.rs +++ b/crates/synapse-core/src/lib.rs @@ -35,6 +35,13 @@ pub enum RefusalCode { WalTornFrame, /// A WAL record payload passed its checksums but does not decode (binary codec v2). WalRecordMalformed, + /// A binary wire frame is not in its one canonical encoding: bad magic, version, flags, + /// kind, length over the negotiated cap, truncated, or a malformed body (step G1). + WireFrameMalformed, + /// A well-formed wire frame arrived out of protocol order: no hello first, a want that is + /// not a subset of the have, an unsolicited or repeated chunk, or a submit before every + /// wanted chunk arrived (step G1). + WireProtocolViolation, CheckpointCorrupt, IoFailure, diff --git a/crates/synapse-store/src/codec.rs b/crates/synapse-store/src/codec.rs index 87dee29..d4f97ab 100644 --- a/crates/synapse-store/src/codec.rs +++ b/crates/synapse-store/src/codec.rs @@ -671,6 +671,25 @@ pub fn decode_record(bytes: &[u8], cap: u64) -> Result Ok(record) } +/// Encode one changeset envelope alone: `CODEC_V2 | envelope body`, the same field layout a +/// `ChangesetIngest` record uses. The wire (`synapse-wire`, step G1) carries proposals in it. +pub fn encode_envelope(envelope: &ChangesetEnvelope) -> SynapseResult> { + let mut w = Writer(Vec::with_capacity(256)); + w.u8(CODEC_V2); + put_envelope(&mut w, envelope)?; + Ok(w.0) +} + +/// Decode exactly one envelope written by [`encode_envelope`]. `cap` bounds every declared +/// length and reservation; trailing bytes and every non-canonical form are refused. +pub fn decode_envelope(bytes: &[u8], cap: u64) -> Result { + let mut r = Reader::new(bytes, cap); + get_version(&mut r)?; + let envelope = get_envelope(&mut r)?; + r.finish()?; + Ok(envelope) +} + /// Encode `record` with `codec`. pub fn encode_record_with(record: &WalRecord, codec: RecordCodec) -> SynapseResult> { match codec { diff --git a/crates/synapse-wire/Cargo.toml b/crates/synapse-wire/Cargo.toml new file mode 100644 index 0000000..0217d7f --- /dev/null +++ b/crates/synapse-wire/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "synapse-wire" +version.workspace = true +edition.workspace = true +license.workspace = true +authors.workspace = true +repository.workspace = true +description = "Binary wire frames with a fuzzed decoder, have-want chunk negotiation, and stream transports for Synapse (ADR 0003 step G1)" + +[dependencies] +ed25519-dalek.workspace = true +serde_json.workspace = true +synapse-auth.workspace = true +synapse-core.workspace = true +synapse-store.workspace = true diff --git a/crates/synapse-wire/src/bin/synapse-wire-fuzz.rs b/crates/synapse-wire/src/bin/synapse-wire-fuzz.rs new file mode 100644 index 0000000..1e7e6ee --- /dev/null +++ b/crates/synapse-wire/src/bin/synapse-wire-fuzz.rs @@ -0,0 +1,175 @@ +//! Run the in-repository coverage-guided fuzzer on the wire frame decoder. +//! +//! ```text +//! synapse-wire-fuzz --out DIR [--seconds N | --execs N] [--seed S] [--cap BYTES] +//! ``` +//! +//! Writes `DIR/spec.json` (budget, seed, cap, revision) before the first execution, then +//! `DIR/result.json` and `DIR/corpus.bin` (every input that reached new coverage, replayed +//! afterwards without instrumentation: each must be a canonical frame or a typed refusal). +//! Exits non-zero on any violation. + +use std::path::PathBuf; +use std::process::ExitCode; +use synapse_wire::frame::WireLimits; +use synapse_wire::fuzz::{ + corpus_to_bytes, malformed_seed_corpus, replay_corpus, run, seed_corpus, Budget, CountingAlloc, + FuzzConfig, +}; + +#[global_allocator] +static ALLOC: CountingAlloc = CountingAlloc; + +fn usage() -> ExitCode { + eprintln!( + "usage: synapse-wire-fuzz --out DIR [--seconds N | --execs N] [--seed S] [--cap BYTES]" + ); + ExitCode::from(2) +} + +fn git_rev() -> String { + std::process::Command::new("git") + .args(["rev-parse", "HEAD"]) + .output() + .ok() + .filter(|o| o.status.success()) + .map(|o| String::from_utf8_lossy(&o.stdout).trim().to_string()) + .unwrap_or_else(|| "unknown".into()) +} + +fn main() -> ExitCode { + let args: Vec = std::env::args().skip(1).collect(); + let mut out: Option = None; + let mut budget = Budget::Seconds(60.0); + let mut seed = 0x5EED_6100_u64; + let mut cap = 8192u32; + let mut i = 0; + while i < args.len() { + let val = args.get(i + 1); + match (args[i].as_str(), val) { + ("--out", Some(v)) => out = Some(PathBuf::from(v)), + ("--seconds", Some(v)) => match v.parse() { + Ok(s) => budget = Budget::Seconds(s), + Err(_) => return usage(), + }, + ("--execs", Some(v)) => match v.parse() { + Ok(n) => budget = Budget::Execs(n), + Err(_) => return usage(), + }, + ("--seed", Some(v)) => match v.parse() { + Ok(s) => seed = s, + Err(_) => return usage(), + }, + ("--cap", Some(v)) => match v.parse() { + Ok(c) => cap = c, + Err(_) => return usage(), + }, + _ => return usage(), + } + i += 2; + } + let Some(out) = out else { return usage() }; + if let Err(e) = std::fs::create_dir_all(&out) { + eprintln!("cannot create {}: {e}", out.display()); + return ExitCode::from(2); + } + let limits = WireLimits { + max_frame_body: cap, + }; + let mut seeds = seed_corpus(&limits); + let valid_seeds = seeds.len(); + seeds.extend(malformed_seed_corpus(&limits)); + let (budget_kind, budget_value) = match budget { + Budget::Execs(n) => ("execs", n as f64), + Budget::Seconds(s) => ("seconds", s), + }; + let spec = serde_json::json!({ + "tool": "synapse-wire-fuzz", + "kind": "in-repository coverage-guided mutation fuzzer (edge feedback from instrumented frame-decoder states)", + "target": "synapse_wire::frame::decode_frame, then synapse_store::codec::decode_envelope on Submit payloads", + "budget_kind": budget_kind, + "budget_value": budget_value, + "seed": seed, + "max_frame_body": cap, + "seed_inputs": seeds.len(), + "valid_seed_inputs": valid_seeds, + "git_rev": git_rev(), + "declared_before_run": true, + }); + let write = |name: &str, bytes: &[u8]| -> Result<(), ExitCode> { + std::fs::write(out.join(name), bytes).map_err(|e| { + eprintln!("cannot write {name}: {e}"); + ExitCode::from(2) + }) + }; + let spec_text = serde_json::to_string_pretty(&spec).expect("json") + "\n"; + if let Err(c) = write("spec.json", spec_text.as_bytes()) { + return c; + } + eprintln!("spec written; fuzzing ({budget_kind} {budget_value}, seed {seed}, cap {cap})"); + + let report = run( + FuzzConfig { + seed, + budget, + limits, + max_corpus: 50_000, + }, + &seeds, + ); + let replay = replay_corpus(&report.corpus, &limits); + let result = serde_json::json!({ + "execs": report.execs, + "elapsed_s": report.elapsed_s, + "execs_per_s": report.execs as f64 / report.elapsed_s.max(1e-9), + "edges": report.edges, + "instrumented_sites": report.sites_total, + "sites_unreached_lines": report.sites_unreached, + "corpus_entries": report.corpus.len(), + "corpus_found_at_execs": report.corpus_found_at, + "largest_input_bytes": report.largest_input, + "alloc_tracking_installed": report.alloc_tracking, + "peak_single_alloc_bytes": report.peak_alloc, + "peak_total_alloc_per_decode_bytes": report.peak_alloc_total, + "outcomes": report.outcomes, + "violation_total": report.violation_total(), + "violation_counts": report.violation_counts, + "violations": report.violations.iter().map(|v| serde_json::json!({ + "kind": v.kind, "detail": v.detail, "input_hex": hex(&v.input), + })).collect::>(), + "corpus_replay": { + "entries": replay.entries, + "accepted_canonical": replay.accepted_canonical, + "refused_by_kind": replay.refused, + "violations": replay.violations, + "peak_single_alloc_bytes": replay.peak_alloc, + }, + }); + let result_text = serde_json::to_string_pretty(&result).expect("json") + "\n"; + if let Err(c) = write("result.json", result_text.as_bytes()) { + return c; + } + if let Err(c) = write("corpus.bin", &corpus_to_bytes(&report.corpus)) { + return c; + } + eprintln!( + "execs {} in {:.1} s, edges {}, sites {}/{}, corpus {}, violations {}, replay violations {}", + report.execs, + report.elapsed_s, + report.edges, + report.sites_total - report.sites_unreached.len(), + report.sites_total, + report.corpus.len(), + report.violation_total(), + replay.violations.len() + ); + if report.violation_total() == 0 && replay.violations.is_empty() && report.alloc_tracking { + ExitCode::SUCCESS + } else { + ExitCode::FAILURE + } +} + +fn hex(b: &[u8]) -> String { + b.iter().map(|x| format!("{x:02x}")).collect() +} diff --git a/crates/synapse-wire/src/frame.rs b/crates/synapse-wire/src/frame.rs new file mode 100644 index 0000000..da1df8e --- /dev/null +++ b/crates/synapse-wire/src/frame.rs @@ -0,0 +1,921 @@ +//! Binary wire frames (ADR 0003 section 9, step G1). +//! +//! Frame = 16-byte header, then `body_len` bytes of body. Little-endian, fixed width: +//! +//! | Bytes | Field | +//! | :--- | :--- | +//! | 0..4 | magic `SYNW` | +//! | 4 | version `1` | +//! | 5 | kind (1 hello, 2 have, 3 want, 4 chunk, 5 submit, 6 accepted, 7 refused) | +//! | 6 | flags `0` (any other value is refused) | +//! | 7 | reserved `0` (any other value is refused) | +//! | 8..12 | `request_id` u32 | +//! | 12..16 | `body_len` u32 | +//! +//! Body primitives follow the A1 codec (`synapse_store::codec`): `u8`, `u16`, `u32`, `u64` +//! little endian; byte strings and strings `u32 len | bytes` (strings UTF-8); sequences +//! `u32 count | items`; fixed arrays raw; option and enum tags one byte. There is exactly one +//! encoding per frame: any other tag, trailing byte, invalid UTF-8, invalid `RepoId`, +//! unsorted or repeated digest, or non-canonical capability chain is refused, so decode then +//! encode gives the input bytes back. +//! +//! Untrusted input: `body_len` is checked against the negotiated cap before anything is +//! allocated or read, and every inner length and count is checked against the cap and the +//! bytes left in the body. The body decoder only ever sees the body slice, so it cannot read +//! past the frame into the next one. + +use crate::probe::{NoProbe, Probe}; +use synapse_auth::{ + Capability, CapabilityChain, ChainedRequest, ReferenceKind, RequestScope, MAX_CHAIN_DEPTH, +}; +use synapse_core::{ + BlobDigest, ChangeId, ChangesetId, RefusalCode, RepoId, SynapseError, SynapseResult, WalSeq, +}; + +/// Frame magic. +pub const WIRE_MAGIC: [u8; 4] = *b"SYNW"; +/// Frame format version. +pub const WIRE_VERSION: u8 = 1; +/// Fixed header length. +pub const FRAME_HEADER_LEN: usize = 16; +/// Default cap on a frame's declared body length (16 MiB). +pub const DEFAULT_MAX_FRAME_BODY: u32 = 16 << 20; +/// Longest refusal code name carried by a `Refused` frame. +pub const MAX_REFUSAL_CODE_LEN: usize = 64; + +/// Limits a peer applies to frames it reads. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct WireLimits { + /// Largest declared body length accepted; larger declarations are refused before any + /// allocation or read. + pub max_frame_body: u32, +} + +impl Default for WireLimits { + fn default() -> Self { + Self { + max_frame_body: DEFAULT_MAX_FRAME_BODY, + } + } +} + +/// Frame kind byte. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum FrameKind { + Hello = 1, + Have = 2, + Want = 3, + Chunk = 4, + Submit = 5, + Accepted = 6, + Refused = 7, +} + +impl FrameKind { + /// Every kind, in kind-byte order. + pub const ALL: [FrameKind; 7] = [ + Self::Hello, + Self::Have, + Self::Want, + Self::Chunk, + Self::Submit, + Self::Accepted, + Self::Refused, + ]; + + pub fn byte(self) -> u8 { + self as u8 + } + + pub fn from_byte(b: u8) -> Option { + Self::ALL.get(usize::from(b).wrapping_sub(1)).copied() + } + + pub fn name(self) -> &'static str { + match self { + Self::Hello => "Hello", + Self::Have => "Have", + Self::Want => "Want", + Self::Chunk => "Chunk", + Self::Submit => "Submit", + Self::Accepted => "Accepted", + Self::Refused => "Refused", + } + } +} + +/// Opening frame of each side: the limits it will apply to frames it reads. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Hello { + pub max_frame_body: u32, + /// Largest total of chunk bytes the receiver buffers for one negotiation. + pub max_pending_chunk_bytes: u64, +} + +/// Sender offers the chunks a change needs (strictly increasing digests). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Have { + pub repo_id: RepoId, + pub digests: Vec, +} + +/// Receiver asks for the offered chunks it lacks (strictly increasing digests). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Want { + pub digests: Vec, +} + +/// One chunk's content. Until G2 a chunk is a whole blob and its digest is the `BlobDigest`. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Chunk { + pub digest: BlobDigest, + pub bytes: Vec, +} + +/// The change is durable at `wal_seq` (or was already, for an idempotent duplicate). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Accepted { + pub wal_seq: WalSeq, + pub changeset_id: ChangesetId, + pub duplicate: bool, +} + +/// A typed refusal. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Refused { + pub code: RefusalCode, + pub message: String, +} + +/// A frame body by kind. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum FrameBody { + Hello(Hello), + Have(Have), + Want(Want), + Chunk(Chunk), + /// A capability-chained request whose payload is one `synapse_store::codec` + /// binary envelope. + Submit(Box), + Accepted(Accepted), + Refused(Refused), +} + +impl FrameBody { + pub fn kind(&self) -> FrameKind { + match self { + Self::Hello(_) => FrameKind::Hello, + Self::Have(_) => FrameKind::Have, + Self::Want(_) => FrameKind::Want, + Self::Chunk(_) => FrameKind::Chunk, + Self::Submit(_) => FrameKind::Submit, + Self::Accepted(_) => FrameKind::Accepted, + Self::Refused(_) => FrameKind::Refused, + } + } +} + +/// One frame. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Frame { + pub request_id: u32, + pub body: FrameBody, +} + +/// Parsed and checked header. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct FrameHeader { + pub kind: FrameKind, + pub request_id: u32, + pub body_len: u32, +} + +impl FrameHeader { + /// Header plus body length. + pub fn frame_len(&self) -> usize { + FRAME_HEADER_LEN + self.body_len as usize + } +} + +/// Typed refusal from the frame decoder. `at` is the absolute byte offset in the frame. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum WireRefusal { + /// The input ends before a field: `need` more bytes were required. + Truncated { at: usize, need: usize }, + /// The first four bytes are not `SYNW`. + BadMagic { found: [u8; 4] }, + /// The version byte is not [`WIRE_VERSION`]. + VersionUnsupported { found: u8 }, + /// The flags byte is not zero. + FlagsNonZero { found: u8 }, + /// The reserved byte is not zero. + ReservedNonZero { found: u8 }, + /// The kind byte names no frame kind. + UnknownKind { found: u8 }, + /// A declared length or count needs more than the cap allows. + LengthOverCap { at: usize, declared: u64, cap: u64 }, + /// Bytes remain after the last field of the body. + TrailingBytes { at: usize, count: usize }, + /// A tag byte (capability, reference kind, option, bool) has no meaning. + UnknownTag { + at: usize, + field: &'static str, + tag: u8, + }, + /// A string is not UTF-8. + InvalidUtf8 { at: usize }, + /// A repository id fails `RepoId::new`. + InvalidRepoId { at: usize }, + /// A second encoding of the same value would exist (unsorted or repeated digests, + /// a capability chain that does not re-encode to its bytes). + NotCanonical { at: usize, field: &'static str }, + /// The embedded capability chain is refused by its own decoder. + Chain { at: usize, code: RefusalCode }, + /// A `Refused` frame names no known refusal code. + UnknownRefusalCode { at: usize }, +} + +impl WireRefusal { + /// Short stable name of the refusal kind. + pub fn kind(&self) -> &'static str { + match self { + Self::Truncated { .. } => "Truncated", + Self::BadMagic { .. } => "BadMagic", + Self::VersionUnsupported { .. } => "VersionUnsupported", + Self::FlagsNonZero { .. } => "FlagsNonZero", + Self::ReservedNonZero { .. } => "ReservedNonZero", + Self::UnknownKind { .. } => "UnknownKind", + Self::LengthOverCap { .. } => "LengthOverCap", + Self::TrailingBytes { .. } => "TrailingBytes", + Self::UnknownTag { .. } => "UnknownTag", + Self::InvalidUtf8 { .. } => "InvalidUtf8", + Self::InvalidRepoId { .. } => "InvalidRepoId", + Self::NotCanonical { .. } => "NotCanonical", + Self::Chain { .. } => "Chain", + Self::UnknownRefusalCode { .. } => "UnknownRefusalCode", + } + } + + /// The refusal as a `SynapseError` with code `WireFrameMalformed`. + pub fn into_error(self) -> SynapseError { + SynapseError::new( + RefusalCode::WireFrameMalformed, + format!("wire frame: {} ({self:?})", self.kind()), + ) + } +} + +type Decoded = Result; + +// --------------------------------------------------------------------------------------- +// Encoder +// --------------------------------------------------------------------------------------- + +fn too_large(what: &str) -> SynapseError { + SynapseError::new( + RefusalCode::QuotaPayloadTooLarge, + format!("{what} exceeds the 32-bit length field"), + ) +} + +struct Writer(Vec); + +impl Writer { + fn u8(&mut self, v: u8) { + self.0.push(v); + } + fn u32(&mut self, v: u32) { + self.0.extend_from_slice(&v.to_le_bytes()); + } + fn u64(&mut self, v: u64) { + self.0.extend_from_slice(&v.to_le_bytes()); + } + fn raw(&mut self, b: &[u8]) { + self.0.extend_from_slice(b); + } + fn len(&mut self, n: usize, what: &str) -> SynapseResult<()> { + self.u32(u32::try_from(n).map_err(|_| too_large(what))?); + Ok(()) + } + fn bytes(&mut self, b: &[u8], what: &str) -> SynapseResult<()> { + self.len(b.len(), what)?; + self.raw(b); + Ok(()) + } + fn str(&mut self, s: &str, what: &str) -> SynapseResult<()> { + self.bytes(s.as_bytes(), what) + } + fn digests(&mut self, d: &[BlobDigest]) -> SynapseResult<()> { + if d.windows(2).any(|w| w[0].0 >= w[1].0) { + return Err(SynapseError::new( + RefusalCode::WireFrameMalformed, + "digests must be strictly increasing", + )); + } + self.len(d.len(), "digest count")?; + d.iter().for_each(|x| self.raw(&x.0)); + Ok(()) + } +} + +fn refusal_code_name(code: RefusalCode) -> String { + format!("{code:?}") +} + +fn put_body(w: &mut Writer, body: &FrameBody) -> SynapseResult<()> { + match body { + FrameBody::Hello(h) => { + w.u32(h.max_frame_body); + w.u64(h.max_pending_chunk_bytes); + } + FrameBody::Have(h) => { + RepoId::new(h.repo_id.as_str())?; + w.str(h.repo_id.as_str(), "repository id")?; + w.digests(&h.digests)?; + } + FrameBody::Want(x) => w.digests(&x.digests)?, + FrameBody::Chunk(c) => { + w.raw(&c.digest.0); + w.bytes(&c.bytes, "chunk")?; + } + FrameBody::Submit(r) => { + let n = r.chain.links.len(); + if n == 0 || n > MAX_CHAIN_DEPTH { + return Err(SynapseError::new( + RefusalCode::AuthChainBroken, + format!("chain length {n} outside 1..={MAX_CHAIN_DEPTH}"), + )); + } + w.bytes(&r.chain.encode(), "capability chain")?; + RepoId::new(r.target_repo_id.as_str())?; + w.str(r.target_repo_id.as_str(), "repository id")?; + w.raw(&r.agent_key); + w.u8(r.required_capability.tag_byte()); + w.len(r.scope.paths.len(), "scope path count")?; + for p in &r.scope.paths { + w.str(p, "scope path")?; + } + w.u8(r.scope.reference.map_or(0, ReferenceKind::tag_byte)); + match r.scope.join_change { + None => w.u8(0), + Some(id) => { + w.u8(1); + w.raw(&id.0); + } + } + w.raw(&r.request_nonce); + w.u64(r.timestamp_ms); + w.bytes(&r.payload, "payload")?; + w.raw(&r.agent_signature); + } + FrameBody::Accepted(a) => { + w.u64(a.wal_seq.0); + w.raw(&a.changeset_id.0); + w.u8(u8::from(a.duplicate)); + } + FrameBody::Refused(r) => { + w.str(&refusal_code_name(r.code), "refusal code")?; + w.str(&r.message, "refusal message")?; + } + } + Ok(()) +} + +/// Encode one frame. Fails only when a field cannot be represented (a length above `u32`, +/// an invalid repository id, unsorted digests, an empty or over-deep chain). +pub fn encode_frame(frame: &Frame) -> SynapseResult> { + let mut w = Writer(Vec::with_capacity(64)); + w.raw(&WIRE_MAGIC); + w.u8(WIRE_VERSION); + w.u8(frame.body.kind().byte()); + w.u8(0); + w.u8(0); + w.u32(frame.request_id); + w.u32(0); + put_body(&mut w, &frame.body)?; + let body_len = w.0.len() - FRAME_HEADER_LEN; + let body_len = u32::try_from(body_len).map_err(|_| too_large("frame body"))?; + w.0[12..16].copy_from_slice(&body_len.to_le_bytes()); + Ok(w.0) +} + +/// Encode one frame and refuse it (`QuotaPayloadTooLarge`) when its body exceeds the +/// peer's `max_frame_body`, since the peer would refuse it anyway. +pub fn encode_frame_within(frame: &Frame, limits: &WireLimits) -> SynapseResult> { + let bytes = encode_frame(frame)?; + let body = bytes.len() - FRAME_HEADER_LEN; + if body as u64 > u64::from(limits.max_frame_body) { + return Err(SynapseError::new( + RefusalCode::QuotaPayloadTooLarge, + format!( + "{} frame body {body} exceeds the peer's max_frame_body {}", + frame.body.kind().name(), + limits.max_frame_body + ), + )); + } + Ok(bytes) +} + +// --------------------------------------------------------------------------------------- +// Decoder +// --------------------------------------------------------------------------------------- + +/// Record that the decoder reached this source line. +macro_rules! cov { + ($r:expr) => { + $r.probe.site(line!()) + }; +} + +struct Reader<'b, 'p, P: Probe> { + buf: &'b [u8], + pos: usize, + /// Absolute offset of `buf[0]` in the frame (for refusal offsets and the probe). + base: usize, + cap: u64, + probe: &'p mut P, +} + +impl<'b, P: Probe> Reader<'b, '_, P> { + fn at(&self) -> usize { + self.base + self.pos + } + + fn remaining(&self) -> usize { + self.buf.len() - self.pos + } + + fn take(&mut self, n: usize) -> Decoded<&'b [u8]> { + if n > self.remaining() { + cov!(self); + return Err(WireRefusal::Truncated { + at: self.at(), + need: n - self.remaining(), + }); + } + let s = &self.buf[self.pos..self.pos + n]; + self.pos += n; + let end = self.at(); + self.probe.touched(end); + Ok(s) + } + + fn array(&mut self) -> Decoded<[u8; N]> { + let mut a = [0u8; N]; + a.copy_from_slice(self.take(N)?); + Ok(a) + } + + fn u8(&mut self) -> Decoded { + Ok(self.take(1)?[0]) + } + fn u32(&mut self) -> Decoded { + Ok(u32::from_le_bytes(self.array()?)) + } + fn u64(&mut self) -> Decoded { + Ok(u64::from_le_bytes(self.array()?)) + } + + /// A `u32` length of a byte run: checked against the cap, then the body. + fn byte_len(&mut self) -> Decoded { + let at = self.at(); + let n = self.u32()?; + if u64::from(n) > self.cap { + cov!(self); + return Err(WireRefusal::LengthOverCap { + at, + declared: u64::from(n), + cap: self.cap, + }); + } + let n = n as usize; + if n > self.remaining() { + cov!(self); + return Err(WireRefusal::Truncated { + at: self.at(), + need: n - self.remaining(), + }); + } + cov!(self); + Ok(n) + } + + fn bytes(&mut self) -> Decoded> { + let n = self.byte_len()?; + Ok(self.take(n)?.to_vec()) + } + + fn str(&mut self) -> Decoded { + let at = self.at(); + let n = self.byte_len()?; + let raw = self.take(n)?; + match std::str::from_utf8(raw) { + Ok(s) => { + cov!(self); + Ok(s.to_owned()) + } + Err(_) => { + cov!(self); + Err(WireRefusal::InvalidUtf8 { at }) + } + } + } + + /// A `u32` count of items at least `min_item` bytes each: checked against the cap and + /// the body before anything is reserved. + fn count(&mut self, min_item: usize) -> Decoded { + let at = self.at(); + let n = self.u32()?; + let need = u64::from(n) * min_item as u64; + if need > self.cap { + cov!(self); + return Err(WireRefusal::LengthOverCap { + at, + declared: need, + cap: self.cap, + }); + } + if need > self.remaining() as u64 { + cov!(self); + return Err(WireRefusal::Truncated { + at: self.at(), + need: need as usize - self.remaining(), + }); + } + cov!(self); + Ok(n as usize) + } + + fn repo(&mut self) -> Decoded { + let at = self.at(); + let s = self.str()?; + match RepoId::new(s) { + Ok(r) => { + cov!(self); + Ok(r) + } + Err(_) => { + cov!(self); + Err(WireRefusal::InvalidRepoId { at }) + } + } + } + + /// `u32 count | digest*count`, strictly increasing. + fn digests(&mut self) -> Decoded> { + let n = self.count(32)?; + let mut out: Vec = Vec::with_capacity(n); + for _ in 0..n { + let at = self.at(); + let d = BlobDigest(self.array()?); + if out.last().is_some_and(|p| p.0 >= d.0) { + cov!(self); + return Err(WireRefusal::NotCanonical { + at, + field: "digest order", + }); + } + cov!(self); + out.push(d); + } + Ok(out) + } + + fn finish(&mut self) -> Decoded<()> { + if self.remaining() != 0 { + cov!(self); + return Err(WireRefusal::TrailingBytes { + at: self.at(), + count: self.remaining(), + }); + } + cov!(self); + Ok(()) + } +} + +fn capability_from_tag(tag: u8) -> Option { + match tag { + 1 => Some(Capability::Read), + 2 => Some(Capability::Propose), + 3 => Some(Capability::Evaluate), + 4 => Some(Capability::Review), + 5 => Some(Capability::Publish), + 6 => Some(Capability::Undo), + _ => None, + } +} + +fn refusal_code_from_name(name: &str) -> Option { + if name.is_empty() || name.len() > MAX_REFUSAL_CODE_LEN { + return None; + } + if !name.bytes().all(|b| b.is_ascii_alphanumeric()) { + return None; + } + let code: RefusalCode = serde_json::from_value(serde_json::Value::String(name.into())).ok()?; + (refusal_code_name(code) == name).then_some(code) +} + +fn get_submit(r: &mut Reader<'_, '_, P>) -> Decoded { + let chain_at = r.at(); + let chain_bytes = { + let n = r.byte_len()?; + r.take(n)? + }; + let chain = match CapabilityChain::decode(chain_bytes) { + Ok(c) => c, + Err(e) => { + cov!(r); + return Err(WireRefusal::Chain { + at: chain_at, + code: e.code, + }); + } + }; + if chain.encode() != chain_bytes { + cov!(r); + return Err(WireRefusal::NotCanonical { + at: chain_at, + field: "capability chain", + }); + } + cov!(r); + let target_repo_id = r.repo()?; + let agent_key = r.array()?; + let cap_at = r.at(); + let cap_tag = r.u8()?; + let Some(required_capability) = capability_from_tag(cap_tag) else { + cov!(r); + return Err(WireRefusal::UnknownTag { + at: cap_at, + field: "capability", + tag: cap_tag, + }); + }; + cov!(r); + let paths_at = r.at(); + let n = r.count(4)?; + // Each path costs 4 wire bytes at least but a whole `String` in memory: bound the + // decoded size, not only the wire size, by the cap (found by the fuzzer). + let decoded = n as u64 * std::mem::size_of::() as u64; + if decoded > r.cap { + cov!(r); + return Err(WireRefusal::LengthOverCap { + at: paths_at, + declared: decoded, + cap: r.cap, + }); + } + let mut paths = Vec::with_capacity(n); + for _ in 0..n { + paths.push(r.str()?); + } + let ref_at = r.at(); + let reference = match r.u8()? { + 0 => None, + 1 => Some(ReferenceKind::OwnDrafts), + 2 => Some(ReferenceKind::CanonicalViaPromotionQueue), + tag => { + cov!(r); + return Err(WireRefusal::UnknownTag { + at: ref_at, + field: "reference kind", + tag, + }); + } + }; + cov!(r); + let join_at = r.at(); + let join_change = match r.u8()? { + 0 => None, + 1 => Some(ChangeId(r.array()?)), + tag => { + cov!(r); + return Err(WireRefusal::UnknownTag { + at: join_at, + field: "join change option", + tag, + }); + } + }; + cov!(r); + let request_nonce = r.array()?; + let timestamp_ms = r.u64()?; + let payload = r.bytes()?; + let agent_signature = r.array()?; + cov!(r); + Ok(ChainedRequest { + chain, + target_repo_id, + agent_key, + required_capability, + scope: RequestScope { + paths, + reference, + join_change, + }, + request_nonce, + timestamp_ms, + payload, + agent_signature, + }) +} + +fn get_body(r: &mut Reader<'_, '_, P>, kind: FrameKind) -> Decoded { + let body = match kind { + FrameKind::Hello => { + cov!(r); + FrameBody::Hello(Hello { + max_frame_body: r.u32()?, + max_pending_chunk_bytes: r.u64()?, + }) + } + FrameKind::Have => { + cov!(r); + let repo_id = r.repo()?; + FrameBody::Have(Have { + repo_id, + digests: r.digests()?, + }) + } + FrameKind::Want => { + cov!(r); + FrameBody::Want(Want { + digests: r.digests()?, + }) + } + FrameKind::Chunk => { + cov!(r); + let digest = BlobDigest(r.array()?); + FrameBody::Chunk(Chunk { + digest, + bytes: r.bytes()?, + }) + } + FrameKind::Submit => { + cov!(r); + FrameBody::Submit(Box::new(get_submit(r)?)) + } + FrameKind::Accepted => { + cov!(r); + let wal_seq = WalSeq(r.u64()?); + let changeset_id = ChangesetId(r.array()?); + let at = r.at(); + let duplicate = match r.u8()? { + 0 => false, + 1 => true, + tag => { + cov!(r); + return Err(WireRefusal::UnknownTag { + at, + field: "duplicate", + tag, + }); + } + }; + FrameBody::Accepted(Accepted { + wal_seq, + changeset_id, + duplicate, + }) + } + FrameKind::Refused => { + cov!(r); + let at = r.at(); + let name = r.str()?; + let Some(code) = refusal_code_from_name(&name) else { + cov!(r); + return Err(WireRefusal::UnknownRefusalCode { at }); + }; + FrameBody::Refused(Refused { + code, + message: r.str()?, + }) + } + }; + r.finish()?; + Ok(body) +} + +fn header_probed( + bytes: &[u8], + limits: &WireLimits, + probe: &mut P, +) -> Decoded { + let mut r = Reader { + buf: bytes, + pos: 0, + base: 0, + cap: u64::from(limits.max_frame_body), + probe, + }; + let h: [u8; FRAME_HEADER_LEN] = r.array()?; + cov!(r); + let magic: [u8; 4] = h[0..4].try_into().expect("4 bytes"); + if magic != WIRE_MAGIC { + cov!(r); + return Err(WireRefusal::BadMagic { found: magic }); + } + if h[4] != WIRE_VERSION { + cov!(r); + return Err(WireRefusal::VersionUnsupported { found: h[4] }); + } + let Some(kind) = FrameKind::from_byte(h[5]) else { + cov!(r); + return Err(WireRefusal::UnknownKind { found: h[5] }); + }; + if h[6] != 0 { + cov!(r); + return Err(WireRefusal::FlagsNonZero { found: h[6] }); + } + if h[7] != 0 { + cov!(r); + return Err(WireRefusal::ReservedNonZero { found: h[7] }); + } + let request_id = u32::from_le_bytes(h[8..12].try_into().expect("4 bytes")); + let body_len = u32::from_le_bytes(h[12..16].try_into().expect("4 bytes")); + if body_len > limits.max_frame_body { + cov!(r); + return Err(WireRefusal::LengthOverCap { + at: 12, + declared: u64::from(body_len), + cap: u64::from(limits.max_frame_body), + }); + } + cov!(r); + Ok(FrameHeader { + kind, + request_id, + body_len, + }) +} + +/// Parse and check the 16-byte header (magic, version, kind, flags, reserved, and the +/// declared body length against `limits`). Reads at most [`FRAME_HEADER_LEN`] bytes. +pub fn decode_header(bytes: &[u8], limits: &WireLimits) -> Result { + header_probed(bytes, limits, &mut NoProbe) +} + +/// Decode a body of exactly `header.body_len` bytes (as read from a stream after +/// [`decode_header`]). +pub fn decode_body( + header: &FrameHeader, + body: &[u8], + limits: &WireLimits, +) -> Result { + body_probed(header, body, limits, &mut NoProbe) +} + +fn body_probed( + header: &FrameHeader, + body: &[u8], + limits: &WireLimits, + probe: &mut P, +) -> Decoded { + if body.len() != header.body_len as usize { + return Err(WireRefusal::Truncated { + at: FRAME_HEADER_LEN + body.len().min(header.body_len as usize), + need: (header.body_len as usize).saturating_sub(body.len()), + }); + } + let mut r = Reader { + buf: body, + pos: 0, + base: FRAME_HEADER_LEN, + cap: u64::from(limits.max_frame_body), + probe, + }; + let body = get_body(&mut r, header.kind)?; + Ok(Frame { + request_id: header.request_id, + body, + }) +} + +/// Decode the first frame of `buf` (a stream buffer that may hold more frames after it). +/// Returns the frame and the number of bytes it occupies. Only the first +/// `16 + body_len` bytes are ever read. +pub fn decode_frame(buf: &[u8], limits: &WireLimits) -> Result<(Frame, usize), WireRefusal> { + decode_frame_probed(buf, limits, &mut NoProbe) +} + +/// [`decode_frame`] reporting decoder states and reads to `probe` (used by the fuzzer). +pub fn decode_frame_probed( + buf: &[u8], + limits: &WireLimits, + probe: &mut P, +) -> Result<(Frame, usize), WireRefusal> { + let header = header_probed(buf, limits, probe)?; + let end = header.frame_len(); + if buf.len() < end { + probe.site(line!()); + return Err(WireRefusal::Truncated { + at: buf.len(), + need: end - buf.len(), + }); + } + let frame = body_probed(&header, &buf[FRAME_HEADER_LEN..end], limits, probe)?; + Ok((frame, end)) +} diff --git a/crates/synapse-wire/src/fuzz.rs b/crates/synapse-wire/src/fuzz.rs new file mode 100644 index 0000000..9a5ea94 --- /dev/null +++ b/crates/synapse-wire/src/fuzz.rs @@ -0,0 +1,718 @@ +//! In-repository coverage-guided fuzzer for the untrusted frame decoder (step G1). +//! +//! What it is, plainly: a deterministic mutation loop with edge-coverage feedback. The +//! decoder in `frame.rs` is compiled with an [`EdgeProbe`] at every branch (AFL-style edge +//! map over source-line sites); an input that reaches a new edge, or an edge a new number of +//! times (hit-count bucket), joins the corpus and is mutated further. It is not libFuzzer or +//! AFL: there is no compiler instrumentation, so coverage is exactly the instrumented +//! decoder states of `frame.rs` (the capability chain decoder of `synapse-auth` and the +//! envelope decoder of `synapse-store::codec` run, and are checked, but are not +//! instrumented). The budget (executions or seconds) and the seed are fixed before a run. +//! +//! The target is what a server does with untrusted bytes: [`decode_frame`] on the input, +//! then, for a `Submit` frame, `decode_envelope` on its payload. Every execution checks: +//! * no panic (`catch_unwind`); +//! * no read past the frame: the probe's high-water mark never exceeds the declared frame +//! end, and decoding the input followed by different trailing bytes gives the same answer +//! whenever the input already held the whole declared frame; +//! * no allocation above the cap: the largest single allocation during the decode is at +//! most `max_frame_body` (needs [`CountingAlloc`] as the global allocator); +//! * a frame that decodes re-encodes to exactly the bytes it was decoded from, and a +//! payload that decodes as an envelope re-encodes to exactly the payload; +//! * everything else is a typed [`WireRefusal`] (or a typed `CodecRefusal` for a payload). + +use crate::frame::{ + decode_frame, decode_frame_probed, encode_frame, Frame, FrameBody, WireLimits, WireRefusal, + FRAME_HEADER_LEN, +}; +use crate::probe::{bucket, EdgeProbe, EDGE_MAP_LEN}; +use std::alloc::{GlobalAlloc, Layout, System}; +use std::cell::Cell; +use std::collections::BTreeMap; +use std::panic::{catch_unwind, AssertUnwindSafe}; +use std::time::Instant; +use synapse_store::codec::{decode_envelope, encode_envelope}; +use synapse_store::CodecRefusal; + +// --------------------------------------------------------------------------------------- +// Allocation accounting +// --------------------------------------------------------------------------------------- + +thread_local! { + static TRACK: Cell = const { Cell::new(false) }; + static PEAK: Cell = const { Cell::new(0) }; + static TOTAL: Cell = const { Cell::new(0) }; +} + +fn note(size: usize) { + let _ = TRACK.try_with(|t| { + if t.get() { + let _ = PEAK.try_with(|p| p.set(p.get().max(size))); + let _ = TOTAL.try_with(|p| p.set(p.get().saturating_add(size))); + } + }); +} + +/// Global allocator that records, per thread and only while a measurement is open, the +/// largest single allocation and the total bytes allocated. Install it in the binary or +/// test that runs the fuzzer: `#[global_allocator] static A: CountingAlloc = CountingAlloc;` +pub struct CountingAlloc; + +// SAFETY: every method forwards to `System` with the same arguments; the bookkeeping only +// touches thread-local `Cell`s through `try_with`, which never allocates. +unsafe impl GlobalAlloc for CountingAlloc { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + note(layout.size()); + System.alloc(layout) + } + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + note(layout.size()); + System.alloc_zeroed(layout) + } + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + note(new_size); + System.realloc(ptr, layout, new_size) + } + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + System.dealloc(ptr, layout) + } +} + +thread_local! { + static QUIET_PANICS: Cell = const { Cell::new(false) }; +} + +/// Silence the panic message of expected (caught) panics on this thread only, leaving the +/// process panic hook in place for every other thread (test harness threads included). +fn quiet_panics_on_this_thread() { + static INSTALL: std::sync::Once = std::sync::Once::new(); + INSTALL.call_once(|| { + let previous = std::panic::take_hook(); + std::panic::set_hook(Box::new(move |info| { + if !QUIET_PANICS.try_with(|q| q.get()).unwrap_or(false) { + previous(info); + } + })); + }); + QUIET_PANICS.with(|q| q.set(true)); +} +/// Run `f`, returning its result (or panic) with (largest single allocation, total bytes). +pub fn measured(f: impl FnOnce() -> T) -> (std::thread::Result, usize, usize) { + PEAK.with(|p| p.set(0)); + TOTAL.with(|p| p.set(0)); + TRACK.with(|t| t.set(true)); + let r = catch_unwind(AssertUnwindSafe(f)); + TRACK.with(|t| t.set(false)); + (r, PEAK.with(|p| p.get()), TOTAL.with(|p| p.get())) +} + +/// True when [`CountingAlloc`] is the global allocator (a probe allocation is seen). +pub fn alloc_tracking_installed() -> bool { + let (_, peak, _) = measured(|| std::hint::black_box(vec![0u8; 4321])); + peak >= 4321 +} + +// --------------------------------------------------------------------------------------- +// Target +// --------------------------------------------------------------------------------------- + +/// What the server-side decode of one input produced. +#[derive(Debug, Clone, PartialEq, Eq)] +#[allow(clippy::large_enum_variant)] // built once per execution; boxing buys nothing here +pub enum TargetOutcome { + /// A frame of `consumed` bytes; for a `Submit`, the payload's envelope decode result. + Accepted { + frame: Frame, + consumed: usize, + payload: Option>, + }, + Refused(WireRefusal), +} + +fn target_with( + input: &[u8], + limits: &WireLimits, + probe: &mut P, +) -> TargetOutcome { + match decode_frame_probed(input, limits, probe) { + Ok((frame, consumed)) => { + let payload = match &frame.body { + FrameBody::Submit(req) => Some(decode_envelope( + &req.payload, + u64::from(limits.max_frame_body), + )), + _ => None, + }; + TargetOutcome::Accepted { + frame, + consumed, + payload, + } + } + Err(r) => TargetOutcome::Refused(r), + } +} + +/// A fuzz target: decode untrusted `input` under `limits`, reporting to the probe. +pub type Target = fn(&[u8], &WireLimits, &mut EdgeProbe) -> TargetOutcome; + +/// The real target: [`decode_frame_probed`], then `decode_envelope` on a `Submit` payload. +pub fn server_decode(input: &[u8], limits: &WireLimits, probe: &mut EdgeProbe) -> TargetOutcome { + target_with(input, limits, probe) +} + +/// The real target without instrumentation. +pub fn target(input: &[u8], limits: &WireLimits) -> TargetOutcome { + target_with(input, limits, &mut crate::probe::NoProbe) +} + +/// Declared end of the frame at the start of `input` (header length plus `body_len`), or +/// the header length when the header is incomplete. +fn declared_end(input: &[u8]) -> usize { + if input.len() < FRAME_HEADER_LEN { + return FRAME_HEADER_LEN; + } + let n = u32::from_le_bytes(input[12..16].try_into().expect("4 bytes")); + FRAME_HEADER_LEN + n as usize +} + +// --------------------------------------------------------------------------------------- +// Engine +// --------------------------------------------------------------------------------------- + +/// Deterministic PRNG (SplitMix64). +#[derive(Debug, Clone)] +pub struct SplitMix64(pub u64); + +impl SplitMix64 { + pub fn next_u64(&mut self) -> u64 { + self.0 = self.0.wrapping_add(0x9E37_79B9_7F4A_7C15); + let mut z = self.0; + z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); + z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); + z ^ (z >> 31) + } + pub fn below(&mut self, n: usize) -> usize { + if n == 0 { + 0 + } else { + (self.next_u64() % n as u64) as usize + } + } + fn chance(&mut self, num: usize, den: usize) -> bool { + self.below(den) < num + } +} + +/// When the run stops; fixed before the run. +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum Budget { + Execs(u64), + Seconds(f64), +} + +#[derive(Debug, Clone)] +pub struct FuzzConfig { + pub seed: u64, + pub budget: Budget, + pub limits: WireLimits, + /// Corpus size limit (new-coverage inputs beyond it are counted, not kept). + pub max_corpus: usize, +} + +/// One broken invariant, with the input that broke it. +#[derive(Debug, Clone)] +pub struct Violation { + pub kind: &'static str, + pub detail: String, + pub input: Vec, +} + +#[derive(Debug, Clone, Default)] +pub struct FuzzReport { + pub execs: u64, + pub elapsed_s: f64, + pub seeds: usize, + /// Distinct edges reached. + pub edges: usize, + /// Inputs that reached new coverage (seeds first), in discovery order. + pub corpus: Vec>, + /// Executions at which each non-seed corpus entry was found. + pub corpus_found_at: Vec, + /// Count per outcome class: `accepted:`, `refused:`, + /// `payload_accepted`, `payload_refused:`. + pub outcomes: BTreeMap, + pub violation_counts: BTreeMap<&'static str, u64>, + /// First violations of each kind (at most 4 each). + pub violations: Vec, + /// Largest single allocation in any decode, bytes. + pub peak_alloc: usize, + /// Largest total bytes allocated by one decode. + pub peak_alloc_total: usize, + pub alloc_tracking: bool, + pub largest_input: usize, + /// Instrumented decoder sites (source lines of `frame.rs`) in total, and those never + /// reached during the run. + pub sites_total: usize, + pub sites_unreached: Vec, +} + +impl FuzzReport { + pub fn violation_total(&self) -> u64 { + self.violation_counts.values().sum() + } + + fn violate(&mut self, kind: &'static str, detail: String, input: &[u8]) { + let n = self.violation_counts.entry(kind).or_insert(0); + *n += 1; + if *n <= 4 { + self.violations.push(Violation { + kind, + detail, + input: input.to_vec(), + }); + } + } +} + +fn classify(out: &TargetOutcome, outcomes: &mut BTreeMap) { + let mut add = |k: String| *outcomes.entry(k).or_insert(0) += 1; + match out { + TargetOutcome::Accepted { frame, payload, .. } => { + add(format!("accepted:{}", frame.body.kind().name())); + match payload { + Some(Ok(_)) => add("payload_accepted".into()), + Some(Err(r)) => add(format!("payload_refused:{}", r.kind())), + None => {} + } + } + TargetOutcome::Refused(r) => add(format!("refused:{}", r.kind())), + } +} + +/// Invariant checks on one execution's outcome. Returns the violations found. +fn check_outcome( + input: &[u8], + out: &TargetOutcome, + limits: &WireLimits, +) -> Vec<(&'static str, String)> { + let mut v = Vec::new(); + if let TargetOutcome::Accepted { + frame, + consumed, + payload, + } = out + { + match encode_frame(frame) { + Ok(bytes) if bytes.as_slice() == &input[..*consumed] => {} + Ok(bytes) => v.push(( + "non_canonical_accept", + format!("re-encoded {} bytes differ from {consumed}", bytes.len()), + )), + Err(e) => v.push(("non_canonical_accept", format!("re-encode refused: {e}"))), + } + if let (Some(Ok(env)), FrameBody::Submit(req)) = (payload, &frame.body) { + match encode_envelope(env) { + Ok(b) if b == req.payload => {} + _ => v.push(( + "payload_non_canonical", + "payload envelope does not re-encode to its bytes".into(), + )), + } + } + if *consumed > input.len() || *consumed != declared_end(input) { + v.push(( + "read_past_frame", + format!("consumed {consumed} of declared {}", declared_end(input)), + )); + } + } + let _ = limits; + v +} + +struct Engine { + target: Target, + scratch: EdgeProbe, + cfg: FuzzConfig, + rng: SplitMix64, + virgin: Vec, + probe: EdgeProbe, + report: FuzzReport, +} + +const INTERESTING_U8: [u8; 12] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0x7F, 0x80, 0xFF]; + +impl Engine { + fn interesting_u32(&mut self, v: &[u8], off: usize) -> u32 { + let cap = self.cfg.limits.max_frame_body; + let remaining = v.len().saturating_sub(off + 4) as u32; + let choices = [ + 0, + 1, + 2, + 3, + 4, + 16, + 32, + 33, + 64, + cap.saturating_sub(1), + cap, + cap.saturating_add(1), + remaining, + remaining.saturating_add(1), + remaining.saturating_sub(1), + remaining / 32, + remaining / 32 + 1, + v.len() as u32, + 0x7FFF_FFFF, + u32::MAX, + ]; + choices[self.rng.below(choices.len())] + } + + fn mutate(&mut self, base: &[u8]) -> Vec { + let mut v = base.to_vec(); + let rounds = 1 + self.rng.below(4); + for _ in 0..rounds { + let len = v.len(); + match self.rng.below(12) { + 0 if len > 0 => { + let i = self.rng.below(len); + v[i] ^= 1 << self.rng.below(8); + } + 1 if len > 0 => { + let i = self.rng.below(len); + v[i] = self.rng.next_u64() as u8; + } + 2 if len > 0 => { + let i = self.rng.below(len); + v[i] = INTERESTING_U8[self.rng.below(INTERESTING_U8.len())]; + } + 3 if len >= 4 => { + let off = self.rng.below(len - 3); + let x = self.interesting_u32(&v, off); + v[off..off + 4].copy_from_slice(&x.to_le_bytes()); + } + 4 => { + let n = self.rng.below(len + 1); + v.truncate(n); + } + 5 => { + let at = self.rng.below(len + 1); + let n = 1 + self.rng.below(16); + let ins: Vec = (0..n).map(|_| self.rng.next_u64() as u8).collect(); + v.splice(at..at, ins); + } + 6 if len > 0 => { + let a = self.rng.below(len); + let b = (a + 1 + self.rng.below(32)).min(len); + v.drain(a..b); + } + 7 if len > 0 => { + let a = self.rng.below(len); + let b = (a + 1 + self.rng.below(64)).min(len); + let piece = v[a..b].to_vec(); + let at = self.rng.below(len + 1); + v.splice(at..at, piece); + } + 8 if !self.report.corpus.is_empty() => { + let other = + self.report.corpus[self.rng.below(self.report.corpus.len())].clone(); + let cut = self.rng.below(len + 1); + let from = self.rng.below(other.len() + 1); + v.truncate(cut); + v.extend_from_slice(&other[from..]); + } + 9 if len >= 64 => { + // Swap two 32-byte runs (reorders digests and keys). + let a = self.rng.below(len - 31); + let b = self.rng.below(len - 31); + let (x, y) = (v[a..a + 32].to_vec(), v[b..b + 32].to_vec()); + v[a..a + 32].copy_from_slice(&y); + v[b..b + 32].copy_from_slice(&x); + } + 10 if len >= 6 => { + v[5] = self.rng.below(9) as u8; + } + 11 if len >= 4 => { + // Rewrite an aligned u32 near a random position to the bytes left. + let off = self.rng.below(len - 3); + let rem = (len - off - 4) as u32; + v[off..off + 4].copy_from_slice(&rem.to_le_bytes()); + } + _ => {} + } + } + // Half the time keep the declared body length honest so mutations reach the body. + if v.len() >= FRAME_HEADER_LEN && self.rng.chance(1, 2) { + let body = (v.len() - FRAME_HEADER_LEN) as u32; + v[12..16].copy_from_slice(&body.to_le_bytes()); + } + v.truncate(self.cfg.limits.max_frame_body as usize + 2 * FRAME_HEADER_LEN); + v + } + + /// Run one input; returns true when it reached new coverage. + fn exec(&mut self, input: &[u8]) -> bool { + self.report.execs += 1; + self.report.largest_input = self.report.largest_input.max(input.len()); + self.probe.reset(); + let limits = self.cfg.limits; + let probe = &mut self.probe; + let t = self.target; + let (res, peak, total) = measured(|| t(input, &limits, probe)); + let out = match res { + Ok(o) => o, + Err(p) => { + let msg = p + .downcast_ref::<&str>() + .map(|s| s.to_string()) + .or_else(|| p.downcast_ref::().cloned()) + .unwrap_or_default(); + self.report.violate("panic", msg, input); + return self.update_coverage(); + } + }; + self.report.peak_alloc = self.report.peak_alloc.max(peak); + self.report.peak_alloc_total = self.report.peak_alloc_total.max(total); + if peak as u64 > u64::from(limits.max_frame_body) { + self.report.violate( + "alloc_over_cap", + format!( + "allocation of {peak} bytes over cap {}", + limits.max_frame_body + ), + input, + ); + } + let end = declared_end(input).min(input.len()); + if self.probe.high_water > end { + self.report.violate( + "read_past_frame", + format!("read to {} past frame end {end}", self.probe.high_water), + input, + ); + } + for (kind, detail) in check_outcome(input, &out, &limits) { + self.report.violate(kind, detail, input); + } + // Trailing-bytes differential: a decision made on a complete frame (or a refusal + // other than truncation) must not depend on what follows the frame. + let truncated = matches!(out, TargetOutcome::Refused(WireRefusal::Truncated { .. })); + if !truncated { + let mut longer = input.to_vec(); + let n = 1 + self.rng.below(48); + longer.extend((0..n).map(|_| self.rng.next_u64() as u8)); + self.scratch.reset(); + let out2 = (self.target)(&longer, &limits, &mut self.scratch); + if out2 != out { + self.report.violate( + "read_past_frame", + "outcome changed when bytes were appended after the frame".into(), + input, + ); + } + } + classify(&out, &mut self.report.outcomes); + self.update_coverage() + } + + fn update_coverage(&mut self) -> bool { + let mut new = false; + let (virgin, edges) = (&mut self.virgin, &mut self.report.edges); + self.probe.for_each_hit(|i, c| { + let b = bucket(c); + if virgin[i] & b != b { + if virgin[i] == 0 { + *edges += 1; + } + virgin[i] |= b; + new = true; + } + }); + new + } +} + +/// Run the fuzzer from `seeds` (valid frames) under `cfg`. +pub fn run(cfg: FuzzConfig, seeds: &[Vec]) -> FuzzReport { + run_target(cfg, seeds, server_decode) +} + +/// Run the fuzzer on another target (negative controls: decoders with planted bugs). +pub fn run_target(cfg: FuzzConfig, seeds: &[Vec], target: Target) -> FuzzReport { + let mut e = Engine { + target, + scratch: EdgeProbe::new(), + rng: SplitMix64(cfg.seed), + virgin: vec![0u8; EDGE_MAP_LEN], + probe: EdgeProbe::new(), + report: FuzzReport { + alloc_tracking: alloc_tracking_installed(), + seeds: seeds.len(), + ..Default::default() + }, + cfg, + }; + quiet_panics_on_this_thread(); + let start = Instant::now(); + for s in seeds { + e.exec(s); + e.report.corpus.push(s.clone()); + } + loop { + let stop = match e.cfg.budget { + Budget::Execs(n) => e.report.execs >= n, + Budget::Seconds(s) => { + e.report.execs.is_multiple_of(256) && start.elapsed().as_secs_f64() >= s + } + }; + if stop { + break; + } + let base = e.report.corpus[e.rng.below(e.report.corpus.len())].clone(); + let input = e.mutate(&base); + if e.exec(&input) && e.report.corpus.len() < e.cfg.max_corpus { + e.report.corpus.push(input); + e.report.corpus_found_at.push(e.report.execs); + } + } + e.report.elapsed_s = start.elapsed().as_secs_f64(); + let lines = crate::probe::instrumented_lines(); + e.report.sites_total = lines.len(); + e.report.sites_unreached = lines + .into_iter() + .filter(|l| !e.probe.sites_seen[*l as usize & (crate::probe::SITE_LINES - 1)]) + .collect(); + QUIET_PANICS.with(|q| q.set(false)); + e.report +} + +/// Replay of a saved corpus without instrumentation. +#[derive(Debug, Clone, Default)] +pub struct CorpusReplay { + pub entries: usize, + /// Entries that decoded and re-encoded to identical bytes (well-formed frames). + pub accepted_canonical: usize, + /// Malformed entries, by typed refusal kind. + pub refused: BTreeMap, + /// Entries that panicked, decoded non-canonically, or allocated over the cap. + pub violations: Vec<(usize, String)>, + pub peak_alloc: usize, +} + +/// Decode every corpus entry: each must be a canonical frame or a typed refusal. +pub fn replay_corpus(corpus: &[Vec], limits: &WireLimits) -> CorpusReplay { + let mut out = CorpusReplay { + entries: corpus.len(), + ..Default::default() + }; + quiet_panics_on_this_thread(); + for (i, input) in corpus.iter().enumerate() { + let (res, peak, _) = measured(|| target(input, limits)); + out.peak_alloc = out.peak_alloc.max(peak); + if peak as u64 > u64::from(limits.max_frame_body) { + out.violations + .push((i, format!("allocation {peak} over cap"))); + } + match res { + Err(_) => out.violations.push((i, "panic".into())), + Ok(o) => { + let v = check_outcome(input, &o, limits); + if !v.is_empty() { + out.violations.push((i, format!("{v:?}"))); + } else { + match &o { + TargetOutcome::Accepted { .. } => out.accepted_canonical += 1, + TargetOutcome::Refused(r) => { + *out.refused.entry(r.kind().to_string()).or_insert(0) += 1 + } + } + } + } + } + } + QUIET_PANICS.with(|q| q.set(false)); + out +} + +/// Serialise a corpus as `u32 count | (u32 len | bytes)*` (little endian). +pub fn corpus_to_bytes(corpus: &[Vec]) -> Vec { + let mut b = Vec::new(); + b.extend_from_slice(&(corpus.len() as u32).to_le_bytes()); + for c in corpus { + b.extend_from_slice(&(c.len() as u32).to_le_bytes()); + b.extend_from_slice(c); + } + b +} + +/// Parse [`corpus_to_bytes`] output; `None` if malformed. +pub fn corpus_from_bytes(b: &[u8]) -> Option>> { + let take4 = |at: usize| -> Option { + Some(u32::from_le_bytes(b.get(at..at + 4)?.try_into().ok()?) as usize) + }; + let n = take4(0)?; + let mut at = 4; + let mut out = Vec::new(); + for _ in 0..n { + let len = take4(at)?; + at += 4; + out.push(b.get(at..at + len)?.to_vec()); + at += len; + } + (at == b.len()).then_some(out) +} + +/// Encoded seed frames ([`crate::testkit::sample_frames`]) that fit `limits`. +pub fn seed_corpus(limits: &WireLimits) -> Vec> { + crate::testkit::sample_frames() + .iter() + .map(|f| encode_frame(f).expect("sample frames encode")) + .filter(|b| b.len() - FRAME_HEADER_LEN <= limits.max_frame_body as usize) + .collect() +} + +/// Malformed frames derived from every seed: wrong magic, version, kind (0 and 8), flags, +/// reserved byte, declared length one over the cap, one byte short, and one trailing byte +/// inside the declared body. Every one must be refused; they join the corpus as seeds. +pub fn malformed_seed_corpus(limits: &WireLimits) -> Vec> { + let mut out = Vec::new(); + for good in seed_corpus(limits) { + let with = |i: usize, v: u8| { + let mut b = good.clone(); + b[i] = v; + b + }; + out.push(with(0, b'X')); + out.push(with(4, 2)); + out.push(with(5, 0)); + out.push(with(5, 8)); + out.push(with(6, 1)); + out.push(with(7, 0x80)); + let mut over = good.clone(); + over[12..16].copy_from_slice(&(limits.max_frame_body.saturating_add(1)).to_le_bytes()); + out.push(over); + out.push(good[..good.len() - 1].to_vec()); + let mut trailing = good.clone(); + trailing.push(0); + let n = (trailing.len() - FRAME_HEADER_LEN) as u32; + trailing[12..16].copy_from_slice(&n.to_le_bytes()); + out.push(trailing); + } + out +} + +/// Decode check used by tests: decode `bytes` fully. +pub fn decode_exact(bytes: &[u8], limits: &WireLimits) -> Result { + let (f, n) = decode_frame(bytes, limits)?; + if n != bytes.len() { + return Err(WireRefusal::TrailingBytes { + at: n, + count: bytes.len() - n, + }); + } + Ok(f) +} diff --git a/crates/synapse-wire/src/lib.rs b/crates/synapse-wire/src/lib.rs new file mode 100644 index 0000000..b7270eb --- /dev/null +++ b/crates/synapse-wire/src/lib.rs @@ -0,0 +1,27 @@ +//! Synapse wire protocol (ADR 0003 section 8 crate `synapse-wire`, step G1). +//! +//! * [`frame`]: length-prefixed binary frames (hello, have, want, chunk, submit, accepted, +//! refused) with one canonical encoding each, and an untrusted-input decoder that checks +//! every declared length against a cap before it allocates or reads, and refuses anything +//! else with a typed [`frame::WireRefusal`]. +//! * [`transport`]: framed connections over any reliable byte stream (Unix socket, TCP). +//! * [`session`]: have-want chunk negotiation (only blobs the server lacks cross the wire) +//! and change submission authorised by a capability chain (step F1), admitted by the +//! group-commit store and acknowledged once durable. +//! * [`fuzz`]: the in-repository coverage-guided fuzzer for the frame decoder, with +//! [`probe`] supplying the edge feedback. +//! * [`testkit`]: deterministic fixtures for tests, the fuzz seed corpus, and benchmarks. + +pub mod frame; +pub mod fuzz; +pub mod probe; +pub mod session; +pub mod testkit; +pub mod transport; + +pub use frame::{ + decode_frame, encode_frame, Frame, FrameBody, FrameKind, WireLimits, WireRefusal, + DEFAULT_MAX_FRAME_BODY, FRAME_HEADER_LEN, +}; +pub use session::{ServerConfig, SubmitReport, WireClient, WireServer}; +pub use transport::FrameConn; diff --git a/crates/synapse-wire/src/probe.rs b/crates/synapse-wire/src/probe.rs new file mode 100644 index 0000000..fb78db9 --- /dev/null +++ b/crates/synapse-wire/src/probe.rs @@ -0,0 +1,162 @@ +//! Coverage probes for the frame decoder. +//! +//! The decoder is generic over a [`Probe`]. Production code passes [`NoProbe`], whose +//! methods are empty and inline away, so the decoder carries no instrumentation cost. The +//! in-repository fuzzer ([`crate::fuzz`]) passes an [`EdgeProbe`], which records every +//! transition between instrumented decoder states (an AFL-style edge map: the edge index is +//! `prev ^ cur` over hashed site ids) and the highest input offset the decoder touched. +//! +//! A site id is the source line of the probe call (`line!()`), so every instrumented branch +//! of `frame.rs` is a distinct state. + +/// Receives decoder state transitions and input reads. +pub trait Probe { + /// The decoder reached instrumented state `site`. + fn site(&mut self, site: u32); + /// The decoder read input bytes up to (not including) absolute offset `end`. + fn touched(&mut self, end: usize); +} + +/// The production probe: records nothing. +#[derive(Debug, Default, Clone, Copy)] +pub struct NoProbe; + +impl Probe for NoProbe { + #[inline(always)] + fn site(&mut self, _site: u32) {} + #[inline(always)] + fn touched(&mut self, _end: usize) {} +} + +/// Size of the edge map (a power of two). +pub const EDGE_MAP_LEN: usize = 1 << 16; + +/// Most distinct edges one execution records in the touched list before falling back +/// to a full scan of the map. +pub const TOUCHED_CAP: usize = 4096; + +/// Source lines tracked for site reach (sites on later lines share slots modulo this). +pub const SITE_LINES: usize = 1 << 13; + +/// Edge-coverage probe used by the fuzzer. +#[derive(Clone)] +pub struct EdgeProbe { + prev: u32, + /// Hit count per edge index (saturating). + pub map: Box<[u8]>, + /// Indices of the edges hit in this execution (preallocated, never grows), unless + /// `overflow` is set. + touched: Vec, + overflow: bool, + /// Every site id (source line) reached since creation; not cleared by `reset`. + pub sites_seen: Box<[bool]>, + /// Highest absolute input offset read (exclusive end). + pub high_water: usize, +} + +impl Default for EdgeProbe { + fn default() -> Self { + Self::new() + } +} + +impl EdgeProbe { + pub fn new() -> Self { + Self { + prev: 0, + map: vec![0u8; EDGE_MAP_LEN].into_boxed_slice(), + touched: Vec::with_capacity(TOUCHED_CAP), + overflow: false, + sites_seen: vec![false; SITE_LINES].into_boxed_slice(), + high_water: 0, + } + } + + /// Clear the map and high-water mark for the next execution (no allocation). + pub fn reset(&mut self) { + self.prev = 0; + if self.overflow { + self.map.fill(0); + } else { + for &i in &self.touched { + self.map[i as usize] = 0; + } + } + self.touched.clear(); + self.overflow = false; + self.high_water = 0; + } + + /// Call `f(index, count)` for every edge hit in this execution. + pub fn for_each_hit(&self, mut f: impl FnMut(usize, u8)) { + if self.overflow { + for (i, &c) in self.map.iter().enumerate() { + if c != 0 { + f(i, c); + } + } + } else { + for &i in &self.touched { + f(i as usize, self.map[i as usize]); + } + } + } +} + +/// Spread a site id over the edge map (Fibonacci hashing). +fn hash_site(site: u32) -> u32 { + (site.wrapping_mul(0x9E37_79B1) >> 16) & (EDGE_MAP_LEN as u32 - 1) +} + +impl Probe for EdgeProbe { + fn site(&mut self, site: u32) { + self.sites_seen[site as usize & (SITE_LINES - 1)] = true; + let cur = hash_site(site); + let idx = ((self.prev ^ cur) as usize) & (EDGE_MAP_LEN - 1); + if self.map[idx] == 0 { + if self.touched.len() < TOUCHED_CAP { + self.touched.push(idx as u32); + } else { + self.overflow = true; + } + } + self.map[idx] = self.map[idx].saturating_add(1); + self.prev = cur >> 1; + } + + fn touched(&mut self, end: usize) { + self.high_water = self.high_water.max(end); + } +} + +/// AFL-style hit-count bucket of one edge (bit per bucket), so a loop that runs more often +/// counts as new behaviour without every extra iteration counting. +pub fn bucket(count: u8) -> u8 { + match count { + 0 => 0, + 1 => 1, + 2 => 2, + 3 => 4, + 4..=7 => 8, + 8..=15 => 16, + 16..=31 => 32, + 32..=127 => 64, + _ => 128, + } +} + +/// Source lines of `frame.rs` that hold an instrumented site (`cov!` or +/// `probe.site(line!())`), so a run can report which sites it never reached. +pub fn instrumented_lines() -> Vec { + include_str!("frame.rs") + .lines() + .enumerate() + .filter(|(_, l)| { + let t = l.trim_start(); + !t.starts_with("//") + && !t.starts_with("$r.") + && (t.starts_with("cov!(") || t.starts_with("probe.site(line!())")) + }) + .map(|(i, _)| i as u32 + 1) + .collect() +} diff --git a/crates/synapse-wire/src/session.rs b/crates/synapse-wire/src/session.rs new file mode 100644 index 0000000..4596756 --- /dev/null +++ b/crates/synapse-wire/src/session.rs @@ -0,0 +1,613 @@ +//! Have-want chunk negotiation and change submission over wire frames. +//! +//! One change crosses the transport in two round trips: +//! +//! ```text +//! client server +//! Hello -------------------------------> (once per connection, both ways) +//! <------------------------------- Hello +//! Have {repo, digests the change needs} -> +//! <---------- Want {the offered digests the server lacks} +//! Chunk * |Want|, Submit {chained request} -> (one write) +//! <--------------- Accepted {wal_seq} | Refused {code} +//! ``` +//! +//! The server lacks a digest when no committed changeset references it and no chunk of the +//! current negotiation carried it, so a chunk the server already holds is never resent +//! (FindMissingBlobs style, ADR 0003 section 5.9). Until G2 a chunk is a whole blob. +//! +//! Server rules (each break is a typed refusal, and the negotiation is reset): +//! * `Hello` first, once (`WireProtocolViolation`). +//! * One `Have` per negotiation, for the server's repository (`AuthCrossRepoDenied`). +//! * A `Chunk` must be wanted and not yet received (`WireProtocolViolation`), match its +//! digest (`BlobDigestMismatch`), and fit the pending-bytes cap (`QuotaPayloadTooLarge`). +//! * A `Submit` must come after every wanted chunk (`WireProtocolViolation`); its payload +//! must be one canonical binary envelope (`WireFrameMalformed`); its capability chain is +//! checked by `PolicyEnforcer::authorize_chain` (step F1) with `Capability::Propose`; the +//! envelope must be for this repository and authored by the leaf audience, and the request +//! scope must list exactly the envelope's paths; then the store admits it with group commit +//! and the reply is sent only after the change is durable. +//! * A frame the server never accepts from a client (`Want`, `Accepted`, `Refused`) is a +//! `WireProtocolViolation`. A malformed frame is refused with `WireFrameMalformed` and the +//! connection is closed, since framing can no longer be trusted. + +use crate::frame::{Accepted, Chunk, Frame, FrameBody, Have, Hello, Refused, Want, WireLimits}; +use crate::transport::FrameConn; +use ed25519_dalek::SigningKey; +use std::collections::{BTreeMap, BTreeSet}; +use std::io::{Read, Write}; +use std::sync::{Arc, Mutex}; +use synapse_auth::{ + BoundaryKind, Capability, CapabilityChain, ChainedRequest, PolicyEnforcer, RequestScope, +}; +use synapse_core::{ + BlobDigest, ChangesetEnvelope, MutationOp, RefusalCode, RepoId, SynapseError, SynapseResult, + WalSeq, +}; +use synapse_store::codec::{decode_envelope, encode_envelope}; +use synapse_store::{IngestOutcome, SharedStore}; + +/// Default cap on chunk bytes buffered for one negotiation (64 MiB). +pub const DEFAULT_MAX_PENDING_CHUNK_BYTES: u64 = 64 << 20; + +fn violation(msg: impl Into) -> SynapseError { + SynapseError::new(RefusalCode::WireProtocolViolation, msg) +} + +/// Build the chained `Propose` request that carries `envelope` over the wire: payload is the +/// binary envelope, scope paths are exactly the envelope's mutation paths. +pub fn submit_request( + agent_key: &SigningKey, + chain: CapabilityChain, + envelope: &ChangesetEnvelope, + request_nonce: [u8; 32], + timestamp_ms: u64, +) -> SynapseResult { + Ok(ChainedRequest::sign_new( + agent_key, + chain, + envelope.repo_id.clone(), + Capability::Propose, + RequestScope { + paths: envelope.mutations.iter().map(|m| m.path.clone()).collect(), + reference: None, + join_change: None, + }, + request_nonce, + timestamp_ms, + encode_envelope(envelope)?, + )) +} + +/// Digests of the blobs an envelope's upserts reference. +fn upsert_digests(envelope: &ChangesetEnvelope) -> impl Iterator + '_ { + envelope.mutations.iter().filter_map(|m| match &m.op { + MutationOp::Upsert { blob_digest, .. } => Some(*blob_digest), + MutationOp::Delete => None, + }) +} + +/// Server configuration. +#[derive(Debug, Clone)] +pub struct ServerConfig { + pub repo_id: RepoId, + /// Limits for frames the server reads (announced in its `Hello`). + pub read_limits: WireLimits, + pub max_pending_chunk_bytes: u64, +} + +/// A wire server for one repository over a shared group-commit store. +#[derive(Clone)] +pub struct WireServer { + cfg: ServerConfig, + store: Arc, + auth: Arc>, + known: Arc>>, + clock: Arc u64 + Send + Sync>, +} + +fn lock(m: &Mutex) -> std::sync::MutexGuard<'_, T> { + m.lock().unwrap_or_else(|p| p.into_inner()) +} + +impl WireServer { + /// Serve `store` with `auth` (holding the repository authority and granted links). + /// `clock` returns the server time in milliseconds. + pub fn new( + cfg: ServerConfig, + store: Arc, + auth: PolicyEnforcer, + clock: Arc u64 + Send + Sync>, + ) -> SynapseResult { + let mut known = BTreeSet::new(); + for cs in store.read().list_changesets(None, None, None)? { + known.extend(upsert_digests(&cs.envelope)); + } + Ok(Self { + cfg, + store, + auth: Arc::new(Mutex::new(auth)), + known: Arc::new(Mutex::new(known)), + clock, + }) + } + + pub fn config(&self) -> &ServerConfig { + &self.cfg + } + + pub fn store(&self) -> &Arc { + &self.store + } + + /// Whether a committed changeset references `digest`. + pub fn knows(&self, digest: &BlobDigest) -> bool { + lock(&self.known).contains(digest) + } + + /// A new per-connection session. + pub fn session(&self) -> Session<'_> { + Session { + server: self, + hello_done: false, + neg: Negotiation::default(), + } + } + + /// Serve one connection until the peer closes it or sends a malformed frame. + pub fn serve(&self, stream: S) -> SynapseResult { + let mut conn = FrameConn::new(stream, self.cfg.read_limits); + let mut session = self.session(); + loop { + match conn.recv() { + Ok(None) => break, + Ok(Some(frame)) => { + if let (false, FrameBody::Hello(h)) = (session.hello_done, &frame.body) { + conn.peer_limits = WireLimits { + max_frame_body: h.max_frame_body, + }; + } + let reply = session.handle(frame); + for f in &reply.frames { + // A reply the peer's own cap refuses cannot be sent: close. + if conn.queue(f).is_err() { + conn.flush()?; + return Ok(conn_stats(&conn)); + } + } + conn.flush()?; + if reply.close { + break; + } + } + Err(e) if e.code == RefusalCode::WireFrameMalformed => { + conn.send(&Frame { + request_id: 0, + body: FrameBody::Refused(Refused { + code: e.code, + message: e.message, + }), + })?; + break; + } + Err(e) => return Err(e), + } + } + Ok(conn_stats(&conn)) + } +} + +fn conn_stats(conn: &FrameConn) -> FrameConnStats { + FrameConnStats { + bytes_sent: conn.bytes_sent, + bytes_received: conn.bytes_received, + frames_sent: conn.frames_sent, + frames_received: conn.frames_received, + } +} + +/// Byte and frame counts of one served connection. +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub struct FrameConnStats { + pub bytes_sent: u64, + pub bytes_received: u64, + pub frames_sent: u64, + pub frames_received: u64, +} + +#[derive(Debug, Default)] +struct Negotiation { + active: bool, + wanted: BTreeSet, + received: BTreeMap>, + pending_bytes: u64, +} + +/// Frames to send back, and whether to close the connection after them. +#[derive(Debug, Default)] +pub struct Reply { + pub frames: Vec, + pub close: bool, +} + +/// Server state of one connection. +pub struct Session<'a> { + server: &'a WireServer, + hello_done: bool, + neg: Negotiation, +} + +impl Session<'_> { + fn refuse(&mut self, request_id: u32, e: SynapseError) -> Reply { + self.neg = Negotiation::default(); + Reply { + frames: vec![Frame { + request_id, + body: FrameBody::Refused(Refused { + code: e.code, + message: e.message, + }), + }], + close: false, + } + } + + /// Handle one well-formed frame from the client. + pub fn handle(&mut self, frame: Frame) -> Reply { + let id = frame.request_id; + let reply_body = match (self.hello_done, frame.body) { + (false, FrameBody::Hello(_)) => { + self.hello_done = true; + Ok(Some(FrameBody::Hello(Hello { + max_frame_body: self.server.cfg.read_limits.max_frame_body, + max_pending_chunk_bytes: self.server.cfg.max_pending_chunk_bytes, + }))) + } + (false, other) => { + let mut r = self.refuse( + id, + violation(format!( + "{} before Hello: Hello must be the first frame", + other.kind().name() + )), + ); + r.close = true; + return r; + } + (true, FrameBody::Hello(_)) => Err(violation("second Hello on one connection")), + (true, FrameBody::Have(h)) => self.have(h).map(|w| Some(FrameBody::Want(w))), + (true, FrameBody::Chunk(c)) => self.chunk(c).map(|()| None), + (true, FrameBody::Submit(req)) => self.submit(*req).map(|a| { + self.neg = Negotiation::default(); + Some(FrameBody::Accepted(a)) + }), + ( + true, + other @ (FrameBody::Want(_) | FrameBody::Accepted(_) | FrameBody::Refused(_)), + ) => Err(violation(format!( + "a server never accepts {} from a client", + other.kind().name() + ))), + }; + match reply_body { + Ok(Some(body)) => Reply { + frames: vec![Frame { + request_id: id, + body, + }], + close: false, + }, + Ok(None) => Reply::default(), + Err(e) => self.refuse(id, e), + } + } + + fn have(&mut self, h: Have) -> SynapseResult { + if self.neg.active { + return Err(violation("Have while a negotiation is open (Submit first)")); + } + if h.repo_id != self.server.cfg.repo_id { + return Err(SynapseError::new( + RefusalCode::AuthCrossRepoDenied, + format!( + "Have for {} on a server for {}", + h.repo_id, self.server.cfg.repo_id + ), + )); + } + let known = lock(&self.server.known); + let wanted: Vec = h + .digests + .iter() + .filter(|d| !known.contains(d)) + .copied() + .collect(); + drop(known); + self.neg = Negotiation { + active: true, + wanted: wanted.iter().copied().collect(), + received: BTreeMap::new(), + pending_bytes: 0, + }; + Ok(Want { digests: wanted }) + } + + fn chunk(&mut self, c: Chunk) -> SynapseResult<()> { + if !self.neg.wanted.contains(&c.digest) { + return Err(violation(format!( + "unsolicited chunk {} (not in the last Want)", + c.digest + ))); + } + if self.neg.received.contains_key(&c.digest) { + return Err(violation(format!("chunk {} sent twice", c.digest))); + } + let computed = BlobDigest::compute(&c.bytes); + if computed != c.digest { + return Err(SynapseError::new( + RefusalCode::BlobDigestMismatch, + format!( + "chunk declared {} but its bytes hash to {computed}", + c.digest + ), + )); + } + let pending = self.neg.pending_bytes + c.bytes.len() as u64; + if pending > self.server.cfg.max_pending_chunk_bytes { + return Err(SynapseError::new( + RefusalCode::QuotaPayloadTooLarge, + format!( + "pending chunk bytes {pending} exceed max_pending_chunk_bytes {}", + self.server.cfg.max_pending_chunk_bytes + ), + )); + } + self.neg.pending_bytes = pending; + self.neg.received.insert(c.digest, c.bytes); + Ok(()) + } + + fn submit(&mut self, req: ChainedRequest) -> SynapseResult { + let srv = self.server; + if let Some(missing) = self + .neg + .wanted + .iter() + .find(|d| !self.neg.received.contains_key(d)) + { + return Err(violation(format!( + "Submit before wanted chunk {missing} arrived" + ))); + } + let envelope = decode_envelope(&req.payload, u64::from(srv.cfg.read_limits.max_frame_body)) + .map_err(|r| { + r.into_error(RefusalCode::WireFrameMalformed, "Submit payload envelope") + })?; + let now_ms = (srv.clock)(); + let request_seq = WalSeq(srv.store.read().committed_seq().0 + 1); + lock(&srv.auth).authorize_chain( + BoundaryKind::Api, + "wire_submit", + &srv.cfg.repo_id, + Capability::Propose, + &req, + request_seq, + now_ms, + )?; + if envelope.repo_id != srv.cfg.repo_id { + return Err(SynapseError::new( + RefusalCode::AuthCrossRepoDenied, + "envelope repo_id does not match the server's repository", + )); + } + if envelope.author_did != req.agent_did() { + return Err(SynapseError::new( + RefusalCode::AuthSignatureInvalid, + "envelope author_did is not the chain's leaf audience", + )); + } + if req.scope.paths.len() != envelope.mutations.len() + || req + .scope + .paths + .iter() + .zip(&envelope.mutations) + .any(|(p, m)| p != &m.path) + { + return Err(SynapseError::new( + RefusalCode::AuthPathOutOfScope, + "request scope must list exactly the envelope's mutation paths", + )); + } + let blobs: Vec<(BlobDigest, Vec)> = + std::mem::take(&mut self.neg.received).into_iter().collect(); + let digests: Vec = upsert_digests(&envelope).collect(); + let outcome = srv.store.submit(envelope, &blobs)?; + lock(&srv.known).extend(digests); + Ok(match outcome { + IngestOutcome::Committed { + wal_seq, + changeset_id, + .. + } => Accepted { + wal_seq, + changeset_id, + duplicate: false, + }, + IngestOutcome::IdempotentDuplicate { + wal_seq, + changeset_id, + } => Accepted { + wal_seq, + changeset_id, + duplicate: true, + }, + }) + } +} + +/// What one submission cost on the wire. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct SubmitReport { + pub accepted: Accepted, + /// Digests offered in the `Have` (0 when the change carries no blobs). + pub offered: usize, + /// Digests the server wanted, so chunks sent. + pub wanted: usize, + pub chunk_bytes_sent: u64, + /// Frame bytes written and read for this submission. + pub wire_bytes_sent: u64, + pub wire_bytes_received: u64, +} + +/// Client side of a wire connection. +pub struct WireClient { + conn: FrameConn, + next_id: u32, + pub server_hello: Hello, +} + +impl WireClient { + /// Exchange `Hello` frames. `read_limits` caps frames this client reads. + pub fn connect(stream: S, read_limits: WireLimits) -> SynapseResult { + let mut conn = FrameConn::new(stream, read_limits); + conn.send(&Frame { + request_id: 1, + body: FrameBody::Hello(Hello { + max_frame_body: read_limits.max_frame_body, + max_pending_chunk_bytes: 0, + }), + })?; + let server_hello = match Self::expect(&mut conn)? { + FrameBody::Hello(h) => h, + other => { + return Err(violation(format!( + "server answered Hello with {}", + other.kind().name() + ))) + } + }; + conn.peer_limits = WireLimits { + max_frame_body: server_hello.max_frame_body, + }; + Ok(Self { + conn, + next_id: 2, + server_hello, + }) + } + + fn expect(conn: &mut FrameConn) -> SynapseResult { + match conn.recv()? { + None => Err(SynapseError::new( + RefusalCode::IoFailure, + "server closed the connection", + )), + Some(Frame { + body: FrameBody::Refused(r), + .. + }) => Err(SynapseError::new(r.code, r.message)), + Some(f) => Ok(f.body), + } + } + + fn id(&mut self) -> u32 { + let id = self.next_id; + self.next_id = self.next_id.wrapping_add(1); + id + } + + /// Submit one change: negotiate which of `blobs` the server lacks, send only those, then + /// the request. Returns after the server's durable acknowledgement. + pub fn submit( + &mut self, + req: &ChainedRequest, + blobs: &[(BlobDigest, Vec)], + ) -> SynapseResult { + let (sent0, recv0) = (self.conn.bytes_sent, self.conn.bytes_received); + let mut by_digest: BTreeMap = BTreeMap::new(); + for (d, b) in blobs { + by_digest.insert(*d, b); + } + let offered = by_digest.len(); + let mut wanted = 0; + let mut chunk_bytes_sent = 0u64; + if offered > 0 { + let id = self.id(); + self.conn.send(&Frame { + request_id: id, + body: FrameBody::Have(Have { + repo_id: req.target_repo_id.clone(), + digests: by_digest.keys().copied().collect(), + }), + })?; + let want = match Self::expect(&mut self.conn)? { + FrameBody::Want(w) => w, + other => { + return Err(violation(format!( + "server answered Have with {}", + other.kind().name() + ))) + } + }; + wanted = want.digests.len(); + for d in &want.digests { + let Some(bytes) = by_digest.get(d) else { + return Err(violation(format!( + "server wanted {d}, which was not offered" + ))); + }; + let id = self.id(); + self.conn.queue(&Frame { + request_id: id, + body: FrameBody::Chunk(Chunk { + digest: *d, + bytes: bytes.to_vec(), + }), + })?; + chunk_bytes_sent += bytes.len() as u64; + } + } + let id = self.id(); + self.conn.queue(&Frame { + request_id: id, + body: FrameBody::Submit(Box::new(req.clone())), + })?; + self.conn.flush()?; + let accepted = match Self::expect(&mut self.conn)? { + FrameBody::Accepted(a) => a, + other => { + return Err(violation(format!( + "server answered Submit with {}", + other.kind().name() + ))) + } + }; + Ok(SubmitReport { + accepted, + offered, + wanted, + chunk_bytes_sent, + wire_bytes_sent: self.conn.bytes_sent - sent0, + wire_bytes_received: self.conn.bytes_received - recv0, + }) + } + + /// Send raw frames and read one reply (tests of server refusals). + pub fn exchange(&mut self, frames: &[Frame]) -> SynapseResult> { + for f in frames { + self.conn.queue(f)?; + } + self.conn.flush()?; + self.conn.recv() + } + + /// Bytes written and read so far, including the hello exchange. + pub fn bytes(&self) -> (u64, u64) { + (self.conn.bytes_sent, self.conn.bytes_received) + } + + pub fn conn_mut(&mut self) -> &mut FrameConn { + &mut self.conn + } +} diff --git a/crates/synapse-wire/src/testkit.rs b/crates/synapse-wire/src/testkit.rs new file mode 100644 index 0000000..3bed157 --- /dev/null +++ b/crates/synapse-wire/src/testkit.rs @@ -0,0 +1,317 @@ +//! Deterministic fixtures shared by the G1 tests, the fuzzer's seed corpus, and the +//! transport benchmark: fixed keys, a capability chain granted by a fixed repository +//! authority, signed envelopes, and one valid frame of every kind. + +use crate::frame::{Accepted, Chunk, Frame, FrameBody, Have, Hello, Refused, Want}; +use crate::session::submit_request; +use ed25519_dalek::SigningKey; +use synapse_auth::{ + Capability, CapabilityChain, CapabilityLink, ChainQuotas, ChangeScope, LinkCaveats, + OperationSet, PathScope, PolicyEnforcer, ReferenceKind, ReferenceScope, ROOT_PARENT, +}; +use synapse_core::{ + encode_did_key_ed25519, BlobDigest, ChangesetEnvelope, ChangesetId, EvidenceAttachment, + FileMode, GitOid, IdempotencyKey, MutationOp, PathMutation, RefusalCode, RepoId, WalSeq, + SYNAPSE_ENVELOPE_VERSION, +}; + +/// Repository of every fixture. +pub const REPO: &str = "aien-spark/synapse"; + +pub fn repo() -> RepoId { + RepoId::new(REPO).expect("valid fixture repository id") +} + +/// Links are valid from 0 to this time (milliseconds, year 2096). +pub const FIXTURE_EXPIRES_AT_MS: u64 = 4_000_000_000_000; + +fn wide_caveats() -> LinkCaveats { + LinkCaveats { + operations: OperationSet::from_capabilities(&[ + Capability::Read, + Capability::Propose, + Capability::Evaluate, + Capability::Review, + Capability::Publish, + Capability::Undo, + ]), + paths: PathScope::whole_repository(), + references: ReferenceScope::from_kinds(&[ + ReferenceKind::OwnDrafts, + ReferenceKind::CanonicalViaPromotionQueue, + ]), + changes: ChangeScope::any(), + quotas: ChainQuotas { + max_ops_per_window: 10_000_000, + window_duration_ms: 60_000, + storage_bytes: 1 << 40, + footprint_paths: 1 << 30, + max_bytes_per_op: 64 << 20, + }, + issued_at_ms: 0, + expires_at_ms: FIXTURE_EXPIRES_AT_MS, + } +} + +/// A repository authority, an agent, and a granted chain from the authority to the agent. +pub struct ChainFixture { + pub authority: SigningKey, + pub agent: SigningKey, + pub chain: CapabilityChain, + /// Chain prefixes, shortest first, in grant order. + prefixes: Vec, +} + +impl ChainFixture { + /// A chain of `depth` links (1 to 3): authority, then intermediate keys, then the agent. + /// `paths` narrows the leaf link's path scope (`None`: whole repository). + pub fn new(depth: usize, paths: Option>) -> Self { + assert!((1..=3).contains(&depth), "fixture depth 1..=3"); + let authority = SigningKey::from_bytes(&[0x11; 32]); + let mids = [ + SigningKey::from_bytes(&[0x22; 32]), + SigningKey::from_bytes(&[0x33; 32]), + ]; + let agent = SigningKey::from_bytes(&[0x44; 32]); + let mut signer = authority.clone(); + let mut parent = ROOT_PARENT; + let mut links = Vec::new(); + let mut prefixes = Vec::new(); + let audiences: Vec = mids[..depth - 1] + .iter() + .cloned() + .chain([agent.clone()]) + .collect(); + for (i, audience) in audiences.into_iter().enumerate() { + let mut caveats = wide_caveats(); + if i + 1 == depth { + if let Some(p) = &paths { + caveats.paths = PathScope::new(p.clone()).expect("valid fixture path scope"); + } + } + let link = CapabilityLink::issue( + &signer, + parent, + [0xA0 + i as u8; 32], + repo(), + audience.verifying_key().to_bytes(), + caveats, + ); + parent = link.digest(); + links.push(link); + prefixes.push(CapabilityChain::new(links.clone())); + signer = audience; + } + Self { + authority, + agent, + chain: CapabilityChain::new(links), + prefixes, + } + } + + pub fn agent_did(&self) -> String { + encode_did_key_ed25519(&self.agent.verifying_key().to_bytes()) + } + + /// An enforcer that trusts the authority and has granted every link at `WalSeq(0)`. + pub fn enforcer(&self) -> PolicyEnforcer { + let mut e = PolicyEnforcer::new(); + e.register_repo_authority( + repo(), + encode_did_key_ed25519(&self.authority.verifying_key().to_bytes()), + ); + for c in &self.prefixes { + e.grant_link(c, WalSeq(0), 1).expect("fixture link grants"); + } + e + } +} + +/// A signed envelope by `agent` upserting `files` and deleting `deletes`, plus its blobs. +/// Paths are sorted, as the envelope requires. +pub fn envelope( + agent: &SigningKey, + label: &str, + files: &[(&str, Vec)], + deletes: &[&str], + created_at_ms: u64, +) -> (ChangesetEnvelope, Vec<(BlobDigest, Vec)>) { + let mut mutations = Vec::new(); + let mut blobs = Vec::new(); + for (path, bytes) in files { + let d = BlobDigest::compute(bytes); + mutations.push(PathMutation { + path: (*path).to_string(), + op: MutationOp::Upsert { + mode: FileMode::Regular644, + blob_digest: d, + size_bytes: bytes.len() as u64, + }, + }); + blobs.push((d, bytes.clone())); + } + for path in deletes { + mutations.push(PathMutation { + path: (*path).to_string(), + op: MutationOp::Delete, + }); + } + mutations.sort_by(|a, b| a.path.cmp(&b.path)); + let mut env = ChangesetEnvelope { + version: SYNAPSE_ENVELOPE_VERSION, + repo_id: repo(), + base_git_oid: GitOid([0x5A; 20]), + parent_changesets: Vec::new(), + author_did: encode_did_key_ed25519(&agent.verifying_key().to_bytes()), + idempotency_key: IdempotencyKey::from_label(label), + created_at_ms, + intent_summary: format!("G1 fixture change {label}"), + mutations, + evidence_receipts: Vec::new(), + signature: Vec::new(), + }; + env.sign(agent); + (env, blobs) +} + +fn digest(n: u8) -> BlobDigest { + let mut d = [n; 32]; + d[0] = n; + BlobDigest(d) +} + +/// At least one valid frame of every kind, with edge cases (empty lists, empty chunk, +/// depth 1 and depth 3 chains, an envelope with evidence and a delete, every option tag). +pub fn sample_frames() -> Vec { + let deep = ChainFixture::new(3, None); + let shallow = ChainFixture::new(1, None); + let (env, _) = envelope( + &deep.agent, + "sample", + &[("crates/a.rs", b"fn a() {}\n".to_vec())], + &["docs/old.md"], + 7, + ); + let mut env_evidence = env.clone(); + env_evidence.evidence_receipts.push(EvidenceAttachment { + gate_name: "unit".into(), + passed: true, + artifact_digest: [9u8; 32], + summary: "ok".into(), + }); + env_evidence.sign(&deep.agent); + let req = submit_request(&deep.agent, deep.chain.clone(), &env, [1u8; 32], 7).expect("req"); + let mut req_scoped = + submit_request(&deep.agent, deep.chain.clone(), &env_evidence, [2u8; 32], 8).expect("req"); + req_scoped.scope.reference = Some(ReferenceKind::OwnDrafts); + req_scoped.scope.join_change = Some(synapse_core::ChangeId([3u8; 16])); + let (env1, _) = envelope(&shallow.agent, "shallow", &[], &["x"], 9); + let mut req_shallow = + submit_request(&shallow.agent, shallow.chain.clone(), &env1, [4u8; 32], 9).expect("req"); + req_shallow.scope.reference = Some(ReferenceKind::CanonicalViaPromotionQueue); + let bodies = vec![ + FrameBody::Hello(Hello { + max_frame_body: 4096, + max_pending_chunk_bytes: 1 << 20, + }), + FrameBody::Have(Have { + repo_id: repo(), + digests: vec![], + }), + FrameBody::Have(Have { + repo_id: repo(), + digests: vec![digest(1), digest(2), digest(3)], + }), + FrameBody::Want(Want { digests: vec![] }), + FrameBody::Want(Want { + digests: vec![digest(2)], + }), + FrameBody::Chunk(Chunk { + digest: BlobDigest::compute(b""), + bytes: vec![], + }), + FrameBody::Chunk(Chunk { + digest: BlobDigest::compute(b"fn a() {}\n"), + bytes: b"fn a() {}\n".to_vec(), + }), + FrameBody::Submit(Box::new(req)), + FrameBody::Submit(Box::new(req_scoped)), + FrameBody::Submit(Box::new(req_shallow)), + FrameBody::Accepted(Accepted { + wal_seq: WalSeq(42), + changeset_id: ChangesetId([6u8; 32]), + duplicate: false, + }), + FrameBody::Accepted(Accepted { + wal_seq: WalSeq(u64::MAX), + changeset_id: ChangesetId([0u8; 32]), + duplicate: true, + }), + FrameBody::Refused(Refused { + code: RefusalCode::WireProtocolViolation, + message: "Submit before wanted chunk".into(), + }), + FrameBody::Refused(Refused { + code: RefusalCode::AuthChainBroken, + message: String::new(), + }), + ]; + bodies + .into_iter() + .enumerate() + .map(|(i, body)| Frame { + request_id: i as u32 * 7919, + body, + }) + .collect() +} + +/// A fresh empty directory under the system temp directory. +pub fn temp_dir(label: &str) -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!( + "synapse-wire-{label}-{}-{}", + std::process::id(), + std::time::SystemTime::now() + .duration_since(std::time::UNIX_EPOCH) + .map(|d| d.as_nanos()) + .unwrap_or(0) + )); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).expect("create temp dir"); + dir +} + +/// A shared group-commit store (default group-commit policy, strict recovery). +pub fn open_store(dir: &std::path::Path) -> std::sync::Arc { + std::sync::Arc::new( + synapse_store::SharedStore::open( + dir, + synapse_store::FsyncPolicy::GROUP_COMMIT_DEFAULT, + synapse_store::RecoveryPolicy::StrictFailClosed, + synapse_store::StoreLimits::default(), + ) + .expect("open shared store"), + ) +} + +/// Server time used by fixture servers (milliseconds). +pub const FIXTURE_NOW_MS: u64 = 1_000_000; + +/// A wire server for [`REPO`] over `store`, trusting `fx`'s authority, with a fixed clock. +pub fn server( + fx: &ChainFixture, + store: std::sync::Arc, +) -> crate::WireServer { + crate::WireServer::new( + crate::ServerConfig { + repo_id: repo(), + read_limits: crate::WireLimits::default(), + max_pending_chunk_bytes: crate::session::DEFAULT_MAX_PENDING_CHUNK_BYTES, + }, + store, + fx.enforcer(), + std::sync::Arc::new(|| FIXTURE_NOW_MS), + ) + .expect("wire server") +} diff --git a/crates/synapse-wire/src/transport.rs b/crates/synapse-wire/src/transport.rs new file mode 100644 index 0000000..18eb528 --- /dev/null +++ b/crates/synapse-wire/src/transport.rs @@ -0,0 +1,149 @@ +//! Stream transports for wire frames. +//! +//! Any reliable, ordered byte stream works (`UnixStream`, `TcpStream`, an in-memory pipe). +//! The reader takes the 16-byte header first, checks the declared body length against its +//! cap, and only then allocates and reads exactly that many bytes, so a hostile peer cannot +//! make it allocate more than `max_frame_body` or consume bytes of the next frame. +//! Outgoing frames are queued and written with one `write_all` per [`FrameConn::flush`]. + +use crate::frame::{ + decode_body, decode_header, encode_frame_within, Frame, WireLimits, WireRefusal, + FRAME_HEADER_LEN, +}; +use std::io::{BufReader, ErrorKind, Read, Write}; +use synapse_core::{RefusalCode, SynapseError, SynapseResult}; + +fn io(e: std::io::Error) -> SynapseError { + SynapseError::new(RefusalCode::IoFailure, format!("wire transport: {e}")) +} + +/// Read one frame. `Ok(None)` is a clean end of stream at a frame boundary; an end of stream +/// inside a frame is `WireFrameMalformed` (truncated). +pub fn read_frame(r: &mut R, limits: &WireLimits) -> SynapseResult> { + let mut header = [0u8; FRAME_HEADER_LEN]; + let mut got = 0; + while got < FRAME_HEADER_LEN { + match r.read(&mut header[got..]) { + Ok(0) if got == 0 => return Ok(None), + Ok(0) => { + return Err(WireRefusal::Truncated { + at: got, + need: FRAME_HEADER_LEN - got, + } + .into_error()) + } + Ok(n) => got += n, + Err(e) if e.kind() == ErrorKind::Interrupted => {} + Err(e) => return Err(io(e)), + } + } + let h = decode_header(&header, limits).map_err(WireRefusal::into_error)?; + // Allocation is bounded by the cap checked in `decode_header`. + let mut body = vec![0u8; h.body_len as usize]; + let mut got = 0; + while got < body.len() { + match r.read(&mut body[got..]) { + Ok(0) => { + return Err(WireRefusal::Truncated { + at: FRAME_HEADER_LEN + got, + need: body.len() - got, + } + .into_error()) + } + Ok(n) => got += n, + Err(e) if e.kind() == ErrorKind::Interrupted => {} + Err(e) => return Err(io(e)), + } + } + decode_body(&h, &body, limits) + .map(Some) + .map_err(WireRefusal::into_error) +} + +/// A framed connection over one bidirectional stream, counting bytes in each direction. +pub struct FrameConn { + stream: BufReader, + out: Vec, + /// Limits applied to frames this side reads. + pub read_limits: WireLimits, + /// Limits the peer announced for frames it reads (applied when encoding). + pub peer_limits: WireLimits, + pub bytes_sent: u64, + pub bytes_received: u64, + pub frames_sent: u64, + pub frames_received: u64, +} + +impl FrameConn { + pub fn new(stream: S, read_limits: WireLimits) -> Self { + Self { + stream: BufReader::with_capacity(64 * 1024, stream), + out: Vec::with_capacity(64 * 1024), + read_limits, + peer_limits: read_limits, + bytes_sent: 0, + bytes_received: 0, + frames_sent: 0, + frames_received: 0, + } + } + + /// Queue one frame for the next [`Self::flush`]. Refused (and nothing queued) if it + /// exceeds the peer's announced `max_frame_body`. + pub fn queue(&mut self, frame: &Frame) -> SynapseResult<()> { + let bytes = encode_frame_within(frame, &self.peer_limits)?; + self.out.extend_from_slice(&bytes); + self.frames_sent += 1; + Ok(()) + } + + /// Write every queued frame. + pub fn flush(&mut self) -> SynapseResult<()> { + if self.out.is_empty() { + return Ok(()); + } + let s = self.stream.get_mut(); + s.write_all(&self.out).map_err(io)?; + s.flush().map_err(io)?; + self.bytes_sent += self.out.len() as u64; + self.out.clear(); + Ok(()) + } + + /// Queue and flush one frame. + pub fn send(&mut self, frame: &Frame) -> SynapseResult<()> { + self.queue(frame)?; + self.flush() + } + + /// Read the next frame (`None` at a clean end of stream). + pub fn recv(&mut self) -> SynapseResult> { + let mut counted = CountingRead { + inner: &mut self.stream, + n: 0, + }; + let frame = read_frame(&mut counted, &self.read_limits); + self.bytes_received += counted.n; + if let Ok(Some(_)) = &frame { + self.frames_received += 1; + } + frame + } + + pub fn get_ref(&self) -> &S { + self.stream.get_ref() + } +} + +struct CountingRead<'a, R: Read> { + inner: &'a mut R, + n: u64, +} + +impl Read for CountingRead<'_, R> { + fn read(&mut self, buf: &mut [u8]) -> std::io::Result { + let n = self.inner.read(buf)?; + self.n += n as u64; + Ok(n) + } +} diff --git a/crates/synapse-wire/tests/g1_fuzz.rs b/crates/synapse-wire/tests/g1_fuzz.rs new file mode 100644 index 0000000..0114602 --- /dev/null +++ b/crates/synapse-wire/tests/g1_fuzz.rs @@ -0,0 +1,255 @@ +//! G1 acceptance: coverage-guided fuzzing of the untrusted length-prefixed frame decoder, +//! for a budget fixed before the run, finds no panic, no read past a frame, and no +//! allocation above the declared cap, and every malformed frame in the fuzz corpus is +//! refused with a typed refusal. +//! +//! The budget here is a fixed execution count (deterministic in CI). The time-budgeted +//! evidence run uses the `synapse-wire-fuzz` binary (see `docs/G1_WIRE_FRAMES.md`). +//! Negative controls plant one bug each in a copy of the target and require the same +//! fuzzer, with the same budget, to report it, so a silent detector cannot pass. + +use synapse_core::RefusalCode; +use synapse_wire::frame::{WireLimits, WireRefusal, FRAME_HEADER_LEN}; +use synapse_wire::fuzz::{ + malformed_seed_corpus, replay_corpus, run, run_target, seed_corpus, server_decode, Budget, + CountingAlloc, FuzzConfig, FuzzReport, TargetOutcome, +}; +use synapse_wire::probe::{EdgeProbe, Probe}; + +#[global_allocator] +static ALLOC: CountingAlloc = CountingAlloc; + +/// Fuzz cap on a frame body (bytes); seeds are all smaller. +const CAP: u32 = 8192; +/// Execution budget, fixed before the run. +const EXECS: u64 = 300_000; +const SEED: u64 = 0x6100_F022; + +fn cfg(execs: u64) -> FuzzConfig { + FuzzConfig { + seed: SEED, + budget: Budget::Execs(execs), + limits: WireLimits { + max_frame_body: CAP, + }, + max_corpus: 20_000, + } +} + +fn seeds() -> Vec> { + let s = seed_corpus(&WireLimits { + max_frame_body: CAP, + }); + assert_eq!(s.len(), VALID_SEEDS, "every sample frame fits the fuzz cap"); + let mut all = s; + all.extend(malformed()); + all +} + +const VALID_SEEDS: usize = 14; + +fn malformed() -> Vec> { + malformed_seed_corpus(&WireLimits { + max_frame_body: CAP, + }) +} + +fn main_run() -> FuzzReport { + run(cfg(EXECS), &seeds()) +} + +#[test] +fn fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap() { + let r = main_run(); + assert!(r.alloc_tracking, "the counting allocator must be installed"); + assert_eq!(r.execs, EXECS); + assert_eq!( + r.violation_total(), + 0, + "violations: {:?}", + r.violations + .iter() + .map(|v| (v.kind, &v.detail)) + .collect::>() + ); + assert!( + r.peak_alloc as u64 <= u64::from(CAP), + "peak {}", + r.peak_alloc + ); + // The run explored the decoder: new coverage beyond the seeds, most sites reached. + assert!(r.corpus.len() > r.seeds, "corpus {}", r.corpus.len()); + assert!( + r.sites_unreached.len() * 10 <= r.sites_total, + "unreached decoder sites (lines of frame.rs): {:?} of {}", + r.sites_unreached, + r.sites_total + ); + // Both accepted and refused outcomes, for every frame kind, were exercised. + for kind in [ + "Hello", "Have", "Want", "Chunk", "Submit", "Accepted", "Refused", + ] { + assert!( + r.outcomes.contains_key(&format!("accepted:{kind}")), + "no accepted {kind}" + ); + } +} + +#[test] +fn every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal() { + let r = main_run(); + let limits = WireLimits { + max_frame_body: CAP, + }; + let replay = replay_corpus(&r.corpus, &limits); + assert!(replay.violations.is_empty(), "{:?}", replay.violations); + let refused: usize = replay.refused.values().sum(); + assert_eq!(replay.entries, replay.accepted_canonical + refused); + // The well-formed seeds are in the corpus and still decode canonically. + assert!( + replay.accepted_canonical >= VALID_SEEDS, + "accepted {} of {VALID_SEEDS} valid seeds", + replay.accepted_canonical + ); + // Every hand-made malformed seed (bad magic, version, kind, flags, reserved, length over + // the cap, truncated, trailing byte) is in the corpus and refused with a typed refusal. + let bad = malformed(); + assert_eq!(bad.len(), VALID_SEEDS * 9); + for (i, input) in bad.iter().enumerate() { + assert_eq!(&r.corpus[VALID_SEEDS + i], input); + match synapse_wire::fuzz::target(input, &limits) { + TargetOutcome::Refused(_) => {} + other => panic!("malformed seed {i} was not refused: {other:?}"), + } + } + assert!(refused > 0); + assert!( + replay.refused.len() >= 10, + "refusal kinds reached: {:?}", + replay.refused + ); + // Each refusal maps to the typed service refusal `WireFrameMalformed`. + for input in &r.corpus { + if let TargetOutcome::Refused(w) = synapse_wire::fuzz::target(input, &limits) { + assert_eq!(w.clone().into_error().code, RefusalCode::WireFrameMalformed); + } + } +} + +// --------------------------------------------------------------------------------------- +// Negative controls: planted bugs the fuzzer must find within the same kind of budget. +// --------------------------------------------------------------------------------------- + +const CONTROL_EXECS: u64 = 60_000; + +fn control(target: synapse_wire::fuzz::Target, kind: &str) { + let r = run_target(cfg(CONTROL_EXECS), &seeds(), target); + assert!( + r.violation_counts.get(kind).copied().unwrap_or(0) > 0, + "planted {kind} bug not found; counts {:?}", + r.violation_counts + ); +} + +/// A decoder that panics on a non-zero flags byte (a missing check before a table lookup). +fn planted_panic(input: &[u8], l: &WireLimits, p: &mut EdgeProbe) -> TargetOutcome { + if input.len() >= FRAME_HEADER_LEN && input[0..4] == *b"SYNW" && input[6] != 0 { + let table = [0u8; 1]; + let i = input[6] as usize; + p.site(1); + let _ = std::hint::black_box(table[std::hint::black_box(i)]); + } + server_decode(input, l, p) +} + +/// A decoder that sizes a buffer from the declared length before checking the cap. +fn planted_over_alloc(input: &[u8], l: &WireLimits, p: &mut EdgeProbe) -> TargetOutcome { + if input.len() >= FRAME_HEADER_LEN { + let n = u32::from_le_bytes(input[12..16].try_into().unwrap()) as usize; + let v: Vec = Vec::with_capacity(n.min(1 << 20)); + std::hint::black_box(v); + } + server_decode(input, l, p) +} + +/// A decoder whose answer depends on the byte after the frame (reads one byte too far). +fn planted_read_past(input: &[u8], l: &WireLimits, p: &mut EdgeProbe) -> TargetOutcome { + let out = server_decode(input, l, p); + if let TargetOutcome::Accepted { consumed, .. } = &out { + if let Some(&next) = input.get(*consumed) { + p.touched(*consumed + 1); + if next & 1 == 1 { + return TargetOutcome::Refused(WireRefusal::TrailingBytes { + at: *consumed, + count: 1, + }); + } + } + } + out +} + +/// A decoder that ignores the reserved byte, so two encodings of one frame decode. +fn planted_non_canonical(input: &[u8], l: &WireLimits, p: &mut EdgeProbe) -> TargetOutcome { + let mut v = input.to_vec(); + if v.len() >= 8 { + v[7] = 0; + } + server_decode(&v, l, p) +} + +#[test] +fn negative_control_fuzzer_finds_planted_panic() { + control(planted_panic, "panic"); +} + +#[test] +fn negative_control_fuzzer_finds_planted_allocation_over_cap() { + control(planted_over_alloc, "alloc_over_cap"); +} + +#[test] +fn negative_control_fuzzer_finds_planted_read_past_frame() { + control(planted_read_past, "read_past_frame"); +} + +#[test] +fn negative_control_fuzzer_finds_planted_non_canonical_accept() { + control(planted_non_canonical, "non_canonical_accept"); +} + +/// Regression from the first 300 s evidence run (`evidence/g1-wire-frames/fuzz-run1-71fa41e/`): a `Submit` +/// whose scope lists many empty paths took 4 wire bytes per path but 24 bytes of memory per +/// decoded `String`, so one allocation passed the cap. The decoder now refuses a path count +/// whose decoded size would pass the cap. +#[test] +fn fuzz_regression_many_scope_paths_stay_under_allocation_cap() { + use synapse_wire::frame::{decode_frame, encode_frame, Frame, FrameBody}; + use synapse_wire::fuzz::measured; + use synapse_wire::testkit::{envelope, ChainFixture}; + let fx = ChainFixture::new(1, None); + let (env, _) = envelope(&fx.agent, "many", &[], &["x"], 1); + let mut req = + synapse_wire::session::submit_request(&fx.agent, fx.chain.clone(), &env, [5; 32], 1) + .unwrap(); + req.scope.paths = vec![String::new(); 400]; + let bytes = encode_frame(&Frame { + request_id: 1, + body: FrameBody::Submit(Box::new(req)), + }) + .unwrap(); + let limits = WireLimits { + max_frame_body: CAP, + }; + assert!(bytes.len() - FRAME_HEADER_LEN <= CAP as usize); + let (res, peak, _) = measured(|| decode_frame(&bytes, &limits)); + assert!( + peak as u64 <= u64::from(CAP), + "largest allocation {peak} over cap {CAP}" + ); + assert!( + matches!(res.unwrap(), Err(WireRefusal::LengthOverCap { .. })), + "refused as over the cap" + ); +} diff --git a/crates/synapse-wire/tests/g1_wire.rs b/crates/synapse-wire/tests/g1_wire.rs new file mode 100644 index 0000000..9aaf2cb --- /dev/null +++ b/crates/synapse-wire/tests/g1_wire.rs @@ -0,0 +1,558 @@ +//! G1 acceptance: every frame kind round-trips to identical bytes; the decoder refuses +//! malformed frames with typed refusals and never reads past a frame; have-want +//! negotiation sends only the chunks the server lacks; a change submitted across a Unix +//! socket is authorised by its capability chain and acknowledged only once durable; and +//! the server refuses protocol breaks with typed refusal codes. + +use std::collections::BTreeSet; +use std::os::unix::net::UnixStream; +use std::thread::JoinHandle; +use synapse_auth::{Capability, ChainedRequest, RequestScope}; +use synapse_core::{RefusalCode, RepoId, SynapseResult}; +use synapse_wire::frame::{ + decode_frame, decode_header, encode_frame, Chunk, Frame, FrameBody, FrameKind, Have, Hello, + Want, WireLimits, WireRefusal, FRAME_HEADER_LEN, +}; +use synapse_wire::session::{submit_request, FrameConnStats}; +use synapse_wire::testkit::{ + envelope, open_store, repo, sample_frames, server, temp_dir, ChainFixture, +}; +use synapse_wire::transport::read_frame; +use synapse_wire::WireClient; + +// --------------------------------------------------------------------------------------- +// Frames +// --------------------------------------------------------------------------------------- + +#[test] +fn every_frame_kind_round_trips_to_identical_bytes() { + let frames = sample_frames(); + let kinds: BTreeSet = frames.iter().map(|f| f.body.kind().byte()).collect(); + assert_eq!(kinds.len(), FrameKind::ALL.len(), "a sample of every kind"); + let limits = WireLimits::default(); + let mut stream = Vec::new(); + for f in &frames { + let bytes = encode_frame(f).unwrap(); + let (back, used) = decode_frame(&bytes, &limits).unwrap(); + assert_eq!(used, bytes.len()); + assert_eq!( + &back, + f, + "{} decodes to the same value", + f.body.kind().name() + ); + assert_eq!( + encode_frame(&back).unwrap(), + bytes, + "{} re-encodes to identical bytes", + f.body.kind().name() + ); + stream.extend_from_slice(&bytes); + } + // Back to back in one stream buffer: each decode takes exactly its own frame. + let mut at = 0; + for f in &frames { + let (back, used) = decode_frame(&stream[at..], &limits).unwrap(); + assert_eq!(&back, f); + at += used; + } + assert_eq!(at, stream.len()); + // And through the stream reader. + let mut r = std::io::Cursor::new(&stream); + for f in &frames { + assert_eq!(read_frame(&mut r, &limits).unwrap().as_ref(), Some(f)); + } + assert!(read_frame(&mut r, &limits).unwrap().is_none()); +} + +fn hello_bytes() -> Vec { + encode_frame(&sample_frames()[0]).unwrap() +} + +#[test] +fn malformed_header_is_refused_with_typed_refusal() { + let limits = WireLimits { + max_frame_body: 1024, + }; + let good = hello_bytes(); + let refuse = |b: &[u8]| decode_frame(b, &limits).unwrap_err(); + let with = |i: usize, v: u8| { + let mut b = good.clone(); + b[i] = v; + b + }; + assert!(matches!( + refuse(&with(0, b'X')), + WireRefusal::BadMagic { .. } + )); + assert!(matches!( + refuse(&with(4, 2)), + WireRefusal::VersionUnsupported { found: 2 } + )); + assert!(matches!( + refuse(&with(5, 0)), + WireRefusal::UnknownKind { found: 0 } + )); + assert!(matches!( + refuse(&with(5, 8)), + WireRefusal::UnknownKind { found: 8 } + )); + assert!(matches!( + refuse(&with(6, 1)), + WireRefusal::FlagsNonZero { found: 1 } + )); + assert!(matches!( + refuse(&with(7, 1)), + WireRefusal::ReservedNonZero { found: 1 } + )); + assert!(matches!( + refuse(&good[..FRAME_HEADER_LEN - 1]), + WireRefusal::Truncated { .. } + )); + assert!(matches!( + refuse(&good[..good.len() - 1]), + WireRefusal::Truncated { .. } + )); + // A declared length over the cap is refused from the header alone: no body needed. + let mut over = good[..FRAME_HEADER_LEN].to_vec(); + over[12..16].copy_from_slice(&1025u32.to_le_bytes()); + assert!(matches!( + refuse(&over), + WireRefusal::LengthOverCap { + declared: 1025, + cap: 1024, + .. + } + )); + // A trailing byte inside the declared body is refused. + let mut trailing = good.clone(); + trailing.push(0); + let n = (trailing.len() - FRAME_HEADER_LEN) as u32; + trailing[12..16].copy_from_slice(&n.to_le_bytes()); + assert!(matches!( + refuse(&trailing), + WireRefusal::TrailingBytes { .. } + )); + // Every refusal is the typed service refusal WireFrameMalformed. + assert_eq!( + refuse(&with(0, b'X')).into_error().code, + RefusalCode::WireFrameMalformed + ); +} + +#[test] +fn malformed_body_is_refused_with_typed_refusal() { + let limits = WireLimits::default(); + let enc = |body: FrameBody| { + encode_frame(&Frame { + request_id: 9, + body, + }) + .unwrap() + }; + let d = |n: u8| synapse_core::BlobDigest([n; 32]); + // Unsorted and repeated digests have a second encoding: refused as not canonical. + let mut unsorted = enc(FrameBody::Want(Want { + digests: vec![d(1), d(2)], + })); + let body = FRAME_HEADER_LEN + 4; + unsorted[body..body + 32].copy_from_slice(&[2; 32]); + unsorted[body + 32..body + 64].copy_from_slice(&[1; 32]); + assert!(matches!( + decode_frame(&unsorted, &limits).unwrap_err(), + WireRefusal::NotCanonical { .. } + )); + let mut repeated = unsorted.clone(); + repeated[body + 32..body + 64].copy_from_slice(&[2; 32]); + assert!(matches!( + decode_frame(&repeated, &limits).unwrap_err(), + WireRefusal::NotCanonical { .. } + )); + // A count that needs more bytes than the body holds is refused before allocating. + let mut count = enc(FrameBody::Want(Want { digests: vec![] })); + count[FRAME_HEADER_LEN..FRAME_HEADER_LEN + 4].copy_from_slice(&u32::MAX.to_le_bytes()); + assert!(matches!( + decode_frame(&count, &limits).unwrap_err(), + WireRefusal::LengthOverCap { .. } | WireRefusal::Truncated { .. } + )); + // An invalid repository id in a Have is refused. + let have = enc(FrameBody::Have(Have { + repo_id: repo(), + digests: vec![], + })); + let mut bad_repo = have.clone(); + bad_repo[FRAME_HEADER_LEN + 4] = b' '; + assert!(matches!( + decode_frame(&bad_repo, &limits).unwrap_err(), + WireRefusal::InvalidRepoId { .. } + )); + let mut bad_utf8 = have; + bad_utf8[FRAME_HEADER_LEN + 4] = 0xFF; + assert!(matches!( + decode_frame(&bad_utf8, &limits).unwrap_err(), + WireRefusal::InvalidUtf8 { .. } + )); +} + +#[test] +fn decoder_never_reads_past_a_frame() { + let limits = WireLimits::default(); + for f in sample_frames() { + let bytes = encode_frame(&f).unwrap(); + // Whatever follows a frame never changes how it decodes. + for tail in [&[][..], &[0u8; 7][..], &[0xFF; 40][..], &hello_bytes()[..]] { + let mut buf = bytes.clone(); + buf.extend_from_slice(tail); + let (back, used) = decode_frame(&buf, &limits).unwrap(); + assert_eq!(used, bytes.len()); + assert_eq!(back, f); + } + // The header alone never decides more than the header: body checks need the body. + let h = decode_header(&bytes, &limits).unwrap(); + assert_eq!(h.frame_len(), bytes.len()); + } +} + +#[test] +fn stream_reader_refuses_length_over_cap_before_reading_the_body() { + let limits = WireLimits { max_frame_body: 64 }; + let mut header = hello_bytes()[..FRAME_HEADER_LEN].to_vec(); + header[12..16].copy_from_slice(&u32::MAX.to_le_bytes()); + // Only the header is available: the reader must refuse without waiting for 4 GiB. + let err = read_frame(&mut std::io::Cursor::new(header), &limits).unwrap_err(); + assert_eq!(err.code, RefusalCode::WireFrameMalformed); + assert!(err.message.contains("LengthOverCap"), "{}", err.message); + // End of stream inside a frame is a typed truncation. + let good = hello_bytes(); + let err = read_frame(&mut std::io::Cursor::new(&good[..20]), &limits).unwrap_err(); + assert_eq!(err.code, RefusalCode::WireFrameMalformed); + assert!(err.message.contains("Truncated"), "{}", err.message); +} + +// --------------------------------------------------------------------------------------- +// Negotiation and submission over a Unix socket +// --------------------------------------------------------------------------------------- + +type ServerThread = JoinHandle>; + +fn connect(srv: &synapse_wire::WireServer) -> (WireClient, ServerThread) { + let (a, b) = UnixStream::pair().unwrap(); + // A missing reply fails the test instead of hanging it. + a.set_read_timeout(Some(std::time::Duration::from_secs(20))) + .unwrap(); + let s = srv.clone(); + let t = std::thread::spawn(move || s.serve(b)); + let c = WireClient::connect(a, WireLimits::default()).unwrap(); + (c, t) +} + +fn blob(tag: u8, len: usize) -> Vec { + (0..len).map(|i| tag ^ (i as u8).wrapping_mul(31)).collect() +} + +#[test] +fn have_want_sends_only_missing_chunks_and_acknowledges_durable_changes() { + let dir = temp_dir("negotiation"); + let fx = ChainFixture::new(2, None); + let shared = blob(0xA1, 3000); + let (b, c) = (blob(0xB2, 3967), blob(0xC3, 3967)); + { + let store = open_store(&dir); + let srv = server(&fx, store.clone()); + let (mut client, t) = connect(&srv); + + // Change 1: both blobs are new, so both are wanted. + let (env1, blobs1) = envelope( + &fx.agent, + "one", + &[("lib/shared.rs", shared.clone()), ("lib/b.rs", b.clone())], + &[], + 10, + ); + let req1 = submit_request(&fx.agent, fx.chain.clone(), &env1, [1; 32], 10).unwrap(); + let r1 = client.submit(&req1, &blobs1).unwrap(); + assert_eq!((r1.offered, r1.wanted), (2, 2)); + assert_eq!(r1.chunk_bytes_sent, (shared.len() + b.len()) as u64); + assert!(!r1.accepted.duplicate); + + // Change 2: the shared blob is already held, so only the new one crosses. + let (env2, blobs2) = envelope( + &fx.agent, + "two", + &[("lib/c.rs", c.clone()), ("lib/shared2.rs", shared.clone())], + &["lib/b.rs"], + 11, + ); + let req2 = submit_request(&fx.agent, fx.chain.clone(), &env2, [2; 32], 11).unwrap(); + let r2 = client.submit(&req2, &blobs2).unwrap(); + assert_eq!((r2.offered, r2.wanted), (2, 1)); + assert_eq!(r2.chunk_bytes_sent, c.len() as u64); + assert!(r2.accepted.wal_seq > r1.accepted.wal_seq); + + // Change 3: every blob is held, so zero chunks cross. + let (env3, blobs3) = envelope(&fx.agent, "three", &[("x/b.rs", b.clone())], &[], 12); + let req3 = submit_request(&fx.agent, fx.chain.clone(), &env3, [3; 32], 12).unwrap(); + let r3 = client.submit(&req3, &blobs3).unwrap(); + assert_eq!((r3.offered, r3.wanted, r3.chunk_bytes_sent), (1, 0, 0)); + assert!(r3.wire_bytes_sent < 2 * 1024, "{}", r3.wire_bytes_sent); + + // Resubmitting a committed change (fresh nonce) is an idempotent duplicate. + let req1b = submit_request(&fx.agent, fx.chain.clone(), &env1, [4; 32], 13).unwrap(); + let r1b = client.submit(&req1b, &blobs1).unwrap(); + assert!(r1b.accepted.duplicate); + assert_eq!(r1b.accepted.changeset_id, r1.accepted.changeset_id); + assert_eq!(r1b.wanted, 0); + + assert_eq!(store.read().committed_seq(), r3.accepted.wal_seq); + drop(client); + let stats = t.join().unwrap().unwrap(); + assert!(stats.frames_received >= 9); + } + // Durable: a fresh open of the directory sees all three changes. + let reopened = open_store(&dir); + let n = reopened + .read() + .list_changesets(None, None, None) + .unwrap() + .len(); + assert_eq!(n, 3); + let _ = std::fs::remove_dir_all(&dir); +} + +// --------------------------------------------------------------------------------------- +// Server refusals +// --------------------------------------------------------------------------------------- + +fn refused_code(reply: Option) -> RefusalCode { + match reply.map(|f| f.body) { + Some(FrameBody::Refused(r)) => r.code, + other => panic!("expected Refused, got {other:?}"), + } +} + +fn frame(id: u32, body: FrameBody) -> Frame { + Frame { + request_id: id, + body, + } +} + +#[test] +fn server_refuses_protocol_violations_with_typed_refusals() { + let dir = temp_dir("refusals"); + let fx = ChainFixture::new(1, Some(vec!["lib".into()])); + let store = open_store(&dir); + let srv = server(&fx, store.clone()); + let (mut client, t) = connect(&srv); + let data = blob(0x5A, 100); + let (env, blobs) = envelope(&fx.agent, "r", &[("lib/r.rs", data.clone())], &[], 5); + let digest = blobs[0].0; + let have = |repo_id: RepoId| { + frame( + 10, + FrameBody::Have(Have { + repo_id, + digests: vec![digest], + }), + ) + }; + + // A chunk nobody asked for. + let c = frame( + 11, + FrameBody::Chunk(Chunk { + digest, + bytes: data.clone(), + }), + ); + assert_eq!( + refused_code(client.exchange(std::slice::from_ref(&c)).unwrap()), + RefusalCode::WireProtocolViolation + ); + // A Have for another repository. + let other = RepoId::new("aien-spark/other").unwrap(); + assert_eq!( + refused_code(client.exchange(&[have(other)]).unwrap()), + RefusalCode::AuthCrossRepoDenied + ); + // Submit before the wanted chunk. + let want = client.exchange(&[have(repo())]).unwrap().unwrap(); + assert!(matches!(want.body, FrameBody::Want(ref w) if w.digests == vec![digest])); + let req = submit_request(&fx.agent, fx.chain.clone(), &env, [7; 32], 5).unwrap(); + let submit = frame(12, FrameBody::Submit(Box::new(req.clone()))); + assert_eq!( + refused_code(client.exchange(std::slice::from_ref(&submit)).unwrap()), + RefusalCode::WireProtocolViolation + ); + // A chunk whose bytes do not hash to its digest. + client.exchange(&[have(repo())]).unwrap(); + let mut wrong = data.clone(); + wrong[0] ^= 1; + let bad = frame( + 13, + FrameBody::Chunk(Chunk { + digest, + bytes: wrong, + }), + ); + assert_eq!( + refused_code(client.exchange(&[bad]).unwrap()), + RefusalCode::BlobDigestMismatch + ); + // The same chunk twice. + client.exchange(&[have(repo())]).unwrap(); + assert_eq!( + refused_code(client.exchange(&[c.clone(), c.clone()]).unwrap()), + RefusalCode::WireProtocolViolation + ); + // Frames a server never accepts from a client, and a second Hello. + for body in [ + FrameBody::Want(Want { digests: vec![] }), + FrameBody::Hello(Hello { + max_frame_body: 1024, + max_pending_chunk_bytes: 0, + }), + ] { + assert_eq!( + refused_code(client.exchange(&[frame(14, body)]).unwrap()), + RefusalCode::WireProtocolViolation + ); + } + // A request scope that does not list exactly the envelope's paths. + let mut narrow = req.clone(); + narrow.scope.paths = vec!["lib".into()]; + narrow.request_nonce = [17; 32]; + let narrow = resign(&fx, narrow); + client.exchange(&[have(repo())]).unwrap(); + assert_eq!( + refused_code( + client + .exchange(&[c.clone(), frame(15, FrameBody::Submit(Box::new(narrow)))]) + .unwrap() + ), + RefusalCode::AuthPathOutOfScope + ); + // A path outside the chain's scope. + let (env_out, blobs_out) = envelope(&fx.agent, "out", &[("src/x.rs", data.clone())], &[], 6); + let req_out = submit_request(&fx.agent, fx.chain.clone(), &env_out, [8; 32], 6).unwrap(); + client.exchange(&[have(repo())]).unwrap(); + let c_out = frame( + 16, + FrameBody::Chunk(Chunk { + digest: blobs_out[0].0, + bytes: data.clone(), + }), + ); + assert_eq!(blobs_out[0].0, digest); + assert_eq!( + refused_code( + client + .exchange(&[c_out, frame(17, FrameBody::Submit(Box::new(req_out)))]) + .unwrap() + ), + RefusalCode::AuthPathOutOfScope + ); + // A request signed by a key that is not the chain's leaf audience. + let stranger = ed25519_dalek::SigningKey::from_bytes(&[0x77; 32]); + let forged = submit_request(&stranger, fx.chain.clone(), &env, [9; 32], 5).unwrap(); + client.exchange(&[have(repo())]).unwrap(); + let code = refused_code( + client + .exchange(&[c.clone(), frame(18, FrameBody::Submit(Box::new(forged)))]) + .unwrap(), + ); + assert!(format!("{code:?}").starts_with("Auth"), "{code:?}"); + // A payload that is not one canonical binary envelope. + let mut junk = req.clone(); + junk.payload = b"not an envelope".to_vec(); + let junk = resign(&fx, junk); + client.exchange(&[have(repo())]).unwrap(); + assert_eq!( + refused_code( + client + .exchange(&[c.clone(), frame(19, FrameBody::Submit(Box::new(junk)))]) + .unwrap() + ), + RefusalCode::WireFrameMalformed + ); + // After every refusal the session still accepts a well-formed change. + let ok = client.submit(&req, &blobs).unwrap(); + assert!(!ok.accepted.duplicate); + assert_eq!(store.read().committed_seq(), ok.accepted.wal_seq); + drop(client); + t.join().unwrap().unwrap(); + let _ = std::fs::remove_dir_all(&dir); +} + +/// Re-sign a request after changing a signed field. +fn resign(fx: &ChainFixture, r: ChainedRequest) -> ChainedRequest { + ChainedRequest::sign_new( + &fx.agent, + r.chain, + r.target_repo_id, + Capability::Propose, + RequestScope { + paths: r.scope.paths, + reference: r.scope.reference, + join_change: r.scope.join_change, + }, + r.request_nonce, + r.timestamp_ms, + r.payload, + ) +} + +#[test] +fn server_closes_connection_on_frame_before_hello_or_malformed_frame() { + use std::io::{Read, Write}; + let dir = temp_dir("close"); + let fx = ChainFixture::new(1, None); + let srv = server(&fx, open_store(&dir)); + let limits = WireLimits::default(); + + // A Have before Hello: refused, then the server closes. + let (mut a, b) = UnixStream::pair().unwrap(); + // A missing reply fails the test instead of hanging it. + a.set_read_timeout(Some(std::time::Duration::from_secs(20))) + .unwrap(); + let s = srv.clone(); + let t = std::thread::spawn(move || s.serve(b)); + let have = encode_frame(&frame( + 1, + FrameBody::Have(Have { + repo_id: repo(), + digests: vec![], + }), + )) + .unwrap(); + a.write_all(&have).unwrap(); + assert_eq!( + refused_code(read_frame(&mut a, &limits).unwrap()), + RefusalCode::WireProtocolViolation + ); + assert!(read_frame(&mut a, &limits).unwrap().is_none()); + t.join().unwrap().unwrap(); + + // Bytes that are not a frame after Hello: refused as malformed, then closed. + let (mut a, b) = UnixStream::pair().unwrap(); + // A missing reply fails the test instead of hanging it. + a.set_read_timeout(Some(std::time::Duration::from_secs(20))) + .unwrap(); + let s = srv.clone(); + let t = std::thread::spawn(move || s.serve(b)); + a.write_all(&hello_bytes()).unwrap(); + assert!(matches!( + read_frame(&mut a, &limits).unwrap().map(|f| f.body), + Some(FrameBody::Hello(_)) + )); + a.write_all(b"GET / HTTP/1.1\r\n\r\n").unwrap(); + assert_eq!( + refused_code(read_frame(&mut a, &limits).unwrap()), + RefusalCode::WireFrameMalformed + ); + let mut rest = Vec::new(); + a.read_to_end(&mut rest).unwrap(); + assert!(rest.is_empty()); + t.join().unwrap().unwrap(); + let _ = std::fs::remove_dir_all(&dir); +} diff --git a/docs/G1_WIRE_FRAMES.md b/docs/G1_WIRE_FRAMES.md new file mode 100644 index 0000000..4c95c94 --- /dev/null +++ b/docs/G1_WIRE_FRAMES.md @@ -0,0 +1,145 @@ +# G1: Binary Wire Frames and Have-Want Negotiation + +ADR 0003 section 9 step G1 (issue aien-spark/synapse#44), section 8 crate `synapse-wire`: binary frames with a fuzzed decoder, have-want chunk negotiation, and stream transports. Needs A1 (binary codec) and F1 (capability chains), both merged. + +Code: `crates/synapse-wire/` (`frame.rs`, `transport.rs`, `session.rs`, `probe.rs`, `fuzz.rs`, `testkit.rs`, `src/bin/synapse-wire-fuzz.rs`); `crates/synapse-bench/src/bin/wire-transport.rs`; `crates/synapse-store/src/codec.rs` (`encode_envelope`, `decode_envelope`); `crates/synapse-core/src/lib.rs` (`RefusalCode::WireFrameMalformed`, `RefusalCode::WireProtocolViolation`). Tests: `crates/synapse-wire/tests/g1_wire.rs`, `crates/synapse-wire/tests/g1_fuzz.rs`. Evidence: `evidence/g1-wire-frames/`. + +## 1. Frame layout + +A frame is a 16-byte header and `body_len` bytes of body. Integers are little endian and fixed width. + +| Bytes | Field | Rule | +| :--- | :--- | :--- | +| 0..4 | magic `SYNW` | else `BadMagic` | +| 4 | version `1` | else `VersionUnsupported` | +| 5 | kind: 1 Hello, 2 Have, 3 Want, 4 Chunk, 5 Submit, 6 Accepted, 7 Refused | else `UnknownKind` | +| 6 | flags `0` | else `FlagsNonZero` | +| 7 | reserved `0` | else `ReservedNonZero` | +| 8..12 | `request_id` u32 | echoed in the reply | +| 12..16 | `body_len` u32 | at most the reader's `max_frame_body` (default 16 MiB), else `LengthOverCap` before any body byte is read or allocated | + +Body primitives follow the A1 codec: byte strings and strings are `u32 len | bytes` (strings UTF-8), sequences are `u32 count | items`, fixed arrays are raw, tags are one byte. + +| Kind | Body | +| :--- | :--- | +| Hello | `max_frame_body` u32, `max_pending_chunk_bytes` u64 | +| Have | `repo_id` string, digests (`u32 count`, 32 bytes each, strictly increasing) | +| Want | digests (strictly increasing) | +| Chunk | `digest` [32], `bytes` | +| Submit | the F1 `ChainedRequest`: `chain` bytes (`CapabilityChain::encode`), `target_repo_id` string, `agent_key` [32], capability tag (1 to 6), scope paths (`u32 count`, strings), reference tag (0 none, 1 own drafts, 2 canonical via promotion queue), join change (0, or 1 then [16]), `request_nonce` [32], `timestamp_ms` u64, `payload` bytes (one binary changeset envelope, `CODEC_V2` and the A1 envelope body), `agent_signature` [64] | +| Accepted | `wal_seq` u64, `changeset_id` [32], `duplicate` 0 or 1 | +| Refused | refusal code name (ASCII letters and digits, at most 64), message string | + +There is exactly one encoding per frame. A trailing byte, unknown tag, invalid UTF-8, invalid `RepoId`, unsorted or repeated digest, a chain that does not re-encode to its own bytes, or an unknown refusal code name is refused, so decode then encode gives back the input bytes. Each refusal is a typed `WireRefusal` with the absolute byte offset; at the service boundary it becomes `RefusalCode::WireFrameMalformed`. + +There is no checksum: frames ride a reliable ordered stream (Unix socket or TCP), and the content that matters is signed (the envelope by its author, the request by the agent, the chain links by their issuers). The decoder takes the body as its own slice, so it cannot read into the next frame; the stream reader takes the header first, checks `body_len` against its cap, and only then allocates and reads exactly that many bytes. + +## 2. Have-want negotiation and submission + +```text +client server + Hello -------------------------------> once per connection, both ways + <------------------------------- Hello + Have {repo, digests the change needs} -> + <---------- Want {offered digests the server lacks} + Chunk x |Want|, Submit {chained request} -> one write + <--------------- Accepted {wal_seq} | Refused {code} +``` + +The server lacks a digest when no committed changeset references it and no chunk of the current negotiation carried it, so a blob the server holds is never sent again (FindMissingBlobs style, section 5.9). Server rules, each a typed refusal that resets the negotiation: + +| Break | Refusal | +| :--- | :--- | +| Any frame before `Hello` (then the connection closes), a second `Hello`, or a frame a server never takes from a client (`Want`, `Accepted`, `Refused`) | `WireProtocolViolation` | +| `Have` for another repository | `AuthCrossRepoDenied` | +| `Chunk` not in the last `Want`, or sent twice | `WireProtocolViolation` | +| `Chunk` bytes that do not hash to its digest | `BlobDigestMismatch` | +| Chunk bytes over `max_pending_chunk_bytes` (default 64 MiB) | `QuotaPayloadTooLarge` | +| `Submit` before every wanted chunk | `WireProtocolViolation` | +| `Submit` payload not one canonical binary envelope | `WireFrameMalformed` | +| Chain, signature, capability (`Propose`), scope, size, rate or nonce check of `PolicyEnforcer::authorize_chain` (F1) | its F1 code | +| Envelope for another repository; envelope author not the chain's leaf audience; request scope not exactly the envelope's paths | `AuthCrossRepoDenied`; `AuthSignatureInvalid`; `AuthPathOutOfScope` | +| Malformed frame (then the connection closes, since framing can no longer be trusted) | `WireFrameMalformed` | + +An accepted change is admitted through `SharedStore::submit` with group commit, and `Accepted` is written only after the batch is durable. A resubmission of a committed change returns `Accepted` with `duplicate = 1`. + +## 3. Fuzzer: what kind it is + +`synapse_wire::fuzz` is an in-repository coverage-guided mutation fuzzer, written for this step (no libFuzzer, AFL or cargo-fuzz, no new external crates). The frame decoder is generic over a `Probe`; production passes `NoProbe` (empty, inlined away), the fuzzer passes `EdgeProbe`, which records an AFL-style edge map (64 Ki slots, edge = previous site xor current site) over 44 instrumented decoder states in `frame.rs` (one per branch; the site id is the source line) and the highest input offset read. An input that reaches a new edge or a new hit-count bucket joins the corpus. Mutations: bit flips, random and boundary bytes, boundary u32 values (0, cap - 1, cap, cap + 1, bytes remaining, u32::MAX and others), truncation, insertion, deletion, duplication, splicing two corpus entries, 32-byte block swaps, kind byte rewrites, and half the time a fix-up of `body_len` to the real body length so mutations reach the body decoder. The random generator is SplitMix64 with a fixed seed; the budget (executions or seconds) and seed are written to `spec.json` before the first execution. + +Limits, stated plainly: coverage is only the instrumented states of `frame.rs`. The capability chain decoder (`synapse-auth`) and the envelope decoder (`synapse-store::codec`) run on every accepted `Submit` and their outputs are checked, but they are not instrumented, so the fuzzer does not steer toward their branches. + +The target is what the server does with untrusted bytes: `decode_frame`, then `decode_envelope` on a `Submit` payload. Every execution checks: + +| Check | How | +| :--- | :--- | +| No panic | `catch_unwind` around the target | +| No read past a frame | the probe's high-water mark never exceeds `16 + body_len`; and the same input followed by random trailing bytes gives the identical result whenever the input held the whole frame (a decision that depends on bytes after the frame shows up as a difference) | +| No allocation above the declared cap | a counting global allocator records the largest single allocation during the decode; it must not exceed `max_frame_body` | +| Canonical accept | an accepted frame re-encodes to exactly the bytes it came from; an accepted payload re-encodes to exactly the payload | +| Typed refusal | anything not accepted is a `WireRefusal` (payloads: a `CodecRefusal`) | + +Seeds are one valid frame of every kind (14 frames, including empty lists, an empty chunk, depth 1 and depth 3 chains, an envelope with evidence and a delete, every option tag) and 126 hand-made malformed frames derived from them (wrong magic, version, kind 0 and 8, flags, reserved, length one over the cap, one byte short, one trailing byte). + +Negative controls (`negative_control_*` in `tests/g1_fuzz.rs`) plant one bug each in a copy of the target (a panic on a non-zero flags byte, a buffer sized from the declared length before the cap check, an answer that depends on the byte after the frame, a decoder that ignores the reserved byte) and require the same fuzzer and budget to report it. All four are found, so the detectors are live. + +### 3.1 Time-budgeted evidence runs + +Both runs: release build with panic unwinding, overflow checks and debug assertions on; 300 s budget, seed 1592615168 and a cap of 8,192 bytes, written to `spec.json` before the first execution. + +| Run | Rev | Executions | Edges | Sites reached | Violations | Largest single allocation | +| :--- | :--- | ---: | ---: | ---: | ---: | ---: | +| 1 (`fuzz-run1-71fa41e/`) | `71fa41e` | 703,411,456 | 99 | 42 of 43 | 1,307 allocation over cap | 8,760 bytes | +| 2 (`fuzz/`) | `2e942f3` | 711,944,192 | 100 | 43 of 44 | 0 | 8,160 bytes | + +Run 1 found a real bug: a `Submit` whose scope lists many empty paths costs 4 wire bytes per path but 24 bytes of memory per decoded `String`, so the path list allocation passed the cap. The decoder now refuses a path count whose decoded size would pass the cap (the A1 codec already did this for its sequences), with the regression test `fuzz_regression_many_scope_paths_stay_under_allocation_cap` (red output in `red-green/red-addendum-fuzz-finding.txt`). Run 2, on the fixed code, found nothing; its corpus of 201 entries replays as 14 canonical accepts and 187 typed refusals of 14 kinds, with no violation. + +The one site neither run reached is line 638 of `frame.rs`: a capability chain that decodes but does not re-encode to its own bytes. The F1 chain decoder already refuses every non-canonical encoding itself, so this check is very likely unreachable; it stays as a guard. + +## 4. Acceptance + +| Acceptance item (issue #44) | Test or evidence | Result | +| :--- | :--- | :--- | +| Every frame kind round-trips to identical bytes | `every_frame_kind_round_trips_to_identical_bytes` (all 7 kinds, singly, back to back in one buffer, and through the stream reader) | PASS | +| Fuzzing for a budget fixed before the run finds no panic, no read past a frame, no allocation above the declared cap | `fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap` (300,000 executions, seed fixed, in CI); time-budgeted run in `evidence/g1-wire-frames/fuzz/` (300 s, seed 1592615168, cap 8192 bytes: 711,944,192 executions, 100 edges, 43 of 44 sites, 0 violations, largest single allocation 8,160 bytes); see section 3.1 | PASS | +| Every malformed frame in the fuzz corpus is refused with a typed refusal | `every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal` (replays the whole corpus: each entry is a canonical frame or a typed refusal, each hand-made malformed seed is refused); corpus replay in `evidence/g1-wire-frames/fuzz/result.json` | PASS | +| Seconds and joules per accepted change across the transport against the bound | `evidence/g1-wire-frames/transport/` (section 5) | MEASURED (see section 5; this is a report, not a pass/fail gate) | + +Supporting tests: `malformed_header_is_refused_with_typed_refusal`, `malformed_body_is_refused_with_typed_refusal`, `decoder_never_reads_past_a_frame`, `stream_reader_refuses_length_over_cap_before_reading_the_body`, `have_want_sends_only_missing_chunks_and_acknowledges_durable_changes` (2 then 1 then 0 chunks as blobs become known; a duplicate is idempotent; a fresh open of the store sees every acknowledged change), `server_refuses_protocol_violations_with_typed_refusals`, `server_closes_connection_on_frame_before_hello_or_malformed_frame`, and the four negative controls. + +Red before green: `evidence/g1-wire-frames/red-green/red.txt` (two stub sets: the body decoder unimplemented; the header, trailing-byte and negotiation checks switched off) and `green.txt`. + +## 5. Transport: seconds and joules per accepted change + +Tool: `crates/synapse-bench/src/bin/wire-transport.rs`, release build, rev `2e942f3`, run 2026-10-16. `spec.json` (arms, change count, repetitions, bound, sensor) was written before the first change; `result.json` holds every per-change latency in nanoseconds and every energy window. + +Setup: one agent submits one change at a time, 2,000 changes per arm, 3 repetitions with the arm order rotated, each arm on a fresh store directory (NVMe, ext4, `GROUP_COMMIT_DEFAULT`). Every change upserts one new 3,967-byte blob (the Gate 4 median new content per change) and one blob shared by every change (sent once, then skipped by negotiation). Arms: + +* `wire`: client and server threads joined by a Unix socket; per change Have, Want, Chunk (only missing blobs), Submit, and Accepted after the durable commit. +* `direct_auth`: the same chain authorisation (depth 2) and store admission in process, with no transport. +* `direct`: store admission only. + +Bound: ADR 0003 section 6 durable latency for one change, as derived in `docs/PHASE5_GROUP_COMMIT.md` section 5: `t_floor = 0.805 ms + 11,500 B x 0.138 s/GiB = 0.806 ms`, `E_floor = 22.731 W x t_floor + 0.2766 mJ = 18.6 mJ`. Fraction of bound is floor divided by measured (1.0 means at the floor). + +| Arm | Median s per change (of 3 reps) | Fraction of time bound | SoC package J per change | Fraction of energy bound | Above idle J per change | +| :--- | ---: | ---: | ---: | ---: | ---: | +| `wire` | 1.628 x 10^-3 | 0.495 | 40.6 x 10^-3 | 0.458 | 3.6 x 10^-3 | +| `direct_auth` | 1.409 x 10^-3 | 0.572 | 34.8 x 10^-3 | 0.534 | 0.8 x 10^-3 | +| `direct` | 1.395 x 10^-3 | 0.578 | 33.4 x 10^-3 | 0.557 | -0.3 x 10^-3 | + +Repetitions for `wire`: 1.354, 1.628 and 1.668 ms per change. The transport (framing, socket hops and negotiation) adds about 0.22 ms per change over the same work in process (`wire` minus `direct_auth`). For comparison, the Phase 5 S3 reference for one change was 2.048 ms and 51.7 mJ. + +Limits, stated plainly: + +* Joules are the `aien_spbm` SoC package meter only: uncalibrated, no published accuracy, not compared with an external meter, NVMe unmeasured. The idle window (30 s) read 24.1 W, but the machine was shared with other work (49 CPU-seconds of other activity during the idle window), so the above-idle column is noise at this size and goes negative for one arm. Package joules per change are the figure to use. +* Repetitions spread by about 20 percent on the shared machine, and an earlier run of the same tool at rev `71fa41e` (kept in `evidence/g1-wire-frames/transport-run1-71fa41e/`) gave 1.807 ms and 64.6 mJ for `wire`. Treat the figures as the scale of the cost, not a tight value. +* Client and server share one process over a Unix socket pair; TCP and a separate client process are not measured. + +## 6. Limits and deviations + +* Chunks are whole blobs until step G2 (content-defined chunking); `Have`, `Want` and `Chunk` carry `BlobDigest`s. There is no separate chunk digest type yet. +* The server's set of known digests is built from committed changesets at start and grows with each accepted change. After a future compaction that drops blobs (none exists yet) a stale entry would make the server skip a chunk it needs; the store then refuses the change with its own typed refusal (`BlobNotFound`) rather than accepting it. +* Refused frames carry the refusal code by its stable name, so a code added later is refused by an older peer as `UnknownRefusalCode` rather than misread. +* The transport arm runs client and server in one process over a Unix socket pair. TCP and a separate client process are not measured. +* Joules come from the `aien_spbm` SoC package meter: package only, uncalibrated, NVMe unmeasured. +* Small public additions outside the new crate: `encode_envelope` and `decode_envelope` in `synapse-store::codec` (the envelope body codec the WAL already used), two refusal codes in `synapse-core`, the crate in the root `Cargo.toml` and `.crumb`, and the `wire-transport` binary in `synapse-bench`. diff --git a/docs/SCHEMA_AND_CONSISTENCY.md b/docs/SCHEMA_AND_CONSISTENCY.md index b5c4bfb..1876f4b 100644 --- a/docs/SCHEMA_AND_CONSISTENCY.md +++ b/docs/SCHEMA_AND_CONSISTENCY.md @@ -93,7 +93,7 @@ During `checkpoint_and_compact(now_ms)`: ## 5. Deterministic Failure and Refusal Codes (`RefusalCode`) Every error path returns a typed `RefusalCode`: -* Storage & Integrity: `BlobDigestMismatch`, `BlobImmutableConflict`, `WalMagicInvalid`, `WalVersionUnsupported`, `WalCrcMismatch`, `WalChainMismatch`, `WalSequenceGap`, `WalTornFrame`, `WalRecordMalformed` (a binary v2 record that fails canonical decoding), `CheckpointCorrupt`, `IoFailure` +* Storage & Integrity: `BlobDigestMismatch`, `BlobImmutableConflict`, `WalMagicInvalid`, `WalVersionUnsupported`, `WalCrcMismatch`, `WalChainMismatch`, `WalSequenceGap`, `WalTornFrame`, `WalRecordMalformed` (a binary v2 record that fails canonical decoding), `WireFrameMalformed` (a binary wire frame that fails canonical decoding, step G1), `WireProtocolViolation` (a well-formed wire frame out of have-want order, step G1), `CheckpointCorrupt`, `IoFailure` * Capacity & Backpressure: `BackpressureOverCapacity`, `QuotaPayloadTooLarge`, `QuotaTooManyPaths`, `QuotaRateLimitExceeded`, `PaginationLimitExceeded` * Schema & Path Validation: `EnvelopeVersionUnsupported`, `PathInvalid`, `PathDuplicate`, `MutationsUnsorted`, `BaseTreeNotFound`, `ParentChangesetNotFound`, `ChangesetNotFound`, `VisibilitySeqAhead`, `IdempotencyKeyConflict` * Auth & Security: `AuthSignatureInvalid`, `AuthGrantSignatureInvalid`, `AuthGrantExpired`, `AuthCapabilityDenied`, `AuthCrossRepoDenied`, `AuthReplayDetected`, `AuthSelfReviewRefused` diff --git a/evidence/g1-wire-frames/fuzz-run1-71fa41e/SHA256SUMS b/evidence/g1-wire-frames/fuzz-run1-71fa41e/SHA256SUMS new file mode 100644 index 0000000..e79b206 --- /dev/null +++ b/evidence/g1-wire-frames/fuzz-run1-71fa41e/SHA256SUMS @@ -0,0 +1,4 @@ +f723a0b25956f62b38abd4e70f6123a0f90cfa1ef3fd4227fded2562705907da corpus.bin +2406d0a47922fd1426c82bd1e47ba2dc6298b2671aa5612f61850ed5c491c876 result.json +4e27cf5886b2f47e20ae79c14aca6f65f8a3dc2e9c92836b72e878791578250b run.log +1b9ccffb17f602818a00c00cfff57c3c8e1d6b8ddd6335ab4080751235575046 spec.json diff --git a/evidence/g1-wire-frames/fuzz-run1-71fa41e/corpus.bin b/evidence/g1-wire-frames/fuzz-run1-71fa41e/corpus.bin new file mode 100644 index 0000000..02b9e00 Binary files /dev/null and b/evidence/g1-wire-frames/fuzz-run1-71fa41e/corpus.bin differ diff --git a/evidence/g1-wire-frames/fuzz-run1-71fa41e/result.json b/evidence/g1-wire-frames/fuzz-run1-71fa41e/result.json new file mode 100644 index 0000000..da30267 --- /dev/null +++ b/evidence/g1-wire-frames/fuzz-run1-71fa41e/result.json @@ -0,0 +1,156 @@ +{ + "alloc_tracking_installed": true, + "corpus_entries": 200, + "corpus_found_at_execs": [ + 141, + 151, + 152, + 157, + 158, + 159, + 166, + 170, + 176, + 181, + 184, + 191, + 192, + 194, + 220, + 251, + 257, + 267, + 274, + 396, + 402, + 418, + 478, + 599, + 619, + 677, + 702, + 720, + 741, + 746, + 876, + 901, + 928, + 1340, + 1970, + 2020, + 2777, + 3151, + 3335, + 3890, + 4152, + 5478, + 10078, + 10244, + 12408, + 13728, + 76566, + 99877, + 433247, + 445117, + 1909916, + 7906839, + 32483975, + 32737503, + 32921468, + 33095464, + 45026149, + 45845340, + 52009525, + 52386549 + ], + "corpus_replay": { + "accepted_canonical": 14, + "entries": 200, + "peak_single_alloc_bytes": 1539, + "refused_by_kind": { + "BadMagic": 14, + "Chain": 1, + "FlagsNonZero": 14, + "InvalidRepoId": 1, + "InvalidUtf8": 2, + "LengthOverCap": 32, + "NotCanonical": 4, + "ReservedNonZero": 14, + "TrailingBytes": 15, + "Truncated": 41, + "UnknownKind": 28, + "UnknownRefusalCode": 1, + "UnknownTag": 5, + "VersionUnsupported": 14 + }, + "violations": [] + }, + "edges": 99, + "elapsed_s": 300.000101035, + "execs": 703411456, + "execs_per_s": 2344704.063676083, + "instrumented_sites": 43, + "largest_input_bytes": 4047, + "outcomes": { + "accepted:Accepted": 2625092, + "accepted:Chunk": 2139500, + "accepted:Have": 1485086, + "accepted:Hello": 1225279, + "accepted:Refused": 716275, + "accepted:Submit": 3378015, + "accepted:Want": 1997650, + "payload_accepted": 2470907, + "payload_refused:InvalidRepoId": 60920, + "payload_refused:InvalidUtf8": 351568, + "payload_refused:LengthOverCap": 401192, + "payload_refused:TrailingBytes": 4155, + "payload_refused:Truncated": 43574, + "payload_refused:UnknownTag": 37540, + "payload_refused:VersionUnsupported": 8159, + "refused:BadMagic": 113858647, + "refused:Chain": 28715365, + "refused:FlagsNonZero": 45094662, + "refused:InvalidRepoId": 8081016, + "refused:InvalidUtf8": 13927278, + "refused:LengthOverCap": 88323979, + "refused:NotCanonical": 7563687, + "refused:ReservedNonZero": 42133196, + "refused:TrailingBytes": 23905060, + "refused:Truncated": 152713443, + "refused:UnknownKind": 91649250, + "refused:UnknownRefusalCode": 7047874, + "refused:UnknownTag": 13459033, + "refused:VersionUnsupported": 53372069 + }, + "peak_single_alloc_bytes": 9000, + "peak_total_alloc_per_decode_bytes": 10923, + "sites_unreached_lines": [ + 638 + ], + "violation_counts": { + "alloc_over_cap": 1307 + }, + "violation_total": 1307, + "violations": [ + { + "detail": "allocation of 8760 bytes over cap 8192", + "input_hex": "53594e5701050000671601005a0700001e010000010001170100000100a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000000000000000000000000000000000000000000000000000000000000000120000006169656e2d737061726b2f73796e61707365d04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300003cdb158770a0b6d150e930fe0404c88bcb8ce806d47bce5cb2dc732b2a8cf1aea4852dc6b5cb09ce499ffeebad9fd72cfc11140fe3a3010000a1c3065323ea0d120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48026d01000001000000656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a04040409000000000000000401000002010012000000616978020004040404040404040404040404040404040404040404040404040404045a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471416418716b5e6c7735d28e985a7a75443546373774414d424d774e73314b79625a656666363145656856397842315a70585147374d3a802fc22400cd28e1b7d43ee99915ddae1b9956b1cc5b123779b7ee0d2fda09000000000000001900000047312066697874757265206368616e6765207300ad30035f1efd50d2e0e201d9ec986dbc3bf26b00000008be519ef64702600c82566c4697e3bfcc5600000000000000000000000000409452a3030000afeee343c808586239cfe868e0d01367fbcaf7b79285bd476fa2ad6004417eadf052bf61e138b8e25eb4ad556bb7c77957c14546f13be220f0f23f563c771300170100000100a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1d3d7f253040aa7d887aec17702a9953efa9f9f358ce7218d7649d54613bc280d120000006169656e2d737061726b2f73796e61707365a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f017cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ce3f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452fc0300009894aacf2031d64ea36ff076351b833351d99f51c27b94e5a04d1ee79882e5fb05c40dc627b9a56ed82a716737c3b08c64b760dc38ec517c7bbc336f4ff10a0a170100000100a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a229a5d3cd9ab49402a91494a816abc3a4b2b2f7652ac28def3ab1991d32033faa120000006169656e2d737061726b2f73796e6170736517cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ced759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000da35294f1108c61a4536e1b22bd5a64cdd513ff1c95559ccdf727ef9067a55962011e5ca7d7d3755ed9b823bf597599690a74bf5a008f1250e545dabddc7740a120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c2702000000000b0000006372617465732f612e72730b000000646f63732f6f6c642e6d640101030303030303030303030303030303030202020202020202020202020202020202020202020202020202020202020202080000000000000075010000020100120000006169656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471417a75443546373774414d424d774e73314b79625a656666363145656856397842315a705851473723d132da286cbf8980f48664ec938cb49db5951a8201b5fa6c4af26ea9e116db07000000000000001800000047312066697874757265206368616e67652073616d706c65020000000b0000006372617465732f612e72730101830057fb96cb505b0b1d6c5e1cc138f9a8314f728664ec938cb49db5951a8201b5fa6c4af26ea9f6e3381c89e10c62c2793c070a000000000000000b000000646f63732f6f6c642e6d64020100000004000000756e6974010909090909090909090909090909090909090909090909090909090909090909020000006f6b400000003a636b79000000b1725667625520763f3332a20e00cb6d1015a25fcd43cd6f25b4f44262bd9acaa09b300c157febdc7bd3cc5ca5e5722635764ab9b573a5be0c13c3ec5cdbfafe52f1172f7490f26ee14477d566ede1727119135e97fe69a2c6dfed482fa392b43707377763bf2719fa61c6c9563dda4efd77960d9e2dc3f209", + "kind": "alloc_over_cap" + }, + { + "detail": "allocation of 8760 bytes over cap 8192", + "input_hex": "53594e5701050000671601005e0700001e010000010001170100000100a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000000000000000000000000000000000000000000000000000000000000000120000006169656e2d737061726b2f73796e61707365d04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300003cdb158770a0b6d150e930fe0404c88bcb8ce806d47bce5cb2dc732b2a8cf1aea4852dc6b5cb09ce499ffeebad9fd72cfc11140fe3a3010000a1c3065323ea0d120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48026d01000001000000656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a04040409000000000000000401000002010012000000616978020004040404040404040404040404040404040404040404040404040404045a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471416418716b5e6c7735d28e985a7a75443546373774414d424d774e73314b79625a656666363145656856397842315a70585147374d3a802fc22400cd28e1b7d43ee99915ddae1b9956b1cc5b123779b7ee0d2fda09000000000000001900000047312066697874757265206368616e00120000006169656e2d737061726b2f73796e61707365d04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f03f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000afeee343c808586239cfe868e0d01367fbcaf7b79285bd476fa2ad6004417eadf052bf61e138b8e25eb4ad556bb7c77957c14546f13be220f0f23f563c771300170100000100a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1d3d7f253040aa7d887aec17702a9953efa9f9f358ce7218d7649d54613bc280d120000006169656e2d737061726b2f73796e61707365a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f017cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ce3f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300009894aacf2031d64ea36ff076351b833351d99f51c27b94e5a04d1ee79882e5fb05c40dc627b9a56ed82a716737c3b08c64b760dc38ec517c7bbc336f4ff10a0a170100000100a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a229a5d3cd9ab49402a91494a816abc3a4b2b2f7652ac28def3ab1991d32033faa120000006169656e2d737061726b2f73796e6170736517cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ced759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000da35294f1108c61a4536e1b22bd5a64cdd513ff1c95559ccdf727ef9067a55962011e5ca7d7d3755ed9b823bf597599690a74bf5a008f1250e545dabddc7740a120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c4802020000000b0000006372617465732f612e72730b000000646f63732f6f6c642e6d6400000101010101010101010101010101010101010101010101010101010101010101070000000000000046010000020100120000006169656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471417a75443546373774414d424d774e73314b79625a656666363145656856397842315a705851473723d132da286cbf8980f48664ec938cb49db5951a8201b5fa6c4af26ea9e116db07000000000000001800000047312066697874757265206368616e67652073616d706c65020000000b0000006372617465732f612e72730101830057fb96cb505b0b1d6c5e1cc138f9a8314f72f6e3381c89e10c62c2793c070a000000000000000b000000646f63732f6f6c642e6d64020000000040000000206c911064e58f5c39e6f160dd123be140789ff74bc19b282216a13a50afd9fee5b98b4da82d54f8860ad346b7d963099d83ebeaba96c1f9d71542ebb08c7d088ef57ce46805d7a1e5b01d72096d6018fb9359b03b07c4a5c284c7b1ca98e17951ac492924f4af21535d3b0d9bcce7b9b80653a7110f8b6fa46410660fcde40d00", + "kind": "alloc_over_cap" + }, + { + "detail": "allocation of 8760 bytes over cap 8192", + "input_hex": "53594e570105000067160100e10700001e010000010001170100000100a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000000000000000000000000000000000000000000000000000000000000000120000006169656e2d737061726b2f73796e61707365d04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300003cdb158770a0b6d150e905fe0404c88bcb8ce806d47bce5cb2dc732b2a8cf1aea4852dc6b5cb09ce499ffeebad9fd72cfc11140fe3a3010000a1c3065323ea0d120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48026d01000001000000656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a04040409000000000000000401000002010012000000616978020004040404040404040404040404040404040404040404040404040404045a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471416418716b5e6c7737d28e985a7a75443546373774414d424d774e73314b79625a656666363145656856397842315a70585147374d3a802fc22400cd28e1b7d43ee99915ddae1b9956b1cc5b12053779b7ee0d2fda09000000000000001900000047312066697874757265206368616e6765207300ad30035f1efd50d2e0e201d9ec986dbc3bf26b00000008be519ef64702600c82566c4697e3bfcc56000000098d4b861b2a49188481a1b93ec0b178a27c791f00e2291166a9264b246fec7601b8b1fe354569ff4255071c7816129e7baecd7b15b1fff5a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f03f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000afeee343c808586239cfe868e0d01367fbcaf7b79285bd476fa2ad6004417eadf052bf61e138b8e25eb4ad556bb7c77957c14546f13be220f0f23f563c771300170100000100a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1d3d7f253040aa7d887aec17702a9953efa9f9f358ce7218d7649d54613bc280d120000006169656e2d737061726b2f73796e61707365a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f017cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ce3f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300009894aacf2031d64ea36ff076351b833351d99f51c27b94e5a04d1ee79882e5fb05c40dc627b9a56ed82a716737c3b08c64b760dc38ec517c7bbc336f4ff10a0a170100000100a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a229a5d3cd9ab49402a91494a816abc3a4b2b2f7652ac28def3ab1991d32033faa120000006169656e2d737061726b2f73796e6170736517cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ced759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000da35294f1108c61a4536e1b22bd5a64cdd513ff1c95559ccdf727ef9067a55962011e5ca7d7d3755ed9b823bf597599690a74bf5a008f1250e545dabddc7740a120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c2702000000000b0000006372617465732f612e72730b000000646f63732f6f6c642e6d640101030303030303030303030303030303030202020202020202020202020202020202020202020202020202020202020202080000000000000075010000020100120000006169656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471417a75443546373774414d424d774e73314b79625a656666363145656856397842315a705851473723d132da286cbf8980f48664ec938cb49db5951a8201b5fa6c4af26ea9e116db07000000000000001800000047312066697874757265206368616e67652073616d706c65020000000b0000006372617465732f612e72730101830057fb96cb505b0b1d6c5e1cc138f9a8314f728664ec938cb49db5951a8201b5fa6c4af26ea9f6e3381c89e10c62c2793c070a000000000000000b000000646f63732f6f6c642e6d64020100000004000000756e6974010909090909090909090909090909090909090909090909090909090909090909020000006f6b400000003a636b79000000b1725667625520763f3332a20e00cb6d1015a25fcd43cd6f25b4f44262bd9acaa09b300c157febdc7bd3cc5ca5e5722635764ab9b573a5be0c13c3ec5cdbfafe52f1172f7490f26ee14477d566ede1727119135e97fe69a2c6dfed482fa392b43707377763bf2719fa61c6c9563dda4efd77960d9e2dc3f209", + "kind": "alloc_over_cap" + }, + { + "detail": "allocation of 8760 bytes over cap 8192", + "input_hex": "53594e570105000067160100f70700001e010000010001170100000100a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000000000000000000000000000000000000000000000000000000000000000120000006169656e2d737061726b2f73796e61707365d04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300003cdb158770a0b6d150e930fe0404c88bcb8ce806d47bce5cb2dc732b2a8cf1aea4852dc6b5cb09ce499ffeebad9fd72cfc11140fe3a3010000a1c3065323ea0d120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c48026d01000001000000656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a04040409000000000000000401000002010012000000616978020004040404040404040404040404040404040404040404040404040404045a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471416418716b5e6c7735d28e985a7a75443546373774414d424d774e73314b79625a656666363145656856397842315a70585147374d3a802fc22400cd28e1b7d43ee99915ddae1b9956b1cc5b123779b7ee0d2fda09000000000000001900000047312066697874757265206368616e6765207300ad30035f1efd50d2e0e201d9ec986dbc3bf26b00000008bea0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a0a00000000000000000000000000000000000000000000000000000000000000000120000006169656e2d737061726b2f73796e61707365d04ab232742bb4ab3a1368bd4615e4e6d0224ab71a016baf8520a332c9778737a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f03f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000afeee343c808586239cfe868e0d01367fbcaf7b79285bd476fa2ad6004417eadf052bf61e138b8e25eb4ad556bb7c77957c14546f13be220f0f23f563c771300170100000100a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1d3d7f253040aa7d887aec17702a9953efa9f9f358ce7218d7649d54613bc280d120000006169656e2d737061726b2f73796e61707365a09aa5f47a6759802ff955f8dc2d2a14a5c99d23be97f864127ff9383455a4f017cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ce3f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a30300009894aacf2031d64ea36ff076351b833351d99f51c27b94e5a04d1ee79882e5fb05c40dc627b9a56ed82a716737c3b08c64b760dc38ec517c7bbc336f4ff10a0a170100000100a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a229a5d3cd9ab49402a91494a816abc3a4b2b2f7652ac28def3ab1991d32033faa120000006169656e2d737061726b2f73796e6170736517cb79fb2b4120f2b1ec65e4198d6e08b28e813feb01e4a400839b85e18080ced759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c483f030100000000000000008096980060ea000000000000000000000001000000000040000000000000000400000000000000000000000000409452a3030000da35294f1108c61a4536e1b22bd5a64cdd513ff1c95559ccdf727ef9067a55962011e5ca7d7d3755ed9b823bf597599690a74bf5a008f1250e545dabddc7740a120000006169656e2d737061726b2f73796e61707365d759793bbc13a2819a827c76adb6fba8a49aee007f49f2d0992d99b825ad2c4802020000000b0000006372617465732f612e72730b000000646f63732f6f6c642e6d640101030303030303030303030303030303030202020202020202020202020202020202020202020202020202020202020202080000000000000075010000020100120000006169656e2d737061726b2f73796e617073655a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a00000000380000006469643a6b65793a7a364d6b74777471417a75443546373774414d424d774e73314b79625a656666363145656856397842315a705851473723d132da286cbf8980f48664ec938cb49db5951a8201b5fa6c4af26ea9e116db07000000000000001800000047312066697874757265206368616e67652073616d706c65020000000b0000006372617465732f612e72730101830057fb96cb505b0b1d6c5e1cc138f9a8314f72f6e3381c89e10c62c2793c070a000000000000000b000000646f63732f6f6c642e6d64020100000004000000756e6974010909090909090909090909090909090909090909090909090909090909090909020000006f6b400000003a636b8db4090db1725667625520763f3332a20e00cb6d1015a25fcd43cd6f25b4f44262bd9acaa09b300c157febdc7bd3cc5ca5e5722635764ab9b573a5be0c13c3ec5cdbfafe52f1172f7490f26ee14477d566ede1727119135e97fe69a2c6dfed482fa392b43707377763bf2719fa61c6c9563dda4efd77960d9e2dc3f209", + "kind": "alloc_over_cap" + } + ] +} diff --git a/evidence/g1-wire-frames/fuzz-run1-71fa41e/run.log b/evidence/g1-wire-frames/fuzz-run1-71fa41e/run.log new file mode 100644 index 0000000..e7b62f8 --- /dev/null +++ b/evidence/g1-wire-frames/fuzz-run1-71fa41e/run.log @@ -0,0 +1,2 @@ +spec written; fuzzing (seconds 300, seed 1592615168, cap 8192) +execs 703411456 in 300.0 s, edges 99, sites 42/43, corpus 200, violations 1307, replay violations 0 diff --git a/evidence/g1-wire-frames/fuzz-run1-71fa41e/spec.json b/evidence/g1-wire-frames/fuzz-run1-71fa41e/spec.json new file mode 100644 index 0000000..7f5487d --- /dev/null +++ b/evidence/g1-wire-frames/fuzz-run1-71fa41e/spec.json @@ -0,0 +1,13 @@ +{ + "budget_kind": "seconds", + "budget_value": 300.0, + "declared_before_run": true, + "git_rev": "71fa41e7905c6a8feed8f406f8a2fc1aacac1ae9", + "kind": "in-repository coverage-guided mutation fuzzer (edge feedback from instrumented frame-decoder states)", + "max_frame_body": 8192, + "seed": 1592615168, + "seed_inputs": 140, + "target": "synapse_wire::frame::decode_frame, then synapse_store::codec::decode_envelope on Submit payloads", + "tool": "synapse-wire-fuzz", + "valid_seed_inputs": 14 +} diff --git a/evidence/g1-wire-frames/fuzz/SHA256SUMS b/evidence/g1-wire-frames/fuzz/SHA256SUMS new file mode 100644 index 0000000..d027015 --- /dev/null +++ b/evidence/g1-wire-frames/fuzz/SHA256SUMS @@ -0,0 +1,4 @@ +666dc4a3d8173be4bf3449cf5afdfe3c0329d96738236befdb6f8abc097d25ad corpus.bin +15d045e8d5a0b609445256dd70f0d44529426c5331ff0ad8afd06c023371a3ad result.json +9140146856a287984ac89fb206fcf6a08274d4ed2df588700eb8c4fbad5b9a18 run.log +4ba465c6632d115dd12c67bde70391635fe401fd38ccafce3c40a09306bea97f spec.json diff --git a/evidence/g1-wire-frames/fuzz/corpus.bin b/evidence/g1-wire-frames/fuzz/corpus.bin new file mode 100644 index 0000000..dea79bc Binary files /dev/null and b/evidence/g1-wire-frames/fuzz/corpus.bin differ diff --git a/evidence/g1-wire-frames/fuzz/result.json b/evidence/g1-wire-frames/fuzz/result.json new file mode 100644 index 0000000..c274cd3 --- /dev/null +++ b/evidence/g1-wire-frames/fuzz/result.json @@ -0,0 +1,134 @@ +{ + "alloc_tracking_installed": true, + "corpus_entries": 201, + "corpus_found_at_execs": [ + 141, + 151, + 152, + 157, + 158, + 159, + 166, + 170, + 176, + 181, + 184, + 191, + 192, + 194, + 220, + 251, + 257, + 267, + 274, + 396, + 402, + 418, + 478, + 599, + 619, + 677, + 702, + 720, + 741, + 746, + 876, + 901, + 928, + 1340, + 1970, + 2020, + 2777, + 3151, + 3335, + 3890, + 4152, + 5478, + 10078, + 10244, + 12408, + 13728, + 76566, + 99877, + 433247, + 445117, + 726503, + 910841, + 987711, + 1098132, + 1166655, + 1715129, + 1754443, + 2794040, + 17821332, + 485865274, + 486193669 + ], + "corpus_replay": { + "accepted_canonical": 14, + "entries": 201, + "peak_single_alloc_bytes": 1539, + "refused_by_kind": { + "BadMagic": 14, + "Chain": 1, + "FlagsNonZero": 14, + "InvalidRepoId": 1, + "InvalidUtf8": 1, + "LengthOverCap": 32, + "NotCanonical": 4, + "ReservedNonZero": 14, + "TrailingBytes": 15, + "Truncated": 43, + "UnknownKind": 28, + "UnknownRefusalCode": 1, + "UnknownTag": 5, + "VersionUnsupported": 14 + }, + "violations": [] + }, + "edges": 100, + "elapsed_s": 300.000003717, + "execs": 711944192, + "execs_per_s": 2373147.2772633717, + "instrumented_sites": 44, + "largest_input_bytes": 4142, + "outcomes": { + "accepted:Accepted": 2655196, + "accepted:Chunk": 2162212, + "accepted:Have": 1502991, + "accepted:Hello": 1240726, + "accepted:Refused": 725779, + "accepted:Submit": 3418788, + "accepted:Want": 2021726, + "payload_accepted": 2500329, + "payload_refused:InvalidRepoId": 61517, + "payload_refused:InvalidUtf8": 354947, + "payload_refused:LengthOverCap": 407182, + "payload_refused:TrailingBytes": 4224, + "payload_refused:Truncated": 44324, + "payload_refused:UnknownTag": 37871, + "payload_refused:VersionUnsupported": 8394, + "refused:BadMagic": 115172148, + "refused:Chain": 28077805, + "refused:FlagsNonZero": 45607213, + "refused:InvalidRepoId": 8169079, + "refused:InvalidUtf8": 13622992, + "refused:LengthOverCap": 90057644, + "refused:NotCanonical": 7630304, + "refused:ReservedNonZero": 42618716, + "refused:TrailingBytes": 24191720, + "refused:Truncated": 155694020, + "refused:UnknownKind": 92727389, + "refused:UnknownRefusalCode": 7131887, + "refused:UnknownTag": 13522113, + "refused:VersionUnsupported": 53993744 + }, + "peak_single_alloc_bytes": 8160, + "peak_total_alloc_per_decode_bytes": 10923, + "sites_unreached_lines": [ + 638 + ], + "violation_counts": {}, + "violation_total": 0, + "violations": [] +} diff --git a/evidence/g1-wire-frames/fuzz/run.log b/evidence/g1-wire-frames/fuzz/run.log new file mode 100644 index 0000000..d97c517 --- /dev/null +++ b/evidence/g1-wire-frames/fuzz/run.log @@ -0,0 +1,2 @@ +spec written; fuzzing (seconds 300, seed 1592615168, cap 8192) +execs 711944192 in 300.0 s, edges 100, sites 43/44, corpus 201, violations 0, replay violations 0 diff --git a/evidence/g1-wire-frames/fuzz/spec.json b/evidence/g1-wire-frames/fuzz/spec.json new file mode 100644 index 0000000..82de42d --- /dev/null +++ b/evidence/g1-wire-frames/fuzz/spec.json @@ -0,0 +1,13 @@ +{ + "budget_kind": "seconds", + "budget_value": 300.0, + "declared_before_run": true, + "git_rev": "2e942f30db474ac0c5f41e350db0f048cd3192d1", + "kind": "in-repository coverage-guided mutation fuzzer (edge feedback from instrumented frame-decoder states)", + "max_frame_body": 8192, + "seed": 1592615168, + "seed_inputs": 140, + "target": "synapse_wire::frame::decode_frame, then synapse_store::codec::decode_envelope on Submit payloads", + "tool": "synapse-wire-fuzz", + "valid_seed_inputs": 14 +} diff --git a/evidence/g1-wire-frames/red-green/SHA256SUMS b/evidence/g1-wire-frames/red-green/SHA256SUMS new file mode 100644 index 0000000..d3d1182 --- /dev/null +++ b/evidence/g1-wire-frames/red-green/SHA256SUMS @@ -0,0 +1,3 @@ +5d594a3252a2ea372796f1a9f8445f8eac7903e1d596f1b671da88de3f222807 green.txt +42ef0bb9c6a9bf38648ed902d16d332c426595ae0b25827975df0bc88c0b0372 red-addendum-fuzz-finding.txt +7cdc7a9e9471222565c262b2808f9873e2ac41e3a30d9f33af8097df79edc85d red.txt diff --git a/evidence/g1-wire-frames/red-green/green.txt b/evidence/g1-wire-frames/red-green/green.txt new file mode 100644 index 0000000..b2e0c25 --- /dev/null +++ b/evidence/g1-wire-frames/red-green/green.txt @@ -0,0 +1,25 @@ +# Green (2026-10-16, rev 2e942f3 + docs): cargo test --locked -p synapse-wire + Running unittests src/lib.rs (target/debug/deps/synapse_wire-b34ce9ceadd8b3f3) +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + Running unittests src/bin/synapse-wire-fuzz.rs (target/debug/deps/synapse_wire_fuzz-22c11daf2773013b) +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s + Running tests/g1_fuzz.rs (target/debug/deps/g1_fuzz-fa9c938a649af829) +test fuzz_regression_many_scope_paths_stay_under_allocation_cap ... ok +test negative_control_fuzzer_finds_planted_read_past_frame ... ok +test negative_control_fuzzer_finds_planted_allocation_over_cap ... ok +test negative_control_fuzzer_finds_planted_non_canonical_accept ... ok +test negative_control_fuzzer_finds_planted_panic ... ok +test every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal ... ok +test fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap ... ok +test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.93s + Running tests/g1_wire.rs (target/debug/deps/g1_wire-87a4b6ca8665564d) +test malformed_body_is_refused_with_typed_refusal ... ok +test malformed_header_is_refused_with_typed_refusal ... ok +test every_frame_kind_round_trips_to_identical_bytes ... ok +test stream_reader_refuses_length_over_cap_before_reading_the_body ... ok +test decoder_never_reads_past_a_frame ... ok +test server_closes_connection_on_frame_before_hello_or_malformed_frame ... ok +test server_refuses_protocol_violations_with_typed_refusals ... ok +test have_want_sends_only_missing_chunks_and_acknowledges_durable_changes ... ok +test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.32s +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s diff --git a/evidence/g1-wire-frames/red-green/red-addendum-fuzz-finding.txt b/evidence/g1-wire-frames/red-green/red-addendum-fuzz-finding.txt new file mode 100644 index 0000000..8816264 --- /dev/null +++ b/evidence/g1-wire-frames/red-green/red-addendum-fuzz-finding.txt @@ -0,0 +1,8 @@ +# Red addendum (2026-10-16): the 300 s fuzz run at 71fa41e (evidence/g1-wire-frames/fuzz-run1-71fa41e) +# found 1307 inputs whose decode made one allocation over the 8192-byte cap: a Submit scope +# with many empty paths (4 wire bytes, 24 bytes of memory each). Regression test, before the fix: +# cargo test -p synapse-wire --test g1_fuzz fuzz_regression +thread 'fuzz_regression_many_scope_paths_stay_under_allocation_cap' (494543) panicked at crates/synapse-wire/tests/g1_fuzz.rs:247:5: +largest allocation 9600 over cap 8192 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace +-- diff --git a/evidence/g1-wire-frames/red-green/red.txt b/evidence/g1-wire-frames/red-green/red.txt new file mode 100644 index 0000000..421c907 --- /dev/null +++ b/evidence/g1-wire-frames/red-green/red.txt @@ -0,0 +1,74 @@ +# Red (2026-10-16, G1 working tree on base e863c87, before the first commit) +# Command: cargo test --no-fail-fast -p synapse-wire --test g1_wire --test g1_fuzz +# Every failure below is an assertion on the behaviour under test (no compile error). +# +# Red 1 stub: the frame body decoder is unimplemented (frame.rs body_probed: every body +# is refused as Truncated). Header checks, transport and server code unchanged. +test negative_control_fuzzer_finds_planted_allocation_over_cap ... ok +test negative_control_fuzzer_finds_planted_panic ... ok +test negative_control_fuzzer_finds_planted_read_past_frame ... FAILED +test negative_control_fuzzer_finds_planted_non_canonical_accept ... FAILED +test every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal ... FAILED +test fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap ... FAILED +thread 'negative_control_fuzzer_finds_planted_read_past_frame' (365422) panicked at crates/synapse-wire/tests/g1_fuzz.rs:148:5: +planted read_past_frame bug not found; counts {} +thread 'negative_control_fuzzer_finds_planted_non_canonical_accept' (365420) panicked at crates/synapse-wire/tests/g1_fuzz.rs:148:5: +planted non_canonical_accept bug not found; counts {} +thread 'every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal' (365417) panicked at crates/synapse-wire/tests/g1_fuzz.rs:110:5: +accepted 0 of 14 valid seeds +thread 'fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap' (365418) panicked at crates/synapse-wire/tests/g1_fuzz.rs:92:9: +no accepted Hello +test result: FAILED. 2 passed; 4 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.85s +test malformed_body_is_refused_with_typed_refusal ... ok +test malformed_header_is_refused_with_typed_refusal ... ok +test every_frame_kind_round_trips_to_identical_bytes ... FAILED +test decoder_never_reads_past_a_frame ... FAILED +test stream_reader_refuses_length_over_cap_before_reading_the_body ... ok +test server_closes_connection_on_frame_before_hello_or_malformed_frame ... FAILED +test server_refuses_protocol_violations_with_typed_refusals ... FAILED +test have_want_sends_only_missing_chunks_and_acknowledges_durable_changes ... FAILED +thread 'every_frame_kind_round_trips_to_identical_bytes' (365505) panicked at crates/synapse-wire/tests/g1_wire.rs:36:58: +called `Result::unwrap()` on an `Err` value: Truncated { at: 16, need: 0 } +thread 'decoder_never_reads_past_a_frame' (365504) panicked at crates/synapse-wire/tests/g1_wire.rs:206:60: +called `Result::unwrap()` on an `Err` value: Truncated { at: 16, need: 0 } +thread 'server_closes_connection_on_frame_before_hello_or_malformed_frame' (365509) panicked at crates/synapse-wire/tests/g1_wire.rs:530:50: +called `Result::unwrap()` on an `Err` value: SynapseError { code: WireFrameMalformed, message: "wire frame: Truncated (Truncated { at: 16, need: 0 })" } +thread 'server_refuses_protocol_violations_with_typed_refusals' (365510) panicked at crates/synapse-wire/tests/g1_wire.rs:245:59: +called `Result::unwrap()` on an `Err` value: SynapseError { code: WireFrameMalformed, message: "wire frame: Truncated (Truncated { at: 16, need: 0 })" } +thread 'have_want_sends_only_missing_chunks_and_acknowledges_durable_changes' (365506) panicked at crates/synapse-wire/tests/g1_wire.rs:245:59: +called `Result::unwrap()` on an `Err` value: SynapseError { code: WireFrameMalformed, message: "wire frame: Truncated (Truncated { at: 16, need: 0 })" } +test result: FAILED. 3 passed; 5 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.06s + +# Red 2 stubs (body decoder intact): the header checks for magic, flags and reserved +# bytes are off, the trailing-bytes check is off (frame.rs), the server wants every +# offered digest instead of only the missing ones, and accepts chunks it did not ask for +# or whose bytes do not match their digest (session.rs). The read timeout turns the +# missing refusal into a failure instead of a hang. +test negative_control_fuzzer_finds_planted_read_past_frame ... ok +test negative_control_fuzzer_finds_planted_panic ... ok +test negative_control_fuzzer_finds_planted_allocation_over_cap ... ok +test negative_control_fuzzer_finds_planted_non_canonical_accept ... ok +test every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal ... FAILED +test fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap ... FAILED +thread 'every_malformed_frame_in_fuzz_corpus_is_refused_with_typed_refusal' (366021) panicked at crates/synapse-wire/tests/g1_fuzz.rs:106:5: +[(14, "[(\"non_canonical_accept\", \"re-encoded 28 bytes differ from 28\")]"), (18, "[(\"non_canonical_accept\", \"re-encoded 28 bytes differ from 28\")]"), (19, "[(\"non_canonical_accept\", \"re-encoded 28 bytes differ from 28\")]"), (22, +thread 'fuzzing_frame_decoder_finds_no_panic_no_read_past_frame_no_allocation_over_cap' (366022) panicked at crates/synapse-wire/tests/g1_fuzz.rs:66:5: +assertion `left == right` failed: violations: [("non_canonical_accept", "re-encoded 28 bytes differ from 28"), ("non_canonical_accept", "re-encoded 28 bytes differ from 28"), ("non_canonical_accept", "re-encoded 28 bytes differ from 28"), ( + left: 27218 +test result: FAILED. 4 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.07s +test malformed_body_is_refused_with_typed_refusal ... ok +test malformed_header_is_refused_with_typed_refusal ... FAILED +test every_frame_kind_round_trips_to_identical_bytes ... ok +test stream_reader_refuses_length_over_cap_before_reading_the_body ... ok +test decoder_never_reads_past_a_frame ... ok +test server_closes_connection_on_frame_before_hello_or_malformed_frame ... ok +test have_want_sends_only_missing_chunks_and_acknowledges_durable_changes ... FAILED +test server_refuses_protocol_violations_with_typed_refusals ... FAILED +thread 'malformed_header_is_refused_with_typed_refusal' (366472) panicked at crates/synapse-wire/tests/g1_wire.rs:78:54: +called `Result::unwrap_err()` on an `Ok` value: (Frame { request_id: 0, body: Hello(Hello { max_frame_body: 4096, max_pending_chunk_bytes: 1048576 }) }, 28) +thread 'have_want_sends_only_missing_chunks_and_acknowledges_durable_changes' (366470) panicked at crates/synapse-wire/tests/g1_wire.rs:288:9: +assertion `left == right` failed + left: (2, 2) +thread 'server_refuses_protocol_violations_with_typed_refusals' (366474) panicked at crates/synapse-wire/tests/g1_wire.rs:369:64: +called `Result::unwrap()` on an `Err` value: SynapseError { code: IoFailure, message: "wire transport: Resource temporarily unavailable (os error 11)" } +test result: FAILED. 5 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out; finished in 20.30s diff --git a/evidence/g1-wire-frames/transport-run1-71fa41e/SHA256SUMS b/evidence/g1-wire-frames/transport-run1-71fa41e/SHA256SUMS new file mode 100644 index 0000000..01a8b43 --- /dev/null +++ b/evidence/g1-wire-frames/transport-run1-71fa41e/SHA256SUMS @@ -0,0 +1,3 @@ +e997a355c31d30d287fc0ee0505020bc21d6ae5d9322e64b9e39f84a5ccf6f79 result.json +e27d1a6e063a6f86b444606cea0908e9ca4e0f5d54d6e54b48158ac47c41a612 run.log +48a7fb3b1dfaf55f72880025ef80cb82878bcb08221036f0c1cb0cd8628e78a5 spec.json diff --git a/evidence/g1-wire-frames/transport-run1-71fa41e/result.json b/evidence/g1-wire-frames/transport-run1-71fa41e/result.json new file mode 100644 index 0000000..0c4f231 --- /dev/null +++ b/evidence/g1-wire-frames/transport-run1-71fa41e/result.json @@ -0,0 +1,18508 @@ +{ + "idle": { + "cpu_e_j": 18.605, + "cpu_p_j": 503.344, + "largest_gap_ms": 100.609, + "loadavg_end": [ + 4.14, + 4.33, + 4.28 + ], + "loadavg_start": [ + 5.44, + 4.56, + 4.35 + ], + "machine_busy_cpu_s": 76.29000000003725, + "nvme_temp_k": 314.0, + "pkg_edge_sd_j": 2.8360225074961107, + "pkg_j": 1042.027, + "pkg_mean_w": 34.73404021206976, + "refusal": null, + "rest_j": 520.078, + "samples": 301, + "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)", + "sys_total_mean_w": 38.042272425249166, + "valid": true, + "window_s": 30.0001668 + }, + "runs": [ + { + "arm": "wire", + "changes": 2000, + "chunk_bytes_sent": 7937967, + "chunks_sent": 2001, + "elapsed_s": 3.2686457349999998, + "energy": { + "cpu_e_j": 1.897, + "cpu_p_j": 54.876, + "largest_gap_ms": 100.662, + "loadavg_end": [ + 4.05, + 4.3, + 4.28 + ], + "loadavg_start": [ + 4.14, + 4.33, + 4.28 + ], + "machine_busy_cpu_s": 8.569999999832362, + "nvme_temp_k": 314.0, + "pkg_edge_sd_j": 2.8092253813795227, + "pkg_j": 112.465, + "pkg_mean_w": 34.40584378427651, + "refusal": null, + "rest_j": 55.69200000000001, + "samples": 34, + "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)", + "sys_total_mean_w": 39.82373529411765, + "valid": true, + "window_s": 3.268776104 + }, + "latencies_ns": [ + 1957524, + 1192235, + 1195292, + 1296221, + 2004740, + 1297484, + 1301133, + 1296413, + 1915331, + 1285853, + 1298140, + 1301421, + 1895219, + 1303021, + 1301004, + 1296557, + 1903603, + 1298893, + 1298412, + 1303981, + 1894675, + 1298237, + 1315213, + 1286172, + 1898115, + 1300125, + 1300813, + 1298349, + 1901794, + 1303661, + 1395454, + 1418078, + 2279878, + 1604128, + 1605376, + 1582671, + 1949684, + 1672176, + 1916307, + 1765281, + 1813266, + 2594154, + 2135717, + 1932899, + 2450952, + 1847186, + 1223052, + 1480255, + 2893740, + 2134741, + 1913395, + 1507455, + 2400040, + 1822321, + 2198998, + 1800594, + 2774203, + 1484319, + 1313757, + 1597663, + 1774338, + 1282717, + 1115131, + 1102474, + 1708049, + 2612154, + 1200220, + 1301181, + 1898114, + 1402206, + 1395198, + 1827698, + 2498520, + 2730059, + 2216694, + 2484025, + 3177967, + 2198934, + 1470078, + 2292247, + 2817339, + 1477439, + 2033780, + 1871714, + 2552969, + 2354056, + 2081668, + 1513215, + 2387512, + 1406429, + 1394206, + 1698721, + 2311735, + 1397293, + 1297661, + 1297085, + 1897939, + 1302028, + 1298925, + 1297565, + 1898035, + 1301773, + 1296012, + 1315309, + 1889075, + 1207308, + 1202300, + 1195163, + 1814402, + 1193212, + 1197868, + 1199132, + 1816881, + 1192556, + 1189804, + 1198908, + 1800561, + 1201020, + 1200940, + 1203004, + 1797490, + 1198155, + 1297997, + 1201804, + 1799698, + 1199195, + 1220652, + 1070635, + 1702129, + 1099675, + 1225868, + 1874306, + 2220918, + 1819426, + 1977699, + 1847122, + 2082309, + 1940723, + 1977332, + 1365997, + 2289015, + 1690912, + 2150677, + 1951828, + 2236373, + 2317334, + 1976788, + 1810674, + 2256326, + 1661808, + 1946803, + 1600144, + 1768738, + 1101770, + 1200444, + 2000084, + 1822466, + 1798225, + 1746514, + 2631866, + 2699194, + 2222342, + 1418190, + 1498431, + 2683434, + 2487865, + 2130389, + 1789633, + 2170918, + 1400829, + 1303853, + 1299565, + 1897283, + 1299068, + 1297741, + 1225756, + 1809970, + 1186764, + 1196123, + 1298685, + 1806082, + 1197356, + 1192780, + 1200475, + 1801314, + 1197484, + 1199804, + 1200412, + 1797969, + 1200428, + 1209132, + 1193020, + 1804065, + 1194428, + 1197740, + 1201692, + 1900562, + 1211244, + 1193516, + 1196284, + 1797570, + 1210796, + 1190315, + 1201260, + 1906803, + 1297005, + 1296556, + 1405710, + 1904339, + 1291069, + 1300236, + 1296413, + 1907475, + 1290093, + 1295548, + 1301869, + 1899475, + 1294301, + 1300508, + 1300013, + 1902067, + 1303053, + 1299229, + 1298172, + 1900243, + 1299757, + 1305469, + 1291292, + 1902323, + 1295645, + 1301821, + 1303853, + 1897202, + 1299341, + 1296349, + 1304013, + 1897042, + 1303613, + 1297693, + 1397806, + 1902482, + 1300733, + 1297437, + 1303629, + 1914131, + 1290828, + 1295613, + 1403438, + 1889010, + 1311133, + 1299341, + 1295357, + 1902259, + 1294700, + 1299309, + 1299149, + 1910435, + 1295148, + 1295965, + 1302589, + 1899923, + 1299549, + 1297980, + 1297693, + 1901699, + 1301885, + 1297820, + 1298861, + 1901219, + 1296061, + 1305020, + 1397166, + 1903251, + 1295741, + 1303453, + 1297772, + 1908867, + 1283693, + 1607680, + 1602111, + 1788354, + 1097435, + 1436670, + 1283452, + 1894259, + 1298925, + 1301901, + 1319917, + 1878386, + 1295709, + 1297149, + 1405581, + 2001732, + 1296157, + 1297581, + 1300637, + 1899090, + 1309453, + 1294701, + 1294429, + 1900594, + 1302925, + 1302429, + 1298957, + 1899202, + 1295197, + 1303149, + 1298365, + 1900770, + 1299837, + 1298781, + 1301517, + 1901651, + 1296188, + 1299725, + 1302733, + 1889043, + 1309292, + 1498655, + 1300013, + 1901619, + 1307901, + 1294220, + 1503951, + 1896851, + 1317933, + 1281340, + 1299453, + 1898819, + 1298845, + 1301132, + 1302541, + 1899331, + 1298877, + 1297404, + 1305005, + 1904131, + 1296141, + 1304733, + 1305405, + 1881538, + 1298189, + 1302381, + 1293964, + 1901507, + 1308701, + 1296557, + 1293452, + 1897347, + 1299837, + 1301821, + 1310669, + 1896690, + 1295213, + 1301213, + 1395614, + 1903106, + 1498511, + 1598432, + 1401134, + 2213605, + 1900787, + 1681185, + 1192667, + 1798130, + 1101755, + 1100859, + 1102683, + 1697840, + 1097467, + 1229692, + 1474351, + 1715041, + 1081434, + 1099419, + 1178556, + 1721137, + 1099578, + 1099099, + 1100011, + 2140389, + 1378478, + 1291708, + 1300605, + 1902483, + 1297245, + 1302076, + 1299389, + 1900611, + 1296397, + 1299389, + 1298348, + 1909187, + 1295549, + 1297469, + 1298284, + 1900627, + 1299389, + 1298701, + 1299229, + 1900210, + 1309997, + 1301437, + 1294205, + 1891986, + 1298237, + 1320285, + 1286573, + 1900898, + 1295437, + 1299741, + 1300093, + 1905154, + 1294861, + 1300029, + 1302285, + 1896131, + 1301676, + 1301293, + 1297357, + 1899107, + 1307164, + 1294173, + 1301853, + 1899283, + 1298412, + 1316413, + 1281373, + 1901411, + 1307917, + 1394573, + 1293853, + 1902675, + 1298701, + 1305404, + 1393470, + 1922771, + 1275245, + 1311244, + 1313101, + 1888915, + 1295021, + 1301069, + 1295612, + 1899699, + 1307245, + 1291949, + 1299948, + 1902691, + 1298077, + 1319853, + 1385582, + 2004787, + 1504415, + 1298925, + 1296701, + 1919363, + 1378573, + 1697473, + 1381885, + 2094581, + 1429038, + 1295021, + 1494607, + 1913026, + 1197036, + 1376286, + 1327133, + 1896642, + 2083893, + 3128111, + 1572975, + 2396280, + 1707201, + 2603801, + 2278087, + 3341889, + 1373085, + 1901635, + 2125125, + 2148549, + 1501487, + 1600143, + 1324445, + 2065925, + 1501230, + 1226428, + 1390558, + 2289447, + 1496942, + 2422792, + 1944675, + 2232246, + 1421662, + 1677745, + 2242774, + 3360705, + 1395886, + 1599632, + 1701488, + 2515321, + 1472351, + 1431998, + 1299100, + 1900611, + 1302733, + 1295933, + 1481902, + 2643818, + 2224694, + 2532585, + 1699377, + 2225718, + 2060372, + 2188822, + 1725584, + 2308983, + 1694113, + 2494872, + 2206054, + 2578506, + 2099444, + 1542735, + 1577040, + 2302375, + 2149637, + 2659994, + 1687329, + 2203461, + 1696865, + 2373751, + 2461720, + 2575402, + 1691744, + 1397934, + 1601520, + 2298503, + 1521007, + 2057652, + 2125429, + 2421160, + 1941283, + 1864770, + 1695889, + 2393623, + 2376536, + 2808843, + 1598320, + 2298423, + 1698736, + 1623936, + 1574448, + 3050590, + 2525849, + 1541023, + 1297405, + 1900162, + 1464399, + 1405502, + 1838898, + 2085236, + 1398542, + 1401678, + 1387614, + 2097364, + 1600336, + 1696545, + 1503726, + 2299447, + 2056996, + 2769723, + 2212822, + 2507657, + 1272284, + 1292077, + 1297677, + 1906947, + 1301197, + 1300780, + 1392334, + 2863836, + 2833692, + 2249046, + 2440504, + 2409368, + 1726993, + 1789298, + 2824843, + 3898407, + 2023604, + 1920755, + 1699504, + 2099845, + 2547625, + 2452920, + 2266150, + 2986366, + 2192693, + 2762428, + 1518415, + 2070004, + 1423134, + 1364253, + 1401966, + 1936419, + 1393566, + 1309293, + 1300045, + 1918946, + 1273133, + 1296989, + 1298669, + 1904050, + 1298541, + 1302541, + 1296877, + 2000179, + 1317325, + 1282221, + 1301245, + 1900402, + 1299373, + 1300813, + 1298461, + 1900483, + 1298252, + 1302061, + 1298637, + 1899603, + 1300332, + 1298077, + 1319549, + 1888323, + 1294620, + 1297565, + 1299901, + 1900323, + 1319229, + 1278908, + 1303917, + 1899411, + 1298749, + 1399789, + 1301837, + 1899043, + 1299181, + 1305373, + 1295996, + 1900531, + 1301229, + 1296029, + 1301660, + 1913523, + 1284861, + 1301005, + 1301404, + 1898051, + 1299725, + 1297741, + 1300332, + 1902371, + 1302717, + 1296429, + 1300077, + 1900002, + 1302125, + 1302781, + 1297229, + 1901842, + 1299293, + 1298077, + 1300461, + 2200277, + 1596800, + 1600560, + 1196492, + 1696880, + 1100075, + 1100427, + 1102875, + 2913709, + 1591151, + 1740625, + 1355694, + 1696336, + 1098667, + 1176828, + 1120779, + 1705121, + 1096506, + 1428910, + 2540921, + 2471529, + 2302742, + 1572320, + 1188668, + 2790219, + 2348791, + 2306295, + 1629184, + 3000381, + 1946004, + 1275356, + 1649680, + 2779356, + 2199701, + 2451352, + 1634097, + 3033885, + 1873523, + 1436414, + 1257788, + 2215558, + 1698817, + 1733361, + 1999828, + 3413921, + 1945779, + 1173196, + 1442046, + 2062084, + 1094027, + 1363838, + 1137883, + 1871554, + 1873475, + 1569615, + 1729585, + 2081573, + 2399271, + 1701361, + 1599184, + 2724250, + 2083573, + 1610544, + 2271142, + 2583930, + 2174053, + 1762497, + 1955076, + 2343703, + 1945923, + 1941923, + 1812242, + 2638970, + 1750609, + 1745457, + 2885196, + 2623786, + 1844642, + 1303165, + 1861138, + 2666459, + 2133461, + 2225654, + 1510142, + 1776322, + 1093723, + 1103931, + 1521166, + 1901251, + 1081291, + 999146, + 998665, + 1608448, + 995162, + 1208732, + 1714801, + 2438136, + 2066340, + 2104997, + 1662272, + 2776171, + 1465647, + 1885090, + 2051973, + 2860684, + 1457614, + 1841634, + 1892835, + 1992995, + 2090629, + 1801986, + 1382749, + 1814242, + 1914243, + 2016276, + 1769121, + 2300679, + 1705105, + 2197749, + 2195510, + 2446056, + 2073284, + 1886819, + 2066356, + 2441160, + 2496889, + 1694352, + 1588848, + 3177295, + 2039220, + 1384286, + 1182156, + 2054324, + 2425976, + 2046916, + 1373677, + 2620858, + 2019604, + 1460926, + 1471967, + 2335527, + 2136053, + 1551871, + 1093403, + 1940403, + 1907075, + 1836802, + 1564383, + 2691195, + 2452824, + 1938195, + 1697153, + 2549257, + 1856674, + 1319661, + 2104997, + 2120308, + 1810002, + 1623664, + 1256989, + 2463000, + 2008484, + 1785441, + 1300685, + 2606682, + 1939011, + 1687200, + 1999508, + 2995837, + 1867699, + 2108836, + 1488527, + 1892755, + 1864386, + 1246876, + 1496511, + 2301159, + 1597215, + 2113493, + 2356151, + 2216518, + 1746257, + 2235398, + 1926707, + 2183350, + 1705201, + 1487934, + 1605648, + 2102085, + 1700912, + 2008148, + 2071893, + 2313366, + 1933155, + 1788690, + 2216870, + 2200133, + 1875491, + 2653450, + 1757697, + 2170246, + 1317197, + 1502366, + 1685201, + 2952989, + 1658560, + 1952003, + 2247207, + 2759179, + 1524207, + 1090794, + 1594928, + 2448968, + 1688241, + 1798913, + 2064197, + 2798187, + 1452543, + 2385831, + 1700177, + 2708714, + 1589488, + 2155141, + 1938483, + 2301383, + 2046724, + 2139781, + 1635936, + 2462793, + 1719504, + 1805170, + 2164517, + 2542681, + 1765666, + 1722769, + 1592319, + 2403112, + 1805474, + 2140869, + 1955987, + 2440712, + 1756497, + 2095573, + 1401246, + 2659082, + 1996116, + 1538543, + 1488558, + 2227830, + 1797970, + 1501999, + 2193717, + 2429848, + 1376542, + 1892514, + 1698705, + 2522665, + 2095813, + 1986307, + 1703441, + 2467496, + 1964387, + 2101541, + 1654240, + 2394808, + 1599408, + 1493342, + 1209708, + 2312263, + 2323991, + 1648784, + 1427614, + 2845804, + 2246166, + 1705233, + 1699265, + 2661386, + 1217020, + 1224268, + 1742497, + 1866738, + 1778066, + 1938563, + 1642640, + 1912995, + 2043108, + 1961315, + 1604880, + 2922285, + 1979219, + 2741035, + 1971876, + 2646202, + 1748993, + 1832018, + 1891570, + 3092991, + 2214422, + 1905090, + 1974788, + 3249920, + 1924819, + 1401662, + 1300444, + 2111445, + 1609344, + 1788978, + 2012227, + 2622922, + 2079493, + 1981827, + 1616160, + 2796331, + 1437087, + 1737409, + 1691440, + 2776300, + 1555103, + 2125189, + 2103861, + 2564601, + 2026740, + 1562895, + 1332605, + 2779132, + 1159675, + 1101915, + 1467614, + 2578314, + 2197541, + 1279229, + 1177755, + 1700721, + 1094059, + 1100299, + 1101082, + 1606048, + 999594, + 999514, + 1000314, + 1601760, + 1005097, + 992234, + 1001482, + 1601040, + 1013514, + 984633, + 1000234, + 1599712, + 999562, + 1000106, + 999913, + 1921571, + 1490863, + 1314301, + 1803010, + 2197813, + 1698321, + 1603376, + 1692464, + 2085317, + 1455582, + 2896189, + 2072340, + 2584858, + 1933027, + 2057508, + 1301501, + 2377623, + 1330797, + 1809282, + 1793314, + 2304278, + 1698209, + 1601824, + 1797329, + 2198966, + 1697233, + 1487822, + 1608432, + 1983700, + 1303852, + 1306365, + 1295485, + 1897859, + 1300269, + 1297340, + 1302157, + 1903427, + 1291548, + 1299725, + 1299917, + 1900307, + 1321741, + 1281548, + 1296877, + 1902243, + 1300797, + 1298236, + 1299213, + 1899939, + 1299389, + 1303532, + 1297373, + 1901795, + 1297549, + 1299197, + 1322381, + 1884322, + 1297565, + 1298333, + 1297612, + 1899203, + 1320365, + 1280029, + 1298620, + 1897603, + 1300125, + 1318413, + 1297693, + 1902290, + 1296957, + 1297901, + 1302621, + 1903650, + 1296205, + 1292333, + 1502463, + 2024755, + 1491391, + 1303837, + 1185468, + 1803809, + 1195148, + 1203932, + 1196780, + 1798545, + 1198156, + 1200252, + 1200956, + 1904323, + 1304700, + 1291261, + 1403358, + 1811266, + 1326861, + 1361693, + 1309005, + 1895539, + 1296077, + 1299260, + 1211068, + 1789410, + 1233772, + 1275996, + 1223517, + 1777025, + 1217308, + 1173723, + 1201164, + 1799922, + 1190684, + 1203708, + 1214283, + 1796914, + 1309677, + 1180956, + 1200747, + 1814914, + 1189740, + 1199212, + 1191452, + 1829858, + 1278956, + 1193020, + 1211388, + 1828034, + 1267068, + 1201884, + 1300077, + 1791185, + 1332654, + 1277516, + 1189292, + 1804290, + 1219180, + 1182059, + 1198972, + 1832610, + 1270684, + 1298189, + 1233612, + 1864931, + 1196107, + 1200604, + 1196428, + 1811650, + 1229452, + 1263452, + 1205692, + 1800306, + 1188796, + 1198411, + 1202876, + 1825154, + 1279597, + 1199772, + 1234556, + 1872178, + 1191324, + 1305325, + 1196636, + 1797041, + 1217436, + 1185756, + 1199228, + 1804161, + 1216076, + 1180908, + 1199340, + 1797553, + 1206300, + 1220412, + 1276397, + 1838546, + 1157547, + 1196460, + 1207404, + 1823074, + 1170187, + 1205020, + 1203724, + 1790050, + 1227660, + 1183019, + 1188732, + 1836722, + 1278205, + 1188139, + 1197116, + 1809730, + 1194124, + 1203692, + 1202139, + 1796818, + 1198460, + 1198812, + 1197339, + 1803202, + 1308557, + 1288397, + 1430318, + 2479480, + 1706577, + 1801058, + 1891282, + 2196198, + 2055652, + 2899261, + 2477368, + 2956109, + 1852722, + 2634890, + 1825698, + 2386744, + 1726689, + 1486350, + 1298653, + 1909491, + 1288284, + 1294637, + 1306365, + 1899139, + 1298332, + 1295469, + 1301357, + 1896515, + 1302605, + 1298444, + 1296861, + 2197638, + 1801809, + 1695873, + 1905267, + 2302598, + 1501039, + 1297181, + 1305757, + 1996003, + 2197590, + 1303837, + 1298861, + 1906274, + 1504031, + 1394046, + 1300077, + 1901618, + 1304013, + 1295677, + 1293533, + 1906194, + 1207932, + 1185052, + 1307453, + 1814450, + 1292524, + 1295997, + 1292381, + 1800338, + 1199931, + 1199340, + 1316077, + 1885779, + 1301388, + 1297501, + 1516495, + 2190294, + 1296284, + 1296701, + 1517039, + 2085573, + 1790033, + 1615568, + 1815426, + 2077220, + 1694593, + 1705921, + 1646688, + 2754635, + 1303021, + 1285421, + 1299436, + 1906083, + 1290413, + 1300925, + 1301068, + 2104597, + 1300589, + 1297021, + 1298572, + 1896227, + 1304029, + 1396974, + 1293916, + 1906291, + 1299869, + 1295821, + 1305933, + 1891794, + 1297917, + 1297485, + 1300924, + 1902659, + 1305325, + 1295485, + 1300140, + 1900387, + 1296749, + 1324989, + 1275340, + 1902019, + 1299293, + 1299085, + 1300637, + 1918018, + 1280493, + 1299405, + 1300220, + 1900691, + 1307549, + 1296525, + 1294620, + 1899315, + 1302045, + 1309165, + 1295709, + 1897378, + 1296829, + 1347501, + 1248620, + 1900403, + 1300285, + 1297725, + 1307469, + 1908914, + 1193548, + 1199516, + 1199260, + 1802961, + 1297885, + 1320269, + 1270829, + 1898626, + 1306605, + 1308589, + 1283501, + 1920707, + 1280012, + 1297165, + 1302573, + 1897042, + 1300797, + 1302909, + 1296973, + 1905426, + 1298573, + 1297021, + 1297213, + 1901106, + 1295901, + 1323021, + 1277565, + 1902242, + 1300461, + 1299901, + 1298429, + 1897810, + 1303485, + 1299357, + 1296685, + 1903490, + 1300125, + 1299213, + 1292157, + 1906754, + 1297037, + 1299853, + 1304685, + 1902947, + 1298124, + 1301053, + 1297053, + 1900994, + 1295693, + 1299453, + 1305501, + 1917443, + 1278332, + 1300253, + 1592848, + 2404887, + 1805970, + 2288839, + 2113060, + 3114239, + 1983219, + 2236054, + 1966564, + 2322999, + 2732826, + 3100799, + 1758977, + 1885331, + 1489758, + 2305287, + 2218342, + 2143797, + 1558159, + 2226518, + 2856588, + 2769884, + 2008371, + 2731883, + 1379230, + 2529592, + 2558089, + 1598975, + 1702833, + 2117029, + 2096949, + 2950573, + 2655802, + 2227078, + 1853746, + 2208262, + 1307964, + 2547049, + 1803522, + 1253932, + 1280621, + 1902579, + 1744113, + 1756577, + 1320717, + 1877715, + 1299612, + 1295629, + 1301117, + 1899187, + 1302060, + 1296701, + 1301261, + 1898755, + 1299692, + 1307645, + 1675009, + 2300438, + 1601024, + 2430488, + 2068164, + 2344631, + 2380872, + 2200517, + 2515033, + 2668234, + 2392488, + 1420254, + 1788993, + 3086207, + 2130341, + 3000829, + 1913651, + 3057294, + 2410840, + 2160805, + 1727745, + 2612506, + 1814402, + 1371885, + 2167877, + 3784965, + 1779042, + 1289341, + 1295900, + 1902419, + 1297165, + 1355005, + 2142469, + 3183040, + 1705344, + 1395630, + 2159509, + 2655066, + 2907405, + 1903907, + 2272950, + 2302311, + 1597567, + 1700497, + 1661168, + 3063567, + 1298764, + 1293933, + 1867842, + 2127141, + 1730545, + 1274637, + 1303181, + 1895586, + 1301693, + 1382974, + 1421230, + 1896130, + 1299229, + 1301325, + 1299709, + 2358231, + 1343325, + 1297437, + 1299725, + 1898994, + 1300765, + 1648992, + 1989460, + 2874972, + 2669290, + 1700225, + 2403656, + 2644810, + 1950755, + 2000787, + 1700049, + 2100709, + 1627760, + 1596432, + 1499278, + 3513315, + 3891110, + 1886611, + 1303244, + 2750699, + 3373602, + 1798657, + 1277997, + 2450216, + 1349453, + 1301293, + 1297565, + 1897714, + 1297581, + 1326621, + 1274413, + 1900002, + 1299629, + 1298829, + 1300061, + 1926051, + 1275244, + 1298093, + 1299549, + 1902146, + 1298589, + 1298957, + 1300445, + 1900594, + 1298413, + 1299709, + 1299629, + 1903907, + 1296204, + 1323661, + 1274989, + 1899106, + 1301069, + 1297869, + 1216716, + 1802450, + 1196779, + 1210972, + 1384046, + 2218278, + 1808626, + 1695984, + 1908771, + 2327351, + 1361437, + 1297485, + 1297997, + 1904787, + 1296652, + 1300813, + 1309565, + 1909763, + 1386365, + 1205404, + 1197164, + 1809746, + 1296269, + 1184539, + 1218156, + 1781490, + 1325645, + 1478062, + 1506271, + 2095525, + 1598751, + 1415950, + 1484543, + 2104164, + 1595311, + 1413854, + 1320381, + 1864306, + 1188828, + 1205996, + 1294045, + 1802801, + 1197676, + 1205052, + 1197356, + 1819826, + 1182571, + 1216092, + 1183644, + 1836098, + 1285485, + 1279868, + 1306013, + 1899123, + 1313885, + 1280300, + 1300653, + 1899347, + 1297868, + 1305037, + 1296397, + 2001668, + 1509167, + 1491918, + 1802018, + 2004132, + 1392701, + 1218556, + 1283101, + 1822354, + 1978995, + 1393070, + 1198268, + 1800209, + 1197804, + 1199468, + 1197596, + 1906579, + 1196075, + 1216956, + 1193980, + 1810546, + 1381165, + 1195148, + 1226988, + 1801586, + 1281628, + 1192588, + 1196428, + 1802754, + 1198987, + 1196156, + 1210188, + 1798466, + 1202188, + 1193675, + 1201692, + 1807538, + 1191772, + 1203644, + 1192699, + 1799074, + 1197868, + 1207676, + 1222812, + 2057476, + 1235804, + 1288061, + 1205563, + 1790098, + 1298749, + 1194684, + 1201659, + 1801538, + 1223068, + 1397710, + 1288013, + 1797665, + 1192732, + 1213436, + 1497519, + 2012547, + 1509903, + 1281597, + 1287532, + 1795442, + 1198156, + 1205820, + 1211676, + 1788961, + 1195356, + 1199132, + 1199916, + 1837042, + 1371837, + 1502127, + 1599312, + 2319878, + 1295437, + 1182188, + 1207628, + 1808209, + 1291149, + 1188140, + 1195628, + 1800545, + 1196652, + 1201516, + 1212604, + 1895314, + 1221292, + 1290397, + 1188956, + 1807042, + 1193099, + 1200444, + 1202092, + 1792066, + 1199035, + 1200316, + 1198108, + 1798050, + 1201067, + 1326141, + 1493135, + 2186630, + 1605439, + 1492687, + 1500399, + 2306806, + 1792546, + 1654160, + 1166636, + 1889362, + 1307053, + 1178108, + 1098475, + 1704000, + 987194, + 999434, + 999130, + 1597567, + 1004570, + 996842, + 1002762, + 1607232, + 1105003, + 1086074, + 1007178, + 1726785, + 1286493, + 1194220, + 1082266, + 1730017, + 1298957, + 1423086, + 1577327, + 2293479, + 1804610, + 1699296, + 1608544, + 1891955, + 1599888, + 1397597, + 1303245, + 1766754, + 1233244, + 1507086, + 1101467, + 1891267, + 1288413, + 1203963, + 1228540, + 1869075, + 1203356, + 1190603, + 1202108, + 1820146, + 1280269, + 1193611, + 1198636, + 1809218, + 1192460, + 1198779, + 1532048, + 2403063, + 1487807, + 2494936, + 1296445, + 1890835, + 1403997, + 1399390, + 1496031, + 2102005, + 1512638, + 1396398, + 1291773, + 1898131, + 1202427, + 1200524, + 1202380, + 1685265, + 1093466, + 1009434, + 988730, + 1603136, + 995833, + 1010826, + 990490, + 1600192, + 998586, + 1011146, + 993241, + 1595024, + 999466, + 1000714, + 999690, + 1610783, + 1123035, + 1301965, + 1298269, + 1921571, + 1273212, + 1107067, + 1194364, + 1919683, + 1489119, + 1607439, + 1490783, + 2195318, + 1697968, + 1803490, + 1610528, + 2087700, + 1294397, + 1190220, + 1210860, + 1790881, + 1196044, + 1202460, + 1199132, + 1799409, + 1297661, + 1203340, + 1197804, + 1816738, + 1207819, + 1195036, + 1186716, + 1681760, + 996586, + 998794, + 999434, + 1600848, + 1000377, + 999114, + 999354, + 1600848, + 998778, + 1000489, + 1136092, + 1896866, + 1299853, + 1296941, + 1301389, + 1900130, + 1292685, + 1204828, + 1299389, + 1801841, + 1088411, + 1088235, + 994889, + 1600544, + 999242, + 1000170, + 998010, + 1600767, + 998682, + 1001578, + 999130, + 1600304, + 999817, + 999386, + 1005626, + 1608576, + 986170, + 1001722, + 1003609, + 1601824, + 995370, + 1100075, + 1098955, + 1599263, + 998986, + 999354, + 1001450, + 1598912, + 999737, + 999978, + 999626, + 1613328, + 1088347, + 998793, + 1000074, + 1599584, + 1255580, + 1795106, + 1827490, + 2155269, + 1798402, + 1174699, + 1026362, + 1908771, + 1291133, + 1186747, + 1199452, + 1794114, + 1419422, + 1497359, + 1499630, + 2104997, + 1404862, + 1293773, + 1181371, + 1902307, + 1315357, + 1306973, + 1282060, + 1903555, + 1498847, + 1396333, + 1491439, + 2167733, + 1907971, + 1993636, + 2081220, + 2557065, + 1716449, + 1589232, + 1501935, + 2098436, + 1400766, + 1496079, + 1499678, + 2102757, + 1499359, + 1506735, + 1503070, + 2089317, + 1873810, + 1886531, + 1938659, + 2573785, + 1403646, + 1498191, + 1499550, + 2108549, + 1689409, + 1828338, + 1958755, + 2177317, + 1815218, + 1858194, + 1480927, + 2412776, + 1892274, + 1499391, + 1398798, + 2214485, + 1493919, + 1507263, + 1282237 + ], + "max_s": 0.003898407, + "p50_s": 0.001493342, + "p99_s": 0.003033885, + "pkg_above_idle_j_per_change": -0.000536400320294355, + "pkg_j_per_change": 0.056232500000000005, + "rep": 0, + "s_per_change": 0.0016343228675, + "wire_bytes_received_per_change": 109.016, + "wire_bytes_sent_per_change": 5316.4545 + }, + { + "arm": "direct_auth", + "changes": 2000, + "chunk_bytes_sent": 0, + "chunks_sent": 0, + "elapsed_s": 3.37299534, + "energy": { + "cpu_e_j": 2.356, + "cpu_p_j": 53.058, + "largest_gap_ms": 100.271, + "loadavg_end": [ + 3.96, + 4.28, + 4.27 + ], + "loadavg_start": [ + 4.05, + 4.3, + 4.28 + ], + "machine_busy_cpu_s": 8.260000000009313, + "nvme_temp_k": 314.0, + "pkg_edge_sd_j": 2.7212859339396775, + "pkg_j": 112.422, + "pkg_mean_w": 33.32880991182691, + "refusal": null, + "rest_j": 57.007999999999996, + "samples": 35, + "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)", + "sys_total_mean_w": 37.94311428571428, + "valid": true, + "window_s": 3.373117741 + }, + "latencies_ns": [ + 1625920, + 993978, + 999257, + 999514, + 1600864, + 1124187, + 1295837, + 1299228, + 1897699, + 1399998, + 1243916, + 1450254, + 1901507, + 1263596, + 1434335, + 1301132, + 1908675, + 1184924, + 1198684, + 1203483, + 1898451, + 1401326, + 1397005, + 1396286, + 1804546, + 1095851, + 1101723, + 1100202, + 1877059, + 1224876, + 1307261, + 1299532, + 1900323, + 1298109, + 1301309, + 1229644, + 1763793, + 1196044, + 1098875, + 1099834, + 1700817, + 1099579, + 1200332, + 1110939, + 1791873, + 1097275, + 1099883, + 1100187, + 1698944, + 1098971, + 1101707, + 1215132, + 1891874, + 1295325, + 1394366, + 1400814, + 1904930, + 1397342, + 1199692, + 1296253, + 1999875, + 1296525, + 1399502, + 1404302, + 1906530, + 1302653, + 1199260, + 1087691, + 1600671, + 999610, + 1122011, + 1396222, + 1793057, + 1193436, + 1200524, + 1099451, + 1810130, + 1393341, + 1303533, + 1194316, + 1957363, + 1344365, + 1213116, + 1383486, + 2000563, + 1199884, + 1100027, + 1097659, + 1700672, + 1098875, + 1100427, + 1209852, + 2090069, + 1399133, + 1319805, + 1193148, + 1789986, + 1098378, + 1099867, + 1098715, + 1710433, + 1191420, + 1098378, + 1100859, + 1699425, + 1099675, + 1211164, + 1395165, + 1899251, + 1401310, + 1398781, + 1500687, + 1998228, + 1401886, + 1399053, + 1399326, + 1904499, + 1194796, + 1204315, + 1192300, + 1800290, + 1099483, + 1198907, + 1101595, + 1798770, + 1099115, + 1099802, + 1099915, + 1801810, + 1204332, + 1196684, + 1097450, + 1700289, + 1098811, + 1200812, + 1098874, + 1793394, + 1418670, + 1495423, + 1396157, + 1890819, + 1399166, + 1399902, + 1412349, + 1889283, + 1395502, + 1401373, + 1398270, + 1903587, + 1403134, + 1395501, + 1422014, + 2137333, + 1647665, + 1676368, + 1945523, + 1974307, + 1203292, + 1098603, + 1098731, + 1805874, + 1299388, + 1389614, + 1399598, + 2434904, + 1350989, + 1302205, + 1395438, + 2403143, + 1791922, + 1860002, + 1842690, + 2414184, + 2241702, + 1782945, + 1814050, + 2634314, + 1729089, + 1725633, + 1586688, + 1895074, + 1390942, + 1658992, + 1149483, + 1699153, + 1099163, + 1099195, + 1203740, + 2257510, + 1894274, + 1896867, + 1900627, + 1854194, + 1384078, + 1964403, + 1896723, + 2485208, + 1564111, + 1314445, + 1377918, + 2001827, + 1432638, + 1368062, + 1394270, + 2428488, + 1677072, + 1689009, + 1404237, + 2004404, + 1395790, + 1417118, + 1968739, + 2318455, + 1946483, + 1713953, + 1668352, + 1987156, + 1629664, + 1454734, + 1300173, + 2296614, + 1649057, + 1913186, + 1644384, + 2298775, + 1704193, + 1885250, + 1887475, + 1918435, + 1395069, + 1406382, + 1921283, + 2134517, + 1340557, + 1488559, + 2151253, + 2116485, + 1330413, + 1399870, + 1834594, + 2405927, + 2015572, + 1994052, + 2111397, + 2334262, + 1752818, + 1664640, + 1420238, + 2622522, + 1534687, + 1813778, + 1744433, + 2606409, + 2096117, + 1252636, + 1294749, + 2004340, + 1301372, + 1502559, + 1504319, + 2022468, + 1275516, + 1211436, + 1098091, + 1700209, + 1098155, + 1099754, + 1555424, + 2530457, + 1314493, + 1996243, + 1473903, + 2213717, + 2028580, + 1863539, + 1416590, + 2299142, + 1487391, + 1845730, + 1979203, + 2365720, + 1680272, + 2076644, + 1251917, + 2260646, + 1755825, + 1381390, + 1301069, + 1899938, + 1302733, + 1307293, + 1484030, + 2366952, + 1871890, + 1817714, + 1969011, + 2432824, + 1841282, + 1739297, + 1868259, + 2486136, + 2168102, + 1616111, + 1914387, + 2230438, + 1203676, + 1646624, + 1866402, + 2355736, + 2064244, + 1745473, + 1325885, + 2329863, + 1991348, + 1853010, + 1585855, + 2370520, + 2093796, + 1750913, + 2049477, + 2039876, + 1760385, + 1739281, + 1423118, + 2397607, + 1882035, + 1809138, + 1295196, + 1908627, + 1294157, + 1298477, + 1307917, + 1813937, + 2493225, + 2209974, + 1679856, + 2644746, + 1661392, + 1791842, + 1796434, + 2396423, + 2154405, + 1838514, + 1814258, + 2380920, + 1764641, + 1789426, + 2109492, + 2597290, + 1669264, + 1580240, + 1505407, + 2187781, + 1499967, + 2148837, + 1770257, + 2341191, + 1770130, + 1199116, + 1198571, + 1815282, + 1382190, + 1696528, + 1656625, + 2498888, + 1640784, + 1741441, + 1918355, + 2241046, + 1398446, + 1516239, + 1545487, + 2238934, + 1697073, + 1960835, + 1638480, + 2562185, + 1251213, + 1294636, + 1940131, + 6616513, + 1233005, + 1937299, + 1664944, + 2248822, + 1812466, + 1250140, + 1386238, + 2166357, + 1638944, + 1394238, + 1963011, + 2239830, + 1660800, + 1640369, + 1557471, + 2501144, + 1871731, + 1926451, + 1349405, + 2155493, + 1146075, + 1404094, + 1645376, + 2371272, + 1633808, + 1901122, + 1550256, + 1930099, + 1914914, + 1335950, + 1397725, + 2006388, + 1407038, + 1306461, + 1194459, + 1698721, + 1396766, + 1958403, + 1347469, + 2583946, + 1440510, + 1924531, + 1149659, + 1791122, + 1644208, + 1485166, + 1927699, + 2253863, + 1953683, + 1233612, + 1810482, + 2421847, + 1366702, + 1959459, + 1555183, + 1988212, + 1705105, + 1650656, + 1339965, + 2658682, + 1557231, + 1946372, + 1248060, + 2060964, + 1327101, + 1400702, + 1707025, + 1993331, + 1963028, + 1552527, + 1288812, + 2307575, + 1947619, + 1650817, + 1288284, + 2561897, + 1885395, + 1434702, + 1878530, + 2368488, + 1286652, + 1715649, + 1507951, + 2260358, + 1401150, + 1399918, + 1748113, + 1849058, + 1407070, + 1396510, + 1314285, + 1886514, + 1583136, + 1601471, + 1600704, + 2200246, + 1604495, + 1591440, + 1803746, + 2020804, + 1523071, + 1322685, + 1614656, + 2363463, + 1376429, + 1412558, + 2120773, + 2691434, + 2091845, + 1759073, + 1838706, + 2592554, + 1806033, + 1669681, + 1895538, + 2457529, + 1926227, + 1440830, + 1211212, + 1967411, + 1603936, + 1845106, + 2089508, + 2148757, + 1799826, + 1326285, + 1481327, + 2098308, + 1595376, + 1499263, + 1502430, + 2199654, + 1499695, + 1947427, + 2007652, + 2611337, + 1864562, + 1902195, + 1729057, + 2692395, + 2091940, + 2117637, + 1443486, + 2251254, + 1650096, + 1357358, + 1455118, + 2182293, + 1589152, + 1415662, + 1744049, + 2586106, + 2115444, + 1999668, + 1466606, + 2258231, + 1897250, + 1727857, + 2081941, + 2664970, + 1469054, + 1963395, + 1396846, + 2210790, + 1885618, + 1149596, + 1094730, + 1701217, + 1103835, + 1213692, + 1182491, + 1698705, + 1101499, + 1101099, + 1189547, + 2262487, + 1640288, + 1397534, + 1400269, + 1809570, + 1197372, + 1389357, + 1710689, + 2012068, + 1691729, + 1397725, + 1200044, + 1906787, + 1387806, + 1393661, + 1400126, + 1901251, + 1208844, + 1098538, + 1103291, + 1695873, + 1104731, + 1196059, + 1098411, + 1700321, + 1099163, + 1100698, + 1099195, + 1810386, + 1402094, + 1397470, + 1397085, + 2106453, + 1395198, + 1397917, + 1306301, + 1989844, + 1390589, + 1301837, + 1400974, + 2001268, + 1498030, + 1398462, + 1312813, + 1885058, + 1406334, + 1393134, + 1400734, + 2004291, + 1310061, + 1287261, + 1399326, + 2004083, + 1399806, + 1398286, + 1394894, + 2005555, + 1392622, + 1399534, + 1400205, + 2559818, + 1903698, + 1466479, + 1690096, + 1882371, + 1964851, + 2024548, + 1406798, + 2264150, + 1336717, + 1416846, + 1289549, + 2263766, + 1332845, + 1396542, + 1401469, + 1999908, + 1546399, + 1727393, + 1538735, + 1794802, + 1099355, + 1099082, + 1099387, + 2047652, + 1906355, + 1244636, + 1294957, + 2559449, + 1338445, + 1699633, + 1400366, + 1998675, + 1211948, + 1837250, + 1561312, + 2497128, + 1817730, + 1673921, + 1476638, + 2081652, + 1775186, + 1925475, + 1601760, + 2242054, + 1397325, + 1400814, + 1362637, + 1939795, + 1403630, + 1640960, + 1912547, + 2098165, + 1556415, + 1682721, + 1604639, + 2257542, + 1898323, + 1340685, + 1732865, + 1882291, + 1386301, + 1733121, + 1796226, + 2072340, + 1656113, + 1743505, + 1398478, + 2330806, + 1677409, + 1957875, + 1977540, + 1958771, + 1699345, + 1955843, + 1772801, + 2528649, + 1644032, + 1309389, + 1392910, + 1999491, + 1505679, + 1392254, + 1955059, + 1973491, + 1272253, + 1691408, + 1420622, + 2423208, + 1837026, + 1512895, + 1119403, + 1976531, + 1421086, + 1704529, + 2100501, + 2241302, + 1645168, + 1313085, + 1392014, + 2298726, + 1703249, + 1398670, + 1397773, + 2244358, + 1261549, + 1907138, + 1390238, + 2099653, + 1698128, + 1657409, + 1900018, + 1836242, + 1418990, + 1541647, + 1641153, + 2260838, + 1940947, + 1415118, + 1539615, + 1842082, + 1397598, + 1418478, + 1937859, + 2244502, + 1513246, + 1293917, + 1389294, + 2268358, + 1635088, + 1719921, + 1377918, + 2402327, + 1696881, + 1575663, + 1884275, + 1950627, + 1295773, + 1831250, + 1173131, + 1824882, + 1578480, + 1293116, + 1202908, + 1700113, + 1096363, + 1099434, + 1103211, + 1946979, + 1503743, + 1641728, + 1829442, + 2320423, + 1358189, + 1951892, + 1647536, + 2254710, + 1894530, + 1647537, + 1406029, + 2000868, + 1467791, + 1325356, + 1398430, + 2245526, + 1906163, + 1643472, + 1529135, + 2188950, + 1384269, + 1422222, + 1953891, + 2333831, + 1648385, + 1861490, + 1273980, + 2558905, + 1654993, + 1647104, + 1896419, + 1945571, + 1403325, + 1203372, + 1099035, + 1900051, + 1393789, + 1396702, + 1396846, + 2253190, + 1250540, + 1699249, + 1645856, + 2213942, + 1897218, + 1915475, + 1431214, + 2459928, + 1425534, + 1405566, + 2149045, + 1944275, + 1121307, + 1201212, + 1374478, + 2002371, + 1595712, + 1654080, + 1348942, + 1902738, + 1298989, + 1414046, + 1579967, + 1835298, + 1386142, + 1288717, + 1308492, + 1926946, + 1458479, + 1868114, + 1436894, + 2355415, + 1339854, + 1308220, + 1293373, + 2659802, + 1442702, + 1295485, + 1299709, + 1905843, + 1308332, + 1382878, + 1957107, + 2336247, + 1223020, + 1918915, + 1646736, + 2479785, + 1587087, + 1662624, + 1758018, + 2105508, + 1341246, + 1541967, + 1569151, + 2284279, + 1314541, + 1195243, + 1201564, + 1990516, + 1559759, + 1650544, + 1384622, + 2262598, + 1150043, + 1097579, + 1100459, + 1800801, + 1453903, + 1639584, + 1927091, + 2540537, + 1630160, + 1705232, + 1696161, + 2158069, + 1599936, + 1670848, + 1443535, + 2182469, + 2545177, + 1655344, + 1368062, + 1976659, + 1707617, + 1603296, + 1284492, + 2304727, + 1924787, + 1368205, + 1956196, + 2104804, + 1338813, + 1399150, + 1401086, + 2001924, + 1398957, + 1401742, + 1612768, + 2019940, + 1616496, + 1909346, + 1149580, + 1698896, + 1098523, + 1101003, + 1100107, + 2048564, + 1903602, + 1335182, + 1404765, + 2560681, + 1335710, + 1650496, + 1511407, + 2240502, + 1660880, + 1670672, + 1841954, + 2118645, + 1622288, + 1285853, + 1659360, + 2473768, + 1364046, + 1633648, + 1399902, + 2124628, + 1472911, + 1926451, + 1342045, + 2272310, + 1726977, + 1315693, + 1195740, + 1812690, + 1693584, + 1643617, + 1554239, + 2293750, + 1199804, + 1100955, + 1097627, + 1700096, + 1101339, + 1100379, + 1203068, + 2100484, + 1405870, + 1293677, + 1401294, + 1997267, + 1413454, + 1395518, + 1395438, + 1900082, + 1391966, + 1297309, + 1517135, + 1889666, + 1431198, + 1658481, + 1702992, + 2156933, + 1239997, + 1692912, + 1594080, + 1925267, + 1192156, + 1100394, + 1098523, + 2054868, + 1236732, + 1660833, + 1635376, + 2004643, + 1645697, + 1910258, + 1152188, + 2052020, + 1911555, + 1325565, + 1647536, + 2270214, + 1281421, + 1660256, + 1502047, + 1946707, + 1399310, + 1960355, + 1900275, + 1941859, + 1401053, + 1204508, + 1816274, + 2278502, + 1393518, + 1663744, + 1241853, + 1700800, + 1198828, + 1200460, + 1099355, + 1900178, + 1652353, + 1659872, + 1938659, + 2504121, + 1637952, + 1963939, + 1732737, + 2220054, + 1391069, + 1687345, + 1557903, + 2244934, + 1395678, + 1428270, + 1934771, + 2358119, + 1595344, + 1847218, + 1343037, + 1997652, + 1398014, + 1396029, + 1400894, + 2000756, + 1212524, + 1193739, + 1392766, + 2014996, + 1582079, + 1499007, + 1601184, + 2200517, + 1215900, + 1097483, + 1099115, + 1699377, + 1099770, + 1101163, + 1099371, + 1699201, + 1100698, + 1098635, + 1200796, + 1700449, + 1098794, + 1100123, + 1100587, + 1699825, + 1098811, + 1100410, + 1100667, + 1699745, + 1206252, + 1301709, + 1192283, + 1798482, + 1395822, + 1301372, + 1411374, + 1989204, + 1432894, + 1358477, + 1486431, + 2191829, + 1496575, + 1619584, + 1855378, + 2354455, + 1571584, + 1906642, + 1596192, + 2669418, + 1732417, + 1876003, + 1337837, + 1896835, + 1316348, + 1215036, + 1483647, + 2219990, + 1870066, + 1856594, + 2090485, + 2641722, + 2161653, + 1836914, + 1819250, + 2579401, + 1752241, + 1290189, + 1632128, + 1932627, + 1298509, + 1400430, + 1599647, + 2194902, + 1327645, + 1196972, + 1304204, + 2230454, + 2040356, + 1853475, + 1351261, + 2112005, + 1857170, + 1832082, + 1789937, + 2317703, + 1395006, + 1300428, + 1296621, + 2369096, + 1855650, + 2137509, + 1661920, + 2441784, + 1827298, + 1911651, + 1841938, + 2165797, + 1481279, + 2048100, + 2007443, + 2701323, + 1702561, + 1534383, + 1512494, + 2654539, + 2170069, + 1818338, + 1984835, + 2167157, + 1851347, + 1986211, + 1756049, + 2430200, + 1882323, + 1321341, + 1691056, + 2305959, + 1478718, + 2173398, + 1715024, + 2379336, + 1892098, + 1888179, + 2102437, + 2144005, + 1850994, + 1768401, + 1574352, + 2515192, + 1603680, + 1882547, + 1638768, + 2359447, + 1801633, + 1596320, + 1496991, + 2659114, + 1847106, + 1859970, + 1651840, + 2350072, + 2086948, + 1858018, + 1766706, + 2181781, + 1543903, + 1594048, + 1600624, + 2204933, + 1420654, + 1401054, + 1203980, + 1999811, + 1503407, + 2038740, + 1448062, + 2327623, + 1868243, + 1870978, + 1814994, + 2232758, + 1559135, + 1604992, + 2282454, + 2416264, + 2168037, + 1843586, + 1424990, + 2178678, + 1512526, + 1570304, + 2075284, + 2535561, + 2323767, + 1827298, + 1454302, + 2788699, + 1597696, + 1779602, + 2119172, + 2459929, + 2110580, + 1547199, + 1763010, + 2455480, + 1562031, + 2157717, + 1943123, + 2206198, + 2321735, + 1473614, + 1762834, + 2339015, + 1838370, + 2139573, + 1721265, + 2223189, + 1481359, + 2494904, + 3832022, + 4161513, + 4153305, + 1556559, + 1503423, + 1598543, + 2206806, + 1595792, + 1577743, + 1437262, + 2083141, + 1590367, + 1605760, + 1608512, + 2022212, + 1475822, + 1620208, + 1576800, + 2200709, + 1818242, + 1875026, + 1773666, + 2529273, + 1844674, + 2171861, + 1577744, + 3759924, + 3370546, + 4565276, + 3402546, + 2122005, + 1576159, + 1601424, + 1595839, + 2277127, + 1438734, + 1589008, + 1604319, + 2094997, + 2174501, + 1424046, + 1416558, + 2499977, + 1844226, + 1790785, + 2271863, + 2429399, + 1548400, + 2061700, + 2084916, + 2404536, + 1441886, + 1918995, + 2002596, + 2450488, + 2082884, + 1451550, + 1868995, + 2789627, + 1836834, + 1496431, + 1856530, + 2453816, + 1405422, + 1405566, + 2154277, + 2386855, + 2109365, + 1430462, + 1410942, + 1899298, + 1406942, + 1954995, + 1701649, + 2422936, + 2172853, + 1879955, + 1456862, + 2353991, + 1452606, + 1864115, + 1537087, + 2188629, + 1864627, + 1348125, + 1114507, + 1698432, + 1098891, + 1191580, + 1402062, + 2026276, + 2113140, + 1437374, + 1418686, + 2563337, + 1530047, + 2153094, + 1902930, + 2137941, + 1807682, + 1766689, + 1690513, + 2589209, + 1357038, + 1402029, + 2146181, + 2637978, + 1518031, + 1484255, + 1588175, + 2205542, + 1806418, + 1424094, + 1394173, + 2234038, + 1838914, + 1497535, + 1507055, + 1913459, + 1310397, + 1282732, + 1300029, + 2213590, + 1690224, + 1984980, + 1346077, + 2222998, + 1510895, + 1903122, + 1592928, + 1878994, + 1177404, + 1096875, + 1097818, + 1799922, + 1195932, + 1588495, + 1966308, + 2241302, + 1313629, + 1687760, + 1207708, + 2151653, + 1633536, + 1402574, + 1664336, + 2486761, + 1347581, + 1563007, + 1738545, + 2301079, + 1951411, + 1448318, + 1557968, + 2188645, + 1705569, + 1348669, + 1697809, + 2307878, + 1607568, + 1944835, + 1649504, + 2247847, + 1521022, + 1881187, + 1904803, + 2370775, + 1365437, + 1701633, + 1944419, + 2525353, + 1327997, + 1613984, + 1283900, + 2001796, + 1397518, + 1960819, + 1648496, + 2197158, + 1557263, + 1241116, + 1400174, + 2756027, + 1637632, + 1453614, + 1906035, + 1843714, + 1656448, + 1339229, + 1407934, + 2256214, + 1437263, + 2308006, + 1833570, + 2279175, + 1628608, + 1911330, + 1645201, + 1803553, + 1499279, + 1704033, + 1387101, + 2254710, + 1645953, + 1661280, + 1147515, + 2305783, + 1686240, + 1623344, + 1932563, + 2499193, + 1242988, + 1558447, + 1347741, + 2155702, + 1892802, + 1342973, + 1662465, + 2094356, + 1240492, + 1804002, + 1396526, + 2001523, + 1636624, + 1664145, + 1301005, + 2001971, + 1288861, + 1300877, + 1401613, + 2191238, + 1601568, + 1496110, + 1595728, + 2101413, + 1514783, + 1494718, + 1597424, + 1929923, + 1193372, + 1205355, + 1193020, + 1698145, + 1099482, + 1099643, + 1100491, + 1700401, + 1098987, + 1100554, + 1098347, + 1702225, + 1097787, + 1100170, + 1100235, + 1700209, + 1099419, + 1100171, + 1211147, + 1985108, + 1396766, + 1398365, + 1405374, + 1995364, + 1209036, + 1198971, + 1453999, + 2495352, + 1904275, + 1897106, + 1672849, + 1978643, + 1303101, + 1521071, + 1923907, + 2500120, + 1640785, + 1933922, + 1381742, + 1893395, + 1390093, + 1668337, + 1735249, + 1931667, + 1462478, + 1299773, + 1565631, + 1744193, + 1100459, + 1097931, + 1101067, + 1893746, + 1397534, + 1401614, + 1963475, + 2294214, + 1687089, + 1653712, + 1401566, + 1998132, + 1301437, + 1206523, + 1193628, + 2281302, + 1975316, + 1640304, + 1702753, + 1899490, + 1313405, + 1289581, + 1401598, + 2000467, + 1464367, + 1457774, + 1491343, + 1878530, + 1702129, + 1736129, + 1362061, + 2258566, + 1640337, + 1400637, + 1299741, + 2266854, + 1718641, + 1960179, + 1949155, + 2144870, + 1519550, + 1486479, + 1611984, + 2379431, + 1920595, + 1588384, + 1472478, + 2136549, + 1810578, + 1894274, + 1334718, + 2564601, + 1898674, + 1886627, + 1656992, + 2296791, + 1661872, + 1497263, + 1639104, + 2556473, + 1902195, + 1338957, + 1398733, + 2007188, + 1399694, + 1398590, + 1312284, + 2290567, + 1293821, + 1399165, + 1969732, + 2333623, + 1398781, + 1398430, + 1305629, + 2259830, + 2049284, + 1915187, + 1371501, + 1901203, + 1299053, + 1406814, + 1392925, + 2405352, + 1394142, + 1403725, + 1610176, + 1990100, + 1695712, + 1918931, + 1378590, + 2159285, + 1498623, + 1241980, + 1660144, + 2240102, + 1399502, + 1392158, + 1413069, + 2294423, + 1558495, + 1780690, + 1259852, + 2002532, + 1657760, + 2151221, + 1959859, + 1898147, + 1230716, + 1962051, + 1371342, + 2540569, + 1730561, + 1204860, + 1100394, + 1700657, + 1098171, + 1107915, + 1193931, + 1698241, + 1100635, + 1099547, + 1097722, + 1702049, + 1098827, + 1099659, + 1199579, + 1996372, + 1206028, + 1199388, + 1099402, + 1822978, + 1500527, + 1371678, + 1411133, + 2174550, + 1616176, + 2132597, + 1729712, + 2559770, + 1769617, + 1905523, + 1400029, + 2001060, + 2059300, + 1868547, + 1463422, + 1992515, + 1302077, + 1501647, + 2047556, + 2041540, + 1432142, + 1196412, + 1099547, + 1900866, + 1285277, + 1548943, + 1734673, + 2362487, + 1839010, + 1734705, + 1473327, + 2449048, + 1549359, + 2059092, + 1715297, + 2696699, + 2174261, + 1449102, + 1853602, + 2438712, + 1864178, + 1851315, + 1583951, + 2323095, + 2137493, + 1349053, + 1988404, + 2407991, + 1495295, + 1600352, + 1857282, + 2357431, + 1396974, + 1308269, + 1291500, + 1992740, + 1232908, + 1193884, + 1299468, + 1698817, + 1098859, + 1100427, + 1098490, + 1702209, + 1098235, + 1099627, + 1100170, + 1700241, + 1100235, + 1209660, + 1492750, + 1997092, + 1397950, + 1404029, + 1394046, + 2253686, + 1899667, + 1349005, + 1394014, + 2424280, + 1375597, + 1702145, + 1310029, + 1984979, + 1644096, + 1617872, + 1639200, + 2259494, + 1646464, + 1391182, + 1701633, + 1999635, + 1741458, + 1914898, + 1907187, + 1841106, + 1399150, + 1500207, + 1300108, + 2000788, + 1501055, + 1397981, + 1399566, + 2001716, + 1398557, + 1401902, + 1400958, + 1999332, + 1395437, + 1400942, + 1204828, + 1790689, + 1399150, + 1396126, + 1406062, + 2001843, + 1402958, + 1304445, + 1193147, + 2001492, + 1400030, + 1396638, + 1397053, + 2106037, + 1205084, + 1302060, + 1392014, + 1995652, + 1480398, + 1421918, + 1399374, + 1806402, + 1395005, + 1397870, + 1396478, + 2177269, + 1323309, + 1314237, + 1194428, + 1794625, + 1399054, + 1652016, + 2038548, + 2368856, + 1995763, + 1656032, + 1292285, + 2233574, + 1656528, + 1648416, + 1494607, + 2268038, + 1305613, + 1281661, + 1409133, + 2294215, + 1956291, + 1339117, + 1319101, + 1983572, + 1402797, + 1396590, + 1401438, + 2000051, + 1395438, + 1404798, + 1395486, + 2002131, + 1399486, + 1399550, + 1397981, + 2003444, + 1399518, + 1656992, + 1342781, + 2002356, + 1312909, + 1291852, + 1400846, + 1997700, + 1401486, + 1405549, + 1391534, + 1896275, + 1399357, + 1402046, + 1398286, + 1904259, + 1698560, + 1987428, + 1955571, + 2256294, + 1645616, + 1566351, + 1690849, + 2144453, + 1687729, + 1661120, + 1659712, + 1940771, + 1397550, + 1297837, + 1403742, + 2001715, + 1397054, + 1402078, + 1313500, + 1795458, + 1291917, + 1396366, + 1401149, + 1999988, + 1495279, + 1411197, + 1397454, + 1906579, + 1395997, + 1400238, + 1407006, + 1990372, + 1397677, + 1397950, + 1394078, + 1918514, + 1388190, + 1402574, + 1298845, + 2098148, + 1399086, + 1397390, + 1399357, + 1922003, + 1460591, + 1508030, + 1587728, + 2198629, + 1504063, + 1410350, + 1313373, + 2001140, + 1397181, + 1580288, + 1596559, + 2097877, + 1411054, + 1597328, + 1515806, + 2004660, + 1400494, + 1396702, + 1399357, + 1913171, + 1386430, + 1397501, + 1414078, + 2183590, + 1583215, + 1596016, + 1518591, + 2181221, + 1598304, + 1605648, + 1600287, + 2228646, + 1586896, + 1610847, + 1595472, + 2193382, + 1600415, + 1498511, + 1595008, + 2106260, + 1591952, + 1599120, + 1602303, + 2203206, + 1600480, + 1598479, + 1403310, + 2201014, + 1593375, + 1509695, + 1494655, + 2103428, + 1597680, + 1409310, + 1485983, + 2190565, + 1596784, + 1598111, + 1599936, + 2234966, + 1477774, + 1591904, + 1598192, + 2022404, + 1576511, + 1597856, + 1604175, + 2027812, + 1506399, + 1193932, + 1198156, + 1792945, + 1398350, + 1207500, + 1401758, + 1996547, + 1404526, + 1396590, + 1400861, + 2007780, + 1401438, + 1503295, + 1387053, + 2005700, + 1548607, + 1529951, + 1594896, + 2199045, + 1599744, + 1601616, + 1599183, + 2199542, + 1600512, + 1607759, + 2410920, + 2086533, + 1499982, + 1511679, + 1490607, + 2191141, + 1598512, + 1590127, + 1902083, + 2099269, + 1420782, + 1400013, + 1486191, + 2114501, + 1583119, + 1504079, + 1492159, + 2268150, + 1537119, + 1313501, + 1209100, + 1788113, + 1294589, + 1299309 + ], + "max_s": 0.006616513, + "p50_s": 0.001635376, + "p99_s": 0.002654539, + "pkg_above_idle_j_per_change": -0.0023700036279699576, + "pkg_j_per_change": 0.056211, + "rep": 0, + "s_per_change": 0.00168649767, + "wire_bytes_received_per_change": 0.0, + "wire_bytes_sent_per_change": 0.0 + }, + { + "arm": "direct", + "changes": 2000, + "chunk_bytes_sent": 0, + "chunks_sent": 0, + "elapsed_s": 2.666455096, + "energy": { + "cpu_e_j": 2.007, + "cpu_p_j": 48.022, + "largest_gap_ms": 101.205, + "loadavg_end": [ + 3.96, + 4.28, + 4.27 + ], + "loadavg_start": [ + 3.96, + 4.28, + 4.27 + ], + "machine_busy_cpu_s": 7.260000000009313, + "nvme_temp_k": 314.0, + "pkg_edge_sd_j": 2.9631688201215094, + "pkg_j": 96.773, + "pkg_mean_w": 36.29125815511284, + "refusal": null, + "rest_j": 46.744, + "samples": 28, + "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)", + "sys_total_mean_w": 40.47978571428572, + "valid": true, + "window_s": 2.666565033 + }, + "latencies_ns": [ + 951018, + 1495134, + 1028074, + 1298317, + 1198604, + 1700961, + 972729, + 900201, + 899913, + 1500751, + 900600, + 1024234, + 1298621, + 1899267, + 975769, + 1023642, + 1298925, + 1800642, + 1297917, + 1307372, + 1291565, + 1899075, + 1296684, + 990490, + 1213548, + 1797650, + 1310349, + 1282492, + 1100283, + 1797602, + 1312524, + 1201212, + 1401854, + 2001316, + 1294636, + 1412910, + 1279165, + 1794673, + 1302509, + 1113371, + 1187500, + 1998131, + 1505343, + 1209372, + 1188972, + 1802849, + 1194652, + 1106123, + 1398590, + 1798289, + 1404382, + 1297661, + 1192507, + 1721569, + 1278941, + 985786, + 899864, + 1633424, + 1186092, + 1307533, + 1363709, + 1728017, + 1404078, + 1199420, + 1293532, + 1710049, + 1189420, + 1313133, + 1285196, + 1901523, + 1311805, + 971593, + 1015770, + 1799330, + 1194972, + 1203772, + 1509454, + 1899507, + 1298541, + 1300972, + 1191932, + 1701313, + 1299229, + 1099562, + 1298317, + 1900547, + 1101467, + 983017, + 898825, + 1500495, + 898857, + 1014234, + 1303020, + 1800290, + 1299149, + 1298988, + 1204844, + 1899955, + 1299789, + 1201499, + 1296685, + 1795858, + 1295469, + 1320813, + 1286588, + 1899523, + 1394797, + 1113803, + 1285149, + 1811858, + 1298717, + 1290668, + 1508799, + 1894403, + 1327949, + 953465, + 1023994, + 1904371, + 1076602, + 1550815, + 1051211, + 1600079, + 996842, + 1180572, + 1022218, + 1597263, + 999594, + 1098523, + 1001466, + 1599248, + 1004761, + 995658, + 998906, + 1603072, + 997882, + 999801, + 1101915, + 1602976, + 995754, + 997993, + 1094523, + 1608624, + 996922, + 1001482, + 998873, + 1791042, + 1009338, + 1005754, + 995113, + 1598144, + 1000106, + 1086923, + 1201675, + 1798722, + 1200844, + 1198572, + 1119803, + 1679040, + 1196700, + 1203468, + 1198859, + 1798898, + 1126379, + 1178332, + 1200363, + 1797698, + 1197484, + 2040932, + 1553599, + 2107109, + 1384301, + 1496335, + 1239084, + 1679633, + 1200731, + 1118091, + 1179820, + 2156645, + 1825282, + 1215580, + 1103755, + 1797761, + 1100171, + 1199324, + 1548735, + 2034884, + 1032922, + 998842, + 998810, + 1599904, + 999481, + 1002730, + 1394190, + 1885074, + 1215452, + 1201276, + 1202252, + 1794545, + 1201724, + 1205084, + 1011002, + 1597920, + 1002057, + 1086539, + 1004394, + 1599456, + 994873, + 1108347, + 998874, + 1595056, + 998074, + 998505, + 999834, + 1601488, + 1004282, + 1002106, + 994665, + 1600496, + 1000650, + 999578, + 1019322, + 1604815, + 1003498, + 994778, + 992474, + 1602463, + 984250, + 1002810, + 997370, + 1600287, + 1006698, + 990906, + 997434, + 1600304, + 1113850, + 1013274, + 979018, + 1598240, + 1113483, + 990681, + 1001706, + 1609280, + 982250, + 1005145, + 993450, + 1624800, + 977498, + 997017, + 996682, + 1623120, + 993786, + 993226, + 995337, + 1621168, + 978394, + 1021258, + 979273, + 1597216, + 997690, + 1021754, + 983226, + 1595695, + 1003514, + 1005802, + 1013898, + 1578223, + 997770, + 1026234, + 990634, + 1589023, + 996218, + 1016042, + 994554, + 1593744, + 1012938, + 982985, + 997626, + 1597216, + 1005833, + 1017226, + 985898, + 1596320, + 1008554, + 1005465, + 985978, + 1615792, + 984842, + 1015690, + 979225, + 1605760, + 995242, + 998778, + 1015833, + 1582080, + 998842, + 1000730, + 1113211, + 1608543, + 982298, + 997050, + 998873, + 1600144, + 1000314, + 998922, + 1000106, + 1600543, + 1024250, + 983450, + 995754, + 1614960, + 984153, + 997562, + 999018, + 1615712, + 987593, + 1019402, + 1082939, + 1594960, + 1008265, + 993002, + 997866, + 1600000, + 1009497, + 992442, + 998042, + 1599456, + 1009418, + 992953, + 997994, + 1601136, + 997610, + 999017, + 999930, + 1600256, + 998986, + 999898, + 999305, + 1513935, + 991642, + 997882, + 998905, + 1599568, + 999386, + 998922, + 901609, + 1598575, + 899353, + 901609, + 999594, + 1712465, + 1196251, + 1192876, + 1200172, + 1800513, + 1197740, + 1199340, + 1109659, + 1792049, + 1099051, + 1107499, + 1196348, + 1797041, + 1209404, + 1182124, + 1506207, + 2066356, + 1142699, + 1237404, + 1066603, + 1685840, + 896249, + 898169, + 900360, + 1499871, + 900633, + 898297, + 900169, + 1502206, + 898153, + 899769, + 901241, + 1498687, + 900744, + 900569, + 898745, + 1500335, + 899641, + 899544, + 900041, + 1501071, + 898745, + 900489, + 899592, + 1499839, + 901401, + 898217, + 900377, + 1501038, + 899065, + 900153, + 900889, + 1499598, + 898937, + 900121, + 899609, + 1500815, + 899864, + 899801, + 899961, + 1500015, + 899625, + 899993, + 899672, + 1501119, + 900313, + 898409, + 900425, + 1500046, + 900025, + 899673, + 901497, + 1499422, + 1015130, + 1200652, + 1096907, + 1796193, + 1309741, + 1300013, + 1495647, + 2101716, + 1695185, + 1201692, + 984793, + 1802258, + 1514847, + 1209100, + 1390605, + 1997700, + 1500623, + 1083610, + 1015658, + 1808434, + 1467086, + 1322493, + 1502655, + 2093237, + 1089482, + 1013402, + 1463711, + 1832658, + 1202507, + 1196236, + 1191564, + 1804177, + 1209372, + 1095787, + 1200540, + 1801538, + 1301292, + 1206604, + 1190396, + 1814658, + 1172315, + 1205932, + 1203068, + 1803665, + 1190956, + 1104267, + 1202412, + 1814945, + 1179420, + 1000666, + 1206316, + 1798913, + 1191820, + 1206732, + 1207660, + 1801729, + 1192044, + 1193852, + 1110091, + 1787969, + 1307277, + 1192716, + 1210828, + 1908450, + 1289693, + 1307037, + 1192795, + 1808610, + 1208620, + 1196748, + 1187643, + 1725409, + 1172684, + 1203164, + 1192427, + 1710481, + 1195916, + 1200812, + 1208411, + 1787762, + 1203740, + 1214892, + 1185147, + 1793858, + 1201276, + 1096154, + 1122555, + 2176742, + 1207452, + 1198523, + 1193724, + 1800754, + 1198187, + 1200956, + 1198204, + 1796882, + 1206715, + 1213068, + 1190444, + 1822322, + 974729, + 1202156, + 1197564, + 1797330, + 1302956, + 1088539, + 1210076, + 1805906, + 1097002, + 1099179, + 1209292, + 1793986, + 1207515, + 1109979, + 1081307, + 1697185, + 1107994, + 1008794, + 985050, + 1596960, + 994649, + 1003002, + 995786, + 1599408, + 998089, + 999482, + 1008922, + 1594496, + 996746, + 1220139, + 1195484, + 1797922, + 1315277, + 1078490, + 1200540, + 1800994, + 1096011, + 1102506, + 1197500, + 1708273, + 989961, + 997690, + 1000682, + 1606928, + 995050, + 998377, + 996346, + 1600448, + 999114, + 999577, + 1000922, + 1601072, + 999354, + 1011034, + 997593, + 1595536, + 1007482, + 1201756, + 1258396, + 1645264, + 991898, + 994266, + 1000890, + 1594735, + 999050, + 999450, + 1001370, + 1598063, + 1000842, + 1000474, + 998266, + 1600671, + 999050, + 1001642, + 999258, + 1609808, + 995481, + 996346, + 1004650, + 1591152, + 896520, + 900249, + 899545, + 1502623, + 900361, + 910840, + 990954, + 1496735, + 898905, + 898936, + 900873, + 1499103, + 904041, + 895993, + 900456, + 1499695, + 900025, + 900041, + 900105, + 1500014, + 902537, + 896521, + 901561, + 1506447, + 893048, + 899545, + 901657, + 1498815, + 901609, + 899512, + 900617, + 1500399, + 896841, + 899641, + 902136, + 1498975, + 1211324, + 993082, + 896393, + 1498766, + 899097, + 900585, + 899001, + 1503470, + 1003018, + 1129147, + 969226, + 1627952, + 983177, + 990874, + 998282, + 1606976, + 996601, + 998666, + 1000074, + 1599936, + 1002650, + 1004169, + 994922, + 1797330, + 1203580, + 1097258, + 1200076, + 1712673, + 1084123, + 1200187, + 1201500, + 1697457, + 1206540, + 1195035, + 1096955, + 1710193, + 1189483, + 1101419, + 1000698, + 1709249, + 997754, + 1193035, + 1192748, + 1797650, + 1010074, + 998601, + 998506, + 1805090, + 1023114, + 981417, + 996778, + 1594000, + 999194, + 999497, + 899673, + 1502367, + 1002570, + 999002, + 1003497, + 1694641, + 1007162, + 1013914, + 988010, + 1605743, + 998378, + 989434, + 1005626, + 1600639, + 991738, + 998058, + 998842, + 1600943, + 998842, + 1000298, + 1000266, + 1598847, + 1000426, + 1100475, + 1200844, + 1720929, + 987673, + 993562, + 1007578, + 1592832, + 997097, + 1001066, + 998474, + 1599360, + 999050, + 999273, + 1000346, + 1607984, + 994714, + 1011674, + 989353, + 1606576, + 992922, + 1013210, + 984953, + 1599520, + 998106, + 1000890, + 1001289, + 1598192, + 1006538, + 996202, + 998970, + 1598239, + 998394, + 1000042, + 999706, + 1599983, + 999178, + 1000314, + 999306, + 1503742, + 997674, + 1007386, + 1006986, + 1591520, + 1004873, + 994410, + 999818, + 1594800, + 1004601, + 995066, + 998458, + 1601360, + 999130, + 999081, + 1004218, + 1605120, + 995482, + 1014602, + 985225, + 1605216, + 994874, + 999978, + 996137, + 1603760, + 999338, + 1003434, + 1001082, + 1591007, + 999866, + 1000410, + 1007674, + 1595215, + 997706, + 998858, + 998698, + 1517567, + 1002745, + 991434, + 992666, + 1598511, + 999626, + 1001738, + 999370, + 1600336, + 1002121, + 997722, + 997866, + 1600256, + 1002842, + 996553, + 1004858, + 1613632, + 1088923, + 1090186, + 1246141, + 1766865, + 1209692, + 1191643, + 1195868, + 1699921, + 1203660, + 1205787, + 1182956, + 1817714, + 1294109, + 1296924, + 982666, + 1499663, + 899304, + 900793, + 900489, + 1499375, + 899897, + 899480, + 928137, + 1577536, + 897593, + 902777, + 895960, + 1523439, + 988394, + 988682, + 911817, + 1598127, + 996106, + 1013578, + 994986, + 3205615, + 988346, + 1899075, + 1601263, + 1008458, + 1686913, + 1186651, + 1798498, + 1098843, + 1100570, + 1098027, + 1700929, + 1116011, + 999322, + 1179787, + 1704737, + 1097435, + 1099547, + 1100890, + 1803522, + 1014186, + 1008490, + 997770, + 1593199, + 999578, + 996506, + 1000122, + 1605583, + 998746, + 1000106, + 1007594, + 1592783, + 1014938, + 999626, + 998266, + 1586944, + 996361, + 997834, + 1000122, + 1625648, + 978617, + 890745, + 898521, + 1500415, + 898856, + 900185, + 900201, + 1624112, + 1295741, + 1304333, + 1207323, + 1795202, + 1109531, + 1180427, + 1200892, + 1800050, + 1198284, + 1198059, + 1102155, + 1820082, + 1088923, + 983545, + 993818, + 1499167, + 896809, + 905385, + 894728, + 1499663, + 910297, + 891705, + 898472, + 1498831, + 900345, + 899753, + 901289, + 1515807, + 884296, + 898009, + 900457, + 1499951, + 903032, + 898297, + 898729, + 1499567, + 899545, + 900152, + 900409, + 1499663, + 899833, + 899609, + 900216, + 1500111, + 900473, + 900713, + 899977, + 1499102, + 899497, + 899449, + 913209, + 1593711, + 894169, + 899449, + 899801, + 1500335, + 899224, + 900793, + 899273, + 1499887, + 900073, + 901720, + 898233, + 1499903, + 899689, + 914537, + 894408, + 1494527, + 898921, + 899129, + 898873, + 1500478, + 899849, + 899097, + 900217, + 1500174, + 900025, + 899929, + 898937, + 1500831, + 900280, + 899609, + 899881, + 1500335, + 899385, + 899736, + 900169, + 1500063, + 900361, + 899881, + 902473, + 1507054, + 895177, + 896409, + 902985, + 1496078, + 899817, + 899833, + 899417, + 1500687, + 900008, + 898985, + 901193, + 1500047, + 899224, + 900281, + 899481, + 1501471, + 900169, + 898665, + 903768, + 1496303, + 899833, + 911609, + 889577, + 1502110, + 896681, + 899769, + 899337, + 1501022, + 899049, + 901225, + 898729, + 1500287, + 906584, + 1003098, + 1100315, + 1811154, + 980154, + 898392, + 899609, + 1513247, + 991642, + 896632, + 900457, + 1498223, + 899609, + 899881, + 899464, + 1501375, + 898601, + 900729, + 900089, + 1499502, + 899625, + 899737, + 902713, + 1497487, + 900120, + 903865, + 895689, + 1502175, + 899113, + 910792, + 991066, + 1501103, + 896361, + 899928, + 899081, + 1501183, + 899257, + 901049, + 899432, + 1614016, + 1199212, + 986298, + 1118875, + 1797169, + 2209638, + 979050, + 898056, + 1498559, + 899401, + 898409, + 911225, + 1590399, + 899785, + 900249, + 900025, + 1498446, + 899097, + 899913, + 900537, + 1500335, + 898696, + 903177, + 897337, + 1500271, + 899305, + 909929, + 993673, + 1497935, + 899641, + 899001, + 900216, + 1500335, + 900153, + 899065, + 900457, + 1499630, + 899481, + 900729, + 1021578, + 1906339, + 1294620, + 977434, + 1128043, + 1572879, + 911465, + 991226, + 896057, + 1500191, + 898728, + 900041, + 899705, + 1502703, + 898297, + 899608, + 900025, + 1499519, + 899849, + 899960, + 899945, + 1501359, + 902345, + 896441, + 901960, + 1499695, + 1027178, + 1194268, + 977050, + 1499694, + 900089, + 900089, + 1223020, + 1800929, + 1097371, + 978986, + 899369, + 1500494, + 798648, + 900425, + 900537, + 1499071, + 902536, + 900713, + 900489, + 1500095, + 895912, + 900057, + 899049, + 1500799, + 899209, + 900840, + 899929, + 1499439, + 900057, + 899577, + 900536, + 1503919, + 895737, + 899945, + 902313, + 1510878, + 988810, + 899225, + 899049, + 1504350, + 895305, + 905209, + 894809, + 1624160, + 1296236, + 1302365, + 1198220, + 1798962, + 1297724, + 1299917, + 1200412, + 1697840, + 1300461, + 1193628, + 1002298, + 1593039, + 897033, + 897305, + 909113, + 1596016, + 893256, + 899929, + 901225, + 1499935, + 898536, + 899753, + 900761, + 1499295, + 901945, + 898904, + 901881, + 1497583, + 900393, + 901913, + 899128, + 1715441, + 988458, + 903033, + 1114427, + 1793233, + 1097611, + 1105563, + 980297, + 1500399, + 898601, + 901321, + 1015674, + 1800513, + 1298957, + 1099419, + 985226, + 1498814, + 899289, + 900217, + 900953, + 1618112, + 1192123, + 1304429, + 1101035, + 1583439, + 899065, + 900569, + 900409, + 1501134, + 900985, + 897817, + 1018586, + 1798754, + 1299740, + 1200140, + 1299933, + 1800642, + 981577, + 1219500, + 1298317, + 1800066, + 1299516, + 1301117, + 1297597, + 1907107, + 975609, + 899337, + 1217228, + 1814498, + 1289516, + 1296093, + 1198444, + 1901026, + 1201340, + 1206540, + 1291132, + 1795730, + 1204172, + 1296749, + 1302076, + 1797714, + 1304797, + 980969, + 898233, + 1617152, + 1197308, + 1194139, + 1204428, + 1800162, + 1484606, + 1213676, + 1104875, + 1806674, + 1517295, + 1474430, + 1199676, + 1700753, + 1191419, + 1203724, + 1408782, + 1902707, + 1481758, + 1209676, + 1689232, + 2006948, + 1303245, + 1683968, + 1215388, + 1694529, + 1304941, + 1263740, + 1564448, + 1879698, + 1296477, + 1195531, + 983274, + 1718433, + 1299021, + 982857, + 899401, + 1499375, + 899528, + 900377, + 900329, + 1612544, + 1294957, + 992441, + 899641, + 1500975, + 898233, + 900264, + 900553, + 1608736, + 1198748, + 1309469, + 1397405, + 1690081, + 1199196, + 1418494, + 1719552, + 2078085, + 1198460, + 1506862, + 1391774, + 1797234, + 1299116, + 1195404, + 1197228, + 2111124, + 1500991, + 1493471, + 984857, + 1500175, + 1033034, + 1477007, + 1510991, + 1995011, + 1203468, + 979369, + 900905, + 1498527, + 1179740, + 1144347, + 1518671, + 2066532, + 1571199, + 1228028, + 1201340, + 1793394, + 1202700, + 1203227, + 1101339, + 1801778, + 1197548, + 1103514, + 984282, + 1499343, + 900809, + 898792, + 900105, + 1502175, + 1011658, + 1299516, + 1200892, + 1799650, + 1303085, + 1194395, + 1197836, + 1705761, + 1097435, + 1196123, + 1307085, + 2198774, + 5296084, + 5110434, + 5293940, + 5791752, + 4900720, + 4997825, + 4877264, + 5627447, + 5001249, + 5103202, + 5111250, + 5381429, + 4994769, + 4893040, + 4866016, + 5569622, + 4982305, + 4911712, + 5191939, + 5716984, + 4936144, + 5142627, + 5316180, + 5667927, + 5217236, + 5816409, + 5393140, + 5781561, + 4993265, + 5119778, + 5297652, + 5401365, + 1182876, + 1207051, + 1191164, + 1906899, + 1302093, + 1198139, + 1495183, + 1982371, + 1321117, + 1411726, + 1490191, + 1908194, + 1505215, + 1486575, + 1404590, + 1788369, + 1411358, + 1452414, + 1554143, + 2088885, + 1200460, + 1511502, + 1069867, + 1702481, + 1215212, + 1199771, + 1303869, + 1802674, + 1186843, + 1200140, + 1304765, + 1796130, + 1493646, + 1399806, + 1199868, + 1904082, + 1186812, + 1100779, + 1199996, + 1601215, + 997514, + 1200764, + 1199435, + 1892787, + 1599088, + 1358269, + 1727697, + 2054020, + 1298077, + 1386285, + 1303085, + 2018228, + 1276284, + 1296781, + 1199036, + 1589423, + 1211532, + 1198908, + 1200124, + 1800673, + 1298013, + 1099515, + 1199132, + 2127525, + 1370557, + 1307277, + 1200092, + 1798657, + 1199804, + 1198028, + 1592911, + 2022340, + 1579776, + 1752385, + 1360925, + 1893043, + 1404045, + 1404414, + 1506751, + 1781969, + 1415998, + 1485935, + 1197868, + 1902034, + 1401646, + 1596208, + 986425, + 1499471, + 1607920, + 1300861, + 1721120, + 1997684, + 1287837, + 1299580, + 983946, + 1501103, + 898760, + 1019690, + 1302893, + 2091797, + 1199083, + 1203308, + 1501535, + 1793874, + 1420653, + 1480783, + 1401022, + 2095780, + 1480431, + 1413534, + 1092730, + 1733985, + 1080939, + 1485695, + 1607039, + 2200054, + 1400270, + 1193851, + 1202092, + 2403272, + 1505950, + 1297021, + 1201772, + 2091956, + 1631056, + 1364910, + 1115691, + 1900738, + 1292397, + 1202540, + 1507791, + 2103796, + 1290477, + 981769, + 1124843, + 2198694, + 1600704, + 1299164, + 1474479, + 1901362, + 1099435, + 1295869, + 1886370, + 1923731, + 1521391, + 1387438, + 1198732, + 1585599, + 899465, + 1026442, + 1404094, + 1981667, + 1301037, + 1501007, + 1328429, + 1557471, + 1098075, + 1212667, + 1751138, + 2146245, + 1410061, + 1607408, + 1188716, + 1584687, + 1010890, + 1204604, + 1201068, + 1901075, + 1501134, + 1816402, + 1062714, + 1499503, + 998570, + 1350525, + 1633936, + 1908259, + 1803202, + 1404829, + 1098539, + 1800242, + 1349357, + 1244140, + 1406110, + 1993060, + 1206219, + 1200860, + 1293629, + 1796689, + 1408030, + 1099163, + 1200476, + 1879250, + 1743457, + 1596672, + 1197228, + 1705408, + 1404030, + 1489423, + 1586015, + 2125301, + 1189612, + 1201084, + 1502126, + 1903459, + 1506223, + 1694016, + 1777634, + 1892866, + 1597008, + 1790465, + 2015508, + 1893427, + 1422654, + 1197835, + 1491855, + 2646442, + 1567407, + 1079339, + 1190620, + 1934515, + 1292252, + 1511359, + 1489839, + 2284214, + 1212972, + 982954, + 1013545, + 1901475, + 1299661, + 1303021, + 1490894, + 1912355, + 977882, + 1021626, + 1189851, + 2115301, + 1582847, + 1408254, + 1442782, + 1638016, + 1313181, + 1194460, + 1200780, + 1896642, + 1304093, + 1108795, + 980698, + 1500366, + 898585, + 1027258, + 1297165, + 1801874, + 1186187, + 1203628, + 1306669, + 1701024, + 1182860, + 1107195, + 1201452, + 1792705, + 1306365, + 1199340, + 1203420, + 1800737, + 1300957, + 981034, + 898025, + 1716928, + 1299245, + 1111883, + 974922, + 1497294, + 898873, + 900025, + 899385, + 1501278, + 899209, + 900921, + 899577, + 1499439, + 900024, + 900057, + 899801, + 1500735, + 899545, + 900328, + 899017, + 1500655, + 899961, + 899896, + 902633, + 1496543, + 900345, + 899881, + 900696, + 1501679, + 897417, + 1024954, + 1094075, + 1700896, + 1199708, + 1198972, + 1203100, + 1895410, + 1197116, + 1206764, + 979497, + 1499839, + 900105, + 898905, + 900361, + 1499486, + 903049, + 896425, + 903433, + 1497262, + 899225, + 899977, + 900473, + 1500399, + 899176, + 899417, + 901321, + 1500079, + 899513, + 899224, + 899769, + 1640096, + 961226, + 899289, + 900488, + 1499455, + 900489, + 1548815, + 1459614, + 1805762, + 1590512, + 1514894, + 1482895, + 2316007, + 1393325, + 1189756, + 1201820, + 1903522, + 1406206, + 1581312, + 1418174, + 2005411, + 1483583, + 1376413, + 1135387, + 1682769, + 902201, + 1017834, + 1311165, + 1999811, + 1068955, + 900184, + 898617, + 1500319, + 900425, + 898793, + 1128475, + 1885490, + 1307949, + 1299133, + 1308796, + 1776370, + 1217644, + 977385, + 1216348, + 1795778, + 1197916, + 1204203, + 1196204, + 1803634, + 1295036, + 1105595, + 983834, + 1827458, + 1179483, + 1201228, + 990106, + 1708577, + 1199627, + 1208300, + 1189100, + 1701264, + 1197372, + 1200300, + 1198604, + 1807441, + 1197324, + 1303005, + 1103051, + 1791313, + 1500255, + 1203052, + 1279324, + 2111189, + 1299389, + 1397821, + 1197116, + 2001556, + 1001562, + 900200, + 899801, + 1500975, + 997466, + 1198283, + 1198924, + 1797618, + 1400605, + 1221260, + 1202028, + 1893187, + 989081, + 900105, + 899545, + 1499279, + 900265, + 1001561, + 897353, + 1714577, + 1200140, + 1196283, + 1299869, + 1705089, + 1410862, + 1192843, + 1587440, + 2117317, + 1293180, + 1198076, + 1103339, + 1580559, + 899385, + 900425, + 898921, + 1799969, + 1324781, + 1293789, + 1384157, + 2123557, + 1390190, + 1294893, + 988441, + 1499967, + 1013050, + 1196124, + 1521455, + 1992515, + 1290285, + 1308221, + 1594223, + 2190646, + 1412413, + 1502991, + 1189868, + 1902066, + 1294685, + 1604736, + 1397438, + 2098836, + 1497247, + 1198619, + 1199228, + 1908051, + 1697345, + 1191035, + 1100331, + 1799762, + 1199515, + 1199900, + 1489535, + 1810113, + 1199404, + 1097067, + 1201420, + 1712272, + 1189724, + 1197420, + 1229484, + 1770737, + 1200684, + 1204988, + 1300317, + 1798849, + 1295389, + 1100203, + 1199499, + 2134549, + 1475903, + 1300684, + 1307341, + 1677153, + 1495454, + 1723457, + 1699681, + 1699985, + 1353709, + 1533823, + 1209948, + 1805473, + 1491951, + 1196236, + 1192715, + 1819362, + 1377390, + 997401, + 898793, + 1610576, + 1776353, + 1334622, + 1192475, + 1902403, + 1407982, + 1090906, + 1303277, + 2002308, + 1763313, + 1232460, + 1306653, + 2296534, + 1393726, + 1489551, + 1518222, + 2097125, + 1383646, + 1111658, + 1513695, + 2085973, + 1389613, + 1209196, + 1097643, + 1802050, + 1099754, + 1206188, + 1289581, + 1800977, + 1385806, + 1309469, + 991402, + 1500126, + 1013002, + 1303997, + 1393022, + 2042356, + 1573055, + 1288477, + 1594319, + 2101301, + 1405470, + 1501454, + 1617904, + 2077956, + 1095979, + 1201356, + 1464446, + 2250998, + 1488735, + 1202092, + 1687952, + 2493753, + 1569503, + 1161467, + 1392366, + 2085780, + 1197852, + 1301469, + 1325005, + 2184773, + 1394782, + 984522, + 1012186, + 2012195, + 1403822, + 1482879, + 1203243, + 1897347, + 1406606, + 979721, + 900537, + 1908451, + 1315965, + 1509934, + 1280205, + 1974771, + 1322445, + 1209500, + 1095787, + 1897170, + 1405245, + 1395774, + 1504831, + 1792113, + 1292749, + 1106091, + 1104171, + 1692400, + 1395070, + 1391517, + 1720225 + ], + "max_s": 0.005816409, + "p50_s": 0.00120014, + "p99_s": 0.005103202, + "pkg_above_idle_j_per_change": 0.002076211457839442, + "pkg_j_per_change": 0.0483865, + "rep": 0, + "s_per_change": 0.001333227548, + "wire_bytes_received_per_change": 0.0, + "wire_bytes_sent_per_change": 0.0 + }, + { + "arm": "direct_auth", + "changes": 2000, + "chunk_bytes_sent": 0, + "chunks_sent": 0, + "elapsed_s": 3.078394543, + "energy": { + "cpu_e_j": 2.122, + "cpu_p_j": 48.378, + "largest_gap_ms": 100.212, + "loadavg_end": [ + 3.89, + 4.26, + 4.26 + ], + "loadavg_start": [ + 3.96, + 4.28, + 4.27 + ], + "machine_busy_cpu_s": 8.020000000018626, + "nvme_temp_k": 315.0, + "pkg_edge_sd_j": 2.710011346461781, + "pkg_j": 102.178, + "pkg_mean_w": 33.19072497992081, + "refusal": null, + "rest_j": 51.678, + "samples": 32, + "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)", + "sys_total_mean_w": 38.3089375, + "valid": true, + "window_s": 3.07851064 + }, + "latencies_ns": [ + 1000522, + 1595136, + 999033, + 1000650, + 999274, + 1819426, + 1181035, + 999402, + 999978, + 1819410, + 1703728, + 1177388, + 998730, + 1600703, + 999290, + 1000794, + 1201164, + 1910386, + 1304109, + 1313437, + 1187548, + 1683824, + 997850, + 999850, + 999690, + 1600463, + 1111451, + 1301645, + 1398542, + 1802161, + 1197596, + 1398158, + 1313820, + 1804690, + 1072395, + 999402, + 998393, + 1602192, + 997962, + 1000698, + 998617, + 1600672, + 999434, + 1001306, + 998809, + 1599920, + 1130011, + 1390414, + 1299180, + 2000196, + 1200268, + 1080170, + 999450, + 1600976, + 1119339, + 1399230, + 1081274, + 1819346, + 1079899, + 999289, + 999626, + 1601856, + 1118363, + 1405293, + 1075403, + 1599616, + 999321, + 1000378, + 999258, + 1601520, + 1120155, + 1396925, + 1399118, + 1897603, + 1084666, + 999946, + 999850, + 1600272, + 1218651, + 1294109, + 1298093, + 1900659, + 1299164, + 1301693, + 1298269, + 1996947, + 1400190, + 1400270, + 1397549, + 1693361, + 998586, + 1206620, + 1607663, + 2094789, + 1502447, + 1501646, + 1395886, + 2000228, + 1304700, + 1710721, + 1490175, + 2087300, + 1510319, + 1691697, + 1408093, + 1685841, + 999466, + 1106458, + 1599728, + 2292599, + 1958099, + 1653216, + 1196588, + 1711616, + 1190876, + 1956483, + 1892739, + 1939811, + 1400157, + 1420270, + 1185132, + 2554601, + 1825746, + 1308957, + 1723105, + 1989427, + 1202108, + 1196236, + 1197579, + 1700993, + 1298189, + 1691920, + 1662753, + 2328662, + 1505343, + 1331389, + 1676177, + 2296518, + 1397886, + 1399901, + 1398990, + 1999732, + 1504799, + 1957427, + 1338925, + 2548185, + 1649504, + 1500543, + 1565967, + 1935859, + 1399678, + 1414045, + 1689329, + 1807106, + 1198011, + 1100123, + 1103739, + 1870866, + 1685185, + 1635376, + 1395917, + 2561658, + 1639008, + 1400285, + 1864771, + 2238550, + 1643456, + 1513518, + 1147564, + 2400791, + 1948499, + 1641120, + 1399550, + 2562505, + 1239820, + 1658161, + 1640144, + 2566713, + 1893554, + 1645472, + 1308173, + 2494617, + 1610704, + 1390957, + 1944931, + 2505145, + 1147883, + 1951027, + 1239676, + 2214886, + 1941731, + 1557279, + 1194252, + 1701441, + 1452446, + 1334365, + 1703552, + 1808434, + 1099467, + 1098443, + 1191915, + 1811442, + 1096107, + 1102587, + 1192043, + 2245670, + 1251053, + 1213388, + 1094602, + 1700529, + 1100283, + 1103242, + 1291949, + 2317671, + 1682960, + 1204284, + 1099115, + 1700225, + 1207387, + 1282877, + 1961155, + 1839394, + 1210284, + 1097691, + 1099402, + 1702897, + 1542239, + 1833490, + 1678993, + 2079764, + 1913283, + 1900338, + 1648321, + 1804241, + 1097179, + 1100411, + 1098427, + 1700352, + 1222604, + 1179100, + 1646320, + 2239974, + 1399485, + 1962692, + 1643216, + 2544905, + 1911138, + 1555760, + 1194395, + 1945539, + 1267629, + 1282924, + 1608544, + 2147269, + 1552847, + 1948852, + 1145435, + 1702496, + 1096827, + 1559375, + 1631808, + 2162358, + 1336733, + 1211724, + 1097850, + 1699505, + 1099659, + 1100986, + 1204620, + 1994532, + 1395821, + 1396814, + 1399198, + 2002227, + 1452479, + 1268252, + 1188556, + 1797969, + 1097163, + 1099851, + 1100123, + 1701120, + 1098971, + 1098619, + 1099867, + 1701968, + 1099739, + 1099147, + 1099531, + 1701696, + 1099275, + 1098827, + 1099771, + 1701056, + 1113611, + 1191004, + 1197276, + 1700240, + 1097867, + 1100667, + 1099450, + 1706385, + 1195164, + 1098843, + 1203851, + 1992276, + 1391054, + 1401293, + 1400894, + 2001220, + 1396477, + 1212412, + 1098715, + 1698769, + 1100810, + 1196092, + 1394990, + 2007219, + 1201484, + 1099979, + 1098331, + 1702000, + 1294141, + 1403822, + 1448862, + 1756385, + 1097067, + 1098811, + 1100315, + 1719184, + 1183084, + 1097323, + 1099834, + 1701553, + 1098171, + 1100155, + 1101578, + 1698385, + 1099563, + 1099707, + 1109850, + 1795058, + 1201388, + 1095147, + 1100154, + 1810162, + 1398142, + 1502431, + 1388557, + 2103445, + 1400669, + 1397086, + 1400670, + 1997475, + 1199756, + 1098043, + 1204188, + 1997075, + 1398366, + 1400206, + 1203963, + 1697233, + 1098683, + 1100971, + 1205611, + 1992116, + 1299293, + 1396733, + 1206844, + 1697089, + 1100219, + 1099802, + 1101707, + 1702865, + 1200076, + 1098330, + 1097499, + 1701249, + 1104218, + 1190844, + 1662512, + 2191158, + 1900642, + 1897747, + 1340445, + 2001636, + 1399086, + 1399181, + 1397934, + 2002516, + 1400237, + 1300413, + 1400110, + 2106244, + 1393518, + 1298637, + 1402077, + 2000244, + 1208396, + 1394685, + 1395502, + 2162917, + 1650416, + 1385886, + 1992307, + 1908803, + 1299885, + 1398318, + 1400013, + 2260358, + 1897427, + 1340909, + 1212076, + 2036708, + 1450094, + 1586720, + 1641024, + 1973619, + 1315613, + 1193804, + 1099770, + 1701249, + 1102875, + 1698208, + 1509583, + 1789266, + 1197851, + 1099643, + 1099755, + 1711313, + 1389821, + 1671841, + 1326157, + 2298694, + 1594288, + 1660112, + 1642720, + 2290807, + 1534287, + 1375837, + 1403006, + 1899314, + 1298669, + 1402174, + 1399534, + 1992323, + 1402014, + 1312477, + 1194507, + 1700881, + 1294301, + 1399053, + 1398254, + 1999812, + 1207291, + 1191740, + 1399102, + 2001923, + 1312621, + 1286573, + 1398253, + 2116357, + 1392958, + 1396878, + 1399341, + 1898803, + 1396381, + 1401902, + 1405406, + 1990211, + 1398798, + 1399518, + 1400558, + 1897634, + 1402574, + 1209948, + 1288860, + 2261318, + 1897203, + 1641008, + 1211148, + 2273606, + 1875235, + 1498558, + 1801138, + 2498584, + 1242380, + 1300573, + 1412446, + 1996548, + 1399053, + 1401758, + 1394574, + 2301510, + 1955475, + 1147916, + 1099498, + 1798562, + 1100603, + 1111243, + 1191115, + 1800242, + 1098091, + 1098106, + 1099771, + 1807938, + 1396366, + 1399133, + 1403790, + 1999187, + 1297709, + 1399150, + 1400302, + 2102708, + 1290189, + 1398078, + 1395613, + 2004228, + 1297965, + 1403629, + 1395406, + 1899410, + 1403550, + 1311117, + 1194796, + 1795489, + 1394446, + 1398718, + 1209820, + 1698656, + 1100315, + 1098971, + 1099066, + 1702257, + 1298477, + 1652800, + 1849426, + 1992724, + 1399085, + 1399678, + 1662448, + 2100133, + 1232812, + 1666032, + 1912883, + 2505401, + 1977027, + 1154315, + 1186716, + 2558777, + 2052852, + 1749361, + 1643392, + 2193670, + 1209451, + 1297421, + 1855954, + 1837106, + 1962307, + 1239853, + 1207803, + 1804818, + 1092491, + 1105051, + 1455502, + 2482360, + 1348349, + 1322365, + 1187756, + 1699121, + 1099226, + 1101067, + 1100123, + 2156037, + 1344877, + 1701041, + 1947731, + 2103221, + 1599119, + 1897299, + 1486078, + 2541273, + 1412830, + 1315661, + 1644880, + 1844434, + 1398398, + 1663856, + 1548607, + 1889795, + 1304748, + 1398286, + 1307453, + 1992243, + 1314685, + 1385118, + 1306765, + 1794817, + 1099707, + 1098667, + 1098891, + 1701920, + 1202908, + 1397262, + 1400605, + 1999044, + 1301773, + 1396989, + 1400286, + 2005620, + 1385485, + 1404094, + 1399374, + 1994979, + 1400862, + 1408030, + 1390109, + 1997876, + 1407742, + 1310044, + 1193948, + 1698705, + 1274428, + 1315197, + 1399710, + 2002803, + 1412702, + 1388814, + 1397422, + 2244758, + 1366013, + 1687488, + 1653457, + 2507976, + 1340557, + 1400030, + 1373629, + 2247734, + 1639377, + 1897906, + 1650336, + 2151333, + 1238108, + 1618912, + 1594704, + 1987955, + 1700305, + 1660048, + 1147355, + 2289671, + 1403278, + 1396829, + 1404062, + 2005700, + 1485182, + 1301757, + 1400158, + 2000707, + 1398238, + 1302957, + 1398045, + 2002356, + 1209740, + 1389949, + 1405646, + 1994756, + 1396541, + 1399022, + 1213116, + 1891170, + 1395982, + 1399870, + 1397678, + 2002627, + 1399998, + 1299244, + 1401870, + 1900451, + 1398014, + 1211579, + 1098475, + 1702849, + 1398302, + 1304908, + 1194348, + 1701137, + 1103098, + 1098331, + 1097691, + 2157541, + 1346093, + 1687009, + 1401373, + 2263415, + 1912418, + 2626154, + 1960595, + 2249670, + 1653040, + 1144123, + 1190363, + 2007620, + 1405710, + 1402605, + 1427886, + 1971508, + 1282028, + 1727217, + 1537999, + 2492969, + 1341293, + 1663088, + 1898947, + 1842546, + 1203900, + 1099146, + 1194700, + 2006404, + 1939667, + 1352893, + 1401598, + 1806161, + 1651744, + 1337421, + 1648785, + 2266774, + 1384669, + 1401726, + 1312989, + 1987235, + 1701329, + 1709521, + 1547359, + 2503240, + 1334829, + 1300301, + 1210156, + 2052756, + 1338957, + 1613600, + 1284429, + 2003123, + 1207676, + 1453726, + 1337117, + 1996772, + 1210332, + 1099803, + 1099626, + 1700161, + 1592592, + 1299404, + 1501695, + 2547465, + 1347501, + 1316125, + 1283133, + 2311814, + 1305901, + 1192972, + 1098570, + 1701425, + 1100667, + 1098459, + 1099882, + 1792706, + 1546687, + 1864098, + 1683969, + 2250230, + 1569327, + 1286845, + 1666528, + 2092309, + 1237500, + 1648064, + 1161739, + 2207718, + 1645504, + 1146715, + 1098459, + 1700321, + 1100682, + 1098027, + 1413150, + 2009044, + 1928034, + 1641489, + 1406973, + 1896435, + 1401774, + 1309052, + 1285629, + 2296326, + 1993156, + 1804610, + 1301884, + 2259303, + 1643024, + 1692352, + 1966035, + 1840354, + 1400958, + 1298829, + 1400014, + 2247494, + 2005683, + 1350285, + 1394670, + 2303975, + 1562735, + 1608080, + 1743185, + 2285670, + 1661472, + 1911667, + 1321933, + 1906131, + 1758209, + 1899042, + 1901843, + 2337079, + 1416302, + 1951347, + 1648864, + 2246118, + 1732929, + 1704001, + 1663312, + 2200069, + 1642241, + 1805601, + 1638064, + 1952371, + 1955348, + 1642560, + 1411053, + 2299447, + 1687296, + 1663441, + 1747713, + 1889122, + 1664177, + 1642752, + 1592095, + 2216774, + 1955891, + 1138443, + 1191660, + 1997300, + 1647920, + 1600015, + 1459759, + 1991363, + 1960627, + 1241932, + 1397054, + 2404088, + 1958835, + 1237228, + 1813794, + 2289894, + 1399358, + 1950947, + 1348237, + 2015172, + 1942259, + 1341245, + 1616928, + 2098260, + 1383038, + 1703985, + 1847570, + 1948851, + 1615200, + 1944963, + 1649872, + 2553609, + 1637904, + 1657968, + 1150411, + 1700513, + 1097851, + 1099578, + 1101899, + 1792930, + 1397870, + 1710976, + 1948243, + 1836722, + 1963683, + 1512367, + 1636768, + 2295831, + 1694112, + 1663617, + 1236012, + 2561817, + 1637760, + 1700929, + 1957987, + 2201157, + 1555615, + 1386254, + 1685489, + 2574905, + 1808257, + 1329517, + 1399454, + 1811138, + 1096923, + 1099002, + 1455887, + 2242102, + 1392733, + 1404606, + 1763185, + 1834210, + 1399374, + 1397438, + 1447630, + 2056212, + 1557647, + 1638848, + 1315389, + 2445256, + 1640432, + 1673472, + 1622096, + 2009012, + 1401982, + 1397837, + 1398094, + 2002420, + 1397437, + 1398494, + 1400734, + 2001443, + 1395454, + 1301901, + 1399325, + 2014948, + 1385470, + 1401038, + 1398477, + 1810466, + 1203964, + 1196187, + 1097611, + 1698945, + 1099403, + 1103930, + 1097963, + 1698945, + 1100058, + 1098715, + 1100811, + 1799970, + 1407949, + 1391102, + 1397438, + 1997075, + 1296621, + 1400126, + 1399565, + 2000548, + 1315165, + 1192620, + 1099130, + 1792210, + 1210844, + 1393837, + 1294589, + 2000548, + 1315436, + 1284509, + 1401102, + 2101732, + 1397342, + 1209580, + 1098715, + 1700192, + 1101323, + 1102619, + 1099355, + 1698096, + 1202668, + 1946691, + 1643024, + 2254342, + 1649648, + 1390094, + 1401438, + 1900610, + 1400894, + 1575247, + 1837778, + 2092341, + 1653200, + 1900035, + 1234620, + 2165413, + 1899795, + 1333437, + 1671648, + 2070116, + 1174332, + 1191547, + 1398974, + 2205526, + 1654592, + 1475054, + 1744417, + 1922163, + 1299533, + 1207292, + 1313533, + 2007539, + 1183708, + 1287948, + 1310173, + 2551113, + 1635344, + 1207980, + 1200428, + 1698848, + 1100491, + 1204300, + 1286572, + 1999204, + 1210236, + 1288268, + 1400270, + 2009828, + 1394525, + 1207404, + 1098907, + 1701361, + 1305516, + 1388862, + 1395278, + 2001923, + 1398686, + 1405182, + 1391965, + 1897875, + 1406510, + 1396733, + 1217244, + 1891683, + 1389357, + 1402382, + 1400350, + 1911538, + 1388910, + 1396462, + 1405485, + 1995572, + 1399998, + 1208572, + 1100666, + 1798722, + 1659072, + 1638816, + 1609088, + 2144917, + 1344557, + 1956131, + 1149275, + 2052037, + 1813185, + 1489087, + 1337741, + 2330775, + 1603055, + 1174188, + 1099291, + 1699744, + 1096731, + 1099851, + 1101451, + 1703760, + 1095483, + 1099659, + 1099050, + 1701697, + 1611152, + 1419630, + 1471246, + 1998196, + 1394365, + 1330557, + 1286877, + 1889618, + 1389518, + 1398478, + 1399405, + 1915523, + 1194572, + 1098763, + 1099018, + 2146053, + 1642032, + 1399038, + 1402734, + 2001619, + 1408878, + 1394494, + 1408238, + 1994243, + 1308669, + 1282588, + 1400190, + 2001332, + 1398317, + 1407422, + 1404030, + 1901315, + 1396845, + 1397230, + 1403326, + 1991779, + 1323869, + 1197036, + 1191275, + 1708961, + 1188684, + 1098507, + 1100138, + 1704097, + 1102283, + 1389229, + 1325005, + 2059061, + 1326812, + 1393694, + 1398750, + 1900610, + 1398462, + 1397758, + 1401373, + 2002708, + 1399854, + 1297276, + 1396222, + 2000404, + 1403085, + 1401758, + 1408638, + 1992003, + 1306349, + 1193692, + 1098347, + 1700720, + 1098843, + 1099547, + 1100122, + 1699265, + 1199052, + 1587231, + 3511363, + 1405182, + 1398669, + 1401806, + 1999347, + 1401102, + 1312285, + 1389294, + 1901954, + 1388942, + 1397310, + 1400765, + 1900019, + 1403325, + 1398462, + 1397710, + 1901154, + 1396878, + 1301181, + 1400542, + 1999955, + 1400446, + 1403374, + 1309884, + 1886659, + 1398205, + 1398942, + 1399102, + 2001796, + 1400365, + 1398654, + 1398654, + 1898690, + 1397806, + 1318813, + 1283596, + 2000740, + 1401870, + 1400189, + 1397278, + 1899283, + 1400685, + 1400622, + 1398830, + 2003459, + 1402222, + 1399166, + 1311964, + 1993940, + 1199164, + 1304252, + 1688241, + 2298838, + 1398622, + 1314813, + 1550543, + 2483768, + 1447294, + 1699488, + 1666049, + 1746257, + 1099514, + 1100907, + 1196284, + 1997331, + 1402462, + 1672273, + 1988771, + 2198101, + 1894979, + 1901075, + 1442942, + 2561145, + 1338269, + 1392510, + 1403069, + 1999428, + 1496542, + 1317869, + 1285629, + 2000244, + 1396909, + 1501055, + 1457742, + 2505017, + 1650384, + 2648794, + 1346365, + 1993107, + 1314237, + 1287149, + 1498526, + 2313895, + 1600080, + 1194028, + 1307964, + 2098421, + 1393165, + 1309741, + 1295245, + 1999091, + 1304653, + 1392606, + 1402814, + 1997171, + 1495055, + 1207308, + 1199275, + 1797922, + 1100395, + 1097210, + 1201836, + 1800274, + 1097163, + 1101130, + 1200572, + 1991428, + 1307948, + 1395246, + 1409598, + 2544681, + 1639712, + 1602015, + 1860131, + 1834178, + 1666384, + 1237644, + 1693168, + 2270183, + 1244828, + 1948003, + 1153211, + 2052836, + 1345261, + 1401373, + 1605360, + 1794177, + 1097403, + 1099435, + 1100267, + 1896530, + 1516047, + 1817698, + 1360749, + 2006836, + 1955875, + 1884482, + 1949796, + 2302438, + 1515839, + 1947459, + 1146731, + 2052532, + 1896995, + 1338189, + 1316637, + 2157397, + 1745361, + 1687776, + 1203900, + 1803874, + 1651216, + 1491839, + 1572431, + 1874514, + 1302957, + 1205196, + 1096299, + 1701696, + 1097771, + 1204716, + 1389885, + 2260007, + 1898274, + 1264957, + 1279148, + 2228774, + 1369837, + 1494303, + 1402126, + 1998451, + 1674161, + 1583535, + 1641136, + 2217190, + 1598127, + 1284525, + 1403022, + 2002611, + 1203948, + 1706657, + 1801889, + 2084629, + 1662608, + 1893491, + 1640928, + 2361703, + 1686688, + 1349485, + 1400478, + 2000260, + 1670336, + 1141403, + 1192684, + 2248262, + 1861106, + 1305261, + 1281020, + 2303847, + 1559535, + 1337917, + 1658144, + 2240310, + 1556112, + 1645792, + 1208268, + 1889778, + 1313837, + 1194156, + 1099594, + 1699713, + 1098683, + 1100634, + 1258557, + 1938499, + 1297389, + 1397309, + 1298797, + 2307094, + 1396142, + 1398734, + 1314557, + 1900130, + 1195308, + 1097227, + 1100906, + 1700321, + 1107659, + 1395598, + 1655424, + 2233078, + 1400829, + 1399742, + 1401470, + 2243638, + 1900050, + 1896419, + 1165483, + 1948515, + 1340253, + 1402638, + 1401918, + 1998611, + 1399726, + 1561087, + 1662801, + 1783089, + 1098523, + 1099003, + 1105658, + 1794162, + 1707297, + 1193883, + 1593888, + 1994819, + 1399998, + 1399934, + 1494862, + 2012228, + 1295709, + 1408270, + 1949075, + 2488664, + 1910435, + 1652320, + 1304573, + 2503976, + 1381246, + 1614768, + 1600159, + 1896387, + 1553839, + 1496367, + 1650992, + 2249766, + 1648848, + 1306269, + 1291564, + 1991044, + 1296924, + 1315981, + 1884739, + 2459544, + 1843842, + 1714657, + 1598575, + 2131269, + 1613760, + 1237180, + 1551279, + 1760465, + 1097291, + 1099307, + 1100459, + 1895298, + 1659680, + 1638368, + 1619296, + 2181302, + 1206908, + 1954915, + 1145019, + 1798017, + 1099419, + 1408622, + 1949731, + 2151413, + 1286845, + 1630064, + 1627072, + 2500552, + 1700225, + 1147339, + 1451870, + 1938195, + 1399150, + 1398013, + 1401262, + 2302935, + 1400893, + 1206972, + 1455726, + 2235366, + 1398750, + 1699729, + 1400109, + 2246582, + 1163836, + 1098650, + 1098891, + 1699841, + 1197643, + 1398622, + 1643536, + 2167286, + 1192571, + 1099851, + 1100315, + 2059460, + 1142715, + 1098955, + 1102411, + 1700656, + 1307053, + 1386398, + 1403053, + 1903875, + 1397886, + 1401197, + 1399310, + 1799282, + 1098954, + 1098043, + 1100203, + 1702225, + 1405405, + 1396750, + 1399294, + 2000451, + 1296877, + 1399246, + 1398557, + 1999668, + 1399534, + 1400941, + 1402414, + 1991363, + 1403774, + 1397454, + 1395981, + 2007140, + 1395070, + 1394189, + 1405134, + 1902307, + 1205756, + 1451230, + 1595759, + 2241158, + 1801298, + 1400222, + 1208667, + 1997588, + 1637856, + 1774737, + 1936659, + 2190070, + 1367197, + 1382142, + 1404701, + 2567882, + 1329149, + 1813921, + 1947971, + 1837826, + 1963940, + 1634032, + 1400973, + 2268198, + 1895635, + 1648032, + 1291245, + 2297718, + 1491967, + 1976851, + 1636576, + 2261926, + 1632160, + 1317613, + 1530063, + 2513737, + 1637504, + 1399773, + 1967700, + 2097924, + 1896051, + 1639520, + 1314637, + 2528024, + 1653649, + 1414925, + 1547488, + 2240278, + 1658256, + 1639296, + 1403677, + 2000020, + 1400366, + 1301005, + 1648192, + 2508824, + 1341133, + 1646560, + 1652353, + 2316598, + 1190700, + 1191212, + 1399117, + 2261398, + 1642544, + 1397982, + 1401902, + 1897442, + 1396910, + 1867682, + 1632864, + 2266150, + 1896499, + 1555071, + 1195324, + 2154885, + 1734721, + 1656384, + 1649488, + 2216374, + 1532895, + 1656208, + 1947475, + 2236998, + 1410190, + 1401438, + 1639840, + 1759537, + 1188092, + 1400477, + 1771042, + 2061316, + 1178427, + 1099467, + 1098987, + 1707473, + 1093498, + 1299533, + 1403550, + 1897794, + 1397438, + 1815906, + 1592063, + 1986516, + 1661296, + 1335213, + 1557439, + 2501049, + 1899650, + 1650512, + 1809762, + 2239878, + 1646688, + 1857330, + 1637184, + 2560377, + 1899587, + 1886242, + 1814994, + 2237398, + 1557535, + 1598704, + 1341549, + 2003124, + 1313868, + 1283581, + 1404766, + 2294358, + 1825698, + 1381405, + 1395566, + 2271462, + 1737153, + 1400526, + 1294813, + 2305974, + 1386526, + 1963619, + 1459870, + 2238486, + 1811842, + 1429982, + 1655936, + 2255878, + 1689313, + 1761985, + 1549183, + 1796834, + 1189979, + 1396318, + 1398542, + 2248646, + 1769313, + 1601839, + 1191804, + 1699249, + 1105275, + 1289708, + 1643488, + 2275286, + 1687969, + 1306269, + 1299980, + 1911939, + 1636304, + 1897555, + 1637280, + 2260294, + 1911363, + 1433710, + 1953043, + 2242310, + 1705488, + 1201612, + 1451838, + 1937827, + 1957811, + 1152812, + 1098826, + 1706337, + 1551087, + 1548783, + 1383246, + 2000404, + 1402301, + 1399870, + 1396654, + 2003299, + 1315469, + 1391438, + 1402877, + 1997204, + 1408446, + 1398589, + 1397566, + 1999939, + 1309757, + 1189100, + 1097595, + 1708304, + 1391678, + 1403150, + 1399229, + 2100613, + 1397806, + 1402493, + 1395374, + 2002500, + 1397677, + 1297677, + 1398926, + 2010723, + 1385742, + 1398397, + 1402158, + 1898051, + 1404445, + 1399550, + 1350941, + 1970388, + 1184795, + 1196876, + 1099771, + 1699232, + 1108651, + 1197276, + 1197692, + 1696944, + 1098779, + 1099915, + 1101690, + 1701217, + 1103019, + 1195548, + 1211115, + 1795890, + 1196940, + 1197227, + 1201452, + 1801090, + 1196651, + 1098907, + 1099003, + 1702609, + 1197611, + 1300957, + 1395006, + 1998883, + 1402382, + 1308141, + 1194827, + 1801490, + 1317629, + 1190716, + 2092612, + 1800914, + 1198459, + 1304189, + 1204556, + 1896834, + 1193644, + 1197564, + 1098171, + 1701008, + 1199420, + 1099963, + 1099146, + 1812434, + 1490559, + 1397117, + 1397902, + 2000852, + 1400189, + 1499119, + 1395582, + 2013299, + 1194172, + 1299581, + 1404029, + 2005236, + 1191884, + 1198923, + 1200364, + 1708305, + 1194060, + 1097514, + 1098827, + 1699729, + 1098458, + 1098923, + 1201628, + 1702113, + 1107818, + 1294685, + 1393902, + 2003315, + 1301293, + 1398606, + 1305180, + 1895747, + 1394206, + 1295436, + 1401054, + 2000628, + 1206747, + 1097771, + 1099435, + 1700384, + 1100619, + 1199900, + 1406494, + 1991683, + 1394382, + 1297852, + 1399454, + 1810994, + 1098539, + 1099322, + 1098763, + 1710113, + 1205180, + 1189691, + 1198508, + 1706609, + 1191867, + 1200700, + 1202604, + 1798177, + 1102123, + 1097611, + 1098715, + 1911234, + 1390766, + 1301581, + 1299580, + 1796738, + 1097723, + 1099514, + 1199100, + 2006804, + 1194939, + 1395406, + 1393518, + 2007907, + 1393774, + 1399118, + 1399373, + 2000164, + 1298925, + 1406237, + 1329437, + 1918339, + 1259069, + 1197275, + 1099883, + 1701185, + 1203163, + 1197836, + 1101467, + 1697280, + 1100203, + 1098699, + 1210892, + 1992531, + 1371886, + 1423470, + 1400461, + 1816930, + 1198972, + 1190236, + 1195291, + 1800050, + 1098491, + 1100362, + 1098683, + 1699857, + 1099386, + 1099243, + 1100011, + 1701201, + 1105306, + 1196044, + 1098251, + 1699264, + 1204396, + 1106011, + 1193580, + 1806177, + 1199756, + 1197340, + 1201275, + 1793650, + 1198412, + 1205739, + 1195980, + 1698033, + 1108043, + 1200587, + 1202636, + 1798530, + 1192491, + 1096875, + 1207484, + 1799410, + 1195115, + 1198972, + 1098971, + 1801089, + 1206204, + 1292589, + 1399613, + 2000692, + 1200716, + 1297100, + 1311549, + 1898611, + 1197004, + 1200651, + 1196396, + 1797538, + 1098266, + 1099931, + 1109259, + 1794610, + 1197579, + 1108747, + 1193276, + 1891394, + 1213516, + 1195612, + 1197771, + 2006436, + 1393022, + 1399245, + 1399406, + 2005204, + 1393085, + 1203452, + 1395118, + 2005043, + 1401454, + 1389166, + 1298956, + 2004260, + 1308445, + 1393661, + 1395150, + 2005940, + 1305964, + 1284589, + 1322477, + 1796993, + 1191052, + 1197916, + 1104747 + ], + "max_s": 0.003511363, + "p50_s": 0.001401774, + "p99_s": 0.002528024, + "pkg_above_idle_j_per_change": -0.002375556181522306, + "pkg_j_per_change": 0.051088999999999996, + "rep": 1, + "s_per_change": 0.0015391972715, + "wire_bytes_received_per_change": 0.0, + "wire_bytes_sent_per_change": 0.0 + }, + { + "arm": "direct", + "changes": 2000, + "chunk_bytes_sent": 0, + "chunks_sent": 0, + "elapsed_s": 2.690672819, + "energy": { + "cpu_e_j": 1.466, + "cpu_p_j": 43.843, + "largest_gap_ms": 100.2, + "loadavg_end": [ + 3.82, + 4.24, + 4.25 + ], + "loadavg_start": [ + 3.89, + 4.26, + 4.26 + ], + "machine_busy_cpu_s": 6.659999999916181, + "nvme_temp_k": 315.0, + "pkg_edge_sd_j": 2.746393306347299, + "pkg_j": 90.511, + "pkg_mean_w": 33.63631116773043, + "refusal": null, + "rest_j": 45.20199999999999, + "samples": 28, + "sensor": "aien_spbm hwmon, SoC package only (GB10 SPBM firmware counters: energy 1 mJ step, update about 0.1 s, sampled at 10 Hz; no published accuracy; not compared with an external meter)", + "sys_total_mean_w": 38.96696428571428, + "valid": true, + "window_s": 2.690871765 + }, + "latencies_ns": [ + 963498, + 1815138, + 1190171, + 1197052, + 985386, + 1500254, + 899865, + 900425, + 902057, + 1497614, + 900505, + 899865, + 1040698, + 1674032, + 1302061, + 983626, + 898745, + 1500926, + 898585, + 900697, + 900137, + 1502238, + 898473, + 902137, + 896425, + 1620416, + 1094682, + 988474, + 897193, + 1500446, + 909689, + 991258, + 900601, + 1612384, + 984553, + 899833, + 899737, + 1500254, + 898537, + 900825, + 899161, + 1501487, + 899208, + 1225708, + 1090139, + 1584975, + 899321, + 899833, + 900729, + 1500911, + 897960, + 899945, + 900649, + 1501167, + 899336, + 904713, + 894425, + 1503023, + 896393, + 902296, + 898665, + 1501439, + 899049, + 1108794, + 1105979, + 1900531, + 1104235, + 980553, + 900329, + 1498159, + 898872, + 900489, + 899753, + 1501967, + 899385, + 898696, + 1011290, + 1593920, + 897177, + 897176, + 900633, + 1500591, + 1220044, + 1196075, + 1199244, + 1586048, + 896985, + 900504, + 899609, + 1501199, + 1020746, + 1297260, + 1310845, + 1795442, + 1099499, + 974265, + 899449, + 1500159, + 901368, + 901305, + 922953, + 1688417, + 986041, + 899545, + 899529, + 1500303, + 901496, + 1020922, + 1299053, + 1578736, + 1021257, + 1297805, + 1194012, + 1590096, + 895272, + 900217, + 900217, + 1620288, + 1320381, + 960233, + 1015578, + 1902035, + 1299884, + 1099915, + 1097259, + 1705072, + 978298, + 898985, + 899625, + 1503278, + 897449, + 900409, + 927609, + 1573455, + 898137, + 1019130, + 1297901, + 1682848, + 999962, + 902713, + 899177, + 1498670, + 900857, + 901097, + 1014346, + 1902994, + 1298717, + 1199980, + 1300381, + 1898834, + 1303821, + 1193932, + 983753, + 1514319, + 999386, + 994697, + 996858, + 1684529, + 1102506, + 1099563, + 1098555, + 1817842, + 1484094, + 1395390, + 1402846, + 2015251, + 1280765, + 1406958, + 1212940, + 1591343, + 900713, + 900233, + 897912, + 1500127, + 899001, + 903321, + 898649, + 1500366, + 898681, + 900217, + 900953, + 1501438, + 896569, + 902841, + 1018042, + 1802561, + 1190892, + 1096523, + 1299212, + 1801073, + 1309389, + 1190940, + 1093482, + 1801874, + 1301773, + 1184923, + 1395758, + 1897266, + 1406926, + 1388942, + 1395437, + 1726625, + 1094491, + 1108043, + 891257, + 1498990, + 899145, + 903145, + 1114187, + 1799537, + 1197500, + 1200860, + 993545, + 1493423, + 897545, + 899689, + 900568, + 1500527, + 898153, + 900505, + 900825, + 1499326, + 901305, + 899769, + 899033, + 1502110, + 899705, + 898857, + 899513, + 1619440, + 980489, + 899241, + 900441, + 1501262, + 899705, + 902073, + 909241, + 1610720, + 1089098, + 995674, + 998938, + 1604752, + 995337, + 1002890, + 889641, + 1500382, + 899433, + 900009, + 899225, + 1499822, + 899929, + 899673, + 900089, + 1500335, + 899816, + 900025, + 900073, + 1627776, + 1293469, + 1299036, + 1079899, + 1616224, + 1098714, + 1108251, + 1191916, + 1916115, + 1068026, + 898809, + 899529, + 1500814, + 899705, + 900361, + 902281, + 1497678, + 1012938, + 1104987, + 990330, + 1597807, + 998042, + 1001242, + 999402, + 1500542, + 999818, + 998650, + 900681, + 1600319, + 1000922, + 1098315, + 899369, + 1508494, + 995818, + 996890, + 999210, + 1500894, + 998634, + 902025, + 997722, + 1607407, + 1206492, + 1201164, + 1476734, + 1932099, + 1298653, + 1379725, + 1294493, + 1905715, + 1218156, + 1300924, + 1283901, + 1816786, + 1298316, + 1097627, + 1295709, + 1988723, + 1380910, + 1401549, + 1310861, + 1983812, + 1314572, + 1377262, + 1410334, + 1933507, + 1352141, + 1231100, + 1283180, + 3168447, + 1981892, + 1637856, + 1561599, + 1745073, + 1099499, + 1101499, + 1102826, + 1792130, + 1403294, + 1655392, + 1339549, + 1803761, + 1099547, + 1103307, + 1106731, + 1800945, + 1191772, + 1247116, + 1177212, + 1800193, + 1216780, + 1482815, + 1330733, + 2065620, + 1197356, + 1200411, + 1326429, + 1778306, + 1363901, + 1235116, + 1297709, + 1809201, + 1289901, + 1110235, + 1504335, + 1789393, + 1401422, + 1435470, + 1079114, + 1919795, + 1255852, + 1505183, + 1306237, + 1794257, + 1306221, + 1197660, + 1198828, + 1692256, + 1105915, + 1215500, + 973177, + 1502287, + 894937, + 898681, + 900136, + 1499535, + 900425, + 900185, + 899448, + 1500015, + 900089, + 900793, + 899801, + 1498910, + 900457, + 899465, + 900185, + 1501454, + 898313, + 899817, + 900121, + 1801233, + 898969, + 899769, + 899849, + 1501230, + 899145, + 899209, + 901209, + 1499054, + 900265, + 899081, + 902793, + 1497598, + 899673, + 900649, + 899801, + 1500174, + 900217, + 899193, + 899769, + 1500542, + 899705, + 900425, + 899481, + 1500510, + 899081, + 899993, + 903081, + 1497359, + 900312, + 898985, + 900377, + 1500991, + 899000, + 899913, + 899881, + 1600704, + 900632, + 901353, + 898089, + 1713201, + 1209276, + 977481, + 1022730, + 1902275, + 1295020, + 1192620, + 1201660, + 1906626, + 1368398, + 1403502, + 1398397, + 1998500, + 1496750, + 1404286, + 1427982, + 1983091, + 1184684, + 1208956, + 1840146, + 2503976, + 1143499, + 1101339, + 1099707, + 1703937, + 1099082, + 1190780, + 1682881, + 2461272, + 1920786, + 1893075, + 1258956, + 2182133, + 1741218, + 1356893, + 1662416, + 2248582, + 1685008, + 1942339, + 1523055, + 2492425, + 1564591, + 1185787, + 1461807, + 2243718, + 1305036, + 1304285, + 1385086, + 1894914, + 1397230, + 1657328, + 1339917, + 1808674, + 1201100, + 1105530, + 1193852, + 1620096, + 1324973, + 1174907, + 1197164, + 2204326, + 1428046, + 1169979, + 1210556, + 2026388, + 1270076, + 1345901, + 1159500, + 1693664, + 888777, + 1428782, + 1284540, + 2102389, + 1219388, + 1399070, + 1180747, + 2100661, + 983705, + 1611776, + 1231292, + 1870738, + 1199596, + 985130, + 900440, + 1500639, + 898585, + 997178, + 1318957, + 1990355, + 1203852, + 1199324, + 1202795, + 1796722, + 1200315, + 992010, + 896937, + 1500703, + 900344, + 898489, + 900345, + 1500719, + 899112, + 900457, + 1017386, + 1799522, + 984841, + 1008010, + 1209804, + 1900243, + 1200283, + 1289885, + 1205436, + 1802705, + 1196220, + 984794, + 899465, + 1814785, + 1300125, + 1195500, + 1204011, + 1901299, + 984618, + 899400, + 1016586, + 1799202, + 1304989, + 1196203, + 1196108, + 1696721, + 988889, + 898921, + 902457, + 1498815, + 1004409, + 1218716, + 1383598, + 1806354, + 1520846, + 1178604, + 1504543, + 1795713, + 1515839, + 1089947, + 1192651, + 2006964, + 1502223, + 1196827, + 1194108, + 1799362, + 1200779, + 1329213, + 1380606, + 1884642, + 1302349, + 1196220, + 1721984, + 1886339, + 1193580, + 1099706, + 1201660, + 1907971, + 1493966, + 1105195, + 1287837, + 1828018, + 964457, + 1022810, + 1496447, + 1890770, + 1196812, + 1238716, + 1267164, + 1862914, + 1135243, + 1099482, + 987626, + 1500511, + 899384, + 899337, + 1219804, + 1804450, + 1100443, + 1095082, + 1293149, + 1893122, + 1114395, + 1291821, + 1304765, + 1809281, + 971978, + 899401, + 901193, + 1610351, + 1420558, + 1183532, + 984249, + 1630704, + 1287229, + 982057, + 900025, + 1613344, + 1313949, + 1195580, + 976921, + 1498991, + 900217, + 899240, + 900441, + 1500079, + 902121, + 897320, + 900857, + 1618240, + 1737681, + 1264476, + 1403150, + 1795202, + 1335853, + 1199467, + 1060907, + 1806049, + 1200700, + 1099195, + 1192395, + 2100021, + 1300333, + 1456030, + 1041402, + 1903283, + 1496558, + 1295421, + 1205628, + 1799745, + 1306269, + 978874, + 899177, + 1625807, + 1398286, + 1397086, + 1429054, + 1869922, + 1197436, + 1289532, + 1214940, + 1808002, + 1358413, + 1231180, + 1200156, + 2096548, + 1545072, + 1259676, + 1310173, + 1685200, + 1194252, + 1302381, + 1196923, + 1905315, + 1199884, + 1299676, + 1294445, + 1803602, + 1536479, + 1267660, + 1292685, + 1733345, + 1283564, + 1280397, + 1300380, + 1901315, + 1302797, + 1201595, + 1195004, + 1898579, + 1301068, + 1222188, + 1280221, + 1710096, + 1299677, + 1523743, + 1497903, + 1862658, + 1498831, + 1099242, + 1469087, + 2239654, + 1099050, + 1293645, + 1200940, + 1810513, + 1285997, + 1716817, + 1084298, + 1839874, + 948234, + 899448, + 899705, + 1503935, + 896585, + 1015402, + 1292012, + 1712641, + 1307149, + 1593471, + 1295901, + 2098037, + 1305244, + 1292317, + 1198908, + 1704496, + 1207724, + 1198012, + 1498622, + 1805186, + 1199612, + 1296861, + 1286892, + 1590448, + 1009514, + 1199755, + 1104331, + 1825234, + 1271292, + 1405278, + 1193372, + 1940211, + 1053658, + 1206396, + 1203516, + 1797089, + 1097211, + 1307917, + 1304940, + 1789634, + 1100107, + 1205131, + 1211468, + 1774993, + 1301101, + 1208220, + 984026, + 1615487, + 1200156, + 1305565, + 1197916, + 1701216, + 979802, + 898281, + 899688, + 1501055, + 1025002, + 1199980, + 1100059, + 1899762, + 1291037, + 1299053, + 1205195, + 1799346, + 1300125, + 1298444, + 1099739, + 1900083, + 1301324, + 1299197, + 1199436, + 1895186, + 1298909, + 1200620, + 983209, + 1617456, + 982922, + 899641, + 899000, + 1501327, + 1027050, + 1188364, + 1206683, + 1898531, + 1300621, + 1299452, + 1203740, + 1896067, + 1299052, + 1298045, + 1293805, + 1805185, + 1199612, + 1202972, + 1196828, + 1823633, + 1181628, + 1305229, + 1186715, + 1837762, + 1293245, + 1169851, + 1531535, + 1769234, + 1311004, + 1283549, + 1639776, + 1549071, + 896745, + 1208156, + 1200411, + 2105317, + 1210076, + 1341645, + 1486622, + 1765202, + 1500750, + 1299213, + 1200828, + 1794945, + 1196428, + 1193100, + 1215308, + 1900402, + 1298045, + 1194444, + 985737, + 1615872, + 1338989, + 1162939, + 1557984, + 1839682, + 1545263, + 1249932, + 1201260, + 1904882, + 1419502, + 1176668, + 985577, + 1500351, + 1016970, + 1236300, + 1266524, + 1800498, + 1192796, + 1613648, + 1081994, + 1801538, + 2195605, + 1328045, + 1276125, + 1814273, + 1321597, + 1179596, + 1186731, + 2303575, + 1338637, + 1265020, + 1089963, + 2107957, + 1333565, + 1263676, + 1101419, + 1914658, + 1285533, + 1299837, + 1336861, + 1791201, + 1176748, + 1199900, + 1100586, + 1692897, + 1293468, + 1199244, + 1202940, + 1906259, + 1434510, + 942681, + 1058778, + 1853266, + 1197004, + 1212908, + 1298701, + 1889746, + 988522, + 1547967, + 1064602, + 1801330, + 1313661, + 1197499, + 1505119, + 1700833, + 1399501, + 1181932, + 1100443, + 1801777, + 1198908, + 1199212, + 1718513, + 1893170, + 1285437, + 1199323, + 987226, + 1909651, + 1106027, + 983817, + 899849, + 1714833, + 1102298, + 1195260, + 1720273, + 1690576, + 1305453, + 1085419, + 1300220, + 1900467, + 1494463, + 1203819, + 1302733, + 1583408, + 1123739, + 1290508, + 1539407, + 1846946, + 1302973, + 1205452, + 1196876, + 1804273, + 1635792, + 1169404, + 1193755, + 2301303, + 1336653, + 1162571, + 1100683, + 1794290, + 1204235, + 1202172, + 1505535, + 1697568, + 1295773, + 1200396, + 1198172, + 1707040, + 1195932, + 1196764, + 1099210, + 1710945, + 1288477, + 1428190, + 1171387, + 1700657, + 1105339, + 1195963, + 1308045, + 1992099, + 1531967, + 952378, + 898601, + 1499822, + 900841, + 899577, + 900601, + 1617183, + 1195996, + 1226828, + 1175820, + 1711120, + 1298397, + 1189916, + 983465, + 1817602, + 1199324, + 1400781, + 1189676, + 1935395, + 956345, + 898921, + 899881, + 1502158, + 899625, + 901177, + 897161, + 1502559, + 1016153, + 1598016, + 1309725, + 1789809, + 1198092, + 1500015, + 1309389, + 1881378, + 1102875, + 991401, + 901641, + 1498479, + 899929, + 900265, + 900280, + 1610656, + 1463166, + 1545999, + 1293581, + 1838402, + 1160219, + 986426, + 1022474, + 1909571, + 1284476, + 1233708, + 1272509, + 1888386, + 1310877, + 1283037, + 1211211, + 1801634, + 1192684, + 1212187, + 1264765, + 2020020, + 1099258, + 1103611, + 1098155, + 1800769, + 1107611, + 980634, + 898729, + 1499854, + 898937, + 1014826, + 1200044, + 1901954, + 1339229, + 1158476, + 1201131, + 1804850, + 1198700, + 1300380, + 1194364, + 1799650, + 1538927, + 1157755, + 1400814, + 1809025, + 1428894, + 1271773, + 1291916, + 1586736, + 1018890, + 1195052, + 1304412, + 1795458, + 984713, + 898153, + 1000314, + 1500271, + 900105, + 900424, + 1017946, + 1896979, + 984153, + 900073, + 901097, + 1498543, + 899976, + 1014890, + 1104059, + 1803282, + 1191403, + 1341613, + 1159564, + 1796689, + 1304077, + 1301069, + 1096906, + 1698593, + 1199532, + 1198859, + 987754, + 1612096, + 1375869, + 1339421, + 975850, + 1611568, + 1330397, + 1167499, + 1302589, + 1917619, + 1278604, + 1309709, + 1190827, + 1587376, + 897753, + 900297, + 899752, + 1641376, + 1173148, + 1300349, + 1195755, + 2193286, + 1116187, + 1300540, + 1699761, + 1798289, + 1303037, + 1503215, + 1289468, + 1998388, + 985354, + 1017530, + 1213691, + 1895283, + 1207852, + 1079354, + 985818, + 1628032, + 1300572, + 972170, + 1117083, + 1583359, + 1014298, + 1198364, + 1200508, + 1698592, + 1198476, + 986122, + 1000042, + 1617503, + 1194652, + 1718353, + 1088890, + 1580192, + 900601, + 898984, + 900505, + 1614672, + 1099995, + 1296348, + 1301421, + 1807394, + 1093418, + 985290, + 899561, + 1725457, + 1190139, + 1098747, + 1217356, + 1786785, + 982586, + 1111995, + 1305725, + 1798865, + 1198332, + 984250, + 900136, + 1500255, + 897465, + 900760, + 899449, + 1502207, + 898393, + 901849, + 897224, + 1501071, + 898841, + 900601, + 898904, + 1622064, + 1298237, + 1299725, + 1297868, + 1698785, + 1299308, + 1098011, + 1099291, + 1808274, + 1299260, + 1094459, + 1092107, + 1605247, + 993898, + 998170, + 999418, + 1600271, + 999626, + 999290, + 998682, + 1605439, + 997946, + 998378, + 1001786, + 1707824, + 994890, + 998298, + 999609, + 1604512, + 997482, + 996522, + 999881, + 1611040, + 990298, + 997770, + 1102986, + 1602352, + 997610, + 1000521, + 999226, + 1602256, + 994138, + 999497, + 998730, + 1968451, + 1440398, + 995802, + 997514, + 1599712, + 998361, + 999194, + 999034, + 1601727, + 998650, + 903113, + 997482, + 1600159, + 998490, + 899193, + 900521, + 1501438, + 1001370, + 996922, + 900745, + 1599935, + 999818, + 899337, + 999114, + 1500846, + 1000634, + 1000186, + 1000074, + 1597343, + 1190060, + 1200172, + 1657312, + 2781947, + 1174011, + 997962, + 1000042, + 1692624, + 1198268, + 1195420, + 1121083, + 1679408, + 1198508, + 2040212, + 1051418, + 1532751, + 990234, + 998666, + 1001977, + 1601920, + 1461118, + 1037946, + 998330, + 1599856, + 1431998, + 1069242, + 999306, + 1598304, + 1395421, + 1205324, + 999082, + 1599135, + 998410, + 1000810, + 1000234, + 1599487, + 998874, + 1408366, + 995242, + 1598079, + 998410, + 1184555, + 1261709, + 1910851, + 1303308, + 1310733, + 1409886, + 2371383, + 1831570, + 1380749, + 2438312, + 2416808, + 1917395, + 1660528, + 1201804, + 1903666, + 1690481, + 1492094, + 1584048, + 1901010, + 1220988, + 1100155, + 1488622, + 2362808, + 1972419, + 1258508, + 1098395, + 1701456, + 1076091, + 1133851, + 1194972, + 1798401, + 1103179, + 1121355, + 1181580, + 1799249, + 1200140, + 2098836, + 1918659, + 2128437, + 1153307, + 1198684, + 1525535, + 2170709, + 1100139, + 1109323, + 1458894, + 1956211, + 992138, + 998681, + 1000490, + 1600528, + 1112155, + 1403549, + 1085675, + 1598144, + 1002169, + 998234, + 999114, + 1600735, + 1000394, + 998042, + 901849, + 1598591, + 1000106, + 1001402, + 997594, + 1500878, + 998570, + 900761, + 899385, + 2022851, + 1078091, + 999386, + 1000714, + 1601967, + 998378, + 1000074, + 1197595, + 2449832, + 1137052, + 1528014, + 1898659, + 2099029, + 1401501, + 1399630, + 1733137, + 2013139, + 1486863, + 953593, + 998426, + 1600896, + 999641, + 901081, + 1187372, + 1813442, + 1809089, + 1898947, + 1496286, + 1777074, + 1501566, + 1197916, + 1202300, + 1806482, + 1299948, + 1210860, + 998362, + 1697072, + 1092971, + 1284445, + 1480238, + 1831442, + 1219036, + 1909523, + 1497566, + 2174293, + 1312509, + 1110971, + 989610, + 1597279, + 999226, + 1901603, + 1002457, + 1625600, + 976586, + 994778, + 999577, + 1621296, + 979962, + 998186, + 999369, + 1599920, + 1000010, + 999562, + 1001161, + 1598976, + 1000266, + 998985, + 1000330, + 1503407, + 998650, + 998537, + 1004010, + 1597632, + 998586, + 1109786, + 1091627, + 1606144, + 993385, + 998154, + 1002794, + 1599472, + 1012138, + 988505, + 998378, + 1601408, + 997369, + 999178, + 999370, + 1600447, + 998714, + 901449, + 998090, + 1601199, + 999914, + 1000458, + 998218, + 1600239, + 1207660, + 1198636, + 1099179, + 1597135, + 1099643, + 997418, + 1000761, + 1598672, + 900441, + 1002698, + 1096490, + 1898883, + 1110235, + 1101115, + 991817, + 1796546, + 1109995, + 1186539, + 1217900, + 2181893, + 1303645, + 1105163, + 1304045, + 1597535, + 1000698, + 996282, + 1000490, + 1606015, + 1094619, + 1112187, + 1194683, + 1700273, + 1090923, + 1001226, + 998425, + 1699873, + 999002, + 999081, + 1213292, + 1741105, + 1156332, + 1204155, + 1200572, + 1801234, + 1197435, + 1097435, + 1201628, + 1899810, + 989930, + 1212908, + 1115819, + 1676656, + 1092971, + 997018, + 1000233, + 1715041, + 1299981, + 989113, + 1013370, + 1886579, + 1275276, + 1231324, + 1307149, + 1897091, + 1290876, + 1195100, + 1209548, + 1892786, + 1205260, + 1197420, + 1300956, + 1899715, + 1208172, + 985481, + 1203436, + 1826930, + 1382382, + 1296716, + 1199132, + 1802274, + 1298700, + 988538, + 1309645, + 1796961, + 1099771, + 1196780, + 1202651, + 1896867, + 1446206, + 1047770, + 1198988, + 1700961, + 1295868, + 1198204, + 2083396, + 2407768, + 1013002, + 1188155, + 1100891, + 1800082, + 1622752, + 1903282, + 1379374, + 1881810, + 1022378, + 1523823, + 1692032, + 1765298, + 1200027, + 1200540, + 1474431, + 2614233, + 1525775, + 1752929, + 2169141, + 2172614, + 1756705, + 1636896, + 1659632, + 2490696, + 1452750, + 1502863, + 1451806, + 2056036, + 1278669, + 1200396, + 1289916, + 2103893, + 1229260, + 992154, + 1203387, + 1714737, + 1182075, + 1199708, + 1200172, + 1800386, + 1196603, + 1199388, + 1403966, + 2086212, + 1581856, + 1316796, + 1835762, + 2208438, + 1150939, + 1277933, + 1139435, + 1683056, + 1759089, + 1776882, + 1261644, + 1800994, + 1199259, + 1100475, + 1199356, + 2040004, + 1359101, + 1200236, + 1201227, + 2033364, + 1565024, + 1201035, + 1397502, + 1702705, + 1199979, + 1359390, + 1733809, + 2104644, + 1461678, + 1514175, + 1568928, + 1920146, + 1513295, + 1643552, + 1276829, + 2436328, + 1081306, + 997514, + 999401, + 2022852, + 1262397, + 1199947, + 1536463, + 1946675, + 1222492, + 1450255, + 1159531, + 1866434, + 1317149, + 1014730, + 999402, + 1685248, + 1560767, + 1487071, + 1385629, + 2367384, + 1115994, + 999322, + 999082, + 1784241, + 1210092, + 1189164, + 1746145, + 2605769, + 1266333, + 1520287, + 1641072, + 2192277, + 1724209, + 1562735, + 1789890, + 1948675, + 1306236, + 1295693, + 1201628, + 1698208, + 1301117, + 1199372, + 2186133, + 2320359, + 1197788, + 1197691, + 1115659, + 1777058, + 1782369, + 1870850, + 1254668, + 1838706, + 1365326, + 1111339, + 1187451, + 1994788, + 1409549, + 1424718, + 1074683, + 2452136, + 1606064, + 1335725, + 1198139, + 1799346, + 1197436, + 1786225, + 1858402, + 2131541, + 1859874, + 1913603, + 1389790, + 1999667, + 1453294, + 1463150, + 1282125, + 2292726, + 1737681, + 1852674, + 1669089, + 2135781, + 1726417, + 1875250, + 1361597, + 1798274, + 1202347, + 1198716, + 1200716, + 2433288, + 2358103, + 1225164, + 1192779, + 2167414, + 1744161, + 1603871, + 1397550, + 1792401, + 1305213, + 1291757, + 1499838, + 2215910, + 1502703, + 1390333, + 1603680, + 2127445, + 1794369, + 1259085, + 1841810, + 2058500, + 1105835, + 1931842, + 1915123, + 2142277, + 1198188, + 1197371, + 1200972, + 1932403, + 1277532, + 1099771, + 997354, + 1745537, + 1375037, + 1295661, + 1097883, + 1820882, + 1275420, + 1303677, + 1297980, + 1899635, + 1311421, + 974601, + 1113547, + 1901747, + 1301244, + 1201004, + 1432190, + 1778258, + 1293276, + 1403646, + 1519279, + 1771041, + 1219596, + 1592128, + 1512926, + 2196230, + 1289852, + 1506431, + 1063530, + 1712353, + 1102363, + 1288525, + 1201147, + 1836594, + 1373918, + 1294476, + 1104043, + 1796354, + 1200411, + 1422110, + 1065947, + 1499118, + 899961, + 900009, + 900633, + 1937330, + 1277181, + 1423214, + 1386765, + 2010660, + 1416350, + 1375837, + 1505311, + 2078564, + 1298637, + 1199420, + 1199467, + 1999716, + 1104987, + 1411437, + 1083499, + 1926387, + 1161547, + 1013178, + 1195820, + 1931139, + 1371901, + 1206732, + 981545, + 1498031, + 899929, + 900073, + 899672, + 1500591, + 899465, + 1024346, + 1419166, + 2066996, + 1202828, + 1195611, + 1207644, + 1796434, + 1529759, + 1479598, + 1605264, + 1913202, + 1474207, + 1094250, + 1634928, + 2201382, + 1367085, + 1197420, + 987210, + 1500318, + 1007866, + 1529039, + 1482238, + 1891795, + 1101179, + 1631392, + 1371565, + 1799346, + 1098298, + 1200796, + 1200076, + 1686384, + 1307405, + 1294653, + 1416509, + 1913395, + 1172796, + 1104906, + 1101163, + 1585456, + 899704, + 899865, + 899481, + 1615200, ``` The diff is longer than this page shows; the raw diff has all of it.