AGENTS.md #
PDS MOOver: tools to migrate an atmosphere account to a new PDS, find missing blobs, keep backups and restore from them. The repo is two halves that only meet over XRPC:
- Rust (Cargo workspace:
web,worker,cron-worker,admin_cli,shared,lexicon_types_crate): the backup service and its XRPC API. It does not serve or build the UI. - JavaScript (pnpm workspace:
web-uiandpackages/*): the frontend and the migration logic.
JavaScript layout #
web-ui/– SvelteKit 2 + Svelte 5 (runes) app. The user signs in through their own PDS with atproto OAuth and all migration logic runs in the browser. The server only serves pages and/oauth-client-metadata.json(web-ui/src/routes/oauth-client-metadata.json/+server.ts), whose public URL is the OAuthclient_id.packages/moover/–@pds-moover/moover, the migration logic (Migrator,MissingBlobs,BackupService,Restore,PlcOps, rotation key helpers). Platform agnostic: no SvelteKit, no browser globals, no storage. Sessions and storage are handed in by the caller.packages/lexicons/–@pds-moover/lexicons, generated TypeScript for the JSON in/lexicons.packages/mock-atmosphere/– in-memory mock network for tests (see Testing).
Commands #
Run from the repo root (pnpm only; the packageManager pin and .npmrc engine-strict live there).
pnpm installpnpm dev– the web ui. Must be http://127.0.0.1:5173: dev uses an atproto loopback OAuth client, authorization servers only redirect to127.0.0.1, and the OAuth client refuses to run onlocalhost.pnpm lint– ESLint (web-ui)pnpm check– svelte-check for web-ui,tsc --noEmitfor packages/mooverpnpm test– vitest in web-ui and packages/moover (colocated*.test.ts), node:test in packages/mock-atmosphere. Single file:pnpm --filter @pds-moover/moover test lib/plc-ops.test.tspnpm test:e2e– builds the mock, then runs Playwright in web-uipnpm build– builds every package (lexicons first, in dependency order)
Verify changes with:
pnpm lint && pnpm check && pnpm test && pnpm test:e2e
Workspace rules #
- Workspace packages export their TypeScript source (
exportspoints atlib/*.ts), so nothing needs building for dev, typecheck or tests.publishConfig.exportsswaps indist/on publish. - In
web-ui/package.jsonthe workspace packages are devDependencies on purpose: adapter-node leavesdependenciesas runtime imports, and those would resolve to.tsfiles. As devDependencies (plusssr.noExternalinweb-ui/vite.config.ts) they are bundled. @atproto/lex*versions are pinned once, in thecatalogofpnpm-workspace.yaml. The migration code doesinstanceofchecks against their classes, so the workspace (and the bundle: seededupeinweb-ui/vite.config.ts) must contain exactly one copy.
Lexicons (generated code) #
packages/lexicons/lib/lexicons/** is generated from /lexicons by pnpm lex:generate
(@atproto/lex codegen). Never hand-edit it: add or change the lexicon JSON under /lexicons,
rerun the script, import from @pds-moover/lexicons. The Rust types in lexicon_types_crate are
generated separately (jacquard) from the same JSON and are not part of the JS workflow.
Formatting #
Formatter is oxfmt (.oxfmtrc.json: no semicolons, single quotes, arrowParens: avoid). It is
not a devDependency: run oxfmt (or pnpm dlx oxfmt). ESLint enforces single quotes; oxlint
(.oxlintrc.json, pnpm --filter web-ui exec oxlint) is a secondary linter with no package
script. Older files keep the style they were written in; match the file you are editing.
OAuth architecture notes #
- Each page requests only the scopes it needs (
web-ui/src/lib/oauth/scopes.ts); the client metadata advertises the union (ALL_SCOPES). - Dev = loopback client (client_id =
http://localhost?redirect_uri=...&scope=...); prod = hosted client_idhttps://<PUBLIC_APP_URL>/oauth-client-metadata.json. - The source account is the OAuth session (persisted by the browser OAuth client in IndexedDB).
The destination account is a password session (
@atproto/lex-password-session) cached in localStorage (web-ui/src/lib/sessionCache.ts+ per-flow wrappers) so a migration can resume after a refresh. - The package never imports the OAuth client. It takes any
AccountAgent(did+fetchHandler), which both an OAuth session and a password session satisfy.
Sentry #
@sentry/sveltekitin web-ui only. Both sides readPUBLIC_SENTRY_DSNat runtime and stay off when it is unset (local dev, e2e). Browser init isweb-ui/src/hooks.client.ts, server init isweb-ui/src/instrumentation.server.ts(loaded viakit.experimental.instrumentation).- Browser events go through the same-origin tunnel
web-ui/src/routes/cowbell/+server.ts, which only forwards envelopes addressed to our DSN. Keep the path free of words like "sentry" or "monitoring" that ad blockers match on. web-ui/src/lib/sentryScrub.tsstrips the user block, hostname and URL query strings from every event and breadcrumb. IP-derived location is removed on the Sentry side by the project's "Prevent Storing of IP Addresses" setting, not by the SDK.- Events are tagged
side: browser|server. Flow pages tagsource_pds/target_pds(hostnames only) throughweb-ui/src/lib/sentryContext.tsin a$effectthat clears them on leave. - Caught errors go through
reportError(error, op)inweb-ui/src/lib/sentryReport.ts, next to the existingconsole.error. It drops conditions the UI handles itself (2FA prompts, wrong passwords, bad invite codes or PLC tokens, rate limits, aborted requests) and tags the rest withop(e.g.migration.run). Uselevel: 'warning'for best-effort work the page recovers from. Never put handles, DIDs or emails inextra. - Source maps upload on
vite buildwhenSENTRY_AUTH_TOKENis available (gitignoredweb-ui/.env.sentry-build-plugin, mounted into the image build as a secret byjust release).
Testing #
- Unit – vitest, node environment. Package logic is tested in
packages/moover/lib, client modules inweb-ui/src. - mock-atmosphere – one process, five listeners: source PDS :31001, dest PDS :31002,
plc.directory :31003, slingshot :31004, PDS MOOver directory API :31005. Each PDS is also its
own OAuth authorization server (
src/roles/oauth.ts) that approves on the spot; DPoP proofs are required but never verified./_mock/resetseeds a scenario,/_mock/statesnapshots it. Its own node:test files run the package against it with a password session, which is the check that the package works outside a browser. - E2E –
web-ui/e2e, Playwright, Chromium, one worker (the mock state is shared). Specs sign in through the real@atproto/oauth-client-browseragainst the mock. The app runs on 127.0.0.1:5183 so it never attaches to a dev server you have open. External origins are routed to the mock ine2e/support/routes.ts; the two server-side fetches (directory lookup and describeServer for/moover/<pds>) are routed bye2e/support/ssr-fetch-rewrite.mjs, preloaded into the dev server. There is no test-only code in the app itself. - Pages are server-rendered, so use
gotoApp/gotoSignIn/signInWithOAuthfrome2e/support/fixtures.ts: typing into a form before hydration loses the input.
Deploy #
Images are built from Dockerfiles/ and pushed with the justfile (just release); production
composes are in ProductionComposes/. just test-build-ui builds the web ui image locally
without pushing. Every image builds from the repo root: Dockerfiles/web-ui.Dockerfile copies
web-ui plus packages/lexicons and packages/moover, so a new workspace package the ui imports
has to be added there too. The web ui is a Node server (@sveltejs/adapter-node, node build)
that reads PUBLIC_APP_URL, ORIGIN and PUBLIC_XRPC_BASE at start-up (documented in
web-ui/.env.example). Destination PDSs come
from the public com.pdsmoover.pds.listPds/searchPds directory endpoints on the
PUBLIC_XRPC_BASE API.