Commit Graph
44 Commits
Author SHA1 Message Date
james.maesandJames Maes 4b73d11754 feat(mail): select an explicit account for SendMessage (#232)
SendMessage previously always sent from the first configured account
with no way to choose, so it silently used the wrong identity the
moment a second account existed. Add an optional account_id field to
SendMessageRequest; when set, resolve that specific account and fail
with a new AccountNotFound error if it does not exist, rather than
falling back to a different account. Omitting account_id preserves
the prior first-account behavior. Thread the selector through
ComposeRequest, resolve_sending_account, the CLI's mail send --account
flag, and regenerate the nuncio.v1 descriptor golden.

Refs #196, #170

Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-29 21:45:16 -05:00
james.maesandJames Maes 0b8307a268 M5: Account lifecycle over gRPC (edit/delete/test) + persist TLS mode (#230)
* feat(store): persist per-account IMAP/SMTP TLS modes; add account CRUD

Adds a backfill-safe imap_tls_mode/smtp_tls_mode column migration,
binds+reads both modes in save_account/list_accounts (previously
validated then silently discarded and hardcoded back to ImplicitTls),
and adds get_account/delete_account. Regression test proves the modes
survive a save/list/get round-trip.

Refs #194 #182

* feat(mail): branch IMAP/SMTP transport on TlsMode; add connection probes

Threads TlsMode through ImapEngine/ImapDualSocketManager and
SmtpTransportEngine so implicit TLS, STARTTLS, and plain are genuine
transport paths (a unified MailStream plus a real IMAP STARTTLS
negotiation), not validate-and-discard. Adds bounded connect timeout
and per-engine probe_connection backing TestAccountConnection, with
mock/loopback-only setup tests for each mode.

Refs #194 #182

* feat(accounts): edit/delete/test account lifecycle over gRPC

Implements Accounts UpdateAccount/RemoveAccount/TestAccountConnection in
the daemon (update mirrors add_account's keyring rollback discipline;
test probes real IMAP+SMTP via an injectable tester, honoring persisted
TLS modes), wires the configured TLS modes into build_mail_backend/
build_smtp_sender, and replaces the fabricated CLI account
show/edit/delete/test handlers with real thin gRPC clients. Adds an
offline full-daemon lifecycle E2E and unauth-rejection coverage for all
three new RPCs.

Refs #194 #182

* fix(accounts): restore prior credential on update rollback

A password rotation that fails to persist previously deleted the
just-written secret, destroying the working credential the key already
held and orphaning the still-present account row. Snapshot the prior
secret first and restore it on save failure (falling back to delete
only when none existed). Regression tests force save_account to fail
and assert the original secret survives.

Refs #194 #182

* docs(accounts): scope TestAccountConnection SMTP claim to reachability

The SMTP leg only dials and negotiates TLS/STARTTLS; it performs no AUTH
(lettre exposes no clean auth-only probe on AsyncSmtpTransport), while
IMAP genuinely logs in. Clarify the proto doc for smtp_ok/smtp_error and
the CLI output wording so nothing implies SMTP authentication was
verified. Doc-only proto change; golden unchanged.

Refs #194 #182

---------

Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-29 20:57:55 -05:00
james.maesandJames Maes 2e9c43a32c feat(filter): add streaming Filters.Triage RPC for retroactive rescan (#226)
Adds a server-streaming Triage RPC that walks the whole message store
in bounded keyset chunks, evaluates the live FilterEngine against each
message via the shared apply_filter_actions helper, and streams real
cumulative progress -- so the active rule set can be applied to mail
synced before those rules existed. Wires the CLI's first streaming-RPC
consumer (filter triage) and regenerates the proto contract golden.

Refs #193

Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-29 19:54:30 -05:00
james.maesandJames Maes 6cb8ae5753 feat(filter): move edit/export/import/logs onto Filters gRPC service (#224)
Adds UpdateRule/ExportRules/ImportRules/GetExecutionLogs to the
authenticated Filters gRPC service and rewires the CLI's
filter edit/export/import/logs subcommands onto it, replacing their
throwaway ephemeral local-db reads with the daemon's real, persistent
store and live FilterEngine. ImportRules now reports per-line parse
failures instead of silently dropping them.

Regenerates the nuncio-proto contract-stability golden for the
additive proto changes.

Refs #192

Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-29 19:37:19 -05:00
james.maesandJames Maes 174c5457f4 feat(contacts): add Contacts gRPC vertical (proto, daemon, CLI, E2E) (#218)
Publish the M2-S1 contacts engine over the daemon's authenticated gRPC
API, mirroring the Calendar vertical: add nuncio.v1.Contacts (Sync,
ListContacts, GetContact, CreateContact) plus Contact/ContactEmail/
ContactPhone messages to the proto contract and regenerate the golden
descriptor.

Wire ContactsEngineOverrides + ContactsGrpcService into nunciod,
mounted behind its own BearerAuthInterceptor exactly like every other
service. ListContacts/GetContact always read genuinely persisted data
from DatabaseEngine; Sync fetches from an injected ContactsBackend
(MockContactsBackend in tests) and persists via
contacts_sync::sync_with_backend, mirroring calendar_sync.rs; with no
backend injected, production Sync returns an honest error since
AccountConfig carries no per-account CardDAV configuration yet.

Add connect_contacts/AuthenticatedContactsClient to nuncio-proto's
shared client helpers. Replace the CLI's Commands::Contact handlers
(previously a disposable in-memory ContactsDatabase.in_memory() per
invocation) with real gRPC calls against the daemon, so a contact
added via `contact add` persists and is visible to a later, separate
CLI invocation.

Deviations from the issue's literal proto sketch, flagged for review:
- Added CreateContact (not in the issue's message list): the
  acceptance criteria requires `contact add` to persist a locally-
  authored contact across CLI invocations, but the daemon has no
  per-account CardDAV credential to write back to a real server. This
  RPC only ever writes to the daemon's own local store -- never a
  fabricated CardDAV write-back -- which is the same honest-surface
  spirit as Calendar's "no create/delete" note (that note is about not
  pretending to write to the remote server, not about never
  persisting locally-authored data at all).
- ListContacts/CreateContact take a required account_id (the issue
  sketched a bare ListContactsRequest{}), because the real
  DatabaseEngine::list_contacts/save_contact are account-scoped;
  ContactSubcommand::List/Search/Add/Sync now all take --account to
  match.
- Contact search has no server-side RPC; `contact search` fetches the
  full ListContacts result and filters client-side by display name,
  organization, and email.
- Contact's created_at/updated_at/last_interacted_at are omitted from
  the proto message -- no client use case identified for them yet.

Full-daemon offline E2E (contacts_e2e_test.rs) proves Sync -> List/Get
over the authenticated API, CreateContact's persistence surviving a
second, independent client connection, and an unauthenticated call
rejected with Code::Unauthenticated.

Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-29 18:23:32 -05:00
james.maesandJames Maes f926d09839 feat(calendar): add Calendar gRPC vertical (proto, daemon, CLI, E2E) (#214)
Wire the orphaned nuncio-cal engine into nunciod as a real, authenticated
gRPC vertical mirroring Mail: add service Calendar (Sync/ListEvents/GetEvent)
to nuncio.proto with a regenerated descriptor golden, connect_calendar in
nuncio-proto's client, calendar_sync::sync_with_backend plus
CalendarEngineOverrides/CalendarGrpcService mounted behind its own
BearerAuthInterceptor in nunciod::grpc, and real `cal sync`/`cal list` gRPC
clients in nuncio-cli replacing the fabricated CLI output. ListEvents/GetEvent
always read genuinely persisted data; production Sync returns an honest error
since there is no persisted per-account CalDAV configuration yet, and only an
injected MockCalendarBackend exercises a working Sync. Adds unit, daemon
integration, and offline full-daemon E2E tests, including an
unauthenticated-call-rejected assertion for the new service.

Refs #185

Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-29 17:19:15 -05:00
James Maes e890746633 fix(nunciod): keep ephemeral test-db TempDir alive for its user's lifetime
Several gRPC test helpers created an ephemeral sqlite-backed
DatabaseEngine via connect_ephemeral() and then discarded the
returned TempDir guard before returning the still-live db/server to
the caller. Dropping the guard unlinks the directory backing the
sqlite file; on Windows the still-open file handle keeps the data
reachable (masking the bug locally), but on Linux the directory entry
disappears immediately, so any pool connection opened afterward fails
with "unable to open database file" -- exactly the flake CI hit in
nunciod::grpc::tests::preview_rule_dry_runs_against_a_stored_message_without_persisting.

Fixes the same pattern in nunciod::grpc's spawn_test_server and
spawn_filters_test_server helpers, nuncio-cli's HeadlessRunner
(ephemeral_with), and grpc_auth_test's start_server: each now returns
(or stores) the TempDir so it stays alive for as long as its caller
keeps using the database.
2026-07-29 11:03:40 -05:00
James Maes 6ead680c12 refactor: remove the legacy JSON-RPC IPC; daemon serves gRPC only
Delete nuncio-core::ipc (IpcDaemonServer, IpcClient, framing, protocol -- the
demux-race transport), the daemon's :9422 boot + JSON-RPC handler, the stubbed
'nuncio-cli daemon' subcommand, and the IPC-transport test (gRPC coverage
already exists). The daemon now awaits nunciod::grpc::serve as its foreground
task; DB/keyring/sync/outbox/update remain background tasks.

Refs #173
2026-07-27 07:45:06 -05:00
James Maes b073fa6a7d style: comments state intent, not backlog/issue/phase references
Reword ~190 source comments and user-facing strings across crates/ to explain
the code's intent/constraints instead of citing story numbers, GH issues, or
roadmap phases (that traceability lives in git history + docs). Kept RFC and
technical rationale; changed no logic. Enforces the CLAUDE.md comment convention.
2026-07-27 07:32:20 -05:00
James Maes 739cf43d97 fix(cli): 'account list' shows per-account details, not just the count
The plain-text (non --json) listing printed only 'N account(s) registered'; it
now lists each account's id, name, email, IMAP/SMTP endpoints, and TLS. The
--json output already carried the fields. Test asserts the details appear in
plain output.
2026-07-27 07:11:13 -05:00
James Maes 7053d79f6b feat(grpc): Export + Audit services over authenticated gRPC
Add authenticated Export (ExportMailbox -> mbox/eml-zip/json/jsonl written to a
local file, backed by the real ExportEngine + a scoped message query) and Audit
(ListRecords, VerifyChain over the WORM ledger with a structured report) gRPC
services, each mounted with the bearer interceptor like the others. Wire CLI
'mail export' and 'system audit list/verify'. Audit records expose the record
MAC, never the signing key. Offline tests cover export content/counts, chain
verify (intact + tampered), and auth rejection.

Refs #172
2026-07-27 07:09:06 -05:00
James Maes c7a73afcd0 feat(grpc): Filters gRPC service (create/list/delete/validate/preview)
Add an authenticated Filters service backed by the NSQL engine + store:
CreateRule/DeleteRule persist and hot-reload the live FilterEngine (ArcSwap);
ValidateRule returns an honest valid/error verdict without failing the RPC;
PreviewRule dry-runs a candidate (unsaved) rule against stored mail. Mounted
with the bearer interceptor like the other services (auth-rejection tested).
Wire CLI filter create/list/delete/validate/test to it; the shared filter_engine
instance is reused by both the gRPC path and the legacy filter.* handler during
the transition. filter edit/export/import/logs stay local for now (tracked).

Refs #171
2026-07-27 05:38:33 -05:00
James Maes dd10eda5f3 test(e2e): full offline mail-spine E2E + injectable engine seam + Sync RPC
Add MailEngineOverrides so tests inject MockMailBackend/MockMessageSender into a
live daemon without production depending on mocks (default = real engines). Add
an authenticated Mail.Sync RPC (awaits completion) and wire CLI 'mail sync' to
it, off the ephemeral runner. New spine_e2e_test drives the whole spine over
gRPC offline: AddAccount -> Sync -> ListMessages/GetMessage -> MarkRead (with
MessageFlagsChanged on Subscribe) -> SendMessage (captured by the mock sender).

Refs #161
2026-07-27 01:26:26 -05:00
James Maes 03cbd68d49 feat(grpc): real SMTP send + separate account SMTP endpoint
Add the outbound path: authenticated Mail.SendMessage builds an SMTP transport
from the account's SMTP endpoint + keyring password and sends via
SmtpTransportEngine -- honest success/failure, never fabricated. New
MessageSender trait (production SmtpTransportEngine; MockMessageSender for tests)
mirrors the sync MailBackend seam. #168: AccountConfig gains smtp_host/smtp_port
via a backfill-safe accounts migration (old rows fall back to the IMAP
host/port); proto + CLI now persist the SMTP endpoint instead of dropping it.
CLI 'mail send' is a real gRPC client; the fabricated 'Message sent' output is
gone. Tests prove the exact message reaches a mock transport and failures
surface honestly (no live network).

Refs #160 #168
2026-07-27 01:01:46 -05:00
James Maes aa1b6c0ce5 feat(grpc): mail read path over authenticated gRPC (list/read/mark/search)
Add an authenticated Mail service (ListFolders, ListMessages, GetMessage,
MarkRead, SearchMessages), mounted with the bearer interceptor like
System/Accounts. Backed by DatabaseEngine read methods + a new set_message_read;
GetMessage returns the decrypted body; MarkRead persists then emits
MessageFlagsChanged (so it streams via Subscribe). Wire nuncio-cli
mail list/read/mark/search + folder list off the ephemeral runner onto the
daemon over gRPC, with honest errors when the daemon is unreachable. Offline
E2E round-trips all RPCs and proves mark-read persistence + streaming.

Refs #159
2026-07-27 00:24:22 -05:00
James Maes 515e09c7b9 feat(grpc): persistent account management with keyring-only credentials
Add an authenticated Accounts gRPC service (AddAccount/ListAccounts), mounted
with the same bearer interceptor as System (every service authenticated). The
daemon now uses a persistent DB (~/.nuncio/nuncio.db; was ephemeral temp_dir)
and stores account passwords ONLY in the OS keyring -- never in SQLite, logs,
Debug/Serialize output, or the ListAccounts response (CLI PasswordArg redacts;
rpassword prompt, no echo). Wire nuncio-cli account add/list to the daemon over
gRPC. Tests prove persistence across restart and credential secrecy.
Security-reviewed, APPROVED.

Refs #156 #157
2026-07-26 23:36:00 -05:00
James Maes e0a77a4862 feat(grpc): add authenticated Subscribe event stream (push channel)
Add System.Subscribe server-streaming RPC on the authenticated System service,
mapping every CoreEvent variant to a nuncio.v1.Event oneof. The daemon streams
live EventBus broadcasts (skip-on-lag with a warning; clean close when the bus
drops). Add a client subscribe helper in nuncio-proto. Regression test proves
20 concurrent unary GetStatus calls and 20 streamed events arrive uncorrupted
and in order -- the property the old hand-rolled JSON-RPC IPC demux lacked.

Refs #151
2026-07-26 22:18:32 -05:00
James Maes d8b962d499 feat(grpc): CLI 'system status' round-trips to the daemon over gRPC
Move the gRPC address resolver and add an authenticated client helper
(connect_system + BearerTokenInterceptor) into the shared nuncio-proto crate so
client shells never depend on the nunciod binary. Wire nuncio-cli's system
status to query the live daemon over gRPC (token from an injectable OS keyring),
printing real status or an honest error when unreachable. Refactor nunciod to
reuse the shared addr items. Reconcile tests to assert the real gRPC round-trip
instead of local ephemeral state.

Refs #150
2026-07-26 22:06:10 -05:00
James Maes 4f3b2a609d chore: adopt working baseline and green all quality gates
Adopt the previously-uncommitted working-tree edits (audited state) as the
baseline. Fix real clippy lints properly (manual_strip -> strip_prefix,
let-else for infallible hardcoded regex/HMAC constructors, type aliases for
complex tuples); convert user-reachable CLI/daemon unwrap/expect to graceful
errors; allow unwrap/expect/panic in test code per project convention.

Quarantine one flaky recovery test (corruption-detection/close race) with an
explicit #[ignore] + tracking (GH #155, Phase 1.B). fmt, clippy (-D warnings,
all targets), and the full suite pass.
2026-07-26 19:56:05 -05:00
James Maes 74ced8e11a feat(contacts): design and implement dedicated nuncio-contacts crate with CardDAV sync, FTS5 trigram search, and pure CLI subcommands 2026-07-23 15:15:45 -05:00
James Maes bef2fca246 fix(cli): handle save_account error explicitly in handle_add_account 2026-07-23 13:01:21 -05:00
James Maes 2119f2c6c6 feat(telemetry): add DaemonTelemetry entity, cross-platform auto-update engine, and webhook HMAC integration tests 2026-07-23 12:49:10 -05:00
James Maes 646e4faa84 feat(filter,store,nunciod): fully implement Epic 8 (NSQL Filter Engine) and Epic 9 (Database Self-Healing Recovery) 2026-07-23 12:00:57 -05:00
James Maes dc30056fa0 feat(parity): enforce 1:1 account management parity across CLI, TUI, GUI, and MCP 2026-07-23 11:16:44 -05:00
James Maes 0974277c80 docs(licenses): add THIRD_PARTY_LICENSES.md and third-party library acknowledgments across CLI, TUI, GUI, and MCP 2026-07-23 10:55:59 -05:00
James Maes b617deb1e5 fix(cli,tui): enforce 100% mathematically aligned vertical borders across CLI and TUI splash screen banners 2026-07-23 10:52:43 -05:00
James Maes af1365ab7e feat(cli,tui): add brand splash screen banner with ASCII art logo, Latin etymology, and 4-shell highlights 2026-07-23 10:49:53 -05:00
James Maes b292c5ae45 feat(cli): add nuncio daemon subcommand for launching centralized background server 2026-07-23 08:11:38 -05:00
James Maes a5dfb7c38e feat(cli): persist AccountConfig to SQLite DB in handle_add_account 2026-07-22 21:30:29 -05:00
James Maes 3c4d26355a style(cli): format cli_system_test.rs with rustfmt 2026-07-22 21:17:20 -05:00
James Maes fc2af50faf feat(tests): add comprehensive system test suites for CLI, TUI, and GUI presentation shells 2026-07-22 21:13:44 -05:00
James Maes b6e943b711 style(workspace): format all crates with rustfmt for 100% CI compliance 2026-07-22 20:46:25 -05:00
James Maes 3d81f6882a feat(cli): enforce pure Noun + Verb command structure with verbose logging and clap help annotations 2026-07-22 20:44:16 -05:00
James Maes a13fdbb7be feat(cli): standardize Noun + Verb command tree structure across CLI, core IPC, and documentation 2026-07-22 20:42:10 -05:00
James Maes e8ae7b3ad9 fix(workspace): resolve all clippy lints, trait imports, and dead-code warnings for clean local build 2026-07-22 20:38:08 -05:00
James Maes ca5e8149b9 feat(store): add multi-account database schema and CLI account switching commands 2026-07-22 20:22:55 -05:00
James Maes aff8543992 feat(config): add TlsMode support for ImplicitTls, StartTls, and Plain unencrypted protocols 2026-07-22 20:07:32 -05:00
James Maes 21c81d75c2 feat(cli): add AddAccount subcommand with secure password entry and SSL defaults 2026-07-22 20:06:13 -05:00
James Maes fa2b88f648 feat(cli): add live folder listing and message reading commands 2026-07-22 20:02:20 -05:00
James Maes 7b45cc2b9e style(compiler): enforce workspace-level strict lints and forbid unsafe code 2026-07-22 19:55:32 -05:00
james.maesandJames Maes a510117c97 feat(cli): add HeadlessRunner integrating EventBus and DatabaseEngine (#51)
Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-22 19:51:13 -05:00
james.maesandJames Maes 10e7a87c34 feat(cli): add JsonResponse machine output formatter and pipeline helpers (#50)
Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-22 19:50:55 -05:00
james.maesandJames Maes 88356d3208 feat(cli): add Clap subcommand hierarchy and global argument flags (#49)
Co-authored-by: James Maes <jmaes@dmdbrands.com>
2026-07-22 19:50:35 -05:00
James Maes a869e3510e feat: add nuncio-cli command line interface crate 2026-07-22 18:59:24 -05:00