# Foundation operations

Run all first-party operations from the composed, runnable edition checkout
with the shared RER command path. To get a runnable checkout, run
`npx -y @runeditrun/rer install just-every/run-purse` (or start it directly with
`npx -y @runeditrun/rer dev just-every/run-purse`). The detailed flags and effects are in
`RUN-LOCALLY.md` and `SEED-COMMAND-CONTRACT.md`.

```sh
rer setup --owner-email you@example.com
rer dev
```

Use the setup prompt instead of the owner-email flag when entering the real
mailbox. `rer dev` opens the app as the owner. For ordinary outbox sign-in,
start with `rer dev --login`, then run `rer outbox` and open its `/__dev/key`
`RER_OPEN` link; it opens the key gate. Follow the newest ordinary sign-in message; no external email is sent. Stop `dev` with
`rer dev --stop` or Ctrl-C, and stop `preview` with
`rer preview --stop` before build or verification.

```sh
rer verify
rer reset --yes
rer export --output exports/installation.rer
rer import --input exports/installation.rer --yes
rer deploy
rer describe
```

Use `rer describe` to inspect the checkout's actual
capabilities. `rer check --profile first-party` validates the
declared command contract; it does not run application journeys or contact a
provider.

## Local data and recovery

Setup and development use explicit owner identity and real local migrations.
Dev and preview use the same owner and canonical `.wrangler/state`; the local
development outbox is available only on loopback. Any process with access to
the machine can read that outbox and sign in as the owner. Private settings are
kept in `.dev.vars` with mode 0600 and are not copied into build output.

Local export creates a private archive with an integrity receipt and explicit
exclusions. The foundation has no product-domain tables or background jobs; an
edition's archive contains the supported domain tables and resources that its
adapter declares. Owner/auth, outbox, bookkeeping, private settings and
transient runtime state are excluded. Import validates and restores atomically
into an empty destination; confirmed reset preserves export archives. Run setup
after restore to establish a fresh owner. Each first-party seed verifies local
export/import/export equivalence across its supported resources. Remote transfer
is available only when the adapter declares complete resource coverage.

Preserve ambiguous state and applied migration history. Never place a remote
credential, owner secret or local resource ID in source. A schema change needs
a forward migration and verified transition/recovery.

## Deployment

`rer deploy --dry-run` validates the real owner-account
deployment declaration and builds locally without provider requests. Real
deployment requires privately supplied `CLOUDFLARE_ACCOUNT_ID` and
`CLOUDFLARE_API_TOKEN` and the declared owner/session/setup secrets. For a
Business without an email provider, set `MAIL_PROVIDER=none` and use `rer signin`
to issue the owner a one-time sign-in link. Email delivery requires a verified
`MAIL_FROM` and the selected provider's credentials. Follow the owner-account deploy-kit
instructions under `node_modules/@runeditrun/rer/modules/deploy-kit`; account scope,
resource ownership, migrations, receipt and health checks are defined there.
Local validation does not prove hosted acceptance, provider delivery or remote
health.

## Backup and upgrade

A pre-upgrade export restores only with the Purse release that made it. Restore it
into an empty installation of that release, upgrade that installation’s source
in place, run `rer install` and `rer setup`, then export again. Keep the original release
and private export until recovery is verified. Never import an older release’s
archive directly into the current release.


Email request intake optionally uses Resend receiving. Configure the business request address in Requests, route that exact address in the receiving provider, and connect its signed `email.received` webhook to `/api/purse/email-intake/inbound`. Provide `EMAIL_INTAKE_WEBHOOK_SECRET` and `MAIL_API_KEY` as private deployment inputs; do not commit them. The configured outbound provider sends the native sign-in-required draft link. Address configuration is a record, not proof of mailbox delivery. The owner can inspect durable ingestion outcomes in Requests and reconcile uncertain provider messages; automatic replay never repeats a claimed ingestion or send. Source originals use the declared private `ORIGINALS` R2 binding and travel in complete local RER archives.

## Hosted installation package

`packaging.json` declares Purse's existing Worker, D1 migrations and private
ORIGINALS bucket. Run `pnpm run build`, `pnpm delivery:spec`, then
`node scripts/delivery/base/cli.mjs package --config packaging.json --output rer-package`.
`pnpm check:deployment-spec` refuses a stale committed import specification.
The Managed workflow is dispatch only; packaging creates no deployment or release.

Hosted sign-in and notification mail supports RER managed relay, Resend, SendGrid
and Cloudflare. Assisted setup collects the selected provider's sender and private
credential; Cloudflare also requires its account ID. RER supplies the relay URL
and installation credential for Managed hosting. Local development keeps mail
suppressed. Packaging does not prove provider delivery.
