# Independent sender outbox

Source: https://usecns.dev/hippocampus-topic-independent-sender-outbox/

[Start here](https://usecns.dev/manual-hippocampus/)
[CLI commands](https://usecns.dev/commands-hippocampus/)
[Configuration & integration](https://usecns.dev/hippocampus-topics/)

`sender::Setup` fixes `destination: receiver::Identity`, origin, enrollment revision, `max_pending_bytes` (positive ≤64 MiB) and `max_rows` (positive ≤1024, including pending/accepted/cancelled jobs). It cannot reroute an existing root. `SyntheticSender::create_synthetic(root, setup)` requires a new private root; `open(root, &setup)` exclusively locks and audits exact original setup/evidence. No collector handles, source reread or retention leases are used.

`enqueue(&binding, body) -> Delivery` copies exact authorized validated synthetic Pi envelope bytes. Same key/exact bytes is idempotent even at capacity; differing full bytes conflict; cancelled episode refuses. `lookup(&binding) -> Option<Delivery>` reports `State::{Pending, Accepted, Cancelled}`, optional original `historical_receipt` and `receipt_verification: Option<ReceiptVerification>` under current local trust. Pending without a receipt has no verdict.

`attempt(&binding, callback) -> Delivery` invokes `FnOnce(&Binding, metadata_bytes, body_bytes) -> Result<Vec<u8>, ()>` exactly once for pending work. It constructs matching metadata from immutable saved bytes. Callback error/lost reply or invalid receipt leaves those bytes pending; remote acceptance may already have occurred. A matching receipt must verify as `Trusted` under the sender's durable receipt policy **read after the callback**, plus exact scope/bytes, generation and synthetic profile, before receipt journaling and body reclamation commit in **one transaction**. Accepted jobs return saved receipt without callback/reconnection even if its current verdict becomes `Compromised`; they never resurrect payload or resend.

For a local callback use `receiver.accept(b, metadata, body, trusted_now_ms).map(|a| a.historical_receipt).map_err(|_| ())` (see `tests/sender.rs:54–63`). For HTTPS, call `client.send(b, metadata, body).map_err(|_| ())`. To reconcile without upload, return `client.lookup(b, metadata, body)`'s historical receipt from the callback, mapping `None`/error to `Err(())`; never treat absence as acceptance or trigger implicit PUT. Receiver disposition is separate from the sender's historical acceptance state.

`cancel_episode(episode)` atomically fences future enqueue/attempt and drops pending copies without receiver access, even at payload/job capacity. Separate fence reserve covers 1024 unknown episodes plus recorded job episodes. It preserves any historical receipt; cancellation cannot recall bytes already transmitted. No unsuppress, automatic retry, coherent backup rollback protection, export or migration API exists.

`SenderError`: `InvalidSetup`, `InvalidRoot`, `Locked`, `Denied`, `InvalidArchive`, `Conflict`, `Quota`, `Cancelled`, `Missing`, `Transport`, `InvalidReceipt`, `Integrity`, `Storage`. Errors are content-free and callback details are not wrapped. Transport/invalid-receipt failures do not justify deletion; conflicts/integrity require investigation.