Repository navigation
Description
Why
Today a workspace (a tenant) exists only if a super admin provisions it in the operator console ((admin)/admin/tenants/new). The owner wants a person with no workspace to be able to create one themselves, right after signing in with Google, and to land in it as its admin on a free allowance.
This ticket is the backend half of the founder path only. Members joining an existing workspace never reach it (see #1400).
What the user sees
The user sees nothing directly; #1403 is the UI. The /welcome flow submits a workspace name, the kind of data (people or accounts), and acceptance of the terms. Then it watches real provisioning progress until the workspace is ready.
How
-
Pull out a shared provisioning helper.
frontend/src/app/api/admin/orgs/route.tsPOST (L65-96) currently does these steps inline:- calls er-server
POST /v1/orgswith the operator token; - runs
mintServiceKeys(frontend/src/lib/bff/admin.ts), which seals viewer, steward and admin keys intoorg_credentials; - inserts
orgs_registry; - writes the
org.provisionaudit row.
Move those steps into one server-only helper. The operator route then calls that helper, with no change in behaviour.
- calls er-server
-
POST /api/auth/signup/workspace.- Requires: a valid pending-identity cookie from First-sign-in router: join an existing workspace vs found a new one #1400 that is not staff.
- Before anything is created, re-check on the server that:
- no pending invite matches the email (if one does, redirect to
/join); - this Google
subhasn't already founded a workspace (one self-serve workspace per person).
- no pending invite matches the email (if one does, redirect to
- Input: the workspace display name (2–60 characters), the entity type (
personoraccount, the only supported models; seelaunch-readiness.md), andterms_accepted = true. - Steps:
- Derive the slug: lowercase, ASCII, hyphens. Refuse reserved words (
admin,app,api,login,welcome,join,docsand every top-level route) and taken slugs. Suggest-2on a clash. - Create the user (no password), the identity and
terms_accepted_at, in one transaction, then commit. - Call the shared provisioning helper with the entity type.
- Insert
org_members(role=admin). - Set the free allowance with the operator
PATCH /v1/orgs/{org}/allowance(set_allowance,rust/crates/er-server/src/lib.rs:6463). The value comes fromERWEB_SIGNUP_FREE_ALLOWANCE. - Write
user_onboarding(kind=founder)for First-run state and the tour offer, per user per workspace #1404. - Call
createSession. - Write the audit row
org.self_serve_provisionwith the actor and the slug.
- Derive the slug: lowercase, ASCII, hyphens. Refuse reserved words (
-
GET /api/auth/signup/status?org=. It reports the real phases in order:registered: the registry row exists;provisioning: er-server reports org stateprovisioning;config_ready: config v1 exists;dataset_ready: the default dataset exists;keys_ready: the sealed credentials exist;active.
The UI moves forward only on these, which is the motion rule that bans progress filled in between polls. Poll every 1s, with a timeout.
-
When something fails. If provisioning fails or times out:
- Mark the registry row failed, and show "We couldn't finish setting up your workspace — try again".
- "Try again" re-runs provisioning for the same slug.
- Never leave a membership pointing at an org that doesn't exist.
-
Abuse controls.
- One workspace per person.
- A global daily cap,
ERWEB_SIGNUP_DAILY_CAP(default 25). Past the cap, the copy says "We're at capacity for new workspaces today — try tomorrow", and the event is audited. - A WAF rate rule on
/api/auth/signup/*. - Signup requires Google; there is no password signup.
-
Feature flag.
ERWEB_SELF_SERVE_SIGNUP_ENABLED, read by the router in First-sign-in router: join an existing workspace vs found a new one #1400. -
Prerequisite to verify first. er-server returns 503 from auto-provisioning unless
ER_PROVISION_MODEis set (rust/crates/er-server/src/provision.rs:18). Whether prod sets it is unverified. Check it in the prod er-server env by name, and if it's missing, set it topostgresin the chart values before anything else.
Acceptance criteria
- On the dev cluster, a signup goes from
registeredtoactive. Measure and record the p50 and p95 over 10 runs in this ticket. Cinematic login, /welcome (founder) and /join (member) screens #1403's scene is tuned to that number. - A person who already founded a workspace is refused a second one.
- A person with a pending matching invite is redirected to
/joinand never gets a workspace. Test this by calling the endpoint directly. - Reserved and taken slugs are refused with a suggestion.
- The daily cap is enforced, and resets the next UTC day.
- A forced provisioning failure leaves no membership for a missing org, and "Try again" succeeds.
- The operator console's "new tenant" still works unchanged through the shared helper; its existing tests stay green.
- The new org's allowance reads back as the configured value from
GET /v1/orgs/{org}/usage. -
ER_PROVISION_MODEis confirmed in prod by name.
Out of scope
- Billing and paid plans.
- Deleting a self-serve workspace from the customer's side. The operator console can do it.
- Password signup, which needs mail and is blocked on Prod SES + observability: envs/prod has neither — invites and password resets drop silently #939 and Flip prod mail backend to SES in values-prod.yaml — gated on the production-access grant #943.
Depends on
#1398 and #1400. This ticket blocks #1403 and #1406.
Where to start
frontend/src/app/api/admin/orgs/route.ts.frontend/src/lib/bff/admin.ts.rust/crates/er-server/src/lib.rs:create_orgat L1175 andprovision_orgat L967.rust/crates/er-server/src/provision.rs.frontend/src/components/admin/new-tenant.tsx.
Estimate: 1.5 engineer-weeks.
Part of the E31 epic (#1396) (linked as parent). Decisions recorded 2026-11-28 with the owner.
Activity