fix(sdk): send() returns SendState (Sent|Queued), and build the SDK in CI #51
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_9a29fd3c"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
crates/onionwire-sdkhas not compiled since the outbox work (Node::send()->Result<OutboxStatus, String>, PR #45): E0308 atcrates/onionwire-sdk/src/lib.rs:195. Root CI never compiled the crate (separate cargo workspace) andandroid-release.ymlonly builds it on av*.*.*tag, so a release would have shipped a broken AAR. This PR is the fix plus the CI job that makes the rot impossible.Send shape (SDK is the consumer boundary)
Wire::send()now returnsWResult<SendState>, andSendStateis a UniFFI enum -> Kotlinenum class SendState { SENT, QUEUED }:ChatMessagegainsdelivery: String?="sent" | "queued" | "sending" | "failed: <reason>"for outgoing rows (read from the message's outbox row),nullfor incoming. An outgoing row with no outbox row was accepted on the first attempt, so it reads"sent". Both are documented and verified against real generated UniFFI output, not hand-written from memory.Drift found (item 2)
crates/onionwire-sdk/Cargo.lockwas stale: the root crate gainedsha2(zeroize work) and the SDK lock did not list it, socargo build --lockedfailed with "cannot update the lock file ... because --locked was passed". Updated here; the new CI job runs--locked, which is what caught it.crates/onionwire-sdk/README.mdstill documented "Fail closed: peer onion down -> the send fails. No outbox, no spool in v1", "a send retries the peer for up to 3 minutes before failing", and "identity keys in sqlite are plaintext". All three are untrue now (outbox, SQLCipher). Rewritten against the actual API.rusqlitefeature change, so no NDK rebuild was required: the SDK host build compiles vendored OpenSSL since SQLCipher landed, and the new job exercises that on every PR.CI
New
sdkjob in.forgejo/workflows/ci.yml, samedockerrunner label and sameonionwire-ci-piconcurrency group so it cannot overlap the root job:cargo test --locked && cargo clippy --locked --all-targets -- -D warningsincrates/onionwire-sdk, samerust:1.91-bookwormcontainer, with its own target volume (the SDK resolves the root crate withrustls, so sharing the root job's target dir would thrash both jobs' feature-unified artifacts). The job body was smoke-run locally in the same image before pushing.Verification
cargo buildin the SDK reproduced the card's E0308; the two new unit tests failed to compile against the missing mapping (cannot find function send_state).crates/onionwire-sdk:cargo test4 passed / 0 failed (2 new),cargo clippy --all-targets -- -D warningsexit 0.cargo test --lockedexit 0, 0 failed.Stack / merge order
Based on
feat/tui-msgid-join(PR #50) because it consumesstore::Message::idand the outbox API from #45. Merge order: #45 -> #48 -> #50 -> this. Forgejo reportsmergeable: falseagainstmainuntil those land - that is the stack, not a conflict.Left out of scope on purpose (follow-up card filed):
android/app's Compose UI still says "Sends fail closed ... There is no outbox in v1." andWireViewModel.send()drops the returnedSendState. Kotlin-facing, so it belongs with the app, not this crate.N queuedfooter`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.queued (try 3/8, retry 45s)from the SDK outbox rows #59queued (try 3/8, retry 45s)from the SDK outbox rows #5908a4accf370de5f7b2200de5f7b220168727ac39168727ac39381f424733The SDK has returned `SendState` and a per-row `ChatMessage.delivery` since the local outbox landed, but the app still said "there is no outbox in v1" and threw the state away. - `WireViewModel.send()` returns `SendState`; `ChatScreen` no longer discards it. A `QUEUED` send raises a "local-only until the retry worker gets a circuit through" hint instead of pretending success. - Outgoing rows render the TUI's delivery markers from `ChatMessage.delivery` (`✓` / `◷ queued` / `» sending` / `✗ failed: <reason>`), plus the TUI's `{n} queued` footer while the outbox still owns rows. Incoming rows stay unmarked; an unreadable state renders no marker rather than a tick. - The empty-chat copy describes the outbox (8 attempts, backoff capped at 30 min, local-only until it lands) instead of denying it exists. - New pure `Delivery.kt` so the vocabulary is unit-testable without a device. Verified: `./gradlew :app:assembleDebug :app:testDebugUnitTest` → BUILD SUCCESSFUL, 15 tests / 0 failures (10 new), APK contains the new copy and no longer the "There is no outbox" string. Stacked on the SDK fix (PR #51).6867a6c4306796f861e06796f861e0f2dcd79d5cThe TUI can say why a queued row is still queued ('queued (try n/8, retry 45s)') because it reads OutboxEntry::attempts and next_attempt_at directly. The SDK exposed neither: ChatMessage.delivery is a flat 'queued'/'sending'/'failed: <reason>' string and Wire had no outbox accessor, so an Android chat row could only invent a countdown. Adds OutboxRow { message_id, status, attempts, next_attempt_at, last_error } and Wire::outbox(pubkey_hex) over Node::outbox_pending, plus outbox_max_attempts() so the client renders 'try n/8' against the core's own budget instead of a hardcoded 8. Additive: Wire::send() and ChatMessage.delivery are untouched. # Conflicts: # crates/onionwire-sdk/src/lib.rsqueued (try 3/8, retry 45s)from the SDK's outbox rows