Skip to content

feat(auth): beta links let one person past the waitlist without knowing their email - #1246

Merged
allisonmahmood merged 2 commits into
mainfrom
t3/beta-invite-links
Nov 5, 2026
Merged

allisonmahmood merged 2 commits into
mainfrom
t3/beta-invite-links

Conversation

@allisonmahmood

@allisonmahmood allisonmahmood commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

What changed

Big prospects ask for "a link to try it", but the person who will actually try Patchy is on the CEO's team, and nobody knows their email. Clerk's waitlist only admits an invitation to a known address. A beta link is a forwardable address, /join/<secret>, made by the operator for a company's name. The first work email entered keeps the link for good, and Clerk emails that address an ordinary invitation. Its sign-up proves the mailbox and shows the terms checkbox. Create-or-join then marks the link used and starts the company with the link's name, which the person can change. They invite their team from /company as usual.

pnpm beta-links create --for "Acme" [--days 30] prints the link once. list shows each link's state, the email it went to, and its person's company. resend <id> replaces a lost invitation, and revoke <id> ends a link and withdraws its invitation. Each command takes --json.

Look at

The page, in each state (personas instance; the mock picked was B):

Open Refused email Sent
open refused sent
Couldn't send (Try again, same address only) Used Ended (410)
failed used ended

Create-or-join after the link, with the link's name filled in:

create company

Serialization. Claim, retry, resend and revoke each lock the link's row (SELECT … FOR UPDATE) and hold the lock through the Clerk call and the commit, uninterruptibly. This is the pattern Invitations.ts uses, so a revoke can't cross a send. The test "holds a revoke until the invitation being sent is stored, then withdraws it" fails if that lock is removed (checked by hand).

Design choices (reviewed twice by GPT 6.1 Sol before building):

  • What a link page shows. Once an invitation is sent, the page has no resend button. A lost email goes through the operator. This keeps a forwarded link from spending Clerk's instance-wide limit of 100 invitations an hour, which company invitations share.
  • Clerk failures. If Clerk fails, the address stays reserved and Try again goes to that address only, because Clerk may have created an invitation whose answer never reached us. A link gets five attempts from its page in all, then says to ask whoever sent it, so a link Clerk keeps refusing can't spend the hourly allowance. The operator's resend isn't counted.
  • One live link per address, so arriving at create-or-join names exactly one link.
  • InvitationNotPending gains state: accepted | revoked, so revoke can say "they already have an account" instead of "withdrawn". Company invitations handle it as before.

How it was verified

  • BetaLinks.test.ts (11 cases, migrated Postgres, recording, failing and slow Clerk layers) covers:
    • each state;
    • the secret and full address never appearing in the page;
    • a cross-origin POST getting a 403;
    • one email per link and one live link per address;
    • Clerk failing, then Try again, and Try again stopping after five attempts;
    • two links claiming one address at the same moment (the second gets the 409 refusal, not a 503);
    • expiry;
    • arrival marking the link once and prefilling the company name;
    • resend and revoke, including an already-accepted invitation, revoke waiting for a send in flight, and unknown secrets.
  • Other suites. packages/auth, packages/companies and the migration-ledger test pass (324 tests). pnpm typecheck and pnpm lint are clean. Locally, pnpm check failed only in the CLI suites, from T3 Code's stray GET / probes, and in the SDK installer suite, because this shell has no npm on PATH. Neither touches this change.
  • Headless Chromium on a personas instance: refused email, then claim, then the sent page, then signing in as that address, then create-or-join with "Acme" filled in, company created, link used.
  • Against a throwaway Clerk development app set up like production (waitlist mode, terms consent, email code, no passwords), with pnpm dev --clerk:
    • The link created a real pending Clerk invitation.
    • The invitation opened Clerk's sign-up page, which asked only for the terms checkbox.
    • After signing in, create-or-join showed "Acme Probe" filled in, and the link read "This link has been used".
    • resend replaced the invitation at Clerk. revoke withdrew it, and a second revoke was safe. Revoking a link whose invitation had been accepted reported accepted.
    • Clerk's development instances only hand a session back to a local app through a redirect, so the run clicked the door's Sign in once after sign-up. Production shares patchyhq.com, so this extra click doesn't happen there.
  • Not checked: production. The table arrives with the release, and the first real link waits for that deploy.

Release impact

  • Breaking — requires action from anyone already running this
  • Not breaking — no action required

The change adds one table and new routes. Nothing existing changes shape, and no configuration is new: the operator script reads the settings the server already has.

Migration id: this takes 0034_beta_links, and #1204 also takes 34. Whichever lands second renumbers to 35. The ledger test fails until it does.

  • What does a revert leave behind? The beta_links table and its rows, plus any Clerk invitations already sent. The release before ignores the table. A sent invitation still admits its person through Clerk, and they land on create-or-join without the name filled in.
  • Does the release before it still work with that? Yes.

Built by Claude Opus 5.5 (claude-opus-5-5) in Claude Code, running in T3 Code.

…ng their email

A prospect's CEO wants someone on their team to try the beta, and nobody knows
that person's email, while Clerk's waitlist only admits an invitation to a known
address. A beta link is a forwardable address, /join/<secret>, made by the
operator for a company's name. The first work email entered keeps the link, and
Clerk emails that address an ordinary invitation, whose sign-up proves the
mailbox and takes the terms. Create-or-join then marks the link used and starts
the company with the link's name, which the person can change.

`pnpm beta-links` creates, lists, resends and revokes links against an
instance's database. Each change holds the link's row lock through the Clerk
call, as company invitations do, so a revoke can't cross a send.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added area:server Touches the server area area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes labels Nov 5, 2026
…ainly

From review: a failed link's page could ask Clerk for an invitation without
limit, so it now counts its attempts and stops after five; the operator's
resend isn't counted. A claim racing another link for the same address now
gets the "already has an invitation" refusal instead of a 503. A link that
is no longer open shows its state whatever was submitted. Revoking a link
Clerk never confirmed an invitation for reports `unconfirmed`, since a lost
reply may have left one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@allisonmahmood

Copy link
Copy Markdown
Owner Author

GPT 6.1 Sol review of e5e457d, and what came of it (fixes in fed988e):

  1. Revoke can leave an invitation Patchy never heard about. If Clerk creates an invitation but its reply is lost, the link holds the address with no invitation id. Kept as an accepted risk, the same gap company invitations have: such an invitation admits only the link's own address. Revoke now reports unconfirmed instead of none, and OPERATIONS says the Clerk dashboard is the only way to withdraw it. Matching Clerk's invitations to links (tagging them with metadata and listing them per address) was judged more machinery than the risk warrants.
  2. A failed link could call Clerk without limit. Fixed: invite_attempts counts each call, and a link's page gets five attempts in all. After that it says to ask whoever sent the link. The operator's resend isn't counted.
  3. A claim racing another link for the same address answered 503. Fixed: the live-email index's unique violation now becomes the 409 "That email already has an invitation." Covered by a test that fails without the fix.
  4. An invalid email on a link no longer open showed the open form. Fixed: the email is checked only after the link's state, under its lock, so ended, sent and used links show their state whatever is posted.
  5. --json doesn't cover flags the parser refuses. Not changed: Effect's CLI prints usage to stdout before any handler runs, and this script is operator-only (ADR-0004's contract binds the patchy CLI). Parse failures still exit 1 and name the flag; the script's header now says so.

@allisonmahmood

Copy link
Copy Markdown
Owner Author

Acceptance: PASS with notes

Checked fed988e6a29f98b5b2bbab8c2588d37d770aa2ff (base 354133da06e1d005f29926789190fc5f7826d34a) on a fresh throwaway team personas instance, by GPT-6.1 Sol in the Codex harness through T3 Code. I did not write this change. No linked issue supplies Done means, so this checks the PR's What changed.

Done means

  • Create and follow a beta link: passed. Operator create --for and list --json worked against the throwaway database. The stored digest matched the secret's SHA-256; list did not return the URL/secret. Missing database configuration returned { "ok": false, "error": ... }, exit 1. Invalid --days 0 exited 1 with usage, matching the documented parser exception to JSON output.
  • One address keeps the link: passed. Chromium submitted a mixed-case address; list showed its normalized address and sent. A later different address left it unchanged with one invitation attempt. Another link claiming that address returned 409. The sent page masked the email and offered no resend form.
  • Sign in, prefill, create, and mark used: passed. Signing in as the reserved address reached Create your company with Acceptance Prospect / acceptance-prospect prefilled. Editing both fields created the renamed company and reached Home. List showed used and the new company handle; an anonymous revisit showed “This link has been used” and Sign in. Unrelated enrollment was unaffected.
  • Resend, revoke, failure/retry, and contention: passed offline. The focused suites include all 11 beta-link cases over migrated Postgres with recording, failing, accepted-invitation and slow Clerk layers, including the five-attempt cap and claim/revoke serialization. Real Clerk operations are qualified below.
  • Refusal states: passed. Direct requests returned cross-origin POST 403, malformed email 422 without reserving the link, and unknown-secret GET/POST 404. An expired unclaimed-link fixture returned 410 and refused reservation; used links stayed used beyond expiry. Responses carried no-store, same-origin referrer policy and a self-only form CSP. The browser reported no page exceptions, and the sent page had no horizontal overflow at 390px.

Golden journeys

  • Sign in: passed. Signed-out /company returned 401 with Sign in; Ben's session opened it with 200; logout restored 401.
  • Invite and join: passed. Ada invited a new address; that persona chose Join Acme Co and reached Home. A separate pending invite could be resent and revoked, disappearing from the People rows. Deactivating the new member gave that member 403; reactivation restored 200.
  • Other golden journeys do not intersect this diff. CI's browser, packed CLI, tier 2 and other required checks were green for the supplied head.

Evidence

pnpm exec vitest run packages/auth packages/companies apps/server/src/migrations.test.ts
Test Files  31 passed (31)
     Tests  324 passed (324)

Rollback answers: match the diff. The additive beta_links table/rows remain and are ignored by the preceding release. Already-sent Clerk invitations remain ordinary invitations; the previous enrollment flow can admit those people without the suggested company name. Existing contracts and data shapes are preserved, so this does not require one-way. CI rollback rehearsal passed all four stages: previous release → PR merge → previous release → PR merge, on the same data.

Not run

  • Independent real-Clerk beta-link invitation delivery, mailbox verification/terms consent, and operator resend/revoke: this run used personas, whose invitations are recorded rather than mailed. The offline cases passed; CI clerk-live was green, but that is not an independent live beta-link run.

Notes

  • Initial environment setup hit npm 12's default refusal of remote tarballs. A local allow-remote=root setting in the disposable environment's CLI directory let setup complete; no repository or personal configuration was changed. This runner issue is outside the diff.
  • pnpm dev down completed and deleted this run's instance and environment. The tracked checkout remains clean; no production, ~/.patchy, PR code, branch, body or labels were changed.

Acceptance: reserved address is masked and the sent page offers no resend form

@allisonmahmood
allisonmahmood merged commit 1d59c40 into main Nov 5, 2026
24 checks passed
allisonmahmood added a commit that referenced this pull request Nov 5, 2026
…a link (#1247)

## What changed

This adds release 38's What's new entry, written from `1d59c40`. It
covers everything merged since release 37's `through` (`dc89c70`), and
sets the `patchy` release to `0.38.0` in `packages/patchy/package.json`
and `CURRENT_RELEASE`.

| Change | PRs |
| --- | --- |
| Behind the scenes: Patchy can now give a prospect a link that lets one
person on their team skip the waitlist, for someone whose email nobody
knows yet | #1246 |

There's no announced change: nobody already using Patchy sees anything
different, and the link is handed out by Patchy, not something people
can turn on. #1245 is release 37's own entry.

## Look at

- **The entry**, at the top of `releases` in
`packages/core/src/whatsNew.ts`.
- **Rollback safety, from the live commit `354133d` (release 37) to
`1d59c40`:**
- #1246 is the only change. It adds migration `0034_beta_links`, a new
`beta_links` table that nothing earlier reads, plus the `/join/:secret`
routes. Release 37 starts with that migration in its ledger and ignores
the table. Its `rollback-rehearsal` check passed all four stages, on the
same data. Not `one-way`.
- Invitations a beta link already sent stay ordinary Clerk invitations
after a rollback: their person can still sign up, and lands on
create-or-join without the company name filled in.
- No new configuration. The operator script reads settings the server
already has.
- #1204 also uses migration id 34 and must renumber to 35 before it
lands; its ledger test will fail until it does.

**Rollback line:** If this release misbehaves, roll back to `354133d`
(release 37).

## How it was verified

- **Tests.** The `packages/core` and `packages/api` suites pass (133
tests), including `whatsNew.test.ts` and `schemas.test.ts`.
- **The range.** #1246 had a GPT 6.1 Sol review with every finding fixed
or answered in writing, acceptance PASS with notes, and all 18 required
checks green on its head before it was squash-merged.
- **Deploy state.** The live commit, pinned from `/healthz/deep`, is
`354133d` (release 37). The Deploy run updated last succeeded, and none
is unfinished.

## Release impact

- [ ] **Breaking** — requires action from anyone already running this
- [x] **Not breaking** — no action required

Text and version numbers only. Like every release, the `0.38.0` bump
tells CLIs and patch repos installed before this deploy to upgrade.

- **What does a revert leave behind?** Nothing.
- **Does the release before it still work with that?** Yes.

Built by Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, through T3
Code.

Co-authored-by: Claude Opus 5.5 <[email protected]>
@allisonmahmood
allisonmahmood deleted the t3/beta-invite-links branch November 5, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, shared testing infrastructure, development scripts and tooling area:docs Touches the docs area area:server Touches the server area area:ui Portal and first-party browser pages, shared rendering and styles size:xl Over 1,000 changed lines; review in multiple passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant