feat(mail): select an explicit account for SendMessage #232

Merged
KofTwentyTwo merged 1 commits from story/m5-s3-send-account-selection into dev 2026-07-30 02:45:16 +00:00
KofTwentyTwo commented 2026-07-30 02:44:00 +00:00 (Migrated from github.com)

Summary

  • SendMessage previously always sent from the first configured account (resolve_sending_account) with no way to choose, silently sending from the wrong identity the moment a second account existed.
  • Adds optional string account_id = 7; to SendMessageRequest (additive, next unused field number). When set, resolves that specific account; a non-existent account_id fails with a new, distinct SendError::AccountNotFound(String) variant rather than a silent fallback. NoAccountConfigured stays reserved for "zero accounts exist". Omitting account_id preserves today's exact "first configured account" behavior.
  • Threads the selector through ComposeRequest, resolve_sending_account, send_message_for_account/send_message_with_injected_sender, the SendMessage gRPC handler, and a new nuncio-cli mail send --account <id> flag.
  • Regenerated the nuncio.v1 descriptor golden (crates/nuncio-proto/proto/nuncio/v1/descriptor.bin) per the contract-stability recipe; contract_stability::descriptor_matches_committed_golden passes.

Closes #196. Refs #170.

Tests

  • send.rs: new tests proving (a) two accounts + explicit account_id for the second sends from that account (From: assertion against MockMessageSender), and (b) an unknown account_id fails with SendError::AccountNotFound, never a silent fallback.
  • grpc.rs/spine_e2e_test.rs: existing SendMessage request literals updated to pass account_id: None, preserving current single/first-account behavior.
  • nuncio-cli/src/runner.rs: extended the existing mail send stub-daemon test to also exercise --account <id>, asserting the daemon receives the exact account_id over the wire.
  • Mail remains mounted behind its BearerAuthInterceptor (no mounting change); auth tests unaffected.
  • All mock-only (MockMessageSender / stub gRPC daemon); no live network.

Gate output

$ cargo fmt --all -- --check
(clean, no output)

$ cargo check-all
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.05s
(zero warnings)

$ cargo test-all
... 419 tests passed across the workspace; 0 failed; 0 ignored ...

Test plan

  • cargo fmt --all -- --check
  • cargo check-all (clippy --all-targets --workspace -D warnings, zero warnings)
  • cargo test-all (419 passed, 0 failed, 0 ignored)
  • contract_stability::descriptor_matches_committed_golden passes with the regenerated golden
## Summary - `SendMessage` previously always sent from the first configured account (`resolve_sending_account`) with no way to choose, silently sending from the wrong identity the moment a second account existed. - Adds `optional string account_id = 7;` to `SendMessageRequest` (additive, next unused field number). When set, resolves that specific account; a non-existent `account_id` fails with a new, distinct `SendError::AccountNotFound(String)` variant rather than a silent fallback. `NoAccountConfigured` stays reserved for "zero accounts exist". Omitting `account_id` preserves today's exact "first configured account" behavior. - Threads the selector through `ComposeRequest`, `resolve_sending_account`, `send_message_for_account`/`send_message_with_injected_sender`, the `SendMessage` gRPC handler, and a new `nuncio-cli mail send --account <id>` flag. - Regenerated the `nuncio.v1` descriptor golden (`crates/nuncio-proto/proto/nuncio/v1/descriptor.bin`) per the contract-stability recipe; `contract_stability::descriptor_matches_committed_golden` passes. Closes #196. Refs #170. ## Tests - `send.rs`: new tests proving (a) two accounts + explicit `account_id` for the second sends from that account (`From:` assertion against `MockMessageSender`), and (b) an unknown `account_id` fails with `SendError::AccountNotFound`, never a silent fallback. - `grpc.rs`/`spine_e2e_test.rs`: existing `SendMessage` request literals updated to pass `account_id: None`, preserving current single/first-account behavior. - `nuncio-cli/src/runner.rs`: extended the existing `mail send` stub-daemon test to also exercise `--account <id>`, asserting the daemon receives the exact `account_id` over the wire. - `Mail` remains mounted behind its `BearerAuthInterceptor` (no mounting change); auth tests unaffected. - All mock-only (`MockMessageSender` / stub gRPC daemon); no live network. ## Gate output ``` $ cargo fmt --all -- --check (clean, no output) $ cargo check-all Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.05s (zero warnings) $ cargo test-all ... 419 tests passed across the workspace; 0 failed; 0 ignored ... ``` ## Test plan - [x] `cargo fmt --all -- --check` - [x] `cargo check-all` (clippy `--all-targets --workspace -D warnings`, zero warnings) - [x] `cargo test-all` (419 passed, 0 failed, 0 ignored) - [x] `contract_stability::descriptor_matches_committed_golden` passes with the regenerated golden
Sign in to join this conversation.