apps/mail/cloudflare/acceptance/run.mjs starts the emitted Mail Worker in a
local workerd, through the same unstable_startWorker call the CI emitted-Worker
acceptance uses (scripts/ci/wave1-native-runtime.mjs). It then exercises login,
inbox, thread, compose, the three paste shapes, send, attachments and inline CID
images over HTTP and writes a JSON evidence file. It runs on the Studio, never on
the M4, and builds nothing itself.
What is real and what is a fixture
The Worker is reached with
worker.fetch and an origin override, so its request
host is mail.tuturuuu.com (the production profile’s root host) and no DNS, port
or TLS is involved. That host is also one the Supabase cookie policy accepts.
Every outbound request from the Worker passes through the harness: the object
store and send API fixtures answer, Supabase is forwarded, and any other host is
denied with status 599 and listed in the evidence. A denied host such as
tuturuuu.com means a page or route reached for Web, which this run does not
provide.
Prerequisites
- A checkout of the exact source SHA on the Studio, with
bun install --frozen-lockfile --ignore-scriptsdone. - A build of that SHA with
MAIL_DEPLOYMENT_PROFILE=productionand the staging Supabase public values, so the Supabase project baked into the bundle is the staging one. This differs from the sealed CI artifact only in those baked public values. - A staging fixture: a user able to sign in, a workspace with the mailbox at
MAIL_ACCEPT_MAILBOX_ADDRESS, an active Cloudflare-inbound mail domain row forMAIL_ACCEPT_DOMAINwith the Cloudflare outbound provider, and no customer data. - The inert placeholder
MAIL_CLOUDFLARE_API_TOKEN(prefixinert-staging-), the stagingMAIL_CLOUDFLARE_INGEST_SECRET, and the other staging secret names the Mail profile lists. All are read from a 0600 custody env file; none is written to the repository or the evidence.
Environment names
Commands on the Studio
Run one queued job so the build, seal and acceptance share a single slot. The custody file path is the one named in the fixture grant.prepare refuses an existing publication profile.
Cleanup
The harness removes its scratch copy and stops workerd on exit. In the Studio worktree, remove the rebuildable output before another run:Steps and assertions
- Build identity:
/api/build-inforeports the Mail app, the source SHA and the profile. - Anonymous gate: an unauthenticated page answers 307 and an unauthenticated API call answers 401 with no cookie set.
- Login: Supabase password sign-in, the cookie in the
@supabase/ssrlayout, then the inbox page answers 200. - Bootstrap lists the fixture mailbox.
- Inbound: a domain check, three signed ingests that import once and deduplicate on replay, and a forged and an unsigned event that answer 401.
- Inbox and thread lists contain the three messages.
- Thread and message detail return the expected attachments; the raw source matches its stored hash.
- Attachment download: bytes match, the headers are
attachment,nosniff,private, no-store, a sandbox CSP andSAMEORIGIN; a Range read answers 206. - Inline CID image: served inline as
image/pngwith the same header policy and matching bytes. - Compose and paste shapes: a draft, an inline image upload, a file attachment, and a rich HTML body whose embedded image is uploaded and referenced; the draft carries one attachment and two inline images.
- Send under the inert provider: the response is 502
MAIL_SEND_UNCONFIRMED, the provider is contacted exactly once, the message stays in the durablesendingstate, and a replay answers 200 without contacting the provider again. This is the fail-closed behavior: no retry and no fallback transport. - Document and API headers:
X-Frame-Options: DENY,Cache-Control: private, no-store,X-Robots-Tagand a content security policy on the document. - Egress: no host outside the object-store fixture, the send fixture and Supabase was contacted.
Browser paste
The paste event handlers run in a browser, which this harness does not provide: the Worker is reached in process, with no browser-reachable origin. Their behavior is covered bymail-composer-paste.test.ts, and the harness covers the
server side of each shape. A real browser paste check belongs to the hosted
staging acceptance.
Remaining hosted-only dependencies
- Cloudflare Access verification and the staging custom domain run only in the staging artifact, behind the hosted staging publication.
- A real R2 bucket and its S3 credentials.
- A real Cloudflare Email Sending call. The first real send is verified after cutover with the production token and a fleet-owned recipient.
- The Web login page,
verify-tokenand any Web-owned API the Mail pages call. - The route attach and the Vercel alias rollback.