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

zat.dev/zds

atproto pds · mirror of https://tangled.org/zat.dev/zds

0
0
121 lines · 6.1 KB Raw History

Space policy upgrade (v0.7.0)

History: the v0.7.0 upgrade guide for the October 29, 2026 alpha. Later alphas renamed several methods it names (getSpaceCredential is authorizeSpaceSync, listRepos is listWriters); the current contract is permissioned data.

ZDS v0.7.0 adopts the October 29, 2026 Spaces alpha (migration guide, reference implementation at 5d88b414a). A space is governed by one policy object instead of the simplespace read policy, write policy, and app access. Old routes and request shapes are removed, not translated.

Client changes

October 22October 29
com.atproto.simplespace.{createSpace,updateSpace,getSpace,deleteSpace}com.atproto.space.*
com.atproto.simplespace.{putMember,removeMember,listMembers}com.atproto.memberspace.*
com.atproto.simplespace.checkUserAccesscom.atproto.managedspace.checkUserAccess
readPolicy, writePolicy, appAccesspolicy
{
  "spaceType": "example.shared.notes",
  "policy": {"$type": "com.atproto.memberspace.policy", "publicRead": true}
}
  • updateSpace takes {space, policy} and replaces the policy wholesale. To change one field, read it with getSpace and send the whole object back.
  • getSpace returns {uri, policy} to the owner only. A space credential gets 401; syncers read the published com.atproto.space.policy/self record.
  • Member methods on a space under another policy answer PolicyMismatch.
  • A user the policy refuses gets SpaceNotFound from getSpaceCredential, not AccountNotAuthorized. AppNotAuthorized comes only after the user passes.
  • Managing apps serve com.atproto.managedspace.checkAccess (the lexicon review's name), check lxm against that NSID, and answer read and write together. ZDS omits repo for a credential request that carries no delegation token.
  • The authority no longer appears in its own member list; it is authorized under every policy without one.

New methods: com.atproto.space.removeWriter and com.atproto.space.clearRecords, and since v0.7.1 the account-migration methods below.

Moving spaces with an account (v0.7.1)

After the usual account migration steps, a migration tool:

  1. Lists the account's spaces on the old host with com.atproto.space.listSpaces, following cursor. The spaces the account is the authority of are those whose space URI names the account's DID.
  2. For each owned space, downloads com.atproto.space.exportSpaceMeta?space=… and POSTs the bytes to com.atproto.space.importSpaceMeta on the new host with Content-Type: application/vnd.dasl.star. This must come before importing the account's own repo in that space, which otherwise answers SpaceNotFound.
  3. For each space the account holds a repo in, downloads com.atproto.space.getRepo for its own repo and POSTs it to com.atproto.space.importRepo, then copies the repo's blobs with com.atproto.space.listBlobs and getBlob on the old host and com.atproto.repo.uploadBlob on the new one. A blob an imported record references is kept.

Imports replace what the new host holds, so a failed step can be retried. They take the account's own session or OAuth (manage=create and manage=update for importSpaceMeta, create for each collection in the archive for importRepo), not an app password, and accept archives up to 128 MiB. Writer entries keep their spaceRev, so syncers' listRepos cursors stay valid; the imported repo gets a new rev with unchanged data. Notification registrations, credential revocations, and deleted-space tombstones are not carried over.

Stored data

Startup converts each authority space once, in one transaction, as the reference PDS's 006-space-policy does:

stored simplespace configurationpolicy
managing app on read, write, or bothmanagedspace with that app; member list and app allow-list deleted
otherwise, public readmemberspace with publicRead: true
otherwise, public writememberspace with publicWrite: true
app access allow-listmemberspace allowedApps

simplespace_members moves to memberspace_members without the authority's own rows, and the per-side policy columns are dropped. Migrated spaces publish nothing. A binary rollback cannot read the new schema, so back up the database before upgrading.

A configuration with a managing app on only one side has no exact equivalent: the app is then asked about both sides, a public read side stops issuing credentials without a delegation token, and a member list or allow-list is dropped. Before deploying, list affected spaces with the read-only query in tools/space-policy-preflight.sql against a copy of the database:

sqlite3 -readonly zds-copy.sqlite3 < tools/space-policy-preflight.sql

No rows means no space changes access.

Differences from the reference PDS

  • checkAccess on ZDS is the generic PDS answer, denying both read and write.
  • ZDS validates managingApp as a DID with an optional non-empty service fragment; the reference checks only the did: prefix.
  • clearRecords applies no separate write rate limit; ZDS has none for space writes.
  • The space imports accept up to 128 MiB, as com.atproto.repo.importRepo does, and have no "accepting imports" switch. com.atproto.repo.importRepo itself still accepts app-password sessions; the space imports do not. Aligning repo.importRepo is a follow-up.

Validation

just test covers policy normalization and rejection, the legacy mapping, the startup migration and its restart, published records through every flag and $type change, writer removal, and clearRecords (scope checks, kept records, the empty digest, no-op). just smoke-permissioned exercises the routes over HTTP, including a stub managing app for read and write checks.