Repository navigation
Description
Replaces #360. Staging-driven development needs one safe entry point to staging that you or an agent can call: deploy, refresh data, get a logged-in session. Today that takes ad-hoc flyctl ssh and hand-written SQL, and the test logins use passwords committed to this public repo.
Decisions (2026-10-01)
- Passwords: random, new on every seed run, stored only in a local file. No shared store.
- Seed code: TypeScript inside the app, run in the staging container, reusing the app's own member and password code. No hashing logic copied into bash.
- Scope: logins first. Fixtures (an Apple-only member, a draft Submission owned by the test member, …) come later in their own issue.
- feat(ops): repeatable staging test-user seeding + workflow docs #360 is closed, not built on.
Shape
scripts/staging.sh <verb>, allow-listed in .claude/settings.json (Bash(./scripts/staging.sh:*)).
| Verb | Does |
|---|---|
deploy |
flyctl deploy --config fly.staging.toml --app basny-bap-staging from the current checkout. Refuses a dirty tree; prints the commit deployed. |
refresh |
Deletes staging's DB files and restarts the machine so start.sh restores from prod's replica, then runs seed. |
seed |
Starts the scale-to-zero machine if needed, runs the in-container seed, writes the credentials file. |
login <admin|member> |
Logs in once and writes a cookie jar; reuses it while the session is still valid. Prints the jar path. |
Seed (src/staging/seed.ts, compiled into the image)
- Exits non-zero unless
STAGING=1. - Upserts
baptest+admin@porcnick.com(admin) andbaptest+e2e@porcnick.com(member) with the existing member and password functions (src/db/members.ts,src/auth.ts). - Generates both passwords itself, sets them, clears those accounts' failed-login lockouts and sessions, and prints the credentials as one JSON line on stdout. Passwords never appear in a command line.
- Touches no account outside the two
baptest+addresses.
staging.sh seed writes that JSON to ~/.config/mulm/staging-test-users.env (mode 600) as STAGING_URL, STAGING_ADMIN_EMAIL, STAGING_ADMIN_PASSWORD, STAGING_USER_EMAIL, STAGING_USER_PASSWORD.
Email can't leave staging
Staging holds every real member's address. Today only disableEmails: true in staging's CONFIG_JSON stops mail. Make STAGING=1 disable email in src/notifications.ts (and any other sender) whatever the config says, with a test.
Login
POST /auth/login with Origin, fields email/password. Success = HX-Redirect: / plus a session_id cookie. Login rate-limits after a few attempts (429, 15 minutes), so login must reuse a valid jar rather than log in every call. Jars go under ~/.cache/mulm/.
Acceptance
-
staging.sh seedon a fresh refresh yields two working logins; running it again rotates both passwords and the old ones stop working. -
seedrun against prod (STAGINGunset) refuses and changes nothing. -
staging.sh login admintwice in a row logs in once. - With
STAGING=1anddisableEmails: false, no email is sent (unit test). -
staging.sh deployrefuses a dirty tree. -
.claude/skills/ops.mdanddocs/DEPLOY.mddescribe the verbs; the old manual steps are removed. - The committed passwords in
e2e/helpers/testData.tsno longer work on staging.
Out of scope
- Fixtures (follow-up issue).
- Running the Playwright suite against staging.
Activity
Add scripts/staging.sh: deploy, refresh, seed and login for staging (#…