# Foundation operations

Run all first-party operations from the composed, runnable edition checkout
with `rer`. To get a runnable checkout, run `npx -y @runeditrun/rer dev just-every/run-terrace` (set up only: `npx -y @runeditrun/rer setup just-every/run-terrace`; without Node: `curl -fsSL https://runeditrun.com/install.sh | sh -s -- dev just-every/run-terrace`). Inside that checkout, `rer dev` alone launches it for review. The detailed flags and effects are in
`RUN-LOCALLY.md` and `SEED-COMMAND-CONTRACT.md`.

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

Use the setup prompt instead of the owner-email flag when entering the real
mailbox. Follow the newest ordinary sign-in message in the printed local
outbox; 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. 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.

## Hosted delivery

The seed-owned `packaging.json` declares the actual Worker, unchanged D1
migrations and recovery procedure. After `pnpm run build`, run
`pnpm delivery:spec` to refresh the committed deployment specification and
`pnpm check:deployment-spec` to verify it. Package with
`node scripts/delivery/base/cli.mjs package --config packaging.json --output rer-package`;
the output directory must be new. Generated delivery folders are disposable.

Local development suppresses email. For hosted email, select Resend, SendGrid,
Cloudflare or RER in setup and supply the matching sender and private API key.
Cloudflare also needs its account ID. Managed hosting assigns `MAIL_PROVIDER`,
`MAIL_FROM`, `MAIL_RELAY_URL` and the private `MAIL_API_KEY`. Configure-email-later
is for local setup; it does not provide production delivery. Provider acceptance
is distinct from delivery, and human approval remains required for outbound
product actions.

To host without outbound email, set `MAIL_PROVIDER=none` and leave the sender
and mail credentials unset. Email links and invitations are unavailable. From
the deployment checkout, run `rer signin` with the Cloudflare credentials used
to deploy and the same `--environment NAME` if you named an environment. Open
the one-time owner link privately and confirm.

A deployment already sending mail holds its provider, sender or credentials on
the Worker. To switch it off, use the same checkout and Cloudflare credentials
as the deployment. For a named environment, add `--environment NAME` to both
commands. Keep `MAIL_PROVIDER=none` in the inputs for later full redeploys.

```sh
rer deploy --set-secret MAIL_PROVIDER=none
rer deploy --unset-secret MAIL_API_KEY
```

When upgrading a 0.1.5 deployment that will keep sending mail, supply
`MAIL_FROM` again. Resend is the default. To choose another provider, set
`MAIL_PROVIDER` and supply its credentials. The existing `MAIL_API_KEY` is inherited
on a full redeploy.
