~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

An account on another server moves here to become a group

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/import

What changes

An account on another server becomes a group (import.rs, docs/design/moving.md#an-account-becoming-a-group). It keeps its DID, so whoever follows it, and whatever points at it, still does.

  • checkImport says what a move would make of the account before anything moves:

    • its handle here (a domain of its own that still names it, and that neither this host nor its server gives out, comes along);
    • its address (its handle's first label, or one asked for, under this host's domain);
    • whether either is taken.
  • importAccount takes the account's own createAccount service token for this host, checked against its key in the directory. Only a did:plc account can move, and never the caller's own. It then:

    • makes the account here, switched off, with keys of its own;
    • copies its files, then its repo, checked against its key and whole;
    • answers with what the PLC operation should name.

    Its records keep their CIDs. A record this host wouldn't keep is left out. A file that doesn't come, or isn't what its CID says, is also left out, and the records holding it still point at it. If the copy fails, nothing of it stays. The one who started may start again; nobody else may.

  • completeImport:

    • sends the signed operation once it gives the account to this host as importAccount said;
    • switches the account on and tells the relays who it is;
    • makes its group, with its profile's name and words, run by whoever moved it.

Shared with moving a group. A group or account taken in keeps its address under this host's domain beside a handle of its own. It sends an #identity event when it's switched on. A failed take-in removes the files it uploaded, so it leaves none behind. group.rs can now make an existing account a group (make_group). Asked.copied lets a copied record keep pointing at a file that didn't come.

From #3mzhxpugcnjyn's review. A moved group's own domain comes along only while this host's resolvers say it names the group: the snapshot's word for it isn't enough. migrateComplete ends the export token.

Why

This is step 8's fourth part, from the prototype's methods/importAccount.ts. It is atproto's account migration with the group made at the end. The person moving the account gets the token and the signed operation from the account's own server, so only the account itself can hand its DID over.

How it was checked

tests/import.rs has 18 tests, covering the cases of the prototype's importAccount.test.ts in this host's terms. The account lives on a fake old server (its repo, its files in pages, describeServer, handle resolution), with its DID in the fake directory. The tests cover:

  • the copy, with CIDs kept;
  • an own domain kept, an address asked for, and both taken;
  • each refusal of the token, SameAccount, NotPlc and NotAllowed;
  • restarting, and failed copies leaving nothing behind;
  • unreachable servers, and files that don't come;
  • every way an operation can fail to give the account here, and the directory refusing it;
  • the label rules.

tests/migration.rs adds two tests: a moved group's own domain kept only while it names the group, and a taken one refused. It also checks that the export token ends. just cov is at 100% locally.

Shortcomings

  • importAccountSpace isn't here. It brings the spaces such an account governs, and its repos in others', in the space alpha's archives. It waits for the alpha to publish its meta archive, which the version the prototype builds against doesn't have. Its lexicon stays, unserved.
  • The old server keeps its copy until its owner deletes it there.

🤖 Generated with Claude Code

Approved

This adds checkImport, importAccount and completeImport, so a did:plc account on another server can move here and become a group. It also pulls out take_in, creds, identity and make_group so moving a group can share them. The token check is sound: it uses the account's own key, this host's audience and the createAccount method, and it refuses SameAccount and non-PLC accounts. completeImport only goes ahead once the signed operation names this host, the keys made here and the handle. Server fetches go through pinned. I found no blocking bug.

I haven't read the test files (tests/import.rs, tests/migration.rs) or the docs diffs. Of the pull's checks, check passed, web and lexicons were skipped, and test and e2e hadn't finished when I looked. I haven't verified the 100% coverage claim.

There is one gap I'd close, though it needn't block the merge. In complete_import, a failure after the PLC operation is published leaves the account stuck. That covers a failed activate_arrived, make_group, end_import or record. The account is already pointed at this host. Calling completeImport again republishes an operation whose prev is now stale, so the directory will refuse it. The user gets InvalidOperation for good and the pending row stays. Consider checking whether the directory already names this host before publishing, as migrate_activate does, and skipping the publish if it does.

crates/group-host/src/import.rsline 527Outdated

These lines can no longer be read.

review.knotless.dev

The operation is already published at line 520 by the time make_group can fail. A retry then reaches publish again and the directory refuses a stale prev. Make this step resumable, for example by skipping the publish when the directory already names this host for the DID.

Merged as 1be0ab3