Remove email post-drop legacy infrastructure - #1216
Conversation
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
📝 WalkthroughWalkthroughThe PR removes the mailbox legacy-graph pre-drop backup workflow, approval contracts, control-plane routes, tests, documentation, and migration fixtures. It adds migration 0140 to remove related database residue and updates backup validation, deployment configuration, and mailbox terminology. ChangesMailbox pre-drop backup removal
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
|
🔎 Preview deployed: https://kody-pr-1216.kody-a99.workers.dev Worker: Mocks:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/worker/src/email/inbound-mailbox-authority-mirror-migration.node.test.ts`:
- Around line 220-227: Update the migration test around applyMigrationsBefore
and authorityMirrorMigration to explicitly cover migration 0140’s
email_inbound_usage_effects schema or tear-down behavior. Preserve the existing
migration 0129 coverage, either by keeping that schema assertion in this test or
adding a separate targeted migration 0140 test.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 422f2897-1529-484d-8f03-b2ece099f76f
📒 Files selected for processing (45)
.github/workflows/deploy.ymldocs/contributing/architecture/data-storage.mddocs/contributing/architecture/run-records.mddocs/contributing/disaster-recovery.mddocs/contributing/environment-variables.mddocs/contributing/mailbox-legacy-graph-drop.mdpackages/backup-control-plane/backup-control-plane-test-support.tspackages/backup-control-plane/backup-policy.tspackages/backup-control-plane/backup-runtime.node.test.tspackages/backup-control-plane/backup-runtime.tspackages/backup-control-plane/backup-types.tspackages/backup-control-plane/control-plane-fetch.node.test.tspackages/backup-control-plane/control-plane-fetch.tspackages/backup-control-plane/control-plane-ui.tspackages/backup-control-plane/mailbox-pre-drop-approval.node.test.tspackages/backup-control-plane/mailbox-pre-drop-approval.tspackages/backup-control-plane/mailbox-pre-drop-persistence.tspackages/backup-control-plane/mailbox-pre-drop-policy.tspackages/backup-control-plane/mailbox-pre-drop-r2-policy.tspackages/backup-control-plane/mailbox-pre-drop-runtime.tspackages/backup-control-plane/mailbox-pre-drop-snapshot.tspackages/backup-control-plane/mailbox-pre-drop-verification.tspackages/backup-control-plane/mailbox-pre-drop-workflow.node.test.tspackages/backup-control-plane/mailbox-pre-drop-workflow.tspackages/backup-control-plane/readme.mdpackages/backup-control-plane/worker.tspackages/backup-control-plane/wrangler.jsoncpackages/shared/src/mailbox-pre-drop-approval.tspackages/worker/migrations/0140-drop-email-postdrop-residue.sqlpackages/worker/src/account/data-targets.tspackages/worker/src/account/user-owned-surfaces.tspackages/worker/src/email/inbound-mailbox-authority-mirror-migration.node.test.tspackages/worker/src/email/legacy-email-graph-drop-migration.node.test.tspackages/worker/src/email/mailbox-inbound-effect-ledger.tspackages/worker/src/email/mailbox-message-deletion-tombstones.tspackages/worker/src/email/mailbox-mutations.tspackages/worker/src/email/mailbox-schema.tspackages/worker/src/email/repo-search.workers.test.tspackages/worker/src/email/test-schema.tspackages/worker/src/email/user-graph-drop-approval-migration.node.test.tstools/apply-local-app-migrations.tstools/ci/backup-resources-reconcile-cli.tstools/ci/backup-resources.node.test.tstools/local-mailbox-pre-drop-approval-fixture.sqltools/migration-ledger.json
💤 Files with no reviewable changes (22)
- packages/backup-control-plane/mailbox-pre-drop-approval.ts
- docs/contributing/mailbox-legacy-graph-drop.md
- packages/backup-control-plane/mailbox-pre-drop-workflow.ts
- packages/backup-control-plane/mailbox-pre-drop-r2-policy.ts
- packages/backup-control-plane/backup-control-plane-test-support.ts
- packages/backup-control-plane/mailbox-pre-drop-workflow.node.test.ts
- packages/backup-control-plane/mailbox-pre-drop-verification.ts
- packages/backup-control-plane/control-plane-fetch.node.test.ts
- tools/local-mailbox-pre-drop-approval-fixture.sql
- packages/backup-control-plane/mailbox-pre-drop-approval.node.test.ts
- packages/backup-control-plane/mailbox-pre-drop-runtime.ts
- packages/backup-control-plane/control-plane-ui.ts
- packages/worker/src/email/test-schema.ts
- packages/backup-control-plane/control-plane-fetch.ts
- packages/backup-control-plane/worker.ts
- packages/backup-control-plane/mailbox-pre-drop-snapshot.ts
- packages/backup-control-plane/readme.md
- packages/backup-control-plane/mailbox-pre-drop-persistence.ts
- packages/worker/src/account/data-targets.ts
- packages/worker/src/email/user-graph-drop-approval-migration.node.test.ts
- packages/backup-control-plane/mailbox-pre-drop-policy.ts
- packages/shared/src/mailbox-pre-drop-approval.ts
| 'idx_email_delivery_events_user_dedupe_expires' | ||
| ) | ||
| ORDER BY name`, | ||
| ) | ||
| .all(), | ||
| ).toEqual([ | ||
| { name: 'idx_email_delivery_events_user_dedupe_expires' }, | ||
| { name: 'idx_email_delivery_events_user_state_created' }, |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 8 \
'authorityMirrorMigration|applyMigrationLikeD1|email_inbound_usage_effects|idx_email_inbound' \
packages/worker/src/email/inbound-mailbox-authority-mirror-migration.node.test.ts \
packages/worker/migrations/0129-email-inbound-mailbox-authority-mirror.sql \
packages/worker/migrations/0140-drop-email-postdrop-residue.sql || true
rg -n -C 8 \
'0140-drop-email-postdrop-residue|email_inbound_usage_effects' \
packages/worker/src/email packages/worker/migrations || trueRepository: kentcdodds/kody
Length of output: 29983
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
wc -l packages/worker/src/email/inbound-mailbox-authority-mirror-migration.node.test.ts
sed -n '1,260p' packages/worker/src/email/inbound-mailbox-authority-mirror-migration.node.test.tsRepository: kentcdodds/kody
Length of output: 7709
Preserve coverage for migration 0129.
applyMigrationsBefore(db, authorityMirrorMigration) only applies migrations before 0129-email-inbound-mailbox-authority-mirror.sql, so this test does not cover migration 0140. Keep the email_inbound_usage_effects schema check here, or add a separate migration 0140 test for the tear-down.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@packages/worker/src/email/inbound-mailbox-authority-mirror-migration.node.test.ts`
around lines 220 - 227, Update the migration test around applyMigrationsBefore
and authorityMirrorMigration to explicitly cover migration 0140’s
email_inbound_usage_effects schema or tear-down behavior. Preserve the existing
migration 0129 coverage, either by keeping that schema assertion in this test or
adding a separate targeted migration 0140 test.
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/worker/src/email/email-postdrop-migration.node.test.ts`:
- Around line 19-22: Replace the dynamic extraction of droppedTables using the
regex pattern and matchAll on the sql variable with a hardcoded list of the two
expected retired table names as literals. Then add assertions that verify each
of these specific tables exists in the database before running the migration and
does not exist after the migration completes, ensuring the test fails if
unintended tables are dropped.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 52319c9f-206c-40af-ac28-e06c75167cba
📒 Files selected for processing (1)
packages/worker/src/email/email-postdrop-migration.node.test.ts
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
…tdrop-80df # Conflicts: # tools/migration-ledger.json Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
Intent
Complete the post-cutover email legacy teardown from #1069 now that migration 0135 has removed the shared email graph in production.
Summary
due_at, user_id(renumbered from assigned 0140 after 0141 landed onmain; sibling-reserved 0142 remains untouched)Testing
npm run validate— passed on final headBACKUP_WORKFLOWandRESTORE_WORKFLOW0143-drop-email-postdrop-residue.sql✅System changes
System recap — extends existing primitives (medium risk)
Mode: recap · Base:
main@b9f83a33· Head:41186fddClassification: extends — removes a deployed one-shot control-plane lane and contracts the final D1 email schema without adding a primitive.
Primitives touched
backup-control-planed1-app-dbemailmailboxSystem map
The nightly backup/restore lane remains intact while migration 0143 contracts retired email state and Mailbox remains the permanent per-user authority.
Legend: green = composes (wiring only) · amber = extended by this PR · red = new primitive · gray = context (unchanged, included only when an edge crosses it).
Invariants
email_user_graph_authorityandsystem_email_graph_authorityremain permanent fail-closed gates.Conductor report
STATUS done — PR #1216 squash-merged as
e090800e; localnpm run validate, PR CI, preview migration, AI review, and production deploy are green; production logs show0143-drop-email-postdrop-residue.sqlapplied ✅. No assigned legacy remains outside immutable migration history; issue #1069 follow-up complete.Summary by CodeRabbit
Bug Fixes
Documentation
Chores