Legendary Arena Lab

Secrets and Environment

app

Migration in progress. api.legendary-arena.com and PostgreSQL are moving from Render to a self-hosted DigitalOcean Ubuntu host behind Cloudflare. Render remains rollback-ready until decommission phase.

Secrets and Environment

Define and protect the server environment contract that moved from Render secret storage to host-managed secret files.

Summary

Use infra/.env.example as the placeholder reference only. Real values must never be committed.

Required posture

  • Runtime secret file path: /etc/la/.env
  • File mode: 600
  • Owner: root (or tightly controlled service owner)
  • Source of truth: secure secret manager or manual secure injection

Scope of values

The environment contract includes:

  • database URL and runtime port values
  • JWT and auth provider secrets
  • Stripe keys and webhook secrets
  • anti-abuse submit tokens
  • Cloudflare R2 credentials
  • Brevo alert credentials

Verification

sudo test -f /etc/la/.env
sudo stat -c '%a %U:%G %n' /etc/la/.env

Expected:

  • file exists
  • mode is 600
  • ownership matches host policy

Installing the production values (rehearsed 2026-10-12)

The real values live only in the Render dashboard (legendary-arena-server → Environment). Copy all of them, not just the render.yaml list: some keys the server reads are set only in the dashboard.

  1. Click Export on Render’s Environment tab and save the file as <folder>\render-secrets.env, where <folder> is the operator’s private ops folder.
  2. scp it to /tmp/ on the droplet.
  3. Merge it into /etc/la/.env without printing any value:
    • Render’s values replace the matching keys.
    • These keys stay as the droplet sets them: DATABASE_URL (local Postgres), NODE_ENV, NODE_VERSION, PORT, and LEGENDS_PUBLISHER_ENABLED.
    • Any leftover REPLACE placeholder is blanked.
    • The file is written 600 root:root, and /tmp/render-secrets.env is shredded.
  4. Verify by key name only: list each key as set/EMPTY, check for duplicates, and check that no REPLACE is left.
  5. Redeploy (40-app-deploy.ps1). The startup log should show the Hanko verifier against the production tenant and no errors.

Keys production doesn’t set (COACH_MODEL, the three BREVO_*_TEMPLATE_IDs) stay blank or at the code default. PAR_VERSION is left out of the file entirely. A blank PAR_VERSION= line set the empty string, which the server kept instead of its v1 default, so the PAR gate loaded nothing and every competitive score was refused as par_not_published from the cutover until legendary-arena #3354 (2026-11-13), which makes a blank value fall back to v1. To check a live server, its startup log must read “continuing with seed-only coverage (128 scenarios, v1)”, not “PAR index unavailable”. COACH_MODEL=claude-sonnet-5 is the server’s own DEFAULT_COACH_MODEL, so it behaves exactly like unset. JWT_SECRET must be Render’s value, or every signed-in session breaks at the flip.

The legends publisher holds production R2 credentials

With LEGENDS_PUBLISHER_ENABLED=true, the server writes the public legends board to the production R2 bucket every 5 minutes, built from its own database. A droplet holding production R2 keys and an empty (or stale) database would overwrite the live board. Only one publisher may run at a time, and it must be the one with the live database:

  • Before cutover: the droplet runs with LEGENDS_PUBLISHER_ENABLED=false.
  • At cutover, after the production restore: set it to true on the droplet and restart la-server. In Render’s dashboard, set it to false, because Render’s database goes stale the moment api. flips.
  • On rollback: reverse both.

Rotation practice

  • rotate compromised or shared secrets immediately
  • restart service after secret updates
  • document rotation event and impact window in ops notes

References

  • Plan section 4.5 secrets-and-env page stub
  • Plan section 10 open items and ownership notes