Skip to content

Consolidate AT Protocol access into one repo module#188

Merged
lukebennett88 merged 1 commit into
mainfrom
refactor/atproto-repo-adapter
Jun 15, 2026
Merged

Consolidate AT Protocol access into one repo module#188
lukebennett88 merged 1 commit into
mainfrom
refactor/atproto-repo-adapter

Conversation

@lukebennett88

Copy link
Copy Markdown
Owner

Problem

The AT Protocol handshake (resolve handle → resolve PDS → create session → read/write records) was re-implemented in all three apps/web/scripts/ files. sync-standard-site.ts had the good, Zod-validated version; delete-record.ts and list-records.ts had shallow untyped copies (as-cast JSON, no validation). The sync orchestration (executePlan) could only run against the live network, so it had no test coverage.

Solution

New domain-agnostic module apps/web/scripts/atproto.ts exposing a small AtprotoRepo interface with two adapters:

  • connectAtprotoRepo({ identifier, password }) — the HTTP adapter; performs the handshake internally and owns the listRecords pagination loop.
  • createInMemoryAtprotoRepo(...) — an in-memory adapter for tests that enforces the same record contract (validates writes through ExistingRecordSchema, rejects duplicate rkeys on create).

executePlan now takes the AtprotoRepo interface and is exported, so it is unit-tested against the in-memory adapter (create / update-and-merge / delete paths). delete-record.ts and list-records.ts now use the shared client and drop their untyped copies. The module carries no knowledge of site.standard.document, the publication URI, posts, or the manifest.

Verification

  • pnpm --filter @lukebennett/web test:standard-site — 25 tests pass (existing suite unchanged + new atproto.test.ts).
  • pnpm --filter @lukebennett/web check — prettier, biome, and tsc --noEmit clean.

Part of an architecture review pass; sibling PRs cover the manifest contract, Cloud Image preview, and renderer registry.

Extract the atproto handshake (resolve DID, resolve PDS, create session)
and generic XRPC helpers/schemas out of sync-standard-site.ts into a new
domain-agnostic scripts/atproto.ts. Expose an AtprotoRepo interface with
an HTTP adapter (connectAtprotoRepo) and an in-memory adapter
(createInMemoryAtprotoRepo) for tests.

sync-standard-site.ts now depends on the module: executePlan takes an
AtprotoRepo and is exported so it can be tested without the network.
delete-record.ts and list-records.ts drop their untyped copies and use
connectAtprotoRepo. Adds scripts/atproto.test.ts to the suite.
@netlify

netlify Bot commented Jun 15, 2026

Copy link
Copy Markdown

Deploy Preview for lukebennett ready!

Name Link
🔨 Latest commit a081415
🔍 Latest deploy log https://app.netlify.com/projects/lukebennett/deploys/6a2fa2c1d349c50009998c25
😎 Deploy Preview https://deploy-preview-188--lukebennett.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@lukebennett88 lukebennett88 merged commit d5999b8 into main Jun 15, 2026
5 checks passed
@lukebennett88 lukebennett88 deleted the refactor/atproto-repo-adapter branch June 15, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant