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

@ -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"
);
}