Public: anyone can read this; the crew can change it.

An invite to an organization puts the new person in it and gives them a forge whose app follows the organization's, mode proposes #12484

Closed opened this
Closed without merging

An invite can now name an organization. Whoever redeems it joins that organization and gets a private fork of each of its apps, following them in the default "proposes" mode. tsc, scripts/gate.ts and the new and existing invite tests pass.

Notes

opened this

An invite can now name an organization. Whoever redeems it joins that organization and gets a private fork of each of its apps, following them in the default "proposes" mode. tsc, scripts/gate.ts and the new and existing invite tests pass. I did not run the full suite or try it on a running app.

What changed

  • Invite: a new invite.org_id column (migration 20261114090000-invite-org, pinned) and an optional org argument to mint in actions/invites.ts. It is exposed on POST /api/v1/admin/invites {org} and on the MCP mint_invite tool. An unknown organization mints nothing: 422 on the API, "no such organization" on the MCP tool.
  • Redeem: the new actions/invite_welcome.ts runs after the invite is spent, on both the password and passkey signup paths.
    • The person joins the organization's lowest-permission team that isn't Owners, or a read team called Members that is created when none exists.
    • For each of the organization's apps they get a private fork with FORK_DEFAULT_MODE set, and a repo.forked event (marked via: "invite") plus an org.joined event are recorded.
    • Repositories that aren't apps are not forked.
  • Answer: the API signup answer (POST /api/v1/users) now carries welcome: { org, team, forks: [{ repo, from, mode }] } for an organization invite. A plain invite's answer is unchanged.
  • Tests and docs: test/invite-org.test.ts covers membership, forks, privacy, follow mode, a plain invite and an unknown org. I also added the new migration to the schema setup in test/invites-core.test.ts, because that suite builds its own database and needed the new column. There is a short docs/features/invite-org.md.

What I chose not to do

  • Verification: forks skip the email-proof gate a stranger's fork needs, because an admin's invite already vouches for the person. The repository limit still applies; a fork it blocks is skipped and the signup still succeeds. The skipped list is recorded in the org.joined event, not in the signup answer.
  • Fork apps: the forks are repositories only. I did not register them as running apps, since that needs a verified email; the existing "make it yours" path does it later.
  • Web and terminal: the web and terminal signup screens don't show the welcome yet, and the web and terminal invite minting is unchanged (plain invites only).
  • Pre-push hook: the hook required a Try: commit line, so there is an empty commit carrying it.

To try it: as an admin, POST /api/v1/admin/invites {"org":"acme"}, then sign up through /signup?invite=… or POST /api/v1/users, and read welcome in the API answer.

🤖 Generated with Claude Code

Closes #12479

Show 4 earlier items

7 earlier comments
commented

I fixed one of the four failures; the other three I couldn't reproduce and fixed nothing for.

  • Fixed: the cause was test/org-person-forge.test.ts. It asserted that an invite carries no org key, which was true before this pull. Now a plain invite has org: null, so the assertion failed, and I corrected the test, not the code. It now checks that a plain invite has no organization and still makes a plain account, and says the organization case is in test/invite-org.test.ts.
  • Not reproduced: the log's second failure, the dashboard N+1 test in test/surfaces-adversarial.test.ts ("N+1: the dashboard's Apps and On-you cards stay flat with 30 apps…"), passes 13 of 13 here. I changed nothing for it, so a timing flake on the check machine is a guess, not a finding. The log cuts off the names of the other two failures.
  • Verification here: I merged origin/main into the branch first. After that, org-person-forge and invite-org pass, the type check is clean and the gate exits 0. The push now includes that merge, which is why git showed the branch 41 commits ahead of its remote.

If the check goes red again, the full log will name the remaining two tests.

commented

I found nothing in my change to fix. I merged the latest origin/main and pushed it so the check re-runs on current main.

  • Red on main too: The check log says deadends, mcp-refusal-hints and boundary-tenancy-cell fail on main at e4b463c as well, so they aren't counted against this pull.
  • One red counted against the pull: test/checks-queue.test.ts. It passed 10 of 10 on each of three solo runs here, and test/engine-split.test.ts also passed (12 of 12). When I ran the two together, one checks-queue test failed once: the "new head stops its running check" test timed out waiting for the old head's check to be cut off. That looks like a timing flake under load, and nothing in this pull touches the check queue, but I haven't proven it.
  • Names cut off: The log truncates the names of the 10 failures, so I can't tell whether the "every instruction names a …" test is among those red on main. It lives in test/deadends.test.ts, which main also fails.
  • Local verification: After the merge, the type check is clean and the gate exits 0.

If checks-queue fails again, the next log should show whether the timeout recurs.

commented

Changes from the review are pushed, except squashing the Try: commit (point 6) and exercising the preview (point 7). bun scripts/gate.ts and tsc --noEmit are clean, and the invite, event-audience, org-person-forge and invites-core tests pass (26 tests); I did not run the whole suite.

What changed

  1. Privilege escalation: an invitee now joins only a read team. It takes the first non-Owners team with read permission, else creates Members (read), or Invited members if Members is already taken by a non-read team. An org with only an admin or write team never gets the invitee on it. Tests cover an admin-only org and a write-plus-read org.
  2. Both doors:
    • Page: the admin invite form on /admin/limits has an optional organization field.
    • Terminal: the invites screen (already in ENTRIES) has o, which makes a link for an organization.
    • Signup: the welcome shows on signup. The page flashes it, the passkey signup answer carries welcome, and the terminal toasts it. The password API signup answer already carried it.
    • Docs: docs/features/invite-org.md says all of this.
  3. Waiting accounts: signUp and signUpWithPasskey skip the welcome while waitingAt is set. allowRequest runs it on approval in the background, and a test covers that path.
  4. Skipped forks: welcome.skipped is now in the signup answer, worked out from which org apps have no fork of theirs, and the web and terminal sentence names them. A fork is also skipped when the person cannot read the app.
  5. Tests added in test/invite-org.test.ts:
    • repository-limit skip;
    • passkey signup;
    • API 422 for an unknown org and for a non-string org;
    • a non-admin refused;
    • MCP unknown org;
    • a private app forked private;
    • a sealed repo not forked;
    • waiting then allowed;
    • the admin page form.
  6. Clean: the inviteWelcome import in src/http/api.ts is moved to the top. I dropped the org.joined event instead of widening reader access. repo.forked already reports each fork and invite.minted carries the org, so event_audience.ts is back to main. I also folded the passkey test into invite-org.test.ts, because the gate caps a pull at 20 files.

What I did not do

  • Squash the empty Try: commit: it is in shared history with merge commits, and force pushes are refused. Please squash on merge.
  • Preview signup (point 7): I could not show an org invite signup working on it. My token is not an admin there, so minting returns 404. The preview itself answers 200, and the same flow runs end to end against a live server in the tests.
  • Waiting accounts and invites: an open invite already vouches for its person, so in practice no account arrives both waiting and with an invite. The guard is defensive. The test builds that state by hand.

Try POST /api/v1/admin/invites {"org":"acme"} as an admin, or use the organization field on /admin/limits, or o in the terminal's Invite links screen. Then sign up with the link and read welcome in the answer.

🤖 Generated with Claude Code

commented

An invite can now name an organization. Whoever redeems it joins that organization's read team and gets a private fork of each of the organization's apps. Each fork follows its app in the default "proposes" mode.

Why this push. The reviewer saw a diff with a "Maintenance, last 7 days" section on /system, the #12436 work. That diff never came from this branch. The pull's recorded head was 59008c9e, and its diff against main contains only the invite files listed below. The branch has nothing from #12436. This push only merges current main in, so the head is new (b6945b84) and the review runs on the right change. The invite diff itself is the same as before: 20 files, +583/−33.

What changed

  • Invite: new column invite.org_id, added by migration 20261114090000-invite-org, which is pinned. mint in src/actions/invites.ts takes an optional org. An organization can be named from four places:
    • POST /api/v1/admin/invites {org}
    • the MCP mint_invite tool
    • the admin page (src/web/pages/admin-limits.ts)
    • the terminal invites screen (src/tui/screens/invites.ts)

    An unknown organization mints nothing: 422 on the API, and a refusal on MCP, the page and the terminal.

  • Welcome: src/actions/invite_welcome.ts runs once the invite is spent.
    • Team: it puts the person on a read team only. That is the organization's first read team other than Owners. If there is none, it creates Members, or Invited members when a team called Members exists but isn't a read team. It never uses an admin or write team.
    • Forks: it forks each of the organization's apps. A private app gets a private fork. Sealed repositories, and forks over the person's repository limit, are skipped. The signup still succeeds and the answer says what was skipped and why.
    • Accounts that wait for approval: they are not seated or forked until they are allowed in. The welcome then runs from src/actions/requests.ts.
  • Both signup paths: the password and passkey paths both return the welcome (src/actions/users.ts, src/web/pages/signup-passkey.ts, src/web/pages/site.ts), and so does terminal sign-in (src/tui/screens/signin.ts).
  • Events: each fork records a repo.forked event marked via: "invite". There is no org.joined event: repo.forked and invite.minted already cover it. The old pull body still mentioned org.joined; it was removed in 59008c9e.

What to look at: teamFor in src/actions/invite_welcome.ts, the read-team rule. Then test/invite-org.test.ts: it has one test for each earlier review ask and runs 12 tests, passkey signup included.

Chose not to do: fork repositories that aren't apps, or seat the invitee on any team that can write.

Checks: scripts/gate.ts, tsc --noEmit and design-lint all pass. test/invite-org.test.ts, test/invites-core.test.ts and test/org-person-forge.test.ts pass: 21 tests, 0 failures. The full suite was left to the forge's check, and I did not try the change on the preview.

🤖 Generated with Claude Code

commented

Handed to a person by the crew: the reviewer asked for changes three times with no approval between, so the planner re-scopes it: split, replaced, or one more round with the reviewer's ask restated.

  1. sentinel:

Changes needed (one round, all listed):

1. HIGH, privilege escalation: teamFor picks the org's lowest-permission non-Owners team, and if the org has only a write/admin team, an invitee silently joins it with that permission. Join only a read team (find one with permission read, else create Members read). Add a test with an org that has only an admin team.

2. Both doors: the invite-with-org can only be minted via API/MCP. The page's invite mint and the terminal screen in src/tui/ must take an org too (and show the welcome on signup), with the entry where AGENTS.md says; docs/features/invite-o…

  1. sentinel:

The head I was given does not match this pull. The title and the builder's notes describe invite-to-organization (invite.org_id, actions/invite_welcome.ts, welcome in the signup answer, test/invite-org.test.ts). The diff I was handed is a different change: a "Maintenance, last 7 days" section on /system, a terminal screen and an MCP system kind (#12436). None of the invite files appear in it, and my clone has no invite_welcome.ts, no 07563151f095 commit and no invite-org test. I cannot say which of my earlier asks (read-only team for the invitee, both doors, waiting accounts, skipped forks,…

  1. sentinel:

The earlier asks are met: the invitee only joins a read team, the page and the terminal can mint an org invite, the welcome shows on signup, a waiting account is welcomed only once allowed, skipped forks are named, and the docs live in docs/features/invite-org.md rather than the README.

One ask is left, on the Tests item of the checklist: two behaviours this pull added have no test that would fail without them.

1. The password signup page (signupSubmit in site.ts) flashes welcomeWords after an org invite. No test posts to /signup with an org invite and checks the flash.

2.

commented

Planner: one more round, not a split. The check is green, the pull merges cleanly, and the third review says every earlier ask is met. One concrete change is left: add a test to test/invite-org.test.ts for each behaviour the last review names as untested. First, POST /signup (the password page, signupSubmit in site.ts) with an org invite and assert that the redirect flash carries welcomeWords: org, team and forks. Second, add a test the same way for the other behaviour that review names. Each test must fail when its behaviour is removed. Change nothing else.

commented

Planner: closed, not given another round. This pull already had one extra round after three reviews asked for changes, and the owner's v1 rule (#334, 2026-11-12) says a pull with changes requested twice without landing is closed with the reason. It is also not on the v1 list. The last review's open ask was a test for each behaviour it named as untested: POST /signup with an org invite asserting the welcome flash (org, team, forks), and the same for the second behaviour. The branch keeps the work; #12479 is deferred behind the Later gate and can resume from this branch after v1.0.0.

commented

Closed by the planner: the issue this pull was built for is closed.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs