Provision Support

One command, idempotent

Read the MX constraint first — it is the one decision here you cannot take back casually. pithy add support wrote the wiring; pithy support is the command; Using Support is what you do afterwards.

pithy support provision

Safe to re-run. --json prints one machine-readable line, so CI and agents drive the same command a human does.

Three things have to exist, and none can be a hand-written binding

An R2 bucketAttachments and raw messages
A classification WorkerPer environment, prebuilt
An Email Routing rulePer environment, the one that actually delivers the mail

The bucket is created only if something would write to it

Mail attachments, the raw MIME copy, or in-app uploads.

Turn all three off and no bucket is created and no binding is written — which is the right shape for an inbox that never needs a screenshot.

Turn any one back on and the next pithy upgrade writes the binding, and the next provision creates the bucket.

The message index exists only while you search by meaning

With search: { semantic: true }, provision creates <project>-<env>-support-messages in Vectorize for each environment, before the classification Worker that binds it is deployed, writes the SUPPORT_VECTORIZE binding into that environment’s stanza, and backfills the index once from the messages already stored. Vectorize needs the paid Workers plan.

Turn it off and the next provision drops the index, after the deploy that stopped binding it, with the model stamps that named its vectors, and takes the binding out again. Re-embedding after a model change is pithy vector reprocess --index support-messages, never provision.

The routing rule is derived, and Email Routing stays your switch

So provision derives the rule and never the switch. For each environment it reads the addresses support’s inboundAddresses claims, finds the zone that holds each one’s domain (the parent zone, for a subdomain), checks that Email Routing is already enabled for that domain, and sends the exact address to the Worker pithy deploy names for the environment. Off, that environment is refused, naming the domain and where in the Cloudflare dashboard to turn it on, and no rule is made.

A project that has not turned Email Routing on yet provisions everything else, and the first run after you turn it on routes the address. Each environment can claim its own address, staging@help.example.com beside support@help.example.com, and gets its own rule to its own Worker.

Read the MX constraint before you turn Email Routing on. It is the single most important thing to know about this capability. The three routing flags, --routing-zone, --inbound-address and --app-worker, remain as an override for a rule the derivation would not make, all or nothing; pithy support has the details and the permissions routing takes.

The rule name carries the project

<project>-<env>-support-inbound, one per environment, deliberately distinct from the email capability’s bounce rule. The override flags make one project-global rule instead, <project>-global-support-inbound.

A rule is found by the address it matches, not only by its name. One already sending the address to the Worker is left alone, whatever it is called. The sole enabled rule sending it elsewhere is updated to the Worker, keeping its name, and several enabled rules claiming it are refused by name rather than guessed between.

An address two environments both claim is refused for both, because one exact-address rule delivers to one Worker. Give each environment its own address.

Teardown removes the rule first

pithy support deprovision --env <environment>

--env is required. A teardown removes exactly one named environment’s classification Worker and its classify and reprocess Workflows, never every environment, so a run meant for staging cannot take production’s with it.

Mail stops arriving before the Workers that would have handled it go away.

Your stored correspondence is left alone unless you pass --storage.

The environment’s own rule goes either way: each rule that sends an address its composition claims to its Worker. A rule for that address sending it anywhere else is left, and so is every other environment’s. --routing-zone is only for the project-global rule the override flags made, and only with the last environment.

Everything is idempotent

Find-then-create for resources, a deploy that overwrites, and a routing step that leaves a rule already sending the address to its Worker alone and skips an environment that claims no address.

The live Cloudflare and wrangler steps sit behind a seam, so the ordering, the idempotency contract and the per-environment fan-out are unit-tested without touching Cloudflare.

ESC