# Workflow: nightly staging refresh

## Goal
Staging mirrors production every morning, automatically, with no dump-and-restore pipeline to maintain.

## Steps
1. Make `staging` a child branch of the production branch.
2. Schedule a job (cron, GitHub Actions) that calls reset-from-parent on the staging branch via the Neon API or CLI.
3. After reset, re-run branch-local setup the refresh wiped: seed test users, set feature flags, scrub or anonymize anything staging should not have.
4. Smoke-test staging; alert if the reset or the setup fails.

## Ordering constraints
- Reset first, then setup: setup applied before reset is wiped.
- Run it in the small hours of the staging timezone; anyone using staging at 3am opted into the risk.

## Traps
- Reset is destructive to the branch by design; nothing on staging should be irreproducible. If it is, that is the real bug.
- Resetting the wrong direction (parent from child) would be catastrophic; hardcode the branch IDs and have the job assert the target is the staging branch.
- Anonymization: if staging must not hold production PII, the post-reset step must scrub it every time, not just the first time.

## Verify
Morning check: staging row counts match production's from the reset time; the job logs show reset, setup, and smoke test green.