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

Groups move from one host to another, whole, keeping their DID

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

What changes

A group moves from one group host to another, whole, and keeps its DID (migration.rs, docs/design/moving.md).

  1. migratePrepare, at the source, for one who configures the group, answers three things:
    • a service token the group signs for the destination;
    • the group's handle, address and spaces;
    • an hour's token for migrateExport, which serves what nothing public serves whole: its files, and each space's state and repo.
  2. migrateReceive, at the destination, pulls the group in and keeps it switched off, with keys of its own here. It answers with what the PLC operation should name.
  3. migrateComplete, at the source, signs and sends that operation, keeping stewards' recovery keys ahead of the new host's, and switches the group off there.
  4. migrateActivate, at the destination, switches the group on once the directory names this host, and reads its spaces' index again.

What moves with it:

  • its public repo and its files;
  • in each of its spaces, its own repo and what the authority keeps (whether the space is publicly readable, who writes there and what they last wrote, and who has grants beyond its access record).

Members' repos stay at their own PDSes. The destination keeps the writer set, so it reads them on.

Why

This is step 8's third part, from the prototype's methods/migration.ts. The destination checks everything before the directory changes, and anything it can't check leaves nothing behind:

  • the token is the group's, by its current key;
  • the source is reached only at the address the group's DID names, and only at a public address;
  • the repo is signed by the group and whole;
  • each space's repo is what its commit's set hash says;
  • each file is what its CID says;
  • the mover configures the group by its own records as they arrive.

How it was checked

tests/migration.rs covers:

  • a whole move between two hosts on one directory;
  • preparing only for one who configures, and exporting only with the token;
  • receiving only for one who configures by the group's own records;
  • completing only toward what names the destination, and not once the host holds no key;
  • a fake source whose repo, file or space repo doesn't check out;
  • the handle a group takes here (a domain of its own is kept);
  • a group whose DID names no host.

These are the cases of the prototype's migration.test.ts. just cov is at 100% locally.

Shortcomings

  • A space's state moves as this host keeps it, as JSON, not as the space alpha's meta archive. A move between two group hosts doesn't need the archive, but a move to a plain PDS (the prototype's leaving) isn't here.
  • The destination builds the group's repos again from the records under its new key. The old commits aren't kept.
  • Spaces the group writes in that another authority governs don't move.
  • The opensocial migrate command that walks the four steps comes in its own pull.

🤖 Generated with Claude Code

Approved

This adds the four-step group move (prepare, receive, complete, activate). I read migration.rs, which holds the logic, and found nothing that blocks merging.

I did not read the other changed files: tests/migration.rs, the small edits in repo.rs, space.rs, store.rs, token_writes.rs, authority.rs and lib.rs, the jose additions, the docs and the lexicon. Their checks pass: check, lexicons, web and e2e succeeded, and test was still running when I looked.

Two things worth fixing, neither blocking:

  • Failed receive leaves files on disk. The cleanup calls Store::delete_account, which returns the blob CIDs, but the result is dropped. The files receive uploaded stay on disk after a failed receive, which the "leaves nothing behind" claim doesn't cover. Host::delete_account in lifecycle.rs calls remove_blobs with that list. Do the same here, but without its DID tombstone, since the DID is still the old host's.
  • The snapshot's handle is trusted. handle_here takes any handle that differs from address as "a domain of its own" and stores it without checking it. A caller who passes a mismatched handle and address can register an arbitrary handle on this host. The caller needs the group's service token, so this is low risk. Resolving the handle to the group's DID before keeping it would close it.

One smaller point: the export token travels in the query string, where access logs may capture it. It is good for an hour, but it stays valid after migrateComplete. Clearing it on completion would be tidy.

crates/group-host/src/migration.rsline 451Outdated

These lines can no longer be read.

review.knotless.dev

delete_account returns the blob CIDs, and they are dropped, so the files uploaded earlier in receive stay on disk after a failed receive. Pass them to remove_blobs, as Host::delete_account does.

Merged as 54e0ba7