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

opensocial import moves an account and its spaces here

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

What changes

opensocial import <account> [--address <label>] moves an account from its server here, to become a group run by whoever is signed in (OPENSOCIAL_AS). It signs in to the account at its own server with OPENSOCIAL_IMPORT_PASSWORD, the account's own password, since its server signs its identity over for no app password. Then it:

  1. checks the plan (checkImport), and stops with the host's reason if the move is refused;
  2. hands over the account's createAccount token (importAccount);
  3. brings each space the account governs or wrote in, as its server exports them: a governed space's meta first, then its files there, then its repo (importAccountSpace);
  4. has the account's server email a code.

opensocial import <account> --code <code> then has that server sign the PLC operation and calls completeImport.

checkImport says more. It now answers with pds, the server the account lives on. While the caller's own move of the account is pending, it also answers with recommendedCreds, what the operation should name, so the second run needs nothing kept from the first. Both are new optional output fields.

The harness catches mailed codes. harness/pds.mjs keeps each PLC code the reference PDS mails, by address, and serves it at mail (GET <mail>?to=<address>), as the account's inbox would have it.

Why

A console page, or a command, was the missing client for the import methods. You chose the command first, and a console page next. The command already signs in as a person with a password. A page needs a second, broad sign-in to the moving account, which the host's atproto-only console sign-in doesn't hold.

The move is two runs rather than a prompt for the code, because an email can take a while to arrive and the process may end in between. checkImport gives back what the second run needs, rather than the command keeping state on disk.

How it was checked

tests/commands.rs moves an account on the reference PDS. It makes its own account, so the shared Alice and Bob stay put. That account governs a memberspace Alice reads, holding a record with a file, and a personal space it hasn't written in.

The test refuses three runs: one without OPENSOCIAL_IMPORT_PASSWORD, one asking for an address the host refuses, and --code before any move has started. Then it runs import, reads the code from the harness, and runs import --code. On the host, the account is switched on, the forum is public with Alice reading it, the account's repo there holds the record, and the forum's writer set has heard of it.

tests/import.rs checks that checkImport answers with pds, and with recommendedCreds for whoever is moving the account and nobody else.

The command test needs the alpha's spaces (listSpaces), so it runs on CI only. On my machine it returns early.

Shortcomings

  • It moves one account in one go. If the first run fails partway, running it again starts over: importAccount discards what the earlier start copied.
  • A space file the account's server lists but won't serve fails the run, rather than being left out as importAccount leaves out a missing file.
  • The console page is next.

🤖 Generated with Claude Code

Approved

This adds opensocial import, which moves an account and its spaces in two runs. It also makes checkImport answer with pds and, for the person doing the move, recommendedCreds. The harness now keeps the PLC codes the reference PDS mails. I read the whole diff against AGENTS.md and found nothing that must change. I did not run the checks, and the command test returns early without the space alpha.

The code, tests and docs match each other. The docs the repo asks for (cli.md, moving.md, the README, the lexicon) are updated, and the #an-account-becoming-a-group anchor exists.

One small risk: check_import calls account.expect("a move's account") at crates/group-host/src/import.rs:387. It relies on importAccount having created the account row whenever an account_import row exists. I could not see that start_import and the account insert happen in one transaction. If a crash falls between them, a checkImport from the person moving the account would panic. Returning None, so recommendedCreds is left out, would be safer. This is not a blocker.

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

These lines can no longer be read.

review.knotless.dev

This expect panics if a pending move has no account row, for example after a crash between the two inserts. Skipping recommendedCreds in that case would be safer.

chadtmiller.com

A pending move can't exist without its account row: account_import.did REFERENCES account (did), and the host runs with foreign_keys on (store.rs:791). So the database refuses the pending row without the account, and deleting an account removes its pending move first (store.rs:500). The account is also made before the move is recorded (take_in, then start_import), so a crash between them leaves no pending row. The expect states that invariant rather than guarding a case that can happen, as completeImport's does, so I've left it.

Approved

The only change since my last review is the commit "Ask for the code with no body, as the method takes none". It stops the code request from sending a body, which fits a method that takes none. I found nothing wrong with it. I did not run the checks.

My earlier note is still open, and it was not a blocker. The expect("a move's account") calls in crates/group-host/src/import.rs, at line 387 and again near line 516, would panic if a pending move had no account row. Returning None there is still safer. Merging as it is is fine.

Approved

Since my last review there are two commits. One adds a small next helper and turns the listing loops into while let. The other extends the command test. I found nothing wrong and did not run the checks.

  • Listing loops: pagination behaves as before. The first page is requested with no cursor, and the loop stops when the cursor is empty.
  • Missing files: a file the server lists but won't serve now fails the run with {space} has no file {cid}. The PR body's Shortcomings section already says this.
  • Test: the account now writes in a calendar that Alice governs, and the move uses --address. The asserts match: 3 spaces, 2 records, 1 file, and the calendar's paths are checked on the host.

My earlier note is still open and was never a blocker. The expect("a move's account") calls in crates/group-host/src/import.rs at lines 387 and 516 would panic if a pending move had no account row. Returning None there would be safer. Merging as it is is fine.

Merged as 4764bfb