chadtmiller.com/group-host
atmosphere group host
Moving
A group has to be able to leave its host, and an existing account may want to arrive here as a group. The host shouldn't be the only way out, and two hosts must never both act for the group at once.
What moves and what stays
A group's identity is its did:plc document in the PLC directory. Its records and files sit on this host, and its spaces hold its own repo here and members' repos on their PDSes. A move keeps the DID, so references to the group still hold. The DID moves by a PLC operation, a signed change the directory accepts only from a rotation key the last operation lists (DIDs and PLC).
In a group move, only the spaces the group governs move, and a repo it keeps in someone else's space stays behind. Members' repos stay on their PDSes. The new host keeps each writer's repo rev and digest, so it reads them on without waiting for a write, and members' PDSes find it through the group's DID (space sync).
Moving a group to another host
An account usually moves with its owner confirming the PLC operation by
an emailed code
(account migration).
No person owns a group's identity, so the source host signs with its
own rotation key, and the destination pulls the data from the source.
A move is four calls: migratePrepare at the source, migrateReceive
at the destination, migrateComplete at the source, then
migrateActivate at the destination. The API reference lists them.
The source prepares only while the directory's last operation lists its
key (else NotController). It answers a service JWT signed by the
group's key for the destination, and an export token for
migrateExport, which serves the files and each space's state.
The destination trusts nothing the caller says about where the group
lives. It resolves the group's DID fresh, checks the JWT is the group's
and meant for it, and pulls only from the PDS the document names. Any
failed answer from the source stops the move (SourceUnreadable). The
repo must be signed by the group's current key, and each file must hash
to its listed CID. A space repo must name the group and the space, and
its digest must equal its commit's. A missing or wrong file fails the
whole move, since the source still serves and records mustn't point at
nothing. The group gets the first label of its old address under
HANDLE_DOMAIN, and keeps a handle on a domain of its own only while
that still resolves to it.
The destination makes its own keys and rebuilds the repos as new
commits under them, so old commits go but each record keeps its CID.
It holds the account switched off, checks group.configure last
against the records that arrived, and forgets it all if anything fails.
migrateComplete then signs the next operation. It keeps the stewards'
recovery keys first, swaps the source's rotation key for the
destination's, and points the group's PDS and keys at the destination.
So the stewards can still take the group back (recovery).
If the directory refuses, the group stays on at the source. Once it's
published, the source switches the group off, and with no rotation key
left it can't move the group again.
migrateActivate answers NotYet until the directory names the
destination, and you ask again. Then the destination switches the group
on, tells relays and its spaces, and publishes its spaces' policies. So
the group is whole on exactly one host at every step.
Moving takes group.configure on the group, and the member who holds it
chooses the destination, where they must be allowed to start groups.
atgrp group move makes the four calls and resumes at activation after
an earlier run (CLI). There's no console page or
MCP tool for it, since an MCP client should never take a group away.
Details:
- A pulled file may be up to
BLOB_UPLOAD_LIMIT, and a repo or space archive up to 256 MiB.
Bringing an account here as a group
Any did:plc account on any PDS can become a group here, keeping its
DID. A did:web account can't (NotPlc), since its document lives on
its own domain. This is ordinary
account migration. A
createAccount service token shows the account's server consents, and
that server signs the PLC operation once its owner confirms an emailed
code. Only someone allowed to start groups may bring one, and never
their own account.
The host makes the account switched off with its own keys, then copies
the files and the repo, checked against the account's current key. A
record that isn't valid by the data model, or whose $type doesn't
match its collection, is left out. A file that doesn't come or doesn't
match is left out with a warning. That's looser than a group move,
because an account on an arbitrary PDS may already have lost files.
The account keeps its handle only on a domain of its own that still
resolves to it, and always gets an address under HANDLE_DOMAIN. The
API reference lists the handle rules.
Its spaces come along when its server reports spacesAlpha, and so
does the account's repo in another account's space. Personal and member
spaces both become an unlisted org.atgrp.policy. A member space keeps
its publicRead and its members as grants, and a space already under
org.atgrp.policy keeps its policy as it is. A policy this host can't
express is UnsupportedPolicy. checkImport shows the plan before
anything moves.
completeImport takes the operation the account's server signed, which
must point the account here with this host's keys (else
InvalidOperation). One the directory already has isn't sent again, so
a retry works. The host then switches the account on, tells its spaces
(silent while it was off, since they'd check the old key), and makes it
a group with the mover as founder. The old server keeps its copy until
its owner deletes it.
From the console and the command
The console's /move page signs you in, then to the account at its
server by OAuth, asking only for a createAccount token, identity
changes and reading its own spaces
(permissions). The host holds
that session, refreshes it, and revokes it when you finish or cancel,
or after 24 hours. atgrp account import does the same with the
account's password, and takes the emailed code on a second run.
When the host changes its address
Only DID documents name the host's address, so only they change. Run
group-host move-host --from <old address> with the host stopped and
PUBLIC_URL set to the new address. It repoints each account's
services, signs with the host's rotation key, and tells relays. It
skips an ended DID and one a steward has taken. If the directory fails
on one account, it moves the rest and exits with an error, so you run
it again. Handles under the old domain stay, and sessions keep working,
since the host finds OAuth tokens by hash.