Skip to content

Remove inline MIME runtime compatibility - #854

Merged
kody-bot merged 1 commit into
mainfrom
cursor/legacy-purge-b-data-migrations-f449
Jul 22, 2026
Merged

kody-bot merged 1 commit into
mainfrom
cursor/legacy-purge-b-data-migrations-f449

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • remove raw-MIME offload maintenance endpoint, deploy loop, claim protocol, and sticky queue runtime
  • simplify MIME reads to R2 raw_mime_key only
  • remove all runtime SQL/type references to transitional inline/blocked/queue schema
  • simplify deletion to deterministic per-user MIME keys
  • keep physical columns/table for one deploy so the later migration-only contract is safe

Rollout

Production after required-R2 writes reported remainingInline=0, remainingBlockedInline=0, and remainingBlobCleanup=0. This is the code-first half of expand/contract; no schema migration is included.

Validation

  • complete unit suite: 1,069 tests passed
  • typecheck, format, and migration ordering passed
System recap β€” extends existing primitives (medium risk)

Mode: recap Β· Base: main @ a25adea9 Β· Head: b75dcac5

Classification: extends β€” removes runtime dependence on transitional MIME schema while retaining physical compatibility for one release.

Invariants

  • Runtime is compatible before and after the future schema drop.
  • MIME reads use only per-user deterministic R2 keys.
  • No endpoint can create or clear inline MIME.
Open in WebΒ Open in CursorΒ 

Summary by CodeRabbit

  • New Features

    • Email raw content is now stored and retrieved consistently from durable blob storage.
    • Email size validation now uses the unified raw-message limit.
  • Bug Fixes

    • Account deletion and retention cleanup now use consistent message keys and retry safely when blob deletion fails.
    • Administrative email views continue to display raw content through the updated storage flow.
  • Chores

    • Removed the legacy raw-content migration maintenance endpoint and deployment sweep.
    • Updated architecture and operational documentation to reflect the current storage and retention behavior.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

πŸ“ Walkthrough

Walkthrough

Email raw-MIME handling now stores and reads content through deterministic R2 keys, updates deletion and retention cleanup to delete those keys before D1 rows, excludes transitional cleanup-queue data from runtime account coverage, and removes the offload maintenance endpoint and deployment sweep.

Changes

Raw-MIME storage contract

Layer / File(s) Summary
R2-backed MIME persistence and reads
packages/worker/src/email/*, packages/worker/src/app/admin-system-email-data.ts
Inbound MIME is written to EMAIL_BLOBS, D1 stores raw_mime_key, and MIME reads no longer fall back to inline raw_mime.
Metadata and validation updates
packages/worker/src/email/parser.ts, packages/worker/src/email/types.ts, packages/worker/src/email/inbound.ts
The raw-MIME limit is named maxRawMimeBytes, and EmailMessageRecord exposes rawMimeKey and rawSize.
Test fixture updates
packages/worker/src/email/*.test.ts, packages/worker/src/mcp/capabilities/admin/admin-capabilities.node.test.ts, packages/worker/src/email/test-schema.ts, packages/worker/src/storage-runner.workers.test.ts
Tests and schemas validate key-based MIME storage and provide mocked R2 reads for administrative email access.

Deletion and retention cleanup

Layer / File(s) Summary
Account deletion inventory
packages/worker/src/app/account-deletion.ts, packages/worker/src/app/account-data-targets.ts
Account deletion derives message blob keys from user and message IDs, retains attachment keys, and no longer targets cleanup-queue objects.
Retention deletion ordering
packages/worker/src/app/retention.ts, packages/worker/src/email/system-email.ts
User and system email pruning deletes deterministic R2 keys before D1 rows and skips rows when blob deletion fails.
Coverage and retention tests
packages/worker/src/app/*test.ts
Tests reflect deterministic key deletion and verify transitional cleanup-queue columns remain physical but outside runtime coverage.
Architecture documentation
docs/contributing/architecture/data-storage.md
Storage, account deletion, and retention documentation describes the Stage 4b1 key-only contract and transitional cleanup-queue status.

Offload maintenance removal

Layer / File(s) Summary
Deployment and routing removal
.github/workflows/deploy.yml, packages/worker/src/index.ts, packages/worker/src/email-raw-mime-offload-maintenance.ts
The deployment offload sweep and worker maintenance route were removed; the path now falls through to the generic unknown-maintenance endpoint.
Maintenance test cleanup
packages/worker/src/email-raw-mime-offload-maintenance.node.test.ts, packages/worker/src/email-raw-mime-offload-races.node.test.ts, packages/worker/src/test-support/email-raw-mime-offload-fixtures.ts, packages/worker/src/security/public-route-hardening.workers.test.ts
Offload-specific tests and fixtures were removed, and route-hardening coverage now references package-privacy backfill.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InboundEmail
  participant insertEmailMessage
  participant EMAIL_BLOBS
  participant APP_DB
  participant loadRawMime
  InboundEmail->>insertEmailMessage: parse and store raw MIME
  insertEmailMessage->>EMAIL_BLOBS: write deterministic object
  insertEmailMessage->>APP_DB: store raw_mime_key
  loadRawMime->>EMAIL_BLOBS: read by raw_mime_key
  EMAIL_BLOBS-->>loadRawMime: return raw MIME
Loading

Possibly related PRs

πŸš₯ Pre-merge checks | βœ… 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
βœ… Passed checks (4 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly matches the main change: removing runtime compatibility for inline MIME handling.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
πŸ“ Generate docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/legacy-purge-b-data-migrations-f449

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.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@cursor
cursor Bot force-pushed the cursor/legacy-purge-b-data-migrations-f449 branch from b75dcac to 0eb3a8b Compare July 22, 2026 08:07
@kody-bot
kody-bot marked this pull request as ready for review July 22, 2026 08:09

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/deploy.yml (1)

269-269: πŸ—„οΈ Data Integrity & Integration | 🟠 Major | πŸ—οΈ Heavy lift

Gate deployment on the required raw-MIME transition verification.

The PR requires production confirmation that remainingInline=0, remainingBlockedInline=0, and remainingBlobCleanup=0, but this workflow removes the maintenance step without adding any equivalent pre-deploy check. Deploying first can leave legacy MIME unreadable and cleanup-queue rows outside deletion/export coverage. Add a pre-deploy D1 verification gate or an auditable required release step before this removal ships.

πŸ€– 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 @.github/workflows/deploy.yml at line 269, Update the production deployment
workflow around β€œπŸ§ͺ Execute smoke check (production)” to add an auditable
pre-deploy D1 verification gate before deployment proceeds. The gate must
confirm remainingInline=0, remainingBlockedInline=0, and remainingBlobCleanup=0,
and fail or block the deployment when any value is nonzero; preserve the
existing smoke-check flow after successful verification.
πŸ€– 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.

Outside diff comments:
In @.github/workflows/deploy.yml:
- Line 269: Update the production deployment workflow around β€œπŸ§ͺ Execute smoke
check (production)” to add an auditable pre-deploy D1 verification gate before
deployment proceeds. The gate must confirm remainingInline=0,
remainingBlockedInline=0, and remainingBlobCleanup=0, and fail or block the
deployment when any value is nonzero; preserve the existing smoke-check flow
after successful verification.

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b22cc030-d27a-454b-99ed-0a401ba932bc

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a25adea and 0eb3a8b.

πŸ“’ Files selected for processing (26)
  • .github/workflows/deploy.yml
  • docs/contributing/architecture/data-storage.md
  • packages/worker/src/app/account-data-targets.ts
  • packages/worker/src/app/account-deletion.node.test.ts
  • packages/worker/src/app/account-deletion.ts
  • packages/worker/src/app/account-export.node.test.ts
  • packages/worker/src/app/admin-system-email-data.ts
  • packages/worker/src/app/retention.node.test.ts
  • packages/worker/src/app/retention.ts
  • packages/worker/src/email-raw-mime-offload-maintenance.node.test.ts
  • packages/worker/src/email-raw-mime-offload-maintenance.ts
  • packages/worker/src/email-raw-mime-offload-races.node.test.ts
  • packages/worker/src/email/inbound.ts
  • packages/worker/src/email/inbound.workers.test.ts
  • packages/worker/src/email/outbound.workers.test.ts
  • packages/worker/src/email/parser.ts
  • packages/worker/src/email/raw-mime-key.node.test.ts
  • packages/worker/src/email/repo.ts
  • packages/worker/src/email/system-email.ts
  • packages/worker/src/email/test-schema.ts
  • packages/worker/src/email/types.ts
  • packages/worker/src/index.ts
  • packages/worker/src/mcp/capabilities/admin/admin-capabilities.node.test.ts
  • packages/worker/src/security/public-route-hardening.workers.test.ts
  • packages/worker/src/storage-runner.workers.test.ts
  • packages/worker/src/test-support/email-raw-mime-offload-fixtures.ts
πŸ’€ Files with no reviewable changes (9)
  • packages/worker/src/email-raw-mime-offload-maintenance.node.test.ts
  • packages/worker/src/email-raw-mime-offload-races.node.test.ts
  • packages/worker/src/index.ts
  • packages/worker/src/email/types.ts
  • packages/worker/src/email-raw-mime-offload-maintenance.ts
  • packages/worker/src/app/admin-system-email-data.ts
  • packages/worker/src/security/public-route-hardening.workers.test.ts
  • packages/worker/src/test-support/email-raw-mime-offload-fixtures.ts
  • packages/worker/src/app/account-data-targets.ts

@github-actions

Copy link
Copy Markdown
Contributor

πŸ”Ž Preview deployed: https://kody-pr-854.kody-a99.workers.dev

Worker: kody-pr-854
D1: kody-pr-854-db
KV: kody-pr-854-oauth-kv

Mocks:

@kody-bot
kody-bot merged commit 98e077d into main Jul 22, 2026
8 of 9 checks passed
@kody-bot
kody-bot deleted the cursor/legacy-purge-b-data-migrations-f449 branch July 22, 2026 08:23
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.

3 participants