8000 Spec: staging toolchain, phase 1 (deploy, refresh, seed, login) · Issue #475 · jra3/mulm · GitHub
[go: up one dir, main page]

Skip to content

Spec: staging toolchain, phase 1 (deploy, refresh, seed, login) #475

Closed

Description

@jra3

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) and baptest+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 seed on a fresh refresh yields two working logins; running it again rotates both passwords and the old ones stop working.
  • seed run against prod (STAGING unset) refuses and changes nothing.
  • staging.sh login admin twice in a row logs in once.
  • With STAGING=1 and disableEmails: false, no email is sent (unit test).
  • staging.sh deploy refuses a dirty tree.
  • .claude/skills/ops.md and docs/DEPLOY.md describe the verbs; the old manual steps are removed.
  • The committed passwords in e2e/helpers/testData.ts no longer work on staging.

Out of scope

  • Fixtures (follow-up issue).
  • Running the Playwright suite against staging.

Activity

  1. added
    enhancement
    infrastructure
    ready-for-agent
    on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementinfrastructureready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0