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

An account moving here brings its spaces

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

What changes

Spaces come with an account moving here. fyi.opensocial.importAccountSpace serves while an account's move is pending (after importAccount, before completeImport). Whoever started the move hands over each of the account's spaces as its own server exports them, since only the account, signed in there, may export them:

  • meta: a space it governs, as the alpha's meta archive (com.atproto.space.exportSpaceMeta).
  • repo: its repo in a space, its own or another's, as a STAR archive (com.atproto.space.getRepo). It is checked against its commit's set hash, and records this host wouldn't keep are left out, as importAccount does.
  • blob: a file of its in a space.

A policy becomes grants. A personalspace is the group's alone. A memberspace's members get the grants it gave them, and its public reading becomes the space's. A policy this host would not keep as it says is refused with UnsupportedPolicy: anyone writing, only some apps, or a managing app. The two spaces a group makes for itself are refused with SpaceReserved. Bringing a part again replaces what came before, and starting the move over discards it all.

Spaces hear of it once it is switched on. Its repos tell their spaces' authorities nothing while it is switched off. completeImport tells each one, by the account's key here, and indexes the spaces it governs again.

atproto: STAR and the space meta archive. read_star_parts and write_star read and write a STAR archive of any profile, as the alpha's star.ts does: lengths in their shortest form and at most six bytes, the metadata in DRISL's one form with a $type, and an end only between pairs. The repo archive is built on them, and a record in one is now held to a mebibyte, as the alpha holds it. read_space_meta reads the meta archive: its sections in order, each key once and in byte order, and every writer a DID with TIDs and a digest.

Lexicon. importAccountSpace gains SpaceReserved and TooLarge, and descriptions on its output and errors.

Why

My earlier note that the alpha had no meta archive was wrong. The prototype's lockfile had moved to the October 29 alpha, which has it, but its node_modules still held the October 22 build, and I read that. The October 29 package also installs only with its @atproto/* dependencies pinned: its ranges resolve lex-cbor and lex-data to a stray 0.0.0 whose dependencies are workspace:*. That is in the reference vectors' README.

The policy becomes grants, rather than being kept as the policy object as the prototype does, because this host decides who reads and writes from its grants and a group's access records. Keeping a policy it doesn't enforce would quietly change who may use the space, so those policies are refused.

A repo doesn't tell its space while the account is switched off. An authority elsewhere checks the account's service token against the key the directory names, which is still the old server's until completeImport, and it would refuse that for good.

The changes elsewhere:

  • space_commit now honours Asked.copied, so a record in a space may point at a file that didn't come, as one in the public repo already may.
  • keeps moved from import.rs so both imports share it.
  • importAccountSpace reads a part's body only once it knows the caller is the one moving the account, and the part: an archive up to 100 MiB, a file up to BLOB_UPLOAD_LIMIT.

How it was checked

  • atproto: space-meta.json comes from space-meta.mjs, run against @atproto/space 0.0.0-spaces-alpha-20261029171913. It holds two archives the alpha writes, with what it reads back, and the 19 archives its own tests refuse. Here the two read the same, and every one it refuses is refused. The STAR tests cover each new refusal, and atproto stays at 100% of lines and functions on its own.
  • Host (tests/import.rs, porting the prototype's importAccount.test.ts space cases):
    • A memberspace with members (one a localhost did:web, its record key unencoded), writers, a file, and a repo holding it and a file that never came. A personal space. A repo in another group's space here, which grants the account writing, and one in a space that grants it nothing. Only after completeImport does the first hear of it, and the second turns it away.
    • Bringing meta and a repo again replaces them, and starting over discards them.
    • Every refusal.
    • record_key_to_did.
  • Interop (tests/interop.rs): Alice, on the reference PDS, governs a memberspace Bob reads and she writes in. What it exports is read here: her policy, Bob as a member, and her repo, whose digest is the writer set's. This runs only where GROUP_HOST_DEV_ENV names the alpha, so on CI and not on my machine.
  • cargo test --workspace passes here.

Shortcomings

  • No client drives it yet. Neither the console nor the opensocial command imports an account, so there is nothing yet that exports the parts and hands them over. That comes with an import page or command.
  • The interop test reads the reference PDS's archives but doesn't run the whole import against an account there.

Review

This builds on at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.pull/3mzipvq36bgrm (xrpc::read_body), so read that first; its commits show here until it merges. Then read import_space.rs, then the STAR rework in crates/atproto/src/space.rs.

🤖 Generated with Claude Code

Approved

This adds importAccountSpace, so a pending account move can bring its spaces (meta, repo and blob parts). A space's policy is turned into grants, and the repos tell their spaces' authorities in completeImport. The STAR reader and writer are reworked, and read_space_meta is new. I read the host source, the atproto space.rs changes and the check results. I did not read the tests, the reference vectors/scripts, the lexicon or the docs.

I found no bugs in what I read:

  • Refusing unsupported policies is the right call, and the ordering checks (meta before repos, reserved spaces, owner checks) hold up.
  • The varint and frame bounds are sound.
  • space_commit now passes asked.copied through to check, which is what lets a record point at a file that didn't come.

Checks: check, lexicons, web and e2e pass. test fails at the coverage gate. The report shows 1 line missed in total, and import_space.rs is at 99.58% on lines. Your gate is 100%, so a test or simplification is needed. A usual cause is a ? that cargo fmt put on its own line, as AGENTS.md describes. Look at import_space_repo and access first. This is the gate's to enforce, so I'm not withholding approval for it, but the pull can't merge until test is green.

Approved

This is the same pull as before: importAccountSpace lets a pending account move bring its spaces, with the STAR and space-meta archive work in atproto. Since my last review the author added two things. The space repos' query is now bound before its ? so the line counts for coverage. And the part's body is read only once the caller is known to be the one moving the account, which also takes in the read_body change merged from host/body-limit.

My earlier review found no bugs and asked for nothing except a green test. That is now done: at head 6f748f2 every check passes (check, lexicons, web, e2e and test), and the coverage gate that failed before is green.

I did not re-read the whole diff this round. Beyond the check results, I relied on the two new commits' messages and on the earlier review of the rest. The body-before-auth change is a sound way to avoid holding up to 100 MiB for an unauthenticated caller. Nothing I know of blocks the merge.

Approved

This is the same pull as before: importAccountSpace lets a pending account move bring its spaces, with the STAR and space-meta archive work in atproto. The only new commit since my last review at 6f748f2 is a merge of origin/main into the branch, at 94786e4. I didn't re-read the diff this round. I relied on my earlier reviews and on the check results.

I asked for nothing last round, and nothing is outstanding. At 94786e4 every check passes: check, lexicons, web, e2e and test, including the coverage gate. The pull is a fast-forward. I know of nothing that blocks the merge.

Merged as 552d611