From 650b0f60d7903d6c52511e7f471b8227a7ac1550 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Tue, 17 Nov 2026 12:44:16 -0500 Subject: [PATCH 1/5] test(compact): pin the bytes State::to_compact writes, as hex goldens Ten fixed states that between them hold the nine words, a checked proof (mined, suspect after a fork, and kept after a stale), every HintStatus kind without a verdict and with one read from an ARC body (the presence hint carrying a verdict by Hint's public fields), and the seven Reask kinds, each reached through the public API. Each state's to_compact is compared with bytes written out in the test, and a state whose word is not mined restores equal to itself. Why: the make-room pull request before 0.9.0 (bsv-stack-lean docs/DECISIONS-2026-10-19.md 28.8.1 (c), ruled 2026-11-17 16:1xZ) must move no byte the crate writes. This commit lands alone on the base, so the later commits are measured against it. No test of the base changes. Co-Authored-By: Claude Opus 5.5 --- tests/compact_golden.rs | 347 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 tests/compact_golden.rs diff --git a/tests/compact_golden.rs b/tests/compact_golden.rs new file mode 100644 index 0000000..92c3945 --- /dev/null +++ b/tests/compact_golden.rs @@ -0,0 +1,347 @@ +//! The compact bytes pinned (bsv-stack-lean #92; the make-room pull request +//! of the rulings of 2026-11-17, the stack's 28.8.1 (c)): fixed states that +//! between them hold every word, a checked proof, every hint status with and +//! without a verdict and every re-ask, each written by `State::to_compact` +//! and compared with bytes spelled out here as hex. A change that moves one +//! byte the crate writes fails here, whatever else it keeps. +// The lint bar binds the library; a test may unwrap, and its fixtures fail loudly +// (bsv-stack-lean #134). +#![allow( + clippy::pedantic, + clippy::unwrap_used, + clippy::expect_used, + clippy::panic +)] +mod common; +use bsv_tracker::*; +use common::*; + +fn hex(bytes: &[u8]) -> String { + bytes.iter().map(|b| format!("{b:02x}")).collect() +} + +/// The bytes the state writes, against the golden; a state whose word is not +/// `mined` also restores equal to itself (a mined word restores suspect with +/// its recheck due, `State::from_compact`'s rule, so it is not compared). +fn golden(name: &str, s: &State, expected: &str) { + let bytes = s.to_compact(); + assert_eq!(hex(&bytes), expected, "{name}: the compact bytes moved"); + let restored = State::from_compact(&bytes).unwrap(); + if !matches!(s.word(), Word::Mined(_)) { + assert_eq!(&restored, s, "{name}"); + } +} + +/// A verdict read from an ARC body, so the test builds none by literal. +fn arc(body: &str, source: &str, observed: u64) -> Hint { + Verdict::from_arc_body(&hash(1), body.as_bytes()) + .unwrap() + .into_hint(source, observed) +} + +/// Every hint status: nine without a verdict, nine with one. +fn every_hint() -> Vec { + let plain = [ + HintStatus::Accepted, + HintStatus::Seen, + HintStatus::Mined { height: 900 }, + HintStatus::StaleBlock, + HintStatus::Rejected { + reason: "r \u{e9}".into(), + }, + HintStatus::DoubleSpend { + competitors: vec![hash(7), "not-an-id".into()], + }, + HintStatus::DoubleSpend { + competitors: vec![], + }, + HintStatus::OrphanMempool, + HintStatus::Unknown, + HintStatus::MempoolPresent { + source: "courier-a".into(), + }, + ]; + let mut hints: Vec = plain + .into_iter() + .enumerate() + .map(|(i, status)| Hint::new(format!("plain-{i}"), status, 100 + i as u64)) + .collect(); + let competitor = hash(7); + let bodies = [ + r#"{"txStatus":"ACCEPTED_BY_NETWORK"}"#.to_string(), + r#"{"txStatus":"SEEN_ON_NETWORK","extraInfo":"note"}"#.to_string(), + r#"{"txStatus":"MINED","blockHeight":900}"#.to_string(), + r#"{"txStatus":"MINED_IN_STALE_BLOCK","blockHeight":899}"#.to_string(), + r#"{"txStatus":"REJECTED","extraInfo":"bad script"}"#.to_string(), + format!(r#"{{"txStatus":"DOUBLE_SPEND_ATTEMPTED","competingTxs":["{competitor}"]}}"#), + r#"{"txStatus":"SEEN_IN_ORPHAN_MEMPOOL"}"#.to_string(), + r#"{"txStatus":"UNKNOWN"}"#.to_string(), + ]; + for (i, body) in bodies.iter().enumerate() { + hints.push(arc(body, &format!("arc-{i}"), 200 + i as u64)); + } + // The presence hint is never a broadcaster's reduction; a host may still + // keep a verdict beside it. + let mut present = arc(r#"{"txStatus":"SEEN_ON_NETWORK"}"#, "courier", 300); + present.status = HintStatus::MempoolPresent { + source: "courier-b".into(), + }; + hints.push(present); + hints +} + +fn mined_state(h: &mut TestHeaders) -> State { + let txid = hash(1); + let p = proof(&txid, 10, 2); + h.insert(&p, 10); + let mut s = State::new(&txid); + step(&mut s, h, Input::Evidence(Evidence::Proof(p))); + s +} + +#[test] +fn every_hint_status_with_and_without_a_verdict_is_held() { + let hints = every_hint(); + for (code, want) in [ + (0, 2), + (1, 2), + (2, 2), + (3, 2), + (4, 2), + (5, 3), + (6, 2), + (7, 2), + (8, 2), + ] { + let n = hints + .iter() + .filter(|h| match code { + 0 => h.status == HintStatus::Accepted, + 1 => h.status == HintStatus::Seen, + 2 => matches!(h.status, HintStatus::Mined { .. }), + 3 => h.status == HintStatus::StaleBlock, + 4 => matches!(h.status, HintStatus::Rejected { .. }), + 5 => matches!(h.status, HintStatus::DoubleSpend { .. }), + 6 => h.status == HintStatus::OrphanMempool, + 7 => h.status == HintStatus::Unknown, + _ => matches!(h.status, HintStatus::MempoolPresent { .. }), + }) + .count(); + assert_eq!(n, want, "status {code}"); + } + assert_eq!(hints.iter().filter(|h| h.verdict.is_some()).count(), 9); +} + +#[test] +fn unknown_and_no_reask() { + golden( + "unknown", + &State::new(hash(1)), + "01000000000000000000000000000000000000000000000000000000000000000001000000000000", + ); +} + +#[test] +fn built_with_spend() { + let h = TestHeaders::default(); + let mut s = State::new(hash(1)); + step(&mut s, &h, Input::Host(HostAction::Build)); + step(&mut s, &h, Input::Host(HostAction::SpendAttempt)); + assert_eq!(s.reask(), Some(&Reask::Spend)); + golden( + "built", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001010000000001", + "06", + ), + ); +} + +#[test] +fn announced_with_age() { + let h = TestHeaders::default(); + let mut s = State::new(hash(1)); + step(&mut s, &h, Input::Host(HostAction::Build)); + step(&mut s, &h, hint(HintStatus::Accepted, 10)); + step(&mut s, &h, Input::Host(HostAction::Tick(70))); + assert_eq!(s.word(), &Word::Announced); + assert_eq!(s.reask(), Some(&Reask::Age)); + golden( + "announced", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001020000011073", + "7475622062726f6164636173746572000a00010a0105", + ), + ); +} + +#[test] +fn seen_with_every_hint_and_a_hint_reask() { + let h = TestHeaders::default(); + let mut s = State::new(hash(1)); + step(&mut s, &h, Input::Host(HostAction::Build)); + for hint in every_hint() { + step(&mut s, &h, Input::Hint(hint)); + } + assert_eq!(s.word(), &Word::Seen); + assert_eq!(s.hints().len(), 19); + assert!(matches!(s.reask(), Some(Reask::Hint(_)))); + golden( + "seen", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001030000130763", + "6f75726965720809636f75726965722d62ac02010f5345454e5f4f4e5f4e4554574f524b00000005", + "6172632d3707cf010107554e4b4e4f574e000000056172632d3606ce0101165345454e5f494e5f4f", + "525048414e5f4d454d504f4f4c000000056172632d35050100000000000000000000000000000000", + "0000000000000000000000000000000007cd010116444f55424c455f5350454e445f415454454d50", + "54454400000100000000000000000000000000000000000000000000000000000000000000000705", + "6172632d34040a62616420736372697074cc01010852454a454354454400010a6261642073637269", + "707400056172632d3303cb0101144d494e45445f494e5f5354414c455f424c4f434b018307000005", + "6172632d32028407ca0101054d494e45440184070000056172632d3101c901010f5345454e5f4f4e", + "5f4e4554574f524b0001046e6f746500056172632d3000c801011341434345505445445f42595f4e", + "4554574f524b00000007706c61696e2d390809636f75726965722d616d0007706c61696e2d38076c", + "0007706c61696e2d37066b0007706c61696e2d3605006a0007706c61696e2d350502000000000000", + "00000000000000000000000000000000000000000000000000000701096e6f742d616e2d69646900", + "07706c61696e2d3404047220c3a9680007706c61696e2d3303670007706c61696e2d320284076600", + "07706c61696e2d3101650007706c61696e2d3000640001ac020102056172632d3707cf010107554e", + "4b4e4f574e000000", + ), + ); +} + +#[test] +fn mined_with_recheck() { + let mut h = TestHeaders::default(); + let mut s = mined_state(&mut h); + let other = proof(&hash(2), 11, 3); + h.insert(&other, 11); + step(&mut s, &h, Input::Evidence(Evidence::Competitor(other))); + assert!(matches!(s.word(), Word::Mined(_))); + assert!(s.evidence().is_some()); + assert_eq!(s.reask(), Some(&Reask::Recheck)); + golden( + "mined", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001040100000000", + "00000000000000000000000000000000000000000000000000000000010a01020006000000000000", + "00000000000000000000000000000000000000000000000000000101040000000000000000000000", + "00000000000000000000000000000000000000000002000000000000000000000000000000000000", + "00000000000000000000000000000a00ff8f6e7ac7aa0bfc98af8be24ed6ae1ab243f64aaa065366", + "b2215e697fddb64b00ff8f6e7ac7aa0bfc98af8be24ed6ae1ab243f64aaa065366b2215e697fddb6", + "4b010000000104", + ), + ); +} + +#[test] +fn mined_suspect_with_fork() { + let mut h = TestHeaders::default(); + let mut s = mined_state(&mut h); + step(&mut s, &h, Input::Evidence(Evidence::Chain(fork(9)))); + assert!(s.suspect()); + assert_eq!(s.reask(), Some(&Reask::Fork { height: 9 })); + golden( + "fork", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001040100000000", + "00000000000000000000000000000000000000000000000000000000010a01020006000000000000", + "00000000000000000000000000000000000000000000000000000101040000000000000000000000", + "00000000000000000000000000000000000000000002000000000000000000000000000000000000", + "00000000000000000000000000000a00ff8f6e7ac7aa0bfc98af8be24ed6ae1ab243f64aaa065366", + "b2215e697fddb64b00ff8f6e7ac7aa0bfc98af8be24ed6ae1ab243f64aaa065366b2215e697fddb6", + "4b01010000010109", + ), + ); +} + +#[test] +fn stale_with_reorg() { + let mut h = TestHeaders::default(); + let mut s = mined_state(&mut h); + h.move_root(10, 50); + step(&mut s, &h, Input::Evidence(Evidence::Chain(reorg(10)))); + assert_eq!(s.word(), &Word::Stale); + assert_eq!(s.reask(), Some(&Reask::Reorg { fork_height: 10 })); + golden( + "stale", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001050100000000", + "00000000000000000000000000000000000000000000000000000000010a01020006000000000000", + "00000000000000000000000000000000000000000000000000000101040000000000000000000000", + "00000000000000000000000000000000000000000002000000000000000000000000000000000000", + "00000000000000000000000000000a00ff8f6e7ac7aa0bfc98af8be24ed6ae1ab243f64aaa065366", + "b2215e697fddb64b00ff8f6e7ac7aa0bfc98af8be24ed6ae1ab243f64aaa065366b2215e697fddb6", + "4b0100000001000a", + ), + ); +} + +#[test] +fn rejected_with_proof_failed() { + let h = TestHeaders::default(); + let mut s = State::new(hash(1)); + step( + &mut s, + &h, + Input::Evidence(Evidence::Verdict(NodeVerdict::Rejected { + reason: "node said no".into(), + })), + ); + let wrong = proof(&hash(3), 12, 4); + assert_eq!( + s.step(¶ms(), &h, Input::Evidence(Evidence::Proof(wrong))), + Err(CheckError::TxidMismatch) + ); + assert_eq!(s.reask(), Some(&Reask::ProofFailed { height: 12 })); + golden( + "rejected", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001060c6e6f6465", + "2073616964206e6f0000000001030c", + ), + ); +} + +#[test] +fn conflicted_by_ids_and_text() { + let h = TestHeaders::default(); + let mut s = State::new(hash(1)); + step( + &mut s, + &h, + Input::Evidence(Evidence::Verdict(NodeVerdict::Conflicted { + competitors: vec![hash(8), "Not-An-Id".into()], + })), + ); + assert!(matches!(s.word(), Word::Conflicted { .. })); + golden( + "conflicted", + &s, + concat!( + "01000000000000000000000000000000000000000000000000000000000000000001070200000000", + "000000000000000000000000000000000000000000000000000000000801094e6f742d416e2d4964", + "0000000000", + ), + ); +} + +#[test] +fn abandoned() { + let h = TestHeaders::default(); + let mut s = State::new(hash(1)); + step(&mut s, &h, Input::Host(HostAction::Build)); + step(&mut s, &h, Input::Host(HostAction::Abandon)); + assert_eq!(s.word(), &Word::Abandoned); + golden( + "abandoned", + &s, + "01000000000000000000000000000000000000000000000000000000000000000001080000000000", + ); +} From b010d8f76803b5882dc904ac01df1de4c7d50f76 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Tue, 17 Nov 2026 12:45:35 -0500 Subject: [PATCH 2/5] feat!: five types non-exhaustive, and Verdict::new #[non_exhaustive] on the enums HostAction, Reask, HintStatus and VerdictError and on the struct Verdict; the type alone, no variant marked, Verdict's four fields still pub. Verdict::new(status) builds a verdict holding the word as given (not trimmed, not checked) with no height, no reason and no competitors; from_arc_body stays the checked reader. Why: the rulings of 2026-11-17 16:1xZ (bsv-stack-lean docs/RULINGS-2026-10-12.md; docs/DECISIONS-2026-10-19.md 28.8.1 (c), VerdictError by the keeper's reading of 17:1xZ) land bsv-tracker #45, #46 and #47 after the 0.9.0 cut as minors; with the marks their new kinds, the status-code field and a refusal reader's error are additive. A host's exhaustive match on the four enums, and a Verdict literal, stop compiling now instead. The proof: a compile_fail doctest per type, each quoting its code (E0004 for the four enums, E0639 for the literal); on nightly, where rustdoc checks the code, all five hold, and with the marks removed all five compile. tests/verdicts.rs builds its three verdicts with Verdict::new and field assignments, the same values and answers. No match in src/ gains a wildcard arm, and no test under tests/ matches one of the five enums without one, so none gains an arm. Co-Authored-By: Claude Opus 5.5 --- src/hints.rs | 69 +++++++++++++++++++++++++++++++++++++++++++++++ src/state.rs | 37 +++++++++++++++++++++++++ tests/verdicts.rs | 29 +++++++------------- 3 files changed, 115 insertions(+), 20 deletions(-) diff --git a/src/hints.rs b/src/hints.rs index 745d792..44ddbfe 100644 --- a/src/hints.rs +++ b/src/hints.rs @@ -3,7 +3,29 @@ use serde::Deserialize; use std::fmt; /// A broadcaster's claim reduced to the Lean hint vocabulary. +/// +/// `#[non_exhaustive]` (the room made before 0.9.0, bsv-stack-lean +/// `docs/DECISIONS-2026-10-19.md` 28.8.1 (c)): a later minor may add a kind, +/// so a host's match outside this crate carries a wildcard arm. +/// +/// ```compile_fail,E0004 +/// use bsv_tracker::HintStatus; +/// fn kind(status: &HintStatus) -> u8 { +/// match status { +/// HintStatus::Accepted => 0, +/// HintStatus::Seen => 1, +/// HintStatus::Mined { .. } => 2, +/// HintStatus::StaleBlock => 3, +/// HintStatus::Rejected { .. } => 4, +/// HintStatus::DoubleSpend { .. } => 5, +/// HintStatus::OrphanMempool => 6, +/// HintStatus::Unknown => 7, +/// HintStatus::MempoolPresent { .. } => 8, +/// } +/// } +/// ``` #[derive(Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum HintStatus { /// The broadcaster accepted the transaction. Accepted, @@ -70,7 +92,23 @@ impl Hint { } } /// Raw broadcaster metadata. HTTP acceptance is not chain evidence. +/// +/// `#[non_exhaustive]` (bsv-stack-lean `docs/DECISIONS-2026-10-19.md` +/// 28.8.1 (c)): a later minor may add a field, so a host outside this crate +/// builds one with [`Verdict::new`] and assigns the fields after it; the +/// four fields stay public to read and to assign. +/// +/// ```compile_fail,E0639 +/// use bsv_tracker::Verdict; +/// let _ = Verdict { +/// status: "SEEN_ON_NETWORK".into(), +/// height: None, +/// reason: None, +/// competitors: vec![], +/// }; +/// ``` #[derive(Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] pub struct Verdict { /// The `txStatus` word, trimmed and upper-cased by [`Verdict::from_arc_body`]. pub status: String, @@ -82,6 +120,19 @@ pub struct Verdict { pub competitors: Vec, } impl Verdict { + /// A verdict holding `status` as given, not trimmed and not checked, with + /// no height, no reason and no competitors. A host assigns the other + /// fields after it. [`Verdict::from_arc_body`] stays the checked reader + /// of a broadcaster's body; this constructor checks nothing. + #[must_use] + pub fn new(status: impl Into) -> Self { + Self { + status: status.into(), + height: None, + reason: None, + competitors: Vec::new(), + } + } /// Read an ARC body as metadata, checking its echoed txid and the bounded /// status vocabulary at bsv-rs@7bc623c. HTTP status is never consulted. /// @@ -243,7 +294,25 @@ impl Verdict { } /// An invalid broadcaster body is a reported fault, never chain evidence. +/// +/// `#[non_exhaustive]` (bsv-stack-lean `docs/DECISIONS-2026-10-19.md` +/// 28.8.1 (c), the keeper's reading of 2026-11-17 17:1xZ): a later minor's +/// reader may add a variant, so a host's match outside this crate carries a +/// wildcard arm that reports the fault. +/// +/// ```compile_fail,E0004 +/// use bsv_tracker::VerdictError; +/// fn kind(error: &VerdictError) -> u8 { +/// match error { +/// VerdictError::Shape(_) => 0, +/// VerdictError::TxidMismatch => 1, +/// VerdictError::InvalidMetadata => 2, +/// VerdictError::UnknownStatus(_) => 3, +/// } +/// } +/// ``` #[derive(Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum VerdictError { /// The expected fields cannot be decoded. Shape(String), diff --git a/src/state.rs b/src/state.rs index f9b1e0c..d1bf457 100644 --- a/src/state.rs +++ b/src/state.rs @@ -104,7 +104,24 @@ pub enum Evidence { Recheck, } /// Acts supplied by the host, including its clock and spend guard. +/// +/// `#[non_exhaustive]` (bsv-stack-lean `docs/DECISIONS-2026-10-19.md` +/// 28.8.1 (c)): a later minor may add an act, so a host's match outside this +/// crate carries a wildcard arm. +/// +/// ```compile_fail,E0004 +/// use bsv_tracker::HostAction; +/// fn kind(action: &HostAction) -> u8 { +/// match action { +/// HostAction::Build => 0, +/// HostAction::Abandon => 1, +/// HostAction::SpendAttempt => 2, +/// HostAction::Tick(_) => 3, +/// } +/// } +/// ``` #[derive(Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum HostAction { /// The host built the transaction. Build, @@ -126,7 +143,27 @@ pub enum Input { Host(HostAction), } /// A value for the host to execute; the crate never fetches anything. +/// +/// `#[non_exhaustive]` (bsv-stack-lean `docs/DECISIONS-2026-10-19.md` +/// 28.8.1 (c)): a later minor may add a kind, so a host's match outside this +/// crate carries a wildcard arm. +/// +/// ```compile_fail,E0004 +/// use bsv_tracker::Reask; +/// fn kind(reask: &Reask) -> u8 { +/// match reask { +/// Reask::Reorg { .. } => 0, +/// Reask::Fork { .. } => 1, +/// Reask::Hint(_) => 2, +/// Reask::ProofFailed { .. } => 3, +/// Reask::Recheck => 4, +/// Reask::Age => 5, +/// Reask::Spend => 6, +/// } +/// } +/// ``` #[derive(Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum Reask { /// The root moved: the active header at the mined height no longer /// carries the stored proof's root, so the word is stale; fetch a fresh diff --git a/tests/verdicts.rs b/tests/verdicts.rs index 8f59a62..9d3b24f 100644 --- a/tests/verdicts.rs +++ b/tests/verdicts.rs @@ -98,33 +98,22 @@ fn arcade_twelve_words_and_reorg_markers_remain_hints() { "MINED", "IMMUTABLE", ] { - let verdict = Verdict { - status: word.into(), - height: Some(10), - reason: None, - competitors: vec![], - }; + let mut verdict = Verdict::new(word); + verdict.height = Some(10); let mut s = State::new(hash(1)); step(&mut s, &h, Input::Host(HostAction::Build)); step(&mut s, &h, Input::Hint(verdict.into_hint("Arcade", 10))); assert_eq!(s.word().chain(), None, "{word}"); assert_eq!(s.evidence(), None); } - let unmine = Verdict { - status: "SEEN_ON_NETWORK".into(), - height: None, - reason: Some("reorg_unmined".into()), - competitors: vec![], - } - .into_hint("Arcade", 10); + let mut unmine = Verdict::new("SEEN_ON_NETWORK"); + unmine.reason = Some("reorg_unmined".into()); + let unmine = unmine.into_hint("Arcade", 10); // 0.4.1 (bsv-stack-lean #169): only the status words name a stale block. assert_eq!(unmine.status, HintStatus::Seen); - let reanchor = Verdict { - status: "MINED".into(), - height: Some(11), - reason: Some("reorg_reanchor".into()), - competitors: vec![], - } - .into_hint("Arcade", 11); + let mut reanchor = Verdict::new("MINED"); + reanchor.height = Some(11); + reanchor.reason = Some("reorg_reanchor".into()); + let reanchor = reanchor.into_hint("Arcade", 11); assert_eq!(reanchor.status, HintStatus::Mined { height: 11 }); } From 0c945f09615cf91d322a6fa58ed0767d52f1d948 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Tue, 17 Nov 2026 12:47:28 -0500 Subject: [PATCH 3/5] feat: the kinds' words, LABELS, and the stored form of HintStatus HintStatus::label and Reask::label (#[must_use]) give each kind its stable word, the payload not in it, the snake_case of the variant's name; each is a match with no wildcard arm, so a kind added without its word does not compile. HintStatus::LABELS and Reask::LABELS are every word in declaration order, which is the compact form's tag order, as a &'static [&'static str] so a later kind does not change the type. HintStatus derives Serialize and Deserialize, internally tagged by its word ({"status":"mined","height":900}); MempoolPresent's source is written as courier and DoubleSpend's competitors are left out when empty, so the form equals the JSON bsv-wallet-cli already stores. No #[serde(other)] and no default kind: an unknown word and a missing payload are refused. Reask gets the words alone (no serde, no Display, no bytes); Hint, Verdict and HostAction no serde. Why: the ruling's labels (bsv-stack-lean docs/DECISIONS-2026-10-19.md 28.8.1 (c), 2026-11-17 16:1xZ): a host that stores hints and shows re-asks takes the words from the crate instead of a hand map, so a kind a later minor adds is kept and surfaced, never mapped to Unknown. Tests: tests/labels.rs (the sixteen pairs, both lists, every status's text round-tripped, the serde tag equal to label, the refusals, and the host's shape: a struct with the status flattened between source and observed reads every text the CLI's StoredHint::of writes, a copy of it at bsv-wallet-cli 108f80e, and writes it back identical); two unit tests in src/compact.rs that LABELS[i] is the word of the kind the compact writer tags i. The compact goldens are unchanged. Co-Authored-By: Claude Opus 5.5 --- src/compact.rs | 62 +++++++++++ src/hints.rs | 54 +++++++++- src/state.rs | 28 +++++ tests/labels.rs | 266 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 408 insertions(+), 2 deletions(-) create mode 100644 tests/labels.rs diff --git a/src/compact.rs b/src/compact.rs index 2dcee0d..75e17f3 100644 --- a/src/compact.rs +++ b/src/compact.rs @@ -538,3 +538,65 @@ fn raw_id(s: &str) -> Option<[u8; 32]> { } Some(raw) } + +#[cfg(test)] +mod tests { + use super::Writer; + use crate::{Hint, HintStatus, Reask}; + + /// The tag the compact writer gives a status, read from its first byte. + fn status_tag(status: &HintStatus) -> usize { + let mut w = Writer(Vec::new()); + w.status(status); + usize::from(w.0[0]) + } + fn reask_tag(reask: &Reask) -> usize { + let mut w = Writer(Vec::new()); + w.reask(reask); + usize::from(w.0[0]) + } + + #[test] + fn hint_status_labels_are_the_compact_tag_order() { + let every = [ + HintStatus::Accepted, + HintStatus::Seen, + HintStatus::Mined { height: 1 }, + HintStatus::StaleBlock, + HintStatus::Rejected { reason: "r".into() }, + HintStatus::DoubleSpend { + competitors: vec![], + }, + HintStatus::OrphanMempool, + HintStatus::Unknown, + HintStatus::MempoolPresent { source: "c".into() }, + ]; + assert_eq!(every.len(), HintStatus::LABELS.len()); + let mut tags: Vec = every.iter().map(status_tag).collect(); + for status in &every { + assert_eq!(HintStatus::LABELS[status_tag(status)], status.label()); + } + tags.sort_unstable(); + assert_eq!(tags, (0..HintStatus::LABELS.len()).collect::>()); + } + + #[test] + fn reask_labels_are_the_compact_tag_order() { + let every = [ + Reask::Reorg { fork_height: 1 }, + Reask::Fork { height: 1 }, + Reask::Hint(Hint::new("s", HintStatus::Accepted, 0)), + Reask::ProofFailed { height: 1 }, + Reask::Recheck, + Reask::Age, + Reask::Spend, + ]; + assert_eq!(every.len(), Reask::LABELS.len()); + let mut tags: Vec = every.iter().map(reask_tag).collect(); + for reask in &every { + assert_eq!(Reask::LABELS[reask_tag(reask)], reask.label()); + } + tags.sort_unstable(); + assert_eq!(tags, (0..Reask::LABELS.len()).collect::>()); + } +} diff --git a/src/hints.rs b/src/hints.rs index 44ddbfe..abcccf5 100644 --- a/src/hints.rs +++ b/src/hints.rs @@ -1,5 +1,5 @@ use crate::{Height, Timestamp, TxId}; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use std::fmt; /// A broadcaster's claim reduced to the Lean hint vocabulary. @@ -24,7 +24,22 @@ use std::fmt; /// } /// } /// ``` -#[derive(Clone, Debug, PartialEq, Eq)] +/// +/// **The stored form.** The serde form below is this crate's stored form of +/// a status: an object whose key `status` holds the kind's word +/// ([`HintStatus::label`]) and whose payload sits beside it under its +/// field's name: `height` for `mined`, `reason` for `rejected`, +/// `competitors` for `double_spend` (left out when there are none) and +/// `courier` for `mempool_present` (the courier that answered, so a status +/// sits beside a hint's own `source` in one object). So +/// `{"status":"accepted"}`, `{"status":"mined","height":900}` and +/// `{"status":"mempool_present","courier":"c"}`. The reader refuses a word it +/// does not know and a kind whose payload is missing; it never reads either +/// as [`HintStatus::Unknown`]. The tag key, the words and the field names are +/// stable under the rule of [`HintStatus::LABELS`]: a word never changes and +/// is never reused, and a later minor only appends. +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(tag = "status", rename_all = "snake_case")] #[non_exhaustive] pub enum HintStatus { /// The broadcaster accepted the transaction. @@ -46,6 +61,7 @@ pub enum HintStatus { /// The broadcaster reports a double spend. DoubleSpend { /// The competing txids the broadcaster names. + #[serde(default, skip_serializing_if = "Vec::is_empty")] competitors: Vec, }, /// The broadcaster reports the transaction in its orphan mempool. @@ -64,9 +80,43 @@ pub enum HintStatus { /// hint's re-ask. [`Verdict::into_hint`] never produces it. MempoolPresent { /// The courier that answered the presence (the host's name for it). + /// Its stored form's field is `courier`. + #[serde(rename = "courier")] source: String, }, } +impl HintStatus { + /// Every kind's word, in declaration order, which is the order of the + /// compact form's status tags (tag `i` is `LABELS[i]`). A word never + /// changes and is never reused; a later minor only appends. + pub const LABELS: &'static [&'static str] = &[ + "accepted", + "seen", + "mined", + "stale_block", + "rejected", + "double_spend", + "orphan_mempool", + "unknown", + "mempool_present", + ]; + /// The kind's stable word, the payload not in it: `mined` for + /// `Mined { height: 900 }`. It is the `status` of the stored form. + #[must_use] + pub fn label(&self) -> &'static str { + match self { + Self::Accepted => "accepted", + Self::Seen => "seen", + Self::Mined { .. } => "mined", + Self::StaleBlock => "stale_block", + Self::Rejected { .. } => "rejected", + Self::DoubleSpend { .. } => "double_spend", + Self::OrphanMempool => "orphan_mempool", + Self::Unknown => "unknown", + Self::MempoolPresent { .. } => "mempool_present", + } + } +} /// An observed hint, carrying its source and host supplied time. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Hint { diff --git a/src/state.rs b/src/state.rs index d1bf457..6d4bb3d 100644 --- a/src/state.rs +++ b/src/state.rs @@ -195,6 +195,34 @@ pub enum Reask { /// The host is about to spend; recheck before it does. Spend, } +impl Reask { + /// Every kind's word, in declaration order, which is the order of the + /// compact form's re-ask tags (tag `i` is `LABELS[i]`). A word never + /// changes and is never reused; a later minor only appends. + pub const LABELS: &'static [&'static str] = &[ + "reorg", + "fork", + "hint", + "proof_failed", + "recheck", + "age", + "spend", + ]; + /// The kind's stable word, the payload not in it: `reorg` for + /// `Reorg { fork_height: 10 }`, `hint` for any `Hint(_)`. + #[must_use] + pub fn label(&self) -> &'static str { + match self { + Self::Reorg { .. } => "reorg", + Self::Fork { .. } => "fork", + Self::Hint(_) => "hint", + Self::ProofFailed { .. } => "proof_failed", + Self::Recheck => "recheck", + Self::Age => "age", + Self::Spend => "spend", + } + } +} /// Host selected scheduling parameters. #[derive(Clone, Debug, PartialEq, Eq)] pub struct Params { diff --git a/tests/labels.rs b/tests/labels.rs new file mode 100644 index 0000000..d01b5de --- /dev/null +++ b/tests/labels.rs @@ -0,0 +1,266 @@ +//! The kinds' words and the stored form of a hint status (the make-room pull +//! request of the rulings of 2026-11-17, bsv-stack-lean +//! `docs/DECISIONS-2026-10-19.md` 28.8.1 (c)): each kind's word, the two +//! lists in order, the serde form of every status as text, the refusals, and +//! the host's shape, read and written byte for byte as bsv-wallet-cli stores +//! its hints today. +// The lint bar binds the library; a test may unwrap, and its fixtures fail loudly +// (bsv-stack-lean #134). +#![allow( + clippy::pedantic, + clippy::unwrap_used, + clippy::expect_used, + clippy::panic +)] +use bsv_tracker::*; +use serde::{Deserialize, Serialize}; + +fn id() -> String { + "ab".repeat(32) +} + +/// Each status with its word and its stored form, in declaration order. +fn statuses() -> Vec<(HintStatus, &'static str, String)> { + vec![ + ( + HintStatus::Accepted, + "accepted", + r#"{"status":"accepted"}"#.into(), + ), + (HintStatus::Seen, "seen", r#"{"status":"seen"}"#.into()), + ( + HintStatus::Mined { height: 900 }, + "mined", + r#"{"status":"mined","height":900}"#.into(), + ), + ( + HintStatus::StaleBlock, + "stale_block", + r#"{"status":"stale_block"}"#.into(), + ), + ( + HintStatus::Rejected { reason: "r".into() }, + "rejected", + r#"{"status":"rejected","reason":"r"}"#.into(), + ), + ( + HintStatus::DoubleSpend { + competitors: vec![id()], + }, + "double_spend", + format!(r#"{{"status":"double_spend","competitors":["{}"]}}"#, id()), + ), + ( + HintStatus::DoubleSpend { + competitors: vec![], + }, + "double_spend", + r#"{"status":"double_spend"}"#.into(), + ), + ( + HintStatus::OrphanMempool, + "orphan_mempool", + r#"{"status":"orphan_mempool"}"#.into(), + ), + ( + HintStatus::Unknown, + "unknown", + r#"{"status":"unknown"}"#.into(), + ), + ( + HintStatus::MempoolPresent { source: "c".into() }, + "mempool_present", + r#"{"status":"mempool_present","courier":"c"}"#.into(), + ), + ] +} + +fn reasks() -> Vec<(Reask, &'static str)> { + vec![ + (Reask::Reorg { fork_height: 10 }, "reorg"), + (Reask::Fork { height: 10 }, "fork"), + (Reask::Hint(Hint::new("s", HintStatus::Accepted, 1)), "hint"), + (Reask::ProofFailed { height: 10 }, "proof_failed"), + (Reask::Recheck, "recheck"), + (Reask::Age, "age"), + (Reask::Spend, "spend"), + ] +} + +#[test] +fn every_kind_has_its_word() { + for (status, word, _) in statuses() { + assert_eq!(status.label(), word, "{status:?}"); + } + for (reask, word) in reasks() { + assert_eq!(reask.label(), word, "{reask:?}"); + } +} + +#[test] +fn the_lists_are_the_words_in_declaration_order() { + assert_eq!( + HintStatus::LABELS, + &[ + "accepted", + "seen", + "mined", + "stale_block", + "rejected", + "double_spend", + "orphan_mempool", + "unknown", + "mempool_present", + ] + ); + assert_eq!( + Reask::LABELS, + &[ + "reorg", + "fork", + "hint", + "proof_failed", + "recheck", + "age", + "spend" + ] + ); + let mut words: Vec<&str> = statuses().iter().map(|(_, w, _)| *w).collect(); + words.dedup(); + assert_eq!(words, HintStatus::LABELS); + let words: Vec<&str> = reasks().iter().map(|(_, w)| *w).collect(); + assert_eq!(words, Reask::LABELS); +} + +#[test] +fn every_status_round_trips_through_its_stored_form() { + for (status, word, text) in statuses() { + assert_eq!(serde_json::to_string(&status).unwrap(), text, "{word}"); + let back: HintStatus = serde_json::from_str(&text).unwrap(); + assert_eq!(back, status, "{word}"); + assert_eq!(serde_json::to_string(&back).unwrap(), text, "{word}"); + // The serde tag is the label. + let value: serde_json::Value = serde_json::from_str(&text).unwrap(); + assert_eq!(value["status"], status.label(), "{word}"); + } +} + +#[test] +fn a_word_this_release_does_not_know_and_a_missing_payload_are_refused() { + for text in [ + r#"{"status":"non_final"}"#, + r#"{"status":"mined"}"#, + r#"{"status":"mempool_present"}"#, + r#"{"status":"rejected"}"#, + r#"{"status":"Accepted"}"#, + r#"{"height":900}"#, + ] { + assert!( + serde_json::from_str::(text).is_err(), + "{text} must be refused, never read as unknown" + ); + } +} + +/// The host's shape: a hint's source, its status flattened beside it, and +/// its observed time, the keys in the order bsv-wallet-cli writes them. +#[derive(Debug, PartialEq, Serialize, Deserialize)] +struct HostHint { + source: String, + #[serde(flatten)] + status: HintStatus, + observed: Timestamp, +} + +/// bsv-wallet-cli's `StoredHint` and its `of`, copied from its beta line +/// (`src/tracker_host.rs:408-452` at 108f80e), so the texts below are what +/// that host has already stored. Its match gains the arm a host's sentence +/// asks for: a kind it does not name fails aloud. +#[derive(Serialize)] +struct CliStoredHint { + source: String, + status: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + height: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + reason: Option, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + competitors: Vec, + #[serde(default, skip_serializing_if = "Option::is_none")] + courier: Option, + observed: Timestamp, +} +impl CliStoredHint { + fn of(hint: &Hint) -> Self { + let mut courier = None; + let (status, height, reason, competitors) = match &hint.status { + HintStatus::Accepted => ("accepted", None, None, vec![]), + HintStatus::Seen => ("seen", None, None, vec![]), + HintStatus::Mined { height } => ("mined", Some(*height), None, vec![]), + HintStatus::StaleBlock => ("stale_block", None, None, vec![]), + HintStatus::Rejected { reason } => ("rejected", None, Some(reason.clone()), vec![]), + HintStatus::DoubleSpend { competitors } => { + ("double_spend", None, None, competitors.clone()) + } + HintStatus::OrphanMempool => ("orphan_mempool", None, None, vec![]), + HintStatus::Unknown => ("unknown", None, None, vec![]), + HintStatus::MempoolPresent { source } => { + courier = Some(source.clone()); + ("mempool_present", None, None, vec![]) + } + other => panic!("a kind the copy of the CLI's map does not name: {other:?}"), + }; + Self { + source: hint.source.clone(), + status: status.to_string(), + height, + reason, + competitors, + courier, + observed: hint.observed, + } + } +} + +#[test] +fn the_hosts_shape_reads_and_writes_the_rows_the_cli_has_stored() { + let rows = [ + r#"{"source":"arc","status":"accepted","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"seen","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"mined","height":900,"observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"stale_block","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"rejected","reason":"r","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"rejected","reason":"","observed":1700000000}"#.to_string(), + format!( + r#"{{"source":"arc","status":"double_spend","competitors":["{}"],"observed":1700000000}}"#, + id() + ), + r#"{"source":"arc","status":"double_spend","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"orphan_mempool","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"unknown","observed":1700000000}"#.to_string(), + r#"{"source":"arc","status":"mempool_present","courier":"c","observed":1700000000}"# + .to_string(), + ]; + let mut statuses: Vec = statuses().into_iter().map(|(s, _, _)| s).collect(); + statuses.insert(5, HintStatus::Rejected { reason: "".into() }); + assert_eq!(rows.len(), statuses.len()); + for (text, status) in rows.iter().zip(statuses) { + let hint = Hint::new("arc", status.clone(), 1_700_000_000); + // The row is the text the CLI writes for this hint. + assert_eq!( + &serde_json::to_string(&CliStoredHint::of(&hint)).unwrap(), + text + ); + // The host's shape reads it as the status, and writes it back unchanged. + let read: HostHint = serde_json::from_str(text).unwrap(); + assert_eq!(read.source, "arc"); + assert_eq!(read.status, status, "{text}"); + assert_eq!(read.observed, 1_700_000_000); + assert_eq!(&serde_json::to_string(&read).unwrap(), text); + } + // A row whose word this release does not know is refused in the shape too. + assert!(serde_json::from_str::( + r#"{"source":"arc","status":"non_final","observed":1}"# + ) + .is_err()); +} From 5cce54d672dad7d4338b11648ff96240a77737c9 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Tue, 17 Nov 2026 12:47:48 -0500 Subject: [PATCH 4/5] docs: the hosts' sentence for the kinds a later release adds README.md gains "Kinds a later release adds" between "Broadcaster hints" and "Events and records", and the rustdoc of Reask and of HintStatus carries the same sentence: a re-ask of a kind the host does not name is kept and surfaced by Reask::label, never dropped by a wildcard arm; a hint status is stored by its serde form and read back by it, never mapped by hand, and a status the reader refuses is surfaced, never read as HintStatus::Unknown. The words never change, are never reused, and a later minor only appends. Why: the sentence is the second of the ruling's three additions (bsv-stack-lean docs/DECISIONS-2026-10-19.md 28.8.1 (c), 2026-11-17 16:1xZ): without it the marks trade a compile error at a host's pin for a wrong answer at run time. Docs only; no code moves. Co-Authored-By: Claude Opus 5.5 --- README.md | 15 +++++++++++++++ src/hints.rs | 5 ++++- src/state.rs | 3 ++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a48e2ce..0f17daa 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,21 @@ Since 0.7.0 it moves `built` to `announced`, as an acceptance does: someone announced the transaction, and the same hint gives the same word whether or not this host did. It writes no chain word. +## Kinds a later release adds + +`HostAction`, `Reask`, `HintStatus`, `VerdictError` and `Verdict` are +`#[non_exhaustive]`: a later minor may add a kind, an error or a field, so a +host's match on one of the four enums carries a wildcard arm, and a host +builds a `Verdict` with `Verdict::new` and assigns its fields after it. That +arm keeps and surfaces what the host does not name. A re-ask of a kind the +host does not name is kept and surfaced by `Reask::label`, never dropped by a +wildcard arm. A hint status is stored by its serde form +(`{"status":"mined","height":900}`) and read back by it, never mapped by hand, +and a status the reader refuses is surfaced, never read as +`HintStatus::Unknown`. Each kind's word (`label`, and `LABELS` for every word +in declaration order, the compact form's tag order) never changes and is +never reused; a later minor only appends. + ## Events and records `docs/SPEC.md` records the specification relationship and diff --git a/src/hints.rs b/src/hints.rs index abcccf5..99fb6bf 100644 --- a/src/hints.rs +++ b/src/hints.rs @@ -6,7 +6,10 @@ use std::fmt; /// /// `#[non_exhaustive]` (the room made before 0.9.0, bsv-stack-lean /// `docs/DECISIONS-2026-10-19.md` 28.8.1 (c)): a later minor may add a kind, -/// so a host's match outside this crate carries a wildcard arm. +/// so a host's match outside this crate carries a wildcard arm. A hint status +/// is stored by its serde form and read back by it, never mapped by hand, and +/// a status the reader refuses is surfaced, never read as +/// [`HintStatus::Unknown`]. /// /// ```compile_fail,E0004 /// use bsv_tracker::HintStatus; diff --git a/src/state.rs b/src/state.rs index 6d4bb3d..87ecc91 100644 --- a/src/state.rs +++ b/src/state.rs @@ -146,7 +146,8 @@ pub enum Input { /// /// `#[non_exhaustive]` (bsv-stack-lean `docs/DECISIONS-2026-10-19.md` /// 28.8.1 (c)): a later minor may add a kind, so a host's match outside this -/// crate carries a wildcard arm. +/// crate carries a wildcard arm. A re-ask of a kind the host does not name is +/// kept and surfaced by [`Reask::label`], never dropped by a wildcard arm. /// /// ```compile_fail,E0004 /// use bsv_tracker::Reask; From 1d6141b45fc788eaa40776522d021cb65fede7c8 Mon Sep 17 00:00:00 2001 From: John Calhoun Date: Tue, 17 Nov 2026 12:48:22 -0500 Subject: [PATCH 5/5] changelog: Unreleased, the room made before 0.9.0 The lead paragraph (the rows of the rulings of 2026-11-17, bsv-stack-lean docs/DECISIONS-2026-10-19.md 28.8.1 (c); the five types non-exhaustive, so a host's exhaustive match on the four enums and a Verdict literal stop compiling; no behaviour moves and the compact bytes are unchanged, pinned by tests/compact_golden.rs), then Changed (the five marks), Added (Verdict::new, label and LABELS, the serde form of HintStatus, the tests) and Hosts (the wildcard arm that keeps and surfaces, Verdict::new for a literal, the stored form, and that bsv-wallet-cli's stored rows read as they are). Also one word of a test comment in src/compact.rs ("leading byte"), for the wording rule; no code moves. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 20 ++++++++++++++++++++ src/compact.rs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c8e4c2..5b3580d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ ## [Unreleased] +Room for the three rows of the rulings of 2026-11-17 (bsv-stack-lean `docs/RULINGS-2026-10-12.md`, 16:1xZ; `docs/DECISIONS-2026-10-19.md` 28.8.1 (c) with its three additions, and the keeper's reading of 17:1xZ for `VerdictError`): finality (#45), the status code (#46) and `conflicted` keeping its proof (#47) land after the 0.9.0 cut as minors, each behind its Lean, and none of them is built here. Five public types turn `#[non_exhaustive]`, so a host's exhaustive `match` on `HostAction`, `Reask`, `HintStatus` or `VerdictError`, and a `Verdict` built by literal, stop compiling: a break on this line, by the semver note of 0.3.0. No behaviour moves: every test of the base keeps its name and its answer, and the compact bytes are unchanged, pinned by `tests/compact_golden.rs`, which landed on the base before any other change. + +### Changed + +- `#[non_exhaustive]` on the enums `HostAction`, `Reask`, `HintStatus` and `VerdictError` and on the struct `Verdict`: the type alone, no variant marked, `Verdict`'s four fields still public to read and to assign. A `compile_fail` doctest on each pins the break (E0004 for a match outside the crate, E0639 for the literal). + +### Added + +- `Verdict::new(status)`: a verdict holding the word as given (not trimmed, not checked), with no height, no reason and no competitors; the fields are assigned after it, and `Verdict::from_arc_body` stays the checked reader. +- `HintStatus::label` and `Reask::label`: each kind's stable word, the payload not in it (`accepted`, `seen`, `mined`, `stale_block`, `rejected`, `double_spend`, `orphan_mempool`, `unknown`, `mempool_present`; `reorg`, `fork`, `hint`, `proof_failed`, `recheck`, `age`, `spend`). `HintStatus::LABELS` and `Reask::LABELS`: every word in declaration order, which is the compact form's tag order. A word never changes and is never reused; a later minor only appends. +- The serde form of `HintStatus`, the crate's stored form of a status: internally tagged by its word under `status`, the payload beside it as `height`, `reason`, `competitors` (left out when empty) and `courier` (`MempoolPresent`'s `source`), so `{"status":"mined","height":900}`. A word this release does not know, and a kind whose payload is missing, are refused, never read as `Unknown`. `Reask` has the words alone; `Hint`, `Verdict` and `HostAction` have no serde. +- Tests: `tests/compact_golden.rs` (the compact bytes of ten states that hold every word, a checked proof, every status with and without a verdict and every re-ask), `tests/labels.rs` (the words, both lists, every status's text round-tripped, the refusals, and the host's shape below), and two unit tests that `LABELS[i]` is the word of the kind the compact writer tags `i`. + +### Hosts + +- A match on `HostAction`, `Reask`, `HintStatus` or `VerdictError` gains a wildcard arm that keeps and surfaces what the host does not name: a re-ask by `Reask::label`, an error as the fault it is. Never an arm that maps to `HintStatus::Unknown` or drops the value. +- A `Verdict` built by literal becomes `Verdict::new(status)` with its other fields assigned after it. +- A host that stores hints stores the serde form of `HintStatus` and reads it back by it, never by a hand map, and surfaces a status the reader refuses. +- bsv-wallet-cli's stored rows read as they are: a struct with the status flattened between `source` and `observed` reads every text its `StoredHint::of` writes (beta at 108f80e) and writes it back identical (`tests/labels.rs`). Its pin of the next prerelease replaces its two hand maps with these words. + ## [0.9.0-beta.8] - 2026-11-17 ### Changed: the pin to bsv-rs 0.9.0-beta.8 diff --git a/src/compact.rs b/src/compact.rs index 75e17f3..21f073e 100644 --- a/src/compact.rs +++ b/src/compact.rs @@ -544,7 +544,7 @@ mod tests { use super::Writer; use crate::{Hint, HintStatus, Reask}; - /// The tag the compact writer gives a status, read from its first byte. + /// The tag the compact writer gives a status, read from its leading byte. fn status_tag(status: &HintStatus) -> usize { let mut w = Writer(Vec::new()); w.status(status);