Skip to content

feat(pds): align lexicon validation with reference PDS#160

Merged
ascorbic merged 2 commits into
mainfrom
lexicon-validation-parity
May 6, 2026
Merged

feat(pds): align lexicon validation with reference PDS#160
ascorbic merged 2 commits into
mainfrom
lexicon-validation-parity

Conversation

@ascorbic
Copy link
Copy Markdown
Owner

@ascorbic ascorbic commented May 6, 2026

Summary

Brings cirrus's lexicon validation to parity with the reference PDS (bluesky-social/atproto), and closes a few correctness gaps along the way.

  • Honors the validate flag (true requires a known schema, false skips schema validation, undefined validates known schemas optimistically).
  • Returns validationStatus (\"valid\" | \"unknown\") on createRecord / putRecord / per-write in applyWrites.
  • Reconciles record \$type with collection (fills in if missing, rejects mismatches).
  • Validates rkeys against the schema's keySchema (e.g. app.bsky.feed.post requires a TID, app.bsky.actor.profile requires self); enforces generic isRecordKey shape unconditionally.
  • Rejects legacy {cid, mimeType} blob refs.
  • Broadens the bundled schema set with com.atproto.lexicon.schema, app.bsky.actor.status, app.bsky.notification.declaration, chat.bsky.actor.declaration.
  • Moves authoritative rkey allocation into the DO with a collision-retry loop, so worker-isolate clockid collisions (1/1024 per same-ms concurrent create) can't surface as 500s.
  • Translates client-supplied rkey collisions to 409 RecordAlreadyExists and intra-batch duplicates to 400 InvalidRequest (distinct from the 409).
  • Tightens 400 surface area: missing rkey on applyWrites#update/#delete, non-boolean validate flag, non-string rkey (incl. null), empty-string rkey.

Test plan

  • pnpm -F @getcirrus/pds test:unit — 273 tests pass
  • pnpm -F @getcirrus/pds test:cli — 84 tests pass
  • pnpm -F @getcirrus/pds build — clean
  • New regression coverage: validate-flag rejection, intra-batch dup, validate=true unknown collection, empty-rkey, RecordAlreadyExists 409, batch validationStatus echoing, validate=false rkey-shape enforcement, validate=false record round-trip, profile auto-rkey rejection
  • Manual smoke test against a deployed PDS via pnpm test:e2e (not run in CI)

Honor the `validate` flag, return `validationStatus`, validate rkeys
against schema `keySchema`, reject legacy blob refs, and broaden the
bundled schema set. Move authoritative rkey allocation into the DO
with a collision-retry loop so worker-isolate clockid collisions
can't surface as 500s. Translate client-supplied rkey collisions to
409 and intra-batch duplicates to 400.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 6, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
atproto-pds 790b1db May 06 2026, 09:11 AM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 6, 2026

Open in StackBlitz

npm i https://pkg.pr.new/create-pds@160
npm i https://pkg.pr.new/@getcirrus/oauth-provider@160
npm i https://pkg.pr.new/@getcirrus/pds@160

commit: 790b1db

Now that the validator enforces the schema's keySchema (e.g. tidString
for app.bsky.feed.post), uniqueRkey() must return a valid TID.
@ascorbic ascorbic merged commit a492bf7 into main May 6, 2026
5 checks passed
@ascorbic ascorbic deleted the lexicon-validation-parity branch May 6, 2026 18:29
@mixie-bot mixie-bot Bot mentioned this pull request May 6, 2026
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