feat(outbox): local chat retry queue — queue sends and retry with backoff #45
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/local-outbox"
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?
What
Replaces the "compose → send failed" cliff for chat with a persistent local outbox. When a friend's v3 onion cannot be dialed, the message is stored locally and retried by a background worker with exponential backoff until it is delivered, terminal-fails, or the process exits. Still peer-to-peer: no server, no store-and-forward relay, no new wire prefix. Each attempt is a fresh Noise IK handshake straight to
(friend.onion, 80), exactly the v1 one-shot session.This reverses the
no outbox / no retry queuelock for chat only, authorized on 2026-09-12. The "no hosted chat server / no store-and-forward relay" half of the lock stands.Threat-model delta (2 lines)
/wipeclears outbox rows with chat history.Both are written up in
docs/THREAT_MODEL.md("Local outbox (chat retry queue) is local, and it re-dials on a schedule").Design
src/outbox.rs(new):Outbox(store +Deliverer),ArtiDeliverer(the real transport), purebackoff_secs(),is_permanent_send_error(), background worker.Failed(reason). Schedule is a pure function asserted numerically by a unit test.spawn_flush_allinNode::start_with_passphrase), (c) that peer was just heard from (successful handshake inhandle_incoming, or a successfulconnect_onion()), which ignores the backoff for that friend's rows.flush_outbox()lets a UI thread kick (b) on demand.Node::send()now returnsResult<OutboxStatus, String>—Sent/Queued, instead ofErron transport failure. Status enum:Queued,Sending,Sent,Failed(String).Node::send()still returnsErrimmediately and nothing is queued.session::Error::into_message()reuses the canonicalfingerprint_mismatch_banner()string so the classifier cannot drift from the UI wording.message_id+friend_id+ attempts +next_attempt_at(absolute unix second, so scheduling survives restart) + status +last_error. The body is read back from the joinedmessagesrow, so it stays under that row's existing AEAD + AAD (owmsg1 || friend_id_le64 || dir || 0x00 || row_id_le64). The outbox table has no body column.Node::start_with_passphrasecallsOutbox::reset_stale()on unlock: a process killed mid-attempt leavessendingrows, which are requeued rather than stranded./wipedeletesoutboxrows first, then zeroes + deletesmessages(wipe_messages)./wipe-allremoves the dir, which takes the table with it.Deliberately not queued
src/file.rstransfers and payment/rcpframes stay fail-closed (send_once/try_send, one-shot, unchanged). Their chunk-level pacing/retry inside a live transfer is unchanged. No new frame prefix anywhere.Forced one-line change in a PR-#27-owned file
src/tui.rsis owned by open PR #27, butNode::send()'s return type change makes today'sOk(())arm not compile. The diff there is one arm (Ok(())→Ok(_)) plus a two-line comment; no UI surfacing is added (that is child cardt_d9a5b065). Expect a trivial conflict if both land — nothing worth resolving by hand beyond taking both sides. hotspot: src/tui.rs — signature change fromsend()forces one arm; the real UI work is t_d9a5b065.Evidence
New coverage in
tests/outbox.rs(all offline — the transport is a fake/flakyDeliverer, so no Tor needed):send_to_dead_onion_is_queued_and_row_persists— dead onion →Queued, row in the store, notErr.flaky_peer_is_flushed_by_the_worker_on_schedule— peer comes up later → worker flushes →Sent.backoff_schedule_doubles_from_30s_and_caps_at_30m— schedule asserted numerically, incl.u32::MAX(no shift overflow).max_attempts_reaches_failed_and_stops_retrying— terminalFailed, attempts stop.queued_message_survives_reopen_and_flushes_after_unlock— close + reopen the db, then flush.protocol_error_fails_immediately_and_is_not_queued— pinned-identity/protocol error → immediateErr, nothing queued.transport_errors_are_retryable_protocol_errors_are_not— the classifier.flush_friend_ignores_the_schedule_when_that_peer_was_seen— trigger (c).missing_prekey_is_fatal_not_queued.wipe_clears_outbox_rows—/wipepath.README (deferred)
README.mdis owned by open PR #38, so this PR does not touch it. Proposed replacement wording, for you to apply after #38 lands:Line ~115 (usage paragraph), replace:
with:
Line ~159, replace:
with:
Line ~167 ("never raw frames. No outbox, no resume, no images in the TUI.") →
never raw frames. No resume, no images in the TUI.Line ~312 ("Out of v1" list):
outbox→server-side outbox / store-and-forward relay, keeping the list otherwise as-is.ad59a171b3068b655c19Merge order 6 of 7: #38 -> #42 -> #41 -> #44 -> #43 -> #45 -> #46
Second of the core three. Two things to know before merging: (1) after #43 lands this needs one rebase — textual conflict in
docs/THREAT_MODEL.md, verified by a real merge simulation, not guessed; (2) it touchedsrc/tui.rs(a two-lineOk(_)compile fix at ~line 1366) although its card scoped that file away — reviewed as acceptable, and PR #27 has already merged, so the rebase onto main was clean.Note: Forgejo refuses a formal approval from this token ("approve your own pull is not allowed" — the PRs were pushed by account
sirius, which is also the token's user). This review records the sign-off and the merge position; a human approval click is still needed. Rebased onto currentmainbefore this review, diff verified byte-identical.N queuedfooter #48N queuedfooter #48068b655c19d6d157765aRebased onto
mainafter #43 / #44 landed — conflict resolveddocs/THREAT_MODEL.mdconflicted with the merged SQLCipher PR (#43), as predicted in the sign-off review. Resolution:sqlcipherstays removed (it shipped in #43) and the list now names a server-side outbox / store-and-forward relay, with the note that the local retry queue "never leaves the device".No other file conflicted.
src/store.rsauto-merged with the SQLCipher changes (outbox table + retry worker on top of thePRAGMA keypath) andcargo check --all-targetspasses locally on the rebased tree. Diff vsmainis now 9 files, this PR's own changes only.