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

An account's link to an outside identity is one table keyed by kind, with a prover per kind #18536

opened this

Merged 1h 8m ago, live in production

This adds accountlink (account, kind, outside id, proved at, how) beside gamelink, which stays for now. It also gives the kind interface a prover, and Minecraft's is the first. Step 1 of 2 is only the expand.

Notes

opened this

This adds account_link (account, kind, outside id, proved at, how) beside game_link, which stays for now. It also gives the kind interface a prover, and Minecraft's is the first. Step 1 of 2 is only the expand. The write path has not moved, and game_link is not dropped. The gate, bun x tsc --noEmit and the covering tests pass, including the new test/account-link.test.ts. I did not run the whole suite.

Migration

  • 20261206183000-account-link creates the table and backfills it from every game_link row that names a UUID.
  • Triggers on game_link (insert, update, delete) keep account_link in step.
  • The previous release writes only game_link, so it runs unchanged on the changed database, and its links show in the new table.
  • One UUID linked on several boxes is one account_link row. That row goes when the account's last box link for that UUID goes.
  • A link with no UUID proves nothing, so it gets no row.
  • Dropping game_link and moving the writes is left for the next release (contract). This keeps rollback safe.

Prover

  • IdentityProver in src/kinds/kind.ts is now a real interface instead of a stub: kind, clean, prove, proved and owners.
  • Minecraft's is src/kinds/minecraft/prover.ts. Its outside id is the UUID the game server lists, and cleanUuid validates it.
  • src/core/account_link.ts holds the plain table functions.

Where it is reached

  • The !forge link in src/games/chat.ts calls identity.prove after it writes game_link.
  • provenAs in src/core/proven_identities.ts reads account_link.
  • provenAs goes through core/account_link.ts instead of the prover. Importing kinds/ from core/proven_identities.ts made an import cycle that broke verify.ts at load.

Tests

  • test/account-link.test.ts covers three things:
    • A pre-change snapshot restores, boots with only the new migration applied, and keeps its links.
    • The old release's writes show up in the new table and clear it again, including the cascade when an account is deleted.
    • The prover accepts a UUID and refuses a name.
  • test/kinds.test.ts now expects two stub parts instead of three, since identity moved.

Not done

  • No page, action, API route or tool changes, so the commit says No door.
  • bun scripts/similar.ts flagged cleanUuid as 1.00 like cleanMinecraft in src/core/identities.ts. They validate different things (a UUID versus a name), so I kept both.

To try

  • bun test test/account-link.test.ts test/kinds.test.ts test/schema-migrations.test.ts

Closes #18490

commented

This adds account_link (account, kind, outside id, proved at, how) beside game_link, which stays for now. It also gives the kind interface a prover, and Minecraft's is the first. Step 1 of 2 is only the expand. The write path has not moved, and game_link is not dropped. The gate, bun x tsc --noEmit and the covering tests pass, including the new test/account-link.test.ts. I did not run the whole suite.

Migration

  • 20261206183000-account-link creates the table and backfills it from every game_link row that names a UUID.
  • Triggers on game_link (insert, update, delete) keep account_link in step.
  • The previous release writes only game_link, so it runs unchanged on the changed database, and its links show in the new table.
  • One UUID linked on several boxes is one account_link row. That row goes when the account's last box link for that UUID goes.
  • A link with no UUID proves nothing, so it gets no row.
  • Dropping game_link and moving the writes is left for the next release (contract). This keeps rollback safe.

Prover

  • IdentityProver in src/kinds/kind.ts is now a real interface instead of a stub: kind, clean, prove, proved and owners.
  • Minecraft's is src/kinds/minecraft/prover.ts. Its outside id is the UUID the game server lists, and cleanUuid validates it.
  • src/core/account_link.ts holds the plain table functions.

Where it is reached

  • The !forge link in src/games/chat.ts calls identity.prove after it writes game_link.
  • provenAs in src/core/proven_identities.ts reads account_link.
  • provenAs goes through core/account_link.ts instead of the prover. Importing kinds/ from core/proven_identities.ts made an import cycle that broke verify.ts at load.

Tests

  • test/account-link.test.ts covers three things:
    • A pre-change snapshot restores, boots with only the new migration applied, and keeps its links.
    • The old release's writes show up in the new table and clear it again, including the cascade when an account is deleted.
    • The prover accepts a UUID and refuses a name.
  • test/kinds.test.ts now expects two stub parts instead of three, since identity moved.

Not done

  • No page, action, API route or tool changes, so the commit says No door.
  • bun scripts/similar.ts flagged cleanUuid as 1.00 like cleanMinecraft in src/core/identities.ts. They validate different things (a UUID versus a name), so I kept both.

To try

  • bun test test/account-link.test.ts test/kinds.test.ts test/schema-migrations.test.ts
commented

Both of juniper's requested fixes are in and pushed. The tests I ran pass: test/account-link.test.ts and test/schema-migrations.test.ts, and bun x tsc --noEmit is clean. I did not run the full suite or the budget and duplicate-import tests the check named. I did not run bun scripts/design-lint.ts, because no src/web/ file changed.

What changed

  • Re-link leaves no stale row. INSERT OR REPLACE removes a row without firing the DELETE trigger, so account_link kept the old claim. A new BEFORE INSERT trigger on game_link now clears the account_link row of the game_link row about to be replaced. It keeps that row if the same account still holds the same UUID on another box.
  • One writer. I dropped the identity.prove call and its import from src/games/chat.ts. The triggers are the only writer while the previous release is still running. The prover's prove becomes the writer in step 2, when the writes move. The migration comment says this.
  • Re-pinned. I edited the migration in place and re-stamped its pin. This pull is its only home, so nothing has applied it yet.
  • New test. It runs the real INSERT OR REPLACE that chat.ts uses, once with a changed UUID and once with a changed user_id. It expects no stale row, and it keeps the shared row when another box still holds the UUID. I did not run the test against the old trigger to confirm it fails there.

UUID check (not settled)

  • The backfill and triggers never filtered with cleanUuid. They keep every non-empty UUID, lowercased.
  • Whether every UUID the server lists passes cleanUuid is not confirmed. The only evidence in the repo is a comment in src/games/metrics.ts showing list uuids as Alice (069a79f4-44e9-4726-a5be-fca90e38aaf5).
  • A UUID that fails the regex still gets a row, but the prover's owners lookup cleans its input and would not find it.

Not done

  • The gate reports that cleanUuid in src/kinds/minecraft/prover.ts is a near-duplicate of cleanMinecraft in src/core/identities.ts. I did not merge them.
  • The gate also notes a comment line over 100 columns in src/games/chat.ts. It said the nightly rewrap handles that on main.

There is no door change: the work is storage only. The commit says No door: with that reason.

Sign in to join this conversation.

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

Keyboard shortcuts

Docs