# v399 — CORI Mail send-review and audit visibility hardening

Current baseline reviewed: v398.

v399 returns to product work after the documentation cleanup closeout. It hardens CORI Mail's approved-send review experience without moving settings or provider details into the CORI Mail surface.

## Decision

Continue the CORI Mail track before notification digest/email triggers.

Reason: v389 added guarded approved-send execution. v399 makes that execution easier for normal users to verify by showing plain send-review history, status summaries, and safe audit visibility.

## Product changes

- Added `/api/cori-mail/send-history`.
- Added a schema-backed send-review history reader in `CoriMailPersistenceService`.
- Expanded CORI Mail memory counts to include:
  - queued sends;
  - needs-attention sends;
  - sent sends;
  - approved/waiting sends;
  - failed sends.
- Added a new **Send review and audit** panel on `/cori/mail`.
- Added user-facing recent send-review records with:
  - simple status;
  - recipient;
  - subject;
  - reviewed/approved/sent timing;
  - plain explanation of what happened.
- Sanitized failure explanations so normal users see simple action-oriented wording instead of SMTP credentials, raw provider responses, or technical delivery logs.
- Refreshed send history after:
  - saving a draft;
  - opening send review;
  - approving/sending;
  - preparing work cards.

## Placement and safety

CORI Mail may show simple email readiness, send status, and audit visibility.

CORI Mail must not show:

- SMTP usernames or passwords;
- provider diagnostics;
- raw SMTP logs;
- raw delivery logs;
- credential fields;
- settings controls.

Provider setup remains in:

`/company/integrations`

## What changed in code

- `app/(dashboard)/cori/mail/page.tsx`
- `app/api/cori-mail/send-history/route.ts`
- `src/modules/cori-mail/cori-mail-persistence.service.ts`

## Prisma impact

No Prisma schema changes were made.

v399 uses existing `CoriMailSendAuditRecord` fields.

## Build validation

- Direct preflight script passed with no missing local imports:
  - `node scripts/dispatchspot-build-preflight.mjs`
- The sandbox `npm run dispatchspot:preflight` wrapper printed the same passing preflight output but did not return cleanly in this environment.
- Local Next build was not run in the sandbox because installed dependencies / `node_modules` are not included in the source package.

## Next recommendation

Proceed to notification digest/email trigger behavior, while keeping:

- notification preferences in Workspace Settings > Notifications;
- provider setup in Workspace Integrations;
- `/notifications` as alert/action-only.
