fix(sdk): surface Sent/Queued on send(), and build the SDK in CI
All checks were successful
ci / test (pull_request) Successful in 4m5s
ci / sdk (pull_request) Successful in 6m47s

`Node::send()` became `Result<OutboxStatus, String>` in the local-outbox work,
which broke `crates/onionwire-sdk` (E0308 at src/lib.rs:195) — and nothing
noticed, because the SDK is a separate cargo workspace that root CI never
compiles and android-release.yml only builds on a v*.*.* tag.

- `Wire::send()` now returns `WResult<SendState>` (`Sent` | `Queued`) instead
  of swallowing the outcome as `()`. A queued send is local-only until the
  retry worker gets a circuit through, so the Kotlin boundary must be able to
  tell it apart from a delivered one.
- `ChatMessage` gains `delivery: Option<String>` ("sent" | "queued" |
  "sending" | "failed: <reason>"), populated from the message's outbox row;
  `None` for incoming messages. An outgoing row with no outbox row was accepted
  on the first attempt, so it reads "sent".
- New `sdk` job in `.forgejo/workflows/ci.yml`: `cargo test --locked` +
  `cargo clippy --locked --all-targets -- -D warnings` in `crates/onionwire-sdk`
  in the same rust:1.91-bookworm container, with its own target volume (the SDK
  resolves the root crate with rustls, so sharing the root job's target dir
  would thrash feature-unified artifacts).
- Drift found while un-rotting it: the SDK `Cargo.lock` was stale (missing
  `sha2`, added to the root crate by the zeroize work), so `--locked` failed;
  and the SDK README still said "no outbox, no spool in v1" and "identity keys
  in sqlite are plaintext", both untrue since the outbox and SQLCipher landed.

Tests: crates/onionwire-sdk 4 passed (2 new unit tests over the status
mapping), clippy clean; root `cargo test --locked` clean. The CI job body was
smoke-run locally in the same container image before being committed.

# Conflicts:
#	crates/onionwire-sdk/src/lib.rs
This commit is contained in:
Hermes rust-dev 2026-09-12 15:16:38 -04:00 • committed by agent
commit 168727ac39
No known key found for this signature in database
20 changed files with 306 additions and 103 deletions

View file

@ -1,6 +1,6 @@
//! M6: typed-frame dispatcher — classify before append_message.
use onionwire::dispatch::{classify, Kind};
use onionwire::dispatch::{Kind, classify};
#[test]
fn chat_is_chat() {

View file

@ -5,11 +5,11 @@
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
use onionwire::Store;
use onionwire::outbox::{
BACKOFF_CAP_SECS, BACKOFF_START_SECS, BoxFut, Deliverer, Outbox, OutboxStatus, backoff_secs,
is_permanent_send_error,
};
use onionwire::Store;
const PASS: &str = "outbox-pass";
@ -96,9 +96,7 @@ fn backoff_schedule_doubles_from_30s_and_caps_at_30m() {
#[test]
fn transport_errors_are_retryable_protocol_errors_are_not() {
assert!(!is_permanent_send_error(
"connect abc.onion:80: timed out"
));
assert!(!is_permanent_send_error("connect abc.onion:80: timed out"));
assert!(!is_permanent_send_error("connect abc.onion:80: refused"));
assert!(is_permanent_send_error("fingerprint mismatch"));
assert!(is_permanent_send_error("frame too large"));
@ -114,7 +112,11 @@ async fn send_to_dead_onion_is_queued_and_row_persists() {
let ob = outbox(Arc::clone(&store), dead, 8);
let status = ob.send(&pk(1), b"hello dead peer").await.unwrap();
assert_eq!(status, OutboxStatus::Queued, "dead onion must queue, not Err");
assert_eq!(
status,
OutboxStatus::Queued,
"dead onion must queue, not Err"
);
assert!(!status.is_terminal());
let pending = ob.pending(&pk(1)).unwrap();
@ -122,7 +124,9 @@ async fn send_to_dead_onion_is_queued_and_row_persists() {
assert_eq!(pending[0].status, OutboxStatus::Queued);
assert_eq!(pending[0].attempts, 1, "the immediate attempt counted");
assert!(
ob.status_of_message(pending[0].message_id).unwrap().is_some(),
ob.status_of_message(pending[0].message_id)
.unwrap()
.is_some(),
"status is addressable by chat row id"
);
@ -253,7 +257,12 @@ async fn protocol_error_fails_immediately_and_is_not_queued() {
"protocol errors are never queued"
);
assert!(
store.lock().unwrap().list_messages(&pk(1)).unwrap().is_empty(),
store
.lock()
.unwrap()
.list_messages(&pk(1))
.unwrap()
.is_empty(),
"a failed protocol send is not written to history"
);
}

View file

@ -2,8 +2,8 @@
use std::sync::{Mutex, MutexGuard};
use onionwire::qr;
use onionwire::Store;
use onionwire::qr;
static ENV_LOCK: Mutex<()> = Mutex::new(());

View file

@ -1,7 +1,7 @@
//! Composer Enter must send chat to the selected friend, not only slash commands.
use onionwire::tui::{
composer_enter, take_job_result, ComposerAction, SlashCmd, WipeKind, TUI_POLL,
ComposerAction, SlashCmd, TUI_POLL, WipeKind, composer_enter, take_job_result,
};
use std::sync::mpsc;
use std::time::{Duration, Instant};

View file

@ -46,7 +46,11 @@ fn spawn_echo(
async fn launch_echo(
client: &Client,
nickname: &str,
) -> (Arc<RunningOnionService>, tokio::task::JoinHandle<()>, String) {
) -> (
Arc<RunningOnionService>,
tokio::task::JoinHandle<()>,
String,
) {
let launched = client
.launch_onion_service(hs::hs_config(nickname).expect("hs_config"))
.expect("launch_onion_service")
@ -66,7 +70,10 @@ async fn echo_ping(client: &Client, onion: &str) -> Result<(), String> {
.write_all(PING)
.await
.map_err(|e| format!("write ping: {e}"))?;
stream.flush().await.map_err(|e| format!("flush ping: {e}"))?;
stream
.flush()
.await
.map_err(|e| format!("flush ping: {e}"))?;
let mut buf = vec![0u8; PING.len()];
stream
.read_exact(&mut buf)

View file

@ -12,8 +12,8 @@
//! checkpoint, and the SDK's typed error after shutdown — runs in the normal
//! suite (`tests/hs.rs`, `src/node.rs`, `crates/onionwire-sdk/src/lib.rs`).
use onionwire::node::{FlushOutcome, Node};
use onionwire::hs::TorState;
use onionwire::node::{FlushOutcome, Node};
#[tokio::test(flavor = "multi_thread")]
#[ignore = "needs live Tor network"]
@ -93,4 +93,4 @@ async fn shutdown_stops_the_node_and_later_calls_are_typed_errors() {
home.join("onionwire.db").exists(),
"shutdown must not delete the store"
);
}
}

View file

@ -11,19 +11,19 @@
//! `chars().count()` width checks here match `tests/tui_chrome.rs` on purpose.
//! They are the known-wrong metric (see `chars_count_is_not_terminal_cells`).
use onionwire::FriendProfile;
use onionwire::qr;
use onionwire::tui::{
backup_screen_text, banner_for_width, compact_banner, draw_share, fingerprint_mismatch_banner,
help_overlay_text, main_footer_hints, onion_glyph, quit_screen_text, restore_screen_text,
rotate_screen_text, status_footer, who_overlay_text, wipe_screen_text, wordmark_banner,
ProfileEditor, WipeKind,
ProfileEditor, WipeKind, backup_screen_text, banner_for_width, compact_banner, draw_share,
fingerprint_mismatch_banner, help_overlay_text, main_footer_hints, onion_glyph,
quit_screen_text, restore_screen_text, rotate_screen_text, status_footer, who_overlay_text,
wipe_screen_text, wordmark_banner,
};
use onionwire::FriendProfile;
use ratatui::Frame;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
use ratatui::layout::{Constraint, Layout, Rect};
use ratatui::widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Wrap};
use ratatui::Frame;
use ratatui::Terminal;
const SIZES: [(u16, u16); 3] = [(80, 24), (120, 40), (200, 60)];
const FP: &str = "abcdef0123456789deadbeefcafebabe";

View file

@ -426,7 +426,14 @@ fn pending_row(
}
fn queued_row(message_id: i64, body: &str, attempts: u32, next_in: i64, now: i64) -> OutboxEntry {
pending_row(message_id, body, OutboxStatus::Queued, attempts, next_in, now)
pending_row(
message_id,
body,
OutboxStatus::Queued,
attempts,
next_in,
now,
)
}
fn sending_row(message_id: i64, body: &str, now: i64) -> OutboxEntry {
@ -549,7 +556,12 @@ fn delivery_markers_have_exercised_ascii_fallbacks() {
in_msg(5, "epsilon"),
];
let pending = vec![
failed_row(1, "alpha", "connect peer.onion:80: connection timed out", now),
failed_row(
1,
"alpha",
"connect peer.onion:80: connection timed out",
now,
),
queued_row(2, "beta", 1, 30, now),
sending_row(3, "gamma", now),
];

View file

@ -13,7 +13,6 @@ use tokio::net::TcpListener;
/// `ONIONWIRE_WALLET_NO_SPEND` is process-wide; tests that touch env serialize.
static ENV_LOCK: Mutex<()> = Mutex::new(());
fn row(txid: &str, amount: &str, address: &str) -> TransferRow {
TransferRow {
txid: txid.into(),
@ -321,10 +320,7 @@ async fn no_spend_mode_refuses_transfer_with_no_rpc_request() {
.await
.unwrap_err()
.to_string();
assert!(
err.to_ascii_lowercase().contains("view-only"),
"got {err}"
);
assert!(err.to_ascii_lowercase().contains("view-only"), "got {err}");
tokio::time::sleep(std::time::Duration::from_millis(200)).await;
let seen = log.lock().expect("log").clone();
assert!(seen.is_empty(), "no RPC request may be made: {seen:?}");

View file

@ -1,8 +1,8 @@
//! M5: wipe messages (keep identity + friends); wipe-all is a new person.
use onionwire::tui::{
parse_slash, quit_screen_text, wipe_screen_text, QuitDecision, QuitPrompt, WipeDecision,
WipeKind, WipePrompt,
QuitDecision, QuitPrompt, WipeDecision, WipeKind, WipePrompt, parse_slash, quit_screen_text,
wipe_screen_text,
};
use onionwire::{PaymentWrite, Store};

View file

@ -4,11 +4,11 @@
//! core dumps, OS `String` interning, `src/file.rs` + TUI buffers, and the
//! Noise handshake/transport state that lives inside `snow`.
use onionwire::Store;
use onionwire::backup::BackupKeys;
use onionwire::profile;
use onionwire::session::Keys;
use onionwire::wallet::Wallet;
use onionwire::Store;
use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing};
/// Type-level: the wrapper is applied to the type, not just mentioned in a