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

Connections on an account: verified identities the person controls, each with its own uses, and a lookup that answers only on opt-in #18120

opened this in answer to

Merged 4h 15m ago, live in production

This pull adds the core of #18108: proven email connections on an account, each with opt-in uses, an opt-in-only lookup for integrations, and report attribution that goes through that opt-in. It is partial.

Notes

opened this

This pull adds the core of #18108: proven email connections on an account, each with opt-in uses, an opt-in-only lookup for integrations, and report attribution that goes through that opt-in. It is partial. The settings page, terminal screen and Apple app are not built, and the Minecraft link and the account's proven email have not moved into the new list. I ran tsc, test/identities.test.ts, the lazy-list, migration, same-origin, feature-docs and reports tests, and the dead-code, module-state, duplicate-import and job-timing tests. All pass. I did not run the full suite or hit the preview.

What changed

  • Connections list. An email connection stays unproven until the code mailed to it is given back. The code is stored as a hash and works once, for 30 minutes, with 5 tries. Mail goes through mailerOf and sendCapped, so it uses the forge's mail key and its caps.
  • Proving an address. A unique index lets only one account prove an address. A second account that tries gets a 409.
  • Uses. Each connection has feedback and profile, both off by default. A use can only be chosen once the connection is proven.
  • Account API. GET, POST, POST /:id/confirm, PUT /:id/uses/:use and DELETE /:id under /api/v1/connections are same-origin and account-level.
  • Lookup. POST /api/v1/connections/lookup takes {email, use} and a key in X-Forge-Lookup-Key. Unknown, unproven and not-opted-in all answer {user: null}. A missing or revoked key gets a 404.
  • Lookup keys. An admin mints them at POST /api/v1/connections/lookup-keys, shown once and stored as a hash, and revokes them with DELETE …/lookup-keys/:id.
  • Rate limit and audit. Each key gets 60 calls a minute, counted from the audit table in the database. Every call is a row there.
  • Reports. fileReport takes an optional reporter. POST …/reports with a lookup key and a reporter address names the reporter only when feedback is on. Removing the connection or switching the use off stops later reports naming them, and filed reports are untouched.
  • Notice. The API says that issues already filed are not rewritten, but no settings page shows that notice yet.
  • Code layout. The new modules are core/identities.ts, actions/identities.ts and http/api/identities.ts, plus migration 20261204060000-connections. The name avoids the existing core/connections.ts and actions/connections.ts, which hold the model and cloud connections. A short how-to is in docs/features/account-identities.md.

What I left out

  • Settings page, terminal screen, Apple app. The commit line says No door: for this reason.
  • Minecraft and the proven email. The Minecraft link and the account's proven email (core/verify.ts) are still stored where they were, so there is still more than one place that says who someone is.
  • Other kinds. Only email exists. The kind column is checked against that one value, so TestFlight, GitHub and Minecraft need a migration and their own proof flows.
  • The #18081 bridge. It isn't on main, so nothing calls the reporter input yet except the reports route.
  • Scoped token. The lookup key is its own credential in its own header, not a token scope. The token layer 401s any unknown bearer, so a scoped token would have meant changes to every gate.
  • Similarity warnings. scripts/gate.ts flags a few new functions as similar to others, for example listConnections and listTeams. They are different tables and queries, so I reused nothing.

To try it

  1. Sign in, then POST /api/v1/connections {"email": …}.
  2. POST /api/v1/connections/:id/confirm {"code": …} with the mailed code.
  3. PUT /api/v1/connections/:id/uses/feedback {"on": true}.
  4. As an admin, POST /api/v1/connections/lookup-keys {"name": …}.
  5. POST /api/v1/connections/lookup with that key in X-Forge-Lookup-Key.

test/identities.test.ts runs the whole sequence from the issue's "Done when".

🤖 Generated with Claude Code

Closes #18108

Show 4 earlier items

7 earlier comments
commented

I merged main into the branch and pushed it. The only conflict was src/generated/marks.ts.

  • Resolution: that file is generated, so I took main's version and regenerated it with bun scripts/own-source.ts instead of hand-merging. The result has no conflict markers and covers both sides' marks.
  • Checks run: bun x tsc --noEmit is clean, and test/own-source.test.ts passes (3 tests).
  • Not run: I did not run any other tests locally. scripts/fast.ts could only say the affected set was too broad to name (2987 files). I stopped a broad bun test run that timed out. The forge's check runs the full suite on this push.
commented

This push is a merge of current main into the branch, with no new code. I didn't reproduce the red check on #18120, which is a planner test about a "second park". Nothing in this change touches that test, so a later merge of main may have fixed it.

I ran the four checks you named, plus the connections tests, on the merged tree. All 18 tests pass:

  • dead exports
  • module-level state that requests write to
  • the during job timing list
  • duplicate imports
  • test/identities.test.ts

bun x tsc --noEmit and bun scripts/design-lint.ts are clean too. I did not run the full suite, and I did not run the planner test.

gate.ts --fix left nothing to commit. It only warns about similar-looking functions in src/core/identities.ts and one over-long comment in src/core/account_purge.ts.

What's on the branch (connections, #18108)

  • Core and API: a connections list per account, with identities kept in src/core/identities.ts. The routes are /api/v1/connections (add, remove, confirm), per-use opt-in, and a scoped lookup with its own keys. A migration adds the tables.
  • Lookup: it answers only for a verified identifier whose owner opted into that use. Unknown, unproven and not opted in all answer the same.
  • Reports: reports filed through the bridge name the reporter only through that opt-in.
  • How-to: docs/features/account-identities.md.

Left out

  • Moving the Minecraft link and the account's proven email (core/verify.ts) into this list.
  • The OAuth and in-game proof flows.
  • The terminal, settings page and Apple app doors.

I haven't checked these against the issue's checklist.

Try it: run bun test test/identities.test.ts.

commented

Still red on current main: the survival performance set > the terminal shows the set as the page does, and s previews it. Fix it and push.

commented

The connections API now passes the two contract tests the check flagged. The other two failures passed when I re-ran them alone, so I made no change for them. The type check printed nothing, and I did not re-run the full suite, so the forge's check on this push is the full verdict.

What was wrong: the /api/v1/connections routes, added in #18108, were missing from the OpenAPI contract in two places.

  • Tag: connections was not in TAG_WORDS, so test/contract-openapi-tags.test.ts failed. I added connections to src/contract/tags.ts with a one-line description.
  • Statuses: five routes answered 404 or 422 without declaring it, which test/openapi-errors.test.ts caught. I added those statuses to refuses in the six route files under src/contract/openapi/routes/: 404 on deleteApiV1ConnectionsId and deleteApiV1ConnectionsLookupKeysId, 422 on the other four.

The other two failures: the survival performance set > the terminal shows the set… (20 s) and the doors > a push to the branch a cell runs is synced…. Both passed when I re-ran test/game-mods.test.ts and test/dev-cell.test.ts, so I treated them as timeouts under shard load, not caused by this pull. If they fail again on the new check, they need a look of their own.

Gate: bun scripts/gate.ts --fix ran and still prints "one implementation?" similarity notes about src/core/identities.ts. I did not act on them.

Pushed as 5c729b1eb.

commented

Connections now have both doors, and the review's seven items are addressed. tsc, the gate and 201 tests across 28 related files pass; the forge's check runs the full suite. I fixed two palette-roster tests that the new entry broke. The gate prints two "one implementation?" similarity notes for identityRemove and the screen test's draw, and I left them as they are.

What changed

  • Both doors (1):
    • Page: Settings › Proven emails at /settings/identities, in src/web/pages/identities.ts. It is server-rendered and escaped, and every act is a same-origin form (readForm) by the signed-in account only. NOT_RETROACTIVE sits beside the uses. It is listed in the settings nav, the palette rows, settings_routes.ts, lazy_lists.ts and marks/settings.json.
    • Terminal: the "Proven emails" screen (src/tui/screens/identities.ts) and a palette entry. Keys: a add, c code, f/p toggle a use, d remove after a y/n.
    • Shared code: both doors call the same actions as the API. The refusal words now live in one table, CONNECTION_WORDS, which the API also uses.
  • Enumeration (2): adding an address another account proved now answers 201 like any new address, mails nothing and stores an unprovable row. Its confirm answers 422 wrong_code, not 404, so it looks like a real pending connection. Only the 3-a-day mail cap on an address can still tell the two apart; the doc says so.
  • Mail abuse (3): sendCapped was keyed on the address and the whole forge only, so add-then-remove cycles were not capped per account. Sends now pass scope connection:<id>, which caps a member at 20 mails a day.
  • Audit (4): a key's rows older than 24 h are deleted on its next call, using the existing (key_id, at) index.
  • reporterFor (5): it is now a single lookup through a new findNamed, which returns the user. It returns at once, touching no table, when the header is empty.
  • Tidy (6): I removed the Use re-export (nothing imported it). A bad key name now answers invalid_name, in the code, the contract and the docs.
  • Tests (7): test/identities.test.ts now covers the same-answer 201, the per-account mail cap, invalid_name, audit pruning, and the reports route with a revoked key and with no header. The existing test that expected 409 now expects 201. New test/identities-doors.test.ts covers the page (sign-in gate, cross-origin 403, add, prove, use, remove, another account's row untouched) and the screen.

Not done: the Apple app, and moving the Minecraft link or the account's proven email into this list. The 10-per-account connection limit is unchanged; the new mail cap is what stops add/remove cycles.

Try it:

  • Open /settings/identities signed in, add an email, give back the mailed code, then turn a use on.
  • Or open "Proven emails" from the terminal palette.
[
  {"go": "/settings/identities", "look": "Proven emails page: an add-address form, the not-retroactive note, and 'None yet.' on a fresh account", "expect": "signed out it redirects to sign-in; signed in it shows the page inside the settings layout with 'Proven emails' in the Connections group"},
  {"go": "/settings/identities", "look": "Add an address, then use the code field on its row", "expect": "the row reads 'not proven yet' with a code field; a wrong code flashes 'that code is wrong or has expired'; the right one shows 'proven' with feedback and profile both off"},
  {"go": "/settings/identities", "look": "Turn feedback on, then Remove the row", "expect": "the use reads 'on' and the flash repeats that issues already filed are not rewritten; Remove deletes the row"}
]

🤖 Generated with Claude Code

commented

The check failed because the new /settings/identities page had no entry in the design audit, so the audit test counted 142 entries against 143 pages. I added the missing line to docs/design/audit.md, after /settings/origins.

test/design-audit.test.ts now passes (4 of 4) and I pushed the fix. I did not run bun x tsc --noEmit or any other tests, since the change is a single documentation line.

bun scripts/gate.ts still prints two "one implementation?" notes about similar functions (identityRemove and identityConfirm, and draw in the identities-doors test). They are advisory and I left them alone.

The commit says No door: because the change touches no page, action, API route or MCP tool.

commented

The first-view budget test was failing because Settings › Proven emails, the nav entry this pull adds, put two more words on the settings page. It had 155 words against a budget of 153. I raised the settings budget to 155 at both widths in docs/design/attention-budget.json, with a note on why, as the budget file's rule requires for a raise.

I merged main into the branch first, because its budget for settings had already moved to 153. test/attention.test.ts and test/attention-stamped.test.ts pass locally, 7 tests in all. I did not run the rest of the suite, so the full check on this push is the first run of everything else.

bun scripts/gate.ts --fix printed two "one implementation?" similarity notes and changed nothing:

  • identityRemove is 0.76 like identityConfirm in src/web/pages/identities.ts.
  • draw in test/identities-doors.test.ts is 1.00 like a text helper in test/feed-filters.test.ts.

I left both as they are. I didn't run bun x tsc --noEmit, since only the budget JSON changed.

What to look at: the budget change is the only edit in this fix. The rest of the pull is unchanged.

How to try it: bun test test/attention.test.ts test/attention-stamped.test.ts.

commented

I merged main into the branch and pushed it. Three files conflicted, and none of the conflicts needed a judgement call.

  • src/http/api.ts and src/http/lazy_lists.ts: I kept both sides. identityRoutes and the connections routes now sit next to main's new mailAwsRoutes and /api/v1/mail-aws entries.
  • src/generated/marks.ts: I took main's version and regenerated it with bun scripts/own-source.ts, so it includes the connections marks and has no conflict markers left.

bun x tsc --noEmit is clean. I ran 802 tests across 56 files covering own-source, attention, identities, connections, lazy lists and the API contract, and all passed. I did not run the full suite, so the forge's check on this push is its first run. bun scripts/gate.ts --fix left one note that I did not act on: draw in test/identities-doors.test.ts is flagged as identical to a text helper in test/feed-filters.test.ts.

The pull itself is as before: connections on an account, verified identities, the settings page and terminal screen. The settings first-view budget is at 155 words for the "Proven emails" nav entry.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs