Skip to content

ENG-3299: Add CorrespondenceMetadata model and table#7867

Draft
JadeCara wants to merge 8 commits intoENG-3299/enums-scopes-encryptionfrom
ENG-3299/correspondence-metadata
Draft

ENG-3299: Add CorrespondenceMetadata model and table#7867
JadeCara wants to merge 8 commits intoENG-3299/enums-scopes-encryptionfrom
ENG-3299/correspondence-metadata

Conversation

@JadeCara
Copy link
Copy Markdown
Contributor

@JadeCara JadeCara commented Apr 8, 2026

Ticket ENG-3299

Dependency: Requires #7866 to be merged first (stacked PR)

Description Of Changes

PR 2 of 2 for ENG-3299. Creates the CorrespondenceMetadata table with a 1:1 relationship to Comment for delivery tracking and email threading.

Table fields:

  • comment_id — FK to comment.id, UNIQUE (1:1), CASCADE delete
  • message_id — UNIQUE, indexed (idempotency key for deduplication)
  • in_reply_to — threading reference to parent message
  • reply_to_address — indexed for inbound routing
  • delivery_status — varchar with default pending (values: pending/sent/delivered/bounced/failed)
  • delivered_at, bounce_reason, sender_email, recipient_email

Design decision: delivery_status uses varchar (not a PG enum) to avoid cross-migration enum type dependencies. Validation happens at the Python model layer via CorrespondenceDeliveryStatus enum.

Code Changes

  • src/fides/api/models/comment.py — Added CorrespondenceMetadata model with 1:1 relationship to Comment
  • src/fides/api/db/base.py — Registered CorrespondenceMetadata for Alembic discovery
  • New migration: creates correspondence_metadata table with indexes and constraints

Steps to Confirm

  1. Run alembic upgrade head — verify table created
  2. Run alembic downgrade -1 then alembic upgrade head — verify full cycle
  3. Verify table schema: \d correspondence_metadata shows all columns, UNIQUE on comment_id and message_id, FK to comment.id with CASCADE
  4. Run pytest tests/ctl/models/test_comment.py — all pass

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change
    • Updates unreleased work already in Changelog, no new entry necessary
  • UX feedback:
    • All UX related changes have been reviewed by a designer
    • No UX review needed
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

JadeCara and others added 2 commits April 8, 2026 17:16
Create correspondence_metadata table (1:1 with comment) for delivery
tracking and threading. Fields: message_id (unique, idempotency key),
in_reply_to, reply_to_address, delivery_status, delivered_at,
bounce_reason, sender_email, recipient_email.

CASCADE delete from comment ensures cleanup. delivery_status uses
varchar (not PG enum) to avoid cross-migration enum dependencies.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
fides-plus-nightly Ignored Ignored Preview Apr 9, 2026 10:58pm
fides-privacy-center Ignored Ignored Apr 9, 2026 10:58pm

Request Review

JadeCara and others added 3 commits April 8, 2026 17:22
Tests the constraints the TLA+ spec relies on:
- message_id UNIQUE (idempotency guard)
- comment_id UNIQUE (1:1 relationship)
- CASCADE delete (PR deletion cleanup)
- Default delivery_status is "pending" (FSM initial state)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.09%. Comparing base (e5c7f63) to head (bb8a2d7).
⚠️ Report is 2 commits behind head on ENG-3299/enums-scopes-encryption.

Additional details and impacted files
@@                        Coverage Diff                        @@
##           ENG-3299/enums-scopes-encryption    #7867   +/-   ##
=================================================================
  Coverage                             85.08%   85.09%           
=================================================================
  Files                                   627      628    +1     
  Lines                                 40799    40821   +22     
  Branches                               4742     4742           
=================================================================
+ Hits                                  34714    34736   +22     
  Misses                                 5017     5017           
  Partials                               1068     1068           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant