zat.dev/zds
atproto pds · mirror of https://tangled.org/zat.dev/zds
zds 0.25.1 Latest 2 packages, all images
account takedown runbook
This runbook is for operator action against accounts hosted on this ZDS instance. It covers test-account cleanup, emergency suspension, and long-term host takedown. It is not a global identity takedown mechanism.
authority boundary
A PDS operator controls local hosting for accounts on that PDS:
- whether this PDS reports a hosted account as active
- whether this PDS serves the account's repo, records, and blobs
- whether this PDS accepts authenticated writes for the account
- whether this PDS emits account-status events on its local firehose
- whether this PDS retains or purges local account data according to policy
A PDS operator does not, by this action alone, erase all downstream copies, control every relay or appview, or tombstone a PLC identity. Downstream services are expected to respect account-status changes, but propagation is hop-by-hop and can lag or diverge.
References:
- Account lifecycle guide: https://atproto.com/guides/account-lifecycle
- Account hosting status spec: https://atproto.com/specs/account
- Sync and
#accountevents: https://atproto.com/specs/sync
status vocabulary
Atproto distinguishes several inactive hosting states:
deactivated: user or host temporarily pauses the account. Content should not be displayed or redistributed, but infrastructure does not need to delete local copies.suspended: host temporarily pauses the account.takendown: host or service removes the repository long-term for policy or terms reasons.deleted: account deletion. Downstream services should stop serving content and may delete data according to policy.
ZDS stores account hosting state in accounts.account_status. The currently
implemented operator states are:
activedeactivatedtakendown
suspended is reserved vocabulary from the protocol, but ZDS does not yet
expose an operator workflow for it. deleted is reached only through
permanent deletion (below); no account row carries it.
Current behavior:
com.atproto.server.deactivateAccountsetsaccount_status: "deactivated". Under a takedown it records the deactivation separately, so clearing the takedown leaves the account deactivated, as the reference PDS keepsdeactivatedAtapart from the takedown.com.atproto.server.activateAccountreturns the account toactiveonly fromdeactivated.com.atproto.admin.updateSubjectStatuscan apply or cleartakendownfor a repo subject, and take down or restore a single record or blob (see record and blob takedowns).com.atproto.admin.getSubjectStatusreads the takedown status of an account, record, or blob, and the account's deactivation.- applying
takendownends refresh tokens and revokes OAuth token families. Access tokens stay valid until they expire, as in the reference PDS, so clients getAccountTakedowninstead of a dead session. - ZDS emits a
#accountevent withactive: falseand the precise inactive status. com.atproto.sync.getRepoStatusreportsactive: falseand the precise inactive status, and omitsrevwhile inactive.- public repo/blob/read XRPCs and authenticated repo writes are denied while the account is inactive.
response levels
test account cleanup
Use this when the operator owns the test account and wants to remove clutter.
Default action:
- Verify the account DID and handle.
- Export or snapshot enough metadata to undo mistakes.
- Deactivate first.
- Leave physical purge as a separate, reviewed step.
temporary safety pause
Use this when an account may be compromised, abusive, or causing operational harm, but the final policy decision is not ready.
Default action:
- Capture evidence and timestamps.
- Deactivate the account.
- Revoke active local sessions and OAuth grants if the compromise involves credentials.
- Verify
getRepoStatusreports inactive. - Watch relay/appview behavior and logs.
- Decide later whether to reactivate, keep suspended, or perform long-term takedown.
long-term host takedown
Use this when the PDS will no longer host the account.
ZDS has a first-class takendown state for hosted repo subjects. It stops local
hosting without deleting rows or blob bytes. Treat takedown as the normal
long-term operator action; treat physical purge as a separate retention-policy
decision.
Behavior:
- durable status distinct from user deactivation
#accountevent withactive: falseandstatus: "takendown"getRepoStatusreturnsactive: falseandstatus: "takendown"- writes, repo exports, record reads, and blob reads are denied
- refresh tokens end and OAuth grants are revoked; access tokens run out on their own
Remaining gap:
- ZDS should add a richer admin audit row for operator status changes. Until then, preserve external notes with actor, reason, timestamps, and affected DID.
investigation checklist
Before changing account state:
fly ssh console -a zds-pds -C "sqlite3 /data/zds.sqlite3 \
\"select handle,did,account_status,datetime(created_at,'unixepoch'),\
datetime(activated_at,'unixepoch'),email \
from accounts order by created_at;\""
For a candidate DID, inspect footprint before deciding:
did='did:plc:example'
fly ssh console -a zds-pds -C "sqlite3 /data/zds.sqlite3 \"
select 'records', count(*) from records where did='$did'
union all select 'repo_blocks', count(*) from repo_blocks where did='$did'
union all select 'commits', count(*) from commits where did='$did'
union all select 'blobs', count(*) from blobs where did='$did'
union all select 'spaces_owned', count(*) from permissioned_spaces where authority_did='$did'
union all select 'space_actor_state', count(*) from permissioned_space_actor_state where actor_did='$did'
union all select 'space_records', count(*) from permissioned_space_records where repo_did='$did'
union all select 'space_repos', count(*) from permissioned_space_repos where repo_did='$did'
union all select 'session_tokens', count(*) from session_tokens where did='$did'
union all select 'oauth_tokens', count(*) from oauth_tokens where did='$did';
\""
Record:
- handle and DID
- who requested action
- why action is justified
- whether the account is operator-owned test data or another user's account
- current record/blob/space footprint
- whether a backup is needed before action
- planned status and retention policy
current ZDS actions
For user-initiated deactivation, use the existing XRPC with the user's own bearer token.
For operator-driven takedown, use the admin XRPC with ZDS_ADMIN_TOKEN:
curl -fsS -X POST "https://pds.zat.dev/xrpc/com.atproto.admin.updateSubjectStatus" \
-H "authorization: Bearer $ZDS_ADMIN_TOKEN" \
-H "content-type: application/json" \
--data-binary @- <<JSON | jq .
{
"subject": {
"$type": "com.atproto.admin.defs#repoRef",
"did": "$did"
},
"takedown": {
"applied": true,
"ref": "operator-note-or-ticket"
}
}
JSON
A takedown ends the account's refresh tokens and stops it serving to anyone else,
and its spaces stop issuing credentials and listing writers. It does not trap
the account: as proposal 0016 and the reference PDS intend, the owner can still
sign in with createSession and "allowTakendown": true to a limited session
that exports its repo, blobs, preferences, and spaces
(sync.getRepo/getBlob/listBlobs, app.bsky.actor.getPreferences,
com.atproto.space.listSpaces/exportSpaceMeta/getRepo/listBlobs/getBlob),
signs PLC operations, and requests service auth for
com.atproto.server.createAccount on a new host. It can also deactivate
itself and file a com.atproto.moderation.createReport appeal. It cannot write
or change settings. Use deletion, not takedown, if the data must not leave.
To clear an operator takedown:
curl -fsS -X POST "https://pds.zat.dev/xrpc/com.atproto.admin.updateSubjectStatus" \
-H "authorization: Bearer $ZDS_ADMIN_TOKEN" \
-H "content-type: application/json" \
--data-binary @- <<JSON | jq .
{
"subject": {
"$type": "com.atproto.admin.defs#repoRef",
"did": "$did"
},
"takedown": {
"applied": false
}
}
JSON
To permanently delete an account, as pdsadmin account delete does on the
reference PDS:
curl -fsS -X POST "https://pds.zat.dev/xrpc/com.atproto.admin.deleteAccount" \
-H "authorization: Bearer $ZDS_ADMIN_TOKEN" \
-H "content-type: application/json" \
--data "$(jq -nc --arg did "$did" '{did:$did}')"
This removes the account and everything it owns (records, commits, blocks,
blobs, sessions, credentials, spaces it is authority for), replaces its firehose
history with one #account event with status: "deleted", notifies crawlers,
and deletes its blob files. It cannot be undone; take a database backup first
when the account might matter. It does not touch PLC: the DID keeps pointing
here and resolves to RepoNotFound. An unknown DID returns AccountNotFound.
Prefer deactivation or takedown when the account may need to come back.
If direct SQL is unavoidable in an emergency, the minimum semantic behavior is:
- Set
account_status. - Insert a
#accountevent withactive: falseand the precise status. - Notify crawlers.
- Revoke tokens if credential compromise is part of the incident.
Do not perform only step 1 and call it done; downstream services learn about status through repo-status reads and firehose account events.
verification
After deactivation or takedown:
curl -fsS "https://pds.zat.dev/xrpc/com.atproto.sync.getRepoStatus?did=$did" | jq .
Expected for ZDS takedown:
{
"did": "did:plc:...",
"active": false,
"status": "takendown"
}
Also verify:
- the account does not appear as active on the landing page
- repo export, record reads, and blob reads do not continue to make unavailable content public
- the firehose emitted a recent
#accountevent - relays/appviews eventually stop serving or redistributing the account's content
record and blob takedowns
For one piece of content rather than a whole account, take down the record or the blob. The subjects and responses follow the reference PDS.
# a record: a com.atproto.repo.strongRef
curl -fsS -X POST "https://pds.zat.dev/xrpc/com.atproto.admin.updateSubjectStatus" \
-H "authorization: Bearer $ZDS_ADMIN_TOKEN" -H 'content-type: application/json' \
--data '{"subject":{"$type":"com.atproto.repo.strongRef","uri":"at://did:plc:.../app.bsky.feed.post/...","cid":"bafy..."},"takedown":{"applied":true,"ref":"case-123"}}'
# a blob: a com.atproto.admin.defs#repoBlobRef
curl -fsS -X POST "https://pds.zat.dev/xrpc/com.atproto.admin.updateSubjectStatus" \
-H "authorization: Bearer $ZDS_ADMIN_TOKEN" -H 'content-type: application/json' \
--data '{"subject":{"$type":"com.atproto.admin.defs#repoBlobRef","did":"did:plc:...","cid":"bafk..."},"takedown":{"applied":true}}'
# read either back
curl -fsS -G -H "authorization: Bearer $ZDS_ADMIN_TOKEN" --data-urlencode "uri=at://..." \
"https://pds.zat.dev/xrpc/com.atproto.admin.getSubjectStatus"
curl -fsS -H "authorization: Bearer $ZDS_ADMIN_TOKEN" \
"https://pds.zat.dev/xrpc/com.atproto.admin.getSubjectStatus?did=did:plc:...&blob=bafk..."
Send "applied": false to restore. A takedown without a ref is stamped with
the current time.
- A taken down record answers
repo.getRecordwithRecordNotFoundand is left out ofrepo.listRecords. It stays in the signed repo, sosync.getRepoandsync.getRecordstill serve it, as on the reference PDS. Editing the record keeps the takedown; deleting it ends the takedown. - A taken down blob answers
sync.getBlobandspace.getBlobwithBlobNotFound, so it is covered in every space the account writes to, andrepo.uploadBlobrefuses it with "Blob has been takendown, cannot re-upload". The bytes stay on disk until the takedown is lifted or the account is purged. - Neither changes the account's status or emits a firehose event.
physical purge
Physical purge is different from account status.
Before purging rows or blob bytes:
- confirm this is operator-owned test data, or that policy/terms require purge
- take a database backup or Fly volume snapshot if rollback matters
- understand foreign-key cascades for the affected tables
- decide whether global blob/block tables may contain shared data
- record what was deleted
For non-test accounts, prefer a two-step process:
- deactivate or takedown now
- purge after a retention window
This keeps the emergency action reversible while still stopping local hosting.
remaining manual boundary
ZDS has first-class user deactivation and operator takedown, including token
revocation, repo-status responses, and #account events. Deleting an account
removes its rows, repo, space data, and blobs here and emits a deleted
#account event. An operator deletes one with
com.atproto.admin.deleteAccount, and an account deletes itself with
com.atproto.server.requestAccountDelete (which emails a code) and
com.atproto.server.deleteAccount (DID, password, and that code). Neither
reaches downstream copies, and neither changes the DID's PLC record unless the
host opts in (see the operator guide). Choosing to purge rather than take down
stays a reviewed decision, for the reasons in physical purge.
Do not keep live account identifiers or database footprints in this runbook. Capture incident-specific evidence in the operator's private record, then use the investigation and verification steps above.