Consolidate AT Protocol access into one repo module#188
Merged
Conversation
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.
✅ Deploy Preview for lukebennett ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.tshad the good, Zod-validated version;delete-record.tsandlist-records.tshad 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.tsexposing a smallAtprotoRepointerface with two adapters:connectAtprotoRepo({ identifier, password })— the HTTP adapter; performs the handshake internally and owns thelistRecordspagination loop.createInMemoryAtprotoRepo(...)— an in-memory adapter for tests that enforces the same record contract (validates writes throughExistingRecordSchema, rejects duplicate rkeys on create).executePlannow takes theAtprotoRepointerface and is exported, so it is unit-tested against the in-memory adapter (create / update-and-merge / delete paths).delete-record.tsandlist-records.tsnow use the shared client and drop their untyped copies. The module carries no knowledge ofsite.standard.document, the publication URI, posts, or the manifest.Verification
pnpm --filter @lukebennett/web test:standard-site— 25 tests pass (existing suite unchanged + newatproto.test.ts).pnpm --filter @lukebennett/web check— prettier, biome, andtsc --noEmitclean.Part of an architecture review pass; sibling PRs cover the manifest contract, Cloud Image preview, and renderer registry.